From 9cce20c7c60a1f7807f452cf8858fdfcdfc3255f Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 31 Jul 2015 15:13:26 +0300 Subject: [PATCH] Partition feature definition. --- src/FeaturesPlugin/CMakeLists.txt | 3 + .../FeaturesPlugin_Extrusion.cpp | 2 +- .../FeaturesPlugin_Partition.cpp | 57 ++++++++++++++++ src/FeaturesPlugin/FeaturesPlugin_Partition.h | 62 ++++++++++++++++++ src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp | 3 + src/FeaturesPlugin/partition_widget.xml | 22 +++++++ src/FeaturesPlugin/plugin-Features.xml | 3 + src/PartSet/PartSet_icons.qrc | 1 + src/PartSet/icons/partition.png | Bin 0 -> 899 bytes 9 files changed, 152 insertions(+), 1 deletion(-) create mode 100755 src/FeaturesPlugin/FeaturesPlugin_Partition.cpp create mode 100755 src/FeaturesPlugin/FeaturesPlugin_Partition.h create mode 100755 src/FeaturesPlugin/partition_widget.xml create mode 100755 src/PartSet/icons/partition.png 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 0000000000000000000000000000000000000000..bc3ce0188c613faadfb1b4b4230bbc7a9b09f5bb GIT binary patch literal 899 zcmV-}1AP36P)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ;`AI}URCwBA{Qv(y12q9a05LI882|(j)eQs)AgUV( z5I~H$BvMjRz=8Ys?_W6n^XCu4&!0cR`0LlN44*%LX87>o1H=9M_u=LM1P}{0!x9q{ z|EqiCGW`AbpW)A65dH^d{|3^3{`_P33B*5s{bkrQA&%kw`}ZI%%0T=Ah`#~^5QdlI z;^O|Rd*(Cz0%`pHkKxL*D4fEfnjegWbOK)eGWfWQW-tE>M%6dB3D0Mh*H zGXuk~U%+JXi{Ts4dq06j>f=Kjyf$OuZzL}OLwG#I-di1k4x0|XGun>TNGfV2TLE!9|M&SUug z@f8Cz3mY&JeuMG