## Specific definitions: EHsc to avoid exceptions-linkage unresolved symbols
ADD_DEFINITIONS(-DWIN32 -D_WINDOWS /EHsc)
ENDIF(WIN32)
+
+IF(UNIX)
+ IF(CMAKE_COMPILER_IS_GNUCC)
+ #C++11 is not supported on some platforms, disable it
+ MESSAGE(STATUS "Setting -std=c++0x flag for the gcc...")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+
+ #Supporting test coverage checks (gcov) in the DEBUG mode
+ IF(USE_TEST_COVERAGE)
+ INCLUDE(CodeCoverage)
+ MESSAGE(STATUS "Setting flags for gcov support the gcc...")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
+ SET(CMAKE_SHARED_LINKER_FLAGS "-lgcov")
+
+ SETUP_TARGET_FOR_COVERAGE(test_coverage # Name for custom target.
+ ctest # Name of the test driver executable that runs the tests.
+ coverage) # Name of output directory.
+ ENDIF(USE_TEST_COVERAGE)
+
+ #SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -E")
+ MESSAGE(STATUS "gcc flags are: " ${CMAKE_CXX_FLAGS})
+ MESSAGE(STATUS "linker flags are: " ${CMAKE_SHARED_LINKER_FLAGS})
+ ENDIF(CMAKE_COMPILER_IS_GNUCC)
+ENDIF(UNIX)
# It could be called only once
FIND_PACKAGE(LibXml2 REQUIRED)
-IF(UNIX)
- IF(CMAKE_COMPILER_IS_GNUCC)
- #C++11 is not supported on some platforms, disable it
- MESSAGE(STATUS "Setting -std=c++0x flag for the gcc...")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-
- #Supporting test coverage checks (gcov) in the DEBUG mode
- IF(USE_TEST_COVERAGE)
- INCLUDE(CodeCoverage)
- MESSAGE(STATUS "Setting flags for gcov support the gcc...")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
- SET(CMAKE_SHARED_LINKER_FLAGS "-lgcov")
-
- SETUP_TARGET_FOR_COVERAGE(test_coverage # Name for custom target.
- ctest # Name of the test driver executable that runs the tests.
- coverage) # Name of output directory.
- ENDIF(USE_TEST_COVERAGE)
-
- #SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -E")
- MESSAGE(STATUS "gcc flags are: " ${CMAKE_CXX_FLAGS})
- MESSAGE(STATUS "linker flags are: " ${CMAKE_SHARED_LINKER_FLAGS})
- ENDIF(CMAKE_COMPILER_IS_GNUCC)
-ENDIF(UNIX)
-
IF(${HAVE_SALOME})
SET(SHAPER_INSTALL_ADDONS bin/salome CACHE INTERNAL "" FORCE)
SET(SHAPER_INSTALL_BIN lib/salome CACHE INTERNAL "" FORCE)
SET(SHAPER_INSTALL_XML_RESOURCES share/salome/resources/shaper CACHE INTERNAL "" FORCE)
SET(SHAPER_INSTALL_GUI_DOC share/doc/salome/gui/SHAPER CACHE INTERNAL "" FORCE)
SET(SHAPER_INSTALL_TUI_DOC share/doc/salome/tui/SHAPER CACHE INTERNAL "" FORCE)
+ # without SALOME there is another kind of documentation, separated one
+ ADD_SUBDIRECTORY (doc)
ELSE(${HAVE_SALOME})
SET(SHAPER_INSTALL_ADDONS addons CACHE INTERNAL "" FORCE)
SET(SHAPER_INSTALL_BIN bin CACHE INTERNAL "" FORCE)
SET(SHAPER_INSTALL_TUI_DOC doc CACHE INTERNAL "" FORCE)
ENDIF(${HAVE_SALOME})
-#IF(CMAKE_BUILD_TYPE MATCHES Release)
-ADD_SUBDIRECTORY (doc)
-#ENDIF(CMAKE_BUILD_TYPE MATCHES Release)
ADD_SUBDIRECTORY (src/Config)
ADD_SUBDIRECTORY (src/Events)
ADD_SUBDIRECTORY (src/Model)
ADD_SUBDIRECTORY (src/BuildPlugin)
ADD_SUBDIRECTORY (src/PrimitivesPlugin)
ADD_SUBDIRECTORY (src/FeaturesPlugin)
+ADD_SUBDIRECTORY (src/CollectionPlugin)
ADD_SUBDIRECTORY (src/SamplePanelPlugin)
ADD_SUBDIRECTORY (src/SketcherPrs)
ADD_SUBDIRECTORY (src/SketchPlugin)
ADD_SUBDIRECTORY (src/ConstructionAPI)
ADD_SUBDIRECTORY (src/ExchangeAPI)
ADD_SUBDIRECTORY (src/FeaturesAPI)
+ADD_SUBDIRECTORY (src/CollectionAPI)
ADD_SUBDIRECTORY (src/ParametersAPI)
ADD_SUBDIRECTORY (src/PartSetAPI)
ADD_SUBDIRECTORY (src/PrimitivesAPI)
--- /dev/null
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+INCLUDE(Common)
+
+SET(PROJECT_HEADERS
+ CollectionAPI.h
+ CollectionAPI_Group.h
+)
+
+SET(PROJECT_SOURCES
+ CollectionAPI_Group.cpp
+)
+
+SET(PROJECT_LIBRARIES
+ ModelAPI
+ ModelHighAPI
+)
+
+INCLUDE_DIRECTORIES(
+ ${PROJECT_SOURCE_DIR}/src/Events
+ ${PROJECT_SOURCE_DIR}/src/ModelAPI
+ ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
+)
+
+# Plugin headers dependency
+INCLUDE_DIRECTORIES(
+ ${PROJECT_SOURCE_DIR}/src/GeomAPI
+ ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
+ ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+ ${PROJECT_SOURCE_DIR}/src/CollectionPlugin
+)
+
+ADD_DEFINITIONS(-DCOLLECTIONAPI_EXPORTS)
+ADD_LIBRARY(CollectionAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(CollectionAPI ${PROJECT_LIBRARIES})
+
+# SWIG wrapper
+
+INCLUDE(PythonAPI)
+
+SET_SOURCE_FILES_PROPERTIES(CollectionAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(CollectionAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
+SET(SWIG_LINK_LIBRARIES
+ CollectionAPI
+ ModelHighAPI
+ ModelAPI
+ ${PYTHON_LIBRARIES}
+)
+
+SET(SWIG_MODULE_CollectionAPI_EXTRA_DEPS ${SWIG_MODULE_CollectionAPI_EXTRA_DEPS}
+ ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i
+ doxyhelp.i
+ ${PROJECT_HEADERS}
+)
+
+SWIG_ADD_MODULE(CollectionAPI python CollectionAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(CollectionAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+ SET_TARGET_PROPERTIES(_CollectionAPI PROPERTIES DEBUG_OUTPUT_NAME _CollectionAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _CollectionAPI DESTINATION ${SHAPER_INSTALL_SWIG})
+INSTALL(TARGETS CollectionAPI DESTINATION ${SHAPER_INSTALL_BIN})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CollectionAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef COLLECTIONAPI_H
+#define COLLECTIONAPI_H
+
+#if defined COLLECTIONAPI_EXPORTS
+#if defined WIN32
+#define COLLECTIONAPI_EXPORT __declspec( dllexport )
+#else
+#define COLLECTIONAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define COLLECTIONAPI_EXPORT __declspec( dllimport )
+#else
+#define COLLECTIONAPI_EXPORT
+#endif
+#endif
+
+#endif
--- /dev/null
+/* CollectionAPI.i */
+
+%module CollectionAPI
+
+%{
+#ifndef CollectionAPI_swig_H_
+#define CollectionAPI_swig_H_
+
+ #include <ModelHighAPI_swig.h>
+
+ #include "CollectionAPI.h"
+ #include "CollectionAPI_Group.h"
+
+#endif // CollectionAPI_swig_H_
+%}
+
+%include "doxyhelp.i"
+
+// import other modules
+%import "ModelHighAPI.i"
+
+// to avoid error on this
+#define COLLECTIONAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_shared_ptr.i"
+
+// shared pointers
+%shared_ptr(CollectionAPI_Group)
+
+// all supported interfaces
+%include "CollectionAPI_Group.h"
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: CollectionAPI_Group.cpp
+// Created: 07 June 2016
+// Author: Dmitry Bobylev
+
+#include "CollectionAPI_Group.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Integer.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+CollectionAPI_Group::CollectionAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+CollectionAPI_Group::CollectionAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setGroupList(theGroupList);
+ }
+}
+
+//==================================================================================================
+CollectionAPI_Group::~CollectionAPI_Group()
+{
+
+}
+
+//==================================================================================================
+void CollectionAPI_Group::setGroupList(const std::list<ModelHighAPI_Selection>& theGroupList)
+{
+ fillAttribute(theGroupList, mygroupList);
+
+ execute();
+}
+
+//==================================================================================================
+void CollectionAPI_Group::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ AttributeSelectionListPtr anAttrList = aBase->selectionList(CollectionPlugin_Group::LIST_ID());
+
+ theDumper << aBase << " = model.addGroup(" << aDocName << ", " << anAttrList << ")" << std::endl;
+}
+
+//==================================================================================================
+GroupPtr addGroup(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(CollectionAPI_Group::ID());
+ return GroupPtr(new CollectionAPI_Group(aFeature, theGroupList));
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: CollectionAPI_Group.h
+// Created: 07 June 2016
+// Author: Dmitry Bobylev
+
+#ifndef CollectionAPI_Group_H_
+#define CollectionAPI_Group_H_
+
+#include "CollectionAPI.h"
+
+#include <CollectionPlugin_Group.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Selection;
+
+/// \class CollectionAPI_Group
+/// \ingroup CPPHighAPI
+/// \brief Interface for Group feature.
+class CollectionAPI_Group: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ COLLECTIONAPI_EXPORT
+ explicit CollectionAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ COLLECTIONAPI_EXPORT
+ CollectionAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theGroupList);
+
+ /// Destructor.
+ COLLECTIONAPI_EXPORT
+ virtual ~CollectionAPI_Group();
+
+ INTERFACE_1(CollectionPlugin_Group::ID(),
+ groupList, CollectionPlugin_Group::LIST_ID(),
+ ModelAPI_AttributeSelectionList, /** Group list*/)
+
+ /// Set main objects.
+ COLLECTIONAPI_EXPORT
+ void setGroupList(const std::list<ModelHighAPI_Selection>& theGroupList);
+
+ /// Dump wrapped feature
+ COLLECTIONAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on Group object.
+typedef std::shared_ptr<CollectionAPI_Group> GroupPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Group feature.
+COLLECTIONAPI_EXPORT
+GroupPtr addGroup(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theGroupList);
+
+#endif // CollectionAPI_Group_H_
--- /dev/null
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+INCLUDE(Common)
+INCLUDE(UnitTest)
+
+SET(PROJECT_HEADERS
+ CollectionPlugin.h
+ CollectionPlugin_Plugin.h
+ CollectionPlugin_Group.h
+)
+
+SET(PROJECT_SOURCES
+ CollectionPlugin_Plugin.cpp
+ CollectionPlugin_Group.cpp
+)
+
+SET(XML_RESOURCES
+ plugin-Collection.xml
+ group_widget.xml
+)
+
+SET(TEXT_RESOURCES
+ CollectionPlugin_msg_en.ts
+)
+
+SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
+
+
+INCLUDE_DIRECTORIES(
+ ../ModelAPI
+ ../GeomAPI
+ ../GeomAlgoAPI
+ ../GeomValidators
+ ../Events
+)
+
+SET(PROJECT_LIBRARIES
+ Events
+ ModelAPI
+ GeomAPI
+ GeomAlgoAPI
+ GeomValidators
+)
+
+ADD_DEFINITIONS(-DCOLLECTIONPLUGIN_EXPORTS)
+ADD_LIBRARY(CollectionPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${TEXT_RESOURCES})
+TARGET_LINK_LIBRARIES(CollectionPlugin ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS CollectionPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
+INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
+INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Collection)
+INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
+
+ADD_UNIT_TESTS(
+ TestGroup.py
+)
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+#ifndef COLLECTIONPLUGIN_H
+#define COLLECTIONPLUGIN_H
+
+#if defined COLLECTIONPLUGIN_EXPORTS
+#if defined WIN32
+#define COLLECTIONPLUGIN_EXPORT __declspec( dllexport )
+#else
+#define COLLECTIONPLUGIN_EXPORT
+#endif
+#else
+#if defined WIN32
+#define COLLECTIONPLUGIN_EXPORT __declspec( dllimport )
+#else
+#define COLLECTIONPLUGIN_EXPORT
+#endif
+#endif
+
+#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: CollectionPlugin_Group.cpp
+// Created: 08 Oct 2014
+// Author: Sergey BELASH
+
+#include "CollectionPlugin_Group.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultGroup.h>
+
+CollectionPlugin_Group::CollectionPlugin_Group()
+{
+}
+
+void CollectionPlugin_Group::initAttributes()
+{
+ //data()->addAttribute(CollectionPlugin_Group::NAME_ID(), ModelAPI_AttributeString::typeId());
+ data()->addAttribute(CollectionPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+}
+
+void CollectionPlugin_Group::execute()
+{
+ if (results().empty() || firstResult()->isDisabled()) { // just create result if not exists
+ ResultPtr aGroup = document()->createGroup(data());
+ setResult(aGroup);
+ }
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: CollectionPlugin_Group.h
+// Created: 08 Oct 2014
+// Author: Sergey BELASH
+
+#ifndef COLLECTIONPLUGIN_GROUP_H_
+#define COLLECTIONPLUGIN_GROUP_H_
+
+#include "CollectionPlugin.h"
+#include <ModelAPI_Feature.h>
+#include <GeomAPI_Shape.h>
+
+/**\class CollectionPlugin_Group
+ * \ingroup Plugins
+ * \brief Feature for selection of sub-shapes of some shapes.
+ *
+ * All selected sub-shapes must be of equal type (vertex, edge, face, etc) but may
+ * be selected on different objects.
+ */
+class CollectionPlugin_Group : public ModelAPI_Feature
+{
+ public:
+ /// Extrusion kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_GROUP_ID("Group");
+ return MY_GROUP_ID;
+ }
+ /// attribute name of selected entities list
+ inline static const std::string& LIST_ID()
+ {
+ static const std::string MY_GROUP_LIST_ID("group_list");
+ return MY_GROUP_LIST_ID;
+ }
+
+ /// Returns the kind of a feature
+ COLLECTIONPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = CollectionPlugin_Group::ID();
+ return MY_KIND;
+ }
+
+ /// Creates a new part document if needed
+ COLLECTIONPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ COLLECTIONPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Result of groups is created on the fly and don't stored to the document
+ COLLECTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return true;}
+
+ /// Use plugin manager for features creation
+ CollectionPlugin_Group();
+
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+#include <CollectionPlugin_Plugin.h>
+
+#include <CollectionPlugin_Group.h>
+#include <ModelAPI_Session.h>
+
+#include <string>
+#include <memory>
+
+// the only created instance of this plugin
+static CollectionPlugin_Plugin* MY_COLLECTION_INSTANCE = new CollectionPlugin_Plugin();
+
+CollectionPlugin_Plugin::CollectionPlugin_Plugin()
+{
+ SessionPtr aMgr = ModelAPI_Session::get();
+ // register this plugin
+ ModelAPI_Session::get()->registerPlugin(this);
+}
+
+FeaturePtr CollectionPlugin_Plugin::createFeature(std::string theFeatureID)
+{
+ if (theFeatureID == CollectionPlugin_Group::ID()) {
+ return FeaturePtr(new CollectionPlugin_Group);
+ }
+
+ // feature of such kind is not found
+ return FeaturePtr();
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: CollectionPlugin_Plugin.hxx
+// Created: 07 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef CollectionPlugin_Plugin_H_
+#define CollectionPlugin_Plugin_H_
+
+#include "CollectionPlugin.h"
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+
+/**\class CollectionPlugin_Plugin
+ * \ingroup Plugins
+ * \brief The main class for management the 3D features as plugin.
+ */
+class COLLECTIONPLUGIN_EXPORT CollectionPlugin_Plugin : public ModelAPI_Plugin
+{
+ public:
+ /// Creates the feature object of this plugin by the feature string ID
+ virtual FeaturePtr createFeature(std::string theFeatureID);
+
+ public:
+ /// Default constructor
+ CollectionPlugin_Plugin();
+};
+
+#endif
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+
+ <context>
+ <name>Group</name>
+ <message>
+ <source>group_list - GeomValidators_BodyShapes: Error: Context is empty.</source>
+ <translation>Selected object has empty context.</translation>
+ </message>
+ <message>
+ <source>group_list - GeomValidators_BodyShapes: Error: Result construction selected.</source>
+ <translation>Constructions not allowed for selection.</translation>
+ </message>
+ <message>
+ <source>group_list - GeomValidators_BodyShapes: Error: Attribute \"%1\" does not supported by this validator.</source>
+ <translation>Attribute "%1" does not supported by "GeomValidators_BodyShapes" validator.</translation>
+ </message>
+
+ <message>
+ <source>Model_FeatureValidator: Attribute "group_list" is not initialized.</source>
+ <translation>Objects not selected.</translation>
+ </message>
+ </context>
+
+</TS>
--- /dev/null
+"""
+ TestBoolean.py
+ Unit test of FeaturesPlugin_Group class
+
+ class FeaturesPlugin_Group
+ static const std::string MY_GROUP_ID("Group");
+ static const std::string MY_GROUP_LIST_ID("group_list");
+
+ data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+__updated__ = "2014-12-16"
+
+aSession = ModelAPI_Session.get()
+# Create a part for extrusions & boolean
+aSession.startOperation()
+aPartFeature = aSession.moduleDocument().addFeature("Part")
+aSession.finishOperation()
+aPart = aSession.activeDocument()
+#=========================================================================
+# Create a sketch with triangle and extrude it
+#=========================================================================
+aSession.startOperation()
+aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine")
+aSketchLineB = aTriangleSketchFeature.addFeature("SketchLine")
+aSketchLineC = aTriangleSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
+aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
+aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
+aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint"))
+aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint"))
+aLineAStartPoint.setValue(-100., 0.)
+aLineAEndPoint.setValue(100., 0.)
+aLineBStartPoint.setValue(100., 0.)
+aLineBEndPoint.setValue(0., 173.2)
+aLineCStartPoint.setValue(0., 173.2)
+aLineCEndPoint.setValue(-100., 0.)
+aSession.finishOperation()
+# Build sketch faces
+aSession.startOperation()
+aSketchResult = aTriangleSketchFeature.firstResult()
+aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
+origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt()
+dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir()
+norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir()
+aSketchFaces = ShapeList()
+GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aSketchEdges, aSketchFaces)
+# Create extrusion on them
+anExtrusionFt = aPart.addFeature("Extrusion")
+anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0])
+anExtrusionFt.string("CreationMethod").setValue("BySizes")
+anExtrusionFt.real("to_size").setValue(50)
+anExtrusionFt.real("from_size").setValue(50)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult())
+#=========================================================================
+# Create group of vertex
+#=========================================================================
+aSession.startOperation()
+aGroupFeature = aSession.activeDocument().addFeature("Group")
+aSelectionListAttr = aGroupFeature.selectionList("group_list")
+aSelectionListAttr.setSelectionType("vertex")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1_1")
+aSession.finishOperation()
+#=========================================================================
+# Check results
+#=========================================================================
+assert(aSelectionListAttr.size() == 6)
+aGroupResult = aGroupFeature.firstResult()
+assert(aGroupResult)
+#=========================================================================
+# Create group of edges
+#=========================================================================
+aSession.startOperation()
+aGroupFeature = aSession.activeDocument().addFeature("Group")
+aSelectionListAttr = aGroupFeature.selectionList("group_list")
+aSelectionListAttr.setSelectionType("edge")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1_1")
+aSession.finishOperation()
+#=========================================================================
+# Check results
+#=========================================================================
+assert(aSelectionListAttr.size() == 9)
+aGroupResult = aGroupFeature.firstResult()
+assert(aGroupResult)
+#=========================================================================
+# Create group of faces
+#=========================================================================
+aSession.startOperation()
+aGroupFeature = aSession.activeDocument().addFeature("Group")
+aSelectionListAttr = aGroupFeature.selectionList("group_list")
+aSelectionListAttr.setSelectionType("face")
+aShapeExplorer = GeomAPI_ShapeExplorer(anExtrusionBody.shape(), GeomAPI_Shape.FACE)
+while aShapeExplorer.more():
+ aSelectionListAttr.append(anExtrusionBody, aShapeExplorer.current())
+ aShapeExplorer.next();
+aSession.finishOperation()
+#=========================================================================
+# Check results
+#=========================================================================
+assert(aSelectionListAttr.size() == 5)
+aGroupResult = aGroupFeature.firstResult()
+assert(aGroupResult)
+#=========================================================================
+# Create group of solids
+#=========================================================================
+aSession.startOperation()
+aGroupFeature = aSession.activeDocument().addFeature("Group")
+aSelectionListAttr = aGroupFeature.selectionList("group_list")
+aSelectionListAttr.setSelectionType("face")
+aSelectionListAttr.append(anExtrusionBody, None)
+aSession.finishOperation()
+#=========================================================================
+# Check results
+#=========================================================================
+assert(aSelectionListAttr.size() == 1)
+aGroupResult = aGroupFeature.firstResult()
+assert(aGroupResult)
+
+#=========================================================================
+# Create group of face
+#=========================================================================
+aSession.startOperation()
+aGroupFeature = aSession.activeDocument().addFeature("Group")
+aSelectionListAttr = aGroupFeature.selectionList("group_list")
+aSelectionListAttr.setSelectionType("face")
+aSelectionListAttr.append("Extrusion_1_1/To_Face_1_1")
+aSession.finishOperation()
+#=========================================================================
+# Check results
+#=========================================================================
+assert(aSelectionListAttr.size() == 1)
+aGroupResult = aGroupFeature.firstResult()
+assert(aGroupResult)
+
+#=========================================================================
+# Create a sketch circle to extrude
+#=========================================================================
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+# Create circle
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0., 57.74)
+aCircleRadius.setValue(50.)
+aSession.finishOperation()
+#=========================================================================
+# Make extrusion on circle
+#=========================================================================
+# Build shape from sketcher results
+aCircleSketchResult = aCircleSketchFeature.firstResult()
+aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape()
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt()
+dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir()
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir()
+aCircleSketchFaces = ShapeList()
+GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces)
+assert(len(aCircleSketchFaces) > 0)
+assert(aCircleSketchFaces[0] is not None)
+# Create extrusion
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+# selection type FACE=4
+anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchFaces[0])
+anExtrusionFt.string("CreationMethod").setValue("BySizes")
+anExtrusionFt.real("to_size").setValue(50)
+anExtrusionFt.real("from_size").setValue(50)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+aCylinderBody = modelAPI_ResultBody(anExtrusionFt.firstResult())
+
+#=========================================================================
+# Create a cut
+#=========================================================================
+aSession.startOperation()
+aBooleanFt = aPart.addFeature("Boolean")
+aBooleanFt.selectionList("main_objects").append(anExtrusionBody, None)
+aBooleanFt.selectionList("tool_objects").append(aCylinderBody, None)
+aBooleanTypeCut = 0
+aBooleanFt.integer("bool_type").setValue(aBooleanTypeCut)
+aBooleanFt.execute()
+aSession.finishOperation()
+
+#=========================================================================
+# Move group feature
+#=========================================================================
+aSession.startOperation()
+aPart.moveFeature(aGroupFeature, aBooleanFt)
+aSession.finishOperation()
+
+#=========================================================================
+# Check results
+#=========================================================================
+aFactory = ModelAPI_Session.get().validators()
+assert(aFactory.validate(aGroupFeature))
+assert(aSelectionListAttr.size() == 1)
+assert(len(aGroupFeature.results()) > 0)
+aGroupResult = aGroupFeature.firstResult()
+assert(aGroupResult)
+assert(aGroupResult.shape())
+#=========================================================================
+# End of test
+#=========================================================================
+
+import model
+assert(model.checkPythonDump())
--- /dev/null
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<source>
+ <multi_selector id="group_list"
+ tooltip="Select a set of objects"
+ type_choice="Vertices Edges Faces Solids"
+ use_choice="true"
+ clear_in_neutral_point="false">
+ <validator id="GeomValidators_BodyShapes"/>
+ </multi_selector>
+</source>
\ No newline at end of file
--- /dev/null
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<plugin>
+ <workbench id="Features" document="Part">
+ <group id="Collections">
+ <feature id="Group"
+ title="Group"
+ tooltip="Create named collection of geometry entities"
+ icon="icons/Collection/shape_group.png">
+ <source path="group_widget.xml"/>
+ </feature>
+ </group>
+ </workbench>
+</plugin>
<plugin library="BuildPlugin" configuration="plugin-Build.xml"/>
<plugin library="PrimitivesPlugin" configuration="plugin-Primitives.xml"/>
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
+ <plugin library="CollectionPlugin" configuration="plugin-Collection.xml"/>
<plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
<plugin script="addons_Features" configuration="addons_Features.xml"/>
<plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="Geometry"/>
#include <iostream>
#endif
-using namespace std;
-
static const double defaultAxisSize = 100;
ConstructionPlugin_Axis::ConstructionPlugin_Axis()
#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
-using namespace std;
-
// the only created instance of this plugin
static ConstructionPlugin_Plugin* MY_CONSTRUCTION_INSTANCE = new ConstructionPlugin_Plugin();
Config_Prop::Color, ConstructionPlugin_Plane::DEFAULT_COLOR());
}
-FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID)
+FeaturePtr ConstructionPlugin_Plugin::createFeature(std::string theFeatureID)
{
if (theFeatureID == ConstructionPlugin_Point::ID()) {
return FeaturePtr(new ConstructionPlugin_Point);
Events_Listener.h
Events_Loop.h
Events_LongOp.h
- Events_InfoMessage.h
+ Events_InfoMessage.h
)
SET(PROJECT_SOURCES
Events_Listener.cpp
Events_Loop.cpp
Events_LongOp.cpp
- Events_InfoMessage.cpp
+ Events_InfoMessage.cpp
)
ADD_DEFINITIONS(-DEVENTS_EXPORTS)
#include <string>
#include <cstring>
-using namespace std;
-
Events_Loop* Events_Loop::loop()
{
// initialized on initialization of the application
Events_ID Events_Loop::eventByName(const char* theName)
{
///! All events created in this session, uniquely identified by the text and char pointer
- static map<string, char*> CREATED_EVENTS;
+ static std::map<std::string, char*> CREATED_EVENTS;
char* aResult;
- string aName(theName);
- map<string, char*>::iterator aFound = CREATED_EVENTS.find(aName);
+ std::string aName(theName);
+ std::map<std::string, char*>::iterator aFound = CREATED_EVENTS.find(aName);
if (aFound == CREATED_EVENTS.end()) { //not created yet
#ifdef WIN32
aResult = _strdup(theName); // copy to make unique internal pointer
void Events_Loop::sendProcessEvent(const std::shared_ptr<Events_Message>& theMessage,
std::list<Events_Listener*>& theListeners, const bool theFlushedNow)
{
- for (list<Events_Listener*>::iterator aL = theListeners.begin(); aL != theListeners.end(); aL++) {
+ std::list<Events_Listener*>::iterator aL = theListeners.begin();
+ for (; aL != theListeners.end(); aL++) {
if (theFlushedNow && (*aL)->groupMessages()) {
(*aL)->groupWhileFlush(theMessage);
} else {
}
}
// send
- map<char*, map<void*, list<Events_Listener*> > >::iterator aFindID = myListeners.find(
- theMessage->eventID().eventText());
+ std::map<char*, std::map<void*, std::list<Events_Listener*> > >::iterator aFindID =
+ myListeners.find(theMessage->eventID().eventText());
if (aFindID != myListeners.end()) {
- map<void*, list<Events_Listener*> >::iterator aFindSender = aFindID->second.find(
+ std::map<void*, std::list<Events_Listener*> >::iterator aFindSender = aFindID->second.find(
theMessage->sender());
if (aFindSender != aFindID->second.end()) {
sendProcessEvent(theMessage, aFindSender->second, isFlushedNow && isGroup);
myImmediateListeners[theID.eventText()] = theListener;
return;
}
- map<char*, map<void*, list<Events_Listener*> > >::iterator aFindID = myListeners.find(
- theID.eventText());
+ std::map<char*, std::map<void*, std::list<Events_Listener*> > >::iterator aFindID =
+ myListeners.find(theID.eventText());
if (aFindID == myListeners.end()) { // create container associated with ID
- myListeners[theID.eventText()] = map<void*, list<Events_Listener*> >();
+ myListeners[theID.eventText()] = std::map<void*, std::list<Events_Listener*> >();
aFindID = myListeners.find(theID.eventText());
}
- map<void*, list<Events_Listener*> >::iterator aFindSender = aFindID->second.find(theSender);
+ std::map<void*, std::list<Events_Listener*> >::iterator aFindSender =
+ aFindID->second.find(theSender);
if (aFindSender == aFindID->second.end()) { // create container associated with sender
- aFindID->second[theSender] = list<Events_Listener*>();
+ aFindID->second[theSender] = std::list<Events_Listener*>();
aFindSender = aFindID->second.find(theSender);
}
// check that listener was not registered wit hsuch parameters before
- list<Events_Listener*>& aListeners = aFindSender->second;
- for (list<Events_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
+ std::list<Events_Listener*>& aListeners = aFindSender->second;
+ for (std::list<Events_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
if (*aL == theListener)
return; // avoid duplicates
}
}
// send accumulated messages to "groupListeners"
- map<char*, map<void*, list<Events_Listener*> > >::iterator aFindID = myListeners.find(
- theID.eventText());
+ std::map<char*, std::map<void*, std::list<Events_Listener*> > >::iterator aFindID =
+ myListeners.find(theID.eventText());
if (aFindID != myListeners.end()) {
- map<void*, list<Events_Listener*> >::iterator aFindSender = aFindID->second.begin();
+ std::map<void*, std::list<Events_Listener*> >::iterator aFindSender =
+ aFindID->second.begin();
for(; aFindSender != aFindID->second.end(); aFindSender++) {
- list<Events_Listener*>::iterator aListener = aFindSender->second.begin();
+ std::list<Events_Listener*>::iterator aListener = aFindSender->second.begin();
for(; aListener != aFindSender->second.end(); aListener++) {
if ((*aListener)->groupMessages()) {
(*aListener)->flushGrouped(theID);
#include <memory>
-using namespace std;
-
// the only created instance of this plugin
static ExchangePlugin_Plugin* MY_EXCHANGE_INSTANCE = new ExchangePlugin_Plugin();
new ExchangePlugin_ExportFormatValidator);
}
-FeaturePtr ExchangePlugin_Plugin::createFeature(string theFeatureID)
+FeaturePtr ExchangePlugin_Plugin::createFeature(std::string theFeatureID)
{
if (theFeatureID == ExchangePlugin_ImportFeature::ID()) {
return FeaturePtr(new ExchangePlugin_ImportFeature);
FeaturesAPI_Boolean.h
FeaturesAPI_Extrusion.h
FeaturesAPI_ExtrusionBoolean.h
- FeaturesAPI_Group.h
FeaturesAPI_Intersection.h
FeaturesAPI_Partition.h
FeaturesAPI_Pipe.h
FeaturesAPI_Boolean.cpp
FeaturesAPI_Extrusion.cpp
FeaturesAPI_ExtrusionBoolean.cpp
- FeaturesAPI_Group.cpp
FeaturesAPI_Intersection.cpp
FeaturesAPI_Partition.cpp
FeaturesAPI_Pipe.cpp
${PROJECT_SOURCE_DIR}/src/FeaturesPlugin
)
-#TODO(spo): is ${CAS_DEFINITIONS} necessary?
-ADD_DEFINITIONS(-DFEATURESAPI_EXPORTS ${CAS_DEFINITIONS})
+ADD_DEFINITIONS(-DFEATURESAPI_EXPORTS)
ADD_LIBRARY(FeaturesAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
TARGET_LINK_LIBRARIES(FeaturesAPI ${PROJECT_LIBRARIES})
SET_SOURCE_FILES_PROPERTIES(FeaturesAPI.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(FeaturesAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-#TODO(spo): is ModelAPI necessary or it could be received by INTERFACE_ (may require modern CMake)?
SET(SWIG_LINK_LIBRARIES
FeaturesAPI
ModelHighAPI
INSTALL(TARGETS _FeaturesAPI DESTINATION ${SHAPER_INSTALL_SWIG})
INSTALL(TARGETS FeaturesAPI DESTINATION ${SHAPER_INSTALL_BIN})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/FeaturesAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
-
-# Tests
-INCLUDE(UnitTest)
-
-ADD_UNIT_TESTS(
-)
-
-# ADD_SUBDIRECTORY (Test)
%shared_ptr(FeaturesAPI_ExtrusionBoolean)
%shared_ptr(FeaturesAPI_ExtrusionCut)
%shared_ptr(FeaturesAPI_ExtrusionFuse)
-%shared_ptr(FeaturesAPI_Group)
%shared_ptr(FeaturesAPI_Intersection)
%shared_ptr(FeaturesAPI_Partition)
%shared_ptr(FeaturesAPI_Pipe)
%include "FeaturesAPI_Boolean.h"
%include "FeaturesAPI_Extrusion.h"
%include "FeaturesAPI_ExtrusionBoolean.h"
-%include "FeaturesAPI_Group.h"
%include "FeaturesAPI_Intersection.h"
%include "FeaturesAPI_Partition.h"
%include "FeaturesAPI_Pipe.h"
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: FeaturesAPI_Group.cpp
-// Created: 07 June 2016
-// Author: Dmitry Bobylev
-
-#include "FeaturesAPI_Group.h"
-
-#include <ModelHighAPI_Dumper.h>
-#include <ModelHighAPI_Integer.h>
-#include <ModelHighAPI_Selection.h>
-#include <ModelHighAPI_Tools.h>
-
-//==================================================================================================
-FeaturesAPI_Group::FeaturesAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature)
-: ModelHighAPI_Interface(theFeature)
-{
- initialize();
-}
-
-//==================================================================================================
-FeaturesAPI_Group::FeaturesAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::list<ModelHighAPI_Selection>& theGroupList)
-: ModelHighAPI_Interface(theFeature)
-{
- if(initialize()) {
- setGroupList(theGroupList);
- }
-}
-
-//==================================================================================================
-FeaturesAPI_Group::~FeaturesAPI_Group()
-{
-
-}
-
-//==================================================================================================
-void FeaturesAPI_Group::setGroupList(const std::list<ModelHighAPI_Selection>& theGroupList)
-{
- fillAttribute(theGroupList, mygroupList);
-
- execute();
-}
-
-//==================================================================================================
-void FeaturesAPI_Group::dump(ModelHighAPI_Dumper& theDumper) const
-{
- FeaturePtr aBase = feature();
- const std::string& aDocName = theDumper.name(aBase->document());
-
- AttributeSelectionListPtr anAttrList = aBase->selectionList(FeaturesPlugin_Group::LIST_ID());
-
- theDumper << aBase << " = model.addGroup(" << aDocName << ", " << anAttrList << ")" << std::endl;
-}
-
-//==================================================================================================
-GroupPtr addGroup(const std::shared_ptr<ModelAPI_Document>& thePart,
- const std::list<ModelHighAPI_Selection>& theGroupList)
-{
- std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Group::ID());
- return GroupPtr(new FeaturesAPI_Group(aFeature, theGroupList));
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: FeaturesAPI_Group.h
-// Created: 07 June 2016
-// Author: Dmitry Bobylev
-
-#ifndef FeaturesAPI_Group_H_
-#define FeaturesAPI_Group_H_
-
-#include "FeaturesAPI.h"
-
-#include <FeaturesPlugin_Group.h>
-
-#include <ModelHighAPI_Interface.h>
-#include <ModelHighAPI_Macro.h>
-
-class ModelHighAPI_Dumper;
-class ModelHighAPI_Selection;
-
-/// \class FeaturesAPI_Group
-/// \ingroup CPPHighAPI
-/// \brief Interface for Group feature.
-class FeaturesAPI_Group: public ModelHighAPI_Interface
-{
-public:
- /// Constructor without values.
- FEATURESAPI_EXPORT
- explicit FeaturesAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature);
-
- /// Constructor with values.
- FEATURESAPI_EXPORT
- FeaturesAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::list<ModelHighAPI_Selection>& theGroupList);
-
- /// Destructor.
- FEATURESAPI_EXPORT
- virtual ~FeaturesAPI_Group();
-
- INTERFACE_1(FeaturesPlugin_Group::ID(),
- groupList, FeaturesPlugin_Group::LIST_ID(),
- ModelAPI_AttributeSelectionList, /** Group list*/)
-
- /// Set main objects.
- FEATURESAPI_EXPORT
- void setGroupList(const std::list<ModelHighAPI_Selection>& theGroupList);
-
- /// Dump wrapped feature
- FEATURESAPI_EXPORT
- virtual void dump(ModelHighAPI_Dumper& theDumper) const;
-};
-
-/// Pointer on Group object.
-typedef std::shared_ptr<FeaturesAPI_Group> GroupPtr;
-
-/// \ingroup CPPHighAPI
-/// \brief Create Group feature.
-FEATURESAPI_EXPORT
-GroupPtr addGroup(const std::shared_ptr<ModelAPI_Document>& thePart,
- const std::list<ModelHighAPI_Selection>& theGroupList);
-
-#endif // FeaturesAPI_Group_H_
#include "FeaturesAPI_Boolean.h"
#include "FeaturesAPI_Extrusion.h"
#include "FeaturesAPI_ExtrusionBoolean.h"
- #include "FeaturesAPI_Group.h"
#include "FeaturesAPI_Intersection.h"
#include "FeaturesAPI_Partition.h"
#include "FeaturesAPI_Pipe.h"
FeaturesPlugin_Rotation.h
FeaturesPlugin_Translation.h
FeaturesPlugin_Boolean.h
- FeaturesPlugin_Group.h
FeaturesPlugin_Intersection.h
FeaturesPlugin_Partition.h
FeaturesPlugin_Pipe.h
FeaturesPlugin_Rotation.cpp
FeaturesPlugin_Translation.cpp
FeaturesPlugin_Boolean.cpp
- FeaturesPlugin_Group.cpp
FeaturesPlugin_Intersection.cpp
FeaturesPlugin_Partition.cpp
FeaturesPlugin_Pipe.cpp
rotation_widget.xml
translation_widget.xml
boolean_widget.xml
- group_widget.xml
recover_widget.xml
partition_widget.xml
placement_widget.xml
TestBooleanFill.py
TestMultiBoolean.py
TestSerialBoolean.py
- TestGroup.py
TestIntersection.py
TestUnion.py
TestRemoveSubShapes.py
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: FeaturesPlugin_Group.cpp
-// Created: 08 Oct 2014
-// Author: Sergey BELASH
-
-#include "FeaturesPlugin_Group.h"
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeInteger.h>
-#include <ModelAPI_AttributeString.h>
-#include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_ResultGroup.h>
-
-
-using namespace std;
-
-FeaturesPlugin_Group::FeaturesPlugin_Group()
-{
-}
-
-void FeaturesPlugin_Group::initAttributes()
-{
- //data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::typeId());
- data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
-}
-
-void FeaturesPlugin_Group::execute()
-{
- if (results().empty() || firstResult()->isDisabled()) { // just create result if not exists
- ResultPtr aGroup = document()->createGroup(data());
- setResult(aGroup);
- }
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: FeaturesPlugin_Group.h
-// Created: 08 Oct 2014
-// Author: Sergey BELASH
-
-#ifndef FEATURESPLUGIN_GROUP_H_
-#define FEATURESPLUGIN_GROUP_H_
-
-#include "FeaturesPlugin.h"
-#include <ModelAPI_Feature.h>
-#include <GeomAPI_Shape.h>
-
-/**\class FeaturesPlugin_Group
- * \ingroup Plugins
- * \brief Feature for selection of sub-shapes of some shapes.
- *
- * All selected sub-shapes must be of equal type (vertex, edge, face, etc) but may
- * be selected on different objects.
- */
-class FeaturesPlugin_Group : public ModelAPI_Feature
-{
- public:
- /// Extrusion kind
- inline static const std::string& ID()
- {
- static const std::string MY_GROUP_ID("Group");
- return MY_GROUP_ID;
- }
- /// attribute name of selected entities list
- inline static const std::string& LIST_ID()
- {
- static const std::string MY_GROUP_LIST_ID("group_list");
- return MY_GROUP_LIST_ID;
- }
-
- /// Returns the kind of a feature
- FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
- {
- static std::string MY_KIND = FeaturesPlugin_Group::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();
-
- /// Result of groups is created on the fly and don't stored to the document
- FEATURESPLUGIN_EXPORT virtual bool isPersistentResult() {return true;}
-
- /// Use plugin manager for features creation
- FeaturesPlugin_Group();
-
-};
-
-#endif
#include <FeaturesPlugin_Extrusion.h>
#include <FeaturesPlugin_ExtrusionCut.h>
#include <FeaturesPlugin_ExtrusionFuse.h>
-#include <FeaturesPlugin_Group.h>
#include <FeaturesPlugin_Intersection.h>
#include <FeaturesPlugin_Translation.h>
#include <FeaturesPlugin_Partition.h>
#include <memory>
-using namespace std;
-
// the only created instance of this plugin
static FeaturesPlugin_Plugin* MY_FEATURES_INSTANCE = new FeaturesPlugin_Plugin();
ModelAPI_Session::get()->registerPlugin(this);
}
-FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID)
+FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
{
if (theFeatureID == FeaturesPlugin_Extrusion::ID()) {
return FeaturePtr(new FeaturesPlugin_Extrusion);
return FeaturePtr(new FeaturesPlugin_Translation);
} else if (theFeatureID == FeaturesPlugin_Boolean::ID()) {
return FeaturePtr(new FeaturesPlugin_Boolean);
- } else if (theFeatureID == FeaturesPlugin_Group::ID()) {
- return FeaturePtr(new FeaturesPlugin_Group);
} else if (theFeatureID == FeaturesPlugin_Intersection::ID()) {
return FeaturePtr(new FeaturesPlugin_Intersection);
} else if (theFeatureID == FeaturesPlugin_Partition::ID()) {
#include <ModelAPI_Result.h>
#include <ModelAPI_Tools.h>
-using namespace std;
-
FeaturesPlugin_Recover::FeaturesPlugin_Recover()
{
}
</message>
</context>
- <context>
- <name>Group</name>
- <message>
- <source>group_list - GeomValidators_BodyShapes: Error: Context is empty.</source>
- <translation>Selected object has empty context.</translation>
- </message>
- <message>
- <source>group_list - GeomValidators_BodyShapes: Error: Result construction selected.</source>
- <translation>Constructions not allowed for selection.</translation>
- </message>
- <message>
- <source>group_list - GeomValidators_BodyShapes: Error: Attribute \"%1\" does not supported by this validator.</source>
- <translation>Attribute "%1" does not supported by "GeomValidators_BodyShapes" validator.</translation>
- </message>
-
- <message>
- <source>Model_FeatureValidator: Attribute "group_list" is not initialized.</source>
- <translation>Objects not selected.</translation>
- </message>
- </context>
-
<context>
<name>Union</name>
<message>
+++ /dev/null
-<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-<source>
- <multi_selector id="group_list"
- tooltip="Select a set of objects"
- type_choice="Vertices Edges Faces Solids"
- use_choice="true"
- clear_in_neutral_point="false">
- <validator id="GeomValidators_BodyShapes"/>
- </multi_selector>
-</source>
\ No newline at end of file
</feature>
</group>
<group id="Collections">
- <feature id="Group"
- title="Group"
- tooltip="Create named collection of geometry entities"
- icon="icons/Features/shape_group.png">
- <source path="group_widget.xml"/>
- </feature>
<feature id="Recover"
title="Recover"
tooltip="Visualize concealed objects"
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
#include <TopoDS_Shape.hxx>
-using namespace std;
-
GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
: GeomAPI_Interface(new TopTools_DataMapOfShapeShape){}
#include <IntAna_QuadQuadGeo.hxx>
-using namespace std;
-
GeomAPI_Pln::GeomAPI_Pln(const std::shared_ptr<GeomAPI_Ax3>& theAxis)
: GeomAPI_Interface(new gp_Ax3(theAxis->impl<gp_Ax3>()))
{
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
-using namespace std;
-
void GeomData_Dir::setValue(const double theX, const double theY, const double theZ)
{
if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY
IMPLEMENT_STANDARD_HANDLE(Model_Application, TDocStd_Application)
IMPLEMENT_STANDARD_RTTIEXT(Model_Application, TDocStd_Application)
-using namespace std;
-
static Handle_Model_Application TheApplication = new Model_Application;
//=======================================================================
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
-using namespace std;
-
void Model_AttributeBoolean::setValue(bool theValue)
{
Standard_Boolean aValue = theValue ? Standard_True : Standard_False;
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
-using namespace std;
-
void Model_AttributeDocRef::setValue(std::shared_ptr<ModelAPI_Document> theDoc)
{
if (myID->Get() != theDoc->id()) {
#include "Model_Objects.h"
#include <ModelAPI_Feature.h>
-using namespace std;
-
bool Model_AttributeRefAttr::isObject()
{
return myID->Get().Length() == 0;
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
theAttr->owner()->data());
- string anID = aData->id(theAttr);
+ std::string anID = aData->id(theAttr);
if (myIsInitialized && object() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
return; // nothing is changed
REMOVE_BACK_REF(theAttr->owner());
#include <TDF_ListIteratorOfLabelList.hxx>
#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
-using namespace std;
-
void Model_AttributeRefAttrList::append(ObjectPtr theObject)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theObject->data());
#include <TDF_Tool.hxx>
#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
-using namespace std;
-
void Model_AttributeRefList::append(ObjectPtr theObject)
{
if (owner()->document() == theObject->document()) {
return anObj;
}
-list<ObjectPtr> Model_AttributeRefList::list()
+std::list<ObjectPtr> Model_AttributeRefList::list()
{
std::list<ObjectPtr> aResult;
std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
#include <TDataStd_AsciiString.hxx>
#include <TDF_Tool.hxx>
-using namespace std;
-
void Model_AttributeReference::setValue(ObjectPtr theObject)
{
// now allow to deselect in this attribute: extrusion from/to
#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>
-using namespace std;
//#define DEB_NAMING 1
#ifdef DEB_NAMING
#include <BRepTools.hxx>
if (selectionLabel().FindAttribute(TDataStd_Name::GetID(), aName)) {
std::string aSubShapeName(TCollection_AsciiString(aName->Get()).ToCString());
std::size_t aPartEnd = aSubShapeName.find('/');
- if (aPartEnd != string::npos && aPartEnd != aSubShapeName.rfind('/')) {
- string aNameInPart = aSubShapeName.substr(aPartEnd + 1);
+ if (aPartEnd != std::string::npos && aPartEnd != aSubShapeName.rfind('/')) {
+ std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1);
int anIndex;
std::string aType; // to reuse already existing selection the type is not needed
return aPart->shapeInPart(aNameInPart, aType, anIndex);
// check this is Part-name: 2 delimiters in the name
std::size_t aPartEnd = theSubShapeName.find('/');
- if (aPartEnd != string::npos && aPartEnd != theSubShapeName.rfind('/')) {
+ if (aPartEnd != std::string::npos && aPartEnd != theSubShapeName.rfind('/')) {
std::string aPartName = theSubShapeName.substr(0, aPartEnd);
ObjectPtr aFound = owner()->document()->objectByName(ModelAPI_ResultPart::group(), aPartName);
if (aFound.get()) { // found such part, so asking it for the name
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aFound);
- string aNameInPart = theSubShapeName.substr(aPartEnd + 1);
+ std::string aNameInPart = theSubShapeName.substr(aPartEnd + 1);
int anIndex;
std::shared_ptr<GeomAPI_Shape> aSelected = aPart->shapeInPart(aNameInPart, theType, anIndex);
if (aSelected.get()) {
#include <TNaming_Iterator.hxx>
#include <NCollection_List.hxx>
-using namespace std;
-
void Model_AttributeSelectionList::append(
const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
const bool theTemporarily)
#include <TDF_RelocationTable.hxx>
#include <TDF_ClosureTool.hxx>
-using namespace std;
-
static Model_Session* myImpl = new Model_Session();
// t oredirect all calls to the root document
return ROOT_DOC->redoList();
}
-FeaturePtr Model_Session::createFeature(string theFeatureID, Model_Document* theDocOwner)
+FeaturePtr Model_Session::createFeature(std::string theFeatureID, Model_Document* theDocOwner)
{
if (this != myImpl) {
return myImpl->createFeature(theFeatureID, theDocOwner);
std::list<std::shared_ptr<ModelAPI_Document> > Model_Session::allOpenedDocuments()
{
- list<std::shared_ptr<ModelAPI_Document> > aResult;
+ std::list<std::shared_ptr<ModelAPI_Document> > aResult;
aResult.push_back(moduleDocument());
// add subs recursively
- list<std::shared_ptr<ModelAPI_Document> >::iterator aDoc = aResult.begin();
+ std::list<std::shared_ptr<ModelAPI_Document> >::iterator aDoc = aResult.begin();
for(; aDoc != aResult.end(); aDoc++) {
DocumentPtr anAPIDoc = *aDoc;
std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(anAPIDoc);
#include <Events_InfoMessage.h>
#include <Config_PropManager.h>
-using namespace std;
-
Model_Update MY_UPDATER_INSTANCE; /// the only one instance initialized on load of the library
//#define DEB_UPDATE
}
}
// update the selection attributes if any
- list<AttributePtr> aRefs =
+ std::list<AttributePtr> aRefs =
theFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
- list<AttributePtr>::iterator aRefsIter = aRefs.begin();
+ std::list<AttributePtr>::iterator aRefsIter = aRefs.begin();
for (; aRefsIter != aRefs.end(); aRefsIter++) {
std::shared_ptr<ModelAPI_AttributeSelection> aSel =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
{
std::set<std::shared_ptr<ModelAPI_Object> >::iterator anObj = theObjects.begin();
for(; anObj != theObjects.end(); anObj++) {
- list<AttributePtr> aRefs =
+ std::list<AttributePtr> aRefs =
(*anObj)->data()->attributes(ModelAPI_AttributeSelection::typeId());
- list<AttributePtr>::iterator aRefsIter = aRefs.begin();
+ std::list<AttributePtr>::iterator aRefsIter = aRefs.begin();
for (; aRefsIter != aRefs.end(); aRefsIter++) {
std::shared_ptr<Model_AttributeSelection> aSel =
std::dynamic_pointer_cast<Model_AttributeSelection>(*aRefsIter);
#include <dlfcn.h>
#endif
-using namespace std;
-
#ifdef _DEBUG
#include <iostream>
#endif
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_Session.h>
-using namespace std;
-
void PartSetPlugin_Duplicate::execute()
{
std::shared_ptr<ModelAPI_Session> aPManager = ModelAPI_Session::get();
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_Events.h>
-using namespace std;
-
PartSetPlugin_Part::PartSetPlugin_Part()
{
}
#include <iostream>
#endif
-using namespace std;
-
// the only created instance of this plugin
static PartSetPlugin_Plugin* MY_PARTSET_INSTANCE = new PartSetPlugin_Plugin();
ModelAPI_Session::get()->registerPlugin(this);
}
-FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID)
+FeaturePtr PartSetPlugin_Plugin::createFeature(std::string theFeatureID)
{
if (theFeatureID == PartSetPlugin_Part::ID()) {
return FeaturePtr(new PartSetPlugin_Part);
#include <PrimitivesPlugin_Plugin.h>
#include <PrimitivesPlugin_Box.h>
-
#include <ModelAPI_Session.h>
#include <string>
-
#include <memory>
-
#include <iostream>
-using namespace std;
-
// the only created instance of this plugin
static PrimitivesPlugin_Plugin* MY_PRIMITIVES_INSTANCE = new PrimitivesPlugin_Plugin();
ModelAPI_Session::get()->registerPlugin(this);
}
-FeaturePtr PrimitivesPlugin_Plugin::createFeature(string theFeatureID)
+FeaturePtr PrimitivesPlugin_Plugin::createFeature(std::string theFeatureID)
{
if (theFeatureID == PrimitivesPlugin_Box::ID()) {
return FeaturePtr(new PrimitivesPlugin_Box);
from construction import *
from exchange import *
from features import *
+from collection import *
from parameter import *
from partset import *
from primitives import *
--- /dev/null
+"""Package for Collection plugin for the Parametric Geometry API of the Modeler.
+"""
+
+from CollectionAPI import addGroup
from FeaturesAPI import addPipe
from FeaturesAPI import addCut, addFuse, addCommon, addSmash, addFill
from FeaturesAPI import addIntersection, addPartition, addUnion, addRemoveSubShapes
-from FeaturesAPI import addGroup, addRecover
+from FeaturesAPI import addRecover
#include <GeomAlgoAPI_EdgeBuilder.h>
#include <GeomDataAPI_Point2D.h>
-using namespace std;
-
SketchPlugin_Line::SketchPlugin_Line()
: SketchPlugin_SketchEntity()
{}
//#define SET_PLANES_COLOR_IN_PREFERENCES
-using namespace std;
-
// the only created instance of this plugin
static SketchPlugin_Plugin* MY_SKETCH_INSTANCE = new SketchPlugin_Plugin();
#endif
}
-FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID)
+FeaturePtr SketchPlugin_Plugin::createFeature(std::string theFeatureID)
{
if (theFeatureID == SketchPlugin_Sketch::ID()) {
return FeaturePtr(new SketchPlugin_Sketch);
#include <GeomDataAPI_Point2D.h>
#include <GeomAlgoAPI_PointBuilder.h>
-using namespace std;
-
SketchPlugin_Point::SketchPlugin_Point()
: SketchPlugin_SketchEntity()
{
#include <math.h>
#include <vector>
-using namespace std;
-
SketchPlugin_Sketch::SketchPlugin_Sketch()
{
}