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"
9 #include <GeomAlgoAPI_Box.h>
10 #include <GeomAlgoAPI_ConeSegment.h>
11 #include <GeomAlgoAPI_EdgeBuilder.h>
12 #include <GeomAlgoAPI_Symmetry.h>
13 #include <GeomAlgoAPI_Translation.h>
15 namespace GeomAlgoAPI_ShapeAPI
17 //=======================================================================================
18 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
19 const double theDx, const double theDy,
20 const double theDz) throw (GeomAlgoAPI_Exception)
22 GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz);
24 if (!aBoxAlgo.check()) {
25 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
30 if(!aBoxAlgo.isDone()) {
31 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
33 if (!aBoxAlgo.checkValid("Box builder with dimensions")) {
34 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
36 return aBoxAlgo.shape();
39 //======================================================================================
40 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
41 std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
42 std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
44 GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint);
46 if (!aBoxAlgo.check()) {
47 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
52 if(!aBoxAlgo.isDone()) {
53 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
55 if (!aBoxAlgo.checkValid("Box builder with two points")) {
56 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
58 return aBoxAlgo.shape();
61 //=========================================================================================================
62 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
63 std::shared_ptr<GeomAPI_Shape> theSourceShape,
64 std::shared_ptr<GeomAPI_Ax1> theAxis,
65 const double theDistance) throw (GeomAlgoAPI_Exception)
67 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance);
69 if (!aTranslationAlgo.check()) {
70 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
73 aTranslationAlgo.build();
75 if(!aTranslationAlgo.isDone()) {
76 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
78 if (!aTranslationAlgo.checkValid("Translation builder with axis and distance")) {
79 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
81 return aTranslationAlgo.shape();
84 //=========================================================================================================
85 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
86 std::shared_ptr<GeomAPI_Shape> theSourceShape,
89 const double theDz) throw (GeomAlgoAPI_Exception)
91 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz);
93 if (!aTranslationAlgo.check()) {
94 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
97 aTranslationAlgo.build();
99 if(!aTranslationAlgo.isDone()) {
100 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
102 if (!aTranslationAlgo.checkValid("Translation builder with dimensions")) {
103 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
105 return aTranslationAlgo.shape();
108 //=========================================================================================================
109 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
110 std::shared_ptr<GeomAPI_Shape> theSourceShape,
111 std::shared_ptr<GeomAPI_Pnt> theStartPoint,
112 std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception)
114 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint);
116 if (!aTranslationAlgo.check()) {
117 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
120 aTranslationAlgo.build();
122 if(!aTranslationAlgo.isDone()) {
123 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
125 if (!aTranslationAlgo.checkValid("Translation builder with two points")) {
126 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
128 return aTranslationAlgo.shape();
131 //=========================================================================================================
132 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
133 std::shared_ptr<GeomAPI_Shape> theSourceShape,
134 std::shared_ptr<GeomAPI_Pnt> thePoint) throw (GeomAlgoAPI_Exception)
136 GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePoint);
138 if (!aSymmetryAlgo.check()) {
139 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
142 aSymmetryAlgo.build();
144 if(!aSymmetryAlgo.isDone()) {
145 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
147 if (!aSymmetryAlgo.checkValid("Symmetry builder by a point")) {
148 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
150 return aSymmetryAlgo.shape();
153 //=========================================================================================================
154 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
155 std::shared_ptr<GeomAPI_Shape> theSourceShape,
156 std::shared_ptr<GeomAPI_Ax1> theAxis) throw (GeomAlgoAPI_Exception)
158 GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, theAxis);
160 if (!aSymmetryAlgo.check()) {
161 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
164 aSymmetryAlgo.build();
166 if(!aSymmetryAlgo.isDone()) {
167 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
169 if (!aSymmetryAlgo.checkValid("Symmetry builder by an axis")) {
170 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
172 return aSymmetryAlgo.shape();
175 //=========================================================================================================
176 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
177 std::shared_ptr<GeomAPI_Shape> theSourceShape,
178 std::shared_ptr<GeomAPI_Ax2> thePlane) throw (GeomAlgoAPI_Exception)
180 GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePlane);
182 if (!aSymmetryAlgo.check()) {
183 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
186 aSymmetryAlgo.build();
188 if(!aSymmetryAlgo.isDone()) {
189 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
191 if (!aSymmetryAlgo.checkValid("Symmetry builder by a plane")) {
192 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
194 return aSymmetryAlgo.shape();
197 //=========================================================================================================
198 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeConeSegment(
199 const double theRMin1, const double theRMax1,
200 const double theRMin2, const double theRMax2,
202 const double theStartPhi, const double theDeltaPhi) throw (GeomAlgoAPI_Exception)
204 GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2,
205 theZ, theStartPhi, theDeltaPhi);
207 if (!aConeSegmentAlgo.check()) {
208 throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
211 aConeSegmentAlgo.build();
213 if(!aConeSegmentAlgo.isDone()) {
214 throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
216 if (!aConeSegmentAlgo.checkValid("Cone Segment builder")) {
217 throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
219 return aConeSegmentAlgo.shape();