Skip to content

Commit

Permalink
Merge branch 'fix_joint_detector'
Browse files Browse the repository at this point in the history
  • Loading branch information
9and3 committed Jun 13, 2024
2 parents 41da968 + 4255081 commit 394a621
Show file tree
Hide file tree
Showing 61 changed files with 1,787 additions and 310 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ temp/
## Python
#######################################
# Byte-compiled / optimized / DLL files
__pycache__/
**/__pycache__/
*.py[cod]
*$py.class

Expand Down
Binary file removed assets/icon_pool/cloud1.png
Binary file not shown.
Binary file removed assets/icon_pool/cloud1.xcf
Binary file not shown.
Binary file removed assets/icon_pool/cloud2.png
Binary file not shown.
Binary file removed assets/icon_pool/cloud2.xcf
Binary file not shown.
Binary file removed assets/icon_pool/code_xml_export.png
Binary file not shown.
Binary file removed assets/icon_pool/code_xml_export.xcf
Binary file not shown.
Binary file removed assets/icon_pool/code_xml_export2.png
Binary file not shown.
Binary file removed assets/icon_pool/code_xml_export2.xcf
Binary file not shown.
Binary file removed assets/icon_pool/df_test_import.png
Binary file not shown.
Binary file removed assets/icon_pool/df_test_import.xcf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added assets/icons/icon_large_assemblytoxml.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/icons/icon_large_buildassembly.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/icons/icon_large_deconstructassembly.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/icons/icon_large_deconstructbeam.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/icons/icon_small_buildassembly.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/icons/icon_small_buildassembly.xcf
Binary file not shown.
Binary file added assets/icons/icon_small_deconstructassembly.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/icons/icon_small_deconstructbeam.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/icons/icon_small_xmlexport.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/icons/logo_pixelized_bwvioelt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion deps/eigen
Submodule eigen updated from f78dfe to 27f817
8 changes: 8 additions & 0 deletions src/diffCheck/geometry/DFMesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ namespace diffCheck::geometry
this->Cvt2DFMesh(O3DTriangleMesh);
}

std::vector<Eigen::Vector3d> DFMesh::GetTightBoundingBox()
{
auto O3DTriangleMesh = this->Cvt2O3DTriangleMesh();
open3d::geometry::OrientedBoundingBox tightOOBB = O3DTriangleMesh->GetMinimalOrientedBoundingBox();
std::vector<Eigen::Vector3d> bboxPts = tightOOBB.GetBoxPoints();
return bboxPts;
}

