-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
+// Copyright (C) 2014-2015 EDF-R&D
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
#include <HYDROData_Polyline3D.h>
#include <HYDROGUI_DataObject.h>
#include <HYDROData_Bathymetry.h>
+#include <HYDROData_LandCoverMap.h>
#include <HYDROData_Profile.h>
#include <QFile>
#include <QFileInfo>
#include <SUIT_MessageBox.h>
-
+#include <TopoDS.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <BRep_Tool.hxx>
+#include <Precision.hxx>
+#include <Handle_Geom_Curve.hxx>
+#include <Handle_Geom_Line.hxx>
+#include <Handle_Geom_TrimmedCurve.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <HYDROData_ShapeFile.h>
HYDROGUI_ExportFileOp::HYDROGUI_ExportFileOp( HYDROGUI_Module* theModule )
: HYDROGUI_Operation( theModule )
{
- setName( tr( "EXPORT_POLYLINE" ) );
+ setName( tr( "EXPORT_TO_SHAPE_FILE" ) );
}
HYDROGUI_ExportFileOp::~HYDROGUI_ExportFileOp()
{
HYDROGUI_Operation::startOperation();
- QString aFilter( "*.shp" ); //temp ext-n; replace with filter; TODO
+ QString aFilter( tr("SHP_FILTER") );
Handle(HYDROData_PolylineXY) aPolyXY;
Handle(HYDROData_Polyline3D) aPoly3D;
NCollection_Sequence<Handle_HYDROData_PolylineXY> aPolyXYSeq;
NCollection_Sequence<Handle_HYDROData_Polyline3D> aPoly3DSeq;
-
+ // TODO
+ Handle_HYDROData_LandCoverMap aLCSeq;
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
}
if (!aPolyXYSeq.IsEmpty() && !aPoly3DSeq.IsEmpty())
- SUIT_MessageBox::warning( module()->getApp()->desktop(), "Export Polyline", "Cannot export polylines of different kind");
+ SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "EXPORT_TO_SHAPE_FILE" ), tr("ERROR_POLYLINES_OF_DIFF_KIND"));
else
{
- QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), "", aFilter, tr( "EXPORT_POLYLINE" ), false );
+ QString aName = "";
+ if (aPolyXYSeq.Size() == 1 && aPoly3DSeq.IsEmpty())
+ aName = aPolyXYSeq(1)->GetName();
+ if (aPoly3DSeq.Size() == 1 && aPolyXYSeq.IsEmpty())
+ aName = aPoly3DSeq(1)->GetName();
+ QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), aName, aFilter, tr( "EXPORT_TO_SHAPE_FILE" ), false );
if (!aFileName.isEmpty())
{
- SHPHandle hSHPHandle;
- if (!aPolyXYSeq.IsEmpty() && aPoly3DSeq.IsEmpty())
+ QStringList aNonExpList;
+ HYDROData_ShapeFile anExporter;
+ // TODO
+ anExporter.Export(aFileName, aPolyXYSeq, aPoly3DSeq, aLCSeq, aNonExpList);
+ if (!aNonExpList.empty())
{
- hSHPHandle = SHPCreate( aFileName.toAscii().data(), SHPT_ARC );
- for (int i = 1; i <= aPolyXYSeq.Size(); i++)
- WriteObjectPolyXY(hSHPHandle, aPolyXYSeq(i));
+ QString aMessage = tr("CANNOT_BE_EXPORTED") + "\n";
+ foreach (QString anNonExpEntName, aNonExpList)
+ aMessage += anNonExpEntName + "\n";
+ SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "EXPORT_TO_SHAPE_FILE" ), aMessage);
}
- else if (aPolyXYSeq.IsEmpty() && !aPoly3DSeq.IsEmpty())
- {
- hSHPHandle = SHPCreate( aFileName.toAscii().data(), SHPT_ARCZ );
- for (int i = 1; i <= aPoly3DSeq.Size(); i++)
- WriteObjectPoly3D(hSHPHandle, aPoly3DSeq(i));
- }
- SHPClose( hSHPHandle );
commit();
}
else
}
-void HYDROGUI_ExportFileOp::WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly )
-{
- SHPObject *aSHPObj;
- std::vector<double> x, y;
- std::vector<int> anPartStart;
-
- for (int i = 0; i < thePoly->NbSections(); i++)
- {
- anPartStart.push_back(x.size());
- HYDROData_PolylineXY::PointsList aPointList = thePoly->GetPoints(i);
- for (int j = 1; j <= aPointList.Size(); j++)
- {
- x.push_back( aPointList(j).X());
- y.push_back( aPointList(j).Y());
- }
- if (thePoly->IsClosedSection(i))
- {
- x.push_back( aPointList(1).X());
- y.push_back( aPointList(1).Y());
- }
- }
-
- aSHPObj = SHPCreateObject( SHPT_ARC, -1, thePoly->NbSections(), &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL );
- SHPWriteObject( theShpHandle, -1, aSHPObj );
- SHPDestroyObject( aSHPObj );
-}
-
-void HYDROGUI_ExportFileOp::WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly )
-{
- SHPObject *aSHPObj;
- std::vector<double> x, y, z;
- std::vector<int> anPartStart;
-
- for (int i = 0; i < thePoly->GetPolylineXY()->NbSections(); i++)
- {
- anPartStart.push_back(x.size());
- HYDROData_PolylineXY::PointsList aPointList = thePoly->GetPolylineXY()->GetPoints(i);
- for (int j = 1; j <= aPointList.Size(); j++)
- {
- x.push_back( aPointList(j).X());
- y.push_back( aPointList(j).Y());
- z.push_back(thePoly->GetAltitudeObject()->GetAltitudeForPoint(gp_XY (aPointList(j).X(), aPointList(j).Y())));
- }
- if ( thePoly->GetPolylineXY()->IsClosedSection(i))
- {
- x.push_back( aPointList(1).X());
- y.push_back( aPointList(1).Y());
- z.push_back(thePoly->GetAltitudeObject()->GetAltitudeForPoint(gp_XY (aPointList(1).X(), aPointList(1).Y())));
-
- }
- }
-
- aSHPObj = SHPCreateObject( SHPT_ARCZ, -1, thePoly->GetPolylineXY()->NbSections(), &anPartStart[0], NULL, x.size(), &x[0], &y[0], &z[0], NULL );
- SHPWriteObject( theShpHandle, -1, aSHPObj );
- SHPDestroyObject( aSHPObj );
-}
-
-
-