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>
29 #include <SALOMEconfig.h>
30 #include CORBA_SERVER_HEADER(GEOM_Gen)
36 class TopTools_ListOfShape;
38 class Handle(HYDROData_Object);
39 class Handle(HYDROData_Region);
40 class Handle(HYDROData_Zone);
41 class Handle(HYDROData_PolylineXY);
42 class Handle(HYDROData_ShapesGroup);
43 class Handle(HYDROData_SplittedShapesGroup);
44 class Handle(HYDROData_Document);
45 class Handle(HYDROData_StricklerTable);
46 class Handle(HYDROData_LandCover);
48 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
51 /**\class HYDROData_CalculationCase
52 * \brief Calculation case is defined by selection of Geometry objects with or without
\93Zone of water
\94.
55 class HYDROData_CalculationCase : public HYDROData_Entity
59 enum PointClassification
61 POINT_OUT, ///< point is out of zone face
62 POINT_IN, ///< point is inside of zone face
63 POINT_ON ///< point is on the edge of zone face
75 * Enumeration of tags corresponding to the persistent object parameters.
79 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
80 DataTag_GeometryObject, ///< reference geometry objects
81 DataTag_ChildRegion, ///< child regions
82 DataTag_Region, ///< reference regions
83 DataTag_Polyline, ///< reference boundary polyline
84 DataTag_GeometryGroup, ///< reference geometry groups
85 DataTag_SplittedGroups, ///< reference splitted groups
86 DataTag_CustomRules, ///< custom rules
87 DataTag_AssignmentMode, ///< assignment mode
88 DataTag_StricklerTable, ///< reference Strickler table
89 DataTag_LandCover, ///< reference land covers
90 DataTag_CustomLandCoverRules, ///< custom rules for land covers priority
91 DataTag_AssignmentLandCoverMode, ///< assignment mode of land covers priority
92 DataTag_ChildLandCoverRegion, ///< child land cover regions
93 DataTag_LandCoverRegion ///< reference land cover regions
98 DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
101 * Returns the kind of this object. Must be redefined in all objects of known type.
103 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
106 * Updates the name of this object.
107 * Reimplemented to update the names of regions, zones and splitted groups.
109 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
112 * Dump Calculation object to Python script representation.
114 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
117 * Update the calcualtion case object.
118 * Call this method whenever you made changes for object data.
120 HYDRODATA_EXPORT virtual void Update();
123 * Returns the list of all reference objects of this object.
125 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
128 // Public methods to work with Calculation
131 * Add new one reference geometry object for calculation case.
133 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
136 * Returns all reference geometry objects of calculation case.
138 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
141 * Removes reference geometry object from calculation case.
143 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
146 * Removes all reference geometry objects from calculation case.
148 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
152 * Add new one reference geometry group for calculation case.
154 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
157 * Returns all reference geometry groups of calculation case.
159 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
162 * Removes reference geometry group from calculation case.
164 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
167 * Removes all reference geometry groups from calculation case.
169 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
173 * Sets reference boundary polyline object for calculation case.
175 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
178 * Returns reference boundary polyline object of calculation case.
180 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
183 * Remove reference boundary polyline object from calculation case.
185 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
189 * Sets reference Strickler table for calculation case.
191 HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
194 * Returns reference Strickler table of calculation case.
196 HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
199 * Remove reference Strickler table from calculation case.
201 HYDRODATA_EXPORT virtual void RemoveStricklerTable();
205 * Add new one reference land cover for calculation case.
207 HYDRODATA_EXPORT virtual bool AddLandCover( const Handle(HYDROData_LandCover)& theLandCover );
210 * Returns all reference land covers of calculation case.
212 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetLandCovers() const;
215 * Removes reference land cover from calculation case.
217 HYDRODATA_EXPORT virtual void RemoveLandCover( const Handle(HYDROData_LandCover)& theLandCover );
220 * Removes all reference land covers from calculation case.
222 HYDRODATA_EXPORT virtual void RemoveLandCovers();
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.
231 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone,
232 const bool theLandCover );
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.
239 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion,
240 const bool theLandCover );
243 * Returns all reference regions of calculation case.
245 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions( const bool theLandCover ) const;
248 * Updates names of regions to correct order.
250 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
253 * Removes reference region from calculation case.
255 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
258 * Removes all reference regions from calculation case.
260 HYDRODATA_EXPORT virtual void RemoveRegions( const bool theLandCover );
263 * Returns all reference geometry groups of calculation case.
265 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
268 * Removes all reference geometry groups from calculation case.
270 HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
273 * Exports the calculation case data (shell and groups) to GEOM module.
274 * \param theStudyId the id of the study where the GEOM module should be used for export
275 * \return the entry of the GEOM object (empty string in the case of error)
277 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
280 * Exports the calculation case data (shell and groups) to GEOM module.
281 * \param theGeomEngine GEOM module engine
282 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
283 * \return true in case of success
285 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
286 SALOMEDS::Study_ptr theStudy,
287 QString& theGeomObjEntry ) const;
290 // Public methods to work with Calculation services
293 * Returns altitude for given point.
294 * \param thePoint the point to examine
295 * \return result altitude value
297 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
300 * Returns altitude for given point on given region.
301 * \param thePoint the point to examine
302 * \param theRegion reference region to check
303 * \return result altitude value
305 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
306 const Handle(HYDROData_Region)& theRegion ) const;
309 * Returns altitude for given point on given zone.
310 * \param thePoint the point to examine
311 * \param theZone reference zone to check
312 * \return result altitude value
314 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
315 const Handle(HYDROData_Zone)& theZone ) const;
318 * Returns altitudes for given points on given region.
319 * \param thePoints the points to examine
320 * \param theRegion reference region to check
321 * \return result altitude value
323 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
324 const NCollection_Sequence<gp_XY>& thePoints,
325 const Handle(HYDROData_Region)& theRegion ) const;
328 * Returns altitudes for given points on given zone.
329 * \param thePoints the points to examine
330 * \param theZone reference zone to check
331 * \return result altitude value
333 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
334 const NCollection_Sequence<gp_XY>& thePoints,
335 const Handle(HYDROData_Zone)& theZone ) const;
338 * Returns region to which the point is belongs.
339 * \param thePoint the point to examine
340 * \param theLandCover the flag indicating,
341 * if it is needed to search land cover region
342 * \return result region
344 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint,
345 const bool theLandCover ) const;
348 * Returns zone to which the point is belongs.
349 * \param thePoint the point to examine
350 * \param theLandCover the flag indicating,
351 * if it is needed to search land cover zone
352 * \return result zone
354 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint,
355 const bool theLandCover ) const;
358 * Returns classification of point for given zone.
359 * \param thePoint the point to examine
360 * \param theZone the zone to examine
361 * \return result classification
363 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
364 const gp_XY& thePoint,
365 const Handle(HYDROData_Zone)& theZone ) const;
367 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
368 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
370 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
371 const bool theIsSetToUpdate = true );
372 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
373 HYDROData_PriorityType thePriority,
374 const Handle(HYDROData_Entity)& theObject2,
375 HYDROData_Zone::MergeAltitudesType theMergeType,
376 HYDROData_CalculationCase::DataTag theDataTag );
377 HYDRODATA_EXPORT bool GetRule( int theIndex,
378 Handle(HYDROData_Entity)& theObject1,
379 HYDROData_PriorityType& thePriority,
380 Handle(HYDROData_Entity)& theObject2,
381 HYDROData_Zone::MergeAltitudesType& theMergeType,
382 HYDROData_CalculationCase::DataTag& theDataTag ) const;
384 HYDRODATA_EXPORT void SetAssignmentLandCoverMode( AssignmentMode theMode );
385 HYDRODATA_EXPORT AssignmentMode GetAssignmentLandCoverMode() const;
387 HYDRODATA_EXPORT QString DumpRules() const;
389 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
394 * Add new one region for calculation case.
395 * The new region is added into the list of reference regions.
397 Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
398 const QString& thePrefixOrName,
399 const bool theLandCover,
400 bool isPrefix = true );
403 * Add new one splitted edges group for calculation case.
405 Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup( const QString& theName );
408 * Exports the given faces as shell and the given groups to GEOM module.
409 * \param theGeomEngine GEOM module engine
410 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
411 * \param theFaces the list of faces to make shell
412 * \param theSplittedGroups the list of groups
413 * \return true in case of success
415 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
416 SALOMEDS::Study_ptr theStudy,
417 const TopTools_ListOfShape& theFaces,
418 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
419 QString& theGeomObjEntry ) const;
422 * Publish the given shape in GEOM as a GEOM object.
423 * \param theGeomEngine GEOM module engine
424 * \param theStudy SALOMEDS study, used for publishing of the shape
425 * \param theShape the shape to publish as a GEOM object
426 * \param theName the name of the published object
427 * \return the published GEOM object
429 GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var theGeomEngine,
430 SALOMEDS::Study_ptr theStudy,
431 const TopoDS_Shape& theShape,
432 const QString& theName,
433 QString& theGeomObjEntry ) const;
435 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
436 const HYDROData_SplitToZonesTool::SplitDataList& theZones,
437 const bool theLandCover );
438 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
439 const HYDROData_SplitToZonesTool::SplitDataList& theZones,
440 const bool theLandCover );
442 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
443 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
445 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
447 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
449 void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
450 const QString& theOldCaseName,
451 const QString& theName );
453 void DumpRegionsToPython( QStringList& theResList,
454 MapOfTreatedObjects& theTreatedObjects,
455 const HYDROData_SequenceOfObjects& theRegions ) const;
458 friend class HYDROData_Iterator;
461 * Creates new object in the internal data structure. Use higher level objects
462 * to create objects with real content.
464 HYDRODATA_EXPORT HYDROData_CalculationCase();
467 * Destructs properties of the object and object itself, removes it from the document.
469 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
471 void DumpSampleMeshing( QStringList& theScript,
472 const QString& theStudyName,
473 const QString& theGeomShapeName,
474 const QString& theMeshName ) const;
477 HYDROData_Warning myLastWarning;