Skip to content

Commit c01271f

Browse files
committed
WIP-ADD thresholding results with upper/higher value
1 parent a86c71c commit c01271f

File tree

3 files changed

+117
-19
lines changed

3 files changed

+117
-19
lines changed

src/gh/components/DF_vizualization/code.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@ def RunScript(self,
3535

3636
# by default we color the target
3737
distances_flattened = [item for sublist in i_results.distances for item in sublist]
38+
3839
min_value = min(min(sublist) for sublist in i_results.distances)
39-
max_value = max(max(sublist) for sublist in i_results.distances)
40+
41+
if i_viz_settings.lower_threshold is not None:
42+
min_value = i_viz_settings.lower_threshold
43+
44+
if i_viz_settings.upper_threshold is not None:
45+
max_value = i_viz_settings.upper_threshold
46+
else:
47+
max_value = max(max(sublist) for sublist in i_results.distances)
4048

4149
o_source = [df_vizualization.color_pcd(src, dist, min_value, max_value) for src, dist in zip(o_source, i_results.distances)]
4250

src/gh/diffCheck/diffCheck/df_vizualization.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def interpolate_color(color1, color2, t):
3535
def value_to_color(value, min_value, max_value):
3636
"""Map a value to a color based on a spectral colormap."""
3737

38+
if value < min_value:
39+
value = min_value
40+
elif value > max_value:
41+
value = max_value
42+
3843
# Define the spectral colormap (simplified)
3944
colormap = [
4045
Color.FromArgb(0, 0, 255), # Blue
@@ -110,7 +115,7 @@ def create_legend(min_value, max_value, steps=10, base_point=rg.Point3d(0, 0, 0)
110115
polyline = rg.Polyline(rect_pts)
111116

112117
legend_geometry.append(mesh)
113-
# legend_geometry.append(polyline.ToPolylineCurve())
118+
legend_geometry.append(polyline.ToPolylineCurve())
114119

115120
text_pt = rg.Point3d(x + 1.25 * width + spacing, y + i * (height + spacing) + height / 10, z)
116121
text_entity = rg.TextEntity()
@@ -154,10 +159,13 @@ def create_histogram(values, min_value, max_value, steps=100, base_point=rg.Poin
154159

155160
# Count the frequencies of values in each bin
156161
for value in values:
157-
if min_value <= value and value <= max_value:
158-
bin_index = (value - min_value) // bin_size
159-
bin_index = int(bin_index)
160-
frequencies[bin_index] += 1
162+
if value < min_value:
163+
value = min_value
164+
elif value > max_value:
165+
value = max_value
166+
bin_index = (value - min_value) // bin_size
167+
bin_index = int(bin_index)
168+
frequencies[bin_index] += 1
161169

162170
x, y, z = base_point.X, base_point.Y, base_point.Z
163171

src/gh/examples/error_viz_tester.ghx

Lines changed: 95 additions & 13 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)