void DFMesh::LoadFromPLY(const std::string &path)
{
std::shared_ptr<diffCheck::geometry::DFMesh> tempMesh_ptr = diffCheck::io::ReadPLYMeshFromFile(path);
Expand Down
9 changes: 9 additions & 0 deletions src/diffCheck/geometry/DFMesh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ namespace diffCheck::geometry
*/
void ApplyTransformation(const diffCheck::transformation::DFTransformation &transformation);

public: ///< Utils
/**
* @brief Get the mesh tight 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> GetTightBoundingBox();

public: ///< I/O loader
/**
* @brief Read a mesh from a file
Expand Down
5 changes: 5 additions & 0 deletions src/diffCheck/geometry/DFPointCloud.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ namespace diffCheck::geometry
this->Normals.clear();
for (auto &normal : O3DPointCloudDown->normals_)
this->Normals.push_back(normal);
std::vector<Eigen::Vector3d> DFPointCloud::GetTightBoundingBox()
{
open3d::geometry::OrientedBoundingBox tightOOBB = this->Cvt2O3DPointCloud()->GetMinimalOrientedBoundingBox();
std::vector<Eigen::Vector3d> bboxPts = tightOOBB.GetBoxPoints();
return bboxPts;
}

void DFPointCloud::ApplyTransformation(const diffCheck::transformation::DFTransformation &transformation)
Expand Down
26 changes: 26 additions & 0 deletions src/diffCheck/geometry/DFPointCloud.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,33 @@ namespace diffCheck::geometry
*
* @param targetSize the target size of the cloud
*/

void DownsampleBySize(int targetSize);
/**
* @brief Get the tight bounding box of the point cloud
*
* @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.
* /// ------- x
* /// /|
* /// / |
* /// / | z
* /// y
* /// 0 ------------------- 1
* /// /| /|
* /// / | / |
* /// / | / |
* /// / | / |
* /// 2 ------------------- 7 |
* /// | |____________|____| 6
* /// | /3 | /
* /// | / | /
* /// | / | /
* /// |/ |/
* /// 5 ------------------- 4
* ///
*/
std::vector<Eigen::Vector3d> GetTightBoundingBox();

public: ///< Transformers
/**
Expand Down
40 changes: 35 additions & 5 deletions src/diffCheckApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,46 @@

int main()
{
std::shared_ptr<diffCheck::geometry::DFPointCloud> pcdSrc = std::make_shared<diffCheck::geometry::DFPointCloud>();
// import clouds
std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr
= std::make_shared<diffCheck::geometry::DFPointCloud>();
std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr
= std::make_shared<diffCheck::geometry::DFMesh>();

// create a sphere from o3d
std::string pathCloud = R"(C:\andre\Downloads\moved_04.ply)";
std::string pathMesh = R"(C:\Users\andre\Downloads\meshtest.ply)";

// dfPointCloudPtr->LoadFromPLY(pathCloud);
dfMeshPtr->LoadFromPLY(pathMesh);

open3d::geometry::TriangleMesh meshO3d = *dfMeshPtr->Cvt2O3DTriangleMesh();


// convert the sphere to a diffCheck point cloud
// auto o3dPointCloud = meshO3d.SamplePointsUniformly(1000);

std::shared_ptr<open3d::geometry::PointCloud> tightBBOX = std::make_shared<open3d::geometry::PointCloud>();

// compute the bounding box
open3d::geometry::OrientedBoundingBox bbox = meshO3d.GetMinimalOrientedBoundingBox();
std::vector<Eigen::Vector3d> bboxPts = bbox.GetBoxPoints();
for (auto &pt : bboxPts)
{
tightBBOX->points_.push_back(pt);
}


dfPointCloudPtr->Cvt2DFPointCloud(tightBBOX);

std::string pathPcdSrc = R"(C:\Users\andre\Downloads\04_pt.ply)";

pcdSrc->LoadFromPLY(pathPcdSrc);

pcdSrc->DownsampleBySize(100);

std::shared_ptr<diffCheck::visualizer::Visualizer> vis = std::make_shared<diffCheck::visualizer::Visualizer>();
vis->AddPointCloud(pcdSrc);
vis->AddPointCloud(dfPointCloudPtr);
// vis->AddMesh(dfMeshPtr);
vis->Run();


return 0;
}
4 changes: 4 additions & 0 deletions src/diffCheckBindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ PYBIND11_MODULE(diffcheck_bindings, m) {

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

.def("get_tight_bounding_box", &diffCheck::geometry::DFPointCloud::GetTightBoundingBox)

.def("get_num_points", &diffCheck::geometry::DFPointCloud::GetNumPoints)
.def("get_num_colors", &diffCheck::geometry::DFPointCloud::GetNumColors)
.def("get_num_normals", &diffCheck::geometry::DFPointCloud::GetNumNormals)
Expand All @@ -67,6 +69,8 @@ PYBIND11_MODULE(diffcheck_bindings, m) {

.def("sample_points_uniformly", &diffCheck::geometry::DFMesh::SampleCloudUniform)

.def("get_tight_bounding_box", &diffCheck::geometry::DFMesh::GetTightBoundingBox)

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

Expand Down
Binary file removed src/gh/components/DF_bind_tester/icon.png
Diff not rendered.
44 changes: 44 additions & 0 deletions src/gh/components/DF_build_assembly/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#! python3

import System
import typing

import Rhino
import Rhino.Geometry as rg
import scriptcontext as sc

from ghpythonlib.componentbase import executingcomponent as component

import diffCheck
from diffCheck.df_geometries import DFBeam, DFAssembly


class DFBuildAssembly(component):
def RunScript(self,
i_assembly_name,
i_breps : System.Collections.Generic.IList[Rhino.Geometry.Brep]):
"""
This component parse a series of breps representing a timber structure or a
timber elements into a DFAssembly object.
:param i_assembly_name: the name of the assembly
:param i_breps: list of breps
:return o_assembly: the DFAssembly object
"""
beams: typing.List[DFBeam] = []
for brep in i_breps:
beam = DFBeam.from_brep_face(brep)
beams.append(beam)

o_assembly = DFAssembly(beams, i_assembly_name)

return o_assembly


# if __name__ == "__main__":
# comp = DFBuildAssembly()
# o_assembly = comp.RunScript(
# i_assembly_name,
# i_breps
# )
Binary file added src/gh/components/DF_build_assembly/icon.png
52 changes: 52 additions & 0 deletions src/gh/components/DF_build_assembly/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "DFBuildAssembly",
"nickname": "DFBuildAssembly",
"category": "diffCheck",
"subcategory": "Structure",
"description": "This component parse a series of breps representing a timber structure or a timber elements into a DFAssembly object.",
"exposure": 4,
"instanceGuid": "bf6f47fe-2a7e-47b5-b1c4-c716c524d245",
"ghpython": {
"hideOutput": true,
"hideInput": true,
"isAdvancedMode": true,
"marshalOutGuids": true,
"iconDisplay": 2,
"inputParameters": [
{
"name": "i_assembly_name",
"nickname": "i_assembly_name",
"description": "The name of the assembly to export.",
"optional": false,
"allowTreeAccess": true,
"showTypeHints": true,
"scriptParamAccess": "item",
"wireDisplay": "default",
"sourceCount": 0,
"typeHintID": "str"
},
{
"name": "i_breps",
"nickname": "i_breps",
"description": "The breps of the structure.",
"optional": true,
"allowTreeAccess": true,
"showTypeHints": true,
"scriptParamAccess": "list",
"wireDisplay": "default",
"sourceCount": 0,
"typeHintID": "brep"
}
],
"outputParameters": [
{
"name": "o_assembly",
"nickname": "o_assembly",
"description": "The create DFAssembly object representing the timber elements.",
"optional": false,
"sourceCount": 0,
"graft": false
}
]
}
}
35 changes: 35 additions & 0 deletions src/gh/components/DF_deconstruct_assembly/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! python3

import System
import typing

import Rhino
import Rhino.Geometry as rg
import scriptcontext as sc

from ghpythonlib.componentbase import executingcomponent as component

import diffCheck
from diffCheck.df_geometries import DFBeam, DFAssembly


class DFDeconstructAssembly(component):
def RunScript(self,
i_assembly):
"""
Deconstruct the DFAssembly into a set of df_beams objects.
:param i_assembly: the DFAssembly object
:return o_beams
"""
o_beams = i_assembly.beams

return o_beams


# if __name__ == "__main__":
# comp = DFDeconstructAssembly()
# o_beams = comp.RunScript(
# i_assembly
# )
40 changes: 40 additions & 0 deletions src/gh/components/DF_deconstruct_assembly/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "DFDeconstructAssembly",
"nickname": "DFDeconstructAssembly",
"category": "diffCheck",
"subcategory": "Structure",
"description": "Deconstruct the DFAssembly into a set of df_beams objects.",
"exposure": 4,
"instanceGuid": "43098147-78a1-41ce-863d-e48337cb8cd5",
"ghpython": {
"hideOutput": true,
"hideInput": true,
"isAdvancedMode": true,
"marshalOutGuids": true,
"iconDisplay": 2,
"inputParameters": [
{
"name": "i_assembly",
"nickname": "i_assembly",
"description": "The DFAssembly object to deconstruct.",
"optional": false,
"allowTreeAccess": true,
"showTypeHints": true,
"scriptParamAccess": "item",
"wireDisplay": "default",
"sourceCount": 0,
"typeHintID": "ghdoc"
}
],
"outputParameters": [
{
"name": "o_beams",
"nickname": "o_beams",
"description": "The set of beams contained by this DFAssembly object.",
"optional": false,
"sourceCount": 0,
"graft": false
}
]
}
}
41 changes: 41 additions & 0 deletions src/gh/components/DF_deconstruct_beam/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#! python3

import System
import typing

import Rhino
import Rhino.Geometry as rg
import scriptcontext as sc

from ghpythonlib.componentbase import executingcomponent as component

import diffCheck
from diffCheck.df_geometries import DFBeam, DFAssembly


class DFDeconstructBeam(component):
def RunScript(self,
i_beams : typing.List[DFBeam]):
"""
Deconstruct the DFBeam object into Rhino objects.
:param i_beams: the DFBeam objects
:return o_side_faces: the side joints of the beam
:return o_joint_faces: the face joints of the beam
:return o_joint_ids: the ids for each face joint
"""
o_side_faces, o_joint_faces, o_joint_ids, o_breps = [], [], [], []

for i_b in i_beams:
o_side_faces = [f.to_brep_face() for f in i_b.side_faces]
o_joint_faces = [f.to_brep_face() for f in i_b.joint_faces]
o_joint_ids = [f.joint_id for f in i_b.joint_faces]

return o_side_faces, o_joint_faces, o_joint_ids

# if __name__ == "__main__":
# comp = DFDeconstructBeam()
# o_side_faces, o_joint_faces, o_joint_ids = comp.RunScript(
# i_beams
# )
Binary file added src/gh/components/DF_deconstruct_beam/icon.png
Loading

0 comments on commit 394a621

Please sign in to comment.