00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MxTriangle6CellExtract_h
00024 #define _MxTriangle6CellExtract_h
00025
00026 #include <MeshVizXLM/mesh/geometry/MiGeometryI.h>
00027
00028 #include <Inventor/STL/vector>
00029 #include <Inventor/STL/utility>
00030
00031 class MiSurfaceCell;
00032
00057 class MESHVIZXLM_EXTR_API MxTriangle6CellExtract
00058 {
00059 public:
00060
00074 static MbVec3d getIsoParametricCoord(const MiGeometryI& meshGeometry, const MiSurfaceCell* triangleCell, const MbVec3d &point);
00075
00081 static MbVec3d getIsoParametricCoord(size_t nodeIndex)
00082 {
00083 return MbVec3d(s_nodesIsoParametricCoords[nodeIndex]);
00084 }
00085
00105 static void getWeight(const MiGeometryI& meshGeometry, const MiSurfaceCell* triangleCell, const MbVec3d &point, std::vector<double>& weights)
00106 {
00107 getWeight(getIsoParametricCoord(meshGeometry,triangleCell,point),weights);
00108 }
00109
00122 static void getWeight(const MbVec3d &ipcoord, std::vector<double>& weights);
00123
00135 static void getDerivs(const MbVec3d &ipcoord, std::vector<double>& derivs);
00136
00150 static bool isPointInsideCell(const MiGeometryI& meshGeometry, const MiSurfaceCell* triangleCell, const MbVec3d &point, std::vector<double>& weights)
00151 {
00152 MbVec3d pcoord = getIsoParametricCoord(meshGeometry,triangleCell,point);
00153 bool inside = ( -1.E-5 < pcoord[0] && pcoord[0] < 1 + 1.E-5 &&
00154 -1.E-5 < pcoord[1] && pcoord[1] < 1 + 1.E-5 &&
00155 -1.E-5 < (pcoord[0]+pcoord[1]) && (pcoord[0]+pcoord[1]) < 1 + 1.E-5);
00156 if (inside)
00157 getWeight(pcoord,weights);
00158 return inside;
00159 }
00160
00168 static size_t getSubTriangleNodesIndex (std::vector<size_t>& triangleNodeIds)
00169 {
00170 triangleNodeIds.assign(s_subTriangleNodeIds,s_subTriangleNodeIds+(4*3));
00171 return 4;
00172 }
00173
00174 friend std::ostream& operator << (std::ostream& s, const MxTriangle6CellExtract& cell);
00175
00176 private:
00177 static double s_nodesIsoParametricCoords[6][3];
00178 static size_t s_subTriangleNodeIds[4*3];
00179 };
00180
00181
00182 inline void
00183 MxTriangle6CellExtract::getWeight(const MbVec3d &ipcoord, std::vector<double>& weight)
00184 {
00185 double r = ipcoord[0];
00186 double s = ipcoord[1];
00187 weight[0] = (1-r-s) * ( 2*(1-r-s)-1 );
00188 weight[1] = r * (2*r-1);
00189 weight[2] = s * (2*s-1);
00190 weight[3] = 4 * r * (1-r-s);
00191 weight[4] = 4 * r * s;
00192 weight[5] = 4 * s * (1-r-s);
00193 }
00194
00195
00196 #endif
00197
00198