Skip to content

Commit 9367db8

Browse files
committed
keep cleaning
1 parent ee1bfa2 commit 9367db8

File tree

1 file changed

+60
-87
lines changed

1 file changed

+60
-87
lines changed

src/geode/inspector/topology/brep_blocks_topology.cpp

Lines changed: 60 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,14 @@
3131
#include <geode/basic/attribute_manager.hpp>
3232
#include <geode/basic/logger.hpp>
3333

34-
#include <geode/geometry/aabb.hpp>
3534
#include <geode/geometry/point.hpp>
3635

3736
#include <geode/mesh/builder/graph_builder.hpp>
3837
#include <geode/mesh/builder/polygonal_surface_builder.hpp>
39-
#include <geode/mesh/builder/vertex_set_builder.hpp>
40-
#include <geode/mesh/core/edged_curve.hpp>
4138
#include <geode/mesh/core/graph.hpp>
42-
#include <geode/mesh/core/point_set.hpp>
4339
#include <geode/mesh/core/polygonal_surface.hpp>
4440
#include <geode/mesh/core/solid_mesh.hpp>
4541
#include <geode/mesh/core/surface_edges.hpp>
46-
#include <geode/mesh/core/triangulated_surface.hpp>
47-
#include <geode/mesh/helpers/aabb_surface_helpers.hpp>
4842

