Skip to content

Commit ee1bfa2

Browse files
committed
start cleaning
1 parent 5bdf9e1 commit ee1bfa2

File tree

3 files changed

+83
-82
lines changed

3 files changed

+83
-82
lines changed

src/geode/inspector/topology/brep_blocks_topology.cpp

Lines changed: 83 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,57 @@ namespace
156156
const geode::BRep& brep )
157157
{
158158
std::vector< geode::uuid > not_boundaries_surfaces;
159-
auto graph = geode::Graph::create();
160-
auto graph_builder = geode::GraphBuilder::create( *graph );
161159
geode::GenericMapping< geode::uuid, geode::index_t >
162160
surface_uuids_to_graph_edges;
163161
geode::BijectiveMapping< geode::uuid, geode::index_t >
164162
line_uuids_to_graph_vertices;
163+
auto graph = geode::Graph::create();
164+
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+
{
165206
for( const auto& line : brep.lines() )
166207
{
167208
line_uuids_to_graph_vertices.map(
168-
line.id(), graph_builder->create_vertex() );
209+
line.id(), graph_builder.create_vertex() );
169210
}
170211
for( const auto& line : brep.lines() )
171212
{
@@ -179,7 +220,7 @@ namespace
179220
const auto boundary_line_vertex =
180221
line_uuids_to_graph_vertices.in2out(
181222
boundary_line.id() );
182-
if( const auto existing_edge = graph->edge_from_vertices(
223+
if( const auto existing_edge = graph.edge_from_vertices(
183224
boundary_line_vertex, line_vertex ) )
184225
{
185226
if( surface_uuids_to_graph_edges
@@ -191,80 +232,60 @@ namespace
191232
}
192233
}
193234
surface_uuids_to_graph_edges.map( incident_surface.id(),
194-
graph_builder->create_edge(
235+
graph_builder.create_edge(
195236
boundary_line_vertex, line_vertex ) );
196237
}
197238
}
198239
}
199-
bool found_not_boundary_surface{ true };
200-
while( found_not_boundary_surface )
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() } )
201250
{
202-
std::vector< bool > to_delete( graph->nb_edges(), false );
203-
for( const auto graph_vertex :
204-
geode::Range{ graph->nb_vertices() } )
251+
if( graph.edges_around_vertex( graph_vertex ).empty() )
205252
{
206-
if( graph->edges_around_vertex( graph_vertex ).empty() )
207-
{
208-
continue;
209-
}
210-
const auto surface_id =
211-
surface_uuids_to_graph_edges
212-
.out2in( graph->edges_around_vertex( graph_vertex )
213-
.at( 0 )
214-
.edge_id )
215-
.at( 0 );
216-
bool should_delete{ true };
217-
for( const auto& edge_around :
218-
graph->edges_around_vertex( graph_vertex ) )
219-
{
220-
if( surface_uuids_to_graph_edges
221-
.out2in( edge_around.edge_id )
253+
continue;
254+
}
255+
const auto surface_id =
256+
surface_uuids_to_graph_edges
257+
.out2in( graph.edges_around_vertex( graph_vertex )
222258
.at( 0 )
223-
!= surface_id )
224-
{
225-
should_delete = false;
226-
break;
227-
}
228-
}
229-
if( !should_delete )
230-
{
231-
continue;
232-
}
233-
if( absl::c_contains( not_boundaries_surfaces, surface_id ) )
234-
{
235-
continue;
236-
}
237-
for( const auto& edge :
238-
surface_uuids_to_graph_edges.in2out( surface_id ) )
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 )
239268
{
240-
to_delete[edge] = true;
269+
should_delete = false;
270+
break;
241271
}
242-
not_boundaries_surfaces.push_back( surface_id );
243272
}
244-
if( !absl::c_contains( to_delete, true ) )
273+
if( !should_delete )
245274
{
246-
found_not_boundary_surface = false;
247275
continue;
248276
}
249-
const auto old2new = graph_builder->delete_edges( to_delete );
250-
geode::GenericMapping< geode::uuid, geode::index_t >
251-
new_surface_uuids_to_graph_edges;
252-
for( const auto& [surface_id, graph_edges] :
253-
surface_uuids_to_graph_edges.in2out_map() )
277+
if( absl::c_contains( not_boundaries_surfaces, surface_id ) )
254278
{
255-
for( const auto graph_edge : graph_edges )
256-
{
257-
if( old2new.at( graph_edge ) != geode::NO_ID )
258-
{
259-
new_surface_uuids_to_graph_edges.map(
260-
surface_id, old2new.at( graph_edge ) );
261-
}
262-
}
279+
continue;
263280
}
264-
surface_uuids_to_graph_edges = new_surface_uuids_to_graph_edges;
265-
graph_builder->delete_isolated_vertices();
281+
for( const auto& edge :
282+
surface_uuids_to_graph_edges.in2out( surface_id ) )
283+
{
284+
to_delete[edge] = true;
285+
}
286+
not_boundaries_surfaces.push_back( surface_id );
266287
}
267-
return not_boundaries_surfaces;
288+
return to_delete;
268289
}
269290

270291
bool verify_blocks_boundaries(

src/geode/inspector/topology/brep_lines_topology.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,6 @@ namespace geode
233233
}
234234
for( const auto unique_vertex_id : Range{ brep_.nb_unique_vertices() } )
235235
{
236-
// if( const auto boundary_nor_internal_line =
237-
// vertex_is_part_of_line_with_wrong_relationships_to_surface(
238-
// unique_vertex_id ) )
239-
// {
240-
// result.unique_vertices_linked_to_not_internal_nor_boundary_line
241-
// .add_issue(
242-
// unique_vertex_id, boundary_nor_internal_line.value()
243-
// );
244-
// }
245236
if( const auto invalid_internal_topology =
246237
vertex_is_part_of_invalid_embedded_line(
247238
unique_vertex_id ) )
@@ -250,14 +241,6 @@ namespace geode
250241
.add_issue(
251242
unique_vertex_id, invalid_internal_topology.value() );
252243
}
253-
// if( const auto invalid_unique_line =
254-
// vertex_is_part_of_invalid_single_line( unique_vertex_id )
255-
// )
256-
// {
257-
// result.unique_vertices_linked_to_a_single_and_invalid_line
258-
// .add_issue( unique_vertex_id, invalid_unique_line.value()
259-
// );
260-
// }
261244
if( const auto lines_but_is_not_corner =
262245
vertex_has_lines_but_is_not_a_corner( unique_vertex_id ) )
263246
{

src/geode/inspector/topology/brep_surfaces_topology.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131

3232
#include <geode/geometry/point.hpp>
3333

34-
#include <geode/mesh/core/edged_curve.hpp>
35-
#include <geode/mesh/core/point_set.hpp>
36-
#include <geode/mesh/core/solid_mesh.hpp>
3734
#include <geode/mesh/core/surface_mesh.hpp>
3835

3936
#include <geode/model/mixin/core/block.hpp>

0 commit comments

Comments
 (0)