0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BOPTools / BOPTools_AlgoTools_2.cxx
index f75982b..cac1dc5 100644 (file)
@@ -1,41 +1,38 @@
 // Created by: Peter KURNEV
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// 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.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 
-#include <BOPTools_AlgoTools.ixx>
-
+#include <BOPTools_AlgoTools.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <Geom_Curve.hxx>
+#include <GeomAbs_CurveType.hxx>
+#include <gp_Pnt.hxx>
+#include <IntTools_Context.hxx>
+#include <IntTools_Curve.hxx>
+#include <IntTools_Range.hxx>
 #include <Precision.hxx>
-
 #include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
 #include <TopoDS_Edge.hxx>
-
-#include <gp_Pnt.hxx>
-
-#include <Geom_Curve.hxx>
-#include <IntTools_Curve.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <GeomAbs_CurveType.hxx>
-
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
+#include <TopoDS_Face.hxx>
 #include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
 
 static
   void TreatCompound(const TopoDS_Shape& theC1, 
@@ -45,8 +42,9 @@ static
 // function: UpdateVertex
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::UpdateVertex (const TopoDS_Vertex& aVF,
-                                     const TopoDS_Vertex& aNewVertex)
+void BOPTools_AlgoTools::UpdateVertex
+  (const TopoDS_Vertex& aVF,
+   const TopoDS_Vertex& aNewVertex)
 {
   Standard_Real aTolVF, aTolNewVertex, aDist, aDTol=1.e-12, aNewTol;
   //
@@ -68,9 +66,9 @@ static
 // function: UpdateVertex
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::UpdateVertex (const TopoDS_Edge& aE,
-                                     const Standard_Real  aT,
-                                     const TopoDS_Vertex& aV)
+void BOPTools_AlgoTools::UpdateVertex (const TopoDS_Edge& aE,
+                                       const Standard_Real  aT,
+                                       const TopoDS_Vertex& aV)
 {
   Standard_Real aTolV, aDist, aDTol=1.e-12, aFirst, aLast;
   gp_Pnt  aPc; 
@@ -78,8 +76,8 @@ static
   gp_Pnt aPv=BRep_Tool::Pnt(aV);
   aTolV=BRep_Tool::Tolerance(aV);
 
-  Handle(Geom_Curve) aC3D=BRep_Tool::Curve(aE, aFirst, aLast);
-  aC3D->D0(aT, aPc);
+  GeomAdaptor_Curve aCA( BRep_Tool::Curve(aE, aFirst, aLast) );
+  aCA.D0(aT, aPc);
   aDist=aPv.Distance(aPc);
   if (aDist>aTolV) {
     BRep_Builder BB;
@@ -91,9 +89,9 @@ static
 // function: UpdateVertex
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::UpdateVertex (const IntTools_Curve& aC,
-                                     const Standard_Real  aT,
-                                     const TopoDS_Vertex& aV)
+void BOPTools_AlgoTools::UpdateVertex (const IntTools_Curve& aC,
+                                       const Standard_Real  aT,
+                                       const TopoDS_Vertex& aV)
 {
   Standard_Real aTolV, aDist, aDTol=1.e-12;
   gp_Pnt  aPc; 
@@ -101,8 +99,8 @@ static
   gp_Pnt aPv=BRep_Tool::Pnt(aV);
   aTolV=BRep_Tool::Tolerance(aV);
 
-  Handle(Geom_Curve) aC3D=aC.Curve();
-  aC3D->D0(aT, aPc);
+  GeomAdaptor_Curve aCA( aC.Curve() );
+  aCA.D0(aT, aPc);
   aDist=aPv.Distance(aPc);
   if (aDist>aTolV) {
     BRep_Builder BB;
@@ -113,12 +111,12 @@ static
 // function: MakeSectEdge
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::MakeSectEdge(const IntTools_Curve& aIC,
-                                     const TopoDS_Vertex& aV1,
-                                     const Standard_Real  aP1,
-                                     const TopoDS_Vertex& aV2,
-                                     const Standard_Real  aP2,
-                                     TopoDS_Edge& aNewEdge)
+void BOPTools_AlgoTools::MakeSectEdge(const IntTools_Curve& aIC,
+                                      const TopoDS_Vertex& aV1,
+                                      const Standard_Real  aP1,
+                                      const TopoDS_Vertex& aV2,
+                                      const Standard_Real  aP2,
+                                      TopoDS_Edge& aNewEdge)
 {
   Handle(Geom_Curve) aC=aIC.Curve ();
   
@@ -138,23 +136,19 @@ static
 // function: MakeSplitEdge
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::MakeSplitEdge(const TopoDS_Edge&   aE,
-                                     const TopoDS_Vertex& aV1,
-                                     const Standard_Real  aP1,
-                                     const TopoDS_Vertex& aV2,
-                                     const Standard_Real  aP2,
-                                     TopoDS_Edge& aNewEdge)
+void BOPTools_AlgoTools::MakeSplitEdge(const TopoDS_Edge&   aE,
+                                       const TopoDS_Vertex& aV1,
+                                       const Standard_Real  aP1,
+                                       const TopoDS_Vertex& aV2,
+                                       const Standard_Real  aP2,
+                                       TopoDS_Edge& aNewEdge)
 {
-  Standard_Real f, l, aTol;
-  Handle(Geom_Curve) aC=BRep_Tool::Curve (aE, f, l);
+  Standard_Real aTol;//f, l, 
   aTol=BRep_Tool::Tolerance(aE);
   //
-  // MakeEdge is used for chechking all input data only 
-  BRepBuilderAPI_MakeEdge aMakeEdge(aC, aV1, aV2, aP1, aP2);
-  //ZZ const TopoDS_Edge& E1=TopoDS::Edge(aMakeEdge.Shape());
   TopoDS_Edge E=aE;
   E.EmptyCopy();
-
+  //
   BRep_Builder BB;
   BB.Add  (E, aV1);
   BB.Add  (E, aV2);
@@ -167,9 +161,9 @@ static
 // function: MakeNewVertex
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::MakeNewVertex(const TopoDS_Vertex& aV1,
-                                     const TopoDS_Vertex& aV2,
-                                     TopoDS_Vertex& aNewVertex)
+void BOPTools_AlgoTools::MakeNewVertex(const TopoDS_Vertex& aV1,
+                                       const TopoDS_Vertex& aV2,
+                                       TopoDS_Vertex& aNewVertex)
 {
   gp_Pnt aPnt1=BRep_Tool::Pnt(aV1);
   Standard_Real aTol1=BRep_Tool::Tolerance(aV1);
@@ -195,9 +189,9 @@ static
 // function: MakeNewVertex
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::MakeNewVertex(const gp_Pnt& aP,
-                                     const Standard_Real aTol,
-                                     TopoDS_Vertex& aNewVertex)
+void BOPTools_AlgoTools::MakeNewVertex(const gp_Pnt& aP,
+                                       const Standard_Real aTol,
+                                       TopoDS_Vertex& aNewVertex)
 {
   BRep_Builder aBB;
   aBB.MakeVertex (aNewVertex, aP, aTol);
@@ -207,11 +201,11 @@ static
 // function: MakeNewVertex
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::MakeNewVertex(const TopoDS_Edge& aE1,
-                                     const Standard_Real aParm1,
-                                     const TopoDS_Edge& aE2,
-                                     const Standard_Real aParm2,
-                                     TopoDS_Vertex& aNewVertex)
+void BOPTools_AlgoTools::MakeNewVertex(const TopoDS_Edge& aE1,
+                                       const Standard_Real aParm1,
+                                       const TopoDS_Edge& aE2,
+                                       const Standard_Real aParm2,
+                                       TopoDS_Vertex& aNewVertex)
 {
   Standard_Real aTol1, aTol2, aMaxTol, aDist; 
   gp_Pnt aPnt1, aPnt2;
@@ -238,10 +232,10 @@ static
 // function: MakeNewVertex
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::MakeNewVertex(const TopoDS_Edge& aE1,
-                                     const Standard_Real aParm1,
-                                     const TopoDS_Face& aF1,
-                                     TopoDS_Vertex& aNewVertex)
+void BOPTools_AlgoTools::MakeNewVertex(const TopoDS_Edge& aE1,
+                                       const Standard_Real aParm1,
+                                       const TopoDS_Face& aF1,
+                                       TopoDS_Vertex& aNewVertex)
 {
   Standard_Real aTol1, aTol2, aMaxTol, delta=1.e-12; 
   gp_Pnt aPnt;
@@ -262,9 +256,9 @@ static
 // function: PointOnEdge
 // purpose: 
 //=======================================================================
-  void BOPTools_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
-                                   const Standard_Real aParm,
-                                   gp_Pnt& aPnt)
+void BOPTools_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
+                                     const Standard_Real aParm,
+                                     gp_Pnt& aPnt)
 {
   Standard_Real f, l;
   Handle(Geom_Curve) C1=BRep_Tool::Curve(aE, f, l);
@@ -275,10 +269,10 @@ static
 //function : CorrectRange
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools::CorrectRange(const TopoDS_Edge& aE1,
-                                    const TopoDS_Edge& aE2,
-                                    const IntTools_Range& aSR,
-                                    IntTools_Range& aNewSR)
+void BOPTools_AlgoTools::CorrectRange(const TopoDS_Edge& aE1,
+                                      const TopoDS_Edge& aE2,
+                                      const IntTools_Range& aSR,
+                                      IntTools_Range& aNewSR)
 {
   Standard_Integer i;
   Standard_Real aRes, aTolE1, aTolE2, aTF, aTL, dT;
@@ -347,10 +341,10 @@ static
 //function : CorrectRange
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools::CorrectRange(const TopoDS_Edge& aE,
-                                    const TopoDS_Face& aF,
-                                    const IntTools_Range& aSR,
-                                    IntTools_Range& aNewSR)
+void BOPTools_AlgoTools::CorrectRange(const TopoDS_Edge& aE,
+                                      const TopoDS_Face& aF,
+                                      const IntTools_Range& aSR,
+                                      IntTools_Range& aNewSR)
 {
   Standard_Integer i;
   Standard_Real aRes, aTolF, aTF, aTL, dT;
@@ -413,7 +407,7 @@ static
 //function : Dimension
 //purpose  : 
 //=======================================================================
-  Standard_Integer BOPTools_AlgoTools::Dimension(const TopoDS_Shape& theS)
+Standard_Integer BOPTools_AlgoTools::Dimension(const TopoDS_Shape& theS)
 {
   Standard_Integer i, iRet, iRx0 = 0, iRx = 0;
   TopAbs_ShapeEnum aTS;
@@ -467,8 +461,8 @@ static
 //function : TreatCompound
 //purpose  : 
 //=======================================================================
-  void TreatCompound(const TopoDS_Shape& theC1, 
-                     BOPCol_ListOfShape& theLSX)
+void TreatCompound(const TopoDS_Shape& theC1, 
+                   BOPCol_ListOfShape& theLSX)
 {
   Standard_Integer aNbC1;
   TopAbs_ShapeEnum aType;