Adding svn:eol-style=LF property
[occt.git] / samples / qt / Graphic3dDemo / src / Sphere_Sphere.cxx
1 #define G005
2
3 #include <Sphere_Sphere.ixx>
4
5 #include <BRepPrimAPI_MakeSphere.hxx>
6
7 #include <AIS_InteractiveContext.hxx>
8 #include <AIS_Drawer.hxx>
9
10 #include <Prs3d_Root.hxx>
11 #include <Prs3d_ShadingAspect.hxx>
12 #include <Prs3d_LineAspect.hxx>
13
14 #include <StdPrs_WFDeflectionShape.hxx>
15
16 #include <Precision.hxx>
17
18 #include <Aspect_Array1OfEdge.hxx>
19
20 #include <Graphic3d_Structure.hxx>
21 #include <Graphic3d_Group.hxx>
22 #include <Graphic3d_AspectLine3d.hxx>
23 #include <Graphic3d_AspectFillArea3d.hxx>
24 #include <Graphic3d_Array1OfVertex.hxx>
25 #include <Graphic3d_Array1OfVertexN.hxx>
26 #include <Graphic3d_Array1OfVertexC.hxx>
27 #include <Graphic3d_Array1OfVertexNC.hxx>
28 #include <Graphic3d_Array1OfVertexNT.hxx>
29 #ifdef G005
30 #include <Graphic3d_ArrayOfTriangles.hxx>
31 #include <Graphic3d_ArrayOfQuadrangles.hxx>
32 #include <gp_Pnt2d.hxx>
33 #include <gp_Vec.hxx>
34 #endif
35
36 #include <Graphic3d_AspectText3d.hxx>
37
38 Standard_CString stText="Test";
39 Standard_Integer stTextHeight=10;
40
41 static void ShadeWithVertex(const Handle(Graphic3d_Group) aGroup,
42                             const gp_Pnt aPosition, 
43                             const Standard_Real aRadius,
44                             const Standard_Real aDeflection,
45                                 const Standard_Boolean isText,
46                                 const Standard_Boolean isOptText) 
47 {
48       Standard_Real R1,R2;
49       Standard_Real X1,Y1,Z1;
50       Standard_Real X2,Y2,Z2;
51       Standard_Real X3,Y3,Z3;
52       Standard_Real X4,Y4,Z4;
53       Standard_Real Xc,Yc,Zc;
54       Standard_Real Beta = 0.;
55       Standard_Real Alpha = 0.;
56       Standard_Integer nbpanes = Sphere_Sphere::NbPanes(aRadius,aDeflection);
57       Standard_Real Dbeta = 2.*Standard_PI/nbpanes;
58       Standard_Real Dalpha = 2.*Standard_PI/nbpanes;
59       Standard_Integer i,j;
60
61       aPosition.Coord (Xc, Yc, Zc);
62           if(isText) {
63                 Handle(Graphic3d_AspectText3d) Text3d = new Graphic3d_AspectText3d();
64                 Text3d->SetTextureMappedFont(isOptText);
65                 aGroup->SetPrimitivesAspect(Text3d);
66           }
67
68 #ifdef G005
69       if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
70         Handle(Graphic3d_ArrayOfTriangles) ptri =
71                 new Graphic3d_ArrayOfTriangles(3*nbpanes*2,0,
72                 Standard_False,Standard_False,Standard_False,Standard_False);
73         Handle(Graphic3d_ArrayOfQuadrangles) pquad =
74                 new Graphic3d_ArrayOfQuadrangles(4*nbpanes*(nbpanes/2-2),0,
75                 Standard_False,Standard_False,Standard_False,Standard_False);
76         aGroup->BeginPrimitives();
77         for( j=0; j<nbpanes/2; j++ ) {
78           Alpha = 0.;
79           R1 = aRadius*sin(Beta);
80           Z1 = Z4 = aRadius*cos(Beta);
81           Beta += Dbeta;
82           R2 = aRadius*sin(Beta);
83           Z2 = Z3 = aRadius*cos(Beta);
84           for( i=0; i<nbpanes; i++ ) {
85             X1 = R1*cos(Alpha);
86             Y1 = R1*sin(Alpha);
87             X2 = R2*cos(Alpha);
88             Y2 = R2*sin(Alpha);
89             Alpha += Dalpha;
90             X3 = R2*cos(Alpha);
91             Y3 = R2*sin(Alpha);
92             X4 = R1*cos(Alpha);
93             Y4 = R1*sin(Alpha);
94             if( j == 0 ) {
95               ptri->AddVertex(X1+Xc,Y1+Yc,Z1+Zc);
96                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
97               ptri->AddVertex(X2+Xc,Y2+Yc,Z2+Zc);
98                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
99               ptri->AddVertex(X3+Xc,Y3+Yc,Z3+Zc);
100                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
101             } else if( j == nbpanes/2-1 ) {
102               ptri->AddVertex(X1+Xc,Y1+Yc,Z1+Zc);
103                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
104               ptri->AddVertex(X2+Xc,Y2+Yc,Z2+Zc);
105                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
106               ptri->AddVertex(X4+Xc,Y4+Yc,Z4+Zc);
107                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
108             } else {
109               pquad->AddVertex(X1+Xc,Y1+Yc,Z1+Zc);
110                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
111               pquad->AddVertex(X2+Xc,Y2+Yc,Z2+Zc);
112                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
113               pquad->AddVertex(X3+Xc,Y3+Yc,Z3+Zc);
114                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
115               pquad->AddVertex(X4+Xc,Y4+Yc,Z4+Zc);
116                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
117             }
118           }
119         }
120 //        aGroup->BeginPrimitives();
121         aGroup->AddPrimitiveArray(ptri);
122         aGroup->AddPrimitiveArray(pquad);
123         aGroup->EndPrimitives();
124       } else
125 #endif
126       {
127         aGroup->BeginPrimitives();
128         Graphic3d_Array1OfVertex TriVertex(1,3*nbpanes*2);
129         Graphic3d_Array1OfVertex QuadVertex(1,4*nbpanes*(nbpanes/2-2));
130         Aspect_Array1OfEdge TriEdge(1,3*nbpanes*2);
131         Aspect_Array1OfEdge QuadEdge(1,4*nbpanes*(nbpanes/2-2));
132         Standard_Integer nt,nq;
133         for( j=nt=nq=0; j<nbpanes/2; j++ ) {
134           Alpha = 0.;
135           R1 = aRadius*sin(Beta);
136           Z1 = Z4 = aRadius*cos(Beta);
137           Beta += Dbeta;
138           R2 = aRadius*sin(Beta);
139           Z2 = Z3 = aRadius*cos(Beta);
140           for( i=0; i<nbpanes; i++ ) {
141             X1 = R1*cos(Alpha);
142             Y1 = R1*sin(Alpha);
143             X2 = R2*cos(Alpha);
144             Y2 = R2*sin(Alpha);
145             Alpha += Dalpha;
146             X3 = R2*cos(Alpha);
147             Y3 = R2*sin(Alpha);
148             X4 = R1*cos(Alpha);
149             Y4 = R1*sin(Alpha);
150             if( j == 0 ) {
151               nt++;
152               TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
153                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
154               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
155               nt++;
156               TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
157                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
158               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
159               nt++;
160               TriVertex(nt).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
161                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
162               TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
163             } else if( j == nbpanes/2-1 ) {
164               nt++;
165               TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
166                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
167               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
168               nt++;
169               TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
170                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
171               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
172               nt++;
173               TriVertex(nt).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
174                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
175               TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
176             } else {
177               nq++;
178               QuadVertex(nq).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
179                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
180               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
181               nq++;
182               QuadVertex(nq).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
183                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
184               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
185               nq++;
186               QuadVertex(nq).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
187                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
188               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
189               nq++;
190               QuadVertex(nq).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
191                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
192               QuadEdge(nq).SetValues(nq,nq-3,Aspect_TOE_VISIBLE);
193             }
194           }
195         }
196 //        aGroup->BeginPrimitives();
197         aGroup->TriangleSet(TriVertex,TriEdge);
198         aGroup->QuadrangleSet(QuadVertex,QuadEdge);
199         aGroup->EndPrimitives();
200       }
201 }
202
203 static void ShadeWithVertexN(const Handle(Graphic3d_Group) aGroup,
204                             const gp_Pnt aPosition, 
205                             const Standard_Real aRadius,
206                             const Standard_Real aDeflection,
207                                 const Standard_Boolean isText,
208                                 const Standard_Boolean isOptText) 
209 {
210       Standard_Real R1,R2;
211       Standard_Real X1,Y1,Z1;
212       Standard_Real X2,Y2,Z2;
213       Standard_Real X3,Y3,Z3;
214       Standard_Real X4,Y4,Z4;
215       Standard_Real Xc,Yc,Zc;
216       Standard_Real Beta = 0.;
217       Standard_Real Alpha = 0.;
218       Standard_Integer nbpanes = Sphere_Sphere::NbPanes(aRadius,aDeflection);
219       Standard_Real Dbeta = 2.*Standard_PI/nbpanes;
220       Standard_Real Dalpha = 2.*Standard_PI/nbpanes;
221       Standard_Integer i,j;
222
223       aPosition.Coord (Xc, Yc, Zc);
224           if(isText) {
225                 Handle(Graphic3d_AspectText3d) Text3d = new Graphic3d_AspectText3d();
226                 Text3d->SetTextureMappedFont(isOptText);
227                 aGroup->SetPrimitivesAspect(Text3d);
228           }
229 #ifdef G005
230       if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
231         Handle(Graphic3d_ArrayOfTriangles) ptri =
232                 new Graphic3d_ArrayOfTriangles(3*nbpanes*2,0,
233                 Standard_True,Standard_False,Standard_False,Standard_False);
234         Handle(Graphic3d_ArrayOfQuadrangles) pquad =
235                 new Graphic3d_ArrayOfQuadrangles(4*nbpanes*(nbpanes/2-2),0,
236                 Standard_True,Standard_False,Standard_False,Standard_False);
237         aGroup->BeginPrimitives();
238         for( j=0; j<nbpanes/2; j++ ) {
239           Alpha = 0.;
240           R1 = aRadius*sin(Beta);
241           Z1 = Z4 = aRadius*cos(Beta);
242           Beta += Dbeta;
243           R2 = aRadius*sin(Beta);
244           Z2 = Z3 = aRadius*cos(Beta);
245           for( i=0; i<nbpanes; i++ ) {
246             X1 = R1*cos(Alpha);
247             Y1 = R1*sin(Alpha);
248             X2 = R2*cos(Alpha);
249             Y2 = R2*sin(Alpha);
250             Alpha += Dalpha;
251             X3 = R2*cos(Alpha);
252             Y3 = R2*sin(Alpha);
253             X4 = R1*cos(Alpha);
254             Y4 = R1*sin(Alpha);
255             if( j == 0 ) {
256                                 ptri->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),
257                                 gp_Vec(X1/aRadius,Y1/aRadius,Z1/aRadius));
258                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
259                                 ptri->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),
260                                 gp_Vec(X2/aRadius,Y2/aRadius,Z2/aRadius));
261                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
262                                 ptri->AddVertex(gp_Pnt(X3+Xc,Y3+Yc,Z3+Zc),
263                                 gp_Vec(X3/aRadius,Y3/aRadius,Z3/aRadius));
264                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
265             } else if( j == nbpanes/2-1 ) {
266                                 ptri->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),
267                                 gp_Vec(X1/aRadius,Y1/aRadius,Z1/aRadius));
268                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
269                                 ptri->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),
270                                 gp_Vec(X2/aRadius,Y2/aRadius,Z2/aRadius));
271                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
272                                 ptri->AddVertex(gp_Pnt(X4+Xc,Y4+Yc,Z4+Zc),
273                                 gp_Vec(X4/aRadius,Y4/aRadius,Z4/aRadius));
274                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
275             } else {
276                                 pquad->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),
277                                 gp_Vec(X1/aRadius,Y1/aRadius,Z1/aRadius));
278                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
279                                 pquad->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),
280                                 gp_Vec(X2/aRadius,Y2/aRadius,Z2/aRadius));
281                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
282                                 pquad->AddVertex(gp_Pnt(X3+Xc,Y3+Yc,Z3+Zc),
283                                 gp_Vec(X3/aRadius,Y3/aRadius,Z3/aRadius));
284                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
285                                 pquad->AddVertex(gp_Pnt(X4+Xc,Y4+Yc,Z4+Zc),
286                                 gp_Vec(X4/aRadius,Y4/aRadius,Z4/aRadius));
287                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
288             }
289           }
290         }
291 //        aGroup->BeginPrimitives();
292         aGroup->AddPrimitiveArray(ptri);
293         aGroup->AddPrimitiveArray(pquad);
294         aGroup->EndPrimitives();
295       } else
296 #endif
297       {
298         aGroup->BeginPrimitives();
299         Graphic3d_Array1OfVertexN TriVertex(1,3*nbpanes*2);
300         Graphic3d_Array1OfVertexN QuadVertex(1,4*nbpanes*(nbpanes/2-2));
301         Aspect_Array1OfEdge TriEdge(1,3*nbpanes*2);
302         Aspect_Array1OfEdge QuadEdge(1,4*nbpanes*(nbpanes/2-2));
303         Standard_Integer nt,nq;
304         for( j=nt=nq=0; j<nbpanes/2; j++ ) {
305           Alpha = 0.;
306           R1 = aRadius*sin(Beta);
307           Z1 = Z4 = aRadius*cos(Beta);
308           Beta += Dbeta;
309           R2 = aRadius*sin(Beta);
310           Z2 = Z3 = aRadius*cos(Beta);
311           for( i=0; i<nbpanes; i++ ) {
312             X1 = R1*cos(Alpha);
313             Y1 = R1*sin(Alpha);
314             X2 = R2*cos(Alpha);
315             Y2 = R2*sin(Alpha);
316             Alpha += Dalpha;
317             X3 = R2*cos(Alpha);
318             Y3 = R2*sin(Alpha);
319             X4 = R1*cos(Alpha);
320             Y4 = R1*sin(Alpha);
321             if( j == 0 ) {
322                                 nt++;
323                                 TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
324                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
325                                 TriVertex(nt).SetNormal(X1/aRadius,Y1/aRadius,Z1/aRadius);
326                                 TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
327                                 nt++;
328                                 TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
329                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
330                                 TriVertex(nt).SetNormal(X2/aRadius,Y2/aRadius,Z2/aRadius);
331                                 TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
332                                 nt++;
333                                 TriVertex(nt).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
334                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
335                                 TriVertex(nt).SetNormal(X3/aRadius,Y3/aRadius,Z3/aRadius);
336                                 TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
337             } else if( j == nbpanes/2-1 ) {
338                                 nt++;
339                                 TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
340                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
341                                 TriVertex(nt).SetNormal(X1/aRadius,Y1/aRadius,Z1/aRadius);
342                                 TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
343                                 nt++;
344                                 TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
345                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
346                                 TriVertex(nt).SetNormal(X2/aRadius,Y2/aRadius,Z2/aRadius);
347                                 TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
348                                 nt++;
349                                 TriVertex(nt).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
350                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
351                                 TriVertex(nt).SetNormal(X4/aRadius,Y4/aRadius,Z4/aRadius);
352                                 TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
353             } else {
354                                 nq++;
355                                 QuadVertex(nq).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
356                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
357                                 QuadVertex(nq).SetNormal(X1/aRadius,Y1/aRadius,Z1/aRadius);
358                                 QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
359                                 nq++;
360                                 QuadVertex(nq).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
361                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
362                                 QuadVertex(nq).SetNormal(X2/aRadius,Y2/aRadius,Z2/aRadius);
363                                 QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
364                                 nq++;
365                                 QuadVertex(nq).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
366                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
367                                 QuadVertex(nq).SetNormal(X3/aRadius,Y3/aRadius,Z3/aRadius);
368                                 QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
369                                 nq++;
370                                 QuadVertex(nq).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
371                                 if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
372                                 QuadVertex(nq).SetNormal(X4/aRadius,Y4/aRadius,Z4/aRadius);
373                                 QuadEdge(nq).SetValues(nq,nq-3,Aspect_TOE_VISIBLE);
374             }
375           }
376         }
377 //        aGroup->BeginPrimitives();
378         aGroup->TriangleSet(TriVertex,TriEdge);
379         aGroup->QuadrangleSet(QuadVertex,QuadEdge);
380         aGroup->EndPrimitives();
381       }
382 }
383
384 static void ShadeWithVertexC(const Handle(Graphic3d_Group) aGroup,
385                             const gp_Pnt aPosition, 
386                             const Standard_Real aRadius,
387                             const Standard_Real aDeflection,
388                                 const Standard_Boolean isText,
389                                 const Standard_Boolean isOptText) 
390 {
391       Standard_Real R1,R2;
392       Standard_Real X1,Y1,Z1;
393       Standard_Real X2,Y2,Z2;
394       Standard_Real X3,Y3,Z3;
395       Standard_Real X4,Y4,Z4;
396       Standard_Real Xc,Yc,Zc;
397       Standard_Real Beta = 0.;
398       Standard_Real Alpha = 0.;
399       Standard_Integer nbpanes = Sphere_Sphere::NbPanes(aRadius,aDeflection);
400       Standard_Real Dbeta = 2.*Standard_PI/nbpanes;
401       Standard_Real Dalpha = 2.*Standard_PI/nbpanes;
402       Quantity_Color C1,C2,C3,C4;
403       Standard_Integer i,j;
404
405       aPosition.Coord (Xc, Yc, Zc);
406           if(isText) {
407                 Handle(Graphic3d_AspectText3d) Text3d = new Graphic3d_AspectText3d();
408                 Text3d->SetTextureMappedFont(isOptText);
409                 aGroup->SetPrimitivesAspect(Text3d);
410           }
411 #ifdef G005
412       if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
413         Handle(Graphic3d_ArrayOfTriangles) ptri =
414                 new Graphic3d_ArrayOfTriangles(3*nbpanes*2,0,
415                 Standard_False,Standard_True,Standard_False,Standard_False);
416         Handle(Graphic3d_ArrayOfQuadrangles) pquad =
417                 new Graphic3d_ArrayOfQuadrangles(4*nbpanes*(nbpanes/2-2),0,
418                 Standard_False,Standard_True,Standard_False,Standard_False);
419         aGroup->BeginPrimitives();
420         for( j=0; j<nbpanes/2; j++ ) {
421           Alpha = 0.;
422           R1 = aRadius*sin(Beta);
423           Z1 = Z4 = aRadius*cos(Beta);
424           Beta += Dbeta;
425           R2 = aRadius*sin(Beta);
426           Z2 = Z3 = aRadius*cos(Beta);
427           for( i=0; i<nbpanes; i++ ) {
428             X1 = R1*cos(Alpha);
429             Y1 = R1*sin(Alpha);
430             C1.SetValues(0.5+X1/aRadius/2.,
431                 0.5+Y1/aRadius/2.,0.5+Z1/aRadius/2.,Quantity_TOC_RGB);
432             X2 = R2*cos(Alpha);
433             Y2 = R2*sin(Alpha);
434             C2.SetValues(0.5+X2/aRadius/2.,
435                 0.5+Y2/aRadius/2.,0.5+Z2/aRadius/2.,Quantity_TOC_RGB);
436             Alpha += Dalpha;
437             X3 = R2*cos(Alpha);
438             Y3 = R2*sin(Alpha);
439             C3.SetValues(0.5+X3/aRadius/2.,
440                 0.5+Y3/aRadius/2.,0.5+Z3/aRadius/2.,Quantity_TOC_RGB);
441             X4 = R1*cos(Alpha);
442             Y4 = R1*sin(Alpha);
443             C4.SetValues(0.5+X4/aRadius/2.,
444                 0.5+Y4/aRadius/2.,0.5+Z4/aRadius/2.,Quantity_TOC_RGB);
445             if( j == 0 ) {
446               ptri->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),C1);
447                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
448               ptri->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),C2);
449                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
450               ptri->AddVertex(gp_Pnt(X3+Xc,Y3+Yc,Z3+Zc),C3);
451                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
452             } else if( j == nbpanes/2-1 ) {
453               ptri->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),C1);
454                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
455               ptri->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),C2);
456                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
457               ptri->AddVertex(gp_Pnt(X4+Xc,Y4+Yc,Z4+Zc),C4);
458                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
459             } else {
460               pquad->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),C1);
461                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
462               pquad->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),C2);
463                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
464               pquad->AddVertex(gp_Pnt(X3+Xc,Y3+Yc,Z3+Zc),C3);
465                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
466               pquad->AddVertex(gp_Pnt(X4+Xc,Y4+Yc,Z4+Zc),C4);
467                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
468             }
469           }
470         }
471 //        aGroup->BeginPrimitives();
472         aGroup->AddPrimitiveArray(ptri);
473         aGroup->AddPrimitiveArray(pquad);
474         aGroup->EndPrimitives();
475       } else
476 #endif
477       {
478         aGroup->BeginPrimitives();
479         Graphic3d_Array1OfVertexC TriVertex(1,3*nbpanes*2);
480         Graphic3d_Array1OfVertexC QuadVertex(1,4*nbpanes*(nbpanes/2-2));
481         Aspect_Array1OfEdge TriEdge(1,3*nbpanes*2);
482         Aspect_Array1OfEdge QuadEdge(1,4*nbpanes*(nbpanes/2-2));
483         Standard_Integer nt,nq;
484         for( j=nt=nq=0; j<nbpanes/2; j++ ) {
485           Alpha = 0.;
486           R1 = aRadius*sin(Beta);
487           Z1 = Z4 = aRadius*cos(Beta);
488           Beta += Dbeta;
489           R2 = aRadius*sin(Beta);
490           Z2 = Z3 = aRadius*cos(Beta);
491           for( i=0; i<nbpanes; i++ ) {
492             X1 = R1*cos(Alpha);
493             Y1 = R1*sin(Alpha);
494             C1.SetValues(0.5+X1/aRadius/2.,
495                 0.5+Y1/aRadius/2.,0.5+Z1/aRadius/2.,Quantity_TOC_RGB);
496             X2 = R2*cos(Alpha);
497             Y2 = R2*sin(Alpha);
498             C2.SetValues(0.5+X2/aRadius/2.,
499                 0.5+Y2/aRadius/2.,0.5+Z2/aRadius/2.,Quantity_TOC_RGB);
500             Alpha += Dalpha;
501             X3 = R2*cos(Alpha);
502             Y3 = R2*sin(Alpha);
503             C3.SetValues(0.5+X3/aRadius/2.,
504                 0.5+Y3/aRadius/2.,0.5+Z3/aRadius/2.,Quantity_TOC_RGB);
505             X4 = R1*cos(Alpha);
506             Y4 = R1*sin(Alpha);
507             C4.SetValues(0.5+X4/aRadius/2.,
508                 0.5+Y4/aRadius/2.,0.5+Z4/aRadius/2.,Quantity_TOC_RGB);
509             if( j == 0 ) {
510               nt++;
511               TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
512                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
513               TriVertex(nt).SetColor(C1);
514               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
515               nt++;
516               TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
517                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
518               TriVertex(nt).SetColor(C2);
519               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
520               nt++;
521               TriVertex(nt).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
522                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
523               TriVertex(nt).SetColor(C3);
524               TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
525             } else if( j == nbpanes/2-1 ) {
526               nt++;
527               TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
528                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
529               TriVertex(nt).SetColor(C1);
530               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
531               nt++;
532               TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
533                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
534               TriVertex(nt).SetColor(C2);
535               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
536               nt++;
537               TriVertex(nt).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
538                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
539               TriVertex(nt).SetColor(C4);
540               TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
541             } else {
542               nq++;
543               QuadVertex(nq).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
544                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
545               QuadVertex(nq).SetColor(C1);
546               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
547               nq++;
548               QuadVertex(nq).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
549                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
550               QuadVertex(nq).SetColor(C2);
551               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
552               nq++;
553               QuadVertex(nq).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
554                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
555               QuadVertex(nq).SetColor(C3);
556               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
557               nq++;
558               QuadVertex(nq).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
559                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
560               QuadVertex(nq).SetColor(C4);
561               QuadEdge(nq).SetValues(nq,nq-3,Aspect_TOE_VISIBLE);
562             }
563           }
564         }
565 //        aGroup->BeginPrimitives();
566         aGroup->TriangleSet(TriVertex,TriEdge);
567         aGroup->QuadrangleSet(QuadVertex,QuadEdge);
568         aGroup->EndPrimitives();
569       }
570 }
571
572 static void ShadeWithVertexNC(const Handle(Graphic3d_Group) aGroup,
573                             const gp_Pnt aPosition, 
574                             const Standard_Real aRadius,
575                             const Standard_Real aDeflection,
576                                 const Standard_Boolean isText,
577                                 const Standard_Boolean isOptText) 
578 {
579       Standard_Real R1,R2;
580       Standard_Real X1,Y1,Z1;
581       Standard_Real X2,Y2,Z2;
582       Standard_Real X3,Y3,Z3;
583       Standard_Real X4,Y4,Z4;
584       Standard_Real Xc,Yc,Zc;
585       Standard_Real Beta = 0.;
586       Standard_Real Alpha = 0.;
587       Standard_Integer nbpanes = Sphere_Sphere::NbPanes(aRadius,aDeflection);
588       Standard_Real Dbeta = 2.*Standard_PI/nbpanes;
589       Standard_Real Dalpha = 2.*Standard_PI/nbpanes;
590       Quantity_Color C1,C2,C3,C4;
591       Standard_Integer i,j;
592
593       aPosition.Coord (Xc, Yc, Zc);
594           if(isText) {
595                 Handle(Graphic3d_AspectText3d) Text3d = new Graphic3d_AspectText3d();
596                 Text3d->SetTextureMappedFont(isOptText);
597                 aGroup->SetPrimitivesAspect(Text3d);
598           }
599 #ifdef G005
600       if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
601         Handle(Graphic3d_ArrayOfTriangles) ptri =
602                 new Graphic3d_ArrayOfTriangles(3*nbpanes*2,0,
603                 Standard_True,Standard_True,Standard_False,Standard_False);
604         Handle(Graphic3d_ArrayOfQuadrangles) pquad =
605                 new Graphic3d_ArrayOfQuadrangles(4*nbpanes*(nbpanes/2-2),0,
606                 Standard_True,Standard_True,Standard_False,Standard_False);
607         aGroup->BeginPrimitives();
608         for( j=0; j<nbpanes/2; j++ ) {
609           Alpha = 0.;
610           R1 = aRadius*sin(Beta);
611           Z1 = Z4 = aRadius*cos(Beta);
612           Beta += Dbeta;
613           R2 = aRadius*sin(Beta);
614           Z2 = Z3 = aRadius*cos(Beta);
615           for( i=0; i<nbpanes; i++ ) {
616             X1 = R1*cos(Alpha);
617             Y1 = R1*sin(Alpha);
618             C1.SetValues(0.5+X1/aRadius/2.,
619                 0.5+Y1/aRadius/2.,0.5+Z1/aRadius/2.,Quantity_TOC_RGB);
620             X2 = R2*cos(Alpha);
621             Y2 = R2*sin(Alpha);
622             C2.SetValues(0.5+X2/aRadius/2.,
623                 0.5+Y2/aRadius/2.,0.5+Z2/aRadius/2.,Quantity_TOC_RGB);
624             Alpha += Dalpha;
625             X3 = R2*cos(Alpha);
626             Y3 = R2*sin(Alpha);
627             C3.SetValues(0.5+X3/aRadius/2.,
628                 0.5+Y3/aRadius/2.,0.5+Z3/aRadius/2.,Quantity_TOC_RGB);
629             X4 = R1*cos(Alpha);
630             Y4 = R1*sin(Alpha);
631             C4.SetValues(0.5+X4/aRadius/2.,
632                 0.5+Y4/aRadius/2.,0.5+Z4/aRadius/2.,Quantity_TOC_RGB);
633             if( j == 0 ) {
634               ptri->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),
635                         gp_Vec(X1/aRadius,Y1/aRadius,Z1/aRadius),C1);
636                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
637               ptri->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),
638                         gp_Vec(X2/aRadius,Y2/aRadius,Z2/aRadius),C2);
639                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
640               ptri->AddVertex(gp_Pnt(X3+Xc,Y3+Yc,Z3+Zc),
641                         gp_Vec(X3/aRadius,Y3/aRadius,Z3/aRadius),C3);
642                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
643             } else if( j == nbpanes/2-1 ) {
644               ptri->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),
645                         gp_Vec(X1/aRadius,Y1/aRadius,Z1/aRadius),C1);
646                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
647               ptri->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),
648                         gp_Vec(X2/aRadius,Y2/aRadius,Z2/aRadius),C2);
649                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
650               ptri->AddVertex(gp_Pnt(X4+Xc,Y4+Yc,Z4+Zc),
651                         gp_Vec(X4/aRadius,Y4/aRadius,Z4/aRadius),C4);
652                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
653             } else {
654               pquad->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),
655                         gp_Vec(X1/aRadius,Y1/aRadius,Z1/aRadius),C1);
656                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
657               pquad->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),
658                         gp_Vec(X2/aRadius,Y2/aRadius,Z2/aRadius),C2);
659                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
660               pquad->AddVertex(gp_Pnt(X3+Xc,Y3+Yc,Z3+Zc),
661                         gp_Vec(X3/aRadius,Y3/aRadius,Z3/aRadius),C3);
662                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
663               pquad->AddVertex(gp_Pnt(X4+Xc,Y4+Yc,Z4+Zc),
664                         gp_Vec(X4/aRadius,Y4/aRadius,Z4/aRadius),C4);
665                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
666             }
667           }
668         }
669 //        aGroup->BeginPrimitives();
670         aGroup->AddPrimitiveArray(ptri);
671         aGroup->AddPrimitiveArray(pquad);
672         aGroup->EndPrimitives();
673       } else
674 #endif
675       {
676         aGroup->BeginPrimitives();
677         Graphic3d_Array1OfVertexNC TriVertex(1,3*nbpanes*2);
678         Graphic3d_Array1OfVertexNC QuadVertex(1,4*nbpanes*(nbpanes/2-2));
679         Aspect_Array1OfEdge TriEdge(1,3*nbpanes*2);
680         Aspect_Array1OfEdge QuadEdge(1,4*nbpanes*(nbpanes/2-2));
681         Standard_Integer nt,nq;
682         for( j=nt=nq=0; j<nbpanes/2; j++ ) {
683           Alpha = 0.;
684           R1 = aRadius*sin(Beta);
685           Z1 = Z4 = aRadius*cos(Beta);
686           Beta += Dbeta;
687           R2 = aRadius*sin(Beta);
688           Z2 = Z3 = aRadius*cos(Beta);
689           for( i=0; i<nbpanes; i++ ) {
690             X1 = R1*cos(Alpha);
691             Y1 = R1*sin(Alpha);
692             C1.SetValues(0.5+X1/aRadius/2.,
693                 0.5+Y1/aRadius/2.,0.5+Z1/aRadius/2.,Quantity_TOC_RGB);
694             X2 = R2*cos(Alpha);
695             Y2 = R2*sin(Alpha);
696             C2.SetValues(0.5+X2/aRadius/2.,
697                 0.5+Y2/aRadius/2.,0.5+Z2/aRadius/2.,Quantity_TOC_RGB);
698             Alpha += Dalpha;
699             X3 = R2*cos(Alpha);
700             Y3 = R2*sin(Alpha);
701             C3.SetValues(0.5+X3/aRadius/2.,
702                 0.5+Y3/aRadius/2.,0.5+Z3/aRadius/2.,Quantity_TOC_RGB);
703             X4 = R1*cos(Alpha);
704             Y4 = R1*sin(Alpha);
705             C4.SetValues(0.5+X4/aRadius/2.,
706                 0.5+Y4/aRadius/2.,0.5+Z4/aRadius/2.,Quantity_TOC_RGB);
707             if( j == 0 ) {
708               nt++;
709               TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
710                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
711               TriVertex(nt).SetNormal(X1/aRadius,Y1/aRadius,Z1/aRadius);
712               TriVertex(nt).SetColor(C1);
713               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
714               nt++;
715               TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
716                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
717               TriVertex(nt).SetNormal(X2/aRadius,Y2/aRadius,Z2/aRadius);
718               TriVertex(nt).SetColor(C2);
719               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
720               nt++;
721               TriVertex(nt).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
722                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
723               TriVertex(nt).SetNormal(X3/aRadius,Y3/aRadius,Z3/aRadius);
724               TriVertex(nt).SetColor(C3);
725               TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
726             } else if( j == nbpanes/2-1 ) {
727               nt++;
728               TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
729                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
730               TriVertex(nt).SetNormal(X1/aRadius,Y1/aRadius,Z1/aRadius);
731               TriVertex(nt).SetColor(C1);
732               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
733               nt++;
734               TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
735                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
736               TriVertex(nt).SetNormal(X2/aRadius,Y2/aRadius,Z2/aRadius);
737               TriVertex(nt).SetColor(C2);
738               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
739               nt++;
740               TriVertex(nt).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
741                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
742               TriVertex(nt).SetNormal(X4/aRadius,Y4/aRadius,Z4/aRadius);
743               TriVertex(nt).SetColor(C4);
744               TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
745             } else {
746               nq++;
747               QuadVertex(nq).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
748                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
749               QuadVertex(nq).SetNormal(X1/aRadius,Y1/aRadius,Z1/aRadius);
750               QuadVertex(nq).SetColor(C1);
751               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
752               nq++;
753               QuadVertex(nq).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
754                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
755               QuadVertex(nq).SetNormal(X2/aRadius,Y2/aRadius,Z2/aRadius);
756               QuadVertex(nq).SetColor(C2);
757               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
758               nq++;
759               QuadVertex(nq).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
760                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
761               QuadVertex(nq).SetNormal(X3/aRadius,Y3/aRadius,Z3/aRadius);
762               QuadVertex(nq).SetColor(C3);
763               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
764               nq++;
765               QuadVertex(nq).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
766                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
767               QuadVertex(nq).SetNormal(X4/aRadius,Y4/aRadius,Z4/aRadius);
768               QuadVertex(nq).SetColor(C4);
769               QuadEdge(nq).SetValues(nq,nq-3,Aspect_TOE_VISIBLE);
770             }
771           }
772         }
773 //        aGroup->BeginPrimitives();
774         aGroup->TriangleSet(TriVertex,TriEdge);
775         aGroup->QuadrangleSet(QuadVertex,QuadEdge);
776         aGroup->EndPrimitives();
777       }
778 }
779
780 static void ShadeWithVertexNT(const Handle(Graphic3d_Group) aGroup,
781                             const gp_Pnt aPosition, 
782                             const Standard_Real aRadius,
783                             const Standard_Real aDeflection,
784                                 const Standard_Boolean isText,
785                                 const Standard_Boolean isOptText) 
786 {
787       Standard_Real R1,R2;
788       Standard_Real X1,Y1,Z1;
789       Standard_Real X2,Y2,Z2;
790       Standard_Real X3,Y3,Z3;
791       Standard_Real X4,Y4,Z4;
792       Standard_Real Xc,Yc,Zc;
793       Standard_Real Beta = 0.;
794       Standard_Real Alpha = 0.;
795       Standard_Integer nbpanes = Sphere_Sphere::NbPanes(aRadius,aDeflection);
796       Standard_Real Dbeta = 2.*Standard_PI/nbpanes;
797       Standard_Real Dalpha = 2.*Standard_PI/nbpanes;
798       Standard_Real Tx1,Ty1,Tx2,Ty2;
799       Standard_Integer i,j;
800
801       aPosition.Coord (Xc, Yc, Zc);
802           if(isText) {
803                 Handle(Graphic3d_AspectText3d) Text3d = new Graphic3d_AspectText3d();
804                 Text3d->SetTextureMappedFont(isOptText);
805                 aGroup->SetPrimitivesAspect(Text3d);
806           }
807 #ifdef G005
808       if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
809         Handle(Graphic3d_ArrayOfTriangles) ptri =
810                 new Graphic3d_ArrayOfTriangles(3*nbpanes*2,0,
811                 Standard_True,Standard_False,Standard_True,Standard_False);
812         Handle(Graphic3d_ArrayOfQuadrangles) pquad =
813                 new Graphic3d_ArrayOfQuadrangles(4*nbpanes*(nbpanes/2-2),0,
814                 Standard_True,Standard_False,Standard_True,Standard_False);
815         aGroup->BeginPrimitives();
816         for( j=0; j<nbpanes/2; j++ ) {
817           Alpha = 0.;
818           R1 = aRadius*sin(Beta);
819           Z1 = Z4 = aRadius*cos(Beta);
820           Beta += Dbeta;
821           R2 = aRadius*sin(Beta);
822           Z2 = Z3 = aRadius*cos(Beta);
823           Ty1 = Standard_Real(j)/nbpanes/2.;
824           Ty2 = Standard_Real(j+1)/nbpanes/2.;
825           for( i=0; i<nbpanes; i++ ) {
826             X1 = R1*cos(Alpha);
827             Y1 = R1*sin(Alpha);
828             X2 = R2*cos(Alpha);
829             Y2 = R2*sin(Alpha);
830             Alpha += Dalpha;
831             X3 = R2*cos(Alpha);
832             Y3 = R2*sin(Alpha);
833             X4 = R1*cos(Alpha);
834             Y4 = R1*sin(Alpha);
835             Tx1 = Standard_Real(i)/nbpanes;
836             Tx2 = Standard_Real(i+1)/nbpanes;
837             if( j == 0 ) {
838               ptri->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),
839                         gp_Vec(X1/aRadius,Y1/aRadius,Z1/aRadius),
840                         gp_Pnt2d(Tx1,Ty1));
841                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
842               ptri->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),
843                         gp_Vec(X2/aRadius,Y2/aRadius,Z2/aRadius),
844                         gp_Pnt2d(Tx1,Ty2));
845                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
846               ptri->AddVertex(gp_Pnt(X3+Xc,Y3+Yc,Z3+Zc),
847                         gp_Vec(X3/aRadius,Y3/aRadius,Z3/aRadius),
848                         gp_Pnt2d(Tx2,Ty2));
849                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
850             } else if( j == nbpanes/2-1 ) {
851               ptri->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),
852                         gp_Vec(X1/aRadius,Y1/aRadius,Z1/aRadius),
853                         gp_Pnt2d(Tx1,Ty1));
854                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
855               ptri->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),
856                         gp_Vec(X2/aRadius,Y2/aRadius,Z2/aRadius),
857                         gp_Pnt2d(Tx1,Ty2));
858                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
859               ptri->AddVertex(gp_Pnt(X4+Xc,Y4+Yc,Z4+Zc),
860                         gp_Vec(X4/aRadius,Y4/aRadius,Z4/aRadius),
861                         gp_Pnt2d(Tx2,Ty1));
862                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
863             } else {
864               pquad->AddVertex(gp_Pnt(X1+Xc,Y1+Yc,Z1+Zc),
865                         gp_Vec(X1/aRadius,Y1/aRadius,Z1/aRadius),
866                         gp_Pnt2d(Tx1,Ty1));
867                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
868               pquad->AddVertex(gp_Pnt(X2+Xc,Y2+Yc,Z2+Zc),
869                         gp_Vec(X2/aRadius,Y2/aRadius,Z2/aRadius),
870                         gp_Pnt2d(Tx1,Ty2));
871                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
872               pquad->AddVertex(gp_Pnt(X3+Xc,Y3+Yc,Z3+Zc),
873                         gp_Vec(X3/aRadius,Y3/aRadius,Z3/aRadius),
874                         gp_Pnt2d(Tx2,Ty2));
875                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
876               pquad->AddVertex(gp_Pnt(X4+Xc,Y4+Yc,Z4+Zc),
877                         gp_Vec(X4/aRadius,Y4/aRadius,Z4/aRadius),
878                         gp_Pnt2d(Tx2,Ty1));
879                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
880             }
881           }
882         }
883 //        aGroup->BeginPrimitives();
884         aGroup->AddPrimitiveArray(ptri);
885         aGroup->AddPrimitiveArray(pquad);
886         aGroup->EndPrimitives();
887       } else
888 #endif
889       {
890         aGroup->BeginPrimitives();
891         Graphic3d_Array1OfVertexNT TriVertex(1,3*nbpanes*2);
892         Graphic3d_Array1OfVertexNT QuadVertex(1,4*nbpanes*(nbpanes/2-2));
893         Aspect_Array1OfEdge TriEdge(1,3*nbpanes*2);
894         Aspect_Array1OfEdge QuadEdge(1,4*nbpanes*(nbpanes/2-2));
895         Standard_Integer nt,nq;
896         for( j=nt=nq=0; j<nbpanes/2; j++ ) {
897           Alpha = 0.;
898           R1 = aRadius*sin(Beta);
899           Z1 = Z4 = aRadius*cos(Beta);
900           Beta += Dbeta;
901           R2 = aRadius*sin(Beta);
902           Z2 = Z3 = aRadius*cos(Beta);
903           Ty1 = Standard_Real(j)/nbpanes/2.;
904           Ty2 = Standard_Real(j+1)/nbpanes/2.;
905           for( i=0; i<nbpanes; i++ ) {
906             X1 = R1*cos(Alpha);
907             Y1 = R1*sin(Alpha);
908             X2 = R2*cos(Alpha);
909             Y2 = R2*sin(Alpha);
910             Alpha += Dalpha;
911             X3 = R2*cos(Alpha);
912             Y3 = R2*sin(Alpha);
913             X4 = R1*cos(Alpha);
914             Y4 = R1*sin(Alpha);
915             Tx1 = Standard_Real(i)/nbpanes;
916             Tx2 = Standard_Real(i+1)/nbpanes;
917             if( j == 0 ) {
918               nt++;
919               TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
920                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
921               TriVertex(nt).SetNormal(X1/aRadius,Y1/aRadius,Z1/aRadius);
922               TriVertex(nt).SetTextureCoordinate(Tx1,Ty1);
923               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
924               nt++;
925               TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
926                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
927               TriVertex(nt).SetNormal(X2/aRadius,Y2/aRadius,Z2/aRadius);
928               TriVertex(nt).SetTextureCoordinate(Tx1,Ty2);
929               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
930               nt++;
931               TriVertex(nt).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
932                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
933               TriVertex(nt).SetNormal(X3/aRadius,Y3/aRadius,Z3/aRadius);
934               TriVertex(nt).SetTextureCoordinate(Tx2,Ty2);
935               TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
936             } else if( j == nbpanes/2-1 ) {
937               nt++;
938               TriVertex(nt).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
939                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
940               TriVertex(nt).SetNormal(X1/aRadius,Y1/aRadius,Z1/aRadius);
941               TriVertex(nt).SetTextureCoordinate(Tx1,Ty1);
942               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
943               nt++;
944               TriVertex(nt).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
945                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
946               TriVertex(nt).SetNormal(X2/aRadius,Y2/aRadius,Z2/aRadius);
947               TriVertex(nt).SetTextureCoordinate(Tx1,Ty2);
948               TriEdge(nt).SetValues(nt,nt+1,Aspect_TOE_VISIBLE);
949               nt++;
950               TriVertex(nt).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
951                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
952               TriVertex(nt).SetNormal(X4/aRadius,Y4/aRadius,Z4/aRadius);
953               TriVertex(nt).SetTextureCoordinate(Tx2,Ty1);
954               TriEdge(nt).SetValues(nt,nt-2,Aspect_TOE_VISIBLE);
955             } else {
956               nq++;
957               QuadVertex(nq).SetCoord(X1+Xc,Y1+Yc,Z1+Zc);
958                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X1+Xc,Y1+Yc,Z1+Zc), stTextHeight);
959               QuadVertex(nq).SetNormal(X1/aRadius,Y1/aRadius,Z1/aRadius);
960               QuadVertex(nq).SetTextureCoordinate(Tx1,Ty1);
961               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
962               nq++;
963               QuadVertex(nq).SetCoord(X2+Xc,Y2+Yc,Z2+Zc);
964                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X2+Xc,Y2+Yc,Z2+Zc), stTextHeight);
965               QuadVertex(nq).SetNormal(X2/aRadius,Y2/aRadius,Z2/aRadius);
966               QuadVertex(nq).SetTextureCoordinate(Tx1,Ty2);
967               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
968               nq++;
969               QuadVertex(nq).SetCoord(X3+Xc,Y3+Yc,Z3+Zc);
970                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X3+Xc,Y3+Yc,Z3+Zc), stTextHeight);
971               QuadVertex(nq).SetNormal(X3/aRadius,Y3/aRadius,Z3/aRadius);
972               QuadVertex(nq).SetTextureCoordinate(Tx2,Ty2);
973               QuadEdge(nq).SetValues(nq,nq+1,Aspect_TOE_VISIBLE);
974               nq++;
975               QuadVertex(nq).SetCoord(X4+Xc,Y4+Yc,Z4+Zc);
976                           if(isText) aGroup->Text(stText,Graphic3d_Vertex(X4+Xc,Y4+Yc,Z4+Zc), stTextHeight);
977               QuadVertex(nq).SetNormal(X4/aRadius,Y4/aRadius,Z4/aRadius);
978               QuadVertex(nq).SetTextureCoordinate(Tx2,Ty1);
979               QuadEdge(nq).SetValues(nq,nq-3,Aspect_TOE_VISIBLE);
980             }
981           }
982         }
983 //        aGroup->BeginPrimitives();
984         aGroup->TriangleSet(TriVertex,TriEdge);
985         aGroup->QuadrangleSet(QuadVertex,QuadEdge);
986         aGroup->EndPrimitives();
987       }
988 }
989
990 //==================================================
991 // Function: 
992 // Purpose :
993 //==================================================
994
995 Sphere_Sphere::Sphere_Sphere(const gp_Pnt& aPosition,
996                          const Standard_Real aRadius,
997                          const Standard_Real aDeflection,
998                          const Standard_Boolean hasVNormals,
999                          const Standard_Boolean hasVColors,
1000                          const Standard_Boolean hasVTexels,
1001                          const Standard_Boolean hasText,
1002                          const Standard_Boolean isOptText
1003 ) :
1004 Sphere_BasicShape(BRepPrimAPI_MakeSphere(aRadius).Shape(),
1005 aDeflection,hasVNormals,hasVColors,hasVTexels),
1006 myRadius(aRadius),
1007 myText(hasText),
1008 myOptText(isOptText)
1009 {
1010   gp_Trsf trsf;
1011   trsf.SetTranslation(gp_Vec(aPosition.X(),aPosition.Y(),aPosition.Z()));
1012   TopLoc_Location location(trsf);
1013   myshape.Location(location);
1014 }
1015
1016 //=======================================================================
1017 //function : Compute
1018 //purpose  : 
1019 //=======================================================================
1020 void Sphere_Sphere::Compute(
1021                         const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
1022                         const Handle(Prs3d_Presentation)& aPrs,
1023                         const Standard_Integer aMode)
1024 {  
1025   aPrs->Clear();
1026   if(myshape.IsNull()) return;
1027
1028   // wire,edge,vertex -> pas de HLR + priorite display superieure
1029   Standard_Integer TheType = (Standard_Integer) myshape.ShapeType();
1030   if(TheType>4 && TheType<8) {
1031     aPrs->SetVisual(Graphic3d_TOS_ALL);
1032     aPrs->SetDisplayPriority(TheType+2);
1033   }
1034   
1035   switch (aMode) {
1036   case 0:{
1037     try { StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); }
1038     catch (Standard_Failure) { 
1039 #ifdef DEB
1040       cout << "Sphere_Sphere::Compute()  failed"<< endl;
1041 #endif
1042       cout << "a Shape should be incorrect : No Compute can be maked on it  "<< endl;     
1043     }
1044     break;
1045   }
1046   case 1:
1047     { 
1048       Handle(Graphic3d_Group) group = Prs3d_Root::CurrentGroup(aPrs);
1049       Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
1050       aspect->SuppressBackFace();
1051       group->SetPrimitivesAspect(aspect);
1052       gp_Pnt position = Position();
1053       Standard_Integer shadeAspect(0);
1054       if( myVNormalsFlag ) shadeAspect |= 1;
1055       if( myVColorsFlag ) shadeAspect |= 2;
1056       if( myVTexelsFlag ) shadeAspect |= 4;
1057       switch( shadeAspect ) {
1058         default:
1059         case 0:
1060           ShadeWithVertex(group,position,myRadius,myDeflection,myText, myOptText);
1061           break;
1062         case 1:
1063           ShadeWithVertexN(group,position,myRadius,myDeflection,myText, myOptText);
1064           break;
1065         case 2:
1066           {
1067             Graphic3d_MaterialAspect material = aspect->FrontMaterial();
1068             material.SetReflectionModeOff(Graphic3d_TOR_AMBIENT);
1069             material.SetReflectionModeOff(Graphic3d_TOR_DIFFUSE);
1070             material.SetReflectionModeOff(Graphic3d_TOR_SPECULAR);
1071             material.SetReflectionModeOff(Graphic3d_TOR_EMISSION);
1072             aspect->SetFrontMaterial(material);
1073             group->SetPrimitivesAspect(aspect);
1074           }
1075           ShadeWithVertexC(group,position,myRadius,myDeflection,myText, myOptText);
1076           break;
1077         case 3:
1078           ShadeWithVertexNC(group,position,myRadius,myDeflection,myText, myOptText);
1079           break;
1080         case 4:
1081 //          ShadeWithVertexT(group,position,myRadius,myDeflection,myText, myOptText);
1082           break;
1083         case 5:
1084           ShadeWithVertexNT(group,position,myRadius,myDeflection,myText, myOptText);
1085           break;
1086         case 6:
1087 //          ShadeWithVertexCT(group,position,myRadius,myDeflection,myText, myOptText);
1088           break;
1089         case 7:
1090 //          ShadeWithVertexNCT(group,position,myRadius,myDeflection,myText, myOptText);
1091           break;
1092       }
1093       Standard_Real value = Transparency() ;
1094       if( value > 0. ) {
1095         SetTransparency( value );
1096       }
1097       break;
1098     }
1099   case 2:
1100     {
1101     }
1102   }
1103   aPrs->ReCompute(); // for hidden line recomputation if necessary...
1104 }
1105
1106 void Sphere_Sphere::SetRadius(const Standard_Real aRadius) {
1107   myRadius = aRadius;
1108 }
1109
1110 Standard_Real Sphere_Sphere::Radius() const {
1111   return myRadius;
1112 }
1113
1114 Standard_Integer Sphere_Sphere::NbPanes(const Standard_Real aRadius,
1115                                 const Standard_Real aDeflection) {
1116   if( aRadius <= 0. ) return 0;
1117   Standard_Real h = aRadius-Abs(aDeflection);
1118   Standard_Real da = 2.*ACos(h/aRadius);
1119   Standard_Integer nbpanes = Standard_Integer(2.*Standard_PI/da);
1120   nbpanes = nbpanes/2*2;
1121   return nbpanes;
1122 }
1123
1124 Standard_Integer Sphere_Sphere::NbPanes(const Standard_Integer nbItems) {
1125   return Standard_Integer(Sqrt(2*nbItems));
1126 }
1127
1128 Standard_Integer Sphere_Sphere::NbItems(const Standard_Integer nbPanes) {
1129   return nbPanes*nbPanes/2;
1130 }
1131
1132 Standard_Real Sphere_Sphere::Deflection(const Standard_Real aRadius,
1133                                 const Standard_Integer nbPanes) {
1134   Standard_Real da = 2.*Standard_PI/nbPanes;
1135   Standard_Real h = aRadius*Cos(da/2.);
1136   return (aRadius-h);
1137 }