Salome HOME
first part of the porting on OCCT 7.0
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.h
index 0f2d6579c4c63824ca34f654a9796e441b3e71fd..af03f9518a787a415296d1f9b3f8bac641ba69a4 100644 (file)
@@ -1,32 +1,61 @@
-
+// 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_CalculationCase_HeaderFile
 #define HYDROData_CalculationCase_HeaderFile
 
 #include <HYDROData_ShapesGroup.h>
+#include <HYDROData_SplitToZonesTool.h>
+#include <HYDROData_PriorityQueue.h>
+#include <HYDROData_Zone.h>
+#include <HYDROData_Warning.h>
+
+#ifdef WIN32
+  #pragma warning ( disable: 4251 )
+#endif
 
+#ifndef LIGHT_MODE
 // IDL includes
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(GEOM_Gen)
+#endif
+
+#ifdef WIN32
+  #pragma warning( default: 4251 )
+#endif
 
 class gp_XY;
 
 class TopoDS_Shape;
 class TopoDS_Shell;
-class TopTools_ListOfShape;
-
-class Handle(HYDROData_Object);
-class Handle(HYDROData_Region);
-class Handle(HYDROData_Zone);
-class Handle(HYDROData_PolylineXY);
-class Handle(HYDROData_ShapesGroup);
-class Handle(HYDROData_SplittedShapesGroup);
-
-DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
 
+class HYDROData_Object;
+class HYDROData_Region;
+class HYDROData_Zone;
+class HYDROData_PolylineXY;
+class HYDROData_ShapesGroup;
+class HYDROData_SplitShapesGroup;
+class HYDROData_Document;
+class HYDROData_StricklerTable;
+class HYDROData_LandCoverMap;
 
 /**\class HYDROData_CalculationCase
- * \brief Calculation case is defined by selection of Geometry objects with or without \93Zone of water\94.
+ * \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
  *
  */
 class HYDROData_CalculationCase : public HYDROData_Entity
@@ -40,7 +69,13 @@ public:
     POINT_ON    ///< point is on the edge of zone face
   };
 
-protected:
+  enum AssignmentMode
+  {
+    MANUAL = 0,
+    AUTOMATIC,
+  };
+
+public:
 
   /**
    * Enumeration of tags corresponding to the persistent object parameters.
@@ -48,17 +83,27 @@ protected:
   enum DataTag
   {
     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
-    DataTag_GeometryObject,   ///< reference geometry objects
-    DataTag_ChildRegion,      ///< child regions
-    DataTag_Region,           ///< reference regions
-    DataTag_Polyline,         ///< reference boundary polyline
-    DataTag_GeometryGroup,    ///< reference geometry groups
-    DataTag_SplittedGroups,   ///< reference splitted groups
+    DataTag_GeometryObject,            ///< reference geometry objects
+    DataTag_ChildRegion,               ///< child regions
+    DataTag_Region,                    ///< reference regions
+    DataTag_Polyline,                  ///< reference boundary polyline
+    DataTag_GeometryGroup,             ///< reference geometry groups
+    DataTag_SplitGroups,               ///< reference split groups
+    DataTag_CustomRules,               ///< custom rules
+    DataTag_AssignmentMode,            ///< assignment mode
+    DataTag_StricklerTable,            ///< reference Strickler table
+
+    DataTag_LandCover_Obsolete,                 ///< reference land covers
+    DataTag_CustomLandCoverRules_Obsolete,      ///< custom rules for land covers priority
+    DataTag_AssignmentLandCoverMode_Obsolete,   ///< assignment mode of land covers priority
+    DataTag_ChildLandCoverRegion_Obsolete,      ///< child land cover regions
+    DataTag_LandCoverRegion_Obsolete,           ///< reference land cover regions
+
+    DataTag_LandCoverMap,              ///< reference to land cover map
   };
 
 public:
-
-  DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
+  DEFINE_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity);
 
   /**
    * Returns the kind of this object. Must be redefined in all objects of known type.
@@ -67,14 +112,15 @@ public:
 
   /**
    * Updates the name of this object.
-   * Reimplemented to update the names of regions, zones and splitted groups.
+   * Reimplemented to update the names of regions, zones and split groups.
    */
-  HYDRODATA_EXPORT virtual void SetName( const QString& theName );
+  HYDRODATA_EXPORT virtual void SetName( const QString& theName );  
 
   /**
    * Dump Calculation object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Update the calcualtion case object.
@@ -102,6 +148,7 @@ public:
 
   /**
    * Removes reference geometry object from calculation case.
+   * \param theObject the object to remove
    */
   HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
 
