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
00083 class MESHIVIZ_API MiVolumeCell : public MiCell
00084 {
00085 public:
00086
00090 virtual size_t getNumFacets() const = 0;
00091
00109 virtual size_t appendNodesIndexOfFacet (size_t facet, std::vector<size_t>& facetNodes) const = 0;
00110
00128 virtual size_t getSubTriangleNodesIndex(size_t SO_UNUSED_PARAM(facet), std::vector<size_t>& SO_UNUSED_PARAM(triangleNodeIds)) const
00129 {
00130 return 0;
00131 }
00132
00143 virtual size_t getSubTetrahedronNodesIndex (std::vector<size_t>& SO_UNUSED_PARAM(tetrahedronNodeIds)) const
00144 {
00145 return 0;
00146 }
00147
00169 virtual size_t appendLocalNodesIndexOfFacet (size_t SO_UNUSED_PARAM(facet), std::vector<size_t>& SO_UNUSED_PARAM(facetNodes)) const
00170 {
00171 throw MiAbstractMethodError("MiVolumeCell::appendLocalNodesIndexOfFacet(size_t facet, std::vector<size_t>& facetNodes)");
00172 }
00173
00208 virtual void getIsosurfTopology(unsigned char caseId, std::vector< std::pair<size_t,size_t> >& edgeList ) const = 0;
00209
00224 virtual unsigned char getMarchingCaseId(std::vector<bool> &nodesSign, size_t beginNodeId=0) const;
00225
00237 virtual MbVec3d getFacetCenter(size_t SO_UNUSED_PARAM(facet), const MiGeometryI& SO_UNUSED_PARAM(geometry)) const;
00238
00239 private: protected:
00243 virtual std::ostream& toStream(std::ostream& s) const;
00244
00245 };
00246
00247
00248 inline unsigned char
00249 MiVolumeCell::getMarchingCaseId(std::vector<bool> &nodesSign, size_t beginNodeId) const
00250 {
00251 unsigned char caseId = 0;
00252 unsigned char maxId = 0;
00253 size_t i;
00254 for (i=0; i<getNumNodes(); ++i)
00255 {
00256 if (nodesSign[getNodeIndex(i)-beginNodeId]) caseId |= (1<<i);
00257 maxId |= (1<<i);
00258 }
00259 if (caseId == maxId)
00260 caseId = 0;
00261 return caseId;
00262 }
00263
00264
00265 inline MbVec3d
00266 MiVolumeCell::getFacetCenter(size_t facet, const MiGeometryI& geometry) const
00267 {
00268 std::vector<size_t> facetNodes;
00269 MbVec3d facetCenter(0);
00270 size_t numFacetNodes = this->appendNodesIndexOfFacet(facet,facetNodes);
00271 for ( size_t n = 0; n < numFacetNodes; ++n)
00272 facetCenter += geometry.getCoord(facetNodes[n]);
00273 return ( facetCenter / (double) numFacetNodes );
00274 }
00275
00276
00277 inline std::ostream&
00278 MiVolumeCell::toStream(std::ostream& s) const
00279 {
00280 s << "# num cell's facets" << std::endl;
00281 s << getNumFacets() << std::endl;
00282
00283 s << "# num cell's nodes" << std::endl;
00284 s << getNumNodes();
00285
00286 std::vector<size_t> facetNodes;
00287 for (size_t i=0; i<getNumFacets(); ++i)
00288 {
00289 facetNodes.clear();
00290 s << std::endl << "[";
00291 appendNodesIndexOfFacet(i,facetNodes);
00292 for (size_t j=0; j<facetNodes.size(); ++j)
00293 s << facetNodes[j] << " ";
00294 s << "]";
00295 }
00296
00297 return s;
00298 }
00299
00300
00301
00302 #ifdef _WIN32
00303 # pragma warning( pop )
00304 #endif
00305
00306 #endif
00307
00308
00309