1 // GeomSources.cpp: implementation of the GeomSources class.
3 //////////////////////////////////////////////////////////////////////
6 #include "GeomSources.h"
7 #include "GeometryApp.h"
10 GeomSources::GeomSources()
14 GeomSources::~GeomSources()
17 void GeomSources::PreProcess(CGeometryDoc* aDoc,DisplayType aDisplayType)
19 if (aDisplayType == No2D3D )
21 aDoc->GetAISContext()->EraseAll(Standard_False);
25 if (aDisplayType == a2DNo3D)
27 aDoc->GetISessionContext()->EraseAll();
31 if (aDisplayType != No2D3D && aDisplayType != a2D3D)
36 if (aDisplayType != a2DNo3D && aDisplayType != a2D3D)
41 if (aDisplayType == a2D3D)
43 aDoc->GetAISContext()->EraseAll(Standard_False);
44 aDoc->GetISessionContext()->EraseAll();
45 aDoc->Put3DOnTop(false);
46 aDoc->Put2DOnTop(false);
49 // send the message Title Horizontaly to the child of doc main frame
50 CGeometryApp* TheAppli = (CGeometryApp*)AfxGetApp();
51 CMainFrame* TheMainFrame= (CMainFrame*)TheAppli->m_pMainWnd;
52 ::SendMessage(TheMainFrame->m_hWndMDIClient, WM_MDITILE, 0, 0);
56 void GeomSources::PostProcess(CGeometryDoc* aDoc,
58 DisplayType aDisplayType,
60 Quantity_Coefficient Coef /* = -1 */
61 /* double Zoom = -1 */)
63 if (aDisplayType == No2D3D || aDisplayType == a2D3D)
65 aDoc->Fit3DViews(Coef);
68 if (aDisplayType == a2DNo3D || aDisplayType == a2D3D)
73 TCollection_AsciiString Message("Results are ");
77 case No2DNo3D: Message = "All results are in this box \n";
79 case No2D3D: Message += "only in 3D \n";
81 case a2DNo3D: Message += "only in 2d \n";
83 case a2D3D: Message += "in both 2D and 3D \n";
86 Message += "====================================\n";
89 CString text(Message.ToCString());
90 aDoc->myCResultDialog.SetText(text);
93 if (! s.LoadString( anID ))
94 AfxMessageBox("Error Loading String: ");
96 CString Title = s.Left( s.Find( '\n' ));
98 aDoc->myCResultDialog.SetTitle(Title);
99 aDoc->SetTitle(Title);
102 void GeomSources::AddSeparator(CGeometryDoc* aDoc,TCollection_AsciiString& aMessage)
104 aMessage+= "------------------------------------------------------------------------\n";
106 void GeomSources::DisplayPoint(CGeometryDoc* aDoc,
109 Standard_Boolean UpdateViewer,
110 Standard_Real anXoffset,
111 Standard_Real anYoffset,
112 Standard_Real TextScale)
114 Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint);
115 aDoc->GetISessionContext()->Display(aGraphicPoint,UpdateViewer);
116 Handle(ISession_Text) aGraphicText = new ISession_Text(aText,aPoint.X()+anXoffset,aPoint.Y()+anYoffset);
117 aGraphicText->SetScale (TextScale);
118 aDoc->GetISessionContext()->Display(aGraphicText,UpdateViewer);
121 void GeomSources::DisplayPoint(CGeometryDoc* aDoc,
124 Standard_Boolean UpdateViewer,
125 Standard_Real anXoffset,
126 Standard_Real anYoffset,
127 Standard_Real aZoffset,
128 Standard_Real TextScale)
130 Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint);
131 aDoc->GetAISContext()->Display(aGraphicPoint,UpdateViewer);
132 Handle(ISession_Text) aGraphicText = new ISession_Text(aText,aPoint.X()+anXoffset,aPoint.Y()+anYoffset,aPoint.Z()+aZoffset);
133 aGraphicText->SetScale (TextScale);
134 aDoc->GetAISContext()->Display(aGraphicText,UpdateViewer);
137 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
138 Handle(Geom2d_Curve) aCurve,
139 Standard_Integer aColorIndex,
140 Standard_Boolean UpdateViewer)
142 Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
143 aGraphicCurve->SetColorIndex(aColorIndex) ;
144 aDoc->GetISessionContext()->Display(aGraphicCurve,UpdateViewer);
147 void GeomSources::DisplayCurveAndCurvature(CGeometryDoc* aDoc,
148 Handle(Geom2d_Curve) aCurve,
149 Standard_Integer aColorIndex,
150 Standard_Boolean UpdateViewer)
152 Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
153 aGraphicCurve->SetDisplayCurbure(Standard_True) ;
154 aGraphicCurve->SetDiscretisation(20);
155 aGraphicCurve->SetColorIndex(aColorIndex) ;
156 aDoc->GetISessionContext()->Display(aGraphicCurve,UpdateViewer);
159 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
160 Handle(Geom_Curve) aCurve,
161 Quantity_NameOfColor aNameOfColor,
162 Standard_Boolean UpdateViewer)
164 Handle(ISession_Curve) aGraphicCurve = new ISession_Curve(aCurve);
165 aDoc->GetAISContext()->SetColor(aGraphicCurve,aNameOfColor, Standard_False);
166 aGraphicCurve->Attributes()->LineAspect()->SetColor(aNameOfColor);
167 aDoc->GetAISContext()->Display(aGraphicCurve,UpdateViewer);
170 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
171 Handle(Geom_Curve) aCurve,
172 Standard_Boolean UpdateViewer)
174 Handle(ISession_Curve) aGraphicCurve = new ISession_Curve(aCurve);
175 aDoc->GetAISContext()->Display(aGraphicCurve,UpdateViewer);
181 void GeomSources::DisplaySurface(CGeometryDoc* aDoc,
182 Handle(Geom_Surface) aSurface,
183 Quantity_NameOfColor aNameOfColor,
184 Standard_Boolean UpdateViewer)
186 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
187 aDoc->GetAISContext()->SetColor(aGraphicalSurface,aNameOfColor, Standard_False);
188 aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
189 aGraphicalSurface->Attributes()->UIsoAspect()->SetColor(aNameOfColor);
190 aGraphicalSurface->Attributes()->VIsoAspect()->SetColor(aNameOfColor);
191 aDoc->GetAISContext()->Display(aGraphicalSurface,UpdateViewer);
194 void GeomSources::DisplaySurface(CGeometryDoc* aDoc,
195 Handle(Geom_Surface) aSurface,
196 Standard_Boolean UpdateViewer)
198 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
199 aDoc->GetAISContext()->Display(aGraphicalSurface,UpdateViewer);
202 // Function name : GeomSources::gpTest1
204 // Return type : void
205 // Argument : CGeometryDoc* aDoc
206 void GeomSources::gpTest1(CGeometryDoc* aDoc)
208 DisplayType TheDisplayType = No2D3D;
209 PreProcess(aDoc,TheDisplayType);
210 //==============================================================
215 Standard_Real result = A.DotCross(B,C);
217 //==============================================================
218 TCollection_AsciiString Message ("\
223 Standard_Real result = A.DotCross(B,C); \n\
225 AddSeparator(aDoc,Message);
226 //--------------------------------------------------------------
227 DisplayPoint(aDoc,gp_Pnt(A),"A (1,2,3)",false,0.1);
228 DisplayPoint(aDoc,gp_Pnt(B),"B (2,2,2)",false,0.1);
229 DisplayPoint(aDoc,gp_Pnt(C),"C (3,2,3)", false,0.1);
231 // to add a numeric value in a TCollectionAsciiString
232 TCollection_AsciiString Message2 (result);
234 Message+= " result = ";
236 PostProcess(aDoc,ID_BUTTON_Test_1,TheDisplayType,Message.ToCString());
239 // Function name : GeomSources::gpTest2
241 // Return type : void
242 // Argument : CGeometryDoc* aDoc
243 void GeomSources::gpTest2(CGeometryDoc* aDoc)
245 DisplayType TheDisplayType = No2D3D;
246 PreProcess(aDoc,TheDisplayType);
247 //==============================================================
251 //==============================================================
252 TCollection_AsciiString Message ("\
254 gp_Pnt P1(1,2,3); \n\
256 AddSeparator(aDoc,Message);
257 //--------------------------------------------------------------
258 DisplayPoint(aDoc,P1,"P1 (1,2,3)",false,0.5);
259 PostProcess(aDoc,ID_BUTTON_Test_2,TheDisplayType,Message.ToCString(),1.0);
263 // Function name : GeomSources::gpTest3
265 // Return type : void
266 // Argument : CGeometryDoc* aDoc
267 void GeomSources::gpTest3(CGeometryDoc* aDoc)
269 DisplayType TheDisplayType = No2D3D;
270 PreProcess(aDoc,TheDisplayType);
271 //==============================================================
276 //==============================================================
277 TCollection_AsciiString Message ("\
282 AddSeparator(aDoc,Message);
283 //--------------------------------------------------------------
284 DisplayPoint(aDoc,P2,"P2 (1,2,3)",false,0.5);
285 PostProcess(aDoc,ID_BUTTON_Test_3,TheDisplayType,Message.ToCString(),1.0 /*0.02*/);
289 // Function name : GeomSources::gpTest4
291 // Return type : void
292 // Argument : CGeometryDoc* aDoc
293 void GeomSources::gpTest4(CGeometryDoc* aDoc)
295 DisplayType TheDisplayType = No2D3D;
296 PreProcess(aDoc,TheDisplayType);
297 //==============================================================
299 gp_Pnt P3 = gp::Origin();
300 Standard_Real TheX = P3.X();
301 Standard_Real TheY = P3.Y();
302 Standard_Real TheZ = P3.Z();
305 //==============================================================
306 TCollection_AsciiString Message ("\
308 gp_Pnt P3 = gp::Origin(); \n\
309 Standard_Real TheX = P3.X(); \n\
310 Standard_Real TheY = P3.Y(); \n\
311 Standard_Real TheZ = P3.Z(); \n\
313 AddSeparator(aDoc,Message);
314 //--------------------------------------------------------------
315 DisplayPoint(aDoc,P3,"P3 = gp::Origin()",false,0.5);
317 TCollection_AsciiString Message2 (TheX);
318 TCollection_AsciiString Message3 (TheY);
319 TCollection_AsciiString Message4 (TheZ);
321 Message += " TheX = ";
323 Message += " TheY = ";
325 Message += " TheZ = ";
329 PostProcess(aDoc,ID_BUTTON_Test_4,TheDisplayType,Message.ToCString(),1.0 /*0.02*/);
333 // Function name : GeomSources::gpTest5
335 // Return type : void
336 // Argument : CGeometryDoc* aDoc
337 void GeomSources::gpTest5(CGeometryDoc* aDoc)
339 DisplayType TheDisplayType = No2D3D;
340 PreProcess(aDoc,TheDisplayType);
341 //==============================================================
346 Standard_Real alpha = 3;
347 Standard_Real beta = 7;
348 PB.BaryCenter(alpha,P2,beta);
350 //==============================================================
351 TCollection_AsciiString Message ("\
353 gp_Pnt P1(1,2,3); \n\
354 gp_Pnt P2(3,4,5); \n\
356 Standard_Real alpha = 3; \n\
357 Standard_Real beta = 7; \n\
358 PB.BaryCenter(alpha,P2,beta); \n\
361 AddSeparator(aDoc,Message);
362 //--------------------------------------------------------------
364 DisplayPoint(aDoc,P1,"P1",false,0.2);
365 DisplayPoint(aDoc,P2,"P2",false,0.2);
366 DisplayPoint(aDoc,PB,"PB = barycenter ( 3 * P1 , 7 * P2) ",false,0.2);
368 TCollection_AsciiString Message2 (PB.X());
369 TCollection_AsciiString Message3 (PB.Y());
370 TCollection_AsciiString Message4 (PB.Z());
379 PostProcess(aDoc,ID_BUTTON_Test_5,TheDisplayType,Message.ToCString());
383 // Function name : GeomSources::gpTest6
385 // Return type : void
386 // Argument : CGeometryDoc* aDoc
387 void GeomSources::gpTest6(CGeometryDoc* aDoc)
389 DisplayType TheDisplayType = No2D3D;
390 PreProcess(aDoc,TheDisplayType);
391 //==============================================================
393 // Compute a 3d point P as BaryCenter of an array of point
399 TColgp_Array1OfPnt array (1,5); // sizing array
400 array.SetValue(1,P1);
401 array.SetValue(2,P2);
402 array.SetValue(3,P3);
403 array.SetValue(4,P4);
404 array.SetValue(5,P5);
406 Standard_Real Tolerance = 8; // ajout de la tolerance
407 GProp_PEquation PE (array,Tolerance);
409 gp_Pnt P; // P declaration
410 Standard_Boolean IsPoint;
422 if (PE.IsLinear()){ /*... */ }
423 if (PE.IsPlanar()){ /*... */ }
424 if (PE.IsSpace()) { /*... */ }
426 //==============================================================
427 TCollection_AsciiString Message ("\
430 // Compute a 3d point P as BaryCenter of an array of point \n\
431 gp_Pnt P1(0,0,5); \n\
432 gp_Pnt P2(1,2,3); \n\
433 gp_Pnt P3(2,3,-2); \n\
434 gp_Pnt P4(4,3,5); \n\
435 gp_Pnt P5(5,5,4); \n\
436 TColgp_Array1OfPnt array (1,5); // sizing array \n\
437 array.SetValue(1,P1); \n\
438 array.SetValue(2,P2); \n\
439 array.SetValue(3,P3); \n\
440 array.SetValue(4,P4); \n\
441 array.SetValue(5,P5); \n\
443 Standard_Real Tolerance = 8; // ajout de la tolerance \n\
444 GProp_PEquation PE (array,Tolerance); \n\
446 gp_Pnt P; // P declaration \n\
447 Standard_Boolean IsPoint; \n\
448 if (PE.IsPoint()){IsPoint = true; \n\
449 P = PE .Point();} \n\
450 else { IsPoint = false; } \n\
451 if (PE.IsLinear()){ /*... */ } \n\
452 if (PE.IsPlanar()){ /*... */ } \n\
453 if (PE.IsSpace()) { /*... */ } \n\
455 AddSeparator(aDoc,Message);
456 //--------------------------------------------------------------
458 TCollection_AsciiString PointName("P");
461 for(Standard_Integer i= array.Lower();i <= array.Upper(); i++)
463 TCollection_AsciiString TheString (i);
464 TheString = PointName+ TheString;
465 DisplayPoint(aDoc,array(i),TheString.ToCString(),false,0.5);
468 DisplayPoint(aDoc,P,"P",false,0.5);
469 TCollection_AsciiString Message2 (P.X());
470 TCollection_AsciiString Message3 (P.Y());
471 TCollection_AsciiString Message4 (P.Z());
473 Message += " IsPoint = ";
476 Message += "True --> ";
479 Message += Message2; Message += " , ";
480 Message += Message3; Message += " , ";
481 Message += Message4; Message += " ); \n";
484 Message += "False\n";
486 Message += " IsLinear = ";
488 Message += "True \n";
490 Message += "False\n";
492 Message += " IsPlanar = ";
494 Message += "True \n";
496 Message += "False\n";
498 Message += " IsSpace = ";
501 Message += "True \n";
503 Message += "False\n";
505 PostProcess(aDoc,ID_BUTTON_Test_6,TheDisplayType,Message.ToCString());
508 // Function name : GeomSources::gpTest7
510 // Return type : void
511 // Argument : CGeometryDoc* aDoc
512 void GeomSources::gpTest7(CGeometryDoc* aDoc)
514 DisplayType TheDisplayType = a2DNo3D;
515 PreProcess(aDoc,TheDisplayType);
516 //==============================================================
522 Handle(Geom2d_TrimmedCurve) C =
523 GCE2d_MakeArcOfCircle (P1,P2,P3).Value();
525 Standard_Real FirstParameter = C->FirstParameter();
526 Standard_Real LastParameter = C->LastParameter();
527 Standard_Real MiddleParameter = (FirstParameter+LastParameter)/2;
528 Standard_Real param = MiddleParameter; //in radians
533 // we recover point P and the vector V
535 //==============================================================
536 TCollection_AsciiString Message ("\
539 gp_Pnt2d P1(0,5); \n\
540 gp_Pnt2d P2(5.5,1); \n\
541 gp_Pnt2d P3(-2,2); \n\
543 Handle(Geom2d_TrimmedCurve) C = \n\
544 GCE2d_MakeArcOfCircle (P1,P2,P3).Value(); \n\
546 Standard_Real FirstParameter = C->FirstParameter(); \n\
547 Standard_Real LastParameter = C->LastParameter(); \n\
548 Standard_Real MiddleParameter = \n\
549 (FirstParameter+LastParameter)/2; \n\
550 Standard_Real param = MiddleParameter; //in radians \n\
554 C->D1(param,P,V); \n\
555 // we recover point P and the vector V \n\
557 AddSeparator(aDoc,Message);
558 //--------------------------------------------------------------
560 DisplayCurve(aDoc,C);
561 Handle(ISession_Direction) aDirection = new ISession_Direction(P,V);
562 aDoc->GetISessionContext()->Display(aDirection, Standard_False);
564 DisplayPoint(aDoc,P,"P",false,0.5);
566 PostProcess(aDoc,ID_BUTTON_Test_7,TheDisplayType,Message.ToCString());
569 // Function name : GeomSources::gpTest8
571 // Return type : void
572 // Argument : CGeometryDoc* aDoc
573 void GeomSources::gpTest8(CGeometryDoc* aDoc)
575 DisplayType TheDisplayType = a2DNo3D;
576 PreProcess(aDoc,TheDisplayType);
577 //==============================================================
579 Standard_Real radius = 5;
580 Handle(Geom2d_Circle) C =
581 new Geom2d_Circle(gp::OX2d(),radius);
582 Standard_Real param = 1.2*M_PI;
583 Geom2dLProp_CLProps2d CLP
584 (C,param,2,Precision::PConfusion());
587 // D is the Tangent direction at parameter 1.2*PI
589 //==============================================================
590 TCollection_AsciiString Message (" \
592 Standard_Real radius = 5; \n\
593 Handle(Geom2d_Circle) C = \n\
594 new Geom2d_Circle(gp::OX2d(),radius); \n\
595 Standard_Real param = 1.2*PI; \n\
596 Geom2dLProp_CLProps2d CLP \n\
597 (C,param,2,Precision::PConfusion()); \n\
600 // D is the Tangent direction at parameter 1.2*PI \n\
602 AddSeparator(aDoc,Message);
603 //--------------------------------------------------------------
604 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
605 aDoc->GetISessionContext()->Display(aCurve,Standard_False);
606 Handle(ISession_Direction) aDirection = new ISession_Direction(gp_Pnt2d(0,0),D,2);
607 aDoc->GetISessionContext()->Display(aDirection,Standard_False);
609 TCollection_AsciiString Message2 (D.X());
610 TCollection_AsciiString Message3 (D.Y());
613 Message += Message2; Message += " , ";
614 Message += Message3; Message += " ); \n";
616 PostProcess(aDoc,ID_BUTTON_Test_8,TheDisplayType,Message.ToCString());
619 // Function name : GeomSources::gpTest9
621 // Return type : void
622 // Argument : CGeometryDoc* aDoc
623 void GeomSources::gpTest9(CGeometryDoc* aDoc)
625 DisplayType TheDisplayType = a2DNo3D;
626 PreProcess(aDoc,TheDisplayType);
628 //==============================================================
630 Standard_Real radius = 5;
631 Handle(Geom2d_Circle) C =
632 new Geom2d_Circle(gp::OX2d(),radius);
633 Geom2dAdaptor_Curve GAC (C);
634 Standard_Real startparam = 10*M_PI/180;
635 Standard_Real abscissa = 45*M_PI/180;
637 C->D0(startparam,P1);
638 // abscissa is the distance along the curve from startparam
639 GCPnts_AbscissaPoint AP (GAC, abscissa, startparam);
641 if (AP.IsDone()){C->D0(AP.Parameter(),P2);}
642 // P is now correctly set
644 //==============================================================
645 TCollection_AsciiString Message (" \n\
648 Standard_Real radius = 5; \n\
649 Handle(Geom2d_Circle) C = \n\
650 new Geom2d_Circle(gp::OX2d(),radius); \n\
651 Geom2dAdaptor_Curve GAC (C); \n\
652 Standard_Real startparam = 10*PI180; \n\
653 Standard_Real abscissa = 45*PI180; \n\
655 C->D0(startparam,P1); \n\
656 // abscissa is the distance along the curve from startparam \n\
657 GCPnts_AbscissaPoint AP (GAC, abscissa, startparam); \n\
659 if (AP.IsDone()){C->D0(AP.Parameter(),P2);} \n\
660 // P is now correctly set \n\
663 AddSeparator(aDoc,Message);
664 //--------------------------------------------------------------
665 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
666 aDoc->GetISessionContext()->Display(aCurve,Standard_False);
668 DisplayPoint(aDoc,P1,"P1");
669 if (AP.IsDone()) DisplayPoint(aDoc,P2,"P2");
671 TCollection_AsciiString Message2 (P1.X());
672 TCollection_AsciiString Message3 (P1.Y());
674 TCollection_AsciiString Message4 (P2.X());
675 TCollection_AsciiString Message5 (P2.Y());
678 Message += Message2; Message += " , ";
679 Message += Message3; Message += " ); \n";
682 Message += Message4; Message += " , ";
683 Message += Message5; Message += " ); \n";
684 PostProcess(aDoc,ID_BUTTON_Test_9,TheDisplayType,Message.ToCString());
687 // Function name : GeomSources::gpTest10
689 // Return type : void
690 // Argument : CGeometryDoc* aDoc
691 void GeomSources::gpTest10(CGeometryDoc* aDoc)
693 DisplayType TheDisplayType = a2DNo3D;
694 PreProcess(aDoc,TheDisplayType);
695 //==============================================================
698 Standard_Real radius = 5;
699 Handle(Geom2d_Circle) C =
700 new Geom2d_Circle(gp::OX2d(),radius);
701 Geom2dAdaptor_Curve GAC (C);
702 Standard_Real abscissa = 3;
703 GCPnts_UniformAbscissa UA (GAC,abscissa);
704 TColgp_SequenceOfPnt2d aSequence;
707 Standard_Real N = UA.NbPoints();
708 Standard_Integer count = 1;
709 for(;count<=N;count++)
711 C->D0(UA.Parameter(count),P);
712 Standard_Real Parameter = UA.Parameter(count);
713 // append P in a Sequence
717 Standard_Real Abscissa = UA.Abscissa();
719 //==============================================================
720 TCollection_AsciiString Message (" \
723 Standard_Real radius = 5; \n\
724 Handle(Geom2d_Circle) C = \n\
725 new Geom2d_Circle(gp::OX2d(),radius); \n\
726 Geom2dAdaptor_Curve GAC (C); \n\
727 Standard_Real abscissa = 3; \n\
728 GCPnts_UniformAbscissa UA (GAC,abscissa); \n\
729 TColgp_SequenceOfPnt2d aSequence; \n\
732 Standard_Real N = UA.NbPoints(); \n\
733 Standard_Integer count = 1; \n\
734 for(;count<=N;count++) \n\
736 C->D0(UA.Parameter(count),P); \n\
737 Standard_Real Parameter = UA.Parameter(count); \n\
738 // append P in a Sequence \n\
739 aSequence.Append(P); \n\
742 Standard_Real Abscissa = UA.Abscissa(); \n\
744 AddSeparator(aDoc,Message);
745 //--------------------------------------------------------------
746 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
747 aDoc->GetISessionContext()->Display(aCurve,Standard_False);
749 TCollection_AsciiString aString;
750 for (Standard_Integer i=1;i<= aSequence.Length();i++)
753 TCollection_AsciiString Message2 (i);
754 TCollection_AsciiString Message3 (UA.Parameter(i));
758 aString +=": Parameter : ";
761 // First and Last texts are displayed with an Y offset, point 4 is upper
762 Standard_Real YOffset = -0.3;
763 YOffset += 0.2 * ( i == 1 );
764 YOffset += 0.4 * ( i == 4 );
765 YOffset += -0.2 * ( i == aSequence.Length() );
767 DisplayPoint(aDoc,aSequence(i),aString.ToCString(),false,0.5,YOffset,0.04);
770 TCollection_AsciiString Message3 (Abscissa);
772 Message += "Abscissa = ";
776 PostProcess(aDoc,ID_BUTTON_Test_10,TheDisplayType,Message.ToCString());
779 // Function name : GeomSources::gpTest11
781 // Return type : void
782 // Argument : CGeometryDoc* aDoc
783 void GeomSources::gpTest11(CGeometryDoc* aDoc)
785 DisplayType TheDisplayType = No2D3D;
786 PreProcess(aDoc,TheDisplayType);
787 //==============================================================
789 Standard_Real radius = 5;
790 Handle(Geom_SphericalSurface) SP =
791 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);
794 gp_Pnt P = SP->Value(u,v);
796 //==============================================================
797 TCollection_AsciiString Message (" \
799 Standard_Real radius = 5; \n\
800 Handle(Geom_SphericalSurface) SP = \n\
801 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius); \n\
802 Standard_Real u = 2; \n\
803 Standard_Real v = 3; \n\
804 gp_Pnt P = SP->Value(u,v); \n\
806 AddSeparator(aDoc,Message);
807 //--------------------------------------------------------------
809 DisplaySurface(aDoc,SP);
810 DisplayPoint(aDoc,P,"P",false,0.5);
811 TCollection_AsciiString Message2 (P.X());
812 TCollection_AsciiString Message3 (P.Y());
820 PostProcess(aDoc,ID_BUTTON_Test_11,TheDisplayType,Message.ToCString());
823 // Function name : GeomSources::gpTest12
825 // Return type : void
826 // Argument : CGeometryDoc* aDoc
827 void GeomSources::gpTest12(CGeometryDoc* aDoc)
829 DisplayType TheDisplayType = No2D3D;
830 PreProcess(aDoc,TheDisplayType);
831 //==============================================================
834 Standard_Real distance, radius = 5;
835 Handle(Geom_Circle) C = new Geom_Circle(gp::XOY(),radius);
836 GeomAPI_ProjectPointOnCurve PPC (P,C);
837 N = PPC.NearestPoint();
838 Standard_Integer NbResults = PPC.NbPoints();
842 for(Standard_Integer i = 1;i<=NbResults;i++)
845 distance = PPC.Distance(i);
846 // do something with Q or distance here
850 //==============================================================
851 TCollection_AsciiString Message (" \
853 gp_Pnt N,Q,P(1,2,3); \n\
854 Standard_Real distance, radius = 5; \n\
855 Handle(Geom_Circle) C = new Geom_Circle(gp::XOY(),radius); \n\
856 GeomAPI_ProjectPointOnCurve PPC (P,C); \n\
857 N = PPC.NearestPoint(); \n\
858 Standard_Integer NbResults = PPC.NbPoints(); \n\
861 for(Standard_Integer i = 1;i<=NbResults;i++){ \n\
862 Q = PPC.Point(i); \n\
863 distance = PPC.Distance(i); \n\
864 // do something with Q or distance here \n\
868 AddSeparator(aDoc,Message);
869 //--------------------------------------------------------------
871 TCollection_AsciiString aString;
873 DisplayPoint(aDoc,P,"P",false,0.5);
875 TCollection_AsciiString Message2 (PPC.LowerDistance());
877 aString = "N : at Distance : ";
880 DisplayPoint(aDoc,N,aString.ToCString(),false,0.5,0,-0.5);
881 DisplayCurve(aDoc,C,false);
885 for(Standard_Integer i = 1;i<=NbResults;i++)
888 distance = PPC.Distance(i);
889 TCollection_AsciiString Message3 (i);
890 TCollection_AsciiString Message4 (distance);
894 aString +=": at Distance : ";
896 DisplayPoint(aDoc,Q,aString.ToCString(),false,0.5);
900 PostProcess(aDoc,ID_BUTTON_Test_12,TheDisplayType,Message.ToCString());
903 // Function name : GeomSources::gpTest13
905 // Return type : void
906 // Argument : CGeometryDoc* aDoc
907 void GeomSources::gpTest13(CGeometryDoc* aDoc)
909 DisplayType TheDisplayType = No2D3D;
910 PreProcess(aDoc,TheDisplayType);
912 //==============================================================
915 Standard_Real distance, radius = 5;
916 Handle(Geom_SphericalSurface) SP =
917 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);
918 GeomAPI_ProjectPointOnSurf PPS(P,SP);
919 N = PPS.NearestPoint();
920 Standard_Integer NbResults = PPS.NbPoints();
923 for(Standard_Integer i = 1;i<=NbResults;i++)
926 distance = PPS.Distance(i);
927 // do something with Q or distance here
931 //==============================================================
932 TCollection_AsciiString Message (" \
934 gp_Pnt N,Q,P(7,8,9); \n\
935 Standard_Real distance, radius = 5; \n\
936 Handle(Geom_SphericalSurface) SP = \n\
937 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius); \n\
938 GeomAPI_ProjectPointOnSurf PPS(P,SP); \n\
939 N = PPS.NearestPoint(); \n\
940 Standard_Integer NbResults = PPS.NbPoints(); \n\
942 for(Standard_Integer i = 1;i<=NbResults;i++){ \n\
943 Q = PPS.Point(i); \n\
944 distance = PPS.Distance(i); \n\
945 // do something with Q or distance here \n\
949 AddSeparator(aDoc,Message);
950 //--------------------------------------------------------------
951 TCollection_AsciiString aString;
953 DisplayPoint(aDoc,P,"P",false,0.5);
954 TCollection_AsciiString Message2 (PPS.LowerDistance());
956 aString = "N : at Distance : "; aString += Message2;
957 DisplayPoint(aDoc,N,aString.ToCString(),false,0.5,0,-0.6);
959 Handle(ISession_Surface) aSurface = new ISession_Surface(SP);
960 Handle (AIS_Drawer) CurDrawer = aSurface->Attributes();
961 CurDrawer->UIsoAspect()->SetNumber(10);
962 CurDrawer->VIsoAspect()->SetNumber(10);
963 aDoc->GetAISContext()->SetLocalAttributes(aSurface, CurDrawer);
964 aDoc->GetAISContext()->Display(aSurface, Standard_False);
968 for(Standard_Integer i = 1;i<=NbResults;i++)
972 distance = PPS.Distance(i);
973 TCollection_AsciiString Message3 (i);
974 TCollection_AsciiString Message4 (distance);
978 aString +=": at Distance : ";
981 DisplayPoint(aDoc,Q,aString.ToCString(),false,0.5);
984 PostProcess(aDoc,ID_BUTTON_Test_13,TheDisplayType,Message.ToCString());
987 // Function name : GeomSources::gpTest14
989 // Return type : void
990 // Argument : CGeometryDoc* aDoc
991 void GeomSources::gpTest14(CGeometryDoc* aDoc)
993 DisplayType TheDisplayType = No2D3D;
994 PreProcess(aDoc,TheDisplayType);
995 //==============================================================
998 gp_Ax3 theAxe(gp::XOY());
1000 Standard_Real MinorRadius = 5;
1001 Standard_Real MajorRadius = 8;
1002 gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius);
1003 IntAna_IntConicQuad ICQ
1004 (EL,PL,Precision::Angular(),Precision::Confusion());
1006 Standard_Integer NbResults = ICQ.NbPoints();
1008 for(Standard_Integer i = 1;i<=NbResults;i++){
1010 // do something with P here
1015 //==============================================================
1016 TCollection_AsciiString Message (" \
1019 gp_Pln PL (gp_Ax3(gp::XOY())); \n\
1020 Standard_Real MinorRadius = 5; \n\
1021 Standard_Real MajorRadius = 8; \n\
1022 gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius); \n\
1023 IntAna_IntConicQuad ICQ \n\
1024 (EL,PL,Precision::Angular(),Precision::Confusion()); \n\
1025 if (ICQ.IsDone()){ \n\
1026 Standard_Integer NbResults = ICQ.NbPoints(); \n\
1027 if (NbResults>0){ \n\
1028 for(Standard_Integer i = 1;i<=NbResults;i++){ \n\
1029 P = ICQ.Point(i); \n\
1030 // do something with P here \n\
1035 AddSeparator(aDoc,Message);
1036 //--------------------------------------------------------------
1038 Handle(Geom_Plane) aPlane = GC_MakePlane(PL).Value();
1039 Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);
1041 DisplaySurface(aDoc,aSurface);
1043 Handle(Geom_Ellipse) anEllips = GC_MakeEllipse(EL).Value();
1044 DisplayCurve(aDoc,anEllips,false);
1046 TCollection_AsciiString aString;
1050 Standard_Integer NbResults = ICQ.NbPoints();
1053 for(Standard_Integer i = 1;i<=NbResults;i++)
1056 TCollection_AsciiString Message2(i);
1059 aString = "P";aString += Message2;
1060 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1065 PostProcess(aDoc,ID_BUTTON_Test_14,TheDisplayType,Message.ToCString());
1068 // Function name : GeomSources::gpTest15
1070 // Return type : void
1071 // Argument : CGeometryDoc* aDoc
1072 void GeomSources::gpTest15(CGeometryDoc* aDoc)
1074 DisplayType TheDisplayType = No2D3D;
1075 PreProcess(aDoc,TheDisplayType);
1076 //==============================================================
1083 P1Copy.Transform(TRSF);
1085 //==============================================================
1086 TCollection_AsciiString Message (" \
1088 gp_Pnt P1(1,2,3); \n\
1089 gp_Pnt P1Copy = P1; \n\
1090 gp_Pnt P2(5,4,6); \n\
1092 TRSF.SetMirror(P2); \n\
1093 P1Copy.Transform(TRSF); \n\
1095 AddSeparator(aDoc,Message);
1096 //--------------------------------------------------------------
1098 DisplayPoint(aDoc,P1Copy,"P1Copy",false,0.5);
1099 DisplayPoint(aDoc,P1,"P1",false,0.5);
1100 DisplayPoint(aDoc,P2,"P2",false,0.5);
1102 PostProcess(aDoc,ID_BUTTON_Test_15,TheDisplayType,Message.ToCString());
1105 // Function name : GeomSources::gpTest16
1107 // Return type : void
1108 // Argument : CGeometryDoc* aDoc
1109 void GeomSources::gpTest16(CGeometryDoc* aDoc)
1111 DisplayType TheDisplayType = No2D3D;
1112 PreProcess(aDoc,TheDisplayType);
1113 //==============================================================
1123 Standard_Boolean result =
1124 V1.IsOpposite(V2,Precision::Angular());
1125 // result should be true
1127 //==============================================================
1128 TCollection_AsciiString Message (" \
1130 gp_Pnt P1(1,2,3); \n\
1131 gp_Pnt P2(5,4,6); \n\
1132 gp_Vec V1 (P1,P2); \n\
1134 gp_Pnt P3(10,4,7); \n\
1135 gp_Pnt P4(2,0,1); \n\
1136 gp_Vec V2 (P3,P4); \n\
1138 Standard_Boolean result = \n\
1139 V1.IsOpposite(V2,Precision::Angular()); \n\
1140 // result should be true \n\
1142 AddSeparator(aDoc,Message);
1143 //--------------------------------------------------------------
1145 DisplayPoint(aDoc,P1,"P1",false,0.5);
1146 DisplayPoint(aDoc,P2,"P2",false,0.5);
1147 DisplayPoint(aDoc,P3,"P3",false,0.5);
1148 DisplayPoint(aDoc,P4,"P4",false,0.5);
1150 Handle(ISession_Direction) aDirection1 = new ISession_Direction(P1,V1);
1151 aDoc->GetAISContext()->Display(aDirection1, Standard_False);
1153 Handle(ISession_Direction) aDirection2 = new ISession_Direction(P3,V2);
1154 aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1156 Message += "result = ";
1157 if (result) Message += "True \n"; else Message += "False \n";
1159 PostProcess(aDoc,ID_BUTTON_Test_16,TheDisplayType,Message.ToCString());
1162 // Function name : GeomSources::gpTest17
1164 // Return type : void
1165 // Argument : CGeometryDoc* aDoc
1166 void GeomSources::gpTest17(CGeometryDoc* aDoc)
1168 DisplayType TheDisplayType = No2D3D;
1169 PreProcess(aDoc,TheDisplayType);
1170 //==============================================================
1174 Standard_Real ang = D1.Angle(D2);
1175 // the result is in radians in the range [0,PI]
1177 //==============================================================
1178 TCollection_AsciiString Message (" \
1180 gp_Dir D1(1,2,3); \n\
1181 gp_Dir D2(3,4,5); \n\
1182 Standard_Real ang = D1.Angle(D2); \n\
1183 // the result is in radians in the range [0,PI] \n\
1185 AddSeparator(aDoc,Message);
1186 //--------------------------------------------------------------
1188 Handle(ISession_Direction) aDirection1 = new ISession_Direction(gp_Pnt(0,0,0),D1,3);
1189 aDoc->GetAISContext()->Display(aDirection1, Standard_False);
1191 Handle(ISession_Direction) aDirection2 = new ISession_Direction(gp_Pnt(0,0,0),D2,3);
1192 aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1194 cout<<" D1.Angle(D2) : "<<ang<<endl;
1196 TCollection_AsciiString Message2 (ang);
1197 TCollection_AsciiString Message3 (ang/M_PI/180);
1199 Message += " ang = ";
1200 Message += Message2;
1201 Message += " radian \n";
1202 Message += " ang/PI180 = ";
1203 Message += Message3;
1204 Message += " degree \n";
1206 PostProcess(aDoc,ID_BUTTON_Test_17,TheDisplayType,Message.ToCString());
1209 // Function name : GeomSources::gpTest18
1211 // Return type : void
1212 // Argument : CGeometryDoc* aDoc
1213 void GeomSources::gpTest18(CGeometryDoc* aDoc)
1215 DisplayType TheDisplayType = a2DNo3D;
1216 PreProcess(aDoc,TheDisplayType);
1217 //==============================================================
1222 gp_Parab2d Para(A,6);
1223 // P is the vertex point
1224 // P and D give the axis of symmetry
1225 // 6 is the focal length of the parabola
1227 //==============================================================
1228 TCollection_AsciiString Message (" \
1230 gp_Pnt2d P(2,3); \n\
1231 gp_Dir2d D(4,5); \n\
1232 gp_Ax22d A(P,D); \n\
1233 gp_Parab2d Para(A,6); \n\
1234 // P is the vertex point \n\
1235 // P and D give the axis of symmetry \n\
1236 // 6 is the focal length of the parabola \n\
1238 AddSeparator(aDoc,Message);
1239 //--------------------------------------------------------------
1241 DisplayPoint(aDoc,P,"P",false,0.5,0,3);
1243 Handle(ISession_Direction) aDirection = new ISession_Direction(P,D,200);
1244 aDoc->GetISessionContext()->Display(aDirection,Standard_False);
1245 Handle(Geom2d_Parabola) aParabola = GCE2d_MakeParabola(Para);
1246 Handle(Geom2d_TrimmedCurve) aTrimmedCurve = new Geom2d_TrimmedCurve(aParabola,-100,100);
1247 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aTrimmedCurve);
1248 //aCurve->SetColorIndex(3);
1249 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1251 Message += " The entity A of type gp_Ax22d is not displayable \n ";
1252 Message += " The entity D of type gp_Dir2d is displayed as a vector \n ( mean with a length != 1 ) \n ";
1253 PostProcess(aDoc,ID_BUTTON_Test_18,TheDisplayType,Message.ToCString());
1256 // Function name : GeomSources::gpTest19
1258 // Return type : void
1259 // Argument : CGeometryDoc* aDoc
1260 void GeomSources::gpTest19(CGeometryDoc* aDoc)
1262 DisplayType TheDisplayType = No2D3D;
1263 PreProcess(aDoc,TheDisplayType);
1264 //==============================================================
1269 Standard_Boolean IsDirectA = A.Direct();
1271 gp_Dir AXDirection = A.XDirection() ;
1272 gp_Dir AYDirection = A.YDirection() ;
1277 // axis3 is now left handed
1278 Standard_Boolean IsDirectA2 = A2.Direct();
1280 gp_Dir A2XDirection = A2.XDirection() ;
1281 gp_Dir A2YDirection = A2.YDirection() ;
1283 //==============================================================
1284 TCollection_AsciiString Message (" \
1286 gp_Pnt P1(2,3,4); \n\
1287 gp_Dir D(4,5,6); \n\
1289 Standard_Boolean IsDirectA = A.Direct(); \n\
1291 gp_Dir AXDirection = A.XDirection() ; \n\
1292 gp_Dir AYDirection = A.YDirection() ; \n\
1294 gp_Pnt P2(5,3,4); \n\
1295 gp_Ax3 A2(P2,D); \n\
1297 // axis3 is now left handed \n\
1298 Standard_Boolean IsDirectA2 = A2.Direct(); \n\
1300 gp_Dir A2XDirection = A2.XDirection() ; \n\
1301 gp_Dir A2YDirection = A2.YDirection() ; \n\
1303 AddSeparator(aDoc,Message);
1304 //--------------------------------------------------------------
1306 DisplayPoint(aDoc,P1,"P1",false,0.1);
1307 Handle(ISession_Direction) aDirection = new ISession_Direction(P1,D,2);
1308 aDoc->GetAISContext()->Display(aDirection, Standard_False);
1310 Handle(ISession_Direction) aDirection2 = new ISession_Direction(P1,AXDirection,2);
1311 aDirection2->SetText(TCollection_ExtendedString("A.XDirection"));
1312 aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1313 Handle(ISession_Direction) aDirection3 = new ISession_Direction(P1,AYDirection,2);
1314 aDirection3->SetText(TCollection_ExtendedString("A.YDirection"));
1315 aDoc->GetAISContext()->Display(aDirection3, Standard_False);
1317 DisplayPoint(aDoc,P2,"P2",false,0.1);
1318 Handle(ISession_Direction) aDirection4 = new ISession_Direction(P2,D,2);
1319 aDoc->GetAISContext()->Display(aDirection4, Standard_False);
1321 Handle(ISession_Direction) aDirection5 = new ISession_Direction(P2,A2XDirection,2);
1322 aDirection5->SetText(TCollection_ExtendedString("A2 XDirection"));
1323 aDoc->GetAISContext()->Display(aDirection5, Standard_False);
1324 Handle(ISession_Direction) aDirection6 = new ISession_Direction(P2,A2YDirection,2);
1325 aDirection6->SetText(TCollection_ExtendedString("A2 YDirection"));
1326 aDoc->GetAISContext()->Display(aDirection6, Standard_False);
1328 Message += "IsDirectA = ";
1330 Message += "True = Right Handed \n";
1332 Message += "False = Left Handed \n";
1334 Message += "IsDirectA2 = ";
1336 Message += "True = Right Handed \n";
1338 Message += "False = Left Handed \n";
1340 PostProcess(aDoc,ID_BUTTON_Test_19,TheDisplayType,Message.ToCString());
1343 // Function name : GeomSources::gpTest20
1345 // Return type : void
1346 // Argument : CGeometryDoc* aDoc
1347 void GeomSources::gpTest20(CGeometryDoc* aDoc)
1349 DisplayType TheDisplayType = a2DNo3D;
1350 PreProcess(aDoc,TheDisplayType);
1351 //==============================================================
1353 TColgp_Array1OfPnt2d array (1,5); // sizing array
1354 array.SetValue(1,gp_Pnt2d (0,0));
1355 array.SetValue(2,gp_Pnt2d (1,2));
1356 array.SetValue(3,gp_Pnt2d (2,3));
1357 array.SetValue(4,gp_Pnt2d (4,3));
1358 array.SetValue(5,gp_Pnt2d (5,5));
1359 Handle(Geom2d_BSplineCurve) SPL1 =
1360 Geom2dAPI_PointsToBSpline(array);
1362 Handle(TColgp_HArray1OfPnt2d) harray =
1363 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1364 harray->SetValue(1,gp_Pnt2d (7+ 0,0));
1365 harray->SetValue(2,gp_Pnt2d (7+ 1,2));
1366 harray->SetValue(3,gp_Pnt2d (7+ 2,3));
1367 harray->SetValue(4,gp_Pnt2d (7+ 4,3));
1368 harray->SetValue(5,gp_Pnt2d (7+ 5,5));
1369 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);
1370 anInterpolation.Perform();
1371 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();
1373 Handle(TColgp_HArray1OfPnt2d) harray2 =
1374 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1375 harray2->SetValue(1,gp_Pnt2d (11+ 0,0));
1376 harray2->SetValue(2,gp_Pnt2d (11+ 1,2));
1377 harray2->SetValue(3,gp_Pnt2d (11+ 2,3));
1378 harray2->SetValue(4,gp_Pnt2d (11+ 4,3));
1379 harray2->SetValue(5,gp_Pnt2d (11+ 5,5));
1380 Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01);
1381 anInterpolation2.Perform();
1382 Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve();
1383 // redefined C++ operator allows these assignments
1385 //==============================================================
1386 TCollection_AsciiString Message (" \
1388 TColgp_Array1OfPnt2d array (1,5); // sizing array \n\
1389 array.SetValue(1,gp_Pnt2d (0,0)); \n\
1390 array.SetValue(2,gp_Pnt2d (1,2)); \n\
1391 array.SetValue(3,gp_Pnt2d (2,3)); \n\
1392 array.SetValue(4,gp_Pnt2d (4,3)); \n\
1393 array.SetValue(5,gp_Pnt2d (5,5)); \n\
1394 Handle(Geom2d_BSplineCurve) SPL1 = \n\
1395 Geom2dAPI_PointsToBSpline(array); \n\
1397 Handle(TColgp_HArray1OfPnt2d) harray = \n\
1398 new TColgp_HArray1OfPnt2d (1,5); // sizing harray \n\
1399 harray->SetValue(1,gp_Pnt2d (7+ 0,0)); \n\
1400 harray->SetValue(2,gp_Pnt2d (7+ 1,2)); \n\
1401 harray->SetValue(3,gp_Pnt2d (7+ 2,3)); \n\
1402 harray->SetValue(4,gp_Pnt2d (7+ 4,3)); \n\
1403 harray->SetValue(5,gp_Pnt2d (7+ 5,5)); \n\
1404 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01); \n\
1405 anInterpolation.Perform(); \n\
1406 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve(); \n\
1408 Handle(TColgp_HArray1OfPnt2d) harray2 = \n\
1409 new TColgp_HArray1OfPnt2d (1,5); // sizing harray \n");
1411 harray2->SetValue(1,gp_Pnt2d (11+ 0,0)); \n\
1412 harray2->SetValue(2,gp_Pnt2d (11+ 1,2)); \n\
1413 harray2->SetValue(3,gp_Pnt2d (11+ 2,3)); \n\
1414 harray2->SetValue(4,gp_Pnt2d (11+ 4,3)); \n\
1415 harray2->SetValue(5,gp_Pnt2d (11+ 5,5)); \n\
1416 Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01); \n\
1417 anInterpolation2.Perform(); \n\
1418 Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve(); \n\
1419 // redefined C++ operator allows these assignments \n\
1421 AddSeparator(aDoc,Message);
1422 //--------------------------------------------------------------
1423 TCollection_AsciiString aString;
1425 for(i = array.Lower();i<=array.Upper();i++)
1427 gp_Pnt2d P = array(i);
1428 TCollection_AsciiString Message2 (i);
1429 aString = "array ";aString += Message2;
1430 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1432 for( int i = harray->Lower();i<=harray->Upper();i++)
1434 gp_Pnt2d P = harray->Value(i);
1435 TCollection_AsciiString Message2 (i);
1436 aString = "harray ";aString += Message2;
1437 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1439 for( i = harray2->Lower();i<=harray2->Upper();i++)
1441 gp_Pnt2d P = harray2->Value(i);
1442 TCollection_AsciiString Message2 (i);
1443 aString = "harray2 ";aString += Message2;
1444 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1449 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1450 aCurve->SetColorIndex(3);
1451 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1454 MessageBox(0,"SPL1.IsNull()","CasCade Error",MB_ICONERROR);
1458 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL2);
1459 aCurve2->SetColorIndex(5);
1460 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1463 MessageBox(0,"SPL2.IsNull()","CasCade Error",MB_ICONERROR);
1467 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL3);
1468 aCurve2->SetColorIndex(6);
1469 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1472 MessageBox(0,"SPL3.IsNull()","CasCade Error",MB_ICONERROR);
1474 Message += " SPL1 is Red \n";
1475 Message += " SPL2 is Blue \n";
1476 Message += " SPL3 is Yellow \n";
1478 PostProcess(aDoc,ID_BUTTON_Test_20,TheDisplayType,Message.ToCString());
1481 void GeomSources::gpTest21(CGeometryDoc* aDoc)
1483 DisplayType TheDisplayType = a2DNo3D;
1484 PreProcess(aDoc,TheDisplayType);
1486 //==============================================================
1488 gp_Pnt2d P1(-184, 101);
1489 gp_Pnt2d P2(20 ,84);
1490 Standard_Real aheight = 1;
1491 FairCurve_Batten B (P1,P2,aheight);
1492 B.SetAngle1(22*M_PI/180);
1493 B.SetAngle2(44*M_PI/180);
1494 FairCurve_AnalysisCode anAnalysisCode;
1495 B.Compute(anAnalysisCode);
1496 Handle(Geom2d_BSplineCurve) C = B.Curve();
1498 //==============================================================
1499 TCollection_AsciiString Message (" \
1501 gp_Pnt2d P1(-184, 101); \n\
1502 gp_Pnt2d P2(20 ,84); \n\
1503 Standard_Real aheight = 1; \n\
1504 FairCurve_Batten B (P1,P2,aheight); \n\
1505 B.SetAngle1(22*PI180); \n\
1506 B.SetAngle2(44*PI180); \n\
1507 FairCurve_AnalysisCode anAnalysisCode; \n\
1508 B.Compute(anAnalysisCode); \n\
1509 Handle(Geom2d_BSplineCurve) C = B.Curve(); \n\
1511 AddSeparator(aDoc,Message);
1512 //--------------------------------------------------------------
1514 DisplayCurveAndCurvature(aDoc,C,6,Standard_False);
1516 PostProcess(aDoc,ID_BUTTON_Test_21,TheDisplayType,Message.ToCString());
1519 void GeomSources::gpTest22(CGeometryDoc* aDoc)
1521 DisplayType TheDisplayType = a2DNo3D;
1522 PreProcess(aDoc,TheDisplayType);
1524 //==============================================================
1526 gp_Pnt2d P1(-184, 41);
1527 gp_Pnt2d P2(20 ,24);
1528 Standard_Real aheight = 1;
1529 FairCurve_MinimalVariation MV (P1,P2,aheight);
1530 MV.SetAngle1(22*M_PI/180);
1531 MV.SetAngle2(44*M_PI/180);
1533 FairCurve_AnalysisCode anAnalysisCode;
1534 MV.Compute(anAnalysisCode);
1536 Handle(Geom2d_BSplineCurve) C = MV.Curve();
1538 //==============================================================
1539 TCollection_AsciiString Message (" \
1541 gp_Pnt2d P1(-184, 41); \n\
1542 gp_Pnt2d P2(20 ,24); \n\
1543 Standard_Real aheight = 1; \n\
1544 FairCurve_MinimalVariation MV (P1,P2,aheight); \n\
1545 MV.SetAngle1(22*PI180); \n\
1546 MV.SetAngle2(44*PI180); \n\
1548 FairCurve_AnalysisCode anAnalysisCode; \n\
1549 MV.Compute(anAnalysisCode); \n\
1551 Handle(Geom2d_BSplineCurve) C = MV.Curve(); \n\
1553 AddSeparator(aDoc,Message);
1554 //--------------------------------------------------------------
1556 DisplayCurveAndCurvature(aDoc,C,7,Standard_False);
1557 DisplayPoint(aDoc,P1,"P1",false,0.5);
1558 DisplayPoint(aDoc,P2,"P2",false,0.5);
1560 PostProcess(aDoc,ID_BUTTON_Test_22,TheDisplayType,Message.ToCString());
1563 // Function name : GeomSources::gpTest23
1565 // Return type : void
1566 // Argument : CGeometryDoc* aDoc
1567 void GeomSources::gpTest23(CGeometryDoc* aDoc)
1569 DisplayType TheDisplayType = a2DNo3D;
1570 PreProcess(aDoc,TheDisplayType);
1571 //==============================================================
1573 Standard_Real major = 12;
1574 Standard_Real minor = 4;
1575 gp_Ax2d axis = gp::OX2d();
1576 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor);
1577 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2);
1579 // The segment goes in the direction Vfrom P1
1580 // to the point projected on this line by P2
1581 // In the example (0,6).
1582 Handle(Geom2d_BSplineCurve) SPL =
1583 Geom2dConvert::CurveToBSplineCurve(TC);
1585 //==============================================================
1586 TCollection_AsciiString Message (" \
1588 Standard_Real major = 12; \n\
1589 Standard_Real minor = 4; \n\
1590 gp_Ax2d axis = gp::OX2d(); \n\
1591 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor); \n\
1593 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2); \n\
1595 // The segment goes in the direction Vfrom P1 \n\
1596 // to the point projected on this line by P2 \n\
1597 // In the example (0,6). \n\
1598 Handle(Geom2d_BSplineCurve) SPL = \n\
1599 Geom2dConvert::CurveToBSplineCurve(TC); \n\
1601 AddSeparator(aDoc,Message);
1602 //--------------------------------------------------------------
1604 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
1605 aCurve->SetColorIndex(3); // Red
1606 aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
1607 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1609 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL);
1610 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1612 PostProcess(aDoc,ID_BUTTON_Test_23,TheDisplayType,Message.ToCString());
1615 // Function name : GeomSources::gpTest24
1617 // Return type : void
1618 // Argument : CGeometryDoc* aDoc
1619 void GeomSources::gpTest24(CGeometryDoc* aDoc)
1621 DisplayType TheDisplayType = a2D3D;
1622 PreProcess(aDoc,TheDisplayType);
1623 //==============================================================
1625 Standard_Real radius = 5;
1626 gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0));
1628 Handle(Geom2d_Circle) circ2d =
1629 new Geom2d_Circle(ax2d,radius);
1631 gp_Ax2d circ2dXAxis = circ2d->XAxis();
1633 // create a 3D curve in a given plane
1634 Handle(Geom_Curve) C3D =
1635 GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY())));
1636 Handle(Geom_Circle) C3DCircle =
1637 Handle(Geom_Circle)::DownCast(C3D);
1639 gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis();
1641 // project it to a 2D curve in another plane
1643 gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 ));
1645 Handle(Geom2d_Curve) C2D =
1646 GeomAPI::To2d(C3D,ProjectionPlane);
1648 Handle(Geom2d_Circle) C2DCircle =
1649 Handle(Geom2d_Circle)::DownCast(C2D);
1650 gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis();
1652 //==============================================================
1653 TCollection_AsciiString Message (" \
1655 Standard_Real radius = 5; \n\
1656 gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0)); \n\
1658 Handle(Geom2d_Circle) circ2d = \n\
1659 new Geom2d_Circle(ax2d,radius); \n\
1661 gp_Ax2d circ2dXAxis = circ2d->XAxis(); \n\
1663 // create a 3D curve in a given plane \n\
1664 Handle(Geom_Curve) C3D = \n\
1665 GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY()))); \n\
1666 Handle(Geom_Circle) C3DCircle = \n\
1667 Handle(Geom_Circle)::DownCast(C3D); \n\
1669 gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis(); \n\
1671 // project it to a 2D curve in another plane \n\
1673 gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 )); \n\
1675 Handle(Geom2d_Curve) C2D = \n\
1676 GeomAPI::To2d(C3D,ProjectionPlane); \n\
1678 Handle(Geom2d_Circle) C2DCircle = \n\
1679 Handle(Geom2d_Circle)::DownCast(C2D); \n\
1680 gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis(); \n\
1682 AddSeparator(aDoc,Message);
1683 //--------------------------------------------------------------
1684 Handle(Geom_Plane) aPlane = GC_MakePlane(gp_Pln(gp_Ax3(gp::XOY()))).Value();
1685 Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);
1686 DisplaySurface(aDoc,aSurface);
1688 Handle(Geom_Plane) aProjectionPlane = GC_MakePlane(ProjectionPlane).Value();
1689 Handle(Geom_RectangularTrimmedSurface) aProjectionPlaneSurface=
1690 new Geom_RectangularTrimmedSurface(aProjectionPlane,-8.,8.,-12.,12.);
1692 DisplaySurface(aDoc,aProjectionPlaneSurface);
1694 Standard_CString aC3DEntityTypeName = C3D->DynamicType()->Name();
1695 Standard_CString aC2DEntityTypeName = C2D->DynamicType()->Name();
1697 Message += " C3D->DynamicType()->Name() = ";
1698 Message += aC3DEntityTypeName; Message += " \n";
1699 Message += " C2D->DynamicType()->Name() = ";
1700 Message += aC2DEntityTypeName; Message += " \n";
1702 DisplayCurve(aDoc,circ2d,4,false);
1703 DisplayCurve(aDoc,C3D,false);
1704 DisplayCurve(aDoc,C2D,5,false);
1706 Handle(ISession_Direction) aC3DCircleXAxisDirection = new ISession_Direction((gp_Pnt)C3DCircleXAxis.Location(),
1707 (gp_Dir)C3DCircleXAxis.Direction(),
1709 aDoc->GetAISContext()->Display(aC3DCircleXAxisDirection, Standard_False);
1711 Handle(ISession_Direction) acirc2dXAxisDirection = new ISession_Direction((gp_Pnt2d)circ2dXAxis.Location(),
1712 (gp_Dir2d)circ2dXAxis.Direction(),
1714 aDoc->GetISessionContext()->Display(acirc2dXAxisDirection, Standard_False);
1716 Handle(ISession_Direction) aC2DCircleXAxisDirection = new ISession_Direction((gp_Pnt2d)C2DCircleXAxis.Location(),
1717 (gp_Dir2d)C2DCircleXAxis.Direction(),
1719 aDoc->GetISessionContext()->Display(aC2DCircleXAxisDirection, Standard_False);
1721 PostProcess(aDoc,ID_BUTTON_Test_24,TheDisplayType,Message.ToCString());
1724 // Function name : GeomSources::gpTest25
1726 // Return type : void
1727 // Argument : CGeometryDoc* aDoc
1728 void GeomSources::gpTest25(CGeometryDoc* aDoc)
1730 DisplayType TheDisplayType = a2DNo3D;
1731 PreProcess(aDoc,TheDisplayType);
1733 //==============================================================
1735 Handle(TColgp_HArray1OfPnt2d) harray =
1736 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1737 harray->SetValue(1,gp_Pnt2d (0,0));
1738 harray->SetValue(2,gp_Pnt2d (-3,1));
1739 harray->SetValue(3,gp_Pnt2d (-2,5));
1740 harray->SetValue(4,gp_Pnt2d (2,9));
1741 harray->SetValue(5,gp_Pnt2d (-4,14));
1743 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);
1744 anInterpolation.Perform();
1745 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve();
1749 gp_Dir2d V1 = gp::DY2d();
1750 Handle(Geom2d_TrimmedCurve) TC1 =
1751 GCE2d_MakeSegment(P1,V1,P2);
1753 Standard_Real tolerance = Precision::Confusion();
1754 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance);
1755 Standard_Integer NbPoints =ICC.NbPoints();
1758 for (Standard_Integer k = 1;k<=NbPoints;k++)
1761 // do something with each intersection point
1764 //==============================================================
1765 TCollection_AsciiString Message (" \
1767 Handle(TColgp_HArray1OfPnt2d) harray = \n\
1768 new TColgp_HArray1OfPnt2d (1,5); // sizing harray \n\
1769 harray->SetValue(1,gp_Pnt2d (0,0)); \n\
1770 harray->SetValue(2,gp_Pnt2d (-3,1)); \n\
1771 harray->SetValue(3,gp_Pnt2d (-2,5)); \n\
1772 harray->SetValue(4,gp_Pnt2d (2,9)); \n\
1773 harray->SetValue(5,gp_Pnt2d (-4,14)); \n\
1775 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01); \n\
1776 anInterpolation.Perform(); \n\
1777 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve(); \n\
1779 gp_Pnt2d P1(-1,-2); \n\
1780 gp_Pnt2d P2(0,15); \n\
1781 gp_Dir2d V1 = gp::DY2d(); \n\
1782 Handle(Geom2d_TrimmedCurve) TC1= \n\
1783 GCE2d_MakeSegment(P1,V1,P2); \n\
1785 Standard_Real tolerance = Precision::Confusion(); \n\
1786 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance); \n\
1787 Standard_Integer NbPoints =ICC.NbPoints(); \n\
1789 for (Standard_Integer k = 1;k<=NbPoints;k++) \n\
1791 PK = ICC.Point(k); \n\
1792 // do something with each intersection point \n\
1795 AddSeparator(aDoc,Message);
1796 //--------------------------------------------------------------
1798 Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL);
1799 aCurve1->SetDisplayPole(Standard_False);
1800 aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
1801 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC1);
1802 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1804 TCollection_AsciiString aString;
1805 for (Standard_Integer i = 1;i<=NbPoints;i++)
1808 // do something with each intersection point
1809 TCollection_AsciiString Message2 (i);
1810 TCollection_AsciiString Message3 (PK.X());
1811 TCollection_AsciiString Message4 (PK.Y());
1813 aString += Message2;
1815 DisplayPoint(aDoc,PK,aString.ToCString(),false,0.5);
1818 Message += Message2;
1820 Message += Message3;
1822 Message += Message4;
1826 PostProcess(aDoc,ID_BUTTON_Test_25,TheDisplayType,Message.ToCString());
1829 // Function name : GeomSources::gpTest26
1831 // Return type : void
1832 // Argument : CGeometryDoc* aDoc
1833 void GeomSources::gpTest26(CGeometryDoc* aDoc)
1835 DisplayType TheDisplayType = a2DNo3D;
1836 PreProcess(aDoc,TheDisplayType);
1838 //==============================================================
1840 //----------- Build TC1 -----------------------
1841 gp_Pnt2d P1(0,0); gp_Pnt2d P2(2,6);
1842 gp_Dir2d V1 = gp::DY2d();
1843 Handle(Geom2d_TrimmedCurve) TC1 = GCE2d_MakeSegment(P1,V1,P2);
1844 Standard_Real FP1 = TC1->FirstParameter();
1845 Standard_Real LP1 = TC1->LastParameter();
1846 //----------- Build TC2 -----------------------
1847 gp_Pnt2d P3(-9,6.5); gp_Dir2d V2 = gp::DX2d();
1848 Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2);
1849 Standard_Real FP2 = TC1->FirstParameter();
1850 Standard_Real LP2 = TC1->LastParameter();
1851 //----------- Extrema TC1 / TC2 ---------------
1852 Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2);
1853 Standard_Real shortestdistance =-1;
1854 if (ECC.NbExtrema() != 0) shortestdistance = ECC.LowerDistance();
1855 //----------- Build SPL1 ----------------------
1856 TColgp_Array1OfPnt2d array (1,5); // sizing array
1857 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));
1858 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));
1859 array.SetValue(5,gp_Pnt2d (-3,5));
1860 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);
1861 Standard_Real FPSPL1 = SPL1->FirstParameter();
1862 Standard_Real LPSPL1 = SPL1->LastParameter();
1863 //----------- Extrema TC1 / SPL1 -------------
1864 Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1);
1865 Standard_Real SPL1shortestdistance =-1;
1866 if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance();
1867 Standard_Integer NbExtrema = ECC2.NbExtrema();
1868 TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2);
1869 for(int i=1;i <= NbExtrema; i++)
1872 ECC2.Points(i,P1,P2);
1873 aSolutionArray(i,1) = P1;
1874 aSolutionArray(i,2) = P2;
1877 //==============================================================
1878 TCollection_AsciiString Message (" \
1879 //----------- Build TC1 ----------------------- \n\
1880 gp_Pnt2d P1(0,0); gp_Pnt2d P2(2,6); \n\
1881 gp_Dir2d V1 = gp::DY2d(); \n\
1882 Handle(Geom2d_TrimmedCurve) TC1 = GCE2d_MakeSegment(P1,V1,P2); \n\
1883 Standard_Real FP1 = TC1->FirstParameter(); \n\
1884 Standard_Real LP1 = TC1->LastParameter(); \n\
1885 //----------- Build TC2 ----------------------- \n\
1886 gp_Pnt2d P3(-9,6.5); gp_Dir2d V2 = gp::DX2d(); \n\
1887 Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2); \n\
1888 Standard_Real FP2 = TC1->FirstParameter(); \n\
1889 Standard_Real LP2 = TC1->LastParameter(); \n\
1890 //----------- Extrema TC1 / TC2 --------------- \n\
1891 Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2); \n\
1892 Standard_Real shortestdistance =-1; \n\
1893 if (ECC.NbExtrema() != 0) shortestdistance = ECC.LowerDistance(); \n\
1894 //----------- Build SPL1 ---------------------- \n\
1895 TColgp_Array1OfPnt2d array (1,5); // sizing array \n\
1896 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2)); \n\
1897 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3)); \n\
1898 array.SetValue(5,gp_Pnt2d (-3,5)); \n\
1899 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array); \n\
1900 Standard_Real FPSPL1 = SPL1->FirstParameter(); \n");
1902 Standard_Real LPSPL1 = SPL1->LastParameter(); \n\
1903 //----------- Extrema TC1 / SPL1 ------------- \n\
1904 Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1); \n\
1905 Standard_Real SPL1shortestdistance =-1; \n\
1906 if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance(); \n\
1907 Standard_Integer NbExtrema = ECC2.NbExtrema(); \n\
1908 TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2); \n\
1909 for(int i=1;i <= NbExtrema; i++) { \n\
1911 ECC2.Points(i,P1,P2); \n\
1912 aSolutionArray(i,1) = P1; aSolutionArray(i,2) = P2; } \n";
1913 AddSeparator(aDoc,Message);
1914 //--------------------------------------------------------------
1916 TCollection_AsciiString aString;
1917 for(int i = array.Lower();i<=array.Upper();i++)
1919 TCollection_AsciiString Message2 (i);
1920 gp_Pnt2d P = array(i);
1922 aString += Message2;
1923 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1928 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1929 aCurve->SetDisplayPole(Standard_False);
1930 aCurve->SetColorIndex(3);
1931 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1934 MessageBox(0,"SPL1.IsNull()","CasCade Error",MB_ICONERROR);
1936 Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(TC1);
1937 aCurve1->SetColorIndex(6);
1938 aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
1939 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC2);
1940 aCurve2->SetColorIndex(5);
1941 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1943 for(int i=1;i <= NbExtrema; i++)
1945 gp_Pnt2d P1 =aSolutionArray(i,1);
1947 TCollection_AsciiString Message2 (i);
1949 aString += Message2;
1950 DisplayPoint(aDoc,P1,aString.ToCString(),false,0.7*i);
1952 gp_Pnt2d P2 = aSolutionArray(i,2);
1954 Handle(Geom2d_TrimmedCurve) SolutionCurve =
1955 GCE2d_MakeSegment(P1,P2);
1956 Handle(ISession2D_Curve) aSolutionCurve = new ISession2D_Curve(SolutionCurve);
1957 aDoc->GetISessionContext()->Display(aSolutionCurve, Standard_False);
1960 Message += "TC1 is Yellow ,TC2 is Blue ,SPL1 is Red \n";
1961 Message += "ECC.NbExtrema() = ";
1962 Message += ECC.NbExtrema();
1963 Message += " shortestdistance = ";
1964 Message+= shortestdistance;
1966 Message += "ECC2.NbExtrema() = ";
1967 Message += NbExtrema;
1968 Message += " SPL1shortestdistance = ";
1969 Message+= SPL1shortestdistance;
1972 PostProcess(aDoc,ID_BUTTON_Test_26,TheDisplayType,Message.ToCString());
1975 // Function name : GeomSources::gpTest27
1977 // Return type : void
1978 // Argument : CGeometryDoc* aDoc
1979 void GeomSources::gpTest27(CGeometryDoc* aDoc)
1981 DisplayType TheDisplayType = a2DNo3D;
1982 PreProcess(aDoc,TheDisplayType);
1983 //==============================================================
1985 TColgp_Array1OfPnt2d array (1,5); // sizing array
1986 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));
1987 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));
1988 array.SetValue(5,gp_Pnt2d (-3,5));
1989 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);
1991 Standard_Real dist = 1;
1992 Handle(Geom2d_OffsetCurve) OC =
1993 new Geom2d_OffsetCurve(SPL1,dist);
1994 Standard_Boolean result = OC->IsCN(2);
1995 Standard_Real dist2 = 1.5;
1996 Handle(Geom2d_OffsetCurve) OC2 =
1997 new Geom2d_OffsetCurve(SPL1,dist2);
1998 Standard_Boolean result2 = OC2->IsCN(2);
2000 //==============================================================
2001 TCollection_AsciiString Message (" \
2003 TColgp_Array1OfPnt2d array (1,5); // sizing array \n\
2004 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2)); \n\
2005 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3)); \n\
2006 array.SetValue(5,gp_Pnt2d (-3,5)); \n\
2007 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array); \n\
2009 Standard_Real dist = 1; \n\
2010 Handle(Geom2d_OffsetCurve) OC = \n\
2011 new Geom2d_OffsetCurve(SPL1,dist); \n\
2012 Standard_Boolean result = OC->IsCN(2); \n\
2014 Standard_Real dist2 = 1.5; \n\
2015 Handle(Geom2d_OffsetCurve) OC2 = \n\
2016 new Geom2d_OffsetCurve(SPL1,dist2); \n\
2017 Standard_Boolean result2 = OC2->IsCN(2); \n\
2019 AddSeparator(aDoc,Message);
2020 //--------------------------------------------------------------
2021 Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL1);
2022 aCurve1->SetColorIndex(6);
2023 aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
2024 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(OC);
2025 aCurve2->SetColorIndex(5);
2026 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2027 Handle(ISession2D_Curve) aCurve3 = new ISession2D_Curve(OC2);
2028 aCurve3->SetColorIndex(3);
2029 aDoc->GetISessionContext()->Display(aCurve3, Standard_False);
2032 Message += "SPL1 is Yellow \n";
2033 Message += "OC is Blue \n";
2034 Message += "OC2 is Red \n\n";
2035 Message += " Warning, Continuity is not guaranteed : \n ";
2037 Message += " result = True \n";
2039 Message += " result = False \n";
2041 Message += " result2 = True \n";
2043 Message += " result2 = False \n";
2045 PostProcess(aDoc,ID_BUTTON_Test_27,TheDisplayType,Message.ToCString());
2048 // Function name : GeomSources::gpTest28
2050 // Return type : void
2051 // Argument : CGeometryDoc* aDoc
2052 void GeomSources::gpTest28(CGeometryDoc* aDoc)
2054 DisplayType TheDisplayType = a2DNo3D;
2055 PreProcess(aDoc,TheDisplayType);
2056 //==============================================================
2060 gp_Lin2d L = gce_MakeLin2d(P1,P2);
2061 // assignment by overloaded operator
2063 //==============================================================
2064 TCollection_AsciiString Message (" \
2066 gp_Pnt2d P1(1,2); \n\
2067 gp_Pnt2d P2(4,5); \n\
2068 gp_Lin2d L = gce_MakeLin2d(P1,P2); \n\
2069 // assignment by overloaded operator \n\
2071 AddSeparator(aDoc,Message);
2072 //--------------------------------------------------------------
2074 DisplayPoint(aDoc,P1,"P1",false,0.5);
2075 DisplayPoint(aDoc,P2,"P2",false,0.5);
2077 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-3,8);
2078 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2079 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2081 PostProcess(aDoc,ID_BUTTON_Test_28,TheDisplayType,Message.ToCString());
2084 // Function name : GeomSources::gpTest29
2086 // Return type : void
2087 // Argument : CGeometryDoc* aDoc
2088 void GeomSources::gpTest29(CGeometryDoc* aDoc)
2090 DisplayType TheDisplayType = a2DNo3D;
2091 PreProcess(aDoc,TheDisplayType);
2093 //==============================================================
2098 GccAna_Pnt2dBisec B(P1,P2);
2101 L = B.ThisSolution();
2104 //==============================================================
2105 TCollection_AsciiString Message (" \
2107 gp_Pnt2d P1(1,2); \n\
2108 gp_Pnt2d P2(4,5); \n\
2110 GccAna_Pnt2dBisec B(P1,P2); \n\
2113 L = B.ThisSolution(); \n\
2116 AddSeparator(aDoc,Message);
2117 //--------------------------------------------------------------
2119 DisplayPoint(aDoc,P1,"P1",false,0.5);
2120 DisplayPoint(aDoc,P2,"P2",false,0.5);
2124 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-8,8);
2125 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2126 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2129 if (B.IsDone()) Message += " \n B Is Done ";
2130 else Message += " \n B Is not Done ";
2131 PostProcess(aDoc,ID_BUTTON_Test_29,TheDisplayType,Message.ToCString());
2134 // Function name : GeomSources::gpTest30
2136 // Return type : void
2137 // Argument : CGeometryDoc* aDoc
2138 void GeomSources::gpTest30(CGeometryDoc* aDoc)
2140 DisplayType TheDisplayType =a2DNo3D ;
2141 PreProcess(aDoc,TheDisplayType);
2143 //==============================================================
2148 gp_Pnt2d P4 (10,10);
2149 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);
2150 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);
2151 GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion());
2152 Standard_Integer NbSol;
2155 NbSol = LT.NbSolutions();
2156 for(Standard_Integer k=1; k<=NbSol; k++)
2158 gp_Lin2d L = LT.ThisSolution(k);
2159 // do something with L
2163 //==============================================================
2164 TCollection_AsciiString Message (" \
2166 gp_Pnt2d P1 (2,3); \n\
2167 gp_Pnt2d P2 (4,4); \n\
2168 gp_Pnt2d P3 (6,7); \n\
2169 gp_Pnt2d P4 (10,10); \n\
2170 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3); \n\
2171 GccEnt_QualifiedCirc QC = GccEnt::Outside(C); \n\
2172 GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion()); \n\
2173 Standard_Integer NbSol; \n\
2174 if (LT.IsDone()) \n\
2176 NbSol = LT.NbSolutions(); \n\
2177 for(Standard_Integer k=1; k<=NbSol; k++) \n\
2179 gp_Lin2d L = LT.ThisSolution(k); \n\
2180 // do something with L \n\
2184 AddSeparator(aDoc,Message);
2185 //--------------------------------------------------------------
2187 DisplayPoint(aDoc,P1,"P1",false,0.5,-1,0.1);
2188 DisplayPoint(aDoc,P2,"P2",false,0.5,-0.7,0.1);
2189 DisplayPoint(aDoc,P3,"P3",false,0.5,-0.5,0.1);
2190 DisplayPoint(aDoc,P4,"P4",false,0.5,0,0.1);
2192 Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2193 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2194 aCurve->SetColorIndex(5);
2195 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2199 Standard_Integer NbSol = LT.NbSolutions();
2200 for(Standard_Integer k=1; k<=NbSol; k++)
2202 gp_Lin2d L = LT.ThisSolution(k);
2203 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-10,20);
2204 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2205 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2208 Message += " C is Blue \n\n";
2209 Message += "LT.IsDone() = ";
2210 if (LT.IsDone()) Message += "True \n"; else Message += "False \n";
2211 TCollection_AsciiString Message2 (NbSol);
2212 Message += "NbSol = "; Message += Message2 ; Message += "\n";
2214 PostProcess(aDoc,ID_BUTTON_Test_30,TheDisplayType,Message.ToCString());
2217 // Function name : GeomSources::gpTest31
2219 // Return type : void
2220 // Argument : CGeometryDoc* aDoc
2221 void GeomSources::gpTest31(CGeometryDoc* aDoc)
2223 DisplayType TheDisplayType = a2DNo3D;
2224 PreProcess(aDoc,TheDisplayType);
2226 //==============================================================
2231 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);
2232 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);
2234 gp_Pnt2d P5 (12,-3);
2235 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1);
2236 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L);
2237 Standard_Real radius = 2;
2238 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion());
2239 Standard_Real parsol,pararg;
2240 gp_Pnt2d tangentpoint1,tangentpoint2;
2244 Standard_Integer NbSol = TR.NbSolutions();
2245 for (Standard_Integer k=1; k<=NbSol; k++)
2247 circ = TR.ThisSolution(k);
2248 // find the solution circle
2249 TR.Tangency1(k,parsol,pararg,tangentpoint1);
2250 // find the first tangent point
2251 TR.Tangency2(k,parsol,pararg,tangentpoint2);
2252 // find the second tangent point
2256 //==============================================================
2257 TCollection_AsciiString Message;
2260 gp_Pnt2d P1 (9,6); \n\
2261 gp_Pnt2d P2 (10,4); \n\
2262 gp_Pnt2d P3 (6,7); \n\
2263 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3); \n\
2264 GccEnt_QualifiedCirc QC = GccEnt::Outside(C); \n\
2265 gp_Pnt2d P4 (-2,7); \n\
2266 gp_Pnt2d P5 (12,-3); \n\
2267 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1); \n\
2268 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L); \n\
2269 Standard_Real radius = 2; \n\
2270 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion()); \n\
2271 Standard_Real parsol,pararg; \n\
2272 gp_Pnt2d tangentpoint1,tangentpoint2; \n\
2274 if (TR.IsDone()) \n\
2276 Standard_Integer NbSol = TR.NbSolutions(); \n\
2277 for (Standard_Integer k=1; k<=NbSol; k++) \n\
2280 circ = TR.ThisSolution(k); \n\
2281 // find the solution circle \n\
2282 TR.Tangency1(k,parsol,pararg,tangentpoint1); \n\
2283 // find the first tangent point \n\
2284 TR.Tangency2(k,parsol,pararg,tangentpoint2); \n\
2285 // find the second tangent point \n\
2289 AddSeparator(aDoc,Message);
2291 //--------------------------------------------------------------
2292 DisplayPoint(aDoc,P1,"P1",false,0.3);
2293 DisplayPoint(aDoc,P2,"P2",false,0.3);
2294 DisplayPoint(aDoc,P3,"P3",false,0.3);
2295 DisplayPoint(aDoc,P4,"P4",false,0.3);
2296 DisplayPoint(aDoc,P5,"P5",false,0.3);
2298 Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2299 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2300 aCurve->SetColorIndex(3);
2302 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2303 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-2,20);
2304 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(aLine);
2305 aCurve2->SetColorIndex(5);
2306 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2310 Standard_Integer NbSol = TR.NbSolutions();
2311 for (Standard_Integer k=1; k<=NbSol; k++)
2313 circ = TR.ThisSolution(k);
2314 Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(circ);
2315 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2316 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2318 // find the solution circle
2319 TR.Tangency1(k,parsol,pararg,tangentpoint1);
2320 // find the first tangent point
2321 TR.Tangency2(k,parsol,pararg,tangentpoint2);
2322 // find the second tangent point
2323 DisplayPoint(aDoc,tangentpoint1,"tangentpoint1",false,0.3);
2324 DisplayPoint(aDoc,tangentpoint2,"tangentpoint2",false,0.3);
2327 Message += "C is Red \n";
2328 Message += "L is Blue \n";
2329 PostProcess(aDoc,ID_BUTTON_Test_31,TheDisplayType,Message.ToCString());
2332 // Function name : GeomSources::gpTest32
2334 // Return type : void
2335 // Argument : CGeometryDoc* aDoc
2336 void GeomSources::gpTest32(CGeometryDoc* aDoc)
2338 DisplayType TheDisplayType = a2DNo3D;
2339 PreProcess(aDoc,TheDisplayType);
2341 //==============================================================
2343 Standard_Real major = 12;
2344 Standard_Real minor = 4;
2345 gp_Ax2d axis = gp::OX2d();
2346 gp_Elips2d EE(axis,major,minor);
2347 Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,M_PI/4);
2349 //==============================================================
2350 TCollection_AsciiString Message (" \
2352 Standard_Real major = 12; \n\
2353 Standard_Real minor = 4; \n\
2354 gp_Ax2d axis = gp::OX2d(); \n\
2355 gp_Elips2d EE(axis,major,minor); \n\
2356 Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,PI/4); \n\
2358 AddSeparator(aDoc,Message);
2359 //--------------------------------------------------------------
2360 Handle(Geom2d_Curve) E = GCE2d_MakeEllipse(EE);
2361 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
2362 aCurve->SetColorIndex(3);
2363 aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
2365 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2366 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(arc);
2367 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2368 TCollection_AsciiString Message2 (M_PI);
2369 Message += " PI = ";Message+= Message2;
2371 PostProcess(aDoc,ID_BUTTON_Test_32,TheDisplayType,Message.ToCString());
2374 // Function name : GeomSources::gpTest33
2376 // Return type : void
2377 // Argument : CGeometryDoc* aDoc
2378 void GeomSources::gpTest33(CGeometryDoc* aDoc)
2380 DisplayType TheDisplayType = No2D3D;
2381 PreProcess(aDoc,TheDisplayType);
2383 //==============================================================
2390 TColgp_Array1OfPnt array (1,5); // sizing array
2391 array.SetValue(1,P1);
2392 array.SetValue(2,P2);
2393 array.SetValue(3,P3);
2394 array.SetValue(4,P4);
2395 array.SetValue(5,P5);
2396 Handle(TColgp_HArray1OfPnt) harray =
2397 new TColgp_HArray1OfPnt (1,5); // sizing harray
2398 harray->SetValue(1,P1.Translated(gp_Vec(4,0,0)));
2399 harray->SetValue(2,P2.Translated(gp_Vec(4,0,0)));
2400 harray->SetValue(3,P3.Translated(gp_Vec(4,0,0)));
2401 harray->SetValue(4,P4.Translated(gp_Vec(4,0,0)));
2402 harray->SetValue(5,P5.Translated(gp_Vec(4,0,0)));
2403 Handle(Geom_BSplineCurve) SPL1 =
2404 GeomAPI_PointsToBSpline(array).Curve();
2406 GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation());
2407 anInterpolation.Perform();
2409 Handle(Geom_BSplineCurve) SPL2;
2410 if (anInterpolation.IsDone())
2411 SPL2 = anInterpolation.Curve();
2413 MessageBox(0,"The Interpolation is Not done","CasCade Warning",MB_ICONWARNING);
2415 //==============================================================
2416 TCollection_AsciiString Message (" \
2418 gp_Pnt P1(0,0,1); \n\
2419 gp_Pnt P2(1,2,2); \n\
2420 gp_Pnt P3(2,3,3); \n\
2421 gp_Pnt P4(4,3,4); \n\
2422 gp_Pnt P5(5,5,5); \n\
2423 TColgp_Array1OfPnt array (1,5); // sizing array \n\
2424 array.SetValue(1,P1); \n\
2425 array.SetValue(2,P2); \n\
2426 array.SetValue(3,P3); \n\
2427 array.SetValue(4,P4); \n\
2428 array.SetValue(5,P5); \n\
2429 Handle(TColgp_HArray1OfPnt) harray = \n\
2430 new TColgp_HArray1OfPnt (1,5); // sizing harray \n\
2431 harray->SetValue(1,P1.Translated(gp_Vec(4,0,0))); \n\
2432 harray->SetValue(2,P2.Translated(gp_Vec(4,0,0))); \n\
2433 harray->SetValue(3,P3.Translated(gp_Vec(4,0,0))); \n\
2434 harray->SetValue(4,P4.Translated(gp_Vec(4,0,0))); \n\
2435 harray->SetValue(5,P5.Translated(gp_Vec(4,0,0))); \n\
2436 Handle(Geom_BSplineCurve) SPL1 = \n\
2437 GeomAPI_PointsToBSpline(array).Curve(); \n");
2440 GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation()); \n\
2441 anInterpolation.Perform(); \n\
2443 Handle(Geom_BSplineCurve) SPL2; \n\
2444 if (anInterpolation.IsDone()) \n\
2445 SPL2 = anInterpolation.Curve(); \n\
2447 MessageBox(0,\"The Interpolation is Not done\",\"CasCade Warning\",MB_ICONWARNING); \n\
2449 AddSeparator(aDoc,Message);
2451 //--------------------------------------------------------------
2453 TCollection_AsciiString aString;
2454 for(Standard_Integer i = array.Lower();i<=array.Upper();i++)
2457 TCollection_AsciiString Message2 (i);
2458 gp_Pnt P = array(i);
2461 aString += Message2;
2462 if (i == 1) aString += " (array) ";
2463 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);\
2466 aString += Message2;
2467 if (i == 1) aString += " (harray) ";
2468 DisplayPoint(aDoc,P.Translated(gp_Vec(4,0,0)),aString.ToCString(),false,0.5);\
2472 Handle(ISession_Curve) aCurve = new ISession_Curve(SPL1);
2473 aDoc->GetAISContext()->SetDisplayMode(aCurve,1);
2474 aDoc->GetAISContext()->Display(aCurve, Standard_False);
2476 if (anInterpolation.IsDone())
2478 Handle(ISession_Curve) aCurve2 = new ISession_Curve(SPL2);
2479 aDoc->GetAISContext()->SetDisplayMode(aCurve2,1);
2480 aDoc->GetAISContext()->Display(aCurve2, Standard_False);
2483 PostProcess(aDoc,ID_BUTTON_Test_33,TheDisplayType,Message.ToCString());
2486 // Function name : GeomSources::gpTest34
2488 // Return type : void
2489 // Argument : CGeometryDoc* aDoc
2490 void GeomSources::gpTest34(CGeometryDoc* aDoc)
2492 DisplayType TheDisplayType = No2D3D;
2493 PreProcess(aDoc,TheDisplayType);
2495 //==============================================================
2497 TColgp_Array1OfPnt array (1,5); // sizing array
2498 array.SetValue(1,gp_Pnt(0,0,1));
2499 array.SetValue(2,gp_Pnt(1,2,2));
2500 array.SetValue(3,gp_Pnt(2,3,3));
2501 array.SetValue(4,gp_Pnt(4,4,4));
2502 array.SetValue(5,gp_Pnt(5,5,5));
2504 GProp_PEquation PE (array,1.5 );
2518 //==============================================================
2519 TCollection_AsciiString Message (" \
2521 TColgp_Array1OfPnt array (1,5); // sizing array \n\
2522 array.SetValue(1,gp_Pnt(0,0,1)); \n\
2523 array.SetValue(2,gp_Pnt(1,2,2)); \n\
2524 array.SetValue(3,gp_Pnt(2,3,3)); \n\
2525 array.SetValue(4,gp_Pnt(4,4,4)); \n\
2526 array.SetValue(5,gp_Pnt(5,5,5)); \n\
2528 GProp_PEquation PE (array,1.5 ); \n\
2530 if (PE.IsPoint()){ /* ... */ } \n\
2532 if (PE.IsLinear()) { L = PE.Line(); } \n\
2533 if (PE.IsPlanar()){ /* ... */ } \n\
2534 if (PE.IsSpace()) { /* ... */ } \n\
2536 AddSeparator(aDoc,Message);
2537 //--------------------------------------------------------------
2538 TCollection_AsciiString aString;
2539 for(Standard_Integer i = array.Lower();i<=array.Upper();i++)
2541 TCollection_AsciiString Message2 (i);
2542 gp_Pnt P = array(i);
2545 aString += Message2;
2546 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
2549 Message += " PE.IsPoint() = ";
2551 Message += "True \n";
2553 Message += "False\n";
2555 if (PE.IsLinear()) {
2556 Message += " PE.IsLinear() = True \n";
2558 Handle(Geom_Line) aLine = new Geom_Line(L);
2559 Handle(Geom_TrimmedCurve) aTrimmedCurve = new Geom_TrimmedCurve(aLine,-10,10);
2560 Handle(ISession_Curve) aCurve = new ISession_Curve(aTrimmedCurve);
2561 aDoc->GetAISContext()->Display(aCurve, Standard_False);
2564 Message += "PE.IsLinear() = False \n";
2566 Message += " PE.IsPlanar() = ";
2568 Message += "True \n";
2570 Message += "False\n";
2572 Message += " PE.IsSpace() = ";
2574 Message += "True \n";
2576 Message += "False\n";
2578 PostProcess(aDoc,ID_BUTTON_Test_34,TheDisplayType,Message.ToCString());
2581 // Function name : GeomSources::gpTest35
2583 // Return type : void
2584 // Argument : CGeometryDoc* aDoc
2585 void GeomSources::gpTest35(CGeometryDoc* aDoc)
2587 DisplayType TheDisplayType = No2D3D;
2588 PreProcess(aDoc,TheDisplayType);
2590 //==============================================================
2594 Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value();
2597 Standard_Real radius1 = 3;
2598 Standard_Real radius2 = 2;
2599 Handle(Geom_Surface) aSurface =
2600 GC_MakeConicalSurface(P3,P4,radius1,radius2).Value();
2601 GeomAPI_IntCS CS (aCurve,aSurface);
2602 Handle(Geom_Curve) segment;
2604 Standard_Integer NbSeg;
2605 Standard_Integer NbPoints;
2608 NbSeg = CS.NbSegments();
2609 for (Standard_Integer k=1; k<=NbSeg; k++)
2611 segment = CS.Segment(k);
2612 // do something with the segment
2615 NbPoints = CS.NbPoints();
2616 for (int k=1; k<=NbPoints; k++)
2618 gp_Pnt aPoint=CS.Point(k);
2619 // do something with the point
2623 //==============================================================
2624 TCollection_AsciiString Message (" \
2626 gp_Pnt P1(-5,-5,0); \n\
2627 gp_Pnt P2(9,9,9); \n\
2628 Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value(); \n\
2629 gp_Pnt P3(3,0,0); \n\
2630 gp_Pnt P4(3,0,10); \n\
2631 Standard_Real radius1 = 3; \n\
2632 Standard_Real radius2 = 2; \n\
2633 Handle(Geom_Surface) aSurface = \n\
2634 GC_MakeConicalSurface(P3,P4,radius1,radius2).Value(); \n\
2635 GeomAPI_IntCS CS (aCurve,aSurface); \n\
2636 Handle(Geom_Curve) segment; \n\
2638 Standard_Integer NbSeg; \n\
2639 Standard_Integer NbPoints; \n\
2642 NbSeg = CS.NbSegments(); \n\
2643 for (Standard_Integer k=1; k<=NbSeg; k++) \n\
2645 segment = CS.Segment(k); \n\
2646 // do something with the segment \n\
2649 NbPoints = CS.NbPoints(); \n\
2650 for (k=1; k<=NbPoints; k++) \n\
2652 gp_Pnt aPoint=CS.Point(k); \n\
2653 // do something with the point \n\
2657 AddSeparator(aDoc,Message);
2659 //--------------------------------------------------------------
2661 Handle(ISession_Curve) aCurve2 = new ISession_Curve(aCurve);
2662 aDoc->GetAISContext()->Display(aCurve2, Standard_False);
2664 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface= new Geom_RectangularTrimmedSurface(aSurface,-50.,50.,false);
2666 DisplaySurface(aDoc,aTrimmedSurface);
2668 TCollection_AsciiString aString;
2672 Standard_Integer NbSeg = CS.NbSegments();
2673 for (k=1; k<=NbSeg; k++)
2675 TCollection_AsciiString Message2 (k);
2676 segment = CS.Segment(k);
2677 aString = "S_";aString += Message2;
2678 Handle(ISession_Curve) aCurve = new ISession_Curve(segment);
2679 aDoc->GetAISContext()->Display(aCurve, Standard_False);
2682 for ( k=1; k<=NbPoints; k++)
2684 TCollection_AsciiString Message2 (k);
2685 gp_Pnt aPoint=CS.Point(k);
2686 aString = "P_";aString += Message2;
2687 DisplayPoint(aDoc,aPoint,aString.ToCString(),false,0.5);
2688 // do something with the point
2691 TCollection_AsciiString Message2 (NbSeg);
2692 TCollection_AsciiString Message3 (NbPoints);
2694 Message += "NbSeg = "; Message += Message2 ; Message += "\n";
2695 Message += "NbPoints = "; Message += Message3 ; Message += "\n";
2697 PostProcess(aDoc,ID_BUTTON_Test_35,TheDisplayType,Message.ToCString());
2700 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2702 // Function name : GeomSources::gpTest36
2704 // Return type : void
2705 // Argument : CGeometryDoc* aDoc
2706 void GeomSources::gpTest36(CGeometryDoc* aDoc)
2708 DisplayType TheDisplayType = No2D3D;
2709 PreProcess(aDoc,TheDisplayType);
2710 //==============================================================
2712 gp_Pnt centre (5,5,0); gp_Pnt axispoint (9,9,0);
2713 Standard_Real radius = 3;
2714 Handle(Geom_Circle) circle =
2715 GC_MakeCircle(centre,axispoint,radius);
2717 Handle(Geom_Geometry) aRotatedEntity = circle->Rotated(gp::OZ(),M_PI/4);
2718 Standard_CString aRotatedEntityTypeName = aRotatedEntity->DynamicType()->Name();
2720 Handle(Geom_Geometry) aMirroredEntity = aRotatedEntity->Mirrored(gp::ZOX());
2721 Standard_CString aMirroredEntityTypeName = aMirroredEntity->DynamicType()->Name();
2723 gp_Pnt scalepoint (4,8,0);
2724 Standard_Real scalefactor = 0.2;
2725 Handle(Geom_Geometry) aScaledEntity =
2726 aMirroredEntity->Scaled(scalepoint, scalefactor);
2727 Standard_CString aScaledEntityTypeName = aScaledEntity->DynamicType()->Name();
2729 Handle (Geom_Transformation) GT = GC_MakeTranslation (centre, scalepoint);
2730 gp_Trsf TR = GT->Trsf();
2732 gp_Vec aTranslationVector(TR.TranslationPart ());
2733 Handle(Geom_Geometry) aTranslatedEntity =
2734 aScaledEntity->Translated( aTranslationVector );
2735 Standard_CString aTranslatedEntityTypeName = aTranslatedEntity->DynamicType()->Name();
2737 gp_Mat matrix = TR.HVectorialPart();
2738 Standard_Real value = matrix.Determinant();
2740 //==============================================================
2741 TCollection_AsciiString Message (" \
2743 gp_Pnt centre (5,5,0); gp_Pnt axispoint (9,9,0); \n\
2744 Standard_Real radius = 3; \n\
2745 Handle(Geom_Circle) circle = \n\
2746 GC_MakeCircle(centre,axispoint,radius); \n\
2748 Handle(Geom_Geometry) aRotatedEntity = circle->Rotated(gp::OZ(),PI/4); \n\
2749 Standard_CString aRotatedEntityTypeName = aRotatedEntity->DynamicType()->Name(); \n\
2751 Handle(Geom_Geometry) aMirroredEntity = aRotatedEntity->Mirrored(gp::ZOX()); \n\
2752 Standard_CString aMirroredEntityTypeName = aMirroredEntity->DynamicType()->Name(); \n\
2754 gp_Pnt scalepoint (4,8,0); \n\
2755 Standard_Real scalefactor = 0.2; \n\
2756 Handle(Geom_Geometry) aScaledEntity = \n\
2757 aMirroredEntity->Scaled(scalepoint, scalefactor); \n\
2758 Standard_CString aScaledEntityTypeName = aScaledEntity->DynamicType()->Name(); \n\
2760 Handle (Geom_Transformation) GT = GC_MakeTranslation (centre, scalepoint); \n\
2761 gp_Trsf TR = GT->Trsf(); \n\
2764 gp_Vec aTranslationVector(TR.TranslationPart ()); \n\
2765 Handle(Geom_Geometry) aTranslatedEntity = \n\
2766 aScaledEntity->Translated( aTranslationVector ); \n\
2767 Standard_CString aTranslatedEntityTypeName = aTranslatedEntity->DynamicType()->Name(); \n\
2769 gp_Mat matrix = TR.HVectorialPart(); \n\
2770 Standard_Real value = matrix.Determinant(); \n\
2772 AddSeparator(aDoc,Message);
2773 //--------------------------------------------------------------
2775 DisplayPoint(aDoc,centre,"centre",false,0.5);
2776 DisplayPoint(aDoc,axispoint,"axispoint",false,0.5);
2777 DisplayPoint(aDoc,scalepoint,"scalepoint",false,0.5);
2779 DisplayCurve(aDoc,circle, Quantity_NOC_RED,false);
2780 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aRotatedEntity),Quantity_NOC_PEACHPUFF, false);
2781 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aMirroredEntity), Quantity_NOC_YELLOWGREEN,false);
2782 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aScaledEntity), Quantity_NOC_GREEN,false);
2783 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aTranslatedEntity),Quantity_NOC_WHITE,false);
2785 TCollection_AsciiString Message0 (M_PI);
2786 Message += " PI = ";
2789 Message += " circle is Red; aRotatedEntity is Peach; aMirroredEntity is Yellow Green\n";
2790 Message += " aScaleEntity is Green; aTranslatedEntity is White\n\n";
2792 TCollection_AsciiString Message2 (aTranslationVector.X());
2793 TCollection_AsciiString Message3 (aTranslationVector.Y());
2794 TCollection_AsciiString Message4 (aTranslationVector.Z());
2795 Message += " aTranslationVector ( ";
2796 Message += Message2; Message += " , ";
2797 Message += Message3; Message += " , ";
2798 Message += Message4; Message += " ); \n";
2800 TCollection_AsciiString Message5 (value);
2801 Message += " value = ";Message+= Message5; Message += "\n";
2803 TCollection_AsciiString Message6 (aRotatedEntityTypeName);
2804 TCollection_AsciiString Message7 (aMirroredEntityTypeName);
2805 TCollection_AsciiString Message8 (aScaledEntityTypeName);
2806 TCollection_AsciiString Message9 (aTranslatedEntityTypeName);
2808 Message += " aRotatedEntityTypeName = ";Message+= Message6; Message += "\n";
2809 Message += " aMirroredEntityTypeName = ";Message+= Message7; Message += "\n";
2810 Message += " aScaledEntityTypeName = ";Message+= Message8; Message += "\n";
2811 Message += " aTranslatedEntityTypeName = ";Message+= Message9; Message += "\n";
2813 PostProcess(aDoc,ID_BUTTON_Test_36,TheDisplayType,Message.ToCString());
2816 // Function name : GeomSources::gpTest37
2818 // Return type : void
2819 // Argument : CGeometryDoc* aDoc
2820 void GeomSources::gpTest37(CGeometryDoc* aDoc)
2822 DisplayType TheDisplayType = No2D3D;
2823 PreProcess(aDoc,TheDisplayType);
2824 //==============================================================
2826 TColgp_Array1OfPnt anArrayofPnt (1,5); // sizing array
2827 anArrayofPnt.SetValue(1,gp_Pnt(0,0,1));
2828 anArrayofPnt.SetValue(2,gp_Pnt(1,2,2));
2829 anArrayofPnt.SetValue(3,gp_Pnt(2,3,3));
2830 anArrayofPnt.SetValue(4,gp_Pnt(4,3,4));
2831 anArrayofPnt.SetValue(5,gp_Pnt(5,5,5));
2833 Standard_Real Tolerance = 1;
2836 GProp_PEquation PE (anArrayofPnt,Tolerance);
2837 if (PE.IsPlanar()) { P = PE.Plane();}
2839 if (PE.IsPoint()) { /* ... */ }
2840 if (PE.IsLinear()) { /* ... */ }
2841 if (PE.IsPlanar()) { P = PE.Plane();}
2842 if (PE.IsSpace()) { /* ... */ }
2844 //==============================================================
2845 TCollection_AsciiString Message (" \
2847 TColgp_Array1OfPnt anArrayofPnt (1,5); // sizing array \n\
2848 anArrayofPnt.SetValue(1,gp_Pnt(0,0,1)); \n\
2849 anArrayofPnt.SetValue(2,gp_Pnt(1,2,2)); \n\
2850 anArrayofPnt.SetValue(3,gp_Pnt(2,3,3)); \n\
2851 anArrayofPnt.SetValue(4,gp_Pnt(4,3,4)); \n\
2852 anArrayofPnt.SetValue(5,gp_Pnt(5,5,5)); \n\
2854 Standard_Real Tolerance = 1; \n\
2857 GProp_PEquation PE (anArrayofPnt,Tolerance); \n\
2858 if (PE.IsPlanar()) { P = PE.Plane();} \n\
2860 if (PE.IsPoint()) { /* ... */ } \n\
2861 if (PE.IsLinear()) { /* ... */ } \n\
2862 if (PE.IsPlanar()) { P = PE.Plane();} \n\
2863 if (PE.IsSpace()) { /* ... */ } \n\
2865 AddSeparator(aDoc,Message);
2866 //--------------------------------------------------------------
2868 TCollection_AsciiString aString;
2869 for(Standard_Integer i = anArrayofPnt.Lower();i<=anArrayofPnt.Upper();i++){
2870 TCollection_AsciiString Message2(i);
2871 gp_Pnt P = anArrayofPnt(i);
2872 aString = "P";aString += Message2;
2873 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
2876 Message += " PE.IsPoint() = "; if (PE.IsPoint()) Message += "True \n"; else Message += "False\n";
2877 Message += " PE.IsLinear() = "; if (PE.IsLinear()) Message += "True \n"; else Message += "False\n";
2879 if (PE.IsPlanar()) {
2880 Message += " PE.IsPlanar() = True \n";
2882 Handle(Geom_Plane) aPlane = new Geom_Plane(P);
2883 Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-4.,4.,-4.,4.);
2885 DisplaySurface(aDoc,aSurface);
2889 Message += " PE.IsPlanar() = False \n";
2891 Message += " PE.IsSpace() = "; if (PE.IsSpace() ) Message += "True \n"; else Message += "False\n";
2893 PostProcess(aDoc,ID_BUTTON_Test_37,TheDisplayType,Message.ToCString());
2896 void GeomSources::gpTest38(CGeometryDoc* aDoc)
2898 DisplayType TheDisplayType = No2D3D;
2899 PreProcess(aDoc,TheDisplayType);
2900 //==============================================================
2902 TColgp_Array1OfPnt array1 (1,5); // sizing array
2903 array1.SetValue(1,gp_Pnt (-4,0,2 )); array1.SetValue(2,gp_Pnt (-7,2,2 ));
2904 array1.SetValue(3,gp_Pnt (-6,3,1 )); array1.SetValue(4,gp_Pnt (-4,3,-1));
2905 array1.SetValue(5,gp_Pnt (-3,5,-2));
2906 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();
2908 TColgp_Array1OfPnt array2 (1,5); // sizing array
2909 array2.SetValue(1,gp_Pnt (-4,0, 2)); array2.SetValue(2,gp_Pnt (-2,2,0 ));
2910 array2.SetValue(3,gp_Pnt (2 ,3,-1)); array2.SetValue(4,gp_Pnt (3 ,7,-2));
2911 array2.SetValue(5,gp_Pnt (4 ,9,-1));
2912 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();
2914 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
2915 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
2916 Handle(Geom_BSplineSurface) aBSplineSurface1 = aGeomFill1.Surface();
2918 Type = GeomFill_CoonsStyle;
2919 GeomFill_BSplineCurves aGeomFill2(
2920 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(10,0,0))),
2921 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(10,0,0))),Type);
2922 Handle(Geom_BSplineSurface) aBSplineSurface2 = aGeomFill2.Surface();
2923 Type = GeomFill_CurvedStyle;
2924 GeomFill_BSplineCurves aGeomFill3(
2925 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(20,0,0))),
2926 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(20,0,0))),Type);
2927 Handle(Geom_BSplineSurface) aBSplineSurface3 = aGeomFill3.Surface();
2929 //==============================================================
2930 TCollection_AsciiString Message (" \
2932 TColgp_Array1OfPnt array1 (1,5); // sizing array \n\
2933 array1.SetValue(1,gp_Pnt (-4,0,2 )); array1.SetValue(2,gp_Pnt (-7,2,2 )); \n\
2934 array1.SetValue(3,gp_Pnt (-6,3,1 )); array1.SetValue(4,gp_Pnt (-4,3,-1)); \n\
2935 array1.SetValue(5,gp_Pnt (-3,5,-2)); \n\
2936 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve(); \n\
2938 TColgp_Array1OfPnt array2 (1,5); // sizing array \n\
2939 array2.SetValue(1,gp_Pnt (-4,0, 2)); array2.SetValue(2,gp_Pnt (-2,2,0 )); \n\
2940 array2.SetValue(3,gp_Pnt (2 ,3,-1)); array2.SetValue(4,gp_Pnt (3 ,7,-2)); \n\
2941 array2.SetValue(5,gp_Pnt (4 ,9,-1)); \n\
2942 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve(); \n\
2944 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
2945 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
2946 Handle(Geom_BSplineSurface) aBSplineSurface1 = aGeomFill1.Surface(); \n\
2948 Type = GeomFill_CoonsStyle; \n\
2949 GeomFill_BSplineCurves aGeomFill2( \n");
2951 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(10,0,0))), \n\
2952 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(10,0,0))),Type); \n\
2953 Handle(Geom_BSplineSurface) aBSplineSurface2 = aGeomFill2.Surface(); \n\
2954 Type = GeomFill_CurvedStyle; \n\
2955 GeomFill_BSplineCurves aGeomFill3( \n\
2956 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(20,0,0))), \n\
2957 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(20,0,0))),Type); \n\
2958 Handle(Geom_BSplineSurface) aBSplineSurface3 = aGeomFill3.Surface(); \n\
2960 AddSeparator(aDoc,Message);
2961 //--------------------------------------------------------------
2963 // Trace des frontieres. -> FreeBoundaryAspect
2964 // Trace des isoparametriques. --> UIsoAspect()
2966 DisplaySurface(aDoc,aBSplineSurface1,Quantity_NOC_YELLOW);
2967 DisplaySurface(aDoc,aBSplineSurface2,Quantity_NOC_SALMON);
2968 DisplaySurface(aDoc,aBSplineSurface3,Quantity_NOC_HOTPINK);
2970 for (int i=0;i<=2;i++)
2972 DisplayCurve(aDoc,Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(i*10,0,0))), Quantity_NOC_RED,false);
2973 DisplayCurve(aDoc,Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(i*10,0,0))), Quantity_NOC_GREEN,false);
2976 Message += "SPL1 is Red; \n";
2977 Message += "SPL2 is Green; \n";
2978 Message += "aBSplineSurface1 is Yellow; ( GeomFill_StretchStyle )\n";
2979 Message += "aBSplineSurface2 is Salmon; ( GeomFill_CoonsStyle ) \n";
2980 Message += "aBSplineSurface3 is Hot pink; ( GeomFill_CurvedStyle ) \n";
2982 PostProcess(aDoc,ID_BUTTON_Test_38,TheDisplayType,Message.ToCString());
2984 void GeomSources::gpTest39(CGeometryDoc* aDoc)
2986 DisplayType TheDisplayType = No2D3D;
2987 PreProcess(aDoc,TheDisplayType);
2988 //==============================================================
2990 TColgp_Array1OfPnt array1 (1,5); // sizing array
2991 array1.SetValue(1,gp_Pnt (-4,0,2 ));
2992 array1.SetValue(2,gp_Pnt (-5,1,0 ));
2993 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
2994 array1.SetValue(4,gp_Pnt (-5,4,-7));
2995 array1.SetValue(5,gp_Pnt (-3,5,-12));
2997 TColgp_Array1OfPnt array2 (1,5); // sizing array
2998 array2.SetValue(1,gp_Pnt (-4,0, 2));
2999 array2.SetValue(2,gp_Pnt (-3,2,1 ));
3000 array2.SetValue(3,gp_Pnt (-1,5,0));
3001 array2.SetValue(4,gp_Pnt (2 ,7,-1));
3002 array2.SetValue(5,gp_Pnt (4 ,9,-1));
3004 TColgp_Array1OfPnt array3 (1,4); // sizing array
3005 array3.SetValue(1,gp_Pnt (-3,5, -12));
3006 array3.SetValue(2,gp_Pnt (-2,6,-7 ));
3007 array3.SetValue(3,gp_Pnt (0 ,8,-3));
3008 array3.SetValue(4,gp_Pnt (4 ,9,-1));
3010 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();
3011 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();
3012 Handle(Geom_BSplineCurve) SPL3 = GeomAPI_PointsToBSpline(array3).Curve();
3014 Handle(GeomAdaptor_HCurve) SPL1Adaptor = new GeomAdaptor_HCurve(SPL1);
3015 Handle(GeomFill_SimpleBound) B1 =
3016 new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular());
3017 Handle(GeomAdaptor_HCurve) SPL2Adaptor = new GeomAdaptor_HCurve(SPL2);
3018 Handle(GeomFill_SimpleBound) B2 =
3019 new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular());
3020 Handle(GeomAdaptor_HCurve) SPL3Adaptor = new GeomAdaptor_HCurve(SPL3);
3021 Handle(GeomFill_SimpleBound) B3 =
3022 new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular());
3023 Standard_Boolean NoCheck= Standard_False;
3025 Standard_Integer MaxDeg = 8;
3026 Standard_Integer MaxSeg = 2;
3027 GeomFill_ConstrainedFilling aConstrainedFilling(MaxDeg, MaxSeg);
3029 aConstrainedFilling.Init(B1,B2,B3,NoCheck);
3031 Handle(Geom_BSplineSurface) aBSplineSurface = aConstrainedFilling.Surface();
3033 //==============================================================
3034 TCollection_AsciiString Message (" \
3036 TColgp_Array1OfPnt array1 (1,5); // sizing array \n\
3038 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve(); \n\
3039 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve(); \n\
3040 Handle(Geom_BSplineCurve) SPL3 = GeomAPI_PointsToBSpline(array3).Curve(); \n\
3042 Handle(GeomAdaptor_HCurve) SPL1Adaptor = new GeomAdaptor_HCurve(SPL1); \n\
3043 Handle(GeomFill_SimpleBound) B1 = \n\
3044 new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular()); \n\
3045 Handle(GeomAdaptor_HCurve) SPL2Adaptor = new GeomAdaptor_HCurve(SPL2); \n\
3046 Handle(GeomFill_SimpleBound) B2 = \n\
3047 new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular()); \n\
3048 Handle(GeomAdaptor_HCurve) SPL3Adaptor = new GeomAdaptor_HCurve(SPL3); \n\
3049 Handle(GeomFill_SimpleBound) B3 = \n\
3050 new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular()); \n\
3051 Standard_Boolean NoCheck= Standard_False; \n\
3053 Standard_Integer MaxDeg = 8; \n");
3055 Standard_Integer MaxSeg = 2; \n\
3056 GeomFill_ConstrainedFilling aConstrainedFilling(MaxDeg, MaxSeg); \n\
3058 aConstrainedFilling.Init(B1,B2,B3,NoCheck); \n\
3060 Handle(Geom_BSplineSurface) aBSplineSurface = aConstrainedFilling.Surface(); \n\
3062 AddSeparator(aDoc,Message);
3063 //--------------------------------------------------------------
3065 TCollection_AsciiString aString;
3067 DisplaySurface(aDoc,aBSplineSurface,Quantity_NOC_YELLOW);
3068 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3069 DisplayCurve(aDoc,SPL2,Quantity_NOC_GREEN ,false);
3070 DisplayCurve(aDoc,SPL3,Quantity_NOC_BLUE1 ,false);
3072 Message += "SPL1 is Red; \n";
3073 Message += "SPL2 is Green; \n";
3074 Message += "SPL3 is Blue; \n";
3076 Message += "aBSplineSurface is Yellow; \n";
3078 PostProcess(aDoc,ID_BUTTON_Test_39,TheDisplayType,Message.ToCString());
3081 void GeomSources::gpTest40(CGeometryDoc* aDoc)
3083 DisplayType TheDisplayType = No2D3D;
3084 PreProcess(aDoc,TheDisplayType);
3085 //==============================================================
3087 TColgp_Array1OfPnt array1 (1,5); // sizing array
3088 array1.SetValue(1,gp_Pnt (-4,0,2 ));
3089 array1.SetValue(2,gp_Pnt (-5,1,0 ));
3090 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3091 array1.SetValue(4,gp_Pnt (-5,4,-7));
3092 array1.SetValue(5,gp_Pnt (-3,5,-12));
3094 Handle(Geom_BSplineCurve) SPL1 =
3095 GeomAPI_PointsToBSpline(array1).Curve();
3097 GeomFill_Pipe aPipe(SPL1,1);
3099 Handle(Geom_Surface) aSurface= aPipe.Surface();
3100 Standard_CString aSurfaceEntityTypeName="Not Computed";
3101 if (!aSurface.IsNull())
3102 aSurfaceEntityTypeName = aSurface->DynamicType()->Name();
3104 Handle(Geom_Ellipse) E = GC_MakeEllipse( gp::XOY() ,3,1).Value();
3105 GeomFill_Pipe aPipe2(SPL1,E);
3107 Handle(Geom_Surface) aSurface2= aPipe2.Surface();
3108 Standard_CString aSurfaceEntityTypeName2="Not Computed";
3109 if (!aSurface2.IsNull()) {
3110 aSurfaceEntityTypeName2 = aSurface2->DynamicType()->Name();
3111 aSurface2->Translate(gp_Vec(5,0,0)); }
3113 Handle(Geom_TrimmedCurve) TC1 =
3114 GC_MakeSegment(gp_Pnt(1,1,1),gp_Pnt(5,5,5));
3115 Handle(Geom_TrimmedCurve) TC2 =
3116 GC_MakeSegment(gp_Pnt(1,1,0),gp_Pnt(4,5,6));
3117 GeomFill_Pipe aPipe3(SPL1,TC1,TC2);
3119 Handle(Geom_Surface) aSurface3 = aPipe3.Surface();
3120 Standard_CString aSurfaceEntityTypeName3="Not Computed";
3121 if (!aSurface3.IsNull())
3123 aSurfaceEntityTypeName3 = aSurface3->DynamicType()->Name();
3124 aSurface3->Translate(gp_Vec(10,0,0));
3127 //==============================================================
3128 TCollection_AsciiString Message (" \
3131 TColgp_Array1OfPnt array1 (1,5); // sizing array \n\
3132 array1.SetValue(1,gp_Pnt (-4,0,2 )); \n\
3133 array1.SetValue(2,gp_Pnt (-5,1,0 )); \n\
3134 array1.SetValue(3,gp_Pnt (-6,2,-2 )); \n\
3135 array1.SetValue(4,gp_Pnt (-5,4,-7)); \n\
3136 array1.SetValue(5,gp_Pnt (-3,5,-12)); \n\
3138 Handle(Geom_BSplineCurve) SPL1 = \n\
3139 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3141 GeomFill_Pipe aPipe(SPL1,1); \n\
3142 aPipe.Perform(); \n\
3143 Handle(Geom_Surface) aSurface= aPipe.Surface(); \n\
3144 Standard_CString aSurfaceEntityTypeName=\"Not Computed\"; \n\
3145 if (!aSurface.IsNull()) \n\
3146 aSurfaceEntityTypeName = aSurface->DynamicType()->Name(); \n\
3148 Handle(Geom_Ellipse) E = GC_MakeEllipse( gp::XOY() ,3,1).Value(); \n\
3149 GeomFill_Pipe aPipe2(SPL1,E); \n\
3150 aPipe2.Perform(); \n");
3152 Handle(Geom_Surface) aSurface2= aPipe2.Surface(); \n\
3153 Standard_CString aSurfaceEntityTypeName2=\"Not Computed\"; \n\
3154 if (!aSurface2.IsNull()) { \n\
3155 aSurfaceEntityTypeName2 = aSurface2->DynamicType()->Name(); \n\
3156 aSurface2->Translate(gp_Vec(5,0,0)); } \n\
3158 Handle(Geom_TrimmedCurve) TC1 = \n\
3159 GC_MakeSegment(gp_Pnt(1,1,1),gp_Pnt(5,5,5)); \n\
3160 Handle(Geom_TrimmedCurve) TC2 = \n\
3161 GC_MakeSegment(gp_Pnt(1,1,0),gp_Pnt(4,5,6)); \n\
3162 GeomFill_Pipe aPipe3(SPL1,TC1,TC2); \n\
3163 aPipe3.Perform(); \n\
3164 Handle(Geom_Surface) aSurface3 = aPipe3.Surface(); \n\
3165 Standard_CString aSurfaceEntityTypeName3=\"Not Computed\"; \n\
3166 if (!aSurface3.IsNull()) \n\
3168 aSurfaceEntityTypeName3 = aSurface3->DynamicType()->Name(); \n\
3169 aSurface3->Translate(gp_Vec(10,0,0)); \n\
3172 AddSeparator(aDoc,Message);
3173 //--------------------------------------------------------------
3175 if (!aSurface.IsNull())
3177 DisplaySurface(aDoc,aSurface,Quantity_NOC_YELLOW);
3179 if (!aSurface2.IsNull())
3181 DisplaySurface(aDoc,aSurface2,Quantity_NOC_YELLOW);
3183 if (!aSurface3.IsNull())
3185 DisplaySurface(aDoc,aSurface3,Quantity_NOC_YELLOW);
3188 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3190 Message += "SPL1 is Red; \n";
3193 TCollection_AsciiString Message2(aSurfaceEntityTypeName);
3194 TCollection_AsciiString Message3(aSurfaceEntityTypeName2);
3195 TCollection_AsciiString Message4(aSurfaceEntityTypeName3);
3197 Message += " aSurfaceEntityTypeName = ";Message+= Message2; Message += "\n";
3198 Message += " aSurfaceEntityTypeName2 = ";Message+= Message3; Message += "\n";
3199 Message += " aSurfaceEntityTypeName3 = ";Message+= Message4; Message += "\n";
3201 PostProcess(aDoc,ID_BUTTON_Test_40,TheDisplayType,Message.ToCString());
3204 void GeomSources::gpTest41(CGeometryDoc* aDoc)
3206 DisplayType TheDisplayType = No2D3D;
3207 PreProcess(aDoc,TheDisplayType);
3208 //==============================================================
3210 TColgp_Array1OfPnt array1 (1,5);
3211 array1.SetValue(1,gp_Pnt (-4,0,2 ));
3212 array1.SetValue(2,gp_Pnt (-5,1,0 ));
3213 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3214 array1.SetValue(4,gp_Pnt (-5,4,-7));
3215 array1.SetValue(5,gp_Pnt (-3,5,-12));
3217 Handle(Geom_BSplineCurve) SPL1 =
3218 GeomAPI_PointsToBSpline(array1).Curve();
3219 Handle(Geom_Curve) FirstSect =
3220 GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value();
3222 GeomFill_Pipe aPipe(SPL1,FirstSect);
3225 Handle(Geom_BSplineSurface) aPipeSurface =
3226 Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface());
3227 Handle(Geom_BSplineSurface) anotherBSplineSurface =
3228 GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6);
3230 //==============================================================
3231 TCollection_AsciiString Message (" \
3233 TColgp_Array1OfPnt array1 (1,5); \n\
3234 array1.SetValue(1,gp_Pnt (-4,0,2 )); \n\
3235 array1.SetValue(2,gp_Pnt (-5,1,0 )); \n\
3236 array1.SetValue(3,gp_Pnt (-6,2,-2 )); \n\
3237 array1.SetValue(4,gp_Pnt (-5,4,-7)); \n\
3238 array1.SetValue(5,gp_Pnt (-3,5,-12)); \n\
3240 Handle(Geom_BSplineCurve) SPL1 = \n\
3241 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3242 Handle(Geom_Curve) FirstSect = \n\
3243 GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value(); \n\
3245 GeomFill_Pipe aPipe(SPL1,FirstSect); \n\
3246 aPipe.Perform(); \n\
3248 Handle(Geom_BSplineSurface) aPipeSurface = \n\
3249 Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface()); \n\
3250 Handle(Geom_BSplineSurface) anotherBSplineSurface = \n\
3251 GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6); \n\
3253 AddSeparator(aDoc,Message);
3254 //--------------------------------------------------------------
3256 if(!aPipeSurface.IsNull())
3258 DisplaySurface(aDoc,aPipeSurface,Quantity_NOC_YELLOW);
3261 if(!anotherBSplineSurface.IsNull())
3263 DisplaySurface(aDoc,anotherBSplineSurface,Quantity_NOC_HOTPINK);
3266 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3267 DisplayCurve(aDoc,FirstSect,Quantity_NOC_GREEN ,false);
3269 Message += "SPL1 is Red; \n";
3270 Message += "SPL2 is Green; \n";
3271 Message += "SPL3 is Blue; \n";
3272 Message += "aBSplineSurface is Yellow; \n";
3273 Message += "anotherBSplineSurface is Hot Pink; \n";
3275 PostProcess(aDoc,ID_BUTTON_Test_41,TheDisplayType,Message.ToCString());
3279 void GeomSources::gpTest42(CGeometryDoc* aDoc)
3281 DisplayType TheDisplayType = No2D3D;
3282 PreProcess(aDoc,TheDisplayType);
3284 //==============================================================
3286 TColgp_Array2OfPnt array1(1,3,1,3);
3287 TColgp_Array2OfPnt array2(1,3,1,3);
3288 TColgp_Array2OfPnt array3(1,3,1,3);
3289 TColgp_Array2OfPnt array4(1,3,1,3);
3291 array1.SetValue(1,1,gp_Pnt(1,1,1));
3292 array1.SetValue(1,2,gp_Pnt(2,1,2));
3293 array1.SetValue(1,3,gp_Pnt(3,1,1));
3294 array1.SetValue(2,1,gp_Pnt(1,2,1));
3295 array1.SetValue(2,2,gp_Pnt(2,2,2));
3296 array1.SetValue(2,3,gp_Pnt(3,2,0));
3297 array1.SetValue(3,1,gp_Pnt(1,3,2));
3298 array1.SetValue(3,2,gp_Pnt(2,3,1));
3299 array1.SetValue(3,3,gp_Pnt(3,3,0));
3301 array2.SetValue(1,1,gp_Pnt(3,1,1));
3302 array2.SetValue(1,2,gp_Pnt(4,1,1));
3303 array2.SetValue(1,3,gp_Pnt(5,1,2));
3304 array2.SetValue(2,1,gp_Pnt(3,2,0));
3305 array2.SetValue(2,2,gp_Pnt(4,2,1));
3306 array2.SetValue(2,3,gp_Pnt(5,2,2));
3307 array2.SetValue(3,1,gp_Pnt(3,3,0));
3308 array2.SetValue(3,2,gp_Pnt(4,3,0));
3309 array2.SetValue(3,3,gp_Pnt(5,3,1));
3311 array3.SetValue(1,1,gp_Pnt(1,3,2));
3312 array3.SetValue(1,2,gp_Pnt(2,3,1));
3313 array3.SetValue(1,3,gp_Pnt(3,3,0));
3314 array3.SetValue(2,1,gp_Pnt(1,4,1));
3315 array3.SetValue(2,2,gp_Pnt(2,4,0));
3316 array3.SetValue(2,3,gp_Pnt(3,4,1));
3317 array3.SetValue(3,1,gp_Pnt(1,5,1));
3318 array3.SetValue(3,2,gp_Pnt(2,5,1));
3319 array3.SetValue(3,3,gp_Pnt(3,5,2));
3321 array4.SetValue(1,1,gp_Pnt(3,3,0));
3322 array4.SetValue(1,2,gp_Pnt(4,3,0));
3323 array4.SetValue(1,3,gp_Pnt(5,3,1));
3324 array4.SetValue(2,1,gp_Pnt(3,4,1));
3325 array4.SetValue(2,2,gp_Pnt(4,4,1));
3326 array4.SetValue(2,3,gp_Pnt(5,4,1));
3327 array4.SetValue(3,1,gp_Pnt(3,5,2));
3328 array4.SetValue(3,2,gp_Pnt(4,5,2));
3329 array4.SetValue(3,3,gp_Pnt(5,5,1));
3331 Handle(Geom_BezierSurface) BZ1 =
3332 new Geom_BezierSurface(array1);
3333 Handle(Geom_BezierSurface) BZ2 =
3334 new Geom_BezierSurface(array2);
3335 Handle(Geom_BezierSurface) BZ3 =
3336 new Geom_BezierSurface(array3);
3337 Handle(Geom_BezierSurface) BZ4 =
3338 new Geom_BezierSurface(array4);
3340 TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2);
3341 bezierarray.SetValue(1,1,BZ1);
3342 bezierarray.SetValue(1,2,BZ2);
3343 bezierarray.SetValue(2,1,BZ3);
3344 bezierarray.SetValue(2,2,BZ4);
3346 GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray);
3347 Handle(Geom_BSplineSurface) BSPLSURF ;
3350 BSPLSURF = new Geom_BSplineSurface(
3351 BB.Poles()->Array2(),
3352 BB.UKnots()->Array1(),
3353 BB.VKnots()->Array1(),
3354 BB.UMultiplicities()->Array1(),
3355 BB.VMultiplicities()->Array1(),
3358 BSPLSURF->Translate(gp_Vec(0,0,2));
3361 //==============================================================
3363 TCollection_AsciiString Message (" \
3365 TColgp_Array2OfPnt array1(1,3,1,3); \n\
3366 TColgp_Array2OfPnt array2(1,3,1,3); \n\
3367 TColgp_Array2OfPnt array3(1,3,1,3); \n\
3368 TColgp_Array2OfPnt array4(1,3,1,3); \n\
3370 // array1.SetValue( ... \n\
3372 Handle(Geom_BezierSurface) BZ1 = \n\
3373 new Geom_BezierSurface(array1); \n\
3374 Handle(Geom_BezierSurface) BZ2 = \n\
3375 new Geom_BezierSurface(array2); \n\
3376 Handle(Geom_BezierSurface) BZ3 = \n\
3377 new Geom_BezierSurface(array3); \n\
3378 Handle(Geom_BezierSurface) BZ4 = \n\
3379 new Geom_BezierSurface(array4); \n\
3381 TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2); \n\
3382 bezierarray.SetValue(1,1,BZ1); \n\
3383 bezierarray.SetValue(1,2,BZ2); \n\
3384 bezierarray.SetValue(2,1,BZ3); \n\
3385 bezierarray.SetValue(2,2,BZ4); \n\
3387 GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray); \n\
3388 Handle(Geom_BSplineSurface) BSPLSURF ; \n\
3389 if (BB.IsDone()){ \n\
3390 BSPLSURF = new Geom_BSplineSurface( \n\
3391 BB.Poles()->Array2(), \n\
3392 BB.UKnots()->Array1(), \n");
3394 BB.VKnots()->Array1(), \n\
3395 BB.UMultiplicities()->Array1(), \n\
3396 BB.VMultiplicities()->Array1(), \n\
3399 BSPLSURF->Translate(gp_Vec(0,0,2)); \n\
3402 AddSeparator(aDoc,Message);
3403 //--------------------------------------------------------------
3405 DisplaySurface(aDoc,BZ1,Quantity_NOC_RED);
3406 DisplaySurface(aDoc,BZ2,Quantity_NOC_GREEN);
3407 DisplaySurface(aDoc,BZ3,Quantity_NOC_BLUE1);
3408 DisplaySurface(aDoc,BZ4,Quantity_NOC_BROWN);
3411 DisplaySurface(aDoc,BSPLSURF,Quantity_NOC_HOTPINK);
3414 Message += "BZ1 is Red; \n";
3415 Message += "BZ2 is Green; \n";
3416 Message += "BZ3 is Blue; \n";
3417 Message += "BZ4 is Brown; \n";
3418 Message += "BSPLSURF is Hot Pink; \n";
3420 PostProcess(aDoc,ID_BUTTON_Test_42,TheDisplayType,Message.ToCString());
3423 void GeomSources::gpTest43(CGeometryDoc* aDoc)
3425 DisplayType TheDisplayType = No2D3D;
3426 PreProcess(aDoc,TheDisplayType);
3427 //==============================================================
3429 TColgp_Array1OfPnt array1 (1,5);
3430 array1.SetValue(1,gp_Pnt (-4,5,5 ));
3431 array1.SetValue(2,gp_Pnt (-3,6,6 ));
3432 array1.SetValue(3,gp_Pnt (-1,7,7 ));
3433 array1.SetValue(4,gp_Pnt (0,8,8));
3434 array1.SetValue(5,gp_Pnt (2,9,9));
3435 Handle(Geom_BSplineCurve) SPL1 =
3436 GeomAPI_PointsToBSpline(array1).Curve();
3438 TColgp_Array1OfPnt array2 (1,5);
3439 array2.SetValue(1,gp_Pnt (-4,5,2 ));
3440 array2.SetValue(2,gp_Pnt (-3,6,3 ));
3441 array2.SetValue(3,gp_Pnt (-1,7,4 ));
3442 array2.SetValue(4,gp_Pnt (0,8,5));
3443 array2.SetValue(5,gp_Pnt (2,9,6));
3444 Handle(Geom_BSplineCurve) SPL2 =
3445 GeomAPI_PointsToBSpline(array2).Curve();
3447 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3448 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3449 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3450 Standard_Real offset = 1;
3451 Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset);
3453 Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset);
3455 Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset);
3457 //==============================================================
3458 TCollection_AsciiString Message (" \
3460 TColgp_Array1OfPnt array1 (1,5); \n\
3461 //array1.SetValue( ... \n\
3462 Handle(Geom_BSplineCurve) SPL1 = \n\
3463 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3465 TColgp_Array1OfPnt array2 (1,5); \n\
3466 // array2.SetValue( ... \n\
3468 Handle(Geom_BSplineCurve) SPL2 = \n\
3469 GeomAPI_PointsToBSpline(array2).Curve(); \n\
3471 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3472 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3473 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface(); \n\
3474 Standard_Real offset = 1; \n\
3475 Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3477 Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3479 Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3481 AddSeparator(aDoc,Message);
3482 //--------------------------------------------------------------
3484 DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_BLUE1);
3485 DisplaySurface(aDoc,GOS,Quantity_NOC_GREEN);
3486 DisplaySurface(aDoc,GOS1,Quantity_NOC_GREEN);
3487 DisplaySurface(aDoc,GOS2,Quantity_NOC_GREEN);
3489 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3490 DisplayCurve(aDoc,SPL2,Quantity_NOC_HOTPINK ,false);
3492 Message += "aGeomSurface is Blue; \n";
3493 Message += "GOS are Green; \n";
3495 PostProcess(aDoc,ID_BUTTON_Test_43,TheDisplayType,Message.ToCString());
3498 void GeomSources::gpTest44(CGeometryDoc* aDoc)
3500 DisplayType TheDisplayType = No2D3D;
3501 PreProcess(aDoc,TheDisplayType);
3502 //==============================================================
3509 TColgp_Array1OfPnt array (1,5);
3510 array.SetValue(1,P1);
3511 array.SetValue(2,P2);
3512 array.SetValue(3,P3);
3513 array.SetValue(4,P4);
3514 array.SetValue(5,P5);
3515 Handle(Geom_BSplineCurve) aCurve =
3516 GeomAPI_PointsToBSpline(array).Curve();
3518 Handle(Geom_SurfaceOfLinearExtrusion) SOLE =
3519 new Geom_SurfaceOfLinearExtrusion(aCurve,aDir);
3521 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface =
3522 new Geom_RectangularTrimmedSurface(SOLE,-10,10,false);
3524 Standard_CString SOLEEntityTypeName="Not Computed";
3527 SOLEEntityTypeName = SOLE->DynamicType()->Name();
3530 //==============================================================
3532 TCollection_AsciiString Message (" \
3534 gp_Pnt P1(0,0,1); \n\
3535 gp_Pnt P2(1,2,2); \n\
3536 gp_Pnt P3(2,3,3); \n\
3537 gp_Pnt P4(4,3,4); \n\
3538 gp_Pnt P5(5,5,5); \n\
3539 TColgp_Array1OfPnt array (1,5); \n\
3540 array.SetValue(1,P1); \n\
3541 array.SetValue(2,P2); \n\
3542 array.SetValue(3,P3); \n\
3543 array.SetValue(4,P4); \n\
3544 array.SetValue(5,P5); \n\
3545 Handle(Geom_BSplineCurve) aCurve = \n\
3546 GeomAPI_PointsToBSpline(array).Curve(); \n\
3547 gp_Dir aDir(1,2,3); \n\
3548 Handle(Geom_SurfaceOfLinearExtrusion) SOLE = \n\
3549 new Geom_SurfaceOfLinearExtrusion(aCurve,aDir); \n\
3551 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface = \n\
3552 new Geom_RectangularTrimmedSurface(SOLE,-10,10,false); \n\
3554 Standard_CString SOLEEntityTypeName=\"Not Computed\"; \n\
3555 if (!SOLE.IsNull()) \n\
3557 SOLEEntityTypeName = SOLE->DynamicType()->Name(); \n\
3560 AddSeparator(aDoc,Message);
3561 //--------------------------------------------------------------
3563 DisplaySurface(aDoc,aTrimmedSurface,Quantity_NOC_GREEN);
3564 DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
3566 Message += "aCurve is Red; \n";
3567 Message += "aTrimmedSurface is Green; \n";
3569 TCollection_AsciiString Message2 (SOLEEntityTypeName);
3571 Message += " SOLEEntityTypeName = ";Message+= Message2; Message += "\n";
3573 PostProcess(aDoc,ID_BUTTON_Test_44,TheDisplayType,Message.ToCString());
3576 void GeomSources::gpTest45(CGeometryDoc* aDoc)
3578 DisplayType TheDisplayType = No2D3D;
3579 PreProcess(aDoc,TheDisplayType);
3581 //==============================================================
3583 TColgp_Array1OfPnt array (1,5);
3584 array.SetValue(1,gp_Pnt (0,0,1));
3585 array.SetValue(2,gp_Pnt (1,2,2));
3586 array.SetValue(3,gp_Pnt (2,3,3));
3587 array.SetValue(4,gp_Pnt (4,3,4));
3588 array.SetValue(5,gp_Pnt (5,5,5));
3589 Handle(Geom_BSplineCurve) aCurve =
3590 GeomAPI_PointsToBSpline(array).Curve();
3591 Handle(Geom_SurfaceOfRevolution) SOR =
3592 new Geom_SurfaceOfRevolution(aCurve,gp::OX());
3594 Standard_CString SOREntityTypeName="Not Computed";
3596 SOREntityTypeName = SOR->DynamicType()->Name();
3598 //==============================================================
3599 TCollection_AsciiString Message (" \
3601 TColgp_Array1OfPnt array (1,5); \n\
3602 array.SetValue(1,gp_Pnt 0,0,1)); \n\
3603 array.SetValue(2,gp_Pnt (1,2,2)); \n\
3604 array.SetValue(3,gp_Pnt (2,3,3)); \n\
3605 array.SetValue(4,gp_Pnt (4,3,4)); \n\
3606 array.SetValue(5,gp_Pnt (5,5,5)); \n\
3607 Handle(Geom_BSplineCurve) aCurve = \n\
3608 GeomAPI_PointsToBSpline(array).Curve(); \n\
3609 Handle(Geom_SurfaceOfRevolution) SOR = \n\
3610 new Geom_SurfaceOfRevolution(aCurve,gp::OX()); \n\
3612 Standard_CString SOREntityTypeName=\"Not Computed\"; \n\
3613 if (!SOR.IsNull()) \n\
3614 SOREntityTypeName = SOR->DynamicType()->Name(); \n\
3616 AddSeparator(aDoc,Message);
3618 //--------------------------------------------------------------
3619 DisplaySurface(aDoc,SOR,Quantity_NOC_GREEN);
3620 DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
3622 Message += "aCurve is Red; \n";
3623 Message += "SOR is Green; \n";
3624 TCollection_AsciiString Message2 (SOREntityTypeName);
3625 Message += " SOREntityTypeName = ";Message+= Message2; Message += "\n";
3627 PostProcess(aDoc,ID_BUTTON_Test_45,TheDisplayType,Message.ToCString());
3630 void GeomSources::gpTest46(CGeometryDoc* aDoc)
3632 DisplayType TheDisplayType = No2D3D;
3633 PreProcess(aDoc,TheDisplayType);
3634 //==============================================================
3636 TColgp_Array1OfPnt array1 (1,5);
3637 array1.SetValue(1,gp_Pnt (-4,5,5 ));
3638 array1.SetValue(2,gp_Pnt (-3,6,6 ));
3639 array1.SetValue(3,gp_Pnt (-1,6,7 ));
3640 array1.SetValue(4,gp_Pnt (0,8,8));
3641 array1.SetValue(5,gp_Pnt (2,9,9));
3642 Handle(Geom_BSplineCurve) SPL1 =
3643 GeomAPI_PointsToBSpline(array1).Curve();
3645 TColgp_Array1OfPnt array2 (1,5);
3646 array2.SetValue(1,gp_Pnt (-4,5,2 ));
3647 array2.SetValue(2,gp_Pnt (-3,6,3 ));
3648 array2.SetValue(3,gp_Pnt (-1,7,4 ));
3649 array2.SetValue(4,gp_Pnt (0,8,5));
3650 array2.SetValue(5,gp_Pnt (2,9,6));
3651 Handle(Geom_BSplineCurve) SPL2 =
3652 GeomAPI_PointsToBSpline(array2).Curve();
3654 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3655 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3656 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3658 Handle(Geom_BSplineSurface) aTranslatedGeomSurface =
3659 Handle(Geom_BSplineSurface)::DownCast(aGeomSurface->Copy());
3661 Standard_Real extension = 3;
3662 Standard_Integer continuity = 2;
3663 Standard_Boolean Udirection = Standard_True;
3664 Standard_Boolean after = Standard_True;
3665 GeomLib::ExtendSurfByLength (aTranslatedGeomSurface,
3666 extension,continuity,Udirection,after);
3668 //==============================================================
3669 TCollection_AsciiString Message (" \
3671 TColgp_Array1OfPnt array1 (1,5); \n\
3673 Handle(Geom_BSplineCurve) SPL1 = \n\
3674 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3676 TColgp_Array1OfPnt array2 (1,5); \n\
3678 Handle(Geom_BSplineCurve) SPL2 = \n\
3679 GeomAPI_PointsToBSpline(array2).Curve(); \n\
3681 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3682 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3683 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface(); \n\
3685 Handle(Geom_BSplineSurface) aTranslatedGeomSurface = \n\
3686 Handle(Geom_BSplineSurface)::DownCast(aGeomSurface->Copy()); \n\
3688 Standard_Real extension = 3; \n\
3689 Standard_Integer continuity = 2; \n\
3690 Standard_Boolean Udirection = Standard_True; \n\
3691 Standard_Boolean after = Standard_True; \n\
3692 GeomLib::ExtendSurfByLength (aTranslatedGeomSurface, \n\
3693 extension,continuity,Udirection,after); \n\
3695 AddSeparator(aDoc,Message);
3696 //--------------------------------------------------------------
3698 if (!aGeomSurface.IsNull())
3700 DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_HOTPINK);
3703 if (!aTranslatedGeomSurface.IsNull())
3705 DisplaySurface(aDoc,aTranslatedGeomSurface,Quantity_NOC_BLUE1);
3708 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3709 DisplayCurve(aDoc,SPL2,Quantity_NOC_GREEN ,false);
3711 Message += "aGeomSurface is Hot Pink; \n";
3712 Message += "aTranslatedGeomSurface is Blue; \n";
3713 Message += "SPL1 is Red; \n";
3714 Message += "SPL2 is Green; \n";
3716 PostProcess(aDoc,ID_BUTTON_Test_46,TheDisplayType,Message.ToCString());
3719 void GeomSources::gpTest47(CGeometryDoc* aDoc)
3721 DisplayType TheDisplayType = No2D3D;
3722 PreProcess(aDoc,TheDisplayType);
3724 //==============================================================
3727 TColgp_Array1OfPnt array1 (1,5);
3728 array1.SetValue(1,gp_Pnt (-5,1,2));
3729 array1.SetValue(2,gp_Pnt (-5,2,2));
3730 array1.SetValue(3,gp_Pnt (-5.3,3,1));
3731 array1.SetValue(4,gp_Pnt (-5,4,1));
3732 array1.SetValue(5,gp_Pnt (-5,5,2));
3733 Handle(Geom_BSplineCurve) SPL1 =
3734 GeomAPI_PointsToBSpline(array1).Curve();
3736 TColgp_Array1OfPnt array2 (1,5);
3737 array2.SetValue(1,gp_Pnt (4,1,2));
3738 array2.SetValue(2,gp_Pnt (4,2,2));
3739 array2.SetValue(3,gp_Pnt (3.7,3,1));
3740 array2.SetValue(4,gp_Pnt (4,4,1));
3741 array2.SetValue(5,gp_Pnt (4,5,2));
3742 Handle(Geom_BSplineCurve) SPL2 =
3743 GeomAPI_PointsToBSpline(array2).Curve();
3745 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3747 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3748 Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface();
3750 TColgp_Array2OfPnt array3 (1,5,1,5);
3751 array3.SetValue(1,1,gp_Pnt (-4,-4,5));
3752 array3.SetValue(1,2,gp_Pnt (-4,-2,5));
3753 array3.SetValue(1,3,gp_Pnt (-4,0,4));
3754 array3.SetValue(1,4,gp_Pnt (-4,2,5));
3755 array3.SetValue(1,5,gp_Pnt (-4,4,5));
3757 array3.SetValue(2,1,gp_Pnt (-2,-4,4));
3758 array3.SetValue(2,2,gp_Pnt (-2,-2,4));
3759 array3.SetValue(2,3,gp_Pnt (-2,0,4));
3760 array3.SetValue(2,4,gp_Pnt (-2,2,4));
3761 array3.SetValue(2,5,gp_Pnt (-2,5,4));
3763 array3.SetValue(3,1,gp_Pnt (0,-4,3.5));
3764 array3.SetValue(3,2,gp_Pnt (0,-2,3.5));
3765 array3.SetValue(3,3,gp_Pnt (0,0,3.5));
3766 array3.SetValue(3,4,gp_Pnt (0,2,3.5));
3767 array3.SetValue(3,5,gp_Pnt (0,5,3.5));
3769 array3.SetValue(4,1,gp_Pnt (2,-4,4));
3770 array3.SetValue(4,2,gp_Pnt (2,-2,4));
3771 array3.SetValue(4,3,gp_Pnt (2,0,3.5));
3772 array3.SetValue(4,4,gp_Pnt (2,2,5));
3773 array3.SetValue(4,5,gp_Pnt (2,5,4));
3775 array3.SetValue(5,1,gp_Pnt (4,-4,5));
3776 array3.SetValue(5,2,gp_Pnt (4,-2,5));
3777 array3.SetValue(5,3,gp_Pnt (4,0,5));
3778 array3.SetValue(5,4,gp_Pnt (4,2,6));
3779 array3.SetValue(5,5,gp_Pnt (4,5,5));
3781 Handle(Geom_BSplineSurface) aSurf2 =
3782 GeomAPI_PointsToBSplineSurface(array3).Surface();
3784 GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2);
3785 Quantity_Length dist = ESS.LowerDistance();
3787 ESS.NearestPoints(P1,P2);
3790 Handle(Geom_Curve) aCurve;
3791 Standard_Integer NbExtrema = ESS.NbExtrema();
3792 for(Standard_Integer k=1;k<=NbExtrema;k++){
3793 ESS.Points(k,P3,P4);
3794 aCurve= GC_MakeSegment(P3,P4).Value();
3795 DisplayCurve(aDoc,aCurve,Quantity_NOC_YELLOW3,false);
3798 //==============================================================
3800 TCollection_AsciiString Message (" \n\
3801 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3803 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3804 Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface(); \n\
3806 Handle(Geom_BSplineSurface) aSurf2 = \n\
3807 GeomAPI_PointsToBSplineSurface(array3).Surface(); \n\
3809 GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2); \n\
3810 Quantity_Length dist = ESS.LowerDistance(); \n\
3812 ESS.NearestPoints(P1,P2); \n\
3815 AddSeparator(aDoc,Message);
3816 Message += "aSurf1 is Green; \n";
3817 Message += "aSurf2 is Hot Pink; \n";
3818 Message += "Nearest points P1 and P2 are shown; \n";
3820 //--------------------------------------------------------------
3824 DisplaySurface(aDoc,aSurf1,Quantity_NOC_GREEN);
3825 DisplaySurface(aDoc,aSurf2,Quantity_NOC_HOTPINK);
3826 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3827 DisplayCurve(aDoc,SPL2,Quantity_NOC_AZURE ,false);
3829 DisplayPoint(aDoc,P1,Standard_CString("P1"));
3830 DisplayPoint(aDoc,P2,Standard_CString("P2"));
3832 PostProcess(aDoc,ID_BUTTON_Test_47,TheDisplayType,Message.ToCString());
3835 void GeomSources::gpTest48(CGeometryDoc* aDoc)
3837 DisplayType TheDisplayType = a2DNo3D;
3838 PreProcess(aDoc,TheDisplayType);
3839 //==============================================================
3841 Standard_Real radius = 3;
3842 Handle(Geom2d_Circle) circle =
3843 new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius);
3845 Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5);
3847 Geom2dAdaptor_Curve GAC (C);
3850 TColgp_Array1OfPnt2d array (1,5); // sizing array
3851 array.SetValue(1,gp_Pnt2d (0,0));
3852 array.SetValue(2,gp_Pnt2d (1,2));
3853 array.SetValue(3,gp_Pnt2d (2,3));
3854 array.SetValue(4,gp_Pnt2d (4,3));
3855 array.SetValue(5,gp_Pnt2d (5,5));
3856 Handle(Geom2d_BSplineCurve) SPL1 =
3857 Geom2dAPI_PointsToBSpline(array);
3860 Handle(TColgp_HArray1OfPnt2d) harray =
3861 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
3862 harray->SetValue(1,gp_Pnt2d (13+ 0,0));
3863 harray->SetValue(2,gp_Pnt2d (13+ 1,2));
3864 harray->SetValue(3,gp_Pnt2d (13+ 2,3));
3865 harray->SetValue(4,gp_Pnt2d (13+ 4,3));
3866 harray->SetValue(5,gp_Pnt2d (13+ 5,5));
3867 Geom2dAPI_Interpolate anInterpolation(harray,Standard_True,0.01);
3868 anInterpolation.Perform();
3869 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();
3872 Geom2dAdaptor_Curve GACC (C);
3873 BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox);
3875 Standard_Real aCXmin, aCYmin, aCXmax, aCYmax;
3876 aCBox.Get( aCXmin, aCYmin, aCXmax,aCYmax);
3879 Geom2dAdaptor_Curve GAC1 (SPL1);
3880 BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box);
3882 Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax;
3883 aSPL1Box.Get( aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax);
3886 Geom2dAdaptor_Curve GAC2 (SPL2);
3887 BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box);
3889 Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax;
3890 aSPL2Box.Get( aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax);
3892 //==============================================================
3893 TCollection_AsciiString Message (" \
3895 Standard_Real radius = 3; \n\
3896 Handle(Geom2d_Circle) circle = \n\
3897 new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius); \n\
3899 Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5); \n\
3900 Geom2dAdaptor_Curve GAC (C); \n\
3902 Handle(Geom2d_BSplineCurve) SPL1 ; // SPL1 = ... \n\
3904 Handle(Geom2d_BSplineCurve) SPL2 ; // SPL2 = ... \n\
3906 Bnd_Box2d aCBox; \n\
3907 Geom2dAdaptor_Curve GACC (C); \n\
3908 BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox); \n\
3910 Standard_Real aCXmin, aCYmin, aCXmax, aCYmax; \n\
3911 aCBox.Get( aCXmin, aCYmin, aCXmax,aCYmax); \n\
3913 Bnd_Box2d aSPL1Box; \n\
3914 Geom2dAdaptor_Curve GAC1 (SPL1); \n\
3915 BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box); \n\
3917 Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax; \n\
3918 aSPL1Box.Get( aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax); \n");
3921 Bnd_Box2d aSPL2Box; \n\
3922 Geom2dAdaptor_Curve GAC2 (SPL2); \n\
3923 BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box); \n\
3925 Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax; \n\
3926 aSPL2Box.Get( aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax); \n\
3928 AddSeparator(aDoc,Message);
3929 //--------------------------------------------------------------
3931 DisplayCurve(aDoc,C ,5);
3932 DisplayCurve(aDoc,SPL1,6 );
3933 DisplayCurve(aDoc,SPL2,7 );
3935 DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmax),Standard_CString("aCXmin,aCYmax"));
3936 DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmax),Standard_CString("aCXmax,aCYmax"));
3937 DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmin),Standard_CString("aCXmin,aCYmin"));
3938 DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmin),Standard_CString("aCXmax,aCYmin"));
3940 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmax),gp_Pnt2d(aCXmax,aCYmax)) ,4); // X,Ymax
3941 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmax,aCYmin)) ,4); // X,Ymin
3942 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmin,aCYmax)) ,4); // Xmin,Y
3943 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmax,aCYmin),gp_Pnt2d(aCXmax,aCYmax)) ,4); // Xmax,Y
3945 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),Standard_CString("aSPL1Xmin,aSPL1Ymax"));
3946 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymax),Standard_CString("aSPL1Xmax,aSPL1Ymax"));
3947 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),Standard_CString("aSPL1Xmin,aSPL1Ymin"));
3948 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),Standard_CString("aSPL1Xmax,aSPL1Ymin"));
3950 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)) ,4); // X,Ymax
3951 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymin)) ,4); // X,Ymin
3952 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmin,aSPL1Ymax)) ,4); // Xmin,Y
3953 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)) ,4); // Xmax,Y
3955 DisplayPoint(aDoc,gp_Pnt2d(aSPL2Xmin,aSPL2Ymax),Standard_CString("aSPL2Xmin,aSPL2Ymax"));
3956 DisplayPoint(aDoc,gp_Pnt2d(aSPL2Xmax,aSPL2Ymax),Standard_CString("aSPL2Xmax,aSPL2Ymax"));
3957 DisplayPoint(aDoc,gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),Standard_CString("aSPL2Xmin,aSPL2Ymin"));
3958 DisplayPoint(aDoc,gp_Pnt2d(aSPL2Xmax,aSPL2Ymin),Standard_CString("aSPL2Xmax,aSPL2Ymin"));
3960 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymax),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)) ,4); // X,Ymax
3961 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymin)) ,4); // X,Ymin
3962 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmin,aSPL2Ymax)) ,4); // Xmin,Y
3963 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmax,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)) ,4); // Xmax,Y
3965 PostProcess(aDoc,ID_BUTTON_Test_48,TheDisplayType,Message.ToCString());
3969 void GeomSources::gpTest49(CGeometryDoc* aDoc)
3971 DisplayType TheDisplayType = No2D3D;
3972 PreProcess(aDoc,TheDisplayType);
3974 //==============================================================
3977 Standard_Real radius = 100;
3978 gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5));
3980 Handle(Geom_Circle) C =
3981 new Geom_Circle(anAxis,radius);
3982 GeomAdaptor_Curve GAC (C);
3983 BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox);
3985 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
3986 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
3988 //==============================================================
3990 TCollection_AsciiString Message (" \
3993 Standard_Real radius = 100; \n\
3994 gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5)); \n\
3996 Handle(Geom_Circle) C = \n\
3997 new Geom_Circle(anAxis,radius); \n\
3998 GeomAdaptor_Curve GAC (C); \n\
3999 BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox); \n\
4001 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ; \n\
4002 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax); \n\
4004 AddSeparator(aDoc,Message);
4005 //--------------------------------------------------------------
4007 DisplayCurve(aDoc,C,Quantity_NOC_BLUE1 ,false);
4009 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmin),Standard_CString("aXmin,aYmax,aZmin"));
4010 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmin),Standard_CString("aXmax,aYmax,aZmin"));
4011 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmin),Standard_CString("aXmin,aYmin,aZmin"));
4012 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmin),Standard_CString("aXmax,aYmin,aZmin"));
4014 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmax),Standard_CString("aXmin,aYmax,aZmax"));
4015 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmax),Standard_CString("aXmax,aYmax,aZmax"));
4016 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmax),Standard_CString("aXmin,aYmin,aZmax"));
4017 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmax),Standard_CString("aXmax,aYmin,aZmax"));
4019 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4020 gp_Pnt(aXmax,aYmax,aZmin)) ,Quantity_NOC_RED); // X,Ymax,ZMin
4021 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4022 gp_Pnt(aXmax,aYmin,aZmin)) ,Quantity_NOC_RED); // X,Ymin,ZMin
4023 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4024 gp_Pnt(aXmin,aYmax,aZmin)) ,Quantity_NOC_RED); // Xmin,Y,ZMin
4025 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4026 gp_Pnt(aXmax,aYmax,aZmin)) ,Quantity_NOC_RED); // Xmax,Y,ZMin
4027 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4028 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // X,Ymax,ZMax
4029 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4030 gp_Pnt(aXmax,aYmin,aZmax)) ,Quantity_NOC_RED); // X,Ymin,ZMax
4031 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4032 gp_Pnt(aXmin,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmin,Y,ZMax
4033 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4034 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmax,Y,ZMax
4035 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4036 gp_Pnt(aXmin,aYmin,aZmax)) ,Quantity_NOC_RED); // Xmin,Ymin,Z
4037 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4038 gp_Pnt(aXmax,aYmin,aZmax)) ,Quantity_NOC_RED); // Xmax,Ymin,Z
4039 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4040 gp_Pnt(aXmin,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmin,Ymax,Z
4041 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4042 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmax,Ymax,Z
4044 PostProcess(aDoc,ID_BUTTON_Test_49,TheDisplayType,Message.ToCString());
4047 void GeomSources::gpTest50(CGeometryDoc* aDoc)
4049 DisplayType TheDisplayType = No2D3D;
4050 PreProcess(aDoc,TheDisplayType);
4051 //==============================================================
4053 TColgp_Array1OfPnt array1 (1,5);
4054 array1.SetValue(1,gp_Pnt (-40,00,20 ));
4055 array1.SetValue(2,gp_Pnt (-70,20,20 ));
4056 array1.SetValue(3,gp_Pnt (-60,30,10 ));
4057 array1.SetValue(4,gp_Pnt (-40,30,-10));
4058 array1.SetValue(5,gp_Pnt (-30,50,-20));
4059 Handle(Geom_BSplineCurve) SPL1 =
4060 GeomAPI_PointsToBSpline(array1).Curve();
4062 TColgp_Array1OfPnt array2 (1,5);
4063 array2.SetValue(1,gp_Pnt (-40,0, 20));
4064 array2.SetValue(2,gp_Pnt (-20,20,0 ));
4065 array2.SetValue(3,gp_Pnt (20 ,30,-10));
4066 array2.SetValue(4,gp_Pnt (30 ,70,-20));
4067 array2.SetValue(5,gp_Pnt (40 ,90,-10));
4068 Handle(Geom_BSplineCurve) SPL2 =
4069 GeomAPI_PointsToBSpline(array2).Curve();
4071 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
4072 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
4073 Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface();
4074 GeomAdaptor_Surface GAS (aSurf);
4076 BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox);
4078 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
4079 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
4081 //==============================================================
4082 TCollection_AsciiString Message (" \
4084 TColgp_Array1OfPnt array1 (1,5); \n\
4085 array1.SetValue(1,gp_Pnt (-40, 0, 20)); \n\
4086 array1.SetValue(2,gp_Pnt (-70, 20, 20)); \n\
4087 array1.SetValue(3,gp_Pnt (-60, 30, 10)); \n\
4088 array1.SetValue(4,gp_Pnt (-40, 30,-10)); \n\
4089 array1.SetValue(5,gp_Pnt (-30, 50,-20)); \n\
4090 Handle(Geom_BSplineCurve) SPL1 = \n\
4091 GeomAPI_PointsToBSpline(array1).Curve(); \n\
4093 TColgp_Array1OfPnt array2 (1,5); \n\
4094 array2.SetValue(1,gp_Pnt (-40, 0, 20)); \n\
4095 array2.SetValue(2,gp_Pnt (-20, 20, 0)); \n\
4096 array2.SetValue(3,gp_Pnt ( 20, 30,-10)); \n\
4097 array2.SetValue(4,gp_Pnt ( 30, 70,-20)); \n\
4098 array2.SetValue(5,gp_Pnt ( 40, 90,-10)); \n\
4099 Handle(Geom_BSplineCurve) SPL2 = \n\
4100 GeomAPI_PointsToBSpline(array2).Curve(); \n\
4102 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
4103 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
4104 Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface(); \n\
4105 GeomAdaptor_Surface GAS (aSurf); \n\
4107 BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox); \n\
4109 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ; \n\
4110 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax); \n\
4112 AddSeparator(aDoc,Message);
4113 //--------------------------------------------------------------
4115 Quantity_NameOfColor aNameOfColor= Quantity_NOC_GREEN;
4116 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurf);
4117 aDoc->GetAISContext()->SetColor(aGraphicalSurface,aNameOfColor);
4118 aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
4119 aGraphicalSurface->Attributes()->UIsoAspect()->SetColor(aNameOfColor);
4120 aGraphicalSurface->Attributes()->VIsoAspect()->SetColor(aNameOfColor);
4122 aDoc->GetAISContext()->SetDisplayMode(aGraphicalSurface,1);
4123 aDoc->GetAISContext()->Display(aGraphicalSurface,false);
4124 // DisplaySurface(aDoc,aSurf,Quantity_NOC_GREEN);
4126 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4127 gp_Pnt(aXmax,aYmax,aZmin)) ,Quantity_NOC_RED); // X,Ymax,ZMin
4128 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4129 gp_Pnt(aXmax,aYmin,aZmin)) ,Quantity_NOC_RED); // X,Ymin,ZMin
4130 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4131 gp_Pnt(aXmin,aYmax,aZmin)) ,Quantity_NOC_RED); // Xmin,Y,ZMin
4132 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4133 gp_Pnt(aXmax,aYmax,aZmin)) ,Quantity_NOC_RED); // Xmax,Y,ZMin
4134 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4135 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // X,Ymax,ZMax
4136 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4137 gp_Pnt(aXmax,aYmin,aZmax)) ,Quantity_NOC_RED); // X,Ymin,ZMax
4138 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4139 gp_Pnt(aXmin,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmin,Y,ZMax
4140 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4141 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmax,Y,ZMax
4142 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4143 gp_Pnt(aXmin,aYmin,aZmax)) ,Quantity_NOC_RED); // Xmin,Ymin,Z
4144 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4145 gp_Pnt(aXmax,aYmin,aZmax)) ,Quantity_NOC_RED); // Xmax,Ymin,Z
4146 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4147 gp_Pnt(aXmin,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmin,Ymax,Z
4148 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4149 gp_Pnt(aXmax,aYmax,aZmax)) ,Quantity_NOC_RED); // Xmax,Ymax,Z
4151 PostProcess(aDoc,ID_BUTTON_Test_50,TheDisplayType,Message.ToCString());