QString aDbfFileName = thePyScriptPath;
aDbfFileName.replace( ".py", ".dbf" );
- ExportSHP( aShpFileName );
+ ExportSHP( aShpFileName, true, 1 );
QString anAttr = "CODE_06"; //TODO: some custom choice
QStringList anAttrValues, aTypes;
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
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,
}
}
-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())
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()));
}
}
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()));
+ }
}
}
}
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