MeshLib
 
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
11{
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
50{
53 EdgePointPair() = default;
54 EdgePointPair( EdgePoint ia, EdgePoint ib ) : a( ia ), b( ib ) {}
56 bool operator==( const EdgePointPair& rhs ) const = default;
57};
58
61{
62 // id of the edge
64 // start of the segment
65 SegmPointf a{ 0.0f };
66 // end of the segment
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() ); };
70 // returns starting EdgePoint
71 [[nodiscard]] EdgePoint edgePointA() const { return { e, a }; }
72 // returns ending EdgePoint
73 [[nodiscard]] EdgePoint edgePointB() const { return { e, b }; }
74 // returns true if the edge is valid and start point is less than end point
75 [[nodiscard]] bool valid() const { return e.valid() && a <= b; }
76};
77
81[[nodiscard]] MRMESH_API bool fromSameTriangle( const MeshTopology & topology, EdgePoint & a, EdgePoint & b );
85[[nodiscard]] inline bool fromSameTriangle( const MeshTopology & topology, EdgePoint && a, EdgePoint && b ) { return fromSameTriangle( topology, a, b ); }
86
87} // namespace MR
int VertId
Definition MRDotNet/MRMeshFwd.h:51
int EdgeId
Definition MRDotNet/MRMeshFwd.h:52
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRDotNet/MRBitSet.h:39
Definition MRMesh/MRMeshTopology.h:18
Definition MRPolylineTopology.h:15
Definition MRCameraOrientationPlugin.h:7
MRMESH_API bool same(const MeshTopology &topology, const EdgePoint &lhs, const EdgePoint &rhs)
returns true if two edge-points are equal considering different representations
two edge-points (e.g. representing collision point of two edges)
Definition MREdgePoint.h:50
EdgePointPair(EdgePoint ia, EdgePoint ib)
Definition MREdgePoint.h:54
bool operator==(const EdgePointPair &rhs) const =default
returns true if two edge-point pairs are equal including equal not-unique representation
EdgePointPair()=default
EdgePoint b
Definition MREdgePoint.h:52
EdgePoint a
Definition MREdgePoint.h:51
encodes a point on an edge of mesh or of polyline
Definition MREdgePoint.h:11
MRMESH_API bool fromSameTriangle(const MeshTopology &topology, EdgePoint &a, EdgePoint &b)
bool inVertex() const
returns true if the point is in a vertex
Definition MREdgePoint.h:29
MRMESH_API VertId getClosestVertex(const MeshTopology &topology) const
returns one of two edge vertices, closest to this point
EdgePoint sym() const
represents the same point relative to sym edge in
Definition MREdgePoint.h:40
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
MRMESH_API EdgePoint(const MeshTopology &topology, VertId v)
EdgePoint(EdgeId e, float a)
Definition MREdgePoint.h:16
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:13
EdgeId e
Definition MREdgePoint.h:12
EdgePoint()=default
MRMESH_API EdgePoint(const PolylineTopology &topology, VertId v)
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:36
bool fromSameTriangle(const MeshTopology &topology, EdgePoint &&a, EdgePoint &&b)
Definition MREdgePoint.h:85
Represents a segment on one edge.
Definition MREdgePoint.h:61
EdgePoint edgePointA() const
Definition MREdgePoint.h:71
EdgeSegment(EdgeId e, float a=0.0f, float b=1.0f)
Definition MREdgePoint.h:69
SegmPointf b
Definition MREdgePoint.h:67
SegmPointf a
Definition MREdgePoint.h:65
bool valid() const
Definition MREdgePoint.h:75
EdgeId e
Definition MREdgePoint.h:63
EdgeSegment()=default
EdgePoint edgePointB() const
Definition MREdgePoint.h:73