Salome HOME
Groups for obstacles implemented (Feature #242).
[modules/hydro.git] / src / HYDROData / HYDROData_Obstacle.cxx
index b83e7cb8af3c9ed39658e0462e520e10b30c4e2f..76480bd1bd93b2e29a16e885173a7de8abd202cd 100644 (file)
@@ -2,27 +2,40 @@
 #include "HYDROData_Obstacle.h"
 
 #include "HYDROData_Document.h"
+#include "HYDROData_EdgesGroup.h"
 
 #include <Basics_Utils.hxx>
 
 #include <BRepTools.hxx>
 #include <BRep_Builder.hxx>
+
 #include <IGESControl_Reader.hxx>
 #include <IGESData_IGESModel.hxx>
+
 #include <STEPControl_Reader.hxx>
+
 #include <Interface_Static.hxx>
+
+#include <TopoDS.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+
 #include <TDataStd_AsciiString.hxx>
+
 #include <TColStd_SequenceOfAsciiString.hxx>
+
 #include <TopExp_Explorer.hxx>
 
+#include <QColor>
 #include <QFile>
 #include <QFileInfo>
 #include <QStringList>
 
 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic
 
+#include <HYDROData_Projection.h>
+
 #define PYTHON_OBSTACLE_ID "KIND_OBSTACLE"
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Obstacle,HYDROData_ArtificialObject)
@@ -60,18 +73,41 @@ QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObj
   return aResList;
 }
 
+void HYDROData_Obstacle::Update()
+{
+  HYDROData_Entity::Update();
+
+  removeGroupObjects();
+  createGroupObjects();
+}
+
 TopoDS_Shape HYDROData_Obstacle::GetTopShape() const
 {
-  // TODO
   return getTopShape();
 }
 
 TopoDS_Shape HYDROData_Obstacle::GetShape3D() const
 {
-  // TODO
   return getShape3D();
 }
 
+void HYDROData_Obstacle::SetShape3D( const TopoDS_Shape& theShape )
+{
+  TopoDS_Face aShape2d = HYDROData_Projection::MakeProjection( theShape );
+  HYDROData_ArtificialObject::SetShape3D( theShape );
+  HYDROData_ArtificialObject::SetTopShape( aShape2d );
+}
+
+QColor HYDROData_Obstacle::DefaultFillingColor()
+{
+  return QColor( Qt::yellow );
+}
+
+QColor HYDROData_Obstacle::DefaultBorderColor()
+{
+  return QColor( Qt::transparent );
+}
+
 bool HYDROData_Obstacle::ImportFromFile( const QString& theFilePath )
 {
   // Check the file existence
@@ -301,3 +337,46 @@ TopoDS_Shape HYDROData_Obstacle::ImportSTEP( const QString& theFilePath ) const
 
   return aResShape;
 }
+
+QColor HYDROData_Obstacle::getDefaultFillingColor() const
+{
+  return DefaultFillingColor();
+}
+
+QColor HYDROData_Obstacle::getDefaultBorderColor() const
+{
+  return DefaultBorderColor();
+}
+
+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 );
+    }
+
+    if ( !aWireEdges.IsEmpty() )
+    {
+      QString aWireGroupName = GetName() + "_External_Wire";
+
+      Handle(HYDROData_EdgesGroup) anExtWireGroup = createGroupObject();
+      anExtWireGroup->SetName( aWireGroupName );
+     
+      anExtWireGroup->SetEdges( aWireEdges );
+    }
+  }
+}
+
+
+
+