Select Git revision
mainWindow.h
Forked from
gmsh / gmsh
Source project has a limited visibility.
MEdge.h 3.63 KiB
// Gmsh - Copyright (C) 1997-2018 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
#ifndef _MEDGE_H_
#define _MEDGE_H_
#include <functional>
#include "MVertex.h"
#include "SVector3.h"
// A mesh edge.
class MEdge {
private:
MVertex *_v[2];
char _si[2]; // sorted indices
public:
MEdge()
{
_v[0] = _v[1] = 0;
_si[0] = _si[1] = 0;
}
MEdge(MVertex *v0, MVertex *v1)
{
_v[0] = v0; _v[1] = v1;
if(_v[1]->getNum() < _v[0]->getNum()) {
_si[0] = 1;
_si[1] = 0;
}
else {
_si[0] = 0;
_si[1] = 1;
}
}
inline int getNumVertices() const { return 2; }
inline MVertex *getVertex(const int i) const { return _v[i]; }
inline MVertex *getSortedVertex(const int i) const { return _v[int(_si[i])]; }
inline MVertex *getMinVertex() const { return _v[int(_si[0])]; }
inline MVertex *getMaxVertex() const { return _v[int(_si[1])]; }
inline int computeCorrespondence(MEdge& other) {
if (other.getVertex(0) == _v[0] && other.getVertex(1) == _v[1]) return 1;
else if (other.getVertex(0) == _v[1] && other.getVertex(1) == _v[0]) return -1;
return 0;
}
SVector3 scaledTangent() const
{
return SVector3(_v[1]->x() - _v[0]->x(),
_v[1]->y() - _v[0]->y(),
_v[1]->z() - _v[0]->z());
}
SVector3 tangent() const
{
SVector3 t(_v[1]->x() - _v[0]->x(),
_v[1]->y() - _v[0]->y(),
_v[1]->z() - _v[0]->z());
t.normalize();
return t;
}
double length() const
{
SVector3 t(_v[1]->x() - _v[0]->x(),
_v[1]->y() - _v[0]->y(),
_v[1]->z() - _v[0]->z());
return t.norm();
}
SVector3 normal() const