]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1813 ... lot 14 combined commit : parts : 1 - 16
authorisn <isn@opencascade.com>
Mon, 20 Aug 2018 16:41:58 +0000 (19:41 +0300)
committerisn <isn@opencascade.com>
Fri, 7 Sep 2018 11:43:15 +0000 (14:43 +0300)
Signed-off-by: isn <isn@opencascade.com>
44 files changed:
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData_BCPolygon.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_BCPolygon.h [new file with mode: 0644]
src/HYDROData/HYDROData_BoundaryPolygonTools.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_BoundaryPolygonTools.h [new file with mode: 0644]
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Entity.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_ImmersibleZone.cxx
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_ShapeFile.cxx
src/HYDROData/HYDROData_ShapeFile.h
src/HYDROData/HYDROData_Tool.cxx
src/HYDROData/HYDROData_Tool.h
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DataObject.cxx
src/HYDROGUI/HYDROGUI_ImportBCPolygonOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportBCPolygonOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx
src/HYDROGUI/HYDROGUI_ImportPolylineOp.h
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Tool2.cxx
src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx
src/HYDROGUI/resources/HYDROGUI_images.ts
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROGUI/resources/icon_bc_import.png [new file with mode: 0644]
src/HYDROGUI/resources/icon_bc_polygon_type_1.png [new file with mode: 0644]
src/HYDROGUI/resources/icon_bc_polygon_type_2.png [new file with mode: 0644]
src/HYDROGUI/resources/icon_bc_polygon_type_3.png [new file with mode: 0644]
src/HYDROGUI/resources/icon_bc_polygon_type_undef.png [new file with mode: 0644]

index d82add816944c54cbb8886d81869aaaa9cfc7970..94a55cc638b3b2f0b3a457ec468ea656f2363247 100644 (file)
@@ -64,6 +64,8 @@ set(PROJECT_HEADERS
     HYDROData_LandCoverMap.h
     HYDROData_LCM_FaceClassifier.h
     HYDROData_DTM.h   
+    HYDROData_BCPolygon.h
+    HYDROData_BoundaryPolygonTools.h 
 )
 
 set(PROJECT_SOURCES 
@@ -126,6 +128,8 @@ set(PROJECT_SOURCES
     HYDROData_LandCoverMap.cxx
     HYDROData_LCM_FaceClassifier.cxx
     HYDROData_DTM.cxx
+    HYDROData_BCPolygon.cxx
+    HYDROData_BoundaryPolygonTools.cxx
  )
 
 SET( ECW_INCLUDES $ENV{ECWLIB_ROOT_DIR}/include )
diff --git a/src/HYDROData/HYDROData_BCPolygon.cxx b/src/HYDROData/HYDROData_BCPolygon.cxx
new file mode 100644 (file)
index 0000000..9276a11
--- /dev/null
@@ -0,0 +1,168 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROData_BCPolygon.h"
+
+//#include "HYDROData_IAltitudeObject.h"
+#include "HYDROData_Document.h"
+//#include "HYDROData_ShapesGroup.h"
+#include "HYDROData_PolylineXY.h"
+#include "HYDROData_ShapesTool.h"
+
+#include <TopoDS.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+#include <TDataStd_Integer.hxx>
+
+#include <HYDROData_Tool.h>
+
+#include <QColor>
+#include <QStringList>
+
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_BCPolygon,HYDROData_Object)
+
+
+HYDROData_BCPolygon::HYDROData_BCPolygon()
+: HYDROData_Object( Geom_2d )
+{
+}
+
+HYDROData_BCPolygon::~HYDROData_BCPolygon()
+{
+}
+
+QStringList HYDROData_BCPolygon::DumpToPython( const QString& thePyScriptPath,
+                                               MapOfTreatedObjects& theTreatedObjects ) const
+{
+  QStringList aResList = dumpObjectCreation( theTreatedObjects );
+  
+  QString aBCName = GetObjPyName();
+
+  //Handle(HYDROData_IAltitudeObject) aRefAltitude = GetAltitudeObject();
+  //setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefAltitude, "SetAltitudeObject" );
+
+  Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline();
+  setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
+
+  aResList << QString( "" );
+
+  aResList << QString( "%1.Update()" ).arg( aBCName );
+  aResList << QString( "" );
+
+  return aResList;
+}
+
+HYDROData_SequenceOfObjects HYDROData_BCPolygon::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Object::GetAllReferenceObjects();
+
+  Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline();
+  if ( !aRefPolyline.IsNull() )
+    aResSeq.Append( aRefPolyline );
+
+  return aResSeq;
+}
+
+int HYDROData_BCPolygon::GetBoundaryType() const
+{
+  Handle(TDataStd_Integer) aBoundaryTypeAttr;
+
+  int aBoundaryTypeVal = 0; //default
+  if( myLab.FindAttribute(TDataStd_Integer::GetID(), aBoundaryTypeAttr ) )
+    aBoundaryTypeVal = aBoundaryTypeAttr->Get();
+  return aBoundaryTypeVal;
+}
+
+void HYDROData_BCPolygon::SetBoundaryType( int theBoundaryType ) const
+{
+  TDataStd_Integer::Set( myLab, theBoundaryType );
+}
+
+void HYDROData_BCPolygon::Update()
+{
+  HYDROData_Object::Update();
+  SetTopShape( generateTopShape() );
+}
+
+void HYDROData_BCPolygon::Update(const TopoDS_Shape& theTopShape)
+{
+  HYDROData_Object::Update();
+  SetTopShape( theTopShape);
+}
+
+bool HYDROData_BCPolygon::IsHas2dPrs() const
+{
+  return true;
+}
+
+TopoDS_Shape HYDROData_BCPolygon::generateTopShape() const
+{
+  return generateTopShape( GetPolyline() );
+}
+
+TopoDS_Shape HYDROData_BCPolygon::generateTopShape( const Handle(HYDROData_PolylineXY)& aPolyline )
+{
+  return HYDROData_Tool::PolyXY2Face(aPolyline);
+}
+
+TopoDS_Shape HYDROData_BCPolygon::GetShape3D() const
+{
+  return GetTopShape();
+}
+
+QColor HYDROData_BCPolygon::DefaultFillingColor() const
+{
+  int aBT = GetBoundaryType();
+  QColor aFC;
+  if (aBT == 1)
+    aFC = QColor( Qt::blue );
+  else if (aBT == 2)
+    aFC = QColor( Qt::darkGreen );
+  else if (aBT == 3)
+    aFC = QColor( Qt::darkYellow );
+  else 
+    aFC = QColor( Qt::red );
+  //aFC.setAlpha(175);
+  return aFC;
+}
+
+QColor HYDROData_BCPolygon::DefaultBorderColor() const
+{
+  return QColor( Qt::black );
+}
+
+void HYDROData_BCPolygon::SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
+{
+  if( IsEqual( GetPolyline(), thePolyline ) )
+    return;
+
+  SetReferenceObject( thePolyline, DataTag_Polyline );
+  Changed( Geom_2d );
+}
+
+Handle(HYDROData_PolylineXY) HYDROData_BCPolygon::GetPolyline() const
+{
+  return Handle(HYDROData_PolylineXY)::DownCast( 
+           GetReferenceObject( DataTag_Polyline ) );
+}
+
+void HYDROData_BCPolygon::RemovePolyline()
+{
+  ClearReferenceObjects( DataTag_Polyline );
+  Changed( Geom_2d );
+}
diff --git a/src/HYDROData/HYDROData_BCPolygon.h b/src/HYDROData/HYDROData_BCPolygon.h
new file mode 100644 (file)
index 0000000..efaf01b
--- /dev/null
@@ -0,0 +1,141 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROData_BCPolygon_HeaderFile
+#define HYDROData_BCPolygon_HeaderFile
+
+#include <HYDROData_Object.h>
+
+class HYDROData_PolylineXY;
+
+/**\class HYDROData_BCPolygon
+ * \brief 
+ *
+ */
+class HYDROData_BCPolygon : public HYDROData_Object
+{
+protected:
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = HYDROData_Object::DataTag_First + 100,
+    DataTag_Polyline,     ///< reference polyline
+    DataTag_BoundaryType  ///< boundary type: cutting(1), bounding(2), selection(3) 
+};
+
+public:
+  DEFINE_STANDARD_RTTIEXT(HYDROData_BCPolygon, HYDROData_Object);
+
+  /**
+   * Returns the kind of this object. Must be redefined in all objects of known type.
+   */
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_BC_POLYGON;}
+
+  /**
+   * Dump object to Python script representation.
+   */
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
+
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
+  /**
+   * Update the object.
+   * Call this method whenever you made changes for object data.
+   */
+  HYDRODATA_EXPORT virtual void Update();
+
+  /**
+   * Update the object with new top shape.
+   * Call this method whenever you made changes for object data.
+   */
+  HYDRODATA_EXPORT void Update(const TopoDS_Shape& theTopShape);
+
+  /**
+   * Checks that object has 2D presentation. Reimlemented to retun true.
+   */
+  HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
+
+  /**
+   * Returns the 3d shape of the object.
+   */
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+
+  /**
+   * Returns default filling color for new zone.
+   */
+  HYDRODATA_EXPORT virtual QColor DefaultFillingColor() const;
+
+  /**
+   * Returns default border color for new zone.
+   */
+  HYDRODATA_EXPORT virtual QColor DefaultBorderColor() const;
+
+  /**
+   * Sets reference polyline object for zone.
+   */
+  HYDRODATA_EXPORT virtual void SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
+
+  /**
+   * Returns reference polyline object of zone.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetPolyline() const;
+
+  /**
+   * Remove reference polyline object of zone.
+   */
+  HYDRODATA_EXPORT virtual void RemovePolyline();
+
+  HYDRODATA_EXPORT TopoDS_Shape generateTopShape() const;
+
+  HYDRODATA_EXPORT static TopoDS_Shape generateTopShape( const Handle(HYDROData_PolylineXY)& );
+
+  HYDRODATA_EXPORT int GetBoundaryType() const;
+
+  HYDRODATA_EXPORT void SetBoundaryType( int ) const;
+
+
+private:
+
+  /**
+   * Create all necessary child group objects.
+   */
+  //HYDRODATA_EXPORT void createGroupObjects();
+
+protected:
+
+  friend class HYDROData_Iterator;
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDRODATA_EXPORT HYDROData_BCPolygon();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  virtual HYDRODATA_EXPORT ~HYDROData_BCPolygon();
+};
+
+#endif
diff --git a/src/HYDROData/HYDROData_BoundaryPolygonTools.cxx b/src/HYDROData/HYDROData_BoundaryPolygonTools.cxx
new file mode 100644 (file)
index 0000000..0f40c36
--- /dev/null
@@ -0,0 +1,170 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <HYDROData_Tool.h>
+#include <HYDROData_BoundaryPolygonTools.h>
+
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+
+
+#include <BRep_Builder.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopExp.hxx>
+#include <NCollection_List.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <TopExp_Explorer.hxx>
+
+#include <NCollection_IndexedDataMap.hxx>
+#include <BOPAlgo_BOP.hxx>
+#include <BOPAlgo_Section.hxx>
+
+
+#include <Basics_OCCTVersion.hxx>
+
+static bool FindInterBySection(const TopoDS_Face& IncF, TopoDS_Shape poly)
+{
+  if (IncF.IsNull())
+    return false;
+  //make cmp from edges of Inc_sh
+  TopTools_IndexedMapOfShape IncToolsE;
+  TopExp::MapShapes(IncF, TopAbs_EDGE, IncToolsE);
+  BRep_Builder BB;
+  TopoDS_Compound aToolCmp;
+  BB.MakeCompound(aToolCmp);
+  for (int i=1; i<= IncToolsE.Extent();i++)
+    BB.Add(aToolCmp, IncToolsE(i));
+  //
+  //perform bsection - poly vs aToolCmp
+  BOPAlgo_Section aBOP;
+  aBOP.AddArgument(poly);
+  aBOP.AddArgument(aToolCmp);
+  aBOP.SetRunParallel(true);
+
+  aBOP.Perform();
+  //aBOP.GetReport());
+
+//#if OCC_VERSION_LARGE > 0x07020000
+//  if (aBOP.HasErrors())
+//    return false;
+//#endif
+
+  const TopoDS_Shape& aRes=aBOP.Shape();
+  if (aRes.IsNull())
+    return false;
+
+  bool IsInter = false;
+  TopTools_IndexedMapOfShape aShVE;
+  TopExp::MapShapes(aRes, TopAbs_VERTEX, aShVE);
+  if (aShVE.IsEmpty())
+  {
+    TopExp::MapShapes(aRes, TopAbs_EDGE, aShVE);
+    if (!aShVE.IsEmpty())
+      IsInter = true;
+  }
+  else
+    IsInter = true;
+  return IsInter;
+}
+
+bool HYDROData_BoundaryPolygonTools::CutTool( const TopTools_SequenceOfShape& CutTools, 
+                                              NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes )
+{
+  TopTools_IndexedMapOfShape EdgesTools;
+  for (int i =1; i<=CutTools.Length();i++)
+  {
+    const TopoDS_Shape& CSH = CutTools(i);
+    TopExp::MapShapes(CSH, TopAbs_EDGE, EdgesTools);
+  }
+  //
+  BRep_Builder BB;
+  TopoDS_Compound aToolCmp;
+  BB.MakeCompound(aToolCmp);
+  for (int i=1; i<= EdgesTools.Extent();i++)
+    BB.Add(aToolCmp, EdgesTools(i));
+  //
+  for (int i = 1; i <= ObjToRes.Extent(); i++ )
+  {
+    const TopoDS_Shape& Obj = ObjToRes.FindKey(i);
+    Standard_Real aTol;
+    if (!Obj.IsNull()) 
+    {
+      aTol = Precision::Confusion();
+      BOPAlgo_BOP aBOP;
+      //
+      aBOP.AddArgument(Obj);
+      aBOP.AddTool(aToolCmp);
+      aBOP.SetOperation(BOPAlgo_CUT);
+      aBOP.SetRunParallel(true);
+
+      aBOP.Perform();
+
+#if OCC_VERSION_LARGE > 0x07020000
+  if (aBOP.HasErrors())
+    return false;
+#endif
+
+      const TopoDS_Shape& aRes=aBOP.Shape();
+      ObjToRes.ChangeFromKey(Obj) = aRes;
+    }
+  }
+  return true;
+}
+
+
+bool HYDROData_BoundaryPolygonTools::IncludeTool( const TopTools_SequenceOfShape& IncludeTools, 
+  TopoDS_Shape Obj)
+{
+  TopExp_Explorer exp(Obj, TopAbs_VERTEX);
+  if (!exp.More())
+    return false;
+  TopoDS_Vertex aV = TopoDS::Vertex(exp.Current());
+  gp_Pnt aP = BRep_Tool::Pnt(aV);
+  for (int i=1; i<=IncludeTools.Size(); i++)
+  {
+    TopoDS_Face IncF = TopoDS::Face(IncludeTools(i));
+    bool IsInter = FindInterBySection(IncF, Obj);
+    if (IsInter)
+      return false;
+    //
+    gp_XY aP2d(aP.X(), aP.Y());
+    TopAbs_State aState = HYDROData_Tool::ComputePointState(aP2d, IncF);
+    if (aState != TopAbs_IN)
+      return false;
+  }
+  return true;
+}
+
+bool HYDROData_BoundaryPolygonTools::SelectionTool( const TopTools_SequenceOfShape& SelectionTool, 
+                                    TopoDS_Shape Obj)
+{
+  for (int i=1; i<=SelectionTool.Size(); i++)
+  {
+    TopoDS_Face IncF = TopoDS::Face(SelectionTool(i));
+    bool IsInter = FindInterBySection(IncF, Obj);
+    if (!IsInter)
+      return false;
+  }
+  return true;
+}
+
+
diff --git a/src/HYDROData/HYDROData_BoundaryPolygonTools.h b/src/HYDROData/HYDROData_BoundaryPolygonTools.h
new file mode 100644 (file)
index 0000000..70f4d60
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROData_BoundaryPolygonTools_HeaderFile
+#define HYDROData_BoundaryPolygonTools_HeaderFile
+
+#include "HYDROData.h"
+#include <TopTools_SequenceOfShape.hxx>
+#include <NCollection_IndexedDataMap.hxx>
+
+
+class TopoDS_Shape;
+
+class HYDRODATA_EXPORT HYDROData_BoundaryPolygonTools {
+
+public:
+
+  static bool CutTool( const TopTools_SequenceOfShape& CutTools, 
+                                         NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes );
+
+  static bool IncludeTool( const TopTools_SequenceOfShape& IncludeTools, 
+                                  TopoDS_Shape Obj);
+
+  static bool SelectionTool( const TopTools_SequenceOfShape& SelectionTool, 
+                                    TopoDS_Shape Obj) ;
+
+};
+
+#endif
+
+
index 7a18f687bd3acee687da0a0b3e41bf7334833ced..12aca20da9df2a77b0a89344036dcfe8acc52472 100644 (file)
@@ -30,6 +30,9 @@
 #include "HYDROData_Region.h"
 #include "HYDROData_Tool.h"
 #include "HYDROData_GeomTool.h"
