Skip to content

Commit a82b792

Browse files
committed
FIX-MERGE: linter fixes + merge from eleni's branch
2 parents 699e67d + 8a0ade7 commit a82b792

File tree

12 files changed

+5534
-5169
lines changed

12 files changed

+5534
-5169
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
files: \.py$
2626

2727
- repo: https://github.com/pre-commit/mirrors-mypy
28-
rev: 'v1.11.0'
28+
rev: 'v1.11.1'
2929
hooks:
3030
- id: mypy
3131
files: (src/gh|tests|invokes\.py)
@@ -39,6 +39,6 @@ repos:
3939
args: [--config=pyproject.toml]
4040

4141
- repo: https://github.com/astral-sh/ruff-pre-commit
42-
rev: v0.4.4
42+
rev: v0.6.2
4343
hooks:
4444
- id: ruff

deps/eigen

Submodule eigen updated from 92e373e to f91f8e9

deps/googletest

Submodule googletest updated 48 files

pyproject.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ exclude = [
66
"src/gh/components",
77
"src/gh/diffCheck/setup.py",
88
"temp",
9-
"doc"
9+
"doc",
10+
"src/gh/diffCheck/diffCheck/__init__.py"
1011
]
1112

1213
[[tool.mypy.overrides]]
@@ -18,18 +19,27 @@ module = [
1819
"System.*",
1920
"GH_IO.*",
2021
"clr.*",
21-
"diffcheck_bindings"
22+
"diffcheck_bindings",
23+
"diffCheck.diffcheck_bindings"
2224
]
2325
ignore_missing_imports = true
2426

2527
[[tool.mypy.overrides]]
2628
module = "pefile"
2729
ignore_missing_imports = true
2830

31+
[[tool.mypy.overrides]]
32+
module = "diffCheck"
33+
ignore_undefined_attributes = true
34+
35+
2936

3037
[tool.ruff]
3138
exclude = [
3239
"doc/",
3340
"deps/",
3441
"temp/"
35-
]
42+
]
43+
44+
[tool.ruff.per-file-ignores]
45+
"src/gh/diffCheck/diffCheck/__init__.py" = ["F401", "F403" ,"E402"]

src/gh/components/DF_cloud_mesh_distance/code.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
import Rhino.Geometry as rg
66
from ghpythonlib.componentbase import executingcomponent as component
7-
7+
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
88

99
import diffCheck
1010
from diffCheck import df_cvt_bindings
1111
from diffCheck import df_error_estimation
12-
from diffCheck.df_geometries import DFBeam
12+
from diffCheck.df_geometries import DFAssembly
1313

1414

1515
class DFCloudMeshDistance(component):
1616
def RunScript(self,
1717
i_cloud_source: typing.List[rg.PointCloud],
18-
i_beams: typing.List[DFBeam],
18+
i_assembly: DFAssembly,
1919
i_signed_flag: bool,
2020
i_swap: bool,
2121
i_analysis_resolution):
@@ -24,9 +24,20 @@ def RunScript(self,
2424
scalef = diffCheck.df_util.get_doc_2_meters_unitf()
2525
i_analysis_resolution = 0.1 / scalef
2626

27+
# Based on cloud source input + beam size, decide whether to calculate joints or entire assembly and output respective message
28+
if len(i_assembly.beams) == len(i_cloud_source):
29+
ghenv.Component.Message = "Per Beam" # noqa: F821
30+
rh_mesh_target_list = [beam.to_mesh(i_analysis_resolution) for beam in i_assembly.beams]
31+
elif len(i_assembly.all_joints) == len(i_cloud_source):
32+
ghenv.Component.Message = "Per Joint" # noqa: F821
33+
rh_mesh_target_list = [joint.to_mesh(i_analysis_resolution) for joint in i_assembly._all_joints]
34+
else:
35+
ghenv.Component.AddRuntimeMessage(RML.Warning, "The input number of objects to compare matches neither the number of beams nor the number of joints") # noqa: F821
36+
return None, None, None, None, None, None
37+
2738
# conversion
2839
df_cloud_source_list = [df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cl_s) for i_cl_s in i_cloud_source]
29-
rh_mesh_target_list = [beam.to_mesh(i_analysis_resolution) for beam in i_beams]
40+
3041

3142
# calculate distances
3243
o_result = df_error_estimation.df_cloud_2_rh_mesh_comparison(df_cloud_source_list, rh_mesh_target_list, i_signed_flag, i_swap)

