4
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
5
* Copyright (c) 2009, Willow Garage, Inc.
6
6
* Copyright (c) 2012-, Open Perception, Inc.
7
+ * Copyright (c) 2015, Google, Inc.
7
8
*
8
9
* All rights reserved.
9
10
*
@@ -70,6 +71,10 @@ pcl::CropBox<pcl::PCLPointCloud2>::applyFilter (PCLPointCloud2 &output)
70
71
// PointXYZ local_pt;
71
72
Eigen::Vector3f local_pt (Eigen::Vector3f::Zero ());
72
73
74
+ bool transform_matrix_is_identity = transform_.matrix ().isIdentity ();
75
+ bool translation_is_zero = (translation_ != Eigen::Vector3f::Zero ());
76
+ bool inverse_transform_matrix_is_identity = inverse_transform.matrix ().isIdentity ();
77
+
73
78
for (size_t index = 0 ; index < indices_->size (); ++index )
74
79
{
75
80
// Get local point
@@ -84,18 +89,18 @@ pcl::CropBox<pcl::PCLPointCloud2>::applyFilter (PCLPointCloud2 &output)
84
89
continue ;
85
90
86
91
// Transform point to world space
87
- if (!(transform_. matrix (). isIdentity ()) )
92
+ if (!transform_matrix_is_identity )
88
93
local_pt = transform_ * local_pt;
89
94
90
- if (translation_ != Eigen::Vector3f::Zero () )
95
+ if (translation_is_zero )
91
96
{
92
97
local_pt.x () = local_pt.x () - translation_ (0 );
93
98
local_pt.y () = local_pt.y () - translation_ (1 );
94
99
local_pt.z () = local_pt.z () - translation_ (2 );
95
100
}
96
101
97
102
// Transform point to local space of crop box
98
- if (!(inverse_transform. matrix (). isIdentity ()) )
103
+ if (!inverse_transform_matrix_is_identity )
99
104
local_pt = inverse_transform * local_pt;
100
105
101
106
// If outside the cropbox
@@ -156,6 +161,10 @@ pcl::CropBox<pcl::PCLPointCloud2>::applyFilter (std::vector<int> &indices)
156
161
// PointXYZ local_pt;
157
162
Eigen::Vector3f local_pt (Eigen::Vector3f::Zero ());
158
163
164
+ bool transform_matrix_is_identity = transform_.matrix ().isIdentity ();
165
+ bool translation_is_zero = (translation_ != Eigen::Vector3f::Zero ());
166
+ bool inverse_transform_matrix_is_identity = inverse_transform.matrix ().isIdentity ();
167
+
159
168
for (size_t index = 0 ; index < indices_->size (); index ++)
160
169
{
161
170
// Get local point
@@ -164,18 +173,18 @@ pcl::CropBox<pcl::PCLPointCloud2>::applyFilter (std::vector<int> &indices)
164
173
memcpy (&local_pt, &input_->data [offset], sizeof (float )*3 );
165
174
166
175
// Transform point to world space
167
- if (!(transform_. matrix (). isIdentity ()) )
176
+ if (!transform_matrix_is_identity )
168
177
local_pt = transform_ * local_pt;
169
178
170
- if (translation_ != Eigen::Vector3f::Zero () )
179
+ if (translation_is_zero )
171
180
{
172
181
local_pt.x () -= translation_ (0 );
173
182
local_pt.y () -= translation_ (1 );
174
183
local_pt.z () -= translation_ (2 );
175
184
}
176
185
177
186
// Transform point to local space of crop box
178
- if (!(inverse_transform. matrix (). isIdentity () ))
187
+ if (!(inverse_transform_matrix_is_identity ))
179
188
local_pt = inverse_transform * local_pt;
180
189
181
190
// If outside the cropbox
0 commit comments