From 49432c5821edd68ab63d49980649f9d91873b922 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 3 Oct 2015 14:39:36 +0000
Subject: [PATCH] patch for embedded edges in OCC surfaces

---
 Geo/GModelIO_OCC.cpp |  2 +-
 Geo/OCCFace.cpp      |  2 +-
 Geo/OCCRegion.cpp    | 12 +++++++++---
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp
index 77c07b6bb3..d7b499185f 100644
--- a/Geo/GModelIO_OCC.cpp
+++ b/Geo/GModelIO_OCC.cpp
@@ -108,7 +108,7 @@ void OCC_Internals::addShapeToLists(TopoDS_Shape _shape)
             if(fmap.FindIndex(face) < 1){
               fmap.Add(face);
 
-              for(exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()){
+              for(exp3.Init(exp2.Current().Oriented(TopAbs_FORWARD), TopAbs_WIRE); exp3.More(); exp3.Next()){
                 TopoDS_Wire wire = TopoDS::Wire(exp3.Current());
                 if(wmap.FindIndex(wire) < 1){
                   wmap.Add(wire);
diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp
index 471c1b166d..69bf0b272d 100644
--- a/Geo/OCCFace.cpp
+++ b/Geo/OCCFace.cpp
@@ -42,7 +42,7 @@
 #endif
 
 OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num)
-  : GFace(m, num), s(_s)
+  : GFace(m, num), s(TopoDS::Face(_s.Oriented(TopAbs_FORWARD)))
 {
   setup();
   model()->getOCCInternals()->bind(s, num);
diff --git a/Geo/OCCRegion.cpp b/Geo/OCCRegion.cpp
index 44644cd995..34a20d124a 100644
--- a/Geo/OCCRegion.cpp
+++ b/Geo/OCCRegion.cpp
@@ -36,14 +36,20 @@ void OCCRegion::setup()
     for(exp3.Init(shell, TopAbs_FACE); exp3.More(); exp3.Next()){
       TopoDS_Face face = TopoDS::Face(exp3.Current());
       GFace *f = model()->getOCCInternals()->getOCCFaceByNativePtr(model(),face);
-      if(f){
+      if(!f){
+        Msg::Error("Unknown face in region %d", tag());
+      }
+      else if (face.Orientation() == TopAbs_INTERNAL){
+        Msg::Info("Adding embedded face %d", f->tag());
+        embedded_faces.push_back(f);
+      }
+      else{
         l_faces.push_back(f);
         f->addRegion(this);
       }
-      else
-        Msg::Error("Unknown face in region %d", tag());
     }
   }
+
   Msg::Debug("OCC Region %d with %d faces", tag(), l_faces.size());
 }
 
-- 
GitLab