/usr/include/gmsh/MEdge.h is in libgmsh-dev 2.8.5+dfsg-1.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | // Gmsh - Copyright (C) 1997-2014 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@geuz.org>.
#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])]; }
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
{
// this computes one of the normals to the edge
SVector3 t = tangent(), ex(0., 0., 0.);
if(t[0] == 0.)
ex[0] = 1.;
else if(t[1] == 0.)
ex[1] = 1.;
else
ex[2] = 1.;
SVector3 n = crossprod(t, ex);
n.normalize();
return n;
}
inline SPoint3 barycenter() const
{
return interpolate(0.5);
}
inline SPoint3 interpolate(const double &t) const
{
return SPoint3(t * _v[1]->x() + (1. - t) * _v[0]->x(),
t * _v[1]->y() + (1. - t) * _v[0]->y(),
t * _v[1]->z() + (1. - t) * _v[0]->z());
}
bool isInside(MVertex *v) const;
};
inline bool operator==(const MEdge &e1, const MEdge &e2)
{
return (e1.getMinVertex() == e2.getMinVertex() &&
e1.getMaxVertex() == e2.getMaxVertex());
}
inline bool operator!=(const MEdge &e1, const MEdge &e2)
{
return (e1.getMinVertex() != e2.getMinVertex() ||
e1.getMaxVertex() != e2.getMaxVertex());
}
struct Equal_Edge : public std::binary_function<MEdge, MEdge, bool> {
bool operator()(const MEdge &e1, const MEdge &e2) const
{
return (e1 == e2);
}
};
struct Less_Edge : public std::binary_function<MEdge, MEdge, bool> {
bool operator()(const MEdge &e1, const MEdge &e2) const
{
if(e1.getMinVertex()->getNum() < e2.getMinVertex()->getNum()) return true;
if(e1.getMinVertex()->getNum() > e2.getMinVertex()->getNum()) return false;
if(e1.getMaxVertex()->getNum() < e2.getMaxVertex()->getNum()) return true;
return false;
}
};
#endif
|