0024023: Revamp the OCCT Handle -- downcast (automatic)
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_PointIterator.cxx
CommitLineData
b311480e 1// Created on: 1993-06-17
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <TopOpeBRepDS_PointIterator.ixx>
18#include <TopOpeBRepDS_Interference.hxx>
19#include <TopOpeBRepDS_CurvePointInterference.hxx>
20#include <TopOpeBRepDS_EdgeVertexInterference.hxx>
21#include <Standard_ProgramError.hxx>
22
23//=======================================================================
24//function : TopOpeBRepDS_PointIterator
25//purpose :
26//=======================================================================
27
28TopOpeBRepDS_PointIterator::TopOpeBRepDS_PointIterator
29 (const TopOpeBRepDS_ListOfInterference& L) :
30 TopOpeBRepDS_InterferenceIterator(L)
31{
32 Match();
33}
34
35//=======================================================================
36//function : MatchInterference
37//purpose :
38//=======================================================================
39
40Standard_Boolean TopOpeBRepDS_PointIterator::MatchInterference
41 (const Handle(TopOpeBRepDS_Interference)& I) const
42{
43 TopOpeBRepDS_Kind GT = I->GeometryType();
44 Standard_Boolean r = ( GT == TopOpeBRepDS_POINT) || ( GT == TopOpeBRepDS_VERTEX);
45 return r;
46}
47
48//=======================================================================
49//function : Current
50//purpose :
51//=======================================================================
52
53Standard_Integer TopOpeBRepDS_PointIterator::Current()const
54{
55 return Value()->Geometry();
56}
57
58
59//=======================================================================
60//function : Orientation
61//purpose :
62//=======================================================================
63
64TopAbs_Orientation TopOpeBRepDS_PointIterator::Orientation
65 (const TopAbs_State S)const
66{
67 Handle(TopOpeBRepDS_Interference) I = Value();
68 const TopOpeBRepDS_Transition& T = I->Transition();
69 TopAbs_Orientation o = T.Orientation(S);
70 return o;
71}
72
73
74//=======================================================================
75//function : Parameter
76//purpose :
77//=======================================================================
78
79Standard_Real TopOpeBRepDS_PointIterator::Parameter()const
80{
81
0797d9d3 82#ifdef OCCT_DEBUG
7fd59977 83// cout<<"PointIterator : I = "; Value()->Dump(cout); cout<<endl;
84#endif
85
86 const Handle(TopOpeBRepDS_Interference)& I = Value();
87 Handle(Standard_Type) T = I->DynamicType();
88 if ( T == STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference) ) {
c5f3a425 89 return Handle(TopOpeBRepDS_CurvePointInterference)::DownCast (I)->Parameter();
7fd59977 90 }
91 else if ( T == STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference) ) {
c5f3a425 92 return Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast (I)->Parameter();
7fd59977 93 }
94 else {
95 Standard_ProgramError::Raise("TopOpeBRepDS_PointIterator::Parameter()");
96 return 0.; // windowsNT
97 }
d3f26155 98// return 0.; // windowsNT
7fd59977 99}
100
101//=======================================================================
102//function : IsVertex
103//purpose :
104//=======================================================================
105
106Standard_Boolean TopOpeBRepDS_PointIterator::IsVertex() const
107{
108 return (Value()->GeometryType() == TopOpeBRepDS_VERTEX);
109}
110
111//=======================================================================
112//function : IsPoint
113//purpose :
114//=======================================================================
115
116Standard_Boolean TopOpeBRepDS_PointIterator::IsPoint() const
117{
118 return (Value()->GeometryType() == TopOpeBRepDS_POINT);
119}
120
121//=======================================================================
122//function : DiffOriented
123//purpose :
124//=======================================================================
125
126Standard_Boolean TopOpeBRepDS_PointIterator::DiffOriented() const
127{
128 const Handle(TopOpeBRepDS_Interference)& I = Value();
129 if ( I->DynamicType() == STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference) ) {
c5f3a425 130 return Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast (I)
7fd59977 131 ->Config() == TopOpeBRepDS_DIFFORIENTED;
132 }
133 else {
134 Standard_ProgramError::Raise("TopOpeBRepDS_PointIterator::DiffOriented()");
135 return Standard_False; // windowsNT
136 }
d3f26155 137// return Standard_False; // windowsNT
7fd59977 138}
139
140//=======================================================================
141//function : SameOriented
142//purpose :
143//=======================================================================
144
145Standard_Boolean TopOpeBRepDS_PointIterator::SameOriented() const
146{
147 const Handle(TopOpeBRepDS_Interference)& I = Value();
148 if ( I->DynamicType() == STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference) ) {
c5f3a425 149 return Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast (I)
7fd59977 150 ->Config() == TopOpeBRepDS_SAMEORIENTED;
151 }
152 else {
153 Standard_ProgramError::Raise("TopOpeBRepDS_PointIterator::SameOriented()");
154 return Standard_False; // windowsNT
155 }
7fd59977 156}
157
158//=======================================================================
159//function : Support
160//purpose :
161//=======================================================================
162
163Standard_Integer TopOpeBRepDS_PointIterator::Support() const
164{
165 return (Value()->Support());
166}