0c433bc1e2396babb7737747f2aac010f155a5e5
[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_Curve.hxx>
10 #include <Geom2d_Curve.hxx>
11 GeomSources::GeomSources()
12 {
13 }
14
15 GeomSources::~GeomSources()
16 {
17 }
18 void GeomSources::PreProcess(CGeometryDoc* aDoc,DisplayType aDisplayType)
19 {
20   if (aDisplayType == No2D3D )
21   {   
22     aDoc->GetAISContext()->EraseAll();
23     aDoc->Put3DOnTop(); 
24   }
25
26   if (aDisplayType == a2DNo3D)
27   { 
28     aDoc->GetISessionContext()->EraseAll();
29     aDoc->Put2DOnTop();
30   }
31
32   if (aDisplayType != No2D3D && aDisplayType != a2D3D)
33   {  
34     aDoc->Minimize3D();
35   }
36
37   if (aDisplayType != a2DNo3D && aDisplayType != a2D3D)
38   {  
39     aDoc->Minimize2D();
40   }
41
42   if (aDisplayType == a2D3D)
43   {
44     aDoc->GetAISContext()->EraseAll();
45     aDoc->GetISessionContext()->EraseAll();
46     aDoc->Put3DOnTop(false); 
47     aDoc->Put2DOnTop(false);
48
49     // both on top
50     // send the message Title Horizontaly to the child of doc main frame
51     CGeometryApp* TheAppli = (CGeometryApp*)AfxGetApp();
52     CMainFrame* TheMainFrame= (CMainFrame*)TheAppli->m_pMainWnd;
53     ::SendMessage(TheMainFrame->m_hWndMDIClient, WM_MDITILE, 0, 0);
54   }
55 }
56
57 void GeomSources::PostProcess (CGeometryDoc* aDoc, UINT anID, DisplayType aDisplayType,
58                                const TCollection_AsciiString& theString, Standard_Boolean UpdateViewer, Quantity_Coefficient Coef)
59 {
60   Standard_CString aString = theString.ToCString();
61   if (UpdateViewer)
62   {
63     if (aDisplayType == No2D3D || aDisplayType == a2D3D)
64     {
65       aDoc->Fit3DViews(Coef);
66     }
67
68     if (aDisplayType == a2DNo3D || aDisplayType == a2D3D)
69     {
70       aDoc->Fit2DViews();
71     }
72   }
73
74   TCollection_AsciiString Message("Results are ");
75
76   switch (aDisplayType)
77   {
78   case No2DNo3D: Message = "All results are in this box \n";
79     break;
80   case No2D3D:   Message += "only in 3D \n";
81     break;
82   case a2DNo3D:   Message += "only in 2d \n";
83     break;
84   case a2D3D:     Message += "in both 2D and 3D \n";
85     break;
86   }   
87   Message += "====================================\n";
88   Message += aString;
89
90   CString text(Message.ToCString());
91   aDoc->myCResultDialog.SetText(text);
92
93   CString s;
94   if (! s.LoadString( anID ))
95     AfxMessageBox (L"Error Loading String: ");
96
97   CString Title = s.Left( s.Find( '\n' ));
98
99   aDoc->myCResultDialog.SetTitle(Title);
100   aDoc->SetTitle(Title);
101 }
102
103 void GeomSources::AddSeparator(CGeometryDoc* /*aDoc*/,TCollection_AsciiString& aMessage)
104 {
105   aMessage+= "------------------------------------------------------------------------\n";
106 }
107 void GeomSources::DisplayPoint(CGeometryDoc* aDoc,
108                           const gp_Pnt2d& aPoint,
109                           const char* aText,
110                           Standard_Boolean UpdateViewer,
111                           Standard_Real anXoffset,
112                           Standard_Real anYoffset,
113                           Standard_Real TextScale)
114 {
115   Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint);
116   aDoc->GetISessionContext()->Display(aGraphicPoint,UpdateViewer);
117   Handle(ISession_Text)  aGraphicText = new ISession_Text(aText,aPoint.X()+anXoffset,aPoint.Y()+anYoffset);
118   aGraphicText->SetScale  (TextScale);
119   aDoc->GetISessionContext()->Display(aGraphicText,UpdateViewer);
120 }
121
122 void GeomSources::DisplayPoint(CGeometryDoc* aDoc,
123                           const gp_Pnt& aPoint,
124                           const char* aText,
125                           Standard_Boolean UpdateViewer,
126                           Standard_Real anXoffset,
127                           Standard_Real anYoffset,
128                           Standard_Real aZoffset,
129                           Standard_Real TextScale)
130 {
131   Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint);
132   aDoc->GetAISContext()->Display(aGraphicPoint,UpdateViewer);
133   Handle(ISession_Text)  aGraphicText = new ISession_Text(aText,aPoint.X()+anXoffset,aPoint.Y()+anYoffset,aPoint.Z()+aZoffset);
134   aGraphicText->SetScale  (TextScale);
135   aDoc->GetAISContext()->Display(aGraphicText,UpdateViewer);
136 }
137
138 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
139                           Handle(Geom2d_Curve) aCurve,
140                           Standard_Integer aColorIndex,
141                           Standard_Boolean UpdateViewer)
142 {
143   Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
144   aGraphicCurve->SetColorIndex(aColorIndex) ;
145   aDoc->GetISessionContext()->Display(aGraphicCurve,UpdateViewer);
146 }
147
148 void GeomSources::DisplayCurveAndCurvature(CGeometryDoc* aDoc,
149                           Handle(Geom2d_Curve) aCurve,
150                           Standard_Integer aColorIndex,
151                           Standard_Boolean UpdateViewer)
152 {
153   Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
154   aGraphicCurve->SetDisplayCurbure(Standard_True) ;
155   aGraphicCurve->SetDiscretisation(20);
156   aGraphicCurve->SetColorIndex(aColorIndex) ;
157   aDoc->GetISessionContext()->Display(aGraphicCurve,UpdateViewer);
158 }
159
160 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
161                           Handle(Geom_Curve) aCurve,
162                           Quantity_NameOfColor aNameOfColor, 
163                           Standard_Boolean UpdateViewer)
164 {
165   Handle(ISession_Curve) aGraphicCurve = new ISession_Curve(aCurve);
166   aDoc->GetAISContext()->SetColor(aGraphicCurve,aNameOfColor, Standard_False);
167   aGraphicCurve->Attributes()->LineAspect()->SetColor(aNameOfColor);
168   aDoc->GetAISContext()->Display(aGraphicCurve,UpdateViewer);
169 }
170
171 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
172                           Handle(Geom_Curve) aCurve,
173                           Standard_Boolean UpdateViewer)
174 {
175     Handle(ISession_Curve) aGraphicCurve = new ISession_Curve(aCurve);
176     aDoc->GetAISContext()->Display(aGraphicCurve,UpdateViewer);
177 }
178
179
180
181
182 void GeomSources::DisplaySurface(CGeometryDoc* aDoc,
183                           Handle(Geom_Surface) aSurface,
184                           Quantity_NameOfColor aNameOfColor, 
185                           Standard_Boolean UpdateViewer)
186 {
187   Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
188   aDoc->GetAISContext()->SetColor(aGraphicalSurface,aNameOfColor, Standard_False);
189   aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
190   aGraphicalSurface->Attributes()->UIsoAspect()->SetColor(aNameOfColor);
191   aGraphicalSurface->Attributes()->VIsoAspect()->SetColor(aNameOfColor);
192   aDoc->GetAISContext()->Display(aGraphicalSurface,UpdateViewer);
193 }
194
195 void GeomSources::DisplaySurface(CGeometryDoc* aDoc,
196                           Handle(Geom_Surface) aSurface,
197                           Standard_Boolean UpdateViewer)
198 {
199   Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
200   aDoc->GetAISContext()->Display(aGraphicalSurface,UpdateViewer);
201 }
202
203 void GeomSources::ResetView(CGeometryDoc* aDoc)
204 {
205   aDoc->GetAISContext()->CurrentViewer()->InitActiveViews();
206   Handle(V3d_View) aView = aDoc->GetAISContext()->CurrentViewer()->ActiveView();
207   aView->Reset();
208 }
209
210 // Function name        : GeomSources::gpTest1
211 // Description      : 
212 // Return type          : void 
213 // Argument         : CGeometryDoc* aDoc
214 void GeomSources::gpTest1(CGeometryDoc* aDoc)
215 {
216   DisplayType TheDisplayType = No2D3D;
217   PreProcess(aDoc,TheDisplayType);
218   //==============================================================
219
220   gp_XYZ A(1,2,3);                        
221   gp_XYZ B(2,2,2);                        
222   gp_XYZ C(3,2,3);                        
223   Standard_Real result = A.DotCross(B,C); 
224                                         
225 //==============================================================
226   TCollection_AsciiString Message ("\
227                                         \n\
228 gp_XYZ A(1,2,3);                        \n\
229 gp_XYZ B(2,2,2);                        \n\
230 gp_XYZ C(3,2,3);                        \n\
231 Standard_Real result = A.DotCross(B,C); \n\
232                                         \n");
233   AddSeparator(aDoc,Message);
234 //--------------------------------------------------------------
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   PostProcess(aDoc,ID_BUTTON_Test_1,TheDisplayType,Message);
246 }
247
248 // Function name        : GeomSources::gpTest2
249 // Description      : 
250 // Return type          : void 
251 // Argument         : CGeometryDoc* aDoc
252 void GeomSources::gpTest2(CGeometryDoc* aDoc)
253 {
254   DisplayType TheDisplayType = No2D3D;
255   PreProcess(aDoc,TheDisplayType);
256 //==============================================================
257                    
258   gp_Pnt P1(1,2,3);  
259                    
260 //==============================================================
261   TCollection_AsciiString Message ("\
262                   \n\
263 gp_Pnt P1(1,2,3); \n\
264                   \n");
265   AddSeparator(aDoc,Message);
266 //--------------------------------------------------------------
267   DisplayPoint(aDoc,P1,"P1 (1,2,3)",false,30);
268   PostProcess(aDoc,ID_BUTTON_Test_2,TheDisplayType,Message,Standard_False);
269   ResetView(aDoc);
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,30);
295   PostProcess(aDoc,ID_BUTTON_Test_3,TheDisplayType,Message,Standard_False);
296   ResetView(aDoc);
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,30);
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,Standard_False);
341   ResetView(aDoc);
342 }
343
344
345 // Function name        : GeomSources::gpTest5
346 // Description      : 
347 // Return type          : void 
348 // Argument         : CGeometryDoc* aDoc
349 void GeomSources::gpTest5(CGeometryDoc* aDoc)
350 {
351   DisplayType TheDisplayType = No2D3D;
352   PreProcess(aDoc,TheDisplayType);
353 //==============================================================
354                                
355   gp_Pnt P1(1,2,3);              
356   gp_Pnt P2(3,4,5);              
357   gp_Pnt PB = P1;                
358   Standard_Real alpha = 3;       
359   Standard_Real beta = 7;        
360   PB.BaryCenter(alpha,P2,beta);  
361                                
362 //==============================================================
363   TCollection_AsciiString Message ("\
364                                  \n\
365 gp_Pnt P1(1,2,3);                \n\
366 gp_Pnt P2(3,4,5);                \n\
367 gp_Pnt PB = P1;                  \n\
368 Standard_Real alpha = 3;         \n\
369 Standard_Real beta = 7;          \n\
370 PB.BaryCenter(alpha,P2,beta);    \n\
371                                  \n");
372
373   AddSeparator(aDoc,Message);
374 //--------------------------------------------------------------
375
376   DisplayPoint(aDoc,P1,"P1",false,0.2);
377   DisplayPoint(aDoc,P2,"P2",false,0.2);
378   DisplayPoint(aDoc,PB,"PB = barycenter ( 3 * P1 , 7 * P2) ",false,0.2);
379
380   TCollection_AsciiString Message2 (PB.X());
381   TCollection_AsciiString Message3 (PB.Y());
382   TCollection_AsciiString Message4 (PB.Z());
383
384   Message += " PB ( ";
385   Message += Message2; 
386   Message += " , ";
387   Message += Message3; 
388   Message += " , ";
389   Message += Message4; 
390   Message += " ); ";
391   PostProcess(aDoc,ID_BUTTON_Test_5,TheDisplayType,Message);
392 }
393
394
395 // Function name        : GeomSources::gpTest6
396 // Description      : 
397 // Return type          : void 
398 // Argument         : CGeometryDoc* aDoc
399 void GeomSources::gpTest6(CGeometryDoc* aDoc)
400 {
401   DisplayType TheDisplayType = No2D3D;
402   PreProcess(aDoc,TheDisplayType);
403 //==============================================================
404                                                                  
405 //  Compute a 3d point P as BaryCenter of an array of point
406   gp_Pnt P1(0,0,5);
407   gp_Pnt P2(1,2,3);
408   gp_Pnt P3(2,3,-2);
409   gp_Pnt P4(4,3,5);
410   gp_Pnt P5(5,5,4);                                                
411   TColgp_Array1OfPnt array (1,5); // sizing array                  
412   array.SetValue(1,P1);
413   array.SetValue(2,P2);
414   array.SetValue(3,P3);
415   array.SetValue(4,P4);
416   array.SetValue(5,P5);
417
418   Standard_Real Tolerance = 8; // ajout de la tolerance            
419   GProp_PEquation PE (array,Tolerance);
420
421   gp_Pnt P; // P declaration
422   Standard_Boolean IsPoint;
423
424   if (PE.IsPoint())
425   {
426     IsPoint = true;
427     P = PE .Point();
428   }
429   else 
430   { 
431     IsPoint = false;
432   }                     
433
434   if (PE.IsLinear()){ /*... */ }
435   if (PE.IsPlanar()){ /*... */ }
436   if (PE.IsSpace()) { /*... */ }
437                                                                  
438 //==============================================================
439   TCollection_AsciiString Message ("\
440                                                                  \n\
441                                                                  \n\
442 //  Compute a 3d point P as BaryCenter of an array of point      \n\
443 gp_Pnt P1(0,0,5);                                                \n\
444 gp_Pnt P2(1,2,3);                                                \n\
445 gp_Pnt P3(2,3,-2);                                               \n\
446 gp_Pnt P4(4,3,5);                                                \n\
447 gp_Pnt P5(5,5,4);                                                \n\
448 TColgp_Array1OfPnt array (1,5); // sizing array                  \n\
449 array.SetValue(1,P1);                                            \n\
450 array.SetValue(2,P2);                                            \n\
451 array.SetValue(3,P3);                                            \n\
452 array.SetValue(4,P4);                                            \n\
453 array.SetValue(5,P5);                                            \n\
454                                                                  \n\
455 Standard_Real Tolerance = 8; // ajout de la tolerance            \n\
456 GProp_PEquation PE (array,Tolerance);                            \n\
457                                                                  \n\
458 gp_Pnt P; // P declaration                                       \n\
459 Standard_Boolean IsPoint;                                        \n\
460 if (PE.IsPoint()){IsPoint = true;                                \n\
461                   P = PE .Point();}                              \n\
462                   else { IsPoint = false;  }                     \n\
463 if (PE.IsLinear()){ /*... */ }                                   \n\
464 if (PE.IsPlanar()){ /*... */ }                                   \n\
465 if (PE.IsSpace()) { /*... */ }                                   \n\
466                                                                  \n");
467   AddSeparator(aDoc,Message);
468     //--------------------------------------------------------------
469
470   TCollection_AsciiString PointName("P");
471     
472
473         for(Standard_Integer i= array.Lower();i <= array.Upper(); i++)
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   Message += " IsPoint = ";
486   if (IsPoint) 
487   {
488     Message += "True   -->  ";
489     Message += " P ( ";
490
491     Message += Message2; Message += " , ";
492     Message += Message3; Message += " , ";
493     Message += Message4; Message += " ); \n";
494         }  
495   else 
496     Message += "False\n";
497
498   Message += " IsLinear = ";  
499   if (PE.IsLinear()) 
500     Message += "True \n"; 
501   else
502     Message += "False\n";
503
504   Message += " IsPlanar = ";
505   if (PE.IsPlanar())
506     Message += "True \n";
507   else
508     Message += "False\n";
509
510   Message += " IsSpace = ";
511   if
512     (PE.IsSpace())
513     Message += "True \n";
514   else
515     Message += "False\n";
516
517     PostProcess(aDoc,ID_BUTTON_Test_6,TheDisplayType,Message);
518 }
519
520 // Function name        : GeomSources::gpTest7
521 // Description      : 
522 // Return type          : void 
523 // Argument         : CGeometryDoc* aDoc
524 void GeomSources::gpTest7(CGeometryDoc* aDoc)
525 {
526   DisplayType TheDisplayType = a2DNo3D;
527   PreProcess(aDoc,TheDisplayType);
528 //==============================================================
529                                            
530   gp_Pnt2d P1(0,5);                                       
531   gp_Pnt2d P2(5.5,1);                                     
532   gp_Pnt2d P3(-2,2);                                      
533
534   Handle(Geom2d_Curve) C =                         
535     GCE2d_MakeArcOfCircle (P1,P2,P3).Value();           
536
537   Standard_Real FirstParameter = C->FirstParameter();
538   Standard_Real LastParameter = C->LastParameter();
539   Standard_Real MiddleParameter = (FirstParameter+LastParameter)/2;
540   Standard_Real param = MiddleParameter; //in radians    
541
542   gp_Pnt2d P;                                             
543   gp_Vec2d V;                                             
544   C->D1(param,P,V);                          
545 // we recover point P and the vector V     
546                                            
547 //==============================================================
548   TCollection_AsciiString Message ("\
549                                                     \n\
550                                                     \n\
551 gp_Pnt2d P1(0,5);                                   \n\
552 gp_Pnt2d P2(5.5,1);                                 \n\
553 gp_Pnt2d P3(-2,2);                                  \n\
554                                                     \n\
555 Handle(Geom2d_TrimmedCurve) C =                     \n\
556     GCE2d_MakeArcOfCircle (P1,P2,P3).Value();       \n\
557                                                     \n\
558 Standard_Real FirstParameter = C->FirstParameter(); \n\
559 Standard_Real LastParameter = C->LastParameter();   \n\
560 Standard_Real MiddleParameter =                     \n\
561            (FirstParameter+LastParameter)/2;        \n\
562 Standard_Real param = MiddleParameter; //in radians \n\
563                                                     \n\
564 gp_Pnt2d P;                                         \n\
565 gp_Vec2d V;                                         \n\
566 C->D1(param,P,V);                                   \n\
567 // we recover point P and the vector V              \n\
568                                                     \n");
569   AddSeparator(aDoc,Message);
570   //--------------------------------------------------------------
571
572   DisplayCurve(aDoc,C);
573   Handle(ISession_Direction) aDirection = new ISession_Direction(P,V);
574   aDoc->GetISessionContext()->Display(aDirection, Standard_False);
575
576   DisplayPoint(aDoc,P,"P",false,0.5);
577
578   PostProcess(aDoc,ID_BUTTON_Test_7,TheDisplayType,Message);
579 }
580
581 // Function name        : GeomSources::gpTest8
582 // Description      : 
583 // Return type          : void 
584 // Argument         : CGeometryDoc* aDoc
585 void GeomSources::gpTest8(CGeometryDoc* aDoc)
586 {
587   DisplayType TheDisplayType = a2DNo3D;
588   PreProcess(aDoc,TheDisplayType);
589 //==============================================================
590                                                    
591   Standard_Real radius = 5;                          
592   Handle(Geom2d_Circle) C =                          
593     new Geom2d_Circle(gp::OX2d(),radius);          
594   Standard_Real param = 1.2*M_PI;                      
595   Geom2dLProp_CLProps2d CLP                          
596     (C,param,2,Precision::PConfusion());           
597   gp_Dir2d D;                                    
598   CLP.Tangent(D);                                    
599 // D is the Tangent direction at parameter 1.2*PI  
600                                                    
601 //==============================================================
602   TCollection_AsciiString Message (" \
603                                                    \n\
604 Standard_Real radius = 5;                          \n\
605 Handle(Geom2d_Circle) C =                          \n\
606     new Geom2d_Circle(gp::OX2d(),radius);          \n\
607 Standard_Real param = 1.2*PI;                      \n\
608 Geom2dLProp_CLProps2d CLP                          \n\
609     (C,param,2,Precision::PConfusion());           \n\
610     gp_Dir2d D;                                    \n\
611 CLP.Tangent(D);                                    \n\
612 // D is the Tangent direction at parameter 1.2*PI  \n\
613                                                    \n");
614   AddSeparator(aDoc,Message);
615   //--------------------------------------------------------------
616   Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
617   aDoc->GetISessionContext()->Display(aCurve,Standard_False);
618   Handle(ISession_Direction) aDirection = new ISession_Direction(gp_Pnt2d(0,0),D,2);
619   aDoc->GetISessionContext()->Display(aDirection,Standard_False);
620
621   TCollection_AsciiString Message2 (D.X());
622   TCollection_AsciiString Message3 (D.Y());
623
624   Message += " D ( ";
625   Message += Message2; Message += " , ";
626   Message += Message3; Message += " ); \n";
627
628   PostProcess(aDoc,ID_BUTTON_Test_8,TheDisplayType,Message);
629 }
630
631 // Function name        : GeomSources::gpTest9
632 // Description      : 
633 // Return type          : void 
634 // Argument         : CGeometryDoc* aDoc
635 void GeomSources::gpTest9(CGeometryDoc* aDoc)
636 {
637   DisplayType TheDisplayType = a2DNo3D;
638   PreProcess(aDoc,TheDisplayType);
639
640   //==============================================================
641                                                              
642   Standard_Real radius = 5;                                    
643   Handle(Geom2d_Circle) C =                                    
644     new Geom2d_Circle(gp::OX2d(),radius);                    
645   Geom2dAdaptor_Curve GAC (C);                                 
646   Standard_Real startparam = 10*M_PI/180;                                
647   Standard_Real abscissa = 45*M_PI/180;                                  
648   gp_Pnt2d P1;
649   C->D0(startparam,P1);                                                
650   // abscissa is the distance along the curve from startparam  
651   GCPnts_AbscissaPoint AP (GAC, abscissa, startparam);         
652   gp_Pnt2d P2;                                                  
653   if (AP.IsDone()){C->D0(AP.Parameter(),P2);}                   
654   // P is now correctly set                                    
655
656   //==============================================================
657   TCollection_AsciiString Message (" \n\
658                                                              \n\
659                                                              \n\
660 Standard_Real radius = 5;                                    \n\
661 Handle(Geom2d_Circle) C =                                    \n\
662     new Geom2d_Circle(gp::OX2d(),radius);                    \n\
663 Geom2dAdaptor_Curve GAC (C);                                 \n\
664 Standard_Real startparam = 10*PI180;                            \n\
665 Standard_Real abscissa = 45*PI180;                                 \n\
666 gp_Pnt2d P1;                                                 \n\
667 C->D0(startparam,P1);                                                \n\
668 // abscissa is the distance along the curve from startparam  \n\
669 GCPnts_AbscissaPoint AP (GAC, abscissa, startparam);         \n\
670 gp_Pnt2d P2;                                                  \n\
671 if (AP.IsDone()){C->D0(AP.Parameter(),P2);}                   \n\
672 // P is now correctly set                                    \n\
673                                                              \n\
674                                                              \n");
675   AddSeparator(aDoc,Message);
676   //--------------------------------------------------------------
677   Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
678   aDoc->GetISessionContext()->Display(aCurve,Standard_False);
679
680   DisplayPoint(aDoc,P1,"P1");
681   if (AP.IsDone())    DisplayPoint(aDoc,P2,"P2");
682
683   TCollection_AsciiString Message2 (P1.X());
684   TCollection_AsciiString Message3 (P1.Y());
685
686   TCollection_AsciiString Message4 (P2.X());
687   TCollection_AsciiString Message5 (P2.Y());
688
689   Message += " P1 ( ";
690   Message += Message2; Message += " , ";
691   Message += Message3; Message += " ); \n";
692
693   Message += " P2 ( ";
694   Message += Message4; Message += " , ";
695   Message += Message5; Message += " ); \n";
696   PostProcess(aDoc,ID_BUTTON_Test_9,TheDisplayType,Message);
697 }
698
699 // Function name        : GeomSources::gpTest10
700 // Description      : 
701 // Return type          : void 
702 // Argument         : CGeometryDoc* aDoc
703 void GeomSources::gpTest10(CGeometryDoc* aDoc)
704 {
705   DisplayType TheDisplayType = a2DNo3D;
706   PreProcess(aDoc,TheDisplayType);
707   //==============================================================
708                                                         
709   gp_Pnt2d P;
710   Standard_Real radius = 5;
711   Handle(Geom2d_Circle) C =
712     new Geom2d_Circle(gp::OX2d(),radius);
713   Geom2dAdaptor_Curve GAC (C);
714   Standard_Real abscissa = 3;
715   GCPnts_UniformAbscissa UA (GAC,abscissa);
716   TColgp_SequenceOfPnt2d aSequence;
717   if (UA.IsDone())
718   {                                                     
719     Standard_Real N = UA.NbPoints();
720     Standard_Integer count = 1;
721     for(;count<=N;count++)
722     {                                                  
723       C->D0(UA.Parameter(count),P);
724       //Standard_Real Parameter = UA.Parameter(count);
725       // append P in a Sequence
726       aSequence.Append(P);
727     }                                                   
728   }                                                       
729   Standard_Real Abscissa  = UA.Abscissa();                
730                                                         
731   //==============================================================
732   TCollection_AsciiString Message (" \
733                                                         \n\
734 gp_Pnt2d P;                                             \n\
735 Standard_Real radius = 5;                               \n\
736 Handle(Geom2d_Circle) C =                               \n\
737     new Geom2d_Circle(gp::OX2d(),radius);               \n\
738 Geom2dAdaptor_Curve GAC (C);                            \n\
739 Standard_Real abscissa = 3;                             \n\
740 GCPnts_UniformAbscissa UA (GAC,abscissa);               \n\
741 TColgp_SequenceOfPnt2d aSequence;                       \n\
742 if (UA.IsDone())                                        \n\
743   {                                                     \n\
744     Standard_Real N = UA.NbPoints();                    \n\
745     Standard_Integer count = 1;                         \n\
746     for(;count<=N;count++)                              \n\
747      {                                                  \n\
748         C->D0(UA.Parameter(count),P);                   \n\
749         Standard_Real Parameter = UA.Parameter(count);  \n\
750         // append P in a Sequence                       \n\
751         aSequence.Append(P);                            \n\
752     }                                                   \n\
753 }                                                       \n\
754 Standard_Real Abscissa  = UA.Abscissa();                \n\
755                                                         \n");
756   AddSeparator(aDoc,Message);
757   //--------------------------------------------------------------
758   Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
759   aDoc->GetISessionContext()->Display(aCurve,Standard_False);
760
761   TCollection_AsciiString aString;
762   for (Standard_Integer i=1;i<= aSequence.Length();i++)
763   {
764
765     TCollection_AsciiString Message2 (i);
766     TCollection_AsciiString Message3 (UA.Parameter(i));
767
768     aString = "P";
769     aString += Message2; 
770     aString +=": Parameter : "; 
771     aString += Message3;
772
773     //   First and Last texts are displayed with an Y offset, point 4 is upper
774     Standard_Real YOffset = -0.3;
775     YOffset +=  0.2 * ( i == 1 );
776     YOffset +=  0.4 * ( i == 4 );
777     YOffset += -0.2 * ( i == aSequence.Length() ); 
778
779     DisplayPoint(aDoc,aSequence(i),aString.ToCString(),false,0.5,YOffset,0.04);
780   }
781
782   TCollection_AsciiString Message3 (Abscissa);
783
784   Message += "Abscissa  = ";
785   Message += Message3;
786   Message += " \n";
787
788   PostProcess(aDoc,ID_BUTTON_Test_10,TheDisplayType,Message);
789 }
790
791 // Function name        : GeomSources::gpTest11
792 // Description      : 
793 // Return type          : void 
794 // Argument         : CGeometryDoc* aDoc
795 void GeomSources::gpTest11(CGeometryDoc* aDoc)
796 {
797   DisplayType TheDisplayType = No2D3D;
798   PreProcess(aDoc,TheDisplayType);
799   //==============================================================
800                  
801   Standard_Real radius = 5;
802   Handle(Geom_SphericalSurface) SP =
803     new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);
804   Standard_Real u = 2;
805   Standard_Real v = 3;
806   gp_Pnt P = SP->Value(u,v);                
807                        
808 //==============================================================
809     TCollection_AsciiString Message (" \
810                                                           \n\
811 Standard_Real radius = 5;                                 \n\
812 Handle(Geom_SphericalSurface) SP =                        \n\
813     new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);  \n\
814 Standard_Real u = 2;                                      \n\
815 Standard_Real v = 3;                                      \n\
816 gp_Pnt P = SP->Value(u,v);                                \n\
817                                                           \n");
818   AddSeparator(aDoc,Message);
819   //--------------------------------------------------------------
820
821   DisplaySurface(aDoc,SP);
822   DisplayPoint(aDoc,P,"P",false,0.5);
823   TCollection_AsciiString Message2 (P.X());
824   TCollection_AsciiString Message3 (P.Y());
825         
826   Message += " P ( ";
827   Message += Message2; 
828   Message += " , ";
829   Message += Message3; 
830   Message += " ); \n";
831
832   PostProcess(aDoc,ID_BUTTON_Test_11,TheDisplayType,Message);
833 }
834
835 // Function name        : GeomSources::gpTest12
836 // Description      : 
837 // Return type          : void 
838 // Argument         : CGeometryDoc* aDoc
839 void GeomSources::gpTest12(CGeometryDoc* aDoc)
840 {
841   DisplayType TheDisplayType = No2D3D;
842   PreProcess(aDoc,TheDisplayType);
843   //==============================================================
844
845   gp_Pnt N,Q,P(1,2,3);
846   Standard_Real distance, radius = 5;
847   Handle(Geom_Curve) C = new Geom_Circle(gp::XOY(),radius);
848   GeomAPI_ProjectPointOnCurve PPC (P,C);
849   N = PPC.NearestPoint();
850   Standard_Integer NbResults = PPC.NbPoints();
851
852   if(NbResults>0)
853   {
854     for(Standard_Integer i = 1;i<=NbResults;i++)
855     {
856       Q = PPC.Point(i);
857       distance = PPC.Distance(i);
858       // do something with Q or distance here
859     }
860   }                                                          
861
862   //==============================================================
863   TCollection_AsciiString Message (" \
864                                                             \n\
865 gp_Pnt N,Q,P(1,2,3);                                        \n\
866 Standard_Real distance, radius = 5;                         \n\
867 Handle(Geom_Circle) C = new Geom_Circle(gp::XOY(),radius);  \n\
868 GeomAPI_ProjectPointOnCurve PPC (P,C);                      \n\
869 N = PPC.NearestPoint();                                     \n\
870 Standard_Integer NbResults = PPC.NbPoints();                \n\
871                                                             \n\
872 if(NbResults>0){                                            \n\
873     for(Standard_Integer i = 1;i<=NbResults;i++){           \n\
874       Q = PPC.Point(i);                                     \n\
875       distance = PPC.Distance(i);                           \n\
876         // do something with Q or distance here             \n\
877       }                                                     \n\
878  }                                                          \n\
879                                                             \n");
880     AddSeparator(aDoc,Message);
881 //--------------------------------------------------------------
882
883   TCollection_AsciiString aString;
884
885   DisplayPoint(aDoc,P,"P",false,0.5);
886
887   TCollection_AsciiString Message2 (PPC.LowerDistance());
888
889   aString = "N : at Distance : "; 
890   aString += Message2;
891
892   DisplayPoint(aDoc,N,aString.ToCString(),false,0.5,0,-0.5);
893   DisplayCurve(aDoc,C,Quantity_NOC_YELLOW,false);
894
895   if(NbResults>0)
896   {
897     for(Standard_Integer i = 1;i<=NbResults;i++)
898     {
899       Q = PPC.Point(i);
900       distance = PPC.Distance(i);       
901       TCollection_AsciiString Message3 (i);
902       TCollection_AsciiString Message4 (distance);
903
904       aString = "Q";
905       aString += Message3; 
906       aString +=": at Distance : "; 
907       aString += Message4;
908       DisplayPoint(aDoc,Q,aString.ToCString(),false,0.5);
909     }
910   }
911
912   PostProcess(aDoc,ID_BUTTON_Test_12,TheDisplayType,Message);
913 }
914
915 // Function name        : GeomSources::gpTest13
916 // Description      : 
917 // Return type          : void 
918 // Argument         : CGeometryDoc* aDoc
919 void GeomSources::gpTest13(CGeometryDoc* aDoc)
920 {
921   DisplayType TheDisplayType = No2D3D;
922   PreProcess(aDoc,TheDisplayType);
923
924   //==============================================================
925         
926   gp_Pnt N,Q,P(7,8,9);
927   Standard_Real distance, radius = 5;
928   Handle(Geom_SphericalSurface) SP =
929     new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);
930   GeomAPI_ProjectPointOnSurf PPS(P,SP);
931   N = PPS.NearestPoint();
932   Standard_Integer NbResults = PPS.NbPoints();
933   if(NbResults>0)
934   {
935     for(Standard_Integer i = 1;i<=NbResults;i++)
936     {
937       Q = PPS.Point(i);
938       distance = PPS.Distance(i);
939       // do something with Q or distance here
940     }
941   }                                                         
942                                                           
943   //==============================================================
944     TCollection_AsciiString Message (" \
945                                                           \n\
946 gp_Pnt N,Q,P(7,8,9);                                      \n\
947 Standard_Real distance, radius = 5;                       \n\
948 Handle(Geom_SphericalSurface) SP =                        \n\
949     new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);  \n\
950 GeomAPI_ProjectPointOnSurf PPS(P,SP);                     \n\
951 N = PPS.NearestPoint();                                   \n\
952 Standard_Integer NbResults = PPS.NbPoints();              \n\
953 if(NbResults>0){                                          \n\
954     for(Standard_Integer i = 1;i<=NbResults;i++){         \n\
955     Q = PPS.Point(i);                                     \n\
956     distance = PPS.Distance(i);                           \n\
957     // do something with Q or distance here               \n\
958     }                                                     \n\
959 }                                                         \n\
960                                                           \n");
961  AddSeparator(aDoc,Message);
962  //--------------------------------------------------------------
963  TCollection_AsciiString aString;
964
965  DisplayPoint(aDoc,P,"P",false,0.5);
966  TCollection_AsciiString Message2 (PPS.LowerDistance());
967
968  aString = "N  : at Distance : "; aString += Message2;
969  DisplayPoint(aDoc,N,aString.ToCString(),false,0.5,0,-0.6);
970
971  Handle(ISession_Surface) aSurface = new ISession_Surface(SP);
972  Handle(Prs3d_Drawer) CurDrawer = aSurface->Attributes();
973  CurDrawer->UIsoAspect()->SetNumber(10);
974  CurDrawer->VIsoAspect()->SetNumber(10);
975  aDoc->GetAISContext()->SetLocalAttributes(aSurface, CurDrawer);
976  aDoc->GetAISContext()->Display(aSurface, Standard_False);
977
978  if(NbResults>0)
979  {
980    for(Standard_Integer i = 1;i<=NbResults;i++)
981    {
982
983      Q = PPS.Point(i);
984      distance = PPS.Distance(i);        
985      TCollection_AsciiString Message3 (i);
986      TCollection_AsciiString Message4 (distance);
987
988      aString = "Q";
989      aString += Message3; 
990      aString +=": at Distance : "; 
991      aString += Message4;
992
993      DisplayPoint(aDoc,Q,aString.ToCString(),false,0.5);                        
994    }
995  }
996  PostProcess(aDoc,ID_BUTTON_Test_13,TheDisplayType,Message);
997 }
998
999 // Function name        : GeomSources::gpTest14
1000 // Description      : 
1001 // Return type          : void 
1002 // Argument         : CGeometryDoc* aDoc
1003 void GeomSources::gpTest14(CGeometryDoc* aDoc)
1004 {
1005   DisplayType TheDisplayType = No2D3D;
1006   PreProcess(aDoc,TheDisplayType);
1007   //==============================================================
1008                                                           
1009   gp_Pnt P; 
1010   gp_Ax3 theAxe(gp::XOY());
1011   gp_Pln PL(theAxe);                            
1012   Standard_Real MinorRadius = 5;                            
1013   Standard_Real MajorRadius = 8;                            
1014   gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius);          
1015   IntAna_IntConicQuad ICQ                                   
1016     (EL,PL,Precision::Angular(),Precision::Confusion());  
1017   if (ICQ.IsDone()){                                        
1018     Standard_Integer NbResults = ICQ.NbPoints();          
1019     if (NbResults>0){                                     
1020       for(Standard_Integer i = 1;i<=NbResults;i++){         
1021         P = ICQ.Point(i);                                 
1022         // do something with P here                       
1023       }                                                 
1024     }                                                      
1025   }                                                         
1026                                                           
1027   //==============================================================
1028   TCollection_AsciiString Message (" \
1029                                                           \n\
1030 gp_Pnt P;                                                 \n\
1031 gp_Pln PL (gp_Ax3(gp::XOY()));                            \n\
1032 Standard_Real MinorRadius = 5;                            \n\
1033 Standard_Real MajorRadius = 8;                            \n\
1034 gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius);          \n\
1035 IntAna_IntConicQuad ICQ                                   \n\
1036     (EL,PL,Precision::Angular(),Precision::Confusion());  \n\
1037 if (ICQ.IsDone()){                                        \n\
1038     Standard_Integer NbResults = ICQ.NbPoints();          \n\
1039     if (NbResults>0){                                     \n\
1040     for(Standard_Integer i = 1;i<=NbResults;i++){         \n\
1041         P = ICQ.Point(i);                                 \n\
1042         // do something with P here                       \n\
1043         }                                                 \n\
1044    }                                                      \n\
1045 }                                                         \n\
1046                                                           \n");
1047  AddSeparator(aDoc,Message);
1048  //--------------------------------------------------------------
1049
1050  Handle(Geom_Plane) aPlane = GC_MakePlane(PL).Value();
1051  Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);
1052
1053  DisplaySurface(aDoc,aSurface);
1054
1055  Handle(Geom_Curve) anEllips = GC_MakeEllipse(EL).Value();
1056  DisplayCurve(aDoc,anEllips,Quantity_NOC_YELLOW,false);
1057
1058  TCollection_AsciiString aString;
1059
1060  if (ICQ.IsDone())
1061  {
1062    Standard_Integer NbResults = ICQ.NbPoints();
1063    if (NbResults>0)
1064    {
1065      for(Standard_Integer i = 1;i<=NbResults;i++)
1066      {
1067
1068        TCollection_AsciiString Message2(i);
1069
1070        P = ICQ.Point(i);
1071        aString = "P";aString += Message2; 
1072        DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1073      }
1074    }
1075  }
1076
1077  PostProcess(aDoc,ID_BUTTON_Test_14,TheDisplayType,Message);
1078 }
1079
1080 // Function name        : GeomSources::gpTest15
1081 // Description      : 
1082 // Return type          : void 
1083 // Argument         : CGeometryDoc* aDoc
1084 void GeomSources::gpTest15(CGeometryDoc* aDoc)
1085 {
1086   DisplayType TheDisplayType = No2D3D;
1087   PreProcess(aDoc,TheDisplayType);
1088   //==============================================================
1089  
1090   gp_Pnt P1(1,2,3);    
1091   gp_Pnt P1Copy = P1;  
1092   gp_Pnt P2(5,4,6);    
1093   gp_Trsf TRSF;        
1094   TRSF.SetMirror(P2);  
1095   P1Copy.Transform(TRSF);  
1096
1097   //==============================================================
1098     TCollection_AsciiString Message (" \
1099                          \n\
1100 gp_Pnt P1(1,2,3);        \n\
1101 gp_Pnt P1Copy = P1;      \n\
1102 gp_Pnt P2(5,4,6);        \n\
1103 gp_Trsf TRSF;            \n\
1104 TRSF.SetMirror(P2);      \n\
1105 P1Copy.Transform(TRSF);  \n\
1106                          \n");
1107  AddSeparator(aDoc,Message);
1108  //--------------------------------------------------------------
1109
1110  DisplayPoint(aDoc,P1Copy,"P1Copy",false,0.5);
1111  DisplayPoint(aDoc,P1,"P1",false,0.5);
1112  DisplayPoint(aDoc,P2,"P2",false,0.5);
1113
1114  PostProcess(aDoc,ID_BUTTON_Test_15,TheDisplayType,Message);
1115 }
1116
1117 // Function name        : GeomSources::gpTest16
1118 // Description      : 
1119 // Return type          : void 
1120 // Argument         : CGeometryDoc* aDoc
1121 void GeomSources::gpTest16(CGeometryDoc* aDoc)
1122 {
1123   DisplayType TheDisplayType = No2D3D;
1124   PreProcess(aDoc,TheDisplayType);
1125 //==============================================================
1126                                          
1127   gp_Pnt P1(1,2,3);                        
1128   gp_Pnt P2(5,4,6);                        
1129   gp_Vec V1 (P1,P2);                       
1130
1131   gp_Pnt P3(10,4,7);                       
1132   gp_Pnt P4(2,0,1);                        
1133   gp_Vec V2 (P3,P4);                       
1134
1135   Standard_Boolean result =                
1136     V1.IsOpposite(V2,Precision::Angular());  
1137   // result should be true                 
1138                                          
1139 //==============================================================
1140   TCollection_AsciiString Message (" \
1141                                          \n\
1142 gp_Pnt P1(1,2,3);                        \n\
1143 gp_Pnt P2(5,4,6);                        \n\
1144 gp_Vec V1 (P1,P2);                       \n\
1145                                          \n\
1146 gp_Pnt P3(10,4,7);                       \n\
1147 gp_Pnt P4(2,0,1);                        \n\
1148 gp_Vec V2 (P3,P4);                       \n\
1149                                          \n\
1150 Standard_Boolean result =                \n\
1151 V1.IsOpposite(V2,Precision::Angular());  \n\
1152 // result should be true                 \n\
1153                                          \n");
1154  AddSeparator(aDoc,Message);
1155  //--------------------------------------------------------------
1156
1157  DisplayPoint(aDoc,P1,"P1",false,0.5);
1158  DisplayPoint(aDoc,P2,"P2",false,0.5);
1159  DisplayPoint(aDoc,P3,"P3",false,0.5);
1160  DisplayPoint(aDoc,P4,"P4",false,0.5);
1161
1162  Handle(ISession_Direction) aDirection1 = new ISession_Direction(P1,V1);
1163  aDoc->GetAISContext()->Display(aDirection1, Standard_False);
1164
1165  Handle(ISession_Direction) aDirection2 = new ISession_Direction(P3,V2);
1166  aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1167
1168  Message += "result = ";
1169  if (result) Message += "True \n"; else Message += "False \n";
1170
1171  PostProcess(aDoc,ID_BUTTON_Test_16,TheDisplayType,Message);
1172 }
1173
1174 // Function name        : GeomSources::gpTest17
1175 // Description      : 
1176 // Return type          : void 
1177 // Argument         : CGeometryDoc* aDoc
1178 void GeomSources::gpTest17(CGeometryDoc* aDoc)
1179 {
1180   DisplayType TheDisplayType = No2D3D;
1181   PreProcess(aDoc,TheDisplayType);
1182   //==============================================================
1183
1184   gp_Dir D1(1,2,3);
1185   gp_Dir D2(3,4,5);
1186   Standard_Real ang = D1.Angle(D2);
1187   // the result is in radians in the range [0,PI]  
1188                                                  
1189   //==============================================================
1190   TCollection_AsciiString Message (" \
1191                                                  \n\
1192 gp_Dir D1(1,2,3);                                \n\
1193 gp_Dir D2(3,4,5);                                \n\
1194 Standard_Real ang = D1.Angle(D2);                \n\
1195 // the result is in radians in the range [0,PI]  \n\
1196                                                  \n");
1197   AddSeparator(aDoc,Message);
1198   //--------------------------------------------------------------
1199
1200   Handle(ISession_Direction) aDirection1 = new ISession_Direction(gp_Pnt(0,0,0),D1,3);
1201   aDoc->GetAISContext()->Display(aDirection1, Standard_False);
1202
1203   Handle(ISession_Direction) aDirection2 = new ISession_Direction(gp_Pnt(0,0,0),D2,3);
1204   aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1205
1206   cout<<" D1.Angle(D2) : "<<ang<<endl;
1207
1208   TCollection_AsciiString Message2 (ang);
1209   TCollection_AsciiString Message3 (ang/M_PI/180);
1210
1211   Message += " ang =  "; 
1212   Message += Message2; 
1213   Message += "   radian \n";
1214   Message += " ang/PI180 =  "; 
1215   Message += Message3; 
1216   Message += "   degree \n";
1217
1218   PostProcess(aDoc,ID_BUTTON_Test_17,TheDisplayType,Message);
1219 }
1220
1221 // Function name        : GeomSources::gpTest18
1222 // Description      : 
1223 // Return type          : void 
1224 // Argument         : CGeometryDoc* aDoc
1225 void GeomSources::gpTest18(CGeometryDoc* aDoc)
1226 {
1227   DisplayType TheDisplayType = a2DNo3D;
1228   PreProcess(aDoc,TheDisplayType);
1229   //==============================================================
1230
1231   gp_Pnt2d P(2,3);
1232   gp_Dir2d D(4,5);
1233   gp_Ax22d A(P,D);
1234   gp_Parab2d Para(A,6);
1235   // P is the vertex point                  
1236   // P and D give the axis of symmetry      
1237   // 6 is the focal length of the parabola
1238
1239   //==============================================================
1240   TCollection_AsciiString Message (" \
1241                                           \n\
1242 gp_Pnt2d P(2,3);                          \n\
1243 gp_Dir2d D(4,5);                          \n\
1244 gp_Ax22d A(P,D);                          \n\
1245 gp_Parab2d Para(A,6);                     \n\
1246 // P is the vertex point                  \n\
1247 // P and D give the axis of symmetry      \n\
1248 // 6 is the focal length of the parabola  \n\
1249                                           \n");
1250   AddSeparator(aDoc,Message);
1251   //--------------------------------------------------------------
1252
1253   DisplayPoint(aDoc,P,"P",false,0.5,0,3);
1254
1255   Handle(ISession_Direction) aDirection = new ISession_Direction(P,D,200);
1256   aDoc->GetISessionContext()->Display(aDirection,Standard_False);
1257   Handle(Geom2d_Parabola) aParabola = GCE2d_MakeParabola(Para);
1258   Handle(Geom2d_TrimmedCurve) aTrimmedCurve = new Geom2d_TrimmedCurve(aParabola,-100,100);
1259   Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aTrimmedCurve);
1260   //aCurve->SetColorIndex(3);
1261   aDoc->GetISessionContext()->Display(aCurve, Standard_False);  
1262
1263   Message += " The entity A of type gp_Ax22d is not displayable \n ";
1264   Message += " The entity D of type gp_Dir2d is displayed as a vector \n    ( mean with a length != 1 ) \n ";
1265   PostProcess(aDoc,ID_BUTTON_Test_18,TheDisplayType,Message);
1266 }
1267
1268 // Function name        : GeomSources::gpTest19
1269 // Description      : 
1270 // Return type          : void 
1271 // Argument         : CGeometryDoc* aDoc
1272 void GeomSources::gpTest19(CGeometryDoc* aDoc)
1273 {
1274   DisplayType TheDisplayType = No2D3D;
1275   PreProcess(aDoc,TheDisplayType);
1276   //==============================================================
1277   
1278   gp_Pnt P1(2,3,4);                           
1279   gp_Dir D(4,5,6);                            
1280   gp_Ax3 A(P1,D);                              
1281   Standard_Boolean IsDirectA = A.Direct();    
1282
1283   gp_Dir AXDirection = A.XDirection() ;       
1284   gp_Dir AYDirection = A.YDirection() ;       
1285
1286   gp_Pnt P2(5,3,4);                           
1287   gp_Ax3 A2(P2,D);                            
1288   A2.YReverse();                              
1289   // axis3 is now left handed                 
1290   Standard_Boolean IsDirectA2 = A2.Direct();  
1291               
1292   gp_Dir A2XDirection = A2.XDirection() ;
1293   gp_Dir A2YDirection = A2.YDirection() ;
1294
1295   //==============================================================
1296   TCollection_AsciiString Message (" \
1297                                             \n\
1298 gp_Pnt P1(2,3,4);                           \n\
1299 gp_Dir D(4,5,6);                            \n\
1300 gp_Ax3 A(P,D);                              \n\
1301 Standard_Boolean IsDirectA = A.Direct();    \n\
1302                                             \n\
1303 gp_Dir AXDirection = A.XDirection() ;       \n\
1304 gp_Dir AYDirection = A.YDirection() ;       \n\
1305                                             \n\
1306 gp_Pnt P2(5,3,4);                           \n\
1307 gp_Ax3 A2(P2,D);                            \n\
1308 A2.YReverse();                              \n\
1309 // axis3 is now left handed                 \n\
1310 Standard_Boolean IsDirectA2 = A2.Direct();  \n\
1311                                             \n\
1312 gp_Dir A2XDirection = A2.XDirection() ;     \n\
1313 gp_Dir A2YDirection = A2.YDirection() ;     \n\
1314                                             \n");
1315  AddSeparator(aDoc,Message);
1316  //--------------------------------------------------------------
1317
1318  // Set style for vector lines
1319  Handle(Prs3d_LineAspect) anAxesAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
1320
1321  DisplayPoint(aDoc,P1,"P1",false,0.1);
1322  Handle(ISession_Direction) aDirection = new ISession_Direction(P1,D,2);
1323  aDoc->GetAISContext()->Display(aDirection, Standard_False);
1324
1325  Handle(ISession_Direction) aDirection2 = new ISession_Direction(P1,AXDirection,2);
1326  aDirection2->SetText("A.XDirection");
1327  aDirection2->SetLineAspect (anAxesAspect);
1328  aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1329  Handle(ISession_Direction) aDirection3 = new ISession_Direction(P1,AYDirection,2);
1330  aDirection3->SetText("A.YDirection");
1331  aDirection3->SetLineAspect (anAxesAspect);
1332  aDoc->GetAISContext()->Display(aDirection3, Standard_False);
1333
1334  DisplayPoint(aDoc,P2,"P2",false,0.1);
1335  Handle(ISession_Direction) aDirection4 = new ISession_Direction(P2,D,2);
1336  aDoc->GetAISContext()->Display(aDirection4, Standard_False);
1337
1338  Handle(ISession_Direction) aDirection5 = new ISession_Direction(P2,A2XDirection,2);
1339  aDirection5->SetText("A2 XDirection");
1340  aDirection5->SetLineAspect (anAxesAspect);
1341  aDoc->GetAISContext()->Display(aDirection5, Standard_False);
1342  Handle(ISession_Direction) aDirection6 = new ISession_Direction(P2,A2YDirection,2);
1343  aDirection6->SetText("A2 YDirection");
1344  aDirection6->SetLineAspect (anAxesAspect);
1345  aDoc->GetAISContext()->Display(aDirection6, Standard_False);
1346
1347  Message += "IsDirectA = ";
1348  if(IsDirectA)
1349    Message += "True = Right Handed \n";
1350  else
1351    Message += "False = Left Handed \n";
1352
1353  Message += "IsDirectA2 = ";
1354  if(IsDirectA2)
1355    Message += "True = Right Handed \n";
1356  else
1357    Message += "False = Left Handed  \n";
1358
1359  PostProcess(aDoc,ID_BUTTON_Test_19,TheDisplayType,Message);
1360 }
1361
1362 // Function name        : GeomSources::gpTest20
1363 // Description      : 
1364 // Return type          : void 
1365 // Argument         : CGeometryDoc* aDoc
1366 void GeomSources::gpTest20(CGeometryDoc* aDoc)
1367 {
1368   DisplayType TheDisplayType = a2DNo3D;
1369   PreProcess(aDoc,TheDisplayType);
1370   //==============================================================
1371
1372   TColgp_Array1OfPnt2d array (1,5); // sizing array                    
1373   array.SetValue(1,gp_Pnt2d (0,0));
1374   array.SetValue(2,gp_Pnt2d (1,2));
1375   array.SetValue(3,gp_Pnt2d (2,3));
1376   array.SetValue(4,gp_Pnt2d (4,3));
1377   array.SetValue(5,gp_Pnt2d (5,5));
1378   Handle(Geom2d_BSplineCurve) SPL1 =
1379     Geom2dAPI_PointsToBSpline(array);
1380                                                                      
1381   Handle(TColgp_HArray1OfPnt2d) harray =
1382     new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1383   harray->SetValue(1,gp_Pnt2d (7+ 0,0));
1384   harray->SetValue(2,gp_Pnt2d (7+ 1,2));
1385   harray->SetValue(3,gp_Pnt2d (7+ 2,3));
1386   harray->SetValue(4,gp_Pnt2d (7+ 4,3));
1387   harray->SetValue(5,gp_Pnt2d (7+ 5,5));
1388   Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);
1389   anInterpolation.Perform();
1390   Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();
1391
1392   Handle(TColgp_HArray1OfPnt2d) harray2 =
1393     new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1394   harray2->SetValue(1,gp_Pnt2d (11+ 0,0));
1395   harray2->SetValue(2,gp_Pnt2d (11+ 1,2));
1396   harray2->SetValue(3,gp_Pnt2d (11+ 2,3));
1397   harray2->SetValue(4,gp_Pnt2d (11+ 4,3));
1398   harray2->SetValue(5,gp_Pnt2d (11+ 5,5));
1399   Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01);
1400   anInterpolation2.Perform();
1401   Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve();
1402   // redefined C++ operator allows these assignments
1403  
1404   //==============================================================
1405   TCollection_AsciiString Message (" \
1406                                                                      \n\
1407 TColgp_Array1OfPnt2d array (1,5); // sizing array                    \n\
1408 array.SetValue(1,gp_Pnt2d (0,0));                                    \n\
1409 array.SetValue(2,gp_Pnt2d (1,2));                                    \n\
1410 array.SetValue(3,gp_Pnt2d (2,3));                                    \n\
1411 array.SetValue(4,gp_Pnt2d (4,3));                                    \n\
1412 array.SetValue(5,gp_Pnt2d (5,5));                                    \n\
1413 Handle(Geom2d_BSplineCurve) SPL1 =                                   \n\
1414     Geom2dAPI_PointsToBSpline(array);                                \n\
1415                                                                      \n\
1416 Handle(TColgp_HArray1OfPnt2d) harray =                               \n\
1417     new TColgp_HArray1OfPnt2d (1,5); // sizing harray                \n\
1418 harray->SetValue(1,gp_Pnt2d (7+ 0,0));                               \n\
1419 harray->SetValue(2,gp_Pnt2d (7+ 1,2));                               \n\
1420 harray->SetValue(3,gp_Pnt2d (7+ 2,3));                               \n\
1421 harray->SetValue(4,gp_Pnt2d (7+ 4,3));                               \n\
1422 harray->SetValue(5,gp_Pnt2d (7+ 5,5));                               \n\
1423 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);   \n\
1424 anInterpolation.Perform();                                           \n\
1425 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();          \n\
1426                                                                      \n\
1427 Handle(TColgp_HArray1OfPnt2d) harray2 =                              \n\
1428     new TColgp_HArray1OfPnt2d (1,5); // sizing harray                \n");
1429   Message += "\
1430 harray2->SetValue(1,gp_Pnt2d (11+ 0,0));                             \n\
1431 harray2->SetValue(2,gp_Pnt2d (11+ 1,2));                             \n\
1432 harray2->SetValue(3,gp_Pnt2d (11+ 2,3));                             \n\
1433 harray2->SetValue(4,gp_Pnt2d (11+ 4,3));                             \n\
1434 harray2->SetValue(5,gp_Pnt2d (11+ 5,5));                             \n\
1435 Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01);  \n\
1436 anInterpolation2.Perform();                                          \n\
1437 Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve();         \n\
1438 // redefined C++ operator allows these assignments                   \n\
1439                                                                      \n";
1440   AddSeparator(aDoc,Message);
1441   //--------------------------------------------------------------
1442   TCollection_AsciiString aString;
1443   for(int i = array.Lower();i<=array.Upper();i++)
1444   {
1445     gp_Pnt2d P = array(i);
1446     TCollection_AsciiString Message2 (i);
1447     aString = "array ";aString += Message2;
1448     DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1449   }
1450   for( int i = harray->Lower();i<=harray->Upper();i++)
1451   {
1452     gp_Pnt2d P = harray->Value(i);
1453     TCollection_AsciiString Message2 (i);
1454     aString = "harray ";aString += Message2; 
1455     DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1456   }
1457   for( int i = harray2->Lower();i<=harray2->Upper();i++)
1458   {
1459     gp_Pnt2d P = harray2->Value(i);
1460     TCollection_AsciiString Message2 (i);
1461     aString = "harray2 ";aString += Message2; 
1462     DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1463   }
1464
1465   if (!SPL1.IsNull())
1466   { 
1467     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1468     aCurve->SetColorIndex(3);
1469     aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1470   }
1471   else
1472     MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL1.IsNull()", L"CasCade Error", MB_ICONERROR);
1473
1474   if (!SPL2.IsNull())
1475   {
1476     Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL2);
1477     aCurve2->SetColorIndex(5);
1478     aDoc->GetISessionContext()->Display(aCurve2, Standard_False);  
1479   }
1480   else
1481     MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL2.IsNull()", L"CasCade Error", MB_ICONERROR);
1482
1483   if (!SPL3.IsNull())
1484   {
1485     Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL3);
1486     aCurve2->SetColorIndex(6);
1487     aDoc->GetISessionContext()->Display(aCurve2, Standard_False);  
1488   }
1489   else
1490     MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL3.IsNull()", L"CasCade Error", MB_ICONERROR);
1491
1492   Message += " SPL1  is Red  \n";
1493   Message += " SPL2  is Blue \n";   
1494   Message += " SPL3  is Yellow \n";   
1495
1496   PostProcess(aDoc,ID_BUTTON_Test_20,TheDisplayType,Message);
1497 }
1498
1499 void GeomSources::gpTest21(CGeometryDoc* aDoc)
1500 {
1501   DisplayType TheDisplayType = a2DNo3D;
1502   PreProcess(aDoc,TheDisplayType);
1503
1504   //==============================================================
1505
1506   gp_Pnt2d P1(-184, 101);
1507   gp_Pnt2d P2(20 ,84);
1508   Standard_Real aheight = 1;
1509   FairCurve_Batten B (P1,P2,aheight);
1510   B.SetAngle1(22*M_PI/180);
1511   B.SetAngle2(44*M_PI/180);
1512   FairCurve_AnalysisCode anAnalysisCode;
1513   B.Compute(anAnalysisCode);
1514   Handle(Geom2d_BSplineCurve) C = B.Curve();
1515
1516   //==============================================================
1517   TCollection_AsciiString Message (" \
1518                                             \n\
1519 gp_Pnt2d P1(-184, 101);                     \n\
1520 gp_Pnt2d P2(20 ,84);                        \n\
1521 Standard_Real aheight = 1;                  \n\
1522 FairCurve_Batten B (P1,P2,aheight);         \n\
1523 B.SetAngle1(22*PI180);                      \n\
1524 B.SetAngle2(44*PI180);                      \n\
1525 FairCurve_AnalysisCode anAnalysisCode;      \n\
1526 B.Compute(anAnalysisCode);                  \n\
1527 Handle(Geom2d_BSplineCurve) C = B.Curve();  \n\
1528                                             \n");
1529   AddSeparator(aDoc,Message);
1530   //--------------------------------------------------------------
1531
1532   DisplayCurveAndCurvature(aDoc,C,6,Standard_False);               
1533
1534   PostProcess(aDoc,ID_BUTTON_Test_21,TheDisplayType,Message);
1535 }
1536
1537 void GeomSources::gpTest22(CGeometryDoc* aDoc)
1538 {
1539   DisplayType TheDisplayType = a2DNo3D;
1540   PreProcess(aDoc,TheDisplayType);
1541
1542   //==============================================================
1543                                                 
1544   gp_Pnt2d P1(-184, 41);                          
1545   gp_Pnt2d P2(20 ,24);                            
1546   Standard_Real aheight = 1;                      
1547   FairCurve_MinimalVariation MV (P1,P2,aheight);  
1548   MV.SetAngle1(22*M_PI/180);                         
1549   MV.SetAngle2(44*M_PI/180);                         
1550
1551   FairCurve_AnalysisCode anAnalysisCode;          
1552   MV.Compute(anAnalysisCode);                     
1553
1554   Handle(Geom2d_BSplineCurve) C = MV.Curve();     
1555
1556   //==============================================================
1557   TCollection_AsciiString Message (" \
1558                                                 \n\
1559 gp_Pnt2d P1(-184, 41);                          \n\
1560 gp_Pnt2d P2(20 ,24);                            \n\
1561 Standard_Real aheight = 1;                      \n\
1562 FairCurve_MinimalVariation MV (P1,P2,aheight);  \n\
1563 MV.SetAngle1(22*PI180);                         \n\
1564 MV.SetAngle2(44*PI180);                         \n\
1565                                                 \n\
1566 FairCurve_AnalysisCode anAnalysisCode;          \n\
1567 MV.Compute(anAnalysisCode);                     \n\
1568                                                 \n\
1569 Handle(Geom2d_BSplineCurve) C = MV.Curve();     \n\
1570                                                 \n");
1571   AddSeparator(aDoc,Message);
1572   //--------------------------------------------------------------
1573
1574   DisplayCurveAndCurvature(aDoc,C,7,Standard_False);                   
1575   DisplayPoint(aDoc,P1,"P1",false,0.5);
1576   DisplayPoint(aDoc,P2,"P2",false,0.5);
1577
1578   PostProcess(aDoc,ID_BUTTON_Test_22,TheDisplayType,Message);
1579 }
1580
1581 // Function name        : GeomSources::gpTest23
1582 // Description      : 
1583 // Return type          : void 
1584 // Argument         : CGeometryDoc* aDoc
1585 void GeomSources::gpTest23(CGeometryDoc* aDoc)
1586 {
1587   DisplayType TheDisplayType = a2DNo3D;
1588   PreProcess(aDoc,TheDisplayType);
1589   //==============================================================
1590
1591   Standard_Real major = 12;                                               
1592   Standard_Real minor = 4;                                                
1593   gp_Ax2d axis = gp::OX2d();                                              
1594   Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor);
1595   Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2);
1596
1597   // The segment goes in the direction Vfrom P1  
1598   // to the point projected on this line by P2   
1599   // In the example (0,6).
1600   Handle(Geom2d_BSplineCurve) SPL =
1601     Geom2dConvert::CurveToBSplineCurve(TC);
1602
1603   //==============================================================
1604   TCollection_AsciiString Message (" \
1605                                                                    \n\
1606 Standard_Real major = 12;                                          \n\
1607 Standard_Real minor = 4;                                           \n\
1608 gp_Ax2d axis = gp::OX2d();                                         \n\
1609 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor);   \n\
1610                                                                    \n\
1611 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2);  \n\
1612                                                                    \n\
1613 // The segment goes in the direction Vfrom P1                      \n\
1614 // to the point projected on this line by P2                       \n\
1615 // In the example (0,6).                                           \n\
1616 Handle(Geom2d_BSplineCurve) SPL =                                  \n\
1617     Geom2dConvert::CurveToBSplineCurve(TC);                        \n\
1618                                                                    \n");
1619   AddSeparator(aDoc,Message);
1620   //--------------------------------------------------------------
1621
1622   Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
1623   aCurve->SetColorIndex(3); // Red
1624   aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
1625   aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1626
1627   Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL);
1628   aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1629
1630   PostProcess(aDoc,ID_BUTTON_Test_23,TheDisplayType,Message);
1631 }
1632
1633 // Function name        : GeomSources::gpTest24
1634 // Description      : 
1635 // Return type          : void 
1636 // Argument         : CGeometryDoc* aDoc
1637 void GeomSources::gpTest24(CGeometryDoc* aDoc)
1638 {
1639   DisplayType TheDisplayType = a2D3D;
1640   PreProcess(aDoc,TheDisplayType);
1641   //==============================================================
1642   
1643   Standard_Real radius = 5;
1644   gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0));
1645
1646   Handle(Geom2d_Circle) circ2d =
1647     new Geom2d_Circle(ax2d,radius);
1648
1649   gp_Ax2d circ2dXAxis = circ2d->XAxis();
1650
1651   // create a 3D curve in a given plane
1652   Handle(Geom_Curve) C3D =
1653     GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY())));
1654   Handle(Geom_Circle) C3DCircle =
1655     Handle(Geom_Circle)::DownCast(C3D);
1656
1657   gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis();
1658
1659   // project it to a 2D curve in another plane
1660
1661   gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 ));
1662
1663   Handle(Geom2d_Curve) C2D =
1664     GeomAPI::To2d(C3D,ProjectionPlane);
1665
1666   Handle(Geom2d_Circle) C2DCircle =
1667     Handle(Geom2d_Circle)::DownCast(C2D);
1668   gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis();
1669
1670   //==============================================================
1671   TCollection_AsciiString Message (" \
1672                                                         \n\
1673 Standard_Real radius = 5;                               \n\
1674 gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0));              \n\
1675                                                         \n\
1676 Handle(Geom2d_Circle) circ2d =                          \n\
1677     new Geom2d_Circle(ax2d,radius);                     \n\
1678                                                         \n\
1679 gp_Ax2d circ2dXAxis = circ2d->XAxis();                  \n\
1680                                                         \n\
1681 // create a 3D curve in a given plane                   \n\
1682 Handle(Geom_Curve) C3D =                                \n\
1683     GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY())));    \n\
1684 Handle(Geom_Circle) C3DCircle =                         \n\
1685    Handle(Geom_Circle)::DownCast(C3D);                  \n\
1686                                                         \n\
1687 gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis();             \n\
1688                                                         \n\
1689 // project it to a 2D curve in another plane            \n\
1690                                                         \n\
1691 gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 ));  \n\
1692                                                         \n\
1693 Handle(Geom2d_Curve) C2D =                              \n\
1694     GeomAPI::To2d(C3D,ProjectionPlane);                 \n\
1695                                                         \n\
1696 Handle(Geom2d_Circle) C2DCircle =                       \n\
1697   Handle(Geom2d_Circle)::DownCast(C2D);                 \n\
1698 gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis();            \n\
1699                                                         \n");
1700  AddSeparator(aDoc,Message);
1701  //--------------------------------------------------------------
1702  Handle(Geom_Plane) aPlane = GC_MakePlane(gp_Pln(gp_Ax3(gp::XOY()))).Value();
1703  Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);   
1704  DisplaySurface(aDoc,aSurface);
1705
1706  Handle(Geom_Plane) aProjectionPlane = GC_MakePlane(ProjectionPlane).Value();
1707  Handle(Geom_RectangularTrimmedSurface) aProjectionPlaneSurface=
1708    new Geom_RectangularTrimmedSurface(aProjectionPlane,-8.,8.,-12.,12.);
1709
1710  DisplaySurface(aDoc,aProjectionPlaneSurface);
1711
1712  Standard_CString aC3DEntityTypeName = C3D->DynamicType()->Name();        
1713  Standard_CString aC2DEntityTypeName = C2D->DynamicType()->Name();        
1714
1715  Message += " C3D->DynamicType()->Name() = ";
1716  Message += aC3DEntityTypeName; Message += " \n";
1717  Message += " C2D->DynamicType()->Name() = ";
1718  Message += aC2DEntityTypeName; Message += " \n";
1719
1720  DisplayCurve(aDoc,circ2d,4,false);
1721  DisplayCurve(aDoc,C3D,Quantity_NOC_YELLOW,false);
1722  DisplayCurve(aDoc,C2D,5,false);
1723
1724  Handle(ISession_Direction) aC3DCircleXAxisDirection = new ISession_Direction(C3DCircleXAxis.Location(),C3DCircleXAxis.Direction(),5.2);
1725  aDoc->GetAISContext()->Display(aC3DCircleXAxisDirection, Standard_False);
1726
1727  Handle(ISession_Direction) acirc2dXAxisDirection = new ISession_Direction(circ2dXAxis.Location(),circ2dXAxis.Direction(),5.2);
1728  aDoc->GetISessionContext()->Display(acirc2dXAxisDirection, Standard_False);
1729
1730  Handle(ISession_Direction) aC2DCircleXAxisDirection = new ISession_Direction(C2DCircleXAxis.Location(),C2DCircleXAxis.Direction(),5.2);
1731  aDoc->GetISessionContext()->Display(aC2DCircleXAxisDirection, Standard_False);
1732
1733  PostProcess(aDoc,ID_BUTTON_Test_24,TheDisplayType,Message);
1734 }
1735
1736 // Function name        : GeomSources::gpTest25
1737 // Description      : 
1738 // Return type          : void 
1739 // Argument         : CGeometryDoc* aDoc
1740 void GeomSources::gpTest25(CGeometryDoc* aDoc)
1741 {
1742   DisplayType TheDisplayType = a2DNo3D;
1743   PreProcess(aDoc,TheDisplayType);
1744
1745   //==============================================================
1746
1747   Handle(TColgp_HArray1OfPnt2d) harray =
1748     new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1749   harray->SetValue(1,gp_Pnt2d (0,0));
1750   harray->SetValue(2,gp_Pnt2d (-3,1));
1751   harray->SetValue(3,gp_Pnt2d (-2,5));
1752   harray->SetValue(4,gp_Pnt2d (2,9));
1753   harray->SetValue(5,gp_Pnt2d (-4,14));
1754
1755 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);
1756 anInterpolation.Perform();
1757 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve();
1758
1759 gp_Pnt2d P1(-1,-2);
1760 gp_Pnt2d P2(0,15);
1761 gp_Dir2d V1 = gp::DY2d();
1762 Handle(Geom2d_TrimmedCurve) TC1 =
1763     GCE2d_MakeSegment(P1,V1,P2);
1764
1765 Standard_Real tolerance = Precision::Confusion();
1766 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance);
1767 Standard_Integer NbPoints =ICC.NbPoints();
1768 gp_Pnt2d PK;
1769
1770 for (Standard_Integer k = 1;k<=NbPoints;k++)
1771 {                                                                 
1772   PK = ICC.Point(k);                                              
1773   // do something with each intersection point                    
1774 }                                                                 
1775
1776   //==============================================================
1777   TCollection_AsciiString Message (" \
1778                                                                     \n\
1779 Handle(TColgp_HArray1OfPnt2d) harray =                              \n\
1780     new TColgp_HArray1OfPnt2d (1,5); // sizing harray               \n\
1781 harray->SetValue(1,gp_Pnt2d (0,0));                                 \n\
1782 harray->SetValue(2,gp_Pnt2d (-3,1));                                \n\
1783 harray->SetValue(3,gp_Pnt2d (-2,5));                                \n\
1784 harray->SetValue(4,gp_Pnt2d (2,9));                                 \n\
1785 harray->SetValue(5,gp_Pnt2d (-4,14));                               \n\
1786                                                                     \n\
1787 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);  \n\
1788 anInterpolation.Perform();                                          \n\
1789 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve();          \n\
1790                                                                     \n\
1791 gp_Pnt2d P1(-1,-2);                                                 \n\
1792 gp_Pnt2d P2(0,15);                                                  \n\
1793 gp_Dir2d V1 = gp::DY2d();                                           \n\
1794 Handle(Geom2d_TrimmedCurve) TC1=                                    \n\
1795     GCE2d_MakeSegment(P1,V1,P2);                                    \n\
1796                                                                     \n\
1797 Standard_Real tolerance = Precision::Confusion();                   \n\
1798 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance);                  \n\
1799 Standard_Integer NbPoints =ICC.NbPoints();                          \n\
1800 gp_Pnt2d PK;                                                        \n\
1801 for (Standard_Integer k = 1;k<=NbPoints;k++)                        \n\
1802   {                                                                 \n\
1803     PK = ICC.Point(k);                                              \n\
1804     // do something with each intersection point                    \n\
1805   }                                                                 \n\
1806                                                                     \n");
1807   AddSeparator(aDoc,Message);
1808   //--------------------------------------------------------------
1809
1810   Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL);
1811   aCurve1->SetDisplayPole(Standard_False);
1812   aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
1813   Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC1);
1814   aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1815
1816   TCollection_AsciiString aString;
1817   for (Standard_Integer i = 1;i<=NbPoints;i++)
1818   {
1819     PK = ICC.Point(i);
1820     // do something with each intersection point
1821     TCollection_AsciiString Message2 (i);
1822     TCollection_AsciiString Message3 (PK.X());
1823     TCollection_AsciiString Message4 (PK.Y());
1824     aString = "PK_";
1825     aString += Message2; 
1826
1827     DisplayPoint(aDoc,PK,aString.ToCString(),false,0.5);
1828
1829     Message += "PK_"; 
1830     Message += Message2; 
1831     Message += " ( ";
1832     Message += Message3; 
1833     Message += " , "; 
1834     Message += Message4; 
1835     Message += " )\n"; 
1836   }
1837
1838   PostProcess(aDoc,ID_BUTTON_Test_25,TheDisplayType,Message);
1839 }
1840
1841 // Function name        : GeomSources::gpTest26
1842 // Description      : 
1843 // Return type          : void 
1844 // Argument         : CGeometryDoc* aDoc
1845 void GeomSources::gpTest26(CGeometryDoc* aDoc)
1846 {
1847   DisplayType TheDisplayType = a2DNo3D;
1848   PreProcess(aDoc,TheDisplayType);
1849
1850   //==============================================================
1851
1852   //----------- Build TC1 -----------------------
1853   gp_Pnt2d P1(0,0);  gp_Pnt2d P2(2,6);
1854   gp_Dir2d V1 = gp::DY2d();
1855   Handle(Geom2d_TrimmedCurve) TC1 =  GCE2d_MakeSegment(P1,V1,P2);
1856   Standard_Real FP1 = TC1->FirstParameter();
1857   Standard_Real LP1 = TC1->LastParameter();
1858   //----------- Build TC2 -----------------------
1859   gp_Pnt2d P3(-9,6.5);       gp_Dir2d V2 = gp::DX2d();
1860   Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2);
1861   Standard_Real FP2 = TC1->FirstParameter();
1862   Standard_Real LP2 = TC1->LastParameter();
1863   //----------- Extrema TC1 / TC2 ---------------
1864   Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2);
1865   Standard_Real shortestdistance =-1;
1866   if (ECC.NbExtrema() != 0)  shortestdistance = ECC.LowerDistance();
1867   //----------- Build SPL1 ---------------------- 
1868   TColgp_Array1OfPnt2d array (1,5); // sizing array
1869   array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));
1870   array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));
1871   array.SetValue(5,gp_Pnt2d (-3,5));
1872   Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);
1873   Standard_Real FPSPL1 = SPL1->FirstParameter();
1874   Standard_Real LPSPL1 = SPL1->LastParameter();
1875   //----------- Extrema TC1 / SPL1  -------------                       
1876   Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1);
1877   Standard_Real SPL1shortestdistance =-1;
1878   if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance();
1879   Standard_Integer NbExtrema = ECC2.NbExtrema();
1880   TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2);
1881   for(int i=1;i <= NbExtrema; i++)
1882   {                                  
1883     gp_Pnt2d P1x,P2x;
1884     ECC2.Points(i,P1x,P2x);
1885     aSolutionArray(i,1) = P1x;
1886     aSolutionArray(i,2) = P2x;
1887   }            
1888
1889   //==============================================================
1890   TCollection_AsciiString Message (" \
1891 //----------- Build TC1 -----------------------                       \n\
1892 gp_Pnt2d P1(0,0);  gp_Pnt2d P2(2,6);                                  \n\
1893 gp_Dir2d V1 = gp::DY2d();                                             \n\
1894 Handle(Geom2d_TrimmedCurve) TC1 =  GCE2d_MakeSegment(P1,V1,P2);       \n\
1895 Standard_Real FP1 = TC1->FirstParameter();                            \n\
1896 Standard_Real LP1 = TC1->LastParameter();                             \n\
1897 //----------- Build TC2 -----------------------                       \n\
1898 gp_Pnt2d P3(-9,6.5);       gp_Dir2d V2 = gp::DX2d();                    \n\
1899 Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2);        \n\
1900 Standard_Real FP2 = TC1->FirstParameter();                            \n\
1901 Standard_Real LP2 = TC1->LastParameter();                             \n\
1902 //----------- Extrema TC1 / TC2 ---------------                       \n\
1903 Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2);          \n\
1904 Standard_Real shortestdistance =-1;                                   \n\
1905 if (ECC.NbExtrema() != 0)  shortestdistance = ECC.LowerDistance();    \n\
1906 //----------- Build SPL1 ----------------------                       \n\
1907 TColgp_Array1OfPnt2d array (1,5); // sizing array                     \n\
1908 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2)); \n\
1909 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3)); \n\
1910 array.SetValue(5,gp_Pnt2d (-3,5));                                    \n\
1911 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);  \n\
1912 Standard_Real FPSPL1 = SPL1->FirstParameter();                        \n");
1913 Message += "\
1914 Standard_Real LPSPL1 = SPL1->LastParameter();                         \n\
1915 //----------- Extrema TC1 / SPL1  -------------                       \n\
1916 Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1);  \n\
1917 Standard_Real SPL1shortestdistance =-1;                               \n\
1918 if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance(); \n\
1919 Standard_Integer NbExtrema = ECC2.NbExtrema();                        \n\
1920 TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2);                 \n\
1921 for(int i=1;i <= NbExtrema; i++)   {                                  \n\
1922     gp_Pnt2d P1,P2;                                                   \n\
1923     ECC2.Points(i,P1,P2);                                             \n\
1924     aSolutionArray(i,1) = P1;  aSolutionArray(i,2) = P2; }            \n";
1925  AddSeparator(aDoc,Message);
1926  //--------------------------------------------------------------
1927
1928  TCollection_AsciiString aString;
1929  for(int i = array.Lower();i<=array.Upper();i++)
1930  {
1931    TCollection_AsciiString Message2 (i);
1932    gp_Pnt2d P = array(i);
1933    aString = "array ";
1934    aString += Message2; 
1935    DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1936  }
1937
1938  if (!SPL1.IsNull())
1939  { 
1940    Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1941    aCurve->SetDisplayPole(Standard_False);
1942    aCurve->SetColorIndex(3);
1943    aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1944  }
1945  else
1946    MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL1.IsNull()", L"CasCade Error", MB_ICONERROR);
1947
1948  Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(TC1);
1949  aCurve1->SetColorIndex(6);
1950  aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
1951  Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC2);
1952  aCurve2->SetColorIndex(5);
1953  aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1954
1955  for(int i=1;i <= NbExtrema; i++)
1956  {
1957    gp_Pnt2d P1x =aSolutionArray(i,1);
1958
1959    TCollection_AsciiString Message2 (i);
1960    aString = "P1_";
1961    aString += Message2; 
1962    DisplayPoint(aDoc,P1x,aString.ToCString(),false,0.7*i);
1963
1964    gp_Pnt2d P2x = aSolutionArray(i,2);
1965
1966    Handle(Geom2d_TrimmedCurve) SolutionCurve =
1967      GCE2d_MakeSegment(P1x,P2x);
1968    Handle(ISession2D_Curve) aSolutionCurve = new ISession2D_Curve(SolutionCurve);
1969    aDoc->GetISessionContext()->Display(aSolutionCurve, Standard_False);
1970  }
1971
1972  Message += "TC1 is  Yellow ,TC2 is  Blue ,SPL1 is Red \n";
1973  Message += "ECC.NbExtrema()  = ";
1974  Message += ECC.NbExtrema();
1975  Message += "    shortestdistance = ";
1976  Message+= shortestdistance;
1977  Message += "\n";
1978  Message += "ECC2.NbExtrema() = ";
1979  Message += NbExtrema;
1980  Message += "    SPL1shortestdistance = ";
1981  Message+= SPL1shortestdistance;
1982  Message += "\n";
1983
1984  PostProcess(aDoc,ID_BUTTON_Test_26,TheDisplayType,Message);
1985 }
1986
1987 // Function name        : GeomSources::gpTest27
1988 // Description      : 
1989 // Return type          : void 
1990 // Argument         : CGeometryDoc* aDoc
1991 void GeomSources::gpTest27(CGeometryDoc* aDoc)
1992 {
1993   DisplayType TheDisplayType = a2DNo3D;
1994   PreProcess(aDoc,TheDisplayType);
1995   //==============================================================
1996
1997   TColgp_Array1OfPnt2d array (1,5); // sizing array
1998   array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));
1999   array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));
2000   array.SetValue(5,gp_Pnt2d (-3,5));
2001   Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);
2002
2003   Standard_Real dist = 1;
2004   Handle(Geom2d_OffsetCurve) OC =
2005     new Geom2d_OffsetCurve(SPL1,dist);
2006   Standard_Boolean result = OC->IsCN(2);
2007   Standard_Real dist2 = 1.5;
2008   Handle(Geom2d_OffsetCurve) OC2 =
2009     new Geom2d_OffsetCurve(SPL1,dist2);
2010   Standard_Boolean result2 = OC2->IsCN(2);
2011
2012   //==============================================================
2013   TCollection_AsciiString Message (" \
2014                                                                        \n\
2015 TColgp_Array1OfPnt2d array (1,5); // sizing array                      \n\
2016 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));  \n\
2017 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));  \n\
2018 array.SetValue(5,gp_Pnt2d (-3,5));                                     \n\
2019 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);   \n\
2020                                                                        \n\
2021 Standard_Real dist = 1;                                                \n\
2022 Handle(Geom2d_OffsetCurve) OC =                                        \n\
2023        new Geom2d_OffsetCurve(SPL1,dist);                              \n\
2024 Standard_Boolean result = OC->IsCN(2);                                 \n\
2025                                                                        \n\
2026 Standard_Real dist2 = 1.5;                                             \n\
2027 Handle(Geom2d_OffsetCurve) OC2 =                                       \n\
2028        new Geom2d_OffsetCurve(SPL1,dist2);                             \n\
2029 Standard_Boolean result2 = OC2->IsCN(2);                               \n\
2030                                                                        \n");
2031   AddSeparator(aDoc,Message);
2032   //--------------------------------------------------------------
2033   Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL1);
2034   aCurve1->SetColorIndex(6);
2035   aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
2036   Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(OC);
2037   aCurve2->SetColorIndex(5);
2038   aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2039   Handle(ISession2D_Curve) aCurve3 = new ISession2D_Curve(OC2);
2040   aCurve3->SetColorIndex(3);
2041   aDoc->GetISessionContext()->Display(aCurve3, Standard_False);
2042
2043
2044   Message += "SPL1 is Yellow \n";
2045   Message += "OC   is Blue \n";
2046   Message += "OC2  is Red \n\n";
2047   Message += "  Warning, Continuity is not guaranteed :  \n ";
2048   if(result)
2049     Message += " result  = True  \n";
2050   else
2051     Message += " result  = False \n";
2052   if(result2)
2053     Message += " result2 = True  \n";
2054   else
2055     Message += " result2 = False \n";
2056
2057   PostProcess(aDoc,ID_BUTTON_Test_27,TheDisplayType,Message);
2058 }
2059
2060 // Function name        : GeomSources::gpTest28
2061 // Description      : 
2062 // Return type          : void 
2063 // Argument         : CGeometryDoc* aDoc
2064 void GeomSources::gpTest28(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 = gce_MakeLin2d(P1,P2);
2073   // assignment by overloaded operator  
2074
2075   //==============================================================
2076   TCollection_AsciiString Message (" \
2077                                       \n\
2078 gp_Pnt2d P1(1,2);                     \n\
2079 gp_Pnt2d P2(4,5);                     \n\
2080 gp_Lin2d L = gce_MakeLin2d(P1,P2);    \n\
2081 // assignment by overloaded operator  \n\
2082                                       \n");
2083   AddSeparator(aDoc,Message);
2084   //--------------------------------------------------------------
2085
2086   DisplayPoint(aDoc,P1,"P1",false,0.5);
2087   DisplayPoint(aDoc,P2,"P2",false,0.5);
2088
2089   Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-3,8);
2090   Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2091   aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2092
2093   PostProcess(aDoc,ID_BUTTON_Test_28,TheDisplayType,Message);
2094 }
2095
2096 // Function name        : GeomSources::gpTest29
2097 // Description      : 
2098 // Return type          : void 
2099 // Argument         : CGeometryDoc* aDoc
2100 void GeomSources::gpTest29(CGeometryDoc* aDoc)
2101 {
2102   DisplayType TheDisplayType = a2DNo3D;
2103   PreProcess(aDoc,TheDisplayType);
2104
2105   //==============================================================
2106                              
2107   gp_Pnt2d P1(1,2);
2108   gp_Pnt2d P2(4,5);
2109   gp_Lin2d L;
2110   GccAna_Pnt2dBisec B(P1,P2);
2111   if (B.IsDone())
2112   {
2113     L = B.ThisSolution();
2114   }
2115
2116   //==============================================================
2117   TCollection_AsciiString Message (" \
2118                              \n\
2119 gp_Pnt2d P1(1,2);            \n\
2120 gp_Pnt2d P2(4,5);            \n\
2121 gp_Lin2d L;                  \n\
2122 GccAna_Pnt2dBisec B(P1,P2);  \n\
2123 if (B.IsDone())              \n\
2124     {                        \n\
2125     L = B.ThisSolution();    \n\
2126     }                        \n\
2127                              \n");
2128   AddSeparator(aDoc,Message);
2129   //--------------------------------------------------------------
2130
2131   DisplayPoint(aDoc,P1,"P1",false,0.5);
2132   DisplayPoint(aDoc,P2,"P2",false,0.5);
2133
2134   if (B.IsDone())
2135   {
2136     Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-8,8);
2137     Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2138     aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2139   }
2140
2141   if (B.IsDone()) Message += " \n   B Is Done   ";
2142   else            Message += " \n   B Is not Done    ";
2143   PostProcess(aDoc,ID_BUTTON_Test_29,TheDisplayType,Message);
2144 }
2145
2146 // Function name        : GeomSources::gpTest30
2147 // Description      : 
2148 // Return type          : void 
2149 // Argument         : CGeometryDoc* aDoc
2150 void GeomSources::gpTest30(CGeometryDoc* aDoc)
2151 {
2152   DisplayType TheDisplayType =a2DNo3D ;
2153   PreProcess(aDoc,TheDisplayType);
2154
2155   //==============================================================
2156
2157   gp_Pnt2d P1 (2,3);
2158   gp_Pnt2d P2 (4,4);
2159   gp_Pnt2d P3 (6,7);
2160   gp_Pnt2d P4 (10,10);
2161   gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);
2162   GccEnt_QualifiedCirc QC = GccEnt::Outside(C);
2163   GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion());
2164   if (LT.IsDone())
2165   {
2166     Standard_Integer NbSol = LT.NbSolutions();
2167     for(Standard_Integer k=1; k<=NbSol; k++)
2168     {
2169       gp_Lin2d L = LT.ThisSolution(k);
2170       // do something with L
2171     }
2172   }
2173
2174   //==============================================================
2175   TCollection_AsciiString Message (" \
2176                                                      \n\
2177 gp_Pnt2d P1 (2,3);                                   \n\
2178 gp_Pnt2d P2 (4,4);                                   \n\
2179 gp_Pnt2d P3 (6,7);                                   \n\
2180 gp_Pnt2d P4 (10,10);                                 \n\
2181 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);             \n\
2182 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);        \n\
2183 GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion());  \n\
2184 Standard_Integer NbSol;                              \n\
2185 if (LT.IsDone())                                     \n\
2186   {                                                  \n\
2187       NbSol = LT.NbSolutions();                      \n\
2188       for(Standard_Integer k=1; k<=NbSol; k++)       \n\
2189         {                                            \n\
2190          gp_Lin2d L = LT.ThisSolution(k);            \n\
2191           // do something with L                     \n\
2192         }                                            \n\
2193   }                                                  \n\
2194                                                      \n");
2195   AddSeparator(aDoc,Message);
2196   //--------------------------------------------------------------
2197
2198   DisplayPoint(aDoc,P1,"P1",false,0.5,-1,0.1);
2199   DisplayPoint(aDoc,P2,"P2",false,0.5,-0.7,0.1);
2200   DisplayPoint(aDoc,P3,"P3",false,0.5,-0.5,0.1);
2201   DisplayPoint(aDoc,P4,"P4",false,0.5,0,0.1);
2202
2203   Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2204   Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2205   aCurve->SetColorIndex(5);
2206   aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2207
2208   if (LT.IsDone())
2209   {
2210     Standard_Integer NbSol = LT.NbSolutions();
2211     for(Standard_Integer k=1; k<=NbSol; k++)
2212     {
2213       gp_Lin2d L = LT.ThisSolution(k);
2214       Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-10,20);
2215       Handle(ISession2D_Curve) aCurveN = new ISession2D_Curve(aLine);
2216       aDoc->GetISessionContext()->Display(aCurveN, Standard_False);
2217     }
2218   }
2219   Message += " C is Blue \n\n";
2220   Message += "LT.IsDone() = "; 
2221   if (LT.IsDone())  Message += "True \n"; else Message += "False \n";
2222   TCollection_AsciiString Message2 (LT.NbSolutions());
2223   Message += "NbSol       = "; Message += Message2      ; Message += "\n";
2224
2225   PostProcess(aDoc,ID_BUTTON_Test_30,TheDisplayType,Message);
2226 }
2227
2228 // Function name        : GeomSources::gpTest31
2229 // Description      : 
2230 // Return type          : void 
2231 // Argument         : CGeometryDoc* aDoc
2232 void GeomSources::gpTest31(CGeometryDoc* aDoc)
2233 {
2234   DisplayType TheDisplayType = a2DNo3D;
2235   PreProcess(aDoc,TheDisplayType);
2236
2237   //==============================================================
2238
2239 gp_Pnt2d P1 (9,6);
2240 gp_Pnt2d P2 (10,4);
2241 gp_Pnt2d P3 (6,7);
2242 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);
2243 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);
2244 gp_Pnt2d P4 (-2,7);
2245 gp_Pnt2d P5 (12,-3);
2246 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1);
2247 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L);
2248 Standard_Real radius = 2;
2249 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion());
2250 Standard_Real parsol,pararg;
2251 gp_Pnt2d tangentpoint1,tangentpoint2;
2252 gp_Circ2d circ;
2253 if (TR.IsDone())
2254 {
2255   Standard_Integer NbSol = TR.NbSolutions();
2256   for (Standard_Integer k=1; k<=NbSol; k++)
2257   {
2258     circ = TR.ThisSolution(k);
2259     // find the solution circle
2260     TR.Tangency1(k,parsol,pararg,tangentpoint1);
2261     // find the first tangent point
2262     TR.Tangency2(k,parsol,pararg,tangentpoint2);
2263     // find the second tangent point
2264   }
2265 }
2266
2267   //==============================================================
2268   TCollection_AsciiString Message;
2269   Message = "\
2270                                                                               \n\
2271 gp_Pnt2d P1 (9,6);                                                            \n\
2272 gp_Pnt2d P2 (10,4);                                                           \n\
2273 gp_Pnt2d P3 (6,7);                                                            \n\
2274 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);                                      \n\
2275 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);                                 \n\
2276 gp_Pnt2d P4 (-2,7);                                                           \n\
2277 gp_Pnt2d P5 (12,-3);                                                          \n\
2278 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1);  \n\
2279 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L);                              \n\
2280 Standard_Real radius = 2;                                                     \n\
2281 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion());                \n\
2282 Standard_Real parsol,pararg;                                                  \n\
2283 gp_Pnt2d tangentpoint1,tangentpoint2;                                         \n\
2284 gp_Circ2d circ;                                                               \n\
2285 if (TR.IsDone())                                                              \n\
2286     {                                                                         \n\
2287       Standard_Integer NbSol = TR.NbSolutions();                              \n\
2288       for (Standard_Integer k=1; k<=NbSol; k++)                               \n\
2289         {                                                                     \n";
2290   Message += "\
2291           circ = TR.ThisSolution(k);                                          \n\
2292           // find the solution circle                                         \n\
2293           TR.Tangency1(k,parsol,pararg,tangentpoint1);                        \n\
2294           // find the first tangent point                                     \n\
2295           TR.Tangency2(k,parsol,pararg,tangentpoint2);                        \n\
2296           // find the second tangent point                                    \n\
2297         }                                                                     \n\
2298     }                                                                         \n\
2299                                                                               \n";
2300   AddSeparator(aDoc,Message);
2301
2302   //--------------------------------------------------------------
2303   DisplayPoint(aDoc,P1,"P1",false,0.3);
2304   DisplayPoint(aDoc,P2,"P2",false,0.3);
2305   DisplayPoint(aDoc,P3,"P3",false,0.3);
2306   DisplayPoint(aDoc,P4,"P4",false,0.3);
2307   DisplayPoint(aDoc,P5,"P5",false,0.3);
2308
2309   Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2310   Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2311   aCurve->SetColorIndex(3);
2312
2313   aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2314   Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-2,20);
2315   Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(aLine);
2316   aCurve2->SetColorIndex(5);
2317   aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2318
2319   if (TR.IsDone())
2320   {
2321     Standard_Integer NbSol = TR.NbSolutions();
2322     for (Standard_Integer k=1; k<=NbSol; k++)
2323     {
2324       circ = TR.ThisSolution(k);
2325       Handle(Geom2d_Circle) aCircleN = new Geom2d_Circle(circ);
2326       Handle(ISession2D_Curve) aCurveN = new ISession2D_Curve(aCircleN);
2327       aDoc->GetISessionContext()->Display(aCurveN, Standard_False);
2328
2329       // find the solution circle
2330       TR.Tangency1(k,parsol,pararg,tangentpoint1);
2331       // find the first tangent point                                                                    
2332       TR.Tangency2(k,parsol,pararg,tangentpoint2);
2333       // find the second tangent point
2334       DisplayPoint(aDoc,tangentpoint1,"tangentpoint1",false,0.3);
2335       DisplayPoint(aDoc,tangentpoint2,"tangentpoint2",false,0.3);
2336     }
2337   }
2338   Message += "C is Red \n";
2339   Message += "L is Blue \n";
2340   PostProcess(aDoc,ID_BUTTON_Test_31,TheDisplayType,Message);
2341 }
2342
2343 // Function name        : GeomSources::gpTest32
2344 // Description      : 
2345 // Return type          : void 
2346 // Argument         : CGeometryDoc* aDoc
2347 void GeomSources::gpTest32(CGeometryDoc* aDoc)
2348 {
2349   DisplayType TheDisplayType = a2DNo3D;
2350   PreProcess(aDoc,TheDisplayType);
2351
2352   //==============================================================
2353
2354   Standard_Real major = 12;
2355   Standard_Real minor = 4;
2356   gp_Ax2d axis = gp::OX2d();
2357   gp_Elips2d EE(axis,major,minor);
2358   Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,M_PI/4);
2359
2360   //==============================================================
2361   TCollection_AsciiString Message (" \
2362                                                                         \n\
2363 Standard_Real major = 12;                                               \n\
2364 Standard_Real minor = 4;                                                \n\
2365 gp_Ax2d axis = gp::OX2d();                                              \n\
2366 gp_Elips2d EE(axis,major,minor);                                        \n\
2367 Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,PI/4);  \n\
2368                                                                         \n");
2369   AddSeparator(aDoc,Message);
2370   //--------------------------------------------------------------
2371   Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse(EE);
2372   Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
2373   aCurve->SetColorIndex(3);
2374   aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
2375   //SetWidthOfLine                 
2376   aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2377   Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(arc);
2378   aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2379   TCollection_AsciiString Message2 (M_PI);
2380   Message += " PI = ";Message+= Message2;
2381
2382   PostProcess(aDoc,ID_BUTTON_Test_32,TheDisplayType,Message);
2383 }
2384
2385 // Function name        : GeomSources::gpTest33
2386 // Description      : 
2387 // Return type          : void 
2388 // Argument         : CGeometryDoc* aDoc
2389 void GeomSources::gpTest33(CGeometryDoc* aDoc)
2390 {
2391   DisplayType TheDisplayType = No2D3D;
2392   PreProcess(aDoc,TheDisplayType);
2393
2394   //==============================================================
2395
2396   gp_Pnt P1(0,0,1);
2397   gp_Pnt P2(1,2,2);
2398   gp_Pnt P3(2,3,3);
2399   gp_Pnt P4(4,3,4);
2400   gp_Pnt P5(5,5,5);
2401   TColgp_Array1OfPnt array (1,5); // sizing array
2402   array.SetValue(1,P1);
2403   array.SetValue(2,P2);
2404   array.SetValue(3,P3);
2405   array.SetValue(4,P4);
2406   array.SetValue(5,P5);
2407   Handle(TColgp_HArray1OfPnt) harray =
2408     new TColgp_HArray1OfPnt (1,5); // sizing harray
2409   harray->SetValue(1,P1.Translated(gp_Vec(4,0,0)));
2410   harray->SetValue(2,P2.Translated(gp_Vec(4,0,0)));
2411   harray->SetValue(3,P3.Translated(gp_Vec(4,0,0)));
2412   harray->SetValue(4,P4.Translated(gp_Vec(4,0,0)));
2413   harray->SetValue(5,P5.Translated(gp_Vec(4,0,0)));
2414   Handle(Geom_BSplineCurve) SPL1 =
2415     GeomAPI_PointsToBSpline(array).Curve();
2416
2417   GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation());
2418   anInterpolation.Perform();
2419
2420   Handle(Geom_BSplineCurve) SPL2;
2421   if (anInterpolation.IsDone())
2422     SPL2 = anInterpolation.Curve();
2423   else
2424     MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"The Interpolation is Not done", L"CasCade Warning", MB_ICONWARNING);
2425
2426   //==============================================================
2427   TCollection_AsciiString Message (" \
2428                                                                                         \n\
2429 gp_Pnt P1(0,0,1);                                                                       \n\
2430 gp_Pnt P2(1,2,2);                                                                       \n\
2431 gp_Pnt P3(2,3,3);                                                                       \n\
2432 gp_Pnt P4(4,3,4);                                                                       \n\
2433 gp_Pnt P5(5,5,5);                                                                       \n\
2434 TColgp_Array1OfPnt array (1,5); // sizing array                                         \n\
2435 array.SetValue(1,P1);                                                                   \n\
2436 array.SetValue(2,P2);                                                                   \n\
2437 array.SetValue(3,P3);                                                                   \n\
2438 array.SetValue(4,P4);                                                                   \n\
2439 array.SetValue(5,P5);                                                                   \n\
2440 Handle(TColgp_HArray1OfPnt) harray =                                                    \n\
2441     new TColgp_HArray1OfPnt (1,5); // sizing harray                                     \n\
2442 harray->SetValue(1,P1.Translated(gp_Vec(4,0,0)));                                       \n\
2443 harray->SetValue(2,P2.Translated(gp_Vec(4,0,0)));                                       \n\
2444 harray->SetValue(3,P3.Translated(gp_Vec(4,0,0)));                                       \n\
2445 harray->SetValue(4,P4.Translated(gp_Vec(4,0,0)));                                       \n\
2446 harray->SetValue(5,P5.Translated(gp_Vec(4,0,0)));                                       \n\
2447 Handle(Geom_BSplineCurve) SPL1 =                                                        \n\
2448     GeomAPI_PointsToBSpline(array).Curve();                                             \n");
2449  Message += "\
2450                                                                                         \n\
2451 GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation());  \n\
2452 anInterpolation.Perform();                                                              \n\
2453                                                                                         \n\
2454 Handle(Geom_BSplineCurve) SPL2;                                                         \n\
2455 if (anInterpolation.IsDone())                                                           \n\
2456        SPL2 = anInterpolation.Curve();                                                  \n\
2457 else                                                                                    \n\
2458    MessageBox(0,\"The Interpolation is Not done\",\"CasCade Warning\",MB_ICONWARNING);  \n\
2459                                                                                         \n";
2460   AddSeparator(aDoc,Message);
2461
2462   //--------------------------------------------------------------
2463
2464   TCollection_AsciiString aString;
2465   for(Standard_Integer i = array.Lower();i<=array.Upper();i++)
2466   {
2467
2468     TCollection_AsciiString Message2 (i);
2469     gp_Pnt P = array(i);
2470
2471     aString = "P";
2472     aString += Message2; 
2473     if (i == 1) aString += " (array)  ";
2474     DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);\
2475
2476       aString = "P";
2477     aString += Message2; 
2478     if (i == 1) aString += " (harray)  ";
2479     DisplayPoint(aDoc,P.Translated(gp_Vec(4,0,0)),aString.ToCString(),false,0.5);\
2480
2481   }
2482
2483   Handle(ISession_Curve) aCurve = new ISession_Curve(SPL1);
2484   aDoc->GetAISContext()->SetDisplayMode(aCurve,1);
2485   aDoc->GetAISContext()->Display(aCurve, Standard_False);
2486
2487   if (anInterpolation.IsDone())
2488   {
2489     Handle(ISession_Curve) aCurve2 = new ISession_Curve(SPL2);
2490     aDoc->GetAISContext()->SetDisplayMode(aCurve2,1);
2491     aDoc->GetAISContext()->Display(aCurve2, Standard_False);
2492   }
2493
2494   PostProcess(aDoc,ID_BUTTON_Test_33,TheDisplayType,Message);
2495 }
2496
2497 // Function name        : GeomSources::gpTest34
2498 // Description      : 
2499 // Return type          : void 
2500 // Argument         : CGeometryDoc* aDoc
2501 void GeomSources::gpTest34(CGeometryDoc* aDoc)
2502 {
2503   DisplayType TheDisplayType = No2D3D;
2504   PreProcess(aDoc,TheDisplayType);
2505
2506   //==============================================================
2507
2508   TColgp_Array1OfPnt array (1,5); // sizing array
2509   array.SetValue(1,gp_Pnt(0,0,1));
2510   array.SetValue(2,gp_Pnt(1,2,2));
2511   array.SetValue(3,gp_Pnt(2,3,3));
2512   array.SetValue(4,gp_Pnt(4,4,4));
2513   array.SetValue(5,gp_Pnt(5,5,5));
2514
2515   GProp_PEquation PE (array,1.5 );
2516
2517   if (PE.IsPoint())
2518   {/* ... */}
2519   gp_Lin L;
2520   if (PE.IsLinear())
2521   {
2522     L = PE.Line();
2523   }
2524   if (PE.IsPlanar())
2525   {/* ... */}
2526   if (PE.IsSpace())
2527   {/* ... */}
2528                                                                  
2529   //==============================================================
2530   TCollection_AsciiString Message (" \
2531                                                 \n\
2532 TColgp_Array1OfPnt array (1,5); // sizing array \n\
2533 array.SetValue(1,gp_Pnt(0,0,1));                \n\
2534 array.SetValue(2,gp_Pnt(1,2,2));                \n\
2535 array.SetValue(3,gp_Pnt(2,3,3));                \n\
2536 array.SetValue(4,gp_Pnt(4,4,4));                \n\
2537 array.SetValue(5,gp_Pnt(5,5,5));                \n\
2538                                                 \n\
2539 GProp_PEquation PE (array,1.5 );                \n\
2540                                                 \n\
2541 if (PE.IsPoint()){ /* ... */  }                 \n\
2542 gp_Lin L;                                       \n\
2543 if (PE.IsLinear()) {  L = PE.Line();    }       \n\
2544 if (PE.IsPlanar()){ /* ... */  }                \n\
2545 if (PE.IsSpace()) { /* ... */  }                \n\
2546                                                 \n");
2547   AddSeparator(aDoc,Message);
2548   //--------------------------------------------------------------
2549   TCollection_AsciiString aString;
2550   for(Standard_Integer i = array.Lower();i<=array.Upper();i++)
2551   {
2552     TCollection_AsciiString Message2 (i);
2553     gp_Pnt P = array(i);
2554
2555     aString = "P";
2556     aString += Message2; 
2557     DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
2558   }
2559
2560   Message += " PE.IsPoint()  = ";
2561   if (PE.IsPoint())
2562     Message += "True \n";
2563   else
2564     Message += "False\n";
2565
2566   if (PE.IsLinear()) { 
2567     Message += " PE.IsLinear() = True \n";
2568     L = PE.Line();
2569     Handle(Geom_Line) aLine = new Geom_Line(L);
2570     Handle(Geom_TrimmedCurve) aTrimmedCurve = new Geom_TrimmedCurve(aLine,-10,10);
2571     Handle(ISession_Curve) aCurve = new ISession_Curve(aTrimmedCurve);
2572     aDoc->GetAISContext()->Display(aCurve, Standard_False);
2573   }
2574   else
2575     Message += "PE.IsLinear() = False \n";
2576
2577   Message += " PE.IsPlanar() = ";
2578   if (PE.IsPlanar())
2579     Message += "True \n";
2580   else
2581     Message += "False\n";
2582
2583   Message += " PE.IsSpace() = ";
2584   if (PE.IsSpace())
2585     Message += "True \n";
2586   else
2587     Message += "False\n";
2588
2589   PostProcess(aDoc,ID_BUTTON_Test_34,TheDisplayType,Message);
2590 }
2591
2592 // Function name        : GeomSources::gpTest35
2593 // Description      : 
2594 // Return type          : void 
2595 // Argument         : CGeometryDoc* aDoc
2596 void GeomSources::gpTest35(CGeometryDoc* aDoc)
2597 {
2598   DisplayType TheDisplayType = No2D3D;
2599   PreProcess(aDoc,TheDisplayType);
2600
2601   //==============================================================
2602
2603   gp_Pnt P1(-5,-5,0);
2604   gp_Pnt P2(9,9,9);
2605   Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value();
2606   gp_Pnt P3(3,0,0);
2607   gp_Pnt P4(3,0,10);
2608   Standard_Real radius1 = 3;
2609   Standard_Real radius2 = 2;
2610   Handle(Geom_Surface) aSurface =
2611       GC_MakeConicalSurface(P3,P4,radius1,radius2).Value();
2612   GeomAPI_IntCS CS (aCurve,aSurface);
2613   Handle(Geom_Curve) segment;
2614
2615   Standard_Integer NbSeg = 0;
2616   Standard_Integer NbPoints = 0;
2617   if(CS.IsDone())
2618   {
2619     NbSeg = CS.NbSegments();
2620     for (Standard_Integer k=1; k<=NbSeg; k++)
2621     {
2622       segment = CS.Segment(k);
2623       // do something with the segment
2624     }
2625
2626     NbPoints = CS.NbPoints();
2627     for (int k=1; k<=NbPoints; k++)
2628     {
2629       gp_Pnt aPoint=CS.Point(k);
2630       // do something with the point
2631     }
2632   }
2633
2634   //==============================================================
2635   TCollection_AsciiString Message (" \
2636                                                             \n\
2637 gp_Pnt P1(-5,-5,0);                                         \n\
2638 gp_Pnt P2(9,9,9);                                           \n\
2639 Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value();  \n\
2640 gp_Pnt P3(3,0,0);                                           \n\
2641 gp_Pnt P4(3,0,10);                                          \n\
2642 Standard_Real radius1 = 3;                                  \n\
2643 Standard_Real radius2 = 2;                                  \n\
2644 Handle(Geom_Surface) aSurface =                             \n\
2645     GC_MakeConicalSurface(P3,P4,radius1,radius2).Value();   \n\
2646 GeomAPI_IntCS CS (aCurve,aSurface);                         \n\
2647 Handle(Geom_Curve) segment;                                 \n\
2648                                                             \n\
2649 Standard_Integer NbSeg;                                     \n\
2650 Standard_Integer NbPoints;                                  \n\
2651 if(CS.IsDone())                                             \n\
2652     {                                                       \n\
2653       NbSeg = CS.NbSegments();                              \n\
2654       for (Standard_Integer k=1; k<=NbSeg; k++)             \n\
2655         {                                                   \n\
2656           segment = CS.Segment(k);                          \n\
2657          // do something with the segment                   \n\
2658         }                                                   \n\
2659                                                             \n\
2660       NbPoints = CS.NbPoints();                             \n\
2661       for (k=1; k<=NbPoints; k++)                           \n\
2662         {                                                   \n\
2663           gp_Pnt aPoint=CS.Point(k);                        \n\
2664           // do something with the point                    \n\
2665         }                                                   \n\
2666     }                                                       \n\
2667                                                             \n");
2668   AddSeparator(aDoc,Message);
2669
2670   //--------------------------------------------------------------
2671  
2672   Handle(ISession_Curve) aCurve2 = new ISession_Curve(aCurve);
2673   aDoc->GetAISContext()->Display(aCurve2, Standard_False);
2674
2675   Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface= new Geom_RectangularTrimmedSurface(aSurface,-50.,50.,false);
2676
2677   DisplaySurface(aDoc,aTrimmedSurface);
2678
2679   TCollection_AsciiString aString;
2680   Standard_Integer k;
2681   if(CS.IsDone())
2682   {
2683     NbSeg = CS.NbSegments();
2684     for (k=1; k<=NbSeg; k++)
2685     {
2686       TCollection_AsciiString Message2 (k);
2687       segment = CS.Segment(k);
2688       aString = "S_";aString += Message2;
2689       Handle(ISession_Curve) aCurveN = new ISession_Curve(segment);
2690       aDoc->GetAISContext()->Display(aCurveN, Standard_False);
2691     }
2692
2693     for ( k=1; k<=NbPoints; k++)
2694     {
2695       TCollection_AsciiString Message2 (k);
2696       gp_Pnt aPoint=CS.Point(k);
2697       aString = "P_";aString += Message2;
2698       DisplayPoint(aDoc,aPoint,aString.ToCString(),false,0.5);
2699       // do something with the point
2700     }
2701   }
2702   TCollection_AsciiString Message2 (NbSeg);
2703   TCollection_AsciiString Message3 (NbPoints);
2704
2705   Message += "NbSeg       = "; Message += Message2      ; Message += "\n";
2706   Message += "NbPoints  = "; Message += Message3      ; Message += "\n";
2707
2708   PostProcess(aDoc,ID_BUTTON_Test_35,TheDisplayType,Message);
2709 }
2710
2711 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2712
2713 // Function name        : GeomSources::gpTest36
2714 // Description      : 
2715 // Return type          : void 
2716 // Argument         : CGeometryDoc* aDoc
2717 void GeomSources::gpTest36(CGeometryDoc* aDoc)
2718 {
2719   DisplayType TheDisplayType = No2D3D;
2720   PreProcess(aDoc,TheDisplayType);
2721 //==============================================================
2722
2723   gp_Pnt centre (5,5,0); gp_Pnt axispoint (9,9,0);
2724   Standard_Real radius = 3;
2725   Handle(Geom_Circle) circle =
2726   GC_MakeCircle(centre,axispoint,radius);
2727
2728   Handle(Geom_Geometry) aRotatedEntity = circle->Rotated(gp::OZ(),M_PI/4);
2729   Standard_CString aRotatedEntityTypeName = aRotatedEntity->DynamicType()->Name();
2730
2731   Handle(Geom_Geometry) aMirroredEntity = aRotatedEntity->Mirrored(gp::ZOX());
2732   Standard_CString aMirroredEntityTypeName = aMirroredEntity->DynamicType()->Name();
2733
2734   gp_Pnt scalepoint (4,8,0);
2735   Standard_Real scalefactor = 0.2;
2736   Handle(Geom_Geometry) aScaledEntity =
2737   aMirroredEntity->Scaled(scalepoint, scalefactor);
2738   Standard_CString aScaledEntityTypeName = aScaledEntity->DynamicType()->Name();
2739
2740   Handle (Geom_Transformation) GT = GC_MakeTranslation (centre, scalepoint);
2741   gp_Trsf TR = GT->Trsf();
2742
2743   gp_Vec aTranslationVector(TR.TranslationPart ());
2744   Handle(Geom_Geometry) aTranslatedEntity =
2745   aScaledEntity->Translated( aTranslationVector );
2746   Standard_CString aTranslatedEntityTypeName = aTranslatedEntity->DynamicType()->Name();
2747
2748   gp_Mat matrix = TR.HVectorialPart();
2749   Standard_Real value = matrix.Determinant();
2750
2751 //==============================================================
2752     TCollection_AsciiString Message (" \
2753                                                                                         \n\
2754 gp_Pnt centre (5,5,0);  gp_Pnt axispoint (9,9,0);                                       \n\
2755 Standard_Real radius = 3;                                                               \n\
2756 Handle(Geom_Circle) circle =                                                            \n\
2757     GC_MakeCircle(centre,axispoint,radius);                                             \n\
2758                                                                                         \n\
2759 Handle(Geom_Geometry) aRotatedEntity  = circle->Rotated(gp::OZ(),PI/4);                 \n\
2760 Standard_CString aRotatedEntityTypeName = aRotatedEntity->DynamicType()->Name();        \n\
2761                                                                                         \n\
2762 Handle(Geom_Geometry) aMirroredEntity = aRotatedEntity->Mirrored(gp::ZOX());            \n\
2763 Standard_CString aMirroredEntityTypeName = aMirroredEntity->DynamicType()->Name();      \n\
2764                                                                                         \n\
2765 gp_Pnt scalepoint (4,8,0);                                                              \n\
2766 Standard_Real scalefactor = 0.2;                                                        \n\
2767 Handle(Geom_Geometry) aScaledEntity =                                                   \n\
2768      aMirroredEntity->Scaled(scalepoint, scalefactor);                                  \n\
2769 Standard_CString aScaledEntityTypeName = aScaledEntity->DynamicType()->Name();          \n\
2770                                                                                         \n\
2771 Handle (Geom_Transformation) GT =   GC_MakeTranslation  (centre, scalepoint);           \n\
2772 gp_Trsf TR = GT->Trsf();                                                                \n\
2773                                                                                         \n");
2774    Message +="\
2775 gp_Vec aTranslationVector(TR.TranslationPart ());                                       \n\
2776 Handle(Geom_Geometry) aTranslatedEntity =                                               \n\
2777        aScaledEntity->Translated(  aTranslationVector  );                               \n\
2778 Standard_CString aTranslatedEntityTypeName = aTranslatedEntity->DynamicType()->Name();  \n\
2779                                                                                         \n\
2780 gp_Mat matrix = TR.HVectorialPart();                                                    \n\
2781 Standard_Real value = matrix.Determinant();                                             \n\
2782                                                                                         \n";
2783   AddSeparator(aDoc,Message);
2784   //--------------------------------------------------------------
2785
2786   DisplayPoint(aDoc,centre,"centre",false,0.5);
2787   DisplayPoint(aDoc,axispoint,"axispoint",false,0.5);
2788   DisplayPoint(aDoc,scalepoint,"scalepoint",false,0.5);
2789
2790   DisplayCurve(aDoc,circle, Quantity_NOC_RED,false);
2791   DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aRotatedEntity),Quantity_NOC_PEACHPUFF, false);
2792   DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aMirroredEntity), Quantity_NOC_YELLOWGREEN,false);
2793   DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aScaledEntity), Quantity_NOC_GREEN,false);
2794   DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aTranslatedEntity),Quantity_NOC_WHITE,false);
2795
2796   TCollection_AsciiString Message0 (M_PI);
2797   Message += " PI = ";
2798   Message+= Message0;
2799   Message += "\n";
2800   Message += " circle is Red; aRotatedEntity is Peach; aMirroredEntity is Yellow Green\n";
2801   Message += " aScaleEntity is Green; aTranslatedEntity is White\n\n";
2802
2803   TCollection_AsciiString Message2 (aTranslationVector.X());
2804   TCollection_AsciiString Message3 (aTranslationVector.Y());
2805   TCollection_AsciiString Message4 (aTranslationVector.Z());
2806   Message += " aTranslationVector ( ";
2807   Message += Message2; Message += " , ";
2808   Message += Message3; Message += " , ";
2809   Message += Message4; Message += " ); \n";
2810
2811   TCollection_AsciiString Message5 (value);
2812   Message += " value = ";Message+= Message5; Message += "\n";
2813
2814   TCollection_AsciiString Message6 (aRotatedEntityTypeName);
2815   TCollection_AsciiString Message7 (aMirroredEntityTypeName);
2816   TCollection_AsciiString Message8 (aScaledEntityTypeName);
2817   TCollection_AsciiString Message9 (aTranslatedEntityTypeName);
2818
2819   Message += " aRotatedEntityTypeName = ";Message+= Message6; Message += "\n";
2820   Message += " aMirroredEntityTypeName = ";Message+= Message7; Message += "\n";
2821   Message += " aScaledEntityTypeName = ";Message+= Message8; Message += "\n";
2822   Message += " aTranslatedEntityTypeName = ";Message+= Message9; Message += "\n";
2823
2824   PostProcess(aDoc,ID_BUTTON_Test_36,TheDisplayType,Message);
2825 }
2826
2827 // Function name        : GeomSources::gpTest37
2828 // Description      : 
2829 // Return type          : void 
2830 // Argument         : CGeometryDoc* aDoc
2831 void GeomSources::gpTest37(CGeometryDoc* aDoc)
2832 {
2833   DisplayType TheDisplayType = No2D3D;
2834   PreProcess(aDoc,TheDisplayType);
2835   //==============================================================
2836
2837   TColgp_Array1OfPnt anArrayofPnt (1,5); // sizing array
2838   anArrayofPnt.SetValue(1,gp_Pnt(0,0,1));
2839   anArrayofPnt.SetValue(2,gp_Pnt(1,2,2));
2840   anArrayofPnt.SetValue(3,gp_Pnt(2,3,3));
2841   anArrayofPnt.SetValue(4,gp_Pnt(4,3,4));
2842   anArrayofPnt.SetValue(5,gp_Pnt(5,5,5));
2843
2844   Standard_Real Tolerance = 1;
2845
2846   gp_Pln P;
2847   GProp_PEquation PE (anArrayofPnt,Tolerance);
2848   if (PE.IsPlanar()) { P = PE.Plane();}
2849
2850   if (PE.IsPoint()) { /* ... */ }
2851   if (PE.IsLinear()) { /* ... */ }
2852   if (PE.IsPlanar()) { P = PE.Plane();}
2853   if (PE.IsSpace()) { /* ... */ }
2854
2855   //==============================================================
2856     TCollection_AsciiString Message (" \
2857                                                                  \n\
2858 TColgp_Array1OfPnt anArrayofPnt (1,5); // sizing array           \n\
2859 anArrayofPnt.SetValue(1,gp_Pnt(0,0,1));                          \n\
2860 anArrayofPnt.SetValue(2,gp_Pnt(1,2,2));                          \n\
2861 anArrayofPnt.SetValue(3,gp_Pnt(2,3,3));                          \n\
2862 anArrayofPnt.SetValue(4,gp_Pnt(4,3,4));                          \n\
2863 anArrayofPnt.SetValue(5,gp_Pnt(5,5,5));                          \n\
2864                                                                  \n\
2865 Standard_Real Tolerance = 1;                                     \n\
2866                                                                  \n\
2867 gp_Pln P;                                                        \n\
2868 GProp_PEquation PE (anArrayofPnt,Tolerance);                     \n\
2869 if (PE.IsPlanar()) { P = PE.Plane();}                            \n\
2870                                                                  \n\
2871 if (PE.IsPoint())  { /* ... */  }                                \n\
2872 if (PE.IsLinear()) { /* ... */  }                                \n\
2873 if (PE.IsPlanar()) { P = PE.Plane();}                            \n\
2874 if (PE.IsSpace())  { /* ... */  }                                \n\
2875                                                                  \n");
2876   AddSeparator(aDoc,Message);
2877   //--------------------------------------------------------------
2878
2879   TCollection_AsciiString aString;
2880   for(Standard_Integer i = anArrayofPnt.Lower();i<=anArrayofPnt.Upper();i++){
2881     TCollection_AsciiString Message2(i);
2882     gp_Pnt aP = anArrayofPnt(i);
2883     aString = "P";
2884     aString += Message2; 
2885     DisplayPoint(aDoc,aP,aString.ToCString(),false,0.5);
2886   }
2887
2888   Message += " PE.IsPoint()  = ";  if (PE.IsPoint()) Message += "True \n";  else Message += "False\n";
2889   Message += " PE.IsLinear() = ";  if (PE.IsLinear()) Message += "True \n";  else Message += "False\n";
2890
2891   if (PE.IsPlanar()) { 
2892     Message +=  " PE.IsPlanar() = True \n";
2893     P = PE.Plane();
2894     Handle(Geom_Plane) aPlane = new Geom_Plane(P);
2895     Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-4.,4.,-4.,4.);
2896
2897     DisplaySurface(aDoc,aSurface);
2898
2899   }
2900   else
2901     Message += " PE.IsPlanar() = False \n";
2902
2903   Message += " PE.IsSpace() = ";   if (PE.IsSpace() ) Message += "True \n";  else Message += "False\n";
2904
2905   PostProcess(aDoc,ID_BUTTON_Test_37,TheDisplayType,Message);
2906 }
2907
2908 void GeomSources::gpTest38(CGeometryDoc* aDoc)
2909 {
2910   DisplayType TheDisplayType = No2D3D;
2911   PreProcess(aDoc,TheDisplayType);
2912   //==============================================================
2913
2914   TColgp_Array1OfPnt array1 (1,5); // sizing array
2915   array1.SetValue(1,gp_Pnt (-4,0,2 )); array1.SetValue(2,gp_Pnt (-7,2,2 ));
2916   array1.SetValue(3,gp_Pnt (-6,3,1 )); array1.SetValue(4,gp_Pnt (-4,3,-1));
2917   array1.SetValue(5,gp_Pnt (-3,5,-2));
2918   Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();
2919
2920   TColgp_Array1OfPnt array2 (1,5); // sizing array
2921   array2.SetValue(1,gp_Pnt (-4,0, 2)); array2.SetValue(2,gp_Pnt (-2,2,0 ));
2922   array2.SetValue(3,gp_Pnt (2 ,3,-1)); array2.SetValue(4,gp_Pnt (3 ,7,-2));
2923   array2.SetValue(5,gp_Pnt (4 ,9,-1));
2924   Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();
2925
2926   GeomFill_FillingStyle Type = GeomFill_StretchStyle;
2927   GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
2928   Handle(Geom_BSplineSurface) aBSplineSurface1 = aGeomFill1.Surface();
2929
2930   Type = GeomFill_CoonsStyle;
2931   GeomFill_BSplineCurves aGeomFill2(
2932   Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(10,0,0))),
2933   Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(10,0,0))),Type);
2934   Handle(Geom_BSplineSurface) aBSplineSurface2 = aGeomFill2.Surface();
2935   Type = GeomFill_CurvedStyle;
2936   GeomFill_BSplineCurves aGeomFill3(
2937   Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(20,0,0))),
2938   Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(20,0,0))),Type);
2939   Handle(Geom_BSplineSurface) aBSplineSurface3 = aGeomFill3.Surface();
2940
2941   //==============================================================
2942   TCollection_AsciiString Message (" \
2943                                                                                       \n\
2944 TColgp_Array1OfPnt array1 (1,5); // sizing array                                      \n\
2945 array1.SetValue(1,gp_Pnt (-4,0,2 )); array1.SetValue(2,gp_Pnt (-7,2,2 ));             \n\
2946 array1.SetValue(3,gp_Pnt (-6,3,1 )); array1.SetValue(4,gp_Pnt (-4,3,-1));             \n\
2947 array1.SetValue(5,gp_Pnt (-3,5,-2));                                                  \n\
2948 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();             \n\
2949                                                                                       \n\
2950 TColgp_Array1OfPnt array2 (1,5); // sizing array                                      \n\
2951 array2.SetValue(1,gp_Pnt (-4,0, 2)); array2.SetValue(2,gp_Pnt (-2,2,0 ));             \n\
2952 array2.SetValue(3,gp_Pnt (2 ,3,-1)); array2.SetValue(4,gp_Pnt (3 ,7,-2));             \n\
2953 array2.SetValue(5,gp_Pnt (4 ,9,-1));                                                  \n\
2954 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();             \n\
2955                                                                                       \n\
2956 GeomFill_FillingStyle Type = GeomFill_StretchStyle;                                   \n\
2957 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);                                    \n\
2958 Handle(Geom_BSplineSurface)    aBSplineSurface1 = aGeomFill1.Surface();               \n\
2959                                                                                       \n\
2960 Type = GeomFill_CoonsStyle;                                                           \n\
2961 GeomFill_BSplineCurves aGeomFill2(                                                    \n");
2962 Message += "\
2963         Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(10,0,0))),        \n\
2964         Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(10,0,0))),Type);  \n\
2965 Handle(Geom_BSplineSurface)    aBSplineSurface2 = aGeomFill2.Surface();               \n\
2966 Type = GeomFill_CurvedStyle;                                                          \n\
2967 GeomFill_BSplineCurves aGeomFill3(                                                    \n\
2968         Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(20,0,0))),        \n\
2969         Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(20,0,0))),Type);  \n\
2970 Handle(Geom_BSplineSurface)    aBSplineSurface3 = aGeomFill3.Surface();               \n\
2971                                                                                       \n";
2972   AddSeparator(aDoc,Message);
2973   //--------------------------------------------------------------
2974
2975   // Trace des frontieres.  -> FreeBoundaryAspect
2976   // Trace des isoparametriques.  --> UIsoAspect()
2977
2978   DisplaySurface(aDoc,aBSplineSurface1,Quantity_NOC_YELLOW);
2979   DisplaySurface(aDoc,aBSplineSurface2,Quantity_NOC_SALMON);
2980   DisplaySurface(aDoc,aBSplineSurface3,Quantity_NOC_HOTPINK);
2981
2982   for (int i=0;i<=2;i++)
2983   {
2984     DisplayCurve(aDoc,Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(i*10,0,0))), Quantity_NOC_RED,false);
2985     DisplayCurve(aDoc,Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(i*10,0,0))), Quantity_NOC_GREEN,false);
2986   }
2987
2988   Message += "SPL1                      is Red; \n";
2989   Message += "SPL2                      is Green; \n";
2990   Message += "aBSplineSurface1  is Yellow;       ( GeomFill_StretchStyle )\n";   
2991   Message += "aBSplineSurface2  is Salmon;     ( GeomFill_CoonsStyle ) \n";
2992   Message += "aBSplineSurface3  is Hot pink;   ( GeomFill_CurvedStyle ) \n";
2993
2994   PostProcess(aDoc,ID_BUTTON_Test_38,TheDisplayType,Message);
2995 }
2996 void GeomSources::gpTest39(CGeometryDoc* aDoc)
2997 {
2998   DisplayType TheDisplayType = No2D3D;
2999   PreProcess(aDoc,TheDisplayType);
3000   //==============================================================
3001
3002   TColgp_Array1OfPnt array1 (1,5); // sizing array
3003   array1.SetValue(1,gp_Pnt (-4,0,2 ));
3004   array1.SetValue(2,gp_Pnt (-5,1,0 ));
3005   array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3006   array1.SetValue(4,gp_Pnt (-5,4,-7));
3007   array1.SetValue(5,gp_Pnt (-3,5,-12));
3008
3009   TColgp_Array1OfPnt array2 (1,5); // sizing array
3010   array2.SetValue(1,gp_Pnt (-4,0, 2));
3011   array2.SetValue(2,gp_Pnt (-3,2,1 ));
3012   array2.SetValue(3,gp_Pnt (-1,5,0));
3013   array2.SetValue(4,gp_Pnt (2 ,7,-1));
3014   array2.SetValue(5,gp_Pnt (4 ,9,-1));
3015
3016   TColgp_Array1OfPnt array3 (1,4); // sizing array
3017   array3.SetValue(1,gp_Pnt (-3,5, -12));
3018   array3.SetValue(2,gp_Pnt (-2,6,-7 ));
3019   array3.SetValue(3,gp_Pnt (0 ,8,-3));
3020   array3.SetValue(4,gp_Pnt (4 ,9,-1));
3021
3022   Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();
3023   Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();
3024   Handle(Geom_BSplineCurve) SPL3 = GeomAPI_PointsToBSpline(array3).Curve();
3025
3026   Handle(GeomAdaptor_HCurve) SPL1Adaptor = new GeomAdaptor_HCurve(SPL1);
3027   Handle(GeomFill_SimpleBound) B1 =
3028   new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular());
3029   Handle(GeomAdaptor_HCurve) SPL2Adaptor = new GeomAdaptor_HCurve(SPL2);
3030   Handle(GeomFill_SimpleBound) B2 =
3031   new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular());
3032   Handle(GeomAdaptor_HCurve) SPL3Adaptor = new GeomAdaptor_HCurve(SPL3);
3033   Handle(GeomFill_SimpleBound) B3 =
3034   new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular());
3035   Standard_Boolean NoCheck= Standard_False;
3036
3037   Standard_Integer MaxDeg = 8;
3038   Standard_Integer MaxSeg = 2;
3039   GeomFill_ConstrainedFilling aConstrainedFilling(MaxDeg, MaxSeg);
3040
3041   aConstrainedFilling.Init(B1,B2,B3,NoCheck);
3042
3043   Handle(Geom_BSplineSurface) aBSplineSurface = aConstrainedFilling.Surface();
3044
3045 //==============================================================
3046     TCollection_AsciiString Message (" \
3047                                                                                            \n\
3048 TColgp_Array1OfPnt array1 (1,5); // sizing array                                           \n\
3049 ...                                                                                        \n\
3050 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();                  \n\
3051 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();                  \n\
3052 Handle(Geom_BSplineCurve) SPL3 = GeomAPI_PointsToBSpline(array3).Curve();                  \n\
3053                                                                                            \n\
3054 Handle(GeomAdaptor_HCurve) SPL1Adaptor = new GeomAdaptor_HCurve(SPL1);                     \n\
3055 Handle(GeomFill_SimpleBound) B1 =                                                          \n\
3056    new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular());  \n\
3057 Handle(GeomAdaptor_HCurve) SPL2Adaptor = new GeomAdaptor_HCurve(SPL2);                     \n\
3058 Handle(GeomFill_SimpleBound) B2 =                                                          \n\
3059    new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular());  \n\
3060 Handle(GeomAdaptor_HCurve) SPL3Adaptor = new GeomAdaptor_HCurve(SPL3);                     \n\
3061 Handle(GeomFill_SimpleBound) B3 =                                                          \n\
3062    new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular());  \n\
3063 Standard_Boolean NoCheck= Standard_False;                                                  \n\
3064                                                                                            \n\
3065 Standard_Integer MaxDeg = 8;                                                               \n");
3066 Message += "\
3067 Standard_Integer MaxSeg = 2;                                                               \n\
3068 GeomFill_ConstrainedFilling aConstrainedFilling(MaxDeg, MaxSeg);                           \n\
3069                                                                                            \n\
3070 aConstrainedFilling.Init(B1,B2,B3,NoCheck);                                                \n\
3071                                                                                            \n\
3072 Handle(Geom_BSplineSurface) aBSplineSurface = aConstrainedFilling.Surface();               \n\
3073                                                                                            \n";
3074   AddSeparator(aDoc,Message);
3075   //--------------------------------------------------------------
3076
3077   TCollection_AsciiString aString;
3078
3079   DisplaySurface(aDoc,aBSplineSurface,Quantity_NOC_YELLOW);
3080   DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3081   DisplayCurve(aDoc,SPL2,Quantity_NOC_GREEN ,false);
3082   DisplayCurve(aDoc,SPL3,Quantity_NOC_BLUE1 ,false);
3083
3084   Message += "SPL1                      is Red; \n";
3085   Message += "SPL2                      is Green; \n";
3086   Message += "SPL3                      is Blue; \n";
3087
3088   Message += "aBSplineSurface  is Yellow; \n";   
3089
3090   PostProcess(aDoc,ID_BUTTON_Test_39,TheDisplayType,Message);
3091 }
3092
3093 void GeomSources::gpTest40(CGeometryDoc* aDoc)
3094 {
3095   DisplayType TheDisplayType = No2D3D;
3096   PreProcess(aDoc,TheDisplayType);
3097   //==============================================================
3098
3099   TColgp_Array1OfPnt array1 (1,5); // sizing array
3100   array1.SetValue(1,gp_Pnt (-4,0,2 ));
3101   array1.SetValue(2,gp_Pnt (-5,1,0 ));
3102   array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3103   array1.SetValue(4,gp_Pnt (-5,4,-7));
3104   array1.SetValue(5,gp_Pnt (-3,5,-12));
3105
3106   Handle(Geom_Curve) SPL1 =
3107   GeomAPI_PointsToBSpline(array1).Curve();
3108
3109   GeomFill_Pipe aPipe(SPL1,1);
3110   aPipe.Perform();
3111   Handle(Geom_Surface) aSurface= aPipe.Surface();
3112   Standard_CString aSurfaceEntityTypeName="Not Computed";
3113   if (!aSurface.IsNull())
3114   aSurfaceEntityTypeName = aSurface->DynamicType()->Name();
3115
3116   Handle(Geom_Ellipse) E = GC_MakeEllipse( gp::XOY() ,3,1).Value();
3117   GeomFill_Pipe aPipe2(SPL1,E);
3118   aPipe2.Perform();
3119   Handle(Geom_Surface) aSurface2= aPipe2.Surface();
3120   Standard_CString aSurfaceEntityTypeName2="Not Computed";
3121   if (!aSurface2.IsNull()) {
3122   aSurfaceEntityTypeName2 = aSurface2->DynamicType()->Name();
3123   aSurface2->Translate(gp_Vec(5,0,0)); }
3124
3125   Handle(Geom_TrimmedCurve) TC1 =
3126   GC_MakeSegment(gp_Pnt(1,1,1),gp_Pnt(5,5,5));
3127   Handle(Geom_TrimmedCurve) TC2 =
3128   GC_MakeSegment(gp_Pnt(1,1,0),gp_Pnt(4,5,6));
3129   GeomFill_Pipe aPipe3(SPL1,TC1,TC2);
3130   aPipe3.Perform();
3131   Handle(Geom_Surface) aSurface3 = aPipe3.Surface();
3132   Standard_CString aSurfaceEntityTypeName3="Not Computed";
3133   if (!aSurface3.IsNull())
3134   {
3135   aSurfaceEntityTypeName3 = aSurface3->DynamicType()->Name();
3136   aSurface3->Translate(gp_Vec(10,0,0));
3137   }
3138
3139   //==============================================================
3140     TCollection_AsciiString Message (" \
3141                                                                    \n\
3142                                                                    \n\
3143 TColgp_Array1OfPnt array1 (1,5); // sizing array                   \n\
3144 array1.SetValue(1,gp_Pnt (-4,0,2 ));                               \n\
3145 array1.SetValue(2,gp_Pnt (-5,1,0 ));                               \n\
3146 array1.SetValue(3,gp_Pnt (-6,2,-2 ));                              \n\
3147 array1.SetValue(4,gp_Pnt (-5,4,-7));                               \n\
3148 array1.SetValue(5,gp_Pnt (-3,5,-12));                              \n\
3149                                                                    \n\
3150 Handle(Geom_BSplineCurve) SPL1 =                                   \n\
3151     GeomAPI_PointsToBSpline(array1).Curve();                       \n\
3152                                                                    \n\
3153 GeomFill_Pipe aPipe(SPL1,1);                                       \n\
3154 aPipe.Perform();                                                   \n\
3155 Handle(Geom_Surface) aSurface= aPipe.Surface();                    \n\
3156 Standard_CString aSurfaceEntityTypeName=\"Not Computed\";            \n\
3157 if (!aSurface.IsNull())                                            \n\
3158    aSurfaceEntityTypeName = aSurface->DynamicType()->Name();       \n\
3159                                                                    \n\
3160 Handle(Geom_Ellipse) E = GC_MakeEllipse( gp::XOY() ,3,1).Value();  \n\
3161 GeomFill_Pipe aPipe2(SPL1,E);                                      \n\
3162 aPipe2.Perform();                                                  \n");
3163 Message += "\
3164 Handle(Geom_Surface) aSurface2= aPipe2.Surface();                  \n\
3165 Standard_CString aSurfaceEntityTypeName2=\"Not Computed\";           \n\
3166 if (!aSurface2.IsNull())  {                                        \n\
3167     aSurfaceEntityTypeName2 = aSurface2->DynamicType()->Name();    \n\
3168     aSurface2->Translate(gp_Vec(5,0,0));  }                        \n\
3169                                                                    \n\
3170 Handle(Geom_TrimmedCurve) TC1 =                                    \n\
3171     GC_MakeSegment(gp_Pnt(1,1,1),gp_Pnt(5,5,5));                   \n\
3172 Handle(Geom_TrimmedCurve) TC2 =                                    \n\
3173     GC_MakeSegment(gp_Pnt(1,1,0),gp_Pnt(4,5,6));                   \n\
3174 GeomFill_Pipe aPipe3(SPL1,TC1,TC2);                                \n\
3175 aPipe3.Perform();                                                  \n\
3176 Handle(Geom_Surface) aSurface3 = aPipe3.Surface();                 \n\
3177 Standard_CString aSurfaceEntityTypeName3=\"Not Computed\";           \n\
3178 if (!aSurface3.IsNull())                                           \n\
3179   {                                                                \n\
3180     aSurfaceEntityTypeName3 = aSurface3->DynamicType()->Name();    \n\
3181         aSurface3->Translate(gp_Vec(10,0,0));                      \n\
3182   }                                                                \n\
3183                                                                  \n";
3184   AddSeparator(aDoc,Message);
3185   //--------------------------------------------------------------
3186
3187   if (!aSurface.IsNull())
3188   {
3189     DisplaySurface(aDoc,aSurface,Quantity_NOC_YELLOW);
3190   }
3191   if (!aSurface2.IsNull())
3192   {
3193     DisplaySurface(aDoc,aSurface2,Quantity_NOC_YELLOW);
3194   }
3195   if (!aSurface3.IsNull())
3196   {
3197     DisplaySurface(aDoc,aSurface3,Quantity_NOC_YELLOW);
3198   }
3199
3200   DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3201
3202   Message += "SPL1                      is Red; \n";
3203
3204
3205   TCollection_AsciiString Message2(aSurfaceEntityTypeName);
3206   TCollection_AsciiString Message3(aSurfaceEntityTypeName2);
3207   TCollection_AsciiString Message4(aSurfaceEntityTypeName3);
3208
3209   Message += " aSurfaceEntityTypeName     = ";Message+= Message2; Message += "\n";
3210   Message += " aSurfaceEntityTypeName2     = ";Message+= Message3; Message += "\n";
3211   Message += " aSurfaceEntityTypeName3     = ";Message+= Message4; Message += "\n";
3212
3213   PostProcess(aDoc,ID_BUTTON_Test_40,TheDisplayType,Message);
3214 }
3215
3216 void GeomSources::gpTest41(CGeometryDoc* aDoc)
3217 {
3218   DisplayType TheDisplayType = No2D3D;
3219   PreProcess(aDoc,TheDisplayType);
3220   //==============================================================
3221
3222   TColgp_Array1OfPnt array1 (1,5);
3223   array1.SetValue(1,gp_Pnt (-4,0,2 ));
3224   array1.SetValue(2,gp_Pnt (-5,1,0 ));
3225   array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3226   array1.SetValue(4,gp_Pnt (-5,4,-7));
3227   array1.SetValue(5,gp_Pnt (-3,5,-12));
3228
3229   Handle(Geom_BSplineCurve) SPL1 =
3230     GeomAPI_PointsToBSpline(array1).Curve();
3231   Handle(Geom_Curve) FirstSect =
3232     GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value();
3233
3234   GeomFill_Pipe aPipe(SPL1,FirstSect);
3235   aPipe.Perform();
3236
3237   Handle(Geom_BSplineSurface) aPipeSurface =
3238     Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface());
3239   Handle(Geom_BSplineSurface) anotherBSplineSurface =
3240     GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6);
3241
3242   //==============================================================
3243   TCollection_AsciiString Message (" \
3244                                                                    \n\
3245 TColgp_Array1OfPnt array1 (1,5);                                   \n\
3246 array1.SetValue(1,gp_Pnt (-4,0,2 ));                               \n\
3247 array1.SetValue(2,gp_Pnt (-5,1,0 ));                               \n\
3248 array1.SetValue(3,gp_Pnt (-6,2,-2 ));                              \n\
3249 array1.SetValue(4,gp_Pnt (-5,4,-7));                               \n\
3250 array1.SetValue(5,gp_Pnt (-3,5,-12));                              \n\
3251                                                                    \n\
3252 Handle(Geom_BSplineCurve) SPL1 =                                   \n\
3253     GeomAPI_PointsToBSpline(array1).Curve();                       \n\
3254 Handle(Geom_Curve) FirstSect =                                     \n\
3255     GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value();        \n\
3256                                                                    \n\
3257 GeomFill_Pipe aPipe(SPL1,FirstSect);                               \n\
3258 aPipe.Perform();                                                   \n\
3259                                                                    \n\
3260 Handle(Geom_BSplineSurface) aPipeSurface =                         \n\
3261     Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface());        \n\
3262 Handle(Geom_BSplineSurface) anotherBSplineSurface =                \n\
3263     GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6);        \n\
3264                                                                    \n");
3265   AddSeparator(aDoc,Message);
3266   //--------------------------------------------------------------
3267
3268   if(!aPipeSurface.IsNull())
3269   {
3270     DisplaySurface(aDoc,aPipeSurface,Quantity_NOC_YELLOW);
3271   }
3272
3273   if(!anotherBSplineSurface.IsNull())
3274   {
3275     DisplaySurface(aDoc,anotherBSplineSurface,Quantity_NOC_HOTPINK);
3276   }
3277
3278   DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3279   DisplayCurve(aDoc,FirstSect,Quantity_NOC_GREEN ,false);
3280
3281   Message += "SPL1                              is Red; \n";
3282   Message += "SPL2                              is Green; \n";
3283   Message += "SPL3                              is Blue; \n";
3284   Message += "aBSplineSurface            is Yellow; \n";   
3285   Message += "anotherBSplineSurface  is Hot Pink; \n";   
3286
3287   PostProcess(aDoc,ID_BUTTON_Test_41,TheDisplayType,Message);
3288 }
3289
3290
3291 void GeomSources::gpTest42(CGeometryDoc* aDoc)
3292 {
3293   DisplayType TheDisplayType = No2D3D;
3294   PreProcess(aDoc,TheDisplayType);
3295
3296   //==============================================================
3297
3298   TColgp_Array2OfPnt array1(1,3,1,3);
3299   TColgp_Array2OfPnt array2(1,3,1,3);
3300   TColgp_Array2OfPnt array3(1,3,1,3);
3301   TColgp_Array2OfPnt array4(1,3,1,3);
3302
3303   array1.SetValue(1,1,gp_Pnt(1,1,1));
3304   array1.SetValue(1,2,gp_Pnt(2,1,2));
3305   array1.SetValue(1,3,gp_Pnt(3,1,1));
3306   array1.SetValue(2,1,gp_Pnt(1,2,1));
3307   array1.SetValue(2,2,gp_Pnt(2,2,2));
3308   array1.SetValue(2,3,gp_Pnt(3,2,0));
3309   array1.SetValue(3,1,gp_Pnt(1,3,2));
3310   array1.SetValue(3,2,gp_Pnt(2,3,1));
3311   array1.SetValue(3,3,gp_Pnt(3,3,0));
3312
3313   array2.SetValue(1,1,gp_Pnt(3,1,1));
3314   array2.SetValue(1,2,gp_Pnt(4,1,1));
3315   array2.SetValue(1,3,gp_Pnt(5,1,2));
3316   array2.SetValue(2,1,gp_Pnt(3,2,0));
3317   array2.SetValue(2,2,gp_Pnt(4,2,1));
3318   array2.SetValue(2,3,gp_Pnt(5,2,2));
3319   array2.SetValue(3,1,gp_Pnt(3,3,0));
3320   array2.SetValue(3,2,gp_Pnt(4,3,0));
3321   array2.SetValue(3,3,gp_Pnt(5,3,1));
3322
3323   array3.SetValue(1,1,gp_Pnt(1,3,2));
3324   array3.SetValue(1,2,gp_Pnt(2,3,1));
3325   array3.SetValue(1,3,gp_Pnt(3,3,0));
3326   array3.SetValue(2,1,gp_Pnt(1,4,1));
3327   array3.SetValue(2,2,gp_Pnt(2,4,0));
3328   array3.SetValue(2,3,gp_Pnt(3,4,1));
3329   array3.SetValue(3,1,gp_Pnt(1,5,1));
3330   array3.SetValue(3,2,gp_Pnt(2,5,1));
3331   array3.SetValue(3,3,gp_Pnt(3,5,2));
3332
3333   array4.SetValue(1,1,gp_Pnt(3,3,0));
3334   array4.SetValue(1,2,gp_Pnt(4,3,0));
3335   array4.SetValue(1,3,gp_Pnt(5,3,1));
3336   array4.SetValue(2,1,gp_Pnt(3,4,1));
3337   array4.SetValue(2,2,gp_Pnt(4,4,1));
3338   array4.SetValue(2,3,gp_Pnt(5,4,1));
3339   array4.SetValue(3,1,gp_Pnt(3,5,2));
3340   array4.SetValue(3,2,gp_Pnt(4,5,2));
3341   array4.SetValue(3,3,gp_Pnt(5,5,1));
3342
3343   Handle(Geom_BezierSurface) BZ1 =
3344     new Geom_BezierSurface(array1);
3345   Handle(Geom_BezierSurface) BZ2 =
3346     new Geom_BezierSurface(array2);
3347   Handle(Geom_BezierSurface) BZ3 =
3348     new Geom_BezierSurface(array3);
3349   Handle(Geom_BezierSurface) BZ4 =
3350     new Geom_BezierSurface(array4);
3351
3352   TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2);
3353   bezierarray.SetValue(1,1,BZ1);
3354   bezierarray.SetValue(1,2,BZ2);
3355   bezierarray.SetValue(2,1,BZ3);
3356   bezierarray.SetValue(2,2,BZ4);
3357
3358   GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray);
3359   Handle(Geom_BSplineSurface) BSPLSURF ;
3360   if (BB.IsDone())
3361   {
3362     BSPLSURF = new Geom_BSplineSurface(
3363       BB.Poles()->Array2(),
3364       BB.UKnots()->Array1(),
3365       BB.VKnots()->Array1(),
3366       BB.UMultiplicities()->Array1(),
3367       BB.VMultiplicities()->Array1(),
3368       BB.UDegree(),
3369       BB.VDegree() );
3370     BSPLSURF->Translate(gp_Vec(0,0,2));
3371   }
3372
3373   //==============================================================
3374
3375   TCollection_AsciiString Message (" \
3376                                                                   \n\
3377 TColgp_Array2OfPnt array1(1,3,1,3);                               \n\
3378 TColgp_Array2OfPnt array2(1,3,1,3);                               \n\
3379 TColgp_Array2OfPnt array3(1,3,1,3);                               \n\
3380 TColgp_Array2OfPnt array4(1,3,1,3);                               \n\
3381                                                                   \n\
3382 // array1.SetValue(  ...                                          \n\
3383                                                                   \n\
3384 Handle(Geom_BezierSurface) BZ1 =                                  \n\
3385     new Geom_BezierSurface(array1);                               \n\
3386 Handle(Geom_BezierSurface) BZ2 =                                  \n\
3387     new Geom_BezierSurface(array2);                               \n\
3388 Handle(Geom_BezierSurface) BZ3 =                                  \n\
3389     new Geom_BezierSurface(array3);                               \n\
3390 Handle(Geom_BezierSurface) BZ4 =                                  \n\
3391     new Geom_BezierSurface(array4);                               \n\
3392                                                                   \n\
3393 TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2);              \n\
3394 bezierarray.SetValue(1,1,BZ1);                                    \n\
3395 bezierarray.SetValue(1,2,BZ2);                                    \n\
3396 bezierarray.SetValue(2,1,BZ3);                                    \n\
3397 bezierarray.SetValue(2,2,BZ4);                                    \n\
3398                                                                   \n\
3399 GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray);  \n\
3400    Handle(Geom_BSplineSurface) BSPLSURF ;                         \n\
3401 if (BB.IsDone()){                                                 \n\
3402    BSPLSURF = new Geom_BSplineSurface(                            \n\
3403         BB.Poles()->Array2(),                                     \n\
3404         BB.UKnots()->Array1(),                                    \n");
3405         Message += "\
3406         BB.VKnots()->Array1(),                                    \n\
3407         BB.UMultiplicities()->Array1(),                           \n\
3408         BB.VMultiplicities()->Array1(),                           \n\
3409         BB.UDegree(),                                             \n\
3410         BB.VDegree() );                                           \n\
3411     BSPLSURF->Translate(gp_Vec(0,0,2));                           \n\
3412     }                                                             \n\
3413                                                                   \n";
3414   AddSeparator(aDoc,Message);
3415   //--------------------------------------------------------------
3416
3417   DisplaySurface(aDoc,BZ1,Quantity_NOC_RED);
3418   DisplaySurface(aDoc,BZ2,Quantity_NOC_GREEN);
3419   DisplaySurface(aDoc,BZ3,Quantity_NOC_BLUE1);
3420   DisplaySurface(aDoc,BZ4,Quantity_NOC_BROWN);
3421
3422   if (BB.IsDone()){
3423     DisplaySurface(aDoc,BSPLSURF,Quantity_NOC_HOTPINK);
3424   }
3425
3426   Message += "BZ1 is Red; \n";
3427   Message += "BZ2 is Green; \n";
3428   Message += "BZ3 is Blue; \n";
3429   Message += "BZ4 is Brown; \n";
3430   Message += "BSPLSURF is Hot Pink; \n";
3431
3432   PostProcess(aDoc,ID_BUTTON_Test_42,TheDisplayType,Message);
3433 }
3434
3435 void GeomSources::gpTest43(CGeometryDoc* aDoc)
3436 {
3437   DisplayType TheDisplayType = No2D3D;
3438   PreProcess(aDoc,TheDisplayType);
3439   //==============================================================
3440
3441   TColgp_Array1OfPnt array1 (1,5);
3442   array1.SetValue(1,gp_Pnt (-4,5,5 ));
3443   array1.SetValue(2,gp_Pnt (-3,6,6 ));
3444   array1.SetValue(3,gp_Pnt (-1,7,7 ));
3445   array1.SetValue(4,gp_Pnt (0,8,8));
3446   array1.SetValue(5,gp_Pnt (2,9,9));
3447   Handle(Geom_BSplineCurve) SPL1 =
3448     GeomAPI_PointsToBSpline(array1).Curve();
3449
3450   TColgp_Array1OfPnt array2 (1,5);
3451   array2.SetValue(1,gp_Pnt (-4,5,2 ));
3452   array2.SetValue(2,gp_Pnt (-3,6,3 ));
3453   array2.SetValue(3,gp_Pnt (-1,7,4 ));
3454   array2.SetValue(4,gp_Pnt (0,8,5));
3455   array2.SetValue(5,gp_Pnt (2,9,6));
3456   Handle(Geom_BSplineCurve) SPL2 =
3457     GeomAPI_PointsToBSpline(array2).Curve();
3458
3459   GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3460   GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3461   Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3462   Standard_Real offset = 1;
3463   Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset);
3464   offset = 2;
3465   Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset);
3466   offset = 3;
3467   Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset);
3468
3469   //==============================================================
3470   TCollection_AsciiString Message (" \
3471                                                                                  \n\
3472 TColgp_Array1OfPnt array1 (1,5);                                                 \n\
3473 //array1.SetValue( ...                                                           \n\
3474 Handle(Geom_BSplineCurve) SPL1 =                                                 \n\
3475         GeomAPI_PointsToBSpline(array1).Curve();                                     \n\
3476                                                                                  \n\
3477 TColgp_Array1OfPnt array2 (1,5);                                                 \n\
3478 // array2.SetValue( ...                                                          \n\
3479                                                                                  \n\
3480 Handle(Geom_BSplineCurve) SPL2 =                                                 \n\
3481         GeomAPI_PointsToBSpline(array2).Curve();                                     \n\
3482                                                                                  \n\
3483 GeomFill_FillingStyle Type = GeomFill_StretchStyle;                              \n\
3484 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);                               \n\
3485 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();                 \n\
3486 Standard_Real offset = 1;                                                        \n\
3487 Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset);   \n\
3488  offset = 2;                                                                     \n\
3489 Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset);  \n\
3490 offset = 3;                                                                      \n\
3491 Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset);  \n\
3492                                                                                  \n");
3493   AddSeparator(aDoc,Message);
3494   //--------------------------------------------------------------
3495
3496   DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_BLUE1);
3497   DisplaySurface(aDoc,GOS,Quantity_NOC_GREEN);
3498   DisplaySurface(aDoc,GOS1,Quantity_NOC_GREEN);
3499   DisplaySurface(aDoc,GOS2,Quantity_NOC_GREEN);
3500
3501   DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3502   DisplayCurve(aDoc,SPL2,Quantity_NOC_HOTPINK ,false);
3503
3504   Message += "aGeomSurface  is Blue; \n";
3505   Message += "GOS              are Green; \n";
3506
3507   PostProcess(aDoc,ID_BUTTON_Test_43,TheDisplayType,Message);
3508 }
3509
3510 void GeomSources::gpTest44(CGeometryDoc* aDoc)
3511 {
3512   DisplayType TheDisplayType = No2D3D;
3513   PreProcess(aDoc,TheDisplayType);
3514   //==============================================================
3515
3516   gp_Pnt P1(0,0,1);
3517   gp_Pnt P2(1,2,2);
3518   gp_Pnt P3(2,3,3);
3519   gp_Pnt P4(4,3,4);
3520   gp_Pnt P5(5,5,5);
3521   TColgp_Array1OfPnt array (1,5);
3522   array.SetValue(1,P1);
3523   array.SetValue(2,P2);
3524   array.SetValue(3,P3);
3525   array.SetValue(4,P4);
3526   array.SetValue(5,P5);
3527   Handle(Geom_BSplineCurve) aCurve =
3528     GeomAPI_PointsToBSpline(array).Curve();
3529   gp_Dir aDir(1,2,3);
3530   Handle(Geom_SurfaceOfLinearExtrusion) SOLE =
3531     new Geom_SurfaceOfLinearExtrusion(aCurve,aDir);
3532
3533   Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface =
3534     new Geom_RectangularTrimmedSurface(SOLE,-10,10,false);
3535
3536   Standard_CString SOLEEntityTypeName="Not Computed";
3537   if (!SOLE.IsNull())
3538   {
3539     SOLEEntityTypeName = SOLE->DynamicType()->Name();
3540   }
3541
3542   //==============================================================
3543
3544   TCollection_AsciiString Message (" \
3545                                                            \n\
3546 gp_Pnt P1(0,0,1);                                          \n\
3547 gp_Pnt P2(1,2,2);                                          \n\
3548 gp_Pnt P3(2,3,3);                                          \n\
3549 gp_Pnt P4(4,3,4);                                          \n\
3550 gp_Pnt P5(5,5,5);                                          \n\
3551 TColgp_Array1OfPnt array (1,5);                            \n\
3552 array.SetValue(1,P1);                                      \n\
3553 array.SetValue(2,P2);                                      \n\
3554 array.SetValue(3,P3);                                      \n\
3555 array.SetValue(4,P4);                                      \n\
3556 array.SetValue(5,P5);                                      \n\
3557 Handle(Geom_BSplineCurve) aCurve =                         \n\
3558         GeomAPI_PointsToBSpline(array).Curve();                \n\
3559 gp_Dir aDir(1,2,3);                                        \n\
3560 Handle(Geom_SurfaceOfLinearExtrusion) SOLE =               \n\
3561         new Geom_SurfaceOfLinearExtrusion(aCurve,aDir);        \n\
3562                                                            \n\
3563 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface =   \n\
3564    new Geom_RectangularTrimmedSurface(SOLE,-10,10,false);  \n\
3565                                                            \n\
3566 Standard_CString SOLEEntityTypeName=\"Not Computed\";        \n\
3567 if (!SOLE.IsNull())                                        \n\
3568   {                                                        \n\
3569     SOLEEntityTypeName = SOLE->DynamicType()->Name();      \n\
3570   }                                                        \n\
3571                                                            \n");
3572   AddSeparator(aDoc,Message);
3573   //--------------------------------------------------------------
3574
3575   DisplaySurface(aDoc,aTrimmedSurface,Quantity_NOC_GREEN);
3576   DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
3577
3578   Message += "aCurve   is Red; \n";
3579   Message += "aTrimmedSurface       is Green; \n";
3580
3581   TCollection_AsciiString Message2 (SOLEEntityTypeName);
3582
3583   Message += " SOLEEntityTypeName     = ";Message+= Message2; Message += "\n";
3584
3585   PostProcess(aDoc,ID_BUTTON_Test_44,TheDisplayType,Message);
3586 }
3587
3588 void GeomSources::gpTest45(CGeometryDoc* aDoc)
3589 {
3590   DisplayType TheDisplayType = No2D3D;
3591   PreProcess(aDoc,TheDisplayType);
3592
3593   //==============================================================
3594
3595   TColgp_Array1OfPnt array (1,5);
3596   array.SetValue(1,gp_Pnt (0,0,1));
3597   array.SetValue(2,gp_Pnt (1,2,2));
3598   array.SetValue(3,gp_Pnt (2,3,3));
3599   array.SetValue(4,gp_Pnt (4,3,4));
3600   array.SetValue(5,gp_Pnt (5,5,5));
3601   Handle(Geom_BSplineCurve) aCurve =
3602     GeomAPI_PointsToBSpline(array).Curve();
3603   Handle(Geom_SurfaceOfRevolution) SOR =
3604     new Geom_SurfaceOfRevolution(aCurve,gp::OX());
3605
3606   Standard_CString SOREntityTypeName="Not Computed";
3607   if (!SOR.IsNull())
3608     SOREntityTypeName = SOR->DynamicType()->Name();
3609
3610   //==============================================================
3611   TCollection_AsciiString Message (" \
3612                                                      \n\
3613 TColgp_Array1OfPnt array (1,5);                      \n\
3614 array.SetValue(1,gp_Pnt 0,0,1));                     \n\
3615 array.SetValue(2,gp_Pnt (1,2,2));                    \n\
3616 array.SetValue(3,gp_Pnt (2,3,3));                    \n\
3617 array.SetValue(4,gp_Pnt (4,3,4));                    \n\
3618 array.SetValue(5,gp_Pnt (5,5,5));                    \n\
3619 Handle(Geom_BSplineCurve) aCurve =                   \n\
3620     GeomAPI_PointsToBSpline(array).Curve();          \n\
3621 Handle(Geom_SurfaceOfRevolution) SOR =               \n\
3622     new Geom_SurfaceOfRevolution(aCurve,gp::OX());   \n\
3623                                                      \n\
3624 Standard_CString SOREntityTypeName=\"Not Computed\";   \n\
3625 if (!SOR.IsNull())                                   \n\
3626     SOREntityTypeName = SOR->DynamicType()->Name();  \n\
3627                                                      \n");
3628   AddSeparator(aDoc,Message);
3629
3630   //--------------------------------------------------------------
3631   DisplaySurface(aDoc,SOR,Quantity_NOC_GREEN);
3632   DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
3633
3634   Message += "aCurve   is Red; \n";
3635   Message += "SOR       is Green; \n";
3636   TCollection_AsciiString Message2 (SOREntityTypeName);
3637   Message += " SOREntityTypeName     = ";Message+= Message2; Message += "\n";
3638
3639   PostProcess(aDoc,ID_BUTTON_Test_45,TheDisplayType,Message);
3640 }
3641
3642 void GeomSources::gpTest46(CGeometryDoc* aDoc)
3643 {
3644   DisplayType TheDisplayType = No2D3D;
3645   PreProcess(aDoc,TheDisplayType);
3646   //==============================================================
3647
3648   TColgp_Array1OfPnt array1 (1,5);
3649   array1.SetValue(1,gp_Pnt (-4,5,5 ));
3650   array1.SetValue(2,gp_Pnt (-3,6,6 ));
3651   array1.SetValue(3,gp_Pnt (-1,6,7 ));
3652   array1.SetValue(4,gp_Pnt (0,8,8));
3653   array1.SetValue(5,gp_Pnt (2,9,9));
3654   Handle(Geom_BSplineCurve) SPL1 =
3655     GeomAPI_PointsToBSpline(array1).Curve();
3656
3657   TColgp_Array1OfPnt array2 (1,5);
3658   array2.SetValue(1,gp_Pnt (-4,5,2 ));
3659   array2.SetValue(2,gp_Pnt (-3,6,3 ));
3660   array2.SetValue(3,gp_Pnt (-1,7,4 ));
3661   array2.SetValue(4,gp_Pnt (0,8,5));
3662   array2.SetValue(5,gp_Pnt (2,9,6));
3663   Handle(Geom_BSplineCurve) SPL2 =
3664     GeomAPI_PointsToBSpline(array2).Curve();
3665
3666   GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3667   GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3668   Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3669
3670   Handle(Geom_BoundedSurface) aTranslatedGeomSurface =
3671     Handle(Geom_BoundedSurface)::DownCast(aGeomSurface->Copy());
3672
3673   Standard_Real extension = 3;
3674   Standard_Integer continuity = 2;
3675   Standard_Boolean Udirection = Standard_True;
3676   Standard_Boolean after = Standard_True;
3677   GeomLib::ExtendSurfByLength (aTranslatedGeomSurface,
3678     extension,continuity,Udirection,after);
3679
3680   //==============================================================
3681     TCollection_AsciiString Message (" \
3682                                                                   \n\
3683 TColgp_Array1OfPnt array1 (1,5);                                  \n\
3684 // ...                                                            \n\
3685 Handle(Geom_BSplineCurve) SPL1 =                                  \n\
3686         GeomAPI_PointsToBSpline(array1).Curve();                      \n\
3687                                                                   \n\
3688 TColgp_Array1OfPnt array2 (1,5);                                  \n\
3689 // ...                                                            \n\
3690 Handle(Geom_BSplineCurve) SPL2 =                                  \n\
3691         GeomAPI_PointsToBSpline(array2).Curve();                      \n\
3692                                                                   \n\
3693 GeomFill_FillingStyle Type = GeomFill_StretchStyle;               \n\
3694 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);                \n\
3695 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();  \n\
3696                                                                   \n\
3697 Handle(Geom_BoundedSurface) aTranslatedGeomSurface =              \n\
3698    Handle(Geom_BoundedSurface)::DownCast(aGeomSurface->Copy());   \n\
3699                                                                   \n\
3700 Standard_Real extension = 3;                                      \n\
3701 Standard_Integer continuity = 2;                                  \n\
3702 Standard_Boolean Udirection = Standard_True;                      \n\
3703 Standard_Boolean after = Standard_True;                           \n\
3704 GeomLib::ExtendSurfByLength (aTranslatedGeomSurface,              \n\
3705         extension,continuity,Udirection,after);                       \n\
3706                                                                   \n");
3707   AddSeparator(aDoc,Message);
3708   //--------------------------------------------------------------
3709
3710   if (!aGeomSurface.IsNull())
3711   {
3712     DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_HOTPINK);
3713   }
3714
3715   if (!aTranslatedGeomSurface.IsNull())
3716   {
3717     DisplaySurface(aDoc,aTranslatedGeomSurface,Quantity_NOC_BLUE1);
3718   }
3719
3720   DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3721   DisplayCurve(aDoc,SPL2,Quantity_NOC_GREEN ,false);
3722
3723   Message += "aGeomSurface                    is Hot Pink; \n";
3724   Message += "aTranslatedGeomSurface   is Blue; \n";
3725   Message += "SPL1                                   is Red; \n";
3726   Message += "SPL2                                   is Green; \n";
3727
3728   PostProcess(aDoc,ID_BUTTON_Test_46,TheDisplayType,Message);
3729 }
3730
3731 void GeomSources::gpTest47(CGeometryDoc* aDoc)
3732 {
3733   DisplayType TheDisplayType = No2D3D;
3734   PreProcess(aDoc,TheDisplayType);
3735
3736   //==============================================================
3737
3738
3739   TColgp_Array1OfPnt array1 (1,5);
3740   array1.SetValue(1,gp_Pnt (-5,1,2));
3741   array1.SetValue(2,gp_Pnt (-5,2,2));
3742   array1.SetValue(3,gp_Pnt (-5.3,3,1));
3743   array1.SetValue(4,gp_Pnt (-5,4,1));
3744   array1.SetValue(5,gp_Pnt (-5,5,2));
3745   Handle(Geom_BSplineCurve) SPL1 =
3746     GeomAPI_PointsToBSpline(array1).Curve();
3747
3748   TColgp_Array1OfPnt array2 (1,5);
3749   array2.SetValue(1,gp_Pnt (4,1,2));
3750   array2.SetValue(2,gp_Pnt (4,2,2));
3751   array2.SetValue(3,gp_Pnt (3.7,3,1));
3752   array2.SetValue(4,gp_Pnt (4,4,1));
3753   array2.SetValue(5,gp_Pnt (4,5,2));
3754   Handle(Geom_BSplineCurve) SPL2 =
3755     GeomAPI_PointsToBSpline(array2).Curve();
3756
3757   GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3758
3759   GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3760   Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface();
3761
3762   TColgp_Array2OfPnt array3 (1,5,1,5);
3763   array3.SetValue(1,1,gp_Pnt (-4,-4,5));
3764   array3.SetValue(1,2,gp_Pnt (-4,-2,5));
3765   array3.SetValue(1,3,gp_Pnt (-4,0,4));
3766   array3.SetValue(1,4,gp_Pnt (-4,2,5));
3767   array3.SetValue(1,5,gp_Pnt (-4,4,5));
3768
3769   array3.SetValue(2,1,gp_Pnt (-2,-4,4));
3770   array3.SetValue(2,2,gp_Pnt (-2,-2,4));
3771   array3.SetValue(2,3,gp_Pnt (-2,0,4));
3772   array3.SetValue(2,4,gp_Pnt (-2,2,4));
3773   array3.SetValue(2,5,gp_Pnt (-2,5,4));
3774
3775   array3.SetValue(3,1,gp_Pnt (0,-4,3.5));
3776   array3.SetValue(3,2,gp_Pnt (0,-2,3.5));
3777   array3.SetValue(3,3,gp_Pnt (0,0,3.5));
3778   array3.SetValue(3,4,gp_Pnt (0,2,3.5));
3779   array3.SetValue(3,5,gp_Pnt (0,5,3.5));
3780
3781   array3.SetValue(4,1,gp_Pnt (2,-4,4));
3782   array3.SetValue(4,2,gp_Pnt (2,-2,4));
3783   array3.SetValue(4,3,gp_Pnt (2,0,3.5));
3784   array3.SetValue(4,4,gp_Pnt (2,2,5));
3785   array3.SetValue(4,5,gp_Pnt (2,5,4));
3786
3787   array3.SetValue(5,1,gp_Pnt (4,-4,5));
3788   array3.SetValue(5,2,gp_Pnt (4,-2,5));
3789   array3.SetValue(5,3,gp_Pnt (4,0,5));
3790   array3.SetValue(5,4,gp_Pnt (4,2,6));
3791   array3.SetValue(5,5,gp_Pnt (4,5,5));
3792
3793   Handle(Geom_BSplineSurface) aSurf2 =
3794     GeomAPI_PointsToBSplineSurface(array3).Surface();
3795
3796   GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2);
3797   //Quantity_Length dist = ESS.LowerDistance();
3798   gp_Pnt P1,P2;
3799   ESS.NearestPoints(P1,P2);
3800
3801   gp_Pnt P3,P4;
3802   Handle(Geom_Curve) aCurve;
3803   Standard_Integer NbExtrema = ESS.NbExtrema();
3804   for(Standard_Integer k=1;k<=NbExtrema;k++){
3805     ESS.Points(k,P3,P4);
3806     aCurve= GC_MakeSegment(P3,P4).Value();
3807     DisplayCurve(aDoc,aCurve,Quantity_NOC_YELLOW3,false);
3808 }
3809
3810 //==============================================================
3811
3812     TCollection_AsciiString Message ("                         \n\
3813 GeomFill_FillingStyle Type = GeomFill_StretchStyle;            \n\
3814                                                                \n\
3815 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);             \n\
3816 Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface();     \n\
3817                                                                \n\
3818 Handle(Geom_BSplineSurface) aSurf2 =                           \n\
3819         GeomAPI_PointsToBSplineSurface(array3).Surface();          \n\
3820                                                                \n\
3821 GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2);              \n\
3822 Quantity_Length dist = ESS.LowerDistance();                    \n\
3823 gp_Pnt P1,P2;                                                  \n\
3824 ESS.NearestPoints(P1,P2);                                      \n\
3825                                                                \n"); 
3826
3827   AddSeparator(aDoc,Message);
3828   Message += "aSurf1   is Green; \n";
3829   Message += "aSurf2   is Hot Pink; \n";
3830   Message += "Nearest points P1 and P2 are shown; \n";
3831
3832   //--------------------------------------------------------------
3833
3834 //mfa
3835
3836   DisplaySurface(aDoc,aSurf1,Quantity_NOC_GREEN);
3837   DisplaySurface(aDoc,aSurf2,Quantity_NOC_HOTPINK);
3838   DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3839   DisplayCurve(aDoc,SPL2,Quantity_NOC_AZURE ,false);
3840
3841   DisplayPoint(aDoc,P1,Standard_CString("P1"));
3842   DisplayPoint(aDoc,P2,Standard_CString("P2"));
3843
3844   PostProcess(aDoc,ID_BUTTON_Test_47,TheDisplayType,Message);
3845 }
3846
3847 void GeomSources::gpTest48(CGeometryDoc* aDoc)
3848 {
3849   DisplayType TheDisplayType = a2DNo3D;
3850   PreProcess(aDoc,TheDisplayType);
3851   //==============================================================
3852
3853   Standard_Real radius = 3;
3854   Handle(Geom2d_Circle) circle =
3855     new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius);
3856
3857   Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5);
3858
3859   Geom2dAdaptor_Curve GAC (C);
3860
3861
3862   TColgp_Array1OfPnt2d array (1,5); // sizing array
3863   array.SetValue(1,gp_Pnt2d (0,0));
3864   array.SetValue(2,gp_Pnt2d (1,2));
3865   array.SetValue(3,gp_Pnt2d (2,3));
3866   array.SetValue(4,gp_Pnt2d (4,3));
3867   array.SetValue(5,gp_Pnt2d (5,5));
3868   Handle(Geom2d_BSplineCurve) SPL1 =
3869     Geom2dAPI_PointsToBSpline(array);
3870
3871
3872   Handle(TColgp_HArray1OfPnt2d) harray =
3873     new TColgp_HArray1OfPnt2d (1,5); // sizing harray
3874   harray->SetValue(1,gp_Pnt2d (13+ 0,0));
3875   harray->SetValue(2,gp_Pnt2d (13+ 1,2));
3876   harray->SetValue(3,gp_Pnt2d (13+ 2,3));
3877   harray->SetValue(4,gp_Pnt2d (13+ 4,3));
3878   harray->SetValue(5,gp_Pnt2d (13+ 5,5));
3879   Geom2dAPI_Interpolate anInterpolation(harray,Standard_True,0.01);
3880   anInterpolation.Perform();
3881   Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();
3882
3883   Bnd_Box2d aCBox;
3884   Geom2dAdaptor_Curve GACC (C);
3885   BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox);
3886
3887   Standard_Real aCXmin, aCYmin, aCXmax, aCYmax;
3888   aCBox.Get( aCXmin, aCYmin, aCXmax,aCYmax);
3889
3890   Bnd_Box2d aSPL1Box;
3891   Geom2dAdaptor_Curve GAC1 (SPL1);
3892   BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box);
3893
3894   Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax;
3895   aSPL1Box.Get( aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax);
3896
3897   Bnd_Box2d aSPL2Box;
3898   Geom2dAdaptor_Curve GAC2 (SPL2);
3899   BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box);
3900
3901   Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax;
3902   aSPL2Box.Get( aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax);
3903
3904   //==============================================================
3905     TCollection_AsciiString Message (" \
3906                                                                        \n\
3907 Standard_Real radius = 3;                                              \n\
3908 Handle(Geom2d_Circle) circle =                                         \n\
3909     new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius);  \n\
3910                                                                        \n\
3911 Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5);   \n\
3912 Geom2dAdaptor_Curve GAC (C);                                           \n\
3913                                                                        \n\
3914 Handle(Geom2d_BSplineCurve) SPL1 ; // SPL1 = ...                       \n\
3915                                                                        \n\
3916 Handle(Geom2d_BSplineCurve) SPL2 ; // SPL2 = ...                       \n\
3917                                                                        \n\
3918 Bnd_Box2d aCBox;                                                       \n\
3919 Geom2dAdaptor_Curve GACC (C);                                          \n\
3920 BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox);        \n\
3921                                                                        \n\
3922 Standard_Real aCXmin, aCYmin, aCXmax, aCYmax;                          \n\
3923 aCBox.Get(  aCXmin, aCYmin, aCXmax,aCYmax);                            \n\
3924                                                                        \n\
3925 Bnd_Box2d aSPL1Box;                                                    \n\
3926 Geom2dAdaptor_Curve GAC1 (SPL1);                                       \n\
3927 BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box);     \n\
3928                                                                        \n\
3929 Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax;                 \n\
3930 aSPL1Box.Get(  aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax);             \n");
3931 Message += "\
3932                                                                        \n\
3933 Bnd_Box2d aSPL2Box;                                                    \n\
3934 Geom2dAdaptor_Curve GAC2 (SPL2);                                       \n\
3935 BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box);     \n\
3936                                                                        \n\
3937 Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax;                 \n\
3938 aSPL2Box.Get(  aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax);             \n\
3939                                                                        \n";
3940   AddSeparator(aDoc,Message);
3941   //--------------------------------------------------------------
3942
3943   DisplayCurve(aDoc,C ,5);
3944   DisplayCurve(aDoc,SPL1,6 );
3945   DisplayCurve(aDoc,SPL2,7 );
3946
3947   DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmax),Standard_CString("aCXmin,aCYmax"));
3948   DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmax),Standard_CString("aCXmax,aCYmax"));
3949   DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmin),Standard_CString("aCXmin,aCYmin"));
3950   DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmin),Standard_CString("aCXmax,aCYmin"));
3951
3952   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmax),gp_Pnt2d(aCXmax,aCYmax)).Value() ,4); // X,Ymax
3953   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmax,aCYmin)).Value() ,4); // X,Ymin
3954   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmin,aCYmax)).Value() ,4); // Xmin,Y
3955   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmax,aCYmin),gp_Pnt2d(aCXmax,aCYmax)).Value() ,4); // Xmax,Y
3956
3957   DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),Standard_CString("aSPL1Xmin,aSPL1Ymax"));
3958   DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymax),Standard_CString("aSPL1Xmax,aSPL1Ymax"));
3959   DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),Standard_CString("aSPL1Xmin,aSPL1Ymin"));
3960   DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),Standard_CString("aSPL1Xmax,aSPL1Ymin"));
3961
3962   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)).Value() ,4); // X,Ymax
3963   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymin)).Value() ,4); // X,Ymin
3964   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmin,aSPL1Ymax)).Value() ,4); // Xmin,Y
3965   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)).Value() ,4); // Xmax,Y
3966
3967   DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),Standard_CString("aSPL2Xmin,aSPL2Ymax"));
3968   DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymax),Standard_CString("aSPL2Xmax,aSPL2Ymax"));
3969   DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),Standard_CString("aSPL2Xmin,aSPL2Ymin"));
3970   DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),Standard_CString("aSPL2Xmax,aSPL2Ymin"));
3971
3972   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymax),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)).Value() ,4); // X,Ymax
3973   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymin)).Value() ,4); // X,Ymin
3974   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmin,aSPL2Ymax)).Value() ,4); // Xmin,Y
3975   DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmax,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)).Value() ,4); // Xmax,Y
3976
3977   PostProcess(aDoc,ID_BUTTON_Test_48,TheDisplayType,Message);
3978 }
3979
3980
3981 void GeomSources::gpTest49(CGeometryDoc* aDoc)
3982 {
3983   DisplayType TheDisplayType = No2D3D;
3984   PreProcess(aDoc,TheDisplayType);
3985
3986   //==============================================================
3987
3988   Bnd_Box aBox;
3989   Standard_Real radius = 100;
3990   gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5));
3991
3992   Handle(Geom_Circle) C =
3993     new Geom_Circle(anAxis,radius);
3994   GeomAdaptor_Curve GAC (C);
3995   BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox);
3996
3997   Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
3998   aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
3999
4000   //==============================================================
4001
4002     TCollection_AsciiString Message (" \
4003                                                                \n\
4004 Bnd_Box aBox;                                                  \n\
4005 Standard_Real radius = 100;                                    \n\
4006 gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5));                   \n\
4007                                                                \n\
4008 Handle(Geom_Circle) C =                                        \n\
4009     new Geom_Circle(anAxis,radius);                            \n\
4010 GeomAdaptor_Curve GAC (C);                                     \n\
4011 BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox);  \n\
4012                                                                \n\
4013 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;       \n\
4014 aBox.Get(  aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);             \n\
4015                                                                \n");
4016   AddSeparator(aDoc,Message);
4017   //--------------------------------------------------------------
4018
4019   DisplayCurve(aDoc,C,Quantity_NOC_BLUE1 ,false);
4020
4021   DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmin),Standard_CString("aXmin,aYmax,aZmin"));
4022   DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmin),Standard_CString("aXmax,aYmax,aZmin"));
4023   DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmin),Standard_CString("aXmin,aYmin,aZmin"));
4024   DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmin),Standard_CString("aXmax,aYmin,aZmin"));
4025
4026   DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmax),Standard_CString("aXmin,aYmax,aZmax"));
4027   DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmax),Standard_CString("aXmax,aYmax,aZmax"));
4028   DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmax),Standard_CString("aXmin,aYmin,aZmax"));
4029   DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmax),Standard_CString("aXmax,aYmin,aZmax"));
4030
4031   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4032     gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMin
4033   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4034     gp_Pnt(aXmax,aYmin,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMin
4035   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4036     gp_Pnt(aXmin,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMin
4037   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4038     gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMin
4039   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4040     gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMax
4041   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4042     gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMax
4043   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4044     gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMax
4045   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4046     gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMax
4047   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4048     gp_Pnt(aXmin,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymin,Z
4049   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4050     gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymin,Z
4051   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4052     gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymax,Z
4053   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4054     gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymax,Z
4055
4056   PostProcess(aDoc,ID_BUTTON_Test_49,TheDisplayType,Message);
4057 }
4058
4059 void GeomSources::gpTest50(CGeometryDoc* aDoc)
4060 {
4061   DisplayType TheDisplayType = No2D3D;
4062   PreProcess(aDoc,TheDisplayType);
4063   //==============================================================
4064
4065   TColgp_Array1OfPnt array1 (1,5);
4066   array1.SetValue(1,gp_Pnt (-40,00,20 ));
4067   array1.SetValue(2,gp_Pnt (-70,20,20 ));
4068   array1.SetValue(3,gp_Pnt (-60,30,10 ));
4069   array1.SetValue(4,gp_Pnt (-40,30,-10));
4070   array1.SetValue(5,gp_Pnt (-30,50,-20));
4071   Handle(Geom_BSplineCurve) SPL1 =
4072     GeomAPI_PointsToBSpline(array1).Curve();
4073
4074   TColgp_Array1OfPnt array2 (1,5);
4075   array2.SetValue(1,gp_Pnt (-40,0, 20));
4076   array2.SetValue(2,gp_Pnt (-20,20,0 ));
4077   array2.SetValue(3,gp_Pnt (20 ,30,-10));
4078   array2.SetValue(4,gp_Pnt (30 ,70,-20));
4079   array2.SetValue(5,gp_Pnt (40 ,90,-10));
4080   Handle(Geom_BSplineCurve) SPL2 =
4081     GeomAPI_PointsToBSpline(array2).Curve();
4082
4083   GeomFill_FillingStyle Type = GeomFill_StretchStyle;
4084   GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
4085   Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface();
4086   GeomAdaptor_Surface GAS (aSurf);
4087   Bnd_Box aBox;
4088   BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox);
4089
4090   Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
4091   aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
4092
4093   //==============================================================
4094   TCollection_AsciiString Message (" \
4095                                                                \n\
4096 TColgp_Array1OfPnt array1 (1,5);                               \n\
4097 array1.SetValue(1,gp_Pnt (-40,  0, 20));                           \n\
4098 array1.SetValue(2,gp_Pnt (-70, 20, 20));                           \n\
4099 array1.SetValue(3,gp_Pnt (-60, 30, 10));                           \n\
4100 array1.SetValue(4,gp_Pnt (-40, 30,-10));                           \n\
4101 array1.SetValue(5,gp_Pnt (-30, 50,-20));                           \n\
4102 Handle(Geom_BSplineCurve) SPL1 =                               \n\
4103         GeomAPI_PointsToBSpline(array1).Curve();                   \n\
4104                                                                \n\
4105 TColgp_Array1OfPnt array2 (1,5);                               \n\
4106 array2.SetValue(1,gp_Pnt (-40,  0, 20));                           \n\
4107 array2.SetValue(2,gp_Pnt (-20, 20,  0));                           \n\
4108 array2.SetValue(3,gp_Pnt ( 20, 30,-10));                           \n\
4109 array2.SetValue(4,gp_Pnt ( 30, 70,-20));                           \n\
4110 array2.SetValue(5,gp_Pnt ( 40, 90,-10));                           \n\
4111 Handle(Geom_BSplineCurve) SPL2 =                               \n\
4112         GeomAPI_PointsToBSpline(array2).Curve();                   \n\
4113                                                                \n\
4114 GeomFill_FillingStyle Type = GeomFill_StretchStyle;            \n\
4115 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);             \n\
4116 Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface();      \n\
4117 GeomAdaptor_Surface GAS (aSurf);                               \n\
4118 Bnd_Box aBox;                                                  \n\
4119 BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox);  \n\
4120                                                                \n\
4121 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;       \n\
4122 aBox.Get(  aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);             \n\
4123                                                                \n");
4124   AddSeparator(aDoc,Message);
4125   //--------------------------------------------------------------
4126
4127   Quantity_NameOfColor aNameOfColor= Quantity_NOC_GREEN;
4128   Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurf);
4129   aDoc->GetAISContext()->SetColor(aGraphicalSurface,aNameOfColor);
4130   aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
4131   aGraphicalSurface->Attributes()->UIsoAspect()->SetColor(aNameOfColor);
4132   aGraphicalSurface->Attributes()->VIsoAspect()->SetColor(aNameOfColor);
4133
4134   aDoc->GetAISContext()->SetDisplayMode(aGraphicalSurface,1);
4135   aDoc->GetAISContext()->Display(aGraphicalSurface,false);
4136   //   DisplaySurface(aDoc,aSurf,Quantity_NOC_GREEN);
4137
4138   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4139     gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMin
4140   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4141     gp_Pnt(aXmax,aYmin,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMin
4142   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4143     gp_Pnt(aXmin,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMin
4144   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4145     gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMin
4146   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4147     gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMax
4148   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4149     gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMax
4150   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4151     gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMax
4152   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4153     gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMax
4154   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4155     gp_Pnt(aXmin,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymin,Z
4156   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4157     gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymin,Z
4158   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4159     gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymax,Z
4160   DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4161     gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymax,Z
4162
4163   PostProcess(aDoc,ID_BUTTON_Test_50,TheDisplayType,Message);
4164 }