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
00073 class MESHVIZXLM_EXTR_API MiCell
00074 {
00075 public:
00076
00080 virtual ~MiCell() {}
00081
00087 virtual size_t getNumNodes() const = 0;
00088
00093 virtual size_t getNodeIndex(size_t node) const = 0;
00094
00117 virtual double getRelativeSize(const MiGeometryI* SO_UNUSED_PARAM(meshGeometry)) const
00118 {
00119 return 1;
00120 }
00121
00153 virtual void getWeight(const MbVec3d& SO_UNUSED_PARAM(ipcoord), std::vector<double>& SO_UNUSED_PARAM(weight)) const
00154 {
00155 throw MiAbstractMethodError("MiCell::getWeight(const MbVec3d &, std::vector<double>&)");
00156 }
00157
00184 virtual MbVec3d getIsoParametricCoord(size_t SO_UNUSED_PARAM(nodeIndex)) const
00185 {
00186 throw MiAbstractMethodError("MiCell::getIsoParametricCoord(size_t nodeIndex)");
00187 }
00188
00199 virtual MbVec3d getCenter(const MiGeometryI& geometry) const;
00200
00201
00225 virtual bool isPointInsideCell(const MiGeometryI& SO_UNUSED_PARAM(meshGeometry),
00226 const MbVec3d& SO_UNUSED_PARAM(point),
00227 std::vector<double>& SO_UNUSED_PARAM(weights)) const
00228 {
00229 throw MiAbstractMethodError("MiCell::isPointInsideCell(const MbVec3d &point)");
00230 }
00231
00235 friend std::ostream& operator << (std::ostream& s, const MiCell& cell);
00236
00237 private: protected:
00241 virtual std::ostream& toStream(std::ostream& s) const;
00242
00243 };
00244
00245
00246 inline MbVec3d
00247 MiCell::getCenter(const MiGeometryI& geometry) const
00248 {
00249 MbVec3d center(0);
00250 for (size_t i=0; i<getNumNodes(); ++i)
00251 center += geometry.getCoord(getNodeIndex(i));
00252 return ( center / (double) getNumNodes() );
00253 }
00254
00255
00256 inline std::ostream&
00257 MiCell::toStream(std::ostream& s) const
00258 {
00259 s << "# num cell's nodes" << std::endl;
00260 s << getNumNodes() << std::endl;
00261 s << "[";
00262 for (size_t i=0; i<getNumNodes(); ++i)
00263 s << getNodeIndex(i) << " ";
00264 s << "]";
00265
00266 return s;
00267 }
00268
00269
00270 inline std::ostream&
00271 operator << (std::ostream& s, const MiCell& cell)
00272 {
00273 return cell.toStream(s);
00274 }
00275
00276
00277 #endif
00278
00279
00280
00281
00282
00283
00284
00285