Skip to content

Commit

Permalink
Merge pull request #944 from Geode-solutions/pointsetmerger
Browse files Browse the repository at this point in the history
feat(MeshHelpers): add PointSetMerger class.
  • Loading branch information
panquez authored Jul 1, 2024
2 parents 6d3bf35 + 54fa727 commit b0ac5be
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 1 deletion.
53 changes: 53 additions & 0 deletions include/geode/mesh/helpers/detail/point_set_merger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2019 - 2024 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#pragma once

#include <absl/types/span.h>

#include <geode/mesh/common.h>
#include <geode/mesh/helpers/detail/vertex_merger.h>

namespace geode
{
FORWARD_DECLARATION_DIMENSION_CLASS( PointSet );
} // namespace geode

namespace geode
{
namespace detail
{
template < index_t dimension >
class PointSetMerger : public VertexMerger< PointSet< dimension > >
{
public:
PointSetMerger( absl::Span< const std::reference_wrapper<
const PointSet< dimension > > > pointsets,
double epsilon );
~PointSetMerger();

std::unique_ptr< PointSet< dimension > > merge();
};
ALIAS_2D_AND_3D( PointSetMerger );
} // namespace detail
} // namespace geode
4 changes: 3 additions & 1 deletion src/geode/mesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ add_geode_library(
"helpers/detail/curve_merger.cpp"
"helpers/detail/split_along_solid_facets.cpp"
"helpers/detail/debug.cpp"
"helpers/detail/element_identifier.cpp"
"helpers/detail/element_identifier.cpp"
"helpers/detail/point_set_merger.cpp"
"helpers/detail/solid_merger.cpp"
"helpers/detail/surface_merger.cpp"
"helpers/detail/vertex_merger.cpp"
Expand Down Expand Up @@ -306,6 +307,7 @@ add_geode_library(
"helpers/detail/create_mesh.h"
"helpers/detail/debug.h"
"helpers/detail/element_identifier.h"
"helpers/detail/point_set_merger.h"
"helpers/detail/solid_merger.h"
"helpers/detail/surface_merger.h"
"helpers/detail/vertex_merger.h"
Expand Down
5 changes: 5 additions & 0 deletions src/geode/mesh/helpers/detail/create_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <geode/mesh/core/edged_curve.h>
#include <geode/mesh/core/mesh_factory.h>
#include <geode/mesh/core/point_set.h>
#include <geode/mesh/core/solid_mesh.h>
#include <geode/mesh/core/surface_mesh.h>

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

template std::unique_ptr< PointSet2D > opengeode_mesh_api create_mesh(
absl::Span< const std::reference_wrapper< const PointSet2D > > );
template std::unique_ptr< EdgedCurve2D > opengeode_mesh_api create_mesh(
absl::Span< const std::reference_wrapper< const EdgedCurve2D > > );
template std::unique_ptr< SurfaceMesh2D >
opengeode_mesh_api create_mesh( absl::Span<
const std::reference_wrapper< const SurfaceMesh2D > > );
template std::unique_ptr< PointSet3D > opengeode_mesh_api create_mesh(
absl::Span< const std::reference_wrapper< const PointSet3D > > );
template std::unique_ptr< EdgedCurve3D > opengeode_mesh_api create_mesh(
absl::Span< const std::reference_wrapper< const EdgedCurve3D > > );
template std::unique_ptr< SurfaceMesh3D >
Expand Down
55 changes: 55 additions & 0 deletions src/geode/mesh/helpers/detail/point_set_merger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2019 - 2024 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#include <geode/mesh/helpers/detail/point_set_merger.h>

#include <geode/mesh/core/point_set.h>

namespace geode
{
namespace detail
{
template < index_t dimension >
PointSetMerger< dimension >::PointSetMerger(
absl::Span< const std::reference_wrapper<
const PointSet< dimension > > > pointsets,
double epsilon )
: VertexMerger< PointSet< dimension > >{ pointsets, epsilon }
{
}

template < index_t dimension >
PointSetMerger< dimension >::~PointSetMerger() = default;

template < index_t dimension >
std::unique_ptr< PointSet< dimension > >
PointSetMerger< dimension >::merge()
{
this->create_points();
return this->steal_mesh();
}

template class opengeode_mesh_api PointSetMerger< 2 >;
template class opengeode_mesh_api PointSetMerger< 3 >;
} // namespace detail
} // namespace geode
5 changes: 5 additions & 0 deletions src/geode/mesh/helpers/detail/vertex_merger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
#include <geode/geometry/point.h>

#include <geode/mesh/builder/edged_curve_builder.h>
#include <geode/mesh/builder/point_set_builder.h>
#include <geode/mesh/builder/solid_mesh_builder.h>
#include <geode/mesh/builder/surface_mesh_builder.h>
#include <geode/mesh/core/edged_curve.h>
#include <geode/mesh/core/mesh_factory.h>
#include <geode/mesh/core/point_set.h>
#include <geode/mesh/core/solid_mesh.h>
#include <geode/mesh/core/surface_mesh.h>
#include <geode/mesh/helpers/detail/create_mesh.h>
Expand Down Expand Up @@ -215,6 +217,9 @@ namespace geode
impl_->create_points();
}

template class opengeode_mesh_api VertexMerger< PointSet2D >;
template class opengeode_mesh_api VertexMerger< PointSet3D >;

template class opengeode_mesh_api VertexMerger< EdgedCurve2D >;
template class opengeode_mesh_api VertexMerger< EdgedCurve3D >;

Expand Down

0 comments on commit b0ac5be

Please sign in to comment.