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{
10
11
14{
15 EdgeId e;
16 SegmPointf a;
17
18 [[nodiscard]] EdgePoint() = default;
19 [[nodiscard]] EdgePoint( EdgeId e, float a ) : e( e ), a( a ) { }
20 [[nodiscard]] MRMESH_API EdgePoint( const MeshTopology & topology, VertId v );
21 [[nodiscard]] MRMESH_API EdgePoint( const PolylineTopology & topology, VertId v );
22
24 [[nodiscard]] MRMESH_API VertId inVertex( const MeshTopology & topology ) const;
26 [[nodiscard]] MRMESH_API VertId inVertex( const PolylineTopology & topology ) const;
28 [[nodiscard]] MRMESH_API VertId getClosestVertex( const MeshTopology & topology ) const;
30 [[nodiscard]] MRMESH_API VertId getClosestVertex( const PolylineTopology & topology ) const;
32 [[nodiscard]] bool inVertex() const { return a.inVertex() >= 0; }
34 MRMESH_API void moveToClosestVertex();
36 [[nodiscard]] MRMESH_API bool isBd( const MeshTopology & topology, const FaceBitSet * region = nullptr ) const;
37
39 [[nodiscard]] bool valid() const { return e.valid(); }
40 [[nodiscard]] explicit operator bool() const { return e.valid(); }
41
43 [[nodiscard]] EdgePoint sym() const { return EdgePoint{ e.sym(), 1 - a }; }
45 [[nodiscard]] bool operator==( const EdgePoint& rhs ) const = default;
46};
47
49[[nodiscard]] MRMESH_API bool same( const MeshTopology & topology, const EdgePoint& lhs, const EdgePoint& rhs );
50
53{
56 EdgePointPair() = default;
57 EdgePointPair( EdgePoint ia, EdgePoint ib ) : a( ia ), b( ib ) {}
59 bool operator==( const EdgePointPair& rhs ) const = default;
60};
61
64{
66 EdgeId e;
68 SegmPointf a{ 0.0f };
70 SegmPointf b{ 1.0f };
71 [[nodiscard]] EdgeSegment() = default;
72 [[nodiscard]] EdgeSegment( EdgeId e, float a = 0.0f, float b = 1.0f ) : e( e ), a( a ), b( b ) { assert( valid() ); };
74 [[nodiscard]] EdgePoint edgePointA() const { return { e, a }; }
76 [[nodiscard]] EdgePoint edgePointB() const { return { e, b }; }
78 [[nodiscard]] bool valid() const { return e.valid() && a <= b; }
79
80 bool operator==( const EdgeSegment& rhs ) const = default;
82 [[nodiscard]] EdgeSegment sym() const { return EdgeSegment{ e.sym(), b.sym(), a.sym() }; }
83};
84
88[[nodiscard]] MRMESH_API bool fromSameTriangle( const MeshTopology & topology, EdgePoint & a, EdgePoint & b );
92[[nodiscard]] inline bool fromSameTriangle( const MeshTopology & topology, EdgePoint && a, EdgePoint && b ) { return fromSameTriangle( topology, a, b ); }
93
94}
Definition MRMeshTopology.h:22
Definition MRPolylineTopology.h:18
EdgePointPair(EdgePoint ia, EdgePoint ib)
Definition MREdgePoint.h:57
MRMESH_API bool fromSameTriangle(const MeshTopology &topology, EdgePoint &a, EdgePoint &b)
MRMESH_API bool same(const MeshTopology &topology, const EdgePoint &lhs, const EdgePoint &rhs)
returns true if two edge-points are equal considering different representations
EdgePoint edgePointA() const
returns starting EdgePoint
Definition MREdgePoint.h:74
bool inVertex() const
returns true if the point is in a vertex
Definition MREdgePoint.h:32
MRMESH_API VertId getClosestVertex(const MeshTopology &topology) const
returns one of two edge vertices, closest to this point
bool operator==(const EdgePointPair &rhs) const =default
returns true if two edge-point pairs are equal including equal not-unique representation
EdgeSegment(EdgeId e, float a=0.0f, float b=1.0f)
Definition MREdgePoint.h:72
EdgePoint sym() const
represents the same point relative to sym edge in
Definition MREdgePoint.h:43
MRMESH_API VertId getClosestVertex(const PolylineTopology &topology) const
returns one of two edge vertices, closest to this point
MRMESH_API VertId inVertex(const MeshTopology &topology) const
returns valid vertex id if the point is in vertex, otherwise returns invalid id
EdgeSegment sym() const
represents the same segment relative to sym edge in
Definition MREdgePoint.h:82
SegmPointf b
end of the segment
Definition MREdgePoint.h:70
MRMESH_API EdgePoint(const MeshTopology &topology, VertId v)
EdgePoint(EdgeId e, float a)
Definition MREdgePoint.h:19
EdgePointPair()=default
MRMESH_API VertId inVertex(const PolylineTopology &topology) const
returns valid vertex id if the point is in vertex, otherwise returns invalid id
MRMESH_API bool isBd(const MeshTopology &topology, const FaceBitSet *region=nullptr) const
returns true if the point is on the boundary of the region (or for whole mesh if region is nullptr)
bool operator==(const EdgePoint &rhs) const =default
returns true if two edge-points are equal including equal not-unique representation
SegmPointf a
a in [0,1], a=0 => point is in org( e ), a=1 => point is in dest( e )
Definition MREdgePoint.h:16
EdgeId e
Definition MREdgePoint.h:15
SegmPointf a
start of the segment
Definition MREdgePoint.h:68
EdgePoint()=default
bool valid() const
returns true if the edge is valid and start point is less than end point
Definition MREdgePoint.h:78
EdgePoint b
Definition MREdgePoint.h:55
bool operator==(const EdgeSegment &rhs) const =default
MRMESH_API EdgePoint(const PolylineTopology &topology, VertId v)
EdgeId e
id of the edge
Definition MREdgePoint.h:66
EdgePoint a
Definition MREdgePoint.h:54
MRMESH_API void moveToClosestVertex()
sets this to the closest end of the edge
bool valid() const
consider this valid if the edge ID is valid
Definition MREdgePoint.h:39
EdgeSegment()=default
EdgePoint edgePointB() const
returns ending EdgePoint
Definition MREdgePoint.h:76
bool fromSameTriangle(const MeshTopology &topology, EdgePoint &&a, EdgePoint &&b)
Definition MREdgePoint.h:92
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
two edge-points (e.g. representing collision point of two edges)
Definition MREdgePoint.h:53
encodes a point on an edge of mesh or of polyline
Definition MREdgePoint.h:14
Represents a segment on one edge.
Definition MREdgePoint.h:64