1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMDS_VolumeTool.cxx
23 // Created : Tue Jul 13 12:22:13 2004
24 // Author : Edward AGAPOV (eap)
27 #pragma warning(disable:4786)
30 #include "SMDS_VolumeTool.hxx"
32 #include "SMDS_MeshElement.hxx"
33 #include "SMDS_MeshNode.hxx"
34 #include "SMDS_PolyhedralVolumeOfNodes.hxx"
35 #include "SMDS_Mesh.hxx"
37 #include "utilities.h"
45 // ======================================================
46 // Node indices in faces depending on volume orientation
47 // making most faces normals external
48 // ======================================================
56 // N0 +---|---+ N1 TETRAHEDRON
64 static int Tetra_F [4][4] = { // FORWARD == EXTERNAL
65 { 0, 1, 2, 0 }, // All faces have external normals
69 static int Tetra_R [4][4] = { // REVERSED
70 { 0, 1, 2, 0 }, // All faces but a bottom have external normals
74 static int Tetra_RE [4][4] = { // REVERSED -> FORWARD (EXTERNAL)
75 { 0, 2, 1, 0 }, // All faces have external normals
79 static int Tetra_nbN [] = { 3, 3, 3, 3 };
84 static int Pyramid_F [5][5] = { // FORWARD == EXTERNAL
85 { 0, 1, 2, 3, 0 }, // All faces have external normals
90 static int Pyramid_R [5][5] = { // REVERSED
91 { 0, 1, 2, 3, 0 }, // All faces but a bottom have external normals
96 static int Pyramid_RE [5][5] = { // REVERSED -> FORWARD (EXTERNAL)
97 { 0, 3, 2, 1, 0 }, // All faces but a bottom have external normals
102 static int Pyramid_nbN [] = { 4, 3, 3, 3, 3 };
113 // | / \ | PENTAHEDRON
119 static int Penta_F [5][5] = { // FORWARD
120 { 0, 1, 2, 0, 0 }, // Top face has an internal normal, other - external
121 { 3, 4, 5, 3, 3 }, // 0 is bottom, 1 is top face
125 static int Penta_R [5][5] = { // REVERSED
126 { 0, 1, 2, 0, 0 }, // Bottom face has an internal normal, other - external
127 { 3, 4, 5, 3, 3 }, // 0 is bottom, 1 is top face
131 static int Penta_FE [5][5] = { // FORWARD -> EXTERNAL
137 static int Penta_RE [5][5] = { // REVERSED -> EXTERNAL
143 static int Penta_nbN [] = { 3, 3, 4, 4, 4 };
150 // N4+----------+N7 |
151 // | | | | HEXAHEDRON
154 // | N1+------|---+N2
160 static int Hexa_F [6][5] = { // FORWARD
161 { 0, 1, 2, 3, 0 }, // opposite faces are neighbouring,
162 { 4, 5, 6, 7, 4 }, // odd face(1,3,5) normal is internal, even(0,2,4) - external
163 { 1, 0, 4, 5, 1 }, // same index nodes of opposite faces are linked
167 // static int Hexa_R [6][5] = { // REVERSED
168 // { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring,
169 // { 4, 7, 6, 5, 4 }, // odd face(1,3,5) normal is external, even(0,2,4) - internal
170 // { 1, 5, 4, 0, 1 }, // same index nodes of opposite faces are linked
171 // { 2, 6, 7, 3, 2 },
172 // { 0, 4, 7, 3, 0 },
173 // { 1, 5, 6, 2, 1 }};
174 static int Hexa_FE [6][5] = { // FORWARD -> EXTERNAL
175 { 0, 1, 2, 3, 0 } , // opposite faces are neighbouring,
176 { 4, 7, 6, 5, 4 }, // all face normals are external,
177 { 0, 4, 5, 1, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
181 static int Hexa_RE [6][5] = { // REVERSED -> EXTERNAL
182 { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring,
183 { 4, 5, 6, 7, 4 }, // all face normals are external,
184 { 0, 1, 5, 4, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
188 static int Hexa_nbN [] = { 4, 4, 4, 4, 4, 4 };
197 // N0 +---|---+ N1 TETRAHEDRON
205 static int QuadTetra_F [4][7] = { // FORWARD == EXTERNAL
206 { 0, 4, 1, 5, 2, 6, 0 }, // All faces have external normals
207 { 0, 7, 3, 8, 1, 4, 0 },
208 { 1, 8, 3, 9, 2, 5, 1 },
209 { 0, 6, 2, 9, 3, 7, 0 }};
210 static int QuadTetra_R [4][7] = { // REVERSED
211 { 0, 4, 1, 5, 2, 6, 0 }, // All faces but a bottom have external normals
212 { 0, 4, 1, 8, 3, 7, 0 },
213 { 1, 5, 2, 9, 3, 8, 1 },
214 { 0, 7, 3, 9, 2, 6, 0 }};
215 static int QuadTetra_RE [4][7] = { // REVERSED -> FORWARD (EXTERNAL)
216 { 0, 6, 2, 5, 1, 4, 0 }, // All faces have external normals
217 { 0, 4, 1, 8, 3, 7, 0 },
218 { 1, 5, 2, 9, 3, 8, 1 },
219 { 0, 7, 3, 9, 2, 6, 0 }};
220 static int QuadTetra_nbN [] = { 6, 6, 6, 6 };
230 // | | 9 - middle point for (0,4) etc.
243 static int QuadPyram_F [5][9] = { // FORWARD == EXTERNAL
244 { 0, 5, 1, 6, 2, 7, 3, 8, 0 }, // All faces have external normals
245 { 0, 9, 4, 10,1, 5, 0, 4, 4 },
246 { 1, 10,4, 11,2, 6, 1, 4, 4 },
247 { 2, 11,4, 12,3, 7, 2, 4, 4 },
248 { 3, 12,4, 9, 0, 8, 3, 4, 4 }};
249 static int QuadPyram_R [5][9] = { // REVERSED
250 { 0, 5, 1, 6, 2, 7, 3, 8, 0 }, // All faces but a bottom have external normals
251 { 0, 5, 1, 10,4, 9, 0, 4, 4 },
252 { 1, 6, 2, 11,4, 10,1, 4, 4 },
253 { 2, 7, 3, 12,4, 11,2, 4, 4 },
254 { 3, 8, 0, 9, 4, 12,3, 4, 4 }};
255 static int QuadPyram_RE [5][9] = { // REVERSED -> FORWARD (EXTERNAL)
256 { 0, 8, 3, 7, 2, 6, 1, 5, 0 }, // All faces but a bottom have external normals
257 { 0, 5, 1, 10,4, 9, 0, 4, 4 },
258 { 1, 6, 2, 11,4, 10,1, 4, 4 },
259 { 2, 7, 3, 12,4, 11,2, 4, 4 },
260 { 3, 8, 0, 9, 4, 12,3, 4, 4 }};
261 static int QuadPyram_nbN [] = { 8, 6, 6, 6, 6 };
288 static int QuadPenta_F [5][9] = { // FORWARD
289 { 0, 6, 1, 7, 2, 8, 0, 0, 0 }, // Top face has an internal normal, other - external
290 { 3, 9, 4, 10,5, 11,3, 3, 3 }, // 0 is bottom, 1 is top face
291 { 0, 8, 2, 14,5, 11,3, 12,0 },
292 { 1, 13,4, 10,5, 14,2, 7, 1 },
293 { 0, 12,3, 9, 4, 13,1, 6, 0 }};
294 static int QuadPenta_R [5][9] = { // REVERSED
295 { 0, 6, 1, 7, 2, 8, 0, 0, 0 }, // Bottom face has an internal normal, other - external
296 { 3, 9, 4, 10,5, 11,3, 3, 3 }, // 0 is bottom, 1 is top face
297 { 0, 12,3, 11,5, 14,2, 8, 0 },
298 { 1, 7, 2, 14,5, 10,4, 13,1 },
299 { 0, 6, 1, 13,4, 9, 3, 12,0 }};
300 static int QuadPenta_FE [5][9] = { // FORWARD -> EXTERNAL
301 { 0, 6, 1, 7, 2, 8, 0, 0, 0 },
302 { 3,11, 5, 10,4, 9, 3, 3, 3 },
303 { 0, 8, 2, 14,5, 11,3, 12,0 },
304 { 1, 13,4, 10,5, 14,2, 7, 1 },
305 { 0, 12,3, 9, 4, 13,1, 6, 0 }};
306 static int QuadPenta_RE [5][9] = { // REVERSED -> EXTERNAL
307 { 0, 8, 2, 7, 1, 6, 0, 0, 0 },
308 { 3, 9, 4, 10,5, 11,3, 3, 3 },
309 { 0, 12,3, 11,5, 14,2, 8, 0 },
310 { 1, 7, 2, 14,5, 10,4, 13,1 },
311 { 0, 6, 1, 13,4, 9, 3, 12,0 }};
312 static int QuadPenta_nbN [] = { 6, 6, 8, 8, 8 };
320 // N4+-----+-----+N7 | QUADRATIC
321 // | | 15 | | HEXAHEDRON
330 // | N1+-----+-|---+N2
337 static int QuadHexa_F [6][9] = { // FORWARD
338 { 0, 8, 1, 9, 2, 10,3, 11,0 }, // opposite faces are neighbouring,
339 { 4, 12,5, 13,6, 14,7, 15,4 }, // odd face(1,3,5) normal is internal, even(0,2,4) - external
340 { 1, 8, 0, 16,4, 12,5, 17,1 }, // same index nodes of opposite faces are linked
341 { 2, 10,3, 19,7, 14,6, 18,2 },
342 { 0, 11,3, 19,7, 15,4, 16,0 },
343 { 1, 9, 2, 18,6, 13,5, 17,1 }};
344 // static int Hexa_R [6][5] = { // REVERSED
345 // { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring,
346 // { 4, 7, 6, 5, 4 }, // odd face(1,3,5) normal is external, even(0,2,4) - internal
347 // { 1, 5, 4, 0, 1 }, // same index nodes of opposite faces are linked
348 // { 2, 6, 7, 3, 2 },
349 // { 0, 4, 7, 3, 0 },
350 // { 1, 5, 6, 2, 1 }};
351 static int QuadHexa_FE [6][9] = { // FORWARD -> EXTERNAL
352 { 0, 8, 1, 9, 2, 10,3, 11,0 }, // opposite faces are neighbouring,
353 { 4, 15,7, 14,6, 13,5, 12,4 }, // all face normals are external,
354 { 0, 16,4, 12,5, 17,1, 8, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
355 { 3, 10,2, 18,6, 14,7, 19,3 },
356 { 0, 11,3, 19,7, 15,4, 16,0 },
357 { 1, 17,5, 13,6, 18,2, 9, 1 }};
358 static int QuadHexa_RE [6][9] = { // REVERSED -> EXTERNAL
359 { 0, 11,3, 10,2, 9, 1, 8, 0 }, // opposite faces are neighbouring,
360 { 4, 12,5, 13,6, 14,7, 15,4 }, // all face normals are external,
361 { 0, 8, 1, 17,5, 12,4, 16,0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
362 { 3, 19,7, 14,6, 18,2, 10,3 },
363 { 0, 16,4, 15,7, 19,3, 11,0 },
364 { 1, 9, 2, 18,6, 13,5, 17,1 }};
365 static int QuadHexa_nbN [] = { 8, 8, 8, 8, 8, 8 };
368 // ========================================================
369 // to perform some calculations without linkage to CASCADE
370 // ========================================================
377 XYZ() { x = 0; y = 0; z = 0; }
378 XYZ( double X, double Y, double Z ) { x = X; y = Y; z = Z; }
379 XYZ( const XYZ& other ) { x = other.x; y = other.y; z = other.z; }
380 XYZ( const SMDS_MeshNode* n ) { x = n->X(); y = n->Y(); z = n->Z(); }
381 inline XYZ operator-( const XYZ& other );
382 inline XYZ Crossed( const XYZ& other );
383 inline double Dot( const XYZ& other );
384 inline double Magnitude();
386 inline XYZ XYZ::operator-( const XYZ& Right ) {
387 return XYZ(x - Right.x, y - Right.y, z - Right.z);
389 inline XYZ XYZ::Crossed( const XYZ& Right ) {
390 return XYZ (y * Right.z - z * Right.y,
391 z * Right.x - x * Right.z,
392 x * Right.y - y * Right.x);
394 inline double XYZ::Dot( const XYZ& Other ) {
395 return(x * Other.x + y * Other.y + z * Other.z);
397 inline double XYZ::Magnitude() {
398 return sqrt (x * x + y * y + z * z);
402 //=======================================================================
403 //function : SMDS_VolumeTool
405 //=======================================================================
407 SMDS_VolumeTool::SMDS_VolumeTool ()
410 myVolForward( true ),
412 myVolumeNbNodes( 0 ),
413 myVolumeNodes( NULL ),
414 myExternalFaces( false ),
417 myFaceNodeIndices( NULL ),
422 //=======================================================================
423 //function : SMDS_VolumeTool
425 //=======================================================================
427 SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume)
430 myVolForward( true ),
432 myVolumeNbNodes( 0 ),
433 myVolumeNodes( NULL ),
434 myExternalFaces( false ),
437 myFaceNodeIndices( NULL ),
443 //=======================================================================
444 //function : SMDS_VolumeTool
446 //=======================================================================
448 SMDS_VolumeTool::~SMDS_VolumeTool()
450 if ( myVolumeNodes != NULL ) delete [] myVolumeNodes;
451 if ( myFaceNodes != NULL ) delete [] myFaceNodes;
453 myFaceNodeIndices = NULL;
454 myVolumeNodes = myFaceNodes = NULL;
457 //=======================================================================
458 //function : SetVolume
459 //purpose : Set volume to iterate on
460 //=======================================================================
462 bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume)
470 if (myVolumeNodes != NULL) {
471 delete [] myVolumeNodes;
472 myVolumeNodes = NULL;
475 myExternalFaces = false;
479 myFaceNodeIndices = NULL;
480 if (myFaceNodes != NULL) {
481 delete [] myFaceNodes;
485 if ( theVolume && theVolume->GetType() == SMDSAbs_Volume )
487 myVolume = theVolume;
489 myNbFaces = theVolume->NbFaces();
490 myVolumeNbNodes = theVolume->NbNodes();
494 myVolumeNodes = new const SMDS_MeshNode* [myVolumeNbNodes];
495 SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator();
496 while ( nodeIt->more() ) {
497 myVolumeNodes[ iNode++ ] = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
500 if (myVolume->IsPoly()) {
501 myPolyedre = static_cast<const SMDS_PolyhedralVolumeOfNodes*>( myVolume );
503 MESSAGE("Warning: bad volumic element");
508 switch ( myVolumeNbNodes ) {
517 // define volume orientation
519 GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z );
520 const SMDS_MeshNode* topNode = myVolumeNodes[ myVolumeNbNodes - 1 ];
521 const SMDS_MeshNode* botNode = myVolumeNodes[ 0 ];
522 XYZ upDir (topNode->X() - botNode->X(),
523 topNode->Y() - botNode->Y(),
524 topNode->Z() - botNode->Z() );
525 myVolForward = ( botNormal.Dot( upDir ) < 0 );
533 return ( myVolume != 0 );
536 //=======================================================================
538 //purpose : Inverse volume
539 //=======================================================================
541 #define SWAP_NODES(nodes,i1,i2) \
543 const SMDS_MeshNode* tmp = nodes[ i1 ]; \
544 nodes[ i1 ] = nodes[ i2 ]; \
547 void SMDS_VolumeTool::Inverse ()
549 if ( !myVolume ) return;
551 if (myVolume->IsPoly()) {
552 MESSAGE("Warning: attempt to inverse polyhedral volume");
556 myVolForward = !myVolForward;
559 // inverse top and bottom faces
560 switch ( myVolumeNbNodes ) {
562 SWAP_NODES( myVolumeNodes, 1, 2 );
565 SWAP_NODES( myVolumeNodes, 1, 3 );
568 SWAP_NODES( myVolumeNodes, 1, 2 );
569 SWAP_NODES( myVolumeNodes, 4, 5 );
572 SWAP_NODES( myVolumeNodes, 1, 3 );
573 SWAP_NODES( myVolumeNodes, 5, 7 );
577 SWAP_NODES( myVolumeNodes, 1, 2 );
578 SWAP_NODES( myVolumeNodes, 4, 6 );
579 SWAP_NODES( myVolumeNodes, 8, 9 );
582 SWAP_NODES( myVolumeNodes, 1, 3 );
583 SWAP_NODES( myVolumeNodes, 5, 8 );
584 SWAP_NODES( myVolumeNodes, 6, 7 );
585 SWAP_NODES( myVolumeNodes, 10, 12 );
588 SWAP_NODES( myVolumeNodes, 1, 2 );
589 SWAP_NODES( myVolumeNodes, 4, 5 );
590 SWAP_NODES( myVolumeNodes, 6, 8 );
591 SWAP_NODES( myVolumeNodes, 9, 11 );
592 SWAP_NODES( myVolumeNodes, 13, 14 );
595 SWAP_NODES( myVolumeNodes, 1, 3 );
596 SWAP_NODES( myVolumeNodes, 5, 7 );
597 SWAP_NODES( myVolumeNodes, 8, 11 );
598 SWAP_NODES( myVolumeNodes, 9, 10 );
599 SWAP_NODES( myVolumeNodes, 12, 15 );
600 SWAP_NODES( myVolumeNodes, 13, 14 );
601 SWAP_NODES( myVolumeNodes, 17, 19 );
607 //=======================================================================
608 //function : GetVolumeType
610 //=======================================================================
612 SMDS_VolumeTool::VolumeType SMDS_VolumeTool::GetVolumeType() const
618 // static const VolumeType types[] = {
619 // TETRA, // myVolumeNbNodes = 4
620 // PYRAM, // myVolumeNbNodes = 5
621 // PENTA, // myVolumeNbNodes = 6
622 // UNKNOWN, // myVolumeNbNodes = 7
623 // HEXA // myVolumeNbNodes = 8
625 // return types[ myVolumeNbNodes - 4 ];
626 switch(myVolumeNbNodes) {
627 case 4: return TETRA; break;
628 case 5: return PYRAM; break;
629 case 6: return PENTA; break;
630 case 8: return HEXA; break;
631 case 10: return QUAD_TETRA; break;
632 case 13: return QUAD_PYRAM; break;
633 case 15: return QUAD_PENTA; break;
634 case 20: return QUAD_HEXA; break;
642 //=======================================================================
643 //function : getTetraVolume
645 //=======================================================================
647 static double getTetraVolume(const SMDS_MeshNode* n1,
648 const SMDS_MeshNode* n2,
649 const SMDS_MeshNode* n3,
650 const SMDS_MeshNode* n4)
668 double Q1 = -(X1-X2)*(Y3*Z4-Y4*Z3);
669 double Q2 = (X1-X3)*(Y2*Z4-Y4*Z2);
670 double R1 = -(X1-X4)*(Y2*Z3-Y3*Z2);
671 double R2 = -(X2-X3)*(Y1*Z4-Y4*Z1);
672 double S1 = (X2-X4)*(Y1*Z3-Y3*Z1);
673 double S2 = -(X3-X4)*(Y1*Z2-Y2*Z1);
675 return (Q1+Q2+R1+R2+S1+S2)/6.0;
678 //=======================================================================
680 //purpose : Return element volume
681 //=======================================================================
683 double SMDS_VolumeTool::GetSize() const
689 if ( myVolume->IsPoly() )
694 // split a polyhedron into tetrahedrons
696 SMDS_VolumeTool* me = const_cast< SMDS_VolumeTool* > ( this );
698 me->GetBaryCenter(baryCenter.x, baryCenter.y, baryCenter.z);
699 SMDS_MeshNode bcNode ( baryCenter.x, baryCenter.y, baryCenter.z );
701 for ( int f = 0; f < NbFaces(); ++f )
703 bool externalFace = me->IsFaceExternal( f ); // it calls setFace()
704 for ( int n = 2; n < myFaceNbNodes; ++n )
706 double Vn = getTetraVolume( myFaceNodes[ 0 ],
710 /// cout <<"++++ " << Vn << " nodes " <<myFaceNodes[ 0 ]->GetID() << " " <<myFaceNodes[ n-1 ]->GetID() << " " <<myFaceNodes[ n ]->GetID() << " < " << V << endl;
711 V += externalFace ? -Vn : Vn;
717 const static int ind[] = {
718 0, 1, 3, 6, 11, 19, 32, 46, 66};
719 const static int vtab[][4] = {
736 // quadratic tetrahedron
761 // quadratic pentahedron
778 // quadratic hexahedron
803 int type = GetVolumeType();
805 int n2 = ind[type+1];
807 for (int i = n1; i < n2; i++) {
808 V -= getTetraVolume( myVolumeNodes[ vtab[i][0] ],
809 myVolumeNodes[ vtab[i][1] ],
810 myVolumeNodes[ vtab[i][2] ],
811 myVolumeNodes[ vtab[i][3] ]);
817 //=======================================================================
818 //function : GetBaryCenter
820 //=======================================================================
822 bool SMDS_VolumeTool::GetBaryCenter(double & X, double & Y, double & Z) const
828 for ( int i = 0; i < myVolumeNbNodes; i++ ) {
829 X += myVolumeNodes[ i ]->X();
830 Y += myVolumeNodes[ i ]->Y();
831 Z += myVolumeNodes[ i ]->Z();
833 X /= myVolumeNbNodes;
834 Y /= myVolumeNbNodes;
835 Z /= myVolumeNbNodes;
840 //================================================================================
842 * \brief Classify a point
843 * \param tol - thickness of faces
845 //================================================================================
847 bool SMDS_VolumeTool::IsOut(double X, double Y, double Z, double tol)
849 // LIMITATION: for convex volumes only
851 for ( int iF = 0; iF < myNbFaces; ++iF )
854 if ( !GetFaceNormal( iF, faceNormal.x, faceNormal.y, faceNormal.z ))
856 if ( !IsFaceExternal( iF ))
857 faceNormal = XYZ() - faceNormal; // reverse
859 XYZ face2p( p - XYZ( myFaceNodes[0] ));
860 if ( face2p.Dot( faceNormal ) > tol )
866 //=======================================================================
867 //function : SetExternalNormal
868 //purpose : Node order will be so that faces normals are external
869 //=======================================================================
871 void SMDS_VolumeTool::SetExternalNormal ()
873 myExternalFaces = true;
877 //=======================================================================
878 //function : NbFaceNodes
879 //purpose : Return number of nodes in the array of face nodes
880 //=======================================================================
882 int SMDS_VolumeTool::NbFaceNodes( int faceIndex )
884 if ( !setFace( faceIndex ))
886 return myFaceNbNodes;
889 //=======================================================================
890 //function : GetFaceNodes
891 //purpose : Return pointer to the array of face nodes.
892 // To comfort link iteration, the array
893 // length == NbFaceNodes( faceIndex ) + 1 and
894 // the last node == the first one.
895 //=======================================================================
897 const SMDS_MeshNode** SMDS_VolumeTool::GetFaceNodes( int faceIndex )
899 if ( !setFace( faceIndex ))
904 //=======================================================================
905 //function : GetFaceNodesIndices
906 //purpose : Return pointer to the array of face nodes indices
907 // To comfort link iteration, the array
908 // length == NbFaceNodes( faceIndex ) + 1 and
909 // the last node index == the first one.
910 //=======================================================================
912 const int* SMDS_VolumeTool::GetFaceNodesIndices( int faceIndex )
914 if ( !setFace( faceIndex ))
917 if (myVolume->IsPoly())
919 myPolyIndices.resize( myFaceNbNodes + 1 );
920 myFaceNodeIndices = & myPolyIndices[0];
921 for ( int i = 0; i <= myFaceNbNodes; ++i )
922 myFaceNodeIndices[i] = myVolume->GetNodeIndex( myFaceNodes[i] );
924 return myFaceNodeIndices;
927 //=======================================================================
928 //function : GetFaceNodes
929 //purpose : Return a set of face nodes.
930 //=======================================================================
932 bool SMDS_VolumeTool::GetFaceNodes (int faceIndex,
933 set<const SMDS_MeshNode*>& theFaceNodes )
935 if ( !setFace( faceIndex ))
938 theFaceNodes.clear();
939 int iNode, nbNode = myFaceNbNodes;
940 for ( iNode = 0; iNode < nbNode; iNode++ )
941 theFaceNodes.insert( myFaceNodes[ iNode ]);
946 //=======================================================================
947 //function : IsFaceExternal
948 //purpose : Check normal orientation of a returned face
949 //=======================================================================
951 bool SMDS_VolumeTool::IsFaceExternal( int faceIndex )
953 if ( myExternalFaces || !myVolume )
956 if (myVolume->IsPoly()) {
957 XYZ aNormal, baryCenter, p0 (myPolyedre->GetFaceNode(faceIndex + 1, 1));
958 GetFaceNormal(faceIndex, aNormal.x, aNormal.y, aNormal.z);
959 GetBaryCenter(baryCenter.x, baryCenter.y, baryCenter.z);
960 XYZ insideVec (baryCenter - p0);
961 if (insideVec.Dot(aNormal) > 0)
966 switch ( myVolumeNbNodes ) {
971 // only the bottom of a reversed tetrahedron can be internal
972 return ( myVolForward || faceIndex != 0 );
975 // in a forward pentahedron, the top is internal, in a reversed one - bottom
976 return ( myVolForward ? faceIndex != 1 : faceIndex != 0 );
979 // in a forward hexahedron, even face normal is external, odd - internal
980 bool odd = faceIndex % 2;
981 return ( myVolForward ? !odd : odd );
988 //=======================================================================
989 //function : GetFaceNormal
990 //purpose : Return a normal to a face
991 //=======================================================================
993 bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, double & Z)
995 if ( !setFace( faceIndex ))
998 XYZ p1 ( myFaceNodes[0] );
999 XYZ p2 ( myFaceNodes[1] );
1000 XYZ p3 ( myFaceNodes[2] );
1001 XYZ aVec12( p2 - p1 );
1002 XYZ aVec13( p3 - p1 );
1003 XYZ cross = aVec12.Crossed( aVec13 );
1005 //if ( myFaceNbNodes == 4 ) {
1006 if ( myFaceNbNodes >3 ) {
1007 XYZ p4 ( myFaceNodes[3] );
1008 XYZ aVec14( p4 - p1 );
1009 XYZ cross2 = aVec13.Crossed( aVec14 );
1010 cross.x += cross2.x;
1011 cross.y += cross2.y;
1012 cross.z += cross2.z;
1015 double size = cross.Magnitude();
1016 if ( size <= DBL_MIN )
1026 //=======================================================================
1027 //function : GetFaceArea
1028 //purpose : Return face area
1029 //=======================================================================
1031 double SMDS_VolumeTool::GetFaceArea( int faceIndex )
1033 if (myVolume->IsPoly()) {
1034 MESSAGE("Warning: attempt to obtain area of a face of polyhedral volume");
1038 if ( !setFace( faceIndex ))
1041 XYZ p1 ( myFaceNodes[0] );
1042 XYZ p2 ( myFaceNodes[1] );
1043 XYZ p3 ( myFaceNodes[2] );
1044 XYZ aVec12( p2 - p1 );
1045 XYZ aVec13( p3 - p1 );
1046 double area = aVec12.Crossed( aVec13 ).Magnitude() * 0.5;
1048 if ( myFaceNbNodes == 4 ) {
1049 XYZ p4 ( myFaceNodes[3] );
1050 XYZ aVec14( p4 - p1 );
1051 area += aVec14.Crossed( aVec13 ).Magnitude() * 0.5;
1056 //=======================================================================
1057 //function : GetOppFaceIndex
1058 //purpose : Return index of the opposite face if it exists, else -1.
1059 //=======================================================================
1061 int SMDS_VolumeTool::GetOppFaceIndex( int faceIndex ) const
1064 if (myVolume->IsPoly()) {
1065 MESSAGE("Warning: attempt to obtain opposite face on polyhedral volume");
1069 if ( faceIndex >= 0 && faceIndex < NbFaces() ) {
1070 switch ( myVolumeNbNodes ) {
1072 if ( faceIndex == 0 || faceIndex == 1 )
1073 ind = 1 - faceIndex;
1076 ind = faceIndex + ( faceIndex % 2 ? -1 : 1 );
1084 //=======================================================================
1085 //function : IsLinked
1086 //purpose : return true if theNode1 is linked with theNode2
1087 //=======================================================================
1089 bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1,
1090 const SMDS_MeshNode* theNode2) const
1095 if (myVolume->IsPoly()) {
1097 MESSAGE("Warning: bad volumic element");
1100 bool isLinked = false;
1102 for (iface = 1; iface <= myNbFaces && !isLinked; iface++) {
1103 int inode, nbFaceNodes = myPolyedre->NbFaceNodes(iface);
1105 for (inode = 1; inode <= nbFaceNodes && !isLinked; inode++) {
1106 const SMDS_MeshNode* curNode = myPolyedre->GetFaceNode(iface, inode);
1108 if (curNode == theNode1 || curNode == theNode2) {
1109 int inextnode = (inode == nbFaceNodes) ? 1 : inode + 1;
1110 const SMDS_MeshNode* nextNode = myPolyedre->GetFaceNode(iface, inextnode);
1112 if ((curNode == theNode1 && nextNode == theNode2) ||
1113 (curNode == theNode2 && nextNode == theNode1)) {
1122 // find nodes indices
1123 int i1 = -1, i2 = -1;
1124 for ( int i = 0; i < myVolumeNbNodes; i++ ) {
1125 if ( myVolumeNodes[ i ] == theNode1 )
1127 else if ( myVolumeNodes[ i ] == theNode2 )
1130 return IsLinked( i1, i2 );
1133 //=======================================================================
1134 //function : IsLinked
1135 //purpose : return true if the node with theNode1Index is linked
1136 // with the node with theNode2Index
1137 //=======================================================================
1139 bool SMDS_VolumeTool::IsLinked (const int theNode1Index,
1140 const int theNode2Index) const
1142 if ( myVolume->IsPoly() ) {
1143 return IsLinked(myVolumeNodes[theNode1Index], myVolumeNodes[theNode2Index]);
1146 int minInd = min( theNode1Index, theNode2Index );
1147 int maxInd = max( theNode1Index, theNode2Index );
1149 if ( minInd < 0 || maxInd > myVolumeNbNodes - 1 || maxInd == minInd )
1152 switch ( myVolumeNbNodes ) {
1158 switch ( maxInd - minInd ) {
1160 case 3: return true;
1165 switch ( maxInd - minInd ) {
1166 case 1: return minInd != 2;
1167 case 2: return minInd == 0 || minInd == 3;
1168 case 3: return true;
1173 switch ( maxInd - minInd ) {
1174 case 1: return minInd != 3;
1175 case 3: return minInd == 0 || minInd == 4;
1176 case 4: return true;
1183 case 0: if( maxInd==4 || maxInd==6 || maxInd==7 ) return true;
1184 case 1: if( maxInd==4 || maxInd==5 || maxInd==8 ) return true;
1185 case 2: if( maxInd==5 || maxInd==6 || maxInd==9 ) return true;
1186 case 3: if( maxInd==7 || maxInd==8 || maxInd==9 ) return true;
1194 case 0: if( maxInd==5 || maxInd==8 || maxInd==9 ) return true;
1195 case 1: if( maxInd==5 || maxInd==6 || maxInd==10 ) return true;
1196 case 2: if( maxInd==6 || maxInd==7 || maxInd==11 ) return true;
1197 case 3: if( maxInd==7 || maxInd==8 || maxInd==12 ) return true;
1198 case 4: if( maxInd==9 || maxInd==10 || maxInd==11 || maxInd==12 ) return true;
1206 case 0: if( maxInd==6 || maxInd==8 || maxInd==12 ) return true;
1207 case 1: if( maxInd==6 || maxInd==7 || maxInd==13 ) return true;
1208 case 2: if( maxInd==7 || maxInd==8 || maxInd==14 ) return true;
1209 case 3: if( maxInd==9 || maxInd==11 || maxInd==12 ) return true;
1210 case 4: if( maxInd==9 || maxInd==10 || maxInd==13 ) return true;
1211 case 5: if( maxInd==10 || maxInd==11 || maxInd==14 ) return true;
1219 case 0: if( maxInd==8 || maxInd==11 || maxInd==16 ) return true;
1220 case 1: if( maxInd==8 || maxInd==9 || maxInd==17 ) return true;
1221 case 2: if( maxInd==9 || maxInd==10 || maxInd==18 ) return true;
1222 case 3: if( maxInd==10 || maxInd==11 || maxInd==19 ) return true;
1223 case 4: if( maxInd==12 || maxInd==15 || maxInd==16 ) return true;
1224 case 5: if( maxInd==12 || maxInd==13 || maxInd==17 ) return true;
1225 case 6: if( maxInd==13 || maxInd==14 || maxInd==18 ) return true;
1226 case 7: if( maxInd==14 || maxInd==15 || maxInd==19 ) return true;
1236 //=======================================================================
1237 //function : GetNodeIndex
1238 //purpose : Return an index of theNode
1239 //=======================================================================
1241 int SMDS_VolumeTool::GetNodeIndex(const SMDS_MeshNode* theNode) const
1244 for ( int i = 0; i < myVolumeNbNodes; i++ ) {
1245 if ( myVolumeNodes[ i ] == theNode )
1252 //================================================================================
1254 * \brief Fill vector with boundary faces existing in the mesh
1255 * \param faces - vector of found nodes
1256 * \retval int - nb of found faces
1258 //================================================================================
1260 int SMDS_VolumeTool::GetAllExistingFaces(vector<const SMDS_MeshElement*> & faces)
1263 faces.reserve( NbFaces() );
1264 for ( int iF = 0; iF < NbFaces(); ++iF ) {
1265 const SMDS_MeshFace* face = 0;
1266 const SMDS_MeshNode** nodes = GetFaceNodes( iF );
1267 switch ( NbFaceNodes( iF )) {
1269 face = SMDS_Mesh::FindFace( nodes[0], nodes[1], nodes[2] ); break;
1271 face = SMDS_Mesh::FindFace( nodes[0], nodes[1], nodes[2], nodes[3] ); break;
1273 face = SMDS_Mesh::FindFace( nodes[0], nodes[1], nodes[2],
1274 nodes[3], nodes[4], nodes[5]); break;
1276 face = SMDS_Mesh::FindFace( nodes[0], nodes[1], nodes[2], nodes[3],
1277 nodes[4], nodes[5], nodes[6], nodes[7]); break;
1280 faces.push_back( face );
1282 return faces.size();
1286 //================================================================================
1288 * \brief Fill vector with boundary edges existing in the mesh
1289 * \param edges - vector of found edges
1290 * \retval int - nb of found faces
1292 //================================================================================
1294 int SMDS_VolumeTool::GetAllExistingEdges(vector<const SMDS_MeshElement*> & edges) const
1297 edges.reserve( myVolumeNbNodes * 2 );
1298 for ( int i = 0; i < myVolumeNbNodes; ++i ) {
1299 for ( int j = i + 1; j < myVolumeNbNodes; ++j ) {
1300 if ( IsLinked( i, j )) {
1301 const SMDS_MeshElement* edge =
1302 SMDS_Mesh::FindEdge( myVolumeNodes[i], myVolumeNodes[j] );
1304 edges.push_back( edge );
1308 return edges.size();
1311 //=======================================================================
1312 //function : IsFreeFace
1313 //purpose : check that only one volume is build on the face nodes
1314 //=======================================================================
1316 bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
1318 const int free = true;
1320 if (!setFace( faceIndex ))
1323 const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex );
1324 int nbFaceNodes = myFaceNbNodes;
1326 // evaluate nb of face nodes shared by other volume
1327 int maxNbShared = -1;
1328 typedef map< const SMDS_MeshElement*, int > TElemIntMap;
1329 TElemIntMap volNbShared;
1330 TElemIntMap::iterator vNbIt;
1331 for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
1332 const SMDS_MeshNode* n = nodes[ iNode ];
1333 SMDS_ElemIteratorPtr eIt = n->GetInverseElementIterator();
1334 while ( eIt->more() ) {
1335 const SMDS_MeshElement* elem = eIt->next();
1336 if ( elem != myVolume && elem->GetType() == SMDSAbs_Volume ) {
1338 vNbIt = volNbShared.find( elem );
1339 if ( vNbIt == volNbShared.end() ) {
1340 volNbShared.insert ( TElemIntMap::value_type( elem, nbShared ));
1343 nbShared = ++(*vNbIt).second;
1345 if ( nbShared > maxNbShared )
1346 maxNbShared = nbShared;
1350 if ( maxNbShared < 3 )
1351 return free; // is free
1353 // find volumes laying on the opposite side of the face
1354 // and sharing all nodes
1355 XYZ intNormal; // internal normal
1356 GetFaceNormal( faceIndex, intNormal.x, intNormal.y, intNormal.z );
1357 if ( IsFaceExternal( faceIndex ))
1358 intNormal = XYZ( -intNormal.x, -intNormal.y, -intNormal.z );
1359 XYZ p0 ( nodes[0] ), baryCenter;
1360 for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) {
1361 int nbShared = (*vNbIt).second;
1362 if ( nbShared >= 3 ) {
1363 SMDS_VolumeTool volume( (*vNbIt).first );
1364 volume.GetBaryCenter( baryCenter.x, baryCenter.y, baryCenter.z );
1365 XYZ intNormal2( baryCenter - p0 );
1366 if ( intNormal.Dot( intNormal2 ) < 0 )
1367 continue; // opposite side
1369 // remove a volume from volNbShared map
1370 volNbShared.erase( vNbIt-- );
1373 // here volNbShared contains only volumes laying on the
1374 // opposite side of the face
1375 if ( volNbShared.empty() ) {
1376 return free; // is free
1379 // check if the whole area of a face is shared
1380 bool isShared[] = { false, false, false, false }; // 4 triangle parts of a quadrangle
1381 for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) {
1382 SMDS_VolumeTool volume( (*vNbIt).first );
1383 bool prevLinkShared = false;
1384 int nbSharedLinks = 0;
1385 for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
1386 bool linkShared = volume.IsLinked( nodes[ iNode ], nodes[ iNode + 1] );
1389 if ( linkShared && prevLinkShared &&
1390 volume.IsLinked( nodes[ iNode - 1 ], nodes[ iNode + 1] ))
1391 isShared[ iNode ] = true;
1392 prevLinkShared = linkShared;
1394 if ( nbSharedLinks == nbFaceNodes )
1395 return !free; // is not free
1396 if ( nbFaceNodes == 4 ) {
1397 // check traingle parts 1 & 3
1398 if ( isShared[1] && isShared[3] )
1399 return !free; // is not free
1400 // check triangle parts 0 & 2;
1401 // 0 part could not be checked in the loop; check it here
1402 if ( isShared[2] && prevLinkShared &&
1403 volume.IsLinked( nodes[ 0 ], nodes[ 1 ] ) &&
1404 volume.IsLinked( nodes[ 1 ], nodes[ 3 ] ) )
1405 return !free; // is not free
1411 //=======================================================================
1412 //function : GetFaceIndex
1413 //purpose : Return index of a face formed by theFaceNodes
1414 //=======================================================================
1416 int SMDS_VolumeTool::GetFaceIndex( const set<const SMDS_MeshNode*>& theFaceNodes )
1418 for ( int iFace = 0; iFace < myNbFaces; iFace++ ) {
1419 const SMDS_MeshNode** nodes = GetFaceNodes( iFace );
1420 int nbFaceNodes = NbFaceNodes( iFace );
1421 set<const SMDS_MeshNode*> nodeSet;
1422 for ( int iNode = 0; iNode < nbFaceNodes; iNode++ )
1423 nodeSet.insert( nodes[ iNode ] );
1424 if ( theFaceNodes == nodeSet )
1430 //=======================================================================
1431 //function : GetFaceIndex
1432 //purpose : Return index of a face formed by theFaceNodes
1433 //=======================================================================
1435 /*int SMDS_VolumeTool::GetFaceIndex( const set<int>& theFaceNodesIndices )
1437 for ( int iFace = 0; iFace < myNbFaces; iFace++ ) {
1438 const int* nodes = GetFaceNodesIndices( iFace );
1439 int nbFaceNodes = NbFaceNodes( iFace );
1441 for ( int iNode = 0; iNode < nbFaceNodes; iNode++ )
1442 nodeSet.insert( nodes[ iNode ] );
1443 if ( theFaceNodesIndices == nodeSet )
1449 //=======================================================================
1450 //function : setFace
1452 //=======================================================================
1454 bool SMDS_VolumeTool::setFace( int faceIndex )
1459 if ( myCurFace == faceIndex )
1464 if ( faceIndex < 0 || faceIndex >= NbFaces() )
1467 if (myFaceNodes != NULL) {
1468 delete [] myFaceNodes;
1472 if (myVolume->IsPoly()) {
1474 MESSAGE("Warning: bad volumic element");
1478 // check orientation
1479 bool isGoodOri = true;
1480 if (myExternalFaces)
1481 isGoodOri = IsFaceExternal( faceIndex );
1485 myFaceNbNodes = myPolyedre->NbFaceNodes(faceIndex + 1);
1486 myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1];
1488 for ( iNode = 0; iNode < myFaceNbNodes; iNode++ )
1489 myFaceNodes[ iNode ] = myPolyedre->GetFaceNode(faceIndex + 1, iNode + 1);
1491 for ( iNode = 0; iNode < myFaceNbNodes; iNode++ )
1492 myFaceNodes[ iNode ] = myPolyedre->GetFaceNode(faceIndex + 1, myFaceNbNodes - iNode);
1494 myFaceNodes[ myFaceNbNodes ] = myFaceNodes[ 0 ]; // last = first
1498 // choose face node indices
1499 switch ( myVolumeNbNodes ) {
1501 myFaceNbNodes = Tetra_nbN[ faceIndex ];
1502 if ( myExternalFaces )
1503 myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_RE[ faceIndex ];
1505 myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ];
1508 myFaceNbNodes = Pyramid_nbN[ faceIndex ];
1509 if ( myExternalFaces )
1510 myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_RE[ faceIndex ];
1512 myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_R[ faceIndex ];
1515 myFaceNbNodes = Penta_nbN[ faceIndex ];
1516 if ( myExternalFaces )
1517 myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ];
1519 myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ];
1522 myFaceNbNodes = Hexa_nbN[ faceIndex ];
1523 if ( myExternalFaces )
1524 myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ];
1526 myFaceNodeIndices = Hexa_F[ faceIndex ];
1529 myFaceNbNodes = QuadTetra_nbN[ faceIndex ];
1530 if ( myExternalFaces )
1531 myFaceNodeIndices = myVolForward ? QuadTetra_F[ faceIndex ] : QuadTetra_RE[ faceIndex ];
1533 myFaceNodeIndices = myVolForward ? QuadTetra_F[ faceIndex ] : QuadTetra_R[ faceIndex ];
1536 myFaceNbNodes = QuadPyram_nbN[ faceIndex ];
1537 if ( myExternalFaces )
1538 myFaceNodeIndices = myVolForward ? QuadPyram_F[ faceIndex ] : QuadPyram_RE[ faceIndex ];
1540 myFaceNodeIndices = myVolForward ? QuadPyram_F[ faceIndex ] : QuadPyram_R[ faceIndex ];
1543 myFaceNbNodes = QuadPenta_nbN[ faceIndex ];
1544 if ( myExternalFaces )
1545 myFaceNodeIndices = myVolForward ? QuadPenta_FE[ faceIndex ] : QuadPenta_RE[ faceIndex ];
1547 myFaceNodeIndices = myVolForward ? QuadPenta_F[ faceIndex ] : QuadPenta_R[ faceIndex ];
1550 myFaceNbNodes = QuadHexa_nbN[ faceIndex ];
1551 if ( myExternalFaces )
1552 myFaceNodeIndices = myVolForward ? QuadHexa_FE[ faceIndex ] : QuadHexa_RE[ faceIndex ];
1554 myFaceNodeIndices = QuadHexa_F[ faceIndex ];
1561 myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1];
1562 for ( int iNode = 0; iNode < myFaceNbNodes; iNode++ )
1563 myFaceNodes[ iNode ] = myVolumeNodes[ myFaceNodeIndices[ iNode ]];
1564 myFaceNodes[ myFaceNbNodes ] = myFaceNodes[ 0 ];
1567 myCurFace = faceIndex;
1572 //=======================================================================
1573 //function : GetType
1574 //purpose : return VolumeType by nb of nodes in a volume
1575 //=======================================================================
1577 SMDS_VolumeTool::VolumeType SMDS_VolumeTool::GetType(int nbNodes)
1579 switch ( nbNodes ) {
1580 case 4: return TETRA;
1581 case 5: return PYRAM;
1582 case 6: return PENTA;
1583 case 8: return HEXA;
1584 case 10: return QUAD_TETRA;
1585 case 13: return QUAD_PYRAM;
1586 case 15: return QUAD_PENTA;
1587 case 20: return QUAD_HEXA;
1588 default:return UNKNOWN;
1592 //=======================================================================
1593 //function : NbFaces
1594 //purpose : return nb of faces by volume type
1595 //=======================================================================
1597 int SMDS_VolumeTool::NbFaces( VolumeType type )
1601 case QUAD_TETRA: return 4;
1603 case QUAD_PYRAM: return 5;
1605 case QUAD_PENTA: return 5;
1607 case QUAD_HEXA : return 6;
1612 //================================================================================
1614 * \brief Useful to know nb of corner nodes of a quadratic volume
1615 * \param type - volume type
1616 * \retval int - nb of corner nodes
1618 //================================================================================
1620 int SMDS_VolumeTool::NbCornerNodes(VolumeType type)
1624 case QUAD_TETRA: return 4;
1626 case QUAD_PYRAM: return 5;
1628 case QUAD_PENTA: return 6;
1630 case QUAD_HEXA : return 8;
1637 //=======================================================================
1638 //function : GetFaceNodesIndices
1639 //purpose : Return the array of face nodes indices
1640 // To comfort link iteration, the array
1641 // length == NbFaceNodes( faceIndex ) + 1 and
1642 // the last node index == the first one.
1643 //=======================================================================
1645 const int* SMDS_VolumeTool::GetFaceNodesIndices(VolumeType type,
1650 case TETRA: return Tetra_F[ faceIndex ];
1651 case PYRAM: return Pyramid_F[ faceIndex ];
1652 case PENTA: return external ? Penta_FE[ faceIndex ] : Penta_F[ faceIndex ];
1653 case HEXA: return external ? Hexa_FE[ faceIndex ] : Hexa_F[ faceIndex ];
1654 case QUAD_TETRA: return QuadTetra_F[ faceIndex ];
1655 case QUAD_PYRAM: return QuadPyram_F[ faceIndex ];
1656 case QUAD_PENTA: return external ? QuadPenta_FE[ faceIndex ] : QuadPenta_F[ faceIndex ];
1657 case QUAD_HEXA: return external ? QuadHexa_FE[ faceIndex ] : QuadHexa_F[ faceIndex ];
1663 //=======================================================================
1664 //function : NbFaceNodes
1665 //purpose : Return number of nodes in the array of face nodes
1666 //=======================================================================
1668 int SMDS_VolumeTool::NbFaceNodes(VolumeType type,
1672 case TETRA: return Tetra_nbN[ faceIndex ];
1673 case PYRAM: return Pyramid_nbN[ faceIndex ];
1674 case PENTA: return Penta_nbN[ faceIndex ];
1675 case HEXA: return Hexa_nbN[ faceIndex ];
1676 case QUAD_TETRA: return QuadTetra_nbN[ faceIndex ];
1677 case QUAD_PYRAM: return QuadPyram_nbN[ faceIndex ];
1678 case QUAD_PENTA: return QuadPenta_nbN[ faceIndex ];
1679 case QUAD_HEXA: return QuadHexa_nbN[ faceIndex ];
1685 //=======================================================================
1687 //purpose : return element
1688 //=======================================================================
1690 const SMDS_MeshVolume* SMDS_VolumeTool::Element() const
1692 return static_cast<const SMDS_MeshVolume*>( myVolume );
1695 //=======================================================================
1697 //purpose : return element ID
1698 //=======================================================================
1700 int SMDS_VolumeTool::ID() const
1702 return myVolume ? myVolume->GetID() : 0;