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_Translation.h>
14 #include <GeomAPI_Pnt.h>
15 #include <GeomAPI_Edge.h>
19 namespace GeomAlgoAPI_ShapeAPI
21 //=======================================================================================
22 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
23 const double theDx, const double theDy,
24 const double theDz) throw (GeomAlgoAPI_Exception)
26 GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz);
28 if (!aBoxAlgo.check()) {
29 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
34 if(!aBoxAlgo.isDone()) {
35 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
37 if (!aBoxAlgo.checkValid("Box builder with dimensions")) {
38 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
40 return aBoxAlgo.shape();
43 //======================================================================================
44 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
45 std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
46 std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
48 GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint);
50 if (!aBoxAlgo.check()) {
51 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
56 if(!aBoxAlgo.isDone()) {
57 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
59 if (!aBoxAlgo.checkValid("Box builder with two points")) {
60 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
62 return aBoxAlgo.shape();
65 //=========================================================================================================
66 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
67 std::shared_ptr<GeomAPI_Shape> theSourceShape,
68 std::shared_ptr<GeomAPI_Ax1> theAxis,
69 const double theDistance) throw (GeomAlgoAPI_Exception)
71 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance);
73 if (!aTranslationAlgo.check()) {
74 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
77 aTranslationAlgo.build();
79 if(!aTranslationAlgo.isDone()) {
80 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
82 if (!aTranslationAlgo.checkValid("Translation builder with axis and distance")) {
83 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
85 return aTranslationAlgo.shape();
88 //=========================================================================================================
89 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
90 std::shared_ptr<GeomAPI_Shape> theSourceShape,
93 const double theDz) throw (GeomAlgoAPI_Exception)
95 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz);
97 if (!aTranslationAlgo.check()) {
98 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
101 aTranslationAlgo.build();
103 if(!aTranslationAlgo.isDone()) {
104 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
106 if (!aTranslationAlgo.checkValid("Translation builder with dimensions")) {
107 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
109 return aTranslationAlgo.shape();
112 //=========================================================================================================
113 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
114 std::shared_ptr<GeomAPI_Shape> theSourceShape,
115 std::shared_ptr<GeomAPI_Pnt> theStartPoint,
116 std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception)
118 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint);
120 if (!aTranslationAlgo.check()) {
121 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
124 aTranslationAlgo.build();
126 if(!aTranslationAlgo.isDone()) {
127 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
129 if (!aTranslationAlgo.checkValid("Translation builder with two points")) {
130 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
132 return aTranslationAlgo.shape();
135 //=========================================================================================================
136 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeConeSegment(
137 const double theRMin1, const double theRMax1,
138 const double theRMin2, const double theRMax2,
140 const double theStartPhi, const double theDeltaPhi) throw (GeomAlgoAPI_Exception)
142 GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2,
143 theZ, theStartPhi, theDeltaPhi);
145 if (!aConeSegmentAlgo.check()) {
146 throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
149 aConeSegmentAlgo.build();
151 if(!aConeSegmentAlgo.isDone()) {
152 throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
154 if (!aConeSegmentAlgo.checkValid("Cone Segment builder")) {
155 throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
157 return aConeSegmentAlgo.shape();