Skip to content

Commit 86d55e2

Browse files
committed
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeode into fix_removing_apex_refine_in_remesh
2 parents 0405a7d + 5d50aad commit 86d55e2

File tree

10 files changed

+69
-236
lines changed

10 files changed

+69
-236
lines changed

include/geode/mesh/helpers/convert_edged_curve.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ namespace geode
4747
double axis_coordinate );
4848

4949
template < index_t dimension >
50-
[[nodiscard]] std::unique_ptr< EdgedCurve< dimension > > merge_edged_curves(
51-
absl::Span<
52-
const std::reference_wrapper< const EdgedCurve< dimension > > >
53-
curves );
50+
[[deprecated, nodiscard]] std::unique_ptr< EdgedCurve< dimension > >
51+
merge_edged_curves( absl::Span< const std::reference_wrapper<
52+
const EdgedCurve< dimension > > > curves );
5453
} // namespace geode

include/geode/mesh/helpers/convert_solid_mesh.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace geode
6161
opengeode_mesh_api convert_solid_mesh_into_hybrid_solid(
6262
const SolidMesh3D& solid );
6363

64-
[[nodiscard]] std::unique_ptr< SolidMesh3D >
64+
[[deprecated, nodiscard]] std::unique_ptr< SolidMesh3D >
6565
opengeode_mesh_api merge_solid_meshes(
6666
absl::Span< const std::reference_wrapper< const SolidMesh3D > >
6767
solids );

include/geode/mesh/helpers/convert_surface_mesh.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ namespace geode
103103
local_index_t axis_to_remove );
104104

105105
template < index_t dimension >
106-
[[nodiscard]] std::unique_ptr< SurfaceMesh< dimension > >
106+
[[deprecated, nodiscard]] std::unique_ptr< SurfaceMesh< dimension > >
107107
merge_surface_meshes( absl::Span< const std::reference_wrapper<
108108
const SurfaceMesh< dimension > > > surfaces );
109109
} // namespace geode

