From: Clarisse Genrault Date: Wed, 30 Nov 2016 13:41:49 +0000 (+0100) Subject: Add the GDML primitive "Cone Segment". X-Git-Tag: V_2.7.0~355 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=616cdb9e722efb11caa1bcfcbd02eed1d6695105;p=modules%2Fshaper.git Add the GDML primitive "Cone Segment". --- diff --git a/src/GDMLAPI/CMakeLists.txt b/src/GDMLAPI/CMakeLists.txt new file mode 100644 index 000000000..9084ba827 --- /dev/null +++ b/src/GDMLAPI/CMakeLists.txt @@ -0,0 +1,70 @@ +## Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +INCLUDE(Common) +INCLUDE(UnitTest) + +SET(PROJECT_HEADERS + GDMLAPI.h + GDMLAPI_ConeSegment.h +) + +SET(PROJECT_SOURCES + GDMLAPI_ConeSegment.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/GDMLPlugin +) + +ADD_DEFINITIONS(-DGDMLAPI_EXPORTS ${CAS_DEFINITIONS}) +ADD_LIBRARY(GDMLAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(GDMLAPI ${PROJECT_LIBRARIES}) + +# SWIG wrapper + +INCLUDE(PythonAPI) + +SET_SOURCE_FILES_PROPERTIES(GDMLAPI.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(GDMLAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow") + +SET(SWIG_LINK_LIBRARIES + GDMLAPI + ModelHighAPI + ModelAPI + ${PYTHON_LIBRARIES} +) + +SET(SWIG_MODULE_GDMLAPI_EXTRA_DEPS ${SWIG_MODULE_GDMLAPI_EXTRA_DEPS} + ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i + doxyhelp.i + ${PROJECT_HEADERS} +) + +SWIG_ADD_MODULE(GDMLAPI python GDMLAPI.i ${PROJECT_HEADERS}) +SWIG_LINK_LIBRARIES(GDMLAPI ${SWIG_LINK_LIBRARIES}) + +IF(WIN32) + SET_TARGET_PROPERTIES(_GDMLAPI PROPERTIES DEBUG_OUTPUT_NAME _GDMLAPI_d) +ENDIF(WIN32) + +INSTALL(TARGETS _GDMLAPI DESTINATION ${SHAPER_INSTALL_SWIG}) +INSTALL(TARGETS GDMLAPI DESTINATION ${SHAPER_INSTALL_BIN}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/GDMLAPI.py DESTINATION ${SHAPER_INSTALL_SWIG}) + +# Tests +ADD_UNIT_TESTS(TestConeSegment.py) \ No newline at end of file diff --git a/src/GDMLAPI/GDMLAPI.h b/src/GDMLAPI/GDMLAPI.h new file mode 100644 index 000000000..82a7f1c79 --- /dev/null +++ b/src/GDMLAPI/GDMLAPI.h @@ -0,0 +1,24 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GDMLAPI.h +// Created: 29 Nov 2016 +// Author: Clarisse Genrault (CEA) + +#ifndef GDMLAPI_H +#define GDMLAPI_H + +#if defined GDMLAPI_EXPORTS +#if defined WIN32 +#define GDMLAPI_EXPORT __declspec( dllexport ) +#else +#define GDMLAPI_EXPORT +#endif +#else +#if defined WIN32 +#define GDMLAPI_EXPORT __declspec( dllimport ) +#else +#define GDMLAPI_EXPORT +#endif +#endif + +#endif // GDMLAPI_H diff --git a/src/GDMLAPI/GDMLAPI.i b/src/GDMLAPI/GDMLAPI.i new file mode 100644 index 000000000..55b04e81c --- /dev/null +++ b/src/GDMLAPI/GDMLAPI.i @@ -0,0 +1,31 @@ +/* GDMLAPI.i */ +// File: GDMLAPI.i +// Created: 29 Nov 2016 +// Author: Clarisse Genrault (CEA) + +%module GDMLAPI + +%{ + #include "GDMLAPI_swig.h" +%} + +%include "doxyhelp.i" + +// import other modules +%import "ModelHighAPI.i" + +// to avoid error on this +#define GDMLAPI_EXPORT + +// standard definitions +%include "typemaps.i" +%include "std_string.i" +%include "std_shared_ptr.i" +%include "std_list.i" + +// shared pointers +%shared_ptr(GDMLAPI_ConeSegment) + +// all supported interfaces +%include "GDMLAPI_ConeSegment.h" + diff --git a/src/GDMLAPI/GDMLAPI_ConeSegment.cpp b/src/GDMLAPI/GDMLAPI_ConeSegment.cpp new file mode 100644 index 000000000..f37e931bd --- /dev/null +++ b/src/GDMLAPI/GDMLAPI_ConeSegment.cpp @@ -0,0 +1,72 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D --> + +// File: GDMLAPI_ConeSegment.cpp +// Created: 29 Nov. 2016 +// Author: Clarisse Genrault + +#include "GDMLAPI_ConeSegment.h" + +#include + +//================================================================================================== +GDMLAPI_ConeSegment::GDMLAPI_ConeSegment(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +GDMLAPI_ConeSegment::GDMLAPI_ConeSegment(const std::shared_ptr& theFeature, + const ModelHighAPI_Double& theRMin1, + const ModelHighAPI_Double& theRMax1, + const ModelHighAPI_Double& theRMin2, + const ModelHighAPI_Double& theRMax2, + const ModelHighAPI_Double& theZ, + const ModelHighAPI_Double& theStartPhi, + const ModelHighAPI_Double& theDeltaPhi) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) + setAttributes(theRMin1, theRMax1, theRMin2, theRMax2, theZ, theStartPhi, theDeltaPhi); +} + +//================================================================================================== +GDMLAPI_ConeSegment::~GDMLAPI_ConeSegment() +{ + +} + +//================================================================================================== +void GDMLAPI_ConeSegment::setAttributes(const ModelHighAPI_Double& theRMin1, + const ModelHighAPI_Double& theRMax1, + const ModelHighAPI_Double& theRMin2, + const ModelHighAPI_Double& theRMax2, + const ModelHighAPI_Double& theZ, + const ModelHighAPI_Double& theStartPhi, + const ModelHighAPI_Double& theDeltaPhi) +{ + fillAttribute(theRMin1, rmin1()); + fillAttribute(theRMax1, rmax1()); + fillAttribute(theRMin2, rmin2()); + fillAttribute(theRMax2, rmax2()); + fillAttribute(theZ, z()); + fillAttribute(theStartPhi, startphi()); + fillAttribute(theDeltaPhi, deltaphi()); + + execute(); +} + +//================================================================================================== +ConeSegmentPtr addConeSegment(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theRMin1, + const ModelHighAPI_Double& theRMax1, + const ModelHighAPI_Double& theRMin2, + const ModelHighAPI_Double& theRMax2, + const ModelHighAPI_Double& theZ, + const ModelHighAPI_Double& theStartPhi, + const ModelHighAPI_Double& theDeltaPhi) +{ + std::shared_ptr aFeature = thePart->addFeature(GDMLAPI_ConeSegment::ID()); + return ConeSegmentPtr(new GDMLAPI_ConeSegment(aFeature, theRMin1, theRMax1, theRMin2, theRMax2, + theZ, theStartPhi, theDeltaPhi)); +} diff --git a/src/GDMLAPI/GDMLAPI_ConeSegment.h b/src/GDMLAPI/GDMLAPI_ConeSegment.h new file mode 100644 index 000000000..bd0ea756e --- /dev/null +++ b/src/GDMLAPI/GDMLAPI_ConeSegment.h @@ -0,0 +1,86 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D --> + +// File: GDMLAPI_ConeSegment.h +// Created: 29 Nov. 2016 +// Author: Clarisse Genrault (CEA) + +#ifndef GDMLAPI_ConeSegment_H_ +#define GDMLAPI_ConeSegment_H_ + +#include "GDMLAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Double; + +/// \class GDMLPlugin_ConeSegment +/// \ingroup CPPHighAPI +/// \brief Interface for primitive ConeSegment feature. +class GDMLAPI_ConeSegment: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + GDMLAPI_EXPORT + explicit GDMLAPI_ConeSegment(const std::shared_ptr& theFeature); + + /// Constructor with values. + GDMLAPI_EXPORT + explicit GDMLAPI_ConeSegment(const std::shared_ptr& theFeature, + const ModelHighAPI_Double& theRMin1, + const ModelHighAPI_Double& theRMax1, + const ModelHighAPI_Double& theRMin2, + const ModelHighAPI_Double& theRMax2, + const ModelHighAPI_Double& theZ, + const ModelHighAPI_Double& theStartPhi, + const ModelHighAPI_Double& theDeltaPhi); + + /// Destructor. + GDMLAPI_EXPORT + virtual ~GDMLAPI_ConeSegment(); + + INTERFACE_7(GDMLPlugin_ConeSegment::ID(), + rmin1, GDMLPlugin_ConeSegment::RMIN1_ID(), + ModelAPI_AttributeDouble, /** Inner radius at base of cone */, + rmax1, GDMLPlugin_ConeSegment::RMAX1_ID(), + ModelAPI_AttributeDouble, /** Outer radius at base of cone */, + rmin2, GDMLPlugin_ConeSegment::RMIN2_ID(), + ModelAPI_AttributeDouble, /** Inner radius at top of cone */, + rmax2, GDMLPlugin_ConeSegment::RMAX2_ID(), + ModelAPI_AttributeDouble, /** Outer radius at top of cone */, + z, GDMLPlugin_ConeSegment::Z_ID(), + ModelAPI_AttributeDouble, /** Height of the cone segment */, + startphi, GDMLPlugin_ConeSegment::STARTPHI_ID(), + ModelAPI_AttributeDouble, /** Start angle of the segment */, + deltaphi, GDMLPlugin_ConeSegment::DELTAPHI_ID(), + ModelAPI_AttributeDouble, /** Angle of the segment */) + + /// Set dimensions + GDMLAPI_EXPORT + void setAttributes(const ModelHighAPI_Double& theRMin1, + const ModelHighAPI_Double& theRMax1, + const ModelHighAPI_Double& theRMin2, + const ModelHighAPI_Double& theRMax2, + const ModelHighAPI_Double& theZ, + const ModelHighAPI_Double& theStartPhi, + const ModelHighAPI_Double& theDeltaPhi); +}; + +/// Pointer on primitive ConeSegment object +typedef std::shared_ptr ConeSegmentPtr; + +/// \ingroup CPPHighAPI +/// \brief Create GDML ConeSegment feature. +GDMLAPI_EXPORT +ConeSegmentPtr addConeSegment(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theRMin1, + const ModelHighAPI_Double& theRMax1, + const ModelHighAPI_Double& theRMin2, + const ModelHighAPI_Double& theRMax2, + const ModelHighAPI_Double& theZ, + const ModelHighAPI_Double& theStartPhi, + const ModelHighAPI_Double& theDeltaPhi); + +#endif // GDMLAPI_ConeSegment_H_ diff --git a/src/GDMLAPI/GDMLAPI_swig.h b/src/GDMLAPI/GDMLAPI_swig.h new file mode 100644 index 000000000..b4417410a --- /dev/null +++ b/src/GDMLAPI/GDMLAPI_swig.h @@ -0,0 +1,16 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GDMLAPI_swig.h +// Created: 29 Nov 2016 +// Author: Clarisse Genrault (CEA) + +#ifndef GDMLAPI_swig_H_ +#define GDMLAPI_swig_H_ + + #include + + #include "GDMLAPI.h" + #include "GDMLAPI_ConeSegment.h" + +#endif // GDMLAPI_swig_H_ + diff --git a/src/GDMLAPI/Test/TestConeSegment.py b/src/GDMLAPI/Test/TestConeSegment.py new file mode 100644 index 000000000..ee5d0c423 --- /dev/null +++ b/src/GDMLAPI/Test/TestConeSegment.py @@ -0,0 +1,106 @@ +""" +Test case for GDML Primitive Cone Segment feature. +Written on High API. +""" +from ModelAPI import * +from GeomAPI import * + +import model + +# Get session +aSession = ModelAPI_Session.get() + +# Create a part +aDocument = aSession.activeDocument() +aSession.startOperation() +model.addPart(aDocument) +aDocument = aSession.activeDocument() +aSession.finishOperation() + +# Create several "cone segment" +aSession.startOperation() +aCS1 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,0.,270.).result() +aSession.finishOperation() +assert (aCS1 is not None) + +aSession.startOperation() +aCS2 = model.addConeSegment(aDocument,5.,10.,7.,15.,15.,45.,180.).result() +aSession.finishOperation() +assert (aCS2 is not None) + +aSession.startOperation() +aCS3 = model.addConeSegment(aDocument,5.,10.,7.,15.,15.,-45.,180.).result() +aSession.finishOperation() +assert (aCS3 is not None) + +aSession.startOperation() +aCS4 = model.addConeSegment(aDocument,0.,10.,2.,7.,3.,0.,270.).result() +aSession.finishOperation() +assert (aCS4 is not None) + +aSession.startOperation() +aCS5 = model.addConeSegment(aDocument,5.,8.,0.,6.,10.,45.,270.).result() +aSession.finishOperation() +assert (aCS5 is not None) + +aSession.startOperation() +aCS6 = model.addConeSegment(aDocument,0.,6.,0.,4.,17.,0.,270.).result() +aSession.finishOperation() +assert (aCS6 is not None) + +aSession.startOperation() +aCS7 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,0.,360.).result() +aSession.finishOperation() +assert (aCS7 is not None) + +aSession.startOperation() +aCS8 = model.addConeSegment(aDocument,-5.,11.,5.,8.,12.,0.,270.) +aSession.finishOperation() +assert (len(aCS8.results()) == 0) + +aSession.startOperation() +aCS9 = model.addConeSegment(aDocument,11.,7.,5.,8.,12.,0.,270.) +aSession.finishOperation() +assert (len(aCS9.results()) == 0) + +aSession.startOperation() +aCS10 = model.addConeSegment(aDocument,7.,11.,8.,5.,12.,0.,270.) +aSession.finishOperation() +assert (len(aCS10.results()) == 0) + +aSession.startOperation() +aCS11 = model.addConeSegment(aDocument,7.,11.,-3.,5.,12.,0.,270.) +aSession.finishOperation() +assert (len(aCS11.results()) == 0) + +aSession.startOperation() +aCS12 = model.addConeSegment(aDocument,7.,11.,5.,8.,0.,0.,270.) +aSession.finishOperation() +assert (len(aCS12.results()) == 0) + +aSession.startOperation() +aCS13 = model.addConeSegment(aDocument,7.,11.,5.,8.,-10.,0.,270.) +aSession.finishOperation() +assert (len(aCS13.results()) == 0) + +aSession.startOperation() +aCS14 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,-45.,-45.) +aSession.finishOperation() +assert (len(aCS14.results()) == 0) + +aSession.startOperation() +aCS15 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,45.,450.) +aSession.finishOperation() +assert (len(aCS15.results()) == 0) + +aSession.startOperation() +model.addParameter(aDocument,"rmin1","7.") +model.addParameter(aDocument,"rmax1","11.") +model.addParameter(aDocument,"rmin2","5.") +model.addParameter(aDocument,"rmax2","8.") +model.addParameter(aDocument,"z","12.") +model.addParameter(aDocument,"startphi","0.") +model.addParameter(aDocument,"deltaphi","270.") +aCS16 = model.addConeSegment(aDocument,"rmin1","rmax1","rmin2","rmax2","z","startphi","deltaphi").result() +aSession.finishOperation() +assert (aCS16 is not None) diff --git a/src/GDMLPlugin/CMakeLists.txt b/src/GDMLPlugin/CMakeLists.txt new file mode 100644 index 000000000..8da061a34 --- /dev/null +++ b/src/GDMLPlugin/CMakeLists.txt @@ -0,0 +1,57 @@ +# Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +# File: CMakeLists.txt +# Created: 23 Nov 2016 +# Author: Clarisse Genrault (CEA) + +INCLUDE(Common) +INCLUDE(UnitTest) + +SET(CMAKE_AUTOMOC ON) + +SET(PROJECT_HEADERS + GDMLPlugin.h + GDMLPlugin_Plugin.h + GDMLPlugin_ConeSegment.h +) + +SET(PROJECT_SOURCES + GDMLPlugin_Plugin.cpp + GDMLPlugin_ConeSegment.cpp +) + +SET(XML_RESOURCES + plugin-GDML.xml + conesegment_widget.xml +) + +INCLUDE_DIRECTORIES( + ../ModelAPI + ../GeomAPI + ../GeomAlgoAPI + ../Events + ../Config + ../ModuleBase + ${CAS_INCLUDE_DIRS} +) + +SET(PROJECT_LIBRARIES + Events + Config + ModelAPI + GeomAPI + GeomAlgoAPI + ModuleBase + ${QT_LIBRARIES} +) + +ADD_DEFINITIONS(-DGDMLPLUGIN_EXPORTS) +ADD_LIBRARY(GDMLPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES}) +TARGET_LINK_LIBRARIES(GDMLPlugin ${PROJECT_LIBRARIES}) + +INSTALL(TARGETS GDMLPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES}) +INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}) +INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/GDML) + +ADD_UNIT_TESTS() + diff --git a/src/GDMLPlugin/GDMLPlugin.h b/src/GDMLPlugin/GDMLPlugin.h new file mode 100644 index 000000000..e5670101f --- /dev/null +++ b/src/GDMLPlugin/GDMLPlugin.h @@ -0,0 +1,24 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GDMLPlugin.h +// Created: 23 Nov 2016 +// Author: Clarisse Genrault (CEA) + +#ifndef GDMLPLUGIN_H +#define GDMLPLUGIN_H + +#if defined GDMLPLUGIN_EXPORTS +#if defined WIN32 +#define GDMLPLUGIN_EXPORT __declspec( dllexport ) +#else +#define GDMLPLUGIN_EXPORT +#endif +#else +#if defined WIN32 +#define GDMLPLUGIN_EXPORT __declspec( dllimport ) +#else +#define GDMLPLUGIN_EXPORT +#endif +#endif + +#endif // GDMLPLUGIN_H diff --git a/src/GDMLPlugin/GDMLPlugin_ConeSegment.cpp b/src/GDMLPlugin/GDMLPlugin_ConeSegment.cpp new file mode 100644 index 000000000..bbc4adecc --- /dev/null +++ b/src/GDMLPlugin/GDMLPlugin_ConeSegment.cpp @@ -0,0 +1,93 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GDMLPlugin_ConeSegment.cpp +// Created: 23 Nov 2016 +// Author: Clarisse Genrault (CEA) + +#include + +#include +#include +#include +#include + +//================================================================================================= +GDMLPlugin_ConeSegment::GDMLPlugin_ConeSegment() // Nothing to do during instantiation +{ +} + +//================================================================================================= +void GDMLPlugin_ConeSegment::initAttributes() +{ + data()->addAttribute(GDMLPlugin_ConeSegment::RMIN1_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(GDMLPlugin_ConeSegment::RMAX1_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(GDMLPlugin_ConeSegment::RMIN2_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(GDMLPlugin_ConeSegment::RMAX2_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(GDMLPlugin_ConeSegment::Z_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(GDMLPlugin_ConeSegment::STARTPHI_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(GDMLPlugin_ConeSegment::DELTAPHI_ID(), ModelAPI_AttributeDouble::typeId()); +} + +//================================================================================================= +void GDMLPlugin_ConeSegment::execute() +{ + double aRMin1 = real(GDMLPlugin_ConeSegment::RMIN1_ID())->value(); + double aRMax1 = real(GDMLPlugin_ConeSegment::RMAX1_ID())->value(); + double aRMin2 = real(GDMLPlugin_ConeSegment::RMIN2_ID())->value(); + double aRMax2 = real(GDMLPlugin_ConeSegment::RMAX2_ID())->value(); + double aZ = real(GDMLPlugin_ConeSegment::Z_ID())->value(); + double aStartPhi = real(GDMLPlugin_ConeSegment::STARTPHI_ID())->value(); + double aDeltaPhi = real(GDMLPlugin_ConeSegment::DELTAPHI_ID())->value(); + + std::shared_ptr aConeSegmentAlgo = + std::shared_ptr(new GeomAlgoAPI_ConeSegment(aRMin1, aRMax1, + aRMin2, aRMax2, + aZ, + aStartPhi, aDeltaPhi)); + + // Check with that the arguments for aConeSegmentAlgo are correct + if (!aConeSegmentAlgo->check()){ + setError(aConeSegmentAlgo->getError()); + return; + } + + aConeSegmentAlgo->build(); + + // Check if the creation of the cone segment went well + if(!aConeSegmentAlgo->isDone()) { + setError(aConeSegmentAlgo->getError()); + return; + } + if (!aConeSegmentAlgo->checkValid("Cone Segment builder")) { + setError(aConeSegmentAlgo->getError()); + return; + } + + int aResultIndex = 0; + ResultBodyPtr aResultConeSegment = document()->createBody(data(), aResultIndex); + loadNamingDS(aConeSegmentAlgo, aResultConeSegment); + setResult(aResultConeSegment, aResultIndex); +} + +//================================================================================================= +void GDMLPlugin_ConeSegment::loadNamingDS( + std::shared_ptr theConeSegmentAlgo, + std::shared_ptr theResultConeSegment) +{ + // Load the result + theResultConeSegment->store(theConeSegmentAlgo->shape()); + + // Prepare the naming + theConeSegmentAlgo->prepareNamingFaces(); + + // Insert to faces + int num = 1; + std::map< std::string, std::shared_ptr > listOfFaces = + theConeSegmentAlgo->getCreatedFaces(); + for (std::map< std::string, std::shared_ptr >::iterator + it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) { + std::shared_ptr aFace = (*it).second; + theResultConeSegment->generated(aFace, (*it).first, num++); + } +} + diff --git a/src/GDMLPlugin/GDMLPlugin_ConeSegment.h b/src/GDMLPlugin/GDMLPlugin_ConeSegment.h new file mode 100644 index 000000000..2eb5806ca --- /dev/null +++ b/src/GDMLPlugin/GDMLPlugin_ConeSegment.h @@ -0,0 +1,96 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GDMLPlugin_ConeSegment.h +// Created: 23 Nov 2016 +// Author: Clarisse Genrault (CEA) + +#ifndef GDMLPLUGIN_CONESEGMENT_H_ +#define GDMLPLUGIN_CONESEGMENT_H_ + +#include +#include +#include + +class GeomAPI_Shape; +class ModelAPI_ResultBody; + +/**\class GDMLPlugin_ConeSegment + * \ingroup Plugins + * \brief Feature for creation of a GDML ConeSegment solid. + */ +class GDMLPlugin_ConeSegment : public ModelAPI_Feature +{ + public: + /// Cone segment kind + inline static const std::string& ID() + { + static const std::string MY_CONESEGMENT_ID("ConeSegment"); + return MY_CONESEGMENT_ID; + } + /// attribute name of the inner radius at base of cone + inline static const std::string& RMIN1_ID() + { + static const std::string MY_RMIN1_ID("rmin1"); + return MY_RMIN1_ID; + } + /// attribute name of the outer radius at base of cone + inline static const std::string& RMAX1_ID() + { + static const std::string MY_RMAX1_ID("rmax1"); + return MY_RMAX1_ID; + } + /// attribute name of the inner radius at top of cone + inline static const std::string& RMIN2_ID() + { + static const std::string MY_RMIN2_ID("rmin2"); + return MY_RMIN2_ID; + } + /// attribute name of the outer radius at top of cone + inline static const std::string& RMAX2_ID() + { + static const std::string MY_RMAX2_ID("rmax2"); + return MY_RMAX2_ID; + } + /// attribute name of the height of the cone segment + inline static const std::string& Z_ID() + { + static const std::string MY_Z_ID("z"); + return MY_Z_ID; + } + /// attribute name of the start angle of the segment + inline static const std::string& STARTPHI_ID() + { + static const std::string MY_STARTPHI_ID("startphi"); + return MY_STARTPHI_ID; + } + /// attribute name of the angle of the segment + inline static const std::string& DELTAPHI_ID() + { + static const std::string MY_DELTAPHI_ID("deltaphi"); + return MY_DELTAPHI_ID; + } + + /// Returns the kind of a feature + GDMLPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = GDMLPlugin_ConeSegment::ID(); + return MY_KIND; + } + + /// Creates a new part document if needed + GDMLPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + GDMLPLUGIN_EXPORT virtual void initAttributes(); + + /// Use plugin manager for features creation + GDMLPlugin_ConeSegment(); + + private: + /// Load Naming data structure of the feature to the document + void loadNamingDS(std::shared_ptr theConeSegmentAlgo, + std::shared_ptr theResultConeSegment); + +}; + +#endif // GDMLPLUGIN_CONESEGMENT_H_ diff --git a/src/GDMLPlugin/GDMLPlugin_Plugin.cpp b/src/GDMLPlugin/GDMLPlugin_Plugin.cpp new file mode 100644 index 000000000..e4e0423e8 --- /dev/null +++ b/src/GDMLPlugin/GDMLPlugin_Plugin.cpp @@ -0,0 +1,30 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GDMLPlugin_Plugin.cpp +// Created: 23 Nov 2016 +// Author: Clarisse Genrault (CEA) + +#include + +#include + +#include + +// the only created instance of this plugin +static GDMLPlugin_Plugin* MY_GDML_INSTANCE = new GDMLPlugin_Plugin(); + +GDMLPlugin_Plugin::GDMLPlugin_Plugin() +{ + // register this plugin + ModelAPI_Session::get()->registerPlugin(this); +} + +FeaturePtr GDMLPlugin_Plugin::createFeature(std::string theFeatureID) +{ + if (theFeatureID == GDMLPlugin_ConeSegment::ID()) { + return FeaturePtr(new GDMLPlugin_ConeSegment); + } + // feature of such kind is not found + return FeaturePtr(); +} + diff --git a/src/GDMLPlugin/GDMLPlugin_Plugin.h b/src/GDMLPlugin/GDMLPlugin_Plugin.h new file mode 100644 index 000000000..f91809a10 --- /dev/null +++ b/src/GDMLPlugin/GDMLPlugin_Plugin.h @@ -0,0 +1,29 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GDMLPlugin_Plugin.h +// Created: 23 Nov 2016 +// Author: Clarisse Genrault (CEA) + +#ifndef GDMLPLUGIN_PLUGIN_H_ +#define GDMLPLUGIN_PLUGIN_H_ + +#include "GDMLPlugin.h" +#include +#include + +/**\class GDMLPlugin_Plugin + * \ingroup Plugins + * \brief The main class managing GDML Features as plugins. + */ +class GDMLPLUGIN_EXPORT GDMLPlugin_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 + GDMLPlugin_Plugin(); +}; + +#endif // GDMLPLUGIN_PLUGIN_H_ diff --git a/src/GDMLPlugin/conesegment_widget.xml b/src/GDMLPlugin/conesegment_widget.xml new file mode 100644 index 000000000..23a33b678 --- /dev/null +++ b/src/GDMLPlugin/conesegment_widget.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +