Skip to content

Commit 45b2f43

Browse files
committed
Merge branch 'registration-dev'
2 parents 7b316c7 + ca9af48 commit 45b2f43

File tree

13 files changed

+479
-58
lines changed

13 files changed

+479
-58
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ index-servers=pypi
161161
### Naming & synthax convention
162162
Here's the naming convention for this project:
163163
- ` `: lowerCamelCase.
164-
- `type PrivateVariable`: public member of a class
164+
- `type PublicVariable`: public member of a class
165165
- `type m_PrivateVariable`: Hungarian notation with UpperCamelCase for private class members.
166166
- `static type s_StaticVariable`: Hungarian notation with UpperCamelCase for static members of class.
167167
- `APP_SPEC`: Constants with SNAKE_UPPER_CASE.

deps/eigen

Submodule eigen updated from 2265242 to 34967b0

src/diffCheck.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ const diffCheck::Log LOG = diffCheck::Log();
1010
#include "diffCheck/geometry/DFPointCloud.hh"
1111
#include "diffCheck/geometry/DFMesh.hh"
1212
#include "diffCheck/IOManager.hh"
13-
#include "diffCheck/visualizer.hh"
13+
#include "diffCheck/visualizer.hh"
14+
#include "diffCheck/transformation/DFTransformation.hh"
15+
#include "diffCheck/registrations/DFGlobalRegistrations.hh"

src/diffCheck/geometry/DFMesh.cc

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "diffCheck/geometry/DFMesh.hh"
2-
32
#include "diffCheck/IOManager.hh"
43

54

@@ -18,33 +17,6 @@ namespace diffCheck::geometry
1817
{
1918
this->Faces[i] = O3DTriangleMesh->triangles_[i];
2019
}
21-
22-
// if (O3DTriangleMesh->HasVertexNormals())
23-
// {
24-
// this->NormalsVertex.resize(O3DTriangleMesh->vertex_normals_.size());
25-
// for (size_t i = 0; i < O3DTriangleMesh->vertex_normals_.size(); i++)
26-
// {
27-
// this->NormalsVertex[i] = O3DTriangleMesh->vertex_normals_[i];
28-
// }
29-
// }
30-
31-
// if (O3DTriangleMesh->HasTriangleNormals())
32-
// {
33-
// this->NormalsFace.resize(O3DTriangleMesh->triangle_normals_.size());
34-
// for (size_t i = 0; i < O3DTriangleMesh->triangle_normals_.size(); i++)
35-
// {
36-
// this->NormalsFace[i] = O3DTriangleMesh->triangle_normals_[i];
37-
// }
38-
// }
39-
40-
// if (O3DTriangleMesh->HasVertexColors())
41-
// {
42-
// this->ColorsVertex.resize(O3DTriangleMesh->vertex_colors_.size());
43-
// for (size_t i = 0; i < O3DTriangleMesh->vertex_colors_.size(); i++)
44-
// {
45-
// this->ColorsVertex[i] = O3DTriangleMesh->vertex_colors_[i];
46-
// }
47-
// }
4820
}
4921

5022
std::shared_ptr<open3d::geometry::TriangleMesh> DFMesh::Cvt2O3DTriangleMesh()
@@ -83,6 +55,13 @@ namespace diffCheck::geometry
8355
return O3DTriangleMesh;
8456
}
8557

