X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FGEOMImpl%2FGEOMImpl_PipeDriver.cxx;h=9fa0d3beb2046694720d83a1e59c31c15aa535cf;hb=25a3dc91508bb59688142bc616b10facc61dfc3d;hp=5bb530e396aa9b8d828f64b007789295132d32e8;hpb=693e5f65fe0f4868fe2e0f2923aef6a3afb20d67;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index 5bb530e39..9fa0d3beb 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 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 @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -209,17 +210,13 @@ static bool FillForOtherEdges(const TopoDS_Shape& F1, const TopoDS_Shape& V1, TopTools_IndexedDataMapOfShapeShape& FF) { - //cout<<"FillForOtherEdges"<IsKind(STANDARD_TYPE(Geom_Plane))) { + nbPlanar++; + } + else if (aS->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + Handle(Geom_RectangularTrimmedSurface) aTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(aS); + if (aTS->BasisSurface()->IsKind(STANDARD_TYPE(Geom_Plane))) { + nbPlanar++; + } + } + aS = BRep_Tool::Surface(TopoDS::Face(aSh2)); + if (aS->IsKind(STANDARD_TYPE(Geom_Plane))) { + nbPlanar++; + } + else if (aS->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + Handle(Geom_RectangularTrimmedSurface) aTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(aS); + if (aTS->BasisSurface()->IsKind(STANDARD_TYPE(Geom_Plane))) { + nbPlanar++; + } + } + } + if (nbPlanar < 2) { + TopoDS_Shape aPipe = aBuilder.Shape(); + // make sewing for result + Handle(BRepBuilderAPI_Sewing) aSewing = new BRepBuilderAPI_Sewing; + Standard_Real aTol = Precision::Confusion(); + aSewing->SetTolerance(aTol); + aSewing->SetFaceMode(Standard_True); + aSewing->SetFloatingEdgesMode(Standard_False); + aSewing->SetNonManifoldMode(Standard_False); + TopExp_Explorer anExp; + for (anExp.Init(aPipe, TopAbs_FACE); anExp.More(); anExp.Next()) { + aSewing->Add(anExp.Current()); + } + aSewing->Add(aSh1); + aSewing->Add(aSh2); + aSewing->Perform(); + aShape = aSewing->SewedShape(); + if (aShape.ShapeType() == TopAbs_SHELL) { + // Build a solid. + BRepBuilderAPI_MakeSolid aMkSolid; + aMkSolid.Add(TopoDS::Shell(aShape)); + if (!aMkSolid.IsDone()) { + isDone = Standard_False; + } + else { + TopoDS_Solid aSolid = aMkSolid.Solid(); + BRepClass3d_SolidClassifier aSC(aSolid); + aSC.PerformInfinitePoint(Precision::Confusion()); + if (aSC.State() == TopAbs_IN) { + aShape = aSolid.Reversed(); + } + else { + aShape = aSolid; + } + } + } + else { + isDone = Standard_False; + } + } + else { + isDone = Standard_False; + } + if (!isDone) { + isDone = aBuilder.MakeSolid(); + if (isDone) { + aShape = aBuilder.Shape(); + } + } + return isDone; +} + //======================================================================= //function : CreatePipeWithDifferentSections //purpose : @@ -845,7 +898,6 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections 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"); @@ -919,7 +971,7 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections } } if (nbEdges we have to update WirePath + // one of edges was split => we have to update WirePath BRep_Builder B; TopoDS_Wire W; B.MakeWire(W); @@ -981,7 +1033,6 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections P1 = P2; } int LastLoc = 1; - //cout<<"Edges.Length()="<IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) aTc = Handle(Geom_TrimmedCurve)::DownCast(aC); + aC = aTc->BasisCurve(); + } + if (!aC->IsKind(STANDARD_TYPE(Geom_Line))) + doThruSections = false; + } + } + } + + if (doThruSections) { + BRepOffsetAPI_ThruSections aBuilder (NeedCreateSolid, Standard_True, Precision::Confusion()*10.0); + aBuilder.CheckCompatibility(Standard_False); + + for (int ibase = 1; ibase <= nbBases; ibase++) { + TopoDS_Shape aBase = aSeqBases.Value(ibase); + aBuilder.AddWire(TopoDS::Wire(aBase)); + } + + aBuilder.Build(); + aShape = aBuilder.Shape(); + } + else { // old implementation without splitting BRepOffsetAPI_MakePipeShell aBuilder(aWirePath); GeomFill_Trihedron theBestMode = EvaluateBestSweepMode(aWirePath); @@ -1269,14 +1358,20 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections Standard_Boolean isDone = BuildPipeShell(aBuilder); - if (isDone && NeedCreateSolid) { - isDone = aBuilder.MakeSolid(); + if (isDone) { + if (NeedCreateSolid) { + TopoDS_Shape aSh1 = aSeqFaces.Value(1); + TopoDS_Shape aSh2 = aSeqFaces.Value(aSeqFaces.Length()); + isDone = makeSolid(aBuilder, aSh1, aSh2, aShape); + } + else { + aShape = aBuilder.Shape(); + } } if (!isDone) { Standard_ConstructionError::Raise("Pipe construction failure"); } - aShape = aBuilder.Shape(); if (isCreateGroups) { // Make groups. @@ -1302,6 +1397,7 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections for (j = 1; j <=usedBases.Length(); j++) aBuilder.Delete(usedBases.Value(j)); } + } } return aShape; @@ -1407,7 +1503,6 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, 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 @@ -1739,7 +1834,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces2; TopExp::MapShapesAndAncestors(aShBase2, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces2); - // constuct map face->face + // construct map face->face TopTools_IndexedDataMapOfShapeShape FF; TopoDS_Shape FS1,FS2; if (nbSubBases==0) { @@ -1824,7 +1919,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, bool stat = FillForOtherEdges(FS1,E1,V11,FF); if (!stat) { if (aCI) delete aCI; - Standard_ConstructionError::Raise("FindForOtherEdges: Can not mapping other egdes"); + Standard_ConstructionError::Raise("FindForOtherEdges: Can not map other edges"); } } @@ -1966,8 +2061,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, aShell = TopoDS::Shell(aSewShape); GProp_GProps aSystem; BRepGProp::VolumeProperties(aShell, aSystem); - if (aSystem.Mass()<0) { - //cout<<"aSewShape is reversed"<face (and sub-shapes) + // construct map face->face (and sub-shapes) TopTools_IndexedDataMapOfShapeShape FF; //TopoDS_Shape FS1 = SecFs.Value(i), FS2 = SecFs.Value(i+1); TopoDS_Shape FS1, FS2; @@ -2163,7 +2255,6 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) // auxiliary map vertex->edge for created pipe edges TopTools_IndexedDataMapOfShapeShape VPE; ShapeAnalysis_Edge sae; - //cout<<"FF.Extent()="<IsKind(STANDARD_TYPE(Geom_Conic))) { - // IsConicC1 = true; - // cout<<"C1 - Geom_Conic"<IsKind(STANDARD_TYPE(Geom_Line)) || C1->IsKind(STANDARD_TYPE(Geom_Conic))) { C1 = new Geom_TrimmedCurve(C1,fp,lp); } - //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))) { C3 = new Geom_TrimmedCurve(C3,fp,lp); } - //filebuf fic; - //ostream os(&fic); - //os.precision(15); Handle(Geom_BSplineCurve) CE1 = GeomConvert::CurveToBSplineCurve(C1,Convert_RationalC1); if (CE1->Degree()<3) @@ -2475,8 +2553,7 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) aShell = TopoDS::Shell(aSewShape); GProp_GProps aSystem; BRepGProp::VolumeProperties(aShell, aSystem); - if (aSystem.Mass()<0) { - //cout<<"aSewShape is reversed"<