]> OCCT Git - occt-copy.git/commitdiff
0025477: Boolean Operations with additional tolerance - Fuzzy Boolean operations
authoremv <emv@opencascade.com>
Wed, 19 Nov 2014 11:48:17 +0000 (14:48 +0300)
committeremv <emv@opencascade.com>
Thu, 20 Nov 2014 09:34:17 +0000 (12:34 +0300)
Patch for 6.7.1 version of OCCT.

32 files changed:
src/BOPAlgo/BOPAlgo_Algo.cdl
src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cdl
src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx
src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.lxx
src/BOPAlgo/BOPAlgo_Builder.cdl
src/BOPAlgo/BOPAlgo_Builder.cxx
src/BOPAlgo/BOPAlgo_CheckerSI.cxx
src/BOPAlgo/BOPAlgo_PaveFiller.cdl
src/BOPAlgo/BOPAlgo_PaveFiller.cxx
src/BOPCol/BOPCol.cdl
src/BOPCol/BOPCol_DataMapOfShapeReal.hxx [new file with mode: 0644]
src/BOPCol/FILES
src/BOPDS/BOPDS_DS.cdl
src/BOPDS/BOPDS_DS.cxx
src/BOPDS/BOPDS_DS.lxx
src/BOPTest/BOPTest_BOPCommands.cxx
src/BOPTest/BOPTest_CheckCommands.cxx
src/BOPTest/BOPTest_PartitionCommands.cxx
src/BOPTools/BOPTools_AlgoTools2D.cxx
src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cdl
src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Check.cdl
src/BRepAlgoAPI/BRepAlgoAPI_Check.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Common.cdl
src/BRepAlgoAPI/BRepAlgoAPI_Common.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Cut.cdl
src/BRepAlgoAPI/BRepAlgoAPI_Cut.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cdl
src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Section.cdl
src/GeomInt/GeomInt.cdl
src/GeomInt/GeomInt.cxx [new file with mode: 0644]

index 6b78ed69e730cb39a47fc088e7f2e7017e33ca04..744db0e1fe94c9879b532523766949f99146d5d6 100644 (file)
@@ -59,7 +59,7 @@ is
     RunParallel(me) 
        returns Boolean from Standard; 
     ---Purpose: Returns the flag of parallel processing  
+
 fields 
     myAllocator     : BaseAllocator from BOPCol is protected;
     myErrorStatus   : Integer from Standard is protected;       
index 47fa9f4943aaaa970442f8d0f6e30b70274f23cd..bc596b6a9b100c6a7644bef55b9f00398824575d 100644 (file)
@@ -14,6 +14,7 @@
 -- commercial license or contractual agreement.
 
 class ArgumentAnalyzer from BOPAlgo
+  inherits Algo from BOPAlgo
     ---Purpose: check the validity of argument(s) for Boolean Operations
     
 uses
@@ -21,11 +22,13 @@ uses
     Operation   from BOPAlgo, 
     CheckStatus from BOPAlgo,
     ShapeEnum  from TopAbs,
-    ListOfCheckResult from BOPAlgo
-    
+    ListOfCheckResult  from BOPAlgo, 
+    DataMapOfShapeReal from BOPCol 
+
 is
     Create
        returns ArgumentAnalyzer;
+    ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_ArgumentAnalyzer();"
     ---Purpose: empty constructor
 
     SetShape1(me: in out; TheShape: Shape from TopoDS);
@@ -158,7 +161,22 @@ is
 
 --  TestMergeFace(me: out)
 --  is protected;
+    SetFuzzyValue(me:out; 
+      theFuzz : Real from Standard);
+    ---C++: inline
+    ---Purpose: Sets the additional tolerance
+
+    FuzzyValue(me)
+    returns Real from Standard;
+    ---C++: inline
+    ---Purpose: Returns the additional tolerance 
 
+    UpdateTolerances(me:out); 
+    ---Purpose: Updates the shapes tolerance values.
+     
+    SetDefaultTolerances(me:out);
+    ---Purpose: Reverts the tolerance values for all entities to default values.
 
 fields
 
@@ -176,6 +194,7 @@ fields
     myContinuityMode   : Boolean   from Standard;
     myEmpty1,myEmpty2  : Boolean   from Standard; 
     myResult      : ListOfCheckResult from BOPAlgo; 
-    
-    
+    myFuzzyValue       : Real from Standard is protected;    
+    myToleranceMap     : DataMapOfShapeReal from BOPCol; 
+
 end ArgumentAnalyzer;
index 3326863a2d355bba19ffa8599a19b5b5faa666ce..198513721f248a2fd8fe3a06ec2a3a55bb9100ff 100644 (file)
 #include <Standard_Failure.hxx>
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
+
+#include <BRep_TVertex.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_TFace.hxx>
 #include <BRep_Builder.hxx>
 #include <BRep_Tool.hxx>
 #include <BRepExtrema_DistShapeShape.hxx>
@@ -53,6 +57,7 @@
 
 #include <BOPInt_Context.hxx>
 
+#include <BOPTools.hxx>
 #include <BOPTools_AlgoTools3D.hxx>
 #include <BOPTools_AlgoTools.hxx>
 #include <BOPCol_ListOfShape.hxx>
@@ -63,6 +68,7 @@
 // purpose:
 // ================================================================================
 BOPAlgo_ArgumentAnalyzer::BOPAlgo_ArgumentAnalyzer() : 
+BOPAlgo_Algo(),
 myStopOnFirst(Standard_False),
 myOperation(BOPAlgo_UNKNOWN),
 myArgumentTypeMode(Standard_False),
@@ -74,10 +80,20 @@ myMergeVertexMode(Standard_False),
 myMergeEdgeMode(Standard_False),
 myContinuityMode(Standard_False),
 myEmpty1(Standard_False),
-myEmpty2(Standard_False)
+myEmpty2(Standard_False),
+myFuzzyValue(0.)
 // myMergeFaceMode(Standard_False)
 {
 }
+//=======================================================================
+// function: ~
+// purpose: 
+//=======================================================================
+BOPAlgo_ArgumentAnalyzer::~BOPAlgo_ArgumentAnalyzer()
+{
+  myResult.Clear();
+  myToleranceMap.Clear();
+}
 
 // ================================================================================
 // function: SetShape1
@@ -159,6 +175,8 @@ void BOPAlgo_ArgumentAnalyzer::Perform()
 
     Prepare();
 
+    UpdateTolerances();
+
     if(myArgumentTypeMode) {
       TestTypes();
     }
@@ -202,6 +220,8 @@ void BOPAlgo_ArgumentAnalyzer::Perform()
     aResult.SetCheckStatus(BOPAlgo_CheckUnknown);
     myResult.Append(aResult);
   }
+  //
+  SetDefaultTolerances();
 }
 
 // ================================================================================
@@ -912,3 +932,122 @@ void BOPAlgo_ArgumentAnalyzer::TestContinuity()
 // {
   // not implemented
 // }
+
+// ================================================================================
+// function: UpdateTolerances
+// purpose:
+// ================================================================================
+void BOPAlgo_ArgumentAnalyzer::UpdateTolerances()
+{
+  if (myFuzzyValue == 0.) {
+    return;
+  }
+  //
+  BOPCol_MapOfShape aMapShapes;
+  //
+  if (!myShape1.IsNull()) {
+    BOPTools::MapShapes(myShape1, aMapShapes);
+  }
+  if (!myShape2.IsNull()) {
+    BOPTools::MapShapes(myShape2, aMapShapes);
+  }
+  //
+  if (aMapShapes.IsEmpty()) {
+    return;
+  }
+  //
+  Standard_Real aTol, aFuzz;
+  TopAbs_ShapeEnum aType;
+  BOPCol_MapIteratorOfMapOfShape aIt;
+  //
+  aFuzz = myFuzzyValue / 2.;
+  aIt.Initialize(aMapShapes);
+  for (; aIt.More(); aIt.Next()) {
+    const TopoDS_Shape& aS = aIt.Value();
+    aType = aS.ShapeType();
+    //
+    switch (aType) {
+    case TopAbs_VERTEX: {
+      const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aS;
+      const Handle(BRep_TVertex)& TV = 
+        *((Handle(BRep_TVertex)*)&aV.TShape());
+      aTol = TV->Tolerance();
+      myToleranceMap.Bind(aS, aTol);
+      TV->Tolerance(aTol + aFuzz);
+      break;
+    }
+    case TopAbs_EDGE: {
+      const TopoDS_Edge& aE = *(TopoDS_Edge*)&aS;
+      const Handle(BRep_TEdge)& TE = 
+        *((Handle(BRep_TEdge)*)&aE.TShape());
+      aTol = TE->Tolerance();
+      myToleranceMap.Bind(aS, aTol);
+      TE->Tolerance(aTol + aFuzz);
+      break;
+    }
+    case TopAbs_FACE: {
+      const TopoDS_Face& aF = *(TopoDS_Face*)&aS;
+      const Handle(BRep_TFace)& TF = 
+        *((Handle(BRep_TFace)*)&aF.TShape());
+      aTol = TF->Tolerance();
+      myToleranceMap.Bind(aS, aTol);
+      TF->Tolerance(aTol + aFuzz);
+      break;
+    }
+    default:
+      break;
+    } // switch (aType) {
+  } // for (; aIt.More(); aIt.Next()) {
+}
+
+// ================================================================================
+// function: SetDefaultTolerances
+// purpose:
+// ================================================================================
+void BOPAlgo_ArgumentAnalyzer::SetDefaultTolerances()
+{
+  if (myFuzzyValue == 0.) {
+    return;
+  }
+  //
+  if (myToleranceMap.IsEmpty()) {
+    return;
+  }
+  //
+  Standard_Real aTol;
+  TopAbs_ShapeEnum aType;
+  BOPCol_DataMapIteratorOfDataMapOfShapeReal aIt;
+  //
+  aIt.Initialize(myToleranceMap);
+  for (; aIt.More(); aIt.Next()) {
+    const TopoDS_Shape& aS = aIt.Key();
+    aTol = aIt.Value();
+    aType = aS.ShapeType();
+    //
+    switch (aType) {
+    case TopAbs_VERTEX: {
+      const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aS;
+      const Handle(BRep_TVertex)& TV = 
+        *((Handle(BRep_TVertex)*)&aV.TShape());
+      TV->Tolerance(aTol);
+      break;
+    }
+    case TopAbs_EDGE: {
+      const TopoDS_Edge& aE = *(TopoDS_Edge*)&aS;
+      const Handle(BRep_TEdge)& TE = 
+        *((Handle(BRep_TEdge)*)&aE.TShape());
+      TE->Tolerance(aTol);
+      break;
+    }
+    case TopAbs_FACE: {
+      const TopoDS_Face& aF = *(TopoDS_Face*)&aS;
+      const Handle(BRep_TFace)& TF = 
+        *((Handle(BRep_TFace)*)&aF.TShape());
+      TF->Tolerance(aTol);
+      break;
+    }
+    default:
+      break;
+    } // switch (aType) {
+  } // for (; aIt.More(); aIt.Next()) {
+}
index e248a057cc0f58ec762838d969c3a8789b2e1414..1b9291af71d5d3e300cdf8b3b4477af3427f565a 100644 (file)
@@ -57,6 +57,24 @@ inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::ContinuityMode()
   return myContinuityMode;
 }
 
+//=======================================================================
+//function : SetFuzzyValue
+//purpose  : 
+//=======================================================================
+inline void BOPAlgo_ArgumentAnalyzer::SetFuzzyValue(const Standard_Real theFuzz)
+{
+  if (theFuzz > 0.) {
+    myFuzzyValue = theFuzz;
+  }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose  : 
+//=======================================================================
+inline Standard_Real BOPAlgo_ArgumentAnalyzer::FuzzyValue() const
+{
+  return myFuzzyValue;
+}
 // inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeFaceMode() 
 // {
 //   return myMergeFaceMode;
index f28ffd7129e522148f2faeed8663fe7d8f1091f5..b37bec5cd987605a1906ba6610c0ebdbb4292043 100644 (file)
@@ -212,6 +212,14 @@ is
     returns DataMapOfShapeListOfShape from BOPCol; 
     ---C++: return const &       
     ---Purpose:  Returns mySplits. 
+
+    SetFuzzyValue(me:out; 
+      theFuzz : Real from Standard);
+    ---Purpose: Sets the additional tolerance
+
+    FuzzyValue(me)
+    returns Real from Standard;
+    ---Purpose: Returns the additional tolerance 
     
 fields 
     myArguments  : ListOfShape from BOPCol is protected; 
@@ -226,6 +234,8 @@ fields
     --
     mySplits     : DataMapOfShapeListOfShape from BOPCol is protected; 
     myOrigins    : DataMapOfShapeShape from BOPCol is protected; 
+
+    myFuzzyValue : Real from Standard is protected;
  
 end Builder;
 
index a015c50aca79c7353e7973ecc30868a728dcf0eb..cf5510bcd928f2079a97380df49fcdfc1bad718a 100644 (file)
@@ -40,7 +40,8 @@ BOPAlgo_Builder::BOPAlgo_Builder()
   myImages(100, myAllocator),
   myShapesSD(100, myAllocator),
   mySplits(100, myAllocator),
-  myOrigins(100, myAllocator)
+  myOrigins(100, myAllocator),
+  myFuzzyValue(0.)
 {
 }
 //=======================================================================
@@ -59,7 +60,8 @@ BOPAlgo_Builder::BOPAlgo_Builder
   myImages(100, myAllocator), 
   myShapesSD(100, myAllocator),
   mySplits(100, myAllocator),
-  myOrigins(100, myAllocator)
+  myOrigins(100, myAllocator),
+  myFuzzyValue(0.)
 {
 }
 //=======================================================================
@@ -156,6 +158,24 @@ BOPDS_PDS BOPAlgo_Builder::PDS()
   return myDS;
 }
 //=======================================================================
+//function : SetFuzzyValue
+//purpose  : 
+//=======================================================================
+void BOPAlgo_Builder::SetFuzzyValue(const Standard_Real theFuzz)
+{
+  if (theFuzz > 0.) {
+    myFuzzyValue = theFuzz;
+  }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose  : 
+//=======================================================================
+Standard_Real BOPAlgo_Builder::FuzzyValue() const
+{
+  return myFuzzyValue;
+}
+//=======================================================================
 // function: CheckData
 // purpose: 
 //=======================================================================
@@ -219,6 +239,7 @@ void BOPAlgo_Builder::Perform()
   BOPAlgo_PaveFiller* pPF=new BOPAlgo_PaveFiller(aAllocator);
   //
   pPF->SetArguments(myArguments);
+  pPF->SetFuzzyValue(myFuzzyValue);
   //
   pPF->Perform();
   //
index c6aa13319449b7dc91a5c4327ab8e371acc6ec90..67f364cb89f4b9ade66f0f1dde4b736386af44b0 100644 (file)
@@ -104,6 +104,7 @@ void BOPAlgo_CheckerSI::Init()
   // 1. myDS
   myDS=new BOPDS_DS(myAllocator);
   myDS->SetArguments(myArguments);
+  myDS->SetFuzzyValue(myFuzzyValue);
   myDS->Init();
   //
   // 2.myIterator 
index 32cc1d616ba4f18d6691a88ec5fb7ee78fd7dee7..a228c95e516e82a28fe4af9ba46ccd250089d413 100644 (file)
@@ -93,7 +93,10 @@ is
         theSecAttr : SectionAttribute from BOPAlgo); 
          
     Perform(me:out) 
-      is redefined;   
+      is redefined;    
+    PerformInternal (me:out) 
+      is virtual protected;   
     --  
     -- protected methods 
     -- 
@@ -442,12 +445,21 @@ is
     ---Purpose: 
     -- Updates pave blocks which have the paves with indices contained  
     -- in the map <theDMI>.
-        
+
+    SetFuzzyValue(me:out; 
+        theFuzz : Real from Standard);
+    ---Purpose: Sets the additional tolerance
+
+    FuzzyValue(me)
+    returns Real from Standard;
+    ---Purpose: Returns the additional tolerance 
 fields  
     myArguments   : ListOfShape from BOPCol is protected;  
     myDS          : PDS from BOPDS is protected; 
     myIterator    : PIterator from BOPDS is protected; 
     myContext     : Context from BOPInt is protected;   
     mySectionAttribute : SectionAttribute from BOPAlgo is protected;
+    myFuzzyValue  : Real from Standard is protected;
 
 end PaveFiller;
index c2788ce233b8d417b1979830f3b1012ac59a247e..ef12379301014dff9d3872a8c413cb06ca342401 100644 (file)
@@ -33,7 +33,8 @@
 //=======================================================================
 BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
 :
