summaryrefslogtreecommitdiff
path: root/src/Sweep/Sweep_NumShapeTool.cxx
blob: 505a52b2a8fbb7ca0035a02fd2da460f9ff4f820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// File:	Sweep_NumShapeTool.cxx
// Created:	Wed Jun  2 16:18:37 1993
// Author:	Laurent BOURESCHE
//		<lbo@phylox>


#include <Sweep_NumShapeTool.ixx>
#include <Standard_ConstructionError.hxx>

//=======================================================================
//function : Sweep_NumShapeTool
//purpose  : 
//=======================================================================

Sweep_NumShapeTool::Sweep_NumShapeTool(const Sweep_NumShape& aShape) :
       myNumShape(aShape)
{
}


//=======================================================================
//function : NbShapes
//purpose  : 
//=======================================================================

Standard_Integer  Sweep_NumShapeTool::NbShapes()const 
{
  if (myNumShape.Type()==TopAbs_EDGE){
    if (myNumShape.Closed()) { return myNumShape.Index(); }
    else { return myNumShape.Index() + 1 ;}
  }
  else{
    return 1;
  }
}


//=======================================================================
//function : Index
//purpose  : 
//=======================================================================

Standard_Integer  Sweep_NumShapeTool::Index
  (const Sweep_NumShape& aShape)const 
{
  if (aShape.Type()==TopAbs_EDGE){
    return 1;
  }
  else{
    if (aShape.Closed()) { return 2; }
    else { return (aShape.Index() + 1); }
  }
}


//=======================================================================
//function : Shape
//purpose  : 
//=======================================================================

Sweep_NumShape  Sweep_NumShapeTool::Shape
  (const Standard_Integer anIndex)const 
{
  if (anIndex == 1){
    return myNumShape;
  }
  else{
    return Sweep_NumShape((anIndex-1),TopAbs_VERTEX,
			  myNumShape.Closed(),Standard_False,
			  Standard_False);
  }
}


//=======================================================================
//function : Type
//purpose  : 
//=======================================================================

TopAbs_ShapeEnum  Sweep_NumShapeTool::Type(const Sweep_NumShape& aShape)const 
{
  return aShape.Type();
}



//=======================================================================
//function : Orientation
//purpose  : 
//=======================================================================

TopAbs_Orientation  Sweep_NumShapeTool::Orientation
  (const Sweep_NumShape& aShape)const 
{
  return aShape.Orientation();
}


//=======================================================================
//function : HasFirstVertex
//purpose  : 
//=======================================================================

Standard_Boolean Sweep_NumShapeTool::HasFirstVertex()const
{
  if (myNumShape.Type()==TopAbs_EDGE)
    return !myNumShape.BegInfinite();
  return Standard_True;
}


//=======================================================================
//function : HasLastVertex
//purpose  : 
//=======================================================================

Standard_Boolean Sweep_NumShapeTool::HasLastVertex()const
{
  if (myNumShape.Type()==TopAbs_EDGE)
    return !myNumShape.EndInfinite();
  return Standard_True;
}


//=======================================================================
//function : FirstVertex
//purpose  : 
//=======================================================================

Sweep_NumShape Sweep_NumShapeTool::FirstVertex()const
{
  if (myNumShape.Type()==TopAbs_EDGE){
    if(HasFirstVertex()){
      return Sweep_NumShape(1,TopAbs_VERTEX,
			    myNumShape.Closed(),Standard_False,
			    Standard_False);
    }
    else Standard_ConstructionError::Raise("inifinite Shape");
  }
  return myNumShape;
}


//=======================================================================
//function : LastVertex
//purpose  : 
//=======================================================================

Sweep_NumShape Sweep_NumShapeTool::LastVertex()const
{
  if (myNumShape.Type()==TopAbs_EDGE){
    if(HasLastVertex()){
      return Sweep_NumShape(NbShapes()-1,TopAbs_VERTEX,
			    myNumShape.Closed(),Standard_False,
			    Standard_False);
    }
    else Standard_ConstructionError::Raise("inifinite Shape");
  }
  return myNumShape;
}