+#include <HYDROData_Tool.h>
+#include <HYDROData_BCPolygon.h>
+#include <HYDROData_BoundaryPolygonTools.h>
 
 #ifdef WIN32
   #pragma warning ( disable: 4251 )
@@ -52,6 +55,8 @@
 #include <BRep_Builder.hxx>
 #include <BRepBuilderAPI_Sewing.hxx>
 #include <BRepTopAdaptor_FClass2d.hxx>
+#include <BRepTools_ReShape.hxx>
+#include <BRepLib_MakeWire.hxx>
 
 #include <BRepTools.hxx>
 
@@ -270,6 +275,142 @@ HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects()
   return aResSeq;
 }
 
+static void FilterEdgesByIncludeSelectionBoundaryPolygons( const HYDROData_SplitToZonesTool::SplitDataList& anEdgesList,
+                                                           HYDROData_SequenceOfObjects aBoundaryPolygons,
+                                                           HYDROData_SplitToZonesTool::SplitDataList& outEdgesList)
+{
+  //perform boundary condition polygons on EdgesList
+  TopTools_SequenceOfShape IncTools, SelectionTools;
+  HYDROData_SplitToZonesTool::SplitDataListIterator anIter(anEdgesList);
+  for (int i=1; i<=aBoundaryPolygons.Size();i++)
+  {
+    Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast( aBoundaryPolygons(i));
+    TopoDS_Shape aPolyTopShape = aBCPoly->GetTopShape();
+    int bType = aBCPoly->GetBoundaryType();
+    if (bType == 2) 
+      IncTools.Append(aPolyTopShape);
+    else if (bType == 3)
+      SelectionTools.Append(aPolyTopShape);
+  }
+  
+  while( anIter.hasNext() )
+  {
+    const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
+    if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
+      continue;
+    if (aSplitData.Shape.ShapeType() != TopAbs_EDGE)
+      continue;
+    if (HYDROData_BoundaryPolygonTools::IncludeTool(IncTools, aSplitData.Shape) && HYDROData_BoundaryPolygonTools::SelectionTool(SelectionTools, aSplitData.Shape))
+      outEdgesList.append(aSplitData);
+  }
+}
+
+
+static void SplitEdgesByBoundaryPolygons( const HYDROData_SplitToZonesTool::SplitDataList& anEdgesList,
+                                          const HYDROData_SequenceOfObjects& aBoundaryPolygons,
+                                          NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes)
+{
+  //perform boundary condition polygons on EdgesList
+  TopTools_SequenceOfShape CutTools;
+  ObjToRes.Clear();
+  HYDROData_SplitToZonesTool::SplitDataListIterator anIter(anEdgesList);
+  for (int i=1; i<=aBoundaryPolygons.Size();i++)
+  {
+    Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast( aBoundaryPolygons(i));
+    TopoDS_Shape aPolyTopShape = aBCPoly->GetTopShape();
+    int bType = aBCPoly->GetBoundaryType();
+    if (bType == 1) 
+      CutTools.Append(aPolyTopShape);
+  }
+  
+  while( anIter.hasNext() )
+  {
+    const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
+    if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
+      continue;
+    if (aSplitData.Shape.ShapeType() != TopAbs_EDGE)
+      continue;
+    ObjToRes.Add(aSplitData.Shape, TopoDS_Shape());
+  }
+
+  HYDROData_BoundaryPolygonTools::CutTool(CutTools, ObjToRes);
+}
+
+
+static void PerformEdgeReplInZones(const HYDROData_SplitToZonesTool::SplitDataList& ZoneList,
+                                   const NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes,
+                                   HYDROData_SplitToZonesTool::SplitDataList& outZoneList)
+{
+  HYDROData_SplitToZonesTool::SplitDataListIterator it( ZoneList ); 
+  BRepTools_ReShape reshaper;
+  for (;it.hasNext();)
+  {
+    const HYDROData_SplitToZonesTool::SplitData& aSplitData = it.next();
+    if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
+      continue;
+
+    TopoDS_Shape mS = aSplitData.Shape;
+    for (int i=1; i<=ObjToRes.Extent();i++)
+    {
+      TopoDS_Shape K = ObjToRes.FindKey(i);
+      TopoDS_Shape V = ObjToRes.FindFromIndex(i);
+      if (V.ShapeType() != TopAbs_EDGE && V.ShapeType() != TopAbs_WIRE && V.ShapeType() != TopAbs_COMPOUND)
+        continue;
+      if (V.ShapeType() == TopAbs_COMPOUND)
+      {
+        TopExp_Explorer exp(V, TopAbs_EDGE);
+        TopTools_ListOfShape lE;
+        for (;exp.More();exp.Next())
+          lE.Append(exp.Current());
+        if (lE.Extent() == 1)
+          V = lE.First();
+        else if (lE.Extent() > 1)
+        {
+          BRepLib_MakeWire MW;
+          MW.Add(lE);
+          if (MW.IsDone())
+            V = MW.Wire();
+          else
+            continue;
+        }
+        else 
+          continue;
+      }
+      reshaper.Replace(K, V);
+    }
+    TopoDS_Shape nS = reshaper.Apply(mS);
+    HYDROData_SplitToZonesTool::SplitData aNS(aSplitData.Type, nS, aSplitData.ObjectNames);
+    outZoneList.append(aNS);
+  } 
+}
+
+static void CreateNewEdgeList( const HYDROData_SplitToZonesTool::SplitDataList& theEdges,
+                               const NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes,
+                               HYDROData_SplitToZonesTool::SplitDataList& newEdges)
+{
+  HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theEdges );
+  while( anIter.hasNext() )
+  {
+    const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
+    if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
+      continue;
+
+    const TopoDS_Shape* aDivShape = ObjToRes.Seek(aSplitData.Shape);
+    if (aDivShape)
+    {
+      TopExp_Explorer exp(*aDivShape, TopAbs_EDGE);
+      for (;exp.More();exp.Next())
+      {
+        HYDROData_SplitToZonesTool::SplitData anNewSData(aSplitData.Type, exp.Current(), aSplitData.ObjectNames);
+        newEdges.append(anNewSData);
+      }
+    }
+    else
+      newEdges.append(aSplitData);
+  }
+}
+
+
 void HYDROData_CalculationCase::Update()
 {
   HYDROData_Entity::Update();
@@ -309,17 +450,34 @@ void HYDROData_CalculationCase::Update()
     }
   }
 
+  //
+  //split edges by boundary polygons
+  HYDROData_SequenceOfObjects aBoundaryPolygons = GetBoundaryPolygons();
+  //edge to splitted edge (compound of edges or original edge)
+  NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape> ObjToRes;
+  //split edge list by BP
+  SplitEdgesByBoundaryPolygons(anEdgesList, aBoundaryPolygons, ObjToRes);
+  HYDROData_SplitToZonesTool::SplitDataList aNewZonesList;
+  //replace splitted edges in zone list (faces)
+  PerformEdgeReplInZones(aZonesList, ObjToRes, aNewZonesList);
+  //
+  //create new edges list based on splitting info from ObjToRes
+  HYDROData_SplitToZonesTool::SplitDataList newEdgesList1,newEdgesList2;
+  CreateNewEdgeList(anEdgesList, ObjToRes, newEdgesList1);
+  //filter out edges list by include&selection tools 
+  FilterEdgesByIncludeSelectionBoundaryPolygons(newEdgesList1,aBoundaryPolygons,newEdgesList2);
+  
   switch( GetAssignmentMode() )
   {
   case MANUAL:
-    CreateRegionsDef( aDocument, aZonesList );    
+    CreateRegionsDef( aDocument,aNewZonesList );    
     break;
   case AUTOMATIC:
-    CreateRegionsAuto( aDocument, aZonesList );    
+    CreateRegionsAuto( aDocument,aNewZonesList );    
     break;
   }
 
-  CreateEdgeGroupsDef( aDocument, anEdgesList );
+  CreateEdgeGroupsDef( aDocument, newEdgesList2 );
 }
 
 void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
@@ -459,7 +617,7 @@ void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Docu
     if ( aSplitGroup.IsNull() )
       continue;
 
-    aSplitGroup->AddShape( aSplitData.Shape );
+      aSplitGroup->AddShape( aSplitData.Shape );
 
     TopTools_SequenceOfShape theShapes;
     aSplitGroup->GetShapes(theShapes);
@@ -1486,5 +1644,35 @@ void HYDROData_CalculationCase::RemoveInterPolyObject( const Handle(HYDROData_Po
   Changed( Geom_2d );
 }
 
+bool HYDROData_CalculationCase::AddBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon )
+{
+  HYDROData_CalculationCase::DataTag aDataTag = DataTag_BCPolygon;
+
+  if ( HasReference( theBCPolygon, aDataTag ) )
+    return false; 
+
+  AddReferenceObject( theBCPolygon, aDataTag );
+
+  Changed( Geom_2d );
+
+  return true;
+}
+
+HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetBoundaryPolygons() const
+{
+  return GetReferenceObjects( DataTag_BCPolygon ); 
+}
+
+void HYDROData_CalculationCase::RemoveBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon ) 
+{
+  if ( theBCPolygon.IsNull() )
+    return;
+
+  RemoveReferenceObject( theBCPolygon->Label(), DataTag_BCPolygon );
+
+  Changed( Geom_2d );
+}
+
+
 
 
index ad8a5609ff3f752824364c250de9c020e15d3bd1..f5aefb1b935564b2d89f44c284beec8fe9f84cde 100644 (file)
@@ -54,6 +54,7 @@ class HYDROData_SplitShapesGroup;
 class HYDROData_Document;
 class HYDROData_StricklerTable;
 class HYDROData_LandCoverMap;
