Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Mapping): missing default constructors #1025

Open
wants to merge 5 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/geode/basic/mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
Expand Down Expand Up @@ -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 );
Expand Down
3 changes: 1 addition & 2 deletions include/geode/geometry/aabb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ namespace geode
class AABBTree
{
OPENGEODE_DISABLE_COPY( AABBTree );
OPENGEODE_TEMPLATE_ASSERT_2D_OR_3D( dimension );

public:
/*!
Expand Down Expand Up @@ -237,7 +236,7 @@ namespace geode
private:
IMPLEMENTATION_MEMBER( impl_ );
};
ALIAS_2D_AND_3D( AABBTree );
ALIAS_1D_AND_2D_AND_3D( AABBTree );
} // namespace geode

#include <geode/geometry/detail/aabb_impl.hpp>
1 change: 1 addition & 0 deletions include/geode/geometry/basic_objects/infinite_line.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ namespace geode
private:
CoordinateReferenceSystemManagers< dimension >& crs_managers_;
};
ALIAS_2D_AND_3D( CoordinateReferenceSystemManagersBuilder );
ALIAS_1D_AND_2D_AND_3D( CoordinateReferenceSystemManagersBuilder );
} // namespace geode
2 changes: 1 addition & 1 deletion include/geode/mesh/builder/edged_curve_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ namespace geode
private:
OpenGeodeEdgedCurve< dimension >& geode_edged_curve_;
};
ALIAS_2D_AND_3D( OpenGeodeEdgedCurveBuilder );
ALIAS_1D_AND_2D_AND_3D( OpenGeodeEdgedCurveBuilder );
} // namespace geode
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions include/geode/mesh/builder/point_set_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ namespace geode
: public VertexSetBuilder,
public CoordinateReferenceSystemManagersBuilder< dimension >
{
OPENGEODE_TEMPLATE_ASSERT_2D_OR_3D( dimension );

public:
static constexpr auto dim = dimension;

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ namespace geode
private:
IMPLEMENTATION_MEMBER( impl_ );
};
ALIAS_2D_AND_3D( CoordinateReferenceSystemManagers );
ALIAS_1D_AND_2D_AND_3D( CoordinateReferenceSystemManagers );
} // namespace geode
2 changes: 1 addition & 1 deletion include/geode/mesh/core/edged_curve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ namespace geode
private:
IMPLEMENTATION_MEMBER( impl_ );
};
ALIAS_2D_AND_3D( EdgedCurve );
ALIAS_1D_AND_2D_AND_3D( EdgedCurve );
} // namespace geode
2 changes: 1 addition & 1 deletion include/geode/mesh/core/geode/geode_edged_curve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ namespace geode
private:
IMPLEMENTATION_MEMBER( impl_ );
};
ALIAS_2D_AND_3D( OpenGeodeEdgedCurve );
ALIAS_1D_AND_2D_AND_3D( OpenGeodeEdgedCurve );
} // namespace geode
2 changes: 1 addition & 1 deletion include/geode/mesh/core/geode/geode_point_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ namespace geode
private:
IMPLEMENTATION_MEMBER( impl_ );
};
ALIAS_2D_AND_3D( OpenGeodePointSet );
ALIAS_1D_AND_2D_AND_3D( OpenGeodePointSet );
} // namespace geode
4 changes: 1 addition & 3 deletions include/geode/mesh/core/point_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions include/geode/mesh/helpers/aabb_edged_curve_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace geode
private:
const EdgedCurve< dimension >& mesh_;
};
ALIAS_2D_AND_3D( DistanceToEdge );
ALIAS_1D_AND_2D_AND_3D( DistanceToEdge );

template < index_t dimension >
class GenericMeshAABB< EdgedCurve< dimension > >
Expand Down Expand Up @@ -92,5 +92,5 @@ namespace geode
};
template < index_t dimension >
using EdgedCurveAABB = GenericMeshAABB< EdgedCurve< dimension > >;
ALIAS_2D_AND_3D( EdgedCurveAABB );
ALIAS_1D_AND_2D_AND_3D( EdgedCurveAABB );
} // namespace geode
6 changes: 6 additions & 0 deletions include/geode/mesh/helpers/detail/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 );

Expand Down
1 change: 1 addition & 0 deletions src/geode/geometry/aabb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ namespace geode
return result;
}

template class opengeode_geometry_api AABBTree< 1 >;
template class opengeode_geometry_api AABBTree< 2 >;
template class opengeode_geometry_api AABBTree< 3 >;
} // namespace geode
10 changes: 10 additions & 0 deletions src/geode/geometry/basic_objects/infinite_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
73 changes: 35 additions & 38 deletions src/geode/geometry/points_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace
absl::Span< const geode::Point< dimension > > points_;
geode::local_index_t coord_;
};
ALIAS_2D_AND_3D( Morton_cmp );
ALIAS_1D_AND_2D_AND_3D( Morton_cmp );

/**
* \brief Splits a sequence into two ordered halves.
Expand Down Expand Up @@ -97,10 +97,8 @@ namespace
{
return;
}
constexpr geode::local_index_t COORDY =
COORDX + 1 == 3 ? 0 : COORDX + 1;
constexpr geode::local_index_t COORDZ =
COORDY + 1 == 3 ? 0 : COORDY + 1;
constexpr geode::local_index_t COORDY = COORDX == 2 ? 0 : COORDX + 1;
constexpr geode::local_index_t COORDZ = COORDY == 2 ? 0 : COORDY + 1;

const Morton_cmp3D compX{ points, COORDX };
const Morton_cmp3D compY{ points, COORDY };
Expand Down Expand Up @@ -134,8 +132,7 @@ namespace
{
return;
}
constexpr geode::local_index_t COORDY =
COORDX + 1 == 2 ? 0 : COORDX + 1;
constexpr geode::local_index_t COORDY = COORDX == 1 ? 0 : COORDX + 1;

const Morton_cmp2D compX{ points, COORDX };
const Morton_cmp2D compY{ points, COORDY };
Expand All @@ -151,48 +148,44 @@ namespace
morton_mapping< COORDY >( points, m3, m4 );
}

/*
* Return true if p0 < p1 comparing first X, then Y.
*/
bool lexicographic_compare(
const geode::Point2D& p0, const geode::Point2D& p1 )
template < geode::local_index_t COORDX >
void morton_mapping( absl::Span< const geode::Point1D > points,
const itr& begin,
const itr& end )
{
if( p0.value( 0 ) < p1.value( 0 ) )
{
return true;
}
if( p0.value( 0 ) > p1.value( 0 ) )
if( end - begin <= 1 )
{
return false;
return;
}
return p0.value( 1 ) < p1.value( 1 );
const Morton_cmp1D compX{ points, COORDX };

const auto m0 = begin;
const auto m2 = end;
const auto m1 = split_container( m0, m2, compX );
morton_mapping< COORDX >( points, m0, m1 );
morton_mapping< COORDX >( points, m1, m2 );
}

/*
* Return true if p0 < p1 comparing first X, then Y and last Z.
* Return true if p0 < p1 comparing first X, then Y.
*/
bool lexicographic_compare(
const geode::Point3D& p0, const geode::Point3D& p1 )
template < geode::index_t dimension >
bool lexicographic_compare( const geode::Point< dimension >& p0,
const geode::Point< dimension >& p1 )
{
if( p0.value( 0 ) < p1.value( 0 ) )
{
return true;
}
if( p0.value( 0 ) > p1.value( 0 ) )
{
return false;
}
if( p0.value( 1 ) < p1.value( 1 ) )
{
return true;
}
if( p0.value( 1 ) > p1.value( 1 ) )
for( const auto d : geode::LRange{ dimension - 1 } )
{
return false;
if( p0.value( d ) < p1.value( d ) )
{
return true;
}
if( p0.value( d ) > p1.value( d ) )
{
return false;
}
}
return p0.value( 2 ) < p1.value( 2 );
return p0.value( dimension - 1 ) < p1.value( dimension - 1 );
}

} // namespace