-  BOPAlgo_Algo()
+  BOPAlgo_Algo(),
+  myFuzzyValue(0.)
 {
   myDS=NULL;
   myIterator=NULL;
@@ -45,7 +46,8 @@ BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
 BOPAlgo_PaveFiller::BOPAlgo_PaveFiller
   (const Handle(NCollection_BaseAllocator)& theAllocator)
 :
-  BOPAlgo_Algo(theAllocator)
+  BOPAlgo_Algo(theAllocator),
+  myFuzzyValue(0.)
 {
   myDS=NULL;
   myIterator=NULL;
@@ -123,6 +125,24 @@ const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
   return myArguments;
 }
 //=======================================================================
+//function : SetFuzzyValue
+//purpose  : 
+//=======================================================================
+void BOPAlgo_PaveFiller::SetFuzzyValue(const Standard_Real theFuzz)
+{
+  if (theFuzz > 0.) {
+    myFuzzyValue = theFuzz;
+  }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose  : 
+//=======================================================================
+Standard_Real BOPAlgo_PaveFiller::FuzzyValue() const
+{
+  return myFuzzyValue;
+}
+//=======================================================================
 // function: Init
 // purpose: 
 //=======================================================================
@@ -141,6 +161,7 @@ void BOPAlgo_PaveFiller::Init()
   // 1.myDS 
   myDS=new BOPDS_DS(myAllocator);
   myDS->SetArguments(myArguments);
+  myDS->SetFuzzyValue(myFuzzyValue);
   myDS->Init();
   //
   // 2.myIterator 
@@ -163,67 +184,80 @@ void BOPAlgo_PaveFiller::Perform()
   try { 
     OCC_CATCH_SIGNALS
     //
-    Init();
-    if (myErrorStatus) {
-      return; 
-    }
-    // 00
-    PerformVV();
-    if (myErrorStatus) {
-      return; 
-    }
-    // 01
-    PerformVE();
-    if (myErrorStatus) {
-      return; 
-    }
-    //
-    myDS->UpdatePaveBlocks();
-    // 11
-    PerformEE();
-    if (myErrorStatus) {
-      return; 
-    }
-    // 02
-    PerformVF();
-    if (myErrorStatus) {
-      return; 
-    }
-    // 12
-    PerformEF();
-    if (myErrorStatus) {
-      return; 
-    }
-    //
-    MakeSplitEdges();
-    if (myErrorStatus) {
-      return; 
-    }
-    //
-    // 22
-    PerformFF();
-    if (myErrorStatus) {
-      return; 
-    }
-    //
-    MakeBlocks();
-    if (myErrorStatus) {
-      return; 
-    }
-    //
-    RefineFaceInfoOn();
-    //
-    MakePCurves();
-    if (myErrorStatus) {
-      return; 
-    }
-    //
-    ProcessDE();
-    if (myErrorStatus) {
-      return; 
-    }
-  } // try {
+    PerformInternal();
+  }
+  //
   catch (Standard_Failure) {
     myErrorStatus=11;
-  }  
+  }
+  //
+  myDS->SetDefaultTolerances();
+}
+//=======================================================================
+// function: PerformInternal
+// purpose: 
+//=======================================================================
+void BOPAlgo_PaveFiller::PerformInternal()
+{
+  myErrorStatus=0;
+  //
+  Init();
+  if (myErrorStatus) {
+    return; 
+  }
+  // 00
+  PerformVV();
+  if (myErrorStatus) {
+    return; 
+  }
+  // 01
+  PerformVE();
+  if (myErrorStatus) {
+    return; 
+  }
+  //
+  myDS->UpdatePaveBlocks();
+  // 11
+  PerformEE();
+  if (myErrorStatus) {
+    return; 
+  }
+  // 02
+  PerformVF();
+  if (myErrorStatus) {
+    return; 
+  }
+  // 12
+  PerformEF();
+  if (myErrorStatus) {
+    return; 
+  }
+  //
+  MakeSplitEdges();
+  if (myErrorStatus) {
+    return; 
+  }
+  //
+  // 22
+  PerformFF();
+  if (myErrorStatus) {
+    return; 
+  }
+  //
+  MakeBlocks();
+  if (myErrorStatus) {
+    return; 
+  }
+  //
+  RefineFaceInfoOn();
+  //
+  MakePCurves();
+  if (myErrorStatus) {
+    return; 
+  }
+  //
+  ProcessDE();
+  if (myErrorStatus) {
+    return; 
+  }
 }
index b34cd5c32fa339df07154e8a36b29b7a66fc5bdd..166837f1609b10c2291c536641a9780278bdd477 100644 (file)
@@ -23,7 +23,8 @@ uses
  
 is 
     imported BaseAllocator from BOPCol; 
-    imported DataMapOfShapeInteger from BOPCol; 
+    imported DataMapOfShapeInteger from BOPCol;  
+    imported DataMapOfShapeReal from BOPCol; 
     imported MapOfInteger from BOPCol; 
     imported ListOfInteger from BOPCol; 
     imported PInteger from BOPCol; 
diff --git a/src/BOPCol/BOPCol_DataMapOfShapeReal.hxx b/src/BOPCol/BOPCol_DataMapOfShapeReal.hxx
new file mode 100644 (file)
index 0000000..c61a7f0
--- /dev/null
@@ -0,0 +1,26 @@
+// Created by: Peter KURNEV
+// 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 BOPCol_DataMapOfShapeReal_HeaderFile
+#define BOPCol_DataMapOfShapeReal_HeaderFile
+
+#include <TopoDS_Shape.hxx>  
+#include <TopTools_ShapeMapHasher.hxx>
+  
+#include <NCollection_DataMap.hxx>
+
+typedef NCollection_DataMap<TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> BOPCol_DataMapOfShapeReal; 
+typedef BOPCol_DataMapOfShapeReal::Iterator BOPCol_DataMapIteratorOfDataMapOfShapeReal; 
+#endif
index 7245d70a192c383d3f965c288f1d5f837735cb16..4b61ab49f221e1ee6611904d2807238fbdd3d658 100644 (file)
@@ -36,3 +36,4 @@ BOPCol_BoxBndTree.hxx
 BOPCol_BoxBndTree.cxx
 BOPCol_Box2DBndTree.hxx
 BOPCol_Box2DBndTree.cxx
+BOPCol_DataMapOfShapeReal.hxx
index 2cb8087a14c9af8eaccfd012e7fc7ff82e83f52d..e92f3f9f145634ce4dee84aa74a4852a844a9e99 100644 (file)
@@ -39,6 +39,7 @@ uses
     -- 
     ListOfShape from BOPCol,  
     DataMapOfIntegerInteger from BOPCol,
+    DataMapOfIntegerReal    from BOPCol, 
     DataMapOfShapeInteger   from BOPCol, 
     ListOfInteger           from BOPCol, 
     MapOfInteger            from BOPCol, 
@@ -628,14 +629,24 @@ is
              ---
  
     BuildBndBoxSolid (me:out; 
-               theIndex:Integer from Standard;  
-               theBox:out Box from Bnd) 
-       is protected;  
-           ---Purpose: 
-            --- Computes bouding box <theBox> for the solid with DS-index <theIndex>
-            ---  
-           
+                 theIndex:Integer from Standard;  
+                 theBox:out Box from Bnd) 
+    is protected;  
+    ---Purpose: 
+    -- Computes bouding box <theBox> for the solid with DS-index <theIndex>
 
+    SetFuzzyValue(me:out; 
+                theFuzz : Real from Standard);
+    ---C++: inline 
+    ---Purpose: Sets the extended tolerance
+    FuzzyValue(me)
+             returns Real from Standard;
+    ---C++: inline 
+    ---Purpose: Returns the extended tolerance 
+     
+    SetDefaultTolerances(me:out);
+    ---Purpose: Reverts the tolerance values of unchanged entities to default values.
  
 fields  
     myAllocator        : BaseAllocator from BOPCol is protected;
@@ -666,4 +677,9 @@ fields
     myInterfEZ         : VectorOfInterfEZ from BOPDS is protected;
     myInterfFZ         : VectorOfInterfFZ from BOPDS is protected;
     myInterfZZ         : VectorOfInterfZZ from BOPDS is protected;
+    -- 
+    -- extended tolerance for intersection
+    myFuzzyValue       : Real from Standard is protected;
+    myToleranceMap     : DataMapOfIntegerReal from BOPCol is protected; 
 end DS;
index b9495103eda368c8eb7d1d478fc16bfe8d9236f9..2886c2787ca65b4015a075840da6530d2a5459de 100644 (file)
 #include <gp_Pnt.hxx>
 #include <Bnd_Box.hxx>
 //
+#include <BRep_TVertex.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_TFace.hxx>
+#include <BRep_Tool.hxx>
+//
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
-#include <BRep_Tool.hxx>
 //
 #include <BRepBndLib.hxx>
 //
 #include <BOPCol_MapOfInteger.hxx>
 #include <BOPCol_ListOfInteger.hxx>
 #include <BOPCol_DataMapOfShapeInteger.hxx>
+#include <BOPDS_PDS.hxx>
+#include <BOPCol_DataMapOfIntegerMapOfInteger.hxx>
 //
 #include <BOPDS_IndexRange.hxx>
 #include <BOPDS_ShapeInfo.hxx>
@@ -65,6 +71,16 @@ static
 static
   void SortShell(const int n, BOPDS_Pave *a);
 
+static 
+  void AddShapeAndSubShapes(const Standard_Integer nS,
+                            const BOPDS_ShapeInfo& theSI,
+                            BOPCol_MapOfInteger& theMI);
+
+static 
+  void CollectEdges(const BOPDS_PDS& pDS,
+                    const Standard_Integer nF,
+                    BOPCol_MapOfInteger& theMI);
+
 //=======================================================================
 //function : 
 //purpose  : 
@@ -90,7 +106,9 @@ BOPDS_DS::BOPDS_DS()
   myInterfVZ(myAllocator),
   myInterfEZ(myAllocator),
   myInterfFZ(myAllocator),
-  myInterfZZ(myAllocator)
+  myInterfZZ(myAllocator),
+  myFuzzyValue(0.),
+  myToleranceMap(100, myAllocator)
 {
   myNbShapes=0;
   myNbSourceShapes=0;
@@ -120,7 +138,9 @@ BOPDS_DS::BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator)
   myInterfVZ(myAllocator),
   myInterfEZ(myAllocator),
   myInterfFZ(myAllocator),
-  myInterfZZ(myAllocator)
+  myInterfZZ(myAllocator),
+  myFuzzyValue(0.),
+  myToleranceMap(100, myAllocator)
 {
   myNbShapes=0;
   myNbSourceShapes=0;
@@ -141,6 +161,7 @@ void BOPDS_DS::Clear()
 {
   myNbShapes=0;
   myNbSourceShapes=0;
+  myFuzzyValue=0.;
   //
   myArguments.Clear();
   myRanges.Clear();
@@ -161,6 +182,7 @@ void BOPDS_DS::Clear()
   myInterfEZ.Clear();
   myInterfFZ.Clear();
   myInterfZZ.Clear();
+  myToleranceMap.Clear();
 }
 //=======================================================================
 //function : SetArguments
@@ -400,7 +422,15 @@ void BOPDS_DS::Init()
       Bnd_Box& aBox=aSI.ChangeBox();
       const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aS);
       const gp_Pnt& aP=BRep_Tool::Pnt(aV);
-      aTol=BRep_Tool::Tolerance(aV);
+      //
+      const Handle(BRep_TVertex)& TV = 
+        *((Handle(BRep_TVertex)*)&aV.TShape());
+      aTol = TV->Tolerance();
+      //
+      myToleranceMap.Bind(j, aTol);
+      aTol += myFuzzyValue;
+      TV->Tolerance(aTol);
+      //
       aBox.SetGap(aTol);
       aBox.Add(aP);
     }
