Skip to content

Commit

Permalink
fix(Geometry): add noexcept keyword on simplex basic objects construc…
Browse files Browse the repository at this point in the history
…tors and assignment operators
  • Loading branch information
panquez authored and BotellaA committed Oct 3, 2023
1 parent 742f551 commit 2b91372
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 97 deletions.
38 changes: 22 additions & 16 deletions include/geode/geometry/basic_objects/segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ namespace geode
class GenericSegment
{
public:
GenericSegment( PointType p0, PointType p1 );
GenericSegment( PointType p0, PointType p1 ) noexcept;

GenericSegment( const GenericSegment< PointType, dimension >& other );
GenericSegment(
const GenericSegment< PointType, dimension >& other ) noexcept;
GenericSegment< PointType, dimension >& operator=(
const GenericSegment< PointType, dimension >& other );
GenericSegment( GenericSegment< PointType, dimension >&& other );
const GenericSegment< PointType, dimension >& other ) noexcept;
GenericSegment(
GenericSegment< PointType, dimension >&& other ) noexcept;
GenericSegment< PointType, dimension >& operator=(
GenericSegment< PointType, dimension >&& other );
GenericSegment< PointType, dimension >&& other ) noexcept;

Vector< dimension > direction() const;
Vector< dimension > normalized_direction() const;
Expand All @@ -69,14 +71,15 @@ namespace geode
using Base = GenericSegment< Point< dimension >, dimension >;

public:
explicit OwnerSegment( Point< dimension > p0, Point< dimension > p1 );
explicit OwnerSegment(
Point< dimension > p0, Point< dimension > p1 ) noexcept;

OwnerSegment( const OwnerSegment< dimension >& other );
OwnerSegment( const OwnerSegment< dimension >& other ) noexcept;
OwnerSegment< dimension >& operator=(
const OwnerSegment< dimension >& other );
OwnerSegment( OwnerSegment< dimension >&& other );
const OwnerSegment< dimension >& other ) noexcept;
OwnerSegment( OwnerSegment< dimension >&& other ) noexcept;
OwnerSegment< dimension >& operator=(
OwnerSegment< dimension >&& other );
OwnerSegment< dimension >&& other ) noexcept;
};
ALIAS_1D_AND_2D_AND_3D( OwnerSegment );

Expand All @@ -86,13 +89,16 @@ namespace geode
using Base = GenericSegment< RefPoint< dimension >, dimension >;

public:
Segment( const Point< dimension >& p0, const Point< dimension >& p1 );
Segment( const Point< dimension >& p0,
const Point< dimension >& p1 ) noexcept;

Segment( const Segment< dimension >& other );
Segment( const OwnerSegment< dimension >& other );
Segment< dimension >& operator=( const Segment< dimension >& other );
Segment( Segment< dimension >&& other );
Segment< dimension >& operator=( Segment< dimension >&& other );
Segment( const Segment< dimension >& other ) noexcept;
Segment( const OwnerSegment< dimension >& other ) noexcept;
Segment< dimension >& operator=(
const Segment< dimension >& other ) noexcept;
Segment( Segment< dimension >&& other ) noexcept;
Segment< dimension >& operator=(
Segment< dimension >&& other ) noexcept;
};
ALIAS_1D_AND_2D_AND_3D( Segment );
} // namespace geode
33 changes: 17 additions & 16 deletions include/geode/geometry/basic_objects/tetrahedron.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ namespace geode
{ { 3, 1, 0 } }, { { 0, 1, 2 } } } };

GenericTetrahedron(
PointType p0, PointType p1, PointType p2, PointType p3 );
PointType p0, PointType p1, PointType p2, PointType p3 ) noexcept;

GenericTetrahedron( const GenericTetrahedron& other );
GenericTetrahedron& operator=( const GenericTetrahedron& other );
GenericTetrahedron( GenericTetrahedron&& other );
GenericTetrahedron& operator=( GenericTetrahedron&& other );
GenericTetrahedron( const GenericTetrahedron& other ) noexcept;
GenericTetrahedron& operator=(
const GenericTetrahedron& other ) noexcept;
GenericTetrahedron( GenericTetrahedron&& other ) noexcept;
GenericTetrahedron& operator=( GenericTetrahedron&& other ) noexcept;

Point3D barycenter() const;
void set_point( index_t vertex, PointType point );
Expand All @@ -73,12 +74,12 @@ namespace geode

public:
explicit OwnerTetrahedron(
Point3D p0, Point3D p1, Point3D p2, Point3D p3 );
Point3D p0, Point3D p1, Point3D p2, Point3D p3 ) noexcept;

OwnerTetrahedron( const OwnerTetrahedron& other );
OwnerTetrahedron& operator=( const OwnerTetrahedron& other );
OwnerTetrahedron( OwnerTetrahedron&& other );
OwnerTetrahedron& operator=( OwnerTetrahedron&& other );
OwnerTetrahedron( const OwnerTetrahedron& other ) noexcept;
OwnerTetrahedron& operator=( const OwnerTetrahedron& other ) noexcept;
OwnerTetrahedron( OwnerTetrahedron&& other ) noexcept;
OwnerTetrahedron& operator=( OwnerTetrahedron&& other ) noexcept;
};

class opengeode_geometry_api Tetrahedron
Expand All @@ -90,12 +91,12 @@ namespace geode
Tetrahedron( const Point3D& p0,
const Point3D& p1,
const Point3D& p2,
const Point3D& p3 );
const Point3D& p3 ) noexcept;

Tetrahedron( const Tetrahedron& other );
Tetrahedron( const OwnerTetrahedron& other );
Tetrahedron& operator=( const Tetrahedron& other );
Tetrahedron( Tetrahedron&& other );
Tetrahedron& operator=( Tetrahedron&& other );
Tetrahedron( const Tetrahedron& other ) noexcept;
Tetrahedron( const OwnerTetrahedron& other ) noexcept;
Tetrahedron& operator=( const Tetrahedron& other ) noexcept;
Tetrahedron( Tetrahedron&& other ) noexcept;
Tetrahedron& operator=( Tetrahedron&& other ) noexcept;
};
} // namespace geode
36 changes: 20 additions & 16 deletions include/geode/geometry/basic_objects/triangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ namespace geode
class GenericTriangle
{
public:
GenericTriangle( PointType p0, PointType p1, PointType p2 );
GenericTriangle( PointType p0, PointType p1, PointType p2 ) noexcept;

GenericTriangle( const GenericTriangle< PointType, dimension >& other );
GenericTriangle(
const GenericTriangle< PointType, dimension >& other ) noexcept;
GenericTriangle< PointType, dimension >& operator=(
const GenericTriangle< PointType, dimension >& other );
GenericTriangle( GenericTriangle< PointType, dimension >&& other );
const GenericTriangle< PointType, dimension >& other ) noexcept;
GenericTriangle(
GenericTriangle< PointType, dimension >&& other ) noexcept;
GenericTriangle< PointType, dimension >& operator=(
GenericTriangle< PointType, dimension >&& other );
GenericTriangle< PointType, dimension >&& other ) noexcept;

Point< dimension > barycenter() const;
template < index_t T = dimension >
Expand Down Expand Up @@ -88,14 +90,14 @@ namespace geode
public:
explicit OwnerTriangle( Point< dimension > p0,
Point< dimension > p1,
Point< dimension > p2 );
Point< dimension > p2 ) noexcept;

OwnerTriangle( const OwnerTriangle< dimension >& other );
OwnerTriangle( const OwnerTriangle< dimension >& other ) noexcept;
OwnerTriangle< dimension >& operator=(
const OwnerTriangle< dimension >& other );
OwnerTriangle( OwnerTriangle< dimension >&& other );
const OwnerTriangle< dimension >& other ) noexcept;
OwnerTriangle( OwnerTriangle< dimension >&& other ) noexcept;
OwnerTriangle< dimension >& operator=(
OwnerTriangle< dimension >&& other );
OwnerTriangle< dimension >&& other ) noexcept;
};
ALIAS_2D_AND_3D( OwnerTriangle );
template < index_t dimension >
Expand All @@ -106,13 +108,15 @@ namespace geode
public:
Triangle( const Point< dimension >& p0,
const Point< dimension >& p1,
const Point< dimension >& p2 );
const Point< dimension >& p2 ) noexcept;

