Salome HOME
Common part of dump to python is moved to HYDROData_Entity.
[modules/hydro.git] / src / HYDROData / HYDROData_Obstacle.cxx
index 76480bd1bd93b2e29a16e885173a7de8abd202cd..370b80c7deafbc2b55ff3e69fbf417382663208b 100644 (file)
@@ -2,7 +2,8 @@
 #include "HYDROData_Obstacle.h"
 
 #include "HYDROData_Document.h"
-#include "HYDROData_EdgesGroup.h"
+#include "HYDROData_ShapesGroup.h"
+#include "HYDROData_ShapesTool.h"
 
 #include <Basics_Utils.hxx>
 
@@ -36,8 +37,6 @@
 
 #include <HYDROData_Projection.h>
 
-#define PYTHON_OBSTACLE_ID "KIND_OBSTACLE"
-
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Obstacle,HYDROData_ArtificialObject)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Obstacle,HYDROData_ArtificialObject)
 
@@ -53,20 +52,7 @@ HYDROData_Obstacle::~HYDROData_Obstacle()
 
 QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
 {
-  QStringList aResList;
-
-  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
-  if ( aDocument.IsNull() )
-    return aResList;
-
-  QString aDocName = aDocument->GetDocPyName();
-  QString anObstacleName = GetName();
-
-  aResList << QString( "%1 = %2.CreateObject( %3 );" )
-              .arg( anObstacleName ).arg( aDocName ).arg( PYTHON_OBSTACLE_ID );
-  aResList << QString( "%1.SetName( \"%2\" );" )
-              .arg( anObstacleName ).arg( anObstacleName );
-  aResList << QString( "" );
+  QStringList aResList = HYDROData_Entity::DumpToPython( theTreatedObjects );
 
   // TODO
 
@@ -75,10 +61,11 @@ QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObj
 
 void HYDROData_Obstacle::Update()
 {
-  HYDROData_Entity::Update();
-
   removeGroupObjects();
   createGroupObjects();
+  checkAndSetAltitudeObject();
+
+  HYDROData_Entity::Update();
 }
 
 TopoDS_Shape HYDROData_Obstacle::GetTopShape() const
@@ -353,30 +340,24 @@ void HYDROData_Obstacle::createGroupObjects()
   TopoDS_Shape anObstacleShape = GetTopShape();
   if ( !anObstacleShape.IsNull() )
   {
-    HYDROData_SequenceOfEdges aWireEdges;
-
-    TopExp_Explorer anExp( anObstacleShape, TopAbs_EDGE );
-    for ( ; anExp.More(); anExp.Next() )
-    {
-      TopoDS_Edge anEdge = TopoDS::Edge( anExp.Current() );
-      if ( anEdge.IsNull() )
-        continue;
-
-      aWireEdges.Append( anEdge );
-    }
-
+    TopTools_SequenceOfShape aWireEdges;
+    HYDROData_ShapesTool::ExploreShapeToShapes( anObstacleShape, TopAbs_EDGE, aWireEdges );
     if ( !aWireEdges.IsEmpty() )
     {
-      QString aWireGroupName = GetName() + "_External_Wire";
+      QString aWireGroupName = GetName() + "_Outer_Wire";
 
-      Handle(HYDROData_EdgesGroup) anExtWireGroup = createGroupObject();
+      Handle(HYDROData_ShapesGroup) anExtWireGroup = createGroupObject();
       anExtWireGroup->SetName( aWireGroupName );
      
-      anExtWireGroup->SetEdges( aWireEdges );
+      anExtWireGroup->SetShapes( aWireEdges );
     }
   }
 }
 
+ObjectKind HYDROData_Obstacle::getAltitudeObjectType() const
+{
+  return KIND_OBSTACLE_ALTITUDE;
+}