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
13template <typename T>
15{
16 EdgeId e;
18
19 [[nodiscard]] EdgePointT() = default;
20 [[nodiscard]] EdgePointT( EdgeId e, T a ) : e( e ), a( a ) { }
21 [[nodiscard]] MRMESH_API EdgePointT( const MeshTopology & topology, VertId v );
22 [[nodiscard]] MRMESH_API EdgePointT( const PolylineTopology & topology, VertId v );
23
25 [[nodiscard]] MRMESH_API VertId inVertex( const MeshTopology & topology ) const;
27 [[nodiscard]] MRMESH_API VertId inVertex( const PolylineTopology & topology ) const;
29 [[nodiscard]] MRMESH_API VertId getClosestVertex( const MeshTopology & topology ) const;
31 [[nodiscard]] MRMESH_API VertId getClosestVertex( const PolylineTopology & topology ) const;
33 [[nodiscard]] bool inVertex() const { return a.inVertex() >= 0; }
37 [[nodiscard]] MRMESH_API bool isBd( const MeshTopology & topology, const FaceBitSet * region = nullptr ) const;
38
40 [[nodiscard]] bool valid() const { return e.valid(); }
41 [[nodiscard]] explicit operator bool() const { return e.valid(); }
42
44 [[nodiscard]] EdgePointT sym() const { return EdgePointT{ e.sym(), 1 - a }; }
46 [[nodiscard]] bool operator==( const EdgePointT& rhs ) const = default;
47};
48
50template <typename T>
51[[nodiscard]] MRMESH_API bool same( const MeshTopology & topology, const EdgePointT<T>& lhs, const EdgePointT<T>& rhs );
52MR_BIND_TEMPLATE( bool same( const MeshTopology & topology, const EdgePointT<float>& lhs, const EdgePointT<float>& rhs ) )
53MR_BIND_TEMPLATE( bool same( const MeshTopology & topology, const EdgePointT<double>& lhs, const EdgePointT<double>& rhs ) )
54
55
57{
60 EdgePointPair() = default;
61 EdgePointPair( EdgePoint ia, EdgePoint ib ) : a( ia ), b( ib ) {}
63 bool operator==( const EdgePointPair& rhs ) const = default;
64};
65
67template <typename T>
69{
71 EdgeId e;
76 [[nodiscard]] EdgeSegmentT() = default;
77 [[nodiscard]] EdgeSegmentT( EdgeId e, T a = 0, T b = 1 ) : e( e ), a( a ), b( b ) { assert( valid() ); };
79 [[nodiscard]] EdgePointT<T> edgePointA() const { return { e, a }; }
81 [[nodiscard]] EdgePointT<T> edgePointB() const { return { e, b }; }
83 [[nodiscard]] bool valid() const { return e.valid() && a <= b; }
84
85 bool operator==( const EdgeSegmentT& rhs ) const = default;
87 [[nodiscard]] EdgeSegmentT sym() const { return EdgeSegmentT{ e.sym(), b.sym(), a.sym() }; }
88};
89
93template <typename T>
94[[nodiscard]] MRMESH_API bool fromSameTriangle( const MeshTopology & topology, EdgePointT<T> & a, EdgePointT<T> & b );
95MR_BIND_TEMPLATE( bool fromSameTriangle( const MeshTopology & topology, EdgePointT<float> & a, EdgePointT<float> & b ) )
96MR_BIND_TEMPLATE( bool fromSameTriangle( const MeshTopology & topology, EdgePointT<double> & a, EdgePointT<double> & b ) )
100template <typename T>
101[[nodiscard]] inline bool fromSameTriangle( const MeshTopology & topology, EdgePointT<T> && a, EdgePointT<T> && b ) { return fromSameTriangle( topology, a, b ); }
102MR_BIND_TEMPLATE( bool fromSameTriangle( const MeshTopology & topology, EdgePointT<float> && a, EdgePointT<float> && b ) )
103MR_BIND_TEMPLATE( bool fromSameTriangle( const MeshTopology & topology, EdgePointT<double> && a, EdgePointT<double> && b ) )
104
105}
#define MRMESH_API
Definition MRMeshFwd.h:85
Definition MRMeshTopology.h:31
Definition MRPolylineTopology.h:18
EdgePointT()=default
EdgeId e
Definition MREdgePoint.h:71
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)
struct
Definition MRMeshFwd.h:189
EdgePointPair(EdgePoint ia, EdgePoint ib)
Definition MREdgePoint.h:61
EdgePointT< float >(EdgePointd, EdgePointT< double >)) 1((template< typename T > struct)
bool valid() const
returns true if the edge is valid and start point is less than end point
Definition MREdgePoint.h:83
EdgePoint
Definition MRMeshFwd.h:477
EdgeId e
Definition MREdgePoint.h:16
bool operator==(const EdgePointPair &rhs) const =default
returns true if two edge-point pairs are equal including equal not-unique representation
EdgePointT< T > edgePointB() const
returns ending EdgePoint
Definition MREdgePoint.h:81
EdgePointT< T > edgePointA() const
returns starting EdgePoint
Definition MREdgePoint.h:79
EdgePointT(const MeshTopology &topology, VertId v)
bool same(const MeshTopology &topology, const EdgePointT< T > &lhs, const EdgePointT< T > &rhs)
returns true if two edge-points are equal considering different representations
EdgePointT(EdgeId e, T a)
Definition MREdgePoint.h:20
EdgeSegmentT sym() const
represents the same segment relative to sym edge in
Definition MREdgePoint.h:87
VertId getClosestVertex(const PolylineTopology &topology) const
returns one of two edge vertices, closest to this point
SegmPoint< T > a
a in [0,1], a=0 => point is in org( e ), a=1 => point is in dest( e )
Definition MREdgePoint.h:17
VertId getClosestVertex(const MeshTopology &topology) const
returns one of two edge vertices, closest to this point
EdgePointT
Definition MRMeshFwd.h:476
EdgePointPair()=default
SegmPoint< float > a
Definition MREdgePoint.h:73
bool inVertex() const
returns true if the point is in a vertex
Definition MREdgePoint.h:33
EdgePointT sym() const
represents the same point relative to sym edge in
Definition MREdgePoint.h:44
EdgePoint b
Definition MREdgePoint.h:59
bool operator==(const EdgePointT &rhs) const =default
returns true if two edge-points are equal including equal not-unique representation
void moveToClosestVertex()
sets this to the closest end of the edge
bool operator==(const EdgeSegmentT &rhs) const =default
MR_BIND_TEMPLATE(std::pair< Vector3f, TriPointf > closestPointInTriangle(const Vector3f &p, const Vector3f &a, const Vector3f &b, const Vector3f &c))
EdgePoint a
Definition MREdgePoint.h:58
SegmPoint< float > b
Definition MREdgePoint.h:75
EdgeSegmentT()=default
EdgeSegmentT(EdgeId e, T a=0, T b=1)
Definition MREdgePoint.h:77
bool valid() const
consider this valid if the edge ID is valid
Definition MREdgePoint.h:40
VertId inVertex(const PolylineTopology &topology) const
returns valid vertex id if the point is in vertex, otherwise returns invalid id
EdgePointT(const PolylineTopology &topology, VertId v)
VertId inVertex(const MeshTopology &topology) const
returns valid vertex id if the point is in vertex, otherwise returns invalid id
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
encodes a point on an edge of mesh or of polyline
Definition MREdgePoint.h:15
encodes a point inside a line segment using relative distance in [0,1]
Definition MRSegmPoint.h:17