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 )
47 class TopTools_ListOfShape;
49 class Handle(HYDROData_Object);
50 class Handle(HYDROData_Region);
51 class Handle(HYDROData_Zone);
52 class Handle(HYDROData_PolylineXY);
53 class Handle(HYDROData_ShapesGroup);
54 class Handle(HYDROData_SplitShapesGroup);
55 class Handle(HYDROData_Document);
56 class Handle(HYDROData_StricklerTable);
57 class Handle(HYDROData_LandCoverMap);
59 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
62 /**\class HYDROData_CalculationCase
63 * \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
66 class HYDROData_CalculationCase : public HYDROData_Entity
70 enum PointClassification
72 POINT_OUT, ///< point is out of zone face
73 POINT_IN, ///< point is inside of zone face
74 POINT_ON ///< point is on the edge of zone face
86 * Enumeration of tags corresponding to the persistent object parameters.
90 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
91 DataTag_GeometryObject, ///< reference geometry objects
92 DataTag_ChildRegion, ///< child regions
93 DataTag_Region, ///< reference regions
94 DataTag_Polyline, ///< reference boundary polyline
95 DataTag_GeometryGroup, ///< reference geometry groups
96 DataTag_SplitGroups, ///< reference split groups
97 DataTag_CustomRules, ///< custom rules
98 DataTag_AssignmentMode, ///< assignment mode
99 DataTag_StricklerTable, ///< reference Strickler table
100 DataTag_InterPoly, ///< intersection polyline
102 DataTag_LandCover_Obsolete, ///< reference land covers
103 DataTag_CustomLandCoverRules_Obsolete, ///< custom rules for land covers priority
104 DataTag_AssignmentLandCoverMode_Obsolete, ///< assignment mode of land covers priority
105 DataTag_ChildLandCoverRegion_Obsolete, ///< child land cover regions
106 DataTag_LandCoverRegion_Obsolete, ///< reference land cover regions
108 DataTag_LandCoverMap, ///< reference to land cover map
113 DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
116 * Returns the kind of this object. Must be redefined in all objects of known type.
118 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
121 * Updates the name of this object.
122 * Reimplemented to update the names of regions, zones and split groups.
124 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
127 * Dump Calculation object to Python script representation.
129 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
130 MapOfTreatedObjects& theTreatedObjects ) const;
133 * Update the calcualtion case object.
134 * Call this method whenever you made changes for object data.
136 HYDRODATA_EXPORT virtual void Update();
139 * Returns the list of all reference objects of this object.
141 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
144 // Public methods to work with Calculation
147 * Add new one reference geometry object for calculation case.
149 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
152 * Returns all reference geometry objects of calculation case.
154 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
157 * Removes reference geometry object from calculation case.
158 * \param theObject the object to remove
160 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
163 * Removes all reference geometry objects from calculation case.
165 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
169 * Add new one reference geometry group for calculation case.
170 * \param theGroup the group to add
172 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
175 * Returns all reference geometry groups of calculation case.
177 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
180 * Removes reference geometry group from calculation case.
181 * \param theGroup the group to remove
183 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
186 * Removes all reference geometry groups from calculation case.
188 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
192 * Sets reference boundary polyline object for calculation case.
194 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
197 * Returns reference boundary polyline object of calculation case.
199 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
202 * Remove reference boundary polyline object from calculation case.
204 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
208 * Sets reference Strickler table for calculation case.
210 HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
213 * Returns reference Strickler table of calculation case.
215 HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
218 * Remove reference Strickler table from calculation case.
220 HYDRODATA_EXPORT virtual void RemoveStricklerTable();
223 * Returns reference Land Cover Map of calculation case.
224 * \return the referenced Land Cover Map
226 HYDRODATA_EXPORT Handle(HYDROData_LandCoverMap) GetLandCoverMap() const;
228 HYDRODATA_EXPORT void SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& );
231 * Add new one child region for calculation case.
232 * The new region is added into the list of reference regions.
233 * The label of theZone is changed during this operation
234 * because of new region becomes the new parent for this zone.
235 * \return the created region
237 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
241 * Add new one reference region for calculation case.
242 * The label of theRegion is changed in case if old parent is not this calculation.
243 * \return true in case of success
245 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
248 * Returns all reference regions of calculation case.
249 * \return the list of reference regions
251 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
254 * Updates names of regions to correct order.
256 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
259 * Removes reference region from calculation case.
260 * \param theRegion the region to remove
262 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
265 * Removes all reference regions from calculation case.
267 HYDRODATA_EXPORT virtual void RemoveRegions();
270 * Returns all reference geometry groups of calculation case.
272 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplitGroups() const;
275 * Removes all reference geometry groups from calculation case.
277 HYDRODATA_EXPORT virtual void RemoveSplitGroups();
279 HYDRODATA_EXPORT virtual bool AddInterPoly( const Handle(HYDROData_PolylineXY)& theInterPolyline );
281 HYDRODATA_EXPORT virtual void RemoveInterPolyObject( const Handle(HYDROData_PolylineXY)& theInterPolyline );
283 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetInterPolyObjects() const;
286 * Exports the calculation case data (shell and groups) to GEOM module.
287 * \param theStudyId the id of the study where the GEOM module should be used for export
288 * \return the entry of the GEOM object (empty string in the case of error)
290 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
293 * Exports the calculation case data (shell and groups) to GEOM module.
294 * \param theGeomEngine GEOM module engine
295 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
296 * \param theGeomObjEntry the published GEOM object entry
297 * \param theErrorMsg the error message
298 * \return true in case of success
301 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
302 SALOMEDS::Study_ptr theStudy,
303 QString& theGeomObjEntry,
304 QString& theErrorMsg,
305 QString& statMess) const;
309 // Public methods to work with Calculation services
312 * Returns altitude for given point.
313 * \param thePoint the point to examine
314 * \return result altitude value
316 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
319 * Returns altitude for given point on given region.
320 * \param thePoint the point to examine
321 * \param theRegion reference region to check
322 * \return result altitude value
324 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
325 const Handle(HYDROData_Region)& theRegion,
326 int theMethod = 0) const;
329 * Returns altitude for given point on given zone.
330 * \param thePoint the point to examine
331 * \param theZone reference zone to check
332 * \return result altitude value
334 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
335 const Handle(HYDROData_Zone)& theZone,
336 int theMethod = 0) const;
339 * Returns strickler coefficient for given point.
340 * \param thePoint the point to examine
341 * \return result strickler coefficient
343 HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
345 HYDRODATA_EXPORT std::vector<double> GetStricklerCoefficientForPoints(const std::vector<gp_XY>& thePoints,
350 * Returns altitudes for given points on given region.
351 * \param thePoints the points to examine
352 * \param theRegion reference region to check
353 * \return result altitude value
355 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
356 const NCollection_Sequence<gp_XY>& thePoints,
357 const Handle(HYDROData_Region)& theRegion,
358 int theMethod = 0) const;
361 * Returns altitudes for given points on given zone.
362 * \param thePoints the points to examine
363 * \param theZone reference zone to check
364 * \return result altitude value
366 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
367 const NCollection_Sequence<gp_XY>& thePoints,
368 const Handle(HYDROData_Zone)& theZone,
369 int theMethod = 0) const;
372 * Returns region to which the point is belongs.
373 * \param thePoint the point to examine
374 * if it is needed to search Land Cover region
375 * \return result region
377 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
380 * Returns zone to which the point is belongs.
381 * \param thePoint the point to examine
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 ) const;
388 * Returns classification of point for given zone.
389 * \param thePoint the point to examine
390 * \param theZone the zone to examine
391 * \return result classification
393 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
394 const gp_XY& thePoint,
395 const Handle(HYDROData_Zone)& theZone ) const;
397 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
398 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
400 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
401 const bool theIsSetToUpdate = true );
402 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
403 HYDROData_PriorityType thePriority,
404 const Handle(HYDROData_Entity)& theObject2,
405 HYDROData_Zone::MergeType theMergeType,
406 HYDROData_CalculationCase::DataTag theDataTag );
407 HYDRODATA_EXPORT bool GetRule( int theIndex,
408 Handle(HYDROData_Entity)& theObject1,
409 HYDROData_PriorityType& thePriority,
410 Handle(HYDROData_Entity)& theObject2,
411 HYDROData_Zone::MergeType& theMergeType,
412 HYDROData_CalculationCase::DataTag& theDataTag ) const;
414 HYDRODATA_EXPORT QString DumpRules() const;
416 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
421 * Add new one region for calculation case.
422 * The new region is added into the list of reference regions.
424 Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
425 const QString& thePrefixOrName,
426 bool isPrefix = true );
429 * Add new one split edges group for calculation case.
431 Handle(HYDROData_SplitShapesGroup) addNewSplitGroup( const QString& theName );
434 * Exports the given faces as shell and the given groups to GEOM module.
435 * \param theGeomEngine GEOM module engine
436 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
437 * \param theFaces the list of faces to make shell
438 * \param theSplitGroups the list of groups
439 * \return true in case of success
442 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
443 SALOMEDS::Study_ptr theStudy,
444 const NCollection_IndexedDataMap<TopoDS_Shape, QString>& aFacesToName,
445 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
446 QString& theGeomObjEntry ) const;
449 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
450 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
451 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
452 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
454 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
455 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
457 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
459 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
461 void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
462 const QString& theOldCaseName,
463 const QString& theName );
465 void DumpRegionsToPython( QStringList& theResList,
466 const QString& thePyScriptPath,
467 MapOfTreatedObjects& theTreatedObjects,
468 const HYDROData_SequenceOfObjects& theRegions ) const;
471 friend class HYDROData_Iterator;
474 * Creates new object in the internal data structure. Use higher level objects
475 * to create objects with real content.
477 HYDRODATA_EXPORT HYDROData_CalculationCase();
480 * Destructs properties of the object and object itself, removes it from the document.
482 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
484 void DumpSampleMeshing( QStringList& theScript,
485 const QString& theStudyName,
486 const QString& theGeomShapeName,
487 const QString& theMeshName ) const;
490 HYDROData_Warning myLastWarning;