namespace geode
Expand Down Expand Up @@ -225,11 +218,15 @@ namespace geode
return mapping;
}

template std::vector< index_t > opengeode_geometry_api
lexicographic_mapping( absl::Span< const Point< 1 > > );
template std::vector< index_t > opengeode_geometry_api
lexicographic_mapping( absl::Span< const Point< 2 > > );
template std::vector< index_t > opengeode_geometry_api
lexicographic_mapping( absl::Span< const Point< 3 > > );

template std::vector< index_t > opengeode_geometry_api morton_mapping(
absl::Span< const Point< 1 > > );
template std::vector< index_t > opengeode_geometry_api morton_mapping(
absl::Span< const Point< 2 > > );
template std::vector< index_t > opengeode_geometry_api morton_mapping(
Expand Down
23 changes: 22 additions & 1 deletion src/geode/geometry/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <geode/geometry/basic_objects/segment.hpp>
#include <geode/geometry/basic_objects/tetrahedron.hpp>
#include <geode/geometry/basic_objects/triangle.hpp>
#include <geode/geometry/bounding_box.hpp>
#include <geode/geometry/distance.hpp>
#include <geode/geometry/internal/position_from_sides.hpp>
#include <geode/geometry/internal/predicates.hpp>
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ namespace geode
crs_managers_.set_point( vertex, std::move( point ), {} );
}

template class opengeode_mesh_api
CoordinateReferenceSystemManagersBuilder< 1 >;
template class opengeode_mesh_api
CoordinateReferenceSystemManagersBuilder< 2 >;
template class opengeode_mesh_api
Expand Down
1 change: 1 addition & 0 deletions src/geode/mesh/builder/edged_curve_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/geode/mesh/builder/geode/geode_edged_curve_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace geode
// Operation is directly handled by the AttributeManager
}

template class opengeode_mesh_api OpenGeodeEdgedCurveBuilder< 1 >;
template class opengeode_mesh_api OpenGeodeEdgedCurveBuilder< 2 >;
template class opengeode_mesh_api OpenGeodeEdgedCurveBuilder< 3 >;
} // namespace geode
Loading
Loading