include/geode/mesh/helpers/remove_vertex_duplication.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@ namespace geode
4242
namespace geode
4343
{
4444
template < index_t dimension >
45-
void remove_vertex_duplication( const PointSet< dimension >& mesh,
45+
[[deprecated]] void remove_vertex_duplication(
46+
const PointSet< dimension >& mesh,
4647
PointSetBuilder< dimension >& builder );
4748

4849
template < index_t dimension >
49-
void remove_vertex_duplication( const EdgedCurve< dimension >& mesh,
50+
[[deprecated]] void remove_vertex_duplication(
51+
const EdgedCurve< dimension >& mesh,
5052
EdgedCurveBuilder< dimension >& builder );
5153

5254
template < index_t dimension >
53-
void remove_vertex_duplication( const SurfaceMesh< dimension >& mesh,
55+
[[deprecated]] void remove_vertex_duplication(
56+
const SurfaceMesh< dimension >& mesh,
5457
SurfaceMeshBuilder< dimension >& builder );
5558

56-
void opengeode_mesh_api remove_vertex_duplication(
59+
[[deprecated]] void opengeode_mesh_api remove_vertex_duplication(
5760
const SolidMesh3D& mesh, SolidMeshBuilder3D& builder );
5861
} // namespace geode

src/geode/mesh/helpers/rasterize.cpp

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ namespace
8484
index[axis0] += increments[axis0];
8585
painted_cells.push_back( index );
8686
}
87-
painted_cells.push_back( end );
87+
if( painted_cells.back() != end )
88+
{
89+
painted_cells.push_back( end );
90+
}
8891
return painted_cells;
8992
}
9093

@@ -98,12 +101,17 @@ namespace
98101
std::array< int, dimension > increments;
99102
for( const auto i : geode::LRange{ dimension } )
100103
{
101-
if( end[i] > start[i] )
104+
if( end[i] == start[i] )
105+
{
106+
deltas[i] = 0;
107+
increments[i] = 0;
108+
}
109+
else if( end[i] > start[i] )
102110
{
103111
deltas[i] = end[i] - start[i];
104112
increments[i] = 1;
105113
}
106-
else
114+
else if( end[i] < start[i] )
107115
{
108116
deltas[i] = start[i] - end[i];
109117
increments[i] = -1;
@@ -176,9 +184,9 @@ namespace
176184
std::array< int, dimension > increments;
177185
std::tie( deltas, increments ) =
178186
compute_deltas< dimension >( start, end );
179-
const auto i = get_major_axis< dimension >( deltas );
187+
const auto major_axis = get_major_axis< dimension >( deltas );
180188
return paint_segment_axis< dimension >(
181-
i, deltas, increments, start, end );
189+
major_axis, deltas, increments, start, end );
182190
}
183191

184192
std::vector< CellIndices< 2 > > conservative_voxelization_triangle(
@@ -446,39 +454,56 @@ namespace
446454
return cells;
447455
}
448456

449-
absl::InlinedVector< CellIndices< 3 >, 6 > neighbors(
450-
const geode::Grid3D& grid, const CellIndices< 3 >& cell )
457+
void add_neighbors_to_queue( const geode::Grid3D& grid,
458+
const CellIndices< 3 >& cell,
459+
std::queue< CellIndices< 3 > >& cells_queue,
460+
const CellIndices< 3 >& min,
461+
const CellIndices< 3 >& max )
451462
{
452-
absl::InlinedVector< CellIndices< 3 >, 6 > neighbors;
453-
for( const auto d : geode::LRange{ 3 } )
463+
for( const auto axis : geode::LRange{ 3 } )
454464
{
455-
if( const auto prev = grid.previous_cell( cell, d ) )
465+
if( const auto prev = grid.previous_cell( cell, axis ) )
456466
{
457-
neighbors.push_back( prev.value() );
467+
if( prev.value()[axis] >= min[axis] )
468+
{
469+
cells_queue.emplace( prev.value() );
470+
}
458471
}
459-
if( const auto next = grid.next_cell( cell, d ) )
472+
if( const auto next = grid.next_cell( cell, axis ) )
460473
{
461-
neighbors.push_back( next.value() );
474+
if( next.value()[axis] <= max[axis] )
475+
{
476+
cells_queue.emplace( next.value() );
477+
}
462478
}
463479
}
464-
return neighbors;
465480
}
466481

467482
std::vector< CellIndices< 3 > > conservative_voxelization_segment(
468483
const geode::Grid3D& grid,
469484
const geode::Segment3D& segment,
470-
const std::array< geode::Grid3D::CellsAroundVertex, 2 > /*unused*/ )
485+
const std::array< geode::Grid3D::CellsAroundVertex, 2 > vertex_cells )
471486
{
472487
auto cells = geode::rasterize_segment( grid, segment );
473488
std::vector< bool > tested_cells( grid.nb_cells(), false );
489+
auto min = grid.cell_indices( grid.nb_cells() - 1 );
490+
auto max = grid.cell_indices( 0 );
491+
for( const auto vertex_id : geode::LRange{ 2 } )
492+
{
493+
for( const auto& cell_indices : vertex_cells[vertex_id] )
494+
{
495+
for( const auto axis : geode::LRange{ 3 } )
496+
{
497+
max[axis] = std::max( max[axis], cell_indices[axis] );
498+
min[axis] = std::min( min[axis], cell_indices[axis] );
499+
}
500+
}
501+
}
474502
std::queue< CellIndices< 3 > > to_test;
475503
for( const auto& cell : cells )
476504
{
477505
tested_cells[grid.cell_index( cell )] = true;
478-
for( auto&& neighbor : neighbors( grid, cell ) )
479-
{
480-
to_test.emplace( std::move( neighbor ) );
481-
}
506+
add_neighbors_to_queue( grid, cell, to_test, min, max );
482507
}
483508
const auto half_cell_size =
484509
std::sqrt( grid.cell_length_in_direction( 0 )
@@ -502,10 +527,7 @@ namespace
502527
if( geode::point_segment_distance( center, segment )
503528
<= half_cell_size )
504529
{
505-
for( auto&& neighbor : neighbors( grid, cell ) )
506-
{
507-
to_test.emplace( std::move( neighbor ) );
508-
}
530+
add_neighbors_to_queue( grid, cell, to_test, min, max );
509531
cells.emplace_back( std::move( cell ) );
510532
}
511533
}

tests/mesh/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,6 @@ add_geode_test(
233233
${PROJECT_NAME}::geometry
234234
${PROJECT_NAME}::mesh
235235
)
236-
add_geode_test(
237-
SOURCE "test-remove-vertex-duplication.cpp"
238-
DEPENDENCIES
239-
${PROJECT_NAME}::basic
240-
${PROJECT_NAME}::geometry
241-
${PROJECT_NAME}::mesh
242-
)
243236
add_geode_test(
244237
SOURCE "test-tetrahedral-solid.cpp"
245238
DEPENDENCIES

tests/mesh/test-merge-curve.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include <geode/mesh/builder/edged_curve_builder.hpp>
3232
#include <geode/mesh/core/edged_curve.hpp>
33-
#include <geode/mesh/helpers/convert_edged_curve.hpp>
33+
#include <geode/mesh/helpers/detail/curve_merger.hpp>
3434

3535
std::vector< std::unique_ptr< geode::EdgedCurve2D > > create_curves()
3636
{
@@ -81,8 +81,9 @@ void test()
8181
geode::OpenGeodeMeshLibrary::initialize();
8282

8383
const auto curves = create_curves();
84-
const auto merged = geode::merge_edged_curves< 2 >(
85-
{ *curves[0], *curves[1], *curves[2] } );
84+
geode::detail::EdgedCurveMerger2D merger{ { *curves[0], *curves[1],
85+
*curves[2] } };
86+
const auto merged = merger.merge( geode::GLOBAL_EPSILON );
8687
OPENGEODE_EXCEPTION(
8788
merged->nb_vertices() == 8, "[Test] Wrong number of vertices" );
8889
OPENGEODE_EXCEPTION(

tests/mesh/test-merge-solid.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include <geode/mesh/builder/solid_mesh_builder.hpp>
3232
#include <geode/mesh/core/solid_mesh.hpp>
33-
#include <geode/mesh/helpers/convert_solid_mesh.hpp>
33+
#include <geode/mesh/helpers/detail/solid_merger.hpp>
3434

3535
void test()
3636
{
@@ -87,7 +87,8 @@ void test()
8787
std::vector< std::reference_wrapper< const geode::SolidMesh3D > > meshes{
8888
*mesh0, *mesh1
8989
};
90-
const auto merged = geode::merge_solid_meshes( meshes );
90+
geode::detail::SolidMeshMerger3D merger{ meshes };
91+
const auto merged = merger.merge( geode::GLOBAL_EPSILON );
9192
OPENGEODE_EXCEPTION(
9293
merged->nb_vertices() == 10, "[Test] Wrong number of vertices" );
9394
OPENGEODE_EXCEPTION(

tests/mesh/test-merge-surface.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <geode/mesh/builder/surface_mesh_builder.hpp>
3535
#include <geode/mesh/core/surface_mesh.hpp>
3636
#include <geode/mesh/core/triangulated_surface.hpp>
37-
#include <geode/mesh/helpers/convert_surface_mesh.hpp>
37+
#include <geode/mesh/helpers/detail/surface_merger.hpp>
3838
#include <geode/mesh/io/triangulated_surface_input.hpp>
3939
#include <geode/mesh/io/triangulated_surface_output.hpp>
4040

@@ -74,7 +74,8 @@ void test_create()
7474
std::vector< std::reference_wrapper< const geode::SurfaceMesh2D > > meshes{
7575
*mesh0, *mesh1
7676
};
77-
const auto merged = geode::merge_surface_meshes< 2 >( meshes );
77+
geode::detail::SurfaceMeshMerger2D merger{ meshes };
78+
const auto merged = merger.merge( geode::GLOBAL_EPSILON );
7879
OPENGEODE_EXCEPTION(
7980
merged->nb_vertices() == 6, "[Test] Wrong number of vertices" );
8081
OPENGEODE_EXCEPTION(
@@ -124,7 +125,8 @@ void test_import()
124125
std::vector< std::reference_wrapper< const geode::SurfaceMesh3D > > meshes{
125126
*surface
126127
};
127-
const auto merged = geode::merge_surface_meshes< 3 >( meshes );
128+
geode::detail::SurfaceMeshMerger3D merger{ meshes };
129+
const auto merged = merger.merge( geode::GLOBAL_EPSILON );
128130
geode::save_triangulated_surface(
129131
*dynamic_cast< geode::TriangulatedSurface3D* >( merged.get() ),
130132
"output.og_tsf3d" );

0 commit comments

Comments
 (0)