MeshLib C++ Docs
Loading...
Searching...
No Matches
MRCutTrianglePredicates.h
Go to the documentation of this file.
1#pragma once
2
4#include "MRVector.h"
5#include "MRVector2.h"
6#include <memory>
7#include <optional>
8
9namespace MR
10{
11
14
21struct MR_BIND_IGNORE PreciseCutPoint
22{
24 std::array<PreciseVertCoords, 2> seg;
25
27 std::array<PreciseVertCoords, 3> tri;
28
32 std::array<PreciseVertCoords, 2> wedge;
33
36 std::array<PreciseVertCoords, 3> tri2;
37
38 [[nodiscard]] bool isCrossing() const { return tri2[0].id.valid(); }
39 [[nodiscard]] bool isVertex() const { return !seg[1].id.valid() && !isCrossing(); }
40};
41
58class MR_BIND_IGNORE CutTrianglePredicates
59{
60public:
65
70 MRMESH_API void reset( const std::array<PreciseVertCoords, 3> & tri );
71
90 MRMESH_API void addPoint( VertId v, const PreciseCutPoint & p );
91
93 [[nodiscard]] MRMESH_API bool less( VertId p, VertId q ) const;
94
99 [[nodiscard]] MRMESH_API std::optional<Vector2i> directionByPerturbation( VertId p, VertId q ) const;
100
105 [[nodiscard]] MRMESH_API bool ccw( VertId a, VertId b, VertId c ) const;
106
122 [[nodiscard]] MRMESH_API std::optional<bool> ccwByLines( VertId a, VertId b, VertId c ) const;
123
128 [[nodiscard]] MRMESH_API std::optional<bool> ccwByPerturbation( VertId a, VertId b, VertId c ) const;
129
131 [[nodiscard]] MRMESH_API bool ccwFromBehind( VertId b, VertId pivot ) const;
132
145 [[nodiscard]] MRMESH_API bool failed() const;
146
147private:
149 struct Line
150 {
151 int side = -1;
152 std::array<PreciseVertCoords, 3> plane;
153 };
154
157 struct Impl;
158
160 struct Shift;
161
162 void addCrossing_( VertId v, const PreciseCutPoint & p );
163 bool isCrossing_( VertId v ) const;
164 int compareExact_( VertId p, VertId q, bool yFirst ) const;
165 int exactOrient_( VertId a, VertId b, VertId c ) const;
166 bool ccwExact_( VertId a, VertId b, VertId c ) const;
167 int orientSlow_( VertId a, VertId b, VertId c ) const;
168 std::optional<bool> ccwBySides_( VertId a, VertId b, VertId c ) const;
169 std::optional<bool> ccwByPlanes_( VertId a, VertId b, VertId c ) const;
170 std::optional<bool> ccwByShifts_( VertId a, VertId b, VertId c, const Line * line ) const;
171 std::optional<Vector2i> coincidentDirection_( VertId p, VertId q ) const;
172 std::optional<Vector2i> directionFromSide_( VertId p, VertId q ) const;
173 std::optional<Vector2i> directionAlongCut_( VertId p, VertId q ) const;
174 std::optional<Vector2i> perturbedDirection_( VertId p, VertId q, bool alike ) const;
175 std::optional<Vector2i> shiftDirection_( VertId p, VertId q ) const;
176 std::optional<Shift> shift_( VertId p ) const;
177 std::optional<Line> commonLine_( VertId p, VertId q, bool withVertex ) const;
178 Vector2i lineDirection_( const Line & l ) const;
179 bool along_( const Vector2i & dir, VertId p, VertId q ) const;
180 int sideOfPlane_( const std::array<PreciseVertCoords, 3> & plane, VertId x ) const;
181 int crossingSideOfPlane_( const std::array<PreciseVertCoords, 3> & plane, VertId x ) const;
182 void fail_() const;
183
184 std::array<PreciseVertCoords, 3> tri_;
185 Vector3i64 normal_;
186 int kx_ = 0, ky_ = 1;
187 std::array<Vector2i, 3> sideDirs_;
189 std::unique_ptr<Impl> impl_;
190};
191
193
194}
#define MRMESH_API
Definition MRMeshFwd.h:85
std::optional< Vector2i > directionByPerturbation(VertId p, VertId q) const
std::optional< bool > ccwByLines(VertId a, VertId b, VertId c) const
CutTrianglePredicates(CutTrianglePredicates &&) noexcept
void addPoint(VertId v, const PreciseCutPoint &p)
bool ccw(VertId a, VertId b, VertId c) const
bool less(VertId p, VertId q) const
whether point p comes before point q along the sweep: a strict total order, unless reset or addPoint ...
bool ccwFromBehind(VertId b, VertId pivot) const
whether the triangle of a point far behind pivot against the sweep, b and pivot is counterclockwise,...
void reset(const std::array< PreciseVertCoords, 3 > &tri)
std::optional< bool > ccwByPerturbation(VertId a, VertId b, VertId c) const
Vector<T> is indexed by size_t.
Definition MRVector.h:24
struct
Definition MRMeshFwd.h:189
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRLine.h:16
Definition MRCutTrianglePredicates.h:22
std::array< PreciseVertCoords, 2 > seg
the vertex in seg[0] if seg[1].id is invalid; otherwise the ends of the segment; ignored for a crossi...
Definition MRCutTrianglePredicates.h:24
std::array< PreciseVertCoords, 2 > wedge
Definition MRCutTrianglePredicates.h:32
bool isVertex() const
Definition MRCutTrianglePredicates.h:39
std::array< PreciseVertCoords, 3 > tri2
Definition MRCutTrianglePredicates.h:36
std::array< PreciseVertCoords, 3 > tri
the triangle whose plane the segment crosses, or the plane of the first cut of a crossing of two cuts...
Definition MRCutTrianglePredicates.h:27
bool isCrossing() const
Definition MRCutTrianglePredicates.h:38
Definition MRPrecisePredicates3.h:38