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 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(GEOM_Gen)
38 class TopTools_ListOfShape;
40 class Handle(HYDROData_Object);
41 class Handle(HYDROData_Region);
42 class Handle(HYDROData_Zone);
43 class Handle(HYDROData_PolylineXY);
44 class Handle(HYDROData_ShapesGroup);
45 class Handle(HYDROData_SplittedShapesGroup);
46 class Handle(HYDROData_Document);
47 class Handle(HYDROData_StricklerTable);
48 class Handle(HYDROData_LandCover);
50 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
53 /**\class HYDROData_CalculationCase
54 * \brief Calculation case is defined by selection of Geometry objects with or without
\93Zone of water
\94.
57 class HYDROData_CalculationCase : public HYDROData_Entity
61 enum PointClassification
63 POINT_OUT, ///< point is out of zone face
64 POINT_IN, ///< point is inside of zone face
65 POINT_ON ///< point is on the edge of zone face
77 * Enumeration of tags corresponding to the persistent object parameters.
81 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
82 DataTag_GeometryObject, ///< reference geometry objects
83 DataTag_ChildRegion, ///< child regions
84 DataTag_Region, ///< reference regions
85 DataTag_Polyline, ///< reference boundary polyline
86 DataTag_GeometryGroup, ///< reference geometry groups
87 DataTag_SplittedGroups, ///< reference splitted groups
88 DataTag_CustomRules, ///< custom rules
89 DataTag_AssignmentMode, ///< assignment mode
90 DataTag_StricklerTable, ///< reference Strickler table
91 DataTag_LandCover, ///< reference land covers
92 DataTag_CustomLandCoverRules, ///< custom rules for land covers priority
93 DataTag_AssignmentLandCoverMode, ///< assignment mode of land covers priority
94 DataTag_ChildLandCoverRegion, ///< child land cover regions
95 DataTag_LandCoverRegion ///< reference land cover regions
100 DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
103 * Returns the kind of this object. Must be redefined in all objects of known type.
105 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
108 * Updates the name of this object.
109 * Reimplemented to update the names of regions, zones and splitted groups.
111 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
114 * Dump Calculation object to Python script representation.
116 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
119 * Update the calcualtion case object.
120 * Call this method whenever you made changes for object data.
122 HYDRODATA_EXPORT virtual void Update();
125 * Returns the list of all reference objects of this object.
127 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
130 // Public methods to work with Calculation
133 * Add new one reference geometry object for calculation case.
135 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
138 * Returns all reference geometry objects of calculation case.
140 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
143 * Removes reference geometry object from calculation case.
144 * \param theObject the object to remove
146 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
149 * Removes all reference geometry objects from calculation case.
151 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
155 * Add new one reference geometry group for calculation case.
156 * \param theGroup the group to add
158 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
161 * Returns all reference geometry groups of calculation case.
163 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
166 * Removes reference geometry group from calculation case.
167 * \param theGroup the group to remove
169 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
172 * Removes all reference geometry groups from calculation case.
174 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
178 * Sets reference boundary polyline object for calculation case.
180 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
183 * Returns reference boundary polyline object of calculation case.
185 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
188 * Remove reference boundary polyline object from calculation case.
190 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
194 * Sets reference Strickler table for calculation case.
196 HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
199 * Returns reference Strickler table of calculation case.
201 HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
204 * Remove reference Strickler table from calculation case.
206 HYDRODATA_EXPORT virtual void RemoveStricklerTable();
210 * Add new one reference Land Cover for calculation case.
211 * \param theLandCover the Land Cover to add
212 * \return true in case of success
214 HYDRODATA_EXPORT virtual bool AddLandCover( const Handle(HYDROData_LandCover)& theLandCover );
217 * Returns all reference Land Covers of calculation case.
218 * \return the list of referenced Land Covers
220 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetLandCovers() const;
223 * Removes reference Land Cover from calculation case.
224 * \param theLandCover the Land Cover to remove
226 HYDRODATA_EXPORT virtual void RemoveLandCover( const Handle(HYDROData_LandCover)& theLandCover );
229 * Removes all reference Land Covers from calculation case.
231 HYDRODATA_EXPORT virtual void RemoveLandCovers();
235 * Add new one child region for calculation case.
236 * The new region is added into the list of reference regions.
237 * The label of theZone is changed during this operation
238 * because of new region becomes the new parent for this zone.
239 * \param theLandCover if true - Land Cover region will be added
240 * \return the created region
242 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone,
243 const bool theLandCover );
247 * Add new one reference region for calculation case.
248 * The label of theRegion is changed in case if old parent is not this calculation.
249 * \param theLandCover if true - Land Cover region will bw created
250 * \return true in case of success
252 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion,
253 const bool theLandCover );
256 * Returns all reference regions of calculation case.
257 * \param theLandCover if true - Land Cover regions will be returned
258 * \return the list of reference regions
260 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions( const bool theLandCover ) const;
263 * Updates names of regions to correct order.
265 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
268 * Removes reference region from calculation case.
269 * \param theRegion the region to remove
270 * \param theLandCover if true - it means that Land Cover region to be removed
272 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion,
273 const bool theLandCover );
276 * Removes all reference regions from calculation case.
277 * \param theLandCover if true - it means that Land Cover regions to be removed
279 HYDRODATA_EXPORT virtual void RemoveRegions( const bool theLandCover );
282 * Returns all reference geometry groups of calculation case.
284 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
287 * Removes all reference geometry groups from calculation case.
289 HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
292 * Exports the calculation case data (shell and groups) to GEOM module.
293 * \param theStudyId the id of the study where the GEOM module should be used for export
294 * \return the entry of the GEOM object (empty string in the case of error)
296 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
299 * Exports the calculation case data (shell and groups) to GEOM module.
300 * \param theGeomEngine GEOM module engine
301 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
302 * \param theGeomObjEntry the published GEOM object entry
303 * \param theErrorMsg the error message
304 * \return true in case of success
307 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
308 SALOMEDS::Study_ptr theStudy,
309 QString& theGeomObjEntry,
310 QString& theErrorMsg ) const;
314 // Public methods to work with Calculation services
317 * Returns altitude for given point.
318 * \param thePoint the point to examine
319 * \return result altitude value
321 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
324 * Returns altitude for given point on given region.
325 * \param thePoint the point to examine
326 * \param theRegion reference region to check
327 * \return result altitude value
329 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
330 const Handle(HYDROData_Region)& theRegion ) const;
333 * Returns altitude for given point on given zone.
334 * \param thePoint the point to examine
335 * \param theZone reference zone to check
336 * \return result altitude value
338 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
339 const Handle(HYDROData_Zone)& theZone ) const;
342 * Returns strickler coefficient for given point.
343 * \param thePoint the point to examine
344 * \return result strickler coefficient
346 HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
349 * Returns altitudes for given points on given region.
350 * \param thePoints the points to examine
351 * \param theRegion reference region to check
352 * \return result altitude value
354 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
355 const NCollection_Sequence<gp_XY>& thePoints,
356 const Handle(HYDROData_Region)& theRegion ) const;
359 * Returns altitudes for given points on given zone.
360 * \param thePoints the points to examine
361 * \param theZone reference zone 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_Zone)& theZone ) const;
369 * Returns region to which the point is belongs.
370 * \param thePoint the point to examine
371 * \param theLandCover the flag indicating,
372 * if it is needed to search Land Cover region
373 * \return result region
375 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint,
376 const bool theLandCover ) const;
379 * Returns zone to which the point is belongs.
380 * \param thePoint the point to examine
381 * \param theLandCover the flag indicating,
382 * if it is needed to search Land Cover zone
383 * \return result zone
385 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint,
386 const bool theLandCover ) const;
389 * Returns classification of point for given zone.
390 * \param thePoint the point to examine
391 * \param theZone the zone to examine
392 * \return result classification
394 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
395 const gp_XY& thePoint,
396 const Handle(HYDROData_Zone)& theZone ) const;
398 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
399 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
401 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
402 const bool theIsSetToUpdate = true );
403 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
404 HYDROData_PriorityType thePriority,
405 const Handle(HYDROData_Entity)& theObject2,
406 HYDROData_Zone::MergeType theMergeType,
407 HYDROData_CalculationCase::DataTag theDataTag );
408 HYDRODATA_EXPORT bool GetRule( int theIndex,
409 Handle(HYDROData_Entity)& theObject1,
410 HYDROData_PriorityType& thePriority,
411 Handle(HYDROData_Entity)& theObject2,
412 HYDROData_Zone::MergeType& theMergeType,
413 HYDROData_CalculationCase::DataTag& theDataTag ) const;
415 HYDRODATA_EXPORT void SetAssignmentLandCoverMode( AssignmentMode theMode );
416 HYDRODATA_EXPORT AssignmentMode GetAssignmentLandCoverMode() const;
418 HYDRODATA_EXPORT QString DumpRules() const;
419 HYDRODATA_EXPORT QString DumpLandCoverRules() const;
421 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
426 * Add new one region for calculation case.
427 * The new region is added into the list of reference regions.
429 Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
430 const QString& thePrefixOrName,
431 const bool theLandCover,
432 bool isPrefix = true );
435 * Add new one splitted edges group for calculation case.
437 Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup( const QString& theName );
440 * Exports the given faces as shell and the given groups to GEOM module.
441 * \param theGeomEngine GEOM module engine
442 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
443 * \param theFaces the list of faces to make shell
444 * \param theSplittedGroups the list of groups
445 * \return true in case of success
448 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
449 SALOMEDS::Study_ptr theStudy,
450 const TopTools_ListOfShape& theFaces,
451 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
452 QString& theGeomObjEntry ) const;
455 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
456 const HYDROData_SplitToZonesTool::SplitDataList& theZones,
457 const bool theLandCover );
458 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
459 const HYDROData_SplitToZonesTool::SplitDataList& theZones,
460 const bool theLandCover );
462 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
463 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
465 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
466 void DumpLandCoverRulesToPython( 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 MapOfTreatedObjects& theTreatedObjects,
476 const HYDROData_SequenceOfObjects& theRegions ) const;
479 friend class HYDROData_Iterator;
482 * Creates new object in the internal data structure. Use higher level objects
483 * to create objects with real content.
485 HYDRODATA_EXPORT HYDROData_CalculationCase();
488 * Destructs properties of the object and object itself, removes it from the document.
490 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
492 void DumpSampleMeshing( QStringList& theScript,
493 const QString& theStudyName,
494 const QString& theGeomShapeName,
495 const QString& theMeshName ) const;
498 HYDROData_Warning myLastWarning;