Salome HOME
Merge branch 'master' into cgt/devCEA
[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
10 #include <GeomAPI_Pnt.h>
11 #include <GeomAPI_Edge.h>
12 #include <GeomAlgoAPI_EdgeBuilder.h>
13
14 #include <iostream>
15
16 namespace GeomAlgoAPI_ShapeAPI
17 {
18   //=======================================================================================
19   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
20     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(
42     std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
43     std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
44   {
45     GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint);
46
47     if (!aBoxAlgo.check()) {
48       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
49     }
50
51     aBoxAlgo.build();
52
53     if(!aBoxAlgo.isDone()) {
54       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
55     }
56     if (!aBoxAlgo.checkValid("Box builder with two points")) {
57       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
58     }
59     return aBoxAlgo.shape();
60   }
61 }