From: isn Date: Mon, 29 Jun 2015 15:30:35 +0000 (+0300) Subject: Import of landcover -- use fclass2d to determine outer wires and holes X-Git-Tag: v1.4.2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f6d1a1f450e62a671df6ae134432b361a0b141d;p=modules%2Fhydro.git Import of landcover -- use fclass2d to determine outer wires and holes --- diff --git a/src/HYDROData/HYDROData_ShapeFile.cxx b/src/HYDROData/HYDROData_ShapeFile.cxx index 70e657ba..395f9182 100644 --- a/src/HYDROData/HYDROData_ShapeFile.cxx +++ b/src/HYDROData/HYDROData_ShapeFile.cxx @@ -50,7 +50,7 @@ #include #include #include - +#include 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 );