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