@@ -113,6 +160,7 @@ public:
 
   /**
    * Add new one reference geometry group for calculation case.
+   * \param theGroup the group to add
    */
   HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
 
@@ -123,6 +171,7 @@ public:
 
   /**
    * Removes reference geometry group from calculation case.
+   * \param theGroup the group to remove
    */
   HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
 
@@ -148,23 +197,49 @@ public:
   HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
 
 
+  /**
+   * Sets reference Strickler table for calculation case.
+   */
+  HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
+
+  /**
+   * Returns reference Strickler table of calculation case.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
+
+  /**
+   * Remove reference Strickler table from calculation case.
+   */
+  HYDRODATA_EXPORT virtual void RemoveStricklerTable();
+
+  /**
+   * Returns reference Land Cover Map of calculation case.
+   * \return the referenced Land Cover Map
+   */
+  HYDRODATA_EXPORT Handle(HYDROData_LandCoverMap) GetLandCoverMap() const;
+
+  HYDRODATA_EXPORT void SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& );
+
   /**
    * Add new one child region for calculation case.
    * The new region is added into the list of reference regions.
    * The label of theZone is changed during this operation
    * because of new region becomes the new parent for this zone.
+   * \return the created region
    */
-  HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone ); 
 
 
   /**
    * Add new one reference region for calculation case.
    * The label of theRegion is changed in case if old parent is not this calculation.
+   * \return true in case of success
    */
   HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
 
   /**
    * Returns all reference regions of calculation case.
+   * \return the list of reference regions
    */
   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
 
@@ -175,34 +250,46 @@ public:
 
   /**
    * Removes reference region from calculation case.
+   * \param theRegion the region to remove
    */
-  HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
+  HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion ); 
 
   /**
    * Removes all reference regions from calculation case.
    */
   HYDRODATA_EXPORT virtual void RemoveRegions();
 
-  
   /**
    * Returns all reference geometry groups of calculation case.
    */
-  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplitGroups() const;
 
   /**
    * Removes all reference geometry groups from calculation case.
    */
-  HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
+  HYDRODATA_EXPORT virtual void RemoveSplitGroups();
 
+  /**
+   * 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
+   * \return the entry of the GEOM object (empty string in the case of error)
+   */
+  HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
 
   /**
    * Exports the calculation case data (shell and groups) to GEOM module.
    * \param theGeomEngine GEOM module engine
    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
+   * \param theGeomObjEntry the published GEOM object entry
+   * \param theErrorMsg the error message
    * \return true in case of success
    */
+#ifndef LIGHT_MODE
   HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var  theGeomEngine,
-                                        SALOMEDS::Study_ptr theStudy ) const;
+                                        SALOMEDS::Study_ptr theStudy,
+                                        QString& theGeomObjEntry,
+                                        QString& theErrorMsg ) const;
+#endif
 
 public:      
   // Public methods to work with Calculation services
@@ -214,9 +301,67 @@ public:
    */
   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
 
+  /**
+   * Returns altitude for given point on given region.
+   * \param thePoint the point to examine
+   * \param theRegion reference region to check
+   * \return result altitude value
+   */
+  HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                    thePoint,
+                                                       const Handle(HYDROData_Region)& theRegion,
+                                                       int theMethod = 0) const;
+
+  /**
+   * Returns altitude for given point on given zone.
+   * \param thePoint the point to examine
+   * \param theZone reference zone to check
+   * \return result altitude value
+   */
+  HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                  thePoint,
+                                                       const Handle(HYDROData_Zone)& theZone,
+                                                       int theMethod = 0) const;
+
+  /**
+   * Returns strickler coefficient for given point.
+   * \param thePoint the point to examine
+   * \return result strickler coefficient
+   */
+  HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
+
+  /**
+   * Returns altitudes for given points on given region.
+   * \param thePoints the points to examine
+   * \param theRegion reference region to check
+   * \return result altitude value
+   */
+  HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
+    const NCollection_Sequence<gp_XY>& thePoints,
+    const Handle(HYDROData_Region)&    theRegion,
+    int theMethod = 0) const;
+
+  /**
+   * Returns altitudes for given points on given zone.
+   * \param thePoints the points to examine
+   * \param theZone reference zone to check
+   * \return result altitude value
+   */
+  HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
+    const NCollection_Sequence<gp_XY>& thePoints,
+    const Handle(HYDROData_Zone)&      theZone,
+    int theMethod = 0) const;
+
+  /**
+   * Returns region to which the point is belongs.
+   * \param thePoint the point to examine
+   * if it is needed to search Land Cover region
+   * \return result region
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
+
   /**
    * Returns zone to which the point is belongs.
    * \param thePoint the point to examine
+   * if it is needed to search Land Cover zone
    * \return result zone
    */
   HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
