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