// Copyright (C) 2005 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 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 // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "utilities.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include //======================================================================= //function : GetID //purpose : //======================================================================= const Standard_GUID& GEOMImpl_PipeDriver::GetID() { static Standard_GUID aPipeDriver("FF1BBB19-5D14-4df2-980B-3A668264EA16"); return aPipeDriver; } //======================================================================= //function : GEOMImpl_PipeDriver //purpose : //======================================================================= GEOMImpl_PipeDriver::GEOMImpl_PipeDriver() { } //======================================================================= //function : FillForOtherEdges //purpose : auxilary for CreatePipeForShellSections() //======================================================================= static bool FillForOtherEdges(const TopoDS_Shape& F1, const TopoDS_Shape& E1, const TopoDS_Shape& V1, TopTools_IndexedDataMapOfShapeShape& FF) { //cout<<"FillForOtherEdges"<GetBases(); Handle(TColStd_HSequenceOfTransient) aSubBasesObjs = aCIDS->GetSubBases(); Handle(TColStd_HSequenceOfTransient) aLocObjs = aCIDS->GetLocations(); Standard_Boolean aWithContact = (aCIDS->GetWithContactMode()); Standard_Boolean aWithCorrect = (aCIDS->GetWithCorrectionMode()); Standard_Integer nbBases = aBasesObjs->Length(), nbSubBases = (aSubBasesObjs.IsNull() ? 0 :aSubBasesObjs->Length()), nbLocs = (aLocObjs.IsNull() ? 0 :aLocObjs->Length()); 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; 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++) { 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; VLocs.Append(aShapeLoc); } nbLocs = VLocs.Length(); 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++) { TopoDS_Vertex V = TopoDS::Vertex(VLocs.Value(i)); PLocs.Append(BRep_Tool::Pnt(V)); } TopTools_SequenceOfShape Edges; TopTools_SequenceOfShape Wires; TopExp_Explorer anExp; for ( anExp.Init( aWirePath, TopAbs_EDGE ); anExp.More(); anExp.Next() ) { Edges.Append(anExp.Current()); } 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"); } 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"); } 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; if(PC1.Distance(P1)Value(i); if(anItem1.IsNull()) continue; Handle(GEOM_Function) aRefBase1 = Handle(GEOM_Function)::DownCast(anItem1); if(aRefBase1.IsNull()) continue; TopoDS_Shape aShBase1 = aRefBase1->GetValue(); if(aShBase1.IsNull()) continue; TopAbs_ShapeEnum aType1 = aShBase1.ShapeType(); // 2 section Handle(Standard_Transient) anItem2 = aBasesObjs->Value(i+1); if(anItem2.IsNull()) continue; Handle(GEOM_Function) aRefBase2 = Handle(GEOM_Function)::DownCast(anItem2); if(aRefBase2.IsNull()) continue; TopoDS_Shape aShBase2 = aRefBase2->GetValue(); 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; Standard_ConstructionError::Raise("One of section shapes has invalid type"); } bool CreateFewSolids = false; // compare sections TopExp_Explorer anExp; Standard_Integer nbf1 = 0; 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() ) { nbf2++; } if(nbf1==nbf2) { CreateFewSolids = true; } if(!CreateFewSolids) { // we can create only one solid TopoDS_Shape aWire1, aWire2; // prepare aWire1 if(aType1==TopAbs_SHELL) { // create wire as boundary contour if shell is no closed // get free boundary shapes 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() ) { NbWires++; aWire1 = anExp.Current(); } if(NbWires!=1) { // bad case if(aCI) delete aCI; Standard_ConstructionError::Raise("Bad shell is used as section "); } } else { // aType1==TopAbs_FACE TopExp_Explorer aExpW(aShBase1,TopAbs_WIRE); aWire1 = aExpW.Current(); } // prepare aWire2 if(aType2==TopAbs_SHELL) { // create wire as boundary contour if shell is no closed // get free boundary shapes 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() ) { NbWires++; aWire2 = anExp.Current(); } if(NbWires!=1) { // bad case if(aCI) delete aCI; Standard_ConstructionError::Raise("Bad shell is used as section "); } } else { // aType2==TopAbs_FACE TopExp_Explorer aExpW(aShBase2,TopAbs_WIRE); aWire2 = aExpW.Current(); } // make pipe using aWire1 and aWire2 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; 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() ) { B.Add(aShell,anExp.Current()); } 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() ) { B.Add(aShell,anExp.Current()); } // make sewing for this shell Handle(BRepBuilderAPI_Sewing) aSewing = new BRepBuilderAPI_Sewing; aSewing->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(); const TopoDS_Shape aSewShape = aSewing->SewedShape(); if( aSewShape.ShapeType() == TopAbs_SHELL ) { aShell = TopoDS::Shell(aSewShape); if(BRep_Tool::IsClosed(aShell)) { TopoDS_Solid aSolid; B.MakeSolid(aSolid); B.Add(aSolid,aShell); B.Add(aComp,aSolid); } else { B.Add(aComp,aShell); } } else { B.Add(aComp,aShell); } } } 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() ) aFaces1.Add(anExp.Current()); for ( anExp.Init( aShBase2, TopAbs_FACE ); anExp.More(); anExp.Next() ) aFaces2.Add(anExp.Current()); // creating map of edge faces TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces1; TopExp::MapShapesAndAncestors(aShBase1, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces1); TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces2; TopExp::MapShapesAndAncestors(aShBase2, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces2); // constuct map face->face TopTools_IndexedDataMapOfShapeShape FF; TopoDS_Shape FS1,FS2; 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++) { TopoDS_Shape tmp = aMapEdgeFaces1.FindKey(j); const TopTools_ListOfShape& aList = aMapEdgeFaces1.FindFromKey(tmp); if(aList.Extent()>1) continue; TopExp_Explorer expv; 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) { E1 = tmp; V11 = V1; V21 = V2; TopTools_ListIteratorOfListOfShape anIter(aList); FS1 = anIter.Value(); maxdist = dist; } } // main direction for comparing gp_Vec VM(PLocs.Value(i),PLocs.Value(i+1)); // find corresponding edge from next section double minang = PI; gp_Pnt P11 = BRep_Tool::Pnt(V11); gp_Pnt P21 = BRep_Tool::Pnt(V21); TopoDS_Shape E2; TopoDS_Vertex V12,V22; for(j=1; j<=aMapEdgeFaces2.Extent(); j++) { TopoDS_Shape tmp = aMapEdgeFaces2.FindKey(j); const TopTools_ListOfShape& aList = aMapEdgeFaces2.FindFromKey(tmp); if(aList.Extent()>1) continue; TopExp_Explorer expv; expv.Init( tmp, TopAbs_VERTEX ); TopoDS_Vertex V1tmp = TopoDS::Vertex(expv.Current()); expv.Next(); TopoDS_Vertex V2tmp = TopoDS::Vertex(expv.Current()); gp_Pnt P1tmp = BRep_Tool::Pnt(V1tmp); gp_Pnt P2tmp = BRep_Tool::Pnt(V2tmp); double d1 = P1tmp.Distance(P11) + P2tmp.Distance(P21); double d2 = P1tmp.Distance(P21) + P2tmp.Distance(P11); TopoDS_Vertex V1,V2; gp_Pnt P1,P2; if(d1>d2) { V1 = V2tmp; P1 = P2tmp; V2 = V1tmp; P2 = P1tmp; } else { V1 = V1tmp; P1 = P1tmp; V2 = V2tmp; P2 = P2tmp; } 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; Standard_ConstructionError::Raise("Invalid subbase shape"); } Handle(GEOM_Function) aRefBase = Handle(GEOM_Function)::DownCast(anItem); 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; Standard_ConstructionError::Raise("Invalid subbase shape"); } 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; Standard_ConstructionError::Raise("Invalid subbase shape"); } Handle(GEOM_Function) aRefBase = Handle(GEOM_Function)::DownCast(anItem); 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; Standard_ConstructionError::Raise("Invalid subbase shape"); } 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; Standard_ConstructionError::Raise("Invalid subbase shape"); } FF.Add(FS1,FS2); // 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; Standard_ConstructionError::Raise("Can not create correct pipe"); } } FindNextPairOfFaces(FS1, aMapEdgeFaces1, aMapEdgeFaces2, FF, aCI); // make pipe for each pair of faces //BRepTools::Write(WPath,"/dn02/users_Linux/skl/work/Bugs/14857/wpath.brep"); for(j=1; j<=FF.Extent(); j++) { TopoDS_Shape F1 = FF.FindKey(j); if( F1.ShapeType() != TopAbs_FACE ) continue; TopoDS_Shape F2 = FF.FindFromIndex(j); TopExp_Explorer aExpW1(F1,TopAbs_WIRE); TopoDS_Wire aWire1 = TopoDS::Wire(aExpW1.Current()); TopExp_Explorer aExpW2(F2,TopAbs_WIRE); TopoDS_Wire aWire2 = TopoDS::Wire(aExpW2.Current()); // make pipe using aWire1 and aWire2 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; 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); //int nbf=0; for ( anExp.Init( aShape, TopAbs_FACE ); anExp.More(); anExp.Next() ) { //nbf++; //cout<<"nbf="<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(); const TopoDS_Shape aSewShape = aSewing->SewedShape(); if( aSewShape.ShapeType() == TopAbs_SHELL ) { aShell = TopoDS::Shell(aSewShape); if(BRep_Tool::IsClosed(aShell)) { TopoDS_Solid aSolid; B.MakeSolid(aSolid); B.Add(aSolid,aShell); B.Add(aComp,aSolid); } else { B.Add(aComp,aShell); } } else { B.Add(aComp,aShell); } } } } } return aComp; } //======================================================================= //function : Execute //purpose : //======================================================================= Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); GEOMImpl_IPipe* aCI= 0; Standard_Integer aType = aFunction->GetType(); if(aType == PIPE_BASE_PATH) aCI = new GEOMImpl_IPipe(aFunction); else if(aType == PIPE_DIFFERENT_SECTIONS) aCI = new GEOMImpl_IPipeDiffSect(aFunction); else if(aType == PIPE_SHELL_SECTIONS) aCI = new GEOMImpl_IPipeShellSect(aFunction); else return 0; Handle(GEOM_Function) aRefPath = aCI->GetPath(); TopoDS_Shape aShapePath = aRefPath->GetValue(); if (aShapePath.IsNull()) { cout<<"Driver : path is null"<GetBase(); TopoDS_Shape aShapeBase = aRefBase->GetValue(); if (aShapeBase.IsNull()) { if(aCI) delete aCI; Standard_NullObject::Raise("MakePipe aborted : null base argument"); } // Make pipe aShape = BRepOffsetAPI_MakePipe(aWirePath, aShapeBase); } //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()); Standard_Integer i =1, nbBases = aBasesObjs->Length(), 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(Standard_Transient) anItem = aBasesObjs->Value(i); if(anItem.IsNull()) continue; Handle(GEOM_Function) aRefBase = Handle(GEOM_Function)::DownCast(anItem); if(aRefBase.IsNull()) continue; TopoDS_Shape aShapeBase = aRefBase->GetValue(); if(aShapeBase.IsNull()) continue; 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(); 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; } } //building pipe with shell sections else if (aType == PIPE_SHELL_SECTIONS) { aShape = CreatePipeForShellSections(aWirePath,aCI); } if (aShape.IsNull()) return 0; BRepCheck_Analyzer ana (aShape, Standard_False); if (!ana.IsValid()) { if(aCI) delete aCI; Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result"); } aFunction->SetValue(aShape); log.SetTouched(Label()); if(aCI) delete aCI; return 1; } //======================================================================= //function : GEOMImpl_PipeDriver_Type_ //purpose : //======================================================================= 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); static Handle_Standard_Type 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); static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PipeDriver", sizeof(GEOMImpl_PipeDriver), 1, (Standard_Address)_Ancestors, (Standard_Address)NULL); return _aType; } //======================================================================= //function : DownCast //purpose : //======================================================================= const Handle(GEOMImpl_PipeDriver) Handle(GEOMImpl_PipeDriver)::DownCast(const Handle(Standard_Transient)& AnObject) { Handle(GEOMImpl_PipeDriver) _anOtherObject; if (!AnObject.IsNull()) { if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PipeDriver))) { _anOtherObject = Handle(GEOMImpl_PipeDriver)((Handle(GEOMImpl_PipeDriver)&)AnObject); } } return _anOtherObject ; }