Salome HOME
Porting on OCCT 7.0 and Qt 5. Make compilable version.
[modules/hydro.git] / src / HYDROData / HYDROData_LandCoverMap.cxx
index 9f8986e2f04e33dd59d8fc2e8d67ab3981c027cf..fe76bd40afe3f04cca64422d76ab8a5ca070dc0a 100644 (file)
 #include <BRepCheck_Shell.hxx>
 #include <BRepCheck_ListOfStatus.hxx>
 #include <TopTools_SequenceOfShape.hxx>
-#include <Handle_Geom_Curve.hxx>
-#include <Handle_Geom_Line.hxx>
-#include <Handle_Geom_TrimmedCurve.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_TrimmedCurve.hxx>
 #include <Geom_TrimmedCurve.hxx>
 #include <TopTools_DataMapOfShapeListOfShape.hxx>
 #include <NCollection_DoubleMap.hxx>
 
+#include <stdexcept>
 
 #include <QFile>
 #include <QString>
@@ -75,7 +76,6 @@ const char TELEMAC_FORMAT = 'f';
 const int TELEMAC_PRECISION = 3;
 
 
-IMPLEMENT_STANDARD_HANDLE(HYDROData_LandCoverMap, HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_LandCoverMap, HYDROData_Entity)
 
 /**
@@ -902,6 +902,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 +933,7 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl
   }
 
   TopTools_IndexedDataMapOfShapeListOfShape ShHistory;
+  ShHistory.Clear();
 
   TopoDS_Shape aResult;
   if( aListOfFaces.Extent() == 1 )
@@ -959,9 +961,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 +991,7 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl
     }
     else
     {
+      //DEBTRACE("--- !aLS.IsEmpty()");
       TopTools_ListIteratorOfListOfShape anIt(aLS);
       for (; anIt.More(); anIt.Next())
       {
@@ -986,13 +1001,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);
           }
       }
     }
@@ -1114,7 +1129,7 @@ void HYDROData_LandCoverMap::RemoveInternal(TopoDS_Shape& ShToRebuild, NCollecti
     //
     if (!anEdgesToRemove.IsEmpty())
     {
-      Handle_ShapeBuild_ReShape aReshape = new ShapeBuild_ReShape();
+      Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape();
       TopoDS_Shape OutF = aReshape->Apply(CurFace);
       TopTools_ListIteratorOfListOfShape aIt(anEdgesToRemove);
       for (; aIt.More(); aIt.Next()) 
@@ -1129,7 +1144,7 @@ void HYDROData_LandCoverMap::RemoveInternal(TopoDS_Shape& ShToRebuild, NCollecti
     }
   }
   //
-  Handle_ShapeBuild_ReShape anExtReshape = new ShapeBuild_ReShape();
+  Handle(ShapeBuild_ReShape) anExtReshape = new ShapeBuild_ReShape();
   for (int i = 1; i <= aF2FReplace->Extent(); i++)
   {
     TopoDS_Face aFK = aF2FReplace->FindKey(i);
@@ -1202,7 +1217,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 
@@ -1217,7 +1232,7 @@ bool HYDROData_LandCoverMap::CheckLinear()
   {
     TopoDS_Edge E = TopoDS::Edge(anEdgeEx.Current());
     double aFP, aLP;
-    Handle_Geom_Curve aCur = BRep_Tool::Curve(E, aFP, aLP);
+    Handle(Geom_Curve) aCur = BRep_Tool::Curve(E, aFP, aLP);
     Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(aCur);
     if (aLine.IsNull())
     {