Skip to content

Commit 3de7937

Browse files
committed
minor corrections
minor test_gp3 test sample pcd correction minor correction minor minor
1 parent 12d02bb commit 3de7937

File tree

3 files changed

+51
-79
lines changed

3 files changed

+51
-79
lines changed

surface/include/pcl/surface/gp3.h

+21-26
Original file line numberDiff line numberDiff line change
@@ -523,29 +523,6 @@ namespace pcl
523523
* gp.setInputCloud(cloud_with_normals)
524524
* ...
525525
* pcl::PolygonMesh pm;
526-
* gp3.reconstruct(pm);
527-
* calculatePolygonArea(cloud_with_normals, pm.vertices);
528-
* gp.reconstruct(pm);
529-
* float functArea=computeTriangleMeshArea(cloud_with_normals, pm.polygons);
530-
* \ingroup
531-
* common
532-
*/
533-
template <typename PointT>
534-
inline float
535-
computeTriangleMeshArea(const shared_ptr<pcl::PointCloud<PointT>>& cloud,
536-
std::vector<pcl::Vertices>& triangleMesh);
537-
538-
/** \brief Calculate the area of a triangle mesh
539-
* \param[in] cloud the point cloud to which the mesh is applied
540-
* \param[in] indices of the point cloud
541-
* \param[in] triangleMesh a triangle mesh
542-
* \return the mesh area
543-
* \note example of use:
544-
* pcl::GreedyProjectionTriangulation<PointN> gp;
545-
* ...
546-
* gp.setInputCloud(cloud_with_normals)
547-
* ...
548-
* pcl::PolygonMesh pm;
549526
* gp.reconstruct(pm);
550527
* float functArea=computeTriangleMeshArea(cloud_with_normals, pm.polygons);
551528
* \ingroup
@@ -554,9 +531,27 @@ namespace pcl
554531

555532
template <typename PointT>
556533
inline float
557-
computeTriangleMeshArea(const shared_ptr<pcl::PointCloud<PointT>>& cloud,
558-
const shared_ptr<Indices>& indices,
559-
std::vector<pcl::Vertices>& triangleMesh);
534+
computeTriangleMeshArea(const shared_ptr<pcl::PointCloud<PointT>>& cloud,
535+
std::vector<pcl::Vertices>& triangleMesh)
536+
{
537+
double area = 0;
538+
pcl::PointCloud<PointT>& cl = (*cloud);
539+
for (auto& triangle_ : triangleMesh) {
540+
if (triangle_.vertices.size() == 3) {
541+
const Eigen::Matrix<double, 3, 1> P(
542+
cl[triangle_.vertices[0]].x - (*cloud)[triangle_.vertices[2]].x,
543+
cl[triangle_.vertices[0]].y - (*cloud)[triangle_.vertices[2]].y,
544+
cl[triangle_.vertices[0]].z - (*cloud)[triangle_.vertices[2]].z);
545+
const Eigen::Matrix<double, 3, 1> Q(
546+
cl[triangle_.vertices[1]].x - (*cloud)[triangle_.vertices[2]].x,
547+
cl[triangle_.vertices[1]].y - (*cloud)[triangle_.vertices[2]].y,
548+
cl[triangle_.vertices[1]].z - (*cloud)[triangle_.vertices[2]].z);
549+
area += 0.5 * P.cross(Q).norm();
550+
}
551+
}
552+
return area;
553+
}
554+
560555

561556
} // namespace pcl
562557

surface/include/pcl/surface/impl/gp3.hpp

-53
Original file line numberDiff line numberDiff line change
@@ -1667,59 +1667,6 @@ pcl::GreedyProjectionTriangulation<PointInT>::getTriangleList (const pcl::Polygo
16671667
#define PCL_INSTANTIATE_GreedyProjectionTriangulation(T) \
16681668
template class PCL_EXPORTS pcl::GreedyProjectionTriangulation<T>;
16691669

1670-
template <typename PointT>
1671-
inline float
1672-
pcl::computeTriangleMeshArea(const shared_ptr<pcl::PointCloud<PointT>>& cloud,
1673-
std::vector<pcl::Vertices>& triangleMesh)
1674-
{
1675-
const pcl::PointCloud<PointT>::ConstPtr input_ = cloud;
1676-
double area = 0;
1677-
for (auto& triangle_ : triangleMesh) {
1678-
if (triangle_.vertices.size() == 3) {
1679-
const Eigen::Matrix<double, 3, 1> P(
1680-
(*input_)[triangle_.vertices[0]].x - (*input_)[triangle_.vertices[2]].x,
1681-
(*input_)[triangle_.vertices[0]].y - (*input_)[triangle_.vertices[2]].y,
1682-
(*input_)[triangle_.vertices[0]].z - (*input_)[triangle_.vertices[2]].z);
1683-
const Eigen::Matrix<double, 3, 1> Q(
1684-
(*input_)[triangle_.vertices[1]].x - (*input_)[triangle_.vertices[2]].x,
1685-
(*input_)[triangle_.vertices[1]].y - (*input_)[triangle_.vertices[2]].y,
1686-
(*input_)[triangle_.vertices[1]].z - (*input_)[triangle_.vertices[2]].z);
1687-
area += 0.5 * P.cross(Q).norm();
1688-
}
1689-
}
1690-
return area;
1691-
}
1692-
1693-
template <typename PointT>
1694-
inline float
1695-
pcl::computeTriangleMeshArea(const shared_ptr<pcl::PointCloud<PointT>>& cloud,
1696-
const shared_ptr<Indices>& indices,
1697-
std::vector<pcl::Vertices>& triangleMesh)
1698-
{
1699-
const pcl::PointCloud<PointT>::ConstPtr input_ = cloud;
1700-
double area = 0;
1701-
for (auto& triangle_ : triangleMesh) {
1702-
if (triangle_.vertices.size() == 3) {
1703-
const Eigen::Matrix<double, 3, 1> P(
1704-
(*input_)[(*indices_)[triangle_.vertices[0]]].x -
1705-
(*input_)[(*indices_)[triangle_.vertices[2]]].x,
1706-
(*input_)[(*indices_)[triangle_.vertices[0]]].y -
1707-
(*input_)[(*indices_)[triangle_.vertices[2]]].y,
1708-
(*input_)[(*indices_)[triangle_.vertices[0]]].z -
1709-
(*input_)[(*indices_)[triangle_.vertices[2]]].z);
1710-
const Eigen::Matrix<double, 3, 1> Q(
1711-
(*input_)[(*indices_)[triangle_.vertices[1]]].x -
1712-
(*input_)[(*indices_)[triangle_.vertices[2]]].x,
1713-
(*input_)[(*indices_)[triangle_.vertices[1]]].y -
1714-
(*input_)[(*indices_)[triangle_.vertices[2]]].y,
1715-
(*input_)[(*indices_)[triangle_.vertices[1]]].z -
1716-
(*input_)[(*indices_)[triangle_.vertices[2]]].z);
1717-
area += 0.5 * P.cross(Q).norm();
1718-
}
1719-
}
1720-
return area;
1721-
}
1722-
17231670
#endif // PCL_SURFACE_IMPL_GP3_H_
17241671

17251672

test/surface/test_gp3.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,36 @@ TEST (PCL, UpdateMesh_With_TextureMapping)
238238
}
239239
}
240240

241+
242+
243+
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
244+
TEST(PCL, computeTriangleMeshArea)
245+
{
246+
// Init objects
247+
PolygonMesh triangles;
248+
GreedyProjectionTriangulation<PointNormal> gp3;
249+
250+
// Set parameters
251+
gp3.setInputCloud(cloud_with_normals);
252+
gp3.setSearchMethod(tree2);
253+
gp3.setSearchRadius(0.025);
254+
gp3.setMu(2.5);
255+
gp3.setMaximumNearestNeighbors(100);
256+
gp3.setMaximumSurfaceAngle(M_PI / 4); // 45 degrees
257+
gp3.setMinimumAngle(M_PI / 18); // 10 degrees
258+
gp3.setMaximumAngle(2 * M_PI / 3); // 120 degrees
259+
gp3.setNormalConsistency(false);
260+
261+
// Reconstruct
262+
gp3.reconstruct(triangles);
263+
264+
float functArea = pcl::computeTriangleMeshArea(cloud_with_normals, triangles.polygons);
265+
EXPECT_NEAR((functArea), 0.0210945, 0.001);
266+
267+
268+
}
269+
270+
241271
/* ---[ */
242272
int
243273
main (int argc, char** argv)

0 commit comments

Comments
 (0)