label="Combine results"
default="true"
tooltip="If True combines all results to one. If False builds separate result for each object."/>
+ <validator id="GeomValidators_PartitionArguments" parameters="main_objects,tool_objects,partition_combine"/>
</source>
GeomValidators_DifferentShapes.h
GeomValidators_Face.h
GeomValidators_Finite.h
+ GeomValidators_PartitionArguments.h
GeomValidators_Positive.h
GeomValidators_ShapeType.h
GeomValidators_Tools.h
GeomValidators_DifferentShapes.cpp
GeomValidators_Face.cpp
GeomValidators_Finite.cpp
+ GeomValidators_PartitionArguments.cpp
GeomValidators_Positive.cpp
GeomValidators_ShapeType.cpp
GeomValidators_Tools.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_PartitionArguments.cpp
+// Created: 17 September 2015
+// Author: Dmitry Bobylev
+
+#include <GeomValidators_PartitionArguments.h>
+
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeSelectionList.h>
+
+//=================================================================================================
+bool GeomValidators_PartitionArguments::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ if(theArguments.size() != 3) {
+ theError = "Wrong number of arguments (expected 3).";
+ return false;
+ }
+
+ int anObjectsNb = 0, aToolsNb = 0;
+ bool isCombine = true;
+
+ std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
+
+ std::shared_ptr<ModelAPI_AttributeSelectionList> anAttrSelList = theFeature->selectionList(*anIt);
+ if(anAttrSelList) {
+ anObjectsNb = anAttrSelList->size();
+ }
+ anIt++;
+
+ anAttrSelList = theFeature->selectionList(*anIt);
+ if(anAttrSelList) {
+ aToolsNb = anAttrSelList->size();
+ }
+ anIt++;
+
+ std::shared_ptr<ModelAPI_AttributeBoolean> anAttrBool = theFeature->boolean(*anIt);
+ if(anAttrBool) {
+ isCombine = anAttrBool->value();
+ }
+
+ if((anObjectsNb > 0 && aToolsNb > 0) || (isCombine && anObjectsNb != 0 && (anObjectsNb + aToolsNb > 1))) {
+ return true;
+ }
+
+ theError = "Not enough arguments";
+ return false;
+}
+
+//=================================================================================================
+bool GeomValidators_PartitionArguments::isNotObligatory(std::string theFeature, std::string theAttribute)
+{
+ if(theAttribute == "tool_objects") {
+ return true;
+ }
+
+ return false;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_PartitionArguments.h
+// Created: 17 September 2015
+// Author: Dmitry Bobylev
+
+#ifndef GeomValidators_PartitionArguments_H
+#define GeomValidators_PartitionArguments_H
+
+#include <GeomValidators.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_FeatureValidator.h>
+
+/** \class GeomValidators_PartitionArguments
+ * \ingroup Validators
+ * \brief Validates that partition operation have enough arguments.
+ */
+class GeomValidators_PartitionArguments : public ModelAPI_FeatureValidator
+{
+public:
+ /** \brief Returns true if feature and/or attributes are valid.
+ * \param[in] theFeature the validated feature.
+ * \param[in] theArguments the arguments in the configuration file for this validator.
+ * \returns true if feature is valid.
+ */
+ GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+
+ /// \return true if the attribute in feature is not obligatory for the feature execution.
+ GEOMVALIDATORS_EXPORT virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
+};
+
+#endif
#include <GeomValidators_ZeroOffset.h>
#include <GeomValidators_BooleanArguments.h>
#include <GeomValidators_Different.h>
+#include <GeomValidators_PartitionArguments.h>
#include <ModelAPI_Object.h>
aFactory->registerValidator("GeomValidators_Different",
new GeomValidators_Different);
+
+ aFactory->registerValidator("GeomValidators_PartitionArguments",
+ new GeomValidators_PartitionArguments);
}
void PartSet_Module::registerFilters()