Salome HOME
Issue #1860: fix end lines with spaces
[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(
21     const double theDx, const double theDy,
22     const double theDz) throw (GeomAlgoAPI_Exception)
23   {
24     GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz);
25
26     if (!aBoxAlgo.check()) {
27       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
28     }
29
30     aBoxAlgo.build();
31
32     if(!aBoxAlgo.isDone()) {
33       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
34     }
35     if (!aBoxAlgo.checkValid("Box builder with dimensions")) {
36       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
37     }
38     return aBoxAlgo.shape();
39   }
40
41   //======================================================================================
42   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
43     std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
44     std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
45   {
46     GeomAlgoAPI_BoxPoints aBoxAlgo(theFirstPoint, theSecondPoint);
47
48     if (!aBoxAlgo.check()) {
49       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
50     }
51
52     aBoxAlgo.build();
53
54     if(!aBoxAlgo.isDone()) {
55       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
56     }
57     if (!aBoxAlgo.checkValid("Box builder with two points")) {
58       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
59     }
60     return aBoxAlgo.shape();
61   }
62 }