+class HYDROData_BCPolygon;
 
 /**\class HYDROData_CalculationCase
  * \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
@@ -94,6 +95,7 @@ public:
     DataTag_AssignmentMode,            ///< assignment mode
     DataTag_StricklerTable,            ///< reference Strickler table
     DataTag_InterPoly,                 ///< intersection polyline
+    DataTag_BCPolygon,                 ///< reference boundary polygons
 
     DataTag_LandCover_Obsolete,                 ///< reference land covers
     DataTag_CustomLandCoverRules_Obsolete,      ///< custom rules for land covers priority
@@ -277,6 +279,12 @@ public:
 
   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetInterPolyObjects() const;
 
+  HYDRODATA_EXPORT virtual bool AddBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon );
+
+  HYDRODATA_EXPORT virtual void RemoveBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon );
+
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetBoundaryPolygons() const;
+
   /**
    * Exports the calculation case data (shell and groups) to GEOM module.
    * \param theStudyId the id of the study where the GEOM module should be used for export
index 34fb535622f8382b0848d35ec108894a14237a0b..c892dcd8b74b8e00d01e56afaf92aa90ccd14ebe 100644 (file)
@@ -334,6 +334,7 @@ bool HYDROData_Document::DumpToPython( const QString& thePyScriptPath,
   aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_DIGUE );
   aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_OBSTACLE );
   aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_LAND_COVER_MAP );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_BC_POLYGON );
   aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_CALCULATION );
 
   // Dump code to close python fuction
index e052c425943f0adc2138c8f90a04847d223b707d..94c4921a78dc8e04e42db0b1440bd7abba083a6e 100644 (file)
@@ -148,6 +148,8 @@ QString HYDROData_Entity::Type( ObjectKind theKind )
     return "Land_cover_map";
   case KIND_DTM:
     return "DTM";
+  case KIND_BC_POLYGON:
+    return "Boundary Polygon";
   }
   return "";
 }
@@ -783,6 +785,7 @@ QString HYDROData_Entity::getPyTypeID() const
     case KIND_LAND_COVER_OBSOLETE: return "";
     case KIND_CHANNEL_ALTITUDE:  return "KIND_CHANNEL_ALTITUDE";
     case KIND_LAND_COVER_MAP:    return "KIND_LAND_COVER_MAP";
+    case KIND_BC_POLYGON:        return "KIND_BC_POLYGON";
     default:                     return "KIND_UNKNOWN"; ///! Unrecognized object
   }
 }
index 91843863d13c6d7ce9fced53c2f5ebe8b01682c9..bba4f693f77f8f47b1f4fecf52bc106625eadb96 100644 (file)
@@ -76,7 +76,8 @@ const ObjectKind KIND_LAND_COVER_OBSOLETE = 27;
 const ObjectKind KIND_CHANNEL_ALTITUDE    = 28;
 const ObjectKind KIND_LAND_COVER_MAP      = 29;
 const ObjectKind KIND_DTM                 = 30;
-const ObjectKind KIND_LAST                = KIND_DTM+1;
+const ObjectKind KIND_BC_POLYGON          = 31;
+const ObjectKind KIND_LAST                = KIND_BC_POLYGON+1;
 
 class MapOfTreatedObjects : public QMap<QString,Handle(Standard_Transient)>
 {
index 6d0ed1508c738b477167d1d47ec76222eb608ad5..0c08bffb1f477dd05dbb7e1c4b9e551a8dbcb7df 100644 (file)
@@ -24,7 +24,7 @@
 #include "HYDROData_PolylineXY.h"
 #include "HYDROData_ShapesTool.h"
 
-#include <BRepBuilderAPI_MakeFace.hxx>
+#include <HYDROData_Tool.h>
 
 #include <TopoDS.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_HSequenceOfShape.hxx>
 
-#include <BRep_Builder.hxx>
-#include <BRepAlgo_FaceRestrictor.hxx>
-#include <BRepCheck_Analyzer.hxx>
 
 #include <ShapeAnalysis.hxx>
 #include <ShapeAnalysis_FreeBounds.hxx>
 
+
 #include <QColor>
 #include <QStringList>
 
@@ -123,134 +121,7 @@ TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape() const
 
 TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape( const Handle(HYDROData_PolylineXY)& aPolyline )
 {
-  //DEBTRACE("generateTopShape");
-  TopoDS_Face aResultFace = TopoDS_Face(); // --- result: default = null face
-
-  if (!aPolyline.IsNull())
-    {
-      TopoDS_Shape aPolylineShape = aPolyline->GetShape();
-#ifdef DEB_IMZ
-      std::string brepName = "imz.brep";
-      BRepTools::Write(aPolylineShape, brepName.c_str());
-#endif
-      TopTools_ListOfShape aWiresList;
-
-      if (!aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE)
-        {
-          // --- only one wire: try to make a face
-          //DEBTRACE("one wire: try to build a face");
-          const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aPolylineShape);
-          if (!aPolylineWire.IsNull())
-            {
-              BRepBuilderAPI_MakeFace aMakeFace(aPolylineWire, Standard_True);
-              aMakeFace.Build();
-              if (aMakeFace.IsDone())
-                {
-                  //DEBTRACE(" a face with the only wire given");
-                  aResultFace = aMakeFace.Face();
-                }
-            }
-        }
-      else
-        {
-          // --- a list of wires ? inventory of wires and edges
-          Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
-          Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
-          TopExp_Explorer anExp(aPolylineShape, TopAbs_WIRE);
-          //DEBTRACE("list of wires ?");
-          for (; anExp.More(); anExp.Next())
-            {
-              if (!anExp.Current().IsNull())
-                {
-                  const TopoDS_Wire& aWire = TopoDS::Wire(anExp.Current());
-                  aWiresList.Append(aWire);
-                  //DEBTRACE("  append wire");
-                  TopExp_Explorer it2(aWire, TopAbs_EDGE);
-                  for (; it2.More(); it2.Next())
-                    aSeqEdges->Append(it2.Current());
-                }
-            }
-          if (aWiresList.IsEmpty())
-            return aResultFace; // --- no wires: null result
-
-          if (aSeqEdges->Length() > 1)
-            {
-              //DEBTRACE("try to connect all the edges together, build a unique wire and a face");
-              // --- try to create one wire by connecting edges with a distance tolerance (no necessity of sharing points)
-              ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, 1E-5, Standard_False, aSeqWires);
-
-              if (aSeqWires->Length() == 1)
-                {
-                  // --- one wire: try to make a face
-                  const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aSeqWires->Value(1));
-                  if (!aPolylineWire.IsNull())
-                    {
-                      BRepBuilderAPI_MakeFace aMakeFace(aPolylineWire, Standard_True);
-                      aMakeFace.Build();
-                      if (aMakeFace.IsDone())
-                        {
-                          //DEBTRACE("  a face from all the wires connected");
-                          aResultFace = aMakeFace.Face();
-                        }
-                    }
-                }
-            }
-
-          if (aResultFace.IsNull())
-            {
-              //DEBTRACE("try to make a face with the first wire of the list and other wires as restrictions");
-              // --- try to make a face with the first wire of the list and other wires as restrictions
-              BRepAlgo_FaceRestrictor aFR;
-              TopoDS_Face aRefFace;
-              TopoDS_Shape aS = aWiresList.First();
-              BRepBuilderAPI_MakeFace aMakeFace(TopoDS::Wire(aWiresList.First()), Standard_True);
-              aMakeFace.Build();
-              if (aMakeFace.IsDone())
-                {
-                  //DEBTRACE("  a face with first wire");
-                  aRefFace = aMakeFace.Face();
-                }
-              if (!aRefFace.IsNull())
-                {
-                  aFR.Init(aRefFace, Standard_False, Standard_True);
-                  TopTools_ListIteratorOfListOfShape anIt(aWiresList);
-                  for (; anIt.More(); anIt.Next())
-                    {
-                      TopoDS_Wire& aWire = TopoDS::Wire(anIt.Value());
-                      if (aWire.IsNull())
-                        continue;
-                      aFR.Add(aWire);
-                    }
-                  aFR.Perform();
-                  if (aFR.IsDone())
-                    {
-                      for (; aFR.More(); aFR.Next())
-                        {
-                          //DEBTRACE("  a restricted face");
-                          aResultFace = aFR.Current();
-                          break;
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-  if (aResultFace.IsNull())
-    return aResultFace;
-
-  //DEBTRACE("check the face");
-  BRepCheck_Analyzer anAnalyzer(aResultFace);
-  if (anAnalyzer.IsValid() && aResultFace.ShapeType() == TopAbs_FACE)
-  {
-    //DEBTRACE("face OK");
-    return aResultFace;
-  }
-  else
-  {
-    //DEBTRACE("bad face");
-  }
-  return TopoDS_Face();
+  return HYDROData_Tool::PolyXY2Face(aPolyline);
 }
 
 void HYDROData_ImmersibleZone::createGroupObjects()
index 3277b3f52d2fb549e39b5dc27d453ba9399244dd..46212c31953d1c34354d63f8efa442fe52cddda1 100644 (file)
@@ -45,7 +45,7 @@
 #include "HYDROData_Zone.h"
 #include "HYDROData_StricklerTable.h"
 #include "HYDROData_DTM.h"
-
+#include "HYDROData_BCPolygon.h"
 #include <TDataStd_Name.hxx>
 #include <TDataStd_NamedData.hxx>
 
@@ -162,6 +162,7 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel )
     case KIND_CHANNEL_ALTITUDE:   aResult = new HYDROData_ChannelAltitude();      break;
     case KIND_LAND_COVER_MAP:     aResult = new HYDROData_LandCoverMap();         break;
     case KIND_DTM:                aResult = new HYDROData_DTM();                  break;
+    case KIND_BC_POLYGON:         aResult = new HYDROData_BCPolygon();            break;
     default:                       break;
   }
 
index 2a38a86d1401211f791bddbcf949b289fb6d1c47..eef771c39552054b76c89b17c8e81f236e441431 100644 (file)
@@ -706,7 +706,7 @@ void HYDROData_ShapeFile::GetFreeIndices(std::vector<int>& theAllowedIndexes, QS
 }
 
 int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName, 
-  NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile)
+  NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile, ImportShapeType theShapeTypesToImport)
 {
   //Free();
   int aStat = TryOpenShapeFile(theFileName);
@@ -728,7 +728,12 @@ int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument,
 
   if (!Parse(aHSHP, HYDROData_ShapeFile::ShapeType_Polyline, theShapeTypeOfFile))
     return 0;
-  if (aHSHP->nShapeType == 3 || aHSHP->nShapeType == 23)
+
+  int sh_type = aHSHP->nShapeType;
+
+  if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || 
+    theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline) 
+    && (sh_type == 3 || sh_type == 23))
   {
     size_t anObjsSize = mySHPObjects.size();
     GetFreeIndices(anAllowedIndexes, "_PolyXY_", anObjsSize, anExistingNames, aBaseFileName);
@@ -739,7 +744,8 @@ int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument,
     }
     aStat = 1;
   }
-  else if (aHSHP->nShapeType == 13)
+  else if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || 
+    theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline3D) && sh_type == 13)
   {
     anInd = 0;
     for (;anAllowedIndexes.size() < mySHPObjects.size();)
@@ -760,7 +766,8 @@ int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument,
     }
     aStat = 1;
   }
-  else if (aHSHP->nShapeType == 5)
+  else if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || 
+    theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polygon) && sh_type == 5)
   {
     //import polygon's contours as polylines
     size_t anObjsSize = mySHPObjects.size();
index 41f2200f7a4a2530089576407349d80f0c8e19f2..b546bd235a5123a713ea2826bd283d930db6d19a 100644 (file)
@@ -63,6 +63,13 @@ enum DBF_FieldType
   DBF_FieldType_Invalid
 };
 
+enum ImportShapeType
+{
+  ImportShapeType_Polyline,
+  ImportShapeType_Polyline3D,
+  ImportShapeType_Polygon,
+  ImportShapeType_All
+};
 
 struct DBF_AttrValue
 {
@@ -130,7 +137,8 @@ public:
                      int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
 
   HYDRODATA_EXPORT int ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName, 
-                                       NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile);
+                                       NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile,
+                                       ImportShapeType theShapeTypesToImport);
 
   HYDRODATA_EXPORT QString GetShapeTypeName(int theType);
 
index 750b8973c998de272c9a9d4e196a458c7c6a92cd..cc142d0cf932723e3076b5048658ab324901c547 100644 (file)
@@ -23,6 +23,7 @@
 #include <HYDROData_Iterator.h>
 #include <HYDROData_NaturalObject.h>
 #include <HYDROData_ShapesGroup.h>
+#include <HYDROData_PolylineXY.h>
 #include <QColor>
 #include <QFile>
 #include <QStringList>
@@ -46,8 +47,6 @@
 
 #include <BRepTools.hxx>
 #include <NCollection_Map.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS_Face.hxx>
 #include <TopTools_ShapeMapHasher.hxx>
 #include <BRep_Builder.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 #include <NCollection_List.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 
+#include <BRepBuilderAPI_MakeFace.hxx>
+
+#include <TopExp_Explorer.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepAlgo_FaceRestrictor.hxx>
+#include <BRepCheck_Analyzer.hxx>
+
+#include <ShapeAnalysis.hxx>
+#include <ShapeAnalysis_FreeBounds.hxx>
+
+
 static int aMaxNameId = INT_MAX;
 static int aMaxColorNb = 92000;
 void HYDROData_Tool::WriteStringsToFile( QFile&             theFile,
@@ -495,6 +508,137 @@ TopoDS_Shape HYDROData_Tool::RebuildCmp(const TopoDS_Shape& in)
   
 }
 
+TopoDS_Shape HYDROData_Tool::PolyXY2Face( const Handle(HYDROData_PolylineXY)& aPolyline )
+{
+  //DEBTRACE("generateTopShape");
+  TopoDS_Face aResultFace = TopoDS_Face(); // --- result: default = null face
+
+  if (!aPolyline.IsNull())
+    {
+      TopoDS_Shape aPolylineShape = aPolyline->GetShape();
+#ifdef DEB_IMZ
+      std::string brepName = "imz.brep";
+      BRepTools::Write(aPolylineShape, brepName.c_str());
+#endif
+      TopTools_ListOfShape aWiresList;
+
+      if (!aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE)
+        {
+          // --- only one wire: try to make a face
+          //DEBTRACE("one wire: try to build a face");
+          const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aPolylineShape);
+          if (!aPolylineWire.IsNull())
+            {
+              BRepBuilderAPI_MakeFace aMakeFace(aPolylineWire, Standard_True);
+              aMakeFace.Build();
+              if (aMakeFace.IsDone())
+                {
+                  //DEBTRACE(" a face with the only wire given");
+                  aResultFace = aMakeFace.Face();
+                }
+            }
+        }
+      else
+        {
+          // --- a list of wires ? inventory of wires and edges
+          Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
+          Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
+          TopExp_Explorer anExp(aPolylineShape, TopAbs_WIRE);
+          //DEBTRACE("list of wires ?");
+          for (; anExp.More(); anExp.Next())
+            {
+              if (!anExp.Current().IsNull())
+                {
+                  const TopoDS_Wire& aWire = TopoDS::Wire(anExp.Current());
+                  aWiresList.Append(aWire);
+                  //DEBTRACE("  append wire");
+                  TopExp_Explorer it2(aWire, TopAbs_EDGE);
+                  for (; it2.More(); it2.Next())
+                    aSeqEdges->Append(it2.Current());
+                }
+            }
+          if (aWiresList.IsEmpty())
+            return aResultFace; // --- no wires: null result
+
+          if (aSeqEdges->Length() > 1)
+            {
+              //DEBTRACE("try to connect all the edges together, build a unique wire and a face");
+              // --- try to create one wire by connecting edges with a distance tolerance (no necessity of sharing points)
+              ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, 1E-5, Standard_False, aSeqWires);
+
+              if (aSeqWires->Length() == 1)
+                {
+                  // --- one wire: try to make a face
+                  const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aSeqWires->Value(1));
+                  if (!aPolylineWire.IsNull())
+                    {
+                      BRepBuilderAPI_MakeFace aMakeFace(aPolylineWire, Standard_True);
+                      aMakeFace.Build();
+                      if (aMakeFace.IsDone())
+                        {
+                          //DEBTRACE("  a face from all the wires connected");
+                          aResultFace = aMakeFace.Face();
+                        }
+                    }
+                }
+            }
+
+          if (aResultFace.IsNull())
+            {
+              //DEBTRACE("try to make a face with the first wire of the list and other wires as restrictions");
+              // --- try to make a face with the first wire of the list and other wires as restrictions
+              BRepAlgo_FaceRestrictor aFR;
+              TopoDS_Face aRefFace;
+              TopoDS_Shape aS = aWiresList.First();
+              BRepBuilderAPI_MakeFace aMakeFace(TopoDS::Wire(aWiresList.First()), Standard_True);
+              aMakeFace.Build();
+              if (aMakeFace.IsDone())
+                {
+                  //DEBTRACE("  a face with first wire");
+                  aRefFace = aMakeFace.Face();
+                }
+              if (!aRefFace.IsNull())
+                {
+                  aFR.Init(aRefFace, Standard_False, Standard_True);
+                  TopTools_ListIteratorOfListOfShape anIt(aWiresList);
+                  for (; anIt.More(); anIt.Next())
+                    {
+                      TopoDS_Wire& aWire = TopoDS::Wire(anIt.Value());
+                      if (aWire.IsNull())
+                        continue;
+                      aFR.Add(aWire);
+                    }
+                  aFR.Perform();
+                  if (aFR.IsDone())
+                    {
+                      for (; aFR.More(); aFR.Next())
+                        {
+                          //DEBTRACE("  a restricted face");
+                          aResultFace = aFR.Current();
+                          break;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+  if (aResultFace.IsNull())
+    return aResultFace;
+
+  //DEBTRACE("check the face");
+  BRepCheck_Analyzer anAnalyzer(aResultFace);
+  if (anAnalyzer.IsValid() && aResultFace.ShapeType() == TopAbs_FACE)
+  {
+    //DEBTRACE("face OK");
+    return aResultFace;
+  }
+  else
+  {
+    //DEBTRACE("bad face");
+  }
+  return TopoDS_Face();
+}
 
 std::ostream& operator<<( std::ostream& theStream, const QString& theText )
 {
index d1f6dbdf87d7395488e7e617bd1e527f6adfed55..82e493666e2ec5fb94df38e2b41c8fe6a0ca144c 100644 (file)
 #include <QStringList>
 #include <Precision.hxx>
 #include <QVector>
+#include <TopTools_SequenceOfShape.hxx>
+#include <NCollection_IndexedDataMap.hxx>
 
+
+class HYDROData_PolylineXY;
 class HYDROData_Document;
 class HYDROData_Entity;
 class HYDROData_SequenceOfObjects;
@@ -137,6 +141,9 @@ public:
   Rebuilds shape container (like compound/compsolid/shell) which contains faces (shared or nonshared with each other)
   */
   static TopoDS_Shape RebuildCmp(const TopoDS_Shape& in);
