File tree Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -118,11 +118,33 @@ namespace diffCheck::geometry
118
118
119
119
std::vector<Eigen::Vector3d> DFPointCloud::GetAxixAlignedBoundingBox ()
120
120
{
121
+ if (this ->Points .empty ()) {
122
+ return {Eigen::Vector3d::Zero (), Eigen::Vector3d::Zero ()};
123
+ }
124
+
125
+ Eigen::Vector3d minBound, maxBound;
126
+
127
+ #ifdef __APPLE__
128
+ // Compute min and max bounds directly from points
129
+ minBound = this ->Points .front ();
130
+ maxBound = this ->Points .front ();
131
+
132
+ for (const auto & point : this ->Points ) {
133
+ minBound = minBound.cwiseMin (point);
134
+ maxBound = maxBound.cwiseMax (point);
135
+ }
136
+ #else
121
137
auto O3DPointCloud = this ->Cvt2O3DPointCloud ();
122
138
auto boundingBox = O3DPointCloud->GetAxisAlignedBoundingBox ();
123
- std::vector<Eigen::Vector3d> extremePoints;
124
- extremePoints. push_back ( boundingBox.GetMinBound ());
139
+
140
+ boundingBox.GetMinBound ());
125
141
extremePoints.push_back (boundingBox.GetMaxBound ());
142
+
143
+ #endif
144
+ std::vector<Eigen::Vector3d> extremePoints;
145
+ extremePoints.push_back (minBound);
146
+ extremePoints.push_back (maxBound);
147
+
126
148
return extremePoints;
127
149
}
128
150
Original file line number Diff line number Diff line change @@ -139,10 +139,10 @@ TEST_F(DFPointCloudTestFixture, AddPoints) {
139
139
EXPECT_EQ (dfPointCloud.GetNumPoints (), 7379 * 2 );
140
140
}
141
141
142
- // TEST_F(DFPointCloudTestFixture, ComputeAABB) {
143
- // std::vector<Eigen::Vector3d> bbox = dfPointCloud.GetAxixAlignedBoundingBox();
144
- // EXPECT_EQ(bbox.size(), 2);
145
- // } // # Segfault
142
+ TEST_F (DFPointCloudTestFixture, ComputeAABB) {
143
+ std::vector<Eigen::Vector3d> bbox = dfPointCloud.GetAxixAlignedBoundingBox ();
144
+ EXPECT_EQ (bbox.size (), 2 );
145
+ } // # Segfault
146
146
147
147
TEST_F (DFPointCloudTestFixture, ComputeOBB) {
148
148
std::vector<Eigen::Vector3d> obb = dfPointCloud.GetTightBoundingBox ();
You can’t perform that action at this time.
0 commit comments