From c773b2aacb4471d14d698e60df3ffa5889421a71 Mon Sep 17 00:00:00 2001 From: adv Date: Mon, 11 Nov 2013 05:03:26 +0000 Subject: [PATCH] Get the gepmetry objects method added. --- src/HYDROData/HYDROData_CalculationCase.cxx | 6 +----- src/HYDROData/HYDROData_Tool.cxx | 10 ++++++++++ src/HYDROData/HYDROData_Tool.h | 8 ++++++++ src/HYDROGUI/HYDROGUI_Tool.cxx | 18 ++++++++++++++++++ src/HYDROGUI/HYDROGUI_Tool.h | 7 +++++++ 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 764d3cd1..0561d47e 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -130,11 +130,7 @@ void HYDROData_CalculationCase::SplitGeometryObjects() bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) { - if ( theObject.IsNull() ) - return false; - - if ( !theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) && - !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) ) + if ( !HYDROData_Tool::IsGeometryObject( theObject ) ) return false; // Wrong type of object if ( HasReference( theObject, DataTag_GeometryObject ) ) diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index 8c05efa2..c217725a 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -1,8 +1,10 @@ #include "HYDROData_Tool.h" +#include "HYDROData_ArtificialObject.h" #include "HYDROData_Image.h" #include "HYDROData_Iterator.h" +#include "HYDROData_NaturalObject.h" #include #include @@ -150,3 +152,11 @@ HYDROData_SequenceOfObjects HYDROData_Tool::FindObjectsByNames( const Handle(HYD return aResSeq; } +bool HYDROData_Tool::IsGeometryObject( const Handle(HYDROData_Entity)& theObject ) +{ + if ( theObject.IsNull() ) + return false; + + return theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) || + theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ); +} diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index 04835c87..5b550ca2 100644 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -59,6 +59,14 @@ public: static HYDROData_SequenceOfObjects FindObjectsByNames( const Handle(HYDROData_Document)& theDoc, const QStringList& theNames, const ObjectKind theObjectKind = KIND_UNKNOWN ); + + /** + * \brief Checks the type of object. + * \param theObject object to check + * \return true if object is geometry object + */ + static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject ); + }; inline bool ValuesEquals( const double& theFirst, const double& theSecond ) diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index 6fa0a831..cf877cb3 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -298,6 +298,24 @@ Handle(HYDROData_Entity) HYDROGUI_Tool::GetSelectedObject( HYDROGUI_Module* theM return NULL; } +HYDROData_SequenceOfObjects HYDROGUI_Tool::GetGeometryObjects( + const Handle(HYDROData_Document)& theDoc ) +{ + HYDROData_SequenceOfObjects aResSeq; + + HYDROData_Iterator anIter( theDoc ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Entity) anObj = anIter.Current(); + if ( !HYDROData_Tool::IsGeometryObject( anObj ) ) + continue; + + aResSeq.Append( anObj ); + } + + return aResSeq; +} + ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule ) { HYDROGUI_DataModel* aModel = theModule->getDataModel(); diff --git a/src/HYDROGUI/HYDROGUI_Tool.h b/src/HYDROGUI/HYDROGUI_Tool.h index 1874513a..56d1035a 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.h +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@ -148,6 +148,13 @@ public: */ static Handle(HYDROData_Entity) GetSelectedObject( HYDROGUI_Module* theModule ); + /** + * \brief Get the geometry data objects from document. + * \param theDoc document + * \return sequence of data objects + */ + static HYDROData_SequenceOfObjects GetGeometryObjects( const Handle(HYDROData_Document)& theDoc ); + /** * \brief Get kind of objects the selected partition contains. * \param theModule module -- 2.39.2