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