Salome HOME
Merge branch 'master' into cgt/devCEA
authorClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 29 Mar 2017 11:55:56 +0000 (13:55 +0200)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 29 Mar 2017 11:55:56 +0000 (13:55 +0200)
1  2 
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp

index 44ec71043ac65f1993fa99a8413b91ea7f4e4a96,83ee6e5fc02556276e2fa0619bbb7a50d713c883..6b26c3eb22d4cab94456beb74a72792b749c5008
@@@ -7,16 -7,13 +7,16 @@@
  #include "GeomAlgoAPI_ShapeAPI.h"
  
  #include <GeomAlgoAPI_Box.h>
 -#include <GeomAlgoAPI_Cylinder.h>
  #include <GeomAlgoAPI_CompoundBuilder.h>
 +#include <GeomAlgoAPI_Cone.h>
  #include <GeomAlgoAPI_ConeSegment.h>
 +#include <GeomAlgoAPI_Cylinder.h>
  #include <GeomAlgoAPI_EdgeBuilder.h>
  #include <GeomAlgoAPI_Rotation.h>
  #include <GeomAlgoAPI_Scale.h>
 +#include <GeomAlgoAPI_Sphere.h>
  #include <GeomAlgoAPI_Symmetry.h>
 +#include <GeomAlgoAPI_Torus.h>
  #include <GeomAlgoAPI_Translation.h>
  
  #include <GeomAPI_Lin.h>
@@@ -195,187 -192,6 +195,187 @@@ namespace GeomAlgoAPI_ShapeAP
      return aCylinderAlgo.shape();
    }
  
 +  //===============================================================================================
 +  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(
 +      std::shared_ptr<GeomAPI_Pnt> theCenterPoint, double theRadius) throw (GeomAlgoAPI_Exception)
 +  {
 +    GeomAlgoAPI_Sphere aSphereAlgo(theCenterPoint, theRadius);
 +
 +    if (!aSphereAlgo.check()) {
 +      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
 +    }
 +
 +    aSphereAlgo.build();
 +
 +    if(!aSphereAlgo.isDone()) {
 +      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
 +    }
 +
 +    if (!aSphereAlgo.checkValid("Sphere builder")) {
 +      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
 +    }
 +    return aSphereAlgo.shape();
 +  }
 +
 +  //===============================================================================================
 +  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(double theRadius)
 +      throw (GeomAlgoAPI_Exception)
 +  {
 +    std::shared_ptr<GeomAPI_Pnt> aCenterPoint =
 +      std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
 +
 +    GeomAlgoAPI_Sphere aSphereAlgo(aCenterPoint, theRadius);
 +
 +    if (!aSphereAlgo.check()) {
 +      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
 +    }
 +
 +    aSphereAlgo.build();
 +
 +    if(!aSphereAlgo.isDone()) {
 +      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
 +    }
 +
 +    if (!aSphereAlgo.checkValid("Sphere builder")) {
 +      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
 +    }
 +    return aSphereAlgo.shape();
 +  }
 +
 +  //===============================================================================================
 +  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(
 +      std::shared_ptr<GeomAPI_Pnt> theBasePoint,
 +      std::shared_ptr<GeomAPI_Edge> theEdge,double theRadius, double theRingRadius)
 +      throw (GeomAlgoAPI_Exception)
 +  {
 +    // Check if the base point is OK
 +    if (!theBasePoint) {
 +      throw GeomAlgoAPI_Exception("Torus builder :: the base point is not valid.");
 +    }
 +    // Check if the edge is OK
 +    if (!theEdge) {
 +      throw GeomAlgoAPI_Exception("Torus 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()));
 +
 +    GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
 +
 +    if (!aTorusAlgo.check()) {
 +      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
 +    }
 +
 +    aTorusAlgo.build();
 +
 +    if(!aTorusAlgo.isDone()) {
 +      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
 +    }
 +
 +    if (!aTorusAlgo.checkValid("Torus builder")) {
 +      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
 +    }
 +    return aTorusAlgo.shape();
 +  }
 +
 +  //===============================================================================================
 +  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(double theRadius,
 +      double theRingRadius) throw (GeomAlgoAPI_Exception)
 +  {
 +    std::shared_ptr<GeomAPI_Pnt> aBasePoint =
 +      std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
 +    std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
 +    std::shared_ptr<GeomAPI_Ax2> anAxis;
 +    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
 +                                                          aEdge->line()->direction()));
 +
 +    GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
 +
 +    if (!aTorusAlgo.check()) {
 +      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
 +    }
 +
 +    aTorusAlgo.build();
 +
 +    if(!aTorusAlgo.isDone()) {
 +      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
 +    }
 +
 +    if (!aTorusAlgo.checkValid("Torus builder")) {
 +      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
 +    }
 +    return aTorusAlgo.shape();
 +  }
 +
 +  //===============================================================================================
 +  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
 +      std::shared_ptr<GeomAPI_Pnt> theBasePoint,
 +      std::shared_ptr<GeomAPI_Edge> theEdge,
 +      double theBaseRadius, double theTopRadius,
 +      double theHeight) throw (GeomAlgoAPI_Exception)
 +  {
 +    // Check if the base point is OK
 +    if (!theBasePoint) {
 +      throw GeomAlgoAPI_Exception("Cone builder :: the base point is not valid.");
 +    }
 +    // Check if the edge is OK
 +    if (!theEdge) {
 +      throw GeomAlgoAPI_Exception("Cone 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()));
 +
 +    GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
 +
 +    if (!aConeAlgo.check()) {
 +      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
 +    }
 +
 +    aConeAlgo.build();
 +
 +    if(!aConeAlgo.isDone()) {
 +      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
 +    }
 +
 +    if (!aConeAlgo.checkValid("Cone builder")) {
 +      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
 +    }
 +    return aConeAlgo.shape();
 +  }
 +
 +  //===============================================================================================
 +  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
 +      double theBaseRadius, double theTopRadius,
 +      double theHeight) throw (GeomAlgoAPI_Exception)
 +  {
 +    std::shared_ptr<GeomAPI_Pnt> aBasePoint =
 +      std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
 +    std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
 +    std::shared_ptr<GeomAPI_Ax2> anAxis;
 +    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
 +                                                          aEdge->line()->direction()));
 +
 +    GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
 +
 +    if (!aConeAlgo.check()) {
 +      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
 +    }
 +
 +    aConeAlgo.build();
 +
 +    if(!aConeAlgo.isDone()) {
 +      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
 +    }
 +
 +    if (!aConeAlgo.checkValid("Cone builder")) {
 +      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
 +    }
 +    return aConeAlgo.shape();
 +  }
 +
    //===============================================================================================
    std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
      std::shared_ptr<GeomAPI_Shape> theSourceShape,
      const double theStep,
      const int theNumber) throw (GeomAlgoAPI_Exception)
    {
-     if (theNumber <=0) {
+     if (!theAxis) {
        std::string aError = "Multitranslation builder ";
-       aError+=":: the number of copies for the first direction is null or negative.";
+       aError+=":: the first axis is not valid";
        throw GeomAlgoAPI_Exception(aError);
      }
  
-     if (!theAxis) {
+     if (theNumber <=0) {
        std::string aError = "Multitranslation builder ";
-       aError+=":: the first axis is not valid";
+       aError+=":: the number of copies for the first direction is null or negative.";
        throw GeomAlgoAPI_Exception(aError);
      }
  
      const double theSecondStep,
      const int theSecondNumber) throw (GeomAlgoAPI_Exception)
    {
-     if (theFirstNumber <=0) {
+     if (!theFirstAxis) {
        std::string aError = "Multitranslation builder ";
-       aError+=":: the number of copies for the first direction is null or negative.";
+       aError+=":: the first axis is not valid";
        throw GeomAlgoAPI_Exception(aError);
      }
  
-     if (theSecondNumber <=0) {
+     if (!theSecondAxis) {
        std::string aError = "Multitranslation builder ";
-       aError+=":: the number of copies for the second direction is null or negative.";
+       aError+=":: the second axis is not valid";
        throw GeomAlgoAPI_Exception(aError);
      }
  
-     if (!theFirstAxis) {
+     if (theFirstNumber <=0) {
        std::string aError = "Multitranslation builder ";
-       aError+=":: the first axis is not valid";
+       aError+=":: the number of copies for the first direction is null or negative.";
        throw GeomAlgoAPI_Exception(aError);
      }
  
-     if (!theSecondAxis) {
+     if (theSecondNumber <=0) {
        std::string aError = "Multitranslation builder ";
-       aError+=":: the second axis is not valid";
+       aError+=":: the number of copies for the second direction is null or negative.";
        throw GeomAlgoAPI_Exception(aError);
      }