]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
possible improvement // speed up import process (SHP to LCM)
authorisn <isn@opencascade.com>
Mon, 16 Nov 2015 14:26:26 +0000 (17:26 +0300)
committerisn <isn@opencascade.com>
Mon, 16 Nov 2015 14:37:36 +0000 (17:37 +0300)
src/HYDROData/HYDROData_ShapeFile.cxx

index c968e72c42eb46608d0ef826defc91aeab2cb661..9f2608fc3da51a94a2c7b59452a610ef1678679f 100644 (file)
 #include <QColor>
 #include <BRepTopAdaptor_FClass2d.hxx>
 #include <TopExp.hxx>
+#include <OSD_Timer.hxx>
+#include <BRepLib_MakeVertex.hxx>
+#include <NCollection_List.hxx>
+#include <GC_MakeSegment.hxx>
+#include <BRep_Builder.hxx>
 
 #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<TopoDS_Vertex> 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