Skip to content

Commit b75aa99

Browse files
WIP-ADD: GetCenterPoint() to point cloud objects
1 parent a1ce0f3 commit b75aa99

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ target_include_directories(${SHARED_LIB_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
9393
# CGAL (header-only) ------------------------------------------------------
9494
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/deps/cgal/include)
9595

96+
# Cilantro (header-only) --------------------------------------------------
97+
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/deps/cilantro/include)
9698
# loguru (header-only) ----------------------------------------------------
9799
download_submodule_project(loguru)
98100
add_subdirectory(deps/loguru)

src/diffCheck/geometry/DFPointCloud.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,15 @@ namespace diffCheck::geometry
125125
this->Colors = cloud->Colors;
126126
this->Normals = cloud->Normals;
127127
}
128+
129+
Eigen::Vector3d DFPointCloud::GetCenterPoint()
130+
{
131+
if (this->Points.size() == 0)
132+
throw std::invalid_argument("The point cloud is empty.");
133+
Eigen::Vector3d center = Eigen::Vector3d::Zero();
134+
for (auto &point : this->Points)
135+
center += point;
136+
center /= this->Points.size();
137+
return center;
138+
}
128139
}

src/diffCheck/geometry/DFPointCloud.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ namespace diffCheck::geometry
103103
int GetNumColors() const { return this->Colors.size(); }
104104
/// @brief Number of normals in the point cloud
105105
int GetNumNormals() const { return this->Normals.size(); }
106+
/// @brief Get the center point of the point cloud
107+
Eigen::Vector3d GetCenterPoint();
106108

107109
/// @brief Check if the cloud has points
108110
bool HasPoints() const { return this->Points.size() > 0; }

0 commit comments

Comments
 (0)