4943
#include <geode/model/helpers/component_mesh_edges.hpp>
5044
#include <geode/model/helpers/ray_tracing.hpp>
@@ -162,51 +156,10 @@ namespace
162156
line_uuids_to_graph_vertices;
163157
auto graph = geode::Graph::create();
164158
auto graph_builder = geode::GraphBuilder::create( *graph );
165-
build_surface_line_graph( brep, *graph, *graph_builder,
166-
surface_uuids_to_graph_edges, line_uuids_to_graph_vertices );
167-
bool found_not_boundary_surface{ true };
168-
while( found_not_boundary_surface )
169-
{
170-
const auto to_delete = find_graph_surfaces_to_delete(
171-
*graph, surface_uuids_to_graph_edges, not_boundaries_surfaces );
172-
if( !absl::c_contains( to_delete, true ) )
173-
{
174-
found_not_boundary_surface = false;
175-
continue;
176-
}
177-
const auto old2new = graph_builder->delete_edges( to_delete );
178-
geode::GenericMapping< geode::uuid, geode::index_t >
179-
new_surface_uuids_to_graph_edges;
180-
for( const auto& [surface_id, graph_edges] :
181-
surface_uuids_to_graph_edges.in2out_map() )
182-
{
183-
for( const auto graph_edge : graph_edges )
184-
{
185-
if( old2new.at( graph_edge ) != geode::NO_ID )
186-
{
187-
new_surface_uuids_to_graph_edges.map(
188-
surface_id, old2new.at( graph_edge ) );
189-
}
190-
}
191-
}
192-
surface_uuids_to_graph_edges = new_surface_uuids_to_graph_edges;
193-
graph_builder->delete_isolated_vertices();
194-
}
195-
return not_boundaries_surfaces;
196-
}
197-
198-
void build_surface_line_graph( const geode::BRep& brep,
199-
geode::Graph& graph,
200-
geode::GraphBuilder& graph_builder,
201-
geode::GenericMapping< geode::uuid, geode::index_t >&
202-
surface_uuids_to_graph_edges,
203-
geode::BijectiveMapping< geode::uuid, geode::index_t >&
204-
line_uuids_to_graph_vertices )
205-
{
206159
for( const auto& line : brep.lines() )
207160
{
208161
line_uuids_to_graph_vertices.map(
209-
line.id(), graph_builder.create_vertex() );
162+
line.id(), graph_builder->create_vertex() );
210163
}
211164
for( const auto& line : brep.lines() )
212165
{
@@ -220,7 +173,7 @@ namespace
220173
const auto boundary_line_vertex =
221174
line_uuids_to_graph_vertices.in2out(
222175
boundary_line.id() );
223-
if( const auto existing_edge = graph.edge_from_vertices(
176+
if( const auto existing_edge = graph->edge_from_vertices(
224177
boundary_line_vertex, line_vertex ) )
225178
{
226179
if( surface_uuids_to_graph_edges
@@ -232,60 +185,80 @@ namespace
232185
}
233186
}
234187
surface_uuids_to_graph_edges.map( incident_surface.id(),
235-
graph_builder.create_edge(
188+
graph_builder->create_edge(
236189
boundary_line_vertex, line_vertex ) );
237190
}
238191
}
239192
}
240-
}
241-
242-
std::vector< bool > find_graph_surfaces_to_delete(
243-
const geode::Graph& graph,
244-
const geode::GenericMapping< geode::uuid, geode::index_t >&
245-
surface_uuids_to_graph_edges,
246-
std::vector< geode::uuid > not_boundaries_surfaces )
247-
{
248-
std::vector< bool > to_delete( graph.nb_edges(), false );
249-
for( const auto graph_vertex : geode::Range{ graph.nb_vertices() } )
193+
bool found_not_boundary_surface{ true };
194+
while( found_not_boundary_surface )
250195
{
251-
if( graph.edges_around_vertex( graph_vertex ).empty() )
196+
std::vector< bool > to_delete( graph->nb_edges(), false );
197+
for( const auto graph_vertex :
198+
geode::Range{ graph->nb_vertices() } )
252199
{
253-
continue;
254-
}
255-
const auto surface_id =
256-
surface_uuids_to_graph_edges
257-
.out2in( graph.edges_around_vertex( graph_vertex )
200+
if( graph->edges_around_vertex( graph_vertex ).empty() )
201+
{
202+
continue;
203+
}
204+
const auto surface_id =
205+
surface_uuids_to_graph_edges
206+
.out2in( graph->edges_around_vertex( graph_vertex )
207+
.at( 0 )
208+
.edge_id )
209+
.at( 0 );
210+
bool should_delete{ true };
211+
for( const auto& edge_around :
212+
graph->edges_around_vertex( graph_vertex ) )
213+
{
214+
if( surface_uuids_to_graph_edges
215+
.out2in( edge_around.edge_id )
258216
.at( 0 )
259-
.edge_id )
260-
.at( 0 );
261-
bool should_delete{ true };
262-
for( const auto& edge_around :
263-
graph.edges_around_vertex( graph_vertex ) )
264-
{
265-
if( surface_uuids_to_graph_edges.out2in( edge_around.edge_id )
266-
.at( 0 )
267-
!= surface_id )
217+
!= surface_id )
218+
{
219+
should_delete = false;
220+
break;
221+
}
222+
}
223+
if( !should_delete )
268224
{
269-
should_delete = false;
270-
break;
225+
continue;
271226
}
227+
if( absl::c_contains( not_boundaries_surfaces, surface_id ) )
228+
{
229+
continue;
230+
}
231+
for( const auto& edge :
232+
surface_uuids_to_graph_edges.in2out( surface_id ) )
233+
{
234+
to_delete[edge] = true;
235+
}
236+
not_boundaries_surfaces.push_back( surface_id );
272237
}
273-
if( !should_delete )
274-
{
275-
continue;
276-
}
277-
if( absl::c_contains( not_boundaries_surfaces, surface_id ) )
238+
if( !absl::c_contains( to_delete, true ) )
278239
{
240+
found_not_boundary_surface = false;
279241
continue;
280242
}
281-
for( const auto& edge :
282-
surface_uuids_to_graph_edges.in2out( surface_id ) )
243+
const auto old2new = graph_builder->delete_edges( to_delete );
244+
geode::GenericMapping< geode::uuid, geode::index_t >
245+
new_surface_uuids_to_graph_edges;
246+
for( const auto& [surface_id, graph_edges] :
247+
surface_uuids_to_graph_edges.in2out_map() )
283248
{
284-
to_delete[edge] = true;
249+
for( const auto graph_edge : graph_edges )
250+
{
251+
if( old2new.at( graph_edge ) != geode::NO_ID )
252+
{
253+
new_surface_uuids_to_graph_edges.map(
254+
surface_id, old2new.at( graph_edge ) );
255+
}
256+
}
285257
}
286-
not_boundaries_surfaces.push_back( surface_id );
258+
surface_uuids_to_graph_edges = new_surface_uuids_to_graph_edges;
259+
graph_builder->delete_isolated_vertices();
287260
}
288-
return to_delete;
261+
return not_boundaries_surfaces;
289262
}
290263

291264
bool verify_blocks_boundaries(

0 commit comments

Comments
 (0)