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
118118
119119 std::vector<Eigen::Vector3d> DFPointCloud::GetAxixAlignedBoundingBox ()
120120 {
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
121137 auto O3DPointCloud = this ->Cvt2O3DPointCloud ();
122138 auto boundingBox = O3DPointCloud->GetAxisAlignedBoundingBox ();
123- std::vector<Eigen::Vector3d> extremePoints;
124- extremePoints. push_back ( boundingBox.GetMinBound ());
139+
140+ boundingBox.GetMinBound ());
125141 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+
126148 return extremePoints;
127149 }
128150
Original file line number Diff line number Diff line change @@ -139,10 +139,10 @@ TEST_F(DFPointCloudTestFixture, AddPoints) {
139139 EXPECT_EQ (dfPointCloud.GetNumPoints (), 7379 * 2 );
140140}
141141
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
146146
147147TEST_F (DFPointCloudTestFixture, ComputeOBB) {
148148 std::vector<Eigen::Vector3d> obb = dfPointCloud.GetTightBoundingBox ();
You can’t perform that action at this time.
0 commit comments