Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
MiVolumeCell.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23#ifndef _MiVolumeCell_H
24#define _MiVolumeCell_H
25
26#ifdef _WIN32
27# pragma warning( push )
28# pragma warning(disable:4250)
29#endif
30
33
34#include <Inventor/STL/vector>
35#include <Inventor/STL/utility>
36
89{
90public:
91
95 virtual size_t getNumFacets() const = 0;
96
114 virtual size_t appendNodesIndexOfFacet (size_t facet, std::vector<size_t>& facetNodes) const = 0;
115
133 virtual size_t getSubTriangleNodesIndex(size_t SO_UNUSED_PARAM(facet), std::vector<size_t>& SO_UNUSED_PARAM(triangleNodeIds)) const
134 {
135 return 0;
136 }
137
148 virtual size_t getSubTetrahedronNodesIndex (std::vector<size_t>& SO_UNUSED_PARAM(tetrahedronNodeIds)) const
149 {
150 return 0;
151 }
152
174 virtual size_t appendLocalNodesIndexOfFacet (size_t SO_UNUSED_PARAM(facet), std::vector<size_t>& SO_UNUSED_PARAM(facetNodes)) const
175 {
176 throw MiAbstractMethodError("MiVolumeCell::appendLocalNodesIndexOfFacet(size_t facet, std::vector<size_t>& facetNodes)");
177 }
178
213 virtual void getIsosurfTopology(unsigned char caseId, std::vector< std::pair<size_t,size_t> >& edgeList ) const = 0;
214
229 virtual unsigned char getMarchingCaseId(std::vector<bool> &nodesSign, size_t beginNodeId=0) const;
230
242 virtual MbVec3d getFacetCenter(size_t SO_UNUSED_PARAM(facet), const MiGeometryI& SO_UNUSED_PARAM(geometry)) const;
243
244private: protected:
248 virtual std::ostream& toStream(std::ostream& s) const;
249
250};
251
252//-----------------------------------------------------------------------------
253inline unsigned char
254MiVolumeCell::getMarchingCaseId(std::vector<bool> &nodesSign, size_t beginNodeId) const
255{
256 unsigned char caseId = 0;
257 unsigned char maxId = 0;
258 size_t i;
259 for (i=0; i<getNumNodes(); ++i)
260 {
261 if (nodesSign[getNodeIndex(i)-beginNodeId]) caseId |= (1<<i);
262 maxId |= (1<<i);
263 }
264 if (caseId == maxId)
265 caseId = 0;
266 return caseId;
267}
268
269//-----------------------------------------------------------------------------
270inline MbVec3d
271MiVolumeCell::getFacetCenter(size_t facet, const MiGeometryI& geometry) const
272{
273 std::vector<size_t> facetNodes;
274 MbVec3d facetCenter(0);
275 size_t numFacetNodes = this->appendNodesIndexOfFacet(facet,facetNodes);
276 for ( size_t n = 0; n < numFacetNodes; ++n)
277 facetCenter += geometry.getCoord(facetNodes[n]);
278 return ( facetCenter / (double) numFacetNodes );
279}
280
281//-----------------------------------------------------------------------------
282inline std::ostream&
283MiVolumeCell::toStream(std::ostream& s) const
284{
285 s << "# num cell's facets" << std::endl;
286 s << getNumFacets() << std::endl;
287
288 s << "# num cell's nodes" << std::endl;
289 s << getNumNodes();
290
291 std::vector<size_t> facetNodes;
292 for (size_t i=0; i<getNumFacets(); ++i)
293 {
294 facetNodes.clear();
295 s << std::endl << "[";
296 appendNodesIndexOfFacet(i,facetNodes);
297 for (size_t j=0; j<facetNodes.size(); ++j)
298 s << facetNodes[j] << " ";
299 s << "]";
300 }
301
302 return s;
303}
304
305
306
307#ifdef _WIN32
308# pragma warning( pop )
309#endif
310
311#endif
312
313
#define MESHVIZXLM_EXTR_API
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Exception handler for Me...
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Defines an abstract cell...
Definition MiCell.h:74
virtual size_t getNodeIndex(size_t node) const =0
Gets the index (in the mesh) of a node.
virtual size_t getNumNodes() const =0
Gets the number of nodes.
virtual std::ostream & toStream(std::ostream &s) const
Performs an output operation on a stream which is returned afterward.
Definition MiCell.h:257
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Generic geometry interfa...
Definition MiGeometryI.h:39
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Defines an abstract cell...
virtual size_t appendLocalNodesIndexOfFacet(size_t facet, std::vector< size_t > &facetNodes) const
Appends the array of local node indices belonging to a given facet to facetNodes.
virtual size_t getSubTriangleNodesIndex(size_t facet, std::vector< size_t > &triangleNodeIds) const
Get a triangulation of the given facet of a non linear volume cell.
virtual void getIsosurfTopology(unsigned char caseId, std::vector< std::pair< size_t, size_t > > &edgeList) const =0
Gets the list of topological polygons defining the part of the isosurface topology in this cell.
virtual unsigned char getMarchingCaseId(std::vector< bool > &nodesSign, size_t beginNodeId=0) const
Gets the isosurface "marching cube" entry according to the sign of each node in the cell.
virtual size_t getNumFacets() const =0
Gets the number of facets.
virtual size_t getSubTetrahedronNodesIndex(std::vector< size_t > &tetrahedronNodeIds) const
Get a decomposition in sub-tetrahedra of this volume cell.
virtual std::ostream & toStream(std::ostream &s) const
Performs an output operation on a stream which is returned afterward.
virtual size_t appendNodesIndexOfFacet(size_t facet, std::vector< size_t > &facetNodes) const =0
Appends the array of node indices belonging to a given facet to facetNode.
virtual MbVec3d getFacetCenter(size_t facet, const MiGeometryI &geometry) const
Gets the center of the specified cell facet.