Skip to content

Commit 394a621

Browse files
committed
Merge branch 'fix_joint_detector'
2 parents 41da968 + 4255081 commit 394a621

File tree

61 files changed

+1787
-310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1787
-310
lines changed

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ temp/
8585
## Python
8686
#######################################
8787
# Byte-compiled / optimized / DLL files
88-
__pycache__/
88+
**/__pycache__/
8989
*.py[cod]
9090
*$py.class
9191

Diff for: assets/icon_pool/cloud1.png

-12 KB
Binary file not shown.

Diff for: assets/icon_pool/cloud1.xcf

-2.93 KB
Binary file not shown.

Diff for: assets/icon_pool/cloud2.png

-10.5 KB
Binary file not shown.

Diff for: assets/icon_pool/cloud2.xcf

-4.77 KB
Binary file not shown.

Diff for: assets/icon_pool/code_xml_export.png

-12.5 KB
Binary file not shown.

Diff for: assets/icon_pool/code_xml_export.xcf

-4.85 KB
Binary file not shown.

Diff for: assets/icon_pool/code_xml_export2.png

-11.5 KB
Binary file not shown.

Diff for: assets/icon_pool/code_xml_export2.xcf

-5.6 KB
Binary file not shown.

Diff for: assets/icon_pool/df_test_import.png

-11.1 KB
Binary file not shown.

Diff for: assets/icon_pool/df_test_import.xcf

-6.77 KB
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.

Diff for: assets/icons/icon_large_assemblytoxml.png

19.7 KB

Diff for: assets/icons/icon_large_buildassembly.png

19.7 KB

Diff for: assets/icons/icon_large_deconstructassembly.png

31.3 KB

Diff for: assets/icons/icon_large_deconstructbeam.png

17.1 KB

Diff for: assets/icons/icon_small_buildassembly.png

11.2 KB

Diff for: assets/icons/icon_small_buildassembly.xcf

3.89 KB
Binary file not shown.

Diff for: assets/icons/icon_small_deconstructassembly.png

12.5 KB

Diff for: assets/icons/icon_small_deconstructbeam.png

9.54 KB

Diff for: assets/icons/icon_small_xmlexport.png

11.5 KB

Diff for: assets/icons/logo_pixelized_bwvioelt.png

11.7 KB

Diff for: deps/eigen

Submodule eigen updated from f78dfe3 to 27f8176

Diff for: src/diffCheck/geometry/DFMesh.cc

+8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ namespace diffCheck::geometry
7171
this->Cvt2DFMesh(O3DTriangleMesh);
7272
}
7373

74+
std::vector<Eigen::Vector3d> DFMesh::GetTightBoundingBox()
75+
{
76+
auto O3DTriangleMesh = this->Cvt2O3DTriangleMesh();
77+
open3d::geometry::OrientedBoundingBox tightOOBB = O3DTriangleMesh->GetMinimalOrientedBoundingBox();
78+
std::vector<Eigen::Vector3d> bboxPts = tightOOBB.GetBoxPoints();
79+
return bboxPts;
80+
}
81+
7482
void DFMesh::LoadFromPLY(const std::string &path)
7583
{
7684
std::shared_ptr<diffCheck::geometry::DFMesh> tempMesh_ptr = diffCheck::io::ReadPLYMeshFromFile(path);

Diff for: src/diffCheck/geometry/DFMesh.hh

+9
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ namespace diffCheck::geometry
6262
*/
6363
void ApplyTransformation(const diffCheck::transformation::DFTransformation &transformation);
6464

65+
public: ///< Utils
66+
/**
67+
* @brief Get the mesh tight bounding box
68+
*
69+
* @return std::vector<Eigen::Vector3d> A vector of two Eigen::Vector3d, with the first one being the minimum
70+
* point and the second one the maximum point of the bounding box.
71+
*/
72+
std::vector<Eigen::Vector3d> GetTightBoundingBox();
73+
6574
public: ///< I/O loader
6675
/**
6776
* @brief Read a mesh from a file

Diff for: src/diffCheck/geometry/DFPointCloud.cc

+5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ namespace diffCheck::geometry
105105
this->Normals.clear();
106106
for (auto &normal : O3DPointCloudDown->normals_)
107107
this->Normals.push_back(normal);
108+
std::vector<Eigen::Vector3d> DFPointCloud::GetTightBoundingBox()
109+
{
110+
open3d::geometry::OrientedBoundingBox tightOOBB = this->Cvt2O3DPointCloud()->GetMinimalOrientedBoundingBox();
111+
std::vector<Eigen::Vector3d> bboxPts = tightOOBB.GetBoxPoints();
112+
return bboxPts;
108113
}
109114

110115
void DFPointCloud::ApplyTransformation(const diffCheck::transformation::DFTransformation &transformation)

Diff for: src/diffCheck/geometry/DFPointCloud.hh

+26
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,33 @@ namespace diffCheck::geometry
7878
*
7979
* @param targetSize the target size of the cloud
8080
*/
81+
8182
void DownsampleBySize(int targetSize);
83+
/**
84+
* @brief Get the tight bounding box of the point cloud
85+
*
86+
* @return std::vector<Eigen::Vector3d> A vector of two Eigen::Vector3d, with the first one being the minimum
87+
* point and the second one the maximum point of the bounding box.
88+
* /// ------- x
89+
* /// /|
90+
* /// / |
91+
* /// / | z
92+
* /// y
93+
* /// 0 ------------------- 1
94+
* /// /| /|
95+
* /// / | / |
96+
* /// / | / |
97+
* /// / | / |
98+
* /// 2 ------------------- 7 |
99+
* /// | |____________|____| 6
100+
* /// | /3 | /
101+
* /// | / | /
102+
* /// | / | /
103+
* /// |/ |/
104+
* /// 5 ------------------- 4
105+
* ///
106+
*/
107+
std::vector<Eigen::Vector3d> GetTightBoundingBox();
82108

83109
public: ///< Transformers
84110
/**

Diff for: src/diffCheckApp.cc

+35-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,46 @@
66

77
int main()
88
{
9-
std::shared_ptr<diffCheck::geometry::DFPointCloud> pcdSrc = std::make_shared<diffCheck::geometry::DFPointCloud>();
9+
// import clouds
10+
std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr
11+
= std::make_shared<diffCheck::geometry::DFPointCloud>();
12+
std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr
13+
= std::make_shared<diffCheck::geometry::DFMesh>();
14+
15+
// create a sphere from o3d
16+
std::string pathCloud = R"(C:\andre\Downloads\moved_04.ply)";
17+
std::string pathMesh = R"(C:\Users\andre\Downloads\meshtest.ply)";
18+
19+
// dfPointCloudPtr->LoadFromPLY(pathCloud);
20+
dfMeshPtr->LoadFromPLY(pathMesh);
21+
22+
open3d::geometry::TriangleMesh meshO3d = *dfMeshPtr->Cvt2O3DTriangleMesh();
23+
24+
25+
// convert the sphere to a diffCheck point cloud
26+
// auto o3dPointCloud = meshO3d.SamplePointsUniformly(1000);
27+
28+
std::shared_ptr<open3d::geometry::PointCloud> tightBBOX = std::make_shared<open3d::geometry::PointCloud>();
29+
30+
// compute the bounding box
31+
open3d::geometry::OrientedBoundingBox bbox = meshO3d.GetMinimalOrientedBoundingBox();
32+
std::vector<Eigen::Vector3d> bboxPts = bbox.GetBoxPoints();
33+
for (auto &pt : bboxPts)
34+
{
35+
tightBBOX->points_.push_back(pt);
36+
}
37+
38+
39+
dfPointCloudPtr->Cvt2DFPointCloud(tightBBOX);
1040

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

13-
pcdSrc->LoadFromPLY(pathPcdSrc);
1442

15-
pcdSrc->DownsampleBySize(100);
1643

1744
std::shared_ptr<diffCheck::visualizer::Visualizer> vis = std::make_shared<diffCheck::visualizer::Visualizer>();
18-
vis->AddPointCloud(pcdSrc);
45+
vis->AddPointCloud(dfPointCloudPtr);
46+
// vis->AddMesh(dfMeshPtr);
1947
vis->Run();
48+
49+
2050
return 0;
2151
}

Diff for: src/diffCheckBindings.cc

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ PYBIND11_MODULE(diffcheck_bindings, m) {
4141

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

44+
.def("get_tight_bounding_box", &diffCheck::geometry::DFPointCloud::GetTightBoundingBox)
45+
4446
.def("get_num_points", &diffCheck::geometry::DFPointCloud::GetNumPoints)
4547
.def("get_num_colors", &diffCheck::geometry::DFPointCloud::GetNumColors)
4648
.def("get_num_normals", &diffCheck::geometry::DFPointCloud::GetNumNormals)
@@ -67,6 +69,8 @@ PYBIND11_MODULE(diffcheck_bindings, m) {
6769

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

72+
.def("get_tight_bounding_box", &diffCheck::geometry::DFMesh::GetTightBoundingBox)
73+
7074
.def("get_num_vertices", &diffCheck::geometry::DFMesh::GetNumVertices)
7175
.def("get_num_faces", &diffCheck::geometry::DFMesh::GetNumFaces)
7276

Diff for: src/gh/components/DF_bind_tester/icon.png

-11.1 KB
Binary file not shown.

Diff for: src/gh/components/DF_build_assembly/code.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#! python3
2+
3+
import System
4+
import typing
5+
6+
import Rhino
7+
import Rhino.Geometry as rg
8+
import scriptcontext as sc
9+
10+
from ghpythonlib.componentbase import executingcomponent as component
11+
12+
import diffCheck
13+
from diffCheck.df_geometries import DFBeam, DFAssembly
14+
15+
16+
class DFBuildAssembly(component):
17+
def RunScript(self,
18+
i_assembly_name,
19+
i_breps : System.Collections.Generic.IList[Rhino.Geometry.Brep]):
20+
"""
21+
This component parse a series of breps representing a timber structure or a
22+
timber elements into a DFAssembly object.
23+
24+
:param i_assembly_name: the name of the assembly
25+
:param i_breps: list of breps
26+
27+
:return o_assembly: the DFAssembly object
28+
"""
29+
beams: typing.List[DFBeam] = []
30+
for brep in i_breps:
31+
beam = DFBeam.from_brep_face(brep)
32+
beams.append(beam)
33+
34+
o_assembly = DFAssembly(beams, i_assembly_name)
35+
36+
return o_assembly
37+
38+
39+
# if __name__ == "__main__":
40+
# comp = DFBuildAssembly()
41+
# o_assembly = comp.RunScript(
42+
# i_assembly_name,
43+
# i_breps
44+
# )

Diff for: src/gh/components/DF_build_assembly/icon.png

11.2 KB

Diff for: src/gh/components/DF_build_assembly/metadata.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "DFBuildAssembly",
3+
"nickname": "DFBuildAssembly",
4+
"category": "diffCheck",
5+
"subcategory": "Structure",
6+
"description": "This component parse a series of breps representing a timber structure or a timber elements into a DFAssembly object.",
7+
"exposure": 4,
8+
"instanceGuid": "bf6f47fe-2a7e-47b5-b1c4-c716c524d245",
9+
"ghpython": {
10+
"hideOutput": true,
11+
"hideInput": true,
12+
"isAdvancedMode": true,
13+
"marshalOutGuids": true,
14+
"iconDisplay": 2,
15+
"inputParameters": [
16+
{
17+
"name": "i_assembly_name",
18+
"nickname": "i_assembly_name",
19+
"description": "The name of the assembly to export.",
20+
"optional": false,
21+
"allowTreeAccess": true,
22+
"showTypeHints": true,
23+
"scriptParamAccess": "item",
24+
"wireDisplay": "default",
25+
"sourceCount": 0,
26+
"typeHintID": "str"
27+
},
28+
{
29+
"name": "i_breps",
30+
"nickname": "i_breps",
31+
"description": "The breps of the structure.",
32+
"optional": true,
33+
"allowTreeAccess": true,
34+
"showTypeHints": true,
35+
"scriptParamAccess": "list",
36+
"wireDisplay": "default",
37+
"sourceCount": 0,
38+
"typeHintID": "brep"
39+
}
40+
],
41+
"outputParameters": [
42+
{
43+
"name": "o_assembly",
44+
"nickname": "o_assembly",
45+
"description": "The create DFAssembly object representing the timber elements.",
46+
"optional": false,
47+
"sourceCount": 0,
48+
"graft": false
49+
}
50+
]
51+
}
52+
}

Diff for: src/gh/components/DF_deconstruct_assembly/code.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#! python3
2+
3+
import System
4+
import typing
5+
6+
import Rhino
7+
import Rhino.Geometry as rg
8+
import scriptcontext as sc
9+
10+
from ghpythonlib.componentbase import executingcomponent as component
11+
12+
import diffCheck
13+
from diffCheck.df_geometries import DFBeam, DFAssembly
14+
15+
16+
class DFDeconstructAssembly(component):
17+
def RunScript(self,
18+
i_assembly):
19+
"""
20+
Deconstruct the DFAssembly into a set of df_beams objects.
21+
22+
:param i_assembly: the DFAssembly object
23+
24+
:return o_beams
25+
"""
26+
o_beams = i_assembly.beams
27+
28+
return o_beams
29+
30+
31+
# if __name__ == "__main__":
32+
# comp = DFDeconstructAssembly()
33+
# o_beams = comp.RunScript(
34+
# i_assembly
35+
# )

Diff for: src/gh/components/DF_deconstruct_assembly/icon.png

12.5 KB
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "DFDeconstructAssembly",
3+
"nickname": "DFDeconstructAssembly",
4+
"category": "diffCheck",
5+
"subcategory": "Structure",
6+
"description": "Deconstruct the DFAssembly into a set of df_beams objects.",
7+
"exposure": 4,
8+
"instanceGuid": "43098147-78a1-41ce-863d-e48337cb8cd5",
9+
"ghpython": {
10+
"hideOutput": true,
11+
"hideInput": true,
12+
"isAdvancedMode": true,
13+
"marshalOutGuids": true,
14+
"iconDisplay": 2,
15+
"inputParameters": [
16+
{
17+
"name": "i_assembly",
18+
"nickname": "i_assembly",
19+
"description": "The DFAssembly object to deconstruct.",
20+
"optional": false,
21+
"allowTreeAccess": true,
22+
"showTypeHints": true,
23+
"scriptParamAccess": "item",
24+
"wireDisplay": "default",
25+
"sourceCount": 0,
26+
"typeHintID": "ghdoc"
27+
}
28+
],
29+
"outputParameters": [
30+
{
31+
"name": "o_beams",
32+
"nickname": "o_beams",
33+
"description": "The set of beams contained by this DFAssembly object.",
34+
"optional": false,
35+
"sourceCount": 0,
36+
"graft": false
37+
}
38+
]
39+
}
40+
}

Diff for: src/gh/components/DF_deconstruct_beam/code.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#! python3
2+
3+
import System
4+
import typing
5+
6+
import Rhino
7+
import Rhino.Geometry as rg
8+
import scriptcontext as sc
9+
10+
from ghpythonlib.componentbase import executingcomponent as component
11+
12+
import diffCheck
13+
from diffCheck.df_geometries import DFBeam, DFAssembly
14+
15+
16+
class DFDeconstructBeam(component):
17+
def RunScript(self,
18+
i_beams : typing.List[DFBeam]):
19+
"""
20+
Deconstruct the DFBeam object into Rhino objects.
21+
22+
:param i_beams: the DFBeam objects
23+
24+
:return o_side_faces: the side joints of the beam
25+
:return o_joint_faces: the face joints of the beam
26+
:return o_joint_ids: the ids for each face joint
27+
"""
28+
o_side_faces, o_joint_faces, o_joint_ids, o_breps = [], [], [], []
29+
30+
for i_b in i_beams:
31+
o_side_faces = [f.to_brep_face() for f in i_b.side_faces]
32+
o_joint_faces = [f.to_brep_face() for f in i_b.joint_faces]
33+
o_joint_ids = [f.joint_id for f in i_b.joint_faces]
34+
35+
return o_side_faces, o_joint_faces, o_joint_ids
36+
37+
# if __name__ == "__main__":
38+
# comp = DFDeconstructBeam()
39+
# o_side_faces, o_joint_faces, o_joint_ids = comp.RunScript(
40+
# i_beams
41+
# )

Diff for: src/gh/components/DF_deconstruct_beam/icon.png

9.54 KB

0 commit comments

Comments
 (0)