From: Clarisse Genrault Date: Wed, 30 Nov 2016 13:43:12 +0000 (+0100) Subject: Add the GDML primitive "Cone Segment". X-Git-Tag: V_2.7.0~354 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=de0943dbcdcbf2c9d8d15d3d6e45b5e1023d0f7f;p=modules%2Fshaper.git Add the GDML primitive "Cone Segment". --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a2007df6..e076e675c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ ADD_SUBDIRECTORY (src/PartSetPlugin) ADD_SUBDIRECTORY (src/ConstructionPlugin) ADD_SUBDIRECTORY (src/BuildPlugin) ADD_SUBDIRECTORY (src/PrimitivesPlugin) +ADD_SUBDIRECTORY (src/GDMLPlugin) ADD_SUBDIRECTORY (src/FeaturesPlugin) ADD_SUBDIRECTORY (src/CollectionPlugin) ADD_SUBDIRECTORY (src/SamplePanelPlugin) @@ -97,6 +98,7 @@ ADD_SUBDIRECTORY (src/ParametersAPI) ADD_SUBDIRECTORY (src/PartSetAPI) ADD_SUBDIRECTORY (src/PrimitivesAPI) ADD_SUBDIRECTORY (src/SketchAPI) +ADD_SUBDIRECTORY (src/GDMLAPI) IF(${HAVE_SALOME}) ADD_SUBDIRECTORY (src/SHAPERGUI) diff --git a/src/Config/plugins.xml.in b/src/Config/plugins.xml.in index 9f654a7b0..e2b18a79c 100644 --- a/src/Config/plugins.xml.in +++ b/src/Config/plugins.xml.in @@ -8,6 +8,7 @@ + diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 783cbf385..d79ee1466 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -46,6 +46,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_XAOExport.h GeomAlgoAPI_XAOImport.h GeomAlgoAPI_Copy.h + GeomAlgoAPI_ConeSegment.h ) SET(PROJECT_SOURCES @@ -87,6 +88,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_XAOExport.cpp GeomAlgoAPI_XAOImport.cpp GeomAlgoAPI_Copy.cpp + GeomAlgoAPI_ConeSegment.cpp ) SET(PROJECT_LIBRARIES @@ -152,5 +154,6 @@ INSTALL(TARGETS GeomAlgoAPI DESTINATION ${SHAPER_INSTALL_BIN}) INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG}) ADD_UNIT_TESTS(TestAPI_Box.py + TestAPI_GDMLConeSegment.py TestAPI_Translation.py) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI.i b/src/GeomAlgoAPI/GeomAlgoAPI.i index be79ae013..3476e73f2 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI.i +++ b/src/GeomAlgoAPI/GeomAlgoAPI.i @@ -34,6 +34,7 @@ %shared_ptr(GeomAlgoAPI_Translation) %shared_ptr(GeomAlgoAPI_Transform) %shared_ptr(GeomAlgoAPI_Box) +%shared_ptr(GeomAlgoAPI_ConeSegment) %shared_ptr(GeomAlgoAPI_Copy) // all supported interfaces diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Box.h b/src/GeomAlgoAPI/GeomAlgoAPI_Box.h index c47af8b46..449d633f6 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Box.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Box.h @@ -4,8 +4,8 @@ // Created: 17 Mar 2016 // Author: Clarisse Genrault (CEA) -#ifndef GeomAlgoAPI_Box_H_ -#define GeomAlgoAPI_Box_H_ +#ifndef GEOMALGOAPI_BOX_H_ +#define GEOMALGOAPI_BOX_H_ #include #include @@ -61,4 +61,4 @@ class GeomAlgoAPI_Box : public GeomAlgoAPI_MakeShape }; -#endif +#endif // GEOMALGOAPI_BOX_H_ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp index 37ecc1296..d778964e8 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -5,14 +5,16 @@ // Author: Clarisse Genrault (CEA) #include "GeomAlgoAPI_ShapeAPI.h" + #include +#include +#include #include #include #include -#include -#include +//#include namespace GeomAlgoAPI_ShapeAPI { @@ -129,4 +131,29 @@ namespace GeomAlgoAPI_ShapeAPI } return aTranslationAlgo.shape(); } + + //========================================================================================================= + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeConeSegment( + const double theRMin1, const double theRMax1, + const double theRMin2, const double theRMax2, + const double theZ, + const double theStartPhi, const double theDeltaPhi) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2, + theZ, theStartPhi, theDeltaPhi); + + if (!aConeSegmentAlgo.check()) { + throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError()); + } + + aConeSegmentAlgo.build(); + + if(!aConeSegmentAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError()); + } + if (!aConeSegmentAlgo.checkValid("Cone Segment builder")) { + throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError()); + } + return aConeSegmentAlgo.shape(); + } } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h index 5e0ef0ba9..92f057444 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h @@ -69,6 +69,23 @@ public: std::shared_ptr theSourceShape, std::shared_ptr theStartPoint, std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception); + + /// Creates a cone segment using standard GDML parameters + /// \param theRMin1 Inner radius at base of cone + /// \param theRMax1 Outer radius at base of cone + /// \param theRMin2 Inner radius at top of cone + /// \param theRMax2 Outer radius at top of cone + /// \param theZ Height of cone segment + /// \param theStartPhi Start angle of the segment + /// \param theDeltaPhi Angle of the segment + static std::shared_ptr makeConeSegment( + const double theRMin1, + const double theRMax1, + const double theRMin2, + const double theRMax2, + const double theZ, + const double theStartPhi, + const double theDeltaPhi) throw (GeomAlgoAPI_Exception); }; } #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_swig.h b/src/GeomAlgoAPI/GeomAlgoAPI_swig.h index df537f620..e39352b1e 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_swig.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_swig.h @@ -1,8 +1,9 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -// File: GeomAlgoAPI_swig.h +// File: GeomAlgoAPI_swig.h // Created: Dec 15, 2015 // Author: Sergey POKHODENKO +// Modified by Clarisse Genrault (CEA) : 24 Nov 2016 #ifndef SRC_GEOMALGOAPI_GEOMALGOAPI_SWIG_H_ #define SRC_GEOMALGOAPI_GEOMALGOAPI_SWIG_H_ @@ -44,6 +45,7 @@ #include "GeomAlgoAPI_Exception.h" #include "GeomAlgoAPI_ShapeAPI.h" #include "GeomAlgoAPI_Box.h" + #include "GeomAlgoAPI_ConeSegment.h" #include "GeomAlgoAPI_Copy.h" #include diff --git a/src/PrimitivesAPI/CMakeLists.txt b/src/PrimitivesAPI/CMakeLists.txt index e97ba19a5..5453b7ad4 100644 --- a/src/PrimitivesAPI/CMakeLists.txt +++ b/src/PrimitivesAPI/CMakeLists.txt @@ -1,6 +1,7 @@ ## Copyright (C) 2014-2016 CEA/DEN, EDF R&D INCLUDE(Common) +INCLUDE(UnitTest) SET(PROJECT_HEADERS PrimitivesAPI.h @@ -30,7 +31,6 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/PrimitivesPlugin ) -#TODO(spo): is ${CAS_DEFINITIONS} necessary? ADD_DEFINITIONS(-DPRIMITIVESAPI_EXPORTS ${CAS_DEFINITIONS}) ADD_LIBRARY(PrimitivesAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) TARGET_LINK_LIBRARIES(PrimitivesAPI ${PROJECT_LIBRARIES}) @@ -42,7 +42,6 @@ INCLUDE(PythonAPI) SET_SOURCE_FILES_PROPERTIES(PrimitivesAPI.i PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(PrimitivesAPI.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 PrimitivesAPI ModelHighAPI @@ -68,9 +67,4 @@ INSTALL(TARGETS PrimitivesAPI DESTINATION ${SHAPER_INSTALL_BIN}) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/PrimitivesAPI.py DESTINATION ${SHAPER_INSTALL_SWIG}) # Tests -INCLUDE(UnitTest) - -ADD_UNIT_TESTS( -) - -# ADD_SUBDIRECTORY (Test) +ADD_UNIT_TESTS(TestBox.py) \ No newline at end of file diff --git a/src/PrimitivesAPI/PrimitivesAPI_swig.h b/src/PrimitivesAPI/PrimitivesAPI_swig.h index 87ba2a6d5..dc7f95a4c 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_swig.h +++ b/src/PrimitivesAPI/PrimitivesAPI_swig.h @@ -9,7 +9,7 @@ #include + #include "PrimitivesAPI.h" #include "PrimitivesAPI_Box.h" - #endif // PrimitivesAPI_swig_H_ diff --git a/src/PrimitivesPlugin/CMakeLists.txt b/src/PrimitivesPlugin/CMakeLists.txt index faa66cc8a..2623477a5 100644 --- a/src/PrimitivesPlugin/CMakeLists.txt +++ b/src/PrimitivesPlugin/CMakeLists.txt @@ -4,8 +4,6 @@ # Created: 07 Apr 2016 # Author: Clarisse genrault (CEA) -INCLUDE(UnitTest) - SET(PROJECT_HEADERS PrimitivesPlugin.h PrimitivesPlugin_Plugin.h @@ -44,6 +42,4 @@ INSTALL(TARGETS PrimitivesPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES}) INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}) INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Primitives) -ADD_UNIT_TESTS(TestBox.py -) diff --git a/src/PrimitivesPlugin/Test/TestBox.py b/src/PrimitivesPlugin/Test/TestBox.py deleted file mode 100644 index 3caff58e0..000000000 --- a/src/PrimitivesPlugin/Test/TestBox.py +++ /dev/null @@ -1,53 +0,0 @@ -""" -Test case for Primitive Box 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 a box with dimensions -aSession.startOperation() -aBox1 = model.addBox(aDocument, 10, 10, 10).result() -aSession.finishOperation() -assert (aBox1 is not None) - -# Create a first point -aSession.startOperation() -aFirstPoint = model.addPoint(aDocument, 0, 0, 0).result() -aSession.finishOperation() - -# Create a second point -aSession.startOperation() -aSecondPoint = model.addPoint(aDocument, 50, 50, 50).result() -aSession.finishOperation() - -# Create a box with 2 points -aSession.startOperation() -aBox2 = model.addBox(aDocument, aFirstPoint, aSecondPoint).result() -aSession.finishOperation() -assert (aBox2 is not None) - -# Create a box with dimensions (error) -aSession.startOperation() -aBox3 = model.addBox(aDocument, -10, 10, 10).result() -aSession.finishOperation() -assert (aBox3 is not None) - -# Create a box with 2 points (error) -aSession.startOperation() -aBox4 = model.addBox(aDocument, aFirstPoint, aFirstPoint).result() -aSession.finishOperation() -assert (aBox4 is not None) - diff --git a/src/PythonAPI/model/__init__.py b/src/PythonAPI/model/__init__.py index 4330709c2..34d537d59 100644 --- a/src/PythonAPI/model/__init__.py +++ b/src/PythonAPI/model/__init__.py @@ -23,3 +23,4 @@ from collection import * from parameter import * from partset import * from primitives import * +from gdml import *