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 );
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 * Exports the calculation case data (shell and groups) to GEOM module.
290 * \param theStudyId the id of the study where the GEOM module should be used for export
291 * \return the entry of the GEOM object (empty string in the case of error)
293 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
296 * Exports the calculation case data (shell and groups) to GEOM module.
297 * \param theGeomEngine GEOM module engine
298 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
299 * \param theGeomObjEntry the published GEOM object entry
300 * \param theErrorMsg the error message
301 * \return true in case of success
304 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
305 SALOMEDS::Study_ptr theStudy,
306 QString& theGeomObjEntry,
307 QString& theErrorMsg,
308 QString& statMess) const;
312 // Public methods to work with Calculation services
315 * Returns altitude for given point.
316 * \param thePoint the point to examine
317 * \return result altitude value
319 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
322 * Returns altitude for given point on given region.
323 * \param thePoint the point to examine
324 * \param theRegion reference region to check
325 * \return result altitude value
327 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
328 const Handle(HYDROData_Region)& theRegion,
329 int theMethod = 0) const;
332 * Returns altitude for given point on given zone.
333 * \param thePoint the point to examine
334 * \param theZone reference zone to check
335 * \return result altitude value
337 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
338 const Handle(HYDROData_Zone)& theZone,
339 int theMethod = 0) 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;
348 HYDRODATA_EXPORT std::vector<double> GetStricklerCoefficientForPoints(const std::vector<gp_XY>& thePoints,
352 HYDRODATA_EXPORT std::vector<int> GetStricklerTypeForPoints( const std::vector<gp_XY>& thePoints ) const;
355 * Returns altitudes for given points on given region.
356 * \param thePoints the points to examine
357 * \param theRegion reference region to check
358 * \return result altitude value
360 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
361 const NCollection_Sequence<gp_XY>& thePoints,
362 const Handle(HYDROData_Region)& theRegion,
363 int theMethod = 0) const;
366 * Returns altitudes for given points on given zone.
367 * \param thePoints the points to examine
368 * \param theZone reference zone to check
369 * \return result altitude value
371 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
372 const NCollection_Sequence<gp_XY>& thePoints,
373 const Handle(HYDROData_Zone)& theZone,
374 int theMethod = 0) const;
377 * Returns region to which the point is belongs.
378 * \param thePoint the point to examine
379 * if it is needed to search Land Cover region
380 * \return result region
382 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
385 * Returns zone to which the point is belongs.
386 * \param thePoint the point to examine
387 * if it is needed to search Land Cover zone
388 * \return result zone
390 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
393 * Returns classification of point for given zone.
394 * \param thePoint the point to examine
395 * \param theZone the zone to examine
396 * \return result classification
398 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
399 const gp_XY& thePoint,
400 const Handle(HYDROData_Zone)& theZone ) const;
402 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
403 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
405 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
406 const bool theIsSetToUpdate = true );
407 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
408 HYDROData_PriorityType thePriority,
409 const Handle(HYDROData_Entity)& theObject2,
410 HYDROData_Zone::MergeType theMergeType,
411 HYDROData_CalculationCase::DataTag theDataTag );
412 HYDRODATA_EXPORT bool GetRule( int theIndex,
413 Handle(HYDROData_Entity)& theObject1,
414 HYDROData_PriorityType& thePriority,
415 Handle(HYDROData_Entity)& theObject2,
416 HYDROData_Zone::MergeType& theMergeType,
417 HYDROData_CalculationCase::DataTag& theDataTag ) const;
419 HYDRODATA_EXPORT QString DumpRules() 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 bool isPrefix = true );
434 * Add new one split edges group for calculation case.
436 Handle(HYDROData_SplitShapesGroup) addNewSplitGroup( const QString& theName );
439 * Exports the given faces as shell and the given groups to GEOM module.
440 * \param theGeomEngine GEOM module engine
441 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
442 * \param theFaces the list of faces to make shell
443 * \param theSplitGroups the list of groups
444 * \return true in case of success
447 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
448 SALOMEDS::Study_ptr theStudy,
449 const NCollection_IndexedDataMap<TopoDS_Shape, QString>& aFacesToName,
450 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
451 QString& theGeomObjEntry ) const;
454 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
455 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
456 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
457 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
459 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
460 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
462 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
464 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
466 void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
467 const QString& theOldCaseName,
468 const QString& theName );
470 void DumpRegionsToPython( QStringList& theResList,
471 const QString& thePyScriptPath,
472 MapOfTreatedObjects& theTreatedObjects,
473 const HYDROData_SequenceOfObjects& theRegions ) const;
476 friend class HYDROData_Iterator;
479 * Creates new object in the internal data structure. Use higher level objects
480 * to create objects with real content.
482 HYDRODATA_EXPORT HYDROData_CalculationCase();
485 * Destructs properties of the object and object itself, removes it from the document.
487 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
489 void DumpSampleMeshing( QStringList& theScript,
490 const QString& theStudyName,
491 const QString& theGeomShapeName,
492 const QString& theMeshName ) const;
495 HYDROData_Warning myLastWarning;