+
+  static TopoDS_Shape PolyXY2Face(const Handle(HYDROData_PolylineXY)& aPolyline);
+  
 };
 
 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
index ae49195687c5014f7099594e6b285e980692e344..5d7211b2b0cd953eef126dec764d9f869a642ce6 100644 (file)
@@ -41,6 +41,7 @@ set(PROJECT_HEADERS
     HYDROGUI_ImportLandCoverMapOp.h
     HYDROGUI_ImportLandCoverMapDlg.h
     HYDROGUI_ImportPolylineOp.h
+    HYDROGUI_ImportBCPolygonOp.h
     HYDROGUI_ImportSinusXOp.h
     HYDROGUI_ExportSinusXOp.h
     HYDROGUI_ExportSinusXDlg.h
@@ -154,6 +155,8 @@ set(PROJECT_HEADERS
     HYDROGUI_ZoneSetColorOp.h
     HYDROGUI_PolyAttrDlg.h
     HYDROGUI_ShowAttrPolyOp.h
+    HYDROGUI_SetBoundaryTypePolygonOp.h
+    HYDROGUI_SetBoundaryTypePolygonDlg.h
 )
 
 QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -199,6 +202,7 @@ set(PROJECT_SOURCES
     HYDROGUI_ImportSinusXOp.cxx
     HYDROGUI_ExportSinusXOp.cxx
     HYDROGUI_ExportSinusXDlg.cxx
+    HYDROGUI_ImportBCPolygonOp.cxx
     HYDROGUI_ExportLandCoverMapDlg.cxx
     HYDROGUI_InputPanel.cxx
     HYDROGUI_LandCoverArgsFilter.cxx
@@ -310,6 +314,8 @@ set(PROJECT_SOURCES
     HYDROGUI_ZoneSetColorOp.cxx
     HYDROGUI_PolyAttrDlg.cxx
     HYDROGUI_ShowAttrPolyOp.cxx
+    HYDROGUI_SetBoundaryTypePolygonOp.cxx
+    HYDROGUI_SetBoundaryTypePolygonDlg.cxx
 )
 
 add_definitions(
index 1133fcb18dfe23ac9d75924a4559c0de2d4e3187..b5c783d84ebbc4d037be6b095ba709b88248e77f 100644 (file)
@@ -71,6 +71,8 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
 {
   addPage( createObjectsPage() );
   addPage( createGroupsPage() );
+  addPage( createBoundaryPolygonsPage() );
+
   addPage( createLandCoverMapPage() );
   addPage( createZonesPage() );
 }
@@ -309,6 +311,85 @@ QWizardPage* HYDROGUI_CalculationDlg::createGroupsPage() {
   return aPage;
 }
 
+QWizardPage* HYDROGUI_CalculationDlg::createBoundaryPolygonsPage() {
+  QWizardPage* aPage = new QWizardPage( mainFrame() );
+  QFrame* aFrame = new QFrame( aPage );
+
+  myBoundaryPolygons = new QListWidget( aPage );
+  myBoundaryPolygons->setSelectionMode( QListWidget::ExtendedSelection );
+  myBoundaryPolygons->setEditTriggers( QListWidget::NoEditTriggers );
+  myBoundaryPolygons->setViewMode( QListWidget::ListMode );
+  myBoundaryPolygons->setSortingEnabled( true );
+
+  myISBoundaryPolygons = new QListWidget( aPage );
+  myISBoundaryPolygons->setSelectionMode( QListWidget::ExtendedSelection );
+  myISBoundaryPolygons->setEditTriggers( QListWidget::NoEditTriggers );
+  myISBoundaryPolygons->setViewMode( QListWidget::ListMode );
+  myISBoundaryPolygons->setSortingEnabled( true );
+
+  myAvailableBoundaryPolygons = new QListWidget( aPage );
+  myAvailableBoundaryPolygons->setSelectionMode( QListWidget::ExtendedSelection );
+  myAvailableBoundaryPolygons->setEditTriggers( QListWidget::NoEditTriggers );
+  myAvailableBoundaryPolygons->setViewMode( QListWidget::ListMode );
+  myAvailableBoundaryPolygons->setSortingEnabled( true );
+
+  //connect( myGroups, SIGNAL( itemSelectionChanged() ), 
+  //  SIGNAL( groupsSelected() ) ); //TODO
+
+  QFrame* aBPFrame = new QFrame( aPage );
+  QGridLayout* aBPLayout = new QGridLayout( aBPFrame );
+  aBPLayout->setMargin( 5 );
+  aBPLayout->setSpacing( 5 );
+  aBPFrame->setLayout( aBPLayout );
+
+  QFrame* aBtnsFrame = new QFrame( aBPFrame );
+  QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
+  aBtnsLayout->setMargin( 5 );
+  aBtnsLayout->setSpacing( 5 );
+  aBtnsFrame->setLayout( aBtnsLayout );
+  QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
+  QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
+
+  // Fill the butons frame with two buttons
+  aBtnsLayout->addWidget( anAddBtn );
+  aBtnsLayout->addWidget( aRemoveBtn );
+  aBtnsLayout->addStretch( 1 );
+
+  QLabel* anIncludedLabelCut = new QLabel( tr( "INCLUDED_BOUNDARY_POLYGONS_CUT" ), aBPFrame );
+
+  QLabel* anAvailableLabel = new QLabel( tr( "AVAILABLE_BOUNDARY_POLYGONS" ), aBPFrame );
+  
+  QLabel* anIncludedLabelIS = new QLabel( tr( "INCLUDED_BOUNDARY_POLYGONS_INCSEL" ) );
+
+  // Fill the objects frame with two lists, two labels and with buttons frame
+  aBPLayout->addWidget( anAvailableLabel, 0, 0, Qt::AlignHCenter );
+  aBPLayout->addWidget( anIncludedLabelCut, 0, 2, Qt::AlignHCenter );
+
+  aBPLayout->addWidget( myAvailableBoundaryPolygons, 1, 0, 3, 1 );
+  aBPLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
+  aBPLayout->addWidget( myBoundaryPolygons, 1, 2 );
+
+  aBPLayout->addWidget( anIncludedLabelIS, 2, 2 );
+
+  aBPLayout->addWidget( myISBoundaryPolygons, 3, 2 );
+
+
+  // Fill the page
+  QGridLayout* aPageLayout = new QGridLayout( aPage );
+  aPageLayout->setMargin( 5 );
+  aPageLayout->setSpacing( 5 );
+  aPageLayout->setVerticalSpacing( 10 );
+  aPageLayout->addWidget( aBPFrame, 0, 0 );
+
+  aPage->setLayout( aPageLayout );
+
+  connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addBoundaryPolygons() ) );
+  connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeBoundaryPolygons() ) );
+
+  return aPage;
+}
+
+
 QWizardPage* HYDROGUI_CalculationDlg::createLandCoverMapPage() {
   QWizardPage* aPage = new QWizardPage( mainFrame() );
   QFrame* aFrame = new QFrame( aPage );
@@ -731,6 +812,70 @@ void HYDROGUI_CalculationDlg::excludeGroups( const QStringList& theObjects )
   moveItems( myGroups, myAvailableGroups, theObjects );
 }
 
