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;
58 /**\class HYDROData_CalculationCase
59 * \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
62 class HYDROData_CalculationCase : public HYDROData_Entity
66 enum PointClassification
68 POINT_OUT, ///< point is out of zone face
69 POINT_IN, ///< point is inside of zone face
70 POINT_ON ///< point is on the edge of zone face
82 * Enumeration of tags corresponding to the persistent object parameters.
86 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
87 DataTag_GeometryObject, ///< reference geometry objects
88 DataTag_ChildRegion, ///< child regions
89 DataTag_Region, ///< reference regions
90 DataTag_Polyline, ///< reference boundary polyline
91 DataTag_GeometryGroup, ///< reference geometry groups
92 DataTag_SplitGroups, ///< reference split groups
93 DataTag_CustomRules, ///< custom rules
94 DataTag_AssignmentMode, ///< assignment mode
95 DataTag_StricklerTable, ///< reference Strickler table
96 DataTag_InterPoly, ///< intersection polyline
98 DataTag_LandCover_Obsolete, ///< reference land covers
99 DataTag_CustomLandCoverRules_Obsolete, ///< custom rules for land covers priority
100 DataTag_AssignmentLandCoverMode_Obsolete, ///< assignment mode of land covers priority
101 DataTag_ChildLandCoverRegion_Obsolete, ///< child land cover regions
102 DataTag_LandCoverRegion_Obsolete, ///< reference land cover regions
104 DataTag_LandCoverMap, ///< reference to land cover map
108 DEFINE_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity);
111 * Returns the kind of this object. Must be redefined in all objects of known type.
113 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
116 * Updates the name of this object.
117 * Reimplemented to update the names of regions, zones and split groups.
119 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
122 * Dump Calculation object to Python script representation.
124 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
125 MapOfTreatedObjects& theTreatedObjects ) const;
128 * Update the calcualtion case object.
129 * Call this method whenever you made changes for object data.
131 HYDRODATA_EXPORT virtual void Update();
134 * Returns the list of all reference objects of this object.
136 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
139 // Public methods to work with Calculation
142 * Add new one reference geometry object for calculation case.
144 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
147 * Returns all reference geometry objects of calculation case.
149 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
152 * Removes reference geometry object from calculation case.
153 * \param theObject the object to remove
155 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
158 * Removes all reference geometry objects from calculation case.
160 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
164 * Add new one reference geometry group for calculation case.
165 * \param theGroup the group to add
167 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
170 * Returns all reference geometry groups of calculation case.
172 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
175 * Removes reference geometry group from calculation case.
176 * \param theGroup the group to remove
178 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
181 * Removes all reference geometry groups from calculation case.
183 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
187 * Sets reference boundary polyline object for calculation case.
189 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
192 * Returns reference boundary polyline object of calculation case.
194 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
197 * Remove reference boundary polyline object from calculation case.
199 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
203 * Sets reference Strickler table for calculation case.
205 HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
208 * Returns reference Strickler table of calculation case.
210 HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
213 * Remove reference Strickler table from calculation case.
215 HYDRODATA_EXPORT virtual void RemoveStricklerTable();
218 * Returns reference Land Cover Map of calculation case.
219 * \return the referenced Land Cover Map
221 HYDRODATA_EXPORT Handle(HYDROData_LandCoverMap) GetLandCoverMap() const;
223 HYDRODATA_EXPORT void SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& );
226 * Add new one child region for calculation case.
227 * The new region is added into the list of reference regions.
228 * The label of theZone is changed during this operation
229 * because of new region becomes the new parent for this zone.
230 * \return the created region
232 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
236 * Add new one reference region for calculation case.
237 * The label of theRegion is changed in case if old parent is not this calculation.
238 * \return true in case of success
240 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
243 * Returns all reference regions of calculation case.
244 * \return the list of reference regions
246 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
249 * Updates names of regions to correct order.
251 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
254 * Removes reference region from calculation case.
255 * \param theRegion the region to remove
257 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
260 * Removes all reference regions from calculation case.
262 HYDRODATA_EXPORT virtual void RemoveRegions();
265 * Returns all reference geometry groups of calculation case.
267 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplitGroups() const;
270 * Removes all reference geometry groups from calculation case.
272 HYDRODATA_EXPORT virtual void RemoveSplitGroups();
274 HYDRODATA_EXPORT virtual bool AddInterPoly( const Handle(HYDROData_PolylineXY)& theInterPolyline );
276 HYDRODATA_EXPORT virtual void RemoveInterPolyObject( const Handle(HYDROData_PolylineXY)& theInterPolyline );
278 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetInterPolyObjects() const;
281 * Exports the calculation case data (shell and groups) to GEOM module.
282 * \param theStudyId the id of the study where the GEOM module should be used for export
283 * \return the entry of the GEOM object (empty string in the case of error)
285 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
288 * Exports the calculation case data (shell and groups) to GEOM module.
289 * \param theGeomEngine GEOM module engine
290 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
291 * \param theGeomObjEntry the published GEOM object entry
292 * \param theErrorMsg the error message
293 * \return true in case of success
296 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
297 SALOMEDS::Study_ptr theStudy,
298 QString& theGeomObjEntry,
299 QString& theErrorMsg,
300 QString& statMess) const;
304 // Public methods to work with Calculation services
307 * Returns altitude for given point.
308 * \param thePoint the point to examine
309 * \return result altitude value
311 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
314 * Returns altitude for given point on given region.
315 * \param thePoint the point to examine
316 * \param theRegion reference region to check
317 * \return result altitude value
319 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
320 const Handle(HYDROData_Region)& theRegion,
321 int theMethod = 0) const;
324 * Returns altitude for given point on given zone.
325 * \param thePoint the point to examine
326 * \param theZone reference zone to check
327 * \return result altitude value
329 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
330 const Handle(HYDROData_Zone)& theZone,
331 int theMethod = 0) const;
334 * Returns strickler coefficient for given point.
335 * \param thePoint the point to examine
336 * \return result strickler coefficient
338 HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
340 HYDRODATA_EXPORT std::vector<double> GetStricklerCoefficientForPoints(const std::vector<gp_XY>& thePoints,
344 HYDRODATA_EXPORT std::vector<int> GetStricklerTypeForPoints( const std::vector<gp_XY>& thePoints ) const;
347 * Returns altitudes for given points on given region.
348 * \param thePoints the points to examine
349 * \param theRegion reference region to check
350 * \return result altitude value
352 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
353 const NCollection_Sequence<gp_XY>& thePoints,
354 const Handle(HYDROData_Region)& theRegion,
355 int theMethod = 0) const;
358 * Returns altitudes for given points on given zone.
359 * \param thePoints the points to examine
360 * \param theZone reference zone to check
361 * \return result altitude value
363 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
364 const NCollection_Sequence<gp_XY>& thePoints,
365 const Handle(HYDROData_Zone)& theZone,
366 int theMethod = 0) const;
369 * Returns region to which the point is belongs.
370 * \param thePoint the point to examine
371 * if it is needed to search Land Cover region
372 * \return result region
374 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
377 * Returns zone to which the point is belongs.
378 * \param thePoint the point to examine
379 * if it is needed to search Land Cover zone
380 * \return result zone
382 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
385 * Returns classification of point for given zone.
386 * \param thePoint the point to examine
387 * \param theZone the zone to examine
388 * \return result classification
390 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
391 const gp_XY& thePoint,
392 const Handle(HYDROData_Zone)& theZone ) const;
394 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
395 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
397 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
398 const bool theIsSetToUpdate = true );
399 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
400 HYDROData_PriorityType thePriority,
401 const Handle(HYDROData_Entity)& theObject2,
402 HYDROData_Zone::MergeType theMergeType,
403 HYDROData_CalculationCase::DataTag theDataTag );
404 HYDRODATA_EXPORT bool GetRule( int theIndex,
405 Handle(HYDROData_Entity)& theObject1,
406 HYDROData_PriorityType& thePriority,
407 Handle(HYDROData_Entity)& theObject2,
408 HYDROData_Zone::MergeType& theMergeType,
409 HYDROData_CalculationCase::DataTag& theDataTag ) const;
411 HYDRODATA_EXPORT QString DumpRules() const;
413 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
418 * Add new one region for calculation case.
419 * The new region is added into the list of reference regions.
421 Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
422 const QString& thePrefixOrName,
423 bool isPrefix = true );
426 * Add new one split edges group for calculation case.
428 Handle(HYDROData_SplitShapesGroup) addNewSplitGroup( const QString& theName );
431 * Exports the given faces as shell and the given groups to GEOM module.
432 * \param theGeomEngine GEOM module engine
433 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
434 * \param theFaces the list of faces to make shell
435 * \param theSplitGroups the list of groups
436 * \return true in case of success
439 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
440 SALOMEDS::Study_ptr theStudy,
441 const NCollection_IndexedDataMap<TopoDS_Shape, QString>& aFacesToName,
442 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
443 QString& theGeomObjEntry ) const;
446 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
447 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
448 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
449 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
451 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
452 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
454 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
456 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
458 void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
459 const QString& theOldCaseName,
460 const QString& theName );
462 void DumpRegionsToPython( QStringList& theResList,
463 const QString& thePyScriptPath,
464 MapOfTreatedObjects& theTreatedObjects,
465 const HYDROData_SequenceOfObjects& theRegions ) const;
468 friend class HYDROData_Iterator;
471 * Creates new object in the internal data structure. Use higher level objects
472 * to create objects with real content.
474 HYDRODATA_EXPORT HYDROData_CalculationCase();
477 * Destructs properties of the object and object itself, removes it from the document.
479 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
481 void DumpSampleMeshing( QStringList& theScript,
482 const QString& theStudyName,
483 const QString& theGeomShapeName,
484 const QString& theMeshName ) const;
487 HYDROData_Warning myLastWarning;