]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Import of landcover -- use fclass2d to determine outer wires and holes
authorisn <isn@opencascade.com>
Mon, 29 Jun 2015 15:30:35 +0000 (18:30 +0300)
committerisn <isn@opencascade.com>
Mon, 29 Jun 2015 16:08:17 +0000 (19:08 +0300)
src/HYDROData/HYDROData_ShapeFile.cxx

index 70e657ba7e77c642431242945e9a7db096fbd300..395f9182a70dda852a612ffaecf5d69f3dcd7af4 100644 (file)
@@ -50,7 +50,7 @@
 #include <ShapeFix_Shape.hxx>
 #include <TopTools_SequenceOfShape.hxx>
 #include <QColor>
-
+#include <BRepTopAdaptor_FClass2d.hxx>
 
 HYDROData_ShapeFile::HYDROData_ShapeFile() : myHSHP(NULL)
 { 
@@ -289,11 +289,10 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F
   TopoDS_Edge E; 
   int nParts = anObj->nParts;
   gp_Pln pln(gp_Pnt(0,0,0), gp_Dir(0,0,1));
-  BRepBuilderAPI_MakeFace aFBuilder(pln);
 
   //Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
   //sfs->FixFaceTool()->FixOrientationMode() = 1;
-  
+  TopTools_SequenceOfShape aWires;
   for ( int i = 0 ; i < nParts ; i++ )
   { 
     BRepBuilderAPI_MakeWire aBuilder;
@@ -316,14 +315,24 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F
     
     aBuilder.Build();
     W = TopoDS::Wire(aBuilder.Shape());
-    W.Reverse();
-    aFBuilder.Add(W);
+    W.Orientation(TopAbs_FORWARD);
+    BRepBuilderAPI_MakeFace aDB(pln, W);
+    TopoDS_Face aDummyFace = TopoDS::Face(aDB.Shape());
+    BRepTopAdaptor_FClass2d FClass(aDummyFace, Precision::PConfusion());
+    if ( i == 0 && FClass.PerformInfinitePoint() == TopAbs_OUT) 
+      W.Reverse();
+    if ( i > 0 && FClass.PerformInfinitePoint() != TopAbs_IN) 
+      W.Reverse();
+   
+    aWires.Append(W);
   }
+  
+  BRepBuilderAPI_MakeFace aFBuilder(pln, TopoDS::Wire(aWires(1)));
+  for (int i = 2; i <= aWires.Length(); i++)
+    aFBuilder.Add(TopoDS::Wire(aWires(i)));
+  TopoDS_Face DF = TopoDS::Face(aFBuilder.Shape());
 
-  aFBuilder.Build();
-  TopoDS_Face DF = aFBuilder.Face();
   BRepLib::BuildCurves3d(DF);  
-  bool IsInf = DF.Infinite();
   if(!DF.IsNull()) 
   {
     //sfs->Init ( DF );