Salome HOME
Correction following passing of unit tests.
authorClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 3 Mar 2017 08:37:52 +0000 (09:37 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 3 Mar 2017 08:37:52 +0000 (09:37 +0100)
src/FeaturesPlugin/translation_widget.xml
src/GDMLAPI/GDMLAPI_ConeSegment.cpp
src/GDMLAPI/GDMLAPI_ConeSegment.h
src/GDMLPlugin/conesegment_widget.xml
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp
src/PrimitivesAPI/PrimitivesAPI_Cylinder.cpp

index a5b247dc6e89f6d6ea1e86864d1d4ab96eccdc8e..cb83abb94241f595183ce3a8b459cb010bfdc179 100644 (file)
@@ -1,4 +1,4 @@
-<!-- Copyright (C) 2014-2016 CEA/DEN, EDF R&D -->
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 <!-- Modified by Clarisse Genrault (CEA) : 17 Nov 2016 -->
 <source>
   <toolbox id="CreationMethod">
@@ -94,4 +94,4 @@
       </shape_selector>
     </box>
  </toolbox>
-</source>
\ No newline at end of file
+</source>
index f37e931bd62342444c73aaef36f44d65a870477b..3bdfa66dad6051757f37d6a86ae9469c78ee86fb 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "GDMLAPI_ConeSegment.h"
 
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Tools.h>
 
 //==================================================================================================
@@ -33,7 +34,6 @@ GDMLAPI_ConeSegment::GDMLAPI_ConeSegment(const std::shared_ptr<ModelAPI_Feature>
 //==================================================================================================
 GDMLAPI_ConeSegment::~GDMLAPI_ConeSegment()
 {
-
 }
 
 //==================================================================================================
@@ -56,6 +56,28 @@ void GDMLAPI_ConeSegment::setAttributes(const ModelHighAPI_Double& theRMin1,
   execute();
 }
 
+//==================================================================================================
+void GDMLAPI_ConeSegment::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  theDumper << aBase << " = model.addConeSegment(" << aDocName;
+
+  AttributeDoublePtr anAttrRMin1 = aBase->real(GDMLPlugin_ConeSegment::RMIN1_ID());
+  AttributeDoublePtr anAttrRMax1 = aBase->real(GDMLPlugin_ConeSegment::RMAX1_ID());
+  AttributeDoublePtr anAttrRMin2 = aBase->real(GDMLPlugin_ConeSegment::RMIN2_ID());
+  AttributeDoublePtr anAttrRMax2 = aBase->real(GDMLPlugin_ConeSegment::RMAX2_ID());
+  AttributeDoublePtr anAttrZ = aBase->real(GDMLPlugin_ConeSegment::Z_ID());
+  AttributeDoublePtr anAttrStartPhi = aBase->real(GDMLPlugin_ConeSegment::STARTPHI_ID());
+  AttributeDoublePtr anAttrDeltaPhi = aBase->real(GDMLPlugin_ConeSegment::DELTAPHI_ID());
+  theDumper << ", " << anAttrRMin1 << ", " << anAttrRMax1;
+  theDumper << ", " << anAttrRMin2 << ", " << anAttrRMax2;
+  theDumper << ", " << anAttrZ << ", " << anAttrStartPhi << " , " << anAttrDeltaPhi;
+
+  theDumper << ")" << std::endl;
+}
+
 //==================================================================================================
 ConeSegmentPtr addConeSegment(const std::shared_ptr<ModelAPI_Document>& thePart,
                               const ModelHighAPI_Double& theRMin1,
index bd0ea756eea8cc3ac087b731db42477615193513..af7c6d1d7addb229740b9a6a73b0937111f6f5d5 100644 (file)
@@ -66,6 +66,10 @@ public:
                      const ModelHighAPI_Double& theZ,
                      const ModelHighAPI_Double& theStartPhi,
                      const ModelHighAPI_Double& theDeltaPhi);
+
+  /// Dump wrapped feature
+  GDMLAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
 };
 
 /// Pointer on primitive ConeSegment object
index 23a33b6783b04dfa3dada05b4dfd32032a7d33a5..66b698c65f788245f30cca7d1e6f8278888b3bdf 100644 (file)
@@ -44,7 +44,6 @@
       step="1.0"
       default="12.0"
       tooltip="Enter the height">
-      <validator id="GeomValidators_Positive"/>
     </doublevalue>
     <doublevalue
       id="startphi"
@@ -59,7 +58,6 @@
       step="15.0"
       default="270."
       tooltip="Enter the revolution angle">
-      <validator id="GeomValidators_Positive"/>
     </doublevalue>
   </groupbox>
   <label title="" icon="icons/GDML/gui_cone_segment.png"/>
index 090fd30968b522233547ec73bf5e5a2822040632..b0dabccc9cb1f3866c7ea8ae3773f29b8dc069d9 100644 (file)
@@ -105,6 +105,15 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
     double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
   {
+    // Check if the base point is OK
+    if (!theBasePoint) {
+      throw GeomAlgoAPI_Exception("Cylinder builder :: the base point is not valid.");
+    }
+    // Check if the edge is OK
+    if (!theEdge) {
+      throw GeomAlgoAPI_Exception("Cylinder builder :: the axis is not valid.");
+    }
+
     std::shared_ptr<GeomAPI_Ax2> anAxis;
     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
                                                           theEdge->line()->direction()));
index 3724bcf2e22693f16a5d8707a14e6ddde6e77e65..0ff6336f0a80eb1618942d44d8be0a4779199175 100644 (file)
@@ -82,6 +82,10 @@ bool GeomAlgoAPI_Translation::check()
         myError = "Translation builder :: source shape is invalid.";
         return false;
       }
+      if(myStartPoint->distance(myEndPoint) < Precision::Confusion()) {
+        myError = "Translation builder :: start point and end point coincide.";
+        return false;
+      }
       return true;
     }
     default: {
index 7d342b9141b112709f49a322f15698773a2e7fcf..4bd696da7e8149e2cf827834b1f821338ae4f7ec 100644 (file)
@@ -10,6 +10,8 @@
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
 
+#include <iostream>
+
 //==================================================================================================
 PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature)
 : ModelHighAPI_Interface(theFeature)
@@ -124,8 +126,8 @@ CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Double& theRadius,
                         const ModelHighAPI_Double& theHeight)
 {
-  ModelHighAPI_Selection aBasePoint("VERT", "Origin");
-  ModelHighAPI_Selection anAxis("EDGE", "OZ");
+  ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin");
+  ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ");
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
                                                 theRadius, theHeight));
@@ -137,9 +139,9 @@ CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Double& theHeight,
                         const ModelHighAPI_Double& theAngle)
 {
-  ModelHighAPI_Selection aBasePoint("VERT", "Origin");
-  ModelHighAPI_Selection anAxis("EDGE", "OZ");
+  ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin");
+  ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ");
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
-                                                theRadius, theHeight));
-}
\ No newline at end of file
+                                                theRadius, theHeight, theAngle));
+}