58+
void DFMesh::ApplyTransformation(const diffCheck::transformation::DFTransformation &transformation)
59+
{
60+
auto O3DTriangleMesh = this->Cvt2O3DTriangleMesh();
61+
O3DTriangleMesh->Transform(transformation.TransformationMatrix);
62+
this->Cvt2DFMesh(O3DTriangleMesh);
63+
}
64+
8665
void DFMesh::LoadFromPLY(const std::string &path)
8766
{
8867
std::shared_ptr<diffCheck::geometry::DFMesh> tempMesh_ptr = diffCheck::io::ReadPLYMeshFromFile(path);

src/diffCheck/geometry/DFMesh.hh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <Eigen/Core>
44
#include <open3d/Open3D.h>
55

6+
#include <diffCheck/transformation/DFTransformation.hh>
7+
68
namespace diffCheck::geometry
79
{
810
class DFMesh
@@ -11,8 +13,7 @@ namespace diffCheck::geometry
1113
DFMesh() = default;
1214
~DFMesh() = default;
1315

14-
///< Convertes
15-
public:
16+
public: ///< Convertes
1617
/**
1718
* @brief Convert a open3d triangle mesh to our datatype
1819
*
@@ -27,24 +28,29 @@ namespace diffCheck::geometry
2728
*/
2829
std::shared_ptr<open3d::geometry::TriangleMesh> Cvt2O3DTriangleMesh();
2930

30-
///< I/O loader
31-
public:
31+
public: ///< Transformers
32+
/**
33+
* @brief Apply a transformation to the mesh
34+
*
35+
* @param transformation the transformation to apply
36+
*/
37+
void ApplyTransformation(const diffCheck::transformation::DFTransformation &transformation);
38+
39+
public: ///< I/O loader
3240
/**
3341
* @brief Read a mesh from a file
3442
*
3543
* @param filename the path to the file with the extension
3644
*/
3745
void LoadFromPLY(const std::string &path);
3846

39-
///< Getters
40-
public:
47+
public: ///< Getters
4148
/// @brief Number of vertices in the mesh
4249
int GetNumVertices() const { return this->Vertices.size(); }
4350
/// @brief Number of faces in the mesh
4451
int GetNumFaces() const { return this->Faces.size(); }
4552

46-
///< Basic mesh data
47-
public:
53+
public: ///< Basic mesh data
4854
/// @brief Eigen vector of 3D vertices
4955
std::vector<Eigen::Vector3d> Vertices;
5056
/// @brief Eigen vector of faces

src/diffCheck/geometry/DFPointCloud.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,38 @@ namespace diffCheck::geometry
3333
return O3DPointCloud;
3434
}
3535

36+
std::vector<double> DFPointCloud::ComputeP2PDistance(std::shared_ptr<geometry::DFPointCloud> target)
37+
{
38+
std::vector<double> errors;
39+
auto O3DSourcePointCloud = this->Cvt2O3DPointCloud();
40+
auto O3DTargetPointCloud = target->Cvt2O3DPointCloud();
41+
42+
std::vector<double> distances;
43+
44+
distances = O3DSourcePointCloud->ComputePointCloudDistance(*O3DTargetPointCloud);
45+
return distances;
46+
}
47+
48+
std::vector<Eigen::Vector3d> DFPointCloud::ComputeBoundingBox()
49+
{
50+
auto O3DPointCloud = this->Cvt2O3DPointCloud();
51+
auto boundingBox = O3DPointCloud->GetAxisAlignedBoundingBox();
52+
std::vector<Eigen::Vector3d> extremePoints;
53+
extremePoints.push_back(boundingBox.GetMinBound());
54+
extremePoints.push_back(boundingBox.GetMaxBound());
55+
this->BoundingBox = extremePoints;
56+
return extremePoints;
57+
}
58+
void DFPointCloud::ApplyTransformation(const diffCheck::transformation::DFTransformation &transformation)
59+
{
60+
auto O3DPointCloud = this->Cvt2O3DPointCloud();
61+
O3DPointCloud->Transform(transformation.TransformationMatrix);
62+
this->Points.clear();
63+
this->Colors.clear();
64+
this->Normals.clear();
65+
this->Cvt2DFPointCloud(O3DPointCloud);
66+
}
67+
3668
void DFPointCloud::LoadFromPLY(const std::string &path)
3769
{
3870
auto cloud = diffCheck::io::ReadPLYPointCloud(path);

src/diffCheck/geometry/DFPointCloud.hh

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <Eigen/Core>
44
#include <open3d/Open3D.h>
55

6+
#include <diffCheck/transformation/DFTransformation.hh>
7+
68

79
namespace diffCheck::geometry
810
{
@@ -12,8 +14,8 @@ namespace diffCheck::geometry
1214
DFPointCloud() = default;
1315
~DFPointCloud() = default;
1416

15-
///< Converters from other point cloud datatypes libraries to our format
16-
public:
17+
18+
public: ///< Converters from other point cloud datatypes libraries to our format
1719
/**
1820
* @brief Converter from open3d point cloud to our datatype
1921
*
@@ -28,31 +30,59 @@ namespace diffCheck::geometry
2830
*/
2931
std::shared_ptr<open3d::geometry::PointCloud> Cvt2O3DPointCloud();
3032

31-
///< I/O loader
32-
public:
33+
public: ///< Utilities
34+
/**
35+
* @brief Compute the "point to point" distance between this and another point clouds.
36+
*
37+
* For every point in the source point cloud, it looks in the KDTree of the target point cloud and finds the closest point.
38+
* It returns a vector of distances, one for each point in the source point cloud.
39+
*
40+
* @param target The target diffCheck point cloud
41+
* @return std::vector<double> A vector of distances, one for each point in the source point cloud.
42+
*
43+
* @see https://github.com/isl-org/Open3D/blob/main/cpp/open3d/geometry/PointCloud.cpp
44+
*/
45+
std::vector<double> ComputeP2PDistance(std::shared_ptr<geometry::DFPointCloud> target);
46+
47+
/**
48+
* @brief Compute the bounding box of the point cloud and stores it as member of the DFPointCloud object
49+
*
50+
* @return std::vector<Eigen::Vector3d> A vector of two Eigen::Vector3d, with the first one being the minimum point and the second one the maximum point of the bounding box.
51+
*/
52+
std::vector<Eigen::Vector3d> ComputeBoundingBox();
53+
54+
public: ///< Transformers
55+
/**
56+
* @brief Apply a transformation to the point cloud
57+
*
58+
* @param transformation the transformation to apply
59+
*/
60+
void ApplyTransformation(const diffCheck::transformation::DFTransformation &transformation);
61+
62+
public: ///< I/O loader
3363
/**
3464
* @brief Read a point cloud from a file
3565
*
3666
* @param filename the path to the file with the extension
3767
*/
3868
void LoadFromPLY(const std::string &path);
3969

40-
///< Getters
41-
public:
70+
public: ///< Getters
4271
/// @brief Number of points in the point cloud
4372
int GetNumPoints() const { return this->Points.size(); }
4473
/// @brief Number of colors in the point cloud
4574
int GetNumColors() const { return this->Colors.size(); }
4675
/// @brief Number of normals in the point cloud
4776
int GetNumNormals() const { return this->Normals.size(); }
4877

49-
///< Basic point cloud data
50-
public:
78+
public: ///< Basic point cloud data
5179
/// @brief Eigen vector of 3D points
5280
std::vector<Eigen::Vector3d> Points;
5381
/// @brief Eigen vector of 3D colors
5482
std::vector<Eigen::Vector3d> Colors;
5583
/// @brief Eigen vector of 3D normals
5684
std::vector<Eigen::Vector3d> Normals;
85+
/// @brief Eigen vector of two 3D vectors forming the bounnding box.
86+
std::vector<Eigen::Vector3d> BoundingBox;
5787
};
5888
} // namespace diffCheck::geometry

0 commit comments

Comments
 (0)