Skip to content
Snippets Groups Projects
Commit a9b793d7 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

more getEdge/FaceRep

parent e4dd176c
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,42 @@ ...@@ -14,6 +14,42 @@
#include "qualityMeasures.h" #include "qualityMeasures.h"
#endif #endif
void MHexahedron::getEdgeRep(bool curved, int num, double *x, double *y, double *z,
SVector3 *n)
{
// don't use MElement::_getEdgeRep: it's slow due to the creation of MFaces
MVertex *v0 = _v[edges_hexa(num, 0)];
MVertex *v1 = _v[edges_hexa(num, 1)];
x[0] = v0->x(); y[0] = v0->y(); z[0] = v0->z();
x[1] = v1->x(); y[1] = v1->y(); z[1] = v1->z();
if(CTX::instance()->mesh.lightLines > 1){
static const int vv[12] = {2, 2, 3, 3, 2, 0, 1, 0, 6, 5, 4, 4};
MVertex *v2 = _v[vv[num]];
SVector3 t1(x[1] - x[0], y[1] - y[0], z[1] - z[0]);
SVector3 t2(v2->x() - x[0], v2->y() - y[0], v2->z() - z[0]);
SVector3 normal = crossprod(t1, t2);
normal.normalize();
n[0] = n[1] = normal;
}
else{
n[0] = n[1] = SVector3(0., 0., 1.);
}
}
void MHexahedron::getFaceRep(bool curved, int num, double *x, double *y, double *z,
SVector3 *n)
{
static const int f[12][3] = {
{0, 3, 2}, {0, 2, 1},
{0, 1, 5}, {0, 5, 4},
{0, 4, 7}, {0, 7, 3},
{1, 2, 6}, {1, 6, 5},
{2, 3, 7}, {2, 7, 6},
{4, 5, 6}, {4, 6, 7}
};
_getFaceRep(_v[f[num][0]], _v[f[num][1]], _v[f[num][2]], x, y, z, n);
}
int MHexahedron::getVolumeSign() int MHexahedron::getVolumeSign()
{ {
double mat[3][3]; double mat[3][3];
... ...
......
...@@ -70,12 +70,7 @@ class MHexahedron : public MElement { ...@@ -70,12 +70,7 @@ class MHexahedron : public MElement {
return MEdge(_v[edges_hexa(num, 0)], _v[edges_hexa(num, 1)]); return MEdge(_v[edges_hexa(num, 0)], _v[edges_hexa(num, 1)]);
} }
virtual int getNumEdgesRep(bool curved){ return 12; } virtual int getNumEdgesRep(bool curved){ return 12; }
virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n) virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n);
{
static const int f[12] = {0, 0, 1, 0, 1, 0, 3, 2, 1, 2, 3, 4};
MEdge e(getEdge(num));
_getEdgeRep(e.getVertex(0), e.getVertex(1), x, y, z, n, f[num]);
}
virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const
{ {
v.resize(2); v.resize(2);
...@@ -93,19 +88,7 @@ class MHexahedron : public MElement { ...@@ -93,19 +88,7 @@ class MHexahedron : public MElement {
virtual double angleShapeMeasure(); virtual double angleShapeMeasure();
virtual void getFaceInfo (const MFace & face, int &ithFace, int &sign, int &rot)const; virtual void getFaceInfo (const MFace & face, int &ithFace, int &sign, int &rot)const;
virtual int getNumFacesRep(bool curved){ return 12; } virtual int getNumFacesRep(bool curved){ return 12; }
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n) virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n);
{
static const int f[12][3] = {
{0, 3, 2}, {0, 2, 1},
{0, 1, 5}, {0, 5, 4},
{0, 4, 7}, {0, 7, 3},
{1, 2, 6}, {1, 6, 5},
{2, 3, 7}, {2, 7, 6},
{4, 5, 6}, {4, 6, 7}
};
_getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]),
x, y, z, n);
}
virtual void getFaceVertices(const int num, std::vector<MVertex*> &v) const virtual void getFaceVertices(const int num, std::vector<MVertex*> &v) const
{ {
v.resize(4); v.resize(4);
... ...
......
...@@ -18,6 +18,37 @@ ...@@ -18,6 +18,37 @@
#define SQU(a) ((a)*(a)) #define SQU(a) ((a)*(a))
void MQuadrangle::getEdgeRep(bool curved, int num, double *x, double *y, double *z,
SVector3 *n)
{
// don't use MElement::_getEdgeRep: it's slow due to the creation of MFace
MVertex *v0 = _v[edges_quad(num, 0)];
MVertex *v1 = _v[edges_quad(num, 1)];
x[0] = v0->x(); y[0] = v0->y(); z[0] = v0->z();
x[1] = v1->x(); y[1] = v1->y(); z[1] = v1->z();
if(CTX::instance()->mesh.lightLines > 1){
static const int vv[4] = {2, 3, 0, 1};
MVertex *v2 = _v[vv[num]];
SVector3 t1(x[1] - x[0], y[1] - y[0], z[1] - z[0]);
SVector3 t2(v2->x() - x[0], v2->y() - y[0], v2->z() - z[0]);
SVector3 normal = crossprod(t1, t2);
normal.normalize();
n[0] = n[1] = normal;
}
else{
n[0] = n[1] = SVector3(0., 0., 1.);
}
}
void MQuadrangle::getFaceRep(bool curved, int num, double *x, double *y, double *z,
SVector3 *n)
{
static const int f[2][3] = {
{0, 1, 2}, {0, 2, 3}
};
_getFaceRep(_v[f[num][0]], _v[f[num][1]], _v[f[num][2]], x, y, z, n);
}
int MQuadrangleN::getNumEdgesRep(bool curved) int MQuadrangleN::getNumEdgesRep(bool curved)
{ {
return curved ? 4 * CTX::instance()->mesh.numSubEdges : 4; return curved ? 4 * CTX::instance()->mesh.numSubEdges : 4;
... ...
......
...@@ -83,11 +83,7 @@ class MQuadrangle : public MElement { ...@@ -83,11 +83,7 @@ class MQuadrangle : public MElement {
Msg::Error("Could not get edge information for quadranglee %d", getNum()); Msg::Error("Could not get edge information for quadranglee %d", getNum());
} }
virtual int getNumEdgesRep(bool curved){ return 4; } virtual int getNumEdgesRep(bool curved){ return 4; }
virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n) virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n);
{
MEdge e(getEdge(num));
_getEdgeRep(e.getVertex(0), e.getVertex(1), x, y, z, n, 0);
}
virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const
{ {
v.resize(2); v.resize(2);
...@@ -96,14 +92,7 @@ class MQuadrangle : public MElement { ...@@ -96,14 +92,7 @@ class MQuadrangle : public MElement {
virtual int getNumFaces(){ return 1; } virtual int getNumFaces(){ return 1; }
virtual MFace getFace(int num){ return MFace(_v[0], _v[1], _v[2], _v[3]); } virtual MFace getFace(int num){ return MFace(_v[0], _v[1], _v[2], _v[3]); }
virtual int getNumFacesRep(bool curved){ return 2; } virtual int getNumFacesRep(bool curved){ return 2; }
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n) virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n);
{
static const int f[2][3] = {
{0, 1, 2}, {0, 2, 3}
};
_getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]),
x, y, z, n);
}
virtual void getFaceVertices(const int num, std::vector<MVertex*> &v) const virtual void getFaceVertices(const int num, std::vector<MVertex*> &v) const
{ {
v.resize(4); v.resize(4);
... ...
......
...@@ -42,18 +42,10 @@ void MTetrahedron::getEdgeRep(bool curved, int num, double *x, double *y, double ...@@ -42,18 +42,10 @@ void MTetrahedron::getEdgeRep(bool curved, int num, double *x, double *y, double
void MTetrahedron::getFaceRep(bool curved, int num, double *x, double *y, double *z, void MTetrahedron::getFaceRep(bool curved, int num, double *x, double *y, double *z,
SVector3 *n) SVector3 *n)
{ {
// don't use MElement::_getFaceRep: it's slow due to the creation of MFaces
MVertex *v0 = _v[faces_tetra(num, 0)]; MVertex *v0 = _v[faces_tetra(num, 0)];
MVertex *v1 = _v[faces_tetra(num, 1)]; MVertex *v1 = _v[faces_tetra(num, 1)];
MVertex *v2 = _v[faces_tetra(num, 2)]; MVertex *v2 = _v[faces_tetra(num, 2)];
x[0] = v0->x(); x[1] = v1->x(); x[2] = v2->x(); _getFaceRep(v0, v1, v2, x, y, z, n);
y[0] = v0->y(); y[1] = v1->y(); y[2] = v2->y();
z[0] = v0->z(); z[1] = v1->z(); z[2] = v2->z();
SVector3 t1(x[1] - x[0], y[1] - y[0], z[1] - z[0]);
SVector3 t2(x[2] - x[0], y[2] - y[0], z[2] - z[0]);
SVector3 normal = crossprod(t1, t2);
normal.normalize();
for(int i = 0; i < 3; i++) n[i] = normal;
} }
SPoint3 MTetrahedron::circumcenter() SPoint3 MTetrahedron::circumcenter()
... ...
......
...@@ -42,15 +42,7 @@ void MTriangle::getEdgeRep(bool curved, int num, double *x, double *y, double *z ...@@ -42,15 +42,7 @@ void MTriangle::getEdgeRep(bool curved, int num, double *x, double *y, double *z
void MTriangle::getFaceRep(bool curved, int num, double *x, double *y, double *z, void MTriangle::getFaceRep(bool curved, int num, double *x, double *y, double *z,
SVector3 *n) SVector3 *n)
{ {
// don't use MElement::_getFaceRep: it's slow due to the creation of MFaces _getFaceRep(_v[0], _v[1], _v[2], x, y, z, n);
x[0] = _v[0]->x(); x[1] = _v[1]->x(); x[2] = _v[2]->x();
y[0] = _v[0]->y(); y[1] = _v[1]->y(); y[2] = _v[2]->y();
z[0] = _v[0]->z(); z[1] = _v[1]->z(); z[2] = _v[2]->z();
SVector3 t1(x[1] - x[0], y[1] - y[0], z[1] - z[0]);
SVector3 t2(x[2] - x[0], y[2] - y[0], z[2] - z[0]);
SVector3 normal = crossprod(t1, t2);
normal.normalize();
for(int i = 0; i < 3; i++) n[i] = normal;
} }
SPoint3 MTriangle::circumcenter() SPoint3 MTriangle::circumcenter()
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment