00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MiVolumeCell_H
00024 #define _MiVolumeCell_H
00025
00026 #ifdef _WIN32
00027 # pragma warning( push )
00028 # pragma warning(disable:4250)
00029 #endif
00030
00031 #include <MeshVizXLM/mesh/cell/MiCell.h>
00032 #include <MeshVizXLM/mesh/data/MiDataSet.h>
00033
00034 #include <Inventor/STL/vector>
00035 #include <Inventor/STL/utility>
00036
00088 class MESHVIZXLM_EXTR_API MiVolumeCell : public MiCell
00089 {
00090 public:
00091
00095 virtual size_t getNumFacets() const = 0;
00096
00114 virtual size_t appendNodesIndexOfFacet (size_t facet, std::vector<size_t>& facetNodes) const = 0;
00115
00133 virtual size_t getSubTriangleNodesIndex(size_t SO_UNUSED_PARAM(facet), std::vector<size_t>& SO_UNUSED_PARAM(triangleNodeIds)) const
00134 {
00135 return 0;
00136 }
00137
00148 virtual size_t getSubTetrahedronNodesIndex (std::vector<size_t>& SO_UNUSED_PARAM(tetrahedronNodeIds)) const
00149 {
00150 return 0;
00151 }
00152
00174 virtual size_t appendLocalNodesIndexOfFacet (size_t SO_UNUSED_PARAM(facet), std::vector<size_t>& SO_UNUSED_PARAM(facetNodes)) const
00175 {
00176 throw MiAbstractMethodError("MiVolumeCell::appendLocalNodesIndexOfFacet(size_t facet, std::vector<size_t>& facetNodes)");
00177 }
00178
00213 virtual void getIsosurfTopology(unsigned char caseId, std::vector< std::pair<size_t,size_t> >& edgeList ) const = 0;
00214
00229 virtual unsigned char getMarchingCaseId(std::vector<bool> &nodesSign, size_t beginNodeId=0) const;
00230
00242 virtual MbVec3d getFacetCenter(size_t SO_UNUSED_PARAM(facet), const MiGeometryI& SO_UNUSED_PARAM(geometry)) const;
00243
00244 private: protected:
00248 virtual std::ostream& toStream(std::ostream& s) const;
00249
00250 };
00251
00252
00253 inline unsigned char
00254 MiVolumeCell::getMarchingCaseId(std::vector<bool> &nodesSign, size_t beginNodeId) const
00255 {
00256 unsigned char caseId = 0;
00257 unsigned char maxId = 0;
00258 size_t i;
00259 for (i=0; i<getNumNodes(); ++i)
00260 {
00261 if (nodesSign[getNodeIndex(i)-beginNodeId]) caseId |= (1<<i);
00262 maxId |= (1<<i);
00263 }
00264 if (caseId == maxId)
00265 caseId = 0;
00266 return caseId;
00267 }
00268
00269
00270 inline MbVec3d
00271 MiVolumeCell::getFacetCenter(size_t facet, const MiGeometryI& geometry) const
00272 {
00273 std::vector<size_t> facetNodes;
00274 MbVec3d facetCenter(0);
00275 size_t numFacetNodes = this->appendNodesIndexOfFacet(facet,facetNodes);
00276 for ( size_t n = 0; n < numFacetNodes; ++n)
00277 facetCenter += geometry.getCoord(facetNodes[n]);
00278 return ( facetCenter / (double) numFacetNodes );
00279 }
00280
00281
00282 inline std::ostream&
00283 MiVolumeCell::toStream(std::ostream& s) const
00284 {
00285 s << "# num cell's facets" << std::endl;
00286 s << getNumFacets() << std::endl;
00287
00288 s << "# num cell's nodes" << std::endl;
00289 s << getNumNodes();
00290
00291 std::vector<size_t> facetNodes;
00292 for (size_t i=0; i<getNumFacets(); ++i)
00293 {
00294 facetNodes.clear();
00295 s << std::endl << "[";
00296 appendNodesIndexOfFacet(i,facetNodes);
00297 for (size_t j=0; j<facetNodes.size(); ++j)
00298 s << facetNodes[j] << " ";
00299 s << "]";
00300 }
00301
00302 return s;
00303 }
00304
00305
00306
00307 #ifdef _WIN32
00308 # pragma warning( pop )
00309 #endif
00310
00311 #endif
00312
00313
00314