+ if (myVolume->IsPoly()) {
+ if (!myPolyedre) {
+ MESSAGE("Warning: bad volumic element");
+ return false;
+ }
+
+ // check orientation
+ bool isGoodOri = true;
+ if (myExternalFaces) {
+ // get natural orientation
+ XYZ aNormal, baryCenter, p0 (myPolyedre->GetFaceNode(faceIndex + 1, 1));
+ SMDS_VolumeTool vTool (myPolyedre);
+ vTool.GetFaceNormal(faceIndex, aNormal.x, aNormal.y, aNormal.z);
+ vTool.GetBaryCenter(baryCenter.x, baryCenter.y, baryCenter.z);
+ XYZ insideVec (baryCenter - p0);
+ if (insideVec.Dot(aNormal) > 0)
+ isGoodOri = false;
+ }
+
+ // set face nodes
+ int iNode;
+ myFaceNbNodes = myPolyedre->NbFaceNodes(faceIndex + 1);
+ myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1];
+ if (isGoodOri) {
+ for ( iNode = 0; iNode < myFaceNbNodes; iNode++ )
+ myFaceNodes[ iNode ] = myPolyedre->GetFaceNode(faceIndex + 1, iNode + 1);
+ } else {
+ for ( iNode = 0; iNode < myFaceNbNodes; iNode++ )
+ myFaceNodes[ iNode ] = myPolyedre->GetFaceNode(faceIndex + 1, myFaceNbNodes - iNode);
+ }
+ myFaceNodes[ myFaceNbNodes ] = myFaceNodes[ 0 ]; // last = first
+
+ } else {
+ // choose face node indices
+ switch ( myVolumeNbNodes ) {
+ case 4:
+ myFaceNbNodes = Tetra_nbN[ faceIndex ];
+ if ( myExternalFaces )
+ myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_RE[ faceIndex ];
+ else
+ myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ];
+ break;
+ case 5:
+ myFaceNbNodes = Pyramid_nbN[ faceIndex ];
+ if ( myExternalFaces )
+ myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_RE[ faceIndex ];
+ else
+ myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_R[ faceIndex ];
+ break;
+ case 6:
+ myFaceNbNodes = Penta_nbN[ faceIndex ];
+ if ( myExternalFaces )
+ myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ];
+ else
+ myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ];
+ break;
+ case 8:
+ myFaceNbNodes = Hexa_nbN[ faceIndex ];
+ if ( myExternalFaces )
+ myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ];
+ else
+ myFaceNodeIndices = Hexa_F[ faceIndex ];
+ break;
+ default:
+ return false;
+ }
+
+ // set face nodes
+ myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1];
+ for ( int iNode = 0; iNode <= myFaceNbNodes; iNode++ )
+ myFaceNodes[ iNode ] = myVolumeNodes[ myFaceNodeIndices[ iNode ]];
+ }