Salome HOME
Merge branch 'BR_v14_rc' of ssh://git.salome-platform.org/modules/hydro into BR_v14_rc
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportLandcoverOp.cxx
index bad1844c170260e63ed3e3c37050776c59ead81e..5151349cb6d608d0cdc1fbd428b8f9154069add2 100644 (file)
@@ -84,6 +84,23 @@ HYDROGUI_ImportLandCoverOp::~HYDROGUI_ImportLandCoverOp()
 void HYDROGUI_ImportLandCoverOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
+
+  if ( !getPreviewManager() ) {
+    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( 
+                       module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
+  }
+
+  if ( !isApplyAndClose() ) {
+    return;
+  }
+
+  HYDROGUI_ImportLandCoverDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
+  if ( !aPanel ) {
+    return;
+  }
+
+  aPanel->reset();
 }
 
 
@@ -207,6 +224,8 @@ void HYDROGUI_ImportLandCoverOp::ProcessSHP(SHPObject* anObj, int i, TopoDS_Face
     {
       gp_Pnt P1 (anObj->padfX[k], anObj->padfY[k], 0);
       gp_Pnt P2 (anObj->padfX[k+1], anObj->padfY[k+1], 0);
+      if (P1.Distance(P2) < Precision::Confusion())
+        continue;
       BRepBuilderAPI_MakeEdge aMakeEdge(P1, P2);
       aBuilder.Add(TopoDS::Edge(aMakeEdge.Shape()));
     }
@@ -219,7 +238,8 @@ void HYDROGUI_ImportLandCoverOp::ProcessSHP(SHPObject* anObj, int i, TopoDS_Face
 
   aFBuilder.Build();
   TopoDS_Face DF = aFBuilder.Face();
-  BRepLib::BuildCurves3d(DF);
+  BRepLib::BuildCurves3d(DF);  
+  bool IsInf = DF.Infinite();
   if(!DF.IsNull()) 
   {
     //sfs->Init ( DF );
@@ -260,8 +280,8 @@ void HYDROGUI_ImportLandCoverOp::onFileSelected()
     
     startDocOperation();
     QStringList aPolygonsList;
-    for (int i = 1; i < mySHPObjects.size(); i++)
-      aPolygonsList.append("polygon_" + QString::number(i));
+    for (int i = 0; i < mySHPObjects.size(); i++)
+      aPolygonsList.append("polygon_" + QString::number(i + 1));
     aPanel->setPolygonNames(aPolygonsList);
 
     SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );