Skip to content

Commit

Permalink
WIP-ADD: working binding with renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
9and3 committed May 1, 2024
1 parent 3342533 commit ed523d2
Show file tree
Hide file tree
Showing 26 changed files with 807 additions and 4,754 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ target_include_directories(${APP_NAME_EXE}
# pybind11
#--------------------------------------------------------------------------
if (BUILD_PYTHON_MODULE)
set(PYBINDMODULE_NAME diffCheckBindings)
set(PYBINDMODULE_NAME diffcheck_bindings)
set(PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck)
set(TARGET_DLL_PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck/dlls)

Expand Down
Binary file added assets/icon_pool/code_xml_export.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon_pool/code_xml_export.xcf
Binary file not shown.
Binary file added assets/icon_pool/code_xml_export2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon_pool/code_xml_export2.xcf
Binary file not shown.
Binary file added assets/icon_pool/df_test_import.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon_pool/df_test_import.xcf
Binary file not shown.
2 changes: 2 additions & 0 deletions cmake/__noenv__config.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REM configure the project
cmake -S . -B build
3 changes: 0 additions & 3 deletions cmake/activate_conda.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@echo off
setlocal

:: ########################################################################
:: check if conda is available >
:: check that diff_check environment is available >
Expand Down
3 changes: 0 additions & 3 deletions cmake/build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
@echo off
setlocal

REM build the project in Release mode
cmake --build build --config Release
3 changes: 0 additions & 3 deletions cmake/clean_config.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@echo off
setlocal

REM activate the conda diff_check environment otherwise the python wrap won't work
call cmake/activate_conda.bat

Expand Down
5 changes: 1 addition & 4 deletions cmake/config.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@echo off
setlocal

REM activate the conda diff_check environment otherwise the python wrap won't work
call cmake/activate_conda.bat

REM configure the project
cmake -S . -B build -A x64
cmake -S . -B build
18 changes: 17 additions & 1 deletion src/diffCheck/geometry/DFMesh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,23 @@ namespace diffCheck::geometry
class DFMesh
{
public:
DFMesh() = default;
DFMesh() {}
DFMesh(std::vector<Eigen::Vector3d> vertices,
std::vector<Eigen::Vector3i> faces,
std::vector<Eigen::Vector3d> normalsVertex,
std::vector<Eigen::Vector3d> normalsFace,
std::vector<Eigen::Vector3d> colorsVertex)
:
Vertices(vertices),
Faces(faces),
NormalsVertex(normalsVertex),
NormalsFace(normalsFace),
ColorsVertex(colorsVertex)
{
this->ColorsFace.resize(faces.size());
this->ColorsFace.assign(faces.size(), Eigen::Vector3d(0, 0, 0));
}

~DFMesh() = default;

public: ///< Convertes
Expand Down
1 change: 0 additions & 1 deletion src/diffCheck/geometry/DFPointCloud.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ namespace diffCheck::geometry
std::vector<Eigen::Vector3d> extremePoints;
extremePoints.push_back(boundingBox.GetMinBound());
extremePoints.push_back(boundingBox.GetMaxBound());
this->BoundingBox = extremePoints;
return extremePoints;
}
void DFPointCloud::ApplyTransformation(const diffCheck::transformation::DFTransformation &transformation)
Expand Down
10 changes: 5 additions & 5 deletions src/diffCheck/geometry/DFPointCloud.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ namespace diffCheck::geometry
class DFPointCloud
{
public:
DFPointCloud() = default;
DFPointCloud() {}
DFPointCloud(std::vector<Eigen::Vector3d> points,
std::vector<Eigen::Vector3d> colors,
std::vector<Eigen::Vector3d> normals)
: Points(points), Colors(colors), Normals(normals) {}
: Points(points), Colors(colors), Normals(normals)
{}

~DFPointCloud() = default;

Expand Down Expand Up @@ -52,7 +53,8 @@ namespace diffCheck::geometry
/**
* @brief Compute the bounding box of the point cloud and stores it as member of the DFPointCloud object
*
* @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.
* @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.
*/
std::vector<Eigen::Vector3d> ComputeBoundingBox();

Expand Down Expand Up @@ -87,7 +89,5 @@ namespace diffCheck::geometry
std::vector<Eigen::Vector3d> Colors;
/// @brief Eigen vector of 3D normals
std::vector<Eigen::Vector3d> Normals;
/// @brief Eigen vector of two 3D vectors forming the bounding box.
std::vector<Eigen::Vector3d> BoundingBox;
};
} // namespace diffCheck::geometry
7 changes: 4 additions & 3 deletions src/diffCheckApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ int main()

diffCheck::geometry::DFPointCloud dfPointCloud(points, colors, normals);

DIFFCHECK_INFO("Starting diffCheckApp...");


// std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr = std::make_shared<diffCheck::geometry::DFMesh>();
// std::string pathMesh = R"("C:\Users\andre\Downloads\01_mesh.ply")";
// dfMeshPtr->LoadFromPLY(pathMesh);



Expand All @@ -38,10 +41,8 @@ int main()
// std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrWithoutNormals = std::make_shared<diffCheck::geometry::DFPointCloud>();
// std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruth = std::make_shared<diffCheck::geometry::DFPointCloud>();
// std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruthFromMesh = std::make_shared<diffCheck::geometry::DFPointCloud>();
// std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr = std::make_shared<diffCheck::geometry::DFMesh>();

// // std::string pathCloud = R"(C:\Users\andre\Downloads\scan_data_normals.ply\scan_data_normals.ply)";
// // std::string pathMesh = R"(F:\diffCheck\assets\dataset\mesh_fromRh_unfixedLength.ply)";
// // std::string pathMesh = R"(F:\diffCheck\temp\03_mesh.ply)";

// // create a sphere from o3d
Expand Down
70 changes: 61 additions & 9 deletions src/diffCheckBindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,70 @@ namespace py = pybind11;

bool test() { return true; }

PYBIND11_MODULE(diffCheckBindings, m) {
m.doc() = "diffCheck python bindings"; // optional module docstring
PYBIND11_MODULE(diffcheck_bindings, m) {
m.doc() = "The diffcheck bindings for python.";

m.def("test", &test, "A function that returns true for testing import");
//#################################################################################################
// testing namespace
//#################################################################################################

py::class_<diffCheck::geometry::DFPointCloud>(m, "DFPointCloud")
py::module_ submodule_test = m.def_submodule("dfb_test", "A submodule for testing the python bindings.");
submodule_test.def("test", &test, "Simple function testing a vanilla python bindings.");

//#################################################################################################
// df_geometry namespace
//#################################################################################################

py::module_ submodule_geometry = m.def_submodule("dfb_geometry", "A submodule for the geometry classes.");

py::class_<diffCheck::geometry::DFPointCloud>(submodule_geometry, "DFPointCloud")
.def(py::init<>())
.def(py::init<std::vector<Eigen::Vector3d>, std::vector<Eigen::Vector3d>, std::vector<Eigen::Vector3d>>())
.def("Cvt2DFPointCloud", &diffCheck::geometry::DFPointCloud::Cvt2DFPointCloud)
.def("Cvt2O3DPointCloud", &diffCheck::geometry::DFPointCloud::Cvt2O3DPointCloud)
.def("ComputeP2PDistance", &diffCheck::geometry::DFPointCloud::ComputeP2PDistance)
.def("ComputeBoundingBox", &diffCheck::geometry::DFPointCloud::ComputeBoundingBox)

.def("compute_P2PDistance", &diffCheck::geometry::DFPointCloud::ComputeP2PDistance)
.def("compute_BoundingBox", &diffCheck::geometry::DFPointCloud::ComputeBoundingBox)

.def("load_from_PLY", &diffCheck::geometry::DFPointCloud::LoadFromPLY)

.def("get_num_points", &diffCheck::geometry::DFPointCloud::GetNumPoints)
.def("get_num_colors", &diffCheck::geometry::DFPointCloud::GetNumColors)
.def("get_num_normals", &diffCheck::geometry::DFPointCloud::GetNumNormals)

.def_property("points",
[](const diffCheck::geometry::DFPointCloud &self) { return self.Points; },
[](diffCheck::geometry::DFPointCloud &self, const std::vector<Eigen::Vector3d>& value) { self.Points = value; })
.def_property("colors",
[](const diffCheck::geometry::DFPointCloud &self) { return self.Colors; },
[](diffCheck::geometry::DFPointCloud &self, const std::vector<Eigen::Vector3d>& value) { self.Colors = value; })
.def_property("normals",
[](const diffCheck::geometry::DFPointCloud &self) { return self.Normals; },
[](diffCheck::geometry::DFPointCloud &self, const std::vector<Eigen::Vector3d>& value) { self.Normals = value; });

py::class_<diffCheck::geometry::DFMesh>(submodule_geometry, "DFMesh")
.def(py::init<>())
.def(py::init<std::vector<Eigen::Vector3d>, std::vector<Eigen::Vector3i>, std::vector<Eigen::Vector3d>, std::vector<Eigen::Vector3d>, std::vector<Eigen::Vector3d>>())

.def("load_from_PLY", &diffCheck::geometry::DFMesh::LoadFromPLY)

.def("get_num_vertices", &diffCheck::geometry::DFMesh::GetNumVertices)
.def("get_num_faces", &diffCheck::geometry::DFMesh::GetNumFaces)

.def("get_num_points", &diffCheck::geometry::DFPointCloud::GetNumPoints);
.def_property("vertices",
[](const diffCheck::geometry::DFMesh &self) { return self.Vertices; },
[](diffCheck::geometry::DFMesh &self, const std::vector<Eigen::Vector3d>& value) { self.Vertices = value; })
.def_property("faces",
[](const diffCheck::geometry::DFMesh &self) { return self.Faces; },
[](diffCheck::geometry::DFMesh &self, const std::vector<Eigen::Vector3i>& value) { self.Faces = value; })
.def_property("normals_vertex",
[](const diffCheck::geometry::DFMesh &self) { return self.NormalsVertex; },
[](diffCheck::geometry::DFMesh &self, const std::vector<Eigen::Vector3d>& value) { self.NormalsVertex = value; })
.def_property("normals_face",
[](const diffCheck::geometry::DFMesh &self) { return self.NormalsFace; },
[](diffCheck::geometry::DFMesh &self, const std::vector<Eigen::Vector3d>& value) { self.NormalsFace = value; })
.def_property("colors_vertex",
[](const diffCheck::geometry::DFMesh &self) { return self.ColorsVertex; },
[](diffCheck::geometry::DFMesh &self, const std::vector<Eigen::Vector3d>& value) { self.ColorsVertex = value; })
.def_property("colors_face",
[](const diffCheck::geometry::DFMesh &self) { return self.ColorsFace; },
[](diffCheck::geometry::DFMesh &self, const std::vector<Eigen::Vector3d>& value) { self.ColorsFace = value; });
}
28 changes: 28 additions & 0 deletions src/gh/components/DF_bind_tester/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! python3

import System

import Rhino
import Rhino.Geometry as rg
from ghpythonlib.componentbase import executingcomponent as component

import Grasshopper as gh
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML

import diffCheck
from diffCheck import diffcheck_bindings

class DFBindTester(component):
def RunScript(self):
"""
The component test and import bind module for diffCheck.
"""
ghenv.Component.Message = f"diffCheck v: {diffCheck.__version__}"
is_binding_imported = diffcheck_bindings.dfb_test.test()

if not is_binding_imported:
ghenv.Component.AddRuntimeMessage(RML.Warning, "Bindings not imported.")
else:
ghenv.Component.AddRuntimeMessage(RML.Remark, "Bindings imported.")

return is_binding_imported
Binary file added src/gh/components/DF_bind_tester/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/gh/components/DF_bind_tester/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "DFBindTester",
"nickname": "BindT",
"category": "diffCheck",
"subcategory": "Utility",
"description": "This component is testing the binding import of diffCheck.",
"exposure": 4,
"instanceGuid": "7a600924-29bb-4682-8b95-a37752cefdbc",
"ghpython": {
"hideOutput": true,
"hideInput": true,
"isAdvancedMode": true,
"marshalOutGuids": true,
"iconDisplay": 2,
"inputParameters": [],
"outputParameters": [
{
"name": "o_is_imported",
"nickname": "o_is_imported",
"description": "True if the import of the diffCheck bindings is successfull.",
"optional": false,
"sourceCount": 0,
"graft": false
}
]
}
}
36 changes: 36 additions & 0 deletions src/gh/components/DF_mesh_to_cloud/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#! python3

import System

import Rhino
import Rhino.Geometry as rg
from ghpythonlib.componentbase import executingcomponent as component

import Grasshopper as gh
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML

import diffCheck
from diffCheck import diffCheckBindings

class DFMeshToCloud(component):
def RunScript(self):
"""
The component test and import bind module for diffCheck.
"""
ghenv.Component.Message = f"diffCheck v: {diffCheck.__version__}"
is_binding_imported = diffCheckBindings.test()

if not is_binding_imported:
ghenv.Component.AddRuntimeMessage(RML.Warning, "Bindings not imported.")
else:
ghenv.Component.AddRuntimeMessage(RML.Remark, "Bindings imported.")

return is_binding_imported

###################################################################
# >>>>>>>> DEBUG START - to comment out when componentized >>>>>>>>
###################################################################

if __name__ == "__main__":
comp = DFMeshToCloud()
o_is_imported = comp.RunScript()
Binary file added src/gh/components/DF_mesh_to_cloud/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ed523d2

Please sign in to comment.