X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_MEFISTO_2D.cxx;h=88257be18d64506ff72ceba9badfe4836d6a137f;hp=9aaf2b4fcf90d2638032d6687ce8785357d1b437;hb=faa1c8f2bc27c5244a34fe03584826de59cb17b3;hpb=789d7f7415a1e465aee36232e7633eea548ff1fb diff --git a/src/SMESH/SMESH_MEFISTO_2D.cxx b/src/SMESH/SMESH_MEFISTO_2D.cxx index 9aaf2b4fc..88257be18 100644 --- a/src/SMESH/SMESH_MEFISTO_2D.cxx +++ b/src/SMESH/SMESH_MEFISTO_2D.cxx @@ -26,7 +26,6 @@ // Module : SMESH // $Header$ -using namespace std; using namespace std; #include "SMESH_MEFISTO_2D.hxx" #include "SMESH_Gen.hxx" @@ -38,8 +37,6 @@ using namespace std; #include "Rn.h" #include "aptrte.h" -#include "SMESHDS_ListOfPtrHypothesis.hxx" -#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" #include "SMDS_EdgePosition.hxx" @@ -70,20 +67,20 @@ using namespace std; */ //============================================================================= -SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_2D_Algo(hypId, studyId, gen) +SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId, + SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen) { - MESSAGE("SMESH_MEFISTO_2D::SMESH_MEFISTO_2D"); - _name = "MEFISTO_2D"; + MESSAGE("SMESH_MEFISTO_2D::SMESH_MEFISTO_2D"); + _name = "MEFISTO_2D"; // _shapeType = TopAbs_FACE; - _shapeType = (1<::const_iterator itl; - SMESHDS_Hypothesis* theHyp; - - const list& hyps = GetUsedHypothesis(aMesh, aShape); - int nbHyp = hyps.size(); - if (nbHyp != 1) return false; // only one compatible hypothesis allowed - - itl = hyps.begin(); - theHyp = (*itl); - - string hypName = theHyp->GetName(); - int hypId = theHyp->GetID(); - //SCRUTE(hypName); - - bool isOk = false; - - if (hypName == "MaxElementArea") - { - _hypMaxElementArea = dynamic_cast (theHyp); - ASSERT(_hypMaxElementArea); - _maxElementArea = _hypMaxElementArea->GetMaxArea(); - _edgeLength = 0; - isOk =true; - } - - if (hypName == "LengthFromEdges") - { - _hypLengthFromEdges = dynamic_cast (theHyp); - ASSERT(_hypLengthFromEdges); - _edgeLength = 0; - _maxElementArea = 0; - isOk =true; - } - - - if (isOk) - { - isOk = false; - if (_maxElementArea > 0) + //MESSAGE("SMESH_MEFISTO_2D::CheckHypothesis"); + + _hypMaxElementArea = NULL; + _hypLengthFromEdges = NULL; + + list ::const_iterator itl; + const SMESHDS_Hypothesis *theHyp; + + const list &hyps = GetUsedHypothesis(aMesh, aShape); + int nbHyp = hyps.size(); + if (nbHyp != 1) return false;// only one compatible hypothesis allowed + + itl = hyps.begin(); + theHyp = (*itl); + + string hypName = theHyp->GetName(); + int hypId = theHyp->GetID(); + //SCRUTE(hypName); + + bool isOk = false; + + if (hypName == "MaxElementArea") { - _edgeLength = 2*sqrt(_maxElementArea); // triangles : minorant - isOk = true; + _hypMaxElementArea = static_cast(theHyp); + ASSERT(_hypMaxElementArea); + _maxElementArea = _hypMaxElementArea->GetMaxArea(); + _edgeLength = 0; + isOk = true; } - else isOk = (_hypLengthFromEdges != NULL); // **** check mode - } - //SCRUTE(_edgeLength); - //SCRUTE(_maxElementArea); - return isOk; -} + if (hypName == "LengthFromEdges") + { + _hypLengthFromEdges = static_cast(theHyp); + ASSERT(_hypLengthFromEdges); + _edgeLength = 0; + _maxElementArea = 0; + isOk = true; + } + if (isOk) + { + isOk = false; + if (_maxElementArea > 0) + { + _edgeLength = 2 * sqrt(_maxElementArea); // triangles : minorant + isOk = true; + } + else + isOk = (_hypLengthFromEdges != NULL); // **** check mode + } + + //SCRUTE(_edgeLength); + //SCRUTE(_maxElementArea); + return isOk; +} //============================================================================= /*! @@ -169,81 +165,80 @@ bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh, */ //============================================================================= -bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape) +bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) { - MESSAGE("SMESH_MEFISTO_2D::Compute"); - - if (_hypLengthFromEdges) - _edgeLength = ComputeEdgeElementLength(aMesh, aShape); - - bool isOk = false; - const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS(); - SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape); - - const TopoDS_Face& FF = TopoDS::Face(aShape); - bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); - TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); - - Z nblf; //nombre de lignes fermees (enveloppe en tete) - Z *nudslf=NULL; //numero du dernier sommet de chaque ligne fermee - R2 *uvslf=NULL; - Z nbpti=0; //nombre points internes futurs sommets de la triangulation - R2 *uvpti=NULL; - - Z nbst; - R2 *uvst=NULL; - Z nbt; - Z *nust=NULL; - Z ierr=0; - - Z nutysu=1; // 1: il existe un fonction areteideale_() - // Z nutysu=0; // 0: on utilise aretmx - R aretmx=_edgeLength; // longueur max aretes future triangulation - //SCRUTE(aretmx); - - nblf = NumberOfWires(F); - //SCRUTE(nblf); - - nudslf = new Z[1+nblf]; - nudslf[0] = 0; - int iw = 1; - int nbpnt = 0; - - const TopoDS_Wire OW1 = BRepTools::OuterWire(F); - nbpnt += NumberOfPoints (aMesh, OW1); - nudslf [iw++] = nbpnt; - //SCRUTE(nbpnt); - - for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next()) - { - const TopoDS_Wire& W = TopoDS::Wire(exp.Current()); - if (!OW1.IsSame(W)) + MESSAGE("SMESH_MEFISTO_2D::Compute"); + + if (_hypLengthFromEdges) + _edgeLength = ComputeEdgeElementLength(aMesh, aShape); + + bool isOk = false; + const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); + + const TopoDS_Face & FF = TopoDS::Face(aShape); + bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); + + Z nblf; //nombre de lignes fermees (enveloppe en tete) + Z *nudslf = NULL; //numero du dernier sommet de chaque ligne fermee + R2 *uvslf = NULL; + Z nbpti = 0; //nombre points internes futurs sommets de la triangulation + R2 *uvpti = NULL; + + Z nbst; + R2 *uvst = NULL; + Z nbt; + Z *nust = NULL; + Z ierr = 0; + + Z nutysu = 1; // 1: il existe un fonction areteideale_() + // Z nutysu=0; // 0: on utilise aretmx + R aretmx = _edgeLength; // longueur max aretes future triangulation + //SCRUTE(aretmx); + + nblf = NumberOfWires(F); + //SCRUTE(nblf); + + nudslf = new Z[1 + nblf]; + nudslf[0] = 0; + int iw = 1; + int nbpnt = 0; + + const TopoDS_Wire OW1 = BRepTools::OuterWire(F); + nbpnt += NumberOfPoints(aMesh, OW1); + nudslf[iw++] = nbpnt; + //SCRUTE(nbpnt); + + for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) { - nbpnt += NumberOfPoints (aMesh, W); - nudslf [iw++] = nbpnt; - //SCRUTE(nbpnt); + const TopoDS_Wire & W = TopoDS::Wire(exp.Current()); + if (!OW1.IsSame(W)) + { + nbpnt += NumberOfPoints(aMesh, W); + nudslf[iw++] = nbpnt; + //SCRUTE(nbpnt); + } } - } - - uvslf = new R2[nudslf[nblf]]; - //SCRUTE(nudslf[nblf]); - int m = 0; - - map mefistoToDS; // correspondence mefisto index--> points IDNodes - TopoDS_Wire OW = BRepTools::OuterWire(F); - LoadPoints (aMesh, F, OW, uvslf, m, mefistoToDS); - //SCRUTE(m); - - for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next()) - { - const TopoDS_Wire& W = TopoDS::Wire(exp.Current()); - if (!OW.IsSame(W)) + + uvslf = new R2[nudslf[nblf]]; + //SCRUTE(nudslf[nblf]); + int m = 0; + + map mefistoToDS; // correspondence mefisto index--> points IDNodes + TopoDS_Wire OW = BRepTools::OuterWire(F); + LoadPoints(aMesh, F, OW, uvslf, m, mefistoToDS); + //SCRUTE(m); + + for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) { - LoadPoints (aMesh, F, W, uvslf, m, mefistoToDS); - //SCRUTE(m); + const TopoDS_Wire & W = TopoDS::Wire(exp.Current()); + if (!OW.IsSame(W)) + { + LoadPoints(aMesh, F, W, uvslf, m, mefistoToDS); + //SCRUTE(m); + } } - } // SCRUTE(nudslf[nblf]); // for (int i=0; i<=nblf; i++) // { @@ -257,34 +252,36 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh, // SCRUTE(aretmx); // SCRUTE(nblf); - MESSAGE("MEFISTO triangulation ..."); - uvst = NULL; - nust = NULL; - aptrte( nutysu, aretmx, - nblf, nudslf, uvslf, - nbpti, uvpti, - nbst, uvst, nbt, nust, - ierr ); - - if( ierr == 0 ) - { - MESSAGE("... End Triangulation"); - //SCRUTE(nbst); - //SCRUTE(nbt); - StoreResult (aMesh, nbst, uvst, nbt, nust, F, - faceIsForward, mefistoToDS); - isOk = true; - } - else - { - MESSAGE("Error in Triangulation"); - isOk = false; - } - if (nudslf != NULL) delete [] nudslf; - if (uvslf != NULL) delete [] uvslf; - if (uvst != NULL) delete [] uvst; - if (nust != NULL) delete [] nust; - return isOk; + MESSAGE("MEFISTO triangulation ..."); + uvst = NULL; + nust = NULL; + aptrte(nutysu, aretmx, + nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr); + + if (ierr == 0) + { + MESSAGE("... End Triangulation Generated Triangle Number " << nbt); + MESSAGE(" Node Number " << nbst); + //SCRUTE(nbst); + //SCRUTE(nbt); + StoreResult(aMesh, nbst, uvst, nbt, nust, F, + faceIsForward, mefistoToDS); + isOk = true; + } + else + { + MESSAGE("Error in Triangulation"); + isOk = false; + } + if (nudslf != NULL) + delete[]nudslf; + if (uvslf != NULL) + delete[]uvslf; + if (uvst != NULL) + delete[]uvst; + if (nust != NULL) + delete[]nust; + return isOk; } //============================================================================= @@ -293,125 +290,115 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh, */ //============================================================================= -void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh, - const TopoDS_Face& FF, - const TopoDS_Wire& WW, - R2* uvslf, - int& m, - map& mefistoToDS) +void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh, + const TopoDS_Face & FF, + const TopoDS_Wire & WW, R2 * uvslf, int &m, + map&mefistoToDS) { - MESSAGE("SMESH_MEFISTO_2D::LoadPoints"); - - Handle (SMDS_Mesh) meshDS = aMesh.GetMeshDS(); - - double scalex; - double scaley; - TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); - ComputeScaleOnFace(aMesh, F, scalex, scaley); - - TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD)); - BRepTools_WireExplorer wexp(W,F); - for (wexp.Init(W,F);wexp.More(); wexp.Next()) - { - const TopoDS_Edge& E = wexp.Current(); - - // --- IDNodes of first and last Vertex - - TopoDS_Vertex VFirst, VLast; - TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l - - ASSERT(!VFirst.IsNull()); - SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst); - const TColStd_ListOfInteger& lidf - = firstSubMesh->GetSubMeshDS()->GetIDNodes(); - int idFirst= lidf.First(); -// SCRUTE(idFirst); - - ASSERT(!VLast.IsNull()); - SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast); - const TColStd_ListOfInteger& lidl - = lastSubMesh->GetSubMeshDS()->GetIDNodes(); - int idLast= lidl.First(); -// SCRUTE(idLast); - - // --- edge internal IDNodes (relies on good order storage, not checked) - - int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); - //SCRUTE(nbPoints); - - Standard_Real f,l; - Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l); - - const TColStd_ListOfInteger& indElt - = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes(); - TColStd_ListIteratorOfListOfInteger ite(indElt); - //SCRUTE(nbPoints); - //SCRUTE(indElt.Extent()); - ASSERT(nbPoints == indElt.Extent()); - bool isForward = (E.Orientation() == TopAbs_FORWARD); - map params; - for (; ite.More(); ite.Next()) - { - int nodeId = ite.Value(); - Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId); - Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt); - Handle (SMDS_EdgePosition) epos - = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition()); - double param = epos->GetUParameter(); - params[param] = nodeId; -// MESSAGE(" " << param << " " << params[param]); - } + MESSAGE("SMESH_MEFISTO_2D::LoadPoints"); - // --- load 2D values into MEFISTO structure, - // add IDNodes in mefistoToDS map + SMDS_Mesh * meshDS = aMesh.GetMeshDS(); - if (E.Orientation() == TopAbs_FORWARD) - { - gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward - uvslf [m].x = scalex * p.X(); - uvslf [m].y = scaley * p.Y(); - mefistoToDS[m+1] = idFirst; - //MESSAGE(" "<::iterator itp = params.begin(); - for (Standard_Integer i = 1; i<=nbPoints; i++) // nbPoints internal - { - double param = (*itp).first; - gp_Pnt2d p = C2d->Value(param); - uvslf [m].x = scalex * p.X(); - uvslf [m].y = scaley * p.Y(); - mefistoToDS[m+1] = (*itp).second; -// MESSAGE(" "<Value(l); // last point = Vertex Reversed - uvslf [m].x = scalex * p.X(); - uvslf [m].y = scaley * p.Y(); - mefistoToDS[m+1] = idLast; -// MESSAGE(" "<::reverse_iterator itp = params.rbegin(); - for (Standard_Integer i = nbPoints ; i >= 1; i--) - { - double param = (*itp).first; - gp_Pnt2d p = C2d->Value(param); - uvslf [m].x = scalex * p.X(); - uvslf [m].y = scaley * p.Y(); - mefistoToDS[m+1] = (*itp).second; -// MESSAGE(" "< * lid= + aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes(); + const SMDS_MeshNode* idFirst = lid->next(); + delete lid; + + ASSERT(!VLast.IsNull()); + lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); + const SMDS_MeshNode* idLast = lid->next(); + delete lid; + + // --- edge internal IDNodes (relies on good order storage, not checked) + + int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + //SCRUTE(nbPoints); + + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + + SMDS_Iterator * ite= + aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); + + bool isForward = (E.Orientation() == TopAbs_FORWARD); + map params; + + while(ite->more()) + { + const SMDS_MeshNode * node = ite->next(); + const SMDS_EdgePosition* epos + = static_cast(node->GetPosition()); + double param = epos->GetUParameter(); + params[param] = node; + } + delete ite; + // --- load 2D values into MEFISTO structure, + // add IDNodes in mefistoToDS map + + if (E.Orientation() == TopAbs_FORWARD) + { + gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward + uvslf[m].x = scalex * p.X(); + uvslf[m].y = scaley * p.Y(); + mefistoToDS[m + 1] = idFirst; + //MESSAGE(" "<::iterator itp = params.begin(); + for (int i = 1; i <= nbPoints; i++) // nbPoints internal + { + double param = (*itp).first; + gp_Pnt2d p = C2d->Value(param); + uvslf[m].x = scalex * p.X(); + uvslf[m].y = scaley * p.Y(); + mefistoToDS[m + 1] = (*itp).second; +// MESSAGE(" "<Value(l); // last point = Vertex Reversed + uvslf[m].x = scalex * p.X(); + uvslf[m].y = scaley * p.Y(); + mefistoToDS[m + 1] = idLast; +// MESSAGE(" "<::reverse_iterator itp = params.rbegin(); + for (int i = nbPoints; i >= 1; i--) + { + double param = (*itp).first; + gp_Pnt2d p = C2d->Value(param); + uvslf[m].x = scalex * p.X(); + uvslf[m].y = scaley * p.Y(); + mefistoToDS[m + 1] = (*itp).second; +// MESSAGE(" "<Value(param); - if (p.X() < xmin) xmin = p.X(); - if (p.X() > xmax) xmax = p.X(); - if (p.Y() < ymin) ymin = p.Y(); - if (p.Y() > ymax) ymax = p.Y(); -// MESSAGE(" "<< f<<" "<Value(param); + if (p.X() < xmin) + xmin = p.X(); + if (p.X() > xmax) + xmax = p.X(); + if (p.Y() < ymin) + ymin = p.Y(); + if (p.Y() > ymax) + ymax = p.Y(); +// MESSAGE(" "<< f<<" "<Value(xmin, ymoy); - gp_Pnt PY0 = S->Value(xmoy, ymin); - for (Standard_Integer i = 1; i<= nbp; i++) - { - double x = xmin + (double(i)/double(nbp))*(xmax-xmin); - gp_Pnt PX = S->Value(x,ymoy); - double y = ymin + (double(i)/double(nbp))*(ymax-ymin); - gp_Pnt PY = S->Value(xmoy,y); - length_x += PX.Distance(PX0); - length_y += PY.Distance(PY0); - PX0.SetCoord(PX.X(),PX.Y(),PX.Z()); - PY0.SetCoord(PY.X(),PY.Y(),PY.Z()); - } + double xmoy = (xmax + xmin) / 2.; + double ymoy = (ymax + ymin) / 2.; + + Handle(Geom_Surface) S = BRep_Tool::Surface(F); // 3D surface + + double length_x = 0; + double length_y = 0; + gp_Pnt PX0 = S->Value(xmin, ymoy); + gp_Pnt PY0 = S->Value(xmoy, ymin); + for (int i = 1; i <= nbp; i++) + { + double x = xmin + (double (i) / double (nbp))*(xmax - xmin); + gp_Pnt PX = S->Value(x, ymoy); + double y = ymin + (double (i) / double (nbp))*(ymax - ymin); + gp_Pnt PY = S->Value(xmoy, y); + length_x += PX.Distance(PX0); + length_y += PY.Distance(PY0); + PX0.SetCoord(PX.X(), PX.Y(), PX.Z()); + PY0.SetCoord(PY.X(), PY.Y(), PY.Z()); + } // SCRUTE(length_x); // SCRUTE(length_y); - scalex = length_x/(xmax - xmin); - scaley = length_y/(ymax - ymin); + scalex = length_x / (xmax - xmin); + scaley = length_y / (ymax - ymin); // SCRUTE(scalex); // SCRUTE(scaley); - ASSERT(scalex); - ASSERT(scaley); + ASSERT(scalex); + ASSERT(scaley); } //============================================================================= @@ -496,75 +485,71 @@ void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh, */ //============================================================================= -void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh, - Z nbst, R2* uvst, Z nbt, Z* nust, - const TopoDS_Face& F, bool faceIsForward, - map& mefistoToDS) +void SMESH_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh, + Z nbst, R2 * uvst, Z nbt, Z * nust, + const TopoDS_Face & F, bool faceIsForward, + map&mefistoToDS) { - double scalex; - double scaley; - ComputeScaleOnFace(aMesh, F, scalex, scaley); - - Handle (SMESHDS_Mesh) meshDS = aMesh.GetMeshDS(); - - Z n,m; - Handle(Geom_Surface) S = BRep_Tool::Surface(F); - - for ( n=0; nValue(u,v); - - if (mefistoToDS.find(n+1) == mefistoToDS.end()) - { - int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z()); - Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId); - Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt); - meshDS->SetNodeOnFace(node, F); - - //MESSAGE(nodeId<<" "<GetPosition()); - fpos->SetUParameter(u); - fpos->SetVParameter(v); - } - } - - m=0; - int mt=0; - - //SCRUTE(faceIsForward); - for ( n=1; n<=nbt; n++ ) - { - int inode1 = nust[m++]; - int inode2 = nust[m++]; - int inode3 = nust[m++]; - - int nodeId1 = mefistoToDS[inode1]; - int nodeId2 = mefistoToDS[inode2]; - int nodeId3 = mefistoToDS[inode3]; - //MESSAGE("-- "<AddFace(nodeId1, nodeId2, nodeId3); + double u = uvst[n][0] / scalex; + double v = uvst[n][1] / scaley; + gp_Pnt P = S->Value(u, v); + + if (mefistoToDS.find(n + 1) == mefistoToDS.end()) + { + SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); + meshDS->SetNodeOnFace(node, F); + + //MESSAGE(nodeId<<" "<(node->GetPosition()); + fpos->SetUParameter(u); + fpos->SetVParameter(v); + } } - else + + m = 0; + int mt = 0; + + //SCRUTE(faceIsForward); + for (n = 1; n <= nbt; n++) { - faceId = meshDS->AddFace(nodeId1, nodeId3, nodeId2); + int inode1 = nust[m++]; + int inode2 = nust[m++]; + int inode3 = nust[m++]; + + const SMDS_MeshNode *n1, *n2, *n3; + n1 = mefistoToDS[inode1]; + n2 = mefistoToDS[inode2]; + n3 = mefistoToDS[inode3]; + //MESSAGE("-- "<AddFace(n1, n2, n3); + else + elt = meshDS->AddFace(n1, n3, n2); + + meshDS->SetMeshElementOnShape(elt, F); + m++; } - Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId); - meshDS->SetMeshElementOnShape(elt, F); - m++; - } } //============================================================================= @@ -573,35 +558,35 @@ void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh, */ //============================================================================= -double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape) +double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape) { - MESSAGE("SMESH_MEFISTO_2D::ComputeEdgeElementLength"); - // **** a mettre dans SMESH_2D_Algo ? - - const TopoDS_Face& FF = TopoDS::Face(aShape); - bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); - TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); - - double meanElementLength = 100; - double wireLength =0; - int wireElementsNumber =0; - for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next()) - { - const TopoDS_Wire& W = TopoDS::Wire(exp.Current()); - for (TopExp_Explorer expe(W,TopAbs_EDGE); expe.More(); expe.Next()) + MESSAGE("SMESH_MEFISTO_2D::ComputeEdgeElementLength"); + // **** a mettre dans SMESH_2D_Algo ? + + const TopoDS_Face & FF = TopoDS::Face(aShape); + bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); + + double meanElementLength = 100; + double wireLength = 0; + int wireElementsNumber = 0; + for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) { - const TopoDS_Edge& E = TopoDS::Edge(expe.Current()); - int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); - double length = EdgeLength(E); - wireLength += length; - wireElementsNumber += nb; + const TopoDS_Wire & W = TopoDS::Wire(exp.Current()); + for (TopExp_Explorer expe(W, TopAbs_EDGE); expe.More(); expe.Next()) + { + const TopoDS_Edge & E = TopoDS::Edge(expe.Current()); + int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + double length = EdgeLength(E); + wireLength += length; + wireElementsNumber += nb; + } } - } - if (wireElementsNumber) - meanElementLength = wireLength/wireElementsNumber; - //SCRUTE(meanElementLength); - return meanElementLength; + if (wireElementsNumber) + meanElementLength = wireLength / wireElementsNumber; + //SCRUTE(meanElementLength); + return meanElementLength; } //============================================================================= @@ -612,7 +597,7 @@ double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh& aMesh, ostream & SMESH_MEFISTO_2D::SaveTo(ostream & save) { - return save << this; + return save << this; } //============================================================================= @@ -623,7 +608,7 @@ ostream & SMESH_MEFISTO_2D::SaveTo(ostream & save) istream & SMESH_MEFISTO_2D::LoadFrom(istream & load) { - return load >> (*this); + return load >> (*this); } //============================================================================= @@ -632,9 +617,9 @@ istream & SMESH_MEFISTO_2D::LoadFrom(istream & load) */ //============================================================================= -ostream & operator << (ostream & save, SMESH_MEFISTO_2D & hyp) +ostream & operator <<(ostream & save, SMESH_MEFISTO_2D & hyp) { - return save; + return save; } //============================================================================= @@ -643,8 +628,7 @@ ostream & operator << (ostream & save, SMESH_MEFISTO_2D & hyp) */ //============================================================================= -istream & operator >> (istream & load, SMESH_MEFISTO_2D & hyp) +istream & operator >>(istream & load, SMESH_MEFISTO_2D & hyp) { - return load; + return load; } -