Salome HOME
Remove Angle from the list of classes a useless for the current moment.
[modules/shaper.git] / src / GeomAPI / GeomAPI_ShapeIterator.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAPI_ShapeIterator.cpp
4 // Created:     27 April 2016
5 // Author:      Dmitry Bobylev
6
7 #include "GeomAPI_ShapeIterator.h"
8
9 #include <Standard_NoMoreObject.hxx>
10 #include <TopoDS_Iterator.hxx>
11
12 #define MY_ITERATOR implPtr<TopoDS_Iterator>()
13
14 //==================================================================================================
15 GeomAPI_ShapeIterator::GeomAPI_ShapeIterator()
16 : GeomAPI_Interface(new TopoDS_Iterator())
17 {
18 }
19
20 //==================================================================================================
21 GeomAPI_ShapeIterator::GeomAPI_ShapeIterator(const std::shared_ptr<GeomAPI_Shape> theShape)
22 : GeomAPI_Interface(new TopoDS_Iterator())
23 {
24   init(theShape);
25 }
26
27 //==================================================================================================
28 void GeomAPI_ShapeIterator::init(const std::shared_ptr<GeomAPI_Shape> theShape)
29 {
30   if(!theShape.get()) {
31     return;
32   }
33   MY_ITERATOR->Initialize(theShape->impl<TopoDS_Shape>());
34 }
35
36 //==================================================================================================
37 bool GeomAPI_ShapeIterator::more() const
38 {
39   return MY_ITERATOR->More() == Standard_True;
40 }
41
42 //==================================================================================================
43 void GeomAPI_ShapeIterator::next()
44 {
45   try {
46     MY_ITERATOR->Next();
47   } catch (Standard_NoMoreObject) {
48   }
49 }
50
51 //==================================================================================================
52 std::shared_ptr<GeomAPI_Shape> GeomAPI_ShapeIterator::current()
53 {
54   try {
55     const TopoDS_Shape& aShape = MY_ITERATOR->Value();
56     std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape());
57     aGeomShape->setImpl(new TopoDS_Shape(aShape));
58     return aGeomShape;
59   } catch (Standard_NoMoreObject) {
60     return std::shared_ptr<GeomAPI_Shape>();
61   }
62 }