1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_ShapeAPI.cpp
4 // Created: 17 Mar 2016
5 // Author: Clarisse Genrault (CEA)
7 #include "GeomAlgoAPI_ShapeAPI.h"
8 #include <GeomAlgoAPI_Box.h>
9 #include <GeomAlgoAPI_Translation.h>
11 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_Edge.h>
13 #include <GeomAlgoAPI_EdgeBuilder.h>
17 namespace GeomAlgoAPI_ShapeAPI
19 //=======================================================================================
20 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
21 const double theDx, const double theDy,
22 const double theDz) throw (GeomAlgoAPI_Exception)
24 GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz);
26 if (!aBoxAlgo.check()) {
27 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
32 if(!aBoxAlgo.isDone()) {
33 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
35 if (!aBoxAlgo.checkValid("Box builder with dimensions")) {
36 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
38 return aBoxAlgo.shape();
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)
46 GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint);
48 if (!aBoxAlgo.check()) {
49 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
54 if(!aBoxAlgo.isDone()) {
55 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
57 if (!aBoxAlgo.checkValid("Box builder with two points")) {
58 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
60 return aBoxAlgo.shape();
63 //=========================================================================================================
64 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
65 std::shared_ptr<GeomAPI_Shape> theSourceShape,
66 std::shared_ptr<GeomAPI_Ax1> theAxis,
67 const double theDistance) throw (GeomAlgoAPI_Exception)
69 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance);
71 if (!aTranslationAlgo.check()) {
72 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
75 aTranslationAlgo.build();
77 if(!aTranslationAlgo.isDone()) {
78 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
80 if (!aTranslationAlgo.checkValid("Translation builder with axis and distance")) {
81 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
83 return aTranslationAlgo.shape();
86 //=========================================================================================================
87 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
88 std::shared_ptr<GeomAPI_Shape> theSourceShape,
91 const double theDz) throw (GeomAlgoAPI_Exception)
93 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz);
95 if (!aTranslationAlgo.check()) {
96 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
99 aTranslationAlgo.build();
101 if(!aTranslationAlgo.isDone()) {
102 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
104 if (!aTranslationAlgo.checkValid("Translation builder with dimensions")) {
105 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
107 return aTranslationAlgo.shape();
110 //=========================================================================================================
111 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
112 std::shared_ptr<GeomAPI_Shape> theSourceShape,
113 std::shared_ptr<GeomAPI_Pnt> theStartPoint,
114 std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception)
116 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint);
118 if (!aTranslationAlgo.check()) {
119 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
122 aTranslationAlgo.build();
124 if(!aTranslationAlgo.isDone()) {
125 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
127 if (!aTranslationAlgo.checkValid("Translation builder with two points")) {
128 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
130 return aTranslationAlgo.shape();