From aba38d6df2dca6546afbb73047c75296c388d3ea Mon Sep 17 00:00:00 2001 From: skl Date: Wed, 19 Sep 2007 09:36:26 +0000 Subject: [PATCH] Integration of new pipe algorithm (MakePipeWithoutPath). --- idl/GEOM_Gen.idl | 11 +- idl/GEOM_Superv.idl | 3 + src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx | 149 +++ src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx | 4 + src/GEOMImpl/GEOMImpl_PipeDriver.cxx | 1004 ++++++++++++++++--- src/GEOMImpl/GEOMImpl_Types.hxx | 1 + src/GEOM_I/GEOM_I3DPrimOperations_i.cc | 56 +- src/GEOM_I/GEOM_I3DPrimOperations_i.hh | 3 + src/GEOM_I_Superv/GEOM_Superv_i.cc | 17 + src/GEOM_I_Superv/GEOM_Superv_i.hh | 3 + src/GEOM_SWIG/geompy.py | 45 + 11 files changed, 1179 insertions(+), 117 deletions(-) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 118971724..874ce239b 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -910,7 +910,16 @@ module GEOM in GEOM_Object thePath, in boolean theWithContact , in boolean theWithCorrection ); - + + /*! + * Create solids between given sections + * \param theSeqBases - list of sections (shell or face). + * \param theLocations - list of corresponding vertexes + * \return New GEOM_Object, containing the created solids. + */ + GEOM_Object MakePipeShellsWithoutPath (in ListOfGO theSeqBases, + in ListOfGO theLocations ); + }; /*! diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 4ad14db98..875946b9d 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -184,6 +184,9 @@ module GEOM in boolean theWithContact , in boolean theWithCorrection ); + GEOM_Object MakePipeShellsWithoutPath (in ListOfGO theSeqBases, + in ListOfGO theLocations ); + //-----------------------------------------------------------// // BooleanOperations // //-----------------------------------------------------------// diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index de70f1259..2571cae0b 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -1375,6 +1375,23 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections( pyDump<< "], ["; + for(i =1 ; i <= nbSubBases; i++) { + + Handle(Standard_Transient) anItem = theSubBases->Value(i); + if(anItem.IsNull()) + continue; + + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem); + if(!anObj.IsNull()) { + pyDump<< anObj; + if(i < nbBases) + pyDump<<", "; + } + + } + + pyDump<< "], ["; + for(i =1 ; i <= nbLocs; i++) { Handle(Standard_Transient) anItem = theLocations->Value(i); @@ -1396,3 +1413,135 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections( } + +//============================================================================= +/*! + * MakePipeShellsWithoutPath + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath( + const Handle(TColStd_HSequenceOfTransient)& theBases, + const Handle(TColStd_HSequenceOfTransient)& theLocations) +{ + Handle(GEOM_Object) anObj; + SetErrorCode(KO); + if(theBases.IsNull()) + return anObj; + + Standard_Integer nbBases = theBases->Length(); + + if (!nbBases) + return anObj; + + Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length()); + + //Add a new Pipe object + Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE); + + //Add a new Pipe function + + Handle(GEOM_Function) aFunction = + aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH); + if (aFunction.IsNull()) return anObj; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj; + + GEOMImpl_IPipeShellSect aCI (aFunction); + + Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient; + + Standard_Integer i =1; + for( ; i <= nbBases; i++) { + + Handle(Standard_Transient) anItem = theBases->Value(i); + if(anItem.IsNull()) + continue; + Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem); + if(aBase.IsNull()) + continue; + Handle(GEOM_Function) aRefBase = aBase->GetLastFunction(); + if(aRefBase.IsNull()) + continue; + + if(nbLocs) { + Handle(Standard_Transient) anItemLoc = theLocations->Value(i); + if(anItemLoc.IsNull()) + continue; + Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc); + if(aLoc.IsNull()) + continue; + Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction(); + if(aRefLoc.IsNull()) + continue; + aSeqLocs->Append(aRefLoc); + } + + aSeqBases->Append(aRefBase); + } + + if(!aSeqBases->Length()) + return anObj; + + aCI.SetBases(aSeqBases); + aCI.SetLocations(aSeqLocs); + + //Compute the Pipe value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Pipe with shell sections without path driver failed"); + return anObj; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return anObj; + } + + //Make a Python command + GEOM::TPythonDump pyDump(aFunction); + pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath(["; + + for(i =1 ; i <= nbBases; i++) { + + Handle(Standard_Transient) anItem = theBases->Value(i); + if(anItem.IsNull()) + continue; + + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem); + if(!anObj.IsNull()) { + pyDump<< anObj; + if(i < nbBases) + pyDump<<", "; + } + + } + + pyDump<< "], ["; + + for(i =1 ; i <= nbLocs; i++) { + + Handle(Standard_Transient) anItem = theLocations->Value(i); + if(anItem.IsNull()) + continue; + + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem); + if(!anObj.IsNull()) { + pyDump<< anObj; + if(i < nbLocs) + pyDump<<", "; + } + } + + pyDump<< "])"; + + SetErrorCode(OK); + return aPipeDS; + +} + diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index 5773f2f47..d3d7ba49c 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -94,6 +94,10 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { bool theWithContact, bool theWithCorrections); + Standard_EXPORT Handle(GEOM_Object) MakePipeShellsWithoutPath( + const Handle(TColStd_HSequenceOfTransient)& theBases, + const Handle(TColStd_HSequenceOfTransient)& theLocations); + }; #endif diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index 320debb03..eedc298ba 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -31,6 +31,8 @@ #include #include +#include +#include #include #include @@ -41,6 +43,7 @@ #include #include #include +#include #include #include @@ -59,9 +62,22 @@ #include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include #include @@ -72,6 +88,7 @@ #include "utilities.h" //#include "BRepTools.hxx" +//#include "GeomTools.hxx" //======================================================================= @@ -108,6 +125,12 @@ static bool FillForOtherEdges(const TopoDS_Shape& F1, // creating map of vertex edges for both faces TopTools_IndexedDataMapOfShapeListOfShape aMapVertEdge1; TopExp::MapShapesAndAncestors(F1, TopAbs_VERTEX, TopAbs_EDGE, aMapVertEdge1); + if(!FF.Contains(F1)) + cout<<" FillForOtherEdges: map FF not contains key F1"< tol ) { - if(aCI) delete aCI; - Standard_ConstructionError::Raise - ("First location shapes is not coincided with first vertex of aWirePath"); - } - VLocs.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"); - } - VLocs.ChangeValue(nbLocs) = VL; - int jcurr = 2; - TopTools_SequenceOfShape tmpEdges; - for(i=1; i<=Edges.Length() && jcurr0 && Num2>0 ) { TopoDS_Wire W; B.MakeWire(W); - for(j=1; j<=tmpEdges.Length(); j++) - B.Add(W,tmpEdges.Value(j)); - B.Add(W,E); + for(i=Num1; i<=Num2; i++) { + B.Add(W,Edges.Value(i)); + } Wires.Append(W); - VLocs.ChangeValue(jcurr) = V2; - jcurr++; - tmpEdges.Clear(); } else { - // find distance between E and aLocs(jcurr) - double fp,lp; - Handle(Geom_Curve) C = BRep_Tool::Curve(E,fp,lp); - GeomAPI_ProjectPointOnCurve PPC (PLocs.Value(jcurr),C); - if( PPC.NbPoints()>0 && - 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; - gp_Pnt Pfp; - C->D0(fp,Pfp); - if(Pfp.Distance(P1) tol ) { + if(aCI) delete aCI; + Standard_ConstructionError::Raise + ("First location shapes is not coincided with first vertex of aWirePath"); + } + VLocs.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"); + } + 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); + 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; + gp_Pnt Pfp; + C->D0(fp,Pfp); + if(Pfp.Distance(P1)GetBases(); + // vertex for recognition + Handle(TColStd_HSequenceOfTransient) VObjs = aCIDS->GetLocations(); + + Standard_Integer nbBases = aBasesObjs->Length(), + nbv = (VObjs.IsNull() ? 0 :VObjs->Length()); + + 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++) { + // vertex + Handle(Standard_Transient) anItem = VObjs->Value(i); + 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) + continue; + SecVs.Append(V); + // section + anItem = aBasesObjs->Value(i); + if(anItem.IsNull()) + continue; + aRef = Handle(GEOM_Function)::DownCast(anItem); + TopoDS_Shape aSh = aRef->GetValue(); + if(aSh.IsNull()) + continue; + Bases.Append(aSh); + } + nbv = SecVs.Length(); + nbBases = Bases.Length(); + if( nbv != nbBases ) { + if(aCI) delete aCI; + Standard_ConstructionError::Raise("One of shapes for recognition is not a vertex"); + } + + TopoDS_Compound aComp; + B.MakeCompound(aComp); + + for(i=1 ; iface (and subshapes) + TopTools_IndexedDataMapOfShapeShape FF; + //TopoDS_Shape FS1 = SecFs.Value(i), FS2 = SecFs.Value(i+1); + TopoDS_Shape FS1, FS2; + TopoDS_Vertex V1 = TopoDS::Vertex(SecVs(i)); + TopoDS_Vertex V2 = TopoDS::Vertex(SecVs(i+1)); + FindFirstPairFaces(aShBase1, aShBase2, V1, V2, FS1, FS2); + + FF.Add(FS1,FS2); + cout<<" first pair of corresponding faces is found"<edge for created pipe edges + TopTools_IndexedDataMapOfShapeShape VPE; + ShapeAnalysis_Edge sae; + //cout<<"FF.Extent()="<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; + 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))) { + 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; + Standard_ConstructionError::Raise("Surface from face is not plane"); + } + gp_Vec aDir2(Pln2->Axis().Direction()); + + 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.) + aDir1.Reverse(); + 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()) { + TopoDS_Edge E1 = TopoDS::Edge(anExpE.Current()); + nbee++; + if(!FF.Contains(E1)) + cout<<"map FF not contains key E1"<SetValue(1,P2); + HAP->SetValue(2,P3); + GeomAPI_Interpolate anInt(HAP,Standard_False,1.e-7); + anInt.Load(aDir1,aDir2); + anInt.Perform(); + C2 = anInt.Curve(); + B.MakeEdge(E2,C2,1.e-7); + B.Add(E2,TopoDS::Vertex(V2.Oriented(TopAbs_FORWARD))); + B.Add(E2,TopoDS::Vertex(V3.Oriented(TopAbs_REVERSED))); + VPE.Add(V2,E2); + } + // make E4 + TopoDS_Edge E4; + Handle(Geom_BSplineCurve) C4; + if(VPE.Contains(V1)) { + E4 = TopoDS::Edge(VPE.FindFromKey(V1)); + double fp,lp; + C4 = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve(E4,fp,lp)); + } + else { + Handle(TColgp_HArray1OfPnt) HAP = new TColgp_HArray1OfPnt(1,2); + HAP->SetValue(1,P1); + HAP->SetValue(2,P4); + GeomAPI_Interpolate anInt(HAP,Standard_False,1.e-7); + anInt.Load(aDir1,aDir2); + anInt.Perform(); + C4 = anInt.Curve(); + B.MakeEdge(E4,anInt.Curve(),1.e-7); + B.Add(E4,TopoDS::Vertex(V1.Oriented(TopAbs_FORWARD))); + B.Add(E4,TopoDS::Vertex(V4.Oriented(TopAbs_REVERSED))); + VPE.Add(V1,E4); + } + + TopoDS_Wire W; + B.MakeWire(W); + B.Add(W,E1); + B.Add(W,E2); + B.Add(W,E3); + B.Add(W,E4.Reversed()); + //cout<<" wire for edge "<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) + CE1->IncreaseDegree(3); + Handle(Geom_BSplineCurve) CE2 = + GeomConvert::CurveToBSplineCurve(C2,Convert_RationalC1); + if(CE2->Degree()<3) + CE2->IncreaseDegree(3); + Handle(Geom_BSplineCurve) CE3 = + GeomConvert::CurveToBSplineCurve(C3,Convert_RationalC1); + if(CE3->Degree()<3) + CE3->IncreaseDegree(3); + Handle(Geom_BSplineCurve) CE4 = + GeomConvert::CurveToBSplineCurve(C4,Convert_RationalC1); + if(CE4->Degree()<3) + CE4->IncreaseDegree(3); + //cout<<"CE1->Degree()="<Degree()<<" CE2->Degree()="<Degree() + // <<" CE3->Degree()="<Degree()<<" CE4->Degree()="<Degree()<D0(fp1,P1C1); + C1->D0(lp1,P2C1); + gp_Pnt P1C3,P2C3; + C3->D0(fp2,P1C3); + C3->D0(lp2,P2C3); + int n1,n2; + double fp,lp; + // get points from C1 + if(P1.Distance(P1C1)<1.e-6) { + fp = fp1; + lp = lp1; + } + else { + fp = lp1; + lp = fp1; + } + double step = (lp-fp)/(NbP-1); + Points.SetValue(1,1,P1); + double par = fp; + for(n1=2; n1D0(par,P); + Points.SetValue(1,n1,P); + } + Points.SetValue(1,NbP,P2); + // get points from C3 + if(P4.Distance(P1C3)<1.e-6) { + fp = fp2; + lp = lp2; + } + else { + fp = lp2; + lp = fp2; + } + step = (lp-fp)/(NbP-1); + Points.SetValue(NbP,1,P4); + par = fp; + for(n1=2; n1D0(par,P); + Points.SetValue(NbP,n1,P); + } + Points.SetValue(NbP,NbP,P3); + // create isolines and get points from them + 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); + HAP->SetValue(1,PI1); + HAP->SetValue(2,PI2); + GeomAPI_Interpolate anInt(HAP,Standard_False,1.e-7); + anInt.Load(aDir1,aDir2); + anInt.Perform(); + Handle(Geom_Curve) iso = anInt.Curve(); + fp = iso->FirstParameter(); + lp = iso->LastParameter(); + step = (lp-fp)/(NbP-1); + par = fp; + TopoDS_Compound VComp; + B.MakeCompound(VComp); + for(n2=2; n2D0(par,P); + Points.SetValue(n2,n1,P); + } + } + // create surface and face + //Handle(Geom_BezierSurface) BS = new Geom_BezierSurface(Points); + BS = new Geom_BezierSurface(Points); + } + + BRepBuilderAPI_MakeFace BB(BS,W); + TopoDS_Face NewF = BB.Face(); + Handle(ShapeFix_Face) sff = new ShapeFix_Face(NewF); + sff->Perform(); + sff->FixOrientation(); + TopoDS_Face FixedFace = sff->Face(); + aNewFs.Append(FixedFace); + //cout<<" face for edge "<SetTolerance(Precision::Confusion()); + aSewing->SetFaceMode(Standard_True); + aSewing->SetFloatingEdgesMode(Standard_False); + aSewing->SetNonManifoldMode(Standard_False); + for ( anExp.Init( aShell, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + aSewing->Add(anExp.Current()); + } + aSewing->Perform(); + cout<<" shell for face "<SewedShape(); + //BRepTools::Write(aSewShape,"/dn02/users_Linux/skl/work/Bugs/14857/sew.brep"); + if( aSewShape.ShapeType() == TopAbs_SHELL ) { + aShell = TopoDS::Shell(aSewShape); + GProp_GProps aSystem; + BRepGProp::VolumeProperties(aShell, aSystem); + if(aSystem.Mass()<0) { + //cout<<"aSewShape is reversed"<Perform(); + //TopoDS_Shell FixedShell = sfs->Shell(); + /* + GProp_GProps aSystem; + BRepGProp::VolumeProperties(FixedShell, aSystem); + if(aSystem.Mass()<0) { + //cout<<"aSewShape is reversed"<GetPath(); - TopoDS_Shape aShapePath = aRefPath->GetValue(); - + TopoDS_Wire aWirePath; + if(aType != PIPE_SHELLS_WITHOUT_PATH) { + // working with path + Handle(GEOM_Function) aRefPath = aCI->GetPath(); + TopoDS_Shape aShapePath = aRefPath->GetValue(); - if (aShapePath.IsNull()) { - cout<<"Driver : path is null"<SetNotDone(); @@ -659,3 +659,57 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeWithShellSections return GetObject(anObject); } + + +//============================================================================= +/*! + * MakePipeWithShellSections + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeShellsWithoutPath + (const GEOM::ListOfGO& theBases, + const GEOM::ListOfGO& theLocations) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aSeqLocations = new TColStd_HSequenceOfTransient; + int ind=0, aNbBases=0, aNbLocs=0; + + //Get the shapes + aNbBases = theBases.length(); + aNbLocs = theLocations.length(); + + if( aNbLocs && aNbBases != aNbLocs) + return aGEOMObject._retn(); + + for (ind = 0; ind < aNbBases; ind++) { + if (theBases[ind] == NULL) continue; + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()-> + GetObject(theBases[ind]->GetStudyID(), theBases[ind]->GetEntry()); + if(aBase.IsNull()) + continue; + if(aNbLocs) { + Handle(GEOM_Object) aLoc = GetOperations()->GetEngine()->GetObject + (theLocations[ind]->GetStudyID(), theLocations[ind]->GetEntry()); + if(aLoc.IsNull()) + continue; + aSeqLocations->Append(aLoc); + } + aSeqBases->Append(aBase); + } + + if(!aSeqBases->Length()) + return aGEOMObject._retn(); + + // Make pipe + Handle(GEOM_Object) anObject = + GetOperations()->MakePipeShellsWithoutPath(aSeqBases,aSeqLocations); + + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index a9cae2c0b..936fc1330 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -112,6 +112,9 @@ class GEOM_I3DPrimOperations_i : CORBA::Boolean theWithContact, CORBA::Boolean theWithCorrections); + GEOM::GEOM_Object_ptr MakePipeShellsWithoutPath(const GEOM::ListOfGO& theBases, + const GEOM::ListOfGO& theLocations); + ::GEOMImpl_I3DPrimOperations* GetOperations() { return (::GEOMImpl_I3DPrimOperations*)GetImpl(); } }; diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index fa0a64a0e..1a4706b16 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -1017,6 +1017,23 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePipeWithShellSections } +//============================================================================= +// MakePipe: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePipeShellsWithoutPath + (const GEOM::ListOfGO& theBases, + const GEOM::ListOfGO& theLocations) +{ + beginService( " GEOM_Superv_i::MakePipeShellsWithoutPath" ); + MESSAGE("GEOM_Superv_i::MakePipeShellsWithoutPath"); + get3DPrimOp(); + GEOM::GEOM_Object_ptr anObj = + my3DPrimOp->MakePipeShellsWithoutPath(theBases,theLocations); + endService( " GEOM_Superv_i::MakePipeShellsWithoutPath" ); + return anObj; +} + + //============================================================================= // MakeFuse: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 84773c8c4..01ed56829 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -243,6 +243,9 @@ public: GEOM::GEOM_Object_ptr thePath, CORBA::Boolean theWithContact, CORBA::Boolean theWithCorrections); + + GEOM::GEOM_Object_ptr MakePipeShellsWithoutPath(const GEOM::ListOfGO& theBases, + const GEOM::ListOfGO& theLocations); //-----------------------------------------------------------// // BooleanOperations // diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index cf5a61fcf..61228920c 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -768,6 +768,51 @@ def MakePipeWithShellSections(theSeqBases, theSeqSubBases, print "MakePipeWithShellSections : ", PrimOp.GetErrorCode() return anObj +def MakePipeWithShellSectionsBySteps(theSeqBases, theSeqSubBases, + theLocations, thePath, + theWithContact, theWithCorrection): + res = [] + nbsect = len(theSeqBases) + nbsubsect = len(theSeqSubBases) + #print "nbsect = ",nbsect + for i in range(1,nbsect): + #print " i = ",i + tmpSeqBases = [ theSeqBases[i-1], theSeqBases[i] ] + tmpLocations = [ theLocations[i-1], theLocations[i] ] + tmpSeqSubBases = [] + if nbsubsect>0: tmpSeqSubBases = [ theSeqSubBases[i-1], theSeqSubBases[i] ] + anObj = PrimOp.MakePipeWithShellSections(tmpSeqBases, tmpSeqSubBases, + tmpLocations, thePath, + theWithContact, theWithCorrection) + if PrimOp.IsDone() == 0: + print "Problems with pipe creation between ",i," and ",i+1," sections" + print "MakePipeWithShellSections : ", PrimOp.GetErrorCode() + break + else: + print "Pipe between ",i," and ",i+1," sections is OK" + res.append(anObj) + pass + pass + + resc = MakeCompound(res) + #resc = MakeSewing(res, 0.001) + #print "resc: ",resc + return resc + + +## Create solids between given sections +# @param theSeqBases - list of sections (shell or face). +# @param theLocations - list of corresponding vertexes +# @return New GEOM_Object, containing the created solids. +# +# Example: see GEOM_TestAll.py +def MakePipeShellsWithoutPath(theSeqBases, theLocations): + anObj = PrimOp.MakePipeShellsWithoutPath(theSeqBases, theLocations) + if PrimOp.IsDone() == 0: + print "MakePipeShellsWithoutPath : ", PrimOp.GetErrorCode() + return anObj + + # ----------------------------------------------------------------------------- # Create base shapes # ----------------------------------------------------------------------------- -- 2.39.2