+///
+
+void HYDROGUI_CalculationDlg::setAvailableBoundaryPolygons( const QStringList& theBoundaryPolygons, 
+  const QVector<int>& theTypes )
+{
+  myAvailableBoundaryPolygons->clear();
+  myBoundaryPolygons->clear();
+  myISBoundaryPolygons->clear();
+  QString iconStr;
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  int i = 0;
+  foreach( QString aBP, theBoundaryPolygons )
+  {
+    int aBT = theTypes[i];    
+    i++;
+    if (aBT == 1)
+      iconStr = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE1_ICO").toLatin1());
+    else if (aBT == 2)
+      iconStr = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE2_ICO").toLatin1());
+    else if (aBT == 3)
+      iconStr = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE3_ICO").toLatin1());
+    else
+      continue;
+    QPixmap aPM = aResMgr->loadPixmap( "HYDRO", iconStr );
+    QListWidgetItem* item = new QListWidgetItem(QIcon(aPM), aBP);
+    myAvailableBoundaryPolygons->addItem(item);
+  }
+}
+
+QStringList HYDROGUI_CalculationDlg::getSelectedBoundaryPolygons() const
+{
+  return getSelected( myBoundaryPolygons );
+}
+
+QStringList HYDROGUI_CalculationDlg::getSelectedISBoundaryPolygons() const
+{
+  return getSelected( myISBoundaryPolygons );
+}
+
+QStringList HYDROGUI_CalculationDlg::getSelectedAvailableBoundaryPolygons() const
+{
+  return getSelected( myAvailableBoundaryPolygons );
+}
+
+void HYDROGUI_CalculationDlg::includeBoundaryPolygons( const QStringList& theObjects )
+{
+  moveItems( myAvailableBoundaryPolygons, myBoundaryPolygons, theObjects );
+}
+
+void HYDROGUI_CalculationDlg::includeISBoundaryPolygons( const QStringList& theObjects )
+{
+  moveItems( myAvailableBoundaryPolygons, myISBoundaryPolygons, theObjects );
+}
+
+void HYDROGUI_CalculationDlg::excludeBoundaryPolygons( const QStringList& theObjects )
+{
+  moveItems( myBoundaryPolygons, myAvailableBoundaryPolygons, theObjects );
+}
+
+void HYDROGUI_CalculationDlg::excludeISBoundaryPolygons( const QStringList& theObjects )
+{
+  moveItems( myISBoundaryPolygons, myAvailableBoundaryPolygons, theObjects );
+}
+
 /**
   Get creation mode.
   @param theMode the mode
index 6b5a44639c9d80a33394c26cffd47b04bcdfca63..2866b623440101e4729415ba0ea8bf403b57434a 100644 (file)
@@ -69,10 +69,15 @@ public:
   QStringList                getSelectedAvailableGeomObjects() const;
   QStringList                getSelectedGroups() const;
   QStringList                getSelectedAvailableGroups() const;
+  QStringList                getSelectedBoundaryPolygons() const;
+  QStringList                getSelectedISBoundaryPolygons() const;
+  QStringList                getSelectedAvailableBoundaryPolygons() const;
   HYDROGUI_Zone*             getCurrentZone() const;
   
   void                       setAvailableGroups( const QStringList& );
 
+  void                       setAvailableBoundaryPolygons( const QStringList&, const QVector<int>& );
+
   void                       setEditZonesEnabled( const bool theIsEnabled );
 
   HYDROData_ListOfRules      getRules() const;
@@ -85,6 +90,14 @@ public slots:
   void                       excludeGeomObjects( const QStringList& theObjects );
   void                       includeGroups( const QStringList& theObjects );
   void                       excludeGroups( const QStringList& theObjects );
+
+  void                       includeBoundaryPolygons( const QStringList& theObjects );
+  void                       includeISBoundaryPolygons( const QStringList& theObjects );
+
+  void                       excludeBoundaryPolygons( const QStringList& theObjects );
+  void                       excludeISBoundaryPolygons( const QStringList& theObjects );
+
+
   void                       onEmptyName();
   void                       onAlreadyExists( QString theName );
   void                       refreshZonesBrowser();
@@ -122,6 +135,9 @@ signals:
   void                       removeGroups();
   void                       groupsSelected();
 
+  void                       addBoundaryPolygons();
+  void                       removeBoundaryPolygons();
+
   void                       boundarySelected( const QString & theObjName );
   void                       setMergeType( int theMergeType, QString& theBathymetryName );
   void                       createRegion( const QList<SUIT_DataObject*>& theZonesList );
@@ -146,6 +162,8 @@ private:
   
   QWizardPage*               createObjectsPage();
   QWizardPage*               createGroupsPage();
+  QWizardPage*               createBoundaryPolygonsPage();
+
   QWizardPage*               createLandCoverMapPage();
   QWizardPage*               createZonesPage();
   
@@ -169,6 +187,11 @@ private:
   QListWidget*               myAvailableGroups;
   QListWidget*               myGroups;
 
+  QListWidget*               myAvailableBoundaryPolygons;
+  QListWidget*               myBoundaryPolygons;
+  QListWidget*               myISBoundaryPolygons;
+
+
   HYDROGUI_DataBrowser*      myBrowser;
   Handle(HYDROData_CalculationCase) myEditedObject;
   QComboBox*                 myBathymetryChoice;
index 092c97bf3020a24ad6a666be08e2a891e18542d2..739df20fcb81f4ce75dc5bf11039f2ffe6a6844a 100644 (file)
@@ -33,6 +33,7 @@
 #include <HYDROData_Object.h>
 #include <HYDROData_Tool.h>
 #include <HYDROData_StricklerTable.h>
+#include <HYDROData_BCPolygon.h>
 
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewModel.h>
@@ -247,6 +248,9 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
   connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) );
   connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) );
 
+  connect( aPanel, SIGNAL( addBoundaryPolygons() ), SLOT( onAddBoundaryPolygons() ) );
+  connect( aPanel, SIGNAL( removeBoundaryPolygons() ), SLOT( onRemoveBoundaryPolygons() ) );
+
   connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
 
   connect( aPanel, SIGNAL( ruleChanged( bool& ) ), SLOT( onRuleChanged( bool& ) ) );
@@ -816,6 +820,10 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
     setAvailableGroups();
   }
   else if( theIndex==2 )
+  {
+    setAvailableBoundaryPolygons();
+  }
+  else if( theIndex==3 )
   {
     // Land cover map panel
      HYDROGUI_CalculationDlg* aPanel = 
@@ -920,7 +928,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
     closePreview( false );
     createPreview( true );
   }
-  else if( theIndex==3 )
+  else if( theIndex==4 )
   {
     HYDROGUI_CalculationDlg* aPanel = 
       ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
@@ -1013,7 +1021,7 @@ void HYDROGUI_CalculationOp::onHideZones( const int theIndex )
     closePreview( false );
     createPreview( false );
   }
-  if( theIndex==2 )
+  if( theIndex==3 )
   {
     setLandCoverMapVisible( true );
 
@@ -1023,7 +1031,7 @@ void HYDROGUI_CalculationOp::onHideZones( const int theIndex )
     // Hide zones
     setZonesVisible( false );
   }
-  else if( theIndex==3 )
+  else if( theIndex==4 )
   {
     AssignDefaultZonesColors();
 
@@ -1439,6 +1447,110 @@ void HYDROGUI_CalculationOp::onRemoveGroups()
   aPanel->excludeGroups( aSelectedList );
 }
 
+
+void HYDROGUI_CalculationOp::setAvailableBoundaryPolygons()
+{
+  HYDROGUI_CalculationDlg* aPanel = ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+
+  HYDROData_Iterator anIter( doc(), KIND_BC_POLYGON );
+  Handle(HYDROData_BCPolygon) aBCP;
+  QStringList aNames;
+  QVector<int> aTypes; 
+  for (;anIter.More(); anIter.Next())
+  {
+    aBCP = Handle(HYDROData_BCPolygon)::DownCast( anIter.Current() );
+    aNames.append(aBCP->GetName());
+    aTypes.append(aBCP->GetBoundaryType());
+  }
+  HYDROData_SequenceOfObjects aBCPSeq = myEditedObject->GetBoundaryPolygons();
+
+  QStringList aListCut, aListIS;
+  for (int i=1; i<=aBCPSeq.Size();i++)
+  {
+    int type = Handle(HYDROData_BCPolygon)::DownCast(aBCPSeq(i))->GetBoundaryType();
+    if (type == 1)
+      aListCut << aBCPSeq(i)->GetName();
+    else if (type == 2 || type == 3)
+      aListIS << aBCPSeq(i)->GetName();
+  }
+
+  aPanel->setAvailableBoundaryPolygons( aNames, aTypes );
+  aPanel->includeBoundaryPolygons( aListCut );
+  aPanel->includeISBoundaryPolygons( aListIS );
+}
+
+void HYDROGUI_CalculationOp::onRemoveBoundaryPolygons()
+{
+  HYDROGUI_CalculationDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  QStringList aSelectedListCut = aPanel->getSelectedBoundaryPolygons();
+  QStringList aSelectedListIS = aPanel->getSelectedISBoundaryPolygons();
+
+  if ( aSelectedListCut.isEmpty() && aSelectedListIS.isEmpty() )
+    return;
+
+  for (int i = 0; i < aSelectedListCut.length(); i++)
+  {
+    Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast( 
+      HYDROGUI_Tool::FindObjectByName( module(), aSelectedListCut.at(i) ) );
+    if ( aBCPoly.IsNull() )
+      continue;
+    myEditedObject->RemoveBoundaryPolygon( aBCPoly );
+  }
+
+  for (int i = 0; i < aSelectedListIS.length(); i++)
+  {
+    Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast( 
+      HYDROGUI_Tool::FindObjectByName( module(), aSelectedListIS.at(i) ) );
+    if ( aBCPoly.IsNull() )
+      continue;
+    myEditedObject->RemoveBoundaryPolygon( aBCPoly );
+  }
+
+  aPanel->excludeBoundaryPolygons( aSelectedListCut );
+  aPanel->excludeISBoundaryPolygons( aSelectedListIS );
+}
+
+void HYDROGUI_CalculationOp::onAddBoundaryPolygons()
+{
+  HYDROGUI_CalculationDlg* aPanel = ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  QStringList aSelectedList = aPanel->getSelectedAvailableBoundaryPolygons();
+  if ( aSelectedList.isEmpty())
+    return;
+
+  QStringList anAddedListCut, anAddedListIS;
+  for (int i = 0; i < aSelectedList.length(); i++)
+  {
+    Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast( 
+      HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
+    if ( aBCPoly.IsNull() )
+      continue;
+   
+   if ( myEditedObject->AddBoundaryPolygon( aBCPoly ) )
+   {
+     QString aName = aBCPoly->GetName();
+     int type = aBCPoly->GetBoundaryType(); 
+     if (type == 1)
+       anAddedListCut.append(aName);
+     else if (type == 2 || type == 3)
+       anAddedListIS.append(aName);
+   }
+
+  }
+
+  if ( !anAddedListCut.isEmpty() )
+    aPanel->includeBoundaryPolygons(anAddedListCut);
+  if ( !anAddedListIS.isEmpty() )
+    aPanel->includeISBoundaryPolygons(anAddedListIS);
+}
+
 void HYDROGUI_CalculationOp::onChangeMode( int theMode )
 {
   HYDROGUI_CalculationDlg* aPanel = 
index 2f46cb393ccc9f276c96770099300886f409b1cd..8eb18c1463deed01f16d76e1f63768623db0b2d2 100644 (file)
@@ -54,6 +54,8 @@ protected:
 
   void setAvailableGroups();
 
+  void setAvailableBoundaryPolygons();
+
 protected slots:
 
   /**
@@ -80,6 +82,10 @@ protected slots:
    */
   void                            onRemoveGroups();
 
+  void                            onAddBoundaryPolygons();
+
+  void                            onRemoveBoundaryPolygons();
+
   /**
    * Set the given bathymetry/type merge type to the current zone.
    */
index 63d4252c76e48e41ec8561d70e867760007440ba..fc303d0c33a3307ee11b507bfb8c3aea56ae69ad 100644 (file)
@@ -46,6 +46,7 @@
 #include <HYDROData_Stream.h>
 #include <HYDROData_StricklerTable.h>
 #include <HYDROData_LandCoverMap.h>
+#include <HYDROData_BCPolygon.h>
 
 #include <CAM_Module.h>
 #include <CAM_Study.h>
@@ -294,6 +295,9 @@ void HYDROGUI_DataModel::update( const int theStudyId )
   // OBSTACLES
   LightApp_DataObject* anObstaclesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_OBSTACLE ).toLatin1() ) );
 
+  //BC Polygons
+  LightApp_DataObject* aBCPolygonRootObj = createObject( aNewRootObj, tr( partitionName( KIND_BC_POLYGON ).toLatin1() ) );
+
   // STRICKLER TABLES
   LightApp_DataObject* aStricklerTablesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_STRICKLER_TABLE ).toLatin1() ) );
 
