X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_PipeDriver.cxx;h=e5f911209528b654be3dfec16d5a7b51b514890c;hb=e808f9b75f70810dfd0428313d3ba8ad2cfa16df;hp=87a0e5e164bcc44614a79d56a716e362efb9daa3;hpb=004197ec827d52331f0d529202eb4e52a1c4388f;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index 87a0e5e16..e5f911209 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -1,23 +1,23 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include @@ -33,8 +33,6 @@ #include #include -//#include - #include #include #include @@ -66,6 +64,7 @@ #include #include #include +#include #include #include #include @@ -147,21 +146,21 @@ static bool FillForOtherEdges(const TopoDS_Shape& F1, ShapeAnalysis_Edge sae; while(1) { - if(!aMapVertEdge1.Contains(VS1)) + if (!aMapVertEdge1.Contains(VS1)) MESSAGE (" FillForOtherEdges: map aMapVertEdge1 not contains key VS1"); const TopTools_ListOfShape& aList1 = aMapVertEdge1.FindFromKey(VS1); //TopoDS_Shape E1next; TopTools_ListIteratorOfListOfShape anIter1(aList1); - if(anIter1.Value().IsSame(ES1)) { + if (anIter1.Value().IsSame(ES1)) { anIter1.Next(); } //E1next = anIter1.Value(); - if(!aMapVertEdge2.Contains(VS2)) + if (!aMapVertEdge2.Contains(VS2)) MESSAGE (" FillForOtherEdges: map aMapVertEdge2 not contains key VS2"); const TopTools_ListOfShape& aList2 = aMapVertEdge2.FindFromKey(VS2); //TopoDS_Shape E2next; TopTools_ListIteratorOfListOfShape anIter2(aList2); - if(anIter2.Value().IsSame(ES2)) { + if (anIter2.Value().IsSame(ES2)) { anIter2.Next(); } //E2next = anIter2.Value(); @@ -169,20 +168,20 @@ static bool FillForOtherEdges(const TopoDS_Shape& F1, //ES2 = TopoDS::Edge(E2next); ES1 = TopoDS::Edge(anIter1.Value()); ES2 = TopoDS::Edge(anIter2.Value()); - if(!FF.Contains(ES1)) { + if (!FF.Contains(ES1)) { FF.Add(ES1,ES2); } - if(VS1.IsSame(sae.FirstVertex(ES1))) + if (VS1.IsSame(sae.FirstVertex(ES1))) VS1 = sae.LastVertex(ES1); else VS1 = sae.FirstVertex(ES1); - if(VS2.IsSame(sae.FirstVertex(ES2))) + if (VS2.IsSame(sae.FirstVertex(ES2))) VS2 = sae.LastVertex(ES2); else VS2 = sae.FirstVertex(ES2); - if(VS1.IsSame(V1)) + if (VS1.IsSame(V1)) break; - if(!FF.Contains(VS1)) { + if (!FF.Contains(VS1)) { FF.Add(VS1,VS2); } } @@ -211,7 +210,7 @@ static bool FillCorrespondingEdges(const TopoDS_Shape& FS1, BRepOffsetAPI_MakePipeShell aBuilder(aWirePath); aBuilder.Add(aWire1, aLoc1); aBuilder.Add(aWire2, aLoc2); - if(!aBuilder.IsReady()) { + if (!aBuilder.IsReady()) { return false; } aBuilder.Build(); @@ -226,11 +225,11 @@ static bool FillCorrespondingEdges(const TopoDS_Shape& FS1, BRepTools::Write(C,"/dn02/users_Linux/skl/work/Bugs/14857/comp.brep"); */ ShapeAnalysis_Edge sae; - double tol = Max( BRep_Tool::Tolerance(TopoDS::Face(FS1)), - BRep_Tool::Tolerance(TopoDS::Face(FS2)) ); + double tol = Max(BRep_Tool::Tolerance(TopoDS::Face(FS1)), + BRep_Tool::Tolerance(TopoDS::Face(FS2))); TopTools_MapOfShape Vs1,Vs2; TopExp_Explorer exp; - exp.Init( FS1, TopAbs_EDGE ); + exp.Init(FS1, TopAbs_EDGE); TopoDS_Edge E1 = TopoDS::Edge(exp.Current()); TopoDS_Vertex V11 = sae.FirstVertex(E1); TopoDS_Vertex V21 = sae.LastVertex(E1); @@ -240,43 +239,43 @@ static bool FillCorrespondingEdges(const TopoDS_Shape& FS1, //cout<<"P21("<Length(); + Standard_Integer nbLocs = (theHSeqLocs.IsNull() ? 0 : theHSeqLocs->Length()); + + if (nbLocs && nbLocs != nbBases) { + Standard_ConstructionError::Raise("Number of sections is not equal to number of locations "); + } + + TopTools_SequenceOfShape aSeqBases; + TopTools_SequenceOfShape aSeqLocs; + TopTools_SequenceOfShape aSeqFaces; + + Standard_Integer i = 1; + for (i = 1; i <= nbBases; i++) { + if (theHSeqBases->Value(i).IsNull()) + continue; + + // Make copy to prevent modifying of base object 0020766 : EDF 1320 + TopoDS_Shape aShapeBase; + BRepBuilderAPI_Copy Copy (theHSeqBases->Value(i)); + if (Copy.IsDone()) + aShapeBase = Copy.Shape(); + + TopAbs_ShapeEnum aTypeBase = aShapeBase.ShapeType(); + + //if for section was specified face with a few wires then a few + // pipes were build and make solid + Standard_Boolean NeedCreateSolid = Standard_False; + if (aTypeBase == TopAbs_SHELL) { + // create wire as boundary contour if shell is no closed + // get free boundary shapes + ShapeAnalysis_FreeBounds anAnalizer(aShapeBase); + TopoDS_Compound aClosed = anAnalizer.GetClosedWires(); + TopExp_Explorer anExp; + TopoDS_Shape aWire; + Standard_Integer NbWires = 0; + for (anExp.Init(aClosed, TopAbs_WIRE); anExp.More(); anExp.Next()) { + NbWires++; + aWire = anExp.Current(); + } + if (NbWires != 1) { + // bad case + Standard_ConstructionError::Raise("Bad shell is used as section "); + } + NeedCreateSolid = Standard_True; + aSeqFaces.Append(aShapeBase); + aSeqBases.Append(aWire); + } + else if (aTypeBase == TopAbs_FACE) { + NeedCreateSolid = Standard_True; + //for case one path should be used other type function + aSeqFaces.Append(aShapeBase); + TopExp_Explorer aExpW(aShapeBase,TopAbs_WIRE); + for (; aExpW.More(); aExpW.Next()) { + TopoDS_Shape aWireProf = aExpW.Current(); + aSeqBases.Append(aWireProf); + } + } + else if (aTypeBase == TopAbs_WIRE || aTypeBase == TopAbs_VERTEX) { + aSeqBases.Append(aShapeBase); + } + else if (aTypeBase == TopAbs_EDGE) { + TopoDS_Edge anEdge = TopoDS::Edge(aShapeBase); + TopoDS_Shape aWireProf = BRepBuilderAPI_MakeWire(anEdge); + aSeqBases.Append(aWireProf); + } + if (nbLocs) { + TopoDS_Shape aShapeLoc = theHSeqLocs->Value(i); + if (aShapeLoc.IsNull() || aShapeLoc.ShapeType() != TopAbs_VERTEX) + continue; + aSeqLocs.Append(aShapeLoc); + } + } + + nbLocs = aSeqLocs.Length(); + + // skl 02.05.2007 + TopTools_SequenceOfShape Edges; + if (nbLocs > 0) { + // we have to check that each location shape is a vertex from + // path and update aSeqLocs if it is needed (and possible) + TColgp_SequenceOfPnt PLocs; + for (i=1; i<=nbLocs; i++) { + TopoDS_Vertex V = TopoDS::Vertex(aSeqLocs.Value(i)); + PLocs.Append(BRep_Tool::Pnt(V)); + } + //TopTools_SequenceOfShape Edges; + TopExp_Explorer anExp; + for (anExp.Init(aWirePath, TopAbs_EDGE); anExp.More(); anExp.Next()) { + Edges.Append(anExp.Current()); + } + int nbEdges = Edges.Length(); + ShapeAnalysis_Edge sae; + TopoDS_Edge edge = TopoDS::Edge(Edges.First()); + double tol = BRep_Tool::Tolerance(edge); + TopoDS_Vertex VF = sae.FirstVertex(edge); + gp_Pnt PF = BRep_Tool::Pnt(VF); + //cout<<"PF("< tol) { + Standard_ConstructionError::Raise + ("First location shapes is not coincided with first vertex of aWirePath"); + } + aSeqLocs.ChangeValue(1) = VF; + edge = TopoDS::Edge(Edges.Last()); + tol = BRep_Tool::Tolerance(edge); + TopoDS_Vertex VL = sae.LastVertex(edge); + gp_Pnt PL = BRep_Tool::Pnt(VL); + if (PL.Distance(PLocs.Last()) > tol) { + Standard_ConstructionError::Raise + ("Last location shapes is not coincided with last vertex of aWirePath"); + } + aSeqLocs.ChangeValue(nbLocs) = VL; + int jcurr = 2; + for (i=1; i<=Edges.Length() && jcurr0 && + PLocs.Value(jcurr).Distance(PPCurve.Point(1)) < tol) { + double param = PPCurve.Parameter(1); + gp_Pnt PC1; + C->D0(param,PC1); + // split current edge + Handle(Geom_TrimmedCurve) tc1 = new Geom_TrimmedCurve(C,fp,param); + Handle(Geom_TrimmedCurve) tc2 = new Geom_TrimmedCurve(C,param,lp); + TopoDS_Edge E1,E2; + BRep_Builder B; + gp_Pnt Pfp; + C->D0(fp,Pfp); + if (Pfp.Distance(P1) we have to update WirePath + BRep_Builder B; + TopoDS_Wire W; + B.MakeWire(W); + for (i=1; i<=Edges.Length(); i++) { + B.Add(W,TopoDS::Edge(Edges.Value(i))); + } + aWirePath = W; + } + } + + // check curvature of wire for condition that + // max summary angle between directions along + // wire path must be < 4*PI. If not - split wire + // and seguences of shapes, perform pipe for each + // and make sewing after that + double fp,lp; + Handle(Geom_Curve) C = BRep_Tool::Curve(TopoDS::Edge(Edges.Value(1)),fp,lp); + gp_Pnt P1,P2; + gp_Vec Vec1,Vec2; + C->D1(fp,P1,Vec1); + C->D1(lp,P2,Vec2); + double SumAng = fabs(Vec1.Angle(Vec2)); + Vec1 = Vec2; + P1 = P2; + TColStd_SequenceOfInteger SplitEdgeNums,SplitLocNums; + int LastLoc = 1; + //cout<<"Edges.Length()="<D1(lp,P2,Vec2); + double ang = fabs(Vec1.Angle(Vec2)); + SumAng += ang; + if (SumAng>4*PI) { + SumAng = ang; + SplitEdgeNums.Append(i-1); + int j; + for (j=LastLoc+1; j<=aSeqLocs.Length(); j++) { + TopoDS_Vertex aVert = TopoDS::Vertex(aSeqLocs.Value(j)); + gp_Pnt P = BRep_Tool::Pnt(aVert); + if (P1.Distance(P) < tol) { + SplitLocNums.Append(j); + LastLoc = j; + break; + } + } + } + Vec1 = Vec2; + P1 = P2; + } + + if (SplitLocNums.Length()==SplitEdgeNums.Length() && SplitEdgeNums.Length()>0) { + TopTools_SequenceOfShape aSeqRes; + int nn, num1 = 1, num2 = 1; + for (nn=1; nn<=SplitEdgeNums.Length(); nn++) { + // create wirepath and sequences of shapes + BRep_Builder B; + TopoDS_Wire tmpW; + B.MakeWire(tmpW); + for (i=num1; i<=SplitEdgeNums.Value(nn); i++) { + B.Add(tmpW,TopoDS::Edge(Edges.Value(i))); + } + num1 = SplitEdgeNums.Value(nn) + 1; + TopTools_SequenceOfShape aTmpSeqBases; + TopTools_SequenceOfShape aTmpSeqLocs; + for (i=num2; i<=SplitLocNums.Value(nn); i++) { + aTmpSeqBases.Append(aSeqBases.Value(i)); + aTmpSeqLocs.Append(aSeqLocs.Value(i)); + } + num2 = SplitLocNums.Value(nn); + // make pipe + BRepOffsetAPI_MakePipeShell aBuilder(tmpW); + Standard_Integer nbShapes = aTmpSeqBases.Length(); + for (i=1; i<=nbShapes; i++) { + TopoDS_Shape aShapeLoc = aTmpSeqLocs.Value(i); + TopoDS_Vertex aVert = TopoDS::Vertex(aShapeLoc); + aBuilder.Add(aTmpSeqBases.Value(i), aVert, theWithContact, theWithCorrect); + } + if (!aBuilder.IsReady()) { + Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); + } + aBuilder.Build(); + TopoDS_Shape resShape = aBuilder.Shape(); + aSeqRes.Append(resShape); + } + // create wirepath and sequences of shapes for last part + BRep_Builder B; + TopoDS_Wire tmpW; + B.MakeWire(tmpW); + for (i=num1; i<=Edges.Length(); i++) { + B.Add(tmpW,TopoDS::Edge(Edges.Value(i))); + } + TopTools_SequenceOfShape aTmpSeqBases; + TopTools_SequenceOfShape aTmpSeqLocs; + for (i=num2; i<=aSeqLocs.Length(); i++) { + aTmpSeqBases.Append(aSeqBases.Value(i)); + aTmpSeqLocs.Append(aSeqLocs.Value(i)); + } + // make pipe for last part + BRepOffsetAPI_MakePipeShell aBuilder(tmpW); + Standard_Integer nbShapes = aTmpSeqBases.Length(); + for (i=1; i<=nbShapes; i++) { + TopoDS_Shape aShapeLoc = aTmpSeqLocs.Value(i); + TopoDS_Vertex aVert = TopoDS::Vertex(aShapeLoc); + aBuilder.Add(aTmpSeqBases.Value(i), aVert, theWithContact, theWithCorrect); + } + if (!aBuilder.IsReady()) { + Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); + } + aBuilder.Build(); + TopoDS_Shape resShape = aBuilder.Shape(); + aSeqRes.Append(resShape); + // make sewing for result + Handle(BRepBuilderAPI_Sewing) aSewing = new BRepBuilderAPI_Sewing; + aSewing->SetTolerance(Precision::Confusion()); + aSewing->SetFaceMode(Standard_True); + aSewing->SetFloatingEdgesMode(Standard_False); + aSewing->SetNonManifoldMode(Standard_False); + for (i=1; i<=aSeqRes.Length(); i++) { + aSewing->Add(aSeqRes.Value(i)); + } + aSewing->Perform(); + aShape = aSewing->SewedShape(); + } + else { + // old implementation without splitting + BRepOffsetAPI_MakePipeShell aBuilder(aWirePath); + + Standard_Integer nbShapes = aSeqBases.Length(); + Standard_Integer step = nbShapes/nbBases; + + if (nbShapes < nbBases || fmod((double)nbShapes, (double)nbBases)) { + Standard_ConstructionError::Raise("Invalid sections were specified for building pipe"); + } + Standard_Integer ind =0; + for (i = 1; i <= nbShapes && ind < nbShapes; i++) { //i+nbBases <= nbShapes + TopTools_SequenceOfShape usedBases; + Standard_Integer j = 1; + for (; j <= nbBases; j++) { + ind = i + (j-1)*step; + TopoDS_Shape aWireProf = aSeqBases.Value(ind); + usedBases.Append(aWireProf); + if (nbLocs) { + TopoDS_Shape aShapeLoc = aSeqLocs.Value(j); + TopoDS_Vertex aVert = TopoDS::Vertex(aShapeLoc); + aBuilder.Add(aWireProf, aVert, theWithContact, theWithCorrect); + } + else + aBuilder.Add(aWireProf, theWithContact, theWithCorrect); + } + if (!aBuilder.IsReady()) { + Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); + } + aBuilder.Build(); + aShape = aBuilder.Shape(); + aSeqFaces.Append(aShape); + for (j = 1; j <=usedBases.Length(); j++) + aBuilder.Delete(usedBases.Value(j)); + } + + //for case if section is face + if (aSeqFaces.Length() >1) { + BRep_Builder aB; + TopoDS_Compound aComp; + aB.MakeCompound(aComp); + for (i = 1; i <= aSeqFaces.Length(); i++) + aB.Add(aComp,aSeqFaces.Value(i)); + aShape = aComp; + } + } + + return aShape; +} + //======================================================================= //function : CreatePipeForShellSections //purpose : auxilary for Execute() @@ -637,36 +997,36 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, nbSubBases = (aSubBasesObjs.IsNull() ? 0 :aSubBasesObjs->Length()), nbLocs = (aLocObjs.IsNull() ? 0 :aLocObjs->Length()); - if( nbLocs != nbBases) { - if(aCI) delete aCI; + if (nbLocs != nbBases) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Number of sections is not equal to number of locations "); } - if( nbSubBases && nbSubBases != nbBases) { - if(aCI) delete aCI; + if (nbSubBases && nbSubBases != nbBases) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Number of sections is not equal to number of subsections "); } //BRepOffsetAPI_MakePipeShell aBuilder(aWirePath); TopTools_SequenceOfShape VLocs; - for(i=1; i<=nbBases; i++) { + for (i=1; i<=nbBases; i++) { Handle(Standard_Transient) anItemLoc = aLocObjs->Value(i); - if(anItemLoc.IsNull()) + if (anItemLoc.IsNull()) continue; Handle(GEOM_Function) aRefLoc = Handle(GEOM_Function)::DownCast(anItemLoc); TopoDS_Shape aShapeLoc = aRefLoc->GetValue(); - if(aShapeLoc.IsNull() || aShapeLoc.ShapeType() != TopAbs_VERTEX) + if (aShapeLoc.IsNull() || aShapeLoc.ShapeType() != TopAbs_VERTEX) continue; VLocs.Append(aShapeLoc); } nbLocs = VLocs.Length(); - if( nbLocs != nbBases) { - if(aCI) delete aCI; + if (nbLocs != nbBases) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("One of location shapes is not a vertex"); } // split wire path by location points TColgp_SequenceOfPnt PLocs; - for(i=1; i<=nbLocs; i++) { + for (i=1; i<=nbLocs; i++) { TopoDS_Vertex V = TopoDS::Vertex(VLocs.Value(i)); PLocs.Append(BRep_Tool::Pnt(V)); } @@ -675,31 +1035,31 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, TopTools_SequenceOfShape Wires; ShapeAnalysis_Edge sae; - if(nbLocs==2) { + if (nbLocs==2) { TopExp_Explorer anExp; - for ( anExp.Init( aWirePath, TopAbs_EDGE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aWirePath, TopAbs_EDGE); anExp.More(); anExp.Next()) { Edges.Append(anExp.Current()); } Standard_Integer Num1 = 0; Standard_Integer Num2 = 0; - for(i=1; i<=Edges.Length(); i++) { + for (i=1; i<=Edges.Length(); i++) { TopoDS_Edge E = TopoDS::Edge(Edges.Value(i)); double tol = BRep_Tool::Tolerance(E); TopoDS_Vertex V1 = sae.FirstVertex(E); TopoDS_Vertex V2 = sae.LastVertex(E); gp_Pnt P1 = BRep_Tool::Pnt(V1); gp_Pnt P2 = BRep_Tool::Pnt(V2); - if( P1.Distance(PLocs.First()) < tol ) { + if (P1.Distance(PLocs.First()) < tol) { Num1 = i; } - if( P2.Distance(PLocs.Last()) < tol ) { + if (P2.Distance(PLocs.Last()) < tol) { Num2 = i; } } - if( Num1>0 && Num2>0 ) { + if (Num1>0 && Num2>0) { TopoDS_Wire W; B.MakeWire(W); - for(i=Num1; i<=Num2; i++) { + for (i=Num1; i<=Num2; i++) { B.Add(W,Edges.Value(i)); } Wires.Append(W); @@ -710,7 +1070,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, } else { TopExp_Explorer anExp; - for ( anExp.Init( aWirePath, TopAbs_EDGE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aWirePath, TopAbs_EDGE); anExp.More(); anExp.Next()) { Edges.Append(anExp.Current()); } TopoDS_Edge edge = TopoDS::Edge(Edges.First()); @@ -718,8 +1078,8 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, TopoDS_Vertex VF = sae.FirstVertex(edge); gp_Pnt PF = BRep_Tool::Pnt(VF); //cout<<"PF("< tol ) { - if(aCI) delete aCI; + if (PF.Distance(PLocs.First()) > tol) { + if (aCI) delete aCI; Standard_ConstructionError::Raise ("First location shapes is not coincided with first vertex of aWirePath"); } @@ -728,27 +1088,27 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, tol = BRep_Tool::Tolerance(edge); TopoDS_Vertex VL = sae.LastVertex(edge); gp_Pnt PL = BRep_Tool::Pnt(VL); - if( PL.Distance(PLocs.Last()) > tol ) { - if(aCI) delete aCI; + if (PL.Distance(PLocs.Last()) > tol) { + if (aCI) delete aCI; Standard_ConstructionError::Raise ("Last location shapes is not coincided with last vertex of aWirePath"); } VLocs.ChangeValue(nbLocs) = VL; int jcurr = 2; TopTools_SequenceOfShape tmpEdges; - for(i=1; i<=Edges.Length() && jcurr0 && - PLocs.Value(jcurr).Distance(PPC.Point(1)) < tol ) { - double param = PPC.Parameter(1); + GeomAPI_ProjectPointOnCurve PPCurve (PLocs.Value(jcurr),C); + if (PPCurve.NbPoints()>0 && + PLocs.Value(jcurr).Distance(PPCurve.Point(1)) < tol) { + double param = PPCurve.Parameter(1); gp_Pnt PC1; C->D0(param,PC1); // split current edge @@ -772,7 +1132,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, TopoDS_Edge E1,E2; gp_Pnt Pfp; C->D0(fp,Pfp); - if(Pfp.Distance(P1)Value(i); - if(anItem1.IsNull()) + if (anItem1.IsNull()) continue; Handle(GEOM_Function) aRefBase1 = Handle(GEOM_Function)::DownCast(anItem1); - if(aRefBase1.IsNull()) + if (aRefBase1.IsNull()) continue; TopoDS_Shape aShBase1 = aRefBase1->GetValue(); - if(aShBase1.IsNull()) + if (aShBase1.IsNull()) continue; TopAbs_ShapeEnum aType1 = aShBase1.ShapeType(); // 2 section Handle(Standard_Transient) anItem2 = aBasesObjs->Value(i+1); - if(anItem2.IsNull()) + if (anItem2.IsNull()) continue; Handle(GEOM_Function) aRefBase2 = Handle(GEOM_Function)::DownCast(anItem2); - if(aRefBase2.IsNull()) + if (aRefBase2.IsNull()) continue; TopoDS_Shape aShBase2 = aRefBase2->GetValue(); - if(aShBase2.IsNull()) + if (aShBase2.IsNull()) continue; TopAbs_ShapeEnum aType2 = aShBase2.ShapeType(); //BRepTools::Write(aShBase1,"/dn02/users_Linux/skl/work/Bugs/14857/base1.brep"); - bool OkSec = ( aType1==TopAbs_SHELL || aType1==TopAbs_FACE ) && - ( aType2==TopAbs_SHELL || aType2==TopAbs_FACE ); - if( !OkSec ) { - if(aCI) delete aCI; + bool OkSec = (aType1==TopAbs_SHELL || aType1==TopAbs_FACE) && + (aType2==TopAbs_SHELL || aType2==TopAbs_FACE); + if (!OkSec) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("One of section shapes has invalid type"); } @@ -871,14 +1231,14 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, // compare sections TopExp_Explorer anExp; Standard_Integer nbf1 = 0; - for ( anExp.Init( aShBase1, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShBase1, TopAbs_FACE); anExp.More(); anExp.Next()) { nbf1++; } Standard_Integer nbf2 = 0; - for ( anExp.Init( aShBase2, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShBase2, TopAbs_FACE); anExp.More(); anExp.Next()) { nbf2++; } - if(nbf1==nbf2) { + if (nbf1==nbf2) { CreateFewSolids = true; } @@ -887,22 +1247,22 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, bool NeedReverse = false; { // first section - anExp.Init( aShBase1, TopAbs_FACE ); + anExp.Init(aShBase1, TopAbs_FACE); TopoDS_Shape aFace = anExp.Current(); TColgp_SequenceOfPnt aPnts; double xc=0, yc=0, zc=0; - for ( anExp.Init( aFace, TopAbs_VERTEX ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aFace, TopAbs_VERTEX); anExp.More(); anExp.Next()) { TopoDS_Vertex V = TopoDS::Vertex(anExp.Current()); aPnts.Append(BRep_Tool::Pnt(V)); xc += aPnts.Last().X(); yc += aPnts.Last().Y(); zc += aPnts.Last().Z(); } - gp_Pnt PC( xc/aPnts.Length(), yc/aPnts.Length(), zc/aPnts.Length() ); + gp_Pnt PC(xc/aPnts.Length(), yc/aPnts.Length(), zc/aPnts.Length()); gp_Vec V1(PC,aPnts.Value(1)); gp_Vec V2(PC,aPnts.Value(2)); gp_Vec VN = V1.Crossed(V2); - for(int ip=2; ipD0(fp,P1); - if( P1.Distance(PLoc) < tol ) { + if (P1.Distance(PLoc) < tol) { C->D0(fp+(lp-fp)/100,P2); } else { @@ -933,12 +1293,12 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, else { TopoDS_Vertex VL = sae.LastVertex(edge); gp_Pnt PL = BRep_Tool::Pnt(VL); - if( PL.Distance(PLoc) < tol ) { + if (PL.Distance(PLoc) < tol) { double fp,lp; Handle(Geom_Curve) C = BRep_Tool::Curve(edge,fp,lp); gp_Pnt P1,P2; C->D0(fp,P1); - if( P1.Distance(PLoc) < tol ) { + if (P1.Distance(PLoc) < tol) { C->D0(fp+(lp-fp)/100,P2); } else { @@ -952,29 +1312,29 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, } cout<<"VN("<PI/2.) { + if (fabs(VN.Angle(PathNorm))>PI/2.) { NeedReverse = true; aShBase1.Reverse(); } } { // second section - anExp.Init( aShBase2, TopAbs_FACE ); + anExp.Init(aShBase2, TopAbs_FACE); TopoDS_Shape aFace = anExp.Current(); TColgp_SequenceOfPnt aPnts; double xc=0, yc=0, zc=0; - for ( anExp.Init( aFace, TopAbs_VERTEX ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aFace, TopAbs_VERTEX); anExp.More(); anExp.Next()) { TopoDS_Vertex V = TopoDS::Vertex(anExp.Current()); aPnts.Append(BRep_Tool::Pnt(V)); xc += aPnts.Last().X(); yc += aPnts.Last().Y(); zc += aPnts.Last().Z(); } - gp_Pnt PC( xc/aPnts.Length(), yc/aPnts.Length(), zc/aPnts.Length() ); + gp_Pnt PC(xc/aPnts.Length(), yc/aPnts.Length(), zc/aPnts.Length()); gp_Vec V1(PC,aPnts.Value(1)); gp_Vec V2(PC,aPnts.Value(2)); gp_Vec VN = V1.Crossed(V2); - for(int ip=2; ipD0(fp,P1); - if( P1.Distance(PLoc) < tol ) { + if (P1.Distance(PLoc) < tol) { C->D0(fp+(lp-fp)/100,P2); } else { @@ -1005,12 +1365,12 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, else { TopoDS_Vertex VL = sae.LastVertex(edge); gp_Pnt PL = BRep_Tool::Pnt(VL); - if( PL.Distance(PLoc) < tol ) { + if (PL.Distance(PLoc) < tol) { double fp,lp; Handle(Geom_Curve) C = BRep_Tool::Curve(edge,fp,lp); gp_Pnt P1,P2; C->D0(fp,P1); - if( P1.Distance(PLoc) < tol ) { + if (P1.Distance(PLoc) < tol) { C->D0(fp+(lp-fp)/100,P2); } else { @@ -1024,29 +1384,29 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, } //cout<<"VN("<PI/2.) + if (fabs(VN.Angle(PathNorm))>PI/2.) aShBase2.Reverse(); } */ - if(!CreateFewSolids) { + if (!CreateFewSolids) { // we can create only one solid TopoDS_Shape aWire1, aWire2; // prepare aWire1 - if(aType1==TopAbs_SHELL) { + if (aType1==TopAbs_SHELL) { // create wire as boundary contour if shell is no closed // get free boundary shapes - ShapeAnalysis_FreeBounds anAnalizer( aShBase1 ); + ShapeAnalysis_FreeBounds anAnalizer(aShBase1); TopoDS_Compound aClosed = anAnalizer.GetClosedWires(); //TopExp_Explorer anExp; Standard_Integer NbWires = 0; - for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aClosed, TopAbs_WIRE); anExp.More(); anExp.Next()) { NbWires++; aWire1 = anExp.Current(); } - if(NbWires!=1) { + if (NbWires!=1) { // bad case - if(aCI) delete aCI; + if (aCI) delete aCI; Standard_ConstructionError::Raise("Bad shell is used as section "); } } @@ -1055,20 +1415,20 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, aWire1 = aExpW.Current(); } // prepare aWire2 - if(aType2==TopAbs_SHELL) { + if (aType2==TopAbs_SHELL) { // create wire as boundary contour if shell is no closed // get free boundary shapes - ShapeAnalysis_FreeBounds anAnalizer( aShBase2 ); + ShapeAnalysis_FreeBounds anAnalizer(aShBase2); TopoDS_Compound aClosed = anAnalizer.GetClosedWires(); //TopExp_Explorer anExp; Standard_Integer NbWires = 0; - for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aClosed, TopAbs_WIRE); anExp.More(); anExp.Next()) { NbWires++; aWire2 = anExp.Current(); } - if(NbWires!=1) { + if (NbWires!=1) { // bad case - if(aCI) delete aCI; + if (aCI) delete aCI; Standard_ConstructionError::Raise("Bad shell is used as section "); } } @@ -1077,28 +1437,28 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, aWire2 = aExpW.Current(); } // make pipe using aWire1 and aWire2 - if( !aWire1.IsNull() && !aWire2.IsNull() ) { + if (!aWire1.IsNull() && !aWire2.IsNull()) { //BRepOffsetAPI_MakePipeShell aBuilder(aWirePath); BRepOffsetAPI_MakePipeShell aBuilder(WPath); aBuilder.Add(aWire1, TopoDS::Vertex(VLocs(i)), aWithContact, aWithCorrect); aBuilder.Add(aWire2, TopoDS::Vertex(VLocs(i+1)), aWithContact, aWithCorrect); - if(!aBuilder.IsReady()) { - if(aCI) delete aCI; + if (!aBuilder.IsReady()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); } aBuilder.Build(); TopoDS_Shape aShape = aBuilder.Shape(); TopoDS_Shell aShell; B.MakeShell(aShell); - for ( anExp.Init( aShape, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShape, TopAbs_FACE); anExp.More(); anExp.Next()) { B.Add(aShell,anExp.Current()); } - for ( anExp.Init( aShBase1, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShBase1, TopAbs_FACE); anExp.More(); anExp.Next()) { B.Add(aShell,anExp.Current()); } - for ( anExp.Init( aShBase2, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShBase2, TopAbs_FACE); anExp.More(); anExp.Next()) { B.Add(aShell,anExp.Current()); } // make sewing for this shell @@ -1107,19 +1467,19 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, aSewing->SetFaceMode(Standard_True); aSewing->SetFloatingEdgesMode(Standard_False); aSewing->SetNonManifoldMode(Standard_False); - for ( anExp.Init( aShell, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShell, TopAbs_FACE); anExp.More(); anExp.Next()) { aSewing->Add(anExp.Current()); } aSewing->Perform(); const TopoDS_Shape aSewShape = aSewing->SewedShape(); - if( aSewShape.ShapeType() == TopAbs_SHELL ) { + if (aSewShape.ShapeType() == TopAbs_SHELL) { aShell = TopoDS::Shell(aSewShape); GProp_GProps aSystem; BRepGProp::VolumeProperties(aShell, aSystem); - if(aSystem.Mass()<0) { + if (aSystem.Mass()<0) { aShell.Reverse(); } - if(BRep_Tool::IsClosed(aShell)) { + if (BRep_Tool::IsClosed(aShell)) { TopoDS_Solid aSolid; B.MakeSolid(aSolid); B.Add(aSolid,aShell); @@ -1137,10 +1497,10 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, else { // main block - creation few solids (for each pair of faces) TopTools_MapOfShape aFaces1,aFaces2; - for ( anExp.Init( aShBase1, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShBase1, TopAbs_FACE); anExp.More(); anExp.Next()) { aFaces1.Add(anExp.Current()); } - for ( anExp.Init( aShBase2, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShBase2, TopAbs_FACE); anExp.More(); anExp.Next()) { aFaces2.Add(anExp.Current()); } // creating map of edge faces @@ -1152,26 +1512,26 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, // constuct map face->face TopTools_IndexedDataMapOfShapeShape FF; TopoDS_Shape FS1,FS2; - if(nbSubBases==0) { + if (nbSubBases==0) { // find edge the most distant from location point // (this edge is not shared by two faces) double maxdist = 0.; TopoDS_Shape E1; TopoDS_Vertex V11,V21; - for(j=1; j<=aMapEdgeFaces1.Extent(); j++) { + for (j=1; j<=aMapEdgeFaces1.Extent(); j++) { TopoDS_Shape tmp = aMapEdgeFaces1.FindKey(j); const TopTools_ListOfShape& aList = aMapEdgeFaces1.FindFromKey(tmp); - if(aList.Extent()>1) + if (aList.Extent()>1) continue; TopExp_Explorer expv; - expv.Init( tmp, TopAbs_VERTEX ); + expv.Init(tmp, TopAbs_VERTEX); TopoDS_Vertex V1 = TopoDS::Vertex(expv.Current()); expv.Next(); TopoDS_Vertex V2 = TopoDS::Vertex(expv.Current()); gp_Pnt P1 = BRep_Tool::Pnt(V1); gp_Pnt P2 = BRep_Tool::Pnt(V2); double dist = PLocs.Value(i).Distance(P1) + PLocs.Value(i).Distance(P2); - if(dist>maxdist) { + if (dist>maxdist) { E1 = tmp; V11 = V1; V21 = V2; @@ -1188,13 +1548,13 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, gp_Pnt P21 = BRep_Tool::Pnt(V21); TopoDS_Shape E2; TopoDS_Vertex V12,V22; - for(j=1; j<=aMapEdgeFaces2.Extent(); j++) { + for (j=1; j<=aMapEdgeFaces2.Extent(); j++) { TopoDS_Shape tmp = aMapEdgeFaces2.FindKey(j); const TopTools_ListOfShape& aList = aMapEdgeFaces2.FindFromKey(tmp); - if(aList.Extent()>1) + if (aList.Extent()>1) continue; TopExp_Explorer expv; - expv.Init( tmp, TopAbs_VERTEX ); + expv.Init(tmp, TopAbs_VERTEX); TopoDS_Vertex V1tmp = TopoDS::Vertex(expv.Current()); expv.Next(); TopoDS_Vertex V2tmp = TopoDS::Vertex(expv.Current()); @@ -1204,7 +1564,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, double d2 = P1tmp.Distance(P21) + P2tmp.Distance(P11); TopoDS_Vertex V1,V2; gp_Pnt P1,P2; - if(d1>d2) { + if (d1>d2) { V1 = V2tmp; P1 = P2tmp; V2 = V1tmp; P2 = P1tmp; } @@ -1215,7 +1575,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, gp_Vec Vec1(P11,P1); gp_Vec Vec2(P21,P2); double ang = fabs(Vec1.Angle(VM)) + fabs(Vec2.Angle(VM)); - if(angValue(i); - if(anItem.IsNull()) { - if(aCI) delete aCI; + if (anItem.IsNull()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid subbase shape"); } Handle(GEOM_Function) aRefBase = Handle(GEOM_Function)::DownCast(anItem); - if(aRefBase.IsNull()) { - if(aCI) delete aCI; + if (aRefBase.IsNull()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid subbase shape"); } TopoDS_Shape aSh = aRefBase->GetValue(); - if(aSh.IsNull()) { - if(aCI) delete aCI; + if (aSh.IsNull()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid subbase shape"); } - if(aSh.ShapeType()!=TopAbs_FACE) { - if(aCI) delete aCI; + if (aSh.ShapeType()!=TopAbs_FACE) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid subbase shape"); } FS1 = aSh; } { // 2 section Handle(Standard_Transient) anItem = aSubBasesObjs->Value(i+1); - if(anItem.IsNull()) { - if(aCI) delete aCI; + if (anItem.IsNull()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid subbase shape"); } Handle(GEOM_Function) aRefBase = Handle(GEOM_Function)::DownCast(anItem); - if(aRefBase.IsNull()) { - if(aCI) delete aCI; + if (aRefBase.IsNull()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid subbase shape"); } TopoDS_Shape aSh = aRefBase->GetValue(); - if(aSh.IsNull()) { - if(aCI) delete aCI; + if (aSh.IsNull()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid subbase shape"); } - if(aSh.ShapeType()!=TopAbs_FACE) { - if(aCI) delete aCI; + if (aSh.ShapeType()!=TopAbs_FACE) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid subbase shape"); } FS2 = aSh; } - if( !aFaces1.Contains(FS1) || !aFaces2.Contains(FS2) ) { - if(aCI) delete aCI; + if (!aFaces1.Contains(FS1) || !aFaces2.Contains(FS2)) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid subbase shape"); } @@ -1294,8 +1654,8 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, // add pairs of edges to FF bool stat = FillCorrespondingEdges(FS1, FS2, TopoDS::Vertex(VLocs(i)), TopoDS::Vertex(VLocs(i+1)), WPath, FF); - if( !stat ) { - if(aCI) delete aCI; + if (!stat) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Can not create correct pipe"); } } @@ -1303,9 +1663,9 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, FindNextPairOfFaces(FS1, aMapEdgeFaces1, aMapEdgeFaces2, FF, aCI); // make pipe for each pair of faces - for(j=1; j<=FF.Extent(); j++) { + for (j=1; j<=FF.Extent(); j++) { TopoDS_Shape F1 = FF.FindKey(j); - if( F1.ShapeType() != TopAbs_FACE ) + if (F1.ShapeType() != TopAbs_FACE) continue; TopoDS_Shape F2 = FF.FindFromIndex(j); TopExp_Explorer aExpW1(F1,TopAbs_WIRE); @@ -1313,21 +1673,21 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, TopExp_Explorer aExpW2(F2,TopAbs_WIRE); TopoDS_Wire aWire2 = TopoDS::Wire(aExpW2.Current()); // make pipe using aWire1 and aWire2 - if( !aWire1.IsNull() && !aWire2.IsNull() ) { + if (!aWire1.IsNull() && !aWire2.IsNull()) { BRepOffsetAPI_MakePipeShell aBuilder(WPath); aBuilder.Add(aWire1, TopoDS::Vertex(VLocs(i)), aWithContact, aWithCorrect); aBuilder.Add(aWire2, TopoDS::Vertex(VLocs(i+1)), aWithContact, aWithCorrect); - if(!aBuilder.IsReady()) { - if(aCI) delete aCI; + if (!aBuilder.IsReady()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); } aBuilder.Build(); TopoDS_Shape aShape = aBuilder.Shape(); TopoDS_Shell aShell; B.MakeShell(aShell); - for ( anExp.Init( aShape, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShape, TopAbs_FACE); anExp.More(); anExp.Next()) { B.Add(aShell,anExp.Current()); } @@ -1339,20 +1699,20 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, aSewing->SetFaceMode(Standard_True); aSewing->SetFloatingEdgesMode(Standard_False); aSewing->SetNonManifoldMode(Standard_False); - for ( anExp.Init( aShell, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShell, TopAbs_FACE); anExp.More(); anExp.Next()) { aSewing->Add(anExp.Current()); } aSewing->Perform(); const TopoDS_Shape aSewShape = aSewing->SewedShape(); - if( aSewShape.ShapeType() == TopAbs_SHELL ) { + if (aSewShape.ShapeType() == TopAbs_SHELL) { aShell = TopoDS::Shell(aSewShape); GProp_GProps aSystem; BRepGProp::VolumeProperties(aShell, aSystem); - if(aSystem.Mass()<0) { + if (aSystem.Mass()<0) { //cout<<"aSewShape is reversed"<Length(), nbv = (VObjs.IsNull() ? 0 :VObjs->Length()); - if( nbv != nbBases ) { - if(aCI) delete aCI; + if (nbv != nbBases) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Number of shapes for recognition is invalid"); } TopTools_SequenceOfShape SecVs,Bases; - for(i=1; i<=nbBases; i++) { + for (i=1; i<=nbBases; i++) { // vertex Handle(Standard_Transient) anItem = VObjs->Value(i); - if(anItem.IsNull()) + if (anItem.IsNull()) continue; Handle(GEOM_Function) aRef = Handle(GEOM_Function)::DownCast(anItem); TopoDS_Shape V = aRef->GetValue(); - if(V.IsNull() || V.ShapeType() != TopAbs_VERTEX) + if (V.IsNull() || V.ShapeType() != TopAbs_VERTEX) continue; SecVs.Append(V); // section anItem = aBasesObjs->Value(i); - if(anItem.IsNull()) + if (anItem.IsNull()) continue; aRef = Handle(GEOM_Function)::DownCast(anItem); TopoDS_Shape aSh = aRef->GetValue(); - if(aSh.IsNull()) + if (aSh.IsNull()) continue; Bases.Append(aSh); } nbv = SecVs.Length(); nbBases = Bases.Length(); - if( nbv != nbBases ) { - if(aCI) delete aCI; + if (nbv != nbBases) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("One of shapes for recognition is not a vertex"); } @@ -1436,24 +1796,24 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) TopoDS_Shape aShBase2 = Bases.Value(i+1); TopExp_Explorer anExp; Standard_Integer nbf1 = 0; - for ( anExp.Init( aShBase1, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShBase1, TopAbs_FACE); anExp.More(); anExp.Next()) { nbf1++; } Standard_Integer nbf2 = 0; - for ( anExp.Init( aShBase2, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShBase2, TopAbs_FACE); anExp.More(); anExp.Next()) { nbf2++; } //cout<<"nbf1="<IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + if (S1->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { Handle(Geom_RectangularTrimmedSurface) RTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(S1); S1 = RTS->BasisSurface(); } Handle(Geom_Plane) Pln1 = Handle(Geom_Plane)::DownCast(S1); - if( Pln1.IsNull() ) { - if(aCI) delete aCI; + if (Pln1.IsNull()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Surface from face is not plane"); } gp_Vec aDir1(Pln1->Axis().Direction()); Handle(Geom_Surface) S2 = BRep_Tool::Surface(TopoDS::Face(F2)); - if(S2->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + if (S2->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { Handle(Geom_RectangularTrimmedSurface) RTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(S2); S2 = RTS->BasisSurface(); } Handle(Geom_Plane) Pln2 = Handle(Geom_Plane)::DownCast(S2); - if( Pln2.IsNull() ) { - if(aCI) delete aCI; + if (Pln2.IsNull()) { + if (aCI) delete aCI; Standard_ConstructionError::Raise("Surface from face is not plane"); } gp_Vec aDir2(Pln2->Axis().Direction()); @@ -1532,21 +1892,21 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(SecVs(i))); gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(SecVs(i+1))); gp_Vec aDir(P1,P2); - if(fabs(aDir.Angle(aDir1))>PI/2.) + if (fabs(aDir.Angle(aDir1))>PI/2.) aDir1.Reverse(); - if(fabs(aDir.Angle(aDir2))>PI/2.) + if (fabs(aDir.Angle(aDir2))>PI/2.) aDir2.Reverse(); TopExp_Explorer anExpE(F1,TopAbs_EDGE); TopTools_SequenceOfShape aNewFs; //int nbee=0; - for(; anExpE.More(); anExpE.Next()) { + for (; anExpE.More(); anExpE.Next()) { TopoDS_Edge E1 = TopoDS::Edge(anExpE.Current()); //nbee++; - if(!FF.Contains(E1)) + if (!FF.Contains(E1)) MESSAGE ("map FF not contains key E1"); - if(VPE.Contains(E1)) { + if (VPE.Contains(E1)) { aNewFs.Append(VPE.FindFromKey(E1)); #ifdef _DEBUG_ MESSAGE (" using existed face"); @@ -1557,14 +1917,14 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) TopoDS_Edge E3 = TopoDS::Edge(FF.FindFromKey(E1)); TopoDS_Vertex V1 = sae.FirstVertex(E1); TopoDS_Vertex V2 = sae.LastVertex(E1); - if(!FF.Contains(V1)) + if (!FF.Contains(V1)) MESSAGE ("map FF not contains key V1"); - if(!FF.Contains(V2)) + if (!FF.Contains(V2)) MESSAGE ("map FF not contains key V2"); TopoDS_Vertex V3 = TopoDS::Vertex(FF.FindFromKey(V2)); TopoDS_Vertex V4 = TopoDS::Vertex(FF.FindFromKey(V1)); TopoDS_Vertex Vtmp = sae.FirstVertex(E3); - if(Vtmp.IsSame(V4)) + if (Vtmp.IsSame(V4)) E3.Reverse(); gp_Pnt P1 = BRep_Tool::Pnt(V1); gp_Pnt P2 = BRep_Tool::Pnt(V2); @@ -1573,7 +1933,7 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) // make E2 TopoDS_Edge E2; Handle(Geom_BSplineCurve) C2; - if(VPE.Contains(V2)) { + if (VPE.Contains(V2)) { E2 = TopoDS::Edge(VPE.FindFromKey(V2)); double fp,lp; C2 = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve(E2,fp,lp)); @@ -1594,7 +1954,7 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) // make E4 TopoDS_Edge E4; Handle(Geom_BSplineCurve) C4; - if(VPE.Contains(V1)) { + if (VPE.Contains(V1)) { E4 = TopoDS::Edge(VPE.FindFromKey(V1)); double fp,lp; C4 = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve(E4,fp,lp)); @@ -1627,20 +1987,20 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) double fp,lp; Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1,fp,lp); //bool IsConicC1 = false; - //if( C1->IsKind(STANDARD_TYPE(Geom_Conic)) ) { + //if (C1->IsKind(STANDARD_TYPE(Geom_Conic))) { // IsConicC1 = true; // cout<<"C1 - Geom_Conic"<IsKind(STANDARD_TYPE(Geom_Line)) || C1->IsKind(STANDARD_TYPE(Geom_Conic)) ) { + if (C1->IsKind(STANDARD_TYPE(Geom_Line)) || C1->IsKind(STANDARD_TYPE(Geom_Conic))) { C1 = new Geom_TrimmedCurve(C1,fp,lp); } - //if(IsConicC1) { + //if (IsConicC1) { // double tol = BRep_Tool::Tolerance(E1); // GeomConvert_ApproxCurve ApxC1(C1,tol,GeomAbs_C1,10,5); // C1 = ApxC1.Curve(); //} Handle(Geom_Curve) C3 = BRep_Tool::Curve(E3,fp,lp); - if( C3->IsKind(STANDARD_TYPE(Geom_Line)) || C3->IsKind(STANDARD_TYPE(Geom_Conic)) ) { + if (C3->IsKind(STANDARD_TYPE(Geom_Line)) || C3->IsKind(STANDARD_TYPE(Geom_Conic))) { C3 = new Geom_TrimmedCurve(C3,fp,lp); } //filebuf fic; @@ -1648,23 +2008,23 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) //os.precision(15); Handle(Geom_BSplineCurve) CE1 = GeomConvert::CurveToBSplineCurve(C1,Convert_RationalC1); - if(CE1->Degree()<3) + if (CE1->Degree()<3) CE1->IncreaseDegree(3); Handle(Geom_BSplineCurve) CE2 = GeomConvert::CurveToBSplineCurve(C2,Convert_RationalC1); - if(CE2->Degree()<3) + if (CE2->Degree()<3) CE2->IncreaseDegree(3); Handle(Geom_BSplineCurve) CE3 = GeomConvert::CurveToBSplineCurve(C3,Convert_RationalC1); - if(CE3->Degree()<3) + if (CE3->Degree()<3) CE3->IncreaseDegree(3); Handle(Geom_BSplineCurve) CE4 = GeomConvert::CurveToBSplineCurve(C4,Convert_RationalC1); - if(CE4->Degree()<3) + if (CE4->Degree()<3) CE4->IncreaseDegree(3); //cout<<"CE1->Degree()="<Degree()<<" CE2->Degree()="<Degree() // <<" CE3->Degree()="<Degree()<<" CE4->Degree()="<Degree()<D0(par,P); @@ -1711,7 +2071,7 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) } Points.SetValue(1,NbP,P2); // get points from C3 - if(P4.Distance(P1C3)<1.e-6) { + if (P4.Distance(P1C3)<1.e-6) { fp = fp2; lp = lp2; } @@ -1722,7 +2082,7 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) step = (lp-fp)/(NbP-1); Points.SetValue(NbP,1,P4); par = fp; - for(n1=2; n1D0(par,P); @@ -1730,7 +2090,7 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) } Points.SetValue(NbP,NbP,P3); // create isolines and get points from them - for(n1=1; n1<=NbP; n1++) { + for (n1=1; n1<=NbP; n1++) { gp_Pnt PI1 = Points.Value(1,n1); gp_Pnt PI2 = Points.Value(NbP,n1); Handle(TColgp_HArray1OfPnt) HAP = new TColgp_HArray1OfPnt(1,2); @@ -1746,7 +2106,7 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) par = fp; TopoDS_Compound VComp; B.MakeCompound(VComp); - for(n2=2; n2D0(par,P); @@ -1772,7 +2132,7 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) // make shell TopoDS_Shell aShell; B.MakeShell(aShell); - for(int nf=1; nf<=aNewFs.Length(); nf++) { + for (int nf=1; nf<=aNewFs.Length(); nf++) { B.Add(aShell,aNewFs(nf)); } B.Add(aShell,F1); @@ -1784,22 +2144,22 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) aSewing->SetFaceMode(Standard_True); aSewing->SetFloatingEdgesMode(Standard_False); aSewing->SetNonManifoldMode(Standard_False); - for ( anExp.Init( aShell, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + for (anExp.Init(aShell, TopAbs_FACE); anExp.More(); anExp.Next()) { aSewing->Add(anExp.Current()); } aSewing->Perform(); MESSAGE (" shell for face "<SewedShape(); //BRepTools::Write(aSewShape,"/dn02/users_Linux/skl/work/Bugs/14857/sew.brep"); - if( aSewShape.ShapeType() == TopAbs_SHELL ) { + if (aSewShape.ShapeType() == TopAbs_SHELL) { aShell = TopoDS::Shell(aSewShape); GProp_GProps aSystem; BRepGProp::VolumeProperties(aShell, aSystem); - if(aSystem.Mass()<0) { + if (aSystem.Mass()<0) { //cout<<"aSewShape is reversed"<GetValue(); if (aShapeBase.IsNull()) { - if(aCIBN) delete aCIBN; + if (aCIBN) delete aCIBN; Standard_NullObject::Raise("MakePipe aborted : null base argument"); } TopoDS_Shape aProf; - if( aShapeBase.ShapeType() == TopAbs_VERTEX ) { + if (aShapeBase.ShapeType() == TopAbs_VERTEX) { aProf = aShapeBase; } - else if( aShapeBase.ShapeType() == TopAbs_EDGE) { + else if (aShapeBase.ShapeType() == TopAbs_EDGE) { aProf = BRepBuilderAPI_MakeWire(TopoDS::Edge(aShapeBase)).Shape(); } - else if( aShapeBase.ShapeType() == TopAbs_WIRE) { + else if (aShapeBase.ShapeType() == TopAbs_WIRE) { aProf = aShapeBase; } - else if( aShapeBase.ShapeType() == TopAbs_FACE) { + else if (aShapeBase.ShapeType() == TopAbs_FACE) { TopExp_Explorer wexp(aShapeBase,TopAbs_WIRE); aProf = wexp.Current(); } @@ -1885,7 +2245,7 @@ static TopoDS_Shape CreatePipeBiNormalAlongVector(const TopoDS_Wire& aWirePath, PipeBuilder.Add(aProf); if (aShapeVec.IsNull()) { - if(aCIBN) delete aCIBN; + if (aCIBN) delete aCIBN; Standard_NullObject::Raise ("MakePipe aborted : null vector argument"); } @@ -1902,7 +2262,7 @@ static TopoDS_Shape CreatePipeBiNormalAlongVector(const TopoDS_Wire& aWirePath, gp_Dir BiNormal(aVec); PipeBuilder.SetMode(BiNormal); PipeBuilder.Build(); - if( aShapeBase.ShapeType() == TopAbs_FACE) { + if (aShapeBase.ShapeType() == TopAbs_FACE) { PipeBuilder.MakeSolid(); } @@ -1920,44 +2280,44 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); GEOMImpl_IPipe* aCI= 0; Standard_Integer aType = aFunction->GetType(); - if(aType == PIPE_BASE_PATH) + if (aType == PIPE_BASE_PATH) aCI = new GEOMImpl_IPipe(aFunction); - else if(aType == PIPE_DIFFERENT_SECTIONS) + else if (aType == PIPE_DIFFERENT_SECTIONS) aCI = new GEOMImpl_IPipeDiffSect(aFunction); - else if(aType == PIPE_SHELL_SECTIONS) + else if (aType == PIPE_SHELL_SECTIONS) aCI = new GEOMImpl_IPipeShellSect(aFunction); - else if(aType == PIPE_SHELLS_WITHOUT_PATH) + else if (aType == PIPE_SHELLS_WITHOUT_PATH) aCI = new GEOMImpl_IPipeShellSect(aFunction); - else if(aType == PIPE_BI_NORMAL_ALONG_VECTOR) + else if (aType == PIPE_BI_NORMAL_ALONG_VECTOR) aCI = new GEOMImpl_IPipeBiNormal(aFunction); else return 0; TopoDS_Wire aWirePath; - if(aType != PIPE_SHELLS_WITHOUT_PATH) { + if (aType != PIPE_SHELLS_WITHOUT_PATH) { // working with path Handle(GEOM_Function) aRefPath = aCI->GetPath(); TopoDS_Shape aShapePath = aRefPath->GetValue(); if (aShapePath.IsNull()) { MESSAGE ("Driver : path is null"); - if(aCI) delete aCI; + if (aCI) delete aCI; Standard_NullObject::Raise("MakePipe aborted : null path argument"); } // Get path contour bool isOk = false; - if ( aShapePath.ShapeType() == TopAbs_COMPOUND ) { + if (aShapePath.ShapeType() == TopAbs_COMPOUND) { TopTools_SequenceOfShape anEdges; TopExp_Explorer anExp; BRep_Builder B; TopoDS_Wire W; B.MakeWire(W); - for ( anExp.Init( aShapePath, TopAbs_EDGE ); anExp.More(); anExp.Next() ) { - B.Add( W, anExp.Current() ); + for (anExp.Init(aShapePath, TopAbs_EDGE); anExp.More(); anExp.Next()) { + B.Add(W, anExp.Current()); isOk = true; } - if ( isOk ) + if (isOk) aWirePath = W; } else if (aShapePath.ShapeType() == TopAbs_WIRE) { @@ -1971,26 +2331,25 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const isOk = true; } } - if ( !isOk ) { - if(aCI) delete aCI; + if (!isOk) { + if (aCI) delete aCI; Standard_TypeMismatch::Raise("MakePipe aborted : path shape is neither a wire nor an edge"); } } TopoDS_Shape aShape; - if (aType == PIPE_BASE_PATH) - { + if (aType == PIPE_BASE_PATH) { Handle(GEOM_Function) aRefBase = aCI->GetBase(); TopoDS_Shape aShapeBase; // Make copy to prevent modifying of base object 0020766 : EDF 1320 BRepBuilderAPI_Copy Copy(aRefBase->GetValue()); - if( Copy.IsDone() ) + if (Copy.IsDone()) aShapeBase = Copy.Shape(); if (aShapeBase.IsNull()) { - if(aCI) delete aCI; + if (aCI) delete aCI; Standard_NullObject::Raise("MakePipe aborted : null base argument"); } @@ -2001,374 +2360,47 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const //building pipe with different sections else if (aType == PIPE_DIFFERENT_SECTIONS) { GEOMImpl_IPipeDiffSect* aCIDS = (GEOMImpl_IPipeDiffSect*)aCI; - //GEOMImpl_IPipeDiffSect* aCIDS = static_cast(aCI); - //BRepOffsetAPI_MakePipeShell aBuilder(aWirePath); Handle(TColStd_HSequenceOfTransient) aBasesObjs = aCIDS->GetBases (); Handle(TColStd_HSequenceOfTransient) aLocObjs = aCIDS->GetLocations (); Standard_Boolean aWithContact = (aCIDS->GetWithContactMode()); Standard_Boolean aWithCorrect = (aCIDS->GetWithCorrectionMode()); + if (aCI) { + delete aCI; + aCI = 0; + } - Standard_Integer i =1, nbBases = aBasesObjs->Length(), - nbLocs = (aLocObjs.IsNull() ? 0 :aLocObjs->Length()); + Standard_Integer nbBases = aBasesObjs->Length(); + Standard_Integer nbLocs = (aLocObjs.IsNull() ? 0 : aLocObjs->Length()); - if(nbLocs && nbLocs != nbBases) { - if(aCI) delete aCI; - Standard_ConstructionError::Raise("Number of sections is not equal to number of locations "); - } - TopTools_SequenceOfShape aSeqBases; - TopTools_SequenceOfShape aSeqLocs; - TopTools_SequenceOfShape aSeqFaces; - for (; i <= nbBases; i++) { + Handle(TopTools_HSequenceOfShape) aHSeqBases = new TopTools_HSequenceOfShape; + Handle(TopTools_HSequenceOfShape) aHSeqLocs = new TopTools_HSequenceOfShape; + Standard_Integer i; + + for (i = 1; i <= nbBases; i++) { Handle(Standard_Transient) anItem = aBasesObjs->Value(i); - if(anItem.IsNull()) + if (anItem.IsNull()) continue; Handle(GEOM_Function) aRefBase = Handle(GEOM_Function)::DownCast(anItem); - if(aRefBase.IsNull()) + if (aRefBase.IsNull()) continue; - - if(aRefBase->GetValue().IsNull()) + if (aRefBase->GetValue().IsNull()) continue; - // Make copy to prevent modifying of base object 0020766 : EDF 1320 - TopoDS_Shape aShapeBase; - BRepBuilderAPI_Copy Copy(aRefBase->GetValue()); - if( Copy.IsDone() ) - aShapeBase = Copy.Shape(); - - TopAbs_ShapeEnum aTypeBase = aShapeBase.ShapeType(); - - //if for section was specified face with a few wires then a few - // pipes were build and make solid - Standard_Boolean NeedCreateSolid = Standard_False; - if(aTypeBase == TopAbs_SHELL) { - // create wire as boundary contour if shell is no closed - // get free boundary shapes - ShapeAnalysis_FreeBounds anAnalizer( aShapeBase ); - TopoDS_Compound aClosed = anAnalizer.GetClosedWires(); - TopExp_Explorer anExp; - TopoDS_Shape aWire; - Standard_Integer NbWires = 0; - for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() ) { - NbWires++; - aWire = anExp.Current(); - } - if(NbWires!=1) { - // bad case - if(aCI) delete aCI; - Standard_ConstructionError::Raise("Bad shell is used as section "); - } - NeedCreateSolid = Standard_True; - aSeqFaces.Append(aShapeBase); - aSeqBases.Append(aWire); - } - else if(aTypeBase == TopAbs_FACE) { - NeedCreateSolid = Standard_True; - //for case one path should be used other type function - aSeqFaces.Append(aShapeBase); - TopExp_Explorer aExpW(aShapeBase,TopAbs_WIRE); - for (; aExpW.More(); aExpW.Next()) - { - TopoDS_Shape aWireProf = aExpW.Current(); - aSeqBases.Append(aWireProf); - } - } - else if(aTypeBase == TopAbs_WIRE || aTypeBase == TopAbs_VERTEX) { - aSeqBases.Append(aShapeBase); - } - else if(aTypeBase == TopAbs_EDGE) { - TopoDS_Edge anEdge = TopoDS::Edge(aShapeBase); - TopoDS_Shape aWireProf = BRepBuilderAPI_MakeWire(anEdge); - aSeqBases.Append(aWireProf); - } - if(nbLocs) { - Handle(Standard_Transient) anItemLoc = aLocObjs->Value(i); - if(anItemLoc.IsNull()) - continue; - Handle(GEOM_Function) aRefLoc = Handle(GEOM_Function)::DownCast(anItemLoc); - TopoDS_Shape aShapeLoc = aRefLoc->GetValue(); - if(aShapeLoc.IsNull() || aShapeLoc.ShapeType() != TopAbs_VERTEX) - continue; - aSeqLocs.Append(aShapeLoc); - } - } - - nbLocs = aSeqLocs.Length(); - - // skl 02.05.2007 - TopTools_SequenceOfShape Edges; - if(nbLocs>0) { - // we have to check that each location shape is a vertex from - // path and update aSeqLocs if it is needed (and possible) - TColgp_SequenceOfPnt PLocs; - for(i=1; i<=nbLocs; i++) { - TopoDS_Vertex V = TopoDS::Vertex(aSeqLocs.Value(i)); - PLocs.Append(BRep_Tool::Pnt(V)); - } - //TopTools_SequenceOfShape Edges; - TopExp_Explorer anExp; - for ( anExp.Init( aWirePath, TopAbs_EDGE ); anExp.More(); anExp.Next() ) { - Edges.Append(anExp.Current()); - } - int nbEdges = Edges.Length(); - ShapeAnalysis_Edge sae; - TopoDS_Edge edge = TopoDS::Edge(Edges.First()); - double tol = BRep_Tool::Tolerance(edge); - TopoDS_Vertex VF = sae.FirstVertex(edge); - gp_Pnt PF = BRep_Tool::Pnt(VF); - //cout<<"PF("< tol ) { - if(aCI) delete aCI; - Standard_ConstructionError::Raise - ("First location shapes is not coincided with first vertex of aWirePath"); - } - aSeqLocs.ChangeValue(1) = VF; - edge = TopoDS::Edge(Edges.Last()); - tol = BRep_Tool::Tolerance(edge); - TopoDS_Vertex VL = sae.LastVertex(edge); - gp_Pnt PL = BRep_Tool::Pnt(VL); - if( PL.Distance(PLocs.Last()) > tol ) { - if(aCI) delete aCI; - Standard_ConstructionError::Raise - ("Last location shapes is not coincided with last vertex of aWirePath"); - } - aSeqLocs.ChangeValue(nbLocs) = VL; - int jcurr = 2; - for(i=1; i<=Edges.Length() && jcurr0 && - PLocs.Value(jcurr).Distance(PPC.Point(1)) < tol ) { - double param = PPC.Parameter(1); - gp_Pnt PC1; - C->D0(param,PC1); - // split current edge - Handle(Geom_TrimmedCurve) tc1 = new Geom_TrimmedCurve(C,fp,param); - Handle(Geom_TrimmedCurve) tc2 = new Geom_TrimmedCurve(C,param,lp); - TopoDS_Edge E1,E2; - BRep_Builder B; - gp_Pnt Pfp; - C->D0(fp,Pfp); - if(Pfp.Distance(P1) we have to update WirePath - BRep_Builder B; - TopoDS_Wire W; - B.MakeWire(W); - for(i=1; i<=Edges.Length(); i++) { - B.Add(W,TopoDS::Edge(Edges.Value(i))); - } - aWirePath = W; - } - } - - // check curvature of wire for condition that - // max summary angle between directions along - // wire path must be < 4*PI. If not - split wire - // and seguences of shapes, perform pipe for each - // and make sewing after that - double fp,lp; - Handle(Geom_Curve) C = BRep_Tool::Curve(TopoDS::Edge(Edges.Value(1)),fp,lp); - gp_Pnt P1,P2; - gp_Vec Vec1,Vec2; - C->D1(fp,P1,Vec1); - C->D1(lp,P2,Vec2); - double SumAng = fabs(Vec1.Angle(Vec2)); - Vec1 = Vec2; - P1 = P2; - TColStd_SequenceOfInteger SplitEdgeNums,SplitLocNums; - int LastLoc = 1; - //cout<<"Edges.Length()="<D1(lp,P2,Vec2); - double ang = fabs(Vec1.Angle(Vec2)); - SumAng += ang; - if(SumAng>4*PI) { - SumAng = ang; - SplitEdgeNums.Append(i-1); - int j; - for(j=LastLoc+1; j<=aSeqLocs.Length(); j++) { - TopoDS_Vertex aVert = TopoDS::Vertex(aSeqLocs.Value(j)); - gp_Pnt P = BRep_Tool::Pnt(aVert); - if( P1.Distance(P) < tol ) { - SplitLocNums.Append(j); - LastLoc = j; - break; - } - } - } - Vec1 = Vec2; - P1 = P2; + aHSeqBases->Append(aRefBase->GetValue()); } + for (i = 1; i <= nbLocs; i++) { + Handle(Standard_Transient) anItemLoc = aLocObjs->Value(i); + if (anItemLoc.IsNull()) + continue; + Handle(GEOM_Function) aRefLoc = Handle(GEOM_Function)::DownCast(anItemLoc); + TopoDS_Shape aShapeLoc = aRefLoc->GetValue(); + if (aShapeLoc.IsNull() || aShapeLoc.ShapeType() != TopAbs_VERTEX) + continue; - //cout<<"SplitEdgeNums.Length()="<SetTolerance(Precision::Confusion()); - aSewing->SetFaceMode(Standard_True); - aSewing->SetFloatingEdgesMode(Standard_False); - aSewing->SetNonManifoldMode(Standard_False); - for(i=1; i<=aSeqRes.Length(); i++) { - aSewing->Add(aSeqRes.Value(i)); - } - aSewing->Perform(); - aShape = aSewing->SewedShape(); + aHSeqLocs->Append(aShapeLoc); } - else { - // old implementation without splitting - BRepOffsetAPI_MakePipeShell aBuilder(aWirePath); - Standard_Integer nbShapes = aSeqBases.Length(); - Standard_Integer step = nbShapes/nbBases; - - if (nbShapes < nbBases || fmod((double)nbShapes, (double)nbBases)) { - if(aCI) delete aCI; - Standard_ConstructionError::Raise("Invalid sections were specified for building pipe"); - } - Standard_Integer ind =0; - for (i = 1; i <= nbShapes && ind < nbShapes; i++) { //i+nbBases <= nbShapes - TopTools_SequenceOfShape usedBases; - Standard_Integer j = 1; - for (; j <= nbBases; j++) { - ind = i + (j-1)*step; - TopoDS_Shape aWireProf = aSeqBases.Value(ind); - usedBases.Append(aWireProf); - if(nbLocs) { - TopoDS_Shape aShapeLoc = aSeqLocs.Value(j); - TopoDS_Vertex aVert = TopoDS::Vertex(aShapeLoc); - aBuilder.Add(aWireProf,aVert,aWithContact,aWithCorrect); - } - else - aBuilder.Add(aWireProf,aWithContact,aWithCorrect); - } - if(!aBuilder.IsReady()) { - if(aCI) delete aCI; - Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); - } - aBuilder.Build(); - aShape = aBuilder.Shape(); - aSeqFaces.Append(aShape); - for( j = 1; j <=usedBases.Length(); j++) - aBuilder.Delete(usedBases.Value(j)); - } - - //for case if section is face - if(aSeqFaces.Length() >1) { - BRep_Builder aB; - TopoDS_Compound aComp; - aB.MakeCompound(aComp); - for( i = 1; i <= aSeqFaces.Length(); i++) - aB.Add(aComp,aSeqFaces.Value(i)); - aShape = aComp; - } - } + aShape = CreatePipeWithDifferentSections(aWirePath, aHSeqBases, aHSeqLocs, aWithContact, aWithCorrect); } //building pipe with shell sections @@ -2427,11 +2459,11 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_PipeDriver_Type_() { static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + if (aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); - if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + if (aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PipeDriver",