File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -231,6 +231,24 @@ namespace diffCheck::geometry
231231 this ->Normals .push_back (normal);
232232 }
233233
234+ void DFPointCloud::Crop (const std::vector<Eigen::Vector3d> &corners)
235+ {
236+ if (corners.size () != 8 )
237+ throw std::invalid_argument (" The corners vector must contain exactly 8 points." );
238+ open3d::geometry::OrientedBoundingBox obb = open3d::geometry::OrientedBoundingBox::CreateFromPoints (corners);
239+ auto O3DPointCloud = this ->Cvt2O3DPointCloud ();
240+ auto O3DPointCloudCropped = O3DPointCloud->Crop (obb);
241+ this ->Points .clear ();
242+ for (auto &point : O3DPointCloudCropped->points_ )
243+ this ->Points .push_back (point);
244+ this ->Colors .clear ();
245+ for (auto &color : O3DPointCloudCropped->colors_ )
246+ this ->Colors .push_back (color);
247+ this ->Normals .clear ();
248+ for (auto &normal : O3DPointCloudCropped->normals_ )
249+ this ->Normals .push_back (normal);
250+ }
251+
234252 DFPointCloud DFPointCloud::Duplicate () const
235253 {
236254 return DFPointCloud (this ->Points , this ->Colors , this ->Normals );
Original file line number Diff line number Diff line change @@ -97,6 +97,12 @@ namespace diffCheck::geometry
9797 */
9898 void Crop (const Eigen::Vector3d &minBound, const Eigen::Vector3d &maxBound);
9999
100+ /* *
101+ * @brief Crop the point cloud to a bounding box defined by the 8 corners of the box
102+ * @param corners the 8 corners of the bounding box as a vector of Eigen::Vector3d
103+ */
104+ void Crop (const std::vector<Eigen::Vector3d> &corners);
105+
100106 /* *
101107 * @brief Get the duplicate of the point cloud. This is mainly used in the python bindings
102108 *
Original file line number Diff line number Diff line change @@ -61,9 +61,16 @@ PYBIND11_MODULE(diffcheck_bindings, m) {
6161 .def (" remove_statistical_outliers" , &diffCheck::geometry::DFPointCloud::RemoveStatisticalOutliers,
6262 py::arg (" nb_neighbors" ), py::arg (" std_ratio" ))
6363
64- .def (" crop" , &diffCheck::geometry::DFPointCloud::Crop,
64+ .def (" crop" ,
65+ (void (diffCheck::geometry::DFPointCloud::*)(const Eigen::Vector3d&, const Eigen::Vector3d&))
66+ &diffCheck::geometry::DFPointCloud::Crop,
6567 py::arg (" min_bound" ), py::arg (" max_bound" ))
6668
69+ .def (" crop" ,
70+ (void (diffCheck::geometry::DFPointCloud::*)(const std::vector<Eigen::Vector3d>&))
71+ &diffCheck::geometry::DFPointCloud::Crop,
72+ py::arg (" corners" ))
73+
6774 .def (" duplicate" , &diffCheck::geometry::DFPointCloud::Duplicate)
6875
6976 .def (" load_from_PLY" , &diffCheck::geometry::DFPointCloud::LoadFromPLY)
You can’t perform that action at this time.
0 commit comments