Triangle( const Triangle< dimension >& other );
Triangle( const OwnerTriangle< dimension >& other );
Triangle< dimension >& operator=( const Triangle< dimension >& other );
Triangle( Triangle< dimension >&& other );
Triangle< dimension >& operator=( Triangle< dimension >&& other );
Triangle( const Triangle< dimension >& other ) noexcept;
Triangle( const OwnerTriangle< dimension >& other ) noexcept;
Triangle< dimension >& operator=(
const Triangle< dimension >& other ) noexcept;
Triangle( Triangle< dimension >&& other ) noexcept;
Triangle< dimension >& operator=(
Triangle< dimension >&& other ) noexcept;
};
ALIAS_2D_AND_3D( Triangle );
} // namespace geode
34 changes: 18 additions & 16 deletions src/geode/geometry/basic_objects/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,34 @@ namespace geode
{
template < typename PointType, index_t dimension >
GenericSegment< PointType, dimension >::GenericSegment(
PointType p0, PointType p1 )
PointType p0, PointType p1 ) noexcept
: vertices_{ { std::move( p0 ), std::move( p1 ) } }
{
}
template < typename PointType, index_t dimension >
GenericSegment< PointType, dimension >::GenericSegment(
const GenericSegment< PointType, dimension >& other )
const GenericSegment< PointType, dimension >& other ) noexcept
: vertices_( other.vertices_ )
{
}
template < typename PointType, index_t dimension >
GenericSegment< PointType, dimension >&
GenericSegment< PointType, dimension >::operator=(
const GenericSegment< PointType, dimension >& other )
const GenericSegment< PointType, dimension >& other ) noexcept
{
vertices_ = other.vertices_;
return *this;
}
template < typename PointType, index_t dimension >
GenericSegment< PointType, dimension >::GenericSegment(
GenericSegment< PointType, dimension >&& other )
GenericSegment< PointType, dimension >&& other ) noexcept
: vertices_( std::move( other.vertices_ ) )
{
}
template < typename PointType, index_t dimension >
GenericSegment< PointType, dimension >&
GenericSegment< PointType, dimension >::operator=(
GenericSegment< PointType, dimension >&& other )
GenericSegment< PointType, dimension >&& other ) noexcept
{
vertices_ = std::move( other.vertices_ );
return *this;
Expand Down Expand Up @@ -118,67 +118,69 @@ namespace geode

template < index_t dimension >
OwnerSegment< dimension >::OwnerSegment(
Point< dimension > p0, Point< dimension > p1 )
Point< dimension > p0, Point< dimension > p1 ) noexcept
: Base( std::move( p0 ), std::move( p1 ) )
{
}
template < index_t dimension >
OwnerSegment< dimension >::OwnerSegment(
const OwnerSegment< dimension >& other )
const OwnerSegment< dimension >& other ) noexcept
: Base( other )
{
}
template < index_t dimension >
OwnerSegment< dimension >& OwnerSegment< dimension >::operator=(
const OwnerSegment< dimension >& other )
const OwnerSegment< dimension >& other ) noexcept
{
Base::operator=( other );
return *this;
}
template < index_t dimension >
OwnerSegment< dimension >::OwnerSegment( OwnerSegment< dimension >&& other )
OwnerSegment< dimension >::OwnerSegment(
OwnerSegment< dimension >&& other ) noexcept
: Base( std::move( other ) )
{
}
template < index_t dimension >
OwnerSegment< dimension >& OwnerSegment< dimension >::operator=(
OwnerSegment< dimension >&& other )
OwnerSegment< dimension >&& other ) noexcept
{
Base::operator=( other );
return *this;
}

template < index_t dimension >
Segment< dimension >::Segment(
const Point< dimension >& p0, const Point< dimension >& p1 )
const Point< dimension >& p0, const Point< dimension >& p1 ) noexcept
: Base( p0, p1 )
{
}
template < index_t dimension >
Segment< dimension >::Segment( const Segment< dimension >& other )
Segment< dimension >::Segment( const Segment< dimension >& other ) noexcept
: Base( other )
{
}
template < index_t dimension >
Segment< dimension >::Segment( const OwnerSegment< dimension >& other )
Segment< dimension >::Segment(
const OwnerSegment< dimension >& other ) noexcept
: Base( other.vertices()[0], other.vertices()[1] )
{
}
template < index_t dimension >
Segment< dimension >& Segment< dimension >::operator=(
const Segment< dimension >& other )
const Segment< dimension >& other ) noexcept
{
Base::operator=( other );
return *this;
}
template < index_t dimension >
Segment< dimension >::Segment( Segment< dimension >&& other )
Segment< dimension >::Segment( Segment< dimension >&& other ) noexcept
: Base( std::move( other ) )
{
}
template < index_t dimension >
Segment< dimension >& Segment< dimension >::operator=(
Segment< dimension >&& other )
Segment< dimension >&& other ) noexcept
{
Base::operator=( other );
return *this;
Expand Down
Loading

0 comments on commit 2b91372

Please sign in to comment.