33import numpy as np
44
55from ...core .data .dual_contouring_mesh import DualContouringMesh
6-
6+ from ... core . data . stacks_structure import StacksStructure
77
88
99def _apply_fault_relations_to_overlaps (
1010 all_meshes : List [DualContouringMesh ],
11- faults_relations : np .ndarray ,
1211 voxel_overlaps : dict ,
13- n_stacks : int
12+ stacks_structure : StacksStructure
1413) -> None :
1514 """
1615 Apply fault relations to voxel overlaps by updating mesh vertices.
@@ -21,70 +20,48 @@ def _apply_fault_relations_to_overlaps(
2120 voxel_overlaps: Dictionary containing overlap information between stacks
2221 n_stacks: Total number of stacks
2322 """
23+ faults_relations = stacks_structure .faults_relations
24+ n_stacks = stacks_structure .n_stacks
25+ number_surfaces_per_stack = stacks_structure .number_of_surfaces_per_stack_vector
26+
2427 if faults_relations is None :
2528 return
2629
27- # Calculate mesh indices offset for each stack
28- mesh_indices_offset = _calculate_mesh_indices_offset (all_meshes , n_stacks )
29-
3030 # Iterate through fault relations matrix
3131 for origin_stack in range (n_stacks ):
3232 for destination_stack in range (n_stacks ):
33- # If there's a fault relation from origin to destination
3433 if faults_relations [origin_stack , destination_stack ]:
35- overlap_key = f"stack_{ origin_stack } _vs_stack_{ destination_stack } "
34+ for surface_n in range (number_surfaces_per_stack [destination_stack ], number_surfaces_per_stack [destination_stack + 1 ]):
35+ overlap_key = f"stack_{ origin_stack } _vs_stack_{ surface_n } "
3636
37- # Check if there are actual overlaps between these stacks
38- if overlap_key in voxel_overlaps :
39- _apply_vertex_sharing (
40- all_meshes ,
41- origin_stack ,
42- destination_stack ,
43- voxel_overlaps [overlap_key ],
44- mesh_indices_offset
45- )
46-
47-
48- def _calculate_mesh_indices_offset (all_meshes : List [DualContouringMesh ], n_stacks : int ) -> List [int ]:
49- """
50- Calculate the starting mesh index for each stack.
51-
52- Args:
53- all_meshes: List of all dual contouring meshes
54- n_stacks: Total number of stacks
55-
56- Returns:
57- List of starting mesh indices for each stack
58- """
59- # For now, assume each stack has one mesh (this may need adjustment based on actual structure)
60- # This is a simplified approach - you may need to adjust based on how meshes are organized
61- mesh_indices_offset = list (range (n_stacks ))
62- return mesh_indices_offset
37+ # Check if there are actual overlaps between these stacks
38+ if overlap_key in voxel_overlaps :
39+ _apply_vertex_sharing (all_meshes , origin_stack , surface_n , voxel_overlaps [overlap_key ])
6340
6441
6542def _apply_vertex_sharing (
6643 all_meshes : List [DualContouringMesh ],
67- origin_stack : int ,
68- destination_stack : int ,
69- overlap_data : dict ,
70- mesh_indices_offset : List [int ]
44+ origin_mesh : int ,
45+ destination_mesh : int ,
46+ overlap_data : dict
7147) -> None :
7248 """
7349 Apply vertex sharing between origin and destination meshes based on overlap data.
7450
7551 Args:
7652 all_meshes: List of dual contouring meshes
77- origin_stack : Stack index that serves as the source of vertices
78- destination_stack : Stack index that receives vertices from origin
53+ origin_mesh : Stack index that serves as the source of vertices
54+ destination_mesh : Stack index that receives vertices from origin
7955 overlap_data: Dictionary containing indices and overlap information
8056 mesh_indices_offset: Starting mesh index for each stack
8157 """
82- origin_mesh_idx = mesh_indices_offset [origin_stack ]
83- destination_mesh_idx = mesh_indices_offset [destination_stack ]
58+ # origin_mesh_idx = mesh_indices_offset[origin_stack]
59+ # destination_mesh_idx = mesh_indices_offset[destination_stack]
60+ origin_mesh_idx = origin_mesh
61+ destination_mesh_idx = destination_mesh
8462
8563 # Ensure mesh indices are valid
86- if (origin_mesh_idx >= len (all_meshes ) or
87- destination_mesh_idx >= len (all_meshes )):
64+ if origin_mesh_idx >= len (all_meshes ) or destination_mesh_idx >= len (all_meshes ):
8865 return
8966
9067 # Apply the vertex sharing (same logic as original _f function)
@@ -97,20 +74,6 @@ def _apply_vertex_sharing(
9774 destination_mesh .vertices [indices_in_destination ] = origin_mesh .vertices [indices_in_origin ]
9875
9976
100- def _f (all_meshes : list [DualContouringMesh ], destination : int , origin : int , voxel_overlaps : dict ):
101- """
102- Legacy function - kept for backward compatibility.
103- Consider using _apply_fault_relations_to_overlaps for new implementations.
104- """
105- key = f"stack_{ origin } _vs_stack_{ destination } "
106- if key in voxel_overlaps :
107- all_meshes [destination ].vertices [voxel_overlaps [key ]["indices_in_stack_j" ]] = all_meshes [origin ].vertices [voxel_overlaps [key ]["indices_in_stack_i" ]]
108-
109- # def _f(all_meshes: list[DualContouringMesh], destination: int, origin: int, voxel_overlaps: dict):
110- # key = f"stack_{origin}_vs_stack_{destination}"
111- # all_meshes[destination].vertices[voxel_overlaps[key]["indices_in_stack_j"]] = all_meshes[origin].vertices[voxel_overlaps[key]["indices_in_stack_i"]]
112-
113-
11477def find_repeated_voxels_across_stacks (all_left_right_codes : List [np .ndarray ]) -> dict :
11578 """
11679 Find repeated voxels using NumPy operations - better for very large arrays.
0 commit comments