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