@@ -231,47 +376,80 @@ public:
     const gp_XY&                  thePoint,
     const Handle(HYDROData_Zone)& theZone ) const;
 
+  HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
+  HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
+
+  HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
+                                    const bool theIsSetToUpdate = true );
+  HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)&     theObject1,
+                                 HYDROData_PriorityType              thePriority,
+                                 const Handle(HYDROData_Entity)&     theObject2,
+                                 HYDROData_Zone::MergeType theMergeType,
+                                 HYDROData_CalculationCase::DataTag  theDataTag );
+  HYDRODATA_EXPORT bool GetRule( int theIndex, 
+                                 Handle(HYDROData_Entity)&           theObject1,
+                                 HYDROData_PriorityType&             thePriority,
+                                 Handle(HYDROData_Entity)&           theObject2,
+                                 HYDROData_Zone::MergeType& theMergeType,
+                                 HYDROData_CalculationCase::DataTag& theDataTag ) const;
+
+  HYDRODATA_EXPORT QString DumpRules() const;
+
+  HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
+
 private:
 
   /**
    * Add new one region for calculation case.
    * The new region is added into the list of reference regions.
    */
-  HYDRODATA_EXPORT virtual Handle(HYDROData_Region) addNewRegion();
+  Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
+                                         const QString& thePrefixOrName,
+                                         bool isPrefix = true );
 
   /**
-   * Add new one splitted edges group for calculation case.
+   * Add new one split edges group for calculation case.
    */
-  HYDRODATA_EXPORT virtual Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup();
+  Handle(HYDROData_SplitShapesGroup) addNewSplitGroup( const QString& theName );
 
   /**
    * Exports the given faces as shell and the given groups to GEOM module.
    * \param theGeomEngine GEOM module engine
    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
    * \param theFaces the list of faces to make shell 
-   * \param theSplittedGroups the list of groups
+   * \param theSplitGroups the list of groups
    * \return true in case of success
    */
-  HYDRODATA_EXPORT bool Export( GEOM::GEOM_Gen_var                            theGeomEngine,
-                                SALOMEDS::Study_ptr                           theStudy,
-                                const TopTools_ListOfShape&                   theFaces,
-                                const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs ) const;
+#ifndef LIGHT_MODE
+  bool Export( GEOM::GEOM_Gen_var                            theGeomEngine,
+               SALOMEDS::Study_ptr                           theStudy,
+               const TopTools_ListOfShape&                   theFaces,
+               const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
+               QString& theGeomObjEntry ) const;
+#endif
+  
+  void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
+                         const HYDROData_SplitToZonesTool::SplitDataList& theZones );
+  void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
+                          const HYDROData_SplitToZonesTool::SplitDataList& theZones );
 
-  /**
-   * Publish the given shape in GEOM as a GEOM object.
-   * \param theGeomEngine GEOM module engine
-   * \param theStudy SALOMEDS study, used for publishing of the shape
-   * \param theShape the shape to publish as a GEOM object
-   * \param theName the name of the published object
-   * \return the published GEOM object
-   */
-  GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var  theGeomEngine,
-                                            SALOMEDS::Study_ptr theStudy,
-                                            const TopoDS_Shape& theShape, 
-                                            const QString&      theName ) const;
+  void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
+                            const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
 
-protected:
+  void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
+
+  void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
+
+  void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
+                           const QString& theOldCaseName,
+                           const QString& theName );
+  
+  void DumpRegionsToPython( QStringList&                       theResList,
+                            const QString&                     thePyScriptPath,
+                            MapOfTreatedObjects&               theTreatedObjects,
+                            const HYDROData_SequenceOfObjects& theRegions ) const;
 
+protected:
   friend class HYDROData_Iterator;
 
   /**
@@ -284,6 +462,14 @@ protected:
    * Destructs properties of the object and object itself, removes it from the document.
    */
   HYDRODATA_EXPORT ~HYDROData_CalculationCase();
+
+  void DumpSampleMeshing( QStringList& theScript,
+                          const QString& theStudyName,
+                          const QString& theGeomShapeName,
+                          const QString& theMeshName ) const;
+
+private:
+  HYDROData_Warning myLastWarning;
 };
 
 #endif