@@ -414,7 +444,14 @@ void BOPDS_DS::Init()
     if (aTS==TopAbs_EDGE) {
       const TopoDS_Shape& aS=aSI.Shape();
       const TopoDS_Edge& aE=*((TopoDS_Edge*)&aS);
-      aTol=BRep_Tool::Tolerance(aE);
+      //
+      const Handle(BRep_TEdge)& TE = 
+        *((Handle(BRep_TEdge)*)&aE.TShape());
+      aTol = TE->Tolerance();
+      //
+      myToleranceMap.Bind(j, aTol);
+      aTol += myFuzzyValue;
+      TE->Tolerance(aTol);
       //
       if (!BRep_Tool::Degenerated(aE)) {
         Standard_Boolean bInf1, bInf2;
@@ -491,7 +528,14 @@ void BOPDS_DS::Init()
     if (aTS==TopAbs_FACE) {
       const TopoDS_Shape& aS=aSI.Shape();
       const TopoDS_Face& aF=*((TopoDS_Face*)&aS);
-      aTol=BRep_Tool::Tolerance(aF);
+      //
+      const Handle(BRep_TFace)& TF = 
+        *((Handle(BRep_TFace)*)&aF.TShape());
+      aTol = TF->Tolerance();
+      //
+      myToleranceMap.Bind(j, aTol);
+      aTol += myFuzzyValue;
+      TF->Tolerance(aTol);
       //
       Bnd_Box& aBox=aSI.ChangeBox();
       BRepBndLib::Add(aS, aBox);
@@ -2011,3 +2055,236 @@ void BOPDS_DS::BuildBndBoxSolid(const Standard_Integer theIndex,
     }
   }
 }
+
+//=======================================================================
+//function : DefaultTolerances
+//purpose  : 
+//=======================================================================
+void BOPDS_DS::SetDefaultTolerances()
+{
+  if (myFuzzyValue == 0.) {
+    return;
+  }
+  //
+  Standard_Boolean bAdd;
+  Standard_Integer i, j, n1, n2, nS, nSOp, nSs;
+  Standard_Integer anIntType, aNbFF, aNbFIn;
+  Standard_Real aTolDef;
+  TopAbs_ShapeEnum aTS1, aTS2;
+  BOPCol_MapOfInteger aMICh;
+  BOPCol_DataMapOfIntegerMapOfInteger aDMI;
+  BOPCol_ListIteratorOfListOfInteger aItLI;
+  BOPDS_MapIteratorMapOfPassKey aItPK;
+  BOPDS_ListIteratorOfListOfPaveBlock aItPB;
+  BOPCol_MapIteratorOfMapOfInteger aItMI;
+  BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItDMIR;
+  //
+  // 1. Collect interfered shapes
+  // 1.1. Interferences V/V, V/E, V/F, E/E and E/F
+  aItPK.Initialize(myInterfTB);
+  for (; aItPK.More(); aItPK.Next()) {
+    const BOPDS_PassKey& aPK = aItPK.Value();
+    aPK.Ids(n1, n2);
+    //
+    const BOPDS_ShapeInfo& aSI1 = ShapeInfo(n1);
+    const BOPDS_ShapeInfo& aSI2 = ShapeInfo(n2);
+    //
+    aTS1 = aSI1.ShapeType();
+    aTS2 = aSI2.ShapeType();
+    //
+    anIntType = BOPDS_Tools::TypeToInteger(aTS1, aTS2);
+    if (anIntType < 5) {
+      AddShapeAndSubShapes(n1, aSI1, aMICh);
+      AddShapeAndSubShapes(n2, aSI2, aMICh);
+    } // if (anIntType < 5) {
+  } // for (; aIt.More(); aIt.Next()) {
+  //
+  // 1.2 FaceInfo information
+  aNbFF = myFaceInfoPool.Extent();
+  for (i = 0; i < aNbFF; ++i) {
+    const BOPDS_FaceInfo& aFI = myFaceInfoPool(i);
+    nS = aFI.Index();
+    if (aMICh.Contains(nS)) {
+      continue;
+    }
+    //
+    aNbFIn = (aFI.PaveBlocksIn().Extent() + 
+              aFI.VerticesIn().Extent() +
+              aFI.PaveBlocksSc().Extent() +
+              aFI.VerticesSc().Extent());
+    if (aNbFIn > 0) {
+      AddShapeAndSubShapes(nS, ShapeInfo(nS), aMICh);
+    } // if (aNbFIn > 0) {
+  } // for (i = 0; i < aNbFF; ++i) {
+  //
+  // 1.3. Empty F/F interferences
+  aNbFF = myInterfFF.Extent();
+  for (i = 0; i < aNbFF; ++i) {
+    BOPDS_InterfFF& aFF = myInterfFF(i);
+    if ((aFF.Curves().Extent() == 0) &&
+        (aFF.Points().Extent() == 0)) {
+      aFF.Indices(n1, n2);
+      for (j = 0; j < 2; ++j) {
+        nS = !j ? n1 : n2;
+        if (aMICh.Contains(nS)) {
+          continue;
+        }
+        nSOp = !j ? n2 : n1;
+        //
+        BOPCol_MapOfInteger aME, aMEOp;
+        //
+        if (aDMI.IsBound(nS)) {
+          aME = aDMI.Find(nS);
+        } else {
+          CollectEdges(this, nS, aME);
+          aDMI.Bind(nS, aME);
+        }
+        //
+        if (aDMI.IsBound(nSOp)) {
+          aMEOp = aDMI.Find(nSOp);
+        } else {
+          CollectEdges(this, nSOp, aMEOp);
+          aDMI.Bind(nSOp, aMEOp);
+        }
+        //
+        bAdd = Standard_True;
+        aItMI.Initialize(aME);
+        for (; aItMI.More(); aItMI.Next()) {
+          nSs = aItMI.Value();
+          if (!aMEOp.Contains(nSs)) {
+            bAdd = Standard_False;
+            break;
+          }
+        }
+        //
+        if (bAdd) {
+          AddShapeAndSubShapes(nS, ShapeInfo(nS), aMICh);
+          if (j == 0) {
+            AddShapeAndSubShapes(nSOp, ShapeInfo(nSOp), aMICh);
+          }
+        } // if (bAdd) {
+      } // for (j = 0; j < 2; ++j) {
+    } //if ((aFF.Curves().Extent() == 0) &&
+  } // for (i = 0; i < aNbFF; ++i) {
+  //
+  // 2. Back to default tolerance values
+  aItDMIR.Initialize(myToleranceMap);
+  for (; aItDMIR.More(); aItDMIR.Next()) {
+    i = aItDMIR.Key();
+    //
+    if (aMICh.Contains(i)) {
+      continue;
+    }
+    //
+    const BOPDS_ShapeInfo& aSI = ShapeInfo(i);
+    aTolDef = aItDMIR.Value();
+    aTS1 = aSI.ShapeType();
+    switch (aTS1) {
+      case TopAbs_VERTEX: {
+        const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSI.Shape();
+        const Handle(BRep_TVertex)& aTV = 
+          *((Handle(BRep_TVertex)*)&aV.TShape());
+        aTV->Tolerance(aTolDef);
+        break;
+      }
+      case TopAbs_EDGE: {
+        const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSI.Shape();
+        const Handle(BRep_TEdge)& aTE = 
+          *((Handle(BRep_TEdge)*)&aE.TShape());
+        aTE->Tolerance(aTolDef);
+        //
+        const BOPDS_ListOfPaveBlock& aLPB = PaveBlocks(i);
+        aItPB.Initialize(aLPB);
+        for (; aItPB.More(); aItPB.Next()) {
+          const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
+          nS = aPB->Edge();
+          const TopoDS_Edge& aEIm = *(TopoDS_Edge*)&Shape(nS);
+          const Handle(BRep_TEdge)& aTEIm = 
+          *((Handle(BRep_TEdge)*)&aEIm.TShape());
+          aTEIm->Tolerance(aTolDef);
+        }
+        break;
+      }
+      case TopAbs_FACE: {
+        const TopoDS_Face& aF = *(TopoDS_Face*)&aSI.Shape();
+        const Handle(BRep_TFace)& aTF = 
+          *((Handle(BRep_TFace)*)&aF.TShape());
+        aTF->Tolerance(aTolDef);
+        break;
+      }
+      default:
+        break;
+    } // switch (aTS1) {
+  } // for (; aItDMIR.More(); aItDMIR.Next()) {
+}
+
+//=======================================================================
+//function : AddShapeAndSubShapes
+//purpose  : 
+//=======================================================================
+void AddShapeAndSubShapes(const Standard_Integer nS,
+                          const BOPDS_ShapeInfo& theSI,
+                          BOPCol_MapOfInteger& theMI)
+{
+  Standard_Integer nSs;
+  if (theMI.Add(nS)) {
+    const BOPCol_ListOfInteger& aLI = theSI.SubShapes();
+    BOPCol_ListIteratorOfListOfInteger aItLI(aLI);
+    for (; aItLI.More(); aItLI.Next()) {
+      nSs = aItLI.Value();
+      theMI.Add(nSs);
+    }
+  }
+}
+
+//=======================================================================
+//function : CollectEdges
+//purpose  : 
+//=======================================================================
+void CollectEdges(const BOPDS_PDS& pDS,
+                  const Standard_Integer nF,
+                  BOPCol_MapOfInteger& theMI)
+{
+  Standard_Integer i, j, aNbPB, nE, nEIm;
+  BOPCol_ListIteratorOfListOfInteger aItLI;
+  BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
+  //
+  // ON edges
+  const BOPDS_ShapeInfo& aSI = pDS->ShapeInfo(nF);
+  const BOPCol_ListOfInteger& aLI = aSI.SubShapes();
+  aItLI.Initialize(aLI);
+  for (; aItLI.More(); aItLI.Next()) {
+    nE = aItLI.Value();
+    const BOPDS_ShapeInfo& aSIE = pDS->ShapeInfo(nE);
+    if (aSIE.ShapeType() != TopAbs_EDGE) {
+      continue;
+    }
+    //
+    if (!aSIE.HasReference()) {
+      theMI.Add(nE);
+      continue;
+    }
+    //
+    const BOPDS_ListOfPaveBlock& aLPB = pDS->PaveBlocks(nE);
+    aItLPB.Initialize(aLPB);
+    for (; aItLPB.More(); aItLPB.Next()) {
+      const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value();
+      nEIm = aPB->Edge();
+      theMI.Add(nEIm);
+    }
+  }
+  // IN and SC edges
+  const BOPDS_FaceInfo& aFI = pDS->FaceInfo(nF);
+  const BOPDS_IndexedMapOfPaveBlock& aMPBIn = aFI.PaveBlocksIn();
+  const BOPDS_IndexedMapOfPaveBlock& aMPBSc = aFI.PaveBlocksSc();
+  //
+  for (i = 0; i < 2; ++i) {
+    const BOPDS_IndexedMapOfPaveBlock& aMPB = !i ? aMPBIn : aMPBSc;
+    aNbPB = aMPB.Extent();
+    for (j = 1; j <= aNbPB; ++j) {
+      const Handle(BOPDS_PaveBlock)& aPB = aMPB(j);
+      nE = aPB->Edge();
+      theMI.Add(nE);
+    }
+  }
+}
index ba91eccd4efa30f4ccf15d4966de230921b7525b..663c1cd983d3c2156a635c3a9e7c09ac200b9104 100644 (file)
@@ -105,7 +105,7 @@ inline Standard_Integer BOPDS_DS::NbInterfTypes()
 //purpose  : 
 //=======================================================================
 inline void BOPDS_DS::AddInterf(const Standard_Integer theI1,
-                               const Standard_Integer theI2)
+                                const Standard_Integer theI2)
 {
   BOPDS_PassKey aPK;
   //
@@ -133,3 +133,21 @@ inline const BOPDS_MapOfPassKey& BOPDS_DS::Interferences()const
 {
   return myInterfTB;
 }
+//=======================================================================
+//function : SetFuzzyValue
+//purpose  : 
+//=======================================================================
+inline void BOPDS_DS::SetFuzzyValue(const Standard_Real theFuzz)
+{
+  if (theFuzz > 0.) {
+    myFuzzyValue = theFuzz / 2.;
+  }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose  : 
+//=======================================================================
+inline Standard_Real BOPDS_DS::FuzzyValue() const
+{
+  return 2 * myFuzzyValue;
+}
index 119bfc3d4f4c211329ebc6350a2102d0c6dba3e7..5bedf15de20244976cb3b22b62dfe1831134c904 100644 (file)
@@ -44,6 +44,7 @@
 #include <BRepAlgoAPI_Fuse.hxx>
 #include <BRepAlgoAPI_Cut.hxx>
 #include <BRepAlgoAPI_Section.hxx>
+#include <TopoDS_Iterator.hxx>
 
 //
 static BOPAlgo_PaveFiller* pPF=NULL;
@@ -89,18 +90,18 @@ static Standard_Integer bopnews   (Draw_Interpretor&, Standard_Integer, const ch
   const char* g = "BOP commands";
   // Commands
   
-  theCommands.Add("bop"       , "use bop s1 s2"   , __FILE__, bop, g);
+  theCommands.Add("bop"       , "use bop s1 s2 [tol]" , __FILE__, bop, g);
   theCommands.Add("bopcommon" , "use bopcommon r" , __FILE__, bopcommon, g);
   theCommands.Add("bopfuse"   , "use bopfuse r"   , __FILE__,bopfuse, g);
-  theCommands.Add("bopcut"    , "use bopcut"      , __FILE__,bopcut, g);
-  theCommands.Add("boptuc"    , "use boptuc"      , __FILE__,boptuc, g);
-  theCommands.Add("bopsection", "use bopsection"  , __FILE__,bopsection, g);
-  //
-  theCommands.Add("bcommon" , "use bcommon r s1 s2" , __FILE__,bcommon, g);
-  theCommands.Add("bfuse"   , "use bfuse r s1 s2"   , __FILE__,bfuse, g);
-  theCommands.Add("bcut"    , "use bcut r s1 s2"    , __FILE__,bcut, g);
-  theCommands.Add("btuc"    , "use btuc r s1 s2"    , __FILE__,btuc, g);
-  theCommands.Add("bsection", "Use >bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na]", 
+  theCommands.Add("bopcut"    , "use bopcut r"        , __FILE__,bopcut, g);
+  theCommands.Add("boptuc"    , "use boptuc r"        , __FILE__,boptuc, g);
+  theCommands.Add("bopsection", "use bopsection r"    , __FILE__,bopsection, g);
+  //
+  theCommands.Add("bcommon" , "use bcommon r s1 s2 [tol]" , __FILE__,bcommon, g);
+  theCommands.Add("bfuse"   , "use bfuse r s1 s2 [tol]"   , __FILE__,bfuse, g);
+  theCommands.Add("bcut"    , "use bcut r s1 s2 [tol]"    , __FILE__,bcut, g);
+  theCommands.Add("btuc"    , "use btuc r s1 s2 [tol]"    , __FILE__,btuc, g);
+  theCommands.Add("bsection", "Use >bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]", 
                                                       __FILE__, bsection, g);
   //
   theCommands.Add("bopcurves", "use  bopcurves F1 F2 [-2d]", __FILE__, bopcurves, g);
@@ -115,11 +116,12 @@ Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
 {
   char buf[32];
   Standard_Integer iErr;
+  Standard_Real aTol;
   TopoDS_Shape aS1, aS2;
   BOPCol_ListOfShape aLC;
   //
-  if (n!=3) {
-    di << " use bop Shape1 Shape2\n";
+  if (n < 3 || n > 4) {
+    di << " use bop Shape1 Shape2 [tol]\n";
     return 1;
   }
   //
@@ -131,6 +133,11 @@ Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
     return 1;
   }
   //
+  aTol = 0.;
+  if (n == 4) {
+    aTol = Draw::Atof(a[3]);
+  }
+  //
   aLC.Append(aS1);
   aLC.Append(aS2);
   //
@@ -142,6 +149,7 @@ Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
   pPF=new BOPAlgo_PaveFiller(aAL);
   //
   pPF->SetArguments(aLC);
+  pPF->SetFuzzyValue(aTol);
   //
   pPF->Perform();
   iErr=pPF->ErrorStatus();
@@ -203,7 +211,7 @@ Standard_Integer bopsmt(Draw_Interpretor& di,
                         const BOPAlgo_Operation aOp)
 {
   if (n<2) {
-    di << " use bopsmt r\n";
+    di << " use bopsmt r\n [tol]";
     return 0;
   }
   //
@@ -293,101 +301,74 @@ Standard_Integer  bsection(Draw_Interpretor& di,
                            Standard_Integer n, 
                            const char** a)
 {
-  const char* usage = " Usage: bsection Result s1 s2 [-n2d/-n2d1/-n2d2] [-na]\n";
+  const char* usage = " Usage: bsection Result s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]\n";
   if (n < 4) {
     di << usage;
     return 1;
   }
-
+  //
   TopoDS_Shape aS1 = DBRep::Get(a[2]);
   TopoDS_Shape aS2 = DBRep::Get(a[3]);
-  
+  //
   if (aS1.IsNull() || aS2.IsNull()) {
     di << " Null shapes are not allowed \n";
     return 1;
   }
-
+  //
   Standard_Boolean bApp, bPC1, bPC2;
+  Standard_Integer i;
+  Standard_Real aTol;
   //
   bApp = Standard_True;
   bPC1 = Standard_True;
   bPC2 = Standard_True;
-  
-  Standard_Boolean isbadparameter = Standard_False;
-  
-  if(n > 4) {
-    const char* key1 = a[4];
-    const char* key2 = (n > 5) ? a[5] : NULL;
-    const char* pcurveconf = NULL;
-
-    if (key1 && (!strcasecmp(key1,"-n2d") || !strcasecmp(key1,"-n2d1") || !strcasecmp(key1,"-n2d2"))) {
-      pcurveconf = key1;
+  aTol = 0.;
+  //
+  for (i = 4; i < n; ++i) {
+    if (!strcmp(a[i], "-n2d")) {
+      bPC1 = Standard_False;
+      bPC2 = Standard_False;
     }
-    else {
-      if (!strcasecmp(key1,"-na")) {
-        bApp = Standard_False;
-      }
-      else {
-        isbadparameter = Standard_True;
-      }
+    else if (!strcmp(a[i], "-n2d1")) {
+      bPC1 = Standard_False;
     }
-    if (key2) {
-      if(!strcasecmp(key2,"-na")) {
-        bApp = Standard_False;
-      }
-      else {
-        isbadparameter = Standard_True;
-      }
+    else if (!strcmp(a[i], "-n2d2")) {
+      bPC2 = Standard_False;
     }
-
-    if(!isbadparameter && pcurveconf) {      
-      if (!strcasecmp(pcurveconf, "-n2d1")) {
-        bPC1 = Standard_False;
+    else if (!strcmp(a[i], "-na")) {
+        bApp = Standard_False;
       }
       else {
-        if (!strcasecmp(pcurveconf, "-n2d2")) {
-          bPC2 = Standard_False;
-        }
-        else {
-          if (!strcasecmp(pcurveconf, "-n2d")) {
-            bPC1 = Standard_False;
-            bPC2 = Standard_False;
-          }
-        }
+      aTol = Draw::Atof(a[i]);
       }
     }
-  }
-      
-  if(!isbadparameter) {
-    Standard_Integer iErr;
-    char buf[80];
-    //
-    BRepAlgoAPI_Section aSec(aS1, aS2, Standard_False);
-    aSec.Approximation(bApp);
-    aSec.ComputePCurveOn1(bPC1);
-    aSec.ComputePCurveOn2(bPC2);
-    //
-    aSec.Build();
-    iErr=aSec.ErrorStatus();
-    if (!aSec.IsDone()) {
-      Sprintf(buf, " ErrorStatus : %d\n",  iErr);
-      di << buf;
-      return 0;
-    }
-    //
-    const TopoDS_Shape& aR=aSec.Shape();
-    if (aR.IsNull()) {
-      di << " null shape\n";
-      return 0;
-    }
-    DBRep::Set(a[1], aR);
+  //
+  Standard_Integer iErr;
+  char buf[80];
+  //
+  BRepAlgoAPI_Section aSec(aS1, aS2, Standard_False);
+  aSec.Approximation(bApp);
+  aSec.ComputePCurveOn1(bPC1);
+  aSec.ComputePCurveOn2(bPC2);
+  aSec.SetFuzzyValue(aTol);
+  //
+  aSec.Build();
+  iErr=aSec.ErrorStatus();
+  if (!aSec.IsDone()) {
+    Sprintf(buf, " ErrorStatus : %d\n",  iErr);
+    di << buf;
     return 0;
   }
-  else {
-    di << usage;
-    return 1;
+  //
+  const TopoDS_Shape& aR=aSec.Shape();
+  if (aR.IsNull()) {
+    di << " null shape\n";
+    return 0;
   }
+  DBRep::Set(a[1], aR);
+  return 0;
 }
+
 //=======================================================================
 //function : bsmt
 //purpose  : 
@@ -401,9 +382,10 @@ Standard_Integer bsmt (Draw_Interpretor& di,
   Standard_Integer iErr;
   TopoDS_Shape aS1, aS2;
   BOPCol_ListOfShape aLC;
+  Standard_Real aTol;
   //
-  if (n!=4) {
-    di << " use bx r s1 s2\n";
+  if (n < 4 || n > 5) {
+    di << " use bx r s1 s2 [tol]\n";
     return 1;
   }
   //
@@ -414,6 +396,12 @@ Standard_Integer bsmt (Draw_Interpretor& di,
     di << " null shapes are not allowed \n";
     return 1;
   }
+  //
+  aTol = 0.;
+  if (n == 5) {
+    aTol = Draw::Atof(a[4]);
+  }
+  //
   aLC.Append(aS1);
   aLC.Append(aS2);
   //
@@ -421,6 +409,7 @@ Standard_Integer bsmt (Draw_Interpretor& di,
   BOPAlgo_PaveFiller aPF(aAL);
   //
   aPF.SetArguments(aLC);
+  aPF.SetFuzzyValue(aTol);
   //
   aPF.Perform();
   iErr=aPF.ErrorStatus();
index c93f5f8c0affbc872cc3cb26130fc42dbf17ff64..916ed23e3e4d850df063802c264f67474e09faa5 100644 (file)
@@ -87,7 +87,7 @@ Standard_Integer bopcheck
   (Draw_Interpretor& di, Standard_Integer n,  const char** a )
 {
   if (n<2) {
-    di << " Use >bopcheck Shape [level of check: 0 - 9" << "\n";
+    di << " Use >bopcheck Shape [level of check: 0 - 9] [-tol tol]" << "\n";
     di << " The level of check defines "; 
     di << " which interferences will be checked:\n";
     di << " 0 - V/V only\n"; 
@@ -110,12 +110,29 @@ Standard_Integer bopcheck
     return 1;
   }
   //
-  Standard_Integer theLevelOfCheck, aNbInterfTypes;
+  Standard_Integer theLevelOfCheck, aNbInterfTypes, iTol;
+  Standard_Boolean bLevel;
+  Standard_Real aTolerance;
   //
   aNbInterfTypes=BOPDS_DS::NbInterfTypes();
   //
-  theLevelOfCheck = (n==3) ? Draw::Atoi(a[2]) : aNbInterfTypes-1;
-  if (theLevelOfCheck > aNbInterfTypes-1) {
+  aTolerance = 0.;
+  bLevel = Standard_False;
+  theLevelOfCheck = aNbInterfTypes-1;
+  if (n > 2) {
+    if (a[2][0] != '-') {
+      theLevelOfCheck = Draw::Atoi(a[2]); 
+      bLevel = Standard_True;
+    }
+    //
+    iTol = bLevel ? 3 : 2;
+    if (iTol + 1 < n) {
+      if (!strcmp(a[iTol], "-tol")) {
+        aTolerance = Draw::Atof(a[iTol+1]);
+      }
+    }
+  }
+  if (theLevelOfCheck < 0 || theLevelOfCheck > aNbInterfTypes-1) {
     di << "Invalid level";
     return 1;
   }
@@ -145,6 +162,7 @@ Standard_Integer bopcheck
   anArgs.Append(aS);
   aChecker.SetArguments(anArgs);
   aChecker.SetLevelOfCheck(theLevelOfCheck);
+  aChecker.SetFuzzyValue(aTolerance);
   //
   aChecker.Perform();
   iErr = aChecker.ErrorStatus();
@@ -324,7 +342,7 @@ Standard_Integer bopargcheck
   if (n<2) {
     di << "\n";
     di << " Use >bopargcheck Shape1 [[Shape2] ";
-    di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P]] [#BF]" << "\n" << "\n";
+    di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P]] [#BF] [-tol tol]" << "\n" << "\n";
     di << " -<Boolean Operation>" << "\n";
     di << " F (fuse)" << "\n";
     di << " O (common)" << "\n";
@@ -377,11 +395,19 @@ Standard_Integer bopargcheck
   Standard_Integer indxAD = 0;
   Standard_Boolean isS2 = Standard_False;
   Standard_Integer indxS2 = 0;
+  Standard_Real aTolerance = 0;
 
   if(n >= 3) {
     Standard_Integer iIndex = 0;
     for(iIndex = 2; iIndex < n; iIndex++) {
-      if(a[iIndex][0] == '-')
+      if(!strcmp(a[iIndex], "-tol"))
+      {
+        if ((iIndex+1) < n) {
+          ++iIndex;
+          aTolerance = Draw::Atof(a[iIndex]);
+        }
+      }
+      else if(a[iIndex][0] == '-')
       {
         isBO = Standard_True;
         indxBO = iIndex;
@@ -424,6 +450,7 @@ Standard_Integer bopargcheck
 
   // init checker
   BOPAlgo_ArgumentAnalyzer aChecker;
+  aChecker.SetFuzzyValue(aTolerance);
   aChecker.SetShape1(aS1);
 
   // set default options (always tested!) for single and couple shapes
index d01c630de9918665178d6cfbaa7a8e8f396eef49..f9f70a1f185a9c7f1bb7cddf93aaaa328b75c189 100644 (file)
@@ -117,10 +117,10 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
   // Chapter's name
   const char* g = "Partition commands";
   // Commands  
-  theCommands.Add("bfillds"  , "use bfillds [-s -t]" , __FILE__, bfillds, g);
-  theCommands.Add("bbuild"   , "use bbuild r [-s -t]", __FILE__, bbuild, g);
-  theCommands.Add("bbop"     , "use bbop r op"       , __FILE__, bbop, g);
-  theCommands.Add("bclear"   , "use bclear"          , __FILE__, bclear, g);
+  theCommands.Add("bfillds"  , "use bfillds [-s -t] [tol]" , __FILE__, bfillds, g);
+  theCommands.Add("bbuild"   , "use bbuild r [-s -t]"      , __FILE__, bbuild, g);
+  theCommands.Add("bbop"     , "use bbop r op"             , __FILE__, bbop, g);
+  theCommands.Add("bclear"   , "use bclear"                , __FILE__, bclear, g);
 }
 
 //=======================================================================
@@ -147,14 +147,15 @@ Standard_Integer bfillds(Draw_Interpretor& di,
                          Standard_Integer n, 
                          const char** a) 
 { 
-  if (n>3) {
-    di << " use bfillds [-s -t]\n";
+  if (n > 4) {
+    di << " use bfillds [-s -t] [tol]\n";
     return 0;
   }
   //
   char buf[32];
   Standard_Boolean bRunParallel, bShowTime;
   Standard_Integer i, aNbS, iErr;
+  Standard_Real aTol;
   BOPCol_ListIteratorOfListOfShape aIt;
   BOPCol_ListOfShape aLC;
   BOPTime_Chronometer aChrono;
@@ -166,8 +167,9 @@ Standard_Integer bfillds(Draw_Interpretor& di,
     return 0;
   }
   //
-  bShowTime=Standard_False;
-  bRunParallel=Standard_True;
+  bShowTime = Standard_False;
+  bRunParallel = Standard_True;
+  aTol = 0.;
   for (i=1; i<n; ++i) {
     if (!strcmp(a[i], "-s")) {
       bRunParallel=Standard_False;
@@ -175,6 +177,9 @@ Standard_Integer bfillds(Draw_Interpretor& di,
     else if (!strcmp(a[i], "-t")) {
       bShowTime=Standard_True;
     }
+    else {
+      aTol = Draw::Atof(a[i]);
+    }
   }
   //
   BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
@@ -195,6 +200,7 @@ Standard_Integer bfillds(Draw_Interpretor& di,
   //
   aPF.SetArguments(aLC);
   aPF.SetRunParallel(bRunParallel);
+  aPF.SetFuzzyValue(aTol);
   //
   aChrono.Start();
   //
index b6b1087b640cfa9b9a30635977099ce6c4fce40b..712caa7eab345b1edd7b19f363f40c1f06481ec0 100644 (file)
 #include <Geom2d_Ellipse.hxx>
 #include <Geom2d_Parabola.hxx>
 #include <Geom2d_Hyperbola.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+
+#include <Geom2dAdaptor.hxx>
 
 #include <Geom_Curve.hxx>
-#include <GeomAdaptor_HCurve.hxx>
 #include <Geom_TrimmedCurve.hxx>
 #include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
+
+#include <GeomAdaptor_Surface.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomAdaptor_HCurve.hxx>
+#include <GeomAdaptor_HSurface.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+
+#include <GeomProjLib.hxx>
 
 #include <TopLoc_Location.hxx>
 #include <TopExp.hxx>
 #include <ProjLib_ProjectedCurve.hxx>
 
 #include <BRep_Tool.hxx>
-#include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_CurveRepresentation.hxx>
+#include <BRep_GCurve.hxx>
+
 #include <BRepAdaptor_HSurface.hxx>
+
 #include <BRepAdaptor_Curve.hxx>
-#include <BRep_Builder.hxx>
 #include <BRepAdaptor_Surface.hxx>
-#include <Geom2d_Curve.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <BRep_Builder.hxx>
-#include <Geom_Surface.hxx>
-#include <BOPCol_IndexedMapOfShape.hxx>
-#include <BOPTools.hxx>
 #include <BRepClass_FaceClassifier.hxx>
 
+#include <BRepTools.hxx>
+
+#include <BOPCol_IndexedMapOfShape.hxx>
+
+#include <BOPTools.hxx>
+#include <IntTools_Tools.hxx>
+#include <gp_Cylinder.hxx>
+#include <TopExp_Explorer.hxx>
+#include <GeomInt.hxx>
 
 static 
-  Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E);
+  Standard_Boolean CheckEdgeLength (const TopoDS_Edge& );
+
+static
+  Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& , 
+                                                const TopoDS_Face& ,
+                                                Standard_Real& ,
+                                                Standard_Real& ,
+                                                Standard_Boolean& );
+static
+  Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& , 
+                                                const Handle(Geom_Surface)& ,
+                                                const TopLoc_Location& ,
+                                                Standard_Real& ,
+                                                Standard_Real& ,
+                                                Standard_Boolean& );
+static
+  Standard_Real MaxToleranceEdge (const TopoDS_Face& );
 
 //=======================================================================
 //function : BuildPCurveForEdgeOnFace
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
-                                                   const TopoDS_Face& aF)
+void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
+                                                     const TopoDS_Face& aF)
 {
   BRep_Builder aBB;
   Handle(Geom2d_Curve) aC2D;
   Standard_Real  aTolPC, aTolFact, aTolEdge, aFirst, aLast;
   
   Standard_Boolean aHasOld;
-  aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, aC2D, aFirst, aLast, aTolEdge);
+  aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, aC2D, 
+                                                   aFirst, aLast, 
+                                                   aTolEdge);
   if (aHasOld) {
     return;
   }
@@ -91,9 +128,10 @@ static
 //function : EdgeTangent
 //purpose  : 
 //=======================================================================
-  Standard_Boolean BOPTools_AlgoTools2D::EdgeTangent(const TopoDS_Edge& anEdge, 
-                                                 const Standard_Real aT,
-                                                 gp_Vec& aTau)
+Standard_Boolean BOPTools_AlgoTools2D::EdgeTangent
+  (const TopoDS_Edge& anEdge, 
+   const Standard_Real aT,
+   gp_Vec& aTau)
 {
   Standard_Boolean isdgE;
   Standard_Real first, last;
@@ -127,17 +165,18 @@ static
 //function : PointOnOnSurface
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE,
-                                         const TopoDS_Face& aF,
-                                         const Standard_Real aParameter,
-                                         Standard_Real& U,
-                                         Standard_Real& V)
+void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE,
+                                           const TopoDS_Face& aF,
+                                           const Standard_Real aParameter,
+                                           Standard_Real& U,
+                                           Standard_Real& V)
 {
   gp_Pnt2d aP2D;
   Handle(Geom2d_Curve) aC2D;
   Standard_Real aToler, aFirst, aLast;
 
-  BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler); 
+  BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, 
+                                        aFirst, aLast, aToler); 
   aC2D->D0(aParameter, aP2D);
   U=aP2D.X();
   V=aP2D.Y();
@@ -148,32 +187,35 @@ static
 //function : CurveOnSurface
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
-                                         const TopoDS_Face& aF,
-                                         Handle(Geom2d_Curve)& aC2D,
-                                         Standard_Real& aToler)
+void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
+                                           const TopoDS_Face& aF,
+                                           Handle(Geom2d_Curve)& aC2D,
+                                           Standard_Real& aToler)
 {
   Standard_Real aFirst, aLast; 
-
-  BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler); 
-
+  //
+  BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, 
+                                        aFirst, aLast, aToler); 
+  //
   return;
 }
 //=======================================================================
 //function : CurveOnSurface
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
-                                         const TopoDS_Face& aF,
-                                         Handle(Geom2d_Curve)& aC2D,
-                                         Standard_Real& aFirst,
-                                         Standard_Real& aLast,
-                                         Standard_Real& aToler)
+void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
+                                           const TopoDS_Face& aF,
+                                           Handle(Geom2d_Curve)& aC2D,
+                                           Standard_Real& aFirst,
+                                           Standard_Real& aLast,
+                                           Standard_Real& aToler)
 {
   Standard_Boolean aHasOld;
   Handle(Geom2d_Curve) C2D;
 
-  aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, C2D, aFirst, aLast, aToler);
+  aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, C2D, 
+                                                   aFirst, aLast, 
+                                                   aToler);
   if (aHasOld) {
     aC2D=C2D;
     return;
@@ -183,17 +225,17 @@ static
   aC2D=C2D;
   return;
 }
-
 //=======================================================================
 //function : HasCurveOnSurface
 //purpose  : 
 //=======================================================================
-  Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface (const TopoDS_Edge& aE,
-                                                        const TopoDS_Face& aF,
-                                                        Handle(Geom2d_Curve)& aC2D,
-                                                        Standard_Real& aFirst,
-                                                        Standard_Real& aLast,
-                                                        Standard_Real& aToler)
+Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface 
+  (const TopoDS_Edge& aE,
+   const TopoDS_Face& aF,
+   Handle(Geom2d_Curve)& aC2D,
+   Standard_Real& aFirst,
+   Standard_Real& aLast,
+   Standard_Real& aToler)
 {
   Standard_Boolean aHasOld;
   
@@ -204,7 +246,7 @@ static
     return Standard_False;
   }
 
-  aC2D  =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
+  aC2D=BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
   aHasOld=!aC2D.IsNull();
   return aHasOld;
 }
@@ -212,32 +254,35 @@ static
 //function : HasCurveOnSurface
 //purpose  : 
 //=======================================================================
-  Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface (const TopoDS_Edge& aE,
-                                                        const TopoDS_Face& aF)
+Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface 
+  (const TopoDS_Edge& aE,
+   const TopoDS_Face& aF)
                                                    
 {
-  Standard_Boolean aHasOld;
+  Standard_Boolean bHasOld;
   Handle(Geom2d_Curve) aC2D;
   Standard_Real aFirst, aLast;
+  //
   BRep_Tool::Range(aE, aFirst, aLast);
-
+  //
   if((aLast - aFirst) < Precision::PConfusion()) {
     return Standard_False;
   }
-
-  aC2D  =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
-  aHasOld=!aC2D.IsNull();
-  return aHasOld;
+  //
+  aC2D=BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
+  bHasOld=!aC2D.IsNull();
+  //
+  return bHasOld;
 }
-
 //=======================================================================
 //function : AdjustPCurveOnFace
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& aF,
-                                             const Handle(Geom_Curve)&   aC3D,
-                                             const Handle(Geom2d_Curve)& aC2D, 
-                                             Handle(Geom2d_Curve)& aC2DA)
+void BOPTools_AlgoTools2D::AdjustPCurveOnFace 
+  (const TopoDS_Face& aF,
+   const Handle(Geom_Curve)&   aC3D,
+   const Handle(Geom2d_Curve)& aC2D, 
+   Handle(Geom2d_Curve)& aC2DA)
 {
   Standard_Real first, last;
 
@@ -250,16 +295,16 @@ static
 //function : AdjustPCurveOnFace
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& aF,
-                                             const Standard_Real aFirst,
-                                             const Standard_Real aLast,
-                                             const Handle(Geom2d_Curve)& aC2D, 
-                                             Handle(Geom2d_Curve)& aC2DA)
+void BOPTools_AlgoTools2D::AdjustPCurveOnFace 
+  (const TopoDS_Face& aF,
+   const Standard_Real aFirst,
+   const Standard_Real aLast,
+   const Handle(Geom2d_Curve)& aC2D, 
+   Handle(Geom2d_Curve)& aC2DA)
 {
-  Standard_Boolean mincond, maxcond, decalu, decalv;
-  Standard_Integer k, iCnt;
+  Standard_Boolean mincond, maxcond;
   Standard_Real UMin, UMax, VMin, VMax, aT, u2, v2, du, dv, aDelta;
-  Standard_Real aUPeriod, aUP2, aUP1, aUNew, aDif, aUx;
+  Standard_Real aUPeriod;
   //
   aDelta=Precision::PConfusion();
   
@@ -274,68 +319,56 @@ static
 
   u2 = pC2D.X();
   v2 = pC2D.Y();
+  //
+  // du
   du = 0.;
   if (aBAS.IsUPeriodic()) {
-    aUPeriod=aBAS.UPeriod(); 
-    mincond = (u2 < UMin-aDelta);
-    maxcond = (u2 > UMax+aDelta); 
-    
-    decalu = mincond || maxcond;
-    if (decalu) {
-      //du = ( mincond ) ? UPeriod : -UPeriod;
-      //
-      iCnt=1;
-      aUP2=aUPeriod+aUPeriod+aDelta;
-      aUP1=aUPeriod+aDelta;
-      //
-      if (u2 > aUP2) {
-        k=1;
-        do {
-          aUx=u2-k*aUPeriod;
-          iCnt = k++;
-        } while (aUx >= aUP1);
-      }
-      else if (u2 < -aUP2) {
-        k=1;
-        do {
-          aUx=u2+k*aUPeriod;
-          iCnt = (k++) + 1;
-        } while (aUx <= -aUP1);
-      }
-      du = ( mincond ) ? aUPeriod : -aUPeriod;
-      du=iCnt*du;
+    aUPeriod = aBAS.UPeriod(); 
+    //
+    // a. try to clarify u2 using the precision (aDelta)
+    if (fabs(u2-UMin) < aDelta) {
+      u2=UMin;
     }
+    else if (fabs(u2-UMin-aUPeriod) < aDelta) {
+      u2=UMin+aUPeriod;
+    }
+    // b. compute du again using clarified value of u2
+    GeomInt::AdjustPeriodic(u2, UMin, UMax, aUPeriod, u2, du, 0.);
     //
-    aUNew=u2+du;
-    if (aUNew<(UMin-aDelta) || 
-        aUNew>(UMax+aDelta)) {
-      // So previous correction was wrong.
-      // Try to be closer to UMin or UMax.
-      du=0.;
-      if (u2>UMax){
-        aDif=u2-UMax;
-        if (aDif < 4.e-7) {
-          du=-aDif;
+    if (du==0.) {
+      if (aBAS.GetType()==GeomAbs_Cylinder) {
+        Standard_Real aR, dFi, aTol;
+        //
+        gp_Cylinder aCylinder=aBAS.Cylinder();
+        aR=aCylinder.Radius();
+        aTol=MaxToleranceEdge(aF);
+        dFi=aTol/aR;
+        if (dFi<aDelta) {
+          dFi=aDelta;
+        }
+        //
+        mincond = (UMin - u2 > dFi);
+        maxcond = (u2 - UMax > dFi);
+        if (mincond || maxcond) {
+          du = ( mincond ) ? aUPeriod : -aUPeriod;
         }
       }
-    }
-  } // if (BAHS->IsUPeriodic())
-  //
+    } 
+  }
+  
   // dv
   dv = 0.;
   if (aBAS.IsVPeriodic()) {
     Standard_Real aVPeriod, aVm, aVr, aVmid, dVm, dVr;
     //
-    aVPeriod=aBAS.VPeriod();
+    aVPeriod = aBAS.VPeriod();
     mincond = (VMin - v2 > aDelta);
     maxcond = (v2 - VMax > aDelta);
-    decalv = mincond || maxcond;
-    if (decalv) {
+    //
+    if (mincond || maxcond) {
       dv = ( mincond ) ? aVPeriod : -aVPeriod;
     }
     //
-    //xf
     if ((VMax-VMin<aVPeriod) && dv) {
       aVm=v2;
       aVr=v2+dv;
@@ -346,7 +379,6 @@ static
         dv=0.;
       }
     }
-    //xt
   }
   //
   {
@@ -402,8 +434,9 @@ static
 //function : IntermediatePoint
 //purpose  : 
 //=======================================================================
-  Standard_Real BOPTools_AlgoTools2D::IntermediatePoint (const Standard_Real aFirst,
-                                                     const Standard_Real aLast)
+Standard_Real BOPTools_AlgoTools2D::IntermediatePoint 
+  (const Standard_Real aFirst,
+   const Standard_Real aLast)
 {
   //define parameter division number as 10*e^(-PI) = 0.43213918
   const Standard_Real PAR_T = 0.43213918;
@@ -415,7 +448,8 @@ static
 //function : IntermediatePoint
 //purpose  : 
 //=======================================================================
-  Standard_Real BOPTools_AlgoTools2D::IntermediatePoint (const TopoDS_Edge& aE)
+Standard_Real BOPTools_AlgoTools2D::IntermediatePoint 
+  (const TopoDS_Edge& aE)
                                                 
 {
   Standard_Real aT, aT1, aT2;
@@ -432,88 +466,47 @@ static
 //function : BuildPCurveForEdgeOnPlane
 //purpose  : 
 //=======================================================================
-void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (const TopoDS_Edge& aE,
-                                                     const TopoDS_Face& aF)
-{ 
-  Standard_Real aTolE;
-  TopLoc_Location aLoc;
+void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane 
+  (const TopoDS_Edge& aE,
+   const TopoDS_Face& aF)
+{
+  Standard_Boolean bToUpdate;
+  Standard_Real aTolE, aT1, aT2;
   Handle(Geom2d_Curve) aC2D;
-  Handle(Geom_Plane) aGP;
-  Handle(Geom_RectangularTrimmedSurface) aGRTS;
   BRep_Builder aBB;
   //
-  const Handle(Geom_Surface)& aS = BRep_Tool::Surface(aF, aLoc);
-  aGRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS);
-  if(!aGRTS.IsNull()){
-    aGP=Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface());
-    }    
-  else {
-    aGP=Handle(Geom_Plane)::DownCast(aS);
+  aC2D=BRep_Tool_CurveOnSurface(aE, aF, aT1, aT2, bToUpdate);
+  if (bToUpdate) {
+    aTolE=BRep_Tool::Tolerance(aE);
+    aBB.UpdateEdge(aE, aC2D, aF, aTolE);
   }
-  //
-  if (aGP.IsNull()) {
-    return;
-  }
-  //
-  BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolE);
-  aBB.UpdateEdge(aE, aC2D, aF, aTolE);
-  //
-  return;
 }
 //=======================================================================
 // function: BuildPCurveForEdgesOnPlane
 // purpose: 
 //=======================================================================
 void BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane 
-  (const BOPCol_ListOfShape& aEdges,
-   const TopoDS_Face& aFace)
+  (const BOPCol_ListOfShape& aLE,
+   const TopoDS_Face& aF)
 {
-  
-  TopLoc_Location aLoc;
-  Handle(Geom2d_Curve) aC2D;
-  Handle(Geom_Plane) aGP;
-  Handle(Geom_RectangularTrimmedSurface) aGRTS;
-  //
-  const Handle(Geom_Surface)& aS = BRep_Tool::Surface(aFace, aLoc);
-  aGRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS);
-  if(!aGRTS.IsNull()){
-    aGP=Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface());
-    }    
-  else {
-    aGP=Handle(Geom_Plane)::DownCast(aS);
-  }
-  //
-  if (aGP.IsNull()) {
-    return;
-  }
-  //
-  Standard_Boolean bHasOld;
-  Standard_Real aTolE, aT1, aT2;
   BOPCol_ListIteratorOfListOfShape aIt;
-  BRep_Builder aBB;
   //
-  aIt.Initialize(aEdges);
+  aIt.Initialize(aLE);
   for(; aIt.More(); aIt.Next()) {
     const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value());
-    bHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface
-      (aE, aFace, aC2D, aT1, aT2, aTolE);
-    if (!bHasOld) {
-      BOPTools_AlgoTools2D::CurveOnSurface(aE, aFace, aC2D, aTolE);
-      aBB.UpdateEdge(aE, aC2D, aFace, aTolE);
-    }
+    BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (aE, aF);
   }
 }
-
 //=======================================================================
 //function : Make2D
 //purpose  : 
 //=======================================================================
 void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
-                                  const TopoDS_Face& aF,
-                                  Handle(Geom2d_Curve)& aC2D,
-                                 Standard_Real& aFirst,
-                                 Standard_Real& aLast,
-                                 Standard_Real& aToler)
+                                   const TopoDS_Face& aF,
+                                   Handle(Geom2d_Curve)& aC2D,
+                                   Standard_Real& aFirst,
+                                   Standard_Real& aLast,
+                                   Standard_Real& aToler)
 {
   Standard_Boolean aLocIdentity;
   Standard_Real f3d, l3d;
@@ -558,10 +551,10 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
 //function : MakePCurveOnFace
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
-                                           const Handle(Geom_Curve)& aC3D,
-                                           Handle(Geom2d_Curve)& aC2D, //->
-                                           Standard_Real& TolReached2d)
+void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
+                                             const Handle(Geom_Curve)& aC3D,
+                                             Handle(Geom2d_Curve)& aC2D, //->
+                                             Standard_Real& TolReached2d)
 {
   Standard_Real aFirst, aLast;
 
@@ -570,29 +563,34 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
   //
   TolReached2d=0.;
   //
-  BOPTools_AlgoTools2D::MakePCurveOnFace (aF, aC3D, aFirst, aLast, aC2D, TolReached2d);
+  BOPTools_AlgoTools2D::MakePCurveOnFace (aF, aC3D, aFirst, 
+                                          aLast, aC2D, TolReached2d);
 }
 
 //=======================================================================
 //function : MakePCurveOnFace
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
-                                           const Handle(Geom_Curve)& aC3D,
-                                           const Standard_Real aFirst,
-                                           const Standard_Real aLast,
-                                           Handle(Geom2d_Curve)& aC2D, 
-                                           Standard_Real& TolReached2d)
+void BOPTools_AlgoTools2D::MakePCurveOnFace 
+  (const TopoDS_Face& aF,
+   const Handle(Geom_Curve)& aC3D,
+   const Standard_Real aFirst,
+   const Standard_Real aLast,
+   Handle(Geom2d_Curve)& aC2D, 
+   Standard_Real& TolReached2d)
 {
   Standard_Real aTolR;
   Handle(Geom2d_Curve) aC2DA;
-
-  BRepAdaptor_Surface aBAS(aF, Standard_False);
-  Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(aBAS);
-  Handle(GeomAdaptor_HCurve)   aBAHC = new GeomAdaptor_HCurve(aC3D, aFirst, aLast);
+  //
+  Handle(Geom_Surface) aS=BRep_Tool::Surface(aF);
+  GeomAdaptor_Surface aGAS(aS);
+  Handle(GeomAdaptor_HSurface) aBAHS=
+    new GeomAdaptor_HSurface(aGAS);
+  Handle(GeomAdaptor_HCurve) aBAHC = 
+    new GeomAdaptor_HCurve(aC3D, aFirst, aLast);
   
   //when the type of surface is GeomAbs_SurfaceOfRevolution
-  if (aBAS.GetType() == GeomAbs_SurfaceOfRevolution) {
+  if (aGAS.GetType() == GeomAbs_SurfaceOfRevolution) {
     Standard_Real aTR = 1.e-7;
     ProjLib_ProjectedCurve aProj1(aBAHS, aBAHC, aTR);
     BOPTools_AlgoTools2D::MakePCurveOfType(aProj1, aC2D);
@@ -617,7 +615,8 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
   }
   TolReached2d=aTolR;
   
-  BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aFirst, aLast, aC2D, aC2DA);
+  BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aFirst, aLast, 
+                                            aC2D, aC2DA);
   aC2D=aC2DA;
 }
 
@@ -625,8 +624,9 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
 //function : MakePCurveOfType
 //purpose  : 
 //=======================================================================
-  void  BOPTools_AlgoTools2D::MakePCurveOfType(const ProjLib_ProjectedCurve& PC, 
-                                           Handle(Geom2d_Curve)& C2D)
+void  BOPTools_AlgoTools2D::MakePCurveOfType
+  (const ProjLib_ProjectedCurve& PC, 
+   Handle(Geom2d_Curve)& C2D)
 {
   
   switch (PC.GetType()) {
@@ -652,11 +652,11 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
   case GeomAbs_BezierCurve : 
   case GeomAbs_OtherCurve : 
     default :
-    Standard_NotImplemented::Raise("BOPTools_AlgoTools2D::MakePCurveOfType");
+    Standard_NotImplemented::Raise
+      ("BOPTools_AlgoTools2D::MakePCurveOfType");
     break;
   }
 }
-
 //=======================================================================
 //function : CheckEdgeLength
 //purpose  : 
@@ -692,174 +692,144 @@ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
     ln+=d;
     p1=p2;
   }
-  
+  //
   return (ln > Precision::Confusion()); 
 }
-
-
-
-
-
-
-
-
-/*
 //=======================================================================
-//function : FaceNormal
+//function : BRep_Tool_CurveOnSurface
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::FaceNormal (const TopoDS_Face& aF,
-                                     const Standard_Real U,
-                                     const Standard_Real V,
-                                     gp_Vec& aN)
+Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& E, 
+                                              const TopoDS_Face& F,
+                                              Standard_Real& First,
+                                              Standard_Real& Last,
+                                              Standard_Boolean& bToUpdate)
 {
-  gp_Pnt aPnt ;
-  gp_Vec aD1U, aD1V;
-  Handle(Geom_Surface) aSurface;
-
-  aSurface=BRep_Tool::Surface(aF);
-  aSurface->D1 (U, V, aPnt, aD1U, aD1V);
-  aN=aD1U.Crossed(aD1V);
-  aN.Normalize();  
-  if (aF.Orientation() == TopAbs_REVERSED){
-    aN.Reverse();
+  TopLoc_Location l;
+  const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
+  TopoDS_Edge aLocalEdge = E;
+  if (F.Orientation() == TopAbs_REVERSED) {
+    aLocalEdge.Reverse();
   }
-  return;
+  //
+  return BRep_Tool_CurveOnSurface(aLocalEdge,S,l,First,Last,bToUpdate);
 }
 //=======================================================================
-//function : RemovePCurveForEdgeOnFace
+//function : BRep_Tool_CurveOnSurface
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::RemovePCurveForEdgeOnFace (const TopoDS_Edge& aE,
-                                                    const TopoDS_Face& aF)
+Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface
+       (const TopoDS_Edge& E, 
+        const Handle(Geom_Surface)& S,
+        const TopLoc_Location& L,
+        Standard_Real& First,
+        Standard_Real& Last,
+        Standard_Boolean& bToUpdate)
 {
-  BRep_Builder aBB;
-  Handle(Geom2d_Curve) aC2D;
-  Standard_Real  aTol;
+  static const Handle(Geom2d_Curve) nullPCurve;
+  bToUpdate=Standard_False;
+  TopLoc_Location loc = L.Predivided(E.Location());
+  Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
+
+  // find the representation
+  BRep_ListIteratorOfListOfCurveRepresentation itcr
+    ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
+
+  while (itcr.More()) {
+    const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
+    if (cr->IsCurveOnSurface(S,loc)) {
+      const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
+      GC->Range(First,Last);
+      if (GC->IsCurveOnClosedSurface() && Eisreversed)
+        return GC->PCurve2();
+      else
+        return GC->PCurve();
+    }
+    itcr.Next();
+  }
 
-  aTol=BRep_Tool::Tolerance(aE);
-  aBB.UpdateEdge(aE, aC2D, aF, aTol);
-}
-//=======================================================================
-//function : MakeCurveOnSurface
-//purpose  : 
-//=======================================================================
-  void BOPTools_AlgoTools2D::MakeCurveOnSurface (const TopoDS_Edge& aE,
-                                             const TopoDS_Face& aF,
-                                             Handle(Geom2d_Curve)& aC2D,
-                                             Standard_Real& aFirst,
-                                             Standard_Real& aLast,
-                                             Standard_Real& aToler)
-{
-  BOPTools_AlgoTools2D::Make2D(aE, aF, aC2D, aFirst, aLast, aToler);
-}
+  // for planar surface and 3d curve try a projection
+  // modif 21-05-97 : for RectangularTrimmedSurface, try a projection
+  Handle(Geom_Plane) GP;
+  Handle(Geom_RectangularTrimmedSurface) GRTS;
+  GRTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
+  if(!GRTS.IsNull())
+    GP = Handle(Geom_Plane)::DownCast(GRTS->BasisSurface());
+  else
+    GP = Handle(Geom_Plane)::DownCast(S);
+  //fin modif du 21-05-97
 
-//=======================================================================
-//function : TangentOnEdge
-//purpose  : 
-//=======================================================================
-  Standard_Boolean BOPTools_AlgoTools2D::TangentOnEdge(const Standard_Real par, 
-                                                   const TopoDS_Edge& E, 
-                                                   gp_Vec& Tg)
-{
-  Standard_Boolean isdgE;
-  
-  isdgE = BRep_Tool::Degenerated(E); 
-  if (isdgE) {
-    return Standard_False;
-  }
-  if (!CheckEdgeLength(E)) {
-    return Standard_False;
-  }
+  if (!GP.IsNull()) {
 
-  BRepAdaptor_Curve BC(E);
-  //
-  // Body 
-  Standard_Real f, l, tolE, tolp;
-  Standard_Boolean onf, onl, inbounds;
+    Handle(GeomAdaptor_HCurve) HC;
+    Handle(GeomAdaptor_HSurface) HS;
 
-  f = BC.FirstParameter();
-  l = BC.LastParameter();
-  tolE = BC.Tolerance(); 
-  tolp = BC.Resolution(tolE);
-  
-  onf = Abs(f-par)<tolp; 
-  onl = Abs(l-par)<tolp; 
-  inbounds = (f<par) && (par<l);
+    HC = new GeomAdaptor_HCurve();
+    HS = new GeomAdaptor_HSurface();
 
-  if ((!inbounds) && (!onf) && (!onl)) {
-    return Standard_False;
-  }
-  
-  
-  gp_Pnt aP;
+    TopLoc_Location LC;
 
-  BC.D1(par, aP, Tg);
-  Tg.Normalize(); 
-  
-  return Standard_True;
-}
-//=======================================================================
-//function : TangentOnEdge
-//purpose  : 
-//=======================================================================
-  Standard_Boolean BOPTools_AlgoTools2D::TangentOnEdge(const TopoDS_Edge& aE, 
-                                                   gp_Dir& DTg)
-{
-  Standard_Real aT;
-  gp_Vec aTg;
+    Standard_Real f, l;// for those who call with (u,u).
+    Handle(Geom_Curve) C3d =
+      BRep_Tool::Curve(E,/*LC,*/f,l); // transforming plane instead of curve
+    // we can loose scale factor of Curve transformation (eap 13 May 2002)
+
+    LC = L/*.Predivided(LC)*/;
 
-  DTg.SetCoord(1.,0.,0.);
+    if (C3d.IsNull()) return nullPCurve;
 
-  aT= BOPTools_AlgoTools2D::IntermediatePoint (aE);
-  Standard_Boolean bIsFound=BOPTools_AlgoTools2D::TangentOnEdge(aT, aE, aTg);
-  if (bIsFound) {
-    gp_Dir aDTmp(aTg);
-    DTg=aDTmp;
+    Handle(Geom_Plane) Plane = GP;
+    if (!LC.IsIdentity()) {
+      const gp_Trsf& T = LC.Transformation();
+      Handle(Geom_Geometry) GPT = GP->Transformed(T);
+      Plane = *((Handle(Geom_Plane)*)&GPT);
+    }
+    GeomAdaptor_Surface& GAS = HS->ChangeSurface();
+    GAS.Load(Plane);
+    
+    Handle(Geom_Curve) ProjOnPlane = 
+      GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l),
+                                  Plane,
+                                  Plane->Position().Direction(),
+                                  Standard_True);
+    
+    GeomAdaptor_Curve& GAC = HC->ChangeCurve();
+    GAC.Load(ProjOnPlane);
+
+    ProjLib_ProjectedCurve Proj(HS,HC);
+    Handle(Geom2d_Curve) pc = Geom2dAdaptor::MakeCurve(Proj);
+
+    if (pc->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
+      Handle(Geom2d_TrimmedCurve) TC = 
+        (*((Handle(Geom2d_TrimmedCurve)*)&pc));
+      pc = TC->BasisCurve();
+    }
+    First = f; Last = l;
+    //
+    bToUpdate=Standard_True;
+    //
+    return pc;
   }
