From bfd35330cb18bfbed11ce6fe396321f048bd8179 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Wed, 9 Oct 2024 16:42:18 +0200 Subject: [PATCH 1/4] fix(Mapping): missing default constructors --- include/geode/basic/mapping.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/geode/basic/mapping.hpp b/include/geode/basic/mapping.hpp index 982ae9a8b..9ba0fbfd9 100644 --- a/include/geode/basic/mapping.hpp +++ b/include/geode/basic/mapping.hpp @@ -126,6 +126,10 @@ namespace geode class BijectiveMapping : public MappingBase< T1, T2, OneValueStorage > { public: + BijectiveMapping() = default; + BijectiveMapping( BijectiveMapping&& other ) = default; + BijectiveMapping& operator=( BijectiveMapping&& other ) = default; + void map( const T1& in, const T2& out ) { if( this->has_mapping_input( in ) ) @@ -184,6 +188,10 @@ namespace geode class GenericMapping : public MappingBase< T1, T2, MultipleValueStorage > { public: + GenericMapping() = default; + GenericMapping( GenericMapping&& other ) = default; + GenericMapping& operator=( GenericMapping&& other ) = default; + void map( const T1& in, const T2& out ) { this->in2out_mapping()[in].push_back( out ); From 3afa3e7656cecf225d1a671dcaa8d666c8d3e930 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Fri, 3 Jan 2025 10:56:20 +0100 Subject: [PATCH 2/4] fix(EdgedCurve): export 1D implemetation --- include/geode/mesh/builder/edged_curve_builder.hpp | 2 +- include/geode/mesh/core/edged_curve.hpp | 2 +- include/geode/mesh/core/geode/geode_edged_curve.hpp | 2 +- src/geode/mesh/builder/edged_curve_builder.cpp | 1 + src/geode/mesh/core/edged_curve.cpp | 2 ++ src/geode/mesh/core/geode/geode_edged_curve.cpp | 2 ++ 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/geode/mesh/builder/edged_curve_builder.hpp b/include/geode/mesh/builder/edged_curve_builder.hpp index 955d7a152..239b5b851 100644 --- a/include/geode/mesh/builder/edged_curve_builder.hpp +++ b/include/geode/mesh/builder/edged_curve_builder.hpp @@ -71,5 +71,5 @@ namespace geode private: EdgedCurve< dimension >& edged_curve_; }; - ALIAS_2D_AND_3D( EdgedCurveBuilder ); + ALIAS_1D_AND_2D_AND_3D( EdgedCurveBuilder ); } // namespace geode diff --git a/include/geode/mesh/core/edged_curve.hpp b/include/geode/mesh/core/edged_curve.hpp index 43ebf8170..23efe8755 100644 --- a/include/geode/mesh/core/edged_curve.hpp +++ b/include/geode/mesh/core/edged_curve.hpp @@ -94,5 +94,5 @@ namespace geode private: IMPLEMENTATION_MEMBER( impl_ ); }; - ALIAS_2D_AND_3D( EdgedCurve ); + ALIAS_1D_AND_2D_AND_3D( EdgedCurve ); } // namespace geode diff --git a/include/geode/mesh/core/geode/geode_edged_curve.hpp b/include/geode/mesh/core/geode/geode_edged_curve.hpp index 7fd499d83..ee3360448 100644 --- a/include/geode/mesh/core/geode/geode_edged_curve.hpp +++ b/include/geode/mesh/core/geode/geode_edged_curve.hpp @@ -98,5 +98,5 @@ namespace geode private: IMPLEMENTATION_MEMBER( impl_ ); }; - ALIAS_2D_AND_3D( OpenGeodeEdgedCurve ); + ALIAS_1D_AND_2D_AND_3D( OpenGeodeEdgedCurve ); } // namespace geode diff --git a/src/geode/mesh/builder/edged_curve_builder.cpp b/src/geode/mesh/builder/edged_curve_builder.cpp index 511800ec2..558e5da85 100644 --- a/src/geode/mesh/builder/edged_curve_builder.cpp +++ b/src/geode/mesh/builder/edged_curve_builder.cpp @@ -79,6 +79,7 @@ namespace geode } } + template class opengeode_mesh_api EdgedCurveBuilder< 1 >; template class opengeode_mesh_api EdgedCurveBuilder< 2 >; template class opengeode_mesh_api EdgedCurveBuilder< 3 >; } // namespace geode diff --git a/src/geode/mesh/core/edged_curve.cpp b/src/geode/mesh/core/edged_curve.cpp index 32d6bf323..bca39ee4b 100644 --- a/src/geode/mesh/core/edged_curve.cpp +++ b/src/geode/mesh/core/edged_curve.cpp @@ -180,9 +180,11 @@ namespace geode return impl_->texture_manager( *this ); } + template class opengeode_mesh_api EdgedCurve< 1 >; template class opengeode_mesh_api EdgedCurve< 2 >; template class opengeode_mesh_api EdgedCurve< 3 >; + SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, EdgedCurve< 1 > ); SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, EdgedCurve< 2 > ); SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, EdgedCurve< 3 > ); } // namespace geode diff --git a/src/geode/mesh/core/geode/geode_edged_curve.cpp b/src/geode/mesh/core/geode/geode_edged_curve.cpp index 4c20a672a..15bdb912a 100644 --- a/src/geode/mesh/core/geode/geode_edged_curve.cpp +++ b/src/geode/mesh/core/geode/geode_edged_curve.cpp @@ -124,9 +124,11 @@ namespace geode } } } ); } + template class opengeode_mesh_api OpenGeodeEdgedCurve< 1 >; template class opengeode_mesh_api OpenGeodeEdgedCurve< 2 >; template class opengeode_mesh_api OpenGeodeEdgedCurve< 3 >; + SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, OpenGeodeEdgedCurve< 1 > ); SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, OpenGeodeEdgedCurve< 2 > ); SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, OpenGeodeEdgedCurve< 3 > ); } // namespace geode From 7e951ef44f7844811baf1f7c25b3f12f0e7059f8 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Fri, 3 Jan 2025 17:07:40 +0100 Subject: [PATCH 3/4] update --- src/geode/geometry/position.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/geode/geometry/position.cpp b/src/geode/geometry/position.cpp index 1759bf6f4..8ceb818bf 100644 --- a/src/geode/geometry/position.cpp +++ b/src/geode/geometry/position.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,25 @@ namespace geode internal::side( dot0 ), internal::opposite_side( dot1 ) ); } + POSITION point_segment_position_exact( + const Point1D& point, const Segment1D& segment ) + { + const auto& vertices = segment.vertices(); + if( point == vertices[0] ) + { + return POSITION::vertex0; + } + if( point == vertices[1] ) + { + return POSITION::vertex1; + } + if( segment.bounding_box().contains( point ) ) + { + return POSITION::inside; + } + return POSITION::outside; + } + template < index_t dimension > POSITION point_triangle_position_all_zero( const Point< dimension >& point, const Triangle< dimension >& triangle ) @@ -305,9 +325,10 @@ namespace geode return GEO::PCK::aligned_3d( point0, point1, point2 ); } + template POSITION opengeode_geometry_api point_segment_position( + const Point1D&, const Segment1D& ); template POSITION opengeode_geometry_api point_segment_position( const Point2D&, const Segment2D& ); - template POSITION opengeode_geometry_api point_segment_position( const Point3D&, const Segment3D& ); } // namespace geode From e55e2a89c6583fa349412b11af3ccdd31b1df66c Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Tue, 7 Jan 2025 20:43:20 +0100 Subject: [PATCH 4/4] more 1D --- .../geometry/basic_objects/infinite_line.hpp | 1 + .../builder/geode/geode_point_set_builder.hpp | 2 +- .../geode/mesh/builder/point_set_builder.hpp | 4 +--- .../geode/mesh/core/geode/geode_point_set.hpp | 2 +- include/geode/mesh/core/point_set.hpp | 4 +--- include/geode/mesh/helpers/detail/debug.hpp | 6 ++++++ .../geometry/basic_objects/infinite_line.cpp | 10 +++++++++ .../builder/geode/geode_point_set_builder.cpp | 1 + src/geode/mesh/builder/point_set_builder.cpp | 1 + src/geode/mesh/builder/register_builder.cpp | 5 +++++ src/geode/mesh/core/geode/geode_point_set.cpp | 2 ++ src/geode/mesh/core/point_set.cpp | 2 ++ src/geode/mesh/core/register_mesh.cpp | 6 ++++++ src/geode/mesh/helpers/detail/debug.cpp | 21 +++++++++++++++++++ 14 files changed, 59 insertions(+), 8 deletions(-) diff --git a/include/geode/geometry/basic_objects/infinite_line.hpp b/include/geode/geometry/basic_objects/infinite_line.hpp index df271a2db..0ec99399a 100644 --- a/include/geode/geometry/basic_objects/infinite_line.hpp +++ b/include/geode/geometry/basic_objects/infinite_line.hpp @@ -54,6 +54,7 @@ namespace geode [[nodiscard]] const Point< dimension >& origin() const; [[nodiscard]] const Vector< dimension >& direction() const; + [[nodiscard]] double line_constant() const; private: Vector< dimension > direction_; diff --git a/include/geode/mesh/builder/geode/geode_point_set_builder.hpp b/include/geode/mesh/builder/geode/geode_point_set_builder.hpp index be1885308..7bdf4548b 100644 --- a/include/geode/mesh/builder/geode/geode_point_set_builder.hpp +++ b/include/geode/mesh/builder/geode/geode_point_set_builder.hpp @@ -68,5 +68,5 @@ namespace geode private: OpenGeodePointSet< dimension >& geode_point_set_; }; - ALIAS_2D_AND_3D( OpenGeodePointSetBuilder ); + ALIAS_1D_AND_2D_AND_3D( OpenGeodePointSetBuilder ); } // namespace geode diff --git a/include/geode/mesh/builder/point_set_builder.hpp b/include/geode/mesh/builder/point_set_builder.hpp index ef35e856e..f4c5b9ad6 100644 --- a/include/geode/mesh/builder/point_set_builder.hpp +++ b/include/geode/mesh/builder/point_set_builder.hpp @@ -45,8 +45,6 @@ namespace geode : public VertexSetBuilder, public CoordinateReferenceSystemManagersBuilder< dimension > { - OPENGEODE_TEMPLATE_ASSERT_2D_OR_3D( dimension ); - public: static constexpr auto dim = dimension; @@ -75,5 +73,5 @@ namespace geode private: PointSet< dimension >& point_set_; }; - ALIAS_2D_AND_3D( PointSetBuilder ); + ALIAS_1D_AND_2D_AND_3D( PointSetBuilder ); } // namespace geode diff --git a/include/geode/mesh/core/geode/geode_point_set.hpp b/include/geode/mesh/core/geode/geode_point_set.hpp index c6096d730..17e29e979 100644 --- a/include/geode/mesh/core/geode/geode_point_set.hpp +++ b/include/geode/mesh/core/geode/geode_point_set.hpp @@ -94,5 +94,5 @@ namespace geode private: IMPLEMENTATION_MEMBER( impl_ ); }; - ALIAS_2D_AND_3D( OpenGeodePointSet ); + ALIAS_1D_AND_2D_AND_3D( OpenGeodePointSet ); } // namespace geode diff --git a/include/geode/mesh/core/point_set.hpp b/include/geode/mesh/core/point_set.hpp index 251e155c8..e422f0987 100644 --- a/include/geode/mesh/core/point_set.hpp +++ b/include/geode/mesh/core/point_set.hpp @@ -46,8 +46,6 @@ namespace geode class PointSet : public VertexSet, public CoordinateReferenceSystemManagers< dimension > { - OPENGEODE_TEMPLATE_ASSERT_2D_OR_3D( dimension ); - public: using Builder = PointSetBuilder< dimension >; static constexpr auto dim = dimension; @@ -83,5 +81,5 @@ namespace geode template < typename Archive > void serialize( Archive& archive ); }; - ALIAS_2D_AND_3D( PointSet ); + ALIAS_1D_AND_2D_AND_3D( PointSet ); } // namespace geode diff --git a/include/geode/mesh/helpers/detail/debug.hpp b/include/geode/mesh/helpers/detail/debug.hpp index 377687839..e947c47e0 100644 --- a/include/geode/mesh/helpers/detail/debug.hpp +++ b/include/geode/mesh/helpers/detail/debug.hpp @@ -34,6 +34,7 @@ namespace geode FORWARD_DECLARATION_DIMENSION_CLASS( Segment ); FORWARD_DECLARATION_DIMENSION_CLASS( Triangle ); FORWARD_DECLARATION_DIMENSION_CLASS( TetrahedralSolid ); + FORWARD_DECLARATION_DIMENSION_CLASS( TriangulatedSurface ); ALIAS_3D( TetrahedralSolid ); class Tetrahedron; } // namespace geode @@ -50,6 +51,11 @@ namespace geode void save_triangle( const Triangle< dimension >& triangle, std::string_view suffix ); + template < index_t dimension > + void save_triangles( const TriangulatedSurface< dimension >& surface, + absl::Span< const index_t > indices, + std::string_view suffix ); + void opengeode_mesh_api save_tetrahedron( const Tetrahedron& tetrahedron, std::string_view suffix ); diff --git a/src/geode/geometry/basic_objects/infinite_line.cpp b/src/geode/geometry/basic_objects/infinite_line.cpp index 5b91b9309..6fd299bb1 100644 --- a/src/geode/geometry/basic_objects/infinite_line.cpp +++ b/src/geode/geometry/basic_objects/infinite_line.cpp @@ -67,6 +67,16 @@ namespace geode { return direction_; } + template < typename PointType, index_t dimension > + double GenericLine< PointType, dimension >::line_constant() const + { + double line_constant{ 0.0 }; + for( const auto i : LRange{ 2 } ) + { + line_constant -= origin().value( i ) * direction().value( i ); + } + return line_constant; + } template < index_t dimension > OwnerInfiniteLine< dimension >::OwnerInfiniteLine( diff --git a/src/geode/mesh/builder/geode/geode_point_set_builder.cpp b/src/geode/mesh/builder/geode/geode_point_set_builder.cpp index de2368ded..73607a7fb 100644 --- a/src/geode/mesh/builder/geode/geode_point_set_builder.cpp +++ b/src/geode/mesh/builder/geode/geode_point_set_builder.cpp @@ -81,6 +81,7 @@ namespace geode // Operation is directly handled by the AttributeManager } + template class opengeode_mesh_api OpenGeodePointSetBuilder< 1 >; template class opengeode_mesh_api OpenGeodePointSetBuilder< 2 >; template class opengeode_mesh_api OpenGeodePointSetBuilder< 3 >; } // namespace geode diff --git a/src/geode/mesh/builder/point_set_builder.cpp b/src/geode/mesh/builder/point_set_builder.cpp index d003be04f..993176957 100644 --- a/src/geode/mesh/builder/point_set_builder.cpp +++ b/src/geode/mesh/builder/point_set_builder.cpp @@ -77,6 +77,7 @@ namespace geode } } + template class opengeode_mesh_api PointSetBuilder< 1 >; template class opengeode_mesh_api PointSetBuilder< 2 >; template class opengeode_mesh_api PointSetBuilder< 3 >; } // namespace geode diff --git a/src/geode/mesh/builder/register_builder.cpp b/src/geode/mesh/builder/register_builder.cpp index 39120dbb5..16bff3af3 100644 --- a/src/geode/mesh/builder/register_builder.cpp +++ b/src/geode/mesh/builder/register_builder.cpp @@ -57,11 +57,16 @@ namespace geode MeshBuilderFactory::register_mesh_builder< OpenGeodeGraphBuilder >( OpenGeodeGraph::impl_name_static() ); + MeshBuilderFactory::register_mesh_builder< OpenGeodePointSetBuilder1D >( + OpenGeodePointSet1D::impl_name_static() ); MeshBuilderFactory::register_mesh_builder< OpenGeodePointSetBuilder2D >( OpenGeodePointSet2D::impl_name_static() ); MeshBuilderFactory::register_mesh_builder< OpenGeodePointSetBuilder3D >( OpenGeodePointSet3D::impl_name_static() ); + MeshBuilderFactory::register_mesh_builder< + OpenGeodeEdgedCurveBuilder1D >( + OpenGeodeEdgedCurve1D::impl_name_static() ); MeshBuilderFactory::register_mesh_builder< OpenGeodeEdgedCurveBuilder2D >( OpenGeodeEdgedCurve2D::impl_name_static() ); diff --git a/src/geode/mesh/core/geode/geode_point_set.cpp b/src/geode/mesh/core/geode/geode_point_set.cpp index 84bb5a04d..517dcea0f 100644 --- a/src/geode/mesh/core/geode/geode_point_set.cpp +++ b/src/geode/mesh/core/geode/geode_point_set.cpp @@ -102,9 +102,11 @@ namespace geode } } } ); } + template class opengeode_mesh_api OpenGeodePointSet< 1 >; template class opengeode_mesh_api OpenGeodePointSet< 2 >; template class opengeode_mesh_api OpenGeodePointSet< 3 >; + SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, OpenGeodePointSet< 1 > ); SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, OpenGeodePointSet< 2 > ); SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, OpenGeodePointSet< 3 > ); } // namespace geode diff --git a/src/geode/mesh/core/point_set.cpp b/src/geode/mesh/core/point_set.cpp index 7e56e2c0f..d2d3ebb2c 100644 --- a/src/geode/mesh/core/point_set.cpp +++ b/src/geode/mesh/core/point_set.cpp @@ -94,9 +94,11 @@ namespace geode return box; } + template class opengeode_mesh_api PointSet< 1 >; template class opengeode_mesh_api PointSet< 2 >; template class opengeode_mesh_api PointSet< 3 >; + SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, PointSet< 1 > ); SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, PointSet< 2 > ); SERIALIZE_BITSERY_ARCHIVE( opengeode_mesh_api, PointSet< 3 > ); } // namespace geode diff --git a/src/geode/mesh/core/register_mesh.cpp b/src/geode/mesh/core/register_mesh.cpp index 1b8988e1f..f41601712 100644 --- a/src/geode/mesh/core/register_mesh.cpp +++ b/src/geode/mesh/core/register_mesh.cpp @@ -47,6 +47,9 @@ namespace geode MeshFactory::register_default_mesh< OpenGeodeGraph >( Graph::type_name_static(), OpenGeodeGraph::impl_name_static() ); + MeshFactory::register_default_mesh< OpenGeodePointSet1D >( + PointSet1D::type_name_static(), + OpenGeodePointSet1D::impl_name_static() ); MeshFactory::register_default_mesh< OpenGeodePointSet2D >( PointSet2D::type_name_static(), OpenGeodePointSet2D::impl_name_static() ); @@ -54,6 +57,9 @@ namespace geode PointSet3D::type_name_static(), OpenGeodePointSet3D::impl_name_static() ); + MeshFactory::register_default_mesh< OpenGeodeEdgedCurve1D >( + EdgedCurve1D::type_name_static(), + OpenGeodeEdgedCurve1D::impl_name_static() ); MeshFactory::register_default_mesh< OpenGeodeEdgedCurve2D >( EdgedCurve2D::type_name_static(), OpenGeodeEdgedCurve2D::impl_name_static() ); diff --git a/src/geode/mesh/helpers/detail/debug.cpp b/src/geode/mesh/helpers/detail/debug.cpp index d1bc90e1a..9891ffcd8 100644 --- a/src/geode/mesh/helpers/detail/debug.cpp +++ b/src/geode/mesh/helpers/detail/debug.cpp @@ -77,6 +77,18 @@ namespace geode dimension, "d" ) ); } + template < index_t dimension > + void save_triangles( const TriangulatedSurface< dimension >& surface, + absl::Span< const index_t > indices, + std::string_view suffix ) + { + for( const auto index : indices ) + { + save_triangle( surface.triangle( index ), + absl::StrCat( index, "_", suffix ) ); + } + } + void save_tetrahedron( const Tetrahedron& tetrahedron, std::string_view suffix ) { @@ -116,5 +128,14 @@ namespace geode const Triangle< 2 >&, std::string_view ); template void opengeode_mesh_api save_triangle( const Triangle< 3 >&, std::string_view ); + + template void opengeode_mesh_api save_triangles( + const TriangulatedSurface< 2 >&, + absl::Span< const index_t >, + std::string_view ); + template void opengeode_mesh_api save_triangles( + const TriangulatedSurface< 3 >&, + absl::Span< const index_t >, + std::string_view ); } // namespace detail } // namespace geode