summaryrefslogtreecommitdiff
path: root/src/BRepPrimAPI/BRepPrimAPI_MakeSphere.cxx
blob: a0edb711cc620f7c7eafce42f35b3cbf5d33e931 (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// File:	BRepPrimAPI_MakeSphere.cxx
// Created:	Fri Jul 23 15:51:53 1993
// Author:	Remi LEQUETTE
//		<rle@nonox>


#include <BRepPrimAPI_MakeSphere.ixx>
#include <BRepBuilderAPI.hxx>


#include <gp.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax2.hxx>


//-- lbr le 13 decembre 95
static gp_Ax2 SphereComputeAxes() { 
  static Standard_Integer firsttime=1;
  static Standard_Integer modif=0;
  static Standard_Real cosa=cos(0.111);
  static Standard_Real sina=sin(0.111);
  static Standard_Real ux=1.0;
  static Standard_Real uy=0.0;
  
  if(firsttime) { 
    modif = getenv("PRIM_SPHERE") != NULL;
    firsttime = 0;
  }
  if(modif) { 
    Standard_Real nux = cosa*ux+sina*uy;
    Standard_Real nuy =-sina*ux+cosa*uy;
    ux=nux; uy=nuy;
    return(gp_Ax2(gp::Origin(),gp::DZ(),gp_Dir(ux,uy,0.0)));
  }
  else { 
    return(gp::XOY());
  }
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R) :
       mySphere(SphereComputeAxes(),R)
{
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R, 
				       const Standard_Real angle) :
       mySphere(gp_Ax2(gp::Origin(), (angle<0.?-1:1)*gp::DZ(), gp::DX()),
		R)
{
  mySphere.Angle(Abs(angle));
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R,
				       const Standard_Real angle1, 
				       const Standard_Real angle2) :
       mySphere(R)
{
  mySphere.VMin(angle1);
  mySphere.VMax(angle2);
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R, 
				       const Standard_Real angle1,
				       const Standard_Real angle2, 
				       const Standard_Real angle3) :
       mySphere(R)
{
  mySphere.VMin(angle1);
  mySphere.VMax(angle2);
  mySphere.Angle(angle3);
}

//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Pnt& Center,
				       const Standard_Real R) :
       mySphere(gp_Ax2(Center, gp_Dir(0,0,1), gp_Dir(1,0,0)),
		R)
{
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Pnt& Center,
				       const Standard_Real R, 
				       const Standard_Real angle) :
       mySphere(gp_Ax2(Center, gp_Dir(0,0,1), gp_Dir(1,0,0)),
		R)
{
  mySphere.Angle(angle);
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Pnt& Center,
				       const Standard_Real R,
				       const Standard_Real angle1,
				       const Standard_Real angle2) :
       mySphere(gp_Ax2(Center, gp_Dir(0,0,1), gp_Dir(1,0,0)),
		R)
{
  mySphere.VMin(angle1);
  mySphere.VMax(angle2);
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Pnt& Center,
				       const Standard_Real R,
				       const Standard_Real angle1,
				       const Standard_Real angle2,
				       const Standard_Real angle3) :
       mySphere(gp_Ax2(Center, gp_Dir(0,0,1), gp_Dir(1,0,0)),
		R)
{
  mySphere.VMin(angle1);
  mySphere.VMax(angle2);
  mySphere.Angle(angle3);
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Ax2& Axis,
				       const Standard_Real R) :
       mySphere(Axis, R)
{
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Ax2& Axis,
				       const Standard_Real R,
				       const Standard_Real angle) :
       mySphere( Axis, R)
{
  mySphere.Angle(angle);
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Ax2& Axis, 
				       const Standard_Real R,
				       const Standard_Real angle1, 
				       const Standard_Real angle2) :
       mySphere(Axis, R)
{
  mySphere.VMin(angle1);
  mySphere.VMax(angle2);
}


//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose  : 
//=======================================================================

BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Ax2& Axis, 
				       const Standard_Real R,
				       const Standard_Real angle1, 
				       const Standard_Real angle2, 
				       const Standard_Real angle3) :
       mySphere( Axis, R)
{
  mySphere.VMin(angle1);
  mySphere.VMax(angle2);
  mySphere.Angle(angle3);
}



//=======================================================================
//function : OneAxis
//purpose  : 
//=======================================================================

Standard_Address  BRepPrimAPI_MakeSphere::OneAxis()
{
  return &mySphere;
}


//=======================================================================
//function : Sphere
//purpose  : 
//=======================================================================

BRepPrim_Sphere&  BRepPrimAPI_MakeSphere::Sphere()
{
  return mySphere;
}