-  return bIsFound;
-}
   
-//=======================================================================
-//function : TangentOnVertex
-//purpose  : 
-//=======================================================================
-  Standard_Boolean BOPTools_AlgoTools2D::TangentOnVertex (const TopoDS_Vertex& v, 
-                                                      const TopoDS_Vertex& vl, 
-                                                      const TopoDS_Edge& e,
-                                                      gp_Vec& aVec)
-// tg oriented INSIDE 1d(e)
-// vl : last vertex of e
-{
-  Standard_Boolean ok;
-  Standard_Real par;
-  gp_Vec tg; 
-
-  par = BRep_Tool::Parameter(v, e);  
-  ok =BOPTools_AlgoTools2D::TangentOnEdge (par, e, tg);
-  if (!ok) {
-    return ok;
-  }
-  if (v.IsSame(vl)) {
-    tg.Reverse();
-  }
-  aVec=tg;
-
-  return ok;
+  return nullPCurve;
 }
-
 //=======================================================================
-//function : EdgeBounds
+//function : MaxToleranceEdge
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::EdgeBounds (const TopoDS_Edge& aE,
-                                     Standard_Real& aFirst,
-                                     Standard_Real& aLast)
+Standard_Real MaxToleranceEdge (const TopoDS_Face& aF) 
 {
-  BRepAdaptor_Curve aBC(aE);
-  aFirst= aBC.FirstParameter();
-  aLast = aBC.LastParameter();
+  Standard_Real aTol, aTolMax;
+  TopExp_Explorer aExp;
+  //
+  aTolMax=0.;
+  aExp.Init(aF, TopAbs_EDGE);
+  for (; aExp.More(); aExp.Next()) {
+    const TopoDS_Edge& aE=*((TopoDS_Edge *)&aExp.Current());
+    aTol=BRep_Tool::Tolerance(aE);
+    if (aTol>aTolMax) {
+      aTolMax=aTol;
+    }
+  }
+  return aTolMax;
 }
