From d022d0f74e0200a6375d6404487e48f3ff0a5ad3 Mon Sep 17 00:00:00 2001 From: Amaury Johnen <amaury.johnen@uclouvain.be> Date: Wed, 10 May 2017 20:25:47 +0200 Subject: [PATCH] allow hexahedron subdivisions for nice figures --- Geo/MHexahedron.cpp | 34 ++++++++++++++++++++++++++++++++++ Geo/MHexahedron.h | 26 ++------------------------ 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/Geo/MHexahedron.cpp b/Geo/MHexahedron.cpp index 27fa10fb21..458be4e825 100644 --- a/Geo/MHexahedron.cpp +++ b/Geo/MHexahedron.cpp @@ -411,6 +411,40 @@ int MHexahedronN::getNumFacesRep(bool curved) CTX::instance()->mesh.numSubEdges * 2) : 12; } +int MHexahedron::getNumFacesRep(bool curved) +{ + return 6 * (CTX::instance()->mesh.numSubEdges * + CTX::instance()->mesh.numSubEdges * 2); +} + +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); + if (CTX::instance()->mesh.numSubEdges > 1) { + _myGetFaceRep(this, num, x, y, z, n, CTX::instance()->mesh.numSubEdges); + return; + } + static const int f[24][4] = { + {0, 3, 2, 1}, {3, 2, 1, 0}, {2, 1, 0, 3}, {1, 0, 3, 2}, + {0, 1, 5, 4}, {1, 5, 4, 0}, {5, 4, 0, 1}, {4, 0, 1, 5}, + {0, 4, 7, 3}, {4, 7, 3, 0}, {7, 3, 0, 4}, {3, 0, 4, 7}, + {1, 2, 6, 5}, {2, 6, 5, 1}, {6, 5, 1, 2}, {5, 1, 2, 6}, + {2, 3, 7, 6}, {3, 7, 6, 2}, {7, 6, 2, 3}, {6, 2, 3, 7}, + {4, 5, 6, 7}, {5, 6, 7, 4}, {6, 7, 4, 5}, {7, 4, 5, 6} + }; + _getFaceRepQuad(getVertex(f[num][0]), getVertex(f[num][1]), + getVertex(f[num][2]), getVertex(f[num][3]), + x, y, z, n); +} + void _getIndicesReversedHex(int order, indicesReversed &indices) { fullMatrix<double> ref = gmshGenerateMonomialsHexahedron(order); diff --git a/Geo/MHexahedron.h b/Geo/MHexahedron.h index 1ed4c5b5f8..d65e80ad10 100644 --- a/Geo/MHexahedron.h +++ b/Geo/MHexahedron.h @@ -87,30 +87,8 @@ class MHexahedron : public MElement { virtual double getInnerRadius(); virtual double angleShapeMeasure(); virtual void getFaceInfo(const MFace & face, int &ithFace, int &sign, int &rot) const; - virtual int getNumFacesRep(bool curved){ return 24; } - 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(_v[f[num][0]], _v[f[num][1]], _v[f[num][2]], x, y, z, n); - static const int f[24][4] = { - {0, 3, 2, 1}, {3, 2, 1, 0}, {2, 1, 0, 3}, {1, 0, 3, 2}, - {0, 1, 5, 4}, {1, 5, 4, 0}, {5, 4, 0, 1}, {4, 0, 1, 5}, - {0, 4, 7, 3}, {4, 7, 3, 0}, {7, 3, 0, 4}, {3, 0, 4, 7}, - {1, 2, 6, 5}, {2, 6, 5, 1}, {6, 5, 1, 2}, {5, 1, 2, 6}, - {2, 3, 7, 6}, {3, 7, 6, 2}, {7, 6, 2, 3}, {6, 2, 3, 7}, - {4, 5, 6, 7}, {5, 6, 7, 4}, {6, 7, 4, 5}, {7, 4, 5, 6} - }; - _getFaceRepQuad(getVertex(f[num][0]), getVertex(f[num][1]), - getVertex(f[num][2]), getVertex(f[num][3]), - x, y, z, n); - } + virtual int getNumFacesRep(bool curved); + virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n); virtual void getFaceVertices(const int num, std::vector<MVertex*> &v) const { v.resize(4); -- GitLab