X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_LandCoverMap.cxx;h=4b816d8db04ae6591be44cf590584287e59350b3;hb=39b1848f103d89cfb544a1651b3fbf221fc2c401;hp=9f8986e2f04e33dd59d8fc2e8d67ab3981c027cf;hpb=357d12c8701339e897cb70b3711671e8c31daf19;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index 9f8986e2..4b816d8d 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -61,7 +61,9 @@ #include #include #include +#include +#include #include #include @@ -902,6 +904,7 @@ bool HYDROData_LandCoverMap::LocalPartition( const TopoDS_Shape& theNewShape, co // c. add the new shape if it is face with its type if( theNewShape.ShapeType()==TopAbs_FACE ) aNewFaces.Add( TopoDS::Face( theNewShape ), theNewType ); + //DEBTRACE(theNewShape << " " << theNewType); // convert map of shape to type to compound and list of types StoreLandCovers( aNewFaces ); @@ -932,6 +935,7 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl } TopTools_IndexedDataMapOfShapeListOfShape ShHistory; + ShHistory.Clear(); TopoDS_Shape aResult; if( aListOfFaces.Extent() == 1 ) @@ -959,9 +963,21 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl //DEBTRACE(" --- " << aFF); if( aFF.IsNull() ) continue; - TopTools_ListOfShape aLS = ShHistory.FindFromKey(aFF); + //DEBTRACE(ShHistory.IsEmpty()); + //DEBTRACE(aFF.Checked()); + TopTools_ListOfShape aLS; + try + { + aLS = ShHistory.FindFromKey(aFF); //TODO: bug to fix. Observed on an incomplete split of a face + } + catch (...) + { + DEBTRACE("TODO: bug to fix. Observed on an incomplete split of a face"); + //continue; // No, keep aLS empty and propagate the type of the original face + } if (aLS.IsEmpty()) { + //DEBTRACE("--- aLS.IsEmpty()"); QString aSType = theMap.FindFromKey(aFF); //DEBTRACE(" --- " << aSType.toStdString()); if (ShF2FHistory.Contains(aFF)) @@ -977,6 +993,7 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl } else { + //DEBTRACE("--- !aLS.IsEmpty()"); TopTools_ListIteratorOfListOfShape anIt(aLS); for (; anIt.More(); anIt.Next()) { @@ -986,13 +1003,13 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl //if (ShF2FHistory.Contains(aFF)) if (ShF2FHistory.Contains(aMF)) { - aChF2ST.Add(ShF2FHistory.FindFromKey(aMF), aSType); //DEBTRACE("ShF2FHistory.FindFromKey(aMF) " << ShF2FHistory.FindFromKey(aFF)); + aChF2ST.Add(ShF2FHistory.FindFromKey(aMF), aSType); } else { - aChF2ST.Add(aMF, aSType); //DEBTRACE("aMF " << aMF); + aChF2ST.Add(aMF, aSType); } } } @@ -1202,7 +1219,7 @@ bool HYDROData_LandCoverMap::ExportSHP( const QString& theSHPFileName, bool bUse { 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 @@ -1241,3 +1258,38 @@ void HYDROData_LandCoverMap::UpdateLocalCS( double theDx, double theDy ) TopoDS_Shape aLocatedShape = HYDROData_ShapesTool::Translated( aShape, theDx, theDy, 0 ); SetShape( aLocatedShape ); } + +void HYDROData_LandCoverMap::ClassifyPoints( const std::vector& thePoints, std::vector >& theTypes ) const +{ + HYDROData_LCM_FaceClassifier FC(this); + FC.Classify(thePoints, theTypes, NULL); +} + +void HYDROData_LandCoverMap::ClassifyPoints( const std::vector& thePoints, + Handle(HYDROData_StricklerTable) theTable, + std::vector& theCoeffs, double DefValue, bool UseMax ) const +{ + std::vector > 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& SStr = Types[i]; + if (SStr.empty()) + theCoeffs[i] = DefValue; + else + { + std::set::const_iterator it; + std::vector 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(std::begin(C1), std::end(C1))); + else + Val = *(std::min_element(std::begin(C1), std::end(C1))); + theCoeffs[i] = Val; + } + } +}