From: nds Date: Fri, 31 Jul 2015 12:13:26 +0000 (+0300) Subject: Partition feature definition. X-Git-Tag: V_1.4.0_beta4~439 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9cce20c7c60a1f7807f452cf8858fdfcdfc3255f;p=modules%2Fshaper.git Partition feature definition. --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 77f89e52c..1fa7948da 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -12,6 +12,7 @@ SET(PROJECT_HEADERS FeaturesPlugin_Movement.h FeaturesPlugin_Boolean.h FeaturesPlugin_Group.h + FeaturesPlugin_Partition.h FeaturesPlugin_Placement.h FeaturesPlugin_CompositeBoolean.h FeaturesPlugin_ExtrusionBoolean.h @@ -30,6 +31,7 @@ SET(PROJECT_SOURCES FeaturesPlugin_Movement.cpp FeaturesPlugin_Boolean.cpp FeaturesPlugin_Group.cpp + FeaturesPlugin_Partition.cpp FeaturesPlugin_Placement.cpp FeaturesPlugin_CompositeBoolean.cpp FeaturesPlugin_ExtrusionBoolean.cpp @@ -52,6 +54,7 @@ SET(XML_RESOURCES movement_widget.xml boolean_widget.xml group_widget.xml + partition_widget.xml placement_widget.xml ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index 092b37406..26cb739e9 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -28,7 +28,7 @@ #define _LAST_TAG 3 #define EDGE 6 -#define DEBUG_COMPSOLID +//#define DEBUG_COMPSOLID //#define DEBUG_COMPSOLID_SHAPE //================================================================================================= diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp new file mode 100755 index 000000000..284acd118 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -0,0 +1,57 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesPlugin_Partition.cpp +// Created: 31 Jul 2015 +// Author: Natalia ERMOLAEVA + +#include "FeaturesPlugin_Partition.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================================= +FeaturesPlugin_Partition::FeaturesPlugin_Partition() +{ +} + +//================================================================================================= +void FeaturesPlugin_Partition::initAttributes() +{ + + AttributeSelectionListPtr aSelection = + std::dynamic_pointer_cast(data()->addAttribute( + FeaturesPlugin_Partition::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); + aSelection->setSelectionType("SOLID"); + + aSelection = std::dynamic_pointer_cast(data()->addAttribute( + FeaturesPlugin_Partition::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); + aSelection->setSelectionType("SOLID"); + + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID()); +} + +//================================================================================================= +std::shared_ptr FeaturesPlugin_Partition::getShape(const std::string& theAttrName) +{ + std::shared_ptr aObjRef = std::dynamic_pointer_cast< + ModelAPI_AttributeReference>(data()->attribute(theAttrName)); + if (aObjRef) { + std::shared_ptr aConstr = std::dynamic_pointer_cast< + ModelAPI_ResultBody>(aObjRef->value()); + if (aConstr) + return aConstr->shape(); + } + return std::shared_ptr(); +} + +//================================================================================================= +void FeaturesPlugin_Partition::execute() +{ +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.h b/src/FeaturesPlugin/FeaturesPlugin_Partition.h new file mode 100755 index 000000000..444d3e8fb --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.h @@ -0,0 +1,62 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesPlugin_Partition.h +// Created: 31 Jul 2015 +// Author: Natalia ERMOLAEVA + +#ifndef FeaturesPlugin_Partition_H_ +#define FeaturesPlugin_Partition_H_ + +#include "FeaturesPlugin.h" +#include + +/**\class FeaturesPlugin_Partition + * \ingroup Plugins + * \brief Feature for applying of Partition operations on Solids. Partition makes conjunctional + * faces of solids as shared. The result of partitions is a compsolid. + * Main objects are solids, tool objects are solids or faces + */ +class FeaturesPlugin_Partition : public ModelAPI_Feature +{ +public: + /// Extrusion kind + inline static const std::string& ID() + { + static const std::string MY_ID("Partition"); + return MY_ID; + } + /// attribute name of referenced object + inline static const std::string& OBJECT_LIST_ID() + { + static const std::string MY_OBJECT_LIST_ID("main_objects"); + return MY_OBJECT_LIST_ID; + } + /// attribute name of tool object + inline static const std::string& TOOL_LIST_ID() + { + static const std::string MY_TOOL_LIST_ID("tool_objects"); + return MY_TOOL_LIST_ID; + } + + /// Returns the kind of a feature + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = FeaturesPlugin_Partition::ID(); + return MY_KIND; + } + + /// Creates a new part document if needed + FEATURESPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + FEATURESPLUGIN_EXPORT virtual void initAttributes(); + + /// Use plugin manager for features creation + FeaturesPlugin_Partition(); + +private: + std::shared_ptr getShape(const std::string& theAttrName); + +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp index 12ed91342..d3d243a4a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,8 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID) return FeaturePtr(new FeaturesPlugin_Boolean); } else if (theFeatureID == FeaturesPlugin_Group::ID()) { return FeaturePtr(new FeaturesPlugin_Group); + } else if (theFeatureID == FeaturesPlugin_Partition::ID()) { + return FeaturePtr(new FeaturesPlugin_Partition); } else if (theFeatureID == FeaturesPlugin_Placement::ID()) { return FeaturePtr(new FeaturesPlugin_Placement); } else if (theFeatureID == FeaturesPlugin_ExtrusionCut::ID()) { diff --git a/src/FeaturesPlugin/partition_widget.xml b/src/FeaturesPlugin/partition_widget.xml new file mode 100755 index 000000000..33e2c0174 --- /dev/null +++ b/src/FeaturesPlugin/partition_widget.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index b5dc47317..0140d4fca 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -28,6 +28,9 @@ + + + icons/radius.png icons/perpendicular.png icons/parallel.png + icons/partition.png icons/length.png icons/distance.png icons/radius_constr.png diff --git a/src/PartSet/icons/partition.png b/src/PartSet/icons/partition.png new file mode 100755 index 000000000..bc3ce0188 Binary files /dev/null and b/src/PartSet/icons/partition.png differ