From: eap Date: Tue, 14 Jun 2005 10:19:12 +0000 (+0000) Subject: PAL9163. Fix GetFaceNormal() for badly shaped quadrangles X-Git-Tag: T3_0_0_a4~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5467bb25d4a8ca4a84de65bc44b725bdd9d69a29;p=modules%2Fsmesh.git PAL9163. Fix GetFaceNormal() for badly shaped quadrangles --- diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index dd98851eb..2b549d217 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -536,6 +536,15 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub XYZ aVec13( p3 - p1 ); XYZ cross = aVec12.Crossed( aVec13 ); + if ( myFaceNbNodes[ faceIndex ] == 4 ) { + XYZ p4 ( myFaceNodes[3] ); + XYZ aVec14( p4 - p1 ); + XYZ cross2 = aVec13.Crossed( aVec14 ); + cross.x += cross2.x; + cross.y += cross2.y; + cross.z += cross2.z; + } + double size = cross.Magnitude(); if ( size <= DBL_MIN ) return false; @@ -952,8 +961,9 @@ bool SMDS_VolumeTool::setFace( int faceIndex ) // set face nodes myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1]; - for ( int iNode = 0; iNode <= myFaceNbNodes; iNode++ ) + for ( int iNode = 0; iNode < myFaceNbNodes; iNode++ ) myFaceNodes[ iNode ] = myVolumeNodes[ myFaceNodeIndices[ iNode ]]; + myFaceNodes[ myFaceNbNodes ] = myFaceNodes[ 0 ]; } myCurFace = faceIndex;