From: isn Date: Mon, 16 Nov 2015 14:26:26 +0000 (+0300) Subject: possible improvement // speed up import process (SHP to LCM) X-Git-Tag: v1.5~37^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b46bc30957c5dd97a762acc3e08355deb8ea7e8c;p=modules%2Fhydro.git possible improvement // speed up import process (SHP to LCM) --- diff --git a/src/HYDROData/HYDROData_ShapeFile.cxx b/src/HYDROData/HYDROData_ShapeFile.cxx index c968e72c..9f2608fc 100644 --- a/src/HYDROData/HYDROData_ShapeFile.cxx +++ b/src/HYDROData/HYDROData_ShapeFile.cxx @@ -49,11 +49,19 @@ #include #include #include +#include +#include +#include +#include +#include #ifdef WIN32 #pragma warning( disable: 4996 ) #endif +//SHP->TFaces (Import) +#define OSD_TIMER + HYDROData_ShapeFile::HYDROData_ShapeFile() : myHSHP(NULL) { } @@ -342,8 +350,6 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F int nParts = anObj->nParts; gp_Pln pln(gp_Pnt(0,0,0), gp_Dir(0,0,1)); - //Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; - //sfs->FixFaceTool()->FixOrientationMode() = 1; TopTools_SequenceOfShape aWires; for ( int i = 0 ; i < nParts ; i++ ) { @@ -355,14 +361,22 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F else EndIndex = anObj->nVertices; - for ( int k = StartIndex; k < EndIndex - 1 ; k++ ) + NCollection_List aVertices; + gp_Pnt FP (anObj->padfX[StartIndex], anObj->padfY[StartIndex], 0); + TopoDS_Vertex V = BRepLib_MakeVertex(FP).Vertex(); + aVertices.Append(V); + + for ( int k = StartIndex + 1; k < EndIndex; k++ ) { - gp_Pnt P1 (anObj->padfX[k], anObj->padfY[k], 0); - gp_Pnt P2 (anObj->padfX[k+1], anObj->padfY[k+1], 0); + gp_Pnt P1 (anObj->padfX[k - 1], anObj->padfY[k-1], 0); //prev point + gp_Pnt P2 (anObj->padfX[k], anObj->padfY[k], 0); //current point if (P1.Distance(P2) < Precision::Confusion()) continue; - BRepBuilderAPI_MakeEdge aMakeEdge(P1, P2); - aBuilder.Add(TopoDS::Edge(aMakeEdge.Shape())); + TopoDS_Vertex V = BRepLib_MakeVertex(P2).Vertex(); + Handle_Geom_TrimmedCurve aTC = GC_MakeSegment(P1,P2).Value(); + TopoDS_Edge E = BRepLib_MakeEdge(aTC, aVertices.Last(), V).Edge(); + aVertices.Append(V); + aBuilder.Add(E); } aBuilder.Build(); @@ -384,7 +398,6 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F aFBuilder.Add(TopoDS::Wire(aWires(i))); F = TopoDS::Face(aFBuilder.Shape()); - BRepLib::BuildCurves3d(F); } int HYDROData_ShapeFile::ImportPolygons(const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces, int& theShapeTypeOfFile) @@ -402,11 +415,19 @@ int HYDROData_ShapeFile::ImportPolygons(const QString theFileName, QStringList& TopoDS_Face aF; if (myHSHP->nShapeType == 5) { +#ifdef OSD_TIMER + OSD_Timer timer; + timer.Start(); +#endif for (size_t i = 0; i < mySHPObjects.size(); i++) { ReadSHPPolygon(mySHPObjects[i], i, aF); theFaces.Append(aF); } +#ifdef OSD_TIMER + timer.Stop(); + timer.Show(); +#endif return 1; } else