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