From ea62bda94091b65594dec88378bba1cfed8ca616 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 13 May 2009 12:30:28 +0000 Subject: [PATCH] 0020042: EDF 864 SMESH: Mesh of holes (GHS3D/BLSurf) fix findShapeID(): get normal fo geom face at the center of mesh triangle --- src/GHS3DPlugin_GHS3D.cxx | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin_GHS3D.cxx index d7bf596..df635eb 100644 --- a/src/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin_GHS3D.cxx @@ -573,22 +573,29 @@ static int findShapeID(SMESH_Mesh& mesh, if ( !fExp.More() ) return invalidID; // face not found - // find UV of node1 on geomFace + // find UV of the center of triangle on geomFace SMESH_MesherHelper helper( mesh ); - gp_XY uv = helper.GetNodeUV( geomFace, node1 ); - - // check that uv is correct - gp_Pnt node1Pnt ( node1->X(), node1->Y(), node1->Z() ); - double tol = BRep_Tool::Tolerance( geomFace ); - BRepAdaptor_Surface surface( geomFace ); - if ( node1Pnt.Distance( surface.Value( uv.X(), uv.Y() )) > 2 * tol ) { - // project node1 onto geomFace to get right UV - GeomAPI_ProjectPointOnSurf projector( node1Pnt, surface.Surface().Surface() ); - if ( !projector.IsDone() || projector.NbPoints() < 1 ) - return invalidID; - Quantity_Parameter U,V; - projector.LowerDistanceParameters(U,V); - uv = gp_XY( U,V ); + gp_XY UV(0,0); + const SMDS_MeshNode* nodes[3] = { node1, node2, node3 }; + for ( int n = 0; n < 3; ++n ) + { + const SMDS_MeshNode* node = nodes[n] + gp_XY uv = helper.GetNodeUV( geomFace, node ); + + // check that uv is correct + gp_Pnt nodePnt ( node->X(), node->Y(), node->Z() ); + double tol = BRep_Tool::Tolerance( geomFace ); + BRepAdaptor_Surface surface( geomFace ); + if ( nodePnt.Distance( surface.Value( uv.X(), uv.Y() )) > 2 * tol ) { + // project node onto geomFace to get right UV + GeomAPI_ProjectPointOnSurf projector( nodePnt, surface.Surface().Surface() ); + if ( !projector.IsDone() || projector.NbPoints() < 1 ) + return invalidID; + Quantity_Parameter U,V; + projector.LowerDistanceParameters(U,V); + uv = gp_XY( U,V ); + } + UV += uv / 3.; } // normale to face at node1 gp_Pnt node2Pnt ( node2->X(), node2->Y(), node2->Z() ); @@ -601,7 +608,7 @@ static int findShapeID(SMESH_Mesh& mesh, // normale to geomFace at UV gp_Vec du, dv; - surface.D1( uv.X(), uv.Y(), node1Pnt, du, dv ); + surface.D1( UV.X(), UV.Y(), node1Pnt, du, dv ); gp_Vec geomNormal = du ^ dv; if ( geomNormal.SquareMagnitude() < DBL_MIN ) return findShapeID( mesh, node2, node3, node1, toMeshHoles ); -- 2.39.2