From 72680f2cf7108330a70146f5b27330414d82d2c1 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 9 Feb 2017 16:11:44 +0000
Subject: [PATCH] make sure create volumes are finite

---
 Geo/GModelIO_OCC.cpp           | 11 +++++++++--
 benchmarks/boolean/simple4.geo |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp
index decae7ce9f..3b76e017ba 100644
--- a/Geo/GModelIO_OCC.cpp
+++ b/Geo/GModelIO_OCC.cpp
@@ -491,6 +491,9 @@ void OCC_Internals::addPlanarFace(int tag, std::vector<int> wireTags)
         return;
       }
       result = f.Face();
+      //ShapeFix_Face fix(face);
+      //fix.Perform();
+      //result = fix.Face();
     }
     catch(Standard_Failure &err){
       Msg::Error("OpenCASCADE exception %s", err.GetMessageString());
@@ -535,8 +538,8 @@ void OCC_Internals::addSurfaceLoop(int tag, std::vector<int> faceTags)
   TopExp_Explorer exp0;
   for(exp0.Init(result, TopAbs_SHELL); exp0.More(); exp0.Next()){
     TopoDS_Shell shell = TopoDS::Shell(exp0.Current());
-    //ShapeFix_Shell fix;
-    //fix.FixFaceOrientation(shell);
+    //ShapeFix_Shell fix(shell);
+    //fix.Perform();
     //shell = fix.Shell();
     int t = tag;
     if(first){
@@ -574,6 +577,10 @@ void OCC_Internals::addVolume(int tag, std::vector<int> shellTags)
     Msg::Error("OpenCASCADE exception %s", err.GetMessageString());
     return;
   }
+  // make sure the volume is finite
+  ShapeFix_Solid fix(result);
+  fix.Perform();
+  result = TopoDS::Solid(fix.Solid());
   bind(result, tag);
 }
 
diff --git a/benchmarks/boolean/simple4.geo b/benchmarks/boolean/simple4.geo
index c7d4c73279..8709514eb2 100644
--- a/benchmarks/boolean/simple4.geo
+++ b/benchmarks/boolean/simple4.geo
@@ -9,7 +9,7 @@ Point(2) = {1,0,0};
 Point(3) = {1,1,0};
 Point(4) = {0,1,0};
 Point(5) = {0.5,0.5,1};
-Line(1) = {2,1}; // FIXME set {1,2} and the orientation will be screwed
+Line(1) = {1,2};
 Line(2) = {3,2};
 Line(3) = {4,3};
 Line(4) = {1,4};
-- 
GitLab