Skip to content

Commit 784f19d

Browse files
author
Geode-solutions robot
committed
Merge remote-tracking branch 'origin/next'
2 parents ce3eb51 + 724c3f7 commit 784f19d

File tree

12 files changed

+171
-4
lines changed

12 files changed

+171
-4
lines changed

include/geode/basic/assert.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ namespace geode
102102
* Always return 1.
103103
*/
104104
int opengeode_basic_api geode_lippincott();
105+
106+
/*!
107+
* Catch all exceptions and rethrow an OpenGeodeException
108+
*/
109+
void opengeode_basic_api throw_lippincott();
105110
} // namespace geode
106111

107112
#ifdef OPENGEODE_DEBUG

include/geode/geometry/basic_objects/segment.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ namespace geode
6161
[[nodiscard]] const std::array< PointType, 2 >& vertices() const;
6262
[[nodiscard]] BoundingBox< dimension > bounding_box() const;
6363
[[nodiscard]] bool is_degenerated() const;
64+
[[nodiscard]] std::string string() const;
6465

6566
private:
6667
std::array< PointType, 2 > vertices_;
@@ -102,4 +103,41 @@ namespace geode
102103
Segment< dimension >&& other ) noexcept;
103104
};
104105
ALIAS_1D_AND_2D_AND_3D( Segment );
106+
107+
template < index_t dimension >
108+
class OpenGeodeSegmentException : public OpenGeodeException
109+
{
110+
public:
111+
template < typename... Args >
112+
explicit OpenGeodeSegmentException(
113+
Segment< dimension > segment_in, const Args&... message )
114+
: OpenGeodeException{ absl::StrCat(
115+
message..., " at ", segment_in.string() ) },
116+
segment{ std::move( segment_in ) }
117+
{
118+
}
119+
120+
OwnerSegment< dimension > segment;
121+
};
122+
ALIAS_1D_AND_2D_AND_3D( OpenGeodeSegmentException );
105123
} // namespace geode
124+
125+
// NOLINTNEXTLINE
126+
#define OPENGEODE_SEGMENT_EXCEPTION( dimension, condition, segment, ... ) \
127+
if( ABSL_PREDICT_FALSE( !( condition ) ) ) \
128+
throw geode::OpenGeodeSegmentException< dimension > \
129+
{ \
130+
segment, __VA_ARGS__ \
131+
}
132+
133+
// NOLINTNEXTLINE
134+
#define OPENGEODE_SEGMENT1D_EXCEPTION( condition, segment, ... ) \
135+
OPENGEODE_SEGMENT_EXCEPTION( 1, condition, segment, __VA_ARGS__ )
136+
137+
// NOLINTNEXTLINE
138+
#define OPENGEODE_SEGMENT2D_EXCEPTION( condition, segment, ... ) \
139+
OPENGEODE_SEGMENT_EXCEPTION( 2, condition, segment, __VA_ARGS__ )
140+
141+
// NOLINTNEXTLINE
142+
#define OPENGEODE_SEGMENT3D_EXCEPTION( condition, segment, ... ) \
143+
OPENGEODE_SEGMENT_EXCEPTION( 3, condition, segment, __VA_ARGS__ )

include/geode/geometry/basic_objects/tetrahedron.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ namespace geode
6565
[[nodiscard]] const std::array< PointType, 4 >& vertices() const;
6666
[[nodiscard]] BoundingBox3D bounding_box() const;
6767
[[nodiscard]] bool is_degenerated() const;
68+
[[nodiscard]] std::string string() const;
6869

6970
private:
7071
std::array< PointType, 4 > vertices_;
@@ -104,4 +105,28 @@ namespace geode
104105
Tetrahedron( Tetrahedron&& other ) noexcept;
105106
Tetrahedron& operator=( Tetrahedron&& other ) noexcept;
106107
};
108+
109+
class OpenGeodeTetrahedronException : public OpenGeodeException
110+
{
111+
public:
112+
template < typename... Args >
113+
explicit OpenGeodeTetrahedronException(
114+
Tetrahedron tetrahedron_in, const Args&... message )
115+
: OpenGeodeException{ absl::StrCat(
116+
message..., " at ", tetrahedron_in.string() ) },
117+
tetrahedron{ std::move( tetrahedron_in ) }
118+
{
119+
}
120+
121+
OwnerTetrahedron tetrahedron;
122+
};
107123
} // namespace geode
124+
125+
// NOLINTNEXTLINE
126+
#define OPENGEODE_TETRAHEDRON_EXCEPTION( \
127+
dimension, condition, tetrahedron, ... ) \
128+
if( ABSL_PREDICT_FALSE( !( condition ) ) ) \
129+
throw geode::OpenGeodeTetrahedronException< dimension > \
130+
{ \
131+
tetrahedron, __VA_ARGS__ \
132+
}

include/geode/geometry/basic_objects/triangle.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace geode
8686
[[nodiscard]] local_index_t longest_edge_index() const;
8787
[[nodiscard]] double minimum_height() const;
8888
[[nodiscard]] bool is_degenerated() const;
89+
[[nodiscard]] std::string string() const;
8990