@@ -472,6 +476,16 @@ void HYDROGUI_DataModel::update( const int theStudyId )
             obj = createObject( aVisualStateRootObj, aVisualStateObj );
           }
 
+          break;
+        }
+        case KIND_BC_POLYGON:
+        {
+          Handle(HYDROData_BCPolygon) aBCPolygonObj =
+            Handle(HYDROData_BCPolygon)::DownCast( anObj );
+          if( !aBCPolygonObj.IsNull() ) {
+            obj = createObject( aBCPolygonRootObj, aBCPolygonObj );
+          }
+
           break;
         }
       }
@@ -794,6 +808,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
     case KIND_STRICKLER_TABLE:   return "STRICKLER_TABLES";
     case KIND_LAND_COVER_MAP:    return "LAND_COVER_MAPS";
     case KIND_REGION:            return "REGIONS";
+    case KIND_BC_POLYGON:        return "BOUNDARY_POLYGONS";
     default: break;
   }
   return QString();
@@ -817,7 +832,8 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*
                     aKind == KIND_SHAPES_GROUP || aKind == KIND_SPLIT_GROUP || aKind == KIND_ZONE ||
                     aKind == KIND_IMMERSIBLE_ZONE || aKind == KIND_REGION || aKind == KIND_BATHYMETRY ||
                     aKind == KIND_OBSTACLE || aKind == KIND_STREAM || aKind == KIND_CHANNEL ||
-                    aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D || aKind == KIND_LAND_COVER_MAP;
+                    aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D || aKind == KIND_LAND_COVER_MAP ||
+                    aKind == KIND_BC_POLYGON;
   if ( !visibility )
   {
     Handle(HYDROData_Profile) aProfObj = Handle(HYDROData_Profile)::DownCast( theModelObject );
@@ -1172,7 +1188,18 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
     HYDROData_SequenceOfObjects aPolylines = aLandCoverMapObj->GetPolylines();
     buildObjectPartition( aGuiObj, aPolylines, tr( "LAND_COVER_POLYLINES" ), true );*/
   }
-  
+  else if ( anObjectKind == KIND_BC_POLYGON )
+  {
+    Handle(HYDROData_BCPolygon) aBCObj =
+      Handle(HYDROData_BCPolygon)::DownCast( aDataObj );
+
+    LightApp_DataObject* aPolylineSect = 
+      createObject( aGuiObj, tr( "BC_POLYGON_POLYLINE" ), aGuiObj->entry() );
+
+    Handle(HYDROData_PolylineXY) aPolyline = aBCObj->GetPolyline();
+    if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
+      createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
+  }
   HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
   if( aModule )
     aModule->enableLCMActions();
index a616edec298e9d015af926a8b781b1eea61e37f2..f68c26e692f4999d207bfd8e927c067ed1a6b0d1 100644 (file)
@@ -23,6 +23,7 @@
 #include <HYDROData_Object.h>
 #include <HYDROData_ArtificialObject.h>
 #include <HYDROData_NaturalObject.h>
+#include <HYDROData_BCPolygon.h>
 
 #include <TDF_Tool.hxx>
 
@@ -198,6 +199,19 @@ QPixmap HYDROGUI_DataObject::icon( const int theId ) const
         painter.end();
         return qpmD;
       }
+      else if (anObjectKind == KIND_BC_POLYGON)
+      {
+        Handle(HYDROData_BCPolygon) aBCObj = Handle(HYDROData_BCPolygon)::DownCast( aDataObject );
+        int aBT = aBCObj->GetBoundaryType();
+        if (aBT == 1)
+          anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE1_ICO").toLatin1());
+        else if (aBT == 2)
+          anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE2_ICO").toLatin1());
+        else if (aBT == 3)
+          anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE3_ICO").toLatin1());
+        else
+          anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE_UNDEF_ICO").toLatin1());
+      }
       else
         anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() );
     }
diff --git a/src/HYDROGUI/HYDROGUI_ImportBCPolygonOp.cxx b/src/HYDROGUI/HYDROGUI_ImportBCPolygonOp.cxx
new file mode 100644 (file)
index 0000000..8d0c615
--- /dev/null
@@ -0,0 +1,142 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ImportBCPolygonOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_Tool2.h"
+#include <HYDROData_PolylineXY.h>
+
+#include <HYDROData_BCPolygon.h>
+#include <HYDROGUI_DataObject.h>
+
+#include <HYDROGUI_ImportPolylineOp.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_FileDlg.h>
+#include <LightApp_Application.h>
+
+#include <QApplication>
+#include <QFile>
+#include <QFileInfo>
+#include <SUIT_MessageBox.h>
+
+
+HYDROGUI_ImportBCPolygonOp::HYDROGUI_ImportBCPolygonOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+  setName( tr( "IMPORT_BC_POLYGON" ) );
+}
+
+HYDROGUI_ImportBCPolygonOp::~HYDROGUI_ImportBCPolygonOp()
+{
+}
+
+void HYDROGUI_ImportBCPolygonOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  myFileDlg = new SUIT_FileDlg( module()->getApp()->desktop(), true );
+  myFileDlg->setWindowTitle( getName() );
+  myFileDlg->setFileMode( SUIT_FileDlg::ExistingFiles );
+  myFileDlg->setNameFilter( tr("BC_POLYGON_FILTER") );
+
+  connect( myFileDlg, SIGNAL( accepted() ), this, SLOT( onApply() ) );
+  connect( myFileDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
+
+  myFileDlg->exec();
+}
+
+
+bool HYDROGUI_ImportBCPolygonOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
+                                           QStringList& theBrowseObjectsEntries )
+{
+  if ( !myFileDlg )
+  {
+    //abort();
+    return false;
+  }
+
+  QStringList aFileNames = myFileDlg->selectedFiles();
+  
+  QApplication::setOverrideCursor( Qt::WaitCursor );  
+  //startDocOperation();
+
+   NCollection_Sequence<Handle(HYDROData_Entity)> importedEnts = 
+     HYDROGUI_ImportPolylineOp::ImportPolyOp(aFileNames, doc(), module(), 
+     HYDROData_ShapeFile::ImportShapeType_Polygon);
+
+   for (int i=1;i<=importedEnts.Size();i++ )
+   {
+      Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast(importedEnts(i));
+      if (aPolylineXY.IsNull())
+        continue;
+      TopoDS_Shape aTopSh = HYDROData_BCPolygon::generateTopShape(aPolylineXY);
+      if (aTopSh.IsNull())
+        continue;
+
+      //get boundary type from DBF
+      QStringList aDBFTableList;
+      aPolylineXY->GetDBFInfo(aDBFTableList);
+      QVector<QString> aDBFTable = aDBFTableList.toVector();
+      int nbs = aDBFTable.size();
+      QString aBTypeStr;
+      for (int i = 0; i < nbs / 2; i++)
+        if (aDBFTable[i] == "type")
+        {
+          aBTypeStr = aDBFTable[nbs / 2 + i];
+          break;
+        }
+
+      int aBTypeVal = 0;
+      bool Ok = false;
+      aBTypeVal = aBTypeStr.toInt(&Ok);
+      if (!Ok)
+        aBTypeVal = 0;
+
+      QString aPolyXYName = aPolylineXY->GetName();
+      Handle(HYDROData_BCPolygon) aBCObj = Handle(HYDROData_BCPolygon)::DownCast( doc()->CreateObject( KIND_BC_POLYGON ) );
+      aBCObj->SetName( "BP_" + aPolyXYName );
+      aBCObj->SetBoundaryType(aBTypeVal);
+  
+      aBCObj->SetFillingColor( aBCObj->DefaultFillingColor() );
+      aBCObj->SetBorderColor( aBCObj->DefaultBorderColor() );
+      aBCObj->SetPolyline( aPolylineXY );
+      aBCObj->Update(aTopSh);
+
+      module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aBCObj, true );
+      QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aBCObj );
+      theBrowseObjectsEntries.append( anEntry );
+      module()->setIsToUpdate( aBCObj );
+   }
+  if (!aFileNames.empty())
+  {
+    //commitDocOperation();
+    //commit();
+    //module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init | UF_OCCViewer );
+    theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
+  }
+  //else
+  //  abort();
+  
+  QApplication::restoreOverrideCursor();
+  return true;
+}
diff --git a/src/HYDROGUI/HYDROGUI_ImportBCPolygonOp.h b/src/HYDROGUI/HYDROGUI_ImportBCPolygonOp.h
new file mode 100644 (file)
index 0000000..60bb1c9
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_IMPORTBCPOLYGON_H
+#define HYDROGUI_IMPORTBCPOLYGON_H
+
+#include "HYDROGUI_Operation.h"
+#include <vector>
+
+#include <NCollection_Sequence.hxx>
+
+class SUIT_FileDlg;
+class HYDROData_Entity;
+
+class HYDROGUI_ImportBCPolygonOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ImportBCPolygonOp( HYDROGUI_Module* theModule );
+  virtual ~HYDROGUI_ImportBCPolygonOp();
+
+protected:
+  virtual void startOperation();
+ // virtual void onApply();
+    virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg,
+                                           QStringList& theBrowseObjectsEntries );
+  void UpdateView( NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities);
+
+private:
+  SUIT_FileDlg* myFileDlg;
+};
+
+#endif
index 257352f1b1567c14699399e8aa1b0d80b2a72de5..95c1a1bcb13321d095c8427b6a12a211401c4d0a 100644 (file)
@@ -66,19 +66,11 @@ void HYDROGUI_ImportPolylineOp::startOperation()
   myFileDlg->exec();
 }
 
-void HYDROGUI_ImportPolylineOp::onApply()
+NCollection_Sequence<Handle(HYDROData_Entity)> HYDROGUI_ImportPolylineOp::ImportPolyOp(
+  const QStringList& aFileNames, Handle(HYDROData_Document) theDocument,
+  HYDROGUI_Module* module, HYDROData_ShapeFile::ImportShapeType theShapeTypesToImport)
 {
-  if ( !myFileDlg )
-  {
-    abort();
-    return;
-  }
-
-  QStringList aFileNames = myFileDlg->selectedFiles();
-  
-  QApplication::setOverrideCursor( Qt::WaitCursor );  
-  startDocOperation();
-
+  NCollection_Sequence<Handle(HYDROData_Entity)> importedEntities;
   foreach (QString aFileName, aFileNames) 
   {
     if ( aFileName.isEmpty() )
@@ -91,7 +83,8 @@ void HYDROGUI_ImportPolylineOp::onApply()
       HYDROData_ShapeFile anImporter;
       NCollection_Sequence<Handle(HYDROData_Entity)> theEntities;
       int aShapeTypeOfFile = -1;
-      int aStat = anImporter.ImportPolylines(doc(), aFileName, theEntities, aShapeTypeOfFile ); 
+      int aStat = anImporter.ImportPolylines(theDocument, aFileName, theEntities, 
+        aShapeTypeOfFile, theShapeTypesToImport ); 
       if (aStat == 1 || aStat == 2)
       {
         //try to import DBF
@@ -116,7 +109,7 @@ void HYDROGUI_ImportPolylineOp::onApply()
               }
 
               if (indNameAttrFound != -1)
-                bUseNameAttrFound = SUIT_MessageBox::question( module()->getApp()->desktop(),
+                bUseNameAttrFound = SUIT_MessageBox::question( module->getApp()->desktop(),
                                tr( "IMPORT_POLYLINE" ),
                                tr( "IMPORT_POLYLINE_USE_NAME_ATTR" ),
                                QMessageBox::Yes | QMessageBox::No, 
@@ -167,12 +160,13 @@ void HYDROGUI_ImportPolylineOp::onApply()
         }        
       }
       if (aStat == 1)
-        UpdateView(theEntities);
+        UpdateView(module, theEntities);
       else if (aStat == 2)
       {
-        UpdateView(theEntities);
-        SUIT_MessageBox::information(module()->getApp()->desktop(), 
-          tr( "IMPORT_POLYLINE" ), "Contour of the polygon(s) have been imported as polyline(s)");
+        UpdateView(module, theEntities);
+        if (theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All) //if other flag = > no need to show this messagebox
+          SUIT_MessageBox::information(module->getApp()->desktop(), 
+            tr( "IMPORT_POLYLINE" ), "Contour of the polygon(s) have been imported as polyline(s)");
       }
       else
       {
@@ -183,10 +177,29 @@ void HYDROGUI_ImportPolylineOp::onApply()
           aMess += "Cannot open SHX file";
         else 
           aMess += "The shape type of file is " + anImporter.GetShapeTypeName(aShapeTypeOfFile);
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_POLYLINE" ), aMess);
+        SUIT_MessageBox::warning( module->getApp()->desktop(), tr( "IMPORT_POLYLINE" ), aMess);
       }
+      importedEntities.Append(theEntities);
     }
   }
