From d0deed63a9a535b8c57c49de2c53649603d5a559 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 30 Oct 2009 11:50:21 +0000 Subject: [PATCH] 0020128: EDF SMESH 926 : Quadratic conversion of BLSURF mesh add Set_NodeOnEdge() like in V5 --- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 76 +++++++++++++++++------- src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx | 3 + 2 files changed, 56 insertions(+), 23 deletions(-) diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index b8778fe..9b8ae46 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -236,7 +236,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu status_t curv_fun(real t, real *uv, real *dt, real *dtt, void *user_data); status_t surf_fun(real *uv, real *xyz, real*du, real *dv, - real *duu, real *duv, real *dvv, void *user_data); + real *duu, real *duv, real *dvv, void *user_data); status_t message_callback(message_t *msg, void *user_data); //============================================================================= @@ -294,7 +294,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) TopoDS_Edge e = TopoDS::Edge(edge_iter.Current()); int ic = emap.FindIndex(e); if (ic <= 0) - ic = emap.Add(e); + ic = emap.Add(e); double tmin,tmax; curves.push_back(BRep_Tool::CurveOnSurface(e, f, tmin, tmax)); @@ -310,28 +310,28 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) gp_Pnt ee0 = surfaces.back()->Value(e0.X(), e0.Y()); Standard_Real d1=0,d2=0; for (TopExp_Explorer ex_edge(e ,TopAbs_VERTEX); ex_edge.More(); ex_edge.Next()) { - TopoDS_Vertex v = TopoDS::Vertex(ex_edge.Current()); - - ++npts; - if (npts == 1){ - ip = &ip1; - d1 = ee0.SquareDistance(BRep_Tool::Pnt(v)); - } else { - ip = &ip2; + TopoDS_Vertex v = TopoDS::Vertex(ex_edge.Current()); + + ++npts; + if (npts == 1){ + ip = &ip1; + d1 = ee0.SquareDistance(BRep_Tool::Pnt(v)); + } else { + ip = &ip2; d2 = ee0.SquareDistance(BRep_Tool::Pnt(v)); - } - *ip = pmap.FindIndex(v); - if(*ip <= 0) - *ip = pmap.Add(v); + } + *ip = pmap.FindIndex(v); + if(*ip <= 0) + *ip = pmap.Add(v); } if (npts != 2) { - // should not happen - cout << "An edge does not have 2 extremities." << endl; + // should not happen + cout << "An edge does not have 2 extremities." << endl; } else { - if (d1 < d2) - cad_edge_set_extremities(edg, ip1, ip2); - else - cad_edge_set_extremities(edg, ip2, ip1); + if (d1 < d2) + cad_edge_set_extremities(edg, ip1, ip2); + else + cad_edge_set_extremities(edg, ip2, ip1); } } // for edge } //for face @@ -431,11 +431,11 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) mesh_get_edge_tag(msh, it, &tag); if (tags[vtx[0]]) { - meshDS->SetNodeOnEdge(nodes[vtx[0]], TopoDS::Edge(emap(tag))); + Set_NodeOnEdge(meshDS, nodes[vtx[0]], emap(tag)); tags[vtx[0]] = false; }; if (tags[vtx[1]]) { - meshDS->SetNodeOnEdge(nodes[vtx[1]], TopoDS::Edge(emap(tag))); + Set_NodeOnEdge(meshDS, nodes[vtx[1]], emap(tag)); tags[vtx[1]] = false; }; meshDS->SetMeshElementOnShape(edg, TopoDS::Edge(emap(tag))); @@ -505,6 +505,36 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) return true; } +//============================================================================= +/*! + * SetNodeOnEdge + */ +//============================================================================= + +void BLSURFPlugin_BLSURF::Set_NodeOnEdge(SMESHDS_Mesh* meshDS, SMDS_MeshNode* node, const TopoDS_Shape& ed) { + const TopoDS_Edge edge = TopoDS::Edge(ed); + + gp_Pnt pnt(node->X(), node->Y(), node->Z()); + + Standard_Real p0 = 0.0; + Standard_Real p1 = 1.0; + TopLoc_Location loc; + Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, loc, p0, p1); + + if ( !loc.IsIdentity() ) pnt.Transform( loc.Transformation().Inverted() ); + GeomAPI_ProjectPointOnCurve proj(pnt, curve, p0, p1); + + double pa = 0.; + if ( proj.NbPoints() > 0 ) + pa = (double)proj.LowerDistanceParameter(); + +// GProp_GProps LProps; +// BRepGProp::LinearProperties(ed, LProps); +// double lg = (double)LProps.Mass(); + + meshDS->SetNodeOnEdge(node, edge, pa); +} + //============================================================================= /*! * @@ -575,7 +605,7 @@ status_t curv_fun(real t, real *uv, real *dt, real *dtt, void *user_data) } status_t surf_fun(real *uv, real *xyz, real*du, real *dv, - real *duu, real *duv, real *dvv, void *user_data) + real *duu, real *duv, real *dvv, void *user_data) { const Geom_Surface* geometry = (const Geom_Surface*) user_data; diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index aeb6dfc..632dcaa 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -58,6 +58,9 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { protected: const BLSURFPlugin_Hypothesis* _hypothesis; + private: + void Set_NodeOnEdge(SMESHDS_Mesh* meshDS, SMDS_MeshNode* node, const TopoDS_Shape& ed); + // private: // int _topology; // int _physicalMesh; -- 2.39.2