From: emv Date: Fri, 17 Mar 2017 11:33:50 +0000 (+0300) Subject: 0028567: Get rid of the unused DRAW commands based on old Boolean Operations (BRepAlgo) X-Git-Tag: V7_2_0_beta~208 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=e45b5ff7f2355c2eb8fe4dc34f05338102614332;p=occt.git 0028567: Get rid of the unused DRAW commands based on old Boolean Operations (BRepAlgo) 1. Removal of the traces of the usage of old Boolean operations in BRepFeat package. 2. The DRAW commands *fubl* and *cubl* based on old Boolean operations have been removed. The alternative for these commands are the commands *bfuseblend* and *bcutblend* respectively. The last two commands are based on the modern Boolean operations. 3. The DRAW command *ksection* based on old Boolean operations has been removed. The command *bsection* should be used as alternative. Test cases which have been using the *ksection* command have been modified to use the *bsection* command. 4. The class QANewBRepNaming_BooleanOperation has been modified to use modern Boolean operations. The class QANewBRepNaming_BooleanOperation has been removed as not used. The class QANewBRepNaming_BooleanOperationFeat has been renamed to QANewBRepNaming_BooleanOperation as it has nothing to do with Feat algorithm. --- diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index 615cf8a451..f5418fc8a4 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1098,6 +1098,7 @@ The following obsolete features have been removed: Text resolution can be managed by rendering parameter *Graphic3d_RenderingParams::Resolution*, returned by *V3d_View::ChangeRenderingParams()*. * Methods *PrsMgr_PresentationManager::BoundBox*, *PrsMgr_PresentationManager::Hilight* and *SelectMgr_EntityOwner::Hilight* have been removed as not used. The corresponding method in custom implementations of *SelectMgr_EntityOwner* can be removed safely. *PrsMgr_PresentationManager::Color* with the corresponding style must be used instead. * Class *NCollection_QuickSort* has been removed. The code that used the tools provided by that class should be corrected manually. The recommended approach is to use sorting algorithms provided by STL (std::sort). See also @ref upgrade_occt700_sorttools above. +* The class *QANewBRepNaming_BooleanOperationFeat* has been removed. The class *QANewBRepNaming_BooleanOperation* should be used instead. * Package *Dico*. The code that used the tools provided by that package should be corrected manually. The recommended approach is to use *NCollection_DataMap* and *NCollection_IndexedDataMap* classes. @@ -1228,7 +1229,8 @@ The following Grid management methods within class V3d_Viewer do not implicitly * The classes *BOPDS_PassKey* and *BOPDS_PassKeyBoolean* are too excessive and not used any more in Boolean Operations. To replace them the new *BOPDS_Pair* class has been implemented. Thus: - The method *BOPDS_DS::Interferences()* now returns the *BOPDS_MapOfPair*; - The method *BOPDS_Iterator::Value()* takes now only two parameters - the indices of interfering sub-shapes. - -@subsection upgrade_720_UnifySameDomain_history History changes in ShapeUpgrade_UnifySameDomain algorithm -* The result of Generated and Modified methods in ShapeUpgrade_UnifySameDomain class is now returned list of shape instead only one shape. +@subsection upgrade_720_Removal_Of_Old_Boolean_Operations_Draw Removal of the Draw commands based on old Boolean operations + +* The commands *fubl* and *cubl* have been removed. The alternative for these commands are the commands *bfuseblend* and *bcutblend* respectively. +* The command *ksection* has been removed. The alternative for this command is the command *bsection*. \ No newline at end of file diff --git a/dox/user_guides/draw_test_harness/draw_test_harness.md b/dox/user_guides/draw_test_harness/draw_test_harness.md index e7b5861e8b..d4f54d1994 100644 --- a/dox/user_guides/draw_test_harness/draw_test_harness.md +++ b/dox/user_guides/draw_test_harness/draw_test_harness.md @@ -6998,7 +6998,8 @@ Blending is the creation of a new shape by rounding edges to create a fillet. * Use the **depouille** command for drafting. * Use the **chamf** command to add a chamfer to an edge * Use the **blend** command for simple blending. - * Use **fubl** for a fusion + blending operation. + * Use **bfuseblend** for a fusion + blending operation. + * Use **bcutblend** for a cut + blending operation. * Use **buildevol**, **mkevol**, **updatevol** to realize varying radius blending. @@ -7105,24 +7106,43 @@ blend b b 2 . ==- SetRegul 0s ~~~~~ -@subsubsection occt_draw_7_8_4 fubl +@subsubsection occt_draw_7_8_4 bfuseblend -Syntax: +Syntax: +~~~~~ +bfuseblend name shape1 shape2 radius [-d] ~~~~~ -fubl name shape1 shape2 radius -~~~~~ -Creates a boolean fusion of two shapes and then blends (fillets) the intersection edges using the given radius. +Creates a boolean fusion of two shapes and then blends (fillets) the intersection edges using the given radius. +Option [-d] enables the Debugging mode in which the error messages, if any, will be printed. -**Example:** +**Example:** ~~~~~ -# fuse-blend two boxes -box b1 20 20 5 -copy b1 b2 -ttranslate b2 -10 10 3 -fubl a b1 b2 1 +# fuse-blend two boxes +box b1 20 20 5 +copy b1 b2 +ttranslate b2 -10 10 3 +bfuseblend a b1 b2 1 ~~~~~ +@subsubsection occt_draw_7_8_4a bcutblend + +Syntax: +~~~~~ +bcutblend name shape1 shape2 radius [-d] +~~~~~ + +Creates a boolean cut of two shapes and then blends (fillets) the intersection edges using the given radius. +Option [-d] enables the Debugging mode in which the error messages, if any, will be printed. + +**Example:** +~~~~~ +# cut-blend two boxes +box b1 20 20 5 +copy b1 b2 +ttranslate b2 -10 10 3 +bcutblend a b1 b2 1 +~~~~~ @subsubsection occt_draw_7_8_5 mkevol, updatevol, buildevol diff --git a/src/BRepFeat/BRepFeat.cxx b/src/BRepFeat/BRepFeat.cxx index 63ebee58d9..09e7ec8858 100644 --- a/src/BRepFeat/BRepFeat.cxx +++ b/src/BRepFeat/BRepFeat.cxx @@ -57,7 +57,6 @@ #include #include -//#include #define NECHANTBARYC 11 //======================================================================= diff --git a/src/BRepFeat/BRepFeat_Form.cxx b/src/BRepFeat/BRepFeat_Form.cxx index 99a06138ba..604ffb805e 100644 --- a/src/BRepFeat/BRepFeat_Form.cxx +++ b/src/BRepFeat/BRepFeat_Form.cxx @@ -57,10 +57,6 @@ #include #include -//modified by NIZNHY-PKV Thu Mar 21 17:30:25 2002 f -//#include -//#include -//modified by NIZNHY-PKV Thu Mar 21 17:30:29 2002 t #ifdef OCCT_DEBUG extern Standard_Boolean BRepFeat_GettraceFEAT(); #endif @@ -320,10 +316,7 @@ static void Descendants(const TopoDS_Shape&, TopTools_DataMapOfShapeListOfShape locmap; TopExp_Explorer expp(Comp, TopAbs_SOLID); if(expp.More() && !Comp.IsNull() && !myGShape.IsNull()) { - //modified by NIZNHY-PKV Thu Mar 21 17:15:36 2002 f - //BRepAlgo_Cut trP(myGShape,Comp); BRepAlgoAPI_Cut trP(myGShape, Comp); - //modified by NIZNHY-PKV Thu Mar 21 17:15:58 2002 t exp.Init(trP.Shape(), TopAbs_SOLID); if (exp.Current().IsNull()) { theOpe = 2; @@ -395,10 +388,7 @@ static void Descendants(const TopoDS_Shape&, } }// if(!mySUntil.IsNull()) // - //modified by NIZNHY-PKV Thu Mar 21 17:21:49 2002 f - //UpdateDescendants(trP.Builder(),theGShape,Standard_True); // skip faces UpdateDescendants(trP,theGShape,Standard_True); // skip faces - //modified by NIZNHY-PKV Thu Mar 21 17:22:32 2002 t theGlue.Init(mySbase,theGShape); for (itm.Initialize(myGluedF);itm.More();itm.Next()) { @@ -605,10 +595,7 @@ static void Descendants(const TopoDS_Shape&, TopExp_Explorer expp(Comp, TopAbs_SOLID); if(expp.More() && !Comp.IsNull() && !myGShape.IsNull()) { - //modified by NIZNHY-PKV Thu Mar 21 17:24:52 2002 f - //BRepAlgo_Cut trP(myGShape,Comp); BRepAlgoAPI_Cut trP(myGShape, Comp); - //modified by NIZNHY-PKV Thu Mar 21 17:24:56 2002 t // the result is necessarily a compound. exp.Init(trP.Shape(),TopAbs_SOLID); if (!exp.More()) { @@ -659,10 +646,7 @@ static void Descendants(const TopoDS_Shape&, } } } - //modified by NIZNHY-PKV Thu Mar 21 17:27:23 2002 f - //UpdateDescendants(trP.Builder(),theGShape,Standard_True); UpdateDescendants(trP,theGShape,Standard_True); - //modified by NIZNHY-PKV Thu Mar 21 17:27:31 2002 t }//if(expp.More() && !Comp.IsNull() && !myGShape.IsNull()) { // @@ -1007,14 +991,12 @@ static void Descendants(const TopoDS_Shape&, if (!myJustFeat) { // removal of edges of section that have no common vertices // with PartsOfTool preserved - //modified by NIZHNY-EMV Thu May 10 15:56:24 2012 if (bFlag) { theBuilder.PerformResult(); myShape = theBuilder.Shape(); } else { myShape = theBuilder.Shape(); } - //modified by NIZHNY-EMV Thu May 10 15:56:26 2012 Done(); } else { @@ -1372,7 +1354,6 @@ static void Descendants(const TopoDS_Shape& S, } } } -//modified by NIZNHY-PKV Thu Mar 21 18:43:18 2002 f //======================================================================= //function : UpdateDescendants //purpose : @@ -1429,4 +1410,3 @@ static void Descendants(const TopoDS_Shape& S, } } } -//modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t diff --git a/src/BRepFeat/BRepFeat_MakeDPrism.cxx b/src/BRepFeat/BRepFeat_MakeDPrism.cxx index f83906aaa6..84f9ba1aaf 100644 --- a/src/BRepFeat/BRepFeat_MakeDPrism.cxx +++ b/src/BRepFeat/BRepFeat_MakeDPrism.cxx @@ -63,10 +63,6 @@ #include #include -//modified by NIZNHY-PKV Thu Mar 21 17:49:46 2002 f -//#include -//#include -//modified by NIZNHY-PKV Thu Mar 21 17:50:04 2002 t #ifdef OCCT_DEBUG extern Standard_Boolean BRepFeat_GettraceFEAT(); #endif @@ -258,25 +254,15 @@ void BRepFeat_MakeDPrism::Perform(const Standard_Real Height) // if there is no gluing -> call topological operations if(!myJustGluer) { if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 17:32:17 2002 f - //BRepAlgo_Fuse f(mySbase, myGShape); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, myGShape); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:32:23 2002 t Done(); } else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 17:32:57 2002 f - //BRepAlgo_Cut c(mySbase, myGShape); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, myGShape); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:33:00 2002 t Done(); } else { @@ -372,35 +358,21 @@ void BRepFeat_MakeDPrism::Perform(const TopoDS_Shape& Until) TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) bB.Add(Comp,S); - //modified by NIZNHY-PKV Thu Mar 21 17:33:27 2002 - //BRepAlgo_Cut trP(VraiDPrism,Comp); - //UpdateDescendants(trP.Builder(),trP.Shape(), Standard_False); BRepAlgoAPI_Cut trP(VraiDPrism,Comp); UpdateDescendants(trP, trP.Shape(), Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:33:32 2002 t TopExp_Explorer ex(trP.Shape(), TopAbs_SOLID); TopoDS_Shape Cutsh = ex.Current(); if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 17:34:09 2002 f - //BRepAlgo_Fuse f(mySbase, Cutsh); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, Cutsh); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:34:13 2002 t Done(); } else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 17:34:56 2002 f - //BRepAlgo_Cut c(mySbase, Cutsh); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, Cutsh); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:34:59 2002 t Done(); } else { @@ -570,32 +542,19 @@ void BRepFeat_MakeDPrism::Perform(const TopoDS_Shape& From, return; } - //modified by NIZNHY-PKV Thu Mar 21 17:35:48 2002 f - //BRepAlgo_Cut trP(VraiDPrism,Comp); BRepAlgoAPI_Cut trP(VraiDPrism,Comp); - //modified by NIZNHY-PKV Thu Mar 21 17:35:59 2002 t if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 17:36:06 2002 f - //BRepAlgo_Fuse f(mySbase, trP.Shape()); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, trP.Shape()); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:36:33 2002 t Done(); } // else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 17:37:16 2002 f - //BRepAlgo_Cut c(mySbase, trP.Shape()); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, trP.Shape()); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:37:49 2002 t Done(); } else { @@ -764,30 +723,17 @@ void BRepFeat_MakeDPrism::PerformFromEnd(const TopoDS_Shape& Until) return; } - //modified by NIZNHY-PKV Thu Mar 21 17:38:33 2002 f - //BRepAlgo_Cut trP(VraiDPrism,Comp); BRepAlgoAPI_Cut trP(VraiDPrism,Comp); - //modified by NIZNHY-PKV Thu Mar 21 17:38:37 2002 t if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 17:40:03 2002 f - //BRepAlgo_Fuse f(mySbase, trP.Shape()); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, trP.Shape()); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:40:07 2002 t Done(); } else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 17:40:33 2002 t - //BRepAlgo_Cut c(mySbase, trP.Shape()); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, trP.Shape()); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:40:44 2002 t Done(); } else { @@ -835,16 +781,10 @@ void BRepFeat_MakeDPrism::PerformThruAll() GeneratedShapeValid(); if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 17:46:16 2002 f - //BRepAlgo_Cut c(mySbase, myGShape); BRepAlgoAPI_Cut c(mySbase, myGShape); - //modified by NIZNHY-PKV Thu Mar 21 17:46:26 2002 t if (c.IsDone()) { myShape = c.Shape(); - //modified by NIZNHY-PKV Thu Mar 21 17:46:39 2002 f - //UpdateDescendants(c.Builder(), myShape, Standard_False); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:46:43 2002 t Done(); } } @@ -942,30 +882,17 @@ void BRepFeat_MakeDPrism::PerformUntilHeight(const TopoDS_Shape& Until, B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) B.Add(Comp,S); - //modified by NIZNHY-PKV Thu Mar 21 17:47:14 2002 f - //BRepAlgo_Cut trP(VraiDPrism,Comp); BRepAlgoAPI_Cut trP(VraiDPrism,Comp); - //modified by NIZNHY-PKV Thu Mar 21 17:47:21 2002 t if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 17:47:42 2002 f - //BRepAlgo_Fuse f(mySbase, trP.Shape()); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, trP.Shape()); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:47:49 2002 t Done(); } else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 17:48:18 2002 f - //BRepAlgo_Cut c(mySbase, trP.Shape()); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, trP.Shape()); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:48:26 2002 t Done(); } else { diff --git a/src/BRepFeat/BRepFeat_MakeLinearForm.cxx b/src/BRepFeat/BRepFeat_MakeLinearForm.cxx index 7b87354379..143cb58fe2 100644 --- a/src/BRepFeat/BRepFeat_MakeLinearForm.cxx +++ b/src/BRepFeat/BRepFeat_MakeLinearForm.cxx @@ -80,11 +80,6 @@ #include #include -//modified by NIZNHY-PKV Fri Mar 22 16:51:33 2002 f -//#include -//#include -//modified by NIZNHY-PKV Fri Mar 22 16:51:35 2002 t -//#include #ifdef OCCT_DEBUG extern Standard_Boolean BRepFeat_GettraceFEAT(); extern Standard_Boolean BRepFeat_GettraceFEATRIB(); @@ -227,10 +222,7 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, 6.*myBnd, -6.*myBnd, 6.*myBnd); TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape()); - //modified by NIZNHY-PKV Fri Mar 22 16:49:28 2002 f - //BRepAlgo_Common PlaneS(BndBox, PlaneFace); BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace); - //modified by NIZNHY-PKV Fri Mar 22 16:49:39 2002 t TopExp_Explorer EXP; TopoDS_Shape PlaneSect = PlaneS.Shape(); EXP.Init(PlaneSect, TopAbs_WIRE); @@ -945,10 +937,7 @@ void BRepFeat_MakeLinearForm::Perform() Standard_Boolean v1OK = Standard_False, v2OK= Standard_False; TopoDS_Vertex v1, v2, v3, v4, ve1, ve2; - //modified by NIZNHY-PKV Fri Mar 22 16:50:24 2002 f - //BRepAlgo_Section sect (fac, CurrentFace, Standard_False); BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False); - //modified by NIZNHY-PKV Fri Mar 22 16:50:32 2002 t sect.Approximation(Standard_True); sect.Build(); @@ -1069,10 +1058,7 @@ void BRepFeat_MakeLinearForm::Perform() } } - //modified by NIZNHY-PKV Fri Mar 22 16:50:53 2002 f - //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False); BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False); - //modified by NIZNHY-PKV Fri Mar 22 16:51:03 2002 t sectf.Approximation(Standard_True); sectf.Build(); diff --git a/src/BRepFeat/BRepFeat_MakePipe.cxx b/src/BRepFeat/BRepFeat_MakePipe.cxx index c69f9f3d5a..fb64ddac94 100644 --- a/src/BRepFeat/BRepFeat_MakePipe.cxx +++ b/src/BRepFeat/BRepFeat_MakePipe.cxx @@ -44,10 +44,6 @@ #include #include -//modified by NIZNHY-PKV Thu Mar 21 17:54:27 2002 f -//#include -//#include -//modified by NIZNHY-PKV Thu Mar 21 17:54:30 2002 t #ifdef OCCT_DEBUG extern Standard_Boolean BRepFeat_GettraceFEAT(); #endif @@ -200,25 +196,15 @@ void BRepFeat_MakePipe::Perform() if(myGluedF.IsEmpty()) { if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 17:53:05 2002 f - //BRepAlgo_Fuse f(mySbase, myGShape); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, myGShape); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:53:10 2002 t Done(); } else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 17:53:37 2002 f - //BRepAlgo_Cut c(mySbase, myGShape); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, myGShape); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:53:50 2002 t Done(); } else { diff --git a/src/BRepFeat/BRepFeat_MakeRevol.cxx b/src/BRepFeat/BRepFeat_MakeRevol.cxx index c171d8bc4c..da07f85deb 100644 --- a/src/BRepFeat/BRepFeat_MakeRevol.cxx +++ b/src/BRepFeat/BRepFeat_MakeRevol.cxx @@ -296,25 +296,15 @@ void BRepFeat_MakeRevol::Perform(const Standard_Real Angle) if(myGluedF.IsEmpty()) { if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 18:15:06 2002 f - //BRepAlgo_Fuse f(mySbase, myGShape); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, myGShape); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 18:15:11 2002 t Done(); } else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 18:15:37 2002 f - //BRepAlgo_Cut c(mySbase, myGShape); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, myGShape); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 18:15:47 2002 t Done(); } else { @@ -415,10 +405,7 @@ void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& Until) B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) B.Add(Comp,S); - //modified by NIZNHY-PKV Thu Mar 21 18:17:31 2002 f - //BRepAlgo_Cut trP(VraiRevol,Comp); BRepAlgoAPI_Cut trP(VraiRevol,Comp); - //modified by NIZNHY-PKV Thu Mar 21 18:17:37 2002 t TopoDS_Shape Cutsh = trP.Shape(); TopExp_Explorer ex(Cutsh, TopAbs_SOLID); for(; ex.More(); ex.Next()) { @@ -432,25 +419,15 @@ void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& Until) } } if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 18:17:53 2002 f - //BRepAlgo_Fuse f(mySbase, VraiRevol); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, VraiRevol); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 18:17:57 2002 t Done(); } else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 18:18:23 2002 f - //BRepAlgo_Cut c(mySbase, VraiRevol); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, VraiRevol); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 18:18:28 2002 t Done(); } else { @@ -459,41 +436,6 @@ void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& Until) } } } - // Loop of control of descendance - /* - TopExp_Explorer expr(mySbase, TopAbs_FACE); - char nom1[20], nom2[20]; - Standard_Integer ii = 0; - for(; expr.More(); expr.Next()) { - ii++; - sprintf(nom1, "faceinitial_%d", ii); - DBRep::Set(nom1, expr.Current()); - Standard_Integer jj = 0; - const TopTools_ListOfShape& list = Modified(expr.Current()); - TopTools_ListIteratorOfListOfShape ite(list); - for(; ite.More(); ite.Next()) { - jj++; - sprintf(nom2, "facemodifie_%d_%d", ii, jj); - DBRep::Set(nom2, ite.Value()); - } - } - - expr.Init(myPbase, TopAbs_EDGE); - ii=0; - for(; expr.More(); expr.Next()) { - ii++; - sprintf(nom1, "edgeinitial_%d", ii); - DBRep::Set(nom1, expr.Current()); - Standard_Integer jj = 0; - const TopTools_ListOfShape& list = Generated(expr.Current()); - TopTools_ListIteratorOfListOfShape ite(list); - for(; ite.More(); ite.Next()) { - jj++; - sprintf(nom2, "facegeneree_%d_%d", ii, jj); - DBRep::Set(nom2, ite.Value()); - } - } - */ } @@ -618,14 +560,9 @@ void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From, if (!SF.IsNull()) B.Add(Comp,SF); TopoDS_Solid SU = BRepFeat::Tool(mySUntil, FUntil, OrU); if (!SU.IsNull()) B.Add(Comp,SU); - //modified by NIZNHY-PKV Thu Mar 21 18:18:54 2002 f - //BRepAlgo_Cut trP(VraiRevol,Comp); BRepAlgoAPI_Cut trP(VraiRevol,Comp); - //modified by NIZNHY-PKV Thu Mar 21 18:18:57 2002 t TopoDS_Shape Cutsh = trP.Shape(); TopExp_Explorer ex(Cutsh, TopAbs_SOLID); - // Standard_Real PrF = BRepFeat::ParametricBarycenter(mySFrom, myBCurve); - // Standard_Real PrU = BRepFeat::ParametricBarycenter(mySUntil, myBCurve); VraiRevol = ex.Current(); for(; ex.More(); ex.Next()) { Standard_Real PrCur = BRepFeat:: @@ -636,25 +573,15 @@ void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From, } } if(myFuse == 1 && !myJustFeat) { - //modified by NIZNHY-PKV Thu Mar 21 18:19:14 2002 f - //BRepAlgo_Fuse f(mySbase, VraiRevol); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, VraiRevol); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 18:19:18 2002 t Done(); } else if(myFuse == 0 && !myJustFeat) { - //modified by NIZNHY-PKV Thu Mar 21 18:19:46 2002 f - //BRepAlgo_Cut c(mySbase, VraiRevol); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, VraiRevol); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 18:19:50 2002 t Done(); } else { @@ -759,10 +686,7 @@ void BRepFeat_MakeRevol::PerformUntilAngle(const TopoDS_Shape& Until, B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) B.Add(Comp,S); - //modified by NIZNHY-PKV Thu Mar 21 18:20:14 2002 f - //BRepAlgo_Cut trP(VraiRevol,Comp); BRepAlgoAPI_Cut trP(VraiRevol,Comp); - //modified by NIZNHY-PKV Thu Mar 21 18:20:19 2002 t TopoDS_Shape Cutsh = trP.Shape(); TopExp_Explorer ex(Cutsh, TopAbs_SOLID); for(; ex.More(); ex.Next()) { @@ -776,25 +700,15 @@ void BRepFeat_MakeRevol::PerformUntilAngle(const TopoDS_Shape& Until, } } if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 18:20:36 2002 f - //BRepAlgo_Fuse f(mySbase, VraiRevol); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); BRepAlgoAPI_Fuse f(mySbase, VraiRevol); myShape = f.Shape(); UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 18:20:40 2002 t Done(); } else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 18:21:07 2002 f - //BRepAlgo_Cut c(mySbase, VraiRevol); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); BRepAlgoAPI_Cut c(mySbase, VraiRevol); myShape = c.Shape(); UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 18:21:26 2002 t Done(); } else { @@ -855,10 +769,7 @@ static void VerifGluedFaces(const TopoDS_Face& theSkface, B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or); if (!S.IsNull()) B.Add(Comp,S); - //modified by NIZNHY-PKV Thu Mar 21 18:21:54 2002 f - //BRepAlgo_Cut trP(VraiRevol,Comp); BRepAlgoAPI_Cut trP(VraiRevol,Comp); - //modified by NIZNHY-PKV Thu Mar 21 18:21:58 2002 t TopoDS_Shape Cutsh = trP.Shape(); TopExp_Explorer ex(Cutsh, TopAbs_SOLID); for(; ex.More(); ex.Next()) { diff --git a/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx b/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx index 3ab743a636..7549555350 100644 --- a/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx +++ b/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx @@ -94,11 +94,6 @@ #include #include -//modified by NIZNHY-PKV Fri Mar 22 16:56:15 2002 -//#include -//#include -//#include -//modified by NIZNHY-PKV Fri Mar 22 16:56:17 2002 t #ifdef OCCT_DEBUG extern Standard_Boolean BRepFeat_GettraceFEAT(); extern Standard_Boolean BRepFeat_GettraceFEATRIB(); @@ -270,10 +265,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, 6.*myBnd, -6.*myBnd, 6.*myBnd); TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape()); - //modified by NIZNHY-PKV Fri Mar 22 16:52:26 2002 f - //BRepAlgo_Common PlaneS(BndBox, PlaneFace); BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace); - //modified by NIZNHY-PKV Fri Mar 22 16:52:31 2002 t TopExp_Explorer EXP; TopoDS_Shape PlaneSect = PlaneS.Shape(); EXP.Init(PlaneSect, TopAbs_WIRE); @@ -890,14 +882,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, ElSLib::Parameters(myPln->Pln(), CheckPnt, paru, parv); gp_Pnt2d checkpnt2d(paru, parv); if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) { - //modified by NIZNHY-PKV Fri Mar 22 16:52:52 2002 f - //BRepAlgo_Cut c(BndFace, NewBndFace); BRepAlgoAPI_Cut c(BndFace, NewBndFace); - //modified by NIZNHY-PKV Fri Mar 22 16:52:57 2002 t TopExp_Explorer exp(c.Shape(), TopAbs_WIRE); const TopoDS_Wire& aCurWire = TopoDS::Wire(exp.Current()); - // akm 13/02/02 : we know the plane. Why not to use it? - // BRepLib_MakeFace ff(w); BRepLib_MakeFace ff(myPln->Pln(), aCurWire, Standard_True); NewBndFace = TopoDS::Face(ff.Shape()); } @@ -1158,10 +1145,7 @@ void BRepFeat_MakeRevolutionForm::Perform() if (!S1.IsNull()) B.Add(Comp,S1); if (!S2.IsNull()) B.Add(Comp,S2); - //modified by NIZNHY-PKV Fri Mar 22 16:53:20 2002 f - //BRepAlgo_Cut trP(VraiForm,Comp); BRepAlgoAPI_Cut trP(VraiForm,Comp); - //modified by NIZNHY-PKV Fri Mar 22 16:53:23 2002 t // coupe de la nervure par deux plans parallels TopTools_DataMapOfShapeListOfShape SlidingMap; @@ -1287,10 +1271,7 @@ Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& Sl // BRepBuilderAPI_MakeFace fac(myPln); Standard_Boolean LastOK = Standard_False, FirstOK= Standard_False; TopoDS_Vertex v1, v2, v3, v4, Vert; - //modified by NIZNHY-PKV Fri Mar 22 16:54:09 2002 f - //BRepAlgo_Section sect (fac, CurrentFace, Standard_False); BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False); - //modified by NIZNHY-PKV Fri Mar 22 16:54:14 2002 t sect.Approximation(Standard_True); sect.Build(); TopExp_Explorer Ex; @@ -1312,7 +1293,6 @@ Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& Sl return Standard_False; } // - //modified by NIZNHY-PKV Tue Apr 2 15:08:23 2002 f if(!e1.IsNull()) { Standard_Real aTolV1, aTolV2; myListOfEdges.Clear(); @@ -1348,7 +1328,6 @@ Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& Sl myListOfEdges.Clear(); } } - //modified by NIZNHY-PKV Tue Apr 2 15:08:26 2002 t // if(!e1.IsNull()) { myListOfEdges.Clear(); @@ -1513,10 +1492,7 @@ Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& Sl } } - //modified by NIZNHY-PKV Fri Mar 22 16:54:28 2002 f - //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False); BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False); - //modified by NIZNHY-PKV Fri Mar 22 16:54:33 2002 t sectf.Approximation(Standard_True); sectf.Build(); @@ -1618,10 +1594,7 @@ Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& Sl ii = 0; - //modified by NIZNHY-PKV Fri Mar 22 16:54:45 2002 f - //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False); BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False); - //modified by NIZNHY-PKV Fri Mar 22 16:54:52 2002 t sectf.Approximation(Standard_True); sectf.Build(); diff --git a/src/BRepFeat/BRepFeat_RibSlot.cxx b/src/BRepFeat/BRepFeat_RibSlot.cxx index 006329e0d2..786e0f9608 100644 --- a/src/BRepFeat/BRepFeat_RibSlot.cxx +++ b/src/BRepFeat/BRepFeat_RibSlot.cxx @@ -81,10 +81,6 @@ #include #include -//modified by NIZNHY-PKV Fri Mar 22 16:48:13 2002 f -//#include -//#include -//modified by NIZNHY-PKV Fri Mar 22 16:48:16 2002 t #ifdef OCCT_DEBUG extern Standard_Boolean BRepFeat_GettraceFEAT(); extern Standard_Boolean BRepFeat_GettraceFEATRIB(); @@ -743,7 +739,7 @@ TopoDS_Face BRepFeat_RibSlot::ChoiceOfFaces(TopTools_ListOfShape& faces, if(!ASI.IsDone()) continue; for(Standard_Integer jj = 1; jj<=Counter; jj++) { if(ASI.NbPoints(jj) >= 1) { - Standard_Real app = ASI.Point(jj,1).Parameter();//modified by NIZNHY-PKV Fri Mar 22 17:05:23 2002 pp + Standard_Real app = ASI.Point(jj,1).Parameter(); if(app >= 0 && app < Par) { Par = app; FFF = f; @@ -875,7 +871,7 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, faces.Clear(); Map.Clear(); for(; ex4.More(); ex4.Next()) { - const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:04 2002 fx instead f + const TopoDS_Face& fx = TopoDS::Face(ex4.Current()); if ( !Map.Add(fx)) continue; ex5.Init(ex4.Current(), TopAbs_EDGE); for(; ex5.More(); ex5.Next()) { @@ -899,7 +895,7 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, faces.Clear(); Map.Clear(); for(; ex4.More(); ex4.Next()) { - const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f + const TopoDS_Face& fx = TopoDS::Face(ex4.Current()); if ( !Map.Add(fx)) continue; ex5.Init(ex4.Current(), TopAbs_VERTEX); for(; ex5.More(); ex5.Next()) { @@ -931,7 +927,7 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, faces.Clear(); Map.Clear(); for(; ex4.More(); ex4.Next()) { - const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f + const TopoDS_Face& fx = TopoDS::Face(ex4.Current()); if ( !Map.Add(fx)) continue; ex5.Init(ex4.Current(), TopAbs_EDGE); for(; ex5.More(); ex5.Next()) { @@ -956,7 +952,7 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, faces.Clear(); Map.Clear(); for(; ex4.More(); ex4.Next()) { - const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f + const TopoDS_Face& fx = TopoDS::Face(ex4.Current()); if ( !Map.Add(fx)) continue; ex5.Init(ex4.Current(), TopAbs_VERTEX); for(; ex5.More(); ex5.Next()) { @@ -1130,7 +1126,7 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, TopExp_Explorer ex2; ex2.Init(mySbase, TopAbs_FACE); for(; ex2.More(); ex2.Next()) { - TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:16:44 2002 fx/f + TopoDS_Face fx = TopoDS::Face(ex2.Current()); TopExp_Explorer ex3; ex3.Init(fx, TopAbs_EDGE); for(; ex3.More(); ex3.Next()) { @@ -1150,7 +1146,7 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, TopExp_Explorer ex2; ex2.Init(mySbase, TopAbs_FACE); for(; ex2.More(); ex2.Next()) { - TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:13:08 2002 fx/f + TopoDS_Face fx = TopoDS::Face(ex2.Current()); TopExp_Explorer ex3; ex3.Init(fx, TopAbs_VERTEX); for(; ex3.More(); ex3.Next()) { @@ -1183,7 +1179,7 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, TopExp_Explorer ex2; ex2.Init(mySbase, TopAbs_FACE); for(; ex2.More(); ex2.Next()) { - TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:12:06 2002 fx/f + TopoDS_Face fx = TopoDS::Face(ex2.Current()); TopExp_Explorer ex3; ex3.Init(fx, TopAbs_EDGE); for(; ex3.More(); ex3.Next()) { @@ -1203,7 +1199,7 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, TopExp_Explorer ex2; ex2.Init(mySbase, TopAbs_FACE); for(; ex2.More(); ex2.Next()) { - TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:11:36 2002 fx/f + TopoDS_Face fx = TopoDS::Face(ex2.Current()); TopExp_Explorer ex3; ex3.Init(fx, TopAbs_VERTEX); for(; ex3.More(); ex3.Next()) { @@ -1610,13 +1606,10 @@ Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, gp_Pnt2d checkpnt2d(u, v); if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) { // If face is not the correct part of BndFace take the complementary - //modified by NIZNHY-PKV Fri Mar 22 16:46:20 2002 f - //BRepAlgo_Cut c(BndFace, fac); BRepAlgoAPI_Cut c(BndFace, fac); - //modified by NIZNHY-PKV Fri Mar 22 16:46:23 2002 t TopExp_Explorer exp(c.Shape(), TopAbs_WIRE); const TopoDS_Wire& w = TopoDS::Wire(exp.Current()); - BRepLib_MakeFace ffx(w);//modified by NIZNHY-PKV Fri Mar 22 17:10:43 2002 ffx/ff + BRepLib_MakeFace ffx(w); Prof = TopoDS::Face(ffx.Shape()); } else { @@ -2299,16 +2292,10 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, ElSLib::Parameters(myPln->Pln(), CheckPnt, u, v); gp_Pnt2d checkpnt2d(u, v); if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) { - //modified by NIZNHY-PKV Fri Mar 22 16:47:06 2002 f - //BRepAlgo_Cut c(BndFace, fac); BRepAlgoAPI_Cut c(BndFace, fac); - //modified by NIZNHY-PKV Fri Mar 22 16:47:09 2002 t TopExp_Explorer exp(c.Shape(), TopAbs_WIRE); - //modified by NIZNHY-PKV Fri Mar 22 16:47:23 2002 f - //UpdateDescendants(c.Builder(), c.Shape(), Standard_False); UpdateDescendants(c, c.Shape(), Standard_False); - //modified by NIZNHY-PKV Fri Mar 22 16:47:28 2002 t - const TopoDS_Wire& ww = TopoDS::Wire(exp.Current());//modified by NIZNHY-PKV Fri Mar 22 17:10:16 2002 ww/w + const TopoDS_Wire& ww = TopoDS::Wire(exp.Current()); BRepLib_MakeFace ff(ww); Prof = TopoDS::Face(ff.Shape()); } @@ -2330,7 +2317,6 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, return ProfileOK; } -//modified by NIZNHY-PKV Thu Mar 21 18:43:18 2002 f //======================================================================= //function : UpdateDescendants //purpose : @@ -2387,4 +2373,3 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, } } } -//modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t diff --git a/src/BRepTest/BRepTest_FilletCommands.cxx b/src/BRepTest/BRepTest_FilletCommands.cxx index 8d6f15d612..1f4d76f424 100644 --- a/src/BRepTest/BRepTest_FilletCommands.cxx +++ b/src/BRepTest/BRepTest_FilletCommands.cxx @@ -20,9 +20,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -35,7 +32,6 @@ #include #include -//#include #include #include @@ -318,62 +314,6 @@ static Standard_Integer BUILDEVOL(Draw_Interpretor& di, -//********************************************** -// command fuse and cut with fillets * -//********************************************** - -Standard_Integer topoblend(Draw_Interpretor& di, Standard_Integer narg, const char** a) -{ - printtolblend(di); - if(narg != 5) return 1; - Standard_Boolean fuse = !strcmp(a[0],"fubl"); - TopoDS_Shape S1 = DBRep::Get(a[2]); - TopoDS_Shape S2 = DBRep::Get(a[3]); - Standard_Real Rad = Draw::Atof(a[4]); - BRepAlgo_BooleanOperation* BC; - if(fuse){ - BC = new BRepAlgo_Fuse(S1,S2); - } - else{ - BC = new BRepAlgo_Cut(S1,S2); - } - TopoDS_Shape ShapeCut = BC->Shape(); - - Handle(TopOpeBRepBuild_HBuilder) build = BC->Builder(); - TopTools_ListIteratorOfListOfShape its; - - TopoDS_Compound result; - BRep_Builder B; - B.MakeCompound(result); - - TopExp_Explorer ex; - for (ex.Init(ShapeCut,TopAbs_SOLID); ex.More(); ex.Next()) { - const TopoDS_Shape& cutsol = ex.Current(); - - BRepFilletAPI_MakeFillet fill(cutsol); - fill.SetParams(ta,t3d,t2d,t3d,t2d,fl); - fill.SetContinuity(blend_cont, tapp_angle); - its = build->Section(); - while (its.More()) { - TopoDS_Edge E = TopoDS::Edge(its.Value()); - fill.Add(Rad,E); - its.Next(); - } - - fill.Build(); - if(fill.IsDone()){ - B.Add(result,fill.Shape()); - } - else { - B.Add(result,cutsol); - } - } - - delete BC; - DBRep::Set(a[1],result); - return 0; -} - //********************************************** // bfuse or bcut and then blend the section //********************************************** @@ -789,14 +729,6 @@ void BRepTest::FilletCommands(Draw_Interpretor& theCommands) "buildevol end of the evol fillet computation",__FILE__, BUILDEVOL,g); - theCommands.Add("fubl", - "fubl result shape1 shape2 radius",__FILE__, - topoblend,g); - - theCommands.Add("cubl", - "cubl result shape tool radius",__FILE__, - topoblend,g); - theCommands.Add("bfuseblend", "bfuseblend result shape1 shape2 radius [-d]",__FILE__, boptopoblend,g); diff --git a/src/QABugs/QABugs_3.cxx b/src/QABugs/QABugs_3.cxx index 15c9c4445a..2bc76152f0 100644 --- a/src/QABugs/QABugs_3.cxx +++ b/src/QABugs/QABugs_3.cxx @@ -288,45 +288,6 @@ static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, co return 0; } -#include - -static Standard_Integer defNbPntMax = 30; -static Standard_Real defTol3d = 1.e-7; -static Standard_Real defTol2d = 1.e-7; -Standard_Integer NbPntMax = defNbPntMax; -Standard_Real Toler3d =defTol3d; -Standard_Real Toler2d = defTol2d; -// //== // ksection : operateur section appelant BRepAlgo_BooleanOperation -//== // ksection : operateur section appelant BRepAlgo_BooleanOperations -//======================================================================= -Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) { - if (n < 8) { - di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d" << "\n"; - return -1; - } - // a[1]= resultat - // a[2]= shell1 - // a[3]= shell2 - // a[4]= NbPntMax - // a[5]= Toler3d - // a[6]= Toler2d - TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL); - TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL); - if (s1.IsNull() || s2.IsNull()) return 1; - NbPntMax=Draw::Atoi(a[4]); - Toler3d=Draw::Atof(a[5]); - Toler2d=Draw::Atof(a[6]); - - di << "BRepAlgo_BooleanOperations myalgo\n"; - BRepAlgo_BooleanOperations myalgo; - - myalgo.Shapes(s1, s2); - myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d); - TopoDS_Shape res; res = myalgo.Section(); - DBRep::Set(a[1],res); - return 0; -} - #include #include @@ -471,6 +432,7 @@ switch (argc){ return 0; } +#include #include #include @@ -1719,10 +1681,6 @@ void QABugs::Commands_3(Draw_Interpretor& theCommands) { theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group); theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group); theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group); - theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d",__FILE__,ksection,group); - theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d",__FILE__,ksection,group); - theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d",__FILE__,ksection,group); - theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d",__FILE__,ksection,group); theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group); theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group); diff --git a/src/QANewBRepNaming/FILES b/src/QANewBRepNaming/FILES index 086949f486..ecbf894cf3 100644 --- a/src/QANewBRepNaming/FILES +++ b/src/QANewBRepNaming/FILES @@ -2,8 +2,6 @@ QANewBRepNaming.cxx QANewBRepNaming.hxx QANewBRepNaming_BooleanOperation.cxx QANewBRepNaming_BooleanOperation.hxx -QANewBRepNaming_BooleanOperationFeat.cxx -QANewBRepNaming_BooleanOperationFeat.hxx QANewBRepNaming_Box.cxx QANewBRepNaming_Box.hxx QANewBRepNaming_Chamfer.cxx diff --git a/src/QANewBRepNaming/QANewBRepNaming.hxx b/src/QANewBRepNaming/QANewBRepNaming.hxx index ac0742ce28..ce705dd450 100644 --- a/src/QANewBRepNaming/QANewBRepNaming.hxx +++ b/src/QANewBRepNaming/QANewBRepNaming.hxx @@ -36,7 +36,6 @@ class QANewBRepNaming_Revol; class QANewBRepNaming_Cylinder; class QANewBRepNaming_Sphere; class QANewBRepNaming_BooleanOperation; -class QANewBRepNaming_BooleanOperationFeat; class QANewBRepNaming_Common; class QANewBRepNaming_Cut; class QANewBRepNaming_Fuse; @@ -91,7 +90,6 @@ friend class QANewBRepNaming_Revol; friend class QANewBRepNaming_Cylinder; friend class QANewBRepNaming_Sphere; friend class QANewBRepNaming_BooleanOperation; -friend class QANewBRepNaming_BooleanOperationFeat; friend class QANewBRepNaming_Common; friend class QANewBRepNaming_Cut; friend class QANewBRepNaming_Fuse; diff --git a/src/QANewBRepNaming/QANewBRepNaming_BooleanOperation.cxx b/src/QANewBRepNaming/QANewBRepNaming_BooleanOperation.cxx index ed4480db07..69b08733c0 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_BooleanOperation.cxx +++ b/src/QANewBRepNaming/QANewBRepNaming_BooleanOperation.cxx @@ -1,5 +1,5 @@ -// Created on: 1999-11-11 -// Created by: Vladislav ROMASHKO +// Created on: 1999-09-27 +// Created by: Sergey ZARITCHNY // Copyright (c) 1999-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // @@ -15,134 +15,1603 @@ // commercial license or contractual agreement. -#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 #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include + +#ifdef OCCT_DEBUG +#include +#endif + +#ifdef OCCT_DEBUG +#include +#include +#include +#include +static void ModDbgTools_Write(const TopoDS_Shape& shape, + const Standard_CString filename) +{ + ofstream save; + save.open(filename); + save << "DBRep_DrawableShape" << endl << endl; + if(!shape.IsNull()) BRepTools::Write(shape, save); + save.close(); +} + +#endif //======================================================================= //function : QANewBRepNaming_BooleanOperation //purpose : //======================================================================= -QANewBRepNaming_BooleanOperation::QANewBRepNaming_BooleanOperation() -{} + +QANewBRepNaming_BooleanOperation::QANewBRepNaming_BooleanOperation() {} //======================================================================= //function : QANewBRepNaming_BooleanOperation //purpose : //======================================================================= -QANewBRepNaming_BooleanOperation::QANewBRepNaming_BooleanOperation(const TDF_Label& Label) - : QANewBRepNaming_TopNaming(Label) -{} +QANewBRepNaming_BooleanOperation::QANewBRepNaming_BooleanOperation(const TDF_Label& ResultLabel):QANewBRepNaming_TopNaming(ResultLabel) {} //======================================================================= //function : Init //purpose : //======================================================================= -void QANewBRepNaming_BooleanOperation::Init(const TDF_Label& Label) -{ - if(Label.IsNull()) +void QANewBRepNaming_BooleanOperation::Init(const TDF_Label& ResultLabel) { + if(ResultLabel.IsNull()) throw Standard_NullObject("QANewBRepNaming_BooleanOperation::Init The Result label is Null ..."); - myResultLabel = Label; + myResultLabel = ResultLabel; } //======================================================================= -//function : FirstModified +//function : ModifiedFaces //purpose : //======================================================================= -TDF_Label QANewBRepNaming_BooleanOperation::FirstModified() const -{ - return ResultLabel().FindChild(1, Standard_True); +TDF_Label QANewBRepNaming_BooleanOperation::ModifiedFaces() const { +#ifdef OCCT_DEBUG + const TDF_Label& ModifiedFacesLabel = ResultLabel().NewChild(); + TDataStd_Name::Set(ModifiedFacesLabel, "ModifiedFaces"); + return ModifiedFacesLabel; +#else + return ResultLabel().NewChild(); +#endif } //======================================================================= -//function : FirstDeleted +//function : ModifiedEdges //purpose : //======================================================================= -TDF_Label QANewBRepNaming_BooleanOperation::FirstDeleted() const -{ - return ResultLabel().FindChild(2, Standard_True); +TDF_Label QANewBRepNaming_BooleanOperation::ModifiedEdges() const { +#ifdef OCCT_DEBUG + const TDF_Label& ModifiedEdgesLabel = ResultLabel().NewChild(); + TDataStd_Name::Set(ModifiedEdgesLabel, "ModifiedEdges"); + return ModifiedEdgesLabel; +#else + return ResultLabel().NewChild(); +#endif } //======================================================================= -//function : SecondModified +//function : DeletedFaces //purpose : //======================================================================= -TDF_Label QANewBRepNaming_BooleanOperation::SecondModified() const -{ - return ResultLabel().FindChild(3, Standard_True); +TDF_Label QANewBRepNaming_BooleanOperation::DeletedFaces() const { +#ifdef OCCT_DEBUG + const TDF_Label& DeletedFacesLabel = ResultLabel().NewChild(); + TDataStd_Name::Set(DeletedFacesLabel, "DeletedFaces"); + return DeletedFacesLabel; +#else + return ResultLabel().NewChild(); +#endif } //======================================================================= -//function : SecondDeleted +//function : DeletedEdges //purpose : //======================================================================= -TDF_Label QANewBRepNaming_BooleanOperation::SecondDeleted() const -{ - return ResultLabel().FindChild(4, Standard_True); +TDF_Label QANewBRepNaming_BooleanOperation::DeletedEdges() const { +#ifdef OCCT_DEBUG + const TDF_Label& DeletedEdgesLabel = ResultLabel().NewChild(); + TDataStd_Name::Set(DeletedEdgesLabel, "DeletedEdges"); + return DeletedEdgesLabel; +#else + return ResultLabel().NewChild(); +#endif } //======================================================================= -//function : Intersections +//function : DeletedVertices //purpose : //======================================================================= -TDF_Label QANewBRepNaming_BooleanOperation::Intersections() const -{ - return ResultLabel().FindChild(5, Standard_True); +TDF_Label QANewBRepNaming_BooleanOperation::DeletedVertices() const { +#ifdef OCCT_DEBUG + const TDF_Label& DeletedVerticesLabel = ResultLabel().NewChild(); + TDataStd_Name::Set(DeletedVerticesLabel, "DeletedVertices"); + return DeletedVerticesLabel; +#else + return ResultLabel().NewChild(); +#endif } //======================================================================= -//function : Load (BooleanOperation) -//purpose : for a new part +//function : NewShapes +//purpose : +//======================================================================= + +TDF_Label QANewBRepNaming_BooleanOperation::NewShapes() const { +#ifdef OCCT_DEBUG + const TDF_Label& NewShapesLabel = ResultLabel().NewChild(); + TDataStd_Name::Set(NewShapesLabel, "NewShapes"); + return NewShapesLabel; +#else + return ResultLabel().NewChild(); +#endif +} + +//======================================================================= +//function : Content +//purpose : +//======================================================================= + +TDF_Label QANewBRepNaming_BooleanOperation::Content() const { +#ifdef OCCT_DEBUG + const TDF_Label& ContentLabel = ResultLabel().NewChild(); + TDataStd_Name::Set(ContentLabel, "Content"); + return ContentLabel; +#else + return ResultLabel().NewChild(); +#endif +} + +//======================================================================= +//function : DeletedDegeneratedEdges +//purpose : +//======================================================================= + +TDF_Label QANewBRepNaming_BooleanOperation::DeletedDegeneratedEdges() const { +#ifdef OCCT_DEBUG + const TDF_Label& DegeneratedLabel = ResultLabel().NewChild(); + TDataStd_Name::Set(DegeneratedLabel, "DeletedDegeneratedEdges"); + return DegeneratedLabel; +#else + return ResultLabel().NewChild(); +#endif +} + +//======================================================================= +//function : ShapeType +//purpose : +//======================================================================= + +TopAbs_ShapeEnum QANewBRepNaming_BooleanOperation::ShapeType(const TopoDS_Shape& theShape) { + TopAbs_ShapeEnum TypeSh = theShape.ShapeType(); + if (TypeSh == TopAbs_COMPOUND || TypeSh == TopAbs_COMPSOLID) { + TopoDS_Iterator itr(theShape); + if (!itr.More()) return TypeSh; + TypeSh = ShapeType(itr.Value()); + if(TypeSh == TopAbs_COMPOUND) return TypeSh; + itr.Next(); + for(; itr.More(); itr.Next()) + if(ShapeType(itr.Value()) != TypeSh) return TopAbs_COMPOUND; + } + return TypeSh; +} + +//======================================================================= +//function : GetShape +//purpose : +//======================================================================= + +TopoDS_Shape QANewBRepNaming_BooleanOperation::GetShape(const TopoDS_Shape& theShape) const { + if (theShape.ShapeType() == TopAbs_COMPOUND || theShape.ShapeType() == TopAbs_COMPSOLID) { + TopoDS_Iterator itr(theShape); + if (itr.More()) return itr.Value(); + } + return theShape; +} + +//======================================================================= +//function : LoadWire +//purpose : +//======================================================================= + +void QANewBRepNaming_BooleanOperation::LoadWire(BRepAlgoAPI_BooleanOperation& MS) const { + // Naming of modified edges: + TNaming_Builder ModBuilder(ModifiedEdges()); + QANewBRepNaming_Loader::LoadModifiedShapes (MS, MS.Shape1(), TopAbs_EDGE, ModBuilder); + + // load generated vertexes + if(MS.HasGenerated()) { + TNaming_Builder nBuilder (NewShapes()); + QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape1(), TopAbs_EDGE, nBuilder); + QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape2(), TopAbs_FACE, nBuilder); + } + // Naming of deleted edges, dangle vertices + if(MS.HasDeleted()){ + TNaming_Builder DelEBuilder(DeletedEdges()); + QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_EDGE, DelEBuilder); + TNaming_Builder DelVBuilder(DeletedVertices()); + QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_VERTEX, DelEBuilder); + } + } + +//======================================================================= +//function : LoadShell +//purpose : +//======================================================================= + +void QANewBRepNaming_BooleanOperation::LoadShell(BRepAlgoAPI_BooleanOperation& MS) const { +// Naming of modified faces and dangle edges + TNaming_Builder ModFBuilder(ModifiedFaces()); + QANewBRepNaming_Loader::LoadModifiedShapes(MS, MS.Shape1(), TopAbs_FACE, ModFBuilder); + TNaming_Builder ModEBuilder(ModifiedEdges()); + QANewBRepNaming_Loader::LoadModifiedShapes(MS, MS.Shape1(), TopAbs_EDGE, ModEBuilder); + + if(MS.HasGenerated()) { + TNaming_Builder nBuilder (NewShapes()); +// generated Edges + QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape2(), TopAbs_FACE, nBuilder); + QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape1(), TopAbs_FACE, nBuilder); + } + // Naming of deleted faces edges: + if(MS.HasDeleted()){ + TNaming_Builder DelFBuilder(DeletedFaces()); + QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_FACE, DelFBuilder); + + TNaming_Builder DelEBuilder(DeletedEdges()); + QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_EDGE, DelEBuilder); + } +} + +//======================================================================= +//function : LoadContent +//purpose : +//======================================================================= + +void QANewBRepNaming_BooleanOperation::LoadContent(BRepAlgoAPI_BooleanOperation& MS) const { + if (MS.Shape().ShapeType() == TopAbs_COMPSOLID || MS.Shape().ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator itr(MS.Shape()); + Standard_Integer nbShapes = 0; + while (itr.More()) { + nbShapes++; + itr.Next(); + } + if (nbShapes > 1) { + for (itr.Initialize(MS.Shape()); itr.More(); itr.Next()) { + TNaming_Builder bContent(Content()); + bContent.Generated(itr.Value()); + } + } + } +} + +//======================================================================= +//function : LoadResult +//purpose : //======================================================================= -//modified by NIZNHY-PKV Wed Jun 19 09:07:51 2002 f -void QANewBRepNaming_BooleanOperation::Load (BRepAlgo_BooleanOperation& MS) const -//void QANewBRepNaming_BooleanOperation::Load (BRepAlgoAPI_BooleanOperation& MS) const -//modified by NIZNHY-PKV Wed Jun 19 09:07:55 2002 t -{ - const TopoDS_Shape& S1 = MS.Shape1(); - const TopoDS_Shape& S2 = MS.Shape2(); +void QANewBRepNaming_BooleanOperation::LoadResult(BRepAlgoAPI_BooleanOperation& MS) const { + Handle(TDF_TagSource) Tagger = TDF_TagSource::Set(ResultLabel()); + if (Tagger.IsNull()) return; + Tagger->Set(0); TNaming_Builder Builder (ResultLabel()); - Builder.Modify (S1, MS.Shape()); - Builder.Modify (S2, MS.Shape()); + TopoDS_Shape aResult = MS.Shape(); + if (aResult.ShapeType() == TopAbs_COMPOUND) { + Standard_Integer nbSubResults = 0; + TopoDS_Iterator itr(aResult); + for (; itr.More(); itr.Next()) nbSubResults++; + if (nbSubResults == 1) { + itr.Initialize(aResult); + if (itr.More()) aResult = itr.Value(); + } + } + if (MS.Shape1().IsNull()) Builder.Generated(aResult); + else Builder.Modify(MS.Shape1(), aResult); +} + +//======================================================================= +//function : LoadDegenerated +//purpose : +//======================================================================= + +void QANewBRepNaming_BooleanOperation::LoadDegenerated(BRepAlgoAPI_BooleanOperation& MS) const { + TopTools_IndexedMapOfShape allEdges; + TopExp::MapShapes(MS.Shape1(), TopAbs_EDGE, allEdges); + Standard_Integer i = 1; + for (; i <= allEdges.Extent(); i++) { + if (BRep_Tool::Degenerated(TopoDS::Edge(allEdges.FindKey(i)))) { + if (MS.IsDeleted(allEdges.FindKey(i))) { + TNaming_Builder DegeneratedBuilder(DeletedDegeneratedEdges()); + DegeneratedBuilder.Generated(allEdges.FindKey(i)); +#ifdef OCCT_DEBUG + TDataStd_Name::Set(DegeneratedBuilder.NamedShape()->Label(), "DeletedDegenerated"); +#endif + } + } + } +} + +//======================================================================= +//function : IsResultChanged +//purpose : +//======================================================================= + +Standard_Boolean QANewBRepNaming_BooleanOperation::IsResultChanged(BRepAlgoAPI_BooleanOperation& MS) const { + TopoDS_Shape ResSh = MS.Shape(); + if (MS.Shape().ShapeType() == TopAbs_COMPOUND) { + Standard_Integer nbSubResults = 0; + TopoDS_Iterator itr(MS.Shape()); + for (; itr.More(); itr.Next()) nbSubResults++; + if (nbSubResults == 1) { + itr.Initialize(MS.Shape()); + if (itr.More()) ResSh = itr.Value(); + } + } + return MS.Shape1().IsSame(ResSh); +} +//======================================================================= +// Workaround for evolution 1:n +//======================================================================= +static Standard_Boolean IsValidSurfType(const TopoDS_Face& theFace) { + BRepAdaptor_Surface anAdapt(theFace); + Handle( Adaptor3d_HCurve ) aBasisCurve; + const GeomAbs_SurfaceType& aType = anAdapt.GetType(); + if(aType == GeomAbs_Cylinder || aType == GeomAbs_Cone) + return Standard_True; + else if(aType == GeomAbs_SurfaceOfRevolution){ + aBasisCurve = anAdapt.BasisCurve(); + if (aBasisCurve->GetType() == GeomAbs_Line) + return Standard_True; + } + else if(aType == GeomAbs_SurfaceOfExtrusion) { + aBasisCurve = anAdapt.BasisCurve(); + if (aBasisCurve->GetType() == GeomAbs_Circle || aBasisCurve->GetType() == GeomAbs_Ellipse) + return Standard_True; + } +#ifdef OCCT_DEBUG + ModDbgTools_Write(theFace, "Surf"); +#endif + return Standard_False; +} +//======================================================================= +//function : IsWRCase +//purpose : +//======================================================================= + +Standard_Boolean QANewBRepNaming_BooleanOperation::IsWRCase(const BRepAlgoAPI_BooleanOperation& MS) { + const TopoDS_Shape& ObjSh = MS.Shape1(); + const TopoDS_Shape& ToolSh = MS.Shape2(); + const TopAbs_ShapeEnum& Type1 = ShapeType(ObjSh); + if(Type1 == TopAbs_COMPOUND || Type1 > TopAbs_FACE) return Standard_False; + const TopAbs_ShapeEnum& Type2 = ShapeType(ToolSh); + if(Type2 == TopAbs_COMPOUND || Type2 > TopAbs_FACE) return Standard_False; + TopTools_ListOfShape aList; + - TopAbs_ShapeEnum SST1 = TopAbs_FACE; - TopAbs_ShapeEnum SST2 = TopAbs_FACE; + if(Type1 != TopAbs_FACE) { + TopExp_Explorer anExp(ObjSh, TopAbs_FACE); + for(;anExp.More();anExp.Next()) { + if(IsValidSurfType(TopoDS::Face(anExp.Current()))) + aList.Append(anExp.Current()); + } + } else + if(IsValidSurfType(TopoDS::Face(ObjSh))) + aList.Append(ObjSh); + if(aList.Extent() == 1) { + if(Type2 != TopAbs_FACE) { + TopExp_Explorer anExp(ToolSh, TopAbs_FACE); + for(;anExp.More();anExp.Next()) { + if(IsValidSurfType(TopoDS::Face(anExp.Current()))) + aList.Append(anExp.Current()); + } + } else + if(IsValidSurfType(TopoDS::Face(ToolSh))) + aList.Append(ToolSh); + if(aList.Extent() == 2) return Standard_True; + } + return Standard_False; +} + +//======================================================================= +static gp_Ax1 ComputeAxis(const TopoDS_Shape& theShape) { + TopoDS_Face aFace; + TopExp_Explorer anExp(theShape, TopAbs_FACE); + for(;anExp.More();anExp.Next()) { + aFace = TopoDS::Face(anExp.Current()); + BRepAdaptor_Surface anAdapt(aFace); + Handle( Adaptor3d_HCurve ) aBasisCurve; + const GeomAbs_SurfaceType& aType = anAdapt.GetType(); + if(aType == GeomAbs_Cylinder) + return anAdapt.Cylinder().Axis(); + else if(aType == GeomAbs_Cone) + return anAdapt.Cone().Axis(); + else if(aType == GeomAbs_SurfaceOfRevolution) + return anAdapt.AxeOfRevolution(); + else if(aType == GeomAbs_SurfaceOfExtrusion) { + aBasisCurve = anAdapt.BasisCurve(); + if (aBasisCurve->GetType() == GeomAbs_Circle) + return aBasisCurve->Circle().Axis(); + else if(aBasisCurve->GetType() == GeomAbs_Ellipse) + return aBasisCurve->Ellipse().Axis(); + } + } + return gp::OX(); +} +//============================================================================== +// +//========================================================================== +static Standard_Integer Identify(const TopoDS_Face& theFace, const gp_Ax1& theAx) { + GProp_GProps aGProp; + BRepGProp::SurfaceProperties(theFace, aGProp); + gp_Pnt aPoint = aGProp.CentreOfMass(); + gp_Vec aV1(theAx.Direction()); + gp_Vec aV2(theAx.Location(), aPoint); +#ifdef OCCT_DEBUG + gp_Vec v1 = aV1.Crossed(aV2); + cout <<" Z of V1 = " << v1.XYZ().Z() << endl; +#endif + if((aV1.Crossed(aV2)).XYZ().Z() >= 0) return 1; //right orientation + return (-1); //left orientation +} + +//======================================================================= +//function : LoadModified11 +//purpose : 1 : 1 +//======================================================================= + +void QANewBRepNaming_BooleanOperation::LoadModified11 (BRepAlgoAPI_BooleanOperation& MS, + const TopoDS_Shape& ShapeIn, + const TopAbs_ShapeEnum KindOfShape) const + +{ + TopTools_MapOfShape View; + Standard_Boolean found = Standard_False; + TopExp_Explorer ShapeExplorer (ShapeIn, KindOfShape); + for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { + const TopoDS_Shape& Root = ShapeExplorer.Current (); + if (!View.Add(Root)) continue; + const TopTools_ListOfShape& Shapes = MS.Modified (Root); + if(Shapes.Extent() == 1) {found = Standard_True; break;} + } + + if(found) { + View.Clear(); + ShapeExplorer.Init (ShapeIn, KindOfShape); + TNaming_Builder Builder(ModifiedFaces()); + for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { + const TopoDS_Shape& Root = ShapeExplorer.Current (); + if (!View.Add(Root)) continue; + const TopTools_ListOfShape& Shapes = MS.Modified (Root); + if(Shapes.Extent() > 1) continue; + TopTools_ListIteratorOfListOfShape ShapesIterator (Shapes); + for (;ShapesIterator.More (); ShapesIterator.Next ()) { + const TopoDS_Shape& newShape = ShapesIterator.Value (); + if (!Root.IsSame (newShape)) { + //put shapes with evolution 1:1 (may be Compound) +#ifdef OCCT_DEBUG + TCollection_AsciiString entry; + TDF_Tool::Entry(Builder.NamedShape()->Label(), entry); + cout << "Add shape to Compound at Label = "<< entry < i2 + i1=i; + } + theListOut.Append(ArS.Value(i1)); + theListOut.Append(ArS.Value(i2)); + theListOut.Append(ArS.Value(i3)); //single +} +//======================================================================= +//function : Load1nFaces +//purpose : +//======================================================================= + +void QANewBRepNaming_BooleanOperation::Load1nFaces(BRepAlgoAPI_BooleanOperation& MS, const TopoDS_Shape& ShapeIn) const +{ + + TopTools_MapOfShape View; + TopTools_ListOfShape aListR; + TopExp_Explorer ShapeExplorer (ShapeIn, TopAbs_FACE); + for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { + const TopoDS_Shape& Root = ShapeExplorer.Current (); + if (!View.Add(Root)) continue; + const TopTools_ListOfShape& Shapes = MS.Modified (Root); + if(Shapes.Extent() < 2) continue; + aListR.Append(Root); + } + if(ShapeIn.IsEqual(MS.Shape1())) + if(aListR.Extent() > 1) SortRootFaces(aListR, ShapeIn); + + TopTools_ListIteratorOfListOfShape Itr(aListR); + for(;Itr.More();Itr.Next()) { + const TopoDS_Shape& Root = Itr.Value(); + const TopTools_ListOfShape& Shapes = MS.Modified (Root); + TopTools_ListOfShape aList; + gp_Ax1 anAx = ComputeAxis(MS.Shape2()); + if(Shapes.Extent() == 2) + Sort2Faces(Shapes, anAx, aList); + else if(Shapes.Extent() == 3) + Sort3Faces(Shapes, aList); + TopTools_ListIteratorOfListOfShape It(aList); + for(;It.More();It.Next()) { + TNaming_Builder aBuilder(NewShapes()); +// aBuilder.Modify(Root,It.Value ()); + aBuilder.Generated(It.Value ()); + } + } +} + +//======================================================================= +//function : LoadModified faces +//purpose : 1 : n modification +//======================================================================= + +void QANewBRepNaming_BooleanOperation::LoadModified1n (BRepAlgoAPI_BooleanOperation& MS, + const TopoDS_Shape& ShapeIn, + const TopAbs_ShapeEnum KindOfShape) const + +{ +//fill modification 1:n + TopTools_MapOfShape View; + Standard_Integer aNum = 0; + TopExp_Explorer ShapeExplorer (ShapeIn, KindOfShape); + for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { + const TopoDS_Shape& Root = ShapeExplorer.Current (); + if (!View.Add(Root)) continue; + const TopTools_ListOfShape& Shapes = MS.Modified (Root); + if(Shapes.Extent() >= 2) aNum += Shapes.Extent(); + } - if (S1.ShapeType() == TopAbs_FACE || S1.ShapeType() == TopAbs_WIRE ) - SST1 = TopAbs_EDGE; + View.Clear(); + const TopoDS_Shape& Tool = MS.Shape2(); + ShapeExplorer.Init (Tool, KindOfShape); + for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { + const TopoDS_Shape& Root = ShapeExplorer.Current (); + if (!View.Add(Root)) continue; + const TopTools_ListOfShape& Shapes = MS.Modified (Root); + if(Shapes.Extent() >= 2) aNum += Shapes.Extent(); + } + + Handle(TDataStd_IntegerArray) aSAR; + if(!ResultLabel().FindAttribute(TDataStd_IntegerArray::GetID(), aSAR) ) { + //not find + aSAR = TDataStd_IntegerArray::Set(ResultLabel(), 1, 2); + aSAR->SetValue(1, 0); //tag num for faces structure + aSAR->SetValue(2, 0); //tag num for edges structure + } + + if(aSAR->Value(2)) { + Standard_Integer aNE =0; + TDF_Label aLab = ResultLabel().FindChild(aSAR->Value(2)); + Handle(TDataStd_Integer) anAtt; + if(aLab.FindAttribute(TDataStd_Integer::GetID(), anAtt) ) + aNE = anAtt->Get(); + TDF_Label aFLab = ResultLabel().FindChild(aLab.Tag() + aNE); + if(!aFLab.FindAttribute(TDataStd_Integer::GetID(), anAtt)) + aSAR->SetValue(1, 0); + } + TDF_Label aLabelFDS; + if(aSAR->Value(1)) + aLabelFDS = ResultLabel().FindChild(aSAR->Value(1)); // !=0 -already exist + else { + // initial creation of FDS structure + Handle(TDF_TagSource) aTS; + ResultLabel().FindAttribute (TDF_TagSource::GetID (), aTS); + aLabelFDS = NewShapes(); +// aLabelFDS = ResultLabel().FindChild(aSAR->Value(1)); + aSAR->SetValue(1, aLabelFDS.Tag()); //keep tag + aTS->Set(aLabelFDS.Tag()-1); + } + Handle(TDataStd_Integer) anAtt; + if(aLabelFDS.FindAttribute(TDataStd_Integer::GetID(), anAtt) ) { + // modification : check compatibility + if(anAtt->Get() != aNum) { + cout << "WARNING: Case isn't mantained - Number of Faces was changed!"<Get(); + for(Standard_Integer i=aLabelFDS.Tag(); i < aN; i++) { + TDF_Label aLab = ResultLabel().FindChild(i, Standard_False); + if(!aLab.IsNull()) { + Handle(TNaming_NamedShape) aNS; + if(aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + TopoDS_Shape aShape = aNS->Get(); + TNaming_Builder aBuilder(aLab); + aBuilder.Delete(aShape); //Deleted + } + } + } +// + Handle(TDF_TagSource) aTS; + ResultLabel().FindAttribute (TDF_TagSource::GetID (), aTS); + if(!aTS.IsNull()) + aTS->Set(aLabelFDS.Tag()); + anAtt->Set(aNum); + } + } else + TDataStd_Integer::Set(aLabelFDS, aNum); //keep number of faces + + Load1nFaces(MS, ShapeIn); + Load1nFaces(MS, Tool); +} + + +//====================================================================== +static Standard_Boolean IsDirectionPositive (const gp_Ax1& theAx, const gp_Pnt thePnt1, + const gp_Pnt thePnt2) { + Standard_Boolean isPositive; + gp_Vec aVec1(theAx.Direction()); + gp_Vec aVec2(thePnt1, thePnt2); +#ifdef OCCT_DEBUG +// gp_Vec v1 = aVec1.Crossed(aVec2); +// cout <<" Z of V1 = " << v1.XYZ().Z() << endl; +#endif + if((aVec1.Crossed(aVec2)).XYZ().Z() >= 0) isPositive = Standard_True; + else + isPositive = Standard_False; + return isPositive; +} +//====================================================================== +// i => ArS[i] : ArP[i] ; i = ArI[j] +//====================================================================== +static void SortEdges2(const TColgp_Array1OfPnt& theArP, const gp_Ax1& theAx, + TColStd_Array1OfInteger& theArI) +{ + gp_Pnt aPnt = theAx.Location(); + //sort : the nearest point must be first + Standard_Real aD1 = aPnt.Distance(theArP.Value(1)); + Standard_Real aD2 = aPnt.Distance(theArP.Value(2)); + if(aD1 < aD2) { + theArI.SetValue(1, 1); + theArI.SetValue(2, 2); + } else { + theArI.SetValue(1, 2); //change order + theArI.SetValue(2, 1); + } +} +//====================================================================== +// i => ArS[i] : ArP[i] ; i = ArI[j] +//====================================================================== +static void SortEdges3(const TopTools_Array1OfShape& theArS, const TColgp_Array1OfPnt& theArP, + const gp_Ax1& theAx, TColStd_Array1OfInteger& theArI) +{ + Standard_Integer i, j, i1 = 0,i2 = 0, i3 = 0; + TopoDS_Shape aV; + Standard_Boolean adjacent = Standard_False; + for(i=1;i<=3;i++) { + for(j=1;j<=3;j++) { + if(i==j) continue; + const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i))); + const TopoDS_Shape& aV21 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(j))); + const TopoDS_Shape& aV22 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(j))); + if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) {adjacent = Standard_True;aV = aV11;} + else { + const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i))); + if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) {adjacent = Standard_True;aV = aV12;} + } + if(adjacent) { + Standard_Integer aSum = i+j; + switch(aSum) { + case 3: //12 + i1 = 3;i2 = 1;i3 = 2; + break; + case 4: //13 + i1 = 2; i2 = 1;i3 = 3; + break; + case 5: //23 + i1 = 1; i2 = 2;i3 = 3; + } + break; + } + } + if(adjacent) break; + } + gp_Pnt aPnt = theAx.Location(); +// i1 - index of single edge + Standard_Real aD1 = aPnt.Distance(theArP.Value(i1)); + Standard_Real aD2 = aPnt.Distance(theArP.Value(i2)); + if(aD1 > aD2) { //cyclic shift + Standard_Integer aN = i3;// i1 => i3 - to the end + i3 = i1; i1 = aN; + // pair of adjacent i1, i2 + gp_Pnt aCP = BRep_Tool::Pnt(TopoDS::Vertex(aV)); + if(!IsDirectionPositive(theAx, aCP, theArP.Value(i1))) {//first must be positive direction + // change i1 <=>i2 + aN = i2; i2 = i1; + i1 = aN; + } + } else { + // pair of adjacent i2, i3 + gp_Pnt aCP = BRep_Tool::Pnt(TopoDS::Vertex(aV)); + if(!IsDirectionPositive(theAx, aCP, theArP.Value(i2))) {//first must be positive direction + // change i2 <=>i3 + Standard_Integer aN = i3; i3 = i2; + i2 = aN; + } + } +// order i1, i2, i3 + theArI.SetValue(1, i1); + theArI.SetValue(2, i2); + theArI.SetValue(3, i3); +} + +//====================================================================== +// i => ArS[i] : ArP[i] ; i = ArI[j] +//====================================================================== +static void SortEdges4(const TopTools_Array1OfShape& theArS, const TColgp_Array1OfPnt& theArP, + const gp_Ax1& theAx, TColStd_Array1OfInteger& theArI) +{ +// 1. find adjacent edges, build pairs in ArI +// 2. find nearest pair, reorganize ArI +// 3. sort inside pairs +// ======================================= + Standard_Integer i, j, i1 = 0,i2 = 0, i3 = 0, i4 = 0; +// 1. + TopoDS_Shape aV1; + for(i=1;i<=4;i++) { + const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i))); + const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i))); + Standard_Boolean aDjacent = Standard_False; + for(j=1;j<=4;j++) { + if(i==j) continue; + const TopoDS_Shape& aV21 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(j))); + const TopoDS_Shape& aV22 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(j))); + aDjacent = Standard_False; + if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) {aDjacent = Standard_True;aV1 = aV11;} + else + if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) {aDjacent = Standard_True;aV1 = aV12;} + if(aDjacent) { + aDjacent = Standard_True; + Standard_Integer aSum = i+j; + i1 = i; i2 = j; + switch(aSum) { + case 3: //12 + i3 = 3; i4 = 4; + break; + case 4: //13 + i3 = 2; i4 = 4; + break; + case 5: //14 + i3 = 2; i4 = 3; + break; + } + break; + } + } + if(aDjacent) break; + } +// i1,i2 - first pair of adjacent: aV1. +// i3,i4 - next pair of adjacent: aV2. +// find agjacent V (i3-i4) + TopoDS_Shape aV2; + const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i3))); + const TopoDS_Shape& aV21 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i4))); + const TopoDS_Shape& aV22 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i4))); + if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) aV2 = aV11; + else { + const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i3))); + if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) aV2 = aV12; + } + +// 2. find nearest pair + gp_Pnt aCP1 = BRep_Tool::Pnt(TopoDS::Vertex(aV1)); + gp_Pnt aCP2 = BRep_Tool::Pnt(TopoDS::Vertex(aV2)); + gp_Pnt aPnt = theAx.Location(); + Standard_Real aD1 = aPnt.Distance(aCP1);//i1-i2 + Standard_Real aD2 = aPnt.Distance(aCP2);//i3-i4 + if(aD1 > aD2) { //change order of pairs + Standard_Integer a3 = i3;// i1,i2 => i3,i4 - to the end + Standard_Integer a4 = i4; + i3 = i1; i4 = i2; + i1 = a3; i2 = a4; + gp_Pnt aP = aCP2; + aCP2 = aCP1; + aCP1 = aP; + // pair of adjacent i1-i2 is the nearest + } + +// 3. sort inside pairs + if(!IsDirectionPositive(theAx, aCP1, theArP.Value(i1))) {//first must be positive direction + // change i1 <=> i2 + Standard_Integer aN = i2; i2 = i1; + i1 = aN; + } + + if(!IsDirectionPositive(theAx, aCP2, theArP.Value(i3))) {//first must be positive direction + // change i3 <=> i4 +#ifdef OCCT_DEBUG + cout << "SortEdges4: i3 = "<SetValue(1, 0); //tag num for faces structure + aSAR->SetValue(2, 0); //tag num for edges structure + } + TDF_Label aLabelEDS; + if(aSAR->Value(2)) aLabelEDS = ResultLabel().FindChild(aSAR->Value(2)); // !=0 + else { + // initial creation of EDS structure + aLabelEDS = NewShapes(); + aSAR->SetValue(2, aLabelEDS.Tag()); //keep tag + } + Handle(TDataStd_Integer) anAtt; + if(aLabelEDS.FindAttribute(TDataStd_Integer::GetID(), anAtt) ) { + // modification : check compatibility + if(anAtt->Get() != aNE1+aNE2) { + cout << "WARNING: Case isn't mantained - Number of Edges was changed!"<Get(); + for(Standard_Integer i=aLabelEDS.Tag(); i < aN; i++) { + TDF_Label aLab = ResultLabel().FindChild(i, Standard_False); + if(!aLab.IsNull()) { + Handle(TNaming_NamedShape) aNS; + if(aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + TopoDS_Shape aShape = aNS->Get(); + TNaming_Builder aBuilder(aLab); + aBuilder.Delete(aShape); //Deleted + } + } + } +// + Handle(TDF_TagSource) aTS; + ResultLabel().FindAttribute (TDF_TagSource::GetID (), aTS); + if(!aTS.IsNull()) + aTS->Set(aLabelEDS.Tag()); + anAtt->Set(aNE1+aNE2); + } + + } else + TDataStd_Integer::Set(aLabelEDS, aNE1+aNE2); //keep number of edges - // load the intersection edges - TNaming_Builder Builder5(Intersections()); - Handle(TopOpeBRepBuild_HBuilder) build = MS.Builder(); - TopTools_ListIteratorOfListOfShape its = build->Section(); - for (; its.More(); its.Next()) { - Builder5.Select(its.Value(),its.Value()); - } +// Identification +// if(aNE1% 2 > 0) return; + gp_Ax1 anAx = ComputeAxis(MS.Shape2()); + Handle(TDF_TagSource) aTS; + ResultLabel().FindAttribute (TDF_TagSource::GetID (), aTS); + if(!aNE2 && aNE1) { // only 1 ent. +//Top || Bot ? + TopTools_Array1OfShape ArS1(1, aNE1); + SortEdges(aListE1, anAx, ArS1); + for(Standard_Integer i=1; i <= aNE1; i++) { + TopoDS_Shape aShape = ArS1.Value(i); + Standard_Integer aLabTag = aLabelEDS.Tag() + i -1; + TDF_Label aLab = ResultLabel().FindChild(aLabTag); + aTS->Set(aLabTag); + TNaming_Builder aBuilder(aLab); + aBuilder.Generated(aShape); + } + } else if(aNE1 && aNE2) { //2 ent. + TopTools_Array1OfShape ArS1(1, aNE1); + SortEdges(aListE1, anAx, ArS1); + TopTools_Array1OfShape ArS2(1, aNE2); + SortEdges(aListE2, anAx, ArS2); + + gp_Pnt aPnt1 = GetCenterPoint(aListE1.First()); +// gp_Pnt aPnt2 = GetCenterPoint(aListE2.First()); + if(IsDirectionPositive(anAx, anAx.Location(), aPnt1)) { + Standard_Integer i; + for(i=1; i <= aNE1; i++) { + TopoDS_Shape aShape = ArS1.Value(i); + Standard_Integer aLabTag = aLabelEDS.Tag() + i - 1; + TDF_Label aLab = ResultLabel().FindChild(aLabTag); + aTS->Set(aLabTag); + TNaming_Builder aBuilder(aLab); + aBuilder.Generated(aShape); + } + Standard_Integer start = aLabelEDS.Tag() + aNE1; + for(i=1; i <= aNE2; i++) { + TopoDS_Shape aShape = ArS2.Value(i); + Standard_Integer aLabTag = start + i - 1; + TDF_Label aLab = ResultLabel().FindChild(aLabTag); + aTS->Set(aLabTag); + TNaming_Builder aBuilder(aLab); + aBuilder.Generated(aShape); + } + } + else { + Standard_Integer i; + for(i=1; i <= aNE2; i++) { + TopoDS_Shape aShape = ArS2.Value(i); + Standard_Integer aLabTag = aLabelEDS.Tag() + i - 1; + TDF_Label aLab = ResultLabel().FindChild(aLabTag); + aTS->Set(aLabTag); + TNaming_Builder aBuilder(aLab); + aBuilder.Generated(aShape); + } + Standard_Integer start = aLabelEDS.Tag() + aNE2; + for(i=1; i <= aNE1; i++) { + TopoDS_Shape aShape = ArS1.Value(i); + Standard_Integer aLabTag = start + i - 1; + TDF_Label aLab = ResultLabel().FindChild(aLabTag); + aTS->Set(aLabTag); + TNaming_Builder aBuilder(aLab); + aBuilder.Generated(aShape); + } + } + } +} + +//======================================================================= +//function : ISWRCase2 +//purpose : +//======================================================================= +Standard_Boolean QANewBRepNaming_BooleanOperation::IsWRCase2(BRepAlgoAPI_BooleanOperation& MS) { + const TopoDS_Shape& Result = MS.Shape(); + const TopAbs_ShapeEnum& ResType = ShapeType(Result); + if(ResType == TopAbs_COMPOUND || ResType >= TopAbs_FACE) return Standard_False; + + TopExp_Explorer anExp(Result, TopAbs_FACE); + for(;anExp.More();anExp.Next()) { + if(IsValidSurfType(TopoDS::Face(anExp.Current()))) { + TopExp_Explorer anExp1(Result, TopAbs_FACE); + for(;anExp1.More();anExp1.Next()) { + if(!anExp1.Current().IsSame(anExp.Current()) && !IsValidSurfType(TopoDS::Face(anExp1.Current()))) { + TopTools_ListOfShape aList; + aList.Append(anExp.Current()); + aList.Append(anExp1.Current()); + TopTools_ListOfShape anEList; + FindAdjacent2(aList, anEList); + if(anEList.Extent() == 2) { + return Standard_True; + } + } + } + } + } + return Standard_False; +} + +//======================================================================= +//function : LoadWRCase +//purpose : +//======================================================================= + +void QANewBRepNaming_BooleanOperation::LoadWRCase(BRepAlgoAPI_BooleanOperation& MS) const { + const TopoDS_Shape& Result = MS.Shape(); + const TopAbs_ShapeEnum& ResType = ShapeType(Result); + if(ResType == TopAbs_COMPOUND || ResType >= TopAbs_FACE) return; + + TopExp_Explorer anExp(Result, TopAbs_FACE); + for(;anExp.More();anExp.Next()) { + if(IsValidSurfType(TopoDS::Face(anExp.Current()))) { + TopExp_Explorer anExp1(Result, TopAbs_FACE); + for(;anExp1.More();anExp1.Next()) { + if(!anExp1.Current().IsSame(anExp.Current()) && !IsValidSurfType(TopoDS::Face(anExp1.Current()))) { + TopTools_ListOfShape aList; + aList.Append(anExp.Current()); + aList.Append(anExp1.Current()); + TopTools_ListOfShape anEList; + FindAdjacent2(aList, anEList); + if(anEList.Extent() == 2) { + + TopTools_ListIteratorOfListOfShape anEIt(anEList); + GProp_GProps anE1Props, anE2Props; + BRepGProp::LinearProperties(anEList.First(), anE1Props); + BRepGProp::LinearProperties(anEList.Last(), anE2Props); + + const TDF_Label& WRE1Label = ResultLabel().NewChild(); + const TDF_Label& WRE2Label = ResultLabel().NewChild(); + const TDF_Label& WRV1Label = ResultLabel().NewChild(); + const TDF_Label& WRV2Label = ResultLabel().NewChild(); +#ifdef OCCT_DEBUG + TDataStd_Name::Set(WRE1Label, "WorkAroundEdge1"); + TDataStd_Name::Set(WRE2Label, "WorkAroundEdge2"); + TDataStd_Name::Set(WRV1Label, "WorkAroundVertex1"); + TDataStd_Name::Set(WRV2Label, "WorkAroundVertex2"); +#endif + + TNaming_Builder anEBuilder1(WRE1Label); + TNaming_Builder anEBuilder2(WRE2Label); + TNaming_Builder aVBuilder1(WRV1Label); + TNaming_Builder aVBuilder2(WRV2Label); + + if(anE1Props.Mass() > anE2Props.Mass()) { + anEBuilder1.Generated(anEList.Last()); + anEBuilder2.Generated(anEList.First()); + aVBuilder1.Generated(TopExp::FirstVertex(TopoDS::Edge(anEList.Last()))); + aVBuilder2.Generated(TopExp::LastVertex(TopoDS::Edge(anEList.Last()))); + } else { + anEBuilder1.Generated(anEList.First()); + anEBuilder2.Generated(anEList.Last()); + aVBuilder1.Generated(TopExp::FirstVertex(TopoDS::Edge(anEList.First()))); + aVBuilder2.Generated(TopExp::LastVertex(TopoDS::Edge(anEList.First()))); + } + } + } + } + } + } } diff --git a/src/QANewBRepNaming/QANewBRepNaming_BooleanOperation.hxx b/src/QANewBRepNaming/QANewBRepNaming_BooleanOperation.hxx index ed360c1fbf..2c1d70cbac 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_BooleanOperation.hxx +++ b/src/QANewBRepNaming/QANewBRepNaming_BooleanOperation.hxx @@ -1,6 +1,6 @@ -// Created on: 1999-11-11 -// Created by: Vladislav ROMASHKO -// Copyright (c) 1999 Matra Datavision +// Created on: 1999-09-27 +// Created by: Open CASCADE Support +// Copyright (c) 1999-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. @@ -22,8 +22,11 @@ #include #include +#include +#include class TDF_Label; -class BRepAlgo_BooleanOperation; +class BRepAlgoAPI_BooleanOperation; +class TopoDS_Shape; //! To load the BooleanOperation results @@ -34,46 +37,94 @@ public: DEFINE_STANDARD_ALLOC - Standard_EXPORT QANewBRepNaming_BooleanOperation(); + Standard_EXPORT void Init (const TDF_Label& ResultLabel); - Standard_EXPORT QANewBRepNaming_BooleanOperation(const TDF_Label& ResultLabel); + //! Returns the label to insert modified faces of an Object. + Standard_EXPORT TDF_Label ModifiedFaces() const; - Standard_EXPORT void Init (const TDF_Label& ResultLabel); + //! Returns the label to insert modified edges of an Object. + Standard_EXPORT TDF_Label ModifiedEdges() const; + + //! Returns the label to insert deleted faces of an Object. + Standard_EXPORT TDF_Label DeletedFaces() const; + + //! Returns the label to insert deleted edges of an Object. + Standard_EXPORT TDF_Label DeletedEdges() const; - //! Load the boolean operation. - //! Makes a new part attached to the ResultLabel. - Standard_EXPORT void Load (BRepAlgo_BooleanOperation& mkBoolOp) const; + //! Returns the label to insert deleted vertices of an Object. + Standard_EXPORT TDF_Label DeletedVertices() const; - //! Returns the label of the modified faces - //! of the first shape (S1). - Standard_EXPORT TDF_Label FirstModified() const; + //! Returns the label to insert added shapes to an Object + //! (given from tool). + Standard_EXPORT TDF_Label NewShapes() const; - //! Returns the label of the deleted faces - //! of the first shape (S1). - Standard_EXPORT TDF_Label FirstDeleted() const; + Standard_EXPORT TDF_Label Content() const; - //! Returns the label of the modified faces - //! of the second shape (S2). - Standard_EXPORT TDF_Label SecondModified() const; + Standard_EXPORT TDF_Label DeletedDegeneratedEdges() const; - //! Returns the label of the deleted faces - //! of the second shape (S2). - Standard_EXPORT TDF_Label SecondDeleted() const; + //! Returns true if the result is not the same as the object shape. + Standard_EXPORT Standard_Boolean IsResultChanged (BRepAlgoAPI_BooleanOperation& MakeShape) const; - //! Returns the label of intersections - Standard_EXPORT TDF_Label Intersections() const; + //! If the shape is a compound the method + //! returns the underlying shape type. + Standard_EXPORT static TopAbs_ShapeEnum ShapeType (const TopoDS_Shape& theShape); + + //! Returns true if workaround case identified + Standard_EXPORT static Standard_Boolean IsWRCase (const BRepAlgoAPI_BooleanOperation& theMS); + + //! Returns true if workaround case identified + Standard_EXPORT static Standard_Boolean IsWRCase2 (BRepAlgoAPI_BooleanOperation& MS); protected: + + Standard_EXPORT QANewBRepNaming_BooleanOperation(); + + Standard_EXPORT QANewBRepNaming_BooleanOperation(const TDF_Label& ResultLabel); + + //! If the shape is a compound the method + //! returns the underlying shape. + Standard_EXPORT TopoDS_Shape GetShape (const TopoDS_Shape& theShape) const; + + //! A default implementation for naming of a wire as an object of + //! a boolean operation. + Standard_EXPORT void LoadWire (BRepAlgoAPI_BooleanOperation& MakeShape) const; + + //! A default implementation for naming of a shell as an object of + //! a boolean operation. + Standard_EXPORT void LoadShell (BRepAlgoAPI_BooleanOperation& MakeShape) const; + + //! Loads the content of the result. + Standard_EXPORT void LoadContent (BRepAlgoAPI_BooleanOperation& MakeShape) const; + + //! Loads the result. + Standard_EXPORT void LoadResult (BRepAlgoAPI_BooleanOperation& MakeShape) const; + + //! Loads the deletion of the degenerated edges. + Standard_EXPORT void LoadDegenerated (BRepAlgoAPI_BooleanOperation& MakeShape) const; + + //! To process special cases with evolution 1 to n + Standard_EXPORT void LoadModified1n (BRepAlgoAPI_BooleanOperation& theMS, const TopoDS_Shape& theShapeIn, const TopAbs_ShapeEnum theKindOfShape) const; + + //! To process special cases with evolution 1 to 1 + Standard_EXPORT void LoadModified11 (BRepAlgoAPI_BooleanOperation& theMS, const TopoDS_Shape& theShapeIn, const TopAbs_ShapeEnum theKindOfShape) const; + + //! To process special case when result has symmetrical edges + Standard_EXPORT void LoadSymmetricalEdges (BRepAlgoAPI_BooleanOperation& theMS) const; + + Standard_EXPORT void LoadWRCase (BRepAlgoAPI_BooleanOperation& theMS) const; private: + + //! used inside LoadModified1n + Standard_EXPORT void Load1nFaces (BRepAlgoAPI_BooleanOperation& theMS, const TopoDS_Shape& theShapeIn) const; diff --git a/src/QANewBRepNaming/QANewBRepNaming_BooleanOperationFeat.cxx b/src/QANewBRepNaming/QANewBRepNaming_BooleanOperationFeat.cxx deleted file mode 100644 index 35553b009e..0000000000 --- a/src/QANewBRepNaming/QANewBRepNaming_BooleanOperationFeat.cxx +++ /dev/null @@ -1,1617 +0,0 @@ -// Created on: 1999-09-27 -// Created by: Sergey ZARITCHNY -// Copyright (c) 1999-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef OCCT_DEBUG -#include -#endif - -#ifdef OCCT_DEBUG -#include -#include -#include -#include -static void ModDbgTools_Write(const TopoDS_Shape& shape, - const Standard_CString filename) -{ - ofstream save; - save.open(filename); - save << "DBRep_DrawableShape" << endl << endl; - if(!shape.IsNull()) BRepTools::Write(shape, save); - save.close(); -} - -#endif - -//======================================================================= -//function : QANewBRepNaming_BooleanOperationFeat -//purpose : -//======================================================================= - -QANewBRepNaming_BooleanOperationFeat::QANewBRepNaming_BooleanOperationFeat() {} - -//======================================================================= -//function : QANewBRepNaming_BooleanOperationFeat -//purpose : -//======================================================================= - -QANewBRepNaming_BooleanOperationFeat::QANewBRepNaming_BooleanOperationFeat(const TDF_Label& ResultLabel):QANewBRepNaming_TopNaming(ResultLabel) {} - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::Init(const TDF_Label& ResultLabel) { - if(ResultLabel.IsNull()) - throw Standard_NullObject("QANewBRepNaming_BooleanOperationFeat::Init The Result label is Null ..."); - myResultLabel = ResultLabel; -} - -//======================================================================= -//function : ModifiedFaces -//purpose : -//======================================================================= - -TDF_Label QANewBRepNaming_BooleanOperationFeat::ModifiedFaces() const { -#ifdef OCCT_DEBUG - const TDF_Label& ModifiedFacesLabel = ResultLabel().NewChild(); - TDataStd_Name::Set(ModifiedFacesLabel, "ModifiedFaces"); - return ModifiedFacesLabel; -#else - return ResultLabel().NewChild(); -#endif -} - -//======================================================================= -//function : ModifiedEdges -//purpose : -//======================================================================= - -TDF_Label QANewBRepNaming_BooleanOperationFeat::ModifiedEdges() const { -#ifdef OCCT_DEBUG - const TDF_Label& ModifiedEdgesLabel = ResultLabel().NewChild(); - TDataStd_Name::Set(ModifiedEdgesLabel, "ModifiedEdges"); - return ModifiedEdgesLabel; -#else - return ResultLabel().NewChild(); -#endif -} - -//======================================================================= -//function : DeletedFaces -//purpose : -//======================================================================= - -TDF_Label QANewBRepNaming_BooleanOperationFeat::DeletedFaces() const { -#ifdef OCCT_DEBUG - const TDF_Label& DeletedFacesLabel = ResultLabel().NewChild(); - TDataStd_Name::Set(DeletedFacesLabel, "DeletedFaces"); - return DeletedFacesLabel; -#else - return ResultLabel().NewChild(); -#endif -} - -//======================================================================= -//function : DeletedEdges -//purpose : -//======================================================================= - -TDF_Label QANewBRepNaming_BooleanOperationFeat::DeletedEdges() const { -#ifdef OCCT_DEBUG - const TDF_Label& DeletedEdgesLabel = ResultLabel().NewChild(); - TDataStd_Name::Set(DeletedEdgesLabel, "DeletedEdges"); - return DeletedEdgesLabel; -#else - return ResultLabel().NewChild(); -#endif -} - -//======================================================================= -//function : DeletedVertices -//purpose : -//======================================================================= - -TDF_Label QANewBRepNaming_BooleanOperationFeat::DeletedVertices() const { -#ifdef OCCT_DEBUG - const TDF_Label& DeletedVerticesLabel = ResultLabel().NewChild(); - TDataStd_Name::Set(DeletedVerticesLabel, "DeletedVertices"); - return DeletedVerticesLabel; -#else - return ResultLabel().NewChild(); -#endif -} - -//======================================================================= -//function : NewShapes -//purpose : -//======================================================================= - -TDF_Label QANewBRepNaming_BooleanOperationFeat::NewShapes() const { -#ifdef OCCT_DEBUG - const TDF_Label& NewShapesLabel = ResultLabel().NewChild(); - TDataStd_Name::Set(NewShapesLabel, "NewShapes"); - return NewShapesLabel; -#else - return ResultLabel().NewChild(); -#endif -} - -//======================================================================= -//function : Content -//purpose : -//======================================================================= - -TDF_Label QANewBRepNaming_BooleanOperationFeat::Content() const { -#ifdef OCCT_DEBUG - const TDF_Label& ContentLabel = ResultLabel().NewChild(); - TDataStd_Name::Set(ContentLabel, "Content"); - return ContentLabel; -#else - return ResultLabel().NewChild(); -#endif -} - -//======================================================================= -//function : DeletedDegeneratedEdges -//purpose : -//======================================================================= - -TDF_Label QANewBRepNaming_BooleanOperationFeat::DeletedDegeneratedEdges() const { -#ifdef OCCT_DEBUG - const TDF_Label& DegeneratedLabel = ResultLabel().NewChild(); - TDataStd_Name::Set(DegeneratedLabel, "DeletedDegeneratedEdges"); - return DegeneratedLabel; -#else - return ResultLabel().NewChild(); -#endif -} - -//======================================================================= -//function : ShapeType -//purpose : -//======================================================================= - -TopAbs_ShapeEnum QANewBRepNaming_BooleanOperationFeat::ShapeType(const TopoDS_Shape& theShape) { - TopAbs_ShapeEnum TypeSh = theShape.ShapeType(); - if (TypeSh == TopAbs_COMPOUND || TypeSh == TopAbs_COMPSOLID) { - TopoDS_Iterator itr(theShape); - if (!itr.More()) return TypeSh; - TypeSh = ShapeType(itr.Value()); - if(TypeSh == TopAbs_COMPOUND) return TypeSh; - itr.Next(); - for(; itr.More(); itr.Next()) - if(ShapeType(itr.Value()) != TypeSh) return TopAbs_COMPOUND; - } - return TypeSh; -} - -//======================================================================= -//function : GetShape -//purpose : -//======================================================================= - -TopoDS_Shape QANewBRepNaming_BooleanOperationFeat::GetShape(const TopoDS_Shape& theShape) const { - if (theShape.ShapeType() == TopAbs_COMPOUND || theShape.ShapeType() == TopAbs_COMPSOLID) { - TopoDS_Iterator itr(theShape); - if (itr.More()) return itr.Value(); - } - return theShape; -} - -//======================================================================= -//function : LoadWire -//purpose : -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::LoadWire(BRepAlgoAPI_BooleanOperation& MS) const { - // Naming of modified edges: - TNaming_Builder ModBuilder(ModifiedEdges()); - QANewBRepNaming_Loader::LoadModifiedShapes (MS, MS.Shape1(), TopAbs_EDGE, ModBuilder); - - // load generated vertexes - if(MS.HasGenerated()) { - TNaming_Builder nBuilder (NewShapes()); - QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape1(), TopAbs_EDGE, nBuilder); - QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape2(), TopAbs_FACE, nBuilder); - } - // Naming of deleted edges, dangle vertices - if(MS.HasDeleted()){ - TNaming_Builder DelEBuilder(DeletedEdges()); - QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_EDGE, DelEBuilder); - TNaming_Builder DelVBuilder(DeletedVertices()); - QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_VERTEX, DelEBuilder); - } - } - -//======================================================================= -//function : LoadShell -//purpose : -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::LoadShell(BRepAlgoAPI_BooleanOperation& MS) const { -// Naming of modified faces and dangle edges - TNaming_Builder ModFBuilder(ModifiedFaces()); - QANewBRepNaming_Loader::LoadModifiedShapes(MS, MS.Shape1(), TopAbs_FACE, ModFBuilder); - TNaming_Builder ModEBuilder(ModifiedEdges()); - QANewBRepNaming_Loader::LoadModifiedShapes(MS, MS.Shape1(), TopAbs_EDGE, ModEBuilder); - - if(MS.HasGenerated()) { - TNaming_Builder nBuilder (NewShapes()); -// generated Edges - QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape2(), TopAbs_FACE, nBuilder); - QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape1(), TopAbs_FACE, nBuilder); - } - // Naming of deleted faces edges: - if(MS.HasDeleted()){ - TNaming_Builder DelFBuilder(DeletedFaces()); - QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_FACE, DelFBuilder); - - TNaming_Builder DelEBuilder(DeletedEdges()); - QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_EDGE, DelEBuilder); - } -} - -//======================================================================= -//function : LoadContent -//purpose : -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::LoadContent(BRepAlgoAPI_BooleanOperation& MS) const { - if (MS.Shape().ShapeType() == TopAbs_COMPSOLID || MS.Shape().ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator itr(MS.Shape()); - Standard_Integer nbShapes = 0; - while (itr.More()) { - nbShapes++; - itr.Next(); - } - if (nbShapes > 1) { - for (itr.Initialize(MS.Shape()); itr.More(); itr.Next()) { - TNaming_Builder bContent(Content()); - bContent.Generated(itr.Value()); - } - } - } -} - -//======================================================================= -//function : LoadResult -//purpose : -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::LoadResult(BRepAlgoAPI_BooleanOperation& MS) const { - Handle(TDF_TagSource) Tagger = TDF_TagSource::Set(ResultLabel()); - if (Tagger.IsNull()) return; - Tagger->Set(0); - TNaming_Builder Builder (ResultLabel()); - TopoDS_Shape aResult = MS.Shape(); - if (aResult.ShapeType() == TopAbs_COMPOUND) { - Standard_Integer nbSubResults = 0; - TopoDS_Iterator itr(aResult); - for (; itr.More(); itr.Next()) nbSubResults++; - if (nbSubResults == 1) { - itr.Initialize(aResult); - if (itr.More()) aResult = itr.Value(); - } - } - if (MS.Shape1().IsNull()) Builder.Generated(aResult); - else Builder.Modify(MS.Shape1(), aResult); -} - -//======================================================================= -//function : LoadDegenerated -//purpose : -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::LoadDegenerated(BRepAlgoAPI_BooleanOperation& MS) const { - TopTools_IndexedMapOfShape allEdges; - TopExp::MapShapes(MS.Shape1(), TopAbs_EDGE, allEdges); - Standard_Integer i = 1; - for (; i <= allEdges.Extent(); i++) { - if (BRep_Tool::Degenerated(TopoDS::Edge(allEdges.FindKey(i)))) { - if (MS.IsDeleted(allEdges.FindKey(i))) { - TNaming_Builder DegeneratedBuilder(DeletedDegeneratedEdges()); - DegeneratedBuilder.Generated(allEdges.FindKey(i)); -#ifdef OCCT_DEBUG - TDataStd_Name::Set(DegeneratedBuilder.NamedShape()->Label(), "DeletedDegenerated"); -#endif - } - } - } -} - -//======================================================================= -//function : IsResultChanged -//purpose : -//======================================================================= - -Standard_Boolean QANewBRepNaming_BooleanOperationFeat::IsResultChanged(BRepAlgoAPI_BooleanOperation& MS) const { - TopoDS_Shape ResSh = MS.Shape(); - if (MS.Shape().ShapeType() == TopAbs_COMPOUND) { - Standard_Integer nbSubResults = 0; - TopoDS_Iterator itr(MS.Shape()); - for (; itr.More(); itr.Next()) nbSubResults++; - if (nbSubResults == 1) { - itr.Initialize(MS.Shape()); - if (itr.More()) ResSh = itr.Value(); - } - } - return MS.Shape1().IsSame(ResSh); -} -//======================================================================= -// Workaround for evolution 1:n -//======================================================================= -static Standard_Boolean IsValidSurfType(const TopoDS_Face& theFace) { - BRepAdaptor_Surface anAdapt(theFace); - Handle( Adaptor3d_HCurve ) aBasisCurve; - const GeomAbs_SurfaceType& aType = anAdapt.GetType(); - if(aType == GeomAbs_Cylinder || aType == GeomAbs_Cone) - return Standard_True; - else if(aType == GeomAbs_SurfaceOfRevolution){ - aBasisCurve = anAdapt.BasisCurve(); - if (aBasisCurve->GetType() == GeomAbs_Line) - return Standard_True; - } - else if(aType == GeomAbs_SurfaceOfExtrusion) { - aBasisCurve = anAdapt.BasisCurve(); - if (aBasisCurve->GetType() == GeomAbs_Circle || aBasisCurve->GetType() == GeomAbs_Ellipse) - return Standard_True; - } -#ifdef OCCT_DEBUG - ModDbgTools_Write(theFace, "Surf"); -#endif - return Standard_False; -} -//======================================================================= -//function : IsWRCase -//purpose : -//======================================================================= - -Standard_Boolean QANewBRepNaming_BooleanOperationFeat::IsWRCase(const BRepAlgoAPI_BooleanOperation& MS) { - const TopoDS_Shape& ObjSh = MS.Shape1(); - const TopoDS_Shape& ToolSh = MS.Shape2(); - const TopAbs_ShapeEnum& Type1 = ShapeType(ObjSh); - if(Type1 == TopAbs_COMPOUND || Type1 > TopAbs_FACE) return Standard_False; - const TopAbs_ShapeEnum& Type2 = ShapeType(ToolSh); - if(Type2 == TopAbs_COMPOUND || Type2 > TopAbs_FACE) return Standard_False; - TopTools_ListOfShape aList; - - - if(Type1 != TopAbs_FACE) { - TopExp_Explorer anExp(ObjSh, TopAbs_FACE); - for(;anExp.More();anExp.Next()) { - if(IsValidSurfType(TopoDS::Face(anExp.Current()))) - aList.Append(anExp.Current()); - } - } else - if(IsValidSurfType(TopoDS::Face(ObjSh))) - aList.Append(ObjSh); - if(aList.Extent() == 1) { - if(Type2 != TopAbs_FACE) { - TopExp_Explorer anExp(ToolSh, TopAbs_FACE); - for(;anExp.More();anExp.Next()) { - if(IsValidSurfType(TopoDS::Face(anExp.Current()))) - aList.Append(anExp.Current()); - } - } else - if(IsValidSurfType(TopoDS::Face(ToolSh))) - aList.Append(ToolSh); - if(aList.Extent() == 2) return Standard_True; - } - return Standard_False; -} - -//======================================================================= -static gp_Ax1 ComputeAxis(const TopoDS_Shape& theShape) { - TopoDS_Face aFace; - TopExp_Explorer anExp(theShape, TopAbs_FACE); - for(;anExp.More();anExp.Next()) { - aFace = TopoDS::Face(anExp.Current()); - BRepAdaptor_Surface anAdapt(aFace); - Handle( Adaptor3d_HCurve ) aBasisCurve; - const GeomAbs_SurfaceType& aType = anAdapt.GetType(); - if(aType == GeomAbs_Cylinder) - return anAdapt.Cylinder().Axis(); - else if(aType == GeomAbs_Cone) - return anAdapt.Cone().Axis(); - else if(aType == GeomAbs_SurfaceOfRevolution) - return anAdapt.AxeOfRevolution(); - else if(aType == GeomAbs_SurfaceOfExtrusion) { - aBasisCurve = anAdapt.BasisCurve(); - if (aBasisCurve->GetType() == GeomAbs_Circle) - return aBasisCurve->Circle().Axis(); - else if(aBasisCurve->GetType() == GeomAbs_Ellipse) - return aBasisCurve->Ellipse().Axis(); - } - } - return gp::OX(); -} -//============================================================================== -// -//========================================================================== -static Standard_Integer Identify(const TopoDS_Face& theFace, const gp_Ax1& theAx) { - GProp_GProps aGProp; - BRepGProp::SurfaceProperties(theFace, aGProp); - gp_Pnt aPoint = aGProp.CentreOfMass(); - gp_Vec aV1(theAx.Direction()); - gp_Vec aV2(theAx.Location(), aPoint); -#ifdef OCCT_DEBUG - gp_Vec v1 = aV1.Crossed(aV2); - cout <<" Z of V1 = " << v1.XYZ().Z() << endl; -#endif - if((aV1.Crossed(aV2)).XYZ().Z() >= 0) return 1; //right orientation - return (-1); //left orientation -} - -//======================================================================= -//function : LoadModified11 -//purpose : 1 : 1 -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::LoadModified11 (BRepAlgoAPI_BooleanOperation& MS, - const TopoDS_Shape& ShapeIn, - const TopAbs_ShapeEnum KindOfShape) const - -{ - TopTools_MapOfShape View; - Standard_Boolean found = Standard_False; - TopExp_Explorer ShapeExplorer (ShapeIn, KindOfShape); - for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { - const TopoDS_Shape& Root = ShapeExplorer.Current (); - if (!View.Add(Root)) continue; - const TopTools_ListOfShape& Shapes = MS.Modified (Root); - if(Shapes.Extent() == 1) {found = Standard_True; break;} - } - - if(found) { - View.Clear(); - ShapeExplorer.Init (ShapeIn, KindOfShape); - TNaming_Builder Builder(ModifiedFaces()); - for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { - const TopoDS_Shape& Root = ShapeExplorer.Current (); - if (!View.Add(Root)) continue; - const TopTools_ListOfShape& Shapes = MS.Modified (Root); - if(Shapes.Extent() > 1) continue; - TopTools_ListIteratorOfListOfShape ShapesIterator (Shapes); - for (;ShapesIterator.More (); ShapesIterator.Next ()) { - const TopoDS_Shape& newShape = ShapesIterator.Value (); - if (!Root.IsSame (newShape)) { - //put shapes with evolution 1:1 (may be Compound) -#ifdef OCCT_DEBUG - TCollection_AsciiString entry; - TDF_Tool::Entry(Builder.NamedShape()->Label(), entry); - cout << "Add shape to Compound at Label = "<< entry < i2 - i1=i; - } - theListOut.Append(ArS.Value(i1)); - theListOut.Append(ArS.Value(i2)); - theListOut.Append(ArS.Value(i3)); //single -} -//======================================================================= -//function : Load1nFaces -//purpose : -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::Load1nFaces(BRepAlgoAPI_BooleanOperation& MS, const TopoDS_Shape& ShapeIn) const -{ - - TopTools_MapOfShape View; - TopTools_ListOfShape aListR; - TopExp_Explorer ShapeExplorer (ShapeIn, TopAbs_FACE); - for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { - const TopoDS_Shape& Root = ShapeExplorer.Current (); - if (!View.Add(Root)) continue; - const TopTools_ListOfShape& Shapes = MS.Modified (Root); - if(Shapes.Extent() < 2) continue; - aListR.Append(Root); - } - if(ShapeIn.IsEqual(MS.Shape1())) - if(aListR.Extent() > 1) SortRootFaces(aListR, ShapeIn); - - TopTools_ListIteratorOfListOfShape Itr(aListR); - for(;Itr.More();Itr.Next()) { - const TopoDS_Shape& Root = Itr.Value(); - const TopTools_ListOfShape& Shapes = MS.Modified (Root); - TopTools_ListOfShape aList; - gp_Ax1 anAx = ComputeAxis(MS.Shape2()); - if(Shapes.Extent() == 2) - Sort2Faces(Shapes, anAx, aList); - else if(Shapes.Extent() == 3) - Sort3Faces(Shapes, aList); - TopTools_ListIteratorOfListOfShape It(aList); - for(;It.More();It.Next()) { - TNaming_Builder aBuilder(NewShapes()); -// aBuilder.Modify(Root,It.Value ()); - aBuilder.Generated(It.Value ()); - } - } -} - -//======================================================================= -//function : LoadModified faces -//purpose : 1 : n modification -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::LoadModified1n (BRepAlgoAPI_BooleanOperation& MS, - const TopoDS_Shape& ShapeIn, - const TopAbs_ShapeEnum KindOfShape) const - -{ -//fill modification 1:n - TopTools_MapOfShape View; - Standard_Integer aNum = 0; - TopExp_Explorer ShapeExplorer (ShapeIn, KindOfShape); - for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { - const TopoDS_Shape& Root = ShapeExplorer.Current (); - if (!View.Add(Root)) continue; - const TopTools_ListOfShape& Shapes = MS.Modified (Root); - if(Shapes.Extent() >= 2) aNum += Shapes.Extent(); - } - - View.Clear(); - const TopoDS_Shape& Tool = MS.Shape2(); - ShapeExplorer.Init (Tool, KindOfShape); - for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { - const TopoDS_Shape& Root = ShapeExplorer.Current (); - if (!View.Add(Root)) continue; - const TopTools_ListOfShape& Shapes = MS.Modified (Root); - if(Shapes.Extent() >= 2) aNum += Shapes.Extent(); - } - - Handle(TDataStd_IntegerArray) aSAR; - if(!ResultLabel().FindAttribute(TDataStd_IntegerArray::GetID(), aSAR) ) { - //not find - aSAR = TDataStd_IntegerArray::Set(ResultLabel(), 1, 2); - aSAR->SetValue(1, 0); //tag num for faces structure - aSAR->SetValue(2, 0); //tag num for edges structure - } - - if(aSAR->Value(2)) { - Standard_Integer aNE =0; - TDF_Label aLab = ResultLabel().FindChild(aSAR->Value(2)); - Handle(TDataStd_Integer) anAtt; - if(aLab.FindAttribute(TDataStd_Integer::GetID(), anAtt) ) - aNE = anAtt->Get(); - TDF_Label aFLab = ResultLabel().FindChild(aLab.Tag() + aNE); - if(!aFLab.FindAttribute(TDataStd_Integer::GetID(), anAtt)) - aSAR->SetValue(1, 0); - } - TDF_Label aLabelFDS; - if(aSAR->Value(1)) - aLabelFDS = ResultLabel().FindChild(aSAR->Value(1)); // !=0 -already exist - else { - // initial creation of FDS structure - Handle(TDF_TagSource) aTS; - ResultLabel().FindAttribute (TDF_TagSource::GetID (), aTS); - aLabelFDS = NewShapes(); -// aLabelFDS = ResultLabel().FindChild(aSAR->Value(1)); - aSAR->SetValue(1, aLabelFDS.Tag()); //keep tag - aTS->Set(aLabelFDS.Tag()-1); - } - Handle(TDataStd_Integer) anAtt; - if(aLabelFDS.FindAttribute(TDataStd_Integer::GetID(), anAtt) ) { - // modification : check compatibility - if(anAtt->Get() != aNum) { - cout << "WARNING: Case isn't mantained - Number of Faces was changed!"<Get(); - for(Standard_Integer i=aLabelFDS.Tag(); i < aN; i++) { - TDF_Label aLab = ResultLabel().FindChild(i, Standard_False); - if(!aLab.IsNull()) { - Handle(TNaming_NamedShape) aNS; - if(aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - TopoDS_Shape aShape = aNS->Get(); - TNaming_Builder aBuilder(aLab); - aBuilder.Delete(aShape); //Deleted - } - } - } -// - Handle(TDF_TagSource) aTS; - ResultLabel().FindAttribute (TDF_TagSource::GetID (), aTS); - if(!aTS.IsNull()) - aTS->Set(aLabelFDS.Tag()); - anAtt->Set(aNum); - } - } else - TDataStd_Integer::Set(aLabelFDS, aNum); //keep number of faces - - Load1nFaces(MS, ShapeIn); - Load1nFaces(MS, Tool); -} - - -//====================================================================== -static Standard_Boolean IsDirectionPositive (const gp_Ax1& theAx, const gp_Pnt thePnt1, - const gp_Pnt thePnt2) { - Standard_Boolean isPositive; - gp_Vec aVec1(theAx.Direction()); - gp_Vec aVec2(thePnt1, thePnt2); -#ifdef OCCT_DEBUG -// gp_Vec v1 = aVec1.Crossed(aVec2); -// cout <<" Z of V1 = " << v1.XYZ().Z() << endl; -#endif - if((aVec1.Crossed(aVec2)).XYZ().Z() >= 0) isPositive = Standard_True; - else - isPositive = Standard_False; - return isPositive; -} -//====================================================================== -// i => ArS[i] : ArP[i] ; i = ArI[j] -//====================================================================== -static void SortEdges2(const TColgp_Array1OfPnt& theArP, const gp_Ax1& theAx, - TColStd_Array1OfInteger& theArI) -{ - gp_Pnt aPnt = theAx.Location(); - //sort : the nearest point must be first - Standard_Real aD1 = aPnt.Distance(theArP.Value(1)); - Standard_Real aD2 = aPnt.Distance(theArP.Value(2)); - if(aD1 < aD2) { - theArI.SetValue(1, 1); - theArI.SetValue(2, 2); - } else { - theArI.SetValue(1, 2); //change order - theArI.SetValue(2, 1); - } -} -//====================================================================== -// i => ArS[i] : ArP[i] ; i = ArI[j] -//====================================================================== -static void SortEdges3(const TopTools_Array1OfShape& theArS, const TColgp_Array1OfPnt& theArP, - const gp_Ax1& theAx, TColStd_Array1OfInteger& theArI) -{ - Standard_Integer i, j, i1 = 0,i2 = 0, i3 = 0; - TopoDS_Shape aV; - Standard_Boolean adjacent = Standard_False; - for(i=1;i<=3;i++) { - for(j=1;j<=3;j++) { - if(i==j) continue; - const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i))); - const TopoDS_Shape& aV21 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(j))); - const TopoDS_Shape& aV22 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(j))); - if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) {adjacent = Standard_True;aV = aV11;} - else { - const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i))); - if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) {adjacent = Standard_True;aV = aV12;} - } - if(adjacent) { - Standard_Integer aSum = i+j; - switch(aSum) { - case 3: //12 - i1 = 3;i2 = 1;i3 = 2; - break; - case 4: //13 - i1 = 2; i2 = 1;i3 = 3; - break; - case 5: //23 - i1 = 1; i2 = 2;i3 = 3; - } - break; - } - } - if(adjacent) break; - } - gp_Pnt aPnt = theAx.Location(); -// i1 - index of single edge - Standard_Real aD1 = aPnt.Distance(theArP.Value(i1)); - Standard_Real aD2 = aPnt.Distance(theArP.Value(i2)); - if(aD1 > aD2) { //cyclic shift - Standard_Integer aN = i3;// i1 => i3 - to the end - i3 = i1; i1 = aN; - // pair of adjacent i1, i2 - gp_Pnt aCP = BRep_Tool::Pnt(TopoDS::Vertex(aV)); - if(!IsDirectionPositive(theAx, aCP, theArP.Value(i1))) {//first must be positive direction - // change i1 <=>i2 - aN = i2; i2 = i1; - i1 = aN; - } - } else { - // pair of adjacent i2, i3 - gp_Pnt aCP = BRep_Tool::Pnt(TopoDS::Vertex(aV)); - if(!IsDirectionPositive(theAx, aCP, theArP.Value(i2))) {//first must be positive direction - // change i2 <=>i3 - Standard_Integer aN = i3; i3 = i2; - i2 = aN; - } - } -// order i1, i2, i3 - theArI.SetValue(1, i1); - theArI.SetValue(2, i2); - theArI.SetValue(3, i3); -} - -//====================================================================== -// i => ArS[i] : ArP[i] ; i = ArI[j] -//====================================================================== -static void SortEdges4(const TopTools_Array1OfShape& theArS, const TColgp_Array1OfPnt& theArP, - const gp_Ax1& theAx, TColStd_Array1OfInteger& theArI) -{ -// 1. find adjacent edges, build pairs in ArI -// 2. find nearest pair, reorganize ArI -// 3. sort inside pairs -// ======================================= - Standard_Integer i, j, i1 = 0,i2 = 0, i3 = 0, i4 = 0; -// 1. - TopoDS_Shape aV1; - for(i=1;i<=4;i++) { - const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i))); - const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i))); - Standard_Boolean aDjacent = Standard_False; - for(j=1;j<=4;j++) { - if(i==j) continue; - const TopoDS_Shape& aV21 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(j))); - const TopoDS_Shape& aV22 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(j))); - aDjacent = Standard_False; - if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) {aDjacent = Standard_True;aV1 = aV11;} - else - if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) {aDjacent = Standard_True;aV1 = aV12;} - if(aDjacent) { - aDjacent = Standard_True; - Standard_Integer aSum = i+j; - i1 = i; i2 = j; - switch(aSum) { - case 3: //12 - i3 = 3; i4 = 4; - break; - case 4: //13 - i3 = 2; i4 = 4; - break; - case 5: //14 - i3 = 2; i4 = 3; - break; - } - break; - } - } - if(aDjacent) break; - } -// i1,i2 - first pair of adjacent: aV1. -// i3,i4 - next pair of adjacent: aV2. -// find agjacent V (i3-i4) - TopoDS_Shape aV2; - const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i3))); - const TopoDS_Shape& aV21 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i4))); - const TopoDS_Shape& aV22 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i4))); - if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) aV2 = aV11; - else { - const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i3))); - if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) aV2 = aV12; - } - -// 2. find nearest pair - gp_Pnt aCP1 = BRep_Tool::Pnt(TopoDS::Vertex(aV1)); - gp_Pnt aCP2 = BRep_Tool::Pnt(TopoDS::Vertex(aV2)); - gp_Pnt aPnt = theAx.Location(); - Standard_Real aD1 = aPnt.Distance(aCP1);//i1-i2 - Standard_Real aD2 = aPnt.Distance(aCP2);//i3-i4 - if(aD1 > aD2) { //change order of pairs - Standard_Integer a3 = i3;// i1,i2 => i3,i4 - to the end - Standard_Integer a4 = i4; - i3 = i1; i4 = i2; - i1 = a3; i2 = a4; - gp_Pnt aP = aCP2; - aCP2 = aCP1; - aCP1 = aP; - // pair of adjacent i1-i2 is the nearest - } - -// 3. sort inside pairs - if(!IsDirectionPositive(theAx, aCP1, theArP.Value(i1))) {//first must be positive direction - // change i1 <=> i2 - Standard_Integer aN = i2; i2 = i1; - i1 = aN; - } - - if(!IsDirectionPositive(theAx, aCP2, theArP.Value(i3))) {//first must be positive direction - // change i3 <=> i4 -#ifdef OCCT_DEBUG - cout << "SortEdges4: i3 = "<SetValue(1, 0); //tag num for faces structure - aSAR->SetValue(2, 0); //tag num for edges structure - } - TDF_Label aLabelEDS; - if(aSAR->Value(2)) aLabelEDS = ResultLabel().FindChild(aSAR->Value(2)); // !=0 - else { - // initial creation of EDS structure - aLabelEDS = NewShapes(); - aSAR->SetValue(2, aLabelEDS.Tag()); //keep tag - } - Handle(TDataStd_Integer) anAtt; - if(aLabelEDS.FindAttribute(TDataStd_Integer::GetID(), anAtt) ) { - // modification : check compatibility - if(anAtt->Get() != aNE1+aNE2) { - cout << "WARNING: Case isn't mantained - Number of Edges was changed!"<Get(); - for(Standard_Integer i=aLabelEDS.Tag(); i < aN; i++) { - TDF_Label aLab = ResultLabel().FindChild(i, Standard_False); - if(!aLab.IsNull()) { - Handle(TNaming_NamedShape) aNS; - if(aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - TopoDS_Shape aShape = aNS->Get(); - TNaming_Builder aBuilder(aLab); - aBuilder.Delete(aShape); //Deleted - } - } - } -// - Handle(TDF_TagSource) aTS; - ResultLabel().FindAttribute (TDF_TagSource::GetID (), aTS); - if(!aTS.IsNull()) - aTS->Set(aLabelEDS.Tag()); - anAtt->Set(aNE1+aNE2); - } - - } else - TDataStd_Integer::Set(aLabelEDS, aNE1+aNE2); //keep number of edges - -// Identification -// if(aNE1% 2 > 0) return; - gp_Ax1 anAx = ComputeAxis(MS.Shape2()); - Handle(TDF_TagSource) aTS; - ResultLabel().FindAttribute (TDF_TagSource::GetID (), aTS); - if(!aNE2 && aNE1) { // only 1 ent. -//Top || Bot ? - TopTools_Array1OfShape ArS1(1, aNE1); - SortEdges(aListE1, anAx, ArS1); - for(Standard_Integer i=1; i <= aNE1; i++) { - TopoDS_Shape aShape = ArS1.Value(i); - Standard_Integer aLabTag = aLabelEDS.Tag() + i -1; - TDF_Label aLab = ResultLabel().FindChild(aLabTag); - aTS->Set(aLabTag); - TNaming_Builder aBuilder(aLab); - aBuilder.Generated(aShape); - } - } else if(aNE1 && aNE2) { //2 ent. - TopTools_Array1OfShape ArS1(1, aNE1); - SortEdges(aListE1, anAx, ArS1); - TopTools_Array1OfShape ArS2(1, aNE2); - SortEdges(aListE2, anAx, ArS2); - - gp_Pnt aPnt1 = GetCenterPoint(aListE1.First()); -// gp_Pnt aPnt2 = GetCenterPoint(aListE2.First()); - if(IsDirectionPositive(anAx, anAx.Location(), aPnt1)) { - Standard_Integer i; - for(i=1; i <= aNE1; i++) { - TopoDS_Shape aShape = ArS1.Value(i); - Standard_Integer aLabTag = aLabelEDS.Tag() + i - 1; - TDF_Label aLab = ResultLabel().FindChild(aLabTag); - aTS->Set(aLabTag); - TNaming_Builder aBuilder(aLab); - aBuilder.Generated(aShape); - } - Standard_Integer start = aLabelEDS.Tag() + aNE1; - for(i=1; i <= aNE2; i++) { - TopoDS_Shape aShape = ArS2.Value(i); - Standard_Integer aLabTag = start + i - 1; - TDF_Label aLab = ResultLabel().FindChild(aLabTag); - aTS->Set(aLabTag); - TNaming_Builder aBuilder(aLab); - aBuilder.Generated(aShape); - } - } - else { - Standard_Integer i; - for(i=1; i <= aNE2; i++) { - TopoDS_Shape aShape = ArS2.Value(i); - Standard_Integer aLabTag = aLabelEDS.Tag() + i - 1; - TDF_Label aLab = ResultLabel().FindChild(aLabTag); - aTS->Set(aLabTag); - TNaming_Builder aBuilder(aLab); - aBuilder.Generated(aShape); - } - Standard_Integer start = aLabelEDS.Tag() + aNE2; - for(i=1; i <= aNE1; i++) { - TopoDS_Shape aShape = ArS1.Value(i); - Standard_Integer aLabTag = start + i - 1; - TDF_Label aLab = ResultLabel().FindChild(aLabTag); - aTS->Set(aLabTag); - TNaming_Builder aBuilder(aLab); - aBuilder.Generated(aShape); - } - } - } -} - -//======================================================================= -//function : ISWRCase2 -//purpose : -//======================================================================= -Standard_Boolean QANewBRepNaming_BooleanOperationFeat::IsWRCase2(BRepAlgoAPI_BooleanOperation& MS) { - const TopoDS_Shape& Result = MS.Shape(); - const TopAbs_ShapeEnum& ResType = ShapeType(Result); - if(ResType == TopAbs_COMPOUND || ResType >= TopAbs_FACE) return Standard_False; - - TopExp_Explorer anExp(Result, TopAbs_FACE); - for(;anExp.More();anExp.Next()) { - if(IsValidSurfType(TopoDS::Face(anExp.Current()))) { - TopExp_Explorer anExp1(Result, TopAbs_FACE); - for(;anExp1.More();anExp1.Next()) { - if(!anExp1.Current().IsSame(anExp.Current()) && !IsValidSurfType(TopoDS::Face(anExp1.Current()))) { - TopTools_ListOfShape aList; - aList.Append(anExp.Current()); - aList.Append(anExp1.Current()); - TopTools_ListOfShape anEList; - FindAdjacent2(aList, anEList); - if(anEList.Extent() == 2) { - return Standard_True; - } - } - } - } - } - return Standard_False; -} - -//======================================================================= -//function : LoadWRCase -//purpose : -//======================================================================= - -void QANewBRepNaming_BooleanOperationFeat::LoadWRCase(BRepAlgoAPI_BooleanOperation& MS) const { - const TopoDS_Shape& Result = MS.Shape(); - const TopAbs_ShapeEnum& ResType = ShapeType(Result); - if(ResType == TopAbs_COMPOUND || ResType >= TopAbs_FACE) return; - - TopExp_Explorer anExp(Result, TopAbs_FACE); - for(;anExp.More();anExp.Next()) { - if(IsValidSurfType(TopoDS::Face(anExp.Current()))) { - TopExp_Explorer anExp1(Result, TopAbs_FACE); - for(;anExp1.More();anExp1.Next()) { - if(!anExp1.Current().IsSame(anExp.Current()) && !IsValidSurfType(TopoDS::Face(anExp1.Current()))) { - TopTools_ListOfShape aList; - aList.Append(anExp.Current()); - aList.Append(anExp1.Current()); - TopTools_ListOfShape anEList; - FindAdjacent2(aList, anEList); - if(anEList.Extent() == 2) { - - TopTools_ListIteratorOfListOfShape anEIt(anEList); - GProp_GProps anE1Props, anE2Props; - BRepGProp::LinearProperties(anEList.First(), anE1Props); - BRepGProp::LinearProperties(anEList.Last(), anE2Props); - - const TDF_Label& WRE1Label = ResultLabel().NewChild(); - const TDF_Label& WRE2Label = ResultLabel().NewChild(); - const TDF_Label& WRV1Label = ResultLabel().NewChild(); - const TDF_Label& WRV2Label = ResultLabel().NewChild(); -#ifdef OCCT_DEBUG - TDataStd_Name::Set(WRE1Label, "WorkAroundEdge1"); - TDataStd_Name::Set(WRE2Label, "WorkAroundEdge2"); - TDataStd_Name::Set(WRV1Label, "WorkAroundVertex1"); - TDataStd_Name::Set(WRV2Label, "WorkAroundVertex2"); -#endif - - TNaming_Builder anEBuilder1(WRE1Label); - TNaming_Builder anEBuilder2(WRE2Label); - TNaming_Builder aVBuilder1(WRV1Label); - TNaming_Builder aVBuilder2(WRV2Label); - - if(anE1Props.Mass() > anE2Props.Mass()) { - anEBuilder1.Generated(anEList.Last()); - anEBuilder2.Generated(anEList.First()); - aVBuilder1.Generated(TopExp::FirstVertex(TopoDS::Edge(anEList.Last()))); - aVBuilder2.Generated(TopExp::LastVertex(TopoDS::Edge(anEList.Last()))); - } else { - anEBuilder1.Generated(anEList.First()); - anEBuilder2.Generated(anEList.Last()); - aVBuilder1.Generated(TopExp::FirstVertex(TopoDS::Edge(anEList.First()))); - aVBuilder2.Generated(TopExp::LastVertex(TopoDS::Edge(anEList.First()))); - } - } - } - } - } - } -} diff --git a/src/QANewBRepNaming/QANewBRepNaming_BooleanOperationFeat.hxx b/src/QANewBRepNaming/QANewBRepNaming_BooleanOperationFeat.hxx deleted file mode 100644 index 114ea0c497..0000000000 --- a/src/QANewBRepNaming/QANewBRepNaming_BooleanOperationFeat.hxx +++ /dev/null @@ -1,140 +0,0 @@ -// Created on: 1999-09-27 -// Created by: Open CASCADE Support -// Copyright (c) 1999-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _QANewBRepNaming_BooleanOperationFeat_HeaderFile -#define _QANewBRepNaming_BooleanOperationFeat_HeaderFile - -#include -#include -#include - -#include -#include -#include -class TDF_Label; -class BRepAlgoAPI_BooleanOperation; -class TopoDS_Shape; - - -//! To load the BooleanOperationFeat results -class QANewBRepNaming_BooleanOperationFeat : public QANewBRepNaming_TopNaming -{ -public: - - DEFINE_STANDARD_ALLOC - - - Standard_EXPORT void Init (const TDF_Label& ResultLabel); - - //! Returns the label to insert modified faces of an Object. - Standard_EXPORT TDF_Label ModifiedFaces() const; - - //! Returns the label to insert modified edges of an Object. - Standard_EXPORT TDF_Label ModifiedEdges() const; - - //! Returns the label to insert deleted faces of an Object. - Standard_EXPORT TDF_Label DeletedFaces() const; - - //! Returns the label to insert deleted edges of an Object. - Standard_EXPORT TDF_Label DeletedEdges() const; - - //! Returns the label to insert deleted vertices of an Object. - Standard_EXPORT TDF_Label DeletedVertices() const; - - //! Returns the label to insert added shapes to an Object - //! (given from tool). - Standard_EXPORT TDF_Label NewShapes() const; - - Standard_EXPORT TDF_Label Content() const; - - Standard_EXPORT TDF_Label DeletedDegeneratedEdges() const; - - //! Returns true if the result is not the same as the object shape. - Standard_EXPORT Standard_Boolean IsResultChanged (BRepAlgoAPI_BooleanOperation& MakeShape) const; - - //! If the shape is a compound the method - //! returns the underlying shape type. - Standard_EXPORT static TopAbs_ShapeEnum ShapeType (const TopoDS_Shape& theShape); - - //! Returns true if workaround case identified - Standard_EXPORT static Standard_Boolean IsWRCase (const BRepAlgoAPI_BooleanOperation& theMS); - - //! Returns true if workaround case identified - Standard_EXPORT static Standard_Boolean IsWRCase2 (BRepAlgoAPI_BooleanOperation& MS); - - - - -protected: - - - Standard_EXPORT QANewBRepNaming_BooleanOperationFeat(); - - Standard_EXPORT QANewBRepNaming_BooleanOperationFeat(const TDF_Label& ResultLabel); - - //! If the shape is a compound the method - //! returns the underlying shape. - Standard_EXPORT TopoDS_Shape GetShape (const TopoDS_Shape& theShape) const; - - //! A default implementation for naming of a wire as an object of - //! a boolean operation. - Standard_EXPORT void LoadWire (BRepAlgoAPI_BooleanOperation& MakeShape) const; - - //! A default implementation for naming of a shell as an object of - //! a boolean operation. - Standard_EXPORT void LoadShell (BRepAlgoAPI_BooleanOperation& MakeShape) const; - - //! Loads the content of the result. - Standard_EXPORT void LoadContent (BRepAlgoAPI_BooleanOperation& MakeShape) const; - - //! Loads the result. - Standard_EXPORT void LoadResult (BRepAlgoAPI_BooleanOperation& MakeShape) const; - - //! Loads the deletion of the degenerated edges. - Standard_EXPORT void LoadDegenerated (BRepAlgoAPI_BooleanOperation& MakeShape) const; - - //! To process special cases with evolution 1 to n - Standard_EXPORT void LoadModified1n (BRepAlgoAPI_BooleanOperation& theMS, const TopoDS_Shape& theShapeIn, const TopAbs_ShapeEnum theKindOfShape) const; - - //! To process special cases with evolution 1 to 1 - Standard_EXPORT void LoadModified11 (BRepAlgoAPI_BooleanOperation& theMS, const TopoDS_Shape& theShapeIn, const TopAbs_ShapeEnum theKindOfShape) const; - - //! To process special case when result has symmetrical edges - Standard_EXPORT void LoadSymmetricalEdges (BRepAlgoAPI_BooleanOperation& theMS) const; - - Standard_EXPORT void LoadWRCase (BRepAlgoAPI_BooleanOperation& theMS) const; - - - - -private: - - - //! used inside LoadModified1n - Standard_EXPORT void Load1nFaces (BRepAlgoAPI_BooleanOperation& theMS, const TopoDS_Shape& theShapeIn) const; - - - - -}; - - - - - - - -#endif // _QANewBRepNaming_BooleanOperationFeat_HeaderFile diff --git a/src/QANewBRepNaming/QANewBRepNaming_Common.cxx b/src/QANewBRepNaming/QANewBRepNaming_Common.cxx index 9e07034661..5bcd3997d0 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Common.cxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Common.cxx @@ -40,7 +40,7 @@ QANewBRepNaming_Common::QANewBRepNaming_Common() {} //======================================================================= QANewBRepNaming_Common::QANewBRepNaming_Common(const TDF_Label& ResultLabel) - :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {} + :QANewBRepNaming_BooleanOperation(ResultLabel) {} //======================================================================= //function : Load diff --git a/src/QANewBRepNaming/QANewBRepNaming_Common.hxx b/src/QANewBRepNaming/QANewBRepNaming_Common.hxx index d8c779809d..92c8acf779 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Common.hxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Common.hxx @@ -20,13 +20,13 @@ #include #include -#include +#include class TDF_Label; class BRepAlgoAPI_BooleanOperation; -class QANewBRepNaming_Common : public QANewBRepNaming_BooleanOperationFeat +class QANewBRepNaming_Common : public QANewBRepNaming_BooleanOperation { public: diff --git a/src/QANewBRepNaming/QANewBRepNaming_Cut.cxx b/src/QANewBRepNaming/QANewBRepNaming_Cut.cxx index 759e93c2ab..3de38eb8b5 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Cut.cxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Cut.cxx @@ -40,7 +40,7 @@ QANewBRepNaming_Cut::QANewBRepNaming_Cut() {} //======================================================================= QANewBRepNaming_Cut::QANewBRepNaming_Cut(const TDF_Label& ResultLabel) - :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {} + :QANewBRepNaming_BooleanOperation(ResultLabel) {} //======================================================================= //function : Load @@ -141,7 +141,7 @@ void QANewBRepNaming_Cut::Load(BRepAlgoAPI_BooleanOperation& MS) const { LoadModified1n (MS, ObjSh, TopAbs_FACE); LoadModified11 (MS, ObjSh, TopAbs_FACE); LoadModified11 (MS, ToolSh, TopAbs_FACE); - } else if(QANewBRepNaming_BooleanOperationFeat::IsWRCase2(MS)) { + } else if(QANewBRepNaming_BooleanOperation::IsWRCase2(MS)) { LoadModified1n (MS, ObjSh, TopAbs_FACE); LoadModified11 (MS, ObjSh, TopAbs_FACE); LoadModified11 (MS, ToolSh, TopAbs_FACE); diff --git a/src/QANewBRepNaming/QANewBRepNaming_Cut.hxx b/src/QANewBRepNaming/QANewBRepNaming_Cut.hxx index 89c40a5207..857b50d777 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Cut.hxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Cut.hxx @@ -20,13 +20,13 @@ #include #include -#include +#include class TDF_Label; class BRepAlgoAPI_BooleanOperation; -class QANewBRepNaming_Cut : public QANewBRepNaming_BooleanOperationFeat +class QANewBRepNaming_Cut : public QANewBRepNaming_BooleanOperation { public: diff --git a/src/QANewBRepNaming/QANewBRepNaming_Fuse.cxx b/src/QANewBRepNaming/QANewBRepNaming_Fuse.cxx index 52e9177a24..ee546367c2 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Fuse.cxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Fuse.cxx @@ -37,7 +37,7 @@ QANewBRepNaming_Fuse::QANewBRepNaming_Fuse() {} //======================================================================= QANewBRepNaming_Fuse::QANewBRepNaming_Fuse(const TDF_Label& ResultLabel) - :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {} + :QANewBRepNaming_BooleanOperation(ResultLabel) {} //======================================================================= diff --git a/src/QANewBRepNaming/QANewBRepNaming_Fuse.hxx b/src/QANewBRepNaming/QANewBRepNaming_Fuse.hxx index b010553a49..ae6e902bde 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Fuse.hxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Fuse.hxx @@ -20,13 +20,13 @@ #include #include -#include +#include class TDF_Label; class BRepAlgoAPI_BooleanOperation; -class QANewBRepNaming_Fuse : public QANewBRepNaming_BooleanOperationFeat +class QANewBRepNaming_Fuse : public QANewBRepNaming_BooleanOperation { public: diff --git a/src/QANewBRepNaming/QANewBRepNaming_Intersection.cxx b/src/QANewBRepNaming/QANewBRepNaming_Intersection.cxx index 3159e141ae..f82d0c335a 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Intersection.cxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Intersection.cxx @@ -52,7 +52,7 @@ QANewBRepNaming_Intersection::QANewBRepNaming_Intersection() {} //======================================================================= QANewBRepNaming_Intersection::QANewBRepNaming_Intersection(const TDF_Label& ResultLabel) - :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {} + :QANewBRepNaming_BooleanOperation(ResultLabel) {} //======================================================================= //function : Load diff --git a/src/QANewBRepNaming/QANewBRepNaming_Intersection.hxx b/src/QANewBRepNaming/QANewBRepNaming_Intersection.hxx index 16a56f368a..d81cc3d519 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Intersection.hxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Intersection.hxx @@ -20,13 +20,13 @@ #include #include -#include +#include class TDF_Label; class BRepAlgoAPI_BooleanOperation; -class QANewBRepNaming_Intersection : public QANewBRepNaming_BooleanOperationFeat +class QANewBRepNaming_Intersection : public QANewBRepNaming_BooleanOperation { public: diff --git a/src/QANewBRepNaming/QANewBRepNaming_Limitation.cxx b/src/QANewBRepNaming/QANewBRepNaming_Limitation.cxx index 81c08a129b..eb5faceae8 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Limitation.cxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Limitation.cxx @@ -45,7 +45,7 @@ QANewBRepNaming_Limitation::QANewBRepNaming_Limitation() {} //======================================================================= QANewBRepNaming_Limitation::QANewBRepNaming_Limitation(const TDF_Label& ResultLabel) - :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {} + :QANewBRepNaming_BooleanOperation(ResultLabel) {} //======================================================================= //function : Load diff --git a/src/QANewBRepNaming/QANewBRepNaming_Limitation.hxx b/src/QANewBRepNaming/QANewBRepNaming_Limitation.hxx index 6f7c02a604..fbbc46f547 100644 --- a/src/QANewBRepNaming/QANewBRepNaming_Limitation.hxx +++ b/src/QANewBRepNaming/QANewBRepNaming_Limitation.hxx @@ -20,13 +20,13 @@ #include #include -#include +#include class TDF_Label; class QANewModTopOpe_Limitation; -class QANewBRepNaming_Limitation : public QANewBRepNaming_BooleanOperationFeat +class QANewBRepNaming_Limitation : public QANewBRepNaming_BooleanOperation { public: diff --git a/src/QANewDBRepNaming/QANewDBRepNaming_FeatureCommands.cxx b/src/QANewDBRepNaming/QANewDBRepNaming_FeatureCommands.cxx index c235b3cd8a..28614e27fd 100644 --- a/src/QANewDBRepNaming/QANewDBRepNaming_FeatureCommands.cxx +++ b/src/QANewDBRepNaming/QANewDBRepNaming_FeatureCommands.cxx @@ -67,15 +67,15 @@ #include //============================================================== -//function : QANewDBRepNaming_NameBooleanOperationFeat -//purpose : NameBooleanOperationFeat Doc Label Op = 1(Fuse), 2(Cut), 3(Common), 4(Inserction) 5(Limitation) DrawShape1 DrawShape2 [Forward = 0 || Reversed = 1 || BothSides = 2] +//function : QANewDBRepNaming_NameBooleanOperation +//purpose : NameBooleanOperation Doc Label Op = 1(Fuse), 2(Cut), 3(Common), 4(Inserction) 5(Limitation) DrawShape1 DrawShape2 [Forward = 0 || Reversed = 1 || BothSides = 2] //============================================================== -static Standard_Integer QANewDBRepNaming_NameBooleanOperationFeat (Draw_Interpretor& di, +static Standard_Integer QANewDBRepNaming_NameBooleanOperation (Draw_Interpretor& di, Standard_Integer nb, const char ** arg) { if (nb != 6 && nb != 7) { - di << "QANewDBRepNaming_NameBooleanOperationFeat : Error" << "\n"; + di << "QANewDBRepNaming_NameBooleanOperation : Error" << "\n"; return 1; } @@ -359,12 +359,12 @@ void QANewDBRepNaming::FeatureCommands (Draw_Interpretor& theCommands) static Standard_Boolean done = Standard_False; if (done) return; done = Standard_True; - const char* g = "Naming algorithm commands for features" ; + const char* g = "Naming algorithm commands for Booleans"; - theCommands.Add ("NameBooleanOperationFeat", - "NameBooleanOperationFeat Doc Label Operation(1, 2, 3, 4 or 5) DrawShape1 DrawShape2 [Forward = 0 || Reversed = 1 || BothSides = 2] ", - __FILE__, QANewDBRepNaming_NameBooleanOperationFeat, g); + theCommands.Add ("NameBooleanOperation", + "NameBooleanOperation Doc Label Operation(1, 2, 3, 4 or 5) DrawShape1 DrawShape2 [Forward = 0 || Reversed = 1 || BothSides = 2] ", + __FILE__, QANewDBRepNaming_NameBooleanOperation, g); theCommands.Add ("NameFuse", "NameFuse Doc Label DrawShape1 DrawShape2", diff --git a/src/ViewerTest/ViewerTest_FilletCommands.cxx b/src/ViewerTest/ViewerTest_FilletCommands.cxx index 0a3423b8e2..cfeb904b7f 100644 --- a/src/ViewerTest/ViewerTest_FilletCommands.cxx +++ b/src/ViewerTest/ViewerTest_FilletCommands.cxx @@ -21,11 +21,7 @@ #include #include #include -//#include -//#include -//#include #include -#include #include #include #include diff --git a/tests/bugs/modalg_1/buc60669 b/tests/bugs/modalg_1/buc60669 index 2e121198b3..0909aae133 100755 --- a/tests/bugs/modalg_1/buc60669 +++ b/tests/bugs/modalg_1/buc60669 @@ -1,5 +1,3 @@ -pload QAcommands - puts "==================" puts "BUC60669" puts "==================" @@ -14,7 +12,7 @@ checkshape shell1 restore [locate_data_file buc60669b.brep] shell2 checkshape shell2 -ksection result shell1 shell2 1000 0.0001 0.00001 0 +bsection result shell1 shell2 #checksection res checkprops result -l 104.754 diff --git a/tests/bugs/modalg_1/buc60682 b/tests/bugs/modalg_1/buc60682 index 1ee2c95a2a..045944f16a 100755 --- a/tests/bugs/modalg_1/buc60682 +++ b/tests/bugs/modalg_1/buc60682 @@ -1,9 +1,3 @@ -puts "TODO OCC12345 ALL: Faulty BUC60682" -puts "TODO OCC12345 ALL: Error : The area of result shape is" -puts "TODO OCC12345 ALL: Faulty shapes in variables faulty_1 to faulty_" - -pload QAcommands - puts "==================" puts "BUC60682" puts "==================" @@ -11,23 +5,15 @@ puts "==================" restore [locate_data_file buc60682a.brep] shell1 restore [locate_data_file buc60682b.brep] shell2 -set che [checkshape shell1] -if { [regexp {Faulty} $che ] == 1 } { - puts "Faulty BUC60682 (shell 1): Source shape is invalid. It was detected by Checkshape command" - puts "Body of the script was NOT executed" - renamevar shell1 result -} else { - puts "BUC60682 OK (shell 1): Source shape is valid" - set che [checkshape shell2] - if { [regexp {Faulty} $che ] == 1 } { - puts "Faulty BUC60682 (shell 2): Source shape is invalid. It was detected by Checkshape command" - puts "Body of the script was NOT executed" - renamevar shell2 result - } else { - puts "BUC60682 OK (shell 2): Source shape is valid" - ksection result shell1 shell2 1000 0.0001 0.00001 0 - } -} -checkprops result -s 0 +bsection result shell1 shell2 + checkshape result +if {[lindex [checksection result] 4] != 2} { + puts "Error: section is incomplete" +} + +checkprops result -l 5.76248 + +checknbshapes result -edge 1 + checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_1/buc60744 b/tests/bugs/modalg_1/buc60744 index b855b45f04..64df1ca36a 100755 --- a/tests/bugs/modalg_1/buc60744 +++ b/tests/bugs/modalg_1/buc60744 @@ -1,5 +1,3 @@ -pload QAcommands - puts "========================" puts "BUC60744" puts "========================" @@ -8,42 +6,14 @@ puts "" restore [locate_data_file buc60744a.brep] a restore [locate_data_file buc60744b.brep] b -set che [checkshape a] -if { [regexp {Faulty} $che ] == 1 } { - puts "Faulty BUC60744 (shape 1): Source shape is invalid. It was detected by Checkshape command" - puts "Body of the script was NOT executed" - renamevar a result -} else { - puts "BUC60744 OK (shape 1): Source shape is valid" - - set che [checkshape b] - if { [regexp {Faulty} $che ] == 1 } { - puts "Faulty BUC60744 (shape 2): Source shape is invalid. It was detected by Checkshape command" - puts "Body of the script was NOT executed" - renamevar b result - } else { - puts "BUC60744 OK (shape 2): Source shape is valid" - - ksection result a b 1000 0.0001 0.00001 0 - - set ne [llength [explode result e]] - set nv [llength [explode result v]] - - if {$ne >= $nv} { - puts [format "Faulty : the number of edges is %s, but the number of vertexes is %s." $ne $nv] - } - } -} bsection result a b -set ne [llength [explode result e]] -set nv [llength [explode result v]] +checkshape result -if {$ne >= $nv} { - puts [format "Faulty : the number of edges is %s, but the number of vertexes is %s." $ne $nv] +if {[lindex [checksection result] 4] != 2} { + puts "Error: section is incomplete" } -checkprops result -l 228.386 -checkshape result -checksection result +checkprops result -l 228.386 + checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_4/pro19626 b/tests/bugs/modalg_4/pro19626 index 42dd836bdc..1b8e4b6817 100755 --- a/tests/bugs/modalg_4/pro19626 +++ b/tests/bugs/modalg_4/pro19626 @@ -9,11 +9,9 @@ restore [locate_data_file pro19626b.brep] b checkshape b bsection result a b -regexp { nb alone Vertices : +([-0-9.+eE]+)} [checksection result] full num -if { $num != 2 } { - puts " Faulty PRO19626: Result shape is INcorrect !!! " -} else { - puts "PRO19626 OK : Result shape is CORRECT !!! " + +if {[lindex [checksection result] 4] != 2} { + puts "Error PRO19626: section is incomplete" } checkprops result -l 174.597