-
-
-*/
index 1926fc47912ad3a5ce101d51892fe370e5e6596b..a266c96cab5691157f9c6202a91bf54faec48aed 100644 (file)
@@ -46,16 +46,19 @@ uses
     
 is
 
-    Initialize (S1 :Shape from TopoDS; 
-               S2 :Shape from TopoDS; 
-               anOperation:Operation from BOPAlgo);
-       ---Purpose: Prepares the operations for S1 and S2.
+    Initialize ( 
+            theS1 : Shape from TopoDS;  
+            theS2 : Shape from TopoDS; 
+            anOperation : Operation from BOPAlgo; 
+            theFuzz : Real from Standard = 0.0);
+    ---Purpose: Prepares the operations for S1 and S2.
      
-    Initialize (S1   :Shape from TopoDS; 
-               S2   :Shape from TopoDS; 
-               aDSF :PaveFiller from BOPAlgo;                                                               
-               anOperation:Operation from BOPAlgo); 
-       ---Purpose: Prepares the operations for S1 and S2.
+    Initialize ( 
+            theS1  : Shape from TopoDS; 
+            theS2  : Shape from TopoDS; 
+            theDSF : PaveFiller from BOPAlgo;
+            anOperation : Operation from BOPAlgo);
+    ---Purpose: Prepares the operations for S1 and S2.
 
     SetOperation (me:out; 
            anOp:  Operation from BOPAlgo); 