+  return importedEntities;
+}
+
+void HYDROGUI_ImportPolylineOp::onApply()
+{
+  if ( !myFileDlg )
+  {
+    abort();
+    return;
+  }
+
+  QStringList aFileNames = myFileDlg->selectedFiles();
+  
+  QApplication::setOverrideCursor( Qt::WaitCursor );  
+  startDocOperation();
+
+  ImportPolyOp(aFileNames, doc(), module(), HYDROData_ShapeFile::ImportShapeType_All);
   if (!aFileNames.empty())
   {
     commitDocOperation();
@@ -199,16 +212,16 @@ void HYDROGUI_ImportPolylineOp::onApply()
   QApplication::restoreOverrideCursor();
 }
 
-void HYDROGUI_ImportPolylineOp::UpdateView( NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities)
+void HYDROGUI_ImportPolylineOp::UpdateView( HYDROGUI_Module* module, NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities)
 {
-  size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
+  size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module );
   if ( anActiveViewId == 0 )
-    anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() );
+    anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( module );
 
   for (int i = 1; i <= anEntities.Size() ; i++)
   {
     anEntities(i)->Update();
-    module()->setObjectVisible( anActiveViewId, anEntities(i), true );
-    module()->setIsToUpdate( anEntities(i) );
+    module->setObjectVisible( anActiveViewId, anEntities(i), true );
+    module->setIsToUpdate( anEntities(i) );
   }
 }
index 23cb0b87156887e0d645cf4e9c2d51d9187e0b63..695bff4dc1ebaef00503925657d01fe4566f9027 100644 (file)
@@ -23,6 +23,7 @@
 #include <vector>
 
 #include <NCollection_Sequence.hxx>
+#include <HYDROData_ShapeFile.h>
 
 class SUIT_FileDlg;
 class HYDROData_Entity;
@@ -33,12 +34,20 @@ class HYDROGUI_ImportPolylineOp : public HYDROGUI_Operation
 
 public:
   HYDROGUI_ImportPolylineOp( HYDROGUI_Module* theModule );
+
   virtual ~HYDROGUI_ImportPolylineOp();
 
+  static NCollection_Sequence<Handle(HYDROData_Entity)> ImportPolyOp(const QStringList& aFileNames, 
+                                                                     Handle(HYDROData_Document) theDocument,
+                                                                     HYDROGUI_Module* module, 
+                                                                     HYDROData_ShapeFile::ImportShapeType theShapeTypesToImport);
+
 protected:
+
   virtual void startOperation();
   virtual void onApply();
-  void UpdateView( NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities);
+
+  static void UpdateView( HYDROGUI_Module* module, NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities);
 
 private:
   SUIT_FileDlg* myFileDlg;
index d51503a4a97b38ad4068bf45e9a46748a9fc46e6..f9bdea57ac2d9310178b7d135e9bb59d22673a77 100644 (file)
@@ -397,6 +397,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsObjectCanBeColored = false;
   bool isRoot = false;
   bool isStreamHasBottom = false;
+  bool anIsBCPolygon = false;
 
   SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
   SUIT_DataOwnerPtrList anOwners;
@@ -511,6 +512,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsStricklerTable = true;
       else if( anObjectKind == KIND_LAND_COVER_MAP )
         anIsLandCoverMap = true;
+      else if (anObjectKind == KIND_BC_POLYGON)
+        anIsBCPolygon = true;
       else if( anObjectKind == KIND_STREAM )
       {
         anIsStream = true;
@@ -589,6 +592,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       case KIND_VISUAL_STATE:
         theMenu->addAction( action( SaveVisualStateId ) );
         break;
+      case KIND_BC_POLYGON:
+        theMenu->addAction( action( ImportBCPolygonId ) );
+        break;
       }
       theMenu->addSeparator();
     }
@@ -752,6 +758,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       }
       else if (anIsZone)
         theMenu->addAction( action( ZoneSetColorId ) );
+      else if (anIsBCPolygon)
+        theMenu->addAction( action( SetBoundaryTypePolygonId ) );
 
       if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
       {
@@ -801,7 +809,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       anIsImmersibleZone || anIsZone || anIsRegion ||
       anIsBathymetry || anIsObstacle || anIsStream ||
       anIsChannel || anIsDigue || anIsDummyObject3D ||
-      anIsValidProfile || anIsGroup || anIsLandCoverMap )
+      anIsValidProfile || anIsGroup || anIsLandCoverMap ||
+      anIsBCPolygon)
     {
       if( anIsHiddenInSelection )
         theMenu->addAction( action( ShowId ) );
index b5d318aae43de52c4cb3b593fe193fe764a576ef..82402e07bd659dea1da3ea3a903b0994ea7637e7 100644 (file)
@@ -59,6 +59,7 @@
 #include "HYDROGUI_RiverBottomOp.h"
 #include "HYDROGUI_ProfileInterpolateOp.h"
 #include "HYDROGUI_RecognizeContoursOp.h"
+#include <HYDROGUI_ImportBCPolygonOp.h>
 #include "HYDROGUI_SubmersibleOp.h"
 #include "HYDROGUI_StricklerTableOp.h"
 #include "HYDROGUI_DuplicateOp.h"
@@ -76,6 +77,7 @@
 #include "HYDROGUI_PolylineStyleOp.h"
 #include "HYDROGUI_ZoneSetColorOp.h"
 #include <HYDROGUI_ShowAttrPolyOp.h>
+#include <HYDROGUI_SetBoundaryTypePolygonOp.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_Obstacle.h>
 #include <HYDROData_SplitToZonesTool.h>
@@ -145,6 +147,8 @@ void HYDROGUI_Module::createActions()
   createAction( ExportSinusXId, "EXPORT_SINUSX", "EXPORT_SINUSX_ICO" );
   createAction( ImportLandCoverMapId, "IMPORT_LANDCOVER_MAP", "IMPORT_LANDCOVER_MAP_ICO" );
 
+  createAction( ImportBCPolygonId, "IMPORT_BC_POLYGON", "IMPORT_BC_POLYGON_ICO" );
+
   createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" );
   createAction( EditPolylineId, "EDIT_POLYLINE", "EDIT_POLYLINE_ICO" ); 
 
@@ -254,6 +258,7 @@ void HYDROGUI_Module::createActions()
   createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" );
   createAction( ZoneSetColorId, "ZONE_SET_COLOR" );
   createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" );
+  createAction( SetBoundaryTypePolygonId, "SET_BOUNDARY_TYPE_POLYGON" );
 }
 
 void HYDROGUI_Module::createMenus()
@@ -348,6 +353,8 @@ void HYDROGUI_Module::createToolbars()
   createTool( ExportSinusXId, aToolBar );
   createTool( ImportLandCoverMapId, aToolBar );
 
+  createTool( ImportBCPolygonId, aToolBar );
+
   createTool( ImportBathymetryId, aToolBar );
   createTool( CreatePolylineId, aToolBar );
   createTool( CreatePolyline3DId, aToolBar );
@@ -621,6 +628,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case ExportSinusXId:
     anOp = new HYDROGUI_ExportSinusXOp( aModule );
     break;
+  case ImportBCPolygonId:
+    anOp = new HYDROGUI_ImportBCPolygonOp( aModule );
+    break;
   case ObserveImageId:
     anOp = new HYDROGUI_ObserveImageOp( aModule );
     break;
@@ -803,6 +813,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case ShowAttrPolylinesId:
     anOp = new HYDROGUI_ShowAttrPolyOp( aModule );
     break;
+  case SetBoundaryTypePolygonId:
+    anOp = new HYDROGUI_SetBoundaryTypePolygonOp( aModule );
+    break;
   case LandCoverScalarMapModeOnId:
   case LandCoverScalarMapModeOffId:
     anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
index 42e9ab9d37aa98dd2fcf20d84cde5da16825a059..e17c2d28a74532081db34a54cc6f65302e0160f3 100644 (file)
@@ -114,7 +114,8 @@ enum OperationId
   ImportPolylineId,
   ImportSinusXId,
   ExportSinusXId,
-    
+  ImportBCPolygonId, 
+  
   ExportToShapeFileID,
   ImportLandCoverMapId,
 
@@ -148,7 +149,8 @@ enum OperationId
   BathymetryRescaleDefaultId,
   RegenerateRegionColorsId,
   ShowHideArrows,
-  ZoneSetColorId
+  ZoneSetColorId,
+  SetBoundaryTypePolygonId
 };
 
 #endif
diff --git a/src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonDlg.cxx b/src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonDlg.cxx
new file mode 100644 (file)
index 0000000..826beb2
--- /dev/null
@@ -0,0 +1,94 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_SetBoundaryTypePolygonDlg.h"
+#include <QVBoxLayout>
+#include <QPushButton>
+#include <QFrame>
+#include <QLabel>
+#include <QFrame>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <QListWidgetItem>
+
+HYDROGUI_SetBoundaryTypePolygonDlg::HYDROGUI_SetBoundaryTypePolygonDlg( QWidget* theParent, int theType )
+  : QDialog( theParent )
+{
+  QVBoxLayout* aMainLayout = new QVBoxLayout( this );
+  aMainLayout->setMargin( 5 );
+  aMainLayout->setSpacing( 5 );
+
+  QFrame* aBTFrame = new QFrame( this );
+  QLabel* aBoundaryLabel = new QLabel( tr( "BOUNDARY_TYPE" ), aBTFrame );
+  myBTBox = new QComboBox( aBTFrame );
+  myBTBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  QStringList Types;
+  Types << QObject::tr( QString("HYDRO_BC_POLYGON_TYPE1_ICO").toLatin1()) <<
+    QObject::tr( QString("HYDRO_BC_POLYGON_TYPE2_ICO").toLatin1()) <<
+    QObject::tr( QString("HYDRO_BC_POLYGON_TYPE3_ICO").toLatin1());
+
+  myBTBox->addItem(QIcon( aResMgr->loadPixmap( "HYDRO", Types[0])), tr( "CUT_TOOL" ));
+  myBTBox->addItem(QIcon( aResMgr->loadPixmap( "HYDRO", Types[1])), tr( "INCLUDE_TOOL" ));
+  myBTBox->addItem(QIcon( aResMgr->loadPixmap( "HYDRO", Types[2])), tr( "SELECTION_TOOL" ));
+
+  if (theType != 1 && theType != 2 && theType != 3)
+    theType = -1;
+  myBTBox->setCurrentIndex(theType - 1);
+
+  QBoxLayout* aColorLayout = new QHBoxLayout( aBTFrame );
+  aColorLayout->setMargin( 10 );
+  aColorLayout->setSpacing( 5 );
+  aColorLayout->addWidget( aBoundaryLabel );
+  aColorLayout->addWidget( myBTBox );
+
+  aMainLayout->addWidget( aBTFrame );
+
+  // Buttons
+  QPushButton* anOkButton = new QPushButton( tr( "OK" ), this );
+  anOkButton->setDefault( true ); 
+  QPushButton* aCancelButton = new QPushButton( tr( "CANCEL" ), this );
+  aCancelButton->setAutoDefault( true );
+
+  QHBoxLayout* aButtonsLayout = new QHBoxLayout;
+  aButtonsLayout->setMargin( 5 );
+  aButtonsLayout->setSpacing( 5 );
+  aButtonsLayout->addWidget( anOkButton );
+  aButtonsLayout->addStretch();
+  aButtonsLayout->addWidget( aCancelButton );
+
+  aMainLayout->addStretch();
+  aMainLayout->addLayout( aButtonsLayout );
+
+  setLayout( aMainLayout );  
+
+  connect( anOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
+  connect( aCancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
+}
+
+int HYDROGUI_SetBoundaryTypePolygonDlg::GetCurrentType()
+{
+  return myBTBox->currentIndex();
+}
+
+HYDROGUI_SetBoundaryTypePolygonDlg::~HYDROGUI_SetBoundaryTypePolygonDlg()
+{
+}
+
+
diff --git a/src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonDlg.h b/src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonDlg.h
new file mode 100644 (file)
index 0000000..c8820be
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_SETBOUNDARYTYPEPOLYGONDLG_H
+#define HYDROGUI_SETBOUNDARYTYPEPOLYGONDLG_H
+
+#include <QComboBox>
+#include <QDialog>
+
+class HYDROGUI_SetBoundaryTypePolygonDlg : public QDialog
+{
+  Q_OBJECT
+
+public:
+
+  HYDROGUI_SetBoundaryTypePolygonDlg( QWidget* theParent, int theType );
+
+  virtual ~HYDROGUI_SetBoundaryTypePolygonDlg();
+
+  int GetCurrentType();
+  
+private:
+
+  QComboBox* myBTBox;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonOp.cxx b/src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonOp.cxx
new file mode 100644 (file)
index 0000000..eba2662
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_SetBoundaryTypePolygonOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+
+#include <HYDROData_Object.h>
+#include <HYDROData_BCPolygon.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <SUIT_Desktop.h>
+#include <HYDROGUI_Tool2.h>
+#include <HYDROGUI_SetBoundaryTypePolygonDlg.h>
+#include <SUIT_MessageBox.h>
+#include <HYDROGUI_UpdateFlags.h>
+
+HYDROGUI_SetBoundaryTypePolygonOp::HYDROGUI_SetBoundaryTypePolygonOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule ),
+  mySetBTDlg( 0 )
+{
+  setName( tr( "SET_BOUNDARY_TYPE_POLYGON" ) );
+}
+
+HYDROGUI_SetBoundaryTypePolygonOp::~HYDROGUI_SetBoundaryTypePolygonOp()
+{
+}
+
+void HYDROGUI_SetBoundaryTypePolygonOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects(module());
+  myBCP = Handle(HYDROData_BCPolygon)::DownCast(aSeq(1)); 
+
+  int bType = myBCP->GetBoundaryType();
+
+  mySetBTDlg = new HYDROGUI_SetBoundaryTypePolygonDlg( module()->getApp()->desktop(), bType );
+  mySetBTDlg->setModal( true );
+  mySetBTDlg->setWindowTitle(getName());
+
+  // Connect the dialog to operation slots
+  connect( mySetBTDlg, SIGNAL( accepted() ), this, SLOT( onApply()  ) );
+  connect( mySetBTDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
+  
+  mySetBTDlg->exec();
+}
+
+ bool HYDROGUI_SetBoundaryTypePolygonOp::processApply( int& theUpdateFlags,
+                                        QString& theErrorMsg,
+                                        QStringList& theBrowseObjectsEntries )
+{
+  if ( !mySetBTDlg )
+    return false;
+
+  int aType = mySetBTDlg->GetCurrentType();
+
+  myBCP->SetBoundaryType( aType + 1 );
+  myBCP->SetFillingColor( myBCP->DefaultFillingColor() );
+  myBCP->SetBorderColor( myBCP->DefaultBorderColor() );
+    
+  module()->setIsToUpdate( myBCP );
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced;  
+
+  return true;
+}
diff --git a/src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonOp.h b/src/HYDROGUI/HYDROGUI_SetBoundaryTypePolygonOp.h
new file mode 100644 (file)
index 0000000..7b4d2a8
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_SETBOUNDARYTYPEPOLYGONOP_H
+#define HYDROGUI_SETBOUNDARYTYPEPOLYGONOP_H
+
+#include "HYDROGUI_Operation.h"
+#include <HYDROData_Entity.h>
+
+class HYDROData_BCPolygon;
+class HYDROGUI_SetBoundaryTypePolygonDlg;
+
+class HYDROGUI_SetBoundaryTypePolygonOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_SetBoundaryTypePolygonOp( HYDROGUI_Module* theModule );
+
+  virtual ~HYDROGUI_SetBoundaryTypePolygonOp();
+
+  bool processApply( int& theUpdateFlags,
+                     QString& theErrorMsg,
+                     QStringList& theBrowseObjectsEntries );
+
+protected:
+  virtual void startOperation();
+
+private:
+  HYDROGUI_SetBoundaryTypePolygonDlg* mySetBTDlg;
+
+  Handle(HYDROData_BCPolygon) myBCP;
+};
+
+#endif
\ No newline at end of file
index 36df440ae9e560501645f7ee652419bcd20f8979..27568465b9f153e1bde9a5d0b206f4b8f628b01b 100644 (file)
@@ -25,6 +25,7 @@
 #include <HYDROData_Document.h>
 #include <HYDROData_DummyObject3D.h>
 #include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_BCPolygon.h>
 #include <HYDROData_Obstacle.h>
 #include <HYDROData_PolylineXY.h>
 #include <HYDROData_Polyline3D.h>
@@ -303,6 +304,35 @@ void HYDROGUI_Shape::update( bool isUpdateViewer,
 
       setShape( aCompound, false, false );  
     }
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_BCPolygon) ) )
+    {
+      Handle(HYDROData_BCPolygon) aBCObj = Handle(HYDROData_BCPolygon)::DownCast( myObject );
+
+      TopoDS_Shape aBCShape = aBCObj->GetTopShape();
+      if ( !aBCShape.IsNull() ) 
+      {
+        if ( aBCShape.ShapeType() == TopAbs_FACE ) 
+        {
+          TopoDS_Face aBCFace = TopoDS::Face( aBCShape );
+          setFace( aBCFace, false, false, "" );
+        } 
+        else 
+        {
+          myTopoShape = aBCShape;
+          myDisplayMode = AIS_Shaded;
+          buildShape();
+          updateShape( false, false );
+        }
+      }
+
+      QColor aFillingColor = aBCObj->GetFillingColor();
+      QColor aBorderColor = aBCObj->GetBorderColor();
+      aFillingColor.setAlpha(175);
+
+      setFillingColor( aFillingColor, false, false );
+      setBorderColor( aBorderColor, false, false );
+    }
+
   }
  
   if ( myShapes.empty() || !isVisible() )
