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
3201 PostProcess(aDoc,ID_BUTTON_Test_40,TheDisplayType,Message.ToCString());
7fd59977 3202}
3203
3204void GeomSources::gpTest41(CGeometryDoc* aDoc)
3205{
5c1f974e 3206 DisplayType TheDisplayType = No2D3D;
3207 PreProcess(aDoc,TheDisplayType);
3208 //==============================================================
3209
3210 TColgp_Array1OfPnt array1 (1,5);
3211 array1.SetValue(1,gp_Pnt (-4,0,2 ));
3212 array1.SetValue(2,gp_Pnt (-5,1,0 ));
3213 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3214 array1.SetValue(4,gp_Pnt (-5,4,-7));
3215 array1.SetValue(5,gp_Pnt (-3,5,-12));
3216
3217 Handle(Geom_BSplineCurve) SPL1 =
3218 GeomAPI_PointsToBSpline(array1).Curve();
3219 Handle(Geom_Curve) FirstSect =
3220 GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value();
3221
3222 GeomFill_Pipe aPipe(SPL1,FirstSect);
3223 aPipe.Perform();
3224
3225 Handle(Geom_BSplineSurface) aPipeSurface =
3226 Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface());
3227 Handle(Geom_BSplineSurface) anotherBSplineSurface =
3228 GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6);
3229
3230 //==============================================================
3231 TCollection_AsciiString Message (" \
7fd59977 3232 \n\
3233TColgp_Array1OfPnt array1 (1,5); \n\
3234array1.SetValue(1,gp_Pnt (-4,0,2 )); \n\
3235array1.SetValue(2,gp_Pnt (-5,1,0 )); \n\
3236array1.SetValue(3,gp_Pnt (-6,2,-2 )); \n\
3237array1.SetValue(4,gp_Pnt (-5,4,-7)); \n\
3238array1.SetValue(5,gp_Pnt (-3,5,-12)); \n\
3239 \n\
3240Handle(Geom_BSplineCurve) SPL1 = \n\
3241 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3242Handle(Geom_Curve) FirstSect = \n\
3243 GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value(); \n\
3244 \n\
3245GeomFill_Pipe aPipe(SPL1,FirstSect); \n\
3246aPipe.Perform(); \n\
3247 \n\
3248Handle(Geom_BSplineSurface) aPipeSurface = \n\
3249 Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface()); \n\
3250Handle(Geom_BSplineSurface) anotherBSplineSurface = \n\
3251 GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6); \n\
3252 \n");
5c1f974e 3253 AddSeparator(aDoc,Message);
3254 //--------------------------------------------------------------
7fd59977 3255
5c1f974e 3256 if(!aPipeSurface.IsNull())
3257 {
3258 DisplaySurface(aDoc,aPipeSurface,Quantity_NOC_YELLOW);
3259 }
7fd59977 3260
5c1f974e 3261 if(!anotherBSplineSurface.IsNull())
3262 {
3263 DisplaySurface(aDoc,anotherBSplineSurface,Quantity_NOC_HOTPINK);
3264 }
7fd59977 3265
5c1f974e 3266 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3267 DisplayCurve(aDoc,FirstSect,Quantity_NOC_GREEN ,false);
7fd59977 3268
5c1f974e 3269 Message += "SPL1 is Red; \n";
3270 Message += "SPL2 is Green; \n";
3271 Message += "SPL3 is Blue; \n";
3272 Message += "aBSplineSurface is Yellow; \n";
3273 Message += "anotherBSplineSurface is Hot Pink; \n";
7fd59977 3274
5c1f974e 3275 PostProcess(aDoc,ID_BUTTON_Test_41,TheDisplayType,Message.ToCString());
7fd59977 3276}
3277
3278
3279void GeomSources::gpTest42(CGeometryDoc* aDoc)
3280{
5c1f974e 3281 DisplayType TheDisplayType = No2D3D;
3282 PreProcess(aDoc,TheDisplayType);
3283
3284 //==============================================================
3285
3286 TColgp_Array2OfPnt array1(1,3,1,3);
3287 TColgp_Array2OfPnt array2(1,3,1,3);
3288 TColgp_Array2OfPnt array3(1,3,1,3);
3289 TColgp_Array2OfPnt array4(1,3,1,3);
3290
3291 array1.SetValue(1,1,gp_Pnt(1,1,1));
3292 array1.SetValue(1,2,gp_Pnt(2,1,2));
3293 array1.SetValue(1,3,gp_Pnt(3,1,1));
3294 array1.SetValue(2,1,gp_Pnt(1,2,1));
3295 array1.SetValue(2,2,gp_Pnt(2,2,2));
3296 array1.SetValue(2,3,gp_Pnt(3,2,0));
3297 array1.SetValue(3,1,gp_Pnt(1,3,2));
3298 array1.SetValue(3,2,gp_Pnt(2,3,1));
3299 array1.SetValue(3,3,gp_Pnt(3,3,0));
3300
3301 array2.SetValue(1,1,gp_Pnt(3,1,1));
3302 array2.SetValue(1,2,gp_Pnt(4,1,1));
3303 array2.SetValue(1,3,gp_Pnt(5,1,2));
3304 array2.SetValue(2,1,gp_Pnt(3,2,0));
3305 array2.SetValue(2,2,gp_Pnt(4,2,1));
3306 array2.SetValue(2,3,gp_Pnt(5,2,2));
3307 array2.SetValue(3,1,gp_Pnt(3,3,0));
3308 array2.SetValue(3,2,gp_Pnt(4,3,0));
3309 array2.SetValue(3,3,gp_Pnt(5,3,1));
3310
3311 array3.SetValue(1,1,gp_Pnt(1,3,2));
3312 array3.SetValue(1,2,gp_Pnt(2,3,1));
3313 array3.SetValue(1,3,gp_Pnt(3,3,0));
3314 array3.SetValue(2,1,gp_Pnt(1,4,1));
3315 array3.SetValue(2,2,gp_Pnt(2,4,0));
3316 array3.SetValue(2,3,gp_Pnt(3,4,1));
3317 array3.SetValue(3,1,gp_Pnt(1,5,1));
3318 array3.SetValue(3,2,gp_Pnt(2,5,1));
3319 array3.SetValue(3,3,gp_Pnt(3,5,2));
3320
3321 array4.SetValue(1,1,gp_Pnt(3,3,0));
3322 array4.SetValue(1,2,gp_Pnt(4,3,0));
3323 array4.SetValue(1,3,gp_Pnt(5,3,1));
3324 array4.SetValue(2,1,gp_Pnt(3,4,1));
3325 array4.SetValue(2,2,gp_Pnt(4,4,1));
3326 array4.SetValue(2,3,gp_Pnt(5,4,1));
3327 array4.SetValue(3,1,gp_Pnt(3,5,2));
3328 array4.SetValue(3,2,gp_Pnt(4,5,2));
3329 array4.SetValue(3,3,gp_Pnt(5,5,1));
3330
3331 Handle(Geom_BezierSurface) BZ1 =
7fd59977 3332 new Geom_BezierSurface(array1);
5c1f974e 3333 Handle(Geom_BezierSurface) BZ2 =
7fd59977 3334 new Geom_BezierSurface(array2);
5c1f974e 3335 Handle(Geom_BezierSurface) BZ3 =
7fd59977 3336 new Geom_BezierSurface(array3);
5c1f974e 3337 Handle(Geom_BezierSurface) BZ4 =
7fd59977 3338 new Geom_BezierSurface(array4);
7fd59977 3339
5c1f974e 3340 TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2);
3341 bezierarray.SetValue(1,1,BZ1);
3342 bezierarray.SetValue(1,2,BZ2);
3343 bezierarray.SetValue(2,1,BZ3);
3344 bezierarray.SetValue(2,2,BZ4);
7fd59977 3345
5c1f974e 3346 GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray);
3347 Handle(Geom_BSplineSurface) BSPLSURF ;
3348 if (BB.IsDone())
3349 {
3350 BSPLSURF = new Geom_BSplineSurface(
3351 BB.Poles()->Array2(),
3352 BB.UKnots()->Array1(),
3353 BB.VKnots()->Array1(),
3354 BB.UMultiplicities()->Array1(),
3355 BB.VMultiplicities()->Array1(),
3356 BB.UDegree(),
3357 BB.VDegree() );
3358 BSPLSURF->Translate(gp_Vec(0,0,2));
3359 }
3360
3361 //==============================================================
3362
3363 TCollection_AsciiString Message (" \
7fd59977 3364 \n\
3365TColgp_Array2OfPnt array1(1,3,1,3); \n\
3366TColgp_Array2OfPnt array2(1,3,1,3); \n\
3367TColgp_Array2OfPnt array3(1,3,1,3); \n\
3368TColgp_Array2OfPnt array4(1,3,1,3); \n\
3369 \n\
3370// array1.SetValue( ... \n\
3371 \n\
3372Handle(Geom_BezierSurface) BZ1 = \n\
3373 new Geom_BezierSurface(array1); \n\
3374Handle(Geom_BezierSurface) BZ2 = \n\
3375 new Geom_BezierSurface(array2); \n\
3376Handle(Geom_BezierSurface) BZ3 = \n\
3377 new Geom_BezierSurface(array3); \n\
3378Handle(Geom_BezierSurface) BZ4 = \n\
3379 new Geom_BezierSurface(array4); \n\
3380 \n\
3381TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2); \n\
3382bezierarray.SetValue(1,1,BZ1); \n\
3383bezierarray.SetValue(1,2,BZ2); \n\
3384bezierarray.SetValue(2,1,BZ3); \n\
3385bezierarray.SetValue(2,2,BZ4); \n\
3386 \n\
3387GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray); \n\
3388 Handle(Geom_BSplineSurface) BSPLSURF ; \n\
3389if (BB.IsDone()){ \n\
3390 BSPLSURF = new Geom_BSplineSurface( \n\
3391 BB.Poles()->Array2(), \n\
3392 BB.UKnots()->Array1(), \n");
3393 Message += "\
3394 BB.VKnots()->Array1(), \n\
3395 BB.UMultiplicities()->Array1(), \n\
3396 BB.VMultiplicities()->Array1(), \n\
3397 BB.UDegree(), \n\
3398 BB.VDegree() ); \n\
3399 BSPLSURF->Translate(gp_Vec(0,0,2)); \n\
3400 } \n\
3401 \n";
5c1f974e 3402 AddSeparator(aDoc,Message);
3403 //--------------------------------------------------------------
7fd59977 3404
5c1f974e 3405 DisplaySurface(aDoc,BZ1,Quantity_NOC_RED);
3406 DisplaySurface(aDoc,BZ2,Quantity_NOC_GREEN);
3407 DisplaySurface(aDoc,BZ3,Quantity_NOC_BLUE1);
3408 DisplaySurface(aDoc,BZ4,Quantity_NOC_BROWN);
7fd59977 3409
5c1f974e 3410 if (BB.IsDone()){
3411 DisplaySurface(aDoc,BSPLSURF,Quantity_NOC_HOTPINK);
3412 }
7fd59977 3413
5c1f974e 3414 Message += "BZ1 is Red; \n";
3415 Message += "BZ2 is Green; \n";
3416 Message += "BZ3 is Blue; \n";
3417 Message += "BZ4 is Brown; \n";
3418 Message += "BSPLSURF is Hot Pink; \n";
3419
3420 PostProcess(aDoc,ID_BUTTON_Test_42,TheDisplayType,Message.ToCString());
7fd59977 3421}
3422
3423void GeomSources::gpTest43(CGeometryDoc* aDoc)
3424{
5c1f974e 3425 DisplayType TheDisplayType = No2D3D;
3426 PreProcess(aDoc,TheDisplayType);
3427 //==============================================================
3428
3429 TColgp_Array1OfPnt array1 (1,5);
3430 array1.SetValue(1,gp_Pnt (-4,5,5 ));
3431 array1.SetValue(2,gp_Pnt (-3,6,6 ));
3432 array1.SetValue(3,gp_Pnt (-1,7,7 ));
3433 array1.SetValue(4,gp_Pnt (0,8,8));
3434 array1.SetValue(5,gp_Pnt (2,9,9));
3435 Handle(Geom_BSplineCurve) SPL1 =
3436 GeomAPI_PointsToBSpline(array1).Curve();
3437
3438 TColgp_Array1OfPnt array2 (1,5);
3439 array2.SetValue(1,gp_Pnt (-4,5,2 ));
3440 array2.SetValue(2,gp_Pnt (-3,6,3 ));
3441 array2.SetValue(3,gp_Pnt (-1,7,4 ));
3442 array2.SetValue(4,gp_Pnt (0,8,5));
3443 array2.SetValue(5,gp_Pnt (2,9,6));
3444 Handle(Geom_BSplineCurve) SPL2 =
3445 GeomAPI_PointsToBSpline(array2).Curve();
3446
3447 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3448 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3449 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3450 Standard_Real offset = 1;
3451 Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset);
3452 offset = 2;
3453 Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset);
3454 offset = 3;
3455 Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset);
3456
3457 //==============================================================
3458 TCollection_AsciiString Message (" \
7fd59977 3459 \n\
3460TColgp_Array1OfPnt array1 (1,5); \n\
3461//array1.SetValue( ... \n\
3462Handle(Geom_BSplineCurve) SPL1 = \n\
3463 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3464 \n\
3465TColgp_Array1OfPnt array2 (1,5); \n\
3466// array2.SetValue( ... \n\
3467 \n\
3468Handle(Geom_BSplineCurve) SPL2 = \n\
3469 GeomAPI_PointsToBSpline(array2).Curve(); \n\
3470 \n\
3471GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3472GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3473Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface(); \n\
3474Standard_Real offset = 1; \n\
3475Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3476 offset = 2; \n\
3477Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3478offset = 3; \n\
3479Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3480 \n");
5c1f974e 3481 AddSeparator(aDoc,Message);
3482 //--------------------------------------------------------------
7fd59977 3483
5c1f974e 3484 DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_BLUE1);
3485 DisplaySurface(aDoc,GOS,Quantity_NOC_GREEN);
3486 DisplaySurface(aDoc,GOS1,Quantity_NOC_GREEN);
3487 DisplaySurface(aDoc,GOS2,Quantity_NOC_GREEN);
7fd59977 3488
5c1f974e 3489 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3490 DisplayCurve(aDoc,SPL2,Quantity_NOC_HOTPINK ,false);
7fd59977 3491
5c1f974e 3492 Message += "aGeomSurface is Blue; \n";
3493 Message += "GOS are Green; \n";
7fd59977 3494
5c1f974e 3495 PostProcess(aDoc,ID_BUTTON_Test_43,TheDisplayType,Message.ToCString());
7fd59977 3496}
3497
3498void GeomSources::gpTest44(CGeometryDoc* aDoc)
3499{
5c1f974e 3500 DisplayType TheDisplayType = No2D3D;
3501 PreProcess(aDoc,TheDisplayType);
3502 //==============================================================
3503
3504 gp_Pnt P1(0,0,1);
3505 gp_Pnt P2(1,2,2);
3506 gp_Pnt P3(2,3,3);
3507 gp_Pnt P4(4,3,4);
3508 gp_Pnt P5(5,5,5);
3509 TColgp_Array1OfPnt array (1,5);
3510 array.SetValue(1,P1);
3511 array.SetValue(2,P2);
3512 array.SetValue(3,P3);
3513 array.SetValue(4,P4);
3514 array.SetValue(5,P5);
3515 Handle(Geom_BSplineCurve) aCurve =
3516 GeomAPI_PointsToBSpline(array).Curve();
3517 gp_Dir aDir(1,2,3);
3518 Handle(Geom_SurfaceOfLinearExtrusion) SOLE =
3519 new Geom_SurfaceOfLinearExtrusion(aCurve,aDir);
3520
3521 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface =
3522 new Geom_RectangularTrimmedSurface(SOLE,-10,10,false);
3523
3524 Standard_CString SOLEEntityTypeName="Not Computed";
3525 if (!SOLE.IsNull())
3526 {
3527 SOLEEntityTypeName = SOLE->DynamicType()->Name();
3528 }
3529
3530 //==============================================================
3531
3532 TCollection_AsciiString Message (" \
7fd59977 3533 \n\
3534gp_Pnt P1(0,0,1); \n\
3535gp_Pnt P2(1,2,2); \n\
3536gp_Pnt P3(2,3,3); \n\
3537gp_Pnt P4(4,3,4); \n\
3538gp_Pnt P5(5,5,5); \n\
3539TColgp_Array1OfPnt array (1,5); \n\
3540array.SetValue(1,P1); \n\
3541array.SetValue(2,P2); \n\
3542array.SetValue(3,P3); \n\
3543array.SetValue(4,P4); \n\
3544array.SetValue(5,P5); \n\
3545Handle(Geom_BSplineCurve) aCurve = \n\
3546 GeomAPI_PointsToBSpline(array).Curve(); \n\
3547gp_Dir aDir(1,2,3); \n\
3548Handle(Geom_SurfaceOfLinearExtrusion) SOLE = \n\
3549 new Geom_SurfaceOfLinearExtrusion(aCurve,aDir); \n\
3550 \n\
3551Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface = \n\
3552 new Geom_RectangularTrimmedSurface(SOLE,-10,10,false); \n\
3553 \n\
3554Standard_CString SOLEEntityTypeName=\"Not Computed\"; \n\
3555if (!SOLE.IsNull()) \n\
3556 { \n\
3557 SOLEEntityTypeName = SOLE->DynamicType()->Name(); \n\
3558 } \n\
3559 \n");
5c1f974e 3560 AddSeparator(aDoc,Message);
3561 //--------------------------------------------------------------
7fd59977 3562
5c1f974e 3563 DisplaySurface(aDoc,aTrimmedSurface,Quantity_NOC_GREEN);
3564 DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
7fd59977 3565
5c1f974e 3566 Message += "aCurve is Red; \n";
3567 Message += "aTrimmedSurface is Green; \n";
7fd59977 3568
5c1f974e 3569 TCollection_AsciiString Message2 (SOLEEntityTypeName);
7fd59977 3570
5c1f974e 3571 Message += " SOLEEntityTypeName = ";Message+= Message2; Message += "\n";
7fd59977 3572
5c1f974e 3573 PostProcess(aDoc,ID_BUTTON_Test_44,TheDisplayType,Message.ToCString());
7fd59977 3574}
3575
3576void GeomSources::gpTest45(CGeometryDoc* aDoc)
3577{
5c1f974e 3578 DisplayType TheDisplayType = No2D3D;
3579 PreProcess(aDoc,TheDisplayType);
3580
3581 //==============================================================
3582
3583 TColgp_Array1OfPnt array (1,5);
3584 array.SetValue(1,gp_Pnt (0,0,1));
3585 array.SetValue(2,gp_Pnt (1,2,2));
3586 array.SetValue(3,gp_Pnt (2,3,3));
3587 array.SetValue(4,gp_Pnt (4,3,4));
3588 array.SetValue(5,gp_Pnt (5,5,5));
3589 Handle(Geom_BSplineCurve) aCurve =
3590 GeomAPI_PointsToBSpline(array).Curve();
3591 Handle(Geom_SurfaceOfRevolution) SOR =
3592 new Geom_SurfaceOfRevolution(aCurve,gp::OX());
3593
3594 Standard_CString SOREntityTypeName="Not Computed";
3595 if (!SOR.IsNull())
3596 SOREntityTypeName = SOR->DynamicType()->Name();
3597
3598 //==============================================================
3599 TCollection_AsciiString Message (" \
7fd59977 3600 \n\
3601TColgp_Array1OfPnt array (1,5); \n\
3602array.SetValue(1,gp_Pnt 0,0,1)); \n\
3603array.SetValue(2,gp_Pnt (1,2,2)); \n\
3604array.SetValue(3,gp_Pnt (2,3,3)); \n\
3605array.SetValue(4,gp_Pnt (4,3,4)); \n\
3606array.SetValue(5,gp_Pnt (5,5,5)); \n\
3607Handle(Geom_BSplineCurve) aCurve = \n\
3608 GeomAPI_PointsToBSpline(array).Curve(); \n\
3609Handle(Geom_SurfaceOfRevolution) SOR = \n\
3610 new Geom_SurfaceOfRevolution(aCurve,gp::OX()); \n\
3611 \n\
3612Standard_CString SOREntityTypeName=\"Not Computed\"; \n\
3613if (!SOR.IsNull()) \n\
3614 SOREntityTypeName = SOR->DynamicType()->Name(); \n\
3615 \n");
5c1f974e 3616 AddSeparator(aDoc,Message);
3617
3618 //--------------------------------------------------------------
3619 DisplaySurface(aDoc,SOR,Quantity_NOC_GREEN);
3620 DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
7fd59977 3621
5c1f974e 3622 Message += "aCurve is Red; \n";
3623 Message += "SOR is Green; \n";
3624 TCollection_AsciiString Message2 (SOREntityTypeName);
3625 Message += " SOREntityTypeName = ";Message+= Message2; Message += "\n";
7fd59977 3626
5c1f974e 3627 PostProcess(aDoc,ID_BUTTON_Test_45,TheDisplayType,Message.ToCString());
7fd59977 3628}
3629
3630void GeomSources::gpTest46(CGeometryDoc* aDoc)
3631{
5c1f974e 3632 DisplayType TheDisplayType = No2D3D;
3633 PreProcess(aDoc,TheDisplayType);
3634 //==============================================================
3635
3636 TColgp_Array1OfPnt array1 (1,5);
3637 array1.SetValue(1,gp_Pnt (-4,5,5 ));
3638 array1.SetValue(2,gp_Pnt (-3,6,6 ));
3639 array1.SetValue(3,gp_Pnt (-1,6,7 ));
3640 array1.SetValue(4,gp_Pnt (0,8,8));
3641 array1.SetValue(5,gp_Pnt (2,9,9));
3642 Handle(Geom_BSplineCurve) SPL1 =
3643 GeomAPI_PointsToBSpline(array1).Curve();
3644
3645 TColgp_Array1OfPnt array2 (1,5);
3646 array2.SetValue(1,gp_Pnt (-4,5,2 ));
3647 array2.SetValue(2,gp_Pnt (-3,6,3 ));
3648 array2.SetValue(3,gp_Pnt (-1,7,4 ));
3649 array2.SetValue(4,gp_Pnt (0,8,5));
3650 array2.SetValue(5,gp_Pnt (2,9,6));
3651 Handle(Geom_BSplineCurve) SPL2 =
3652 GeomAPI_PointsToBSpline(array2).Curve();
3653
3654 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3655 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3656 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3657
3658 Handle(Geom_BSplineSurface) aTranslatedGeomSurface =
3659 Handle(Geom_BSplineSurface)::DownCast(aGeomSurface->Copy());
3660
3661 Standard_Real extension = 3;
3662 Standard_Integer continuity = 2;
3663 Standard_Boolean Udirection = Standard_True;
3664 Standard_Boolean after = Standard_True;
3665 GeomLib::ExtendSurfByLength (aTranslatedGeomSurface,
3666 extension,continuity,Udirection,after);
3667
3668 //==============================================================
7fd59977 3669 TCollection_AsciiString Message (" \
3670 \n\
3671TColgp_Array1OfPnt array1 (1,5); \n\
3672// ... \n\
3673Handle(Geom_BSplineCurve) SPL1 = \n\
3674 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3675 \n\
3676TColgp_Array1OfPnt array2 (1,5); \n\
3677// ... \n\
3678Handle(Geom_BSplineCurve) SPL2 = \n\
3679 GeomAPI_PointsToBSpline(array2).Curve(); \n\
3680 \n\
3681GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3682GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3683Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface(); \n\
3684 \n\
3685Handle(Geom_BSplineSurface) aTranslatedGeomSurface = \n\
3686 Handle(Geom_BSplineSurface)::DownCast(aGeomSurface->Copy()); \n\
3687 \n\
3688Standard_Real extension = 3; \n\
3689Standard_Integer continuity = 2; \n\
3690Standard_Boolean Udirection = Standard_True; \n\
3691Standard_Boolean after = Standard_True; \n\
3692GeomLib::ExtendSurfByLength (aTranslatedGeomSurface, \n\
3693 extension,continuity,Udirection,after); \n\
3694 \n");
5c1f974e 3695 AddSeparator(aDoc,Message);
3696 //--------------------------------------------------------------
7fd59977 3697
5c1f974e 3698 if (!aGeomSurface.IsNull())
3699 {
3700 DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_HOTPINK);
3701 }
7fd59977 3702
5c1f974e 3703 if (!aTranslatedGeomSurface.IsNull())
3704 {
3705 DisplaySurface(aDoc,aTranslatedGeomSurface,Quantity_NOC_BLUE1);
3706 }
7fd59977 3707
5c1f974e 3708 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3709 DisplayCurve(aDoc,SPL2,Quantity_NOC_GREEN ,false);
7fd59977 3710
5c1f974e 3711 Message += "aGeomSurface is Hot Pink; \n";
3712 Message += "aTranslatedGeomSurface is Blue; \n";
3713 Message += "SPL1 is Red; \n";
3714 Message += "SPL2 is Green; \n";
7fd59977 3715
5c1f974e 3716 PostProcess(aDoc,ID_BUTTON_Test_46,TheDisplayType,Message.ToCString());
7fd59977 3717}
3718
7fd59977 3719void GeomSources::gpTest47(CGeometryDoc* aDoc)
3720{
5c1f974e 3721 DisplayType TheDisplayType = No2D3D;
3722 PreProcess(aDoc,TheDisplayType);
7fd59977 3723
5c1f974e 3724 //==============================================================
3725
3726
3727 TColgp_Array1OfPnt array1 (1,5);
3728 array1.SetValue(1,gp_Pnt (-5,1,2));
3729 array1.SetValue(2,gp_Pnt (-5,2,2));
3730 array1.SetValue(3,gp_Pnt (-5.3,3,1));
3731 array1.SetValue(4,gp_Pnt (-5,4,1));
3732 array1.SetValue(5,gp_Pnt (-5,5,2));
3733 Handle(Geom_BSplineCurve) SPL1 =
3734 GeomAPI_PointsToBSpline(array1).Curve();
3735
3736 TColgp_Array1OfPnt array2 (1,5);
3737 array2.SetValue(1,gp_Pnt (4,1,2));
3738 array2.SetValue(2,gp_Pnt (4,2,2));
3739 array2.SetValue(3,gp_Pnt (3.7,3,1));
3740 array2.SetValue(4,gp_Pnt (4,4,1));
3741 array2.SetValue(5,gp_Pnt (4,5,2));
3742 Handle(Geom_BSplineCurve) SPL2 =
3743 GeomAPI_PointsToBSpline(array2).Curve();
3744
3745 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3746
3747 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3748 Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface();
3749
3750 TColgp_Array2OfPnt array3 (1,5,1,5);
3751 array3.SetValue(1,1,gp_Pnt (-4,-4,5));
3752 array3.SetValue(1,2,gp_Pnt (-4,-2,5));
3753 array3.SetValue(1,3,gp_Pnt (-4,0,4));
3754 array3.SetValue(1,4,gp_Pnt (-4,2,5));
3755 array3.SetValue(1,5,gp_Pnt (-4,4,5));
3756
3757 array3.SetValue(2,1,gp_Pnt (-2,-4,4));
3758 array3.SetValue(2,2,gp_Pnt (-2,-2,4));
3759 array3.SetValue(2,3,gp_Pnt (-2,0,4));
3760 array3.SetValue(2,4,gp_Pnt (-2,2,4));
3761 array3.SetValue(2,5,gp_Pnt (-2,5,4));
3762
3763 array3.SetValue(3,1,gp_Pnt (0,-4,3.5));
3764 array3.SetValue(3,2,gp_Pnt (0,-2,3.5));
3765 array3.SetValue(3,3,gp_Pnt (0,0,3.5));
3766 array3.SetValue(3,4,gp_Pnt (0,2,3.5));
3767 array3.SetValue(3,5,gp_Pnt (0,5,3.5));
3768
3769 array3.SetValue(4,1,gp_Pnt (2,-4,4));
3770 array3.SetValue(4,2,gp_Pnt (2,-2,4));
3771 array3.SetValue(4,3,gp_Pnt (2,0,3.5));
3772 array3.SetValue(4,4,gp_Pnt (2,2,5));
3773 array3.SetValue(4,5,gp_Pnt (2,5,4));
3774
3775 array3.SetValue(5,1,gp_Pnt (4,-4,5));
3776 array3.SetValue(5,2,gp_Pnt (4,-2,5));
3777 array3.SetValue(5,3,gp_Pnt (4,0,5));
3778 array3.SetValue(5,4,gp_Pnt (4,2,6));
3779 array3.SetValue(5,5,gp_Pnt (4,5,5));
3780
3781 Handle(Geom_BSplineSurface) aSurf2 =
3782 GeomAPI_PointsToBSplineSurface(array3).Surface();
3783
3784 GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2);
3785 Quantity_Length dist = ESS.LowerDistance();
3786 gp_Pnt P1,P2;
3787 ESS.NearestPoints(P1,P2);
3788
3789 gp_Pnt P3,P4;
3790 Handle(Geom_Curve) aCurve;
3791 Standard_Integer NbExtrema = ESS.NbExtrema();
3792 for(Standard_Integer k=1;k<=NbExtrema;k++){
3793 ESS.Points(k,P3,P4);
7fd59977 3794 aCurve= GC_MakeSegment(P3,P4).Value();
3795 DisplayCurve(aDoc,aCurve,Quantity_NOC_YELLOW3,false);
3796}
3797
7fd59977 3798//==============================================================
5c1f974e 3799
7fd59977 3800 TCollection_AsciiString Message (" \n\
3801GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3802 \n\
3803GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3804Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface(); \n\
3805 \n\
3806Handle(Geom_BSplineSurface) aSurf2 = \n\
3807 GeomAPI_PointsToBSplineSurface(array3).Surface(); \n\
3808 \n\
3809GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2); \n\
3810Quantity_Length dist = ESS.LowerDistance(); \n\
3811gp_Pnt P1,P2; \n\
3812ESS.NearestPoints(P1,P2); \n\
3813 \n");
3814
5c1f974e 3815 AddSeparator(aDoc,Message);
3816 Message += "aSurf1 is Green; \n";
3817 Message += "aSurf2 is Hot Pink; \n";
3818 Message += "Nearest points P1 and P2 are shown; \n";
7fd59977 3819
5c1f974e 3820 //--------------------------------------------------------------
7fd59977 3821
3822//mfa
3823
5c1f974e 3824 DisplaySurface(aDoc,aSurf1,Quantity_NOC_GREEN);
3825 DisplaySurface(aDoc,aSurf2,Quantity_NOC_HOTPINK);
3826 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3827 DisplayCurve(aDoc,SPL2,Quantity_NOC_AZURE ,false);
3828
3829 DisplayPoint(aDoc,P1,Standard_CString("P1"));
3830 DisplayPoint(aDoc,P2,Standard_CString("P2"));
7fd59977 3831
5c1f974e 3832 PostProcess(aDoc,ID_BUTTON_Test_47,TheDisplayType,Message.ToCString());
7fd59977 3833}
3834
3835void GeomSources::gpTest48(CGeometryDoc* aDoc)
3836{
5c1f974e 3837 DisplayType TheDisplayType = a2DNo3D;
3838 PreProcess(aDoc,TheDisplayType);
3839 //==============================================================
7fd59977 3840
5c1f974e 3841 Standard_Real radius = 3;
3842 Handle(Geom2d_Circle) circle =
3843 new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius);
7fd59977 3844
5c1f974e 3845 Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5);
3846
3847 Geom2dAdaptor_Curve GAC (C);
3848
3849
3850 TColgp_Array1OfPnt2d array (1,5); // sizing array
3851 array.SetValue(1,gp_Pnt2d (0,0));
3852 array.SetValue(2,gp_Pnt2d (1,2));
3853 array.SetValue(3,gp_Pnt2d (2,3));
3854 array.SetValue(4,gp_Pnt2d (4,3));
3855 array.SetValue(5,gp_Pnt2d (5,5));
3856 Handle(Geom2d_BSplineCurve) SPL1 =
3857 Geom2dAPI_PointsToBSpline(array);
3858
3859
3860 Handle(TColgp_HArray1OfPnt2d) harray =
3861 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
3862 harray->SetValue(1,gp_Pnt2d (13+ 0,0));
3863 harray->SetValue(2,gp_Pnt2d (13+ 1,2));
3864 harray->SetValue(3,gp_Pnt2d (13+ 2,3));
3865 harray->SetValue(4,gp_Pnt2d (13+ 4,3));
3866 harray->SetValue(5,gp_Pnt2d (13+ 5,5));
3867 Geom2dAPI_Interpolate anInterpolation(harray,Standard_True,0.01);
3868 anInterpolation.Perform();
3869 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();
3870
3871 Bnd_Box2d aCBox;
3872 Geom2dAdaptor_Curve GACC (C);
3873 BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox);
3874
3875 Standard_Real aCXmin, aCYmin, aCXmax, aCYmax;
3876 aCBox.Get( aCXmin, aCYmin, aCXmax,aCYmax);
3877
3878 Bnd_Box2d aSPL1Box;
3879 Geom2dAdaptor_Curve GAC1 (SPL1);
3880 BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box);
3881
3882 Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax;
3883 aSPL1Box.Get( aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax);
3884
3885 Bnd_Box2d aSPL2Box;
3886 Geom2dAdaptor_Curve GAC2 (SPL2);
3887 BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box);
3888
3889 Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax;
3890 aSPL2Box.Get( aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax);
3891
3892 //==============================================================
7fd59977 3893 TCollection_AsciiString Message (" \
3894 \n\
3895Standard_Real radius = 3; \n\
3896Handle(Geom2d_Circle) circle = \n\
3897 new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius); \n\
3898 \n\
3899Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5); \n\
3900Geom2dAdaptor_Curve GAC (C); \n\
3901 \n\
3902Handle(Geom2d_BSplineCurve) SPL1 ; // SPL1 = ... \n\
3903 \n\
3904Handle(Geom2d_BSplineCurve) SPL2 ; // SPL2 = ... \n\
3905 \n\
3906Bnd_Box2d aCBox; \n\
3907Geom2dAdaptor_Curve GACC (C); \n\
3908BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox); \n\
3909 \n\
3910Standard_Real aCXmin, aCYmin, aCXmax, aCYmax; \n\
3911aCBox.Get( aCXmin, aCYmin, aCXmax,aCYmax); \n\
3912 \n\
3913Bnd_Box2d aSPL1Box; \n\
3914Geom2dAdaptor_Curve GAC1 (SPL1); \n\
3915BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box); \n\
3916 \n\
3917Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax; \n\
3918aSPL1Box.Get( aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax); \n");
3919Message += "\
3920 \n\
3921Bnd_Box2d aSPL2Box; \n\
3922Geom2dAdaptor_Curve GAC2 (SPL2); \n\
3923BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box); \n\
3924 \n\
3925Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax; \n\
3926aSPL2Box.Get( aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax); \n\
3927 \n";
5c1f974e 3928 AddSeparator(aDoc,Message);
3929 //--------------------------------------------------------------
3930
3931 DisplayCurve(aDoc,C ,5);
3932 DisplayCurve(aDoc,SPL1,6 );
3933 DisplayCurve(aDoc,SPL2,7 );
3934
3935 DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmax),Standard_CString("aCXmin,aCYmax"));
3936 DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmax),Standard_CString("aCXmax,aCYmax"));
3937 DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmin),Standard_CString("aCXmin,aCYmin"));
3938 DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmin),Standard_CString("aCXmax,aCYmin"));
3939
3940 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmax),gp_Pnt2d(aCXmax,aCYmax)) ,4); // X,Ymax
3941 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmax,aCYmin)) ,4); // X,Ymin
3942 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmin,aCYmax)) ,4); // Xmin,Y
3943 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmax,aCYmin),gp_Pnt2d(aCXmax,aCYmax)) ,4); // Xmax,Y
3944
3945 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),Standard_CString("aSPL1Xmin,aSPL1Ymax"));
3946 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymax),Standard_CString("aSPL1Xmax,aSPL1Ymax"));
3947 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),Standard_CString("aSPL1Xmin,aSPL1Ymin"));
3948 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),Standard_CString("aSPL1Xmax,aSPL1Ymin"));
3949
3950 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)) ,4); // X,Ymax
3951 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymin)) ,4); // X,Ymin
3952 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmin,aSPL1Ymax)) ,4); // Xmin,Y
3953 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)) ,4); // Xmax,Y
3954
3955 DisplayPoint(aDoc,gp_Pnt2d(aSPL2Xmin,aSPL2Ymax),Standard_CString("aSPL2Xmin,aSPL2Ymax"));
3956 DisplayPoint(aDoc,gp_Pnt2d(aSPL2Xmax,aSPL2Ymax),Standard_CString("aSPL2Xmax,aSPL2Ymax"));
3957 DisplayPoint(aDoc,gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),Standard_CString("aSPL2Xmin,aSPL2Ymin"));
3958 DisplayPoint(aDoc,gp_Pnt2d(aSPL2Xmax,aSPL2Ymin),Standard_CString("aSPL2Xmax,aSPL2Ymin"));
3959
3960 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymax),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)) ,4); // X,Ymax
3961 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymin)) ,4); // X,Ymin
3962 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmin,aSPL2Ymax)) ,4); // Xmin,Y
3963 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmax,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)) ,4); // Xmax,Y
3964
3965 PostProcess(aDoc,ID_BUTTON_Test_48,TheDisplayType,Message.ToCString());
7fd59977 3966}
3967
3968
3969void GeomSources::gpTest49(CGeometryDoc* aDoc)
3970{
5c1f974e 3971 DisplayType TheDisplayType = No2D3D;
3972 PreProcess(aDoc,TheDisplayType);
3973
3974 //==============================================================
3975
3976 Bnd_Box aBox;
3977 Standard_Real radius = 100;
3978 gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5));
3979
3980 Handle(Geom_Circle) C =
3981 new Geom_Circle(anAxis,radius);
3982 GeomAdaptor_Curve GAC (C);
3983 BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox);
3984
3985 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
3986 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
3987
3988 //==============================================================
3989
7fd59977 3990 TCollection_AsciiString Message (" \
3991 \n\
3992Bnd_Box aBox; \n\
3993Standard_Real radius = 100; \n\
3994gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5)); \n\
3995 \n\
3996Handle(Geom_Circle) C = \n\
3997 new Geom_Circle(anAxis,radius); \n\
3998GeomAdaptor_Curve GAC (C); \n\
3999BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox); \n\
4000 \n\
4001Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ; \n\
4002aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax); \n\
4003 \n");
5c1f974e 4004 AddSeparator(aDoc,Message);
4005 //--------------------------------------------------------------
4006
4007 DisplayCurve(aDoc,C,Quantity_NOC_BLUE1 ,false);
4008
4009 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmin),Standard_CString("aXmin,aYmax,aZmin"));
4010 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmin),Standard_CString("aXmax,aYmax,aZmin"));
4011 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmin),Standard_CString("aXmin,aYmin,aZmin"));
4012 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmin),Standard_CString("aXmax,aYmin,aZmin"));
4013
4014 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmax),Standard_CString("aXmin,aYmax,aZmax"));
4015 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmax),Standard_CString("aXmax,aYmax,aZmax"));
4016 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmax),Standard_CString("aXmin,aYmin,aZmax"));
4017 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmax),Standard_CString("aXmax,aYmin,aZmax"));
4018
4019 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4020 gp_Pnt(aXmax,aYmax,aZmin)) ,Quantity_NOC_RED); // X,Ymax,ZMin
4021 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4022 gp_Pnt(aXmax,aYmin,aZmin)) ,Quantity_NOC_RED); // X,Ymin,ZMin
4023 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4024 gp_Pnt(aXmin,aYmax,aZmin)) ,Quantity_NOC_RED); // Xmin,Y,ZMin
4025 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4026 gp_Pnt(aXmax,aYmax,aZmin)) ,Quantity_NOC_RED); // Xmax,Y,ZMin
4027 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4028 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // X,Ymax,ZMax
4029 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4030 gp_Pnt(aXmax,aYmin,aZmax)) ,Quantity_NOC_RED); // X,Ymin,ZMax
4031 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4032 gp_Pnt(aXmin,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmin,Y,ZMax
4033 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4034 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmax,Y,ZMax
4035 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4036 gp_Pnt(aXmin,aYmin,aZmax)) ,Quantity_NOC_RED); // Xmin,Ymin,Z
4037 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4038 gp_Pnt(aXmax,aYmin,aZmax)) ,Quantity_NOC_RED); // Xmax,Ymin,Z
4039 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4040 gp_Pnt(aXmin,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmin,Ymax,Z
4041 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4042 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmax,Ymax,Z
4043
4044 PostProcess(aDoc,ID_BUTTON_Test_49,TheDisplayType,Message.ToCString());
7fd59977 4045}
4046
7fd59977 4047void GeomSources::gpTest50(CGeometryDoc* aDoc)
4048{
5c1f974e 4049 DisplayType TheDisplayType = No2D3D;
4050 PreProcess(aDoc,TheDisplayType);
4051 //==============================================================
4052
4053 TColgp_Array1OfPnt array1 (1,5);
4054 array1.SetValue(1,gp_Pnt (-40,00,20 ));
4055 array1.SetValue(2,gp_Pnt (-70,20,20 ));
4056 array1.SetValue(3,gp_Pnt (-60,30,10 ));
4057 array1.SetValue(4,gp_Pnt (-40,30,-10));
4058 array1.SetValue(5,gp_Pnt (-30,50,-20));
4059 Handle(Geom_BSplineCurve) SPL1 =
4060 GeomAPI_PointsToBSpline(array1).Curve();
4061
4062 TColgp_Array1OfPnt array2 (1,5);
4063 array2.SetValue(1,gp_Pnt (-40,0, 20));
4064 array2.SetValue(2,gp_Pnt (-20,20,0 ));
4065 array2.SetValue(3,gp_Pnt (20 ,30,-10));
4066 array2.SetValue(4,gp_Pnt (30 ,70,-20));
4067 array2.SetValue(5,gp_Pnt (40 ,90,-10));
4068 Handle(Geom_BSplineCurve) SPL2 =
4069 GeomAPI_PointsToBSpline(array2).Curve();
4070
4071 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
4072 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
4073 Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface();
4074 GeomAdaptor_Surface GAS (aSurf);
4075 Bnd_Box aBox;
4076 BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox);
4077
4078 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
4079 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
4080
4081 //==============================================================
4082 TCollection_AsciiString Message (" \
7fd59977 4083 \n\
4084TColgp_Array1OfPnt array1 (1,5); \n\
4085array1.SetValue(1,gp_Pnt (-40, 0, 20)); \n\
4086array1.SetValue(2,gp_Pnt (-70, 20, 20)); \n\
4087array1.SetValue(3,gp_Pnt (-60, 30, 10)); \n\
4088array1.SetValue(4,gp_Pnt (-40, 30,-10)); \n\
4089array1.SetValue(5,gp_Pnt (-30, 50,-20)); \n\
4090Handle(Geom_BSplineCurve) SPL1 = \n\
4091 GeomAPI_PointsToBSpline(array1).Curve(); \n\
4092 \n\
4093TColgp_Array1OfPnt array2 (1,5); \n\
4094array2.SetValue(1,gp_Pnt (-40, 0, 20)); \n\
4095array2.SetValue(2,gp_Pnt (-20, 20, 0)); \n\
4096array2.SetValue(3,gp_Pnt ( 20, 30,-10)); \n\
4097array2.SetValue(4,gp_Pnt ( 30, 70,-20)); \n\
4098array2.SetValue(5,gp_Pnt ( 40, 90,-10)); \n\
4099Handle(Geom_BSplineCurve) SPL2 = \n\
4100 GeomAPI_PointsToBSpline(array2).Curve(); \n\
4101 \n\
4102GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
4103GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
4104Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface(); \n\
4105GeomAdaptor_Surface GAS (aSurf); \n\
4106Bnd_Box aBox; \n\
4107BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox); \n\
4108 \n\
4109Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ; \n\
4110aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax); \n\
4111 \n");
5c1f974e 4112 AddSeparator(aDoc,Message);
4113 //--------------------------------------------------------------
4114
4115 Quantity_NameOfColor aNameOfColor= Quantity_NOC_GREEN;
4116 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurf);
4117 aDoc->GetAISContext()->SetColor(aGraphicalSurface,aNameOfColor);
4118 aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
4119 aGraphicalSurface->Attributes()->UIsoAspect()->SetColor(aNameOfColor);
4120 aGraphicalSurface->Attributes()->VIsoAspect()->SetColor(aNameOfColor);
4121
4122 aDoc->GetAISContext()->SetDisplayMode(aGraphicalSurface,1);
4123 aDoc->GetAISContext()->Display(aGraphicalSurface,false);
4124 // DisplaySurface(aDoc,aSurf,Quantity_NOC_GREEN);
4125
4126 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4127 gp_Pnt(aXmax,aYmax,aZmin)) ,Quantity_NOC_RED); // X,Ymax,ZMin
4128 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4129 gp_Pnt(aXmax,aYmin,aZmin)) ,Quantity_NOC_RED); // X,Ymin,ZMin
4130 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4131 gp_Pnt(aXmin,aYmax,aZmin)) ,Quantity_NOC_RED); // Xmin,Y,ZMin
4132 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4133 gp_Pnt(aXmax,aYmax,aZmin)) ,Quantity_NOC_RED); // Xmax,Y,ZMin
4134 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4135 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // X,Ymax,ZMax
4136 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4137 gp_Pnt(aXmax,aYmin,aZmax)) ,Quantity_NOC_RED); // X,Ymin,ZMax
4138 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4139 gp_Pnt(aXmin,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmin,Y,ZMax
4140 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4141 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmax,Y,ZMax
4142 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4143 gp_Pnt(aXmin,aYmin,aZmax)) ,Quantity_NOC_RED); // Xmin,Ymin,Z
4144 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4145 gp_Pnt(aXmax,aYmin,aZmax)) ,Quantity_NOC_RED); // Xmax,Ymin,Z
4146 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4147 gp_Pnt(aXmin,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmin,Ymax,Z
4148 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4149 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmax,Ymax,Z
4150
4151 PostProcess(aDoc,ID_BUTTON_Test_50,TheDisplayType,Message.ToCString());
7fd59977 4152}