Salome HOME
refs #745
authorisn <isn@opencascade.com>
Thu, 26 Nov 2015 11:54:21 +0000 (14:54 +0300)
committerisn <isn@opencascade.com>
Thu, 26 Nov 2015 11:54:21 +0000 (14:54 +0300)
src/HYDROData/HYDROData_ShapeFile.cxx
src/HYDRO_tests/reference_data/LandCoverMap_Merge_2.png

index 51ca1b02c5ab08692fce0b120709fed0eb170a96..5f48cb2adfbb4e921ddbf7ed649143c0ebf715e5 100644 (file)
@@ -376,6 +376,8 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F
   BRep_Builder BB;
   BB.MakeFace(F);
 
+  NCollection_Sequence<NCollection_Sequence<TopoDS_Edge> > allEdges;
+
   TopTools_SequenceOfShape aWires;
   for ( int i = 0 ; i < nParts ; i++ )
   { 
@@ -386,9 +388,8 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F
       EndIndex = anObj->panPartStart[i + 1];
     else
       EndIndex = anObj->nVertices;
-    
-    TopoDS_Wire W;
-    BB.MakeWire(W);
+
+    NCollection_Sequence<TopoDS_Edge> EPerW;
 
     //First point is same as the last point 
     int NbPnts = EndIndex - StartIndex - 1;
@@ -416,11 +417,32 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F
         E = BRepLib_MakeEdge(aTC, VPoints.First(), VPoints.Value(VPoints.Upper() - 1)).Edge();
       //Add edge to wire
       //If SHP file is correct then the outer wire and the holes will have the correct orientations
-      BB.Add(W, E);
+      
+      EPerW.Append(E);
     }
-    //Wire must be closed anyway
-    W.Closed (BRep_Tool::IsClosed (W));
+    allEdges.Append(EPerW);
+  }
+
+  for (int i = 1; i <= allEdges.Size(); i++)
+  {
+    TopoDS_Wire W;
+    BB.MakeWire(W);
+    for (int j = 1; j <= allEdges(i).Size(); j++)
+      BB.Add(W, allEdges(i)(j));
+    W.Closed (Standard_True);
     W.Orientation(TopAbs_FORWARD);
+    //check on the dummy face first
+    TopoDS_Face DF;
+    BB.MakeFace(DF);
+    BB.Add(DF, W);
+    BB.UpdateFace(DF, aPlaneSur, TopLoc_Location(), Precision::Confusion());
+    //
+    BRepTopAdaptor_FClass2d FClass(DF, Precision::PConfusion());
+    if ( i == 1 && FClass.PerformInfinitePoint() != TopAbs_OUT) 
+      W.Reverse();
+    if ( i > 1 && FClass.PerformInfinitePoint() != TopAbs_IN) 
+      W.Reverse();
+    //
     BB.Add(F, W);
   }
   
index e4ff0803fc0b794bfba5c86aec62ba5e720c4301..4f6daf9ad7e2fa1d77e732dc604d2a3f6ad46353 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/LandCoverMap_Merge_2.png and b/src/HYDRO_tests/reference_data/LandCoverMap_Merge_2.png differ