@@ -176,6 +179,13 @@ is
        ---Purpose: Returns the list  of shapes generated from the shape <S>.
        ---         For use in BRepNaming.
        ---C++:  return const &
+    SetFuzzyValue(me:out; 
+            theFuzz : Real from Standard);
+    ---Purpose: Sets the extended tolerance
+    FuzzyValue(me)
+        returns Real from Standard;
+    ---Purpose: Returns the extended tolerance 
 
 fields
     myS1             : Shape from TopoDS        is protected;
@@ -192,6 +202,9 @@ fields
     myFuseEdges      : Boolean  from  Standard ; 
     myModifFaces     : DataMapOfShapeShape  from  TopTools;   
     myEdgeMap        : DataMapOfShapeShape  from  TopTools;
+    -- 
+    -- extended tolerance for Boolean Operation
+    myFuzzyValue     : Real from Standard is protected;
     
 end BooleanOperation;
 
index 9e99c2fccb69db5d80263b408899bf1e2f275f48..53f7bedad3cbd6fa0a1cd9c58d8936984036ac8c 100644 (file)
 //function : BRepAlgoAPI_BooleanOperation
 //purpose  : 
 //=======================================================================
-  BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& aS1, 
-                                                             const TopoDS_Shape& aS2,
-                                                             const BOPAlgo_Operation anOp)
+BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
+  (const TopoDS_Shape& aS1, 
+   const TopoDS_Shape& aS2,
+   const BOPAlgo_Operation anOp,
+   const Standard_Real theFuzz)
 : 
   myS1(aS1),
   myS2(aS2),
   myDSFiller(NULL),
   myBuilder(NULL),
   myEntryType(1),
-  myFuseEdges(Standard_False)
+  myFuseEdges(Standard_False),
+  myFuzzyValue(theFuzz)
 {
 }
 //=======================================================================
 //function : BRepAlgoAPI_BooleanOperation
 //purpose  : 
 //=======================================================================
-  BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& aS1, 
-                                                             const TopoDS_Shape& aS2,
-                                                             const BOPAlgo_PaveFiller& aDSFiller,
-                                                             const BOPAlgo_Operation anOp)
+BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
+  (const TopoDS_Shape& aS1, 
+   const TopoDS_Shape& aS2,
+   const BOPAlgo_PaveFiller& aDSFiller,
+   const BOPAlgo_Operation anOp)
 : 
   myS1(aS1),
   myS2(aS2),
   myDSFiller(NULL),
   myBuilder(NULL),
   myEntryType(0),
-  myFuseEdges(Standard_False)
+  myFuseEdges(Standard_False),
+  myFuzzyValue(0.)
 {
   if ((Standard_Address) &aDSFiller!=NULL) {
     myDSFiller=(BOPAlgo_PaveFiller*)&aDSFiller;
+    myFuzzyValue = myDSFiller->FuzzyValue();
   }
 }
 //=======================================================================
   return myErrorStatus;    
 }
 //=======================================================================
+//function : SetFuzzyValue
+//purpose  : 
+//=======================================================================
+  void BRepAlgoAPI_BooleanOperation::SetFuzzyValue(const Standard_Real theFuzz)
+{
+  if (theFuzz > 0.) {
+    myFuzzyValue = theFuzz;
+  }
+}
+//=======================================================================
+//function : FuzzyValue
+//purpose  : 
+//=======================================================================
+  Standard_Real BRepAlgoAPI_BooleanOperation::FuzzyValue() const
+{
+  return myFuzzyValue;
+}
+//=======================================================================
 //function : Modified
 //purpose  : 
 //=======================================================================
@@ -219,6 +243,7 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_
     aLS.Append(myS2);
     //
     myDSFiller->SetArguments(aLS);
+    myDSFiller->SetFuzzyValue(myFuzzyValue);
   }
 
   return bIsNewFiller;
index d414e0c6bbc28331d37c9c8ea75c9b0e29dfc4fe..a7ddc7e6ed0d459ec37a0eff4df6dd126c0c050f 100644 (file)
@@ -44,9 +44,10 @@ is
     ---Purpose:  Empty constructor. 
      
     Create( 
-        theS   : Shape   from TopoDS; 
+        theS    : Shape    from TopoDS; 
         bTestSE : Boolean from Standard = Standard_True; 
-        bTestSI : Boolean from Standard = Standard_True) 
+        bTestSI : Boolean from Standard = Standard_True; 
+        theFuzz : Real    from Standard = 0.0) 
     returns Check from BRepAlgoAPI;  
     ---Purpose:  Constructor for checking single shape. 
     -- It calls methods  
@@ -57,14 +58,16 @@ is
     --  bTestSE - flag that specifies whether check on small edges  
     --            should be performed; by default it is set to TRUE;
     --  bTestSI - flag that specifies whether check on self-interference 
-    --            should be performed; by default it is set to TRUE;
+    --            should be performed; by default it is set to TRUE; 
+    --  theFuzz  - The extended tolerance for the check;
      
     Create( 
         theS1   : Shape     from TopoDS; 
         theS2   : Shape     from TopoDS; 
         theOp   : Operation from BOPAlgo = BOPAlgo_UNKNOWN;
         bTestSE : Boolean   from Standard = Standard_True; 
-        bTestSI : Boolean   from Standard = Standard_True) 
+        bTestSI : Boolean   from Standard = Standard_True; 
+        theFuzz : Real      from Standard = 0.0) 
     returns Check from BRepAlgoAPI; 
     ---Purpose: Constructor for couple of shapes.  
     -- It calls methods  
@@ -77,21 +80,24 @@ is
     --  bTestSE - flag that specifies whether check on small edges  
     --            should be performed; by default it is set to TRUE;
     --  bTestSI - flag that specifies whether check on self-interference 
-    --            should be performed; by default it is set to TRUE; 
+    --            should be performed; by default it is set to TRUE;  
+    --  theFuzz - The extended tolerance for the check;
       
     Init(me:out; 
         theS1   : Shape     from TopoDS; 
         theS2   : Shape     from TopoDS; 
         theOp   : Operation from BOPAlgo;
         bTestSE : Boolean   from Standard; 
-        bTestSI : Boolean   from Standard)
+        bTestSI : Boolean   from Standard; 
+        theFuzz : Real      from Standard)
       is protected;  
     ---Purpose: Initialyzes data.
  
     SetData(me:out; 
-        theS   : Shape   from TopoDS; 
+        theS    : Shape    from TopoDS; 
         bTestSE : Boolean from Standard = Standard_True; 
-        bTestSI : Boolean from Standard = Standard_True);
+        bTestSI : Boolean from Standard = Standard_True; 
+        theFuzz : Real    from Standard = 0.0);
     ---Purpose: Sets data for check by Init method.
     -- The method provides alternative way for checking single shape. 
      
@@ -100,7 +106,8 @@ is
         theS2   : Shape     from TopoDS; 
         theOp   : Operation from BOPAlgo = BOPAlgo_UNKNOWN;
         bTestSE : Boolean   from Standard = Standard_True; 
-        bTestSI : Boolean   from Standard = Standard_True);
+        bTestSI : Boolean   from Standard = Standard_True; 
+        theFuzz : Real      from Standard = 0.0);
     ---Purpose: Sets data for check by Init method.
     -- The method provides alternative way for checking couple of shapes.
     
@@ -117,9 +124,10 @@ is
     ---Purpose: Returns faulty shapes.
     
 fields  
-  myS1, myS2 : Shape from TopoDS is protected;  
-  myAnalyzer : PArgumentAnalyzer from BOPAlgo is protected;
-  myResult   : ListOfCheckResult from BOPAlgo is protected;
+  myS1, myS2   : Shape from TopoDS is protected;  
+  myAnalyzer   : PArgumentAnalyzer from BOPAlgo is protected; 
+  myFuzzyValue : Real from Standard is protected;
+  myResult     : ListOfCheckResult from BOPAlgo is protected;
    
 end BooleanOperation;
 
index 7a1ea28e8f47b0468fa14c7cef418397fb9b9277..d0a6866e829373d85f94740b2f62b5ac7c2a8aec 100644 (file)
@@ -23,7 +23,9 @@
 //purpose  : 
 //=======================================================================
   BRepAlgoAPI_Check::BRepAlgoAPI_Check()
-: myAnalyzer(NULL)
+:
+  myAnalyzer(NULL),
+  myFuzzyValue(0.0)
 {
 }
 
 //=======================================================================
   BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
                                        const Standard_Boolean bTestSE,
-                                       const Standard_Boolean bTestSI)
+                                       const Standard_Boolean bTestSI,
+                                       const Standard_Real theFuzz)
 {
-  Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
+  Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI, theFuzz);
   //
   Perform();
 }
                                        const TopoDS_Shape& theS2,
                                        const BOPAlgo_Operation theOp,
                                        const Standard_Boolean bTestSE,
-                                       const Standard_Boolean bTestSI)
+                                       const Standard_Boolean bTestSI,
+                                       const Standard_Real theFuzz)
 {
-  Init(theS1, theS2, theOp, bTestSE, bTestSI);
+  Init(theS1, theS2, theOp, bTestSE, bTestSI, theFuzz);
   //
   Perform();
 }
 //=======================================================================
   void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
                                   const Standard_Boolean bTestSE,
-                                  const Standard_Boolean bTestSI)
+                                  const Standard_Boolean bTestSI,
+                                  const Standard_Real theFuzz)
 {
-  Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
+  Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI, theFuzz);
 }
 
 //=======================================================================
                                   const TopoDS_Shape& theS2,
                                   const BOPAlgo_Operation theOp,
                                   const Standard_Boolean bTestSE,
-                                  const Standard_Boolean bTestSI)
+                                  const Standard_Boolean bTestSI,
+                                  const Standard_Real theFuzz)
 {
-  Init(theS1, theS2, theOp, bTestSE, bTestSI);
+  Init(theS1, theS2, theOp, bTestSE, bTestSI, theFuzz);
 }
 
 
                                const TopoDS_Shape& theS2,
                                const BOPAlgo_Operation theOp,
                                const Standard_Boolean bTestSE,
-                               const Standard_Boolean bTestSI)
+                               const Standard_Boolean bTestSI,
+                               const Standard_Real theFuzz)
 {
   myResult.Clear();
   myS1 = theS1.IsNull() ? theS1 : BRepBuilderAPI_Copy(theS1).Shape();
   myAnalyzer->ArgumentTypeMode() = Standard_True;
   myAnalyzer->SmallEdgeMode() = bTestSE;
   myAnalyzer->SelfInterMode() = bTestSI;
+  myAnalyzer->SetFuzzyValue(theFuzz);
 }
 
 //=======================================================================
index 5ae903fadbbd3bd179b3c934e5ca77035ca22a83..3e3cf2ce34fc1b84dccca7dbb43f96b7d9e90f34 100644 (file)
 
 class Common from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
 
-       ---Purpose: The class Common provides a
-       -- Boolean common operation on a pair of arguments (Boolean Intersection).
-       --  The class Common provides a framework for:
-       -- -           Defining the construction of a common shape;
-       -- -           Implementing the   building algorithm
-       -- -           Consulting the result.
+        ---Purpose: The class Common provides a
+            -- Boolean common operation on a pair of arguments (Boolean Intersection).
+            --  The class Common provides a framework for:
+            -- -           Defining the construction of a common shape;
+            -- -           Implementing the   building algorithm
+            -- -           Consulting the result.
 
 uses
     Shape from TopoDS, 
     PaveFiller from BOPAlgo
 
 is
