From d42b3c64fb51ebaaacc8b79fb0e86977b488476d Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 28 Aug 2015 17:43:56 +0300 Subject: [PATCH] Issue #817: Be able to export the whole part. It provides finite validators to skip Axis,Plane selection in Export. --- src/ExchangePlugin/plugin-Exchange.xml | 1 + src/GeomValidators/CMakeLists.txt | 2 ++ src/GeomValidators/GeomValidators_Finite.cpp | 34 ++++++++++++++++++++ src/GeomValidators/GeomValidators_Finite.h | 28 ++++++++++++++++ src/GeomValidators/GeomValidators_PartSet.h | 5 +-- src/PartSet/PartSet_FilterInfinite.cpp | 2 +- src/PartSet/PartSet_Module.cpp | 3 ++ 7 files changed, 72 insertions(+), 3 deletions(-) create mode 100755 src/GeomValidators/GeomValidators_Finite.cpp create mode 100755 src/GeomValidators/GeomValidators_Finite.h diff --git a/src/ExchangePlugin/plugin-Exchange.xml b/src/ExchangePlugin/plugin-Exchange.xml index adb17dd86..5a0d97d08 100644 --- a/src/ExchangePlugin/plugin-Exchange.xml +++ b/src/ExchangePlugin/plugin-Exchange.xml @@ -14,6 +14,7 @@ + diff --git a/src/GeomValidators/CMakeLists.txt b/src/GeomValidators/CMakeLists.txt index 56c6b1ba4..9a7338db2 100644 --- a/src/GeomValidators/CMakeLists.txt +++ b/src/GeomValidators/CMakeLists.txt @@ -7,6 +7,7 @@ SET(PROJECT_HEADERS GeomValidators_BooleanArguments.h GeomValidators_ConstructionComposite.h GeomValidators_Face.h + GeomValidators_Finite.h GeomValidators_PartSet.h GeomValidators_Positive.h GeomValidators_ShapeType.h @@ -19,6 +20,7 @@ SET(PROJECT_SOURCES GeomValidators_BooleanArguments.cpp GeomValidators_ConstructionComposite.cpp GeomValidators_Face.cpp + GeomValidators_Finite.cpp GeomValidators_PartSet.cpp GeomValidators_Positive.cpp GeomValidators_ShapeType.cpp diff --git a/src/GeomValidators/GeomValidators_Finite.cpp b/src/GeomValidators/GeomValidators_Finite.cpp new file mode 100755 index 000000000..e4f623104 --- /dev/null +++ b/src/GeomValidators/GeomValidators_Finite.cpp @@ -0,0 +1,34 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomValidators_Finite.cpp +// Created: 27 Aug 2015 +// Author: Natalia ERMOLAEVA + +#include + +#include +#include + +bool GeomValidators_Finite::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const +{ + bool aValid = true; + + if (theAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) { + AttributeSelectionListPtr aSelectionListAttr = + std::dynamic_pointer_cast(theAttribute); + for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) { + AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i); + ResultPtr aResult = aSelectAttr->context(); + if (aResult.get() && aResult->groupName() == ModelAPI_ResultConstruction::group()) { + ResultConstructionPtr aConstruction = std::dynamic_pointer_cast(aResult); + if (aConstruction.get() && aConstruction->isInfinite()) { + aValid = false; + } + } + } + } + return aValid; +} + diff --git a/src/GeomValidators/GeomValidators_Finite.h b/src/GeomValidators/GeomValidators_Finite.h new file mode 100755 index 000000000..927142dd6 --- /dev/null +++ b/src/GeomValidators/GeomValidators_Finite.h @@ -0,0 +1,28 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomValidators_Finite.h +// Created: 27 Aug 2015 +// Author: Natalia ERMOLAEVA + +#ifndef GeomValidators_Finite_H +#define GeomValidators_Finite_H + +#include +#include + +/** +* \ingroup Validators +* A validator for finite objects. It returns false for construction infinite results. +*/ +class GeomValidators_Finite : public ModelAPI_AttributeValidator +{ +public: + //! returns true if attribute is valid + //! \param theAttribute the checked attribute + //! \param theArguments arguments of the attribute + GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const; +}; + +#endif diff --git a/src/GeomValidators/GeomValidators_PartSet.h b/src/GeomValidators/GeomValidators_PartSet.h index dc80cc568..b8b374303 100755 --- a/src/GeomValidators/GeomValidators_PartSet.h +++ b/src/GeomValidators/GeomValidators_PartSet.h @@ -1,6 +1,6 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -// File: GeomValidators_Face.h +// File: GeomValidators_PartSet.h // Created: 27 Aug 2015 // Author: Natalia ERMOLAEVA @@ -12,7 +12,8 @@ /** * \ingroup Validators -* A validator for partset objects. +* A validator for partset document. When PartSet is active, the attribute can accept only +* shape, which coincide to the shape of result. */ class GeomValidators_PartSet : public ModelAPI_AttributeValidator { diff --git a/src/PartSet/PartSet_FilterInfinite.cpp b/src/PartSet/PartSet_FilterInfinite.cpp index b26ad156f..7b8d328ba 100755 --- a/src/PartSet/PartSet_FilterInfinite.cpp +++ b/src/PartSet/PartSet_FilterInfinite.cpp @@ -53,7 +53,7 @@ Standard_Boolean PartSet_FilterInfinite::IsOk(const Handle(SelectMgr_EntityOwner } } #ifdef DEBUG_FILTERS - qDebug(QString("ModuleBase_ShapeDocumentFilter::IsOk = %1").arg(aValid).toStdString().c_str()); + qDebug(QString("PartSet_FilterInfinite::IsOk = %1").arg(aValid).toStdString().c_str()); #endif return aValid; } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 361e12d5d..19c8469e3 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -211,6 +212,8 @@ void PartSet_Module::registerValidators() aFactory->registerValidator("GeomValidators_PartSet", new GeomValidators_PartSet); + aFactory->registerValidator("GeomValidators_Finite", new GeomValidators_Finite); + aFactory->registerValidator("GeomValidators_ConstructionComposite", new GeomValidators_ConstructionComposite); -- 2.39.2