1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROData_CalculationCase_HeaderFile
20 #define HYDROData_CalculationCase_HeaderFile
22 #include <HYDROData_ShapesGroup.h>
23 #include <HYDROData_SplitToZonesTool.h>
24 #include <HYDROData_PriorityQueue.h>
25 #include <HYDROData_Zone.h>
26 #include <HYDROData_Warning.h>
30 #pragma warning ( disable: 4251 )
35 #include <SALOMEconfig.h>
36 #include CORBA_SERVER_HEADER(GEOM_Gen)
40 #pragma warning( default: 4251 )
48 class HYDROData_Object;
49 class HYDROData_Region;
51 class HYDROData_PolylineXY;
52 class HYDROData_ShapesGroup;
53 class HYDROData_SplitShapesGroup;
54 class HYDROData_Document;
55 class HYDROData_StricklerTable;
56 class HYDROData_LandCoverMap;
57 class HYDROData_BCPolygon;
59 /**\class HYDROData_CalculationCase
60 * \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
63 class HYDROData_CalculationCase : public HYDROData_Entity
67 enum PointClassification
69 POINT_OUT, ///< point is out of zone face
70 POINT_IN, ///< point is inside of zone face
71 POINT_ON ///< point is on the edge of zone face
83 * Enumeration of tags corresponding to the persistent object parameters.
87 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
88 DataTag_GeometryObject, ///< reference geometry objects
89 DataTag_ChildRegion, ///< child regions
90 DataTag_Region, ///< reference regions
91 DataTag_Polyline, ///< reference boundary polyline
92 DataTag_GeometryGroup, ///< reference geometry groups
93 DataTag_SplitGroups, ///< reference split groups
94 DataTag_CustomRules, ///< custom rules
95 DataTag_AssignmentMode, ///< assignment mode
96 DataTag_StricklerTable, ///< reference Strickler table
97 DataTag_InterPoly, ///< intersection polyline
99 DataTag_LandCover_Obsolete, ///< reference land covers
100 DataTag_CustomLandCoverRules_Obsolete, ///< custom rules for land covers priority
101 DataTag_AssignmentLandCoverMode_Obsolete, ///< assignment mode of land covers priority
102 DataTag_ChildLandCoverRegion_Obsolete, ///< child land cover regions
103 DataTag_LandCoverRegion_Obsolete, ///< reference land cover regions
105 DataTag_LandCoverMap, ///< reference to land cover map
106 DataTag_BCPolygon ///< reference boundary polygons
110 DEFINE_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity);
113 * Returns the kind of this object. Must be redefined in all objects of known type.
115 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
118 * Updates the name of this object.
119 * Reimplemented to update the names of regions, zones and split groups.
121 HYDRODATA_EXPORT virtual void SetName( const QString& theName, bool isDefault = false );
124 * Dump Calculation object to Python script representation.
126 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
127 MapOfTreatedObjects& theTreatedObjects ) const;
130 * Update the calcualtion case object.
131 * Call this method whenever you made changes for object data.
133 HYDRODATA_EXPORT virtual void Update();
136 * Returns the list of all reference objects of this object.
138 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
141 // Public methods to work with Calculation
144 * Add new one reference geometry object for calculation case.
146 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
149 * Returns all reference geometry objects of calculation case.
151 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
154 * Removes reference geometry object from calculation case.
155 * \param theObject the object to remove
157 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
160 * Removes all reference geometry objects from calculation case.
162 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
166 * Add new one reference geometry group for calculation case.
167 * \param theGroup the group to add
169 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
172 * Returns all reference geometry groups of calculation case.
174 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
177 * Removes reference geometry group from calculation case.
178 * \param theGroup the group to remove
180 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
183 * Removes all reference geometry groups from calculation case.
185 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
189 * Sets reference boundary polyline object for calculation case.
191 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
194 * Returns reference boundary polyline object of calculation case.
196 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
199 * Remove reference boundary polyline object from calculation case.
201 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
205 * Sets reference Strickler table for calculation case.
207 HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
210 * Returns reference Strickler table of calculation case.
212 HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
215 * Remove reference Strickler table from calculation case.
217 HYDRODATA_EXPORT virtual void RemoveStricklerTable();
220 * Returns reference Land Cover Map of calculation case.
221 * \return the referenced Land Cover Map
223 HYDRODATA_EXPORT Handle(HYDROData_LandCoverMap) GetLandCoverMap() const;
225 HYDRODATA_EXPORT void SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& );
228 * Add new one child region for calculation case.
229 * The new region is added into the list of reference regions.
230 * The label of theZone is changed during this operation
231 * because of new region becomes the new parent for this zone.
232 * \return the created region
234 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
238 * Add new one reference region for calculation case.
239 * The label of theRegion is changed in case if old parent is not this calculation.
240 * \return true in case of success
242 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
245 * Returns all reference regions of calculation case.
246 * \return the list of reference regions
248 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
251 * Updates names of regions to correct order.
253 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
256 * Removes reference region from calculation case.
257 * \param theRegion the region to remove
259 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
262 * Removes all reference regions from calculation case.
264 HYDRODATA_EXPORT virtual void RemoveRegions();
267 * Returns all reference geometry groups of calculation case.
269 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplitGroups() const;
272 * Removes all reference geometry groups from calculation case.
274 HYDRODATA_EXPORT virtual void RemoveSplitGroups();
276 HYDRODATA_EXPORT virtual bool AddInterPoly( const Handle(HYDROData_PolylineXY)& theInterPolyline );
278 HYDRODATA_EXPORT virtual void RemoveInterPolyObject( const Handle(HYDROData_PolylineXY)& theInterPolyline );
280 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetInterPolyObjects() const;
282 HYDRODATA_EXPORT virtual bool AddBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon );
284 HYDRODATA_EXPORT virtual void RemoveBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon );
286 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetBoundaryPolygons() const;
289 * \brief Set the Container Name to use when not default (FactoryServer).
290 * \param theContainerName the name of the container used for GEOM
291 * (to be used by scripts for distributed execution)
293 HYDRODATA_EXPORT virtual void SetContainerName( const QString& theContainerName );
296 * Exports the calculation case data (shell and groups) to GEOM module.
297 * \return the entry of the GEOM object (empty string in the case of error)
299 HYDRODATA_EXPORT virtual QString Export() const;
302 * Exports the calculation case data (shell and groups) to GEOM module.
303 * \param theGeomEngine GEOM module engine
304 * \param theGeomObjEntry the published GEOM object entry
305 * \param theErrorMsg the error message
306 * \return true in case of success
309 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
310 QString& theGeomObjEntry,
311 QString& theErrorMsg,
312 QString& statMess) const;
316 // Public methods to work with Calculation services
319 * Returns altitude for given point.
320 * \param thePoint the point to examine
321 * \return result altitude value
323 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
326 * Returns altitude for given point on given region.
327 * \param thePoint the point to examine
328 * \param theRegion reference region to check
329 * \return result altitude value
331 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
332 const Handle(HYDROData_Region)& theRegion,
333 int theMethod = 0) const;
336 * Returns altitude for given point on given zone.
337 * \param thePoint the point to examine
338 * \param theZone reference zone to check
339 * \return result altitude value
341 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
342 const Handle(HYDROData_Zone)& theZone,
343 int theMethod = 0) const;
346 * Returns strickler coefficient for given point.
347 * \param thePoint the point to examine
348 * \return result strickler coefficient
350 HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
352 HYDRODATA_EXPORT std::vector<double> GetStricklerCoefficientForPoints(const std::vector<gp_XY>& thePoints,
356 HYDRODATA_EXPORT std::vector<int> GetStricklerTypeForPoints( const std::vector<gp_XY>& thePoints ) const;
359 * Returns altitudes for given points on given region.
360 * \param thePoints the points to examine
361 * \param theRegion reference region to check
362 * \return result altitude value
364 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
365 const NCollection_Sequence<gp_XY>& thePoints,
366 const Handle(HYDROData_Region)& theRegion,
367 int theMethod = 0) const;
370 * Returns altitudes for given points on given zone.
371 * \param thePoints the points to examine
372 * \param theZone reference zone to check
373 * \return result altitude value
375 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
376 const NCollection_Sequence<gp_XY>& thePoints,
377 const Handle(HYDROData_Zone)& theZone,
378 int theMethod = 0) const;
381 * Returns region to which the point is belongs.
382 * \param thePoint the point to examine
383 * if it is needed to search Land Cover region
384 * \return result region
386 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
389 * Returns zone to which the point is belongs.
390 * \param thePoint the point to examine
391 * if it is needed to search Land Cover zone
392 * \return result zone
394 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
397 * Returns classification of point for given zone.
398 * \param thePoint the point to examine
399 * \param theZone the zone to examine
400 * \return result classification
402 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
403 const gp_XY& thePoint,
404 const Handle(HYDROData_Zone)& theZone ) const;
406 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
407 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
409 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
410 const bool theIsSetToUpdate = true );
411 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
412 HYDROData_PriorityType thePriority,
413 const Handle(HYDROData_Entity)& theObject2,
414 HYDROData_Zone::MergeType theMergeType,
415 HYDROData_CalculationCase::DataTag theDataTag );
416 HYDRODATA_EXPORT bool GetRule( int theIndex,
417 Handle(HYDROData_Entity)& theObject1,
418 HYDROData_PriorityType& thePriority,
419 Handle(HYDROData_Entity)& theObject2,
420 HYDROData_Zone::MergeType& theMergeType,
421 HYDROData_CalculationCase::DataTag& theDataTag ) const;
423 HYDRODATA_EXPORT QString DumpRules() const;
425 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
430 * Add new one region for calculation case.
431 * The new region is added into the list of reference regions.
435 HYDRODATA_EXPORT Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
436 const QString& thePrefixOrName,
437 bool isPrefix = true );
440 * Add new one split edges group for calculation case.
442 Handle(HYDROData_SplitShapesGroup) addNewSplitGroup( const QString& theName );
445 * Exports the given faces as shell and the given groups to GEOM module.
446 * \param theGeomEngine GEOM module engine
447 * \param theFaces the list of faces to make shell
448 * \param theSplitGroups the list of groups
449 * \return true in case of success
452 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
453 const NCollection_IndexedDataMap<TopoDS_Shape, QString>& aFacesToName,
454 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
455 QString& theGeomObjEntry ) const;
458 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
459 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
460 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
461 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
463 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
464 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
466 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
468 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
470 void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
471 const QString& theOldCaseName,
472 const QString& theName );
474 void DumpRegionsToPython( QStringList& theResList,
475 const QString& thePyScriptPath,
476 MapOfTreatedObjects& theTreatedObjects,
477 const HYDROData_SequenceOfObjects& theRegions ) const;
480 friend class HYDROData_Iterator;
483 * Creates new object in the internal data structure. Use higher level objects
484 * to create objects with real content.
486 HYDRODATA_EXPORT HYDROData_CalculationCase();
489 * Destructs properties of the object and object itself, removes it from the document.
491 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
493 void DumpSampleMeshing( QStringList& theScript,
494 const QString& theGeomShapeName,
495 const QString& theMeshName ) const;
498 HYDROData_Warning myLastWarning;