Skip to content

Commit 4cc3535

Browse files
committed
basic structure for vizualization components
1 parent fa7498c commit 4cc3535

File tree

10 files changed

+378
-35
lines changed

10 files changed

+378
-35
lines changed

src/gh/components/DF_cloud_to_cloud_distance/code.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,14 @@ def RunScript(self,
4343
df_cloud_target = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_target)
4444

4545
# calculate distances
46-
o_distances = df_error_estimation.cloud_2_cloud_distance(df_cloud_source, df_cloud_target)
47-
o_mse = df_error_estimation.compute_mse(o_distances)
48-
o_max_deviation = df_error_estimation.compute_max_deviation(o_distances)
49-
o_min_deviation = df_error_estimation.compute_min_deviation(o_distances)
50-
o_std_deviation = df_error_estimation.compute_standard_deviation(o_distances)
46+
o_results = df_error_estimation.cloud_2_cloud_distance(df_cloud_source, df_cloud_target)
5147

52-
return o_distances.tolist(), o_mse, o_max_deviation, o_min_deviation, o_std_deviation
48+
return o_results.distances_to_target, o_results.distances_to_target_mse, o_results.distances_to_target_max_deviation, o_results.distances_to_target_min_deviation, o_results.distances_to_target_sd_deviation, o_results
5349

5450