9091
private:
9192
std::array< PointType, 3 > vertices_;
@@ -129,4 +130,37 @@ namespace geode
129130
Triangle< dimension >&& other ) noexcept;
130131
};
131132
ALIAS_2D_AND_3D( Triangle );
133+
134+
template < index_t dimension >
135+
class OpenGeodeTriangleException : public OpenGeodeException
136+
{
137+
public:
138+
template < typename... Args >
139+
explicit OpenGeodeTriangleException(
140+
Triangle< dimension > triangle_in, const Args&... message )
141+
: OpenGeodeException{ absl::StrCat(
142+
message..., " at ", triangle_in.string() ) },
143+
triangle{ std::move( triangle_in ) }
144+
{
145+
}
146+
147+
OwnerTriangle< dimension > triangle;
148+
};
149+
ALIAS_2D_AND_3D( OpenGeodeTriangleException );
132150
} // namespace geode
151+
152+
// NOLINTNEXTLINE
153+
#define OPENGEODE_TRIANGLE_EXCEPTION( dimension, condition, triangle, ... ) \
154+
if( ABSL_PREDICT_FALSE( !( condition ) ) ) \
155+
throw geode::OpenGeodeTriangleException< dimension > \
156+
{ \
157+
triangle, __VA_ARGS__ \
158+
}
159+
160+
// NOLINTNEXTLINE
161+
#define OPENGEODE_TRIANGLE2D_EXCEPTION( condition, triangle, ... ) \
162+
OPENGEODE_TRIANGLE_EXCEPTION( 2, condition, triangle, __VA_ARGS__ )
163+
164+
// NOLINTNEXTLINE
165+
#define OPENGEODE_TRIANGLE3D_EXCEPTION( condition, triangle, ... ) \
166+
OPENGEODE_TRIANGLE_EXCEPTION( 3, condition, triangle, __VA_ARGS__ )

include/geode/geometry/point.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,15 @@ namespace geode
284284
}
285285

286286
// NOLINTNEXTLINE
287-
#define OPENGEODE_POINT_EXCEPTION1D( condition, point, ... ) \
287+
#define OPENGEODE_POINT1D_EXCEPTION( condition, point, ... ) \
288288
OPENGEODE_POINT_EXCEPTION( 1, condition, point, __VA_ARGS__ )
289289

290290
// NOLINTNEXTLINE
291-
#define OPENGEODE_POINT_EXCEPTION2D( condition, point, ... ) \
291+
#define OPENGEODE_POINT2D_EXCEPTION( condition, point, ... ) \
292292
OPENGEODE_POINT_EXCEPTION( 2, condition, point, __VA_ARGS__ )
293293

294294
// NOLINTNEXTLINE
295-
#define OPENGEODE_POINT_EXCEPTION3D( condition, point, ... ) \
295+
#define OPENGEODE_POINT3D_EXCEPTION( condition, point, ... ) \
296296
OPENGEODE_POINT_EXCEPTION( 3, condition, point, __VA_ARGS__ )
297297

298298
namespace std

include/geode/mesh/core/tetrahedral_solid.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ namespace geode
6767
[[nodiscard]] PolyhedronEdgesVertices polyhedron_edges_vertices(
6868
index_t polyhedron ) const final;
6969

70+
[[nodiscard]] std::array< PolyhedronFacetEdge, 6 > polyhedron_edges(
71+
index_t polyhedron ) const;
72+
7073
[[nodiscard]] PolyhedronFacetsVertices polyhedron_facets_vertices(
7174
index_t polyhedron ) const final;
7275

src/geode/basic/assert.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,24 @@ namespace geode
6161
}
6262
return 1;
6363
}
64+
65+
void throw_lippincott()
66+
{
67+
try
68+
{
69+
throw;
70+
}
71+
catch( const OpenGeodeException& /*unused*/ )
72+
{
73+
throw;
74+
}
75+
catch( const std::exception& exception )
76+
{
77+
throw OpenGeodeException{ "std::exception, ", exception.what() };
78+
}
79+
catch( ... )
80+
{
81+
throw OpenGeodeException{ "Unknown exception" };
82+
}
83+
}
6484
} // namespace geode

src/geode/geometry/basic_objects/segment.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ namespace geode
108108
return length() <= GLOBAL_EPSILON;
109109
}
110110

111+
template < typename PointType, index_t dimension >
112+
std::string GenericSegment< PointType, dimension >::string() const
113+
{
114+
const Point< dimension >& point0 = vertices_[0];
115+
const Point< dimension >& point1 = vertices_[1];
116+
return absl::StrCat( "[", point0.string(), ", ", point1.string(), "]" );
117+
}
118+
111119
template < index_t dimension >
112120
OwnerSegment< dimension >::OwnerSegment(
113121
Point< dimension > point0, Point< dimension > point1 ) noexcept

src/geode/geometry/basic_objects/tetrahedron.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ namespace geode
9999
<= GLOBAL_EPSILON;
100100
}
101101

102+
template < typename PointType >
103+
std::string GenericTetrahedron< PointType >::string() const
104+
{
105+
const Point3D& point0 = vertices_[0];
106+
const Point3D& point1 = vertices_[1];
107+
const Point3D& point2 = vertices_[2];
108+
const Point3D& point3 = vertices_[3];
109+
return absl::StrCat( "[", point0.string(), ", ", point1.string(), ", ",
110+
point2.string(), ", ", point3.string(), "]" );
111+
}
112+
102113
OwnerTetrahedron::OwnerTetrahedron( Point3D point0,
103114
Point3D point1,
104115
Point3D point2,

src/geode/geometry/basic_objects/triangle.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,16 @@ namespace geode
285285
<= GLOBAL_EPSILON;
286286
}
287287

288+
template < typename PointType, index_t dimension >
289+
std::string GenericTriangle< PointType, dimension >::string() const
290+
{
291+
const Point< dimension >& point0 = vertices_[0];
292+
const Point< dimension >& point1 = vertices_[1];
293+
const Point< dimension >& point2 = vertices_[2];
294+
return absl::StrCat( "[", point0.string(), ", ", point1.string(), ", ",
295+
point2.string(), "]" );
296+
}
297+
288298
template < index_t dimension >
289299
OwnerTriangle< dimension >::OwnerTriangle( Point< dimension > point0,
290300
Point< dimension > point1,

0 commit comments

Comments
 (0)