From: cconopoima Date: Thu, 11 May 2023 15:29:17 +0000 (-0300) Subject: Passing value of UParameter on SetNodeOndEdge method. X-Git-Tag: V9_11_0b1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ad3e6b574a267f67126a1332d3b1f97686833cbf;p=plugins%2Fgmshplugin.git Passing value of UParameter on SetNodeOndEdge method. --- diff --git a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx index b152cc2..85f1e9a 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx @@ -34,6 +34,11 @@ #include #include +//CAS +#include +#include +#include + #include #include #include @@ -737,7 +742,33 @@ void GMSHPlugin_Mesher::FillSMesh() if ( isCompound ) topoEdge = TopoDS::Edge( getShapeAtPoint( v->point(), topoEdges )); - meshDS->SetNodeOnEdge( node, topoEdge ); + // Based on BLSURFPlugin_BLSURF + gp_Pnt point3D( v->x(),v->y(),v->z() ); + Standard_Real p0 = 0.0; + Standard_Real p1 = 1.0; + TopLoc_Location loc; + Handle(Geom_Curve) curve = BRep_Tool::Curve(topoEdge, loc, p0, p1); + + if ( !curve.IsNull() ) + { + if ( !loc.IsIdentity() ) + point3D.Transform( loc.Transformation().Inverted() ); + + GeomAPI_ProjectPointOnCurve proj(point3D, curve, p0, p1); + + double pa = 0.; + if ( proj.NbPoints() > 0 ) + pa = (double)proj.LowerDistanceParameter(); + + meshDS->SetNodeOnEdge( node, topoEdge, pa ); + } + else + { + meshDS->SetNodeOnEdge( node, topoEdge ); + } + //END on BLSURFPlugin_BLSURF + + _nodeMap.insert({ v, node }); } } @@ -772,7 +803,31 @@ void GMSHPlugin_Mesher::FillSMesh() if ( verts[j]->onWhat()->getVisibility() == 0 ) { SMDS_MeshNode *node = meshDS->AddNode(verts[j]->x(),verts[j]->y(),verts[j]->z() ); - meshDS->SetNodeOnEdge( node, topoEdge ); + + gp_Pnt point3D( verts[j]->x(),verts[j]->y(),verts[j]->z() ); + Standard_Real p0 = 0.0; + Standard_Real p1 = 1.0; + TopLoc_Location loc; + Handle(Geom_Curve) curve = BRep_Tool::Curve(topoEdge, loc, p0, p1); + + if ( !curve.IsNull() ) + { + if ( !loc.IsIdentity() ) + point3D.Transform( loc.Transformation().Inverted() ); + + GeomAPI_ProjectPointOnCurve proj(point3D, curve, p0, p1); + + double pa = 0.; + if ( proj.NbPoints() > 0 ) + pa = (double)proj.LowerDistanceParameter(); + + meshDS->SetNodeOnEdge( node, topoEdge, pa ); + } + else + { + meshDS->SetNodeOnEdge( node, topoEdge ); + } + verts[j]->setEntity(gEdge); _nodeMap.insert({ verts[j], node }); }