Salome HOME
Add the GDML primitive "Cone Segment".
authorClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 30 Nov 2016 13:43:12 +0000 (14:43 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 30 Nov 2016 13:43:12 +0000 (14:43 +0100)
13 files changed:
CMakeLists.txt
src/Config/plugins.xml.in
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI.i
src/GeomAlgoAPI/GeomAlgoAPI_Box.h
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h
src/GeomAlgoAPI/GeomAlgoAPI_swig.h
src/PrimitivesAPI/CMakeLists.txt
src/PrimitivesAPI/PrimitivesAPI_swig.h
src/PrimitivesPlugin/CMakeLists.txt
src/PrimitivesPlugin/Test/TestBox.py [deleted file]
src/PythonAPI/model/__init__.py

index 7a2007df6ca4a1d75586ddd62baa9c0d6d8a47e9..e076e675cbb478367d8c8b6ee654be2d43a59562 100644 (file)
@@ -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)
index 9f654a7b0ba6fe66f9094a3a5ba8f5308fd3110f..e2b18a79c289e4bc0326ad46c9deb5de04c0c011 100644 (file)
@@ -8,6 +8,7 @@
   <plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
   <plugin library="BuildPlugin" configuration="plugin-Build.xml"/>
   <plugin library="PrimitivesPlugin" configuration="plugin-Primitives.xml"/>
+  <plugin library="GDMLPlugin" configuration="plugin-GDML.xml"/>
   <plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
   <plugin library="CollectionPlugin" configuration="plugin-Collection.xml"/>
   <plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
index 783cbf3851673ab5f2185f2874acfb7f94397052..d79ee14662f6884d08274d97dca9b81c08546388 100644 (file)
@@ -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)
 
index be79ae0132fbc72b38c9b7561437cca30f026fc7..3476e73f2ae05aca0d97685d961966b258b8c37e 100644 (file)
@@ -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
index c47af8b464356c7cf970613c63946d0232972d74..449d633f6dc96cb4461dafa2e0b6d6014ccaa81c 100644 (file)
@@ -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 <GeomAPI_Pnt.h>
 #include <GeomAlgoAPI_MakeShape.h>
@@ -61,4 +61,4 @@ class GeomAlgoAPI_Box : public GeomAlgoAPI_MakeShape
 };
 
 
-#endif
+#endif // GEOMALGOAPI_BOX_H_
index 37ecc1296c4bebf7dcaafa8a500ec9eb11a6ac7e..d778964e8c52bff31d207ae5c8c4026c905347b1 100644 (file)
@@ -5,14 +5,16 @@
 // Author:      Clarisse Genrault (CEA)
 
 #include "GeomAlgoAPI_ShapeAPI.h"
+
 #include <GeomAlgoAPI_Box.h>
+#include <GeomAlgoAPI_ConeSegment.h>
+#include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_Translation.h>
 
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Edge.h>
-#include <GeomAlgoAPI_EdgeBuilder.h>
 
-#include <iostream>
+//#include <iostream>
 
 namespace GeomAlgoAPI_ShapeAPI
 {
@@ -129,4 +131,29 @@ namespace GeomAlgoAPI_ShapeAPI
     }
     return aTranslationAlgo.shape();
   }
+
+  //=========================================================================================================
+  std::shared_ptr<GeomAPI_Shape> 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();
+  }
 }
index 5e0ef0ba9e7cc24ba745753a849666b485b6c21d..92f0574442c54be223c0d7d703d4081bda2c82cf 100644 (file)
@@ -69,6 +69,23 @@ public:
                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
                      std::shared_ptr<GeomAPI_Pnt>   theStartPoint,
                      std::shared_ptr<GeomAPI_Pnt>   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<GeomAPI_Shape> 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
index df537f6200f0cd6bcac6a9ecb8b3e95ab77cd1cf..e39352b1ecde107c2885ab192b0ac644d3c4526b 100644 (file)
@@ -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 <memory>
index e97ba19a5b1f89b3209846504a22fb686bd7ce7e..5453b7ad449d5fd3a125888503bf3d51e388a9e7 100644 (file)
@@ -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
index 87ba2a6d5b97d1e382692d58cc7c43578e6c2f22..dc7f95a4c9a2e2a24f1e2eb8eb255cfb8fa4bbb6 100644 (file)
@@ -9,7 +9,7 @@
 
   #include <ModelHighAPI_swig.h>
 
+  #include "PrimitivesAPI.h"
   #include "PrimitivesAPI_Box.h"
 
-
 #endif // PrimitivesAPI_swig_H_
index faa66cc8aff627aef2b6fdda5856bc19dfbaac08..2623477a50d91b975caf65a92367371d35d640dd 100644 (file)
@@ -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 (file)
index 3caff58..0000000
+++ /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)
-
index 4330709c2e978c5c70604895bfe7148729ce35e9..34d537d597987739fb1cd85f025ad8d437cdfbc3 100644 (file)
@@ -23,3 +23,4 @@ from collection import *
 from parameter import *
 from partset import *
 from primitives import *
+from gdml import *