]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Use discretization to write non-linear borders of LCM to SHP file // p.3
authorisn <isn@opencascade.com>
Tue, 17 Nov 2015 09:07:06 +0000 (12:07 +0300)
committerisn <isn@opencascade.com>
Tue, 17 Nov 2015 09:48:30 +0000 (12:48 +0300)
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDROData/HYDROData_ShapeFile.cxx
src/HYDROData/HYDROData_ShapeFile.h

index 951f77d398cabb6c7426dc71c598d5124e8d215e..1187916c6dbf3742c3dd1183261a87c6154a517d 100644 (file)
@@ -939,7 +939,7 @@ QStringList HYDROData_LandCoverMap::DumpToPython( const QString&       thePyScri
   QString aDbfFileName = thePyScriptPath;
   aDbfFileName.replace( ".py", ".dbf" );
 
-  ExportSHP( aShpFileName );
+  ExportSHP( aShpFileName, true, 1 );
 
   QString anAttr = "CODE_06"; //TODO: some custom choice
   QStringList anAttrValues, aTypes;
@@ -1048,11 +1048,11 @@ bool HYDROData_LandCoverMap::ImportSHP( const QString& theSHPFileName,
   return true;
 }
 
-bool HYDROData_LandCoverMap::ExportSHP( const QString& theSHPFileName) const
+bool HYDROData_LandCoverMap::ExportSHP( const QString& theSHPFileName, bool bUseDiscr, double theDefl) const
 {
   HYDROData_ShapeFile anExporter;
   QStringList aList;
-  anExporter.Export(theSHPFileName, this, aList);
+  anExporter.Export(theSHPFileName, this, aList, bUseDiscr, theDefl );
   if (aList.empty())
     return true;
   else 
index 656a482e6c4b7f9d3950e9b1b93c2f2c73b15576..c2437d8c7c978f37e05e5a6493c3ba1d9dbf5171 100644 (file)
@@ -93,7 +93,7 @@ public:
   HYDRODATA_EXPORT bool ImportSHP( const QString& theSHPFileName,
                                    const QList<int>& theIndices = QList<int>() );
  
-  HYDRODATA_EXPORT bool ExportSHP( const QString& theSHPFileName ) const;
+  HYDRODATA_EXPORT bool ExportSHP( const QString& theSHPFileName, bool bUseDiscr = false, double theDefl = 0.1) const;
 
   HYDRODATA_EXPORT DBFStatus ImportDBF( const QString& theDBFFileName, 
                                         const QString& theFieldName, 
index d3ade82aff87c49e9997abeb5836a8b572823dd1..8b0711f86ec36cc975e18a465e0e722f8c228616 100644 (file)
@@ -104,8 +104,8 @@ void HYDROData_ShapeFile::Export(const QString& aFileName,
   }
 }
 
-void HYDROData_ShapeFile::Export(const QString& aFileName,
-  const Handle_HYDROData_LandCoverMap& aLCM, QStringList& aNonExpList)
+void HYDROData_ShapeFile::Export(const QString& aFileName, const Handle_HYDROData_LandCoverMap& aLCM, 
+                                 QStringList& aNonExpList, bool bUseDiscr, double theDefl)
 {
   SHPHandle hSHPHandle;
   if ( !aLCM.IsNull() && !aLCM->IsEmpty())
@@ -115,7 +115,7 @@ void HYDROData_ShapeFile::Export(const QString& aFileName,
     for( ; It.More(); It.Next())
     {
       TopoDS_Face aFace = It.Face();
-      if (WriteObjectPolygon(hSHPHandle, aFace) != 1)
+      if (WriteObjectPolygon(hSHPHandle, aFace, bUseDiscr, theDefl) != 1)
         aNonExpList.append(aLCM->GetName() + "_" +  QString::number(It.Index()));
     }
   }
@@ -289,11 +289,29 @@ void HYDROData_ShapeFile::ProcessFace(const TopoDS_Face& theFace, SHPHandle theS
         BRepAdaptor_Curve Cur( E );
         GCPnts_QuasiUniformDeflection Discr( Cur, theDefl );
         if( !Discr.IsDone() )
-          continue; //skip all edge?
-        for( int i = 1; i <= Discr.NbPoints(); i++ )
+          continue; //skip edge?
+        double NewDefl = theDefl/2.0;
+        while (Discr.NbPoints() < 2)
         {
-          gp_Pnt P = Discr.Value( i );
-          aPnts.Append(gp_Pnt2d(P.X(), P.Y()));
+          Discr.Initialize(Cur, NewDefl);
+          NewDefl = NewDefl/2.0;
+        }
+        //
+        if (E.Orientation() == TopAbs_FORWARD)
+        {
+          for( int i = 1; i <= Discr.NbPoints(); i++ )
+          {
+            gp_Pnt P = Discr.Value( i );
+            aPnts.Append(gp_Pnt2d(P.X(), P.Y()));
+          }
+        }
+        else
+        {
+          for( int i = Discr.NbPoints(); i > 0; i-- )
+          {
+            gp_Pnt P = Discr.Value( i );
+            aPnts.Append(gp_Pnt2d(P.X(), P.Y()));
+          }
         }
       }
     }
index cf24d3b5248b785f6bc7ff86d2b6564afb4b6b87..95a8b1752fa32dc7aac108a6beadc5c1a491af29 100644 (file)
@@ -88,13 +88,15 @@ public:
 
   HYDRODATA_EXPORT void Export(const QString& aFileName,
                                const Handle_HYDROData_LandCoverMap& aLCM,
-                               QStringList& aNonExpList);
+                               QStringList& aNonExpList,
+                               bool bUseDiscr = false, 
+                               double theDefl = 0.1);
 
   int WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly );
 
   int WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly );
 
-  int WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape, bool bUseDiscr = false, double theDefl = 0.1 );
+  int WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape, bool bUseDiscr, double theDefl );
   //Import
   bool Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile);
   //Import Landcover