23#ifndef VCL_SPACE_COMPLEX_MESH_POS_H
24#define VCL_SPACE_COMPLEX_MESH_POS_H
26#include <vclib/mesh/components/adjacent_faces.h>
27#include <vclib/mesh/elements/face.h>
47template<face::HasAdjacentFaces FaceType>
50 const FaceType* mFace =
nullptr;
52 const typename FaceType::VertexType* mVertex =
nullptr;
57 using VertexType = FaceType::VertexType;
64 MeshPos(
const FaceType* f,
short e) : mFace(f), mEdge(e)
67 mVertex = f->vertex(e);
71 MeshPos(
const FaceType* f,
const VertexType* v) : mFace(f), mVertex(v)
73 for (uint
i = 0;
i < f->vertexNumber();
i++)
74 if (f->vertex(
i) == v)
89 MeshPos(
const FaceType* f,
const VertexType* v,
short e) :
90 mFace(f), mVertex(v), mEdge(e)
108 static bool isValid(
const FaceType* f,
const VertexType* v,
short e)
110 if (f ==
nullptr || v ==
nullptr || e < 0)
112 if (!comp::isAdjacentFacesAvailableOn(*f))
114 return (
ushort) e < f->vertexNumber() &&
115 (v == f->vertex(e) || v == f->vertexMod(e + 1));
118 const FaceType* face()
const {
return mFace; }
120 const VertexType* vertex()
const {
return mVertex; }
122 short edge()
const {
return mEdge; }
124 const FaceType* adjFace()
const {
return mFace->adjFace(mEdge); }
126 const VertexType* adjVertex()
const
128 MeshPos<FaceType> tmpPos = *
this;
130 return tmpPos.vertex();
133 short adjEdge()
const
135 MeshPos<FaceType> tmpPos = *
this;
137 return tmpPos.edge();
153 return mFace ==
nullptr || mVertex ==
nullptr || mEdge < 0;
188 const FaceType*
nf = mFace->adjFace(mEdge);
190 mEdge =
nf->indexOfAdjFace(mFace);
205 if (mFace->vertexMod(mEdge) == mVertex) {
206 mVertex = mFace->vertexMod(mEdge + 1);
209 mVertex = mFace->vertexMod(mEdge);
219 if (mFace->vertexMod(mEdge + 1) == mVertex) {
220 mEdge = (mEdge + 1) % (
short) mFace->vertexNumber();
223 short n = mFace->vertexNumber();
224 mEdge = ((mEdge - 1) %
n +
n) %
273 bool onBorder =
false;
274 uint count = countAdjacentFacesToV(onBorder);
284 return mFace ==
op.mFace && mVertex ==
op.mVertex && mEdge ==
op.mEdge;
287 bool operator!=(
const MeshPos& op)
const {
return !(*
this == op); }
289 bool operator<(
const MeshPos& op)
const
291 if (mFace == op.mFace) {
292 if (mEdge == op.mEdge)
293 return mVertex < op.mVertex;
295 return mEdge < op.mEdge;
298 return mFace < op.mFace;
303 uint countAdjacentFacesToV(
bool& onBorder)
const
308 MeshPos<FaceType> mp = *
this;
312 mp.nextEdgeAdjacentToV();
316 if (mp.isEdgeOnBorder())
The MeshPos class describes a "Position in a Mesh" that can be identified with a triplet of Face-Vert...
Definition mesh_pos.h:49
uint numberOfAdjacentFacesToV() const
Returns the number of adjacent faces to the current vertex of this MeshPos. This works also for verti...
Definition mesh_pos.h:271
MeshPos()=default
Empty constructor that creates a null (invalid) MeshPos.
bool isEdgeOnBorder() const
Returns true if the current edge of this MeshPos is on a border. To check if is on border,...
Definition mesh_pos.h:163
void flipVertex()
Moves this MeshPos to the vertex adjacent to the current vertex that shares the same face and the sam...
Definition mesh_pos.h:203
bool isCCWOriented() const
Returns true if the current vertex of the MeshPos corresponts to the first vertex of the current edge...
Definition mesh_pos.h:173
MeshPos(const FaceType *f, const VertexType *v, short e)
Constructor that creates a MeshPos with the given facem vertex and edge. The given triplet must descr...
Definition mesh_pos.h:89
static bool isValid(const FaceType *f, const VertexType *v, short e)
Helper function to check if a MeshPos is valid, that is if:
Definition mesh_pos.h:108
bool nextEdgeOnBorderAdjacentToV()
Moves the MeshPos to the next edge on border that is adjacent to the current vertex of the MeshPos....
Definition mesh_pos.h:254
bool flipFace()
Moves this MeshPos to the face adjacent to the current face that shares the same vertex and the same ...
Definition mesh_pos.h:186
bool isNull() const
Returns true if this is null, non initialized, MeshPos. The result of this function is different from...
Definition mesh_pos.h:151
void nextEdgeAdjacentToV()
Moves this MeshPos to the next edge that is adjacent to the current vertex of the MeshPos....
Definition mesh_pos.h:240
void flipEdge()
Moves this MeshPos to the edge adjacent to the current edge that shares the same face and the same ve...
Definition mesh_pos.h:217
bool isValid() const
Returns true if this MeshPos is valid.
Definition mesh_pos.h:144
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43