index 3dda8c6bd2ad89fceb4254dfae98dd670bd5b927..a7b684ff76b71f5f1e94b54b08eda6d26a1c457d 100644 (file)
@@ -110,6 +110,7 @@ bool HYDROGUI_Tool::IsObjectHasPresentation( const Handle(HYDROData_Entity)& the
          anObjectKind == KIND_DIGUE ||
          anObjectKind == KIND_DUMMY_3D || 
          anObjectKind == KIND_BATHYMETRY ||
+         anObjectKind == KIND_BC_POLYGON ||
          anObjectKind == KIND_LAND_COVER_MAP
 #ifdef DEB_GROUPS
          || anObjectKind == KIND_SHAPES_GROUP ||
index af8b9bf89502ebdaa90f3363c142c8ef10265665..487cc4703342558d7999fd18071161ace5bd69b1 100644 (file)
@@ -24,6 +24,7 @@
 #include <HYDROData_DummyObject3D.h>
 #include <HYDROData_Image.h>
 #include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_BCPolygon.h>
 #include <HYDROData_Obstacle.h>
 #include <HYDROData_PolylineXY.h>
 #include <HYDROData_Polyline3D.h>
@@ -261,6 +262,29 @@ void HYDROGUI_VTKPrsShape::buildShape()
       //setFillingColor( aFillingColor, false, false );
       //setBorderColor( aBorderColor, false, false );
     }
+    else if ( anObject->IsKind( STANDARD_TYPE(HYDROData_BCPolygon) ) )
+    {
+      Handle(HYDROData_BCPolygon) aBCObj =
+        Handle(HYDROData_BCPolygon)::DownCast( anObject );
+
+      TopoDS_Shape aBCShape = aBCObj->GetTopShape();
+      if ( !aBCShape.IsNull() ) 
+      {
+        if ( aBCShape.ShapeType() == TopAbs_FACE )
+        {
+          TopoDS_Face aFace = TopoDS::Face( aBCShape );
+          setFace( aFace, false, false );
+        }
+        else 
+        {
+          myTopoShape = aBCShape;
+        }
+      }
+
+      QColor aFillingColor = aBCObj->GetFillingColor();
+      QColor aBorderColor = aBCObj->GetBorderColor();
+    }
   }
 }
 
index 4a080b6003ce02410960e071a23a46ff33125202..c2d892480bf345ea55fe1feff89ce4d86c171fd3 100644 (file)
       <source>HYDRO_SUBMERSIBLE16_ICO</source>
       <translation>icon_sumb_16.png</translation>
     </message>
-
+    <message>
+      <source>HYDRO_BC_POLYGON_TYPE1_ICO</source>
+      <translation>icon_bc_polygon_type_1.png</translation>
+    </message>
+    <message>
+      <source>HYDRO_BC_POLYGON_TYPE2_ICO</source>
+      <translation>icon_bc_polygon_type_2.png</translation>
+    </message>
+    <message>
+      <source>HYDRO_BC_POLYGON_TYPE3_ICO</source>
+      <translation>icon_bc_polygon_type_3.png</translation>
+    </message>
+    <message>
+      <source>HYDRO_BC_POLYGON_TYPE_UNDEF_ICO</source>
+      <translation>icon_bc_polygon_type_undef.png</translation>
+    </message>
 
     <!-- Icons for objects -->
     <message>
     <message>
       <source>BATHYMETRY_RESCALE_DEFAULT_ICO</source>
       <translation>icon_bathymetry_rescale_default.png</translation>
-    </message>  </context>
+    </message>
+    <message>
+      <source>IMPORT_BC_POLYGON_ICO</source>
+      <translation>icon_bc_import.png</translation>
+    </message> 
+ </context>
 </TS>
index 0ba175c38dd5a34615b70f52c98fc49df484f3ac..ebe6fe75d5219d9fb0c75a9c6296a7f2fa540f42 100644 (file)
       <source>NATURAL_OBJECTS</source>
       <translation>NATURAL OBJECTS</translation>
     </message>
+    <message>
+      <source>BOUNDARY_POLYGONS</source>
+      <translation>BOUNDARY POLYGONS</translation>
+    </message>
     <message>
       <source>BATHYMETRY_FILTER</source>
       <translation>Bathymetry files (*.xyz);;ASC files (*.asc);;All files (*.* *)</translation>
@@ -334,6 +338,18 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>INCLUDED_GROUPS</source>
       <translation>Included groups</translation>
     </message>
+    <message>
+      <source>INCLUDED_BOUNDARY_POLYGONS_CUT</source>
+      <translation>Included boundary polygons (cut tools)</translation>
+    </message>
+    <message>
+      <source>INCLUDED_BOUNDARY_POLYGONS_INCSEL</source>
+      <translation>Included boundary polygons (include/selection tools)</translation>
+    </message>
+    <message>
+      <source>AVAILABLE_BOUNDARY_POLYGONS</source>
+      <translation>Available boundary polygons</translation>
+    </message>
     <message>
       <source>LIMITS</source>
       <translation>Limits</translation>
@@ -1027,6 +1043,10 @@ Would you like to remove all references from the image?</translation>
       <source>DSK_IMPORT_SINUSX</source>
       <translation>Import from SinusX</translation>
     </message>
+    <message>
+      <source>DSK_IMPORT_BC_POLYGON</source>
+      <translation>Import boundary polygons from SHP file</translation>
+    </message>
     <message>
       <source>DSK_EXPORT_SINUSX</source>
       <translation>Export to SinusX</translation>
@@ -1356,6 +1376,10 @@ Would you like to remove all references from the image?</translation>
       <source>MEN_IMPORT_BATHYMETRY</source>
       <translation>Import bathymetry</translation>
     </message>
+    <message>
+      <source>MEN_IMPORT_BC_POLYGON</source>
+      <translation>Import boundary polygons</translation>
+    </message>
     <message>
       <source>MEN_EDIT_IMPORTED_BATHYMETRY</source>
       <translation>Edit imported bathymetry</translation>
@@ -1552,6 +1576,10 @@ Would you like to remove all references from the image?</translation>
       <source>MEN_ZONE_SET_COLOR</source>
       <translation>Set color</translation>
     </message>
+    <message>
+      <source>MEN_SET_BOUNDARY_TYPE_POLYGON</source>
+      <translation>Set boundary type</translation>
+    </message>
     <message>
       <source>STB_CREATE_CALCULATION</source>
       <translation>Create calculation case</translation>
@@ -3617,4 +3645,39 @@ Polyline should consist from one not closed curve.</translation>
     </message>
   </context>
 
+  <context>
+    <name>HYDROGUI_ImportBCPolygonOp</name>
+     <message>
+      <source>BC_POLYGON_FILTER</source>
+      <translation>Shape files (*.shp)</translation>
+    </message>
+  </context>
+  <context>
+    <name>HYDROGUI_SetBoundaryTypePolygonOp</name>
+     <message>
+      <source>SET_BOUNDARY_TYPE_POLYGON</source>
+      <translation>Set Boundary Type</translation>
+    </message>
+  </context>
+  <context>
+    <name>HYDROGUI_SetBoundaryTypePolygonDlg</name>
+     <message>
+      <source>BOUNDARY_TYPE</source>
+      <translation>Boundary Type: </translation>
+    </message>
+     <message>
+      <source>CUT_TOOL</source>
+      <translation>Cut Tool</translation>
+    </message>
+     <message>
+      <source>INCLUDE_TOOL</source>
+      <translation>Include Tool</translation>
+    </message>
+     <message>
+      <source>SELECTION_TOOL</source>
+      <translation>Selection tool</translation>
+    </message>
+
+  </context>
+
 </TS>
diff --git a/src/HYDROGUI/resources/icon_bc_import.png b/src/HYDROGUI/resources/icon_bc_import.png
new file mode 100644 (file)
index 0000000..7485db1
Binary files /dev/null and b/src/HYDROGUI/resources/icon_bc_import.png differ
diff --git a/src/HYDROGUI/resources/icon_bc_polygon_type_1.png b/src/HYDROGUI/resources/icon_bc_polygon_type_1.png
new file mode 100644 (file)
index 0000000..99f3b22
Binary files /dev/null and b/src/HYDROGUI/resources/icon_bc_polygon_type_1.png differ
diff --git a/src/HYDROGUI/resources/icon_bc_polygon_type_2.png b/src/HYDROGUI/resources/icon_bc_polygon_type_2.png
new file mode 100644 (file)
index 0000000..ea4b406
Binary files /dev/null and b/src/HYDROGUI/resources/icon_bc_polygon_type_2.png differ
diff --git a/src/HYDROGUI/resources/icon_bc_polygon_type_3.png b/src/HYDROGUI/resources/icon_bc_polygon_type_3.png
new file mode 100644 (file)
index 0000000..4bb0549
Binary files /dev/null and b/src/HYDROGUI/resources/icon_bc_polygon_type_3.png differ
diff --git a/src/HYDROGUI/resources/icon_bc_polygon_type_undef.png b/src/HYDROGUI/resources/icon_bc_polygon_type_undef.png
new file mode 100644 (file)
index 0000000..66b3daa
Binary files /dev/null and b/src/HYDROGUI/resources/icon_bc_polygon_type_undef.png differ