Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / java / src / SampleGeometryPackage / SampleGeometryPackage.cxx
1 #include <SampleGeometryPackage.hxx>
2 #include <AIS_InteractiveContext.hxx>
3 #include <ISession2D_InteractiveContext.hxx>
4 #include <TCollection_AsciiString.hxx>
5 #include <ISession_Point.hxx>
6 #include <ISession_Curve.hxx>
7 #include <ISession_Surface.hxx>
8 #include <ISession_Text.hxx>
9 #include <ISession_Direction.hxx>
10 #include <ISession2D_Curve.hxx>
11 #include <AIS_Drawer.hxx>
12 #include <gp.hxx>
13 #include <gp_XYZ.hxx>
14 #include <gp_Pnt.hxx>
15 #include <gp_Vec.hxx>
16 #include <gp_Dir.hxx>
17 #include <gp_Ax1.hxx>
18 #include <gp_Ax3.hxx>
19 #include <gp_Trsf.hxx>
20 #include <gp_Mat.hxx>
21 #include <gp_Pln.hxx>
22 #include <gp_Lin.hxx>
23 #include <gp_Elips.hxx>
24 #include <gp_Pnt2d.hxx>
25 #include <gp_Vec2d.hxx>
26 #include <gp_Dir2d.hxx>
27 #include <gp_Ax2d.hxx>
28 #include <gp_Ax22d.hxx>
29 #include <gp_Parab2d.hxx>
30 #include <gp_Lin2d.hxx>
31 #include <gp_Circ2d.hxx>
32 #include <gp_Elips2d.hxx>
33 #include <gce_MakeLin2d.hxx>
34 #include <gce_MakeCirc2d.hxx>
35 #include <Geom2d_Curve.hxx>
36 #include <Geom2d_TrimmedCurve.hxx>
37 #include <Geom2d_Circle.hxx>
38 #include <Geom2d_Parabola.hxx>
39 #include <Geom2d_Ellipse.hxx>
40 #include <Geom2d_BSplineCurve.hxx>
41 #include <Geom2d_OffsetCurve.hxx>
42 #include <Geom2dAPI_PointsToBSpline.hxx>
43 #include <Geom2dAPI_Interpolate.hxx>
44 #include <Geom2dAPI_ExtremaCurveCurve.hxx>
45 #include <Geom2dAPI_InterCurveCurve.hxx>
46 #include <Geom2dAdaptor_Curve.hxx>
47 #include <Geom2dConvert.hxx>
48 #include <Geom2dLProp_CLProps2d.hxx>
49 #include <GCE2d_MakeArcOfCircle.hxx>
50 #include <GCE2d_MakeArcOfEllipse.hxx>
51 #include <GCE2d_MakeEllipse.hxx>
52 #include <GCE2d_MakeParabola.hxx>
53 #include <GCE2d_MakeSegment.hxx>
54 #include <Geom_Curve.hxx>
55 #include <Geom_TrimmedCurve.hxx>
56 #include <Geom_BSplineCurve.hxx>
57 #include <Geom_BSplineSurface.hxx>
58 #include <Geom_BezierSurface.hxx>
59 #include <Geom_Circle.hxx>
60 #include <Geom_Line.hxx>
61 #include <Geom_Surface.hxx>
62 #include <Geom_SphericalSurface.hxx>
63 #include <Geom_Plane.hxx>
64 #include <Geom_Ellipse.hxx>
65 #include <Geom_RectangularTrimmedSurface.hxx>
66 #include <Geom_OffsetSurface.hxx>
67 #include <Geom_SurfaceOfLinearExtrusion.hxx>
68 #include <Geom_SurfaceOfRevolution.hxx>
69 #include <Geom_Geometry.hxx>
70 #include <Geom_Transformation.hxx>
71 #include <GeomAPI.hxx>
72 #include <GeomAPI_PointsToBSpline.hxx>
73 #include <GeomAPI_PointsToBSplineSurface.hxx>
74 #include <GeomAPI_ExtremaSurfaceSurface.hxx>
75 #include <GeomAPI_Interpolate.hxx>
76 #include <GeomAPI_ProjectPointOnCurve.hxx>
77 #include <GeomAPI_ProjectPointOnSurf.hxx>
78 #include <GeomAPI_IntCS.hxx>
79 #include <GeomAdaptor_Curve.hxx>
80 #include <GeomAdaptor_HCurve.hxx>
81 #include <GeomAdaptor_Surface.hxx>
82 #include <GeomConvert.hxx>
83 #include <GeomConvert_CompBezierSurfacesToBSplineSurface.hxx>
84 #include <GeomFill_FillingStyle.hxx>
85 #include <GeomFill_BSplineCurves.hxx>
86 #include <GeomFill_SimpleBound.hxx>
87 #include <GeomFill_ConstrainedFilling.hxx>
88 #include <GeomFill_Pipe.hxx>
89 #include <GeomLib.hxx>
90 #include <GC_MakePlane.hxx>
91 #include <GC_MakeSegment.hxx>
92 #include <GC_MakeCircle.hxx>
93 #include <GC_MakeEllipse.hxx>
94 #include <GC_MakeConicalSurface.hxx>
95 #include <GC_MakeTranslation.hxx>
96 #include <GProp_PEquation.hxx>
97 #include <GCPnts_AbscissaPoint.hxx>
98 #include <GCPnts_UniformAbscissa.hxx>
99 #include <GccAna_Pnt2dBisec.hxx>
100 #include <GccAna_Lin2d2Tan.hxx>
101 #include <GccAna_Circ2d2TanRad.hxx>
102 #include <GccEnt.hxx>
103 #include <GccEnt_QualifiedLin.hxx>
104 #include <GccEnt_QualifiedCirc.hxx>
105 #include <IntAna_IntConicQuad.hxx>
106 #include <FairCurve_Batten.hxx>
107 #include <FairCurve_AnalysisCode.hxx>
108 #include <FairCurve_MinimalVariation.hxx>
109 #include <TColgp_Array1OfPnt.hxx>
110 #include <TColgp_Array2OfPnt.hxx>
111 #include <TColgp_Array1OfPnt2d.hxx>
112 #include <TColgp_Array2OfPnt2d.hxx>
113 #include <TColgp_HArray1OfPnt2d.hxx>
114 #include <TColgp_HArray1OfPnt.hxx>
115 #include <TColgp_SequenceOfPnt2d.hxx>
116 #include <TColStd_HArray1OfInteger.hxx>
117 #include <TColGeom_Array2OfBezierSurface.hxx>
118 #include <Precision.hxx>
119 #include <Quantity_Length.hxx>
120 #include <Bnd_Box2d.hxx>
121 #include <Bnd_Box.hxx>
122 #include <BndLib_Add2dCurve.hxx>
123 #include <BndLib_Add3dCurve.hxx>
124 #include <BndLib_AddSurface.hxx>
125 #include <Prs3d_LineAspect.hxx>
126 #include <Prs3d_IsoAspect.hxx>
127
128 #include <Aspect_Window.hxx>
129 #include <V3d_Viewer.hxx>
130 #include <V3d_View.hxx>
131 #include <V2d_Viewer.hxx>
132 #include <V2d_View.hxx>
133
134 #ifdef WNT
135 #include <WNT_Window.hxx>
136 #include <WNT_GraphicDevice.hxx>
137 #include <WNT_WDriver.hxx>
138 #include <Graphic3d_WNTGraphicDevice.hxx>
139 #else
140 #include <Xw_Window.hxx>
141 #include <Xw_GraphicDevice.hxx>
142 #include <Xw_Driver.hxx>
143 #include <Graphic3d_GraphicDevice.hxx>
144 #endif
145
146
147
148
149 //===============================================================
150 // Function name: CreateViewer3d
151 //===============================================================
152  Handle(V3d_Viewer) SampleGeometryPackage::CreateViewer3d(const Standard_ExtString aName) 
153 {
154 #ifdef WNT
155 static Handle(Graphic3d_WNTGraphicDevice) defaultDevice;
156     
157   if (defaultDevice.IsNull()) 
158     defaultDevice = new Graphic3d_WNTGraphicDevice();
159   return new V3d_Viewer(defaultDevice, aName);
160 #else
161 static Handle(Graphic3d_GraphicDevice) defaultDevice;
162     
163   if (defaultDevice.IsNull()) 
164     defaultDevice = new Graphic3d_GraphicDevice("");
165   return new V3d_Viewer(defaultDevice, aName);
166 #endif //WNT
167 }
168
169 //===============================================================
170 // Function name: SetWindow3d
171 //===============================================================
172 void SampleGeometryPackage::SetWindow3d (const Handle(V3d_View)& aView,
173                                          const Standard_Integer hiwin,
174                                          const Standard_Integer lowin)
175 {
176 #ifdef WNT
177   Handle(Graphic3d_WNTGraphicDevice) d = 
178     Handle(Graphic3d_WNTGraphicDevice)::DownCast(aView->Viewer()->Device());
179   Handle(WNT_Window) w = new WNT_Window(d,hiwin,lowin);
180 #else
181   Handle(Graphic3d_GraphicDevice) d = 
182     Handle(Graphic3d_GraphicDevice)::DownCast(aView->Viewer()->Device());
183   Handle(Xw_Window) w = new Xw_Window(d,hiwin,lowin,Xw_WQ_3DQUALITY);
184 #endif
185   aView->SetWindow(w);
186 }
187
188
189 //===============================================================
190 // Function name: CreateViewer2d
191 //===============================================================
192 Handle(V2d_Viewer) SampleGeometryPackage::CreateViewer2d (const Standard_ExtString aName)
193 {
194 #ifdef WNT
195 static Handle(WNT_GraphicDevice) default2dDevice;
196
197   if(default2dDevice.IsNull()) 
198     default2dDevice = new WNT_GraphicDevice();
199 #else
200   static Handle(Xw_GraphicDevice) default2dDevice;
201
202   if(default2dDevice.IsNull())  {
203     default2dDevice = new Xw_GraphicDevice("",Xw_TOM_READONLY);
204   }
205 #endif
206   return new V2d_Viewer(default2dDevice,aName,"");
207 }
208
209
210 //===============================================================
211 // Function name: CreateView2d
212 //===============================================================
213 Handle(V2d_View) SampleGeometryPackage::CreateView2d (const Handle(V2d_Viewer)& aViewer,
214                                                       const Standard_Integer hiwin,
215                                                       const Standard_Integer lowin)
216 {
217 #ifdef WNT
218   Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device());
219   Handle(WNT_Window) W = new WNT_Window(GD,hiwin,lowin,Quantity_NOC_MATRAGRAY);
220   Handle(WNT_WDriver) D = new WNT_WDriver(W);
221 #else
222   Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device());
223   Handle(Xw_Window) W = new Xw_Window(GD,hiwin,lowin,Xw_WQ_DRAWINGQUALITY,Quantity_NOC_MATRAGRAY);
224   Handle(Xw_Driver) D = new Xw_Driver(W);
225 #endif
226   
227   Handle(V2d_View) V = new V2d_View(D,aViewer);
228   V->Update();
229   return V;
230 }
231
232
233
234 //===============================================================
235
236 void AddSeparator(TCollection_AsciiString& aMessage)
237 {
238     aMessage+= "------------------------------------------------------------------------\n";
239 }
240
241 void DisplayPoint(const Handle(ISession2D_InteractiveContext)& aContext2D, 
242                   const gp_Pnt2d& aPoint, const TCollection_AsciiString& aText, 
243                   Standard_Boolean UpdateViewer = Standard_True,
244                   Standard_Real anXoffset = 0, Standard_Real anYoffset = 0, 
245                   Standard_Real TextScale = 0.05)
246 {
247     Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint);
248     aContext2D->Display(aGraphicPoint,Standard_False);
249     Handle(ISession_Text)  aGraphicText = new ISession_Text(aText,aPoint.X()+anXoffset,aPoint.Y()+anYoffset);
250     aGraphicText->SetScale  (TextScale);
251     aContext2D->Display(aGraphicText,UpdateViewer);
252 }
253
254 void DisplayPoint(const Handle(AIS_InteractiveContext)& aContext, 
255                   const gp_Pnt& aPoint, const TCollection_AsciiString& aText, 
256                   Standard_Boolean UpdateViewer = Standard_True,
257                   Standard_Real anXoffset = 0, Standard_Real anYoffset = 0, Standard_Real aZoffset = 0,
258                   Standard_Real TextScale = 0.05)
259 {
260     Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint);
261     aContext->Display(aGraphicPoint,Standard_False);
262     Handle(ISession_Text)  aGraphicText = new ISession_Text(aText,aPoint.X()+anXoffset,aPoint.Y()+anYoffset,aPoint.Z()+aZoffset);
263     aGraphicText->SetScale  (TextScale);
264     aContext->Display(aGraphicText,UpdateViewer);
265 }
266
267 void DisplayCurve(const Handle(ISession2D_InteractiveContext)& aContext2D,
268                   const Handle(Geom2d_Curve)& aCurve, Standard_Integer aColorIndex = 4,
269                   Standard_Boolean UpdateViewer = Standard_False)
270 {
271     Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
272     aGraphicCurve->SetColorIndex(aColorIndex) ;
273     aContext2D->Display(aGraphicCurve,UpdateViewer);
274 }
275
276 void DisplayCurveAndCurvature(const Handle(ISession2D_InteractiveContext)& aContext2D,
277                               const Handle(Geom2d_Curve)& aCurve, Standard_Integer aColorIndex = 4,
278                               Standard_Boolean UpdateViewer = Standard_False)
279 {
280     Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
281     aGraphicCurve->SetDisplayCurbure(Standard_True) ;
282     aGraphicCurve->SetDiscretisation(20);
283     aGraphicCurve->SetColorIndex(aColorIndex) ;
284     aContext2D->Display(aGraphicCurve,UpdateViewer);
285 }
286
287 void DisplayCurve(const Handle(AIS_InteractiveContext)& aContext,
288                   const Handle(Geom_Curve)& aCurve, Quantity_NameOfColor aNameOfColor, 
289                   Standard_Boolean UpdateViewer = Standard_False)
290 {
291     Handle(ISession_Curve) aGraphicCurve = new ISession_Curve(aCurve);
292     aContext->SetColor(aGraphicCurve,aNameOfColor);
293     aGraphicCurve->Attributes()->LineAspect()->SetColor(aNameOfColor);
294     aContext->Display(aGraphicCurve,UpdateViewer);
295 }
296
297 void DisplayCurve(const Handle(AIS_InteractiveContext)& aContext,
298                   const Handle(Geom_Curve)& aCurve, Standard_Boolean UpdateViewer = Standard_False)
299 {
300     Handle(ISession_Curve) aGraphicCurve = new ISession_Curve(aCurve);
301     aContext->Display(aGraphicCurve,UpdateViewer);
302 }
303
304
305 void DisplaySurface(const Handle(AIS_InteractiveContext)& aContext,
306                     const Handle(Geom_Surface)& aSurface, Quantity_NameOfColor aNameOfColor, 
307                     Standard_Boolean UpdateViewer = Standard_False)
308 {
309     Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
310     aContext->SetColor(aGraphicalSurface,aNameOfColor);
311     aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
312     aGraphicalSurface->Attributes()->UIsoAspect()->SetColor(aNameOfColor);
313     aGraphicalSurface->Attributes()->VIsoAspect()->SetColor(aNameOfColor);
314     aContext->Display(aGraphicalSurface,UpdateViewer);
315 }
316
317 void DisplaySurface(const Handle(AIS_InteractiveContext)& aContext,
318                     const Handle(Geom_Surface)& aSurface, Standard_Boolean UpdateViewer = Standard_False)
319 {
320     Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
321     aContext->Display(aGraphicalSurface,UpdateViewer);
322 }
323
324
325 //===============================================================
326 // Function name: gpTest1
327 //===============================================================
328  void SampleGeometryPackage::gpTest1(const Handle(AIS_InteractiveContext)& aContext,
329                                      TCollection_AsciiString& Message) 
330 {
331     aContext->EraseAll(Standard_False);
332 //==============================================================
333
334 gp_XYZ A(1,2,3);                        
335 gp_XYZ B(2,2,2);                        
336 gp_XYZ C(3,2,3);                        
337 Standard_Real result = A.DotCross(B,C); 
338                                         
339 //==============================================================
340     Message = "\
341                                         \n\
342 gp_XYZ A(1,2,3);                        \n\
343 gp_XYZ B(2,2,2);                        \n\
344 gp_XYZ C(3,2,3);                        \n\
345 Standard_Real result = A.DotCross(B,C); \n\
346                                         \n";
347     AddSeparator(Message);
348     //--------------------------------------------------------------
349     DisplayPoint(aContext,gp_Pnt(A),"A (1,2,3)",Standard_False,0.1);
350     DisplayPoint(aContext,gp_Pnt(B),"B (2,2,2)",Standard_False,0.1);
351     DisplayPoint(aContext,gp_Pnt(C),"C (3,2,3)",Standard_True,0.1);
352
353     Message+= " result = ";
354     Message+= TCollection_AsciiString(result);
355     Message+= "  \n";
356 }
357
358 //===============================================================
359 // Function name: gpTest2
360 //===============================================================
361  void SampleGeometryPackage::gpTest2(const Handle(AIS_InteractiveContext)& aContext,
362                                      TCollection_AsciiString& Message) 
363 {
364     aContext->EraseAll(Standard_False);
365 //==============================================================
366
367 gp_Pnt P1(1,2,3);  
368                    
369 //==============================================================
370     Message = "\
371                   \n\
372 gp_Pnt P1(1,2,3); \n\
373                   \n";
374     AddSeparator(Message);
375     //--------------------------------------------------------------
376     DisplayPoint(aContext,P1,"P1 (1,2,3)",Standard_True,0.5);
377 }
378
379 //===============================================================
380 // Function name: gpTest3
381 //===============================================================
382  void SampleGeometryPackage::gpTest3(const Handle(AIS_InteractiveContext)& aContext,
383                                      TCollection_AsciiString& Message) 
384 {
385     aContext->EraseAll(Standard_False);
386 //==============================================================
387
388 gp_XYZ A(1,2,3);  
389 gp_Pnt P2(A);     
390                   
391 //==============================================================
392     Message = "\
393                    \n\
394 gp_XYZ A(1,2,3);   \n\
395 gp_Pnt P2(A);      \n\
396                    \n";
397     AddSeparator(Message);
398     //--------------------------------------------------------------
399     DisplayPoint(aContext,P2,"P2 (1,2,3)",Standard_True,0.5);
400 }
401
402 //===============================================================
403 // Function name: gpTest4
404 //===============================================================
405  void SampleGeometryPackage::gpTest4(const Handle(AIS_InteractiveContext)& aContext,
406                                      TCollection_AsciiString& Message) 
407 {
408     aContext->EraseAll(Standard_False);
409 //==============================================================
410                                               
411 gp_Pnt P3 = gp::Origin();                     
412 Standard_Real TheX = P3.X();
413 Standard_Real TheY = P3.Y();
414 Standard_Real TheZ = P3.Z();
415   
416                                               
417 //==============================================================
418     Message = "\
419                                \n\
420 gp_Pnt P3 = gp::Origin();      \n\
421 Standard_Real TheX = P3.X();   \n\
422 Standard_Real TheY = P3.Y();   \n\
423 Standard_Real TheZ = P3.Z();   \n\
424                                \n";
425     AddSeparator(Message);
426     //--------------------------------------------------------------
427     DisplayPoint(aContext,P3,"P3 = gp::Origin()",Standard_True,0.5);
428     Message += " TheX = "; Message += TCollection_AsciiString(TheX);
429     Message += " TheY = "; Message += TCollection_AsciiString(TheY);
430     Message += " TheZ = "; Message += TCollection_AsciiString(TheZ);
431 }
432
433 //===============================================================
434 // Function name: gpTest5
435 //===============================================================
436  void SampleGeometryPackage::gpTest5(const Handle(AIS_InteractiveContext)& aContext,
437                                      TCollection_AsciiString& Message) 
438 {
439     aContext->EraseAll(Standard_False);
440 //==============================================================
441                                
442 gp_Pnt P1(1,2,3);              
443 gp_Pnt P2(3,4,5);              
444 gp_Pnt PB = P1;                
445 Standard_Real alpha = 3;       
446 Standard_Real beta = 7;        
447 PB.BaryCenter(alpha,P2,beta);  
448                                
449 //==============================================================
450     Message = "\
451                                  \n\
452 gp_Pnt P1(1,2,3);                \n\
453 gp_Pnt P2(3,4,5);                \n\
454 gp_Pnt PB = P1;                  \n\
455 Standard_Real alpha = 3;         \n\
456 Standard_Real beta = 7;          \n\
457 PB.BaryCenter(alpha,P2,beta);    \n\
458                                  \n";
459
460     AddSeparator(Message);
461     //--------------------------------------------------------------
462
463     DisplayPoint(aContext,P1,"P1",Standard_False,0.2);
464     DisplayPoint(aContext,P2,"P2",Standard_False,0.2);
465     DisplayPoint(aContext,PB,"PB = barycenter ( 3 * P1 , 7 * P2) ",Standard_True,0.2);
466
467     Message += " PB ( ";
468     Message += TCollection_AsciiString(PB.X()); Message += " , ";
469     Message += TCollection_AsciiString(PB.Y()); Message += " , ";
470     Message += TCollection_AsciiString(PB.Z()); Message += " ); ";
471 }
472
473 //===============================================================
474 // Function name: gpTest6
475 //===============================================================
476  void SampleGeometryPackage::gpTest6(const Handle(AIS_InteractiveContext)& aContext,
477                                      TCollection_AsciiString& Message) 
478 {
479     aContext->EraseAll(Standard_False);
480 //==============================================================
481                                                                  
482 //  Compute a 3d point P as BaryCenter of an array of point
483 gp_Pnt P1(0,0,5);                                                
484 gp_Pnt P2(1,2,3);                                                
485 gp_Pnt P3(2,3,-2);                                                
486 gp_Pnt P4(4,3,5);                                                
487 gp_Pnt P5(5,5,4);                                                
488 TColgp_Array1OfPnt array (1,5); // sizing array                  
489 array.SetValue(1,P1);                                            
490 array.SetValue(2,P2);                                            
491 array.SetValue(3,P3);                                            
492 array.SetValue(4,P4);                                            
493 array.SetValue(5,P5);                                            
494                                                                  
495 Standard_Real Tolerance = 8; // ajout de la tolerance            
496 GProp_PEquation PE (array,Tolerance);                            
497                                                                  
498 gp_Pnt P; // P declaration                                    
499 Standard_Boolean IsPoint;                                        
500 if (PE.IsPoint()){IsPoint = Standard_True;                                
501                   P = PE .Point();}                              
502                   else { IsPoint = Standard_False;  }                     
503 if (PE.IsLinear()){ /*... */ }  
504 if (PE.IsPlanar()){ /*... */ }   
505 if (PE.IsSpace()) { /*... */ }     
506                                                                  
507 //==============================================================
508     Message = "\
509                                                                  \n\
510                                                                  \n\
511 //  Compute a 3d point P as BaryCenter of an array of point      \n\
512 gp_Pnt P1(0,0,5);                                                \n\
513 gp_Pnt P2(1,2,3);                                                \n\
514 gp_Pnt P3(2,3,-2);                                               \n\
515 gp_Pnt P4(4,3,5);                                                \n\
516 gp_Pnt P5(5,5,4);                                                \n\
517 TColgp_Array1OfPnt array (1,5); // sizing array                  \n\
518 array.SetValue(1,P1);                                            \n\
519 array.SetValue(2,P2);                                            \n\
520 array.SetValue(3,P3);                                            \n\
521 array.SetValue(4,P4);                                            \n\
522 array.SetValue(5,P5);                                            \n\
523                                                                  \n\
524 Standard_Real Tolerance = 8; // ajout de la tolerance            \n\
525 GProp_PEquation PE (array,Tolerance);                            \n\
526                                                                  \n\
527 gp_Pnt P; // P declaration                                       \n\
528 Standard_Boolean IsPoint;                                        \n\
529 if (PE.IsPoint()){IsPoint = true;                                \n\
530                   P = PE .Point();}                              \n\
531                   else { IsPoint = false;  }                     \n\
532 if (PE.IsLinear()){ /*... */ }                                   \n\
533 if (PE.IsPlanar()){ /*... */ }                                   \n\
534 if (PE.IsSpace()) { /*... */ }                                   \n\
535                                                                  \n";
536     AddSeparator(Message);
537     //--------------------------------------------------------------
538
539     TCollection_AsciiString PointName("P");
540     for(Standard_Integer i= array.Lower();i <= array.Upper(); i++)
541     {
542       TCollection_AsciiString TheString (PointName + TCollection_AsciiString(i));
543       DisplayPoint(aContext,array(i),TheString,Standard_False,0.5);
544     }
545
546     DisplayPoint(aContext,P,"P",Standard_True,0.5);
547
548
549     Message += " IsPoint = ";  if (IsPoint) {
550      Message += "True   -->  ";
551      Message += " P ( ";
552      Message += TCollection_AsciiString(P.X()); Message += " , ";
553      Message += TCollection_AsciiString(P.Y()); Message += " , ";
554      Message += TCollection_AsciiString(P.Z()); Message += " ); \n";
555     }  else Message += "False\n";
556     Message += " IsLinear = ";  if (PE.IsLinear()) Message += "True \n";  else Message += "False\n";
557     Message += " IsPlanar = ";  if (PE.IsPlanar()) Message += "True \n";  else Message += "False\n";
558     Message += " IsSpace = ";   if (PE.IsSpace() ) Message += "True \n";  else Message += "False\n";
559 }
560
561 //===============================================================
562 // Function name: gpTest7
563 //===============================================================
564  void SampleGeometryPackage::gpTest7(const Handle(ISession2D_InteractiveContext)& aContext2D,
565                                      TCollection_AsciiString& Message) 
566 {
567     aContext2D->EraseAll();
568 //==============================================================
569                                            
570 gp_Pnt2d P1(0,5);                                       
571 gp_Pnt2d P2(5.5,1);                                     
572 gp_Pnt2d P3(-2,2);                                      
573                                                         
574 Handle(Geom2d_TrimmedCurve) C =                         
575     GCE2d_MakeArcOfCircle (P1,P2,P3).Value();           
576
577 Standard_Real FirstParameter = C->FirstParameter();
578 Standard_Real LastParameter = C->LastParameter();
579 Standard_Real MiddleParameter = (FirstParameter+LastParameter)/2;
580 Standard_Real param = MiddleParameter; //in radians    
581
582 gp_Pnt2d P;                                             
583 gp_Vec2d V;                                             
584 C->D1(param,P,V);                          
585 // we recover point P and the vector V     
586                                            
587 //==============================================================
588     Message = "\
589                                                     \n\
590                                                     \n\
591 gp_Pnt2d P1(0,5);                                   \n\
592 gp_Pnt2d P2(5.5,1);                                 \n\
593 gp_Pnt2d P3(-2,2);                                  \n\
594                                                     \n\
595 Handle(Geom2d_TrimmedCurve) C =                     \n\
596     GCE2d_MakeArcOfCircle (P1,P2,P3).Value();       \n\
597                                                     \n\
598 Standard_Real FirstParameter = C->FirstParameter(); \n\
599 Standard_Real LastParameter = C->LastParameter();   \n\
600 Standard_Real MiddleParameter =                     \n\
601            (FirstParameter+LastParameter)/2;        \n\
602 Standard_Real param = MiddleParameter; //in radians \n\
603                                                     \n\
604 gp_Pnt2d P;                                         \n\
605 gp_Vec2d V;                                         \n\
606 C->D1(param,P,V);                                   \n\
607 // we recover point P and the vector V              \n\
608                                                     \n";
609
610     AddSeparator(Message);
611     //--------------------------------------------------------------
612
613     DisplayCurve(aContext2D,C);
614     Handle(ISession_Direction) aDirection = new ISession_Direction(P,V);
615     aContext2D->Display(aDirection);
616
617     DisplayPoint(aContext2D,P,"P",Standard_True,0.5);
618 }
619
620 //===============================================================
621 // Function name: gpTest8
622 //===============================================================
623  void SampleGeometryPackage::gpTest8(const Handle(ISession2D_InteractiveContext)& aContext2D,
624                                      TCollection_AsciiString& Message) 
625 {
626     aContext2D->EraseAll();
627 //==============================================================
628                                                    
629 Standard_Real radius = 5;                          
630 Handle(Geom2d_Circle) C =                          
631     new Geom2d_Circle(gp::OX2d(),radius);          
632 Standard_Real param = 1.2*PI;                      
633 Geom2dLProp_CLProps2d CLP                          
634     (C,param,2,Precision::PConfusion());           
635     gp_Dir2d D;                                    
636 CLP.Tangent(D);                                    
637 // D is the Tangent direction at parameter 1.2*PI  
638                                                    
639 //==============================================================
640     Message = " \
641                                                    \n\
642 Standard_Real radius = 5;                          \n\
643 Handle(Geom2d_Circle) C =                          \n\
644     new Geom2d_Circle(gp::OX2d(),radius);          \n\
645 Standard_Real param = 1.2*PI;                      \n\
646 Geom2dLProp_CLProps2d CLP                          \n\
647     (C,param,2,Precision::PConfusion());           \n\
648     gp_Dir2d D;                                    \n\
649 CLP.Tangent(D);                                    \n\
650 // D is the Tangent direction at parameter 1.2*PI  \n\
651                                                    \n";
652     AddSeparator(Message);
653     //--------------------------------------------------------------
654     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
655     aContext2D->Display(aCurve,Standard_False);
656     Handle(ISession_Direction) aDirection = new ISession_Direction(gp_Pnt2d(0,0),D,2);
657     aContext2D->Display(aDirection);
658
659      Message += " D ( ";
660      Message += TCollection_AsciiString(D.X()); Message += " , ";
661      Message += TCollection_AsciiString(D.Y()); Message += " ); \n";
662 }
663
664 //===============================================================
665 // Function name: gpTest9
666 //===============================================================
667  void SampleGeometryPackage::gpTest9(const Handle(ISession2D_InteractiveContext)& aContext2D,
668                                      TCollection_AsciiString& Message) 
669 {
670     aContext2D->EraseAll();
671 //==============================================================
672                                                              
673 Standard_Real radius = 5;                                    
674 Handle(Geom2d_Circle) C =                                    
675     new Geom2d_Circle(gp::OX2d(),radius);                    
676 Geom2dAdaptor_Curve GAC (C);                                 
677 Standard_Real startparam = 10*PI180;                                
678 Standard_Real abscissa = 45*PI180;                                  
679 gp_Pnt2d P1;
680 C->D0(startparam,P1);                                                
681 // abscissa is the distance along the curve from startparam  
682 GCPnts_AbscissaPoint AP (GAC, abscissa, startparam);         
683 gp_Pnt2d P2;                                                  
684 if (AP.IsDone()){C->D0(AP.Parameter(),P2);}                   
685 // P is now correctly set                                    
686                                                              
687 //==============================================================
688     Message = " \n\
689                                                              \n\
690                                                              \n\
691 Standard_Real radius = 5;                                    \n\
692 Handle(Geom2d_Circle) C =                                    \n\
693     new Geom2d_Circle(gp::OX2d(),radius);                    \n\
694 Geom2dAdaptor_Curve GAC (C);                                 \n\
695 Standard_Real startparam = 10*PI180;                            \n\
696 Standard_Real abscissa = 45*PI180;                                 \n\
697 gp_Pnt2d P1;                                                 \n\
698 C->D0(startparam,P1);                                                \n\
699 // abscissa is the distance along the curve from startparam  \n\
700 GCPnts_AbscissaPoint AP (GAC, abscissa, startparam);         \n\
701 gp_Pnt2d P2;                                                  \n\
702 if (AP.IsDone()){C->D0(AP.Parameter(),P2);}                   \n\
703 // P is now correctly set                                    \n\
704                                                              \n\
705                                                              \n";
706     AddSeparator(Message);
707     //--------------------------------------------------------------
708     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
709     aContext2D->Display(aCurve,Standard_False);
710
711     DisplayPoint(aContext2D,P1,"P1");
712     if (AP.IsDone())    DisplayPoint(aContext2D,P2,"P2");
713
714      Message += " P1 ( ";
715      Message += TCollection_AsciiString(P1.X()); Message += " , ";
716      Message += TCollection_AsciiString(P1.Y()); Message += " ); \n";
717
718      Message += " P2 ( ";
719      Message += TCollection_AsciiString(P2.X()); Message += " , ";
720      Message += TCollection_AsciiString(P2.Y()); Message += " ); \n";
721 }
722
723 //===============================================================
724 // Function name: gpTest10
725 //===============================================================
726  void SampleGeometryPackage::gpTest10(const Handle(ISession2D_InteractiveContext)& aContext2D,
727                                      TCollection_AsciiString& Message) 
728 {
729   aContext2D->EraseAll();
730 //==============================================================
731                                                         
732 gp_Pnt2d P;                                             
733 Standard_Real radius = 5;                               
734 Handle(Geom2d_Circle) C =                               
735     new Geom2d_Circle(gp::OX2d(),radius);               
736 Geom2dAdaptor_Curve GAC (C);                            
737 Standard_Real abscissa = 3;                             
738 GCPnts_UniformAbscissa UA (GAC,abscissa);               
739 TColgp_SequenceOfPnt2d aSequence;                       
740 if (UA.IsDone())                                        
741   {                                                     
742     Standard_Real N = UA.NbPoints();                    
743     Standard_Integer count = 1;                         
744     for(;count<=N;count++)                              
745      {                                                  
746         C->D0(UA.Parameter(count),P);                   
747         UA.Parameter(count);  
748         // append P in a Sequence                       
749         aSequence.Append(P);                            
750     }                                                   
751 }                                                       
752 Standard_Real Abscissa  = UA.Abscissa();                
753                                                         
754 //==============================================================
755     Message = " \
756                                                         \n\
757 gp_Pnt2d P;                                             \n\
758 Standard_Real radius = 5;                               \n\
759 Handle(Geom2d_Circle) C =                               \n\
760     new Geom2d_Circle(gp::OX2d(),radius);               \n\
761 Geom2dAdaptor_Curve GAC (C);                            \n\
762 Standard_Real abscissa = 3;                             \n\
763 GCPnts_UniformAbscissa UA (GAC,abscissa);               \n\
764 TColgp_SequenceOfPnt2d aSequence;                       \n\
765 if (UA.IsDone())                                        \n\
766   {                                                     \n\
767     Standard_Real N = UA.NbPoints();                    \n\
768     Standard_Integer count = 1;                         \n\
769     for(;count<=N;count++)                              \n\
770      {                                                  \n\
771         C->D0(UA.Parameter(count),P);                   \n\
772         Standard_Real Parameter = UA.Parameter(count);  \n\
773         // append P in a Sequence                       \n\
774         aSequence.Append(P);                            \n\
775     }                                                   \n\
776 }                                                       \n\
777 Standard_Real Abscissa  = UA.Abscissa();                \n\
778                                                         \n";
779     AddSeparator(Message);
780     //--------------------------------------------------------------
781     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
782     aContext2D->Display(aCurve,Standard_False);
783
784     TCollection_AsciiString aString;
785     for (Standard_Integer i=1;i<= aSequence.Length();i++)
786     {
787      aString = "P";aString += TCollection_AsciiString(i);
788       aString +=": Parameter : "; aString +=TCollection_AsciiString(UA.Parameter(i));
789      //   First and Last texts are displayed with an Y offset, point 4 is upper
790      Standard_Real YOffset = -0.3;
791      YOffset +=  0.2 * ( i == 1 ) ;
792      YOffset +=  0.4 * ( i == 4 ) ;
793      YOffset += -0.2 * ( i == aSequence.Length() ); 
794
795      DisplayPoint(aContext2D,aSequence(i),aString,Standard_False,0.5,YOffset,0.04);
796     }
797     Message += "Abscissa  = "; Message += TCollection_AsciiString(Abscissa); Message += " \n";
798 }
799
800 //===============================================================
801 // Function name: gpTest11
802 //===============================================================
803  void SampleGeometryPackage::gpTest11(const Handle(AIS_InteractiveContext)& aContext,
804                                      TCollection_AsciiString& Message) 
805 {
806   aContext->EraseAll(Standard_False);
807 //==============================================================
808                                                           
809 Standard_Real radius = 5;                                 
810 Handle(Geom_SphericalSurface) SP =                        
811     new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);  
812 Standard_Real u = 2;                                      
813 Standard_Real v = 3;                                      
814 gp_Pnt P = SP->Value(u,v);                                
815                                                           
816 //==============================================================
817     Message = " \
818                                                           \n\
819 Standard_Real radius = 5;                                 \n\
820 Handle(Geom_SphericalSurface) SP =                        \n\
821     new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);  \n\
822 Standard_Real u = 2;                                      \n\
823 Standard_Real v = 3;                                      \n\
824 gp_Pnt P = SP->Value(u,v);                                \n\
825                                                           \n";
826     AddSeparator(Message);
827     //--------------------------------------------------------------
828
829     DisplaySurface(aContext,SP);
830     DisplayPoint(aContext,P,"P",Standard_True,0.5);
831
832     Message += " P ( ";
833     Message += TCollection_AsciiString(P.X()); Message += " , ";
834     Message += TCollection_AsciiString(P.Y()); Message += " ); \n";
835 }
836
837 //===============================================================
838 // Function name: gpTest12
839 //===============================================================
840  void SampleGeometryPackage::gpTest12(const Handle(AIS_InteractiveContext)& aContext,
841                                      TCollection_AsciiString& Message) 
842 {
843   aContext->EraseAll(Standard_False);
844 //==============================================================
845                                                             
846 gp_Pnt N,Q,P(1,2,3);                                        
847 Standard_Real distance, radius = 5;                         
848 Handle(Geom_Circle) C = new Geom_Circle(gp::XOY(),radius);  
849 GeomAPI_ProjectPointOnCurve PPC (P,C);                      
850 N = PPC.NearestPoint();                                     
851 Standard_Integer NbResults = PPC.NbPoints();                
852                                                             
853 if(NbResults>0){                                            
854     for(Standard_Integer i = 1;i<=NbResults;i++){           
855       Q = PPC.Point(i);                                     
856       distance = PPC.Distance(i);                           
857         // do something with Q or distance here             
858       }                                                     
859  }                                                          
860                                                             
861 //==============================================================
862     Message = " \
863                                                             \n\
864 gp_Pnt N,Q,P(1,2,3);                                        \n\
865 Standard_Real distance, radius = 5;                         \n\
866 Handle(Geom_Circle) C = new Geom_Circle(gp::XOY(),radius);  \n\
867 GeomAPI_ProjectPointOnCurve PPC (P,C);                      \n\
868 N = PPC.NearestPoint();                                     \n\
869 Standard_Integer NbResults = PPC.NbPoints();                \n\
870                                                             \n\
871 if(NbResults>0){                                            \n\
872     for(Standard_Integer i = 1;i<=NbResults;i++){           \n\
873       Q = PPC.Point(i);                                     \n\
874       distance = PPC.Distance(i);                           \n\
875         // do something with Q or distance here             \n\
876       }                                                     \n\
877  }                                                          \n\
878                                                             \n";
879     AddSeparator(Message);
880     //--------------------------------------------------------------
881
882     TCollection_AsciiString aString;
883
884     DisplayPoint(aContext,P,"P",Standard_True,0.5);
885
886     aString = "N : at Distance : "; aString += TCollection_AsciiString(PPC.LowerDistance());
887     DisplayPoint(aContext,N,aString,Standard_False,0.5,0,-0.5);
888
889     DisplayCurve(aContext,C,Standard_False);
890
891         if(NbResults>0){
892                 for(Standard_Integer i = 1;i<=NbResults;i++){
893                 Q = PPC.Point(i);
894                 distance = PPC.Distance(i);     
895         
896         aString = "Q";aString += TCollection_AsciiString(i); 
897         aString +=": at Distance : "; aString += TCollection_AsciiString(distance);
898         DisplayPoint(aContext,Q,aString,Standard_False,0.5);
899                 }
900         }
901 }
902
903 //===============================================================
904 // Function name: gpTest13
905 //===============================================================
906  void SampleGeometryPackage::gpTest13(const Handle(AIS_InteractiveContext)& aContext,
907                                      TCollection_AsciiString& Message) 
908 {
909   aContext->EraseAll(Standard_False);
910 //==============================================================
911                                                           
912 gp_Pnt N,Q,P(7,8,9);                                      
913 Standard_Real distance, radius = 5;                       
914 Handle(Geom_SphericalSurface) SP =                        
915     new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);  
916 GeomAPI_ProjectPointOnSurf PPS(P,SP);                     
917 N = PPS.NearestPoint();                                   
918 Standard_Integer NbResults = PPS.NbPoints();              
919 if(NbResults>0){                                          
920     for(Standard_Integer i = 1;i<=NbResults;i++){         
921     Q = PPS.Point(i);                                     
922     distance = PPS.Distance(i);                           
923     // do something with Q or distance here               
924     }                                                     
925 }                                                         
926                                                           
927 //==============================================================
928     Message = " \
929                                                           \n\
930 gp_Pnt N,Q,P(7,8,9);                                      \n\
931 Standard_Real distance, radius = 5;                       \n\
932 Handle(Geom_SphericalSurface) SP =                        \n\
933     new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);  \n\
934 GeomAPI_ProjectPointOnSurf PPS(P,SP);                     \n\
935 N = PPS.NearestPoint();                                   \n\
936 Standard_Integer NbResults = PPS.NbPoints();              \n\
937 if(NbResults>0){                                          \n\
938     for(Standard_Integer i = 1;i<=NbResults;i++){         \n\
939     Q = PPS.Point(i);                                     \n\
940     distance = PPS.Distance(i);                           \n\
941     // do something with Q or distance here               \n\
942     }                                                     \n\
943 }                                                         \n\
944                                                           \n";
945     AddSeparator(Message);
946     //--------------------------------------------------------------
947     TCollection_AsciiString aString;
948
949     DisplayPoint(aContext,P,"P",Standard_False,0.5);
950
951     aString = "N  : at Distance : "; aString += TCollection_AsciiString(PPS.LowerDistance());
952     DisplayPoint(aContext,N,aString,Standard_False,0.5,0,-0.6);
953
954
955
956     Handle(ISession_Surface) aSurface = new ISession_Surface(SP);
957         Handle (AIS_Drawer) CurDrawer = aSurface->Attributes();
958     CurDrawer->UIsoAspect()->SetNumber(10);
959     CurDrawer->VIsoAspect()->SetNumber(10);
960     aContext->SetLocalAttributes(aSurface, CurDrawer);
961     aContext->Display(aSurface);
962
963         if(NbResults>0){
964                 for(Standard_Integer i = 1;i<=NbResults;i++){
965                 Q = PPS.Point(i);
966                 distance = PPS.Distance(i);     
967         
968         aString = "Q";aString += TCollection_AsciiString(i); 
969         aString +=": at Distance : "; aString += TCollection_AsciiString(distance);
970         DisplayPoint(aContext,Q,aString,Standard_False,0.5);
971                 }
972         }
973 }
974
975 //===============================================================
976 // Function name: gpTest14
977 //===============================================================
978  void SampleGeometryPackage::gpTest14(const Handle(AIS_InteractiveContext)& aContext,
979                                      TCollection_AsciiString& Message) 
980 {
981   aContext->EraseAll(Standard_False);
982 //==============================================================
983                                                           
984 gp_Pnt P;                                                 
985 gp_Ax2 aXOY = gp::XOY();
986 gp_Ax3 aAx3(aXOY);
987 gp_Pln PL(aAx3);
988 //gp_Pln PL (gp_Ax3(gp::XOY()));                            
989 Standard_Real MinorRadius = 5;                            
990 Standard_Real MajorRadius = 8;                            
991 gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius);          
992 IntAna_IntConicQuad ICQ                                   
993     (EL,PL,Precision::Angular(),Precision::Confusion());  
994 if (ICQ.IsDone()){                                        
995     Standard_Integer NbResults = ICQ.NbPoints();          
996     if (NbResults>0){                                     
997     for(Standard_Integer i = 1;i<=NbResults;i++){         
998         P = ICQ.Point(i);                                 
999         // do something with P here                       
1000         }                                                 
1001    }                                                      
1002 }                                                         
1003                                                           
1004 //==============================================================
1005     Message = " \
1006                                                           \n\
1007 gp_Pnt P;                                                 \n\
1008 gp_Pln PL (gp_Ax3(gp::XOY()));                            \n\
1009 Standard_Real MinorRadius = 5;                            \n\
1010 Standard_Real MajorRadius = 8;                            \n\
1011 gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius);          \n\
1012 IntAna_IntConicQuad ICQ                                   \n\
1013     (EL,PL,Precision::Angular(),Precision::Confusion());  \n\
1014 if (ICQ.IsDone()){                                        \n\
1015     Standard_Integer NbResults = ICQ.NbPoints();          \n\
1016     if (NbResults>0){                                     \n\
1017     for(Standard_Integer i = 1;i<=NbResults;i++){         \n\
1018         P = ICQ.Point(i);                                 \n\
1019         // do something with P here                       \n\
1020         }                                                 \n\
1021    }                                                      \n\
1022 }                                                         \n\
1023                                                           \n";
1024     AddSeparator(Message);
1025     //--------------------------------------------------------------
1026
1027     Handle(Geom_Plane) aPlane = GC_MakePlane(PL).Value();
1028     Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);
1029         
1030     DisplaySurface(aContext,aSurface);
1031
1032
1033     Handle(Geom_Ellipse) anEllips = GC_MakeEllipse(EL).Value();
1034     DisplayCurve(aContext,anEllips,Standard_False);
1035
1036     TCollection_AsciiString aString;
1037
1038         if (ICQ.IsDone()){
1039                 Standard_Integer NbResults = ICQ.NbPoints();
1040                 if (NbResults>0){
1041                 for(Standard_Integer i = 1;i<=NbResults;i++){
1042                         P = ICQ.Point(i);
1043             aString = "P";aString += TCollection_AsciiString(i); 
1044             DisplayPoint(aContext,P,aString,Standard_False,0.5);
1045                         }
1046                    }
1047                 }
1048 }
1049
1050 //===============================================================
1051 // Function name: gpTest15
1052 //===============================================================
1053  void SampleGeometryPackage::gpTest15(const Handle(AIS_InteractiveContext)& aContext,
1054                                      TCollection_AsciiString& Message) 
1055 {
1056   aContext->EraseAll(Standard_False);
1057 //==============================================================
1058                      
1059 gp_Pnt P1(1,2,3);    
1060 gp_Pnt P1Copy = P1;  
1061 gp_Pnt P2(5,4,6);    
1062 gp_Trsf TRSF;        
1063 TRSF.SetMirror(P2);  
1064 P1Copy.Transform(TRSF);  
1065                      
1066 //==============================================================
1067     Message = " \
1068                          \n\
1069 gp_Pnt P1(1,2,3);        \n\
1070 gp_Pnt P1Copy = P1;      \n\
1071 gp_Pnt P2(5,4,6);        \n\
1072 gp_Trsf TRSF;            \n\
1073 TRSF.SetMirror(P2);      \n\
1074 P1Copy.Transform(TRSF);  \n\
1075                          \n";
1076     AddSeparator(Message);
1077     //--------------------------------------------------------------
1078
1079     DisplayPoint(aContext,P1Copy,"P1Copy",Standard_False,0.5);
1080     DisplayPoint(aContext,P1,"P1",Standard_False,0.5);
1081     DisplayPoint(aContext,P2,"P2",Standard_False,0.5);
1082 }
1083
1084 //===============================================================
1085 // Function name: gpTest16
1086 //===============================================================
1087  void SampleGeometryPackage::gpTest16(const Handle(AIS_InteractiveContext)& aContext,
1088                                      TCollection_AsciiString& Message) 
1089 {
1090   aContext->EraseAll(Standard_False);
1091 //==============================================================
1092                                          
1093 gp_Pnt P1(1,2,3);                        
1094 gp_Pnt P2(5,4,6);                        
1095 gp_Vec V1 (P1,P2);                       
1096                                          
1097 gp_Pnt P3(10,4,7);                       
1098 gp_Pnt P4(2,0,1);                        
1099 gp_Vec V2 (P3,P4);                       
1100                                          
1101 Standard_Boolean result =                
1102 V1.IsOpposite(V2,Precision::Angular());  
1103 // result should be true                 
1104                                          
1105 //==============================================================
1106     Message = " \
1107                                          \n\
1108 gp_Pnt P1(1,2,3);                        \n\
1109 gp_Pnt P2(5,4,6);                        \n\
1110 gp_Vec V1 (P1,P2);                       \n\
1111                                          \n\
1112 gp_Pnt P3(10,4,7);                       \n\
1113 gp_Pnt P4(2,0,1);                        \n\
1114 gp_Vec V2 (P3,P4);                       \n\
1115                                          \n\
1116 Standard_Boolean result =                \n\
1117 V1.IsOpposite(V2,Precision::Angular());  \n\
1118 // result should be true                 \n\
1119                                          \n";
1120     AddSeparator(Message);
1121     //--------------------------------------------------------------
1122
1123     DisplayPoint(aContext,P1,"P1",Standard_False,0.5);
1124     DisplayPoint(aContext,P2,"P2",Standard_False,0.5);
1125     DisplayPoint(aContext,P3,"P3",Standard_False,0.5);
1126     DisplayPoint(aContext,P4,"P4",Standard_False,0.5);
1127
1128     Handle(ISession_Direction) aDirection1 = new ISession_Direction(P1,V1);
1129     aContext->Display(aDirection1);
1130
1131     Handle(ISession_Direction) aDirection2 = new ISession_Direction(P3,V2);
1132     aContext->Display(aDirection2);
1133
1134     Message += "result = ";
1135     if (result) Message += "True \n"; else Message += "False \n";
1136 }
1137
1138 //===============================================================
1139 // Function name: gpTest17
1140 //===============================================================
1141  void SampleGeometryPackage::gpTest17(const Handle(AIS_InteractiveContext)& aContext,
1142                                      TCollection_AsciiString& Message) 
1143 {
1144   aContext->EraseAll(Standard_False);
1145 //==============================================================
1146                                                  
1147 gp_Dir D1(1,2,3);                                
1148 gp_Dir D2(3,4,5);                                
1149 Standard_Real ang = D1.Angle(D2);                
1150 // the result is in radians in the range [0,PI]  
1151                                                  
1152 //==============================================================
1153     Message = " \
1154                                                  \n\
1155 gp_Dir D1(1,2,3);                                \n\
1156 gp_Dir D2(3,4,5);                                \n\
1157 Standard_Real ang = D1.Angle(D2);                \n\
1158 // the result is in radians in the range [0,PI]  \n\
1159                                                  \n";
1160     AddSeparator(Message);
1161     //--------------------------------------------------------------
1162
1163     Handle(ISession_Direction) aDirection1 = new ISession_Direction(gp_Pnt(0,0,0),D1,3);
1164     aContext->Display(aDirection1);
1165
1166     Handle(ISession_Direction) aDirection2 = new ISession_Direction(gp_Pnt(0,0,0),D2,3);
1167     aContext->Display(aDirection2);
1168     
1169     cout<<" D1.Angle(D2) : "<<ang<<endl;
1170
1171     Message += " ang =  "; Message += TCollection_AsciiString(ang); Message += "   radian \n";
1172     Message += " ang/PI180 =  "; Message += TCollection_AsciiString(ang/PI180); Message += "   degree \n";
1173 }
1174
1175 //===============================================================
1176 // Function name: gpTest18
1177 //===============================================================
1178  void SampleGeometryPackage::gpTest18(const Handle(ISession2D_InteractiveContext)& aContext2D,
1179                                      TCollection_AsciiString& Message) 
1180 {
1181   aContext2D->EraseAll();
1182 //==============================================================
1183                                           
1184 gp_Pnt2d P(2,3);                          
1185 gp_Dir2d D(4,5);                          
1186 gp_Ax22d A(P,D);                          
1187 gp_Parab2d Para(A,6);                     
1188 // P is the vertex point                  
1189 // P and D give the axis of symmetry      
1190 // 6 is the focal length of the parabola  
1191                                           
1192 //==============================================================
1193     Message = " \
1194                                           \n\
1195 gp_Pnt2d P(2,3);                          \n\
1196 gp_Dir2d D(4,5);                          \n\
1197 gp_Ax22d A(P,D);                          \n\
1198 gp_Parab2d Para(A,6);                     \n\
1199 // P is the vertex point                  \n\
1200 // P and D give the axis of symmetry      \n\
1201 // 6 is the focal length of the parabola  \n\
1202                                           \n";
1203     AddSeparator(Message);
1204     //--------------------------------------------------------------
1205
1206     DisplayPoint(aContext2D,P,"P",Standard_False,0.5,0,3);
1207
1208     Handle(ISession_Direction) aDirection = new ISession_Direction(P,D,200);
1209     aContext2D->Display(aDirection,Standard_False);
1210     Handle(Geom2d_Parabola) aParabola = GCE2d_MakeParabola(Para);
1211     Handle(Geom2d_TrimmedCurve) aTrimmedCurve = new Geom2d_TrimmedCurve(aParabola,-100,100);
1212     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aTrimmedCurve);
1213     //aCurve->SetColorIndex(3);
1214     aContext2D->Display(aCurve);  
1215
1216     Message += " The entity A of type gp_Ax22d is not displayable \n ";
1217     Message += " The entity D of type gp_Dir2d is displayed as a vector \n    ( mean with a length != 1 ) \n ";
1218 }
1219
1220 //===============================================================
1221 // Function name: gpTest19
1222 //===============================================================
1223  void SampleGeometryPackage::gpTest19(const Handle(AIS_InteractiveContext)& aContext,
1224                                      TCollection_AsciiString& Message) 
1225 {
1226   aContext->EraseAll(Standard_False);
1227 //==============================================================
1228                                             
1229 gp_Pnt P1(2,3,4);                           
1230 gp_Dir D(4,5,6);                            
1231 gp_Ax3 A(P1,D);                              
1232 Standard_Boolean IsDirectA = A.Direct();    
1233                                             
1234 gp_Dir AXDirection = A.XDirection() ;       
1235 gp_Dir AYDirection = A.YDirection() ;       
1236                                             
1237 gp_Pnt P2(5,3,4);                           
1238 gp_Ax3 A2(P2,D);                            
1239 A2.YReverse();                              
1240 // axis3 is now left handed                 
1241 Standard_Boolean IsDirectA2 = A2.Direct();  
1242                                             
1243 gp_Dir A2XDirection = A2.XDirection() ;     
1244 gp_Dir A2YDirection = A2.YDirection() ;     
1245                                             
1246 //==============================================================
1247     Message = " \
1248                                             \n\
1249 gp_Pnt P1(2,3,4);                           \n\
1250 gp_Dir D(4,5,6);                            \n\
1251 gp_Ax3 A(P,D);                              \n\
1252 Standard_Boolean IsDirectA = A.Direct();    \n\
1253                                             \n\
1254 gp_Dir AXDirection = A.XDirection() ;       \n\
1255 gp_Dir AYDirection = A.YDirection() ;       \n\
1256                                             \n\
1257 gp_Pnt P2(5,3,4);                           \n\
1258 gp_Ax3 A2(P2,D);                            \n\
1259 A2.YReverse();                              \n\
1260 // axis3 is now left handed                 \n\
1261 Standard_Boolean IsDirectA2 = A2.Direct();  \n\
1262                                             \n\
1263 gp_Dir A2XDirection = A2.XDirection() ;     \n\
1264 gp_Dir A2YDirection = A2.YDirection() ;     \n\
1265                                             \n";
1266     AddSeparator(Message);
1267     //--------------------------------------------------------------
1268
1269     DisplayPoint(aContext,P1,"P1",Standard_False,0.1);
1270     Handle(ISession_Direction) aDirection = new ISession_Direction(P1,D,2);
1271     aContext->Display(aDirection);
1272
1273     Handle(ISession_Direction) aDirection2 = new ISession_Direction(P1,AXDirection,2);
1274     aDirection2->SetText(TCollection_ExtendedString("A.XDirection"));
1275     aContext->Display(aDirection2);
1276     Handle(ISession_Direction) aDirection3 = new ISession_Direction(P1,AYDirection,2);
1277     aDirection3->SetText(TCollection_ExtendedString("A.YDirection"));
1278     aContext->Display(aDirection3);
1279
1280     DisplayPoint(aContext,P2,"P2",Standard_False,0.1);
1281     Handle(ISession_Direction) aDirection4 = new ISession_Direction(P2,D,2);
1282     aContext->Display(aDirection4);
1283
1284     Handle(ISession_Direction) aDirection5 = new ISession_Direction(P2,A2XDirection,2);
1285     aDirection5->SetText(TCollection_ExtendedString("A2 XDirection"));
1286     aContext->Display(aDirection5);
1287     Handle(ISession_Direction) aDirection6 = new ISession_Direction(P2,A2YDirection,2);
1288     aDirection6->SetText(TCollection_ExtendedString("A2 YDirection"));
1289     aContext->Display(aDirection6);
1290
1291     Message += "IsDirectA = ";
1292     if (IsDirectA) Message += "True = Right Handed \n"; else Message += "False = Left Handed \n";
1293
1294     Message += "IsDirectA2 = ";
1295     if (IsDirectA2) Message += "True = Right Handed \n"; else Message += "False = Left Handed  \n";
1296 }
1297
1298 //===============================================================
1299 // Function name: gpTest20
1300 //===============================================================
1301  void SampleGeometryPackage::gpTest20(const Handle(ISession2D_InteractiveContext)& aContext2D,
1302                                      TCollection_AsciiString& Message) 
1303 {
1304   aContext2D->EraseAll();
1305 //==============================================================
1306                                                                      
1307 TColgp_Array1OfPnt2d array (1,5); // sizing array                    
1308 array.SetValue(1,gp_Pnt2d (0,0));                                    
1309 array.SetValue(2,gp_Pnt2d (1,2));                                    
1310 array.SetValue(3,gp_Pnt2d (2,3));                                    
1311 array.SetValue(4,gp_Pnt2d (4,3));                                    
1312 array.SetValue(5,gp_Pnt2d (5,5));                                    
1313 Handle(Geom2d_BSplineCurve) SPL1 =                                   
1314     Geom2dAPI_PointsToBSpline(array);                                
1315                                                                      
1316 Handle(TColgp_HArray1OfPnt2d) harray =                               
1317     new TColgp_HArray1OfPnt2d (1,5); // sizing harray                
1318 harray->SetValue(1,gp_Pnt2d (7+ 0,0));                               
1319 harray->SetValue(2,gp_Pnt2d (7+ 1,2));                               
1320 harray->SetValue(3,gp_Pnt2d (7+ 2,3));                               
1321 harray->SetValue(4,gp_Pnt2d (7+ 4,3));                               
1322 harray->SetValue(5,gp_Pnt2d (7+ 5,5));                                                                                            
1323 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);   
1324 anInterpolation.Perform();                                           
1325 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();          
1326                                                                      
1327 Handle(TColgp_HArray1OfPnt2d) harray2 =                              
1328     new TColgp_HArray1OfPnt2d (1,5); // sizing harray                
1329 harray2->SetValue(1,gp_Pnt2d (11+ 0,0));                             
1330 harray2->SetValue(2,gp_Pnt2d (11+ 1,2));                             
1331 harray2->SetValue(3,gp_Pnt2d (11+ 2,3));                             
1332 harray2->SetValue(4,gp_Pnt2d (11+ 4,3));                             
1333 harray2->SetValue(5,gp_Pnt2d (11+ 5,5));                             
1334 Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01);  
1335 anInterpolation2.Perform();                                          
1336 Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve();         
1337 // redefined C++ operator allows these assignments                   
1338                                                                      
1339 //==============================================================
1340     Message = " \
1341                                                                      \n\
1342 TColgp_Array1OfPnt2d array (1,5); // sizing array                    \n\
1343 array.SetValue(1,gp_Pnt2d (0,0));                                    \n\
1344 array.SetValue(2,gp_Pnt2d (1,2));                                    \n\
1345 array.SetValue(3,gp_Pnt2d (2,3));                                    \n\
1346 array.SetValue(4,gp_Pnt2d (4,3));                                    \n\
1347 array.SetValue(5,gp_Pnt2d (5,5));                                    \n\
1348 Handle(Geom2d_BSplineCurve) SPL1 =                                   \n\
1349     Geom2dAPI_PointsToBSpline(array);                                \n\
1350                                                                      \n\
1351 Handle(TColgp_HArray1OfPnt2d) harray =                               \n\
1352     new TColgp_HArray1OfPnt2d (1,5); // sizing harray                \n\
1353 harray->SetValue(1,gp_Pnt2d (7+ 0,0));                               \n\
1354 harray->SetValue(2,gp_Pnt2d (7+ 1,2));                               \n\
1355 harray->SetValue(3,gp_Pnt2d (7+ 2,3));                               \n\
1356 harray->SetValue(4,gp_Pnt2d (7+ 4,3));                               \n\
1357 harray->SetValue(5,gp_Pnt2d (7+ 5,5));                               \n\
1358 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);   \n\
1359 anInterpolation.Perform();                                           \n\
1360 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();          \n\
1361                                                                      \n\
1362 Handle(TColgp_HArray1OfPnt2d) harray2 =                              \n\
1363     new TColgp_HArray1OfPnt2d (1,5); // sizing harray                \n";
1364     Message += "\
1365 harray2->SetValue(1,gp_Pnt2d (11+ 0,0));                             \n\
1366 harray2->SetValue(2,gp_Pnt2d (11+ 1,2));                             \n\
1367 harray2->SetValue(3,gp_Pnt2d (11+ 2,3));                             \n\
1368 harray2->SetValue(4,gp_Pnt2d (11+ 4,3));                             \n\
1369 harray2->SetValue(5,gp_Pnt2d (11+ 5,5));                             \n\
1370 Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01);  \n\
1371 anInterpolation2.Perform();                                          \n\
1372 Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve();         \n\
1373 // redefined C++ operator allows these assignments                   \n\
1374                                                                      \n";
1375     AddSeparator(Message);
1376     //--------------------------------------------------------------
1377     TCollection_AsciiString aString;
1378     Standard_Integer i;
1379     for(i = array.Lower();i<=array.Upper();i++){
1380                 gp_Pnt2d P = array(i);
1381         aString = "array ";aString += TCollection_AsciiString(i); 
1382         DisplayPoint(aContext2D,P,aString,Standard_False,0.5);
1383                 }
1384     for( i = harray->Lower();i<=harray->Upper();i++){
1385                 gp_Pnt2d P = harray->Value(i);
1386         aString = "harray ";aString += TCollection_AsciiString(i); 
1387         DisplayPoint(aContext2D,P,aString,Standard_False,0.5);
1388                 }
1389     for( i = harray2->Lower();i<=harray2->Upper();i++){
1390                 gp_Pnt2d P = harray2->Value(i);
1391         aString = "harray2 ";aString += TCollection_AsciiString(i); 
1392         DisplayPoint(aContext2D,P,aString,Standard_False,0.5);
1393                 }
1394
1395     if (!SPL1.IsNull())
1396     { 
1397       Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1398       aCurve->SetColorIndex(3);
1399       aContext2D->Display(aCurve);
1400     }
1401     
1402     if (!SPL2.IsNull())
1403     {
1404       Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL2);
1405       aCurve2->SetColorIndex(5);
1406       aContext2D->Display(aCurve2);  
1407     }
1408
1409     if (!SPL3.IsNull())
1410     {
1411       Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL3);
1412       aCurve2->SetColorIndex(6);
1413       aContext2D->Display(aCurve2);  
1414     }
1415
1416     Message += " SPL1  is Red  \n";
1417     Message += " SPL2  is Blue \n";   
1418     Message += " SPL3  is Yellow \n";   
1419 }
1420
1421 //===============================================================
1422 // Function name: gpTest21
1423 //===============================================================
1424  void SampleGeometryPackage::gpTest21(const Handle(ISession2D_InteractiveContext)& aContext2D,
1425                                      TCollection_AsciiString& Message) 
1426 {
1427   aContext2D->EraseAll();
1428 //==============================================================
1429                                             
1430 gp_Pnt2d P1(-184, 101);                     
1431 gp_Pnt2d P2(20 ,84);                        
1432 Standard_Real aheight = 1;                  
1433 FairCurve_Batten B (P1,P2,aheight);         
1434 B.SetAngle1(22*PI180);                      
1435 B.SetAngle2(44*PI180);                      
1436 FairCurve_AnalysisCode anAnalysisCode;      
1437 B.Compute(anAnalysisCode);                  
1438 Handle(Geom2d_BSplineCurve) C = B.Curve();  
1439                                             
1440 //==============================================================
1441     Message = " \
1442                                             \n\
1443 gp_Pnt2d P1(-184, 101);                     \n\
1444 gp_Pnt2d P2(20 ,84);                        \n\
1445 Standard_Real aheight = 1;                  \n\
1446 FairCurve_Batten B (P1,P2,aheight);         \n\
1447 B.SetAngle1(22*PI180);                      \n\
1448 B.SetAngle2(44*PI180);                      \n\
1449 FairCurve_AnalysisCode anAnalysisCode;      \n\
1450 B.Compute(anAnalysisCode);                  \n\
1451 Handle(Geom2d_BSplineCurve) C = B.Curve();  \n\
1452                                             \n";
1453     AddSeparator(Message);
1454     //--------------------------------------------------------------
1455
1456     DisplayCurveAndCurvature(aContext2D,C,6,Standard_True);               
1457 }
1458
1459 //===============================================================
1460 // Function name: gpTest22
1461 //===============================================================
1462  void SampleGeometryPackage::gpTest22(const Handle(ISession2D_InteractiveContext)& aContext2D,
1463                                      TCollection_AsciiString& Message) 
1464 {
1465   aContext2D->EraseAll();
1466 //==============================================================
1467                                                 
1468 gp_Pnt2d P1(-184, 41);                          
1469 gp_Pnt2d P2(20 ,24);                            
1470 Standard_Real aheight = 1;                      
1471 FairCurve_MinimalVariation MV (P1,P2,aheight);  
1472 MV.SetAngle1(22*PI180);                         
1473 MV.SetAngle2(44*PI180);                         
1474                                                 
1475 FairCurve_AnalysisCode anAnalysisCode;          
1476 MV.Compute(anAnalysisCode);                     
1477                                                 
1478 Handle(Geom2d_BSplineCurve) C = MV.Curve();     
1479                                                 
1480 //==============================================================
1481     Message = " \
1482                                                 \n\
1483 gp_Pnt2d P1(-184, 41);                          \n\
1484 gp_Pnt2d P2(20 ,24);                            \n\
1485 Standard_Real aheight = 1;                      \n\
1486 FairCurve_MinimalVariation MV (P1,P2,aheight);  \n\
1487 MV.SetAngle1(22*PI180);                         \n\
1488 MV.SetAngle2(44*PI180);                         \n\
1489                                                 \n\
1490 FairCurve_AnalysisCode anAnalysisCode;          \n\
1491 MV.Compute(anAnalysisCode);                     \n\
1492                                                 \n\
1493 Handle(Geom2d_BSplineCurve) C = MV.Curve();     \n\
1494                                                 \n";
1495     AddSeparator(Message);
1496     //--------------------------------------------------------------
1497
1498     DisplayCurveAndCurvature(aContext2D,C,7,Standard_True);                   
1499     DisplayPoint(aContext2D,P1,"P1",Standard_False,0.5);
1500     DisplayPoint(aContext2D,P2,"P2",Standard_False,0.5);
1501 }
1502
1503 //===============================================================
1504 // Function name: gpTest23
1505 //===============================================================
1506  void SampleGeometryPackage::gpTest23(const Handle(ISession2D_InteractiveContext)& aContext2D,
1507                                      TCollection_AsciiString& Message) 
1508 {
1509   aContext2D->EraseAll();
1510 //==============================================================
1511                                                
1512 Standard_Real major = 12;                                               
1513 Standard_Real minor = 4;                                                
1514 gp_Ax2d axis = gp::OX2d();                                              
1515 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor);        
1516                    
1517 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2);
1518        
1519 // The segment goes in the direction Vfrom P1  
1520 // to the point projected on this line by P2   
1521 // In the example (0,6).                       
1522 Handle(Geom2d_BSplineCurve) SPL =              
1523     Geom2dConvert::CurveToBSplineCurve(TC);    
1524                                                
1525 //==============================================================
1526     Message = " \
1527                                                                    \n\
1528 Standard_Real major = 12;                                          \n\
1529 Standard_Real minor = 4;                                           \n\
1530 gp_Ax2d axis = gp::OX2d();                                         \n\
1531 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor);   \n\
1532                                                                    \n\
1533 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2);  \n\
1534                                                                    \n\
1535 // The segment goes in the direction Vfrom P1                      \n\
1536 // to the point projected on this line by P2                       \n\
1537 // In the example (0,6).                                           \n\
1538 Handle(Geom2d_BSplineCurve) SPL =                                  \n\
1539     Geom2dConvert::CurveToBSplineCurve(TC);                        \n\
1540                                                                    \n";
1541     AddSeparator(Message);
1542     //--------------------------------------------------------------
1543
1544     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
1545     aCurve->SetColorIndex(3); // Red
1546     aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
1547     aContext2D->Display(aCurve);
1548
1549     Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL);
1550     aContext2D->Display(aCurve2);
1551 }
1552
1553 //===============================================================
1554 // Function name: gpTest24
1555 //===============================================================
1556  void SampleGeometryPackage::gpTest24(const Handle(AIS_InteractiveContext)& aContext,
1557                                       const Handle(ISession2D_InteractiveContext)& aContext2D,
1558                                       TCollection_AsciiString& Message) 
1559 {
1560   aContext->EraseAll(Standard_False);
1561   aContext2D->EraseAll();
1562 //==============================================================
1563                                                         
1564 Standard_Real radius = 5;                               
1565 gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0));              
1566                                                         
1567 Handle(Geom2d_Circle) circ2d =                          
1568     new Geom2d_Circle(ax2d,radius);                     
1569                                                         
1570 gp_Ax2d circ2dXAxis = circ2d->XAxis();                  
1571                                                         
1572 // create a 3D curve in a given plane                   
1573 Handle(Geom_Curve) C3D =                                
1574     GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY())));    
1575 Handle(Geom_Circle) C3DCircle =                         
1576    Handle(Geom_Circle)::DownCast(C3D);                  
1577                                                         
1578 gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis();             
1579                                                         
1580 // project it to a 2D curve in another plane            
1581                                                         
1582 gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 ));  
1583                                                         
1584 Handle(Geom2d_Curve) C2D =                              
1585     GeomAPI::To2d(C3D,ProjectionPlane);                 
1586                                                         
1587 Handle(Geom2d_Circle) C2DCircle =                       
1588   Handle(Geom2d_Circle)::DownCast(C2D);                 
1589 gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis();            
1590                                                         
1591 //==============================================================
1592     Message = " \
1593                                                         \n\
1594 Standard_Real radius = 5;                               \n\
1595 gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0));              \n\
1596                                                         \n\
1597 Handle(Geom2d_Circle) circ2d =                          \n\
1598     new Geom2d_Circle(ax2d,radius);                     \n\
1599                                                         \n\
1600 gp_Ax2d circ2dXAxis = circ2d->XAxis();                  \n\
1601                                                         \n\
1602 // create a 3D curve in a given plane                   \n\
1603 Handle(Geom_Curve) C3D =                                \n\
1604     GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY())));    \n\
1605 Handle(Geom_Circle) C3DCircle =                         \n\
1606    Handle(Geom_Circle)::DownCast(C3D);                  \n\
1607                                                         \n\
1608 gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis();             \n\
1609                                                         \n\
1610 // project it to a 2D curve in another plane            \n\
1611                                                         \n\
1612 gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 ));  \n\
1613                                                         \n\
1614 Handle(Geom2d_Curve) C2D =                              \n\
1615     GeomAPI::To2d(C3D,ProjectionPlane);                 \n\
1616                                                         \n\
1617 Handle(Geom2d_Circle) C2DCircle =                       \n\
1618   Handle(Geom2d_Circle)::DownCast(C2D);                 \n\
1619 gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis();            \n\
1620                                                         \n";
1621     AddSeparator(Message);
1622     //--------------------------------------------------------------
1623     Handle(Geom_Plane) aPlane = GC_MakePlane(gp_Pln(gp_Ax3(gp::XOY()))).Value();
1624     Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);   
1625     DisplaySurface(aContext,aSurface);
1626
1627     Handle(Geom_Plane) aProjectionPlane = GC_MakePlane(ProjectionPlane).Value();
1628     Handle(Geom_RectangularTrimmedSurface) aProjectionPlaneSurface=
1629         new Geom_RectangularTrimmedSurface(aProjectionPlane,-8.,8.,-12.,12.);
1630         
1631     DisplaySurface(aContext,aProjectionPlaneSurface);
1632
1633     Standard_CString aC3DEntityTypeName = C3D->DynamicType()->Name();        
1634     Standard_CString aC2DEntityTypeName = C2D->DynamicType()->Name();        
1635
1636     Message += " C3D->DynamicType()->Name() = ";
1637     Message += aC3DEntityTypeName; Message += " \n";
1638     Message += " C2D->DynamicType()->Name() = ";
1639     Message += aC2DEntityTypeName; Message += " \n";
1640
1641     DisplayCurve(aContext2D,circ2d,4,Standard_False);
1642     DisplayCurve(aContext,C3D,Standard_False);
1643     DisplayCurve(aContext2D,C2D,5,Standard_False);
1644
1645     Handle(ISession_Direction) aC3DCircleXAxisDirection = new ISession_Direction((gp_Pnt)C3DCircleXAxis.Location(),
1646                                                                                  (gp_Dir)C3DCircleXAxis.Direction(),
1647                                                                                  5.2);
1648     aContext->Display(aC3DCircleXAxisDirection);
1649
1650     Handle(ISession_Direction) acirc2dXAxisDirection = new ISession_Direction((gp_Pnt2d)circ2dXAxis.Location(),
1651                                                                               (gp_Dir2d)circ2dXAxis.Direction(),
1652                                                                               5.2);
1653     aContext2D->Display(acirc2dXAxisDirection);
1654
1655     Handle(ISession_Direction) aC2DCircleXAxisDirection = new ISession_Direction((gp_Pnt2d)C2DCircleXAxis.Location(),
1656                                                                               (gp_Dir2d)C2DCircleXAxis.Direction(),
1657                                                                               5.2);
1658     aContext2D->Display(aC2DCircleXAxisDirection);
1659 }
1660
1661 //===============================================================
1662 // Function name: gpTest25
1663 //===============================================================
1664  void SampleGeometryPackage::gpTest25(const Handle(ISession2D_InteractiveContext)& aContext2D,
1665                                      TCollection_AsciiString& Message) 
1666 {
1667   aContext2D->EraseAll();
1668 //==============================================================
1669                                                                     
1670 Handle(TColgp_HArray1OfPnt2d) harray =                              
1671     new TColgp_HArray1OfPnt2d (1,5); // sizing harray               
1672 harray->SetValue(1,gp_Pnt2d (0,0));                                 
1673 harray->SetValue(2,gp_Pnt2d (-3,1));                                
1674 harray->SetValue(3,gp_Pnt2d (-2,5));                                
1675 harray->SetValue(4,gp_Pnt2d (2,9));                                 
1676 harray->SetValue(5,gp_Pnt2d (-4,14));                               
1677                                                                     
1678 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);  
1679 anInterpolation.Perform();                                          
1680 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve();          
1681                                                                     
1682 gp_Pnt2d P1(-1,-2);                                                 
1683 gp_Pnt2d P2(0,15);                                                  
1684 gp_Dir2d V1 = gp::DY2d();                                           
1685 Handle(Geom2d_TrimmedCurve) TC1=                                    
1686     GCE2d_MakeSegment(P1,V1,P2);                                    
1687                                                                     
1688 Standard_Real tolerance = Precision::Confusion();                   
1689 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance);                  
1690 Standard_Integer NbPoints =ICC.NbPoints();                          
1691 gp_Pnt2d PK;                                                        
1692 for (Standard_Integer k = 1;k<=NbPoints;k++)                        
1693   {                                                                 
1694     PK = ICC.Point(k);                                              
1695     // do something with each intersection point                    
1696   }                                                                 
1697                                                                     
1698 //==============================================================
1699     Message = " \
1700                                                                     \n\
1701 Handle(TColgp_HArray1OfPnt2d) harray =                              \n\
1702     new TColgp_HArray1OfPnt2d (1,5); // sizing harray               \n\
1703 harray->SetValue(1,gp_Pnt2d (0,0));                                 \n\
1704 harray->SetValue(2,gp_Pnt2d (-3,1));                                \n\
1705 harray->SetValue(3,gp_Pnt2d (-2,5));                                \n\
1706 harray->SetValue(4,gp_Pnt2d (2,9));                                 \n\
1707 harray->SetValue(5,gp_Pnt2d (-4,14));                               \n\
1708                                                                     \n\
1709 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);  \n\
1710 anInterpolation.Perform();                                          \n\
1711 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve();          \n\
1712                                                                     \n\
1713 gp_Pnt2d P1(-1,-2);                                                 \n\
1714 gp_Pnt2d P2(0,15);                                                  \n\
1715 gp_Dir2d V1 = gp::DY2d();                                           \n\
1716 Handle(Geom2d_TrimmedCurve) TC1=                                    \n\
1717     GCE2d_MakeSegment(P1,V1,P2);                                    \n\
1718                                                                     \n\
1719 Standard_Real tolerance = Precision::Confusion();                   \n\
1720 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance);                  \n\
1721 Standard_Integer NbPoints =ICC.NbPoints();                          \n\
1722 gp_Pnt2d PK;                                                        \n\
1723 for (Standard_Integer k = 1;k<=NbPoints;k++)                        \n\
1724   {                                                                 \n\
1725     PK = ICC.Point(k);                                              \n\
1726     // do something with each intersection point                    \n\
1727   }                                                                 \n\
1728                                                                     \n";
1729     AddSeparator(Message);
1730    //--------------------------------------------------------------
1731
1732     Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL);
1733     aCurve1->SetDisplayPole(Standard_False);
1734     aContext2D->Display(aCurve1);
1735     Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC1);
1736     aContext2D->Display(aCurve2);
1737
1738     TCollection_AsciiString aString;
1739         for (Standard_Integer i = 1;i<=NbPoints;i++)
1740         {
1741                 PK = ICC.Point(i);
1742                 // do something with each intersection point
1743         aString = "PK_";aString += TCollection_AsciiString(i); 
1744         DisplayPoint(aContext2D,PK,aString,Standard_False,0.5);
1745         Message += "PK_"; Message += TCollection_AsciiString(i); Message += " ( ";
1746         Message += TCollection_AsciiString(PK.X()); Message += " , "; 
1747         Message += TCollection_AsciiString(PK.Y()); Message += " )\n"; 
1748         }
1749 }
1750
1751 //===============================================================
1752 // Function name: gpTest26
1753 //===============================================================
1754  void SampleGeometryPackage::gpTest26(const Handle(ISession2D_InteractiveContext)& aContext2D,
1755                                      TCollection_AsciiString& Message) 
1756 {
1757   aContext2D->EraseAll();
1758 //==============================================================
1759                                                                       
1760 //----------- Build TC1 -----------------------                       
1761 gp_Pnt2d P1(0,0);  gp_Pnt2d P2(2,6);                                  
1762 gp_Dir2d V1 = gp::DY2d();                                             
1763 Handle(Geom2d_TrimmedCurve) TC1 =  GCE2d_MakeSegment(P1,V1,P2);       
1764 Standard_Real FP1 = TC1->FirstParameter();                            
1765 Standard_Real LP1 = TC1->LastParameter();                             
1766 //----------- Build TC2 -----------------------                       
1767 gp_Pnt2d P3(-9,6.5);       gp_Dir2d V2 = gp::DX2d();                    
1768 Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2);        
1769 Standard_Real FP2 = TC1->FirstParameter();                            
1770 Standard_Real LP2 = TC1->LastParameter();                             
1771 //----------- Extrema TC1 / TC2 ---------------                       
1772 Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2);          
1773 Standard_Real shortestdistance =-1;                                   
1774 if (ECC.NbExtrema() != 0)  shortestdistance = ECC.LowerDistance();    
1775 //----------- Build SPL1 ----------------------                       
1776 TColgp_Array1OfPnt2d array (1,5); // sizing array                     
1777 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2)); 
1778 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3)); 
1779 array.SetValue(5,gp_Pnt2d (-3,5));                                    
1780 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);  
1781 Standard_Real FPSPL1 = SPL1->FirstParameter();                        
1782 Standard_Real LPSPL1 = SPL1->LastParameter();                         
1783 //----------- Extrema TC1 / SPL1  -------------                       
1784 Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1);  
1785 Standard_Real SPL1shortestdistance =-1;                               
1786 if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance(); 
1787 Standard_Integer NbExtrema = ECC2.NbExtrema();                        
1788 TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2);                 
1789 int i;
1790 for(i=1;i <= NbExtrema; i++)   {                                  
1791     gp_Pnt2d Ploc1,Ploc2;                                                   
1792     ECC2.Points(i,Ploc1,Ploc2);                                             
1793     aSolutionArray(i,1) = Ploc1;  aSolutionArray(i,2) = Ploc2; }            
1794                                                                       
1795 //==============================================================
1796     Message = " \
1797 //----------- Build TC1 -----------------------                       \n\
1798 gp_Pnt2d P1(0,0);  gp_Pnt2d P2(2,6);                                  \n\
1799 gp_Dir2d V1 = gp::DY2d();                                             \n\
1800 Handle(Geom2d_TrimmedCurve) TC1 =  GCE2d_MakeSegment(P1,V1,P2);       \n\
1801 Standard_Real FP1 = TC1->FirstParameter();                            \n\
1802 Standard_Real LP1 = TC1->LastParameter();                             \n\
1803 //----------- Build TC2 -----------------------                       \n\
1804 gp_Pnt2d P3(-9,6.5);       gp_Dir2d V2 = gp::DX2d();                    \n\
1805 Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2);        \n\
1806 Standard_Real FP2 = TC1->FirstParameter();                            \n\
1807 Standard_Real LP2 = TC1->LastParameter();                             \n\
1808 //----------- Extrema TC1 / TC2 ---------------                       \n\
1809 Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2);          \n\
1810 Standard_Real shortestdistance =-1;                                   \n\
1811 if (ECC.NbExtrema() != 0)  shortestdistance = ECC.LowerDistance();    \n\
1812 //----------- Build SPL1 ----------------------                       \n\
1813 TColgp_Array1OfPnt2d array (1,5); // sizing array                     \n\
1814 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2)); \n\
1815 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3)); \n\
1816 array.SetValue(5,gp_Pnt2d (-3,5));                                    \n\
1817 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);  \n\
1818 Standard_Real FPSPL1 = SPL1->FirstParameter();                        \n";
1819 Message += "\
1820 Standard_Real LPSPL1 = SPL1->LastParameter();                         \n\
1821 //----------- Extrema TC1 / SPL1  -------------                       \n\
1822 Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1);  \n\
1823 Standard_Real SPL1shortestdistance =-1;                               \n\
1824 if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance(); \n\
1825 Standard_Integer NbExtrema = ECC2.NbExtrema();                        \n\
1826 TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2);                 \n\
1827 for(int i=1;i <= NbExtrema; i++)   {                                  \n\
1828     gp_Pnt2d P1,P2;                                                   \n\
1829     ECC2.Points(i,P1,P2);                                             \n\
1830     aSolutionArray(i,1) = P1;  aSolutionArray(i,2) = P2; }            \n";
1831     AddSeparator(Message);
1832     //--------------------------------------------------------------
1833
1834     TCollection_AsciiString aString;
1835     for(i = array.Lower();i<=array.Upper();i++){
1836                 gp_Pnt2d P = array(i);
1837         aString = "array ";aString += TCollection_AsciiString(i); 
1838         DisplayPoint(aContext2D,P,aString,Standard_False,0.5);
1839                 }
1840
1841     if (!SPL1.IsNull())
1842     { 
1843       Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1844       aCurve->SetDisplayPole(Standard_False);
1845       aCurve->SetColorIndex(3);
1846       aContext2D->Display(aCurve);
1847     }
1848
1849     Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(TC1);
1850     aCurve1->SetColorIndex(6);
1851     aContext2D->Display(aCurve1);
1852     Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC2);
1853     aCurve2->SetColorIndex(5);
1854     aContext2D->Display(aCurve2);
1855
1856
1857     for(i=1;i <= NbExtrema; i++)
1858     {
1859         gp_Pnt2d Ploc1 =aSolutionArray(i,1);
1860         aString = "P1_";aString += TCollection_AsciiString(i); 
1861         DisplayPoint(aContext2D,P1,aString,Standard_False,0.7*i);
1862
1863         gp_Pnt2d Ploc2 = aSolutionArray(i,2);
1864         
1865         Handle(Geom2d_TrimmedCurve) SolutionCurve =            
1866                GCE2d_MakeSegment(Ploc1,Ploc2);             
1867         Handle(ISession2D_Curve) aSolutionCurve = new ISession2D_Curve(SolutionCurve);
1868         aContext2D->Display(aSolutionCurve);
1869     }
1870
1871     Message += "TC1 is  Yellow ,TC2 is  Blue ,SPL1 is Red \n";
1872     Message += "ECC.NbExtrema()  = "; Message += TCollection_AsciiString(ECC.NbExtrema());
1873     Message += "    shortestdistance = "; Message+= TCollection_AsciiString(shortestdistance); Message += "\n";
1874     Message += "ECC2.NbExtrema() = "; Message += TCollection_AsciiString(NbExtrema);
1875     Message += "    SPL1shortestdistance = "; Message+= TCollection_AsciiString(SPL1shortestdistance); Message += "\n";
1876 }
1877
1878 //===============================================================
1879 // Function name: gpTest27
1880 //===============================================================
1881  void SampleGeometryPackage::gpTest27(const Handle(ISession2D_InteractiveContext)& aContext2D,
1882                                      TCollection_AsciiString& Message) 
1883 {
1884   aContext2D->EraseAll();
1885 //==============================================================
1886                                                                        
1887 TColgp_Array1OfPnt2d array (1,5); // sizing array                      
1888 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));  
1889 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));  
1890 array.SetValue(5,gp_Pnt2d (-3,5));                                     
1891 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);   
1892                                                                        
1893 Standard_Real dist = 1;                                                
1894 Handle(Geom2d_OffsetCurve) OC =                                        
1895        new Geom2d_OffsetCurve(SPL1,dist);                              
1896 Standard_Boolean result = OC->IsCN(2);                                 
1897                                                                        
1898 Standard_Real dist2 = 1.5;                                             
1899 Handle(Geom2d_OffsetCurve) OC2 =                                       
1900        new Geom2d_OffsetCurve(SPL1,dist2);                             
1901 Standard_Boolean result2 = OC2->IsCN(2);                               
1902                                                                        
1903 //==============================================================
1904     Message = " \
1905                                                                        \n\
1906 TColgp_Array1OfPnt2d array (1,5); // sizing array                      \n\
1907 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));  \n\
1908 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));  \n\
1909 array.SetValue(5,gp_Pnt2d (-3,5));                                     \n\
1910 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);   \n\
1911                                                                        \n\
1912 Standard_Real dist = 1;                                                \n\
1913 Handle(Geom2d_OffsetCurve) OC =                                        \n\
1914        new Geom2d_OffsetCurve(SPL1,dist);                              \n\
1915 Standard_Boolean result = OC->IsCN(2);                                 \n\
1916                                                                        \n\
1917 Standard_Real dist2 = 1.5;                                             \n\
1918 Handle(Geom2d_OffsetCurve) OC2 =                                       \n\
1919        new Geom2d_OffsetCurve(SPL1,dist2);                             \n\
1920 Standard_Boolean result2 = OC2->IsCN(2);                               \n\
1921                                                                        \n";
1922     AddSeparator(Message);
1923     //--------------------------------------------------------------
1924     Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL1);
1925     aCurve1->SetColorIndex(6);
1926     aContext2D->Display(aCurve1);
1927     Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(OC);
1928     aCurve2->SetColorIndex(5);
1929     aContext2D->Display(aCurve2);
1930     Handle(ISession2D_Curve) aCurve3 = new ISession2D_Curve(OC2);
1931     aCurve3->SetColorIndex(3);
1932     aContext2D->Display(aCurve3);
1933
1934
1935     Message += "SPL1 is Yellow \n";
1936     Message += "OC   is Blue \n";
1937     Message += "OC2  is Red \n\n";
1938         Message += "  Warning, Continuity is not guaranteed :  \n ";
1939         if(result)    Message += " result  = True  \n";
1940     else          Message += " result  = False \n";
1941         if(result2)   Message += " result2 = True  \n";
1942     else          Message += " result2 = False \n";
1943 }
1944
1945 //===============================================================
1946 // Function name: gpTest28
1947 //===============================================================
1948  void SampleGeometryPackage::gpTest28(const Handle(ISession2D_InteractiveContext)& aContext2D,
1949                                      TCollection_AsciiString& Message) 
1950 {
1951   aContext2D->EraseAll();
1952 //==============================================================
1953                                       
1954 gp_Pnt2d P1(1,2);                     
1955 gp_Pnt2d P2(4,5);                     
1956 gp_Lin2d L = gce_MakeLin2d(P1,P2);    
1957 // assignment by overloaded operator  
1958                                       
1959 //==============================================================
1960     Message = " \
1961                                       \n\
1962 gp_Pnt2d P1(1,2);                     \n\
1963 gp_Pnt2d P2(4,5);                     \n\
1964 gp_Lin2d L = gce_MakeLin2d(P1,P2);    \n\
1965 // assignment by overloaded operator  \n\
1966                                       \n";
1967     AddSeparator(Message);
1968     //--------------------------------------------------------------
1969     
1970     DisplayPoint(aContext2D,P1,"P1",Standard_False,0.5);
1971     DisplayPoint(aContext2D,P2,"P2",Standard_False,0.5);
1972
1973     Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-3,8);
1974     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
1975     aContext2D->Display(aCurve);
1976 }
1977
1978 //===============================================================
1979 // Function name: gpTest29
1980 //===============================================================
1981  void SampleGeometryPackage::gpTest29(const Handle(ISession2D_InteractiveContext)& aContext2D,
1982                                      TCollection_AsciiString& Message) 
1983 {
1984   aContext2D->EraseAll();
1985 //==============================================================
1986                              
1987 gp_Pnt2d P1(1,2);            
1988 gp_Pnt2d P2(4,5);            
1989 gp_Lin2d L;                  
1990 GccAna_Pnt2dBisec B(P1,P2);  
1991 if (B.IsDone())              
1992     {                        
1993     L = B.ThisSolution();    
1994     }                        
1995                              
1996 //==============================================================
1997     Message = " \
1998                              \n\
1999 gp_Pnt2d P1(1,2);            \n\
2000 gp_Pnt2d P2(4,5);            \n\
2001 gp_Lin2d L;                  \n\
2002 GccAna_Pnt2dBisec B(P1,P2);  \n\
2003 if (B.IsDone())              \n\
2004     {                        \n\
2005     L = B.ThisSolution();    \n\
2006     }                        \n\
2007                              \n";
2008     AddSeparator(Message);
2009     //--------------------------------------------------------------
2010
2011     DisplayPoint(aContext2D,P1,"P1",Standard_False,0.5);
2012     DisplayPoint(aContext2D,P2,"P2",Standard_False,0.5);
2013
2014         if (B.IsDone())
2015           {
2016         Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-8,8);
2017         Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2018         aContext2D->Display(aCurve);
2019       }
2020
2021         if (B.IsDone()) Message += " \n   B Is Done   ";
2022     else            Message += " \n   B Is not Done    ";
2023 }
2024
2025 //===============================================================
2026 // Function name: gpTest30
2027 //===============================================================
2028  void SampleGeometryPackage::gpTest30(const Handle(ISession2D_InteractiveContext)& aContext2D,
2029                                      TCollection_AsciiString& Message) 
2030 {
2031   aContext2D->EraseAll();
2032 //==============================================================
2033                                                      
2034 gp_Pnt2d P1 (2,3);                                   
2035 gp_Pnt2d P2 (4,4);                                   
2036 gp_Pnt2d P3 (6,7);                                   
2037 gp_Pnt2d P4 (10,10);                                 
2038 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);             
2039 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);        
2040 GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion());  
2041 Standard_Integer NbSol=0;                              
2042 if (LT.IsDone())                                     
2043   {                                                  
2044       NbSol = LT.NbSolutions();                      
2045       Standard_Integer k;
2046       for(k=1; k<=NbSol; k++)       
2047         {                                            
2048          LT.ThisSolution(k);            
2049           // do something with L                     
2050         }                                            
2051   }                                                  
2052                                                      
2053 //==============================================================
2054     Message = " \
2055                                                      \n\
2056 gp_Pnt2d P1 (2,3);                                   \n\
2057 gp_Pnt2d P2 (4,4);                                   \n\
2058 gp_Pnt2d P3 (6,7);                                   \n\
2059 gp_Pnt2d P4 (10,10);                                 \n\
2060 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);             \n\
2061 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);        \n\
2062 GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion());  \n\
2063 Standard_Integer NbSol;                              \n\
2064 if (LT.IsDone())                                     \n\
2065   {                                                  \n\
2066       NbSol = LT.NbSolutions();                      \n\
2067       for(Standard_Integer k=1; k<=NbSol; k++)       \n\
2068         {                                            \n\
2069          gp_Lin2d L = LT.ThisSolution(k);            \n\
2070           // do something with L                     \n\
2071         }                                            \n\
2072   }                                                  \n\
2073                                                      \n";
2074     AddSeparator(Message);
2075     //--------------------------------------------------------------
2076
2077     DisplayPoint(aContext2D,P1,"P1",Standard_False,0.5,-1,0.1);
2078     DisplayPoint(aContext2D,P2,"P2",Standard_False,0.5,-0.7,0.1);
2079     DisplayPoint(aContext2D,P3,"P3",Standard_False,0.5,-0.5,0.1);
2080     DisplayPoint(aContext2D,P4,"P4",Standard_False,0.5,0,0.1);
2081         
2082     Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2083     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2084     aCurve->SetColorIndex(5);
2085     aContext2D->Display(aCurve);
2086
2087         if (LT.IsDone())
2088                 {
2089                   Standard_Integer NblocSol = LT.NbSolutions();
2090                   Standard_Integer k;
2091                   for(k=1; k<=NblocSol; k++)
2092                         {
2093                           gp_Lin2d L = LT.ThisSolution(k);
2094                           Handle(Geom2d_TrimmedCurve) alocLine = GCE2d_MakeSegment(L,-10,20);
2095                           Handle(ISession2D_Curve) alocCurve = new ISession2D_Curve(alocLine);
2096                           aContext2D->Display(alocCurve);
2097                         }
2098                 }
2099     Message += " C is Blue \n\n";
2100     Message += "LT.IsDone() = "; 
2101     if (LT.IsDone())  Message += "True \n"; else Message += "False \n";
2102     Message += "NbSol       = "; Message += TCollection_AsciiString(NbSol); Message += "\n";
2103 }
2104
2105 //===============================================================
2106 // Function name: gpTest31
2107 //===============================================================
2108  void SampleGeometryPackage::gpTest31(const Handle(ISession2D_InteractiveContext)& aContext2D,
2109                                      TCollection_AsciiString& Message) 
2110 {
2111   aContext2D->EraseAll();
2112 //==============================================================
2113                                                                               
2114 gp_Pnt2d P1 (9,6);                                                            
2115 gp_Pnt2d P2 (10,4);                                                           
2116 gp_Pnt2d P3 (6,7);                                                            
2117 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);                                      
2118 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);                                 
2119 gp_Pnt2d P4 (-2,7);                                                           
2120 gp_Pnt2d P5 (12,-3);                                                          
2121 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1);  
2122 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L);                              
2123 Standard_Real radius = 2;                                                     
2124 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion());                
2125 Standard_Real parsol,pararg;                                                  
2126 gp_Pnt2d tangentpoint1,tangentpoint2;                                         
2127 gp_Circ2d circ;                                                               
2128 if (TR.IsDone())                                                              
2129     {                                                                         
2130       Standard_Integer NbSol = TR.NbSolutions();                              
2131       for (Standard_Integer k=1; k<=NbSol; k++)                               
2132         {                                                                     
2133           circ = TR.ThisSolution(k);                                          
2134           // find the solution circle                                         
2135           TR.Tangency1(k,parsol,pararg,tangentpoint1);                        
2136           // find the first tangent point                                     
2137           TR.Tangency2(k,parsol,pararg,tangentpoint2);                        
2138           // find the second tangent point                                    
2139         }                                                                     
2140     }                                                                         
2141                                                                               
2142 //==============================================================
2143     Message = "\
2144                                                                               \n\
2145 gp_Pnt2d P1 (9,6);                                                            \n\
2146 gp_Pnt2d P2 (10,4);                                                           \n\
2147 gp_Pnt2d P3 (6,7);                                                            \n\
2148 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);                                      \n\
2149 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);                                 \n\
2150 gp_Pnt2d P4 (-2,7);                                                           \n\
2151 gp_Pnt2d P5 (12,-3);                                                          \n\
2152 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1);  \n\
2153 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L);                              \n\
2154 Standard_Real radius = 2;                                                     \n\
2155 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion());                \n\
2156 Standard_Real parsol,pararg;                                                  \n\
2157 gp_Pnt2d tangentpoint1,tangentpoint2;                                         \n\
2158 gp_Circ2d circ;                                                               \n\
2159 if (TR.IsDone())                                                              \n\
2160     {                                                                         \n\
2161       Standard_Integer NbSol = TR.NbSolutions();                              \n\
2162       for (Standard_Integer k=1; k<=NbSol; k++)                               \n\
2163         {                                                                     \n";
2164         Message += "\
2165           circ = TR.ThisSolution(k);                                          \n\
2166           // find the solution circle                                         \n\
2167           TR.Tangency1(k,parsol,pararg,tangentpoint1);                        \n\
2168           // find the first tangent point                                     \n\
2169           TR.Tangency2(k,parsol,pararg,tangentpoint2);                        \n\
2170           // find the second tangent point                                    \n\
2171         }                                                                     \n\
2172     }                                                                         \n\
2173                                                                               \n";
2174     AddSeparator(Message);
2175 //--------------------------------------------------------------
2176     DisplayPoint(aContext2D,P1,"P1",Standard_False,0.3);
2177     DisplayPoint(aContext2D,P2,"P2",Standard_False,0.3);
2178     DisplayPoint(aContext2D,P3,"P3",Standard_False,0.3);
2179     DisplayPoint(aContext2D,P4,"P4",Standard_False,0.3);
2180     DisplayPoint(aContext2D,P5,"P5",Standard_False,0.3);
2181
2182     Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2183     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2184     aCurve->SetColorIndex(3);
2185
2186     aContext2D->Display(aCurve);
2187     Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-2,20);
2188     Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(aLine);
2189     aCurve2->SetColorIndex(5);
2190     aContext2D->Display(aCurve2);
2191
2192         if (TR.IsDone())
2193                 {
2194                   Standard_Integer NblocSol = TR.NbSolutions();
2195                   Standard_Integer k;
2196                   for (k=1; k<=NblocSol; k++)
2197                         {
2198                           circ = TR.ThisSolution(k);
2199                           Handle(Geom2d_Circle) alocCircle = new Geom2d_Circle(circ);
2200                           Handle(ISession2D_Curve) alocCurve = new ISession2D_Curve(alocCircle);
2201                           aContext2D->Display(alocCurve);
2202
2203                           // find the solution circle
2204                           TR.Tangency1(k,parsol,pararg,tangentpoint1);
2205                           // find the first tangent point                                                                        
2206                           TR.Tangency2(k,parsol,pararg,tangentpoint2);
2207                           // find the second tangent point
2208                           DisplayPoint(aContext2D,tangentpoint1,"tangentpoint1",Standard_False,0.3);
2209                           DisplayPoint(aContext2D,tangentpoint2,"tangentpoint2",Standard_False,0.3);
2210                         }
2211                 }
2212     Message += "C is Red \n";
2213     Message += "L is Blue \n";
2214 }
2215
2216 //===============================================================
2217 // Function name: gpTest32
2218 //===============================================================
2219  void SampleGeometryPackage::gpTest32(const Handle(ISession2D_InteractiveContext)& aContext2D,
2220                                      TCollection_AsciiString& Message) 
2221 {
2222   aContext2D->EraseAll();
2223 //==============================================================
2224                                                                         
2225 Standard_Real major = 12;                                               
2226 Standard_Real minor = 4;                                                
2227 gp_Ax2d axis = gp::OX2d();                                              
2228 gp_Elips2d EE(axis,major,minor);;                                           
2229 Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,PI/4);  
2230                                                                         
2231 //==============================================================
2232     Message = " \
2233                                                                         \n\
2234 Standard_Real major = 12;                                               \n\
2235 Standard_Real minor = 4;                                                \n\
2236 gp_Ax2d axis = gp::OX2d();                                              \n\
2237 gp_Elips2d EE(axis,major,minor);                                        \n\
2238 Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,PI/4);  \n\
2239                                                                         \n";
2240     AddSeparator(Message);
2241     //--------------------------------------------------------------
2242     Handle(Geom2d_Curve) E = GCE2d_MakeEllipse(EE).Value();
2243     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
2244     aCurve->SetColorIndex(3);
2245     aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
2246     //SetWidthOfLine                 
2247     aContext2D->Display(aCurve);
2248     Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(arc);
2249     aContext2D->Display(aCurve2);
2250
2251     Message += " PI = ";Message+= TCollection_AsciiString(PI);
2252 }
2253
2254 //===============================================================
2255 // Function name: gpTest33
2256 //===============================================================
2257  void SampleGeometryPackage::gpTest33(const Handle(AIS_InteractiveContext)& aContext,
2258                                      TCollection_AsciiString& Message) 
2259 {
2260   aContext->EraseAll(Standard_False);
2261 //==============================================================
2262                                                                                         
2263 gp_Pnt P1(0,0,1);                                                                       
2264 gp_Pnt P2(1,2,2);                                                                       
2265 gp_Pnt P3(2,3,3);                                                                       
2266 gp_Pnt P4(4,3,4);                                                                       
2267 gp_Pnt P5(5,5,5);                                                                       
2268 TColgp_Array1OfPnt array (1,5); // sizing array                                         
2269 array.SetValue(1,P1);                                                                   
2270 array.SetValue(2,P2);                                                                   
2271 array.SetValue(3,P3);                                                                   
2272 array.SetValue(4,P4);                                                                   
2273 array.SetValue(5,P5);                                                                   
2274 Handle(TColgp_HArray1OfPnt) harray =                                                    
2275     new TColgp_HArray1OfPnt (1,5); // sizing harray                                     
2276 harray->SetValue(1,P1.Translated(gp_Vec(4,0,0)));                                       
2277 harray->SetValue(2,P2.Translated(gp_Vec(4,0,0)));                                       
2278 harray->SetValue(3,P3.Translated(gp_Vec(4,0,0)));                                       
2279 harray->SetValue(4,P4.Translated(gp_Vec(4,0,0)));                                       
2280 harray->SetValue(5,P5.Translated(gp_Vec(4,0,0)));                                       
2281 Handle(Geom_BSplineCurve) SPL1 =                                                        
2282     GeomAPI_PointsToBSpline(array).Curve();                                             
2283                                                                                         
2284 GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation());  
2285 anInterpolation.Perform();                                                              
2286                                                                                         
2287 Handle(Geom_BSplineCurve) SPL2;                                                         
2288 if (anInterpolation.IsDone())                                                           
2289        SPL2 = anInterpolation.Curve();                                                  
2290                                                                                         
2291 //==============================================================
2292     Message = " \
2293                                                                                         \n\
2294 gp_Pnt P1(0,0,1);                                                                       \n\
2295 gp_Pnt P2(1,2,2);                                                                       \n\
2296 gp_Pnt P3(2,3,3);                                                                       \n\
2297 gp_Pnt P4(4,3,4);                                                                       \n\
2298 gp_Pnt P5(5,5,5);                                                                       \n\
2299 TColgp_Array1OfPnt array (1,5); // sizing array                                         \n\
2300 array.SetValue(1,P1);                                                                   \n\
2301 array.SetValue(2,P2);                                                                   \n\
2302 array.SetValue(3,P3);                                                                   \n\
2303 array.SetValue(4,P4);                                                                   \n\
2304 array.SetValue(5,P5);                                                                   \n\
2305 Handle(TColgp_HArray1OfPnt) harray =                                                    \n\
2306     new TColgp_HArray1OfPnt (1,5); // sizing harray                                     \n\
2307 harray->SetValue(1,P1.Translated(gp_Vec(4,0,0)));                                       \n\
2308 harray->SetValue(2,P2.Translated(gp_Vec(4,0,0)));                                       \n\
2309 harray->SetValue(3,P3.Translated(gp_Vec(4,0,0)));                                       \n\
2310 harray->SetValue(4,P4.Translated(gp_Vec(4,0,0)));                                       \n\
2311 harray->SetValue(5,P5.Translated(gp_Vec(4,0,0)));                                       \n\
2312 Handle(Geom_BSplineCurve) SPL1 =                                                        \n\
2313     GeomAPI_PointsToBSpline(array).Curve();                                             \n";
2314     Message += "\
2315                                                                                         \n\
2316 GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation());  \n\
2317 anInterpolation.Perform();                                                              \n\
2318                                                                                         \n\
2319 Handle(Geom_BSplineCurve) SPL2;                                                         \n\
2320 if (anInterpolation.IsDone())                                                           \n\
2321        SPL2 = anInterpolation.Curve();                                                  \n\
2322 else                                                                                    \n\
2323    MessageBox(0,\"The Interpolation is Not done\",\"CasCade Warning\",MB_ICONWARNING);  \n\
2324                                                                                         \n";
2325     AddSeparator(Message);
2326     //--------------------------------------------------------------
2327     TCollection_AsciiString aString;
2328     for(Standard_Integer i = array.Lower();i<=array.Upper();i++){
2329                 gp_Pnt P = array(i);
2330         aString = "P";aString += TCollection_AsciiString(i); 
2331         if (i == 1) aString += " (array)  ";
2332         DisplayPoint(aContext,P,aString,Standard_False,0.5);\
2333         aString = "P";aString += TCollection_AsciiString(i); 
2334         if (i == 1) aString += " (harray)  ";
2335         DisplayPoint(aContext,P.Translated(gp_Vec(4,0,0)),aString,Standard_False,0.5);\
2336         
2337                 }
2338
2339     Handle(ISession_Curve) aCurve = new ISession_Curve(SPL1);
2340     aContext->SetDisplayMode(aCurve,1);
2341     aContext->Display(aCurve);
2342
2343     if (anInterpolation.IsDone()) {
2344         Handle(ISession_Curve) aCurve2 = new ISession_Curve(SPL2);
2345         aContext->SetDisplayMode(aCurve2,1);
2346         aContext->Display(aCurve2);
2347     }
2348 }
2349
2350 //===============================================================
2351 // Function name: gpTest34
2352 //===============================================================
2353  void SampleGeometryPackage::gpTest34(const Handle(AIS_InteractiveContext)& aContext,
2354                                      TCollection_AsciiString& Message) 
2355 {
2356   aContext->EraseAll(Standard_False);
2357 //==============================================================
2358                                                                  
2359 TColgp_Array1OfPnt array (1,5); // sizing array                  
2360 array.SetValue(1,gp_Pnt(0,0,1));                                 
2361 array.SetValue(2,gp_Pnt(1,2,2));                                 
2362 array.SetValue(3,gp_Pnt(2,3,3));                                 
2363 array.SetValue(4,gp_Pnt(4,4,4));                                 
2364 array.SetValue(5,gp_Pnt(5,5,5));                                 
2365                                                                  
2366 GProp_PEquation PE (array,1.5 );                                 
2367                                                                  
2368 if (PE.IsPoint()){ /* ... */  }     
2369 gp_Lin L;                                                        
2370 if (PE.IsLinear()) {  L = PE.Line();    }                      
2371 if (PE.IsPlanar()){ /* ... */  }     
2372 if (PE.IsSpace()) { /* ... */  }     
2373                                                                  
2374 //==============================================================
2375     Message = " \
2376                                                 \n\
2377 TColgp_Array1OfPnt array (1,5); // sizing array \n\
2378 array.SetValue(1,gp_Pnt(0,0,1));                \n\
2379 array.SetValue(2,gp_Pnt(1,2,2));                \n\
2380 array.SetValue(3,gp_Pnt(2,3,3));                \n\
2381 array.SetValue(4,gp_Pnt(4,4,4));                \n\
2382 array.SetValue(5,gp_Pnt(5,5,5));                \n\
2383                                                 \n\
2384 GProp_PEquation PE (array,1.5 );                \n\
2385                                                 \n\
2386 if (PE.IsPoint()){ /* ... */  }                 \n\
2387 gp_Lin L;                                       \n\
2388 if (PE.IsLinear()) {  L = PE.Line();    }       \n\
2389 if (PE.IsPlanar()){ /* ... */  }                \n\
2390 if (PE.IsSpace()) { /* ... */  }                \n\
2391                                                 \n";
2392     AddSeparator(Message);
2393     //--------------------------------------------------------------
2394     TCollection_AsciiString aString;
2395     for(Standard_Integer i = array.Lower();i<=array.Upper();i++){
2396                 gp_Pnt P = array(i);
2397         aString = "P";aString += TCollection_AsciiString(i); 
2398         DisplayPoint(aContext,P,aString,Standard_False,0.5);
2399                 }
2400
2401     Message += " PE.IsPoint()  = ";  if (PE.IsPoint()) Message += "True \n";  else Message += "False\n";
2402
2403         if (PE.IsLinear()) { 
2404          Message += " PE.IsLinear() = True \n";
2405          L = PE.Line();
2406          Handle(Geom_Line) aLine = new Geom_Line(L);
2407          Handle(Geom_TrimmedCurve) aTrimmedCurve = new Geom_TrimmedCurve(aLine,-10,10);
2408          Handle(ISession_Curve) aCurve = new ISession_Curve(aTrimmedCurve);
2409          aContext->Display(aCurve);
2410     }
2411     else
2412     Message += "PE.IsLinear() = False \n";
2413
2414     Message += " PE.IsPlanar() = ";  if (PE.IsPlanar()) Message += "True \n";  else Message += "False\n";
2415     Message += " PE.IsSpace() = ";   if (PE.IsSpace() ) Message += "True \n";  else Message += "False\n";
2416 }
2417
2418 //===============================================================
2419 // Function name: gpTest35
2420 //===============================================================
2421  void SampleGeometryPackage::gpTest35(const Handle(AIS_InteractiveContext)& aContext,
2422                                      TCollection_AsciiString& Message) 
2423 {
2424   aContext->EraseAll(Standard_False);
2425 //==============================================================
2426                                                             
2427 gp_Pnt P1(-5,-5,0);                                         
2428 gp_Pnt P2(9,9,9);                                          
2429 Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value();  
2430 gp_Pnt P3(3,0,0);                                           
2431 gp_Pnt P4(3,0,10);                                          
2432 Standard_Real radius1 = 3;                                  
2433 Standard_Real radius2 = 2;                                  
2434 Handle(Geom_Surface) aSurface =                             
2435     GC_MakeConicalSurface(P3,P4,radius1,radius2).Value();   
2436 GeomAPI_IntCS CS (aCurve,aSurface);                         
2437 Handle(Geom_Curve) segment;                                 
2438                                                             
2439 Standard_Integer NbSeg=0;                                     
2440 Standard_Integer NbPoints=0;                                  
2441 if(CS.IsDone())                                             
2442     {                                                       
2443       NbSeg = CS.NbSegments();
2444       Standard_Integer k;
2445       for (k=1; k<=NbSeg; k++)             
2446         {                                                   
2447           segment = CS.Segment(k);                          
2448          // do something with the segment                   
2449         }                                                   
2450                                                             
2451       NbPoints = CS.NbPoints();                             
2452       for (k=1; k<=NbPoints; k++)                           
2453         {                                                   
2454 //          gp_Pnt aPoint=
2455             CS.Point(k);                        
2456           // do something with the point                    
2457         }                                                   
2458     }                                                       
2459                                                             
2460 //==============================================================
2461     Message = " \
2462                                                             \n\
2463 gp_Pnt P1(-5,-5,0);                                         \n\
2464 gp_Pnt P2(9,9,9);                                           \n\
2465 Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value();  \n\
2466 gp_Pnt P3(3,0,0);                                           \n\
2467 gp_Pnt P4(3,0,10);                                          \n\
2468 Standard_Real radius1 = 3;                                  \n\
2469 Standard_Real radius2 = 2;                                  \n\
2470 Handle(Geom_Surface) aSurface =                             \n\
2471     GC_MakeConicalSurface(P3,P4,radius1,radius2).Value();   \n\
2472 GeomAPI_IntCS CS (aCurve,aSurface);                         \n\
2473 Handle(Geom_Curve) segment;                                 \n\
2474                                                             \n\
2475 Standard_Integer NbSeg;                                     \n\
2476 Standard_Integer NbPoints;                                  \n\
2477 if(CS.IsDone())                                             \n\
2478     {                                                       \n\
2479       NbSeg = CS.NbSegments();                              \n\
2480       for (Standard_Integer k=1; k<=NbSeg; k++)             \n\
2481         {                                                   \n\
2482           segment = CS.Segment(k);                          \n\
2483          // do something with the segment                   \n\
2484         }                                                   \n\
2485                                                             \n\
2486       NbPoints = CS.NbPoints();                             \n\
2487       for (k=1; k<=NbPoints; k++)                           \n\
2488         {                                                   \n\
2489           gp_Pnt aPoint=CS.Point(k);                        \n\
2490           // do something with the point                    \n\
2491         }                                                   \n\
2492     }                                                       \n\
2493                                                             \n";
2494     AddSeparator(Message);
2495     //--------------------------------------------------------------
2496  
2497     Handle(ISession_Curve) aCurve2 = new ISession_Curve(aCurve);
2498     aContext->Display(aCurve2);
2499
2500     Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface= new Geom_RectangularTrimmedSurface(aSurface,-50.,50.,Standard_False);
2501
2502     DisplaySurface(aContext,aTrimmedSurface);
2503
2504     TCollection_AsciiString aString;
2505     if(CS.IsDone())
2506                 {
2507                   Standard_Integer NblocSeg = CS.NbSegments();
2508                   Standard_Integer k;
2509                   for (k=1; k<=NblocSeg; k++)
2510                         {
2511                           segment = CS.Segment(k);
2512                           aString = "S_";aString += TCollection_AsciiString(k);
2513                           Handle(ISession_Curve) alocCurve = new ISession_Curve(segment);
2514                           aContext->Display(alocCurve);
2515                         }
2516         
2517                   for ( k=1; k<=NbPoints; k++)              
2518                     {                                                   
2519                       gp_Pnt aPoint=CS.Point(k);
2520                       aString = "P_";aString += TCollection_AsciiString(k); 
2521                       DisplayPoint(aContext,aPoint,aString,Standard_False,0.5);
2522                       // do something with the point            
2523                     }                                                  
2524                 }
2525
2526   Message += "NbSeg       = "; Message += TCollection_AsciiString(NbSeg); Message += "\n";
2527   Message += "NbPoints  = "; Message += TCollection_AsciiString(NbPoints); Message += "\n";
2528 }
2529
2530 //===============================================================
2531 // Function name: gpTest36
2532 //===============================================================
2533  void SampleGeometryPackage::gpTest36(const Handle(AIS_InteractiveContext)& aContext,
2534                                      TCollection_AsciiString& Message) 
2535 {
2536   aContext->EraseAll(Standard_False);
2537 //==============================================================
2538                                                                                     
2539 gp_Pnt centre (5,5,0);  gp_Pnt axispoint (9,9,0);                                   
2540 Standard_Real radius = 3;                                                           
2541 Handle(Geom_Circle) circle =                                                        
2542     GC_MakeCircle(centre,axispoint,radius);                                         
2543                                                                                     
2544 Handle(Geom_Geometry) aRotatedEntity  = circle->Rotated(gp::OZ(),PI/4);             
2545 Standard_CString aRotatedEntityTypeName = aRotatedEntity->DynamicType()->Name();        
2546                                                                                     
2547 Handle(Geom_Geometry) aMirroredEntity = aRotatedEntity->Mirrored(gp::ZOX());        
2548 Standard_CString aMirroredEntityTypeName = aMirroredEntity->DynamicType()->Name();      
2549                                                                                     
2550 gp_Pnt scalepoint (4,8,0);                                                          
2551 Standard_Real scalefactor = 0.2;                                                    
2552 Handle(Geom_Geometry) aScaledEntity =                                               
2553      aMirroredEntity->Scaled(scalepoint, scalefactor);                              
2554 Standard_CString aScaledEntityTypeName = aScaledEntity->DynamicType()->Name();          
2555                                                                                     
2556 Handle (Geom_Transformation) GT =   GC_MakeTranslation  (centre, scalepoint);       
2557 gp_Trsf TR = GT->Trsf();                                                            
2558                                                                                     
2559 gp_Vec aTranslationVector(TR.TranslationPart ());                                   
2560 Handle(Geom_Geometry) aTranslatedEntity =                                           
2561        aScaledEntity->Translated(  aTranslationVector  );                           
2562 Standard_CString aTranslatedEntityTypeName = aTranslatedEntity->DynamicType()->Name();  
2563                                                                                     
2564 gp_Mat matrix = TR.HVectorialPart();                                                
2565 Standard_Real value = matrix.Determinant();                                         
2566                                                                                     
2567 //==============================================================
2568     Message = " \
2569                                                                                         \n\
2570 gp_Pnt centre (5,5,0);  gp_Pnt axispoint (9,9,0);                                       \n\
2571 Standard_Real radius = 3;                                                               \n\
2572 Handle(Geom_Circle) circle =                                                            \n\