5551
if __name__ == "__main__":
5652
com = CloudToCloudDistance()
57-
o_distances, o_mse, o_max_deviation, o_min_deviation, o_std_deviation = com.RunScript(
53+
o_distances, o_mse, o_max_deviation, o_min_deviation, o_std_deviation, o_results = com.RunScript(
5854
i_cloud_source,
5955
i_cloud_target
6056
)

src/gh/components/DF_cloud_to_mesh_distance/code.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ def RunScript(self,
4242
df_mesh_target = df_cvt_bindings.cvt_rhmesh_2_dfmesh(rhino_mesh_target)
4343

4444
# calculate distances
45-
o_distances = df_error_estimation.cloud_2_mesh_distance(df_cloud_source, df_mesh_target, i_signed_flag)
46-
o_mse = df_error_estimation.compute_mse(o_distances)
47-
o_max_deviation = df_error_estimation.compute_max_deviation(o_distances)
48-
o_min_deviation = df_error_estimation.compute_min_deviation(o_distances)
45+
o_results = df_error_estimation.cloud_2_mesh_distance(df_cloud_source, df_mesh_target, i_signed_flag)
4946

5047
o_mesh = rhino_mesh_target
5148

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#! python3
2+
3+
import System
4+
import typing
5+
6+
import Rhino
7+
import Rhino.Geometry as rg
8+
from ghpythonlib.componentbase import executingcomponent as component
9+
10+
import Grasshopper as gh
11+
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
12+
13+
import diffCheck
14+
from diffCheck import diffcheck_bindings
15+
from diffCheck import df_cvt_bindings
16+
from diffCheck import df_error_estimation
17+
18+
import diffCheck.df_util
19+
20+
21+
class Vizualization(component):
22+
def RunScript(self,
23+
i_results,
24+
i_target_flag,
25+
i_source_flag,
26+
i_viz_settings):
27+
"""
28+
sth sth
29+
"""
30+
31+
i_viz_settings = []
32+
33+
if i_results.source is None or i_results.target is None:
34+
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to compare")
35+
return None
36+
37+
if i_target_flag == False:
38+
o_target = i_results.target
39+
o_target_legend = []
40+
else:
41+
#color the target pointcloud based on viz_settings
42+
43+
#make a legend
44+
45+
pass
46+
47+
if i_source_flag == False:
48+
o_source = i_results.source
49+
o_source_legend = []
50+
else:
51+
#color the source pointcloud based on viz_settings
52+
pass
53+
54+
#df_cloud_source = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_source)
55+
#df_cloud_target = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_target)
56+
57+
58+
return o_source, o_target, o_source_legend, o_target_legend
59+
60+
61+
if __name__ == "__main__":
62+
com = Vizualization()
63+
o_source, o_target, o_source_legend, o_target_legend = com.RunScript(
64+
i_results,
65+
i_target_flag,
66+
i_source_flag,
67+
i_viz_settings
68+
)
9.56 KB
Loading
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"name": "CloudToCloudDistance",
3+
"nickname": "C2CDistance",
4+
"category": "diffCheck",
5+
"subcategory": "Analysis",
6+
"description": "Computes the distance between each point in the source point cloud and its nearest neighbour in thr target point cloud.",
7+
"exposure": 4,
8+
"instanceGuid": "ad21f438-b953-464b-8332-04f4074f3bd0",
9+
"ghpython": {
10+
"hideOutput": true,
11+
"hideInput": true,
12+
"isAdvancedMode": true,
13+
"marshalOutGuids": true,
14+
"iconDisplay": 2,
15+
"inputParameters": [
16+
{
17+
"name": "i_cloud_source",
18+
"nickname": "i_cloud_source",
19+
"description": "The source point cloud.",
20+
"optional": true,
21+
"allowTreeAccess": true,
22+
"showTypeHints": true,
23+
"scriptParamAccess": "item",
24+
"wireDisplay": "default",
25+
"sourceCount": 0,
26+
"typeHintID": "pointcloud"
27+
},
28+
{
29+
"name": "i_cloud_target",
30+
"nickname": "i_cloud_target",
31+
"description": "The target cloud.",
32+
"optional": false,
33+
"allowTreeAccess": true,
34+
"showTypeHints": true,
35+
"scriptParamAccess": "item",
36+
"wireDisplay": "default",
37+
"sourceCount": 0,
38+
"typeHintID": "pointcloud"
39+
},
40+
{
41+
"name": "i_signed_flag",
42+
"nickname": "i_signed_flag",
43+
"description": "whether to take normals into account",
44+
"optional": false,
45+
"allowTreeAccess": false,
46+
"showTypeHints": true,
47+
"scriptParamAccess": "item",
48+
"wireDisplay": "default",
49+
"sourceCount": 0,
50+
"typeHintID": "float"
51+
}
52+
],
53+
"outputParameters": [
54+
{
55+
"name": "o_distance",
56+
"nickname": "o_distance",
57+
"description": "list of calculated distances for each point of the source.",
58+
"optional": false,
59+
"sourceCount": 0,
60+
"graft": false
61+
},
62+
{
63+
"name": "o_mse",
64+
"nickname": "o_mse",
65+
"description": "average squared difference between source and target.",
66+
"optional": false,
67+
"sourceCount": 0,
68+
"graft": false
69+
},
70+
{
71+
"name": "o_max_deviation",
72+
"nickname": "o_max_deviation",
73+
"description": "max deviation between source and target",
74+
"optional": false,
75+
"sourceCount": 0,
76+
"graft": false
77+
},
78+
{
79+
"name": "o_min_deviation",
80+
"nickname": "o_min_deviation",
81+
"description": "min deviation between source and target",
82+
"optional": false,
83+
"sourceCount": 0,
84+
"graft": false
85+
},
86+
{
87+
"name": "o_std_deviation",
88+
"nickname": "o_std_deviation",
89+
"description": "standard deviation between source and target.",
90+
"optional": false,
91+
"sourceCount": 0,
92+
"graft": false
93+
}
94+
]
95+
}
96+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#! python3
2+
3+
import System
4+
import typing
5+
6+
import Rhino
7+
import Rhino.Geometry as rg
8+
from ghpythonlib.componentbase import executingcomponent as component
9+
10+
import Grasshopper as gh
11+
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
12+
13+
import diffCheck
14+
from diffCheck import df_vizualization
15+
16+
import diffCheck.df_util
17+
18+
19+
class VisualizationSettings(component):
20+
def RunScript(self,
21+
i_source_value_type,
22+
i_target_value_type,
23+
i_upper_threshold,
24+
i_lower_threshold,
25+
i_palette):
26+
"""
27+
sth
28+
"""
29+
30+
# pack settings
31+
o_viz_settings = df_vizualization.DFVizSettings(i_source_value_type, i_target_value_type, i_upper_threshold, i_lower_threshold, i_palette)
32+
33+
return o_viz_settings
34+
35+
if __name__ == "__main__":
36+
com = VisualizationSettings()
37+
o_viz_settings = com.RunScript(
38+
i_source_value_type,
39+
i_target_value_type,
40+
i_upper_threshold,
41+
i_lower_threshold,
42+
i_palette
43+
)
9.56 KB
Loading
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"name": "CloudToCloudDistance",
3+
"nickname": "C2CDistance",
4+
"category": "diffCheck",
5+
"subcategory": "Analysis",
6+
"description": "Computes the distance between each point in the source point cloud and its nearest neighbour in thr target point cloud.",
7+
"exposure": 4,
8+
"instanceGuid": "ad21f438-b953-464b-8332-04f4074f3bd0",
9+
"ghpython": {
10+
"hideOutput": true,
11+
"hideInput": true,
12+
"isAdvancedMode": true,
13+
"marshalOutGuids": true,
14+
"iconDisplay": 2,
15+
"inputParameters": [
16+
{
17+
"name": "i_cloud_source",
18+
"nickname": "i_cloud_source",
19+
"description": "The source point cloud.",
20+
"optional": true,
21+
"allowTreeAccess": true,
22+
"showTypeHints": true,
23+
"scriptParamAccess": "item",
24+
"wireDisplay": "default",
25+
"sourceCount": 0,
26+
"typeHintID": "pointcloud"
27+
},
28+
{
29+
"name": "i_cloud_target",
30+
"nickname": "i_cloud_target",
31+
"description": "The target cloud.",
32+
"optional": false,
33+
"allowTreeAccess": true,
34+
"showTypeHints": true,
35+
"scriptParamAccess": "item",
36+
"wireDisplay": "default",
37+
"sourceCount": 0,
38+
"typeHintID": "pointcloud"
39+
},
40+
{
41+
"name": "i_signed_flag",
42+
"nickname": "i_signed_flag",
43+
"description": "whether to take normals into account",
44+
"optional": false,
45+
"allowTreeAccess": false,
46+
"showTypeHints": true,
47+
"scriptParamAccess": "item",
48+
"wireDisplay": "default",
49+
"sourceCount": 0,
50+
"typeHintID": "float"
51+
}
52+
],
53+
"outputParameters": [
54+
{
55+
"name": "o_distance",
56+
"nickname": "o_distance",
57+
"description": "list of calculated distances for each point of the source.",
58+
"optional": false,
59+
"sourceCount": 0,
60+
"graft": false
61+
},
62+
{
63+
"name": "o_mse",
64+
"nickname": "o_mse",
65+
"description": "average squared difference between source and target.",
66+
"optional": false,
67+
"sourceCount": 0,
68+
"graft": false
69+
},
70+
{
71+
"name": "o_max_deviation",
72+
"nickname": "o_max_deviation",
73+
"description": "max deviation between source and target",
74+
"optional": false,
75+
"sourceCount": 0,
76+
"graft": false
77+
},
78+
{
79+
"name": "o_min_deviation",
80+
"nickname": "o_min_deviation",
81+
"description": "min deviation between source and target",
82+
"optional": false,
83+
"sourceCount": 0,
84+
"graft": false
85+
},
86+
{
87+
"name": "o_std_deviation",
88+
"nickname": "o_std_deviation",
89+
"description": "standard deviation between source and target.",
90+
"optional": false,
91+
"sourceCount": 0,
92+
"graft": false
93+
}
94+
]
95+
}
96+
}

0 commit comments

Comments
 (0)