MeshLib C++ Docs
Loading...
Searching...
No Matches
MR2DContoursTriangulation.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#include "MRId.h"
4#include "MRHoleFillPlan.h"
5#include <memory>
6#include <optional>
7
8namespace MR
9{
12
13
15struct PreciseCutPoint;
17
19{
20
28
31{
34 VertId lOrg, lDest;
36 VertId uOrg, uDest;
37
41 float lRatio = 0.0f;
44 float uRatio = 0.0f;
45 bool isIntersection() const { return lDest.valid(); }
46};
47
48using ContourIdMap = std::vector<IntersectionInfo>;
49using ContoursIdMap = std::vector<ContourIdMap>;
50
53{
55 size_t shift{ 0 };
58};
59
65
68MRMESH_API Mesh getOutlineMesh( const Contours2f& contours, IntersectionsMap* interMap = nullptr, const BaseOutlineParameters& params = {} );
69MRMESH_API Mesh getOutlineMesh( const Contours2d& contours, IntersectionsMap* interMap = nullptr, const BaseOutlineParameters& params = {} );
70
76
78MRMESH_API Contours2f getOutline( const Contours2f& contours, const OutlineParameters& params = {} );
79MRMESH_API Contours2f getOutline( const Contours2d& contours, const OutlineParameters& params = {} );
80
91
99
106{
107public:
108 ISweepLineCache() = default;
111 ISweepLineCache( const ISweepLineCache & ) = delete;
115};
116
118MRMESH_API std::unique_ptr<ISweepLineCache> makeSweepLineCache();
119
125MRMESH_API std::optional<Mesh> triangulateDisjointContours( const Contours2d& contours, ISweepLineCache* cache = nullptr );
126MRMESH_API std::optional<Mesh> triangulateDisjointContours( const Contours2f& contours, ISweepLineCache* cache = nullptr );
127
137MRMESH_API std::optional<Mesh> triangulateDisjointContours( const Mesh& mesh, const EdgeLoops& loops, const Vector3f& normal, WholeEdgeMap* outPatchMap = nullptr, ISweepLineCache* cache = nullptr );
138
144MR_BIND_IGNORE MRMESH_API MeshTopology* triangulateDisjointContoursTopology( const Mesh& mesh, const EdgeLoops& loops, const Vector3f& normal, WholeEdgeMap& outPatchMap, ISweepLineCache& cache );
145
160MRMESH_API std::optional<HoleFillPlan> getMonotonePlan( const Mesh& mesh, const EdgeLoops& loops, const Vector3f& normal );
161
169MR_BIND_IGNORE MRMESH_API std::optional<HoleFillPlan> getMonotonePlan( const Mesh& mesh, const EdgeLoops& loops,
170 const std::array<PreciseVertCoords, 3>& tri, const std::function<PreciseCutPoint( VertId )>& pointOf );
171
175MR_BIND_IGNORE MRMESH_API std::optional<Vector<EdgePair>> findCrossings( const Mesh& mesh, const EdgeLoops& loops,
176 const std::array<PreciseVertCoords, 3>& tri, const std::function<PreciseCutPoint( VertId )>& pointOf,
177 const std::function<std::array<PreciseVertCoords, 3>( UndirectedEdgeId )>& cutOf );
178
182MR_BIND_IGNORE MRMESH_API std::optional<Vector<EdgePair>> findCrossings( const Mesh& mesh, const EdgeLoops& loops, const Vector3f& normal );
183
185constexpr size_t cMaxSegmentsInPairs = 32;
186
192MR_BIND_IGNORE MRMESH_API bool hasCrossing( const Vector<TwoVertIds>& segments, const CutTrianglePredicates& preds, ISweepLineCache* cache = nullptr );
193
197MR_BIND_IGNORE MRMESH_API bool hasCrossing( const Vector<TwoVertIds>& segments, const VertCoords& points, const Vector3f& normal,
198 ISweepLineCache* cache = nullptr );
199
200}
201}
#define MRMESH_API
Definition MRMeshFwd.h:85
Definition MRCutTrianglePredicates.h:59
Definition MRMeshTopology.h:31
Definition MR2DContoursTriangulation.h:106
Vector<T> is indexed by size_t.
Definition MRVector.h:24
std::vector< IntersectionInfo > ContourIdMap
Definition MR2DContoursTriangulation.h:48
Mesh triangulateContours(const Contours2d &contours, const TriangulationParameters &params={})
triangulate 2d contours only closed contours are allowed (first point of each contour should be the s...
std::vector< EdgeLoop > EdgeLoops
Definition MRMeshFwd.h:157
VertId lDest
Definition MR2DContoursTriangulation.h:34
std::vector< ContourIdMap > ContoursIdMap
Definition MR2DContoursTriangulation.h:49
ContourIdMap map
map[id-shift] = {lower intersection edge, upper intersection edge}
Definition MR2DContoursTriangulation.h:57
VertId lOrg
Definition MR2DContoursTriangulation.h:34
VertId uDest
Definition MR2DContoursTriangulation.h:36
bool isIntersection() const
Definition MR2DContoursTriangulation.h:45
WindingMode
Specify mode of detecting inside and outside parts of triangulation.
Definition MR2DContoursTriangulation.h:23
float uRatio
Definition MR2DContoursTriangulation.h:44
Contours2< double > Contours2d
Definition MRMeshFwd.h:385
BaseOutlineParameters baseParams
Definition MR2DContoursTriangulation.h:74
bool hasCrossing(const Vector< TwoVertIds > &segments, const CutTrianglePredicates &preds, ISweepLineCache *cache=nullptr)
Contours2f getOutline(const Contours2f &contours, const OutlineParameters &params={})
returns Contour representing outline if input contours
Mesh getOutlineMesh(const Contours2f &contours, IntersectionsMap *interMap=nullptr, const BaseOutlineParameters &params={})
MeshTopology * triangulateDisjointContoursTopology(const Mesh &mesh, const EdgeLoops &loops, const Vector3f &normal, WholeEdgeMap &outPatchMap, ISweepLineCache &cache)
std::unique_ptr< ISweepLineCache > makeSweepLineCache()
creates a cache for the sweep-line triangulation
std::optional< HoleFillPlan > getMonotonePlan(const Mesh &mesh, const EdgeLoops &loops, const Vector3f &normal)
splits the near-planar region bounded by loops in monotone parts, without triangulating them this is ...
bool allowMerge
allow to merge vertices with same coordinates
Definition MR2DContoursTriangulation.h:62
float lRatio
Definition MR2DContoursTriangulation.h:41
virtual ~ISweepLineCache()=0
pure to make the class abstract: instances are created by makeSweepLineCache() only
ISweepLineCache(const ISweepLineCache &)=delete
constexpr size_t cMaxSegmentsInPairs
hasCrossing tests up to this many segments in pairs, which is faster for them than the sweep,...
Definition MR2DContoursTriangulation.h:185
Contours2< float > Contours2f
Definition MRMeshFwd.h:386
Vector< int, FaceId > * outFaceWinding
Definition MR2DContoursTriangulation.h:85
VertId uOrg
ids of upper intersection edge vertices
Definition MR2DContoursTriangulation.h:36
ISweepLineCache & operator=(const ISweepLineCache &)=delete
WindingMode innerType
what to mark as inner part
Definition MR2DContoursTriangulation.h:63
size_t shift
shift of index
Definition MR2DContoursTriangulation.h:55
ContoursIdMap * indicesMap
optional output from result contour ids to input ones
Definition MR2DContoursTriangulation.h:73
IntersectionsMap * outInterMap
Definition MR2DContoursTriangulation.h:89
Vector3f normal(const MeshTopology &topology, const VertCoords &points, FaceId f)
computes triangular face normal from its vertices
Definition MRMeshMath.h:224
std::optional< Mesh > triangulateDisjointContours(const Contours2d &contours, ISweepLineCache *cache=nullptr)
triangulate 2d contours only closed contours are allowed (first point of each contour should be the s...
std::optional< Vector< EdgePair > > findCrossings(const Mesh &mesh, const EdgeLoops &loops, const std::array< PreciseVertCoords, 3 > &tri, const std::function< PreciseCutPoint(VertId)> &pointOf, const std::function< std::array< PreciseVertCoords, 3 >(UndirectedEdgeId)> &cutOf)
@ Positive
Definition MR2DContoursTriangulation.h:25
@ NonZero
Definition MR2DContoursTriangulation.h:24
@ Negative
Definition MR2DContoursTriangulation.h:26
Definition MR2DContoursTriangulation.h:19
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRMesh.h:24
Definition MR2DContoursTriangulation.h:61
Info about intersection point for mapping.
Definition MR2DContoursTriangulation.h:31
struct to map new vertices (only appear on intersections) of the outline to it's edges
Definition MR2DContoursTriangulation.h:53
Definition MR2DContoursTriangulation.h:72
Definition MR2DContoursTriangulation.h:82
Definition MRCutTrianglePredicates.h:22
Definition MRPrecisePredicates3.h:38