#include <Geom_TrimmedCurve.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <NCollection_DoubleMap.hxx>
+#include <HYDROData_LCM_FaceClassifier.h>
+#include <QDir>
#include <stdexcept>
*/
bool HYDROData_LandCoverMap::ExportTelemac( const QString& theFileName,
double theDeflection,
- const Handle(HYDROData_StricklerTable)& theTable ) const
+ const Handle(HYDROData_StricklerTable)& theTable,
+ QString& statMessage) const
{
TopoDS_Shape aLandCoverMapShape = GetShape();
TopTools_ListOfShape aListOfFaces;
QFile aFile( theFileName );
if( !aFile.open( QFile::WriteOnly | QFile::Text ) )
- return false;
+ {
+ QString homeFilePath = QDir::home().absoluteFilePath( theFileName );
+ aFile.setFileName(homeFilePath);
+ if (aFile.open( QFile::WriteOnly | QFile::Text ) )
+ statMessage = "Telemac file have been exported to the home directory: " + homeFilePath;
+ else
+ return false;
+ }
+ else
+ {
+ QString absFilePath = QDir::current().absoluteFilePath( theFileName );
+ statMessage = "Telemac file have been exported to the current directory: " + absFilePath;
+ }
QTextStream aStream( &aFile );
aStream << "# nodes\n";
catch (...)
{
DEBTRACE("TODO: bug to fix. Observed on an incomplete split of a face");
- continue;
+ //continue; // No, keep aLS empty and propagate the type of the original face
}
if (aLS.IsEmpty())
{
{
HYDROData_ShapeFile anExporter;
QStringList aList;
- anExporter.Export(theSHPFileName, this, aList, bUseDiscr, theDefl );
+ anExporter.Export(HYDROData_Document::Document(1), theSHPFileName, this, aList, bUseDiscr, theDefl );
if (aList.empty())
return true;
else
TopoDS_Shape aLocatedShape = HYDROData_ShapesTool::Translated( aShape, theDx, theDy, 0 );
SetShape( aLocatedShape );
}
+
+void HYDROData_LandCoverMap::ClassifyPoints( const std::vector<gp_XY>& thePoints, std::vector<std::set <QString> >& theTypes ) const
+{
+ HYDROData_LCM_FaceClassifier FC(this);
+ FC.Classify(thePoints, theTypes, NULL);
+}
+
+void HYDROData_LandCoverMap::ClassifyPoints( const std::vector<gp_XY>& thePoints,
+ Handle(HYDROData_StricklerTable) theTable,
+ std::vector<double>& theCoeffs, double DefValue, bool UseMax ) const
+{
+ std::vector<std::set <QString> > Types;
+ HYDROData_LCM_FaceClassifier FC(this);
+ FC.Classify(thePoints, Types, NULL);
+ theCoeffs.resize(thePoints.size());
+ for (size_t i = 0; i < Types.size(); i++)
+ {
+ const std::set<QString>& SStr = Types[i];
+ if (SStr.empty())
+ theCoeffs[i] = DefValue;
+ else
+ {
+ std::set<QString>::const_iterator it;
+ std::vector<double> C1(SStr.size());
+ for (it = SStr.begin(); it != SStr.end(); ++it)
+ C1.push_back(theTable->Get( *it, DefValue ));
+ double Val;
+ if (UseMax)
+ Val = *(std::max_element( C1.begin(), C1.end() ) );
+ else
+ Val = *(std::min_element( C1.begin(), C1.end() ) );
+ theCoeffs[i] = Val;
+ }
+ }
+}