MeshLib C++ Docs
Loading...
Searching...
No Matches
MREdgePoint.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRId.h"
4#include "MRSegmPoint.h"
5
6namespace MR
7{
8
10struct EdgePoint
11{
12 EdgeId e;
13 SegmPointf a;
14
15 [[nodiscard]] EdgePoint() = default;
16 [[nodiscard]] EdgePoint( EdgeId e, float a ) : e( e ), a( a ) { }
17 [[nodiscard]] MRMESH_API EdgePoint( const MeshTopology & topology, VertId v );
18 [[nodiscard]] MRMESH_API EdgePoint( const PolylineTopology & topology, VertId v );
19
21 [[nodiscard]] MRMESH_API VertId inVertex( const MeshTopology & topology ) const;
23 [[nodiscard]] MRMESH_API VertId inVertex( const PolylineTopology & topology ) const;
25 [[nodiscard]] MRMESH_API VertId getClosestVertex( const MeshTopology & topology ) const;
27 [[nodiscard]] MRMESH_API VertId getClosestVertex( const PolylineTopology & topology ) const;
29 [[nodiscard]] bool inVertex() const { return a.inVertex() >= 0; }
33 [[nodiscard]] MRMESH_API bool isBd( const MeshTopology & topology, const FaceBitSet * region = nullptr ) const;
34
36 [[nodiscard]] bool valid() const { return e.valid(); }
37 [[nodiscard]] explicit operator bool() const { return e.valid(); }
38
40 [[nodiscard]] EdgePoint sym() const { return EdgePoint{ e.sym(), 1 - a }; }
42 [[nodiscard]] bool operator==( const EdgePoint& rhs ) const = default;
43};
44
46[[nodiscard]] MRMESH_API bool same( const MeshTopology & topology, const EdgePoint& lhs, const EdgePoint& rhs );
47
49struct EdgePointPair
50{
51 EdgePoint a;
52 EdgePoint b;
53 EdgePointPair() = default;
54 EdgePointPair( EdgePoint ia, EdgePoint ib ) : a( ia ), b( ib ) {}
56 bool operator==( const EdgePointPair& rhs ) const = default;
57};
58
60struct EdgeSegment
61{
63 EdgeId e;
65 SegmPointf a{ 0.0f };
67 SegmPointf b{ 1.0f };
68 [[nodiscard]] EdgeSegment() = default;
69 [[nodiscard]] EdgeSegment( EdgeId e, float a = 0.0f, float b = 1.0f ) : e( e ), a( a ), b( b ) { assert( valid() ); };
71 [[nodiscard]] EdgePoint edgePointA() const { return { e, a }; }
73 [[nodiscard]] EdgePoint edgePointB() const { return { e, b }; }
75 [[nodiscard]] bool valid() const { return e.valid() && a <= b; }
76
77 bool operator==( const EdgeSegment& rhs ) const = default;
79 [[nodiscard]] EdgeSegment sym() const { return EdgeSegment{ e.sym(), b.sym(), a.sym() }; }
80};
81
85[[nodiscard]] MRMESH_API bool fromSameTriangle( const MeshTopology & topology, EdgePoint & a, EdgePoint & b );
89[[nodiscard]] inline bool fromSameTriangle( const MeshTopology & topology, EdgePoint && a, EdgePoint && b ) { return fromSameTriangle( topology, a, b ); }
90
91} // namespace MR
#define MRMESH_API
Definition MRMeshFwd.h:80
Definition MREdgePoint.h:50
unsafe EdgePointPair()
Definition MREdgePoint.h:11
unsafe void moveToClosestVertex()
unsafe EdgePoint()
new unsafe ref MR.EdgeId e
unsafe EdgeSegment()
new unsafe MR.SegmPointf a
new unsafe ref MR.EdgeId e
new unsafe MR.SegmPointf b
Definition MRMesh/MRMeshTopology.h:19
static unsafe bool fromSameTriangle(MR.Const_MeshTopology topology, MR.MeshTriPoint a, MR.MeshTriPoint b)
Definition MRCameraOrientationPlugin.h:8
MRMESH_API bool same(const MeshTopology &topology, const EdgePoint &lhs, const EdgePoint &rhs)
returns true if two edge-points are equal considering different representations