Skip to content

Commit 788ceea

Browse files
authored
Merge branch 'main' into test_suite_seg_reg
2 parents db94515 + 69ca054 commit 788ceea

File tree

5 files changed

+88
-3
lines changed

5 files changed

+88
-3
lines changed

deps/eigen

Submodule eigen updated from 3f06651 to 0b646f3

src/gh/diffCheck/diffCheck/df_geometries.py

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,51 @@ def is_joint(self):
198198
def id(self):
199199
return self.__id
200200

201+
@dataclass
202+
class DFJoint:
203+
"""
204+
This class represents a joint, in diffCheck, a joint is a collection of faces
205+
For convenience, this is used only as a return type from the DFBeam class's property for retrieveing joints
206+
"""
207+
208+
id: int
209+
faces: typing.List[DFFace]
210+
211+
def __post_init__(self):
212+
self.id = self.id
213+
self.faces = self.faces or []
214+
215+
def __repr__(self):
216+
return f"Joint id: {self.id}, Faces: {len(self.faces)}"
217+
218+
def to_brep(self):
219+
"""
220+
Convert the joint to a Rhino Brep object
221+
"""
222+
brep = rg.Brep()
223+
for face in self.faces:
224+
brep.Append(face.to_brep_face())
225+
brep.Compact()
226+
return brep
227+
228+
def to_mesh(self, max_edge_length):
229+
"""
230+
Convert the joint to a Rhino Mesh object
231+
"""
232+
rhino_brep_faces = [f.to_brep_face() for f in self.faces]
233+
mesh = rg.Mesh()
234+
235+
new_faces = [f.DuplicateFace(True) for f in rhino_brep_faces]
236+
237+
for f in new_faces:
238+
param = rg.MeshingParameters()
239+
param.MaximumEdgeLength = max_edge_length
240+
mesh_part = rg.Mesh.CreateFromBrep(f, param)[0]
241+
mesh.Append(mesh_part)
242+
243+
mesh.Faces.ConvertQuadsToTriangles()
244+
mesh.Compact()
245+
return mesh
201246

202247
@dataclass
203248
class DFBeam:
@@ -214,6 +259,8 @@ def __post_init__(self):
214259
self._joint_faces = []
215260
self._side_faces = []
216261

262+
self._joints = []
263+
217264
self.__id = uuid.uuid4().int
218265

219266
@classmethod
@@ -274,6 +321,18 @@ def joint_faces(self):
274321
def side_faces(self):
275322
return [face for face in self.faces if not face.is_joint]
276323

324+
@property
325+
def joints(self):
326+
joints : typing.List[DFJoint] = []
327+
temp_faces = self.joint_faces.copy()
328+
while len(temp_faces) > 0:
329+
joint_id = temp_faces[0].joint_id
330+
joint_faces = [face for face in temp_faces if face.joint_id == joint_id]
331+
joint = DFJoint(joint_id, joint_faces)
332+
joints.append(joint)
333+
temp_faces = [face for face in temp_faces if face.joint_id != joint_id]
334+
return joints
335+
277336

278337
@dataclass
279338
class DFAssembly:
@@ -288,9 +347,11 @@ def __post_init__(self):
288347
self.beams = self.beams
289348
self.name = self.name or "Unnamed Assembly"
290349

291-
self._all_jointfaces = []
292-
self._all_sidefaces = []
350+
self._all_jointfaces: typing.List[DFFace] = []
351+
self._all_sidefaces: typing.List[DFFace] = []
293352

353+
self._all_joints: typing.List[DFJoint] = []
354+
294355
def __repr__(self):
295356
return f"Assembly: {self.name}, Beams: {len(self.beams)}"
296357

@@ -370,3 +431,9 @@ def all_side_faces(self):
370431
for beam in self.beams:
371432
self._all_sidefaces.extend(beam.side_faces)
372433
return self._all_sidefaces
434+
435+
@property
436+
def all_joints(self):
437+
for beam in self.beams:
438+
self._all_joints.extend(beam.joints)
439+
return self._all_joints

tests/integration_tests/pybinds_tests/test_pybind_units.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,17 @@ def test_DFPointCloud_properties(create_DFPointCloudSampleRoof):
146146
assert pc.has_colors() == False, "has_colors() should return False"
147147
assert pc.has_normals() == False, "has_normals() should return False"
148148

149+
def test_DFPointCloud_add_points():
150+
point_pc_1 = [(0, 0, 0)]
151+
point_pc_2 = [(1, 1, 1)]
152+
normal_pc_1 = [(0, 0, 1)]
153+
normal_pc_2 = [(1, 0, 0)]
154+
color_pc_1 = [(255, 0, 0)]
155+
color_pc_2 = [(0, 255, 0)]
156+
pc_1 = dfb.dfb_geometry.DFPointCloud(point_pc_1, normal_pc_1, color_pc_1)
157+
pc_2 = dfb.dfb_geometry.DFPointCloud(point_pc_2, normal_pc_2, color_pc_2)
158+
pc_1.add_points(pc_2)
159+
assert pc_1.points.__len__() == 2, "two pointclouds of 1 pt combined into one should have 2 pts"
149160

150161
def test_DFPointCloud_apply_color(create_DFPointCloudSampleRoof):
151162
pc = create_DFPointCloudSampleRoof

tests/unit_tests/DFPointCloudTest.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ TEST_F(DFPointCloudTestFixture, ComputeDistance) {
117117
EXPECT_EQ(distances.size(), 7379);
118118
}
119119

120+
TEST_F(DFPointCloudTestFixture, AddPoints) {
121+
std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloud2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
122+
dfPointCloud2->LoadFromPLY(diffCheck::io::GetRoofQuarterPlyPath());
123+
dfPointCloud.AddPoints(*dfPointCloud2);
124+
EXPECT_EQ(dfPointCloud.GetNumPoints(), 7379 * 2);
125+
}
126+
120127
TEST_F(DFPointCloudTestFixture, ComputeAABB) {
121128
std::vector<Eigen::Vector3d> bbox = dfPointCloud.GetAxixAlignedBoundingBox();
122129
EXPECT_EQ(bbox.size(), 2);

unnamed.gh

26.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)