From 776c398c4da2d5e39acf9991987b7cf029b5933c Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 11 May 2013 19:40:45 +0000
Subject: [PATCH] support OCC 6.6 (but seems MUCH MUCH slower than 6.5)

---
 Geo/GFace.cpp       |  4 ++--
 Geo/GModel.cpp      |  2 +-
 Geo/OCCEdge.cpp     |  9 +++++++++
 Geo/OCCFace.cpp     | 29 +++++++++++++++++++++++++----
 Geo/OCC_Connect.cpp |  2 --
 5 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp
index 428b94c0e9..792673e2f2 100644
--- a/Geo/GFace.cpp
+++ b/Geo/GFace.cpp
@@ -1361,9 +1361,9 @@ void GFace::lloyd(int nbiter, int infn)
 #endif
 }
 
-void GFace::replaceEdges (std::list<GEdge*> &new_edges)
+void GFace::replaceEdges(std::list<GEdge*> &new_edges)
 {
-  replaceEdgesInternal (new_edges);
+  replaceEdgesInternal(new_edges);
   std::list<GEdge*>::iterator it  = l_edges.begin();
   std::list<GEdge*>::iterator it2 = new_edges.begin();
   std::list<int>::iterator it3 = l_dirs.begin();
diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index e32ee9f325..b95b90eb95 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -2740,7 +2740,7 @@ static void glueEdgesInFaces(GModel *model,
     }
     if (aDifferenceExists){
       Msg::Debug("Model Face %d is re-build", f->tag());
-      f->replaceEdges (enew);
+      f->replaceEdges(enew);
     }
   }
 }
diff --git a/Geo/OCCEdge.cpp b/Geo/OCCEdge.cpp
index 08794ede6a..e588e95489 100644
--- a/Geo/OCCEdge.cpp
+++ b/Geo/OCCEdge.cpp
@@ -13,6 +13,7 @@
 
 #if defined(HAVE_OCC)
 #include "GModelIO_OCC.h"
+#include <Standard_Version.hxx>
 #include <Geom2dLProp_CLProps2d.hxx>
 #include <Geom_BezierCurve.hxx>
 #include <Geom_OffsetCurve.hxx>
@@ -23,7 +24,11 @@
 #include <Geom_Circle.hxx>
 #include <Geom_Line.hxx>
 #include <Geom_Conic.hxx>
+#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR < 5)
 #include <BOPTools_Tools.hxx>
+#else
+#include <BOPTools_AlgoTools.hxx>
+#endif
 
 OCCEdge::OCCEdge(GModel *m, TopoDS_Edge edge, int num, GVertex *v1, GVertex *v2)
   : GEdge(m, num, v1, v2), c(edge), trimmed(0)
@@ -330,7 +335,11 @@ void OCCEdge::replaceEndingPointsInternals(GVertex *g0, GVertex *g1)
     _replacement=E;
   }
   else {
+#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR < 5)
     BOPTools_Tools::MakeSplitEdge(aEx, aVR1, t1, aVR2, t2, _replacement);
+#else
+    BOPTools_AlgoTools::MakeSplitEdge(aEx, aVR1, t1, aVR2, t2, _replacement);
+#endif
   }
   TopoDS_Edge temp = c;
   c = _replacement;
diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp
index a3dfb968c3..f0ad8d11e1 100644
--- a/Geo/OCCFace.cpp
+++ b/Geo/OCCFace.cpp
@@ -26,9 +26,16 @@
 #include <Geom_Plane.hxx>
 #include <gp_Pln.hxx>
 #include <BRepMesh_FastDiscret.hxx>
+
+#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR >= 6)
+#include <BOPInt_Context.hxx>
+#include <BOPTools_AlgoTools2D.hxx>
+#include <BOPTools_AlgoTools.hxx>
+#else
 #include <IntTools_Context.hxx>
 #include <BOPTools_Tools2D.hxx>
 #include <BOPTools_Tools3D.hxx>
+#endif
 
 OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num)
   : GFace(m, num), s(_s)
@@ -165,7 +172,7 @@ GPoint OCCFace::point(double par1, double par2) const
   double pp[2] = {par1, par2};
   double umin2, umax2, vmin2, vmax2;
   ShapeAnalysis::GetFaceUVBounds(s, umin2, umax2, vmin2, vmax2);
-  
+
   double du = umax2 - umin2;
   double dv = vmax2 - vmin2;
 
@@ -441,7 +448,10 @@ bool OCCFace::buildSTLTriangulation(bool force)
 
 void OCCFace::replaceEdgesInternal(std::list<GEdge*> &new_edges)
 {
-#if defined(OCC_VERSION_HEX) && OCC_VERSION_HEX >= 0x060503
+
+#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR >= 6)
+  Handle(BOPInt_Context) myContext = new BOPInt_Context;
+#elif defined(OCC_VERSION_HEX) && OCC_VERSION_HEX >= 0x060503
   Handle(IntTools_Context) myContext = new IntTools_Context;
 #else
   IntTools_Context myContext;
@@ -505,7 +515,11 @@ void OCCFace::replaceEdgesInternal(std::list<GEdge*> &new_edges)
 	      continue;
 	    }
 	    else{
-	      aTx=BOPTools_Tools2D::IntermediatePoint(aT1, aT2);
+#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR >= 6)
+	      aTx = BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2);
+#else
+	      aTx = BOPTools_Tools2D::IntermediatePoint(aT1, aT2);
+#endif
 	      gp_Pnt2d aP2D;
 	      aC2D->D0(aTx, aP2D);
 	      aUx=aP2D.X();
@@ -517,11 +531,18 @@ void OCCFace::replaceEdgesInternal(std::list<GEdge*> &new_edges)
 	    }
 	  }
 	}
+#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR >= 6)
+	BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aER, copy_of_s_forward);
+#else
 	BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aER, copy_of_s_forward);
-
+#endif
 	// orient image
 	Standard_Boolean bIsToReverse =
+#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR >= 6)
+          BOPTools_AlgoTools::IsSplitToReverse(aER, aE, myContext);
+#else
           BOPTools_Tools3D::IsSplitToReverse1(aER, aE, myContext);
+#endif
 	if (bIsToReverse) {
 	  aER.Reverse();
 	}
diff --git a/Geo/OCC_Connect.cpp b/Geo/OCC_Connect.cpp
index e1af53c942..0748b0c9f6 100644
--- a/Geo/OCC_Connect.cpp
+++ b/Geo/OCC_Connect.cpp
@@ -41,8 +41,6 @@
 #include <BRep_Tool.hxx>
 #include <BRepClass_FaceClassifier.hxx>
 
-#include <IntTools_Context.hxx>
-
 #include <BRepExtrema_DistShapeShape.hxx>
 #include <BRepOffsetAPI_NormalProjection.hxx>
 #include <BRepTopAdaptor_FClass2d.hxx>
-- 
GitLab