00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MiCell_H
00024 #define _MiCell_H
00025
00026 #include <MeshVizXLM/mesh/geometry/MiGeometryI.h>
00027 #include <MeshVizXLM/MxMeshVizXLM.h>
00028 #include <MeshVizXLM/MiAbstractMethodError.h>
00029
00030 #include <MeshVizXLM/MbVec3.h>
00031 #include <Inventor/STL/vector>
00032 #include <Inventor/STL/ostream>
00033
00068 class MESHVIZXLM_EXTR_API MiCell
00069 {
00070 public:
00071
00075 virtual ~MiCell() {}
00076
00082 virtual size_t getNumNodes() const = 0;
00083
00088 virtual size_t getNodeIndex(size_t node) const = 0;
00089
00112 virtual double getRelativeSize(const MiGeometryI* SO_UNUSED_PARAM(meshGeometry)) const
00113 {
00114 return 1;
00115 }
00116
00148 virtual void getWeight(const MbVec3d& SO_UNUSED_PARAM(ipcoord), std::vector<double>& SO_UNUSED_PARAM(weight)) const
00149 {
00150 throw MiAbstractMethodError("MiCell::getWeight(const MbVec3d &, std::vector<double>&)");
00151 }
00152
00179 virtual MbVec3d getIsoParametricCoord(size_t SO_UNUSED_PARAM(nodeIndex)) const
00180 {
00181 throw MiAbstractMethodError("MiCell::getIsoParametricCoord(size_t nodeIndex)");
00182 }
00183
00194 virtual MbVec3d getCenter(const MiGeometryI& geometry) const;
00195
00196
00220 virtual bool isPointInsideCell(const MiGeometryI& SO_UNUSED_PARAM(meshGeometry),
00221 const MbVec3d& SO_UNUSED_PARAM(point),
00222 std::vector<double>& SO_UNUSED_PARAM(weights)) const
00223 {
00224 throw MiAbstractMethodError("MiCell::isPointInsideCell(const MbVec3d &point)");
00225 }
00226
00230 friend std::ostream& operator << (std::ostream& s, const MiCell& cell);
00231
00232 private: protected:
00236 virtual std::ostream& toStream(std::ostream& s) const;
00237
00238 };
00239
00240
00241 inline MbVec3d
00242 MiCell::getCenter(const MiGeometryI& geometry) const
00243 {
00244 MbVec3d center(0);
00245 for (size_t i=0; i<getNumNodes(); ++i)
00246 center += geometry.getCoord(getNodeIndex(i));
00247 return ( center / (double) getNumNodes() );
00248 }
00249
00250
00251 inline std::ostream&
00252 MiCell::toStream(std::ostream& s) const
00253 {
00254 s << "# num cell's nodes" << std::endl;
00255 s << getNumNodes() << std::endl;
00256 s << "[";
00257 for (size_t i=0; i<getNumNodes(); ++i)
00258 s << getNodeIndex(i) << " ";
00259 s << "]";
00260
00261 return s;
00262 }
00263
00264
00265 inline std::ostream&
00266 operator << (std::ostream& s, const MiCell& cell)
00267 {
00268 return cell.toStream(s);
00269 }
00270
00271
00272 #endif
00273
00274
00275
00276
00277
00278
00279
00280