src/gh/components/DF_cloud_mesh_distance/metadata.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"subcategory": "Analysis",
66
"description": "Computes the distance between a point cloud and a mesh",
77
"exposure": 4,
8-
"instanceGuid": "534a24ba-7e32-482f-a3d7-293647185122",
8+
"instanceGuid": "eda01e34-b89b-4e3c-a9b6-0178a05ae81b",
99
"ghpython": {
1010
"hideOutput": true,
1111
"hideInput": true,
@@ -26,13 +26,13 @@
2626
"typeHintID": "pointcloud"
2727
},
2828
{
29-
"name": "i_beams",
30-
"nickname": "i_beams",
31-
"description": "The target DFbeams",
29+
"name": "i_assembly",
30+
"nickname": "i_assembly",
31+
"description": "The target DFAssembly",
3232
"optional": false,
3333
"allowTreeAccess": true,
3434
"showTypeHints": true,
35-
"scriptParamAccess": "list",
35+
"scriptParamAccess": "item",
3636
"wireDisplay": "default",
3737
"sourceCount": 0,
3838
"typeHintID": "ghdoc"

src/gh/components/DF_joint_segmentator/code.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import Rhino
44

5+
import diffCheck
56
from diffCheck import diffcheck_bindings
67
from diffCheck import df_cvt_bindings as df_cvt
78

@@ -15,20 +16,22 @@
1516
class DFJointSegmentator(component):
1617
def __init__(self):
1718
super(DFJointSegmentator, self).__init__()
18-
def RunScript(self,
19-
i_clusters: typing.List[Rhino.Geometry.PointCloud],
19+
def RunScript(self,
20+
i_clusters: typing.List[Rhino.Geometry.PointCloud],
2021
i_assembly: diffCheck.df_geometries.DFAssembly,
2122
i_angle_threshold: float,
2223
i_distance_threshold: float):
2324

24-
if i_angle_threshold is None : i_angle_threshold = 0.1
25-
if i_distance_threshold is None : i_distance_threshold = 0.1
26-
25+
if i_angle_threshold is None:
26+
i_angle_threshold = 0.1
27+
if i_distance_threshold is None:
28+
i_distance_threshold = 0.1
29+
2730
if len(i_clusters) == 0:
2831
raise ValueError("No clusters given.")
2932
if not isinstance(i_clusters[0], Rhino.Geometry.PointCloud):
3033
raise ValueError("The input clusters must be PointClouds.")
31-
34+
3235
# get number of joints
3336
n_joints = i_assembly.total_number_joints
3437

@@ -60,13 +63,13 @@ def RunScript(self,
6063
# find the corresponding clusters and merge them
6164
df_joint_segment = diffcheck_bindings.dfb_segmentation.DFSegmentation.associate_clusters(df_joint, df_cloud_clusters, i_angle_threshold, i_distance_threshold)
6265
diffcheck_bindings.dfb_segmentation.DFSegmentation.clean_unassociated_clusters(df_cloud_clusters, [df_joint_segment], [df_joint], i_angle_threshold, i_distance_threshold)
63-
66+
6467
# register the merged clusters to the reference point cloud
6568
registration = diffcheck_bindings.dfb_registrations.DFRefinedRegistration.O3DICP(df_joint_segment, ref_df_joint_cloud)
6669
res = registration.transformation_matrix
6770
transforms.append(df_cvt.cvt_ndarray_2_rh_transform(res))
6871
rh_joint_segments.append(df_cvt.cvt_dfcloud_2_rhcloud(df_joint_segment))
69-
72+
7073
o_joint_segments = []
7174
o_transforms = []
7275
o_reference_point_clouds = []
@@ -76,6 +79,6 @@ def RunScript(self,
7679
o_transforms.append(transform)
7780
o_reference_point_clouds.append(_joint_cloud)
7881
else:
79-
ghenv.Component.AddRuntimeMessage(RML.Warning, "Some joints could not be segmented and were ignored.")
82+
ghenv.Component.AddRuntimeMessage(RML.Warning, "Some joints could not be segmented and were ignored.") # noqa: F821
8083

81-
return o_joint_segments, o_transforms, o_reference_point_clouds
84+
return o_joint_segments, o_transforms, o_reference_point_clouds

src/gh/diffCheck/diffCheck/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
os.add_dll_directory(extra_dll_dir)
99

1010
# import the bindings
11-
from . import diffcheck_bindings
11+
from . import diffcheck_bindings # type: ignore[attr-defined]
12+
from . import df_cvt_bindings # type: ignore[attr-defined]

src/gh/diffCheck/diffCheck/df_geometries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def __post_init__(self):
360360
self._all_sidefaces: typing.List[DFFace] = []
361361

362362
self._all_joints: typing.List[DFJoint] = []
363-
363+
364364
def __repr__(self):
365365
return f"Assembly: {self.name}, Beams: {len(self.beams)}"
366366

@@ -451,4 +451,4 @@ def all_joints(self):
451451
self._all_joints = []
452452
for beam in self.beams:
453453
self._all_joints.extend(beam.joints)
454-
return self._all_joints
454+
return self._all_joints

0 commit comments

Comments
 (0)