-    Create (S1,S2 : Shape from TopoDS)  
-       returns Common from BRepAlgoAPI;  
-       ---Purpose: Constructs a common part for shapes aS1 and aS2 .
+    Create (S1,S2   : Shape from TopoDS; 
+            theFuzz : Real from Standard = 0.0)  
+            returns Common from BRepAlgoAPI;  
+        ---Purpose: Constructs a common part for shapes aS1 and aS2 .
  
     Create (S1,S2 : Shape from TopoDS; 
-           aDSF:PaveFiller from BOPAlgo)  
-       returns Common from BRepAlgoAPI;
+            aDSF  : PaveFiller from BOPAlgo)
+            returns Common from BRepAlgoAPI;
 end Common;
 --- Purpose: Constructs a common part for shapes aS1 and aS2 using aDSFiller
index 70d34f64f6fa363d1d70e931b900305bf8bb0d33..3fd5de10ac18ce015bada7d385a38488169f0d75 100644 (file)
@@ -23,8 +23,9 @@
 //purpose  : 
 //=======================================================================
   BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1, 
-                                         const TopoDS_Shape& S2)
-: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_COMMON)
+                                         const TopoDS_Shape& S2,
+                                         const Standard_Real theFuzz)
+: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_COMMON, theFuzz)
 {
   BRepAlgoAPI_BooleanOperation* pBO=
     (BRepAlgoAPI_BooleanOperation*) (void*) this;
index 7540145c367915cdac596e17c88f5840c4db8487..5d8fe1e97c936cf2d7efba7431b1b921ea5f04a7 100644 (file)
 -- commercial license or contractual agreement.
 
 class Cut from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
-       ---Purpose:  The class Cut provides a Boolean
-       -- cut operation on a pair of arguments (Boolean Subtraction).
-       -- The class Cut provides a framework for:
-       --   -      Defining the construction of a cut shape
-       --   -      Implementing the building algorithm
-       --   -      Consulting the result
+        ---Purpose:  The class Cut provides a Boolean
+            -- cut operation on a pair of arguments (Boolean Subtraction).
+            -- The class Cut provides a framework for:
+            --   -      Defining the construction of a cut shape
+            --   -      Implementing the building algorithm
+            --   -      Consulting the result
 
 uses
     Shape from TopoDS,
     PaveFiller from BOPAlgo
 
 is
-    Create (S1,S2 : Shape from TopoDS)  
-       returns Cut from BRepAlgoAPI;  
-       ---Purpose: Shape aS2 cuts shape aS1. The
-       -- resulting shape is a new shape produced by the cut operation.
-       
+    Create (S1, S2  : Shape from TopoDS; 
+            theFuzz : Real from Standard = 0.0)  
+            returns Cut from BRepAlgoAPI;  
+        ---Purpose: Shape aS2 cuts shape aS1. The
+            -- resulting shape is a new shape produced by the cut operation.
+        
 
     Create (S1,S2 : Shape from TopoDS; 
-           aDSF  : PaveFiller  from BOPAlgo; 
-           bFWD  : Boolean from Standard=Standard_True)  
-       returns Cut from BRepAlgoAPI;    
-       --- Purpose: Constructs a new shape cut from
-       -- shape aS1 by shape aS2 using aDSFiller (see
-       -- BRepAlgoAPI_BooleanOperation Constructor).
+            aDSF  : PaveFiller  from BOPAlgo; 
+            bFWD  : Boolean from Standard=Standard_True)
+            returns Cut from BRepAlgoAPI;         
+            --- Purpose: Constructs a new shape cut from
+            -- shape aS1 by shape aS2 using aDSFiller (see
+            -- BRepAlgoAPI_BooleanOperation Constructor).
         
 end Cut;
index 665517f0d107a4fa699d3ae1403bf300180a99ae..57229258f93fb6c034b3365cbd2f07c3f751e2b1 100644 (file)
@@ -23,8 +23,9 @@
 //purpose  : 
 //=======================================================================
   BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1, 
-                                   const TopoDS_Shape& S2)
-: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_CUT)
+                                   const TopoDS_Shape& S2,
+                                   const Standard_Real theFuzz)
+: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_CUT, theFuzz)
 {
   BRepAlgoAPI_BooleanOperation* pBO=
     (BRepAlgoAPI_BooleanOperation*) (void*) this;
@@ -38,7 +39,7 @@
                                    const TopoDS_Shape& S2,
                                    const BOPAlgo_PaveFiller& aDSF,
                                    const Standard_Boolean bFWD)
-: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, (bFWD) ? BOPAlgo_CUT : BOPAlgo_CUT21)
+: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, bFWD ? BOPAlgo_CUT : BOPAlgo_CUT21)
 {
   BRepAlgoAPI_BooleanOperation* pBO=
     (BRepAlgoAPI_BooleanOperation*) (void*) this;
index dcd56a255a39fd96864116b5933c8e879fb858fd..7bb60657024588ce6e92440324b1db3131f06e7d 100644 (file)
 
 class Fuse from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
 
-       ---Purpose:  The class Fuse provides a
-       -- Boolean fusion operation on a pair of arguments (Boolean Union).
-       -- The class Fuse provides a framework for:
-       --   -       Defining the construction of a fused shape;
-       --   -       Implementing the building algorithm
-       --   -       Consulting the result.
+        ---Purpose:  The class Fuse provides a
+            -- Boolean fusion operation on a pair of arguments (Boolean Union).
+            -- The class Fuse provides a framework for:
+            --   -       Defining the construction of a fused shape;
+            --   -       Implementing the building algorithm
+            --   -       Consulting the result.
 
 uses
     Shape from TopoDS, 
     PaveFiller from BOPAlgo
 
 is
-    Create (S1,S2 : Shape from TopoDS)  
-       returns Fuse from BRepAlgoAPI;  
-       ---Purpose: Constructs a fuse of shapes aS1 and aS2.
-        
+    Create (S1, S2  : Shape from TopoDS; 
+            theFuzz : Real from Standard = 0.0)  
+            returns Fuse from BRepAlgoAPI;  
+        ---Purpose: Constructs a fuse of shapes aS1 and aS2.
+         
     Create (S1,S2 : Shape from TopoDS; 
-           aDSF:PaveFiller from BOPAlgo)  
-       returns Fuse from BRepAlgoAPI; 
-    
-       ---Purpose: Constructs a new shape that is a fuse of shapes aS1 and aS2 using aDSFiller. 
+            aDSF  : PaveFiller from BOPAlgo)  
+            returns Fuse from BRepAlgoAPI; 
+        ---Purpose: Constructs a new shape that is a fuse of shapes aS1 and aS2 using aDSFiller. 
     
 end Fuse;
index bca9efab631d8a6a9030bfcc9cc8132d69d4fa0d..85154f4728d48d6b68ad8295337f448188795f71 100644 (file)
@@ -23,8 +23,9 @@
 //purpose  : 
 //=======================================================================
   BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1, 
-                                     const TopoDS_Shape& S2)
-: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_FUSE)
+                                     const TopoDS_Shape& S2,
+                                     const Standard_Real theFuzz)
+: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_FUSE, theFuzz)
 {
   BRepAlgoAPI_BooleanOperation* pBO=
     (BRepAlgoAPI_BooleanOperation*) (void*) this;
index 98ec42ebbc8f307ba9ff0ad0bc2689babb26b50f..39fed0d4b2e1e471ae86c5415870e0253eebacb0 100644 (file)
 
 class Section from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
 
-       ---Purpose: Computes the intersection of two shapes or geometries.
-       -- Geometries can be surfaces of planes.
-       -- Geometries are converted to faces
-       -- When a geometry has been converted to
-       -- topology the created shape can be found using
-       -- the methods Shape1 and Shape2 inherited from the class BooleanOperation.
-       -- The result (Shape() method) is a compound containing 
-       -- edges built on intersection curves.
-       -- By default, the section is performed immediatly in 
-       -- class constructors, with default values :
-       -- - geometries built are NOT approximated.
-       -- - PCurves are NOT computed on both parts.
-       -- Example : giving two shapes S1,S2 accessing faces,
-       -- let compute the section edges R on S1,S2, 
-       -- performing approximation on new curves,
-       -- performing PCurve on part 1 but not on part 2 :
-       -- Standard_Boolean PerformNow = Standard_False;
-       -- BRepBoolAPI_Section S(S1,S2,PerformNow);
-       -- S.ComputePCurveOn1(Standard_True);
-       -- S.Approximation(Standard_True);
-       -- S.Build();
-       -- TopoDS_Shape R = S.Shape();
-       -- On Null Shapes of geometries, NotDone() is called. 
+            ---Purpose: Computes the intersection of two shapes or geometries.
+            -- Geometries can be surfaces of planes.
+            -- Geometries are converted to faces
+            -- When a geometry has been converted to
+            -- topology the created shape can be found using
+            -- the methods Shape1 and Shape2 inherited from the class BooleanOperation.
+            -- The result (Shape() method) is a compound containing 
+            -- edges built on intersection curves.
+            -- By default, the section is performed immediatly in 
+            -- class constructors, with default values :
+            -- - geometries built are NOT approximated.
+            -- - PCurves are NOT computed on both parts.
+            -- Example : giving two shapes S1,S2 accessing faces,
+            -- let compute the section edges R on S1,S2, 
+            -- performing approximation on new curves,
+            -- performing PCurve on part 1 but not on part 2 :
+            -- Standard_Boolean PerformNow = Standard_False;
+            -- BRepBoolAPI_Section S(S1,S2,PerformNow);
+            -- S.ComputePCurveOn1(Standard_True);
+            -- S.Approximation(Standard_True); 
+            -- S.SetFuzzyValue(theFuzz);
+            -- S.Build();
+            -- TopoDS_Shape R = S.Shape();
+            -- On Null Shapes of geometries, NotDone() is called. 
 
 uses
     Pln   from gp,
@@ -51,262 +52,262 @@ uses
     ListOfShape from TopTools
     
 is
-        Create (S1,S2 : Shape from TopoDS; 
-           aDSF:PaveFiller from BOPAlgo;
-           PerformNow : Boolean = Standard_True)  
-       returns Section from BRepAlgoAPI;
+    Create (S1,S2 : Shape from TopoDS; 
+            aDSF:PaveFiller from BOPAlgo;
+            PerformNow : Boolean = Standard_True)  
+            returns Section from BRepAlgoAPI;
     ---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Section(){}"   
 
     Create(Sh1,Sh2 : Shape from TopoDS;
-          PerformNow : Boolean = Standard_True)
-       ---Purpose: see upper
-       ---Level: Public
-       returns Section from BRepAlgoAPI;
+           PerformNow : Boolean = Standard_True)
+            ---Purpose: see upper
+            ---Level: Public
+            returns Section from BRepAlgoAPI;
 
     Create(Sh : Shape from TopoDS; Pl : Pln from gp;
-          PerformNow : Boolean = Standard_True)
-       ---Purpose: see upper
-       ---Level: Public
-       returns Section from BRepAlgoAPI;
+               PerformNow : Boolean = Standard_True)
+            ---Purpose: see upper
+            ---Level: Public
+            returns Section from BRepAlgoAPI;
 
     Create(Sh : Shape from TopoDS; Sf : Surface from Geom;
-          PerformNow : Boolean = Standard_True)
-       ---Purpose: see upper
-       ---Level: Public
-       returns Section from BRepAlgoAPI;
+            PerformNow : Boolean = Standard_True)
+            ---Purpose: see upper
+            ---Level: Public
+            returns Section from BRepAlgoAPI;
 
     Create(Sf : Surface from Geom; Sh : Shape from TopoDS;
-          PerformNow : Boolean = Standard_True)
-       ---Purpose: see upper
-       ---Level: Public
-       returns Section from BRepAlgoAPI;
+            PerformNow : Boolean = Standard_True)
+            ---Purpose: see upper
+            ---Level: Public
+        returns Section from BRepAlgoAPI;
 
     Create(Sf1 : Surface from Geom; Sf2 : Surface from Geom;
-       PerformNow : Boolean = Standard_True)
-       ---Purpose: This and the above classes construct a framework for
-       -- computing the section lines of:
-       -- -       two shapes Sh1 and Sh2, or
-       -- -       shape Sh and plane Pl,  or
-       -- -       shape Sh and surface Sf, or
-       -- -       surface Sf and shape Sh, or
-       -- -       two surfaces Sf1 and Sf2,
-       --   and builds a result if PerformNow equals true, its
-       -- default value. If PerformNow equals false, the intersection
-       -- will be computed later by the function Build.
-       --  The constructed shape will be returned by the function Shape.
-       -- This is a compound object composed of edges. These
-       -- intersection edges may be built:
-       -- -      on new intersection lines, or
-       -- -      on coincident portions of edges in the two intersected    shapes.
-       --   These intersection edges are independent: they are not
-       -- chained or grouped in wires. If no intersection edge exists, the
-       -- result is an empty compound object.
-       -- Note that other objects than TopoDS_Shape shapes involved in
-       -- these syntaxes are converted into faces or shells before
-       -- performing the computation of the intersection. A shape
-       -- resulting from this conversion can be retrieved with the
-       -- function Shape1 or Shape2.
-       -- Parametric 2D curves on intersection edges
-       -- No parametric 2D curve (pcurve) is defined for each elementary
-       -- edge of the result. To attach such parametric curves to the
-       -- constructed edges you may use a constructor with the PerformNow
-       -- flag equal to false; then you use:
-       -- -      the function ComputePCurveOn1 to ask for
-       --    the additional computation of a pcurve in the parametric
-       --    space of the first shape,
-       -- -      the function ComputePCurveOn2 to ask for
-       --    the additional computation of a pcurve in the parametric
-       --    space of the second shape, in the end,
-       -- -      the function Build to construct the result.
-       --   Approximation of intersection edges
-       --   The underlying 3D geometry attached to each elementary edge
-       -- of the result is:
-       -- -       analytic where possible, provided the corresponding
-       --    geometry corresponds to a type of analytic curve
-       --    defined in the Geom package; for example, the intersection
-       --    of a cylindrical shape with a plane gives an ellipse or a    circle;
-       -- -       or elsewhere, given as a succession of points grouped
-       --    together in a BSpline curve of degree 1.
-       -- If you prefer to have an attached 3D geometry which is a
-       -- BSpline approximation of the computed set of points on
-       -- computed elementary intersection edges whose underlying geometry
-       -- is not analytic, you may use a constructor with the PerformNow
-       -- flag equal to false. Then you use:
-       -- -      the function Approximation to ask for this
-       --    computation option, and
-       -- -      the function Build to construct the result.
-       -- -      Note that as a result, approximations will only be
-       --    computed on edges built on new intersection lines.
-       -- -      Example
-       -- You may also combine these computation options. In the following example:
-       -- - each elementary edge of the computed intersection,
-       --   built on a new intersection line, which does not
-       --  correspond to an analytic Geom curve, will be approximated by
-       --   a BSpline curve whose degree is not greater than 8.
-       -- - each elementary edge built on a new intersection line, will have:
-       -- - a pcurve in the parametric space of the intersected face of shape S1,
-       -- - no pcurve in the parametric space of the intersected face of shape S2.
-       --       // TopoDS_Shape S1 = ... , S2 = ... ;
-       -- Standard_Boolean PerformNow = Standard_False;
-       -- BRepAlgoAPI_Section S ( S1, S2, PerformNow );
-       -- S.ComputePCurveOn1 (Standard_True);
-       -- S.Approximation (Standard_True);
-       -- S.Build();
-       -- TopoDS_Shape R = S.Shape();
-       returns Section from BRepAlgoAPI;
+            PerformNow : Boolean = Standard_True)
+            ---Purpose: This and the above classes construct a framework for
+            -- computing the section lines of:
+            -- -       two shapes Sh1 and Sh2, or
+            -- -       shape Sh and plane Pl,  or
+            -- -       shape Sh and surface Sf, or
+            -- -       surface Sf and shape Sh, or
+            -- -       two surfaces Sf1 and Sf2,
+            --   and builds a result if PerformNow equals true, its
+            -- default value. If PerformNow equals false, the intersection
+            -- will be computed later by the function Build.
+            --  The constructed shape will be returned by the function Shape.
+            -- This is a compound object composed of edges. These
+            -- intersection edges may be built:
+            -- -      on new intersection lines, or
+            -- -      on coincident portions of edges in the two intersected    shapes.
+            --   These intersection edges are independent: they are not
+            -- chained or grouped in wires. If no intersection edge exists, the
+            -- result is an empty compound object.
+            -- Note that other objects than TopoDS_Shape shapes involved in
+            -- these syntaxes are converted into faces or shells before
+            -- performing the computation of the intersection. A shape
+            -- resulting from this conversion can be retrieved with the
+            -- function Shape1 or Shape2.
+            -- Parametric 2D curves on intersection edges
+            -- No parametric 2D curve (pcurve) is defined for each elementary
+            -- edge of the result. To attach such parametric curves to the
+            -- constructed edges you may use a constructor with the PerformNow
+            -- flag equal to false; then you use:
+            -- -      the function ComputePCurveOn1 to ask for
+            --    the additional computation of a pcurve in the parametric
+            --    space of the first shape,
+            -- -      the function ComputePCurveOn2 to ask for
+            --    the additional computation of a pcurve in the parametric
+            --    space of the second shape, in the end,
+            -- -      the function Build to construct the result.
+            --   Approximation of intersection edges
+            --   The underlying 3D geometry attached to each elementary edge
+            -- of the result is:
+            -- -       analytic where possible, provided the corresponding
+            --    geometry corresponds to a type of analytic curve
+            --    defined in the Geom package; for example, the intersection
+            --    of a cylindrical shape with a plane gives an ellipse or a    circle;
+            -- -       or elsewhere, given as a succession of points grouped
+            --    together in a BSpline curve of degree 1.
+            -- If you prefer to have an attached 3D geometry which is a
+            -- BSpline approximation of the computed set of points on
+            -- computed elementary intersection edges whose underlying geometry
+            -- is not analytic, you may use a constructor with the PerformNow
+            -- flag equal to false. Then you use:
+            -- -      the function Approximation to ask for this
+            --    computation option, and
+            -- -      the function Build to construct the result.
+            -- -      Note that as a result, approximations will only be
+            --    computed on edges built on new intersection lines.
+            -- -      Example
+            -- You may also combine these computation options. In the following example:
+            -- - each elementary edge of the computed intersection,
+            --   built on a new intersection line, which does not
+            --  correspond to an analytic Geom curve, will be approximated by
+            --   a BSpline curve whose degree is not greater than 8.
+            -- - each elementary edge built on a new intersection line, will have:
+            -- - a pcurve in the parametric space of the intersected face of shape S1,
+            -- - no pcurve in the parametric space of the intersected face of shape S2.
+            --       // TopoDS_Shape S1 = ... , S2 = ... ;
+            -- Standard_Boolean PerformNow = Standard_False;
+            -- BRepAlgoAPI_Section S ( S1, S2, PerformNow );
+            -- S.ComputePCurveOn1 (Standard_True);
+            -- S.Approximation (Standard_True);
+            -- S.Build();
+            -- TopoDS_Shape R = S.Shape();
+        returns Section from BRepAlgoAPI;
 
     Init1(me : out;S1 : Shape from TopoDS);
-       ---Purpose: initialize first part
-       ---Level: Public
+            ---Purpose: initialize first part
+            ---Level: Public
  
     Init1(me : out;Pl : Pln from gp);
-       ---Purpose: initialize first part
-       ---Level: Public
+            ---Purpose: initialize first part
+            ---Level: Public
  
     Init1(me : out;Sf : Surface from Geom);
-       ---Purpose: initialize first part
-       ---Level: Public
+            ---Purpose: initialize first part
+            ---Level: Public
  
     Init2(me : out;S2 : Shape from TopoDS);
-       ---Purpose: initialize second part
-       ---Level: Public
+            ---Purpose: initialize second part
+            ---Level: Public
  
     Init2(me : out;Pl : Pln from gp);
-       ---Purpose: initialize second part
-       ---Level: Public
+            ---Purpose: initialize second part
+            ---Level: Public
  
     Init2(me : out;Sf : Surface from Geom);
-       ---Purpose: Reinitializes the first and the
-       -- second parts on which this algorithm is going to perform
-       -- the intersection computation. This is done with either: the
-       -- surface Sf, the plane Pl or the shape Sh.
-       -- You use the function Build to construct the result.
+            ---Purpose: Reinitializes the first and the
+            -- second parts on which this algorithm is going to perform
+            -- the intersection computation. This is done with either: the
+            -- surface Sf, the plane Pl or the shape Sh.
+            -- You use the function Build to construct the result.
  
     Approximation(me : out;B : Boolean);
-       ---Level: Public
-       ---Purpose: Defines an option for computation
-       -- of further intersections. This computation will be performed by
-       -- the function Build in this framework.
-       -- By default, the underlying 3D geometry attached to each
-       -- elementary edge of the result of a computed intersection is:
-       -- - analytic where possible, provided the corresponding
-       --    geometry corresponds to a type of analytic curve defined in
-       --    the Geom package; for example the intersection of a
-       --    cylindrical shape with a plane gives an ellipse or a circle;
-       -- -      or elsewhere, given as a succession of points grouped
-       -- together in a BSpline curve of degree 1. If Approx equals
-       -- true, when further computations are performed in this framework
-       -- with the function Build, these edges will have an attached 3D
-       --    geometry which is a BSpline approximation of the computed
-       --    set of points.
-       --   Note that as a result, approximations will be computed
-       -- on edges built only on new intersection lines.
+            ---Level: Public
+            ---Purpose: Defines an option for computation
+            -- of further intersections. This computation will be performed by
+            -- the function Build in this framework.
+            -- By default, the underlying 3D geometry attached to each
+            -- elementary edge of the result of a computed intersection is:
+            -- - analytic where possible, provided the corresponding
+            --    geometry corresponds to a type of analytic curve defined in
+            --    the Geom package; for example the intersection of a
+            --    cylindrical shape with a plane gives an ellipse or a circle;
+            -- -      or elsewhere, given as a succession of points grouped
+            -- together in a BSpline curve of degree 1. If Approx equals
+            -- true, when further computations are performed in this framework
+            -- with the function Build, these edges will have an attached 3D
+            --    geometry which is a BSpline approximation of the computed
+            --    set of points.
+            --   Note that as a result, approximations will be computed
+            -- on edges built only on new intersection lines.
  
     ComputePCurveOn1(me : out;B : Boolean);
-       ---Level: Public
-       ---Purpose: 
-       -- Indicates if the Pcurve must be (or not) performed on first part. 
+            ---Level: Public
+            ---Purpose: 
+            -- Indicates if the Pcurve must be (or not) performed on first part. 
 
     ComputePCurveOn2(me : out;B : Boolean);
-       ---Level: Public
-       ---Purpose: Define options for the computation of further
-       -- intersections, which will be performed by the function Build
-       -- in this framework.
-       -- By default, no parametric 2D curve (pcurve) is defined for the
-       -- elementary edges of the result. If ComputePCurve1 equals true,
-       -- further computations performed in this framework with the function
-       -- Build will attach an additional pcurve in the parametric space of
-       -- the first shape to the constructed edges.
-       -- If ComputePCurve2 equals true, the additional pcurve will be
-       -- attached to the constructed edges in the parametric space of the
-       -- second shape.
-       -- These two functions may be used together.
+            ---Level: Public
+            ---Purpose: Define options for the computation of further
+            -- intersections, which will be performed by the function Build
+            -- in this framework.
+            -- By default, no parametric 2D curve (pcurve) is defined for the
+            -- elementary edges of the result. If ComputePCurve1 equals true,
+            -- further computations performed in this framework with the function
+            -- Build will attach an additional pcurve in the parametric space of
+            -- the first shape to the constructed edges.
+            -- If ComputePCurve2 equals true, the additional pcurve will be
+            -- attached to the constructed edges in the parametric space of the
+            -- second shape.
+            -- These two functions may be used together.
  
     Build(me : in out)
-       ---Purpose:  Performs the computation of
-       -- section lines between two parts defined at the time of
-       -- construction of this framework or reinitialized with the Init1 and
-       -- Init2 functions.
-       -- The constructed shape will be returned by the function Shape.
-       -- This is a compound object composed of edges. These
-       -- intersection edges may be built:
-       -- -      on new intersection lines, or
-       -- -      on coincident portions of edges in the two intersected shapes.
-       -- These intersection edges are independent: they are not chained
-       -- or grouped into wires.
-       -- If no intersection edge exists, the result is an empty compound object.
-       -- The shapes involved in the construction of section lines can
-       -- be retrieved with the function Shape1 or Shape2. Note that other
-       -- objects than TopoDS_Shape shapes given as arguments at the
-       -- construction time of this framework, or to the Init1 or
-       -- Init2 function, are converted into faces or shells before
-       -- performing the computation of the intersection.
-       -- Parametric 2D curves on intersection edges
-       -- No parametric 2D curve (pcurve) is defined for the elementary
-       -- edges of the result. To attach parametric curves like this to
-       -- the constructed edges you have to use:
-       -- -      the function
-       -- ComputePCurveOn1 to ask for the additional computation of a
-       -- pcurve in the parametric space of the first shape,
-       -- -      the function
-       --    ComputePCurveOn2 to ask for the additional computation of a
-       --    pcurve in the parametric space of the second shape.
-       -- This must be done before calling this function.
-       --   Approximation of intersection edges
-       -- The underlying 3D geometry attached to each elementary edge of the result is:
-       -- -      analytic (where possible) provided the corresponding
-       -- geometry corresponds to a type of analytic curve defined in
-       --    the Geom package; for example, the intersection of a
-       --    cylindrical shape with a plane gives an ellipse or a circle;    or
-       -- -      elsewhere, given as a succession of points grouped
-       --    together in a BSpline curve of degree 1.
-       --   If, on computed elementary intersection edges whose
-       -- underlying geometry is not analytic, you prefer to have an
-       -- attached 3D geometry which is a Bspline approximation of the
-       -- computed set of points, you have to use the function Approximation
-       -- to ask for this computation option before calling this function.
-       -- You may also have combined these computation options: look at the
-       -- example given above to illustrate the use of the constructors.
-       is redefined static;
+            ---Purpose:  Performs the computation of
+            -- section lines between two parts defined at the time of
+            -- construction of this framework or reinitialized with the Init1 and
+            -- Init2 functions.
+            -- The constructed shape will be returned by the function Shape.
+            -- This is a compound object composed of edges. These
+            -- intersection edges may be built:
+            -- -      on new intersection lines, or
+            -- -      on coincident portions of edges in the two intersected shapes.
+            -- These intersection edges are independent: they are not chained
+            -- or grouped into wires.
+            -- If no intersection edge exists, the result is an empty compound object.
+            -- The shapes involved in the construction of section lines can
+            -- be retrieved with the function Shape1 or Shape2. Note that other
+            -- objects than TopoDS_Shape shapes given as arguments at the
+            -- construction time of this framework, or to the Init1 or
+            -- Init2 function, are converted into faces or shells before
+            -- performing the computation of the intersection.
+            -- Parametric 2D curves on intersection edges
+            -- No parametric 2D curve (pcurve) is defined for the elementary
+            -- edges of the result. To attach parametric curves like this to
+            -- the constructed edges you have to use:
+            -- -      the function
+            -- ComputePCurveOn1 to ask for the additional computation of a
+            -- pcurve in the parametric space of the first shape,
+            -- -      the function
+            --    ComputePCurveOn2 to ask for the additional computation of a
+            --    pcurve in the parametric space of the second shape.
+            -- This must be done before calling this function.
+            --   Approximation of intersection edges
+            -- The underlying 3D geometry attached to each elementary edge of the result is:
+            -- -      analytic (where possible) provided the corresponding
+            -- geometry corresponds to a type of analytic curve defined in
+            --    the Geom package; for example, the intersection of a
+            --    cylindrical shape with a plane gives an ellipse or a circle;    or
+            -- -      elsewhere, given as a succession of points grouped
+            --    together in a BSpline curve of degree 1.
+            --   If, on computed elementary intersection edges whose
+            -- underlying geometry is not analytic, you prefer to have an
+            -- attached 3D geometry which is a Bspline approximation of the
+            -- computed set of points, you have to use the function Approximation
+            -- to ask for this computation option before calling this function.
+            -- You may also have combined these computation options: look at the
+            -- example given above to illustrate the use of the constructors.
+            is redefined static;
 
     HasAncestorFaceOn1(me; E : Shape from TopoDS;
-                          F : out Shape from TopoDS)
-       returns Boolean;
-       ---Level: Public
-       ---Purpose:
-       -- get the face of the first part giving section edge <E>.
-       -- Returns True on the 3 following conditions :
-       -- 1/ <E> is an edge returned by the Shape() method. 
-       -- 2/ First part of section performed is a shape.
-       -- 3/ <E> is built on a intersection curve (i.e <E>
-       --       is not the result of common edges)
-       -- When False, F remains untouched.
+                                       F : out Shape from TopoDS)
+            returns Boolean;
+            ---Level: Public
+            ---Purpose:
+            -- get the face of the first part giving section edge <E>.
+            -- Returns True on the 3 following conditions :
+            -- 1/ <E> is an edge returned by the Shape() method. 
+            -- 2/ First part of section performed is a shape.
+            -- 3/ <E> is built on a intersection curve (i.e <E>
+            --          is not the result of common edges)
+            -- When False, F remains untouched.
 
     HasAncestorFaceOn2(me; E : Shape from TopoDS;
-                          F : out Shape from TopoDS)
-       returns Boolean;
-       ---Purpose:  Identifies the ancestor faces of
-       -- the intersection edge E resulting from the last
-       -- computation performed in this framework, that is, the faces of
-       -- the two original shapes on which the edge E lies:
-       -- -      HasAncestorFaceOn1 gives the ancestor face in the first shape, and
-       -- -      HasAncestorFaceOn2 gives the ancestor face in the second shape.
-       --   These functions return true if an ancestor face F is found, or false if not.
-       --   An ancestor face is identifiable for the edge E if the following
-       -- conditions are satisfied:
-       -- -  the first part on which this algorithm performed its
-       --    last computation is a shape, that is, it was not given as
-       -- a surface or a plane at the time of construction of this
-       -- algorithm or at a later time by the Init1 function,
-       -- - E is one of the elementary edges built by the
-       -- last computation of this section algorithm.
-       -- To use these functions properly, you have to test the returned
-       -- Boolean value before using the ancestor face: F is significant
-       -- only if the returned Boolean value equals true.
+                                    F : out Shape from TopoDS)
+            returns Boolean;
+            ---Purpose:  Identifies the ancestor faces of
+            -- the intersection edge E resulting from the last
+            -- computation performed in this framework, that is, the faces of
+            -- the two original shapes on which the edge E lies:
+            -- -      HasAncestorFaceOn1 gives the ancestor face in the first shape, and
+            -- -      HasAncestorFaceOn2 gives the ancestor face in the second shape.
+            --   These functions return true if an ancestor face F is found, or false if not.
+            --   An ancestor face is identifiable for the edge E if the following
+            -- conditions are satisfied:
+            -- -  the first part on which this algorithm performed its
+            --    last computation is a shape, that is, it was not given as
+            -- a surface or a plane at the time of construction of this
+            -- algorithm or at a later time by the Init1 function,
+            -- - E is one of the elementary edges built by the
+            -- last computation of this section algorithm.
+            -- To use these functions properly, you have to test the returned
+            -- Boolean value before using the ancestor face: F is significant
+            -- only if the returned Boolean value equals true.
 
     InitParameters(me: out)
-       ---Level: Private
-       is private;
+            ---Level: Private
+            is private;
 
 fields
     myshapeisnull       : Boolean from Standard;
index 7b9c80eb38ebedb5b0f411fab625e84a3b430402..700e591a935bf4e3d114ac90f2a4c48c73a972aa 100644 (file)
@@ -51,10 +51,20 @@ is
         Quadric      from IntSurf,
         QuadricTool  from IntSurf,
         WLine        from IntPatch);
-
+        
     private class ParameterAndOrientation;
 
     private class SequenceOfParameterAndOrientation instantiates
        Sequence from TCollection(ParameterAndOrientation);
 
+    AdjustPeriodic(thePar    : Real from Standard;
+                  theParMin : Real from Standard;
+                  theParMax : Real from Standard;
+                  thePeriod : Real from Standard;
+                  theNewPar : out Real from Standard;
+                  theOffset : out Real from Standard;
+                  theEps    : Real from Standard = 0.0)
+    returns Boolean from Standard;        
+    ---Purpose:  Adjusts the parameter <thePar> to the range [theParMin,  theParMax]
+
 end GeomInt;
diff --git a/src/GeomInt/GeomInt.cxx b/src/GeomInt/GeomInt.cxx
new file mode 100644 (file)
index 0000000..ad6bb2b
--- /dev/null
@@ -0,0 +1,50 @@
+
+// Created on:   25.08.14 17:59:59
+// Created by:    jgv@VIVEX
+// 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 <GeomInt.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+//=======================================================================
+//function : AdjustPeriodic
+//purpose  : 
+//=======================================================================
+Standard_Boolean GeomInt::AdjustPeriodic(const Standard_Real thePar,
+                                         const Standard_Real theParMin,
+                                         const Standard_Real theParMax,
+                                         const Standard_Real thePeriod,
+                                         Standard_Real &theNewPar,
+                                         Standard_Real &theOffset,
+                                         const Standard_Real theEps)
+{
+  Standard_Boolean bMin, bMax;
+  //
+  theOffset = 0.;
+  theNewPar = thePar;
+  bMin = theParMin - thePar > theEps;
+  bMax = thePar - theParMax > theEps;
+  //
+  if (bMin || bMax) {
+    Standard_Real dp, aNbPer;
+    //
+    dp = (bMin) ? (theParMax - thePar) : (theParMin - thePar);
+    modf(dp / thePeriod, &aNbPer);
+    //
+    theOffset = aNbPer * thePeriod;
+    theNewPar += theOffset;
+  }
+  //
+  return (theOffset > 0.);
+}