]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #817: Be able to export the whole part.
authornds <nds@opencascade.com>
Fri, 28 Aug 2015 14:43:56 +0000 (17:43 +0300)
committernds <nds@opencascade.com>
Fri, 28 Aug 2015 14:44:30 +0000 (17:44 +0300)
It provides finite validators to skip Axis,Plane selection in Export.

src/ExchangePlugin/plugin-Exchange.xml
src/GeomValidators/CMakeLists.txt
src/GeomValidators/GeomValidators_Finite.cpp [new file with mode: 0755]
src/GeomValidators/GeomValidators_Finite.h [new file with mode: 0755]
src/GeomValidators/GeomValidators_PartSet.h
src/PartSet/PartSet_FilterInfinite.cpp
src/PartSet/PartSet_Module.cpp

index adb17dd86f3acdf4b7a6a0ba71ad0dd07569e7a6..5a0d97d08123c8f773be9f331791c59df5493efc 100644 (file)
@@ -14,6 +14,7 @@
         </export_file_selector>
         <multi_selector id="selection_list" tooltip="Select a set of objects" type_choice="Vertices Edges Faces Solids Objects">
           <validator id="GeomValidators_PartSet"/>
+          <validator id="GeomValidators_Finite"/>
         </multi_selector>
       </feature>
     </group>
index 56c6b1ba4ca44a3e48a2626695108da46c0c1890..9a7338db230cf431bfb67c80e911a901cad3ebe2 100644 (file)
@@ -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 (executable)
index 0000000..e4f6231
--- /dev/null
@@ -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 <GeomValidators_Finite.h>
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultConstruction.h>
+
+bool GeomValidators_Finite::isValid(const AttributePtr& theAttribute,
+                                   const std::list<std::string>& theArguments,
+                                   std::string& theError) const
+{
+  bool aValid = true;
+
+  if (theAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectionListAttr = 
+                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(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<ModelAPI_ResultConstruction>(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 (executable)
index 0000000..927142d
--- /dev/null
@@ -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 <GeomValidators.h>
+#include <ModelAPI_AttributeValidator.h>
+
+/**
+* \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<std::string>& theArguments,
+                                             std::string& theError) const;
+};
+
+#endif
index dc80cc568f2efd768d4fbc62b8390cf779da1bce..b8b374303800e2b091990dc933c59a2eb834e0c0 100755 (executable)
@@ -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
 {
index b26ad156fae12cb6fd815269971925b1ec018719..7b8d328bac88f44067bb6cbdb6e478f5c09f3539 100755 (executable)
@@ -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;
 }
index 361e12d5dde9b2c57fc88a812ed7c7ae7095c839..19c8469e35db2fe8d149e4b68bf5d4470856e6f0 100755 (executable)
@@ -37,6 +37,7 @@
 
 #include <GeomValidators_ShapeType.h>
 #include <GeomValidators_PartSet.h>
+#include <GeomValidators_Finite.h>
 #include <GeomValidators_Face.h>
 #include <GeomValidators_ConstructionComposite.h>
 #include <GeomValidators_ZeroOffset.h>
@@ -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);