Salome HOME
Renaming the direct API high level.
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_ShapeAPI.cpp
1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_ShapeAPI.cpp
4 // Created:     17 Mar 2016
5 // Author:      Clarisse Genrault (CEA)
6
7 #include "GeomAlgoAPI_ShapeAPI.h"
8 #include <GeomAlgoAPI_Box.h>
9 #include <GeomAlgoAPI_BoxPoints.h>
10
11 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_Edge.h>
13 #include <GeomAlgoAPI_EdgeBuilder.h>
14
15 #include <iostream>
16
17 namespace GeomAlgoAPI_ShapeAPI
18 {
19   //=========================================================================================================
20   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(const double theDx, const double theDy, 
21                                                                 const double theDz) throw (GeomAlgoAPI_Exception)
22   {
23     GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz);
24     
25     if (!aBoxAlgo.check()) {
26       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
27     }
28     
29     aBoxAlgo.build();
30     
31     if(!aBoxAlgo.isDone()) {
32       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
33     }
34     if (!aBoxAlgo.checkValid("Box builder with dimensions")) {
35       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
36     }
37     return aBoxAlgo.shape();
38   }
39   
40   //=========================================================================================================
41   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
42                                                                 std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
43   {
44     GeomAlgoAPI_BoxPoints aBoxAlgo(theFirstPoint, theSecondPoint);
45     
46     if (!aBoxAlgo.check()) {
47       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
48     }
49     
50     aBoxAlgo.build();
51     
52     if(!aBoxAlgo.isDone()) {
53       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
54     }
55     if (!aBoxAlgo.checkValid("Box builder with two points")) {
56       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
57     }
58     return aBoxAlgo.shape();
59   }
60 }