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.
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.
* 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
* 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.
==- 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
#include <TopoDS_Vertex.hxx>
#include <TopTools_MapOfShape.hxx>
-//#include <BRepAlgo_Cut.hxx>
#define NECHANTBARYC 11
//=======================================================================
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
-//modified by NIZNHY-PKV Thu Mar 21 17:30:25 2002 f
-//#include <BRepAlgo_Cut.hxx>
-//#include <BRepAlgo_Fuse.hxx>
-//modified by NIZNHY-PKV Thu Mar 21 17:30:29 2002 t
#ifdef OCCT_DEBUG
extern Standard_Boolean BRepFeat_GettraceFEAT();
#endif
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;
}
}// 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()) {
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()) {
}
}
}
- //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()) {
//
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 {
}
}
}
-//modified by NIZNHY-PKV Thu Mar 21 18:43:18 2002 f
//=======================================================================
//function : UpdateDescendants
//purpose :
}
}
}
-//modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
-//modified by NIZNHY-PKV Thu Mar 21 17:49:46 2002 f
-//#include <BRepAlgo_Cut.hxx>
-//#include <BRepAlgo_Fuse.hxx>
-//modified by NIZNHY-PKV Thu Mar 21 17:50:04 2002 t
#ifdef OCCT_DEBUG
extern Standard_Boolean BRepFeat_GettraceFEAT();
#endif
// 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 {
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 {
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 {
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 {
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();
}
}
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 {
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
-//modified by NIZNHY-PKV Fri Mar 22 16:51:33 2002 f
-//#include <BRepAlgo_Section.hxx>
-//#include <BRepAlgo_Common.hxx>
-//modified by NIZNHY-PKV Fri Mar 22 16:51:35 2002 t
-//#include <DbgTools.hxx>
#ifdef OCCT_DEBUG
extern Standard_Boolean BRepFeat_GettraceFEAT();
extern Standard_Boolean BRepFeat_GettraceFEATRIB();
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);
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();
}
}
- //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();
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
-//modified by NIZNHY-PKV Thu Mar 21 17:54:27 2002 f
-//#include <BRepAlgo_Fuse.hxx>
-//#include <BRepAlgo_Cut.hxx>
-//modified by NIZNHY-PKV Thu Mar 21 17:54:30 2002 t
#ifdef OCCT_DEBUG
extern Standard_Boolean BRepFeat_GettraceFEAT();
#endif
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 {
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 {
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()) {
}
}
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 {
}
}
}
- // 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());
- }
- }
- */
}
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::
}
}
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 {
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()) {
}
}
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 {
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()) {
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
-//modified by NIZNHY-PKV Fri Mar 22 16:56:15 2002
-//#include <BRepAlgo_Cut.hxx>
-//#include <BRepAlgo_Section.hxx>
-//#include <BRepAlgo_Common.hxx>
-//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();
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);
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());
}
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;
// 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;
return Standard_False;
}
//
- //modified by NIZNHY-PKV Tue Apr 2 15:08:23 2002 f
if(!e1.IsNull()) {
Standard_Real aTolV1, aTolV2;
myListOfEdges.Clear();
myListOfEdges.Clear();
}
}
- //modified by NIZNHY-PKV Tue Apr 2 15:08:26 2002 t
//
if(!e1.IsNull()) {
myListOfEdges.Clear();
}
}
- //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();
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();
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
-//modified by NIZNHY-PKV Fri Mar 22 16:48:13 2002 f
-//#include <BRepAlgo_Cut.hxx>
-//#include <BRepAlgo_Fuse.hxx>
-//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();
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;
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()) {
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()) {
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()) {
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()) {
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()) {
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()) {
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()) {
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()) {
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 {
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());
}
return ProfileOK;
}
-//modified by NIZNHY-PKV Thu Mar 21 18:43:18 2002 f
//=======================================================================
//function : UpdateDescendants
//purpose :
}
}
}
-//modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t
#include <Draw_Interpretor.hxx>
#include <Draw_Appli.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
-#include <BRepAlgo_BooleanOperation.hxx>
-#include <BRepAlgo_Fuse.hxx>
-#include <BRepAlgo_Cut.hxx>
#include <BiTgte_Blend.hxx>
#include <TopOpeBRepBuild_HBuilder.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
-//#include <BOPTools_DSFiller.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BRepAlgoAPI_BooleanOperation.hxx>
-//**********************************************
-// 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
//**********************************************
"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);
return 0;
}
-#include <BRepAlgo_BooleanOperations.hxx>
-
-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 <Geom_Axis2Placement.hxx>
#include <AIS_Trihedron.hxx>
return 0;
}
+#include <Bnd_BoundSortBox.hxx>
#include <BRepBndLib.hxx>
#include <Bnd_HArray1OfBox.hxx>
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);
QANewBRepNaming.hxx
QANewBRepNaming_BooleanOperation.cxx
QANewBRepNaming_BooleanOperation.hxx
-QANewBRepNaming_BooleanOperationFeat.cxx
-QANewBRepNaming_BooleanOperationFeat.hxx
QANewBRepNaming_Box.cxx
QANewBRepNaming_Box.hxx
QANewBRepNaming_Chamfer.cxx
class QANewBRepNaming_Cylinder;
class QANewBRepNaming_Sphere;
class QANewBRepNaming_BooleanOperation;
-class QANewBRepNaming_BooleanOperationFeat;
class QANewBRepNaming_Common;
class QANewBRepNaming_Cut;
class QANewBRepNaming_Fuse;
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;
-// 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
//
// commercial license or contractual agreement.
-#include <BRepAlgo_BooleanOperation.hxx>
+#include <Adaptor3d_HCurve.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepAlgoAPI_BooleanOperation.hxx>
+#include <BRepGProp.hxx>
+#include <Geom_Ellipse.hxx>
+#include <GeomAbs_SurfaceType.hxx>
+#include <gp.hxx>
+#include <gp_Cone.hxx>
+#include <gp_Cylinder.hxx>
+#include <GProp_GProps.hxx>
+#include <Precision.hxx>
#include <QANewBRepNaming_BooleanOperation.hxx>
#include <QANewBRepNaming_Loader.hxx>
#include <Standard_NullObject.hxx>
+#include <TColgp_Array1OfDir.hxx>
+#include <TColgp_Array1OfPnt.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_IntegerArray.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Real.hxx>
#include <TDF_Label.hxx>
+#include <TDF_TagSource.hxx>
#include <TNaming_Builder.hxx>
-#include <TopOpeBRepBuild_HBuilder.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopTools_Array1OfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+
+#ifdef OCCT_DEBUG
+#include <TDataStd_Name.hxx>
+#endif
+
+#ifdef OCCT_DEBUG
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Tool.hxx>
+#include <BRepTools.hxx>
+#include <TNaming_Tool.hxx>
+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 <<endl;
+#endif
+ Builder.Modify (Root,newShape);
+ }
+ }
+ }
+ }
+}
+//======================================================================
+static gp_Pnt GetCenterPoint(const TopoDS_Shape& theEdge)
+{
+ GProp_GProps aGProp;
+ BRepGProp::LinearProperties(theEdge, aGProp);
+ return aGProp.CentreOfMass();
+}
+//===================================================================
+static void SortRootFaces(TopTools_ListOfShape& theList, const TopoDS_Shape& theShape)
+{
+ TopTools_ListOfShape aList;
+ Standard_Integer aNum = theList.Extent();
+ if(aNum <= 1) return;
+ gp_Ax1 anAx = ComputeAxis(theShape);
+ TopTools_Array1OfShape ArS(1, aNum);
+ TColgp_Array1OfPnt ArP(1, aNum);
+ TColStd_Array1OfInteger ArI(1, aNum);
+ TopTools_ListIteratorOfListOfShape It(theList);
+ Standard_Integer i;
+ for(i=1;It.More();It.Next(),i++) {
+ ArS.SetValue(i, It.Value ());
+ ArI.SetValue(i,0);
+ ArP.SetValue(i, GetCenterPoint(It.Value()));
+
+ }
+ gp_Pnt aPnt = anAx.Location();
+ Standard_Integer I, j;
+ for(j=1;j <= aNum; j++) {
+ if(ArI.Value(j) == -1) continue;
+ Standard_Real aD1 = aPnt.Distance(ArP(j));
+ I = 0;
+ for(i=1;i <= aNum; i++) {
+ if(i==j) continue;
+ if(ArI.Value(i) == -1) continue;
+ Standard_Real aD2 = aPnt.Distance(ArP(i));
+ if(aD2 < aD1) {
+ I = i;
+ aD1 = aD2;
+ }
+ }
+ if (I == 0) continue;
+ ArI.SetValue(I, -1);
+ aList.Append(ArS.Value(I));
+ if(aList.Extent() == aNum -1) {
+ for(i=1; i<=aNum;i++)
+ if(ArI.Value(i) != -1) aList.Append(ArS.Value(i));
+ }
+ }
+ theList.Assign(aList);
+}
+//=======================================================================
+static void Sort2Faces(const TopTools_ListOfShape& Shapes,
+ const gp_Ax1& theAx, TopTools_ListOfShape& theList)
+{
+
+ TopTools_ListIteratorOfListOfShape It(Shapes);
+ for(;It.More();It.Next()) {
+ if(Identify(TopoDS::Face(It.Value()), theAx) == 1)
+ theList.Prepend(It.Value()); //Pos
+ else theList.Append(It.Value()); //Neg
+ }
+}
+
+//=======================================================================
+static void Sort3Faces(const TopTools_ListOfShape& theListIn, TopTools_ListOfShape& theListOut)
+{
+ TopTools_ListIteratorOfListOfShape It (theListIn);
+ TopTools_Array1OfShape ArS(1, theListIn.Extent());
+ TColgp_Array1OfPnt ArP(1, theListIn.Extent());
+
+ Standard_Integer i;
+ for(i=1;It.More();It.Next(),i++) {
+ ArS.SetValue(i, It.Value());
+ ArP.SetValue(i, GetCenterPoint(It.Value()));
+ }
+
+ Standard_Boolean found = Standard_False;
+ Standard_Integer j, i1 = 0, i2 = 0, i3 = 0;
+ TopoDS_Edge anEdge;
+ for(i=1;i<=3;i++) {
+ TopExp_Explorer anExp1(ArS.Value(i), TopAbs_EDGE);
+ for(;anExp1.More();anExp1.Next()) {
+ for(j=1;j<=3;j++) {
+ if(i==j) continue;
+ TopExp_Explorer anExp2(ArS.Value(j), TopAbs_EDGE);
+ for(;anExp2.More();anExp2.Next()) {
+ if(anExp1.Current().IsSame(anExp2.Current())){
+ found = Standard_True;
+ anEdge = TopoDS::Edge(anExp1.Current());
+ break;
+ }
+ }
+ if(found) break;
+ }
+ if(found) {
+ switch(i+j) {
+ case 3: //12
+ i1=1;i2=2; i3=3;
+ break;
+ case 4: //13
+ i1=1;i2=3; i3=2;
+ break;
+ case 5: //23
+ i1=2;i2=3; i3=1;
+ }
+ break;
+ }
+ }
+ if(found) break;
+ }
+
+//i1,i2 - two adjacent faces via sim-edge
+ gp_Pnt aPnt1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge));
+ gp_Pnt aPnt2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge));
+ gp_Vec aVec(aPnt1, aPnt2);
+ gp_Ax1 anAx(aPnt1, gp_Dir(aVec));
+ if (Identify(TopoDS::Face(ArS.Value(i1)), anAx) == -1) {//neg
+ i=i2; i2=i1; //i1 < = > 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!"<<endl;
+ // mark all structure as Deleted
+ Standard_Integer aN = aLabelFDS.Tag()+anAtt->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 = "<<i3<< "i4 = "<< i4 << endl;
+#endif
+ Standard_Integer aN = i4; i4 = i3;
+ i3 = aN;
+ }
+
+// 4. final order i1, i2, i3, i4 - Ok
+#ifdef OCCT_DEBUG
+ cout << "SortEdges4: i1 = " <<i1<<" i2 = "<<i2<< " i3 = "<<i3<< "i4 = "<< i4 << endl;
+#endif
+ theArI.SetValue(1, i1);
+ theArI.SetValue(2, i2);
+ theArI.SetValue(3, i3);
+ theArI.SetValue(4, i4);
+}
+// ======================================================================
+static void SortEdges5 (const TopTools_Array1OfShape& theArS, const TColgp_Array1OfPnt& theArP,
+ const gp_Ax1& theAx, TColStd_Array1OfInteger& theArI)
+{
+// =======================================
+// 1. find middle edge from gr. of 3 edges, build two groups in ArI
+// 2. find nearest group, reorganize ArI - nerest => top
+// 3. sort inside groups
+// 3.1. sort inside group of 2 edges
+// 3.2. sort inside group of 3 edges
+// =======================================
+ Standard_Integer i, j, i1,i2, i3, i4, i5;
+// 1.
+ TopoDS_Shape aV1, aV2, aV;
+ Standard_Integer I=0, J1=0, J2=0;
+ for(i=1;i<=5;i++) {
+ Standard_Boolean found = Standard_False;
+ const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i)));
+ for(j=1;j<=5;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)));
+ if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) {
+ aV1 = aV11; I = i; J1 = j;
+ found = Standard_True;
+ break;
+ }
+ }
+ if (found) {
+ found = Standard_False;
+ const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i)));
+ for(j=1;j<=5;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)));
+ if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) {
+ aV2 = aV12; J2 = j;
+#ifdef OCCT_DEBUG
+ if(I != i) cout << "WARNING:: I != i, I = " << I << ", i = " << i <<endl;
+#endif
+ found = Standard_True;
+ break;
+ }
+ }
+ }
+ if (found) break;
+ }
+// aV1, aV2 - vetexes of middle Edge, I - index of middle Edge, J1, J2 = indexes of
+// adjacent edges of the middle edge
+
+// init & shift group from 3 edges on the top
+ i1=J1; i2=I; i3 = J2; i4=0; i5=0;
+ for(i=1; i<=5;i++) {
+ if(i==i1 || i==i2 ||i==i3) continue;
+ if(!i4) i4=i;
+ else i5 = i;
+ }
+
+// find agjacent V (i4-i5)
+ TopoDS_Shape aV3;
+ const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i4)));
+ const TopoDS_Shape& aV21 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i5)));
+ const TopoDS_Shape& aV22 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i5)));
+ if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) aV3 = aV11;
+ else {
+ const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i4)));
+ if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) aV3 = aV12;
+ }
- if (S2.ShapeType() == TopAbs_FACE || S2.ShapeType() == TopAbs_WIRE )
- SST2 = TopAbs_EDGE;
+// 2. find nearest group (aV1, aV3), reorganize ArI - nerest => top
+ gp_Pnt aDP1 = BRep_Tool::Pnt(TopoDS::Vertex(aV1));
+ gp_Pnt aDP3 = BRep_Tool::Pnt(TopoDS::Vertex(aV3));
+ gp_Pnt aPnt = theAx.Location();
+ Standard_Real aD1 = aPnt.Distance(aDP1);//i1-i2-i3
+ Standard_Real aD2 = aPnt.Distance(aDP3);//i4-i5
+ Standard_Integer aTop = 3;
+ if(aD1 > aD2) { //change order of groups
+ aTop = 2;
+ Standard_Integer a4 = i4;// i1,i2 => i4,i5 - to the end
+ Standard_Integer a5 = i5;
+ i4 = i2; i5 = i1; // i4 - middle edge
+ i1 = a4; i2 = a5;
+ gp_Pnt aP1 = aDP1;
+ aDP1 = aDP3;
+ aDP3 = aP1;
+ // goup of 2 edges i1-i2 is the nearest
+ }
+// 3.1. sort inside group of 2 edges
+ gp_Pnt aDP, aCP;
+ if(aTop == 2) {aDP = aDP1; aCP = theArP.Value(i1);} //i1,i2
+ else {aDP = aDP3; aCP = theArP.Value(i4);} //i4, i5 - group of 2 edges at the bottom
+ if(!IsDirectionPositive(theAx, aDP, aCP)) {//first must be positive direction
+ Standard_Integer aN;
+ if(aTop == 2) {
+ // change i1 <=> i2
+ aN = i2; i2 = i1;
+ i1 = aN;
+ } else {
+ // change i4 <=> i5
+ aN = i5; i5 = i4;
+ i4 = aN;
+ }
+ }
+// 3.2. sort inside group of 3 edges
+ if(aTop == 2) {
+ //i3,i4,i5
+ aDP = theArP.Value(i4); //center of middle edge
+ aCP = theArP.Value(i3);
+ } else {
+ //i1,i2,i3
+ aDP = theArP.Value(i2);
+ aCP = theArP.Value(i1);
+ }
+
+ if(!IsDirectionPositive(theAx, aDP, aCP)) {//first must be positive direction
+ Standard_Integer aN;
+ if(aTop == 2) {
+ // change i3 <=> i5
+ aN = i5; i5 = i3;
+ i3 = aN;
+ } else {
+ // change i1 <=> i3
+ aN = i3; i3 = i1;
+ i1 = aN;
+ }
+ }
+// 4. final order i1, i2, i3, i4, i5 - Ok
+ theArI.SetValue(1, i1);
+ theArI.SetValue(2, i2);
+ theArI.SetValue(3, i3);
+ theArI.SetValue(4, i4);
+ theArI.SetValue(5, i5);
+}
+//=======================================================================
+static void FindAdjacent2(const TopTools_ListOfShape& theList,
+ TopTools_ListOfShape& theListOfEdges) {
+ TopTools_ListIteratorOfListOfShape It (theList);
+ const TopoDS_Shape& aShape1 = It.Value (); It.Next ();
+ const TopoDS_Shape& aShape2 = It.Value ();
+ if(!aShape1.IsNull() && !aShape2.IsNull()) {
+ TopExp_Explorer anExp1(aShape1, TopAbs_EDGE);
+ for(;anExp1.More();anExp1.Next()) {
+ TopExp_Explorer anExp2(aShape2, TopAbs_EDGE);
+ for(;anExp2.More();anExp2.Next()) {
+ if(anExp1.Current().IsSame(anExp2.Current()))
+ theListOfEdges.Append(anExp1.Current());
+ }
+ }
+ }
+}
+//=======================================================================
+static void FindAdjacent3(const TopTools_ListOfShape& theList,
+ TopTools_ListOfShape& theListOfEdges) {
+ TopTools_ListIteratorOfListOfShape It (theList);
+ TopTools_Array1OfShape ArS(1, theList.Extent());
+ TColgp_Array1OfPnt ArP(1, theList.Extent());
+ TColgp_Array1OfDir ArD(1, theList.Extent());
+ Standard_Integer i;
+ for(i=1;It.More();It.Next(),i++) {
+ ArS.SetValue(i, It.Value());
+ gp_Ax1 anAx = ComputeAxis(It.Value());
+ ArP.SetValue(i, anAx.Location());
+ ArD.SetValue(i, anAx.Direction());
+ }
+ Standard_Boolean aDjacent = Standard_False;
+ Standard_Integer j, i2 = 0, i3 = 0; //i2, i3 - indexes of two adjacent faces having the same surface
+ Standard_Integer i1 = 0; //single face
+ for(i=1;i<=3;i++) {
+ for(j=1;j<=3;j++) {
+ if(i==j) continue;
+ if(ArP.Value(i).IsEqual(ArP.Value(j), Precision::Confusion())
+ && ArD.Value(i).IsEqual(ArD.Value(j), Precision::Angular())) {
+ aDjacent = Standard_True;
+ 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;
+ default:
+ i1 = 1; i2 = 2; i3 = 3;
+ }
+ break;
+ }
+ }
+ if(aDjacent) break;
+ }
+
+ TopExp_Explorer anExp1(ArS.Value(i1), TopAbs_EDGE);
+ for(;anExp1.More();anExp1.Next()) {
+ Standard_Boolean found = Standard_False;
+ TopExp_Explorer anExp2(ArS.Value(i2), TopAbs_EDGE);
+ for(;anExp2.More();anExp2.Next()) {
+ if(anExp1.Current().IsSame(anExp2.Current()))
+ {theListOfEdges.Append(anExp1.Current()); found=Standard_True; break;}
+ }
+ if(!found) {
+ TopExp_Explorer anExp3(ArS.Value(i3), TopAbs_EDGE);
+ for(;anExp3.More();anExp3.Next()) {
+ if(anExp1.Current().IsSame(anExp3.Current()))
+ {theListOfEdges.Append(anExp1.Current());break;}
+ }
+ }
+ }
+}
+//=======================================================================
+static void FindAdjacent4(const TopTools_ListOfShape& theList,
+ TopTools_ListOfShape& theListOfEdges) {
+ TopTools_ListIteratorOfListOfShape It (theList);
+ TopTools_Array1OfShape ArS(1, theList.Extent());
+ TColgp_Array1OfPnt ArP(1, theList.Extent());
+ TColgp_Array1OfDir ArD(1, theList.Extent());
+ Standard_Integer i;
+ for(i=1;It.More();It.Next(),i++) {
+ ArS.SetValue(i, It.Value());
+ gp_Ax1 anAx = ComputeAxis(It.Value());
+ ArP.SetValue(i, anAx.Location());
+ ArD.SetValue(i, anAx.Direction());
+ }
+ //find pairs
+ Standard_Integer j, i3=0, i4 = 0;//i3, i4 - indexes of two adjacent faces having the same surface
+ Standard_Integer i1 = 0, i2 = 0;
+ Standard_Boolean aDjacent = Standard_False;
+ for(i=1;i<=4;i++) {
+ for(j=1;j<=4;j++) {
+ if(i==j) continue;
+ if(ArP.Value(i).IsEqual(ArP.Value(j), Precision::Confusion())
+ && ArD.Value(i).IsEqual(ArD.Value(j), Precision::Angular())) {
+ 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;
+ default:
+ i3 = 3; i4 = 4;
+ }
+ break;
+ }
+ }
+ if(aDjacent) break;
+ }
+
+ TopExp_Explorer anExp1(ArS.Value(i1), TopAbs_EDGE);
+ for(;anExp1.More();anExp1.Next()) {
+ Standard_Boolean found = Standard_False;
+ TopExp_Explorer anExp2(ArS.Value(i3), TopAbs_EDGE);
+ for(;anExp2.More();anExp2.Next()) {
+ if(anExp1.Current().IsSame(anExp2.Current()))
+ {theListOfEdges.Append(anExp1.Current()); found=Standard_True; break;}
+ }
+ if(!found) {
+ TopExp_Explorer anExp3(ArS.Value(i4), TopAbs_EDGE);
+ for(;anExp3.More();anExp3.Next()) {
+ if(anExp1.Current().IsSame(anExp3.Current()))
+ {theListOfEdges.Append(anExp1.Current());break;}
+ }
+ }
+ }
+//
+ anExp1.Init(ArS.Value(i2), TopAbs_EDGE);
+ for(;anExp1.More();anExp1.Next()) {
+ Standard_Boolean found = Standard_False;
+ TopExp_Explorer anExp2(ArS.Value(i3), TopAbs_EDGE);
+ for(;anExp2.More();anExp2.Next()) {
+ if(anExp1.Current().IsSame(anExp2.Current()))
+ {theListOfEdges.Append(anExp1.Current()); found=Standard_True; break;}
+ }
+ if(!found) {
+ TopExp_Explorer anExp3(ArS.Value(i4), TopAbs_EDGE);
+ for(;anExp3.More();anExp3.Next()) {
+ if(anExp1.Current().IsSame(anExp3.Current()))
+ {theListOfEdges.Append(anExp1.Current());break;}
+ }
+ }
+ }
+}
+
+//=======================================================================
+// SortEdges: returns
+//=======================================================================
+static void SortEdges(const TopTools_ListOfShape& theListE, const gp_Ax1& theAx,
+ TopTools_Array1OfShape& theARS)
+{
- TNaming_Builder Builder1(FirstModified());
- QANewBRepNaming_Loader::LoadModifiedShapes(MS, S1, SST1, Builder1);
- TNaming_Builder Builder2(FirstDeleted());
- QANewBRepNaming_Loader::LoadDeletedShapes(MS, S1, SST1, Builder2);
+ Standard_Integer aNE1 = theListE.Extent();
+ TopTools_Array1OfShape ArS(1, aNE1);
+ TColgp_Array1OfPnt ArP(1, aNE1);
+ TColStd_Array1OfInteger ArI(1, aNE1);
+ TopTools_ListIteratorOfListOfShape It (theListE);//pairs of edges
+ //for (Standard_Integer i=1;It.More (); It.Next (),i++) {
+ Standard_Integer i;
+ for (i=1;It.More (); It.Next (),i++) {
+ ArS.SetValue(i, It.Value ());
+ ArI.SetValue(i,0);
+ ArP.SetValue(i, GetCenterPoint(It.Value()));
+ }
+ switch(aNE1) {
+ case 2:
+ // Identify position
+ SortEdges2(ArP, theAx, ArI);
+ break;
+ case 3:
+ SortEdges3(ArS, ArP, theAx, ArI);
+ break;
+ case 4:
+ SortEdges4(ArS, ArP, theAx, ArI);
+ break;
+ case 5:
+ SortEdges5(ArS, ArP, theAx, ArI);
+ break;
+ }
- TNaming_Builder Builder3(SecondModified());
- QANewBRepNaming_Loader::LoadModifiedShapes(MS, S2, SST2, Builder3);
- TNaming_Builder Builder4(SecondDeleted());
- QANewBRepNaming_Loader::LoadDeletedShapes(MS, S2, SST2, Builder4);
+ for(i=1;i<=ArI.Upper();i++) {
+#ifdef OCCT_DEBUG
+ cout << "SortEdges: i = " <<i<<" ArI.Value(i) = " <<ArI.Value(i)<< endl;
+#endif
+ theARS.SetValue(i, ArS.Value(ArI.Value(i)));
+
+ }
+}
+//=======================================================================
+//function : LoadSymmetricalEdges
+//purpose :
+//=======================================================================
+
+void QANewBRepNaming_BooleanOperation::LoadSymmetricalEdges (BRepAlgoAPI_BooleanOperation& MS) const
+{
+ const TopoDS_Shape& aResult = MS.Shape();
+ if(aResult.IsNull()) return;
+ 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;
+ const TopAbs_ShapeEnum& Type2 = ShapeType(ToolSh);
+ if(Type2 == TopAbs_COMPOUND || Type2 > TopAbs_FACE) return;
+ TopTools_ListOfShape aList0;
+ if (aResult.ShapeType() == TopAbs_COMPOUND) {
+ TopoDS_Iterator itr(aResult);
+ for (; itr.More(); itr.Next())
+ aList0.Append(itr.Value()); //collect separated entities (bodies)
+
+ }
+ if(aList0.Extent() > 2) return; // case > 2 ent. is not considered
+ TopTools_ListOfShape aList1, aList2;
+ TopTools_ListIteratorOfListOfShape It (aList0); //each item (body) must have at least 1 pair
+ // of "cyl/con" surfaces (in some cases may be 3 or 4 faces depending on sim-edge position)
+ for (;It.More (); It.Next ()) {
+ const TopoDS_Shape& aShape = It.Value (); //1-st solid/shell
+ TopTools_ListOfShape aList;
+ aList.Clear();
+#ifdef OCCT_DEBUG
+// ModDbgTools_Write(aShape, "S0");
+#endif
+ if(aShape.ShapeType() != TopAbs_FACE) {
+ TopExp_Explorer anExp(aShape, TopAbs_FACE);
+ for(;anExp.More();anExp.Next()) {
+ if(IsValidSurfType(TopoDS::Face(anExp.Current())))
+ aList.Append(anExp.Current()); // faces of the current entity
+ }
+ } else
+ if(IsValidSurfType(TopoDS::Face(ObjSh)))
+ aList.Append(aShape);
+
+ if(aList1.Extent() == 0 )
+ aList1.Assign(aList);
+ else
+ aList2.Assign(aList);
+ }
+// aList1,2 contain pairs of faces having more then 1 neghbour edge (each pair)
+ const Standard_Integer aNF1 = aList1.Extent(); // keep n of faces of the first entity
+ const Standard_Integer aNF2 = aList2.Extent(); // keep n of faces of the second entity
+ if(aNF1 + aNF2 < 2) return;
+
+//find Edges
+ TopTools_ListOfShape aListE1, aListE2;
+ Standard_Integer aNE1=0,aNE2=0;
+ if(aNF1 == 2 && !aNF2) {//trivial case - only 2 faces
+ FindAdjacent2(aList1, aListE1);
+ aNE1 = aListE1.Extent();
+ }
+ else { // result is compound of two ent.
+ if (aNF1 == 2) //first ent. has 2 valid faces
+ FindAdjacent2(aList1, aListE1); // find adjacent edges
+ else if (aNF1 == 3) // first ent. has 3 valid faces
+ FindAdjacent3(aList1, aListE1);
+ else if (aNF1 == 4) //first ent. has 4 valid faces
+ FindAdjacent4(aList1, aListE1);
+// set number of symmetry Edges of the first ent.
+ aNE1 = aListE1.Extent();
+
+// Second ent.
+ if (aNF2 == 2) //second ent. has 2 valid faces
+ FindAdjacent2(aList2, aListE2);
+ else if (aNF2 == 3)
+ FindAdjacent3(aList2, aListE2);
+ else if (aNF2 == 4)
+ FindAdjacent4(aList2, aListE2);
+
+ aNE2 = aListE2.Extent();
+ }
+//aListE1, aListE2 - contains Edges
+// if(aNE1 < 2) return;
+// check topological compatibility
+//if exist
+ Handle(TDataStd_IntegerArray) aSAR;
+ if(!ResultLabel().FindAttribute(TDataStd_IntegerArray::GetID(), aSAR) ) {
+ 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
+ }
+ 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!"<<endl;
+ // mark all structure as Deleted
+ Standard_Integer aN = aLabelEDS.Tag()+anAtt->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())));
+ }
+ }
+ }
+ }
+ }
+ }
}
-// 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.
#include <Standard_Handle.hxx>
#include <QANewBRepNaming_TopNaming.hxx>
+#include <Standard_Boolean.hxx>
+#include <TopAbs_ShapeEnum.hxx>
class TDF_Label;
-class BRepAlgo_BooleanOperation;
+class BRepAlgoAPI_BooleanOperation;
+class TopoDS_Shape;
//! To load the BooleanOperation results
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;
+++ /dev/null
-// 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 <Adaptor3d_HCurve.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepAlgoAPI_BooleanOperation.hxx>
-#include <BRepGProp.hxx>
-#include <Geom_Ellipse.hxx>
-#include <GeomAbs_SurfaceType.hxx>
-#include <gp.hxx>
-#include <gp_Cone.hxx>
-#include <gp_Cylinder.hxx>
-#include <GProp_GProps.hxx>
-#include <Precision.hxx>
-#include <QANewBRepNaming_BooleanOperationFeat.hxx>
-#include <QANewBRepNaming_Loader.hxx>
-#include <Standard_NullObject.hxx>
-#include <TColgp_Array1OfDir.hxx>
-#include <TColgp_Array1OfPnt.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-#include <TDataStd_Integer.hxx>
-#include <TDataStd_IntegerArray.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_Real.hxx>
-#include <TDF_Label.hxx>
-#include <TDF_TagSource.hxx>
-#include <TNaming_Builder.hxx>
-#include <TNaming_NamedShape.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopTools_Array1OfShape.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_MapOfShape.hxx>
-
-#ifdef OCCT_DEBUG
-#include <TDataStd_Name.hxx>
-#endif
-
-#ifdef OCCT_DEBUG
-#include <TCollection_AsciiString.hxx>
-#include <TDF_Tool.hxx>
-#include <BRepTools.hxx>
-#include <TNaming_Tool.hxx>
-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 <<endl;
-#endif
- Builder.Modify (Root,newShape);
- }
- }
- }
- }
-}
-//======================================================================
-static gp_Pnt GetCenterPoint(const TopoDS_Shape& theEdge)
-{
- GProp_GProps aGProp;
- BRepGProp::LinearProperties(theEdge, aGProp);
- return aGProp.CentreOfMass();
-}
-//===================================================================
-static void SortRootFaces(TopTools_ListOfShape& theList, const TopoDS_Shape& theShape)
-{
- TopTools_ListOfShape aList;
- Standard_Integer aNum = theList.Extent();
- if(aNum <= 1) return;
- gp_Ax1 anAx = ComputeAxis(theShape);
- TopTools_Array1OfShape ArS(1, aNum);
- TColgp_Array1OfPnt ArP(1, aNum);
- TColStd_Array1OfInteger ArI(1, aNum);
- TopTools_ListIteratorOfListOfShape It(theList);
- Standard_Integer i;
- for(i=1;It.More();It.Next(),i++) {
- ArS.SetValue(i, It.Value ());
- ArI.SetValue(i,0);
- ArP.SetValue(i, GetCenterPoint(It.Value()));
-
- }
- gp_Pnt aPnt = anAx.Location();
- Standard_Integer I, j;
- for(j=1;j <= aNum; j++) {
- if(ArI.Value(j) == -1) continue;
- Standard_Real aD1 = aPnt.Distance(ArP(j));
- I = 0;
- for(i=1;i <= aNum; i++) {
- if(i==j) continue;
- if(ArI.Value(i) == -1) continue;
- Standard_Real aD2 = aPnt.Distance(ArP(i));
- if(aD2 < aD1) {
- I = i;
- aD1 = aD2;
- }
- }
- if (I == 0) continue;
- ArI.SetValue(I, -1);
- aList.Append(ArS.Value(I));
- if(aList.Extent() == aNum -1) {
- for(i=1; i<=aNum;i++)
- if(ArI.Value(i) != -1) aList.Append(ArS.Value(i));
- }
- }
- theList.Assign(aList);
-}
-//=======================================================================
-static void Sort2Faces(const TopTools_ListOfShape& Shapes,
- const gp_Ax1& theAx, TopTools_ListOfShape& theList)
-{
-
- TopTools_ListIteratorOfListOfShape It(Shapes);
- for(;It.More();It.Next()) {
- if(Identify(TopoDS::Face(It.Value()), theAx) == 1)
- theList.Prepend(It.Value()); //Pos
- else theList.Append(It.Value()); //Neg
- }
-}
-
-//=======================================================================
-static void Sort3Faces(const TopTools_ListOfShape& theListIn, TopTools_ListOfShape& theListOut)
-{
- TopTools_ListIteratorOfListOfShape It (theListIn);
- TopTools_Array1OfShape ArS(1, theListIn.Extent());
- TColgp_Array1OfPnt ArP(1, theListIn.Extent());
-
- Standard_Integer i;
- for(i=1;It.More();It.Next(),i++) {
- ArS.SetValue(i, It.Value());
- ArP.SetValue(i, GetCenterPoint(It.Value()));
- }
-
- Standard_Boolean found = Standard_False;
- Standard_Integer j, i1 = 0, i2 = 0, i3 = 0;
- TopoDS_Edge anEdge;
- for(i=1;i<=3;i++) {
- TopExp_Explorer anExp1(ArS.Value(i), TopAbs_EDGE);
- for(;anExp1.More();anExp1.Next()) {
- for(j=1;j<=3;j++) {
- if(i==j) continue;
- TopExp_Explorer anExp2(ArS.Value(j), TopAbs_EDGE);
- for(;anExp2.More();anExp2.Next()) {
- if(anExp1.Current().IsSame(anExp2.Current())){
- found = Standard_True;
- anEdge = TopoDS::Edge(anExp1.Current());
- break;
- }
- }
- if(found) break;
- }
- if(found) {
- switch(i+j) {
- case 3: //12
- i1=1;i2=2; i3=3;
- break;
- case 4: //13
- i1=1;i2=3; i3=2;
- break;
- case 5: //23
- i1=2;i2=3; i3=1;
- }
- break;
- }
- }
- if(found) break;
- }
-
-//i1,i2 - two adjacent faces via sim-edge
- gp_Pnt aPnt1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge));
- gp_Pnt aPnt2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge));
- gp_Vec aVec(aPnt1, aPnt2);
- gp_Ax1 anAx(aPnt1, gp_Dir(aVec));
- if (Identify(TopoDS::Face(ArS.Value(i1)), anAx) == -1) {//neg
- i=i2; i2=i1; //i1 < = > 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!"<<endl;
- // mark all structure as Deleted
- Standard_Integer aN = aLabelFDS.Tag()+anAtt->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 = "<<i3<< "i4 = "<< i4 << endl;
-#endif
- Standard_Integer aN = i4; i4 = i3;
- i3 = aN;
- }
-
-// 4. final order i1, i2, i3, i4 - Ok
-#ifdef OCCT_DEBUG
- cout << "SortEdges4: i1 = " <<i1<<" i2 = "<<i2<< " i3 = "<<i3<< "i4 = "<< i4 << endl;
-#endif
- theArI.SetValue(1, i1);
- theArI.SetValue(2, i2);
- theArI.SetValue(3, i3);
- theArI.SetValue(4, i4);
-}
-// ======================================================================
-static void SortEdges5 (const TopTools_Array1OfShape& theArS, const TColgp_Array1OfPnt& theArP,
- const gp_Ax1& theAx, TColStd_Array1OfInteger& theArI)
-{
-// =======================================
-// 1. find middle edge from gr. of 3 edges, build two groups in ArI
-// 2. find nearest group, reorganize ArI - nerest => top
-// 3. sort inside groups
-// 3.1. sort inside group of 2 edges
-// 3.2. sort inside group of 3 edges
-// =======================================
- Standard_Integer i, j, i1,i2, i3, i4, i5;
-// 1.
- TopoDS_Shape aV1, aV2, aV;
- Standard_Integer I=0, J1=0, J2=0;
- for(i=1;i<=5;i++) {
- Standard_Boolean found = Standard_False;
- const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i)));
- for(j=1;j<=5;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)));
- if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) {
- aV1 = aV11; I = i; J1 = j;
- found = Standard_True;
- break;
- }
- }
- if (found) {
- found = Standard_False;
- const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i)));
- for(j=1;j<=5;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)));
- if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) {
- aV2 = aV12; J2 = j;
-#ifdef OCCT_DEBUG
- if(I != i) cout << "WARNING:: I != i, I = " << I << ", i = " << i <<endl;
-#endif
- found = Standard_True;
- break;
- }
- }
- }
- if (found) break;
- }
-// aV1, aV2 - vetexes of middle Edge, I - index of middle Edge, J1, J2 = indexes of
-// adjacent edges of the middle edge
-
-// init & shift group from 3 edges on the top
- i1=J1; i2=I; i3 = J2; i4=0; i5=0;
- for(i=1; i<=5;i++) {
- if(i==i1 || i==i2 ||i==i3) continue;
- if(!i4) i4=i;
- else i5 = i;
- }
-
-// find agjacent V (i4-i5)
- TopoDS_Shape aV3;
- const TopoDS_Shape& aV11 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i4)));
- const TopoDS_Shape& aV21 = TopExp::FirstVertex(TopoDS::Edge(theArS.Value(i5)));
- const TopoDS_Shape& aV22 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i5)));
- if(aV11.IsSame(aV21) || aV11.IsSame(aV22)) aV3 = aV11;
- else {
- const TopoDS_Shape& aV12 = TopExp::LastVertex(TopoDS::Edge(theArS.Value(i4)));
- if(aV12.IsSame(aV21) || aV12.IsSame(aV22)) aV3 = aV12;
- }
-
-// 2. find nearest group (aV1, aV3), reorganize ArI - nerest => top
- gp_Pnt aDP1 = BRep_Tool::Pnt(TopoDS::Vertex(aV1));
- gp_Pnt aDP3 = BRep_Tool::Pnt(TopoDS::Vertex(aV3));
- gp_Pnt aPnt = theAx.Location();
- Standard_Real aD1 = aPnt.Distance(aDP1);//i1-i2-i3
- Standard_Real aD2 = aPnt.Distance(aDP3);//i4-i5
- Standard_Integer aTop = 3;
- if(aD1 > aD2) { //change order of groups
- aTop = 2;
- Standard_Integer a4 = i4;// i1,i2 => i4,i5 - to the end
- Standard_Integer a5 = i5;
- i4 = i2; i5 = i1; // i4 - middle edge
- i1 = a4; i2 = a5;
- gp_Pnt aP1 = aDP1;
- aDP1 = aDP3;
- aDP3 = aP1;
- // goup of 2 edges i1-i2 is the nearest
- }
-// 3.1. sort inside group of 2 edges
- gp_Pnt aDP, aCP;
- if(aTop == 2) {aDP = aDP1; aCP = theArP.Value(i1);} //i1,i2
- else {aDP = aDP3; aCP = theArP.Value(i4);} //i4, i5 - group of 2 edges at the bottom
- if(!IsDirectionPositive(theAx, aDP, aCP)) {//first must be positive direction
- Standard_Integer aN;
- if(aTop == 2) {
- // change i1 <=> i2
- aN = i2; i2 = i1;
- i1 = aN;
- } else {
- // change i4 <=> i5
- aN = i5; i5 = i4;
- i4 = aN;
- }
- }
-// 3.2. sort inside group of 3 edges
- if(aTop == 2) {
- //i3,i4,i5
- aDP = theArP.Value(i4); //center of middle edge
- aCP = theArP.Value(i3);
- } else {
- //i1,i2,i3
- aDP = theArP.Value(i2);
- aCP = theArP.Value(i1);
- }
-
- if(!IsDirectionPositive(theAx, aDP, aCP)) {//first must be positive direction
- Standard_Integer aN;
- if(aTop == 2) {
- // change i3 <=> i5
- aN = i5; i5 = i3;
- i3 = aN;
- } else {
- // change i1 <=> i3
- aN = i3; i3 = i1;
- i1 = aN;
- }
- }
-// 4. final order i1, i2, i3, i4, i5 - Ok
- theArI.SetValue(1, i1);
- theArI.SetValue(2, i2);
- theArI.SetValue(3, i3);
- theArI.SetValue(4, i4);
- theArI.SetValue(5, i5);
-}
-//=======================================================================
-static void FindAdjacent2(const TopTools_ListOfShape& theList,
- TopTools_ListOfShape& theListOfEdges) {
- TopTools_ListIteratorOfListOfShape It (theList);
- const TopoDS_Shape& aShape1 = It.Value (); It.Next ();
- const TopoDS_Shape& aShape2 = It.Value ();
- if(!aShape1.IsNull() && !aShape2.IsNull()) {
- TopExp_Explorer anExp1(aShape1, TopAbs_EDGE);
- for(;anExp1.More();anExp1.Next()) {
- TopExp_Explorer anExp2(aShape2, TopAbs_EDGE);
- for(;anExp2.More();anExp2.Next()) {
- if(anExp1.Current().IsSame(anExp2.Current()))
- theListOfEdges.Append(anExp1.Current());
- }
- }
- }
-}
-//=======================================================================
-static void FindAdjacent3(const TopTools_ListOfShape& theList,
- TopTools_ListOfShape& theListOfEdges) {
- TopTools_ListIteratorOfListOfShape It (theList);
- TopTools_Array1OfShape ArS(1, theList.Extent());
- TColgp_Array1OfPnt ArP(1, theList.Extent());
- TColgp_Array1OfDir ArD(1, theList.Extent());
- Standard_Integer i;
- for(i=1;It.More();It.Next(),i++) {
- ArS.SetValue(i, It.Value());
- gp_Ax1 anAx = ComputeAxis(It.Value());
- ArP.SetValue(i, anAx.Location());
- ArD.SetValue(i, anAx.Direction());
- }
- Standard_Boolean aDjacent = Standard_False;
- Standard_Integer j, i2 = 0, i3 = 0; //i2, i3 - indexes of two adjacent faces having the same surface
- Standard_Integer i1 = 0; //single face
- for(i=1;i<=3;i++) {
- for(j=1;j<=3;j++) {
- if(i==j) continue;
- if(ArP.Value(i).IsEqual(ArP.Value(j), Precision::Confusion())
- && ArD.Value(i).IsEqual(ArD.Value(j), Precision::Angular())) {
- aDjacent = Standard_True;
- 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;
- default:
- i1 = 1; i2 = 2; i3 = 3;
- }
- break;
- }
- }
- if(aDjacent) break;
- }
-
- TopExp_Explorer anExp1(ArS.Value(i1), TopAbs_EDGE);
- for(;anExp1.More();anExp1.Next()) {
- Standard_Boolean found = Standard_False;
- TopExp_Explorer anExp2(ArS.Value(i2), TopAbs_EDGE);
- for(;anExp2.More();anExp2.Next()) {
- if(anExp1.Current().IsSame(anExp2.Current()))
- {theListOfEdges.Append(anExp1.Current()); found=Standard_True; break;}
- }
- if(!found) {
- TopExp_Explorer anExp3(ArS.Value(i3), TopAbs_EDGE);
- for(;anExp3.More();anExp3.Next()) {
- if(anExp1.Current().IsSame(anExp3.Current()))
- {theListOfEdges.Append(anExp1.Current());break;}
- }
- }
- }
-}
-//=======================================================================
-static void FindAdjacent4(const TopTools_ListOfShape& theList,
- TopTools_ListOfShape& theListOfEdges) {
- TopTools_ListIteratorOfListOfShape It (theList);
- TopTools_Array1OfShape ArS(1, theList.Extent());
- TColgp_Array1OfPnt ArP(1, theList.Extent());
- TColgp_Array1OfDir ArD(1, theList.Extent());
- Standard_Integer i;
- for(i=1;It.More();It.Next(),i++) {
- ArS.SetValue(i, It.Value());
- gp_Ax1 anAx = ComputeAxis(It.Value());
- ArP.SetValue(i, anAx.Location());
- ArD.SetValue(i, anAx.Direction());
- }
- //find pairs
- Standard_Integer j, i3=0, i4 = 0;//i3, i4 - indexes of two adjacent faces having the same surface
- Standard_Integer i1 = 0, i2 = 0;
- Standard_Boolean aDjacent = Standard_False;
- for(i=1;i<=4;i++) {
- for(j=1;j<=4;j++) {
- if(i==j) continue;
- if(ArP.Value(i).IsEqual(ArP.Value(j), Precision::Confusion())
- && ArD.Value(i).IsEqual(ArD.Value(j), Precision::Angular())) {
- 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;
- default:
- i3 = 3; i4 = 4;
- }
- break;
- }
- }
- if(aDjacent) break;
- }
-
- TopExp_Explorer anExp1(ArS.Value(i1), TopAbs_EDGE);
- for(;anExp1.More();anExp1.Next()) {
- Standard_Boolean found = Standard_False;
- TopExp_Explorer anExp2(ArS.Value(i3), TopAbs_EDGE);
- for(;anExp2.More();anExp2.Next()) {
- if(anExp1.Current().IsSame(anExp2.Current()))
- {theListOfEdges.Append(anExp1.Current()); found=Standard_True; break;}
- }
- if(!found) {
- TopExp_Explorer anExp3(ArS.Value(i4), TopAbs_EDGE);
- for(;anExp3.More();anExp3.Next()) {
- if(anExp1.Current().IsSame(anExp3.Current()))
- {theListOfEdges.Append(anExp1.Current());break;}
- }
- }
- }
-//
- anExp1.Init(ArS.Value(i2), TopAbs_EDGE);
- for(;anExp1.More();anExp1.Next()) {
- Standard_Boolean found = Standard_False;
- TopExp_Explorer anExp2(ArS.Value(i3), TopAbs_EDGE);
- for(;anExp2.More();anExp2.Next()) {
- if(anExp1.Current().IsSame(anExp2.Current()))
- {theListOfEdges.Append(anExp1.Current()); found=Standard_True; break;}
- }
- if(!found) {
- TopExp_Explorer anExp3(ArS.Value(i4), TopAbs_EDGE);
- for(;anExp3.More();anExp3.Next()) {
- if(anExp1.Current().IsSame(anExp3.Current()))
- {theListOfEdges.Append(anExp1.Current());break;}
- }
- }
- }
-}
-
-//=======================================================================
-// SortEdges: returns
-//=======================================================================
-static void SortEdges(const TopTools_ListOfShape& theListE, const gp_Ax1& theAx,
- TopTools_Array1OfShape& theARS)
-{
-
- Standard_Integer aNE1 = theListE.Extent();
- TopTools_Array1OfShape ArS(1, aNE1);
- TColgp_Array1OfPnt ArP(1, aNE1);
- TColStd_Array1OfInteger ArI(1, aNE1);
- TopTools_ListIteratorOfListOfShape It (theListE);//pairs of edges
- //for (Standard_Integer i=1;It.More (); It.Next (),i++) {
- Standard_Integer i;
- for (i=1;It.More (); It.Next (),i++) {
- ArS.SetValue(i, It.Value ());
- ArI.SetValue(i,0);
- ArP.SetValue(i, GetCenterPoint(It.Value()));
- }
- switch(aNE1) {
- case 2:
- // Identify position
- SortEdges2(ArP, theAx, ArI);
- break;
- case 3:
- SortEdges3(ArS, ArP, theAx, ArI);
- break;
- case 4:
- SortEdges4(ArS, ArP, theAx, ArI);
- break;
- case 5:
- SortEdges5(ArS, ArP, theAx, ArI);
- break;
- }
-
- for(i=1;i<=ArI.Upper();i++) {
-#ifdef OCCT_DEBUG
- cout << "SortEdges: i = " <<i<<" ArI.Value(i) = " <<ArI.Value(i)<< endl;
-#endif
- theARS.SetValue(i, ArS.Value(ArI.Value(i)));
-
- }
-}
-//=======================================================================
-//function : LoadSymmetricalEdges
-//purpose :
-//=======================================================================
-
-void QANewBRepNaming_BooleanOperationFeat::LoadSymmetricalEdges (BRepAlgoAPI_BooleanOperation& MS) const
-{
- const TopoDS_Shape& aResult = MS.Shape();
- if(aResult.IsNull()) return;
- 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;
- const TopAbs_ShapeEnum& Type2 = ShapeType(ToolSh);
- if(Type2 == TopAbs_COMPOUND || Type2 > TopAbs_FACE) return;
- TopTools_ListOfShape aList0;
- if (aResult.ShapeType() == TopAbs_COMPOUND) {
- TopoDS_Iterator itr(aResult);
- for (; itr.More(); itr.Next())
- aList0.Append(itr.Value()); //collect separated entities (bodies)
-
- }
- if(aList0.Extent() > 2) return; // case > 2 ent. is not considered
- TopTools_ListOfShape aList1, aList2;
- TopTools_ListIteratorOfListOfShape It (aList0); //each item (body) must have at least 1 pair
- // of "cyl/con" surfaces (in some cases may be 3 or 4 faces depending on sim-edge position)
- for (;It.More (); It.Next ()) {
- const TopoDS_Shape& aShape = It.Value (); //1-st solid/shell
- TopTools_ListOfShape aList;
- aList.Clear();
-#ifdef OCCT_DEBUG
-// ModDbgTools_Write(aShape, "S0");
-#endif
- if(aShape.ShapeType() != TopAbs_FACE) {
- TopExp_Explorer anExp(aShape, TopAbs_FACE);
- for(;anExp.More();anExp.Next()) {
- if(IsValidSurfType(TopoDS::Face(anExp.Current())))
- aList.Append(anExp.Current()); // faces of the current entity
- }
- } else
- if(IsValidSurfType(TopoDS::Face(ObjSh)))
- aList.Append(aShape);
-
- if(aList1.Extent() == 0 )
- aList1.Assign(aList);
- else
- aList2.Assign(aList);
- }
-// aList1,2 contain pairs of faces having more then 1 neghbour edge (each pair)
- const Standard_Integer aNF1 = aList1.Extent(); // keep n of faces of the first entity
- const Standard_Integer aNF2 = aList2.Extent(); // keep n of faces of the second entity
- if(aNF1 + aNF2 < 2) return;
-
-//find Edges
- TopTools_ListOfShape aListE1, aListE2;
- Standard_Integer aNE1=0,aNE2=0;
- if(aNF1 == 2 && !aNF2) {//trivial case - only 2 faces
- FindAdjacent2(aList1, aListE1);
- aNE1 = aListE1.Extent();
- }
- else { // result is compound of two ent.
- if (aNF1 == 2) //first ent. has 2 valid faces
- FindAdjacent2(aList1, aListE1); // find adjacent edges
- else if (aNF1 == 3) // first ent. has 3 valid faces
- FindAdjacent3(aList1, aListE1);
- else if (aNF1 == 4) //first ent. has 4 valid faces
- FindAdjacent4(aList1, aListE1);
-// set number of symmetry Edges of the first ent.
- aNE1 = aListE1.Extent();
-
-// Second ent.
- if (aNF2 == 2) //second ent. has 2 valid faces
- FindAdjacent2(aList2, aListE2);
- else if (aNF2 == 3)
- FindAdjacent3(aList2, aListE2);
- else if (aNF2 == 4)
- FindAdjacent4(aList2, aListE2);
-
- aNE2 = aListE2.Extent();
- }
-//aListE1, aListE2 - contains Edges
-// if(aNE1 < 2) return;
-// check topological compatibility
-//if exist
- Handle(TDataStd_IntegerArray) aSAR;
- if(!ResultLabel().FindAttribute(TDataStd_IntegerArray::GetID(), aSAR) ) {
- 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
- }
- 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!"<<endl;
- // mark all structure as Deleted
- Standard_Integer aN = aLabelEDS.Tag()+anAtt->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())));
- }
- }
- }
- }
- }
- }
-}
+++ /dev/null
-// 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 <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <QANewBRepNaming_TopNaming.hxx>
-#include <Standard_Boolean.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-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
//=======================================================================
QANewBRepNaming_Common::QANewBRepNaming_Common(const TDF_Label& ResultLabel)
- :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {}
+ :QANewBRepNaming_BooleanOperation(ResultLabel) {}
//=======================================================================
//function : Load
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-#include <QANewBRepNaming_BooleanOperationFeat.hxx>
+#include <QANewBRepNaming_BooleanOperation.hxx>
class TDF_Label;
class BRepAlgoAPI_BooleanOperation;
-class QANewBRepNaming_Common : public QANewBRepNaming_BooleanOperationFeat
+class QANewBRepNaming_Common : public QANewBRepNaming_BooleanOperation
{
public:
//=======================================================================
QANewBRepNaming_Cut::QANewBRepNaming_Cut(const TDF_Label& ResultLabel)
- :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {}
+ :QANewBRepNaming_BooleanOperation(ResultLabel) {}
//=======================================================================
//function : Load
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);
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-#include <QANewBRepNaming_BooleanOperationFeat.hxx>
+#include <QANewBRepNaming_BooleanOperation.hxx>
class TDF_Label;
class BRepAlgoAPI_BooleanOperation;
-class QANewBRepNaming_Cut : public QANewBRepNaming_BooleanOperationFeat
+class QANewBRepNaming_Cut : public QANewBRepNaming_BooleanOperation
{
public:
//=======================================================================
QANewBRepNaming_Fuse::QANewBRepNaming_Fuse(const TDF_Label& ResultLabel)
- :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {}
+ :QANewBRepNaming_BooleanOperation(ResultLabel) {}
//=======================================================================
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-#include <QANewBRepNaming_BooleanOperationFeat.hxx>
+#include <QANewBRepNaming_BooleanOperation.hxx>
class TDF_Label;
class BRepAlgoAPI_BooleanOperation;
-class QANewBRepNaming_Fuse : public QANewBRepNaming_BooleanOperationFeat
+class QANewBRepNaming_Fuse : public QANewBRepNaming_BooleanOperation
{
public:
//=======================================================================
QANewBRepNaming_Intersection::QANewBRepNaming_Intersection(const TDF_Label& ResultLabel)
- :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {}
+ :QANewBRepNaming_BooleanOperation(ResultLabel) {}
//=======================================================================
//function : Load
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-#include <QANewBRepNaming_BooleanOperationFeat.hxx>
+#include <QANewBRepNaming_BooleanOperation.hxx>
class TDF_Label;
class BRepAlgoAPI_BooleanOperation;
-class QANewBRepNaming_Intersection : public QANewBRepNaming_BooleanOperationFeat
+class QANewBRepNaming_Intersection : public QANewBRepNaming_BooleanOperation
{
public:
//=======================================================================
QANewBRepNaming_Limitation::QANewBRepNaming_Limitation(const TDF_Label& ResultLabel)
- :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {}
+ :QANewBRepNaming_BooleanOperation(ResultLabel) {}
//=======================================================================
//function : Load
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-#include <QANewBRepNaming_BooleanOperationFeat.hxx>
+#include <QANewBRepNaming_BooleanOperation.hxx>
class TDF_Label;
class QANewModTopOpe_Limitation;
-class QANewBRepNaming_Limitation : public QANewBRepNaming_BooleanOperationFeat
+class QANewBRepNaming_Limitation : public QANewBRepNaming_BooleanOperation
{
public:
#include <TopTools_MapOfShape.hxx>
//==============================================================
-//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;
}
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",
#include <Draw_Interpretor.hxx>
#include <Draw_Appli.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
-//#include <BRepAlgo_BooleanOperation.hxx>
-//#include <BRepAlgo_Fuse.hxx>
-//#include <BRepAlgo_Cut.hxx>
#include <BiTgte_Blend.hxx>
-#include <TopOpeBRepBuild_HBuilder.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Shape.hxx>
-pload QAcommands
-
puts "=================="
puts "BUC60669"
puts "=================="
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
-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 "=================="
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
-pload QAcommands
-
puts "========================"
puts "BUC60744"
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
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