Newer
Older
// Gmsh - Copyright (C) 1997-2011 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#ifndef _MVERTEX_H_
#define _MVERTEX_H_
#include "MVertexBoundaryLayerData.h"
class MVertex;
class MVertexLessThanLexicographic{
public:
static double tolerance;
bool operator()(const MVertex *v1, const MVertex *v2) const;
};
class MVertexLessThanNum{
public:
bool operator()(const MVertex *v1, const MVertex *v2) const;
};
protected:
// the immutable id number of the vertex (this number is unique and
// is guaranteed never to change once a vertex has been created)
// a vertex index, used for example during mesh generation or when
// saving a mesh (this index is not necessarily unique, can change
// after mesh renumbering, etc.). By convention, vertices with
// negative indices are not saved
inline void deleteLast() {if(_num == _globalNum) _globalNum--; delete this;}
// get/reset the global node number
static int getGlobalNumber(){ return _globalNum; }
static void resetGlobalNumber(){ _globalNum = 0; }
virtual char getVisibility(){ return _visible; }
virtual void setVisibility(char val){ _visible = val; }
// get the "polynomial order" of the vertex
inline int getPolynomialOrder(){ return _order; }
inline void setPolynomialOrder(int order){ _order = (char)order; }
inline double x() const { return _x; }
inline double y() const { return _y; }
inline double z() const { return _z; }
inline double & x() { return _x; }
inline double & y() { return _y; }
inline double & z() { return _z; }
inline void setXYZ(double x, double y, double z) { _x = x; _y = y; _z = z; }
inline void setEntity(GEntity *ge) { _ge = ge; }
// force the immutable number (this should normally never be used)
void forceNum(int num);
// get/set the index
inline int getIndex() const { return _index; }
inline void setIndex(int index) { _index = index; }
virtual bool getParameter(int i, double &par) const { par = 0.; return false; }
// measure distance to another vertex
double distance(MVertex *v)
{
double dx = _x - v->x();
double dy = _y - v->y();
double dz = _z - v->z();
return sqrt(dx * dx + dy * dy + dz * dz);
}
// linear coordinate search for the vertex in a set
std::set<MVertex*, MVertexLessThanLexicographic>::iterator
linearSearch(std::set<MVertex*, MVertexLessThanLexicographic> &pos);
void writeMSH(FILE *fp, bool binary=false, bool saveParametric=false,
double scalingFactor=1.0);
Emilie Marchandise
committed
void writePLY2(FILE *fp);
void writeVRML(FILE *fp, double scalingFactor=1.0);
void writeUNV(FILE *fp, double scalingFactor=1.0);
void writeVTK(FILE *fp, bool binary=false, double scalingFactor=1.0,
bool bigEndian=false);
void writeMESH(FILE *fp, double scalingFactor=1.0);
void writeINP(FILE *fp, double scalingFactor=1.0);
void writeDIFF(FILE *fp, bool binary, double scalingFactor=1.0);
MVertexBoundaryLayerData* bl_data;
MEdgeVertex(double x, double y, double z, GEntity *ge, double u, double lc = -1.0,
int num = 0)
: MVertex(x, y, z, ge,num), _u(u), _lc(lc)
virtual bool getParameter(int i, double &par) const { par = _u; return true; }
virtual bool setParameter(int i, double par){ _u = par; return true; }
MVertexBoundaryLayerData* bl_data;
MFaceVertex(double x, double y, double z, GEntity *ge, double u, double v, int num = 0)
: MVertex(x, y, z, ge, num), _u(u), _v(v)
virtual bool getParameter(int i, double &par) const { par = (i ? _v : _u); return true; }
virtual bool setParameter(int i, double par)
{
if(!i)
_u = par;
else
_v = par;
return true;
}
bool reparamMeshEdgeOnFace(MVertex *v1, MVertex *v2, GFace *gf,
SPoint2 ¶m1, SPoint2 ¶m2);
bool reparamMeshVertexOnFace(const MVertex *v, const GFace *gf, SPoint2 ¶m,
bool onSurface=true);
Stefen Guzik
committed
bool reparamMeshVertexOnEdge(const MVertex *v, const GEdge *ge, double ¶m);
double angle3Vertices(MVertex *p1, MVertex *p2, MVertex *p3);