diff --git a/src/BRepPrimAPI/BRepPrimAPI_MakePrism.cxx b/src/BRepPrimAPI/BRepPrimAPI_MakePrism.cxx index 5313336c5b..18d9803257 100644 --- a/src/BRepPrimAPI/BRepPrimAPI_MakePrism.cxx +++ b/src/BRepPrimAPI/BRepPrimAPI_MakePrism.cxx @@ -114,7 +114,10 @@ TopoDS_Shape BRepPrimAPI_MakePrism::LastShape() const TopTools_ListOfShape& BRepPrimAPI_MakePrism::Generated (const TopoDS_Shape& S) { myGenerated.Clear(); - myGenerated.Append(myPrism.Shape (S)); + if (myPrism.IsUsed(S) && myPrism.GenIsUsed(S)) + { + myGenerated.Append(myPrism.Shape(S)); + } return myGenerated; } @@ -146,3 +149,13 @@ TopoDS_Shape BRepPrimAPI_MakePrism::LastShape(const TopoDS_Shape &theShape) } // Modified by skv - Fri Mar 4 15:50:09 2005 End + +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= +Standard_Boolean BRepPrimAPI_MakePrism::IsDeleted(const TopoDS_Shape& S) +{ + return !myPrism.IsUsed(S); +} + diff --git a/src/BRepPrimAPI/BRepPrimAPI_MakePrism.hxx b/src/BRepPrimAPI/BRepPrimAPI_MakePrism.hxx index 70f47a9989..c33de96aac 100644 --- a/src/BRepPrimAPI/BRepPrimAPI_MakePrism.hxx +++ b/src/BRepPrimAPI/BRepPrimAPI_MakePrism.hxx @@ -87,7 +87,10 @@ public: //! Returns ListOfShape from TopTools. Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE; - + + //! Returns true if the shape S has been deleted. + Standard_EXPORT virtual Standard_Boolean IsDeleted(const TopoDS_Shape& S) Standard_OVERRIDE; + //! Returns the TopoDS Shape of the bottom of the prism. //! generated with theShape (subShape of the generating shape). Standard_EXPORT TopoDS_Shape FirstShape (const TopoDS_Shape& theShape); @@ -96,9 +99,6 @@ public: //! generated with theShape (subShape of the generating shape). Standard_EXPORT TopoDS_Shape LastShape (const TopoDS_Shape& theShape); - - - protected: diff --git a/src/BRepPrimAPI/BRepPrimAPI_MakeRevol.cxx b/src/BRepPrimAPI/BRepPrimAPI_MakeRevol.cxx index 607abd8dfb..69b34f8d25 100644 --- a/src/BRepPrimAPI/BRepPrimAPI_MakeRevol.cxx +++ b/src/BRepPrimAPI/BRepPrimAPI_MakeRevol.cxx @@ -240,16 +240,49 @@ TopoDS_Shape BRepPrimAPI_MakeRevol::LastShape() const TopTools_ListOfShape& BRepPrimAPI_MakeRevol::Generated (const TopoDS_Shape& S) { myGenerated.Clear(); + + if (!myRevol.IsUsed(S)) + { + return myGenerated; + } + TopoDS_Shape aGS = myRevol.Shape(S); if (!aGS.IsNull()) { if (BRepTools_History::IsSupportedType(aGS)) { + if (aGS.ShapeType() == TopAbs_EDGE) + { + Standard_Boolean isDeg = BRep_Tool::Degenerated(TopoDS::Edge(aGS)); + if (isDeg) + { + TopTools_ListIteratorOfListOfShape anIt(myDegenerated); + for (; anIt.More(); anIt.Next()) + { + if (aGS.IsSame(anIt.Value())) + { + myGenerated.Append(aGS); + if (!myHist.IsNull()) + { + TopTools_ListIteratorOfListOfShape anIt1(myHist->Modified(aGS)); + for (; anIt1.More(); anIt1.Next()) + { + myGenerated.Append(anIt1.Value()); + } + return myGenerated; + } + } + } + return myGenerated; + } + } + // if (myHist.IsNull()) { myGenerated.Append(aGS); return myGenerated; } + // if (myHist->Modified(aGS).IsEmpty()) { myGenerated.Append(aGS); @@ -261,18 +294,19 @@ const TopTools_ListOfShape& BRepPrimAPI_MakeRevol::Generated (const TopoDS_Shape { myGenerated.Append(anIt.Value()); } - if (aGS.ShapeType() == TopAbs_EDGE) - { - if (BRep_Tool::Degenerated(TopoDS::Edge(aGS))) - { - //Append initial common deg. edge - myGenerated.Append(aGS); - } - } } } return myGenerated; } +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= +Standard_Boolean BRepPrimAPI_MakeRevol::IsDeleted(const TopoDS_Shape& S) +{ + return !myRevol.IsUsed(S); +} + //======================================================================= //function : FirstShape diff --git a/src/BRepPrimAPI/BRepPrimAPI_MakeRevol.hxx b/src/BRepPrimAPI/BRepPrimAPI_MakeRevol.hxx index 4e3d3ae13e..2068410e08 100644 --- a/src/BRepPrimAPI/BRepPrimAPI_MakeRevol.hxx +++ b/src/BRepPrimAPI/BRepPrimAPI_MakeRevol.hxx @@ -95,6 +95,10 @@ public: //! Warning: shape S must be shape of type VERTEX, EDGE, FACE, SOLID. //! For shapes of other types method always returns empty list Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE; + + //! Returns true if the shape S has been deleted. + Standard_EXPORT virtual Standard_Boolean IsDeleted(const TopoDS_Shape& S) Standard_OVERRIDE; + //! Returns the TopoDS Shape of the beginning of the revolution, //! generated with theShape (subShape of the generating shape). diff --git a/src/BRepSweep/BRepSweep_NumLinearRegularSweep.cxx b/src/BRepSweep/BRepSweep_NumLinearRegularSweep.cxx index 5a2668a956..3340325944 100644 --- a/src/BRepSweep/BRepSweep_NumLinearRegularSweep.cxx +++ b/src/BRepSweep/BRepSweep_NumLinearRegularSweep.cxx @@ -30,6 +30,7 @@ #include #include #include +#include //======================================================================= //function : BRepSweep_NumLinearRegularSweep @@ -54,9 +55,12 @@ myBuilder(aBuilder), myShapes(1,myGenShapeTool.NbShapes(), 1,myDirShapeTool.NbShapes()), myBuiltShapes(1,myGenShapeTool.NbShapes(), - 1,myDirShapeTool.NbShapes()) + 1,myDirShapeTool.NbShapes()), + myUsedShapes(1, myGenShapeTool.NbShapes(), + 1, myDirShapeTool.NbShapes()) { myBuiltShapes.Init(Standard_False); + myUsedShapes.Init(Standard_False); } //======================================================================= @@ -156,7 +160,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS, Or = It.Orientation(); if(HasShape(subGenS,aDirS)){ newShape = Shape(subGenS,aDirS); - if (GGDShapeIsToAdd(myShapes(iGenS,iDirS),newShape, + Standard_Integer iNewGenS = myGenShapeTool.Index(subGenS); + Standard_Integer iNewDirS = iDirS; + if (GGDShapeIsToAdd(myShapes(iGenS, iDirS), newShape, aGenS,subGenS,aDirS)){ //Les "planchers" doivent etre construits par les //fonctions de construcion geometrique identiquement @@ -165,6 +171,7 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS, //sur. myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; TopAbs_ShapeEnum subGenSType = myGenShapeTool.Type(subGenS); if (aGenSType==TopAbs_FACE){ if(subGenSType==TopAbs_VERTEX){ @@ -248,7 +255,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS, subGenS = It.Value(); if(HasShape(subGenS,aDirS)){ newShape = Shape(subGenS,aDirS); - if (GGDShapeIsToAdd(myShapes(iGenS,iDirS),newShape, + Standard_Integer iNewGenS = myGenShapeTool.Index(subGenS); + Standard_Integer iNewDirS = iDirS; + if (GGDShapeIsToAdd(myShapes(iGenS, iDirS), newShape, aGenS,subGenS,aDirS)){ TopAbs_ShapeEnum subGenSType = myGenShapeTool.Type(subGenS); if (aGenSType==TopAbs_EDGE){ @@ -259,11 +268,13 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS, TopoDS_Shape wi; myBuilder.MakeWire(wi); myBuilder.Add(wi,newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; wi.Closed(BRep_Tool::IsClosed(wi)); WireSeq.Append(wi); } else{ myBuilder.Add(newWire,newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; } SetDirectingPCurve (myShapes(iGenS,iDirS), newShape,bGenS,subGenS,aDirS,Or); @@ -271,6 +282,7 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS, else if (aGenSType==TopAbs_WIRE){ Or = It.Orientation(); myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; } else if (aGenSType==TopAbs_FACE){ Or = It.Orientation(); @@ -282,19 +294,23 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS, } else if(subGenSType == TopAbs_EDGE) { myBuilder.Add(newShell,newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; } } else if(aGenSType == TopAbs_SHELL){ Or = TopAbs_FORWARD; myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; } else if(aGenSType == TopAbs_COMPOUND){ Or = TopAbs_FORWARD; myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; } else{ Or = It.Orientation(); myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; } } } @@ -304,23 +320,28 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS, subDirS = Kt.Value(); if(HasShape(aGenS,subDirS)){ newShape = Shape(aGenS,subDirS); + Standard_Integer iNewGenS = iGenS; + Standard_Integer iNewDirS = myDirShapeTool.Index(subDirS); if (GDDShapeIsToAdd(myShapes(iGenS,iDirS),newShape, aGenS,aDirS,subDirS)){ if (aGenSType==TopAbs_EDGE){ Or = TopAbs::Reverse(Kt.Orientation()); myBuilder.Add(newWire,newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; SetGeneratingPCurve (myShapes(iGenS,iDirS),newShape,aGenS,aDirS,subDirS,Or); } else if(aGenSType==TopAbs_VERTEX){ Or = Kt.Orientation(); myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; SetDirectingParameter (myShapes(iGenS,iDirS),newShape,aGenS,aDirS,subDirS); } else if(aGenSType==TopAbs_FACE){ Or = Kt.Orientation(); myBuilder.Add(newShell,newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; } } } @@ -390,9 +411,12 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS, for (Kt.Init(aDirS);Kt.More();Kt.Next()){ subDirS = Kt.Value(); if(HasShape(aGenS,subDirS)){ + Standard_Integer iNewGenS = iGenS; + Standard_Integer iNewDirS = myDirShapeTool.Index(subDirS); Or = Kt.Orientation(); newShape = Shape(aGenS,subDirS); myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or); + myUsedShapes(iNewGenS, iNewDirS) = Standard_True; } } } @@ -492,3 +516,67 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::SplitShell(const TopoDS_Shape& aNe return comp; } +//======================================================================= +//function : IsUsed +//purpose : +//======================================================================= +Standard_Boolean BRepSweep_NumLinearRegularSweep::IsUsed(const TopoDS_Shape& aGenS) const +{ + Standard_Integer iGenS = myGenShapeTool.Index(aGenS); + Standard_OutOfRange_Raise_if(iGenS == 0, + "BRepSweep_NumLinearRegularSweep::IsUsed: shape index = 0") + Standard_Integer j; + Standard_Boolean isBuilt = Standard_False; + Standard_Boolean isUsed = Standard_False; + for (j = 2; j <= myBuiltShapes.UpperCol(); ++j) + { + isBuilt = isBuilt || myBuiltShapes(iGenS, j); + isUsed = isUsed || myUsedShapes(iGenS, j); + } + if (isUsed) + { + if (aGenS.ShapeType() == TopAbs_VERTEX && IsInvariant(aGenS)) + { + if (myUsedShapes(iGenS, 1) || !Closed()) + { + return isUsed; + } + else + { + return Standard_False; + } + } + else + { + return isUsed; + } + } + // + if (isBuilt) //&& !IsUsed + { + if (!HasShape(aGenS, myDirWire) && !Closed()) + { + return Standard_True; + } + else if (aGenS.ShapeType() == TopAbs_VERTEX && !Closed()) + { + if (!myBuiltShapes(iGenS, 1)) + { + return Standard_True; + } + } + } + return isUsed; +} + +//======================================================================= +//function : GenIsUsed +//purpose : +//======================================================================= +Standard_Boolean BRepSweep_NumLinearRegularSweep::GenIsUsed(const TopoDS_Shape& aGenS) const +{ + Standard_Integer iGenS = myGenShapeTool.Index(aGenS); + Standard_OutOfRange_Raise_if(iGenS == 0, + "BRepSweep_NumLinearRegularSweep::GenIsUsed: shape index = 0") + return myBuiltShapes(iGenS, 1) && myUsedShapes(iGenS, 1); +} diff --git a/src/BRepSweep/BRepSweep_NumLinearRegularSweep.hxx b/src/BRepSweep/BRepSweep_NumLinearRegularSweep.hxx index 60c34602a0..9b23b77896 100644 --- a/src/BRepSweep/BRepSweep_NumLinearRegularSweep.hxx +++ b/src/BRepSweep/BRepSweep_NumLinearRegularSweep.hxx @@ -171,7 +171,10 @@ public: //! can be geometrically inexsistant, then this //! function returns false. Standard_EXPORT virtual Standard_Boolean HasShape (const TopoDS_Shape& aGenS, const Sweep_NumShape& aDirS) const = 0; - + + //! Returns true if aGenS cannot be transformed. + Standard_EXPORT virtual Standard_Boolean IsInvariant(const TopoDS_Shape& aGenS) const = 0; + //! Returns the resulting Shape indexed by aDirS and //! aGenS. Standard_EXPORT TopoDS_Shape Shape (const TopoDS_Shape& aGenS, const Sweep_NumShape& aDirS); @@ -179,7 +182,15 @@ public: //! Returns the resulting Shape indexed by myDirWire //! and aGenS. Standard_EXPORT TopoDS_Shape Shape (const TopoDS_Shape& aGenS); - + + //! Returns true if the initial shape aGenS + //! is used in result shape + Standard_EXPORT Standard_Boolean IsUsed(const TopoDS_Shape& aGenS) const; + + //! Returns true if the shape, generated from theS + //! is used in result shape + Standard_EXPORT Standard_Boolean GenIsUsed(const TopoDS_Shape& theS) const; + //! Returns the resulting Shape indexed by myDirWire //! and myGenShape. Standard_EXPORT TopoDS_Shape Shape(); @@ -220,6 +231,7 @@ protected: Sweep_NumShapeTool myDirShapeTool; TopTools_Array2OfShape myShapes; TColStd_Array2OfBoolean myBuiltShapes; + TColStd_Array2OfBoolean myUsedShapes; private: diff --git a/src/BRepSweep/BRepSweep_Prism.cxx b/src/BRepSweep/BRepSweep_Prism.cxx index 4a9e819e15..07e981270b 100644 --- a/src/BRepSweep/BRepSweep_Prism.cxx +++ b/src/BRepSweep/BRepSweep_Prism.cxx @@ -185,3 +185,21 @@ TopLoc_Location BRepSweep_Prism::Location(const gp_Vec& V)const TopLoc_Location L(gpt); return L; } + +//======================================================================= +//function : IsUsed +//purpose : +//======================================================================= +Standard_Boolean BRepSweep_Prism::IsUsed(const TopoDS_Shape& aGenS) const +{ + return myTranslation.IsUsed(aGenS); +} + +//======================================================================= +//function : GenIsUsed +//purpose : +//======================================================================= +Standard_Boolean BRepSweep_Prism::GenIsUsed(const TopoDS_Shape& aGenS) const +{ + return myTranslation.GenIsUsed(aGenS); +} diff --git a/src/BRepSweep/BRepSweep_Prism.hxx b/src/BRepSweep/BRepSweep_Prism.hxx index e43c836488..69890b85ff 100644 --- a/src/BRepSweep/BRepSweep_Prism.hxx +++ b/src/BRepSweep/BRepSweep_Prism.hxx @@ -80,7 +80,13 @@ public: Standard_EXPORT gp_Vec Vec() const; + //! Returns true if the + //! aGenS is used in resulting shape + Standard_EXPORT Standard_Boolean IsUsed(const TopoDS_Shape& aGenS) const; + //! Returns true if the shape, generated from theS + //! is used in result shape + Standard_EXPORT Standard_Boolean GenIsUsed(const TopoDS_Shape& theS) const; protected: diff --git a/src/BRepSweep/BRepSweep_Revol.cxx b/src/BRepSweep/BRepSweep_Revol.cxx index a78f61545a..95439ccc99 100644 --- a/src/BRepSweep/BRepSweep_Revol.cxx +++ b/src/BRepSweep/BRepSweep_Revol.cxx @@ -215,3 +215,11 @@ gp_Ax1 BRepSweep_Revol::Axe()const } +//======================================================================= +//function : IsUsed +//purpose : +//======================================================================= +Standard_Boolean BRepSweep_Revol::IsUsed(const TopoDS_Shape& aGenS) const +{ + return myRotation.IsUsed(aGenS); +} diff --git a/src/BRepSweep/BRepSweep_Revol.hxx b/src/BRepSweep/BRepSweep_Revol.hxx index b78906755d..6b9d31cc9a 100644 --- a/src/BRepSweep/BRepSweep_Revol.hxx +++ b/src/BRepSweep/BRepSweep_Revol.hxx @@ -77,6 +77,10 @@ public: //! returns the angle. Standard_EXPORT Standard_Real Angle() const; + //! Returns true if the aGenS is used in resulting Shape + Standard_EXPORT Standard_Boolean IsUsed(const TopoDS_Shape& aGenS) const; + + private: //! builds the NumShape. diff --git a/src/BRepSweep/BRepSweep_Rotation.cxx b/src/BRepSweep/BRepSweep_Rotation.cxx index 83d85912b9..953894deb7 100644 --- a/src/BRepSweep/BRepSweep_Rotation.cxx +++ b/src/BRepSweep/BRepSweep_Rotation.cxx @@ -160,7 +160,7 @@ TopoDS_Shape BRepSweep_Rotation::MakeEmptyVertex { //call only in construction mode with copy. Standard_ConstructionError_Raise_if - (!myCopy,"BRepSweep_Translation::MakeEmptyVertex"); + (!myCopy,"BRepSweep_Rotation::MakeEmptyVertex"); gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenV)); TopoDS_Vertex V; if (aDirV.Index()==2) P.Transform(myLocation.Transformation()); diff --git a/src/BRepTest/BRepTest_SweepCommands.cxx b/src/BRepTest/BRepTest_SweepCommands.cxx index f21efd6649..25c33e2340 100644 --- a/src/BRepTest/BRepTest_SweepCommands.cxx +++ b/src/BRepTest/BRepTest_SweepCommands.cxx @@ -45,7 +45,7 @@ #include #include -static BRepOffsetAPI_MakePipeShell* Sweep= 0; +static BRepOffsetAPI_MakePipeShell* Sweep = 0; static BRepOffsetAPI_ThruSections* Generator = 0; #include @@ -65,33 +65,47 @@ static BRepOffsetAPI_ThruSections* Generator = 0; // prism //======================================================================= -static Standard_Integer prism(Draw_Interpretor& , Standard_Integer n, const char** a) +static Standard_Integer prism(Draw_Interpretor&, Standard_Integer n, const char** a) { if (n < 6) return 1; TopoDS_Shape base = DBRep::Get(a[2]); if (base.IsNull()) return 1; - gp_Vec V(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5])); - + gp_Vec V(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); + Standard_Boolean copy = Standard_False; - Standard_Boolean inf = Standard_False; + Standard_Boolean inf = Standard_False; Standard_Boolean sinf = Standard_False; if (n > 6) { copy = (*a[6] == 'c') || (*a[6] == 'C'); - inf = (*a[6] == 'i') || (*a[6] == 'I'); + inf = (*a[6] == 'i') || (*a[6] == 'I'); sinf = (*a[6] == 's') || (*a[6] == 'S'); } TopoDS_Shape res; - if (inf || sinf) - res = BRepPrimAPI_MakePrism(base,gp_Dir(V),inf); + BRepPrimAPI_MakePrism* Prism; + if (inf || sinf) + { + Prism = new BRepPrimAPI_MakePrism(base, gp_Dir(V), inf); + } else - res = BRepPrimAPI_MakePrism(base,V,copy); + { + Prism = new BRepPrimAPI_MakePrism(base, V, copy); + } - DBRep::Set(a[1],res); + res = Prism->Shape(); + + DBRep::Set(a[1], res); + + //History + TopTools_ListOfShape anArgs; + anArgs.Append(base); + BRepTest_Objects::SetHistory(anArgs, *Prism); + + delete Prism; return 0; } @@ -100,20 +114,20 @@ static Standard_Integer prism(Draw_Interpretor& , Standard_Integer n, const char //======================================================================= // revol //======================================================================= -static Standard_Integer revol(Draw_Interpretor& , - Standard_Integer n, const char** a) +static Standard_Integer revol(Draw_Interpretor&, + Standard_Integer n, const char** a) { - if (n < 10) return 1; + if (n < 10) return 1; TopoDS_Shape base = DBRep::Get(a[2]); if (base.IsNull()) return 1; - gp_Pnt P(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5])); - gp_Dir D(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8])); - gp_Ax1 A(P,D); + gp_Pnt P(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); + gp_Dir D(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8])); + gp_Ax1 A(P, D); Standard_Real angle = Draw::Atof(a[9]) * (M_PI / 180.0); - + Standard_Boolean copy = n > 10; @@ -121,7 +135,7 @@ static Standard_Integer revol(Draw_Interpretor& , TopoDS_Shape res = Revol.Shape(); - DBRep::Set(a[1],res); + DBRep::Set(a[1], res); //History TopTools_ListOfShape anArgs; @@ -137,7 +151,7 @@ static Standard_Integer revol(Draw_Interpretor& , //======================================================================= static Standard_Integer pipe(Draw_Interpretor& di, - Standard_Integer n, const char** a) + Standard_Integer n, const char** a) { if (n == 1) { @@ -148,14 +162,14 @@ static Standard_Integer pipe(Draw_Interpretor& di, di << "Approx - force C1-approximation if result is C0\n"; return 0; } - + if (n > 1 && n < 4) return 1; - TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE); - if ( Spine.IsNull()) return 1; + TopoDS_Shape Spine = DBRep::Get(a[2], TopAbs_WIRE); + if (Spine.IsNull()) return 1; TopoDS_Shape Profile = DBRep::Get(a[3]); - if ( Profile.IsNull()) return 1; + if (Profile.IsNull()) return 1; GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet; if (n >= 5) @@ -170,15 +184,15 @@ static Standard_Integer pipe(Draw_Interpretor& di, Standard_Boolean ForceApproxC1 = Standard_False; if (n >= 6) ForceApproxC1 = Standard_True; - + BRepOffsetAPI_MakePipe PipeBuilder(TopoDS::Wire(Spine), - Profile, - Mode, - ForceApproxC1); + Profile, + Mode, + ForceApproxC1); TopoDS_Shape S = PipeBuilder.Shape(); - DBRep::Set(a[1],S); - + DBRep::Set(a[1], S); + // Save history of pipe if (BRepTest_Objects::IsHistoryNeeded()) { @@ -187,50 +201,50 @@ static Standard_Integer pipe(Draw_Interpretor& di, aList.Append(Spine); BRepTest_Objects::SetHistory(aList, PipeBuilder); } - + return 0; } //======================================================================= -static Standard_Integer geompipe(Draw_Interpretor& , - Standard_Integer n, const char** a) +static Standard_Integer geompipe(Draw_Interpretor&, + Standard_Integer n, const char** a) { - TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_EDGE); - if ( Spine.IsNull()) return 1; - if ( n < 5) return 1; - TopoDS_Shape Profile = DBRep::Get(a[3],TopAbs_EDGE); - if ( Profile.IsNull()) return 1; - Standard_Real aSpFirst,aSpLast,aPrFirst,aPrLast; - Handle(Geom_Curve) SpineCurve = BRep_Tool::Curve(TopoDS::Edge(Spine),aSpFirst,aSpLast); - Handle(Geom_Curve) ProfileCurve = BRep_Tool::Curve(TopoDS::Edge(Profile),aPrFirst,aPrLast); - Handle(GeomAdaptor_HCurve) aAdaptCurve = new GeomAdaptor_HCurve(SpineCurve,aSpFirst,aSpLast); + TopoDS_Shape Spine = DBRep::Get(a[2], TopAbs_EDGE); + if (Spine.IsNull()) return 1; + if (n < 5) return 1; + TopoDS_Shape Profile = DBRep::Get(a[3], TopAbs_EDGE); + if (Profile.IsNull()) return 1; + Standard_Real aSpFirst, aSpLast, aPrFirst, aPrLast; + Handle(Geom_Curve) SpineCurve = BRep_Tool::Curve(TopoDS::Edge(Spine), aSpFirst, aSpLast); + Handle(Geom_Curve) ProfileCurve = BRep_Tool::Curve(TopoDS::Edge(Profile), aPrFirst, aPrLast); + Handle(GeomAdaptor_HCurve) aAdaptCurve = new GeomAdaptor_HCurve(SpineCurve, aSpFirst, aSpLast); Standard_Boolean ByACR = Standard_False; Standard_Boolean rotate = Standard_False; Standard_Real Radius = Draw::Atof(a[4]); gp_Pnt ctr; gp_Vec norm; - ProfileCurve->D1(aSpFirst,ctr,norm); - gp_Vec xAxisStart(ctr,SpineCurve->Value(aSpFirst)); - gp_Ax2 aAx2Start(ctr,norm,xAxisStart); - Handle(Geom_Circle) cStart=new Geom_Circle(aAx2Start,Radius); - Standard_Integer k =5; - if(n > k) - ByACR = (Draw::Atoi(a[k++]) ==1); - if(n > k) - rotate = (Draw::Atoi(a[k++])==1); - GeomFill_Pipe aPipe(ProfileCurve,aAdaptCurve,cStart,ByACR,rotate); + ProfileCurve->D1(aSpFirst, ctr, norm); + gp_Vec xAxisStart(ctr, SpineCurve->Value(aSpFirst)); + gp_Ax2 aAx2Start(ctr, norm, xAxisStart); + Handle(Geom_Circle) cStart = new Geom_Circle(aAx2Start, Radius); + Standard_Integer k = 5; + if (n > k) + ByACR = (Draw::Atoi(a[k++]) == 1); + if (n > k) + rotate = (Draw::Atoi(a[k++]) == 1); + GeomFill_Pipe aPipe(ProfileCurve, aAdaptCurve, cStart, ByACR, rotate); aPipe.Perform(Standard_True); if (!aPipe.IsDone()) { cout << "GeomFill_Pipe cannot make a surface" << endl; return 1; } - Handle(Geom_Surface) Sur=aPipe.Surface(); + Handle(Geom_Surface) Sur = aPipe.Surface(); TopoDS_Face F; - if(!Sur.IsNull()) + if (!Sur.IsNull()) F = BRepBuilderAPI_MakeFace(Sur, Precision::Confusion()); - DBRep::Set(a[1],F); + DBRep::Set(a[1], F); return 0; } @@ -241,7 +255,7 @@ static Standard_Integer geompipe(Draw_Interpretor& , Standard_Integer evolved(Draw_Interpretor& di, Standard_Integer n, const char** a) { - if ( n == 1) { + if (n == 1) { //cout << " 1) evolved result base profil : "<< endl; //cout << " The relative position of the profil on the base" << endl; //cout << " is given in the referencial axis. " << endl; @@ -255,34 +269,34 @@ Standard_Integer evolved(Draw_Interpretor& di, Standard_Integer n, const char** return 0; } - if ( n < 4 ) return 1; + if (n < 4) return 1; Standard_Boolean IsAFace = Standard_False; - Standard_Boolean Solid = (!strcmp(a[0],"evolvedsolid")); + Standard_Boolean Solid = (!strcmp(a[0], "evolvedsolid")); - - TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_WIRE,Standard_False); - if ( Base.IsNull()) { - Base = DBRep::Get(a[2],TopAbs_FACE,Standard_False); - IsAFace = Standard_True; + + TopoDS_Shape Base = DBRep::Get(a[2], TopAbs_WIRE, Standard_False); + if (Base.IsNull()) { + Base = DBRep::Get(a[2], TopAbs_FACE, Standard_False); + IsAFace = Standard_True; } - if ( Base.IsNull()) return 1; + if (Base.IsNull()) return 1; - TopoDS_Shape InpuTShape(DBRep::Get(a[3],TopAbs_WIRE,Standard_False)); + TopoDS_Shape InpuTShape(DBRep::Get(a[3], TopAbs_WIRE, Standard_False)); TopoDS_Wire Prof = TopoDS::Wire(InpuTShape); -// TopoDS_Wire Prof = -// TopoDS::Wire(DBRep::Get(a[3],TopAbs_WIRE,Standard_False)); - if ( Prof.IsNull()) return 1; + // TopoDS_Wire Prof = + // TopoDS::Wire(DBRep::Get(a[3],TopAbs_WIRE,Standard_False)); + if (Prof.IsNull()) return 1; if (IsAFace) { - TopoDS_Shape Volevo - = BRepOffsetAPI_MakeEvolved(TopoDS::Face(Base),Prof,GeomAbs_Arc,n == 4,Solid); - DBRep::Set(a[1],Volevo); + TopoDS_Shape Volevo + = BRepOffsetAPI_MakeEvolved(TopoDS::Face(Base), Prof, GeomAbs_Arc, n == 4, Solid); + DBRep::Set(a[1], Volevo); } else { - TopoDS_Shape Volevo - = BRepOffsetAPI_MakeEvolved(TopoDS::Wire(Base),Prof,GeomAbs_Arc,n == 4,Solid); - DBRep::Set(a[1],Volevo); + TopoDS_Shape Volevo + = BRepOffsetAPI_MakeEvolved(TopoDS::Wire(Base), Prof, GeomAbs_Arc, n == 4, Solid); + DBRep::Set(a[1], Volevo); } return 0; @@ -294,41 +308,41 @@ Standard_Integer evolved(Draw_Interpretor& di, Standard_Integer n, const char** //purpose : //======================================================================= -static Standard_Integer pruled(Draw_Interpretor& , - Standard_Integer n, const char** a) +static Standard_Integer pruled(Draw_Interpretor&, + Standard_Integer n, const char** a) { - if ( n != 4) return 1; + if (n != 4) return 1; Standard_Boolean YaWIRE = Standard_False; - TopoDS_Shape S1 = DBRep::Get(a[2],TopAbs_EDGE); - if ( S1.IsNull()) { - S1 = DBRep::Get(a[2],TopAbs_WIRE); + TopoDS_Shape S1 = DBRep::Get(a[2], TopAbs_EDGE); + if (S1.IsNull()) { + S1 = DBRep::Get(a[2], TopAbs_WIRE); if (S1.IsNull()) return 1; YaWIRE = Standard_True; } - TopoDS_Shape S2 = DBRep::Get(a[3],TopAbs_EDGE); - if ( S2.IsNull()) { - S2 = DBRep::Get(a[3],TopAbs_WIRE); - if ( S2.IsNull()) return 1; + TopoDS_Shape S2 = DBRep::Get(a[3], TopAbs_EDGE); + if (S2.IsNull()) { + S2 = DBRep::Get(a[3], TopAbs_WIRE); + if (S2.IsNull()) return 1; if (!YaWIRE) { S1 = BRepLib_MakeWire(TopoDS::Edge(S1)); YaWIRE = Standard_True; } } - else if ( YaWIRE) { + else if (YaWIRE) { S2 = BRepLib_MakeWire(TopoDS::Edge(S2)); } TopoDS_Shape Result; - if ( YaWIRE) { - Result = BRepFill::Shell(TopoDS::Wire(S1),TopoDS::Wire(S2)); + if (YaWIRE) { + Result = BRepFill::Shell(TopoDS::Wire(S1), TopoDS::Wire(S2)); } else { - Result = BRepFill::Face(TopoDS::Edge(S1),TopoDS::Edge(S2)); + Result = BRepFill::Face(TopoDS::Edge(S1), TopoDS::Edge(S2)); } - DBRep::Set(a[1],Result); + DBRep::Set(a[1], Result); return 0; } @@ -340,15 +354,15 @@ static Standard_Integer pruled(Draw_Interpretor& , Standard_Integer gener(Draw_Interpretor&, Standard_Integer n, const char** a) { - if ( n < 4) return 1; + if (n < 4) return 1; - TopoDS_Shape Shape; + TopoDS_Shape Shape; BRepFill_Generator aGenerator; - - for ( Standard_Integer i = 2; i<= n-1 ; i++) { - Shape = DBRep::Get(a[i],TopAbs_WIRE); - if ( Shape.IsNull()) + + for (Standard_Integer i = 2; i <= n - 1; i++) { + Shape = DBRep::Get(a[i], TopAbs_WIRE); + if (Shape.IsNull()) return 1; aGenerator.AddWire(TopoDS::Wire(Shape)); @@ -357,7 +371,7 @@ Standard_Integer gener(Draw_Interpretor&, Standard_Integer n, const char** a) aGenerator.Perform(); TopoDS_Shell Shell = aGenerator.Shell(); - + DBRep::Set(a[1], Shell); @@ -372,64 +386,64 @@ Standard_Integer gener(Draw_Interpretor&, Standard_Integer n, const char** a) Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char** a) { - if (n<6) return 1; + if (n < 6) return 1; Standard_Boolean check = Standard_True; Standard_Boolean samenumber = Standard_True; Standard_Integer index = 2; - // Lecture option - if (!strcmp(a[1],"-N")) { - if (n<7) return 1; + // Lecture option + if (!strcmp(a[1], "-N")) { + if (n < 7) return 1; check = Standard_False; index++; } - TopoDS_Shape Shape; + TopoDS_Shape Shape; - Standard_Boolean issolid = ( Draw::Atoi(a[index]) == 1 ); - Standard_Boolean isruled = ( Draw::Atoi(a[index+1]) == 1 ); + Standard_Boolean issolid = (Draw::Atoi(a[index]) == 1); + Standard_Boolean isruled = (Draw::Atoi(a[index + 1]) == 1); if (Generator != 0) { - delete Generator; + delete Generator; Generator = 0; } - Generator = new BRepOffsetAPI_ThruSections(issolid,isruled); - + Generator = new BRepOffsetAPI_ThruSections(issolid, isruled); + Standard_Integer NbEdges = 0; Standard_Boolean IsFirstWire = Standard_False; - for ( Standard_Integer i = index+2; i<= n-1 ; i++) { + for (Standard_Integer i = index + 2; i <= n - 1; i++) { Standard_Boolean IsWire = Standard_True; Shape = DBRep::Get(a[i], TopAbs_WIRE); if (!Shape.IsNull()) - { - Generator->AddWire(TopoDS::Wire(Shape)); - if (!IsFirstWire) - IsFirstWire = Standard_True; - else - IsFirstWire = Standard_False; - } + { + Generator->AddWire(TopoDS::Wire(Shape)); + if (!IsFirstWire) + IsFirstWire = Standard_True; + else + IsFirstWire = Standard_False; + } else - { - Shape = DBRep::Get(a[i], TopAbs_VERTEX); - IsWire = Standard_False; - if (!Shape.IsNull()) - Generator->AddVertex(TopoDS::Vertex(Shape)); - else - return 1; - } + { + Shape = DBRep::Get(a[i], TopAbs_VERTEX); + IsWire = Standard_False; + if (!Shape.IsNull()) + Generator->AddVertex(TopoDS::Vertex(Shape)); + else + return 1; + } Standard_Integer cpt = 0; TopExp_Explorer PE; for (PE.Init(Shape, TopAbs_EDGE); PE.More(); PE.Next()) { cpt++; } - if (IsFirstWire) + if (IsFirstWire) NbEdges = cpt; else if (IsWire && cpt != NbEdges) - samenumber = Standard_False; - + samenumber = Standard_False; + } check = (check || !samenumber); @@ -439,7 +453,7 @@ Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char* if (Generator->IsDone()) { TopoDS_Shape Shell = Generator->Shape(); - DBRep::Set(a[index-1], Shell); + DBRep::Set(a[index - 1], Shell); // Save history of the lofting if (BRepTest_Objects::IsHistoryNeeded()) BRepTest_Objects::SetHistory(Generator->Wires(), *Generator); @@ -454,14 +468,14 @@ Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char* //======================================================================= // mksweep //======================================================================= -static Standard_Integer mksweep(Draw_Interpretor& , - Standard_Integer n, const char** a) +static Standard_Integer mksweep(Draw_Interpretor&, + Standard_Integer n, const char** a) { - if ( n != 2) return 1; - TopoDS_Shape Spine = DBRep::Get(a[1],TopAbs_WIRE); - if ( Spine.IsNull()) return 1; - if (Sweep !=0) { - delete Sweep; + if (n != 2) return 1; + TopoDS_Shape Spine = DBRep::Get(a[1], TopAbs_WIRE); + if (Spine.IsNull()) return 1; + if (Sweep != 0) { + delete Sweep; Sweep = 0; } Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine)); @@ -472,9 +486,9 @@ static Standard_Integer mksweep(Draw_Interpretor& , // setsweep //======================================================================= static Standard_Integer setsweep(Draw_Interpretor& di, - Standard_Integer n, const char** a) + Standard_Integer n, const char** a) { - if ( n == 1) { + if (n == 1) { //cout << "setsweep options [arg1 [arg2 [...]]] : options are :" << endl; //cout << " -FR : Tangent and Normal are given by Frenet trihedron" <> command !"<< endl; - di << "You have forgotten the <> command !\n"; - return 1; - } - if (!strcmp(a[1],"-FR")) { + if (Sweep == 0) { + //cout << "You have forgotten the <> command !"<< endl; + di << "You have forgotten the <> command !\n"; + return 1; + } + if (!strcmp(a[1], "-FR")) { Sweep->SetMode(Standard_True); } - else if (!strcmp(a[1],"-CF")) { + else if (!strcmp(a[1], "-CF")) { Sweep->SetMode(Standard_False); } - else if (!strcmp(a[1],"-DT")) { + else if (!strcmp(a[1], "-DT")) { Sweep->SetDiscreteMode(); } - else if (!strcmp(a[1],"-DX")) { - if (n!=3) { + else if (!strcmp(a[1], "-DX")) { + if (n != 3) { //cout << "bad arguments !" << endl; di << "bad arguments !\n"; return 1; } TopoDS_Shape Surf; - Surf = DBRep::Get(a[2],TopAbs_SHAPE); + Surf = DBRep::Get(a[2], TopAbs_SHAPE); if (Surf.IsNull()) { - //cout << a[2] <<"is not a shape !" << endl; - di << a[2] <<"is not a shape !\n"; + //cout << a[2] <<"is not a shape !" << endl; + di << a[2] << "is not a shape !\n"; return 1; } Sweep->SetMode(Surf); } - else if (!strcmp(a[1],"-CN")) { - if (n!=5) { + else if (!strcmp(a[1], "-CN")) { + if (n != 5) { //cout << "bad arguments !" << endl; di << "bad arguments !\n"; return 1; @@ -536,14 +550,14 @@ static Standard_Integer setsweep(Draw_Interpretor& di, gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])); Sweep->SetMode(D);; } - else if (!strcmp(a[1],"-FX")) { - if ((n!=5)&&(n!=8)) { + else if (!strcmp(a[1], "-FX")) { + if ((n != 5) && (n != 8)) { //cout << "bad arguments !" << endl; di << "bad arguments !\n"; return 1; } gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])); - if (n==8) { + if (n == 8) { gp_Dir DN(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7])); gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D, DN); Sweep->SetMode(Axe); @@ -553,28 +567,28 @@ static Standard_Integer setsweep(Draw_Interpretor& di, Sweep->SetMode(Axe); } } - else if (!strcmp(a[1],"-G")) // contour guide + else if (!strcmp(a[1], "-G")) // contour guide + { + if (n != 5) { - if (n != 5) - { - //cout << "bad arguments !" << endl; - di << "bad arguments !\n"; - return 1; - } - else - { - TopoDS_Shape Guide = DBRep::Get(a[2],TopAbs_WIRE); - Standard_Boolean CurvilinearEquivalence = Draw::Atoi(a[3]) != 0; - Standard_Integer KeepContact = Draw::Atoi(a[4]); - Sweep->SetMode(TopoDS::Wire(Guide), - CurvilinearEquivalence, - (BRepFill_TypeOfContact)KeepContact); - } + //cout << "bad arguments !" << endl; + di << "bad arguments !\n"; + return 1; } - + else + { + TopoDS_Shape Guide = DBRep::Get(a[2], TopAbs_WIRE); + Standard_Boolean CurvilinearEquivalence = Draw::Atoi(a[3]) != 0; + Standard_Integer KeepContact = Draw::Atoi(a[4]); + Sweep->SetMode(TopoDS::Wire(Guide), + CurvilinearEquivalence, + (BRepFill_TypeOfContact)KeepContact); + } + } + else { //cout << "The option "<< a[1] << " is unknown !" << endl; - di << "The option "<< a[1] << " is unknown !\n"; + di << "The option " << a[1] << " is unknown !\n"; return 1; } return 0; @@ -585,9 +599,9 @@ static Standard_Integer setsweep(Draw_Interpretor& di, // addsweep //======================================================================= static Standard_Integer addsweep(Draw_Interpretor& di, - Standard_Integer n, const char** a) + Standard_Integer n, const char** a) { - if ( n == 1) { + if (n == 1) { //cout << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :" << endl; //cout << " -T : the wire/vertex have to be translated to assume contact"<< endl; //cout << " with the spine" <> command !"<< endl; di << "You have forgotten the <> command !\n"; return 1; @@ -613,57 +627,58 @@ static Standard_Integer addsweep(Draw_Interpretor& di, Section = DBRep::Get(a[1], TopAbs_SHAPE); if (Section.IsNull() || - (Section.ShapeType() != TopAbs_WIRE && - Section.ShapeType() != TopAbs_VERTEX)) - { - //cout << a[1] <<"is not a wire and is not a vertex!" << endl; - di << a[1] <<" is not a wire and is not a vertex!\n"; - return 1; - } + (Section.ShapeType() != TopAbs_WIRE && + Section.ShapeType() != TopAbs_VERTEX)) + { + //cout << a[1] <<"is not a wire and is not a vertex!" << endl; + di << a[1] << " is not a wire and is not a vertex!\n"; + return 1; + } - Standard_Boolean HasVertex=Standard_False, - isT=Standard_False, - isR=Standard_False; + Standard_Boolean HasVertex = Standard_False, + isT = Standard_False, + isR = Standard_False; - if (n > 2) { + if (n > 2) { Standard_Integer cur = 2; // Reading of Vertex - TopoDS_Shape InputVertex(DBRep::Get(a[cur],TopAbs_VERTEX)); + TopoDS_Shape InputVertex(DBRep::Get(a[cur], TopAbs_VERTEX)); Vertex = TopoDS::Vertex(InputVertex); -// Vertex = TopoDS::Vertex(DBRep::Get(a[cur],TopAbs_VERTEX)); + // Vertex = TopoDS::Vertex(DBRep::Get(a[cur],TopAbs_VERTEX)); if (!Vertex.IsNull()) { cur++; HasVertex = Standard_True; } - + // Reading of the translation option - if ((n>cur) && !strcmp(a[cur],"-T")) { + if ((n > cur) && !strcmp(a[cur], "-T")) { cur++; isT = Standard_True; } // Reading of the rotation option - if ((n>cur) && !strcmp(a[cur],"-R")) { + if ((n > cur) && !strcmp(a[cur], "-R")) { cur++; isR = Standard_True; } // law ? - if (n>cur) { - Standard_Integer nbreal = n-cur; - if ( (nbreal < 4) || (nbreal % 2 != 0) ) { - //cout << "bad arguments ! :" < cur) { + Standard_Integer nbreal = n - cur; + if ((nbreal < 4) || (nbreal % 2 != 0)) { + //cout << "bad arguments ! :" <Set(ParAndRad, - Abs(ParAndRad(1).Y() - ParAndRad(L).Y()) < Precision::Confusion()); + thelaw = new (Law_Interpol)(); + thelaw->Set(ParAndRad, + Abs(ParAndRad(1).Y() - ParAndRad(L).Y()) < Precision::Confusion()); } } } @@ -684,20 +699,20 @@ static Standard_Integer addsweep(Draw_Interpretor& di, // deletesweep //======================================================================= static Standard_Integer deletesweep(Draw_Interpretor& di, - Standard_Integer n, const char** a) + Standard_Integer n, const char** a) { - if ( n != 2) { + if (n != 2) { return 1; } TopoDS_Wire Section; - TopoDS_Shape InputShape(DBRep::Get(a[1],TopAbs_SHAPE)); + TopoDS_Shape InputShape(DBRep::Get(a[1], TopAbs_SHAPE)); Section = TopoDS::Wire(InputShape); -// Section = TopoDS::Wire(DBRep::Get(a[1],TopAbs_SHAPE)); + // Section = TopoDS::Wire(DBRep::Get(a[1],TopAbs_SHAPE)); if (Section.IsNull()) { //cout << a[1] <<"is not a wire !" << endl; - di << a[1] <<"is not a wire !\n"; + di << a[1] << "is not a wire !\n"; return 1; - } + } Sweep->Delete(Section); @@ -708,9 +723,9 @@ static Standard_Integer deletesweep(Draw_Interpretor& di, // buildsweep //======================================================================= static Standard_Integer buildsweep(Draw_Interpretor& di, - Standard_Integer n, const char** a) + Standard_Integer n, const char** a) { - if ( n == 1) { + if (n == 1) { //cout << "build sweep result [-M/-C/-R] [-S] [tol] : options are" << endl; //cout << " -M : Discontinuities are treated by Modfication of"<< endl; //cout << " the sweeping mode : it is the default" <> command !"<< endl; di << "You have forgotten the <> command !\n"; return 1; @@ -744,30 +759,30 @@ static Standard_Integer buildsweep(Draw_Interpretor& di, } TopoDS_Shape result; - Standard_Integer cur=2; - if (n>cur) { + Standard_Integer cur = 2; + if (n > cur) { BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed; // Reading Transition - if (!strcmp(a[cur],"-C")) { + if (!strcmp(a[cur], "-C")) { Transition = BRepBuilderAPI_RightCorner; cur++; } - else if (!strcmp(a[cur],"-R")) { + else if (!strcmp(a[cur], "-R")) { Transition = BRepBuilderAPI_RoundCorner; cur++; } Sweep->SetTransitionMode(Transition); } // Reading solid ? - if ((n>cur) && (!strcmp(a[cur],"-S")) ) mksolid = Standard_True; + if ((n > cur) && (!strcmp(a[cur], "-S"))) mksolid = Standard_True; // Calcul le resultat Sweep->Build(); if (!Sweep->IsDone()) { //cout << "Buildsweep : Not Done" << endl; di << "Buildsweep : Not Done\n"; - BRepBuilderAPI_PipeError Stat = Sweep->GetStatus(); + BRepBuilderAPI_PipeError Stat = Sweep->GetStatus(); if (Stat == BRepBuilderAPI_PlaneNotIntersectGuide) { //cout << "Buildsweep : One Plane not intersect the guide" << endl; di << "Buildsweep : One Plane not intersect the guide\n"; @@ -785,7 +800,7 @@ static Standard_Integer buildsweep(Draw_Interpretor& di, if (!B) di << " BuildSweep : It is impossible to make a solid !\n"; } result = Sweep->Shape(); - DBRep::Set(a[1],result); + DBRep::Set(a[1], result); // Save history of sweep if (BRepTest_Objects::IsHistoryNeeded()) { @@ -806,7 +821,7 @@ static Standard_Integer buildsweep(Draw_Interpretor& di, // reached by Sweep //======================================================================= static Standard_Integer errorsweep(Draw_Interpretor& di, - Standard_Integer, const char**) + Standard_Integer, const char**) { if (!Sweep->IsDone()) { @@ -822,35 +837,35 @@ static Standard_Integer errorsweep(Draw_Interpretor& di, // simulsweep //======================================================================= static Standard_Integer simulsweep(Draw_Interpretor& di, - Standard_Integer n, const char** a) + Standard_Integer n, const char** a) { - if ( (n!=3) && (n!=4) ) return 1; - - if (Sweep ==0) { + if ((n != 3) && (n != 4)) return 1; + + if (Sweep == 0) { //cout << "You have forgotten the <> command !"<< endl; di << "You have forgotten the <> command !\n"; return 1; } - + if (!Sweep->IsReady()) { //cout << "You have forgotten the <> command !"<< endl; di << "You have forgotten the <> command !\n"; return 1; } - + char name[100]; TopTools_ListOfShape List; TopTools_ListIteratorOfListOfShape it; Standard_Integer N, ii; N = Draw::Atoi(a[2]); - if (n>3) { + if (n > 3) { BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed; // Lecture Transition - if (!strcmp(a[3],"-C")) { + if (!strcmp(a[3], "-C")) { Transition = BRepBuilderAPI_RightCorner; } - else if (!strcmp(a[3],"-R")) { + else if (!strcmp(a[3], "-R")) { Transition = BRepBuilderAPI_RoundCorner; } Sweep->SetTransitionMode(Transition); @@ -858,8 +873,8 @@ static Standard_Integer simulsweep(Draw_Interpretor& di, // Calculate the result Sweep->Simulate(N, List); - for (ii=1, it.Initialize(List); it.More(); it.Next(), ii++) { - Sprintf(name,"%s_%d",a[1],ii); + for (ii = 1, it.Initialize(List); it.More(); it.Next(), ii++) { + Sprintf(name, "%s_%d", a[1], ii); DBRep::Set(name, it.Value()); } @@ -870,7 +885,7 @@ static Standard_Integer simulsweep(Draw_Interpretor& di, // middlepath //======================================================================= static Standard_Integer middlepath(Draw_Interpretor& /*di*/, - Standard_Integer n, const char** a) + Standard_Integer n, const char** a) { if (n < 5) return 1; @@ -879,8 +894,8 @@ static Standard_Integer middlepath(Draw_Interpretor& /*di*/, TopoDS_Shape StartShape = DBRep::Get(a[3]); if (StartShape.IsNull()) return 1; - - TopoDS_Shape EndShape = DBRep::Get(a[4]); + + TopoDS_Shape EndShape = DBRep::Get(a[4]); if (EndShape.IsNull()) return 1; BRepOffsetAPI_MiddlePath Builder(aShape, StartShape, EndShape); @@ -906,63 +921,63 @@ void BRepTest::SweepCommands(Draw_Interpretor& theCommands) DBRep::BasicCommands(theCommands); const char* g = "Sweep commands"; - + theCommands.Add("prism", - "prism result base dx dy dz [Copy | Inf | Seminf]", - __FILE__,prism,g); - + "prism result base dx dy dz [Copy | Inf | Seminf]", + __FILE__, prism, g); + theCommands.Add("revol", - "revol result base px py pz dx dy dz angle [Copy]", - __FILE__,revol,g); - + "revol result base px py pz dx dy dz angle [Copy]", + __FILE__, revol, g); + theCommands.Add("pipe", - "pipe result Wire_spine Profile [Mode [Approx]], no args to get help", - __FILE__,pipe,g); - + "pipe result Wire_spine Profile [Mode [Approx]], no args to get help", + __FILE__, pipe, g); + theCommands.Add("evolved", - "evolved , no args to get help", - __FILE__,evolved,g); + "evolved , no args to get help", + __FILE__, evolved, g); theCommands.Add("evolvedsolid", - "evolved , no args to get help", - __FILE__,evolved,g); - + "evolved , no args to get help", + __FILE__, evolved, g); + theCommands.Add("pruled", - "pruled result Edge1/Wire1 Edge2/Wire2", - __FILE__,pruled,g); + "pruled result Edge1/Wire1 Edge2/Wire2", + __FILE__, pruled, g); theCommands.Add("gener", "gener result wire1 wire2 [..wire..]", - __FILE__,gener,g); + __FILE__, gener, g); theCommands.Add("thrusections", "thrusections [-N] result issolid isruled shape1 shape2 [..shape..], the option -N means no check on wires, shapes must be wires or vertices (only first or last)", - __FILE__,thrusections,g); - + __FILE__, thrusections, g); + theCommands.Add("mksweep", "mksweep wire", - __FILE__,mksweep,g); + __FILE__, mksweep, g); theCommands.Add("setsweep", "setsweep no args to get help", - __FILE__,setsweep,g); - - theCommands.Add("addsweep", - "addsweep wire [vertex] [-M ] [-C] [auxiilaryshape]:no args to get help", - __FILE__,addsweep,g); + __FILE__, setsweep, g); - theCommands.Add("deletesweep", - "deletesweep wire, To delete a section", - __FILE__,deletesweep,g); + theCommands.Add("addsweep", + "addsweep wire [vertex] [-M ] [-C] [auxiilaryshape]:no args to get help", + __FILE__, addsweep, g); - theCommands.Add("buildsweep", "builsweep [r] [option] [Tol] , no args to get help", - __FILE__,buildsweep,g); + theCommands.Add("deletesweep", + "deletesweep wire, To delete a section", + __FILE__, deletesweep, g); - theCommands.Add("errorsweep", "errorsweep: returns the summary error on resulting surfaces reached by Sweep", - __FILE__,errorsweep,g); + theCommands.Add("buildsweep", "builsweep [r] [option] [Tol] , no args to get help", + __FILE__, buildsweep, g); + + theCommands.Add("errorsweep", "errorsweep: returns the summary error on resulting surfaces reached by Sweep", + __FILE__, errorsweep, g); theCommands.Add("simulsweep", "simulsweep r [n] [option]" - __FILE__,simulsweep,g); + __FILE__, simulsweep, g); theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]" - __FILE__,geompipe,g); - + __FILE__, geompipe, g); + theCommands.Add("middlepath", "middlepath res shape startshape endshape", - __FILE__,middlepath,g); + __FILE__, middlepath, g); } diff --git a/tests/bugs/modalg_7/bug30346_1 b/tests/bugs/modalg_7/bug30346_1 new file mode 100644 index 0000000000..3d94d53063 --- /dev/null +++ b/tests/bugs/modalg_7/bug30346_1 @@ -0,0 +1,21 @@ +puts "========" +puts "0030346: Modeling Algorithms - BRepPrimAPI_MakeRevol throws BRepSweep_Translation::MakeEmptyVertex" +puts "========" +puts "" + +pload MODELING + +plane f 0 0 0 0 1 0 +mkface f f 0 1 0 1 +revol r1 f 0 0 0 0 0 1 60 +savehistory h1 +set s1 [dump h1] +if { !([regexp "0 Deleted" $s1] && [regexp "6 Generated" $s1])} { + puts "Error: wrong history h1" +} +revol r2 f 0 0 0 0 0 1 360 +savehistory h2 +set s2 [dump h2] +if { !([regexp "6 Deleted" $s2] && [regexp "3 Generated" $s2])} { + puts "Error: wrong history h2" +} diff --git a/tests/bugs/modalg_7/bug30346_2 b/tests/bugs/modalg_7/bug30346_2 new file mode 100644 index 0000000000..6fa62957d6 --- /dev/null +++ b/tests/bugs/modalg_7/bug30346_2 @@ -0,0 +1,23 @@ +puts "========" +puts "0030346: Modeling Algorithms - BRepPrimAPI_MakeRevol throws BRepSweep_Translation::MakeEmptyVertex" +puts "========" +puts "" + +pload MODELING + +sphere s 1 +mkface f1 s 0 2*pi 0.785398163397448 1.5707963267949 +prism r1 f1 0 0 2 +savehistory h1 +set s1 [dump h1] +if { !([regexp "0 Deleted" $s1] && [regexp "2 Generated" $s1])} { + puts "Error: wrong history h1" +} +# +mkface f2 s 0 5 0.785398163397448 1.5707963267949 +prism r2 f2 0 0 2 +savehistory h2 +set s2 [dump h2] +if { !([regexp "0 Deleted" $s2] && [regexp "6 Generated" $s2])} { + puts "Error: wrong history h2" +} diff --git a/tests/bugs/moddata_2/bug65 b/tests/bugs/moddata_2/bug65 index bb5a4d7b65..25d9c649d0 100755 --- a/tests/bugs/moddata_2/bug65 +++ b/tests/bugs/moddata_2/bug65 @@ -1,5 +1,3 @@ -puts "TODO OCC12345 ALL: Faulty shapes in variables faulty_1 to faulty_" - puts "================" puts "BUC61023" puts "OCC65" @@ -14,7 +12,10 @@ checkshape sh revol result sh 0 0 0 0 0 1 360 -checkshape result +explode result +#result contains two shapes, one of them (result_2) is bad - empty shell +#because of bad input data, so only result_1 is checked. +checkshape result_1 checkprops result -s 1.0134e+06 checkview -display result -2d -path ${imagedir}/${test_image}.png