Skip to content

Commit b0ac5be

Browse files
authored
Merge pull request #944 from Geode-solutions/pointsetmerger
feat(MeshHelpers): add PointSetMerger class.
2 parents 6d3bf35 + 54fa727 commit b0ac5be

File tree

5 files changed

+121
-1
lines changed

5 files changed

+121
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2019 - 2024 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#pragma once
25+
26+
#include <absl/types/span.h>
27+
28+
#include <geode/mesh/common.h>
29+
#include <geode/mesh/helpers/detail/vertex_merger.h>
30+
31+
namespace geode
32+
{
33+
FORWARD_DECLARATION_DIMENSION_CLASS( PointSet );
34+
} // namespace geode
35+
36+
namespace geode
37+
{
38+
namespace detail
39+
{
40+
template < index_t dimension >
41+
class PointSetMerger : public VertexMerger< PointSet< dimension > >
42+
{
43+
public:
44+
PointSetMerger( absl::Span< const std::reference_wrapper<
45+
const PointSet< dimension > > > pointsets,
46+
double epsilon );
47+
~PointSetMerger();
48+
49+
std::unique_ptr< PointSet< dimension > > merge();
50+
};
51+
ALIAS_2D_AND_3D( PointSetMerger );
52+
} // namespace detail
53+
} // namespace geode

src/geode/mesh/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ add_geode_library(
120120
"helpers/detail/curve_merger.cpp"
121121
"helpers/detail/split_along_solid_facets.cpp"
122122
"helpers/detail/debug.cpp"
123-
"helpers/detail/element_identifier.cpp"
123+
"helpers/detail/element_identifier.cpp"
124+
"helpers/detail/point_set_merger.cpp"
124125
"helpers/detail/solid_merger.cpp"
125126
"helpers/detail/surface_merger.cpp"
126127
"helpers/detail/vertex_merger.cpp"
@@ -306,6 +307,7 @@ add_geode_library(
306307
"helpers/detail/create_mesh.h"
307308
"helpers/detail/debug.h"
308309
"helpers/detail/element_identifier.h"
310+
"helpers/detail/point_set_merger.h"
309311
"helpers/detail/solid_merger.h"
310312
"helpers/detail/surface_merger.h"
311313
"helpers/detail/vertex_merger.h"

src/geode/mesh/helpers/detail/create_mesh.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <geode/mesh/core/edged_curve.h>
3131
#include <geode/mesh/core/mesh_factory.h>
32+
#include <geode/mesh/core/point_set.h>
3233
#include <geode/mesh/core/solid_mesh.h>
3334
#include <geode/mesh/core/surface_mesh.h>
3435

@@ -55,11 +56,15 @@ namespace geode
5556
return Mesh::create( geode::MeshFactory::default_impl( type ) );
5657
}
5758

59+
template std::unique_ptr< PointSet2D > opengeode_mesh_api create_mesh(
60+
absl::Span< const std::reference_wrapper< const PointSet2D > > );
5861
template std::unique_ptr< EdgedCurve2D > opengeode_mesh_api create_mesh(
5962
absl::Span< const std::reference_wrapper< const EdgedCurve2D > > );
6063
template std::unique_ptr< SurfaceMesh2D >
6164
opengeode_mesh_api create_mesh( absl::Span<
6265
const std::reference_wrapper< const SurfaceMesh2D > > );
66+
template std::unique_ptr< PointSet3D > opengeode_mesh_api create_mesh(
67+
absl::Span< const std::reference_wrapper< const PointSet3D > > );
6368
template std::unique_ptr< EdgedCurve3D > opengeode_mesh_api create_mesh(
6469
absl::Span< const std::reference_wrapper< const EdgedCurve3D > > );
6570
template std::unique_ptr< SurfaceMesh3D >
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2019 - 2024 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#include <geode/mesh/helpers/detail/point_set_merger.h>
25+
26+
#include <geode/mesh/core/point_set.h>
27+
28+
namespace geode
29+
{
30+
namespace detail
31+
{
32+
template < index_t dimension >
33+
PointSetMerger< dimension >::PointSetMerger(
34+
absl::Span< const std::reference_wrapper<
35+
const PointSet< dimension > > > pointsets,
36+
double epsilon )
37+
: VertexMerger< PointSet< dimension > >{ pointsets, epsilon }
38+
{
39+
}
40+
41+
template < index_t dimension >
42+
PointSetMerger< dimension >::~PointSetMerger() = default;
43+
44+
template < index_t dimension >
45+
std::unique_ptr< PointSet< dimension > >
46+
PointSetMerger< dimension >::merge()
47+
{
48+
this->create_points();
49+
return this->steal_mesh();
50+
}
51+
52+
template class opengeode_mesh_api PointSetMerger< 2 >;
53+
template class opengeode_mesh_api PointSetMerger< 3 >;
54+
} // namespace detail
55+
} // namespace geode

src/geode/mesh/helpers/detail/vertex_merger.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
#include <geode/geometry/point.h>
3030

3131
#include <geode/mesh/builder/edged_curve_builder.h>
32+
#include <geode/mesh/builder/point_set_builder.h>
3233
#include <geode/mesh/builder/solid_mesh_builder.h>
3334
#include <geode/mesh/builder/surface_mesh_builder.h>
3435
#include <geode/mesh/core/edged_curve.h>
3536
#include <geode/mesh/core/mesh_factory.h>
37+
#include <geode/mesh/core/point_set.h>
3638
#include <geode/mesh/core/solid_mesh.h>
3739
#include <geode/mesh/core/surface_mesh.h>
3840
#include <geode/mesh/helpers/detail/create_mesh.h>
@@ -215,6 +217,9 @@ namespace geode
215217
impl_->create_points();
216218
}
217219

220+
template class opengeode_mesh_api VertexMerger< PointSet2D >;
221+
template class opengeode_mesh_api VertexMerger< PointSet3D >;
222+
218223
template class opengeode_mesh_api VertexMerger< EdgedCurve2D >;
219224
template class opengeode_mesh_api VertexMerger< EdgedCurve3D >;
220225

0 commit comments

Comments
 (0)