1 // GeomSources.cpp: implementation of the GeomSources class.
3 //////////////////////////////////////////////////////////////////////
6 #include "GeomSources.h"
7 #include "GeometryApp.h"
9 #include <Geom_Curve.hxx>
10 #include <Geom2d_Curve.hxx>
11 GeomSources::GeomSources()
15 GeomSources::~GeomSources()
18 void GeomSources::PreProcess(CGeometryDoc* aDoc,DisplayType aDisplayType)
20 if (aDisplayType == No2D3D )
22 aDoc->GetAISContext()->EraseAll();
26 if (aDisplayType == a2DNo3D)
28 aDoc->GetISessionContext()->EraseAll();
32 if (aDisplayType != No2D3D && aDisplayType != a2D3D)
37 if (aDisplayType != a2DNo3D && aDisplayType != a2D3D)
42 if (aDisplayType == a2D3D)
44 aDoc->GetAISContext()->EraseAll();
45 aDoc->GetISessionContext()->EraseAll();
46 aDoc->Put3DOnTop(false);
47 aDoc->Put2DOnTop(false);
50 // send the message Title Horizontaly to the child of doc main frame
51 CGeometryApp* TheAppli = (CGeometryApp*)AfxGetApp();
52 CMainFrame* TheMainFrame= (CMainFrame*)TheAppli->m_pMainWnd;
53 ::SendMessage(TheMainFrame->m_hWndMDIClient, WM_MDITILE, 0, 0);
57 void GeomSources::PostProcess (CGeometryDoc* aDoc, UINT anID, DisplayType aDisplayType,
58 const TCollection_AsciiString& theString, Standard_Boolean UpdateViewer, Quantity_Coefficient Coef)
60 Standard_CString aString = theString.ToCString();
63 if (aDisplayType == No2D3D || aDisplayType == a2D3D)
65 aDoc->Fit3DViews(Coef);
68 if (aDisplayType == a2DNo3D || aDisplayType == a2D3D)
74 TCollection_AsciiString Message("Results are ");
78 case No2DNo3D: Message = "All results are in this box \n";
80 case No2D3D: Message += "only in 3D \n";
82 case a2DNo3D: Message += "only in 2d \n";
84 case a2D3D: Message += "in both 2D and 3D \n";
87 Message += "====================================\n";
90 CString text(Message.ToCString());
91 aDoc->myCResultDialog.SetText(text);
94 if (! s.LoadString( anID ))
95 AfxMessageBox (L"Error Loading String: ");
97 CString Title = s.Left( s.Find( '\n' ));
99 aDoc->myCResultDialog.SetTitle(Title);
100 aDoc->SetTitle(Title);
103 void GeomSources::AddSeparator(CGeometryDoc* /*aDoc*/,TCollection_AsciiString& aMessage)
105 aMessage+= "------------------------------------------------------------------------\n";
107 void GeomSources::DisplayPoint(CGeometryDoc* aDoc,
108 const gp_Pnt2d& aPoint,
110 Standard_Boolean UpdateViewer,
111 Standard_Real anXoffset,
112 Standard_Real anYoffset,
113 Standard_Real TextScale)
115 Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint);
116 aDoc->GetISessionContext()->Display(aGraphicPoint,UpdateViewer);
117 Handle(ISession_Text) aGraphicText = new ISession_Text(aText,aPoint.X()+anXoffset,aPoint.Y()+anYoffset);
118 aGraphicText->SetScale (TextScale);
119 aDoc->GetISessionContext()->Display(aGraphicText,UpdateViewer);
122 void GeomSources::DisplayPoint(CGeometryDoc* aDoc,
123 const gp_Pnt& aPoint,
125 Standard_Boolean UpdateViewer,
126 Standard_Real anXoffset,
127 Standard_Real anYoffset,
128 Standard_Real aZoffset,
129 Standard_Real TextScale)
131 Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint);
132 aDoc->GetAISContext()->Display(aGraphicPoint,UpdateViewer);
133 Handle(ISession_Text) aGraphicText = new ISession_Text(aText,aPoint.X()+anXoffset,aPoint.Y()+anYoffset,aPoint.Z()+aZoffset);
134 aGraphicText->SetScale (TextScale);
135 aDoc->GetAISContext()->Display(aGraphicText,UpdateViewer);
138 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
139 Handle(Geom2d_Curve) aCurve,
140 Standard_Integer aColorIndex,
141 Standard_Boolean UpdateViewer)
143 Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
144 aGraphicCurve->SetColorIndex(aColorIndex) ;
145 aDoc->GetISessionContext()->Display(aGraphicCurve,UpdateViewer);
148 void GeomSources::DisplayCurveAndCurvature(CGeometryDoc* aDoc,
149 Handle(Geom2d_Curve) aCurve,
150 Standard_Integer aColorIndex,
151 Standard_Boolean UpdateViewer)
153 Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
154 aGraphicCurve->SetDisplayCurbure(Standard_True) ;
155 aGraphicCurve->SetDiscretisation(20);
156 aGraphicCurve->SetColorIndex(aColorIndex) ;
157 aDoc->GetISessionContext()->Display(aGraphicCurve,UpdateViewer);
160 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
161 Handle(Geom_Curve) aCurve,
162 Quantity_NameOfColor aNameOfColor,
163 Standard_Boolean UpdateViewer)
165 Handle(ISession_Curve) aGraphicCurve = new ISession_Curve(aCurve);
166 aDoc->GetAISContext()->SetColor(aGraphicCurve,aNameOfColor, Standard_False);
167 aGraphicCurve->Attributes()->LineAspect()->SetColor(aNameOfColor);
168 aDoc->GetAISContext()->Display(aGraphicCurve,UpdateViewer);
171 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
172 Handle(Geom_Curve) aCurve,
173 Standard_Boolean UpdateViewer)
175 Handle(ISession_Curve) aGraphicCurve = new ISession_Curve(aCurve);
176 aDoc->GetAISContext()->Display(aGraphicCurve,UpdateViewer);
182 void GeomSources::DisplaySurface(CGeometryDoc* aDoc,
183 Handle(Geom_Surface) aSurface,
184 Quantity_NameOfColor aNameOfColor,
185 Standard_Boolean UpdateViewer)
187 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
188 aDoc->GetAISContext()->SetColor(aGraphicalSurface,aNameOfColor, Standard_False);
189 aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
190 aGraphicalSurface->Attributes()->UIsoAspect()->SetColor(aNameOfColor);
191 aGraphicalSurface->Attributes()->VIsoAspect()->SetColor(aNameOfColor);
192 aDoc->GetAISContext()->Display(aGraphicalSurface,UpdateViewer);
195 void GeomSources::DisplaySurface(CGeometryDoc* aDoc,
196 Handle(Geom_Surface) aSurface,
197 Standard_Boolean UpdateViewer)
199 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
200 aDoc->GetAISContext()->Display(aGraphicalSurface,UpdateViewer);
203 void GeomSources::ResetView(CGeometryDoc* aDoc)
205 aDoc->GetAISContext()->CurrentViewer()->InitActiveViews();
206 Handle(V3d_View) aView = aDoc->GetAISContext()->CurrentViewer()->ActiveView();
210 // Function name : GeomSources::gpTest1
212 // Return type : void
213 // Argument : CGeometryDoc* aDoc
214 void GeomSources::gpTest1(CGeometryDoc* aDoc)
216 DisplayType TheDisplayType = No2D3D;
217 PreProcess(aDoc,TheDisplayType);
218 //==============================================================
223 Standard_Real result = A.DotCross(B,C);
225 //==============================================================
226 TCollection_AsciiString Message ("\
231 Standard_Real result = A.DotCross(B,C); \n\
233 AddSeparator(aDoc,Message);
234 //--------------------------------------------------------------
236 DisplayPoint(aDoc,gp_Pnt(A),"A (1,2,3)",false,0.1);
237 DisplayPoint(aDoc,gp_Pnt(B),"B (2,2,2)",false,0.1);
238 DisplayPoint(aDoc,gp_Pnt(C),"C (3,2,3)",false,0.1);
240 // to add a numeric value in a TCollectionAsciiString
241 TCollection_AsciiString Message2 (result);
243 Message+= " result = ";
245 PostProcess(aDoc,ID_BUTTON_Test_1,TheDisplayType,Message);
248 // Function name : GeomSources::gpTest2
250 // Return type : void
251 // Argument : CGeometryDoc* aDoc
252 void GeomSources::gpTest2(CGeometryDoc* aDoc)
254 DisplayType TheDisplayType = No2D3D;
255 PreProcess(aDoc,TheDisplayType);
256 //==============================================================
260 //==============================================================
261 TCollection_AsciiString Message ("\
263 gp_Pnt P1(1,2,3); \n\
265 AddSeparator(aDoc,Message);
266 //--------------------------------------------------------------
267 DisplayPoint(aDoc,P1,"P1 (1,2,3)",false,30);
268 PostProcess(aDoc,ID_BUTTON_Test_2,TheDisplayType,Message,Standard_False);
273 // Function name : GeomSources::gpTest3
275 // Return type : void
276 // Argument : CGeometryDoc* aDoc
277 void GeomSources::gpTest3(CGeometryDoc* aDoc)
279 DisplayType TheDisplayType = No2D3D;
280 PreProcess(aDoc,TheDisplayType);
281 //==============================================================
286 //==============================================================
287 TCollection_AsciiString Message ("\
292 AddSeparator(aDoc,Message);
293 //--------------------------------------------------------------
294 DisplayPoint(aDoc,P2,"P2 (1,2,3)",false,30);
295 PostProcess(aDoc,ID_BUTTON_Test_3,TheDisplayType,Message,Standard_False);
300 // Function name : GeomSources::gpTest4
302 // Return type : void
303 // Argument : CGeometryDoc* aDoc
304 void GeomSources::gpTest4(CGeometryDoc* aDoc)
306 DisplayType TheDisplayType = No2D3D;
307 PreProcess(aDoc,TheDisplayType);
308 //==============================================================
310 gp_Pnt P3 = gp::Origin();
311 Standard_Real TheX = P3.X();
312 Standard_Real TheY = P3.Y();
313 Standard_Real TheZ = P3.Z();
316 //==============================================================
317 TCollection_AsciiString Message ("\
319 gp_Pnt P3 = gp::Origin(); \n\
320 Standard_Real TheX = P3.X(); \n\
321 Standard_Real TheY = P3.Y(); \n\
322 Standard_Real TheZ = P3.Z(); \n\
324 AddSeparator(aDoc,Message);
325 //--------------------------------------------------------------
326 DisplayPoint(aDoc,P3,"P3 = gp::Origin()",false,30);
328 TCollection_AsciiString Message2 (TheX);
329 TCollection_AsciiString Message3 (TheY);
330 TCollection_AsciiString Message4 (TheZ);
332 Message += " TheX = ";
334 Message += " TheY = ";
336 Message += " TheZ = ";
340 PostProcess(aDoc,ID_BUTTON_Test_4,TheDisplayType,Message,Standard_False);
345 // Function name : GeomSources::gpTest5
347 // Return type : void
348 // Argument : CGeometryDoc* aDoc
349 void GeomSources::gpTest5(CGeometryDoc* aDoc)
351 DisplayType TheDisplayType = No2D3D;
352 PreProcess(aDoc,TheDisplayType);
353 //==============================================================
358 Standard_Real alpha = 3;
359 Standard_Real beta = 7;
360 PB.BaryCenter(alpha,P2,beta);
362 //==============================================================
363 TCollection_AsciiString Message ("\
365 gp_Pnt P1(1,2,3); \n\
366 gp_Pnt P2(3,4,5); \n\
368 Standard_Real alpha = 3; \n\
369 Standard_Real beta = 7; \n\
370 PB.BaryCenter(alpha,P2,beta); \n\
373 AddSeparator(aDoc,Message);
374 //--------------------------------------------------------------
376 DisplayPoint(aDoc,P1,"P1",false,0.2);
377 DisplayPoint(aDoc,P2,"P2",false,0.2);
378 DisplayPoint(aDoc,PB,"PB = barycenter ( 3 * P1 , 7 * P2) ",false,0.2);
380 TCollection_AsciiString Message2 (PB.X());
381 TCollection_AsciiString Message3 (PB.Y());
382 TCollection_AsciiString Message4 (PB.Z());
391 PostProcess(aDoc,ID_BUTTON_Test_5,TheDisplayType,Message);
395 // Function name : GeomSources::gpTest6
397 // Return type : void
398 // Argument : CGeometryDoc* aDoc
399 void GeomSources::gpTest6(CGeometryDoc* aDoc)
401 DisplayType TheDisplayType = No2D3D;
402 PreProcess(aDoc,TheDisplayType);
403 //==============================================================
405 // Compute a 3d point P as BaryCenter of an array of point
411 TColgp_Array1OfPnt array (1,5); // sizing array
412 array.SetValue(1,P1);
413 array.SetValue(2,P2);
414 array.SetValue(3,P3);
415 array.SetValue(4,P4);
416 array.SetValue(5,P5);
418 Standard_Real Tolerance = 8; // ajout de la tolerance
419 GProp_PEquation PE (array,Tolerance);
421 gp_Pnt P; // P declaration
422 Standard_Boolean IsPoint;
434 if (PE.IsLinear()){ /*... */ }
435 if (PE.IsPlanar()){ /*... */ }
436 if (PE.IsSpace()) { /*... */ }
438 //==============================================================
439 TCollection_AsciiString Message ("\
442 // Compute a 3d point P as BaryCenter of an array of point \n\
443 gp_Pnt P1(0,0,5); \n\
444 gp_Pnt P2(1,2,3); \n\
445 gp_Pnt P3(2,3,-2); \n\
446 gp_Pnt P4(4,3,5); \n\
447 gp_Pnt P5(5,5,4); \n\
448 TColgp_Array1OfPnt array (1,5); // sizing array \n\
449 array.SetValue(1,P1); \n\
450 array.SetValue(2,P2); \n\
451 array.SetValue(3,P3); \n\
452 array.SetValue(4,P4); \n\
453 array.SetValue(5,P5); \n\
455 Standard_Real Tolerance = 8; // ajout de la tolerance \n\
456 GProp_PEquation PE (array,Tolerance); \n\
458 gp_Pnt P; // P declaration \n\
459 Standard_Boolean IsPoint; \n\
460 if (PE.IsPoint()){IsPoint = true; \n\
461 P = PE .Point();} \n\
462 else { IsPoint = false; } \n\
463 if (PE.IsLinear()){ /*... */ } \n\
464 if (PE.IsPlanar()){ /*... */ } \n\
465 if (PE.IsSpace()) { /*... */ } \n\
467 AddSeparator(aDoc,Message);
468 //--------------------------------------------------------------
470 TCollection_AsciiString PointName("P");
473 for(Standard_Integer i= array.Lower();i <= array.Upper(); i++)
475 TCollection_AsciiString TheString (i);
476 TheString = PointName+ TheString;
477 DisplayPoint(aDoc,array(i),TheString.ToCString(),false,0.5);
480 DisplayPoint(aDoc,P,"P",false,0.5);
481 TCollection_AsciiString Message2 (P.X());
482 TCollection_AsciiString Message3 (P.Y());
483 TCollection_AsciiString Message4 (P.Z());
485 Message += " IsPoint = ";
488 Message += "True --> ";
491 Message += Message2; Message += " , ";
492 Message += Message3; Message += " , ";
493 Message += Message4; Message += " ); \n";
496 Message += "False\n";
498 Message += " IsLinear = ";
500 Message += "True \n";
502 Message += "False\n";
504 Message += " IsPlanar = ";
506 Message += "True \n";
508 Message += "False\n";
510 Message += " IsSpace = ";
513 Message += "True \n";
515 Message += "False\n";
517 PostProcess(aDoc,ID_BUTTON_Test_6,TheDisplayType,Message);
520 // Function name : GeomSources::gpTest7
522 // Return type : void
523 // Argument : CGeometryDoc* aDoc
524 void GeomSources::gpTest7(CGeometryDoc* aDoc)
526 DisplayType TheDisplayType = a2DNo3D;
527 PreProcess(aDoc,TheDisplayType);
528 //==============================================================
534 Handle(Geom2d_Curve) C =
535 GCE2d_MakeArcOfCircle (P1,P2,P3).Value();
537 Standard_Real FirstParameter = C->FirstParameter();
538 Standard_Real LastParameter = C->LastParameter();
539 Standard_Real MiddleParameter = (FirstParameter+LastParameter)/2;
540 Standard_Real param = MiddleParameter; //in radians
545 // we recover point P and the vector V
547 //==============================================================
548 TCollection_AsciiString Message ("\
551 gp_Pnt2d P1(0,5); \n\
552 gp_Pnt2d P2(5.5,1); \n\
553 gp_Pnt2d P3(-2,2); \n\
555 Handle(Geom2d_TrimmedCurve) C = \n\
556 GCE2d_MakeArcOfCircle (P1,P2,P3).Value(); \n\
558 Standard_Real FirstParameter = C->FirstParameter(); \n\
559 Standard_Real LastParameter = C->LastParameter(); \n\
560 Standard_Real MiddleParameter = \n\
561 (FirstParameter+LastParameter)/2; \n\
562 Standard_Real param = MiddleParameter; //in radians \n\
566 C->D1(param,P,V); \n\
567 // we recover point P and the vector V \n\
569 AddSeparator(aDoc,Message);
570 //--------------------------------------------------------------
572 DisplayCurve(aDoc,C);
573 Handle(ISession_Direction) aDirection = new ISession_Direction(P,V);
574 aDoc->GetISessionContext()->Display(aDirection, Standard_False);
576 DisplayPoint(aDoc,P,"P",false,0.5);
578 PostProcess(aDoc,ID_BUTTON_Test_7,TheDisplayType,Message);
581 // Function name : GeomSources::gpTest8
583 // Return type : void
584 // Argument : CGeometryDoc* aDoc
585 void GeomSources::gpTest8(CGeometryDoc* aDoc)
587 DisplayType TheDisplayType = a2DNo3D;
588 PreProcess(aDoc,TheDisplayType);
589 //==============================================================
591 Standard_Real radius = 5;
592 Handle(Geom2d_Circle) C =
593 new Geom2d_Circle(gp::OX2d(),radius);
594 Standard_Real param = 1.2*M_PI;
595 Geom2dLProp_CLProps2d CLP
596 (C,param,2,Precision::PConfusion());
599 // D is the Tangent direction at parameter 1.2*PI
601 //==============================================================
602 TCollection_AsciiString Message (" \
604 Standard_Real radius = 5; \n\
605 Handle(Geom2d_Circle) C = \n\
606 new Geom2d_Circle(gp::OX2d(),radius); \n\
607 Standard_Real param = 1.2*PI; \n\
608 Geom2dLProp_CLProps2d CLP \n\
609 (C,param,2,Precision::PConfusion()); \n\
612 // D is the Tangent direction at parameter 1.2*PI \n\
614 AddSeparator(aDoc,Message);
615 //--------------------------------------------------------------
616 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
617 aDoc->GetISessionContext()->Display(aCurve,Standard_False);
618 Handle(ISession_Direction) aDirection = new ISession_Direction(gp_Pnt2d(0,0),D,2);
619 aDoc->GetISessionContext()->Display(aDirection,Standard_False);
621 TCollection_AsciiString Message2 (D.X());
622 TCollection_AsciiString Message3 (D.Y());
625 Message += Message2; Message += " , ";
626 Message += Message3; Message += " ); \n";
628 PostProcess(aDoc,ID_BUTTON_Test_8,TheDisplayType,Message);
631 // Function name : GeomSources::gpTest9
633 // Return type : void
634 // Argument : CGeometryDoc* aDoc
635 void GeomSources::gpTest9(CGeometryDoc* aDoc)
637 DisplayType TheDisplayType = a2DNo3D;
638 PreProcess(aDoc,TheDisplayType);
640 //==============================================================
642 Standard_Real radius = 5;
643 Handle(Geom2d_Circle) C =
644 new Geom2d_Circle(gp::OX2d(),radius);
645 Geom2dAdaptor_Curve GAC (C);
646 Standard_Real startparam = 10*M_PI/180;
647 Standard_Real abscissa = 45*M_PI/180;
649 C->D0(startparam,P1);
650 // abscissa is the distance along the curve from startparam
651 GCPnts_AbscissaPoint AP (GAC, abscissa, startparam);
653 if (AP.IsDone()){C->D0(AP.Parameter(),P2);}
654 // P is now correctly set
656 //==============================================================
657 TCollection_AsciiString Message (" \n\
660 Standard_Real radius = 5; \n\
661 Handle(Geom2d_Circle) C = \n\
662 new Geom2d_Circle(gp::OX2d(),radius); \n\
663 Geom2dAdaptor_Curve GAC (C); \n\
664 Standard_Real startparam = 10*PI180; \n\
665 Standard_Real abscissa = 45*PI180; \n\
667 C->D0(startparam,P1); \n\
668 // abscissa is the distance along the curve from startparam \n\
669 GCPnts_AbscissaPoint AP (GAC, abscissa, startparam); \n\
671 if (AP.IsDone()){C->D0(AP.Parameter(),P2);} \n\
672 // P is now correctly set \n\
675 AddSeparator(aDoc,Message);
676 //--------------------------------------------------------------
677 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
678 aDoc->GetISessionContext()->Display(aCurve,Standard_False);
680 DisplayPoint(aDoc,P1,"P1");
681 if (AP.IsDone()) DisplayPoint(aDoc,P2,"P2");
683 TCollection_AsciiString Message2 (P1.X());
684 TCollection_AsciiString Message3 (P1.Y());
686 TCollection_AsciiString Message4 (P2.X());
687 TCollection_AsciiString Message5 (P2.Y());
690 Message += Message2; Message += " , ";
691 Message += Message3; Message += " ); \n";
694 Message += Message4; Message += " , ";
695 Message += Message5; Message += " ); \n";
696 PostProcess(aDoc,ID_BUTTON_Test_9,TheDisplayType,Message);
699 // Function name : GeomSources::gpTest10
701 // Return type : void
702 // Argument : CGeometryDoc* aDoc
703 void GeomSources::gpTest10(CGeometryDoc* aDoc)
705 DisplayType TheDisplayType = a2DNo3D;
706 PreProcess(aDoc,TheDisplayType);
707 //==============================================================
710 Standard_Real radius = 5;
711 Handle(Geom2d_Circle) C =
712 new Geom2d_Circle(gp::OX2d(),radius);
713 Geom2dAdaptor_Curve GAC (C);
714 Standard_Real abscissa = 3;
715 GCPnts_UniformAbscissa UA (GAC,abscissa);
716 TColgp_SequenceOfPnt2d aSequence;
719 Standard_Real N = UA.NbPoints();
720 Standard_Integer count = 1;
721 for(;count<=N;count++)
723 C->D0(UA.Parameter(count),P);
724 //Standard_Real Parameter = UA.Parameter(count);
725 // append P in a Sequence
729 Standard_Real Abscissa = UA.Abscissa();
731 //==============================================================
732 TCollection_AsciiString Message (" \
735 Standard_Real radius = 5; \n\
736 Handle(Geom2d_Circle) C = \n\
737 new Geom2d_Circle(gp::OX2d(),radius); \n\
738 Geom2dAdaptor_Curve GAC (C); \n\
739 Standard_Real abscissa = 3; \n\
740 GCPnts_UniformAbscissa UA (GAC,abscissa); \n\
741 TColgp_SequenceOfPnt2d aSequence; \n\
744 Standard_Real N = UA.NbPoints(); \n\
745 Standard_Integer count = 1; \n\
746 for(;count<=N;count++) \n\
748 C->D0(UA.Parameter(count),P); \n\
749 Standard_Real Parameter = UA.Parameter(count); \n\
750 // append P in a Sequence \n\
751 aSequence.Append(P); \n\
754 Standard_Real Abscissa = UA.Abscissa(); \n\
756 AddSeparator(aDoc,Message);
757 //--------------------------------------------------------------
758 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
759 aDoc->GetISessionContext()->Display(aCurve,Standard_False);
761 TCollection_AsciiString aString;
762 for (Standard_Integer i=1;i<= aSequence.Length();i++)
765 TCollection_AsciiString Message2 (i);
766 TCollection_AsciiString Message3 (UA.Parameter(i));
770 aString +=": Parameter : ";
773 // First and Last texts are displayed with an Y offset, point 4 is upper
774 Standard_Real YOffset = -0.3;
775 YOffset += 0.2 * ( i == 1 );
776 YOffset += 0.4 * ( i == 4 );
777 YOffset += -0.2 * ( i == aSequence.Length() );
779 DisplayPoint(aDoc,aSequence(i),aString.ToCString(),false,0.5,YOffset,0.04);
782 TCollection_AsciiString Message3 (Abscissa);
784 Message += "Abscissa = ";
788 PostProcess(aDoc,ID_BUTTON_Test_10,TheDisplayType,Message);
791 // Function name : GeomSources::gpTest11
793 // Return type : void
794 // Argument : CGeometryDoc* aDoc
795 void GeomSources::gpTest11(CGeometryDoc* aDoc)
797 DisplayType TheDisplayType = No2D3D;
798 PreProcess(aDoc,TheDisplayType);
799 //==============================================================
801 Standard_Real radius = 5;
802 Handle(Geom_SphericalSurface) SP =
803 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);
806 gp_Pnt P = SP->Value(u,v);
808 //==============================================================
809 TCollection_AsciiString Message (" \
811 Standard_Real radius = 5; \n\
812 Handle(Geom_SphericalSurface) SP = \n\
813 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius); \n\
814 Standard_Real u = 2; \n\
815 Standard_Real v = 3; \n\
816 gp_Pnt P = SP->Value(u,v); \n\
818 AddSeparator(aDoc,Message);
819 //--------------------------------------------------------------
821 DisplaySurface(aDoc,SP);
822 DisplayPoint(aDoc,P,"P",false,0.5);
823 TCollection_AsciiString Message2 (P.X());
824 TCollection_AsciiString Message3 (P.Y());
832 PostProcess(aDoc,ID_BUTTON_Test_11,TheDisplayType,Message);
835 // Function name : GeomSources::gpTest12
837 // Return type : void
838 // Argument : CGeometryDoc* aDoc
839 void GeomSources::gpTest12(CGeometryDoc* aDoc)
841 DisplayType TheDisplayType = No2D3D;
842 PreProcess(aDoc,TheDisplayType);
843 //==============================================================
846 Standard_Real distance, radius = 5;
847 Handle(Geom_Curve) C = new Geom_Circle(gp::XOY(),radius);
848 GeomAPI_ProjectPointOnCurve PPC (P,C);
849 N = PPC.NearestPoint();
850 Standard_Integer NbResults = PPC.NbPoints();
854 for(Standard_Integer i = 1;i<=NbResults;i++)
857 distance = PPC.Distance(i);
858 // do something with Q or distance here
862 //==============================================================
863 TCollection_AsciiString Message (" \
865 gp_Pnt N,Q,P(1,2,3); \n\
866 Standard_Real distance, radius = 5; \n\
867 Handle(Geom_Circle) C = new Geom_Circle(gp::XOY(),radius); \n\
868 GeomAPI_ProjectPointOnCurve PPC (P,C); \n\
869 N = PPC.NearestPoint(); \n\
870 Standard_Integer NbResults = PPC.NbPoints(); \n\
873 for(Standard_Integer i = 1;i<=NbResults;i++){ \n\
874 Q = PPC.Point(i); \n\
875 distance = PPC.Distance(i); \n\
876 // do something with Q or distance here \n\
880 AddSeparator(aDoc,Message);
881 //--------------------------------------------------------------
883 TCollection_AsciiString aString;
885 DisplayPoint(aDoc,P,"P",false,0.5);
887 TCollection_AsciiString Message2 (PPC.LowerDistance());
889 aString = "N : at Distance : ";
892 DisplayPoint(aDoc,N,aString.ToCString(),false,0.5,0,-0.5);
893 DisplayCurve(aDoc,C,Quantity_NOC_YELLOW,false);
897 for(Standard_Integer i = 1;i<=NbResults;i++)
900 distance = PPC.Distance(i);
901 TCollection_AsciiString Message3 (i);
902 TCollection_AsciiString Message4 (distance);
906 aString +=": at Distance : ";
908 DisplayPoint(aDoc,Q,aString.ToCString(),false,0.5);
912 PostProcess(aDoc,ID_BUTTON_Test_12,TheDisplayType,Message);
915 // Function name : GeomSources::gpTest13
917 // Return type : void
918 // Argument : CGeometryDoc* aDoc
919 void GeomSources::gpTest13(CGeometryDoc* aDoc)
921 DisplayType TheDisplayType = No2D3D;
922 PreProcess(aDoc,TheDisplayType);
924 //==============================================================
927 Standard_Real distance, radius = 5;
928 Handle(Geom_SphericalSurface) SP =
929 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);
930 GeomAPI_ProjectPointOnSurf PPS(P,SP);
931 N = PPS.NearestPoint();
932 Standard_Integer NbResults = PPS.NbPoints();
935 for(Standard_Integer i = 1;i<=NbResults;i++)
938 distance = PPS.Distance(i);
939 // do something with Q or distance here
943 //==============================================================
944 TCollection_AsciiString Message (" \
946 gp_Pnt N,Q,P(7,8,9); \n\
947 Standard_Real distance, radius = 5; \n\
948 Handle(Geom_SphericalSurface) SP = \n\
949 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius); \n\
950 GeomAPI_ProjectPointOnSurf PPS(P,SP); \n\
951 N = PPS.NearestPoint(); \n\
952 Standard_Integer NbResults = PPS.NbPoints(); \n\
954 for(Standard_Integer i = 1;i<=NbResults;i++){ \n\
955 Q = PPS.Point(i); \n\
956 distance = PPS.Distance(i); \n\
957 // do something with Q or distance here \n\
961 AddSeparator(aDoc,Message);
962 //--------------------------------------------------------------
963 TCollection_AsciiString aString;
965 DisplayPoint(aDoc,P,"P",false,0.5);
966 TCollection_AsciiString Message2 (PPS.LowerDistance());
968 aString = "N : at Distance : "; aString += Message2;
969 DisplayPoint(aDoc,N,aString.ToCString(),false,0.5,0,-0.6);
971 Handle(ISession_Surface) aSurface = new ISession_Surface(SP);
972 Handle(Prs3d_Drawer) CurDrawer = aSurface->Attributes();
973 CurDrawer->UIsoAspect()->SetNumber(10);
974 CurDrawer->VIsoAspect()->SetNumber(10);
975 aDoc->GetAISContext()->SetLocalAttributes(aSurface, CurDrawer);
976 aDoc->GetAISContext()->Display(aSurface, Standard_False);
980 for(Standard_Integer i = 1;i<=NbResults;i++)
984 distance = PPS.Distance(i);
985 TCollection_AsciiString Message3 (i);
986 TCollection_AsciiString Message4 (distance);
990 aString +=": at Distance : ";
993 DisplayPoint(aDoc,Q,aString.ToCString(),false,0.5);
996 PostProcess(aDoc,ID_BUTTON_Test_13,TheDisplayType,Message);
999 // Function name : GeomSources::gpTest14
1001 // Return type : void
1002 // Argument : CGeometryDoc* aDoc
1003 void GeomSources::gpTest14(CGeometryDoc* aDoc)
1005 DisplayType TheDisplayType = No2D3D;
1006 PreProcess(aDoc,TheDisplayType);
1007 //==============================================================
1010 gp_Ax3 theAxe(gp::XOY());
1012 Standard_Real MinorRadius = 5;
1013 Standard_Real MajorRadius = 8;
1014 gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius);
1015 IntAna_IntConicQuad ICQ
1016 (EL,PL,Precision::Angular(),Precision::Confusion());
1018 Standard_Integer NbResults = ICQ.NbPoints();
1020 for(Standard_Integer i = 1;i<=NbResults;i++){
1022 // do something with P here
1027 //==============================================================
1028 TCollection_AsciiString Message (" \
1031 gp_Pln PL (gp_Ax3(gp::XOY())); \n\
1032 Standard_Real MinorRadius = 5; \n\
1033 Standard_Real MajorRadius = 8; \n\
1034 gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius); \n\
1035 IntAna_IntConicQuad ICQ \n\
1036 (EL,PL,Precision::Angular(),Precision::Confusion()); \n\
1037 if (ICQ.IsDone()){ \n\
1038 Standard_Integer NbResults = ICQ.NbPoints(); \n\
1039 if (NbResults>0){ \n\
1040 for(Standard_Integer i = 1;i<=NbResults;i++){ \n\
1041 P = ICQ.Point(i); \n\
1042 // do something with P here \n\
1047 AddSeparator(aDoc,Message);
1048 //--------------------------------------------------------------
1050 Handle(Geom_Plane) aPlane = GC_MakePlane(PL).Value();
1051 Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);
1053 DisplaySurface(aDoc,aSurface);
1055 Handle(Geom_Curve) anEllips = GC_MakeEllipse(EL).Value();
1056 DisplayCurve(aDoc,anEllips,Quantity_NOC_YELLOW,false);
1058 TCollection_AsciiString aString;
1062 Standard_Integer NbResults = ICQ.NbPoints();
1065 for(Standard_Integer i = 1;i<=NbResults;i++)
1068 TCollection_AsciiString Message2(i);
1071 aString = "P";aString += Message2;
1072 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1077 PostProcess(aDoc,ID_BUTTON_Test_14,TheDisplayType,Message);
1080 // Function name : GeomSources::gpTest15
1082 // Return type : void
1083 // Argument : CGeometryDoc* aDoc
1084 void GeomSources::gpTest15(CGeometryDoc* aDoc)
1086 DisplayType TheDisplayType = No2D3D;
1087 PreProcess(aDoc,TheDisplayType);
1088 //==============================================================
1095 P1Copy.Transform(TRSF);
1097 //==============================================================
1098 TCollection_AsciiString Message (" \
1100 gp_Pnt P1(1,2,3); \n\
1101 gp_Pnt P1Copy = P1; \n\
1102 gp_Pnt P2(5,4,6); \n\
1104 TRSF.SetMirror(P2); \n\
1105 P1Copy.Transform(TRSF); \n\
1107 AddSeparator(aDoc,Message);
1108 //--------------------------------------------------------------
1110 DisplayPoint(aDoc,P1Copy,"P1Copy",false,0.5);
1111 DisplayPoint(aDoc,P1,"P1",false,0.5);
1112 DisplayPoint(aDoc,P2,"P2",false,0.5);
1114 PostProcess(aDoc,ID_BUTTON_Test_15,TheDisplayType,Message);
1117 // Function name : GeomSources::gpTest16
1119 // Return type : void
1120 // Argument : CGeometryDoc* aDoc
1121 void GeomSources::gpTest16(CGeometryDoc* aDoc)
1123 DisplayType TheDisplayType = No2D3D;
1124 PreProcess(aDoc,TheDisplayType);
1125 //==============================================================
1135 Standard_Boolean result =
1136 V1.IsOpposite(V2,Precision::Angular());
1137 // result should be true
1139 //==============================================================
1140 TCollection_AsciiString Message (" \
1142 gp_Pnt P1(1,2,3); \n\
1143 gp_Pnt P2(5,4,6); \n\
1144 gp_Vec V1 (P1,P2); \n\
1146 gp_Pnt P3(10,4,7); \n\
1147 gp_Pnt P4(2,0,1); \n\
1148 gp_Vec V2 (P3,P4); \n\
1150 Standard_Boolean result = \n\
1151 V1.IsOpposite(V2,Precision::Angular()); \n\
1152 // result should be true \n\
1154 AddSeparator(aDoc,Message);
1155 //--------------------------------------------------------------
1157 DisplayPoint(aDoc,P1,"P1",false,0.5);
1158 DisplayPoint(aDoc,P2,"P2",false,0.5);
1159 DisplayPoint(aDoc,P3,"P3",false,0.5);
1160 DisplayPoint(aDoc,P4,"P4",false,0.5);
1162 Handle(ISession_Direction) aDirection1 = new ISession_Direction(P1,V1);
1163 aDoc->GetAISContext()->Display(aDirection1, Standard_False);
1165 Handle(ISession_Direction) aDirection2 = new ISession_Direction(P3,V2);
1166 aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1168 Message += "result = ";
1169 if (result) Message += "True \n"; else Message += "False \n";
1171 PostProcess(aDoc,ID_BUTTON_Test_16,TheDisplayType,Message);
1174 // Function name : GeomSources::gpTest17
1176 // Return type : void
1177 // Argument : CGeometryDoc* aDoc
1178 void GeomSources::gpTest17(CGeometryDoc* aDoc)
1180 DisplayType TheDisplayType = No2D3D;
1181 PreProcess(aDoc,TheDisplayType);
1182 //==============================================================
1186 Standard_Real ang = D1.Angle(D2);
1187 // the result is in radians in the range [0,PI]
1189 //==============================================================
1190 TCollection_AsciiString Message (" \
1192 gp_Dir D1(1,2,3); \n\
1193 gp_Dir D2(3,4,5); \n\
1194 Standard_Real ang = D1.Angle(D2); \n\
1195 // the result is in radians in the range [0,PI] \n\
1197 AddSeparator(aDoc,Message);
1198 //--------------------------------------------------------------
1200 Handle(ISession_Direction) aDirection1 = new ISession_Direction(gp_Pnt(0,0,0),D1,3);
1201 aDoc->GetAISContext()->Display(aDirection1, Standard_False);
1203 Handle(ISession_Direction) aDirection2 = new ISession_Direction(gp_Pnt(0,0,0),D2,3);
1204 aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1206 cout<<" D1.Angle(D2) : "<<ang<<endl;
1208 TCollection_AsciiString Message2 (ang);
1209 TCollection_AsciiString Message3 (ang/M_PI/180);
1211 Message += " ang = ";
1212 Message += Message2;
1213 Message += " radian \n";
1214 Message += " ang/PI180 = ";
1215 Message += Message3;
1216 Message += " degree \n";
1218 PostProcess(aDoc,ID_BUTTON_Test_17,TheDisplayType,Message);
1221 // Function name : GeomSources::gpTest18
1223 // Return type : void
1224 // Argument : CGeometryDoc* aDoc
1225 void GeomSources::gpTest18(CGeometryDoc* aDoc)
1227 DisplayType TheDisplayType = a2DNo3D;
1228 PreProcess(aDoc,TheDisplayType);
1229 //==============================================================
1234 gp_Parab2d Para(A,6);
1235 // P is the vertex point
1236 // P and D give the axis of symmetry
1237 // 6 is the focal length of the parabola
1239 //==============================================================
1240 TCollection_AsciiString Message (" \
1242 gp_Pnt2d P(2,3); \n\
1243 gp_Dir2d D(4,5); \n\
1244 gp_Ax22d A(P,D); \n\
1245 gp_Parab2d Para(A,6); \n\
1246 // P is the vertex point \n\
1247 // P and D give the axis of symmetry \n\
1248 // 6 is the focal length of the parabola \n\
1250 AddSeparator(aDoc,Message);
1251 //--------------------------------------------------------------
1253 DisplayPoint(aDoc,P,"P",false,0.5,0,3);
1255 Handle(ISession_Direction) aDirection = new ISession_Direction(P,D,200);
1256 aDoc->GetISessionContext()->Display(aDirection,Standard_False);
1257 Handle(Geom2d_Parabola) aParabola = GCE2d_MakeParabola(Para);
1258 Handle(Geom2d_TrimmedCurve) aTrimmedCurve = new Geom2d_TrimmedCurve(aParabola,-100,100);
1259 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aTrimmedCurve);
1260 //aCurve->SetColorIndex(3);
1261 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1263 Message += " The entity A of type gp_Ax22d is not displayable \n ";
1264 Message += " The entity D of type gp_Dir2d is displayed as a vector \n ( mean with a length != 1 ) \n ";
1265 PostProcess(aDoc,ID_BUTTON_Test_18,TheDisplayType,Message);
1268 // Function name : GeomSources::gpTest19
1270 // Return type : void
1271 // Argument : CGeometryDoc* aDoc
1272 void GeomSources::gpTest19(CGeometryDoc* aDoc)
1274 DisplayType TheDisplayType = No2D3D;
1275 PreProcess(aDoc,TheDisplayType);
1276 //==============================================================
1281 Standard_Boolean IsDirectA = A.Direct();
1283 gp_Dir AXDirection = A.XDirection() ;
1284 gp_Dir AYDirection = A.YDirection() ;
1289 // axis3 is now left handed
1290 Standard_Boolean IsDirectA2 = A2.Direct();
1292 gp_Dir A2XDirection = A2.XDirection() ;
1293 gp_Dir A2YDirection = A2.YDirection() ;
1295 //==============================================================
1296 TCollection_AsciiString Message (" \
1298 gp_Pnt P1(2,3,4); \n\
1299 gp_Dir D(4,5,6); \n\
1301 Standard_Boolean IsDirectA = A.Direct(); \n\
1303 gp_Dir AXDirection = A.XDirection() ; \n\
1304 gp_Dir AYDirection = A.YDirection() ; \n\
1306 gp_Pnt P2(5,3,4); \n\
1307 gp_Ax3 A2(P2,D); \n\
1309 // axis3 is now left handed \n\
1310 Standard_Boolean IsDirectA2 = A2.Direct(); \n\
1312 gp_Dir A2XDirection = A2.XDirection() ; \n\
1313 gp_Dir A2YDirection = A2.YDirection() ; \n\
1315 AddSeparator(aDoc,Message);
1316 //--------------------------------------------------------------
1318 // Set style for vector lines
1319 Handle(Prs3d_LineAspect) anAxesAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
1321 DisplayPoint(aDoc,P1,"P1",false,0.1);
1322 Handle(ISession_Direction) aDirection = new ISession_Direction(P1,D,2);
1323 aDoc->GetAISContext()->Display(aDirection, Standard_False);
1325 Handle(ISession_Direction) aDirection2 = new ISession_Direction(P1,AXDirection,2);
1326 aDirection2->SetText("A.XDirection");
1327 aDirection2->SetLineAspect (anAxesAspect);
1328 aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1329 Handle(ISession_Direction) aDirection3 = new ISession_Direction(P1,AYDirection,2);
1330 aDirection3->SetText("A.YDirection");
1331 aDirection3->SetLineAspect (anAxesAspect);
1332 aDoc->GetAISContext()->Display(aDirection3, Standard_False);
1334 DisplayPoint(aDoc,P2,"P2",false,0.1);
1335 Handle(ISession_Direction) aDirection4 = new ISession_Direction(P2,D,2);
1336 aDoc->GetAISContext()->Display(aDirection4, Standard_False);
1338 Handle(ISession_Direction) aDirection5 = new ISession_Direction(P2,A2XDirection,2);
1339 aDirection5->SetText("A2 XDirection");
1340 aDirection5->SetLineAspect (anAxesAspect);
1341 aDoc->GetAISContext()->Display(aDirection5, Standard_False);
1342 Handle(ISession_Direction) aDirection6 = new ISession_Direction(P2,A2YDirection,2);
1343 aDirection6->SetText("A2 YDirection");
1344 aDirection6->SetLineAspect (anAxesAspect);
1345 aDoc->GetAISContext()->Display(aDirection6, Standard_False);
1347 Message += "IsDirectA = ";
1349 Message += "True = Right Handed \n";
1351 Message += "False = Left Handed \n";
1353 Message += "IsDirectA2 = ";
1355 Message += "True = Right Handed \n";
1357 Message += "False = Left Handed \n";
1359 PostProcess(aDoc,ID_BUTTON_Test_19,TheDisplayType,Message);
1362 // Function name : GeomSources::gpTest20
1364 // Return type : void
1365 // Argument : CGeometryDoc* aDoc
1366 void GeomSources::gpTest20(CGeometryDoc* aDoc)
1368 DisplayType TheDisplayType = a2DNo3D;
1369 PreProcess(aDoc,TheDisplayType);
1370 //==============================================================
1372 TColgp_Array1OfPnt2d array (1,5); // sizing array
1373 array.SetValue(1,gp_Pnt2d (0,0));
1374 array.SetValue(2,gp_Pnt2d (1,2));
1375 array.SetValue(3,gp_Pnt2d (2,3));
1376 array.SetValue(4,gp_Pnt2d (4,3));
1377 array.SetValue(5,gp_Pnt2d (5,5));
1378 Handle(Geom2d_BSplineCurve) SPL1 =
1379 Geom2dAPI_PointsToBSpline(array);
1381 Handle(TColgp_HArray1OfPnt2d) harray =
1382 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1383 harray->SetValue(1,gp_Pnt2d (7+ 0,0));
1384 harray->SetValue(2,gp_Pnt2d (7+ 1,2));
1385 harray->SetValue(3,gp_Pnt2d (7+ 2,3));
1386 harray->SetValue(4,gp_Pnt2d (7+ 4,3));
1387 harray->SetValue(5,gp_Pnt2d (7+ 5,5));
1388 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);
1389 anInterpolation.Perform();
1390 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();
1392 Handle(TColgp_HArray1OfPnt2d) harray2 =
1393 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1394 harray2->SetValue(1,gp_Pnt2d (11+ 0,0));
1395 harray2->SetValue(2,gp_Pnt2d (11+ 1,2));
1396 harray2->SetValue(3,gp_Pnt2d (11+ 2,3));
1397 harray2->SetValue(4,gp_Pnt2d (11+ 4,3));
1398 harray2->SetValue(5,gp_Pnt2d (11+ 5,5));
1399 Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01);
1400 anInterpolation2.Perform();
1401 Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve();
1402 // redefined C++ operator allows these assignments
1404 //==============================================================
1405 TCollection_AsciiString Message (" \
1407 TColgp_Array1OfPnt2d array (1,5); // sizing array \n\
1408 array.SetValue(1,gp_Pnt2d (0,0)); \n\
1409 array.SetValue(2,gp_Pnt2d (1,2)); \n\
1410 array.SetValue(3,gp_Pnt2d (2,3)); \n\
1411 array.SetValue(4,gp_Pnt2d (4,3)); \n\
1412 array.SetValue(5,gp_Pnt2d (5,5)); \n\
1413 Handle(Geom2d_BSplineCurve) SPL1 = \n\
1414 Geom2dAPI_PointsToBSpline(array); \n\
1416 Handle(TColgp_HArray1OfPnt2d) harray = \n\
1417 new TColgp_HArray1OfPnt2d (1,5); // sizing harray \n\
1418 harray->SetValue(1,gp_Pnt2d (7+ 0,0)); \n\
1419 harray->SetValue(2,gp_Pnt2d (7+ 1,2)); \n\
1420 harray->SetValue(3,gp_Pnt2d (7+ 2,3)); \n\
1421 harray->SetValue(4,gp_Pnt2d (7+ 4,3)); \n\
1422 harray->SetValue(5,gp_Pnt2d (7+ 5,5)); \n\
1423 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01); \n\
1424 anInterpolation.Perform(); \n\
1425 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve(); \n\
1427 Handle(TColgp_HArray1OfPnt2d) harray2 = \n\
1428 new TColgp_HArray1OfPnt2d (1,5); // sizing harray \n");
1430 harray2->SetValue(1,gp_Pnt2d (11+ 0,0)); \n\
1431 harray2->SetValue(2,gp_Pnt2d (11+ 1,2)); \n\
1432 harray2->SetValue(3,gp_Pnt2d (11+ 2,3)); \n\
1433 harray2->SetValue(4,gp_Pnt2d (11+ 4,3)); \n\
1434 harray2->SetValue(5,gp_Pnt2d (11+ 5,5)); \n\
1435 Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01); \n\
1436 anInterpolation2.Perform(); \n\
1437 Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve(); \n\
1438 // redefined C++ operator allows these assignments \n\
1440 AddSeparator(aDoc,Message);
1441 //--------------------------------------------------------------
1442 TCollection_AsciiString aString;
1443 for(int i = array.Lower();i<=array.Upper();i++)
1445 gp_Pnt2d P = array(i);
1446 TCollection_AsciiString Message2 (i);
1447 aString = "array ";aString += Message2;
1448 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1450 for( int i = harray->Lower();i<=harray->Upper();i++)
1452 gp_Pnt2d P = harray->Value(i);
1453 TCollection_AsciiString Message2 (i);
1454 aString = "harray ";aString += Message2;
1455 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1457 for( int i = harray2->Lower();i<=harray2->Upper();i++)
1459 gp_Pnt2d P = harray2->Value(i);
1460 TCollection_AsciiString Message2 (i);
1461 aString = "harray2 ";aString += Message2;
1462 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1467 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1468 aCurve->SetColorIndex(3);
1469 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1472 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL1.IsNull()", L"CasCade Error", MB_ICONERROR);
1476 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL2);
1477 aCurve2->SetColorIndex(5);
1478 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1481 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL2.IsNull()", L"CasCade Error", MB_ICONERROR);
1485 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL3);
1486 aCurve2->SetColorIndex(6);
1487 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1490 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL3.IsNull()", L"CasCade Error", MB_ICONERROR);
1492 Message += " SPL1 is Red \n";
1493 Message += " SPL2 is Blue \n";
1494 Message += " SPL3 is Yellow \n";
1496 PostProcess(aDoc,ID_BUTTON_Test_20,TheDisplayType,Message);
1499 void GeomSources::gpTest21(CGeometryDoc* aDoc)
1501 DisplayType TheDisplayType = a2DNo3D;
1502 PreProcess(aDoc,TheDisplayType);
1504 //==============================================================
1506 gp_Pnt2d P1(-184, 101);
1507 gp_Pnt2d P2(20 ,84);
1508 Standard_Real aheight = 1;
1509 FairCurve_Batten B (P1,P2,aheight);
1510 B.SetAngle1(22*M_PI/180);
1511 B.SetAngle2(44*M_PI/180);
1512 FairCurve_AnalysisCode anAnalysisCode;
1513 B.Compute(anAnalysisCode);
1514 Handle(Geom2d_BSplineCurve) C = B.Curve();
1516 //==============================================================
1517 TCollection_AsciiString Message (" \
1519 gp_Pnt2d P1(-184, 101); \n\
1520 gp_Pnt2d P2(20 ,84); \n\
1521 Standard_Real aheight = 1; \n\
1522 FairCurve_Batten B (P1,P2,aheight); \n\
1523 B.SetAngle1(22*PI180); \n\
1524 B.SetAngle2(44*PI180); \n\
1525 FairCurve_AnalysisCode anAnalysisCode; \n\
1526 B.Compute(anAnalysisCode); \n\
1527 Handle(Geom2d_BSplineCurve) C = B.Curve(); \n\
1529 AddSeparator(aDoc,Message);
1530 //--------------------------------------------------------------
1532 DisplayCurveAndCurvature(aDoc,C,6,Standard_False);
1534 PostProcess(aDoc,ID_BUTTON_Test_21,TheDisplayType,Message);
1537 void GeomSources::gpTest22(CGeometryDoc* aDoc)
1539 DisplayType TheDisplayType = a2DNo3D;
1540 PreProcess(aDoc,TheDisplayType);
1542 //==============================================================
1544 gp_Pnt2d P1(-184, 41);
1545 gp_Pnt2d P2(20 ,24);
1546 Standard_Real aheight = 1;
1547 FairCurve_MinimalVariation MV (P1,P2,aheight);
1548 MV.SetAngle1(22*M_PI/180);
1549 MV.SetAngle2(44*M_PI/180);
1551 FairCurve_AnalysisCode anAnalysisCode;
1552 MV.Compute(anAnalysisCode);
1554 Handle(Geom2d_BSplineCurve) C = MV.Curve();
1556 //==============================================================
1557 TCollection_AsciiString Message (" \
1559 gp_Pnt2d P1(-184, 41); \n\
1560 gp_Pnt2d P2(20 ,24); \n\
1561 Standard_Real aheight = 1; \n\
1562 FairCurve_MinimalVariation MV (P1,P2,aheight); \n\
1563 MV.SetAngle1(22*PI180); \n\
1564 MV.SetAngle2(44*PI180); \n\
1566 FairCurve_AnalysisCode anAnalysisCode; \n\
1567 MV.Compute(anAnalysisCode); \n\
1569 Handle(Geom2d_BSplineCurve) C = MV.Curve(); \n\
1571 AddSeparator(aDoc,Message);
1572 //--------------------------------------------------------------
1574 DisplayCurveAndCurvature(aDoc,C,7,Standard_False);
1575 DisplayPoint(aDoc,P1,"P1",false,0.5);
1576 DisplayPoint(aDoc,P2,"P2",false,0.5);
1578 PostProcess(aDoc,ID_BUTTON_Test_22,TheDisplayType,Message);
1581 // Function name : GeomSources::gpTest23
1583 // Return type : void
1584 // Argument : CGeometryDoc* aDoc
1585 void GeomSources::gpTest23(CGeometryDoc* aDoc)
1587 DisplayType TheDisplayType = a2DNo3D;
1588 PreProcess(aDoc,TheDisplayType);
1589 //==============================================================
1591 Standard_Real major = 12;
1592 Standard_Real minor = 4;
1593 gp_Ax2d axis = gp::OX2d();
1594 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor);
1595 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2);
1597 // The segment goes in the direction Vfrom P1
1598 // to the point projected on this line by P2
1599 // In the example (0,6).
1600 Handle(Geom2d_BSplineCurve) SPL =
1601 Geom2dConvert::CurveToBSplineCurve(TC);
1603 //==============================================================
1604 TCollection_AsciiString Message (" \
1606 Standard_Real major = 12; \n\
1607 Standard_Real minor = 4; \n\
1608 gp_Ax2d axis = gp::OX2d(); \n\
1609 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor); \n\
1611 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2); \n\
1613 // The segment goes in the direction Vfrom P1 \n\
1614 // to the point projected on this line by P2 \n\
1615 // In the example (0,6). \n\
1616 Handle(Geom2d_BSplineCurve) SPL = \n\
1617 Geom2dConvert::CurveToBSplineCurve(TC); \n\
1619 AddSeparator(aDoc,Message);
1620 //--------------------------------------------------------------
1622 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
1623 aCurve->SetColorIndex(3); // Red
1624 aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
1625 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1627 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL);
1628 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1630 PostProcess(aDoc,ID_BUTTON_Test_23,TheDisplayType,Message);
1633 // Function name : GeomSources::gpTest24
1635 // Return type : void
1636 // Argument : CGeometryDoc* aDoc
1637 void GeomSources::gpTest24(CGeometryDoc* aDoc)
1639 DisplayType TheDisplayType = a2D3D;
1640 PreProcess(aDoc,TheDisplayType);
1641 //==============================================================
1643 Standard_Real radius = 5;
1644 gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0));
1646 Handle(Geom2d_Circle) circ2d =
1647 new Geom2d_Circle(ax2d,radius);
1649 gp_Ax2d circ2dXAxis = circ2d->XAxis();
1651 // create a 3D curve in a given plane
1652 Handle(Geom_Curve) C3D =
1653 GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY())));
1654 Handle(Geom_Circle) C3DCircle =
1655 Handle(Geom_Circle)::DownCast(C3D);
1657 gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis();
1659 // project it to a 2D curve in another plane
1661 gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 ));
1663 Handle(Geom2d_Curve) C2D =
1664 GeomAPI::To2d(C3D,ProjectionPlane);
1666 Handle(Geom2d_Circle) C2DCircle =
1667 Handle(Geom2d_Circle)::DownCast(C2D);
1668 gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis();
1670 //==============================================================
1671 TCollection_AsciiString Message (" \
1673 Standard_Real radius = 5; \n\
1674 gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0)); \n\
1676 Handle(Geom2d_Circle) circ2d = \n\
1677 new Geom2d_Circle(ax2d,radius); \n\
1679 gp_Ax2d circ2dXAxis = circ2d->XAxis(); \n\
1681 // create a 3D curve in a given plane \n\
1682 Handle(Geom_Curve) C3D = \n\
1683 GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY()))); \n\
1684 Handle(Geom_Circle) C3DCircle = \n\
1685 Handle(Geom_Circle)::DownCast(C3D); \n\
1687 gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis(); \n\
1689 // project it to a 2D curve in another plane \n\
1691 gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 )); \n\
1693 Handle(Geom2d_Curve) C2D = \n\
1694 GeomAPI::To2d(C3D,ProjectionPlane); \n\
1696 Handle(Geom2d_Circle) C2DCircle = \n\
1697 Handle(Geom2d_Circle)::DownCast(C2D); \n\
1698 gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis(); \n\
1700 AddSeparator(aDoc,Message);
1701 //--------------------------------------------------------------
1702 Handle(Geom_Plane) aPlane = GC_MakePlane(gp_Pln(gp_Ax3(gp::XOY()))).Value();
1703 Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);
1704 DisplaySurface(aDoc,aSurface);
1706 Handle(Geom_Plane) aProjectionPlane = GC_MakePlane(ProjectionPlane).Value();
1707 Handle(Geom_RectangularTrimmedSurface) aProjectionPlaneSurface=
1708 new Geom_RectangularTrimmedSurface(aProjectionPlane,-8.,8.,-12.,12.);
1710 DisplaySurface(aDoc,aProjectionPlaneSurface);
1712 Standard_CString aC3DEntityTypeName = C3D->DynamicType()->Name();
1713 Standard_CString aC2DEntityTypeName = C2D->DynamicType()->Name();
1715 Message += " C3D->DynamicType()->Name() = ";
1716 Message += aC3DEntityTypeName; Message += " \n";
1717 Message += " C2D->DynamicType()->Name() = ";
1718 Message += aC2DEntityTypeName; Message += " \n";
1720 DisplayCurve(aDoc,circ2d,4,false);
1721 DisplayCurve(aDoc,C3D,Quantity_NOC_YELLOW,false);
1722 DisplayCurve(aDoc,C2D,5,false);
1724 Handle(ISession_Direction) aC3DCircleXAxisDirection = new ISession_Direction(C3DCircleXAxis.Location(),C3DCircleXAxis.Direction(),5.2);
1725 aDoc->GetAISContext()->Display(aC3DCircleXAxisDirection, Standard_False);
1727 Handle(ISession_Direction) acirc2dXAxisDirection = new ISession_Direction(circ2dXAxis.Location(),circ2dXAxis.Direction(),5.2);
1728 aDoc->GetISessionContext()->Display(acirc2dXAxisDirection, Standard_False);
1730 Handle(ISession_Direction) aC2DCircleXAxisDirection = new ISession_Direction(C2DCircleXAxis.Location(),C2DCircleXAxis.Direction(),5.2);
1731 aDoc->GetISessionContext()->Display(aC2DCircleXAxisDirection, Standard_False);
1733 PostProcess(aDoc,ID_BUTTON_Test_24,TheDisplayType,Message);
1736 // Function name : GeomSources::gpTest25
1738 // Return type : void
1739 // Argument : CGeometryDoc* aDoc
1740 void GeomSources::gpTest25(CGeometryDoc* aDoc)
1742 DisplayType TheDisplayType = a2DNo3D;
1743 PreProcess(aDoc,TheDisplayType);
1745 //==============================================================
1747 Handle(TColgp_HArray1OfPnt2d) harray =
1748 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1749 harray->SetValue(1,gp_Pnt2d (0,0));
1750 harray->SetValue(2,gp_Pnt2d (-3,1));
1751 harray->SetValue(3,gp_Pnt2d (-2,5));
1752 harray->SetValue(4,gp_Pnt2d (2,9));
1753 harray->SetValue(5,gp_Pnt2d (-4,14));
1755 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);
1756 anInterpolation.Perform();
1757 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve();
1761 gp_Dir2d V1 = gp::DY2d();
1762 Handle(Geom2d_TrimmedCurve) TC1 =
1763 GCE2d_MakeSegment(P1,V1,P2);
1765 Standard_Real tolerance = Precision::Confusion();
1766 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance);
1767 Standard_Integer NbPoints =ICC.NbPoints();
1770 for (Standard_Integer k = 1;k<=NbPoints;k++)
1773 // do something with each intersection point
1776 //==============================================================
1777 TCollection_AsciiString Message (" \
1779 Handle(TColgp_HArray1OfPnt2d) harray = \n\
1780 new TColgp_HArray1OfPnt2d (1,5); // sizing harray \n\
1781 harray->SetValue(1,gp_Pnt2d (0,0)); \n\
1782 harray->SetValue(2,gp_Pnt2d (-3,1)); \n\
1783 harray->SetValue(3,gp_Pnt2d (-2,5)); \n\
1784 harray->SetValue(4,gp_Pnt2d (2,9)); \n\
1785 harray->SetValue(5,gp_Pnt2d (-4,14)); \n\
1787 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01); \n\
1788 anInterpolation.Perform(); \n\
1789 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve(); \n\
1791 gp_Pnt2d P1(-1,-2); \n\
1792 gp_Pnt2d P2(0,15); \n\
1793 gp_Dir2d V1 = gp::DY2d(); \n\
1794 Handle(Geom2d_TrimmedCurve) TC1= \n\
1795 GCE2d_MakeSegment(P1,V1,P2); \n\
1797 Standard_Real tolerance = Precision::Confusion(); \n\
1798 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance); \n\
1799 Standard_Integer NbPoints =ICC.NbPoints(); \n\
1801 for (Standard_Integer k = 1;k<=NbPoints;k++) \n\
1803 PK = ICC.Point(k); \n\
1804 // do something with each intersection point \n\
1807 AddSeparator(aDoc,Message);
1808 //--------------------------------------------------------------
1810 Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL);
1811 aCurve1->SetDisplayPole(Standard_False);
1812 aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
1813 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC1);
1814 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1816 TCollection_AsciiString aString;
1817 for (Standard_Integer i = 1;i<=NbPoints;i++)
1820 // do something with each intersection point
1821 TCollection_AsciiString Message2 (i);
1822 TCollection_AsciiString Message3 (PK.X());
1823 TCollection_AsciiString Message4 (PK.Y());
1825 aString += Message2;
1827 DisplayPoint(aDoc,PK,aString.ToCString(),false,0.5);
1830 Message += Message2;
1832 Message += Message3;
1834 Message += Message4;
1838 PostProcess(aDoc,ID_BUTTON_Test_25,TheDisplayType,Message);
1841 // Function name : GeomSources::gpTest26
1843 // Return type : void
1844 // Argument : CGeometryDoc* aDoc
1845 void GeomSources::gpTest26(CGeometryDoc* aDoc)
1847 DisplayType TheDisplayType = a2DNo3D;
1848 PreProcess(aDoc,TheDisplayType);
1850 //==============================================================
1852 //----------- Build TC1 -----------------------
1853 gp_Pnt2d P1(0,0); gp_Pnt2d P2(2,6);
1854 gp_Dir2d V1 = gp::DY2d();
1855 Handle(Geom2d_TrimmedCurve) TC1 = GCE2d_MakeSegment(P1,V1,P2);
1856 Standard_Real FP1 = TC1->FirstParameter();
1857 Standard_Real LP1 = TC1->LastParameter();
1858 //----------- Build TC2 -----------------------
1859 gp_Pnt2d P3(-9,6.5); gp_Dir2d V2 = gp::DX2d();
1860 Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2);
1861 Standard_Real FP2 = TC1->FirstParameter();
1862 Standard_Real LP2 = TC1->LastParameter();
1863 //----------- Extrema TC1 / TC2 ---------------
1864 Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2);
1865 Standard_Real shortestdistance =-1;
1866 if (ECC.NbExtrema() != 0) shortestdistance = ECC.LowerDistance();
1867 //----------- Build SPL1 ----------------------
1868 TColgp_Array1OfPnt2d array (1,5); // sizing array
1869 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));
1870 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));
1871 array.SetValue(5,gp_Pnt2d (-3,5));
1872 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);
1873 Standard_Real FPSPL1 = SPL1->FirstParameter();
1874 Standard_Real LPSPL1 = SPL1->LastParameter();
1875 //----------- Extrema TC1 / SPL1 -------------
1876 Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1);
1877 Standard_Real SPL1shortestdistance =-1;
1878 if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance();
1879 Standard_Integer NbExtrema = ECC2.NbExtrema();
1880 TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2);
1881 for(int i=1;i <= NbExtrema; i++)
1884 ECC2.Points(i,P1x,P2x);
1885 aSolutionArray(i,1) = P1x;
1886 aSolutionArray(i,2) = P2x;
1889 //==============================================================
1890 TCollection_AsciiString Message (" \
1891 //----------- Build TC1 ----------------------- \n\
1892 gp_Pnt2d P1(0,0); gp_Pnt2d P2(2,6); \n\
1893 gp_Dir2d V1 = gp::DY2d(); \n\
1894 Handle(Geom2d_TrimmedCurve) TC1 = GCE2d_MakeSegment(P1,V1,P2); \n\
1895 Standard_Real FP1 = TC1->FirstParameter(); \n\
1896 Standard_Real LP1 = TC1->LastParameter(); \n\
1897 //----------- Build TC2 ----------------------- \n\
1898 gp_Pnt2d P3(-9,6.5); gp_Dir2d V2 = gp::DX2d(); \n\
1899 Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2); \n\
1900 Standard_Real FP2 = TC1->FirstParameter(); \n\
1901 Standard_Real LP2 = TC1->LastParameter(); \n\
1902 //----------- Extrema TC1 / TC2 --------------- \n\
1903 Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2); \n\
1904 Standard_Real shortestdistance =-1; \n\
1905 if (ECC.NbExtrema() != 0) shortestdistance = ECC.LowerDistance(); \n\
1906 //----------- Build SPL1 ---------------------- \n\
1907 TColgp_Array1OfPnt2d array (1,5); // sizing array \n\
1908 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2)); \n\
1909 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3)); \n\
1910 array.SetValue(5,gp_Pnt2d (-3,5)); \n\
1911 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array); \n\
1912 Standard_Real FPSPL1 = SPL1->FirstParameter(); \n");
1914 Standard_Real LPSPL1 = SPL1->LastParameter(); \n\
1915 //----------- Extrema TC1 / SPL1 ------------- \n\
1916 Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1); \n\
1917 Standard_Real SPL1shortestdistance =-1; \n\
1918 if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance(); \n\
1919 Standard_Integer NbExtrema = ECC2.NbExtrema(); \n\
1920 TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2); \n\
1921 for(int i=1;i <= NbExtrema; i++) { \n\
1923 ECC2.Points(i,P1,P2); \n\
1924 aSolutionArray(i,1) = P1; aSolutionArray(i,2) = P2; } \n";
1925 AddSeparator(aDoc,Message);
1926 //--------------------------------------------------------------
1928 TCollection_AsciiString aString;
1929 for(int i = array.Lower();i<=array.Upper();i++)
1931 TCollection_AsciiString Message2 (i);
1932 gp_Pnt2d P = array(i);
1934 aString += Message2;
1935 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1940 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1941 aCurve->SetDisplayPole(Standard_False);
1942 aCurve->SetColorIndex(3);
1943 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1946 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL1.IsNull()", L"CasCade Error", MB_ICONERROR);
1948 Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(TC1);
1949 aCurve1->SetColorIndex(6);
1950 aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
1951 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC2);
1952 aCurve2->SetColorIndex(5);
1953 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1955 for(int i=1;i <= NbExtrema; i++)
1957 gp_Pnt2d P1x =aSolutionArray(i,1);
1959 TCollection_AsciiString Message2 (i);
1961 aString += Message2;
1962 DisplayPoint(aDoc,P1x,aString.ToCString(),false,0.7*i);
1964 gp_Pnt2d P2x = aSolutionArray(i,2);
1966 Handle(Geom2d_TrimmedCurve) SolutionCurve =
1967 GCE2d_MakeSegment(P1x,P2x);
1968 Handle(ISession2D_Curve) aSolutionCurve = new ISession2D_Curve(SolutionCurve);
1969 aDoc->GetISessionContext()->Display(aSolutionCurve, Standard_False);
1972 Message += "TC1 is Yellow ,TC2 is Blue ,SPL1 is Red \n";
1973 Message += "ECC.NbExtrema() = ";
1974 Message += ECC.NbExtrema();
1975 Message += " shortestdistance = ";
1976 Message+= shortestdistance;
1978 Message += "ECC2.NbExtrema() = ";
1979 Message += NbExtrema;
1980 Message += " SPL1shortestdistance = ";
1981 Message+= SPL1shortestdistance;
1984 PostProcess(aDoc,ID_BUTTON_Test_26,TheDisplayType,Message);
1987 // Function name : GeomSources::gpTest27
1989 // Return type : void
1990 // Argument : CGeometryDoc* aDoc
1991 void GeomSources::gpTest27(CGeometryDoc* aDoc)
1993 DisplayType TheDisplayType = a2DNo3D;
1994 PreProcess(aDoc,TheDisplayType);
1995 //==============================================================
1997 TColgp_Array1OfPnt2d array (1,5); // sizing array
1998 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));
1999 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));
2000 array.SetValue(5,gp_Pnt2d (-3,5));
2001 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);
2003 Standard_Real dist = 1;
2004 Handle(Geom2d_OffsetCurve) OC =
2005 new Geom2d_OffsetCurve(SPL1,dist);
2006 Standard_Boolean result = OC->IsCN(2);
2007 Standard_Real dist2 = 1.5;
2008 Handle(Geom2d_OffsetCurve) OC2 =
2009 new Geom2d_OffsetCurve(SPL1,dist2);
2010 Standard_Boolean result2 = OC2->IsCN(2);
2012 //==============================================================
2013 TCollection_AsciiString Message (" \
2015 TColgp_Array1OfPnt2d array (1,5); // sizing array \n\
2016 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2)); \n\
2017 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3)); \n\
2018 array.SetValue(5,gp_Pnt2d (-3,5)); \n\
2019 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array); \n\
2021 Standard_Real dist = 1; \n\
2022 Handle(Geom2d_OffsetCurve) OC = \n\
2023 new Geom2d_OffsetCurve(SPL1,dist); \n\
2024 Standard_Boolean result = OC->IsCN(2); \n\
2026 Standard_Real dist2 = 1.5; \n\
2027 Handle(Geom2d_OffsetCurve) OC2 = \n\
2028 new Geom2d_OffsetCurve(SPL1,dist2); \n\
2029 Standard_Boolean result2 = OC2->IsCN(2); \n\
2031 AddSeparator(aDoc,Message);
2032 //--------------------------------------------------------------
2033 Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL1);
2034 aCurve1->SetColorIndex(6);
2035 aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
2036 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(OC);
2037 aCurve2->SetColorIndex(5);
2038 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2039 Handle(ISession2D_Curve) aCurve3 = new ISession2D_Curve(OC2);
2040 aCurve3->SetColorIndex(3);
2041 aDoc->GetISessionContext()->Display(aCurve3, Standard_False);
2044 Message += "SPL1 is Yellow \n";
2045 Message += "OC is Blue \n";
2046 Message += "OC2 is Red \n\n";
2047 Message += " Warning, Continuity is not guaranteed : \n ";
2049 Message += " result = True \n";
2051 Message += " result = False \n";
2053 Message += " result2 = True \n";
2055 Message += " result2 = False \n";
2057 PostProcess(aDoc,ID_BUTTON_Test_27,TheDisplayType,Message);
2060 // Function name : GeomSources::gpTest28
2062 // Return type : void
2063 // Argument : CGeometryDoc* aDoc
2064 void GeomSources::gpTest28(CGeometryDoc* aDoc)
2066 DisplayType TheDisplayType = a2DNo3D;
2067 PreProcess(aDoc,TheDisplayType);
2068 //==============================================================
2072 gp_Lin2d L = gce_MakeLin2d(P1,P2);
2073 // assignment by overloaded operator
2075 //==============================================================
2076 TCollection_AsciiString Message (" \
2078 gp_Pnt2d P1(1,2); \n\
2079 gp_Pnt2d P2(4,5); \n\
2080 gp_Lin2d L = gce_MakeLin2d(P1,P2); \n\
2081 // assignment by overloaded operator \n\
2083 AddSeparator(aDoc,Message);
2084 //--------------------------------------------------------------
2086 DisplayPoint(aDoc,P1,"P1",false,0.5);
2087 DisplayPoint(aDoc,P2,"P2",false,0.5);
2089 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-3,8);
2090 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2091 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2093 PostProcess(aDoc,ID_BUTTON_Test_28,TheDisplayType,Message);
2096 // Function name : GeomSources::gpTest29
2098 // Return type : void
2099 // Argument : CGeometryDoc* aDoc
2100 void GeomSources::gpTest29(CGeometryDoc* aDoc)
2102 DisplayType TheDisplayType = a2DNo3D;
2103 PreProcess(aDoc,TheDisplayType);
2105 //==============================================================
2110 GccAna_Pnt2dBisec B(P1,P2);
2113 L = B.ThisSolution();
2116 //==============================================================
2117 TCollection_AsciiString Message (" \
2119 gp_Pnt2d P1(1,2); \n\
2120 gp_Pnt2d P2(4,5); \n\
2122 GccAna_Pnt2dBisec B(P1,P2); \n\
2125 L = B.ThisSolution(); \n\
2128 AddSeparator(aDoc,Message);
2129 //--------------------------------------------------------------
2131 DisplayPoint(aDoc,P1,"P1",false,0.5);
2132 DisplayPoint(aDoc,P2,"P2",false,0.5);
2136 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-8,8);
2137 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2138 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2141 if (B.IsDone()) Message += " \n B Is Done ";
2142 else Message += " \n B Is not Done ";
2143 PostProcess(aDoc,ID_BUTTON_Test_29,TheDisplayType,Message);
2146 // Function name : GeomSources::gpTest30
2148 // Return type : void
2149 // Argument : CGeometryDoc* aDoc
2150 void GeomSources::gpTest30(CGeometryDoc* aDoc)
2152 DisplayType TheDisplayType =a2DNo3D ;
2153 PreProcess(aDoc,TheDisplayType);
2155 //==============================================================
2160 gp_Pnt2d P4 (10,10);
2161 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);
2162 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);
2163 GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion());
2166 Standard_Integer NbSol = LT.NbSolutions();
2167 for(Standard_Integer k=1; k<=NbSol; k++)
2169 gp_Lin2d L = LT.ThisSolution(k);
2170 // do something with L
2174 //==============================================================
2175 TCollection_AsciiString Message (" \
2177 gp_Pnt2d P1 (2,3); \n\
2178 gp_Pnt2d P2 (4,4); \n\
2179 gp_Pnt2d P3 (6,7); \n\
2180 gp_Pnt2d P4 (10,10); \n\
2181 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3); \n\
2182 GccEnt_QualifiedCirc QC = GccEnt::Outside(C); \n\
2183 GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion()); \n\
2184 Standard_Integer NbSol; \n\
2185 if (LT.IsDone()) \n\
2187 NbSol = LT.NbSolutions(); \n\
2188 for(Standard_Integer k=1; k<=NbSol; k++) \n\
2190 gp_Lin2d L = LT.ThisSolution(k); \n\
2191 // do something with L \n\
2195 AddSeparator(aDoc,Message);
2196 //--------------------------------------------------------------
2198 DisplayPoint(aDoc,P1,"P1",false,0.5,-1,0.1);
2199 DisplayPoint(aDoc,P2,"P2",false,0.5,-0.7,0.1);
2200 DisplayPoint(aDoc,P3,"P3",false,0.5,-0.5,0.1);
2201 DisplayPoint(aDoc,P4,"P4",false,0.5,0,0.1);
2203 Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2204 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2205 aCurve->SetColorIndex(5);
2206 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2210 Standard_Integer NbSol = LT.NbSolutions();
2211 for(Standard_Integer k=1; k<=NbSol; k++)
2213 gp_Lin2d L = LT.ThisSolution(k);
2214 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-10,20);
2215 Handle(ISession2D_Curve) aCurveN = new ISession2D_Curve(aLine);
2216 aDoc->GetISessionContext()->Display(aCurveN, Standard_False);
2219 Message += " C is Blue \n\n";
2220 Message += "LT.IsDone() = ";
2221 if (LT.IsDone()) Message += "True \n"; else Message += "False \n";
2222 TCollection_AsciiString Message2 (LT.NbSolutions());
2223 Message += "NbSol = "; Message += Message2 ; Message += "\n";
2225 PostProcess(aDoc,ID_BUTTON_Test_30,TheDisplayType,Message);
2228 // Function name : GeomSources::gpTest31
2230 // Return type : void
2231 // Argument : CGeometryDoc* aDoc
2232 void GeomSources::gpTest31(CGeometryDoc* aDoc)
2234 DisplayType TheDisplayType = a2DNo3D;
2235 PreProcess(aDoc,TheDisplayType);
2237 //==============================================================
2242 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);
2243 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);
2245 gp_Pnt2d P5 (12,-3);
2246 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1);
2247 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L);
2248 Standard_Real radius = 2;
2249 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion());
2250 Standard_Real parsol,pararg;
2251 gp_Pnt2d tangentpoint1,tangentpoint2;
2255 Standard_Integer NbSol = TR.NbSolutions();
2256 for (Standard_Integer k=1; k<=NbSol; k++)
2258 circ = TR.ThisSolution(k);
2259 // find the solution circle
2260 TR.Tangency1(k,parsol,pararg,tangentpoint1);
2261 // find the first tangent point
2262 TR.Tangency2(k,parsol,pararg,tangentpoint2);
2263 // find the second tangent point
2267 //==============================================================
2268 TCollection_AsciiString Message;
2271 gp_Pnt2d P1 (9,6); \n\
2272 gp_Pnt2d P2 (10,4); \n\
2273 gp_Pnt2d P3 (6,7); \n\
2274 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3); \n\
2275 GccEnt_QualifiedCirc QC = GccEnt::Outside(C); \n\
2276 gp_Pnt2d P4 (-2,7); \n\
2277 gp_Pnt2d P5 (12,-3); \n\
2278 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1); \n\
2279 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L); \n\
2280 Standard_Real radius = 2; \n\
2281 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion()); \n\
2282 Standard_Real parsol,pararg; \n\
2283 gp_Pnt2d tangentpoint1,tangentpoint2; \n\
2285 if (TR.IsDone()) \n\
2287 Standard_Integer NbSol = TR.NbSolutions(); \n\
2288 for (Standard_Integer k=1; k<=NbSol; k++) \n\
2291 circ = TR.ThisSolution(k); \n\
2292 // find the solution circle \n\
2293 TR.Tangency1(k,parsol,pararg,tangentpoint1); \n\
2294 // find the first tangent point \n\
2295 TR.Tangency2(k,parsol,pararg,tangentpoint2); \n\
2296 // find the second tangent point \n\
2300 AddSeparator(aDoc,Message);
2302 //--------------------------------------------------------------
2303 DisplayPoint(aDoc,P1,"P1",false,0.3);
2304 DisplayPoint(aDoc,P2,"P2",false,0.3);
2305 DisplayPoint(aDoc,P3,"P3",false,0.3);
2306 DisplayPoint(aDoc,P4,"P4",false,0.3);
2307 DisplayPoint(aDoc,P5,"P5",false,0.3);
2309 Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2310 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2311 aCurve->SetColorIndex(3);
2313 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2314 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-2,20);
2315 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(aLine);
2316 aCurve2->SetColorIndex(5);
2317 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2321 Standard_Integer NbSol = TR.NbSolutions();
2322 for (Standard_Integer k=1; k<=NbSol; k++)
2324 circ = TR.ThisSolution(k);
2325 Handle(Geom2d_Circle) aCircleN = new Geom2d_Circle(circ);
2326 Handle(ISession2D_Curve) aCurveN = new ISession2D_Curve(aCircleN);
2327 aDoc->GetISessionContext()->Display(aCurveN, Standard_False);
2329 // find the solution circle
2330 TR.Tangency1(k,parsol,pararg,tangentpoint1);
2331 // find the first tangent point
2332 TR.Tangency2(k,parsol,pararg,tangentpoint2);
2333 // find the second tangent point
2334 DisplayPoint(aDoc,tangentpoint1,"tangentpoint1",false,0.3);
2335 DisplayPoint(aDoc,tangentpoint2,"tangentpoint2",false,0.3);
2338 Message += "C is Red \n";
2339 Message += "L is Blue \n";
2340 PostProcess(aDoc,ID_BUTTON_Test_31,TheDisplayType,Message);
2343 // Function name : GeomSources::gpTest32
2345 // Return type : void
2346 // Argument : CGeometryDoc* aDoc
2347 void GeomSources::gpTest32(CGeometryDoc* aDoc)
2349 DisplayType TheDisplayType = a2DNo3D;
2350 PreProcess(aDoc,TheDisplayType);
2352 //==============================================================
2354 Standard_Real major = 12;
2355 Standard_Real minor = 4;
2356 gp_Ax2d axis = gp::OX2d();
2357 gp_Elips2d EE(axis,major,minor);
2358 Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,M_PI/4);
2360 //==============================================================
2361 TCollection_AsciiString Message (" \
2363 Standard_Real major = 12; \n\
2364 Standard_Real minor = 4; \n\
2365 gp_Ax2d axis = gp::OX2d(); \n\
2366 gp_Elips2d EE(axis,major,minor); \n\
2367 Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,PI/4); \n\
2369 AddSeparator(aDoc,Message);
2370 //--------------------------------------------------------------
2371 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse(EE);
2372 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
2373 aCurve->SetColorIndex(3);
2374 aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
2376 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2377 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(arc);
2378 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2379 TCollection_AsciiString Message2 (M_PI);
2380 Message += " PI = ";Message+= Message2;
2382 PostProcess(aDoc,ID_BUTTON_Test_32,TheDisplayType,Message);
2385 // Function name : GeomSources::gpTest33
2387 // Return type : void
2388 // Argument : CGeometryDoc* aDoc
2389 void GeomSources::gpTest33(CGeometryDoc* aDoc)
2391 DisplayType TheDisplayType = No2D3D;
2392 PreProcess(aDoc,TheDisplayType);
2394 //==============================================================
2401 TColgp_Array1OfPnt array (1,5); // sizing array
2402 array.SetValue(1,P1);
2403 array.SetValue(2,P2);
2404 array.SetValue(3,P3);
2405 array.SetValue(4,P4);
2406 array.SetValue(5,P5);
2407 Handle(TColgp_HArray1OfPnt) harray =
2408 new TColgp_HArray1OfPnt (1,5); // sizing harray
2409 harray->SetValue(1,P1.Translated(gp_Vec(4,0,0)));
2410 harray->SetValue(2,P2.Translated(gp_Vec(4,0,0)));
2411 harray->SetValue(3,P3.Translated(gp_Vec(4,0,0)));
2412 harray->SetValue(4,P4.Translated(gp_Vec(4,0,0)));
2413 harray->SetValue(5,P5.Translated(gp_Vec(4,0,0)));
2414 Handle(Geom_BSplineCurve) SPL1 =
2415 GeomAPI_PointsToBSpline(array).Curve();
2417 GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation());
2418 anInterpolation.Perform();
2420 Handle(Geom_BSplineCurve) SPL2;
2421 if (anInterpolation.IsDone())
2422 SPL2 = anInterpolation.Curve();
2424 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"The Interpolation is Not done", L"CasCade Warning", MB_ICONWARNING);
2426 //==============================================================
2427 TCollection_AsciiString Message (" \
2429 gp_Pnt P1(0,0,1); \n\
2430 gp_Pnt P2(1,2,2); \n\
2431 gp_Pnt P3(2,3,3); \n\
2432 gp_Pnt P4(4,3,4); \n\
2433 gp_Pnt P5(5,5,5); \n\
2434 TColgp_Array1OfPnt array (1,5); // sizing array \n\
2435 array.SetValue(1,P1); \n\
2436 array.SetValue(2,P2); \n\
2437 array.SetValue(3,P3); \n\
2438 array.SetValue(4,P4); \n\
2439 array.SetValue(5,P5); \n\
2440 Handle(TColgp_HArray1OfPnt) harray = \n\
2441 new TColgp_HArray1OfPnt (1,5); // sizing harray \n\
2442 harray->SetValue(1,P1.Translated(gp_Vec(4,0,0))); \n\
2443 harray->SetValue(2,P2.Translated(gp_Vec(4,0,0))); \n\
2444 harray->SetValue(3,P3.Translated(gp_Vec(4,0,0))); \n\
2445 harray->SetValue(4,P4.Translated(gp_Vec(4,0,0))); \n\
2446 harray->SetValue(5,P5.Translated(gp_Vec(4,0,0))); \n\
2447 Handle(Geom_BSplineCurve) SPL1 = \n\
2448 GeomAPI_PointsToBSpline(array).Curve(); \n");
2451 GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation()); \n\
2452 anInterpolation.Perform(); \n\
2454 Handle(Geom_BSplineCurve) SPL2; \n\
2455 if (anInterpolation.IsDone()) \n\
2456 SPL2 = anInterpolation.Curve(); \n\
2458 MessageBox(0,\"The Interpolation is Not done\",\"CasCade Warning\",MB_ICONWARNING); \n\
2460 AddSeparator(aDoc,Message);
2462 //--------------------------------------------------------------
2464 TCollection_AsciiString aString;
2465 for(Standard_Integer i = array.Lower();i<=array.Upper();i++)
2468 TCollection_AsciiString Message2 (i);
2469 gp_Pnt P = array(i);
2472 aString += Message2;
2473 if (i == 1) aString += " (array) ";
2474 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);\
2477 aString += Message2;
2478 if (i == 1) aString += " (harray) ";
2479 DisplayPoint(aDoc,P.Translated(gp_Vec(4,0,0)),aString.ToCString(),false,0.5);\
2483 Handle(ISession_Curve) aCurve = new ISession_Curve(SPL1);
2484 aDoc->GetAISContext()->SetDisplayMode(aCurve,1);
2485 aDoc->GetAISContext()->Display(aCurve, Standard_False);
2487 if (anInterpolation.IsDone())
2489 Handle(ISession_Curve) aCurve2 = new ISession_Curve(SPL2);
2490 aDoc->GetAISContext()->SetDisplayMode(aCurve2,1);
2491 aDoc->GetAISContext()->Display(aCurve2, Standard_False);
2494 PostProcess(aDoc,ID_BUTTON_Test_33,TheDisplayType,Message);
2497 // Function name : GeomSources::gpTest34
2499 // Return type : void
2500 // Argument : CGeometryDoc* aDoc
2501 void GeomSources::gpTest34(CGeometryDoc* aDoc)
2503 DisplayType TheDisplayType = No2D3D;
2504 PreProcess(aDoc,TheDisplayType);
2506 //==============================================================
2508 TColgp_Array1OfPnt array (1,5); // sizing array
2509 array.SetValue(1,gp_Pnt(0,0,1));
2510 array.SetValue(2,gp_Pnt(1,2,2));
2511 array.SetValue(3,gp_Pnt(2,3,3));
2512 array.SetValue(4,gp_Pnt(4,4,4));
2513 array.SetValue(5,gp_Pnt(5,5,5));
2515 GProp_PEquation PE (array,1.5 );
2529 //==============================================================
2530 TCollection_AsciiString Message (" \
2532 TColgp_Array1OfPnt array (1,5); // sizing array \n\
2533 array.SetValue(1,gp_Pnt(0,0,1)); \n\
2534 array.SetValue(2,gp_Pnt(1,2,2)); \n\
2535 array.SetValue(3,gp_Pnt(2,3,3)); \n\
2536 array.SetValue(4,gp_Pnt(4,4,4)); \n\
2537 array.SetValue(5,gp_Pnt(5,5,5)); \n\
2539 GProp_PEquation PE (array,1.5 ); \n\
2541 if (PE.IsPoint()){ /* ... */ } \n\
2543 if (PE.IsLinear()) { L = PE.Line(); } \n\
2544 if (PE.IsPlanar()){ /* ... */ } \n\
2545 if (PE.IsSpace()) { /* ... */ } \n\
2547 AddSeparator(aDoc,Message);
2548 //--------------------------------------------------------------
2549 TCollection_AsciiString aString;
2550 for(Standard_Integer i = array.Lower();i<=array.Upper();i++)
2552 TCollection_AsciiString Message2 (i);
2553 gp_Pnt P = array(i);
2556 aString += Message2;
2557 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
2560 Message += " PE.IsPoint() = ";
2562 Message += "True \n";
2564 Message += "False\n";
2566 if (PE.IsLinear()) {
2567 Message += " PE.IsLinear() = True \n";
2569 Handle(Geom_Line) aLine = new Geom_Line(L);
2570 Handle(Geom_TrimmedCurve) aTrimmedCurve = new Geom_TrimmedCurve(aLine,-10,10);
2571 Handle(ISession_Curve) aCurve = new ISession_Curve(aTrimmedCurve);
2572 aDoc->GetAISContext()->Display(aCurve, Standard_False);
2575 Message += "PE.IsLinear() = False \n";
2577 Message += " PE.IsPlanar() = ";
2579 Message += "True \n";
2581 Message += "False\n";
2583 Message += " PE.IsSpace() = ";
2585 Message += "True \n";
2587 Message += "False\n";
2589 PostProcess(aDoc,ID_BUTTON_Test_34,TheDisplayType,Message);
2592 // Function name : GeomSources::gpTest35
2594 // Return type : void
2595 // Argument : CGeometryDoc* aDoc
2596 void GeomSources::gpTest35(CGeometryDoc* aDoc)
2598 DisplayType TheDisplayType = No2D3D;
2599 PreProcess(aDoc,TheDisplayType);
2601 //==============================================================
2605 Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value();
2608 Standard_Real radius1 = 3;
2609 Standard_Real radius2 = 2;
2610 Handle(Geom_Surface) aSurface =
2611 GC_MakeConicalSurface(P3,P4,radius1,radius2).Value();
2612 GeomAPI_IntCS CS (aCurve,aSurface);
2613 Handle(Geom_Curve) segment;
2615 Standard_Integer NbSeg = 0;
2616 Standard_Integer NbPoints = 0;
2619 NbSeg = CS.NbSegments();
2620 for (Standard_Integer k=1; k<=NbSeg; k++)
2622 segment = CS.Segment(k);
2623 // do something with the segment
2626 NbPoints = CS.NbPoints();
2627 for (int k=1; k<=NbPoints; k++)
2629 gp_Pnt aPoint=CS.Point(k);
2630 // do something with the point
2634 //==============================================================
2635 TCollection_AsciiString Message (" \
2637 gp_Pnt P1(-5,-5,0); \n\
2638 gp_Pnt P2(9,9,9); \n\
2639 Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value(); \n\
2640 gp_Pnt P3(3,0,0); \n\
2641 gp_Pnt P4(3,0,10); \n\
2642 Standard_Real radius1 = 3; \n\
2643 Standard_Real radius2 = 2; \n\
2644 Handle(Geom_Surface) aSurface = \n\
2645 GC_MakeConicalSurface(P3,P4,radius1,radius2).Value(); \n\
2646 GeomAPI_IntCS CS (aCurve,aSurface); \n\
2647 Handle(Geom_Curve) segment; \n\
2649 Standard_Integer NbSeg; \n\
2650 Standard_Integer NbPoints; \n\
2653 NbSeg = CS.NbSegments(); \n\
2654 for (Standard_Integer k=1; k<=NbSeg; k++) \n\
2656 segment = CS.Segment(k); \n\
2657 // do something with the segment \n\
2660 NbPoints = CS.NbPoints(); \n\
2661 for (k=1; k<=NbPoints; k++) \n\
2663 gp_Pnt aPoint=CS.Point(k); \n\
2664 // do something with the point \n\
2668 AddSeparator(aDoc,Message);
2670 //--------------------------------------------------------------
2672 Handle(ISession_Curve) aCurve2 = new ISession_Curve(aCurve);
2673 aDoc->GetAISContext()->Display(aCurve2, Standard_False);
2675 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface= new Geom_RectangularTrimmedSurface(aSurface,-50.,50.,false);
2677 DisplaySurface(aDoc,aTrimmedSurface);
2679 TCollection_AsciiString aString;
2683 NbSeg = CS.NbSegments();
2684 for (k=1; k<=NbSeg; k++)
2686 TCollection_AsciiString Message2 (k);
2687 segment = CS.Segment(k);
2688 aString = "S_";aString += Message2;
2689 Handle(ISession_Curve) aCurveN = new ISession_Curve(segment);
2690 aDoc->GetAISContext()->Display(aCurveN, Standard_False);
2693 for ( k=1; k<=NbPoints; k++)
2695 TCollection_AsciiString Message2 (k);
2696 gp_Pnt aPoint=CS.Point(k);
2697 aString = "P_";aString += Message2;
2698 DisplayPoint(aDoc,aPoint,aString.ToCString(),false,0.5);
2699 // do something with the point
2702 TCollection_AsciiString Message2 (NbSeg);
2703 TCollection_AsciiString Message3 (NbPoints);
2705 Message += "NbSeg = "; Message += Message2 ; Message += "\n";
2706 Message += "NbPoints = "; Message += Message3 ; Message += "\n";
2708 PostProcess(aDoc,ID_BUTTON_Test_35,TheDisplayType,Message);
2711 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2713 // Function name : GeomSources::gpTest36
2715 // Return type : void
2716 // Argument : CGeometryDoc* aDoc
2717 void GeomSources::gpTest36(CGeometryDoc* aDoc)
2719 DisplayType TheDisplayType = No2D3D;
2720 PreProcess(aDoc,TheDisplayType);
2721 //==============================================================
2723 gp_Pnt centre (5,5,0); gp_Pnt axispoint (9,9,0);
2724 Standard_Real radius = 3;
2725 Handle(Geom_Circle) circle =
2726 GC_MakeCircle(centre,axispoint,radius);
2728 Handle(Geom_Geometry) aRotatedEntity = circle->Rotated(gp::OZ(),M_PI/4);
2729 Standard_CString aRotatedEntityTypeName = aRotatedEntity->DynamicType()->Name();
2731 Handle(Geom_Geometry) aMirroredEntity = aRotatedEntity->Mirrored(gp::ZOX());
2732 Standard_CString aMirroredEntityTypeName = aMirroredEntity->DynamicType()->Name();
2734 gp_Pnt scalepoint (4,8,0);
2735 Standard_Real scalefactor = 0.2;
2736 Handle(Geom_Geometry) aScaledEntity =
2737 aMirroredEntity->Scaled(scalepoint, scalefactor);
2738 Standard_CString aScaledEntityTypeName = aScaledEntity->DynamicType()->Name();
2740 Handle (Geom_Transformation) GT = GC_MakeTranslation (centre, scalepoint);
2741 gp_Trsf TR = GT->Trsf();
2743 gp_Vec aTranslationVector(TR.TranslationPart ());
2744 Handle(Geom_Geometry) aTranslatedEntity =
2745 aScaledEntity->Translated( aTranslationVector );
2746 Standard_CString aTranslatedEntityTypeName = aTranslatedEntity->DynamicType()->Name();
2748 gp_Mat matrix = TR.HVectorialPart();
2749 Standard_Real value = matrix.Determinant();
2751 //==============================================================
2752 TCollection_AsciiString Message (" \
2754 gp_Pnt centre (5,5,0); gp_Pnt axispoint (9,9,0); \n\
2755 Standard_Real radius = 3; \n\
2756 Handle(Geom_Circle) circle = \n\
2757 GC_MakeCircle(centre,axispoint,radius); \n\
2759 Handle(Geom_Geometry) aRotatedEntity = circle->Rotated(gp::OZ(),PI/4); \n\
2760 Standard_CString aRotatedEntityTypeName = aRotatedEntity->DynamicType()->Name(); \n\
2762 Handle(Geom_Geometry) aMirroredEntity = aRotatedEntity->Mirrored(gp::ZOX()); \n\
2763 Standard_CString aMirroredEntityTypeName = aMirroredEntity->DynamicType()->Name(); \n\
2765 gp_Pnt scalepoint (4,8,0); \n\
2766 Standard_Real scalefactor = 0.2; \n\
2767 Handle(Geom_Geometry) aScaledEntity = \n\
2768 aMirroredEntity->Scaled(scalepoint, scalefactor); \n\
2769 Standard_CString aScaledEntityTypeName = aScaledEntity->DynamicType()->Name(); \n\
2771 Handle (Geom_Transformation) GT = GC_MakeTranslation (centre, scalepoint); \n\
2772 gp_Trsf TR = GT->Trsf(); \n\
2775 gp_Vec aTranslationVector(TR.TranslationPart ()); \n\
2776 Handle(Geom_Geometry) aTranslatedEntity = \n\
2777 aScaledEntity->Translated( aTranslationVector ); \n\
2778 Standard_CString aTranslatedEntityTypeName = aTranslatedEntity->DynamicType()->Name(); \n\
2780 gp_Mat matrix = TR.HVectorialPart(); \n\
2781 Standard_Real value = matrix.Determinant(); \n\
2783 AddSeparator(aDoc,Message);
2784 //--------------------------------------------------------------
2786 DisplayPoint(aDoc,centre,"centre",false,0.5);
2787 DisplayPoint(aDoc,axispoint,"axispoint",false,0.5);
2788 DisplayPoint(aDoc,scalepoint,"scalepoint",false,0.5);
2790 DisplayCurve(aDoc,circle, Quantity_NOC_RED,false);
2791 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aRotatedEntity),Quantity_NOC_PEACHPUFF, false);
2792 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aMirroredEntity), Quantity_NOC_YELLOWGREEN,false);
2793 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aScaledEntity), Quantity_NOC_GREEN,false);
2794 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aTranslatedEntity),Quantity_NOC_WHITE,false);
2796 TCollection_AsciiString Message0 (M_PI);
2797 Message += " PI = ";
2800 Message += " circle is Red; aRotatedEntity is Peach; aMirroredEntity is Yellow Green\n";
2801 Message += " aScaleEntity is Green; aTranslatedEntity is White\n\n";
2803 TCollection_AsciiString Message2 (aTranslationVector.X());
2804 TCollection_AsciiString Message3 (aTranslationVector.Y());
2805 TCollection_AsciiString Message4 (aTranslationVector.Z());
2806 Message += " aTranslationVector ( ";
2807 Message += Message2; Message += " , ";
2808 Message += Message3; Message += " , ";
2809 Message += Message4; Message += " ); \n";
2811 TCollection_AsciiString Message5 (value);
2812 Message += " value = ";Message+= Message5; Message += "\n";
2814 TCollection_AsciiString Message6 (aRotatedEntityTypeName);
2815 TCollection_AsciiString Message7 (aMirroredEntityTypeName);
2816 TCollection_AsciiString Message8 (aScaledEntityTypeName);
2817 TCollection_AsciiString Message9 (aTranslatedEntityTypeName);
2819 Message += " aRotatedEntityTypeName = ";Message+= Message6; Message += "\n";
2820 Message += " aMirroredEntityTypeName = ";Message+= Message7; Message += "\n";
2821 Message += " aScaledEntityTypeName = ";Message+= Message8; Message += "\n";
2822 Message += " aTranslatedEntityTypeName = ";Message+= Message9; Message += "\n";
2824 PostProcess(aDoc,ID_BUTTON_Test_36,TheDisplayType,Message);
2827 // Function name : GeomSources::gpTest37
2829 // Return type : void
2830 // Argument : CGeometryDoc* aDoc
2831 void GeomSources::gpTest37(CGeometryDoc* aDoc)
2833 DisplayType TheDisplayType = No2D3D;
2834 PreProcess(aDoc,TheDisplayType);
2835 //==============================================================
2837 TColgp_Array1OfPnt anArrayofPnt (1,5); // sizing array
2838 anArrayofPnt.SetValue(1,gp_Pnt(0,0,1));
2839 anArrayofPnt.SetValue(2,gp_Pnt(1,2,2));
2840 anArrayofPnt.SetValue(3,gp_Pnt(2,3,3));
2841 anArrayofPnt.SetValue(4,gp_Pnt(4,3,4));
2842 anArrayofPnt.SetValue(5,gp_Pnt(5,5,5));
2844 Standard_Real Tolerance = 1;
2847 GProp_PEquation PE (anArrayofPnt,Tolerance);
2848 if (PE.IsPlanar()) { P = PE.Plane();}
2850 if (PE.IsPoint()) { /* ... */ }
2851 if (PE.IsLinear()) { /* ... */ }
2852 if (PE.IsPlanar()) { P = PE.Plane();}
2853 if (PE.IsSpace()) { /* ... */ }
2855 //==============================================================
2856 TCollection_AsciiString Message (" \
2858 TColgp_Array1OfPnt anArrayofPnt (1,5); // sizing array \n\
2859 anArrayofPnt.SetValue(1,gp_Pnt(0,0,1)); \n\
2860 anArrayofPnt.SetValue(2,gp_Pnt(1,2,2)); \n\
2861 anArrayofPnt.SetValue(3,gp_Pnt(2,3,3)); \n\
2862 anArrayofPnt.SetValue(4,gp_Pnt(4,3,4)); \n\
2863 anArrayofPnt.SetValue(5,gp_Pnt(5,5,5)); \n\
2865 Standard_Real Tolerance = 1; \n\
2868 GProp_PEquation PE (anArrayofPnt,Tolerance); \n\
2869 if (PE.IsPlanar()) { P = PE.Plane();} \n\
2871 if (PE.IsPoint()) { /* ... */ } \n\
2872 if (PE.IsLinear()) { /* ... */ } \n\
2873 if (PE.IsPlanar()) { P = PE.Plane();} \n\
2874 if (PE.IsSpace()) { /* ... */ } \n\
2876 AddSeparator(aDoc,Message);
2877 //--------------------------------------------------------------
2879 TCollection_AsciiString aString;
2880 for(Standard_Integer i = anArrayofPnt.Lower();i<=anArrayofPnt.Upper();i++){
2881 TCollection_AsciiString Message2(i);
2882 gp_Pnt aP = anArrayofPnt(i);
2884 aString += Message2;
2885 DisplayPoint(aDoc,aP,aString.ToCString(),false,0.5);
2888 Message += " PE.IsPoint() = "; if (PE.IsPoint()) Message += "True \n"; else Message += "False\n";
2889 Message += " PE.IsLinear() = "; if (PE.IsLinear()) Message += "True \n"; else Message += "False\n";
2891 if (PE.IsPlanar()) {
2892 Message += " PE.IsPlanar() = True \n";
2894 Handle(Geom_Plane) aPlane = new Geom_Plane(P);
2895 Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-4.,4.,-4.,4.);
2897 DisplaySurface(aDoc,aSurface);
2901 Message += " PE.IsPlanar() = False \n";
2903 Message += " PE.IsSpace() = "; if (PE.IsSpace() ) Message += "True \n"; else Message += "False\n";
2905 PostProcess(aDoc,ID_BUTTON_Test_37,TheDisplayType,Message);
2908 void GeomSources::gpTest38(CGeometryDoc* aDoc)
2910 DisplayType TheDisplayType = No2D3D;
2911 PreProcess(aDoc,TheDisplayType);
2912 //==============================================================
2914 TColgp_Array1OfPnt array1 (1,5); // sizing array
2915 array1.SetValue(1,gp_Pnt (-4,0,2 )); array1.SetValue(2,gp_Pnt (-7,2,2 ));
2916 array1.SetValue(3,gp_Pnt (-6,3,1 )); array1.SetValue(4,gp_Pnt (-4,3,-1));
2917 array1.SetValue(5,gp_Pnt (-3,5,-2));
2918 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();
2920 TColgp_Array1OfPnt array2 (1,5); // sizing array
2921 array2.SetValue(1,gp_Pnt (-4,0, 2)); array2.SetValue(2,gp_Pnt (-2,2,0 ));
2922 array2.SetValue(3,gp_Pnt (2 ,3,-1)); array2.SetValue(4,gp_Pnt (3 ,7,-2));
2923 array2.SetValue(5,gp_Pnt (4 ,9,-1));
2924 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();
2926 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
2927 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
2928 Handle(Geom_BSplineSurface) aBSplineSurface1 = aGeomFill1.Surface();
2930 Type = GeomFill_CoonsStyle;
2931 GeomFill_BSplineCurves aGeomFill2(
2932 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(10,0,0))),
2933 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(10,0,0))),Type);
2934 Handle(Geom_BSplineSurface) aBSplineSurface2 = aGeomFill2.Surface();
2935 Type = GeomFill_CurvedStyle;
2936 GeomFill_BSplineCurves aGeomFill3(
2937 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(20,0,0))),
2938 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(20,0,0))),Type);
2939 Handle(Geom_BSplineSurface) aBSplineSurface3 = aGeomFill3.Surface();
2941 //==============================================================
2942 TCollection_AsciiString Message (" \
2944 TColgp_Array1OfPnt array1 (1,5); // sizing array \n\
2945 array1.SetValue(1,gp_Pnt (-4,0,2 )); array1.SetValue(2,gp_Pnt (-7,2,2 )); \n\
2946 array1.SetValue(3,gp_Pnt (-6,3,1 )); array1.SetValue(4,gp_Pnt (-4,3,-1)); \n\
2947 array1.SetValue(5,gp_Pnt (-3,5,-2)); \n\
2948 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve(); \n\
2950 TColgp_Array1OfPnt array2 (1,5); // sizing array \n\
2951 array2.SetValue(1,gp_Pnt (-4,0, 2)); array2.SetValue(2,gp_Pnt (-2,2,0 )); \n\
2952 array2.SetValue(3,gp_Pnt (2 ,3,-1)); array2.SetValue(4,gp_Pnt (3 ,7,-2)); \n\
2953 array2.SetValue(5,gp_Pnt (4 ,9,-1)); \n\
2954 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve(); \n\
2956 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
2957 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
2958 Handle(Geom_BSplineSurface) aBSplineSurface1 = aGeomFill1.Surface(); \n\
2960 Type = GeomFill_CoonsStyle; \n\
2961 GeomFill_BSplineCurves aGeomFill2( \n");
2963 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(10,0,0))), \n\
2964 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(10,0,0))),Type); \n\
2965 Handle(Geom_BSplineSurface) aBSplineSurface2 = aGeomFill2.Surface(); \n\
2966 Type = GeomFill_CurvedStyle; \n\
2967 GeomFill_BSplineCurves aGeomFill3( \n\
2968 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(20,0,0))), \n\
2969 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(20,0,0))),Type); \n\
2970 Handle(Geom_BSplineSurface) aBSplineSurface3 = aGeomFill3.Surface(); \n\
2972 AddSeparator(aDoc,Message);
2973 //--------------------------------------------------------------
2975 // Trace des frontieres. -> FreeBoundaryAspect
2976 // Trace des isoparametriques. --> UIsoAspect()
2978 DisplaySurface(aDoc,aBSplineSurface1,Quantity_NOC_YELLOW);
2979 DisplaySurface(aDoc,aBSplineSurface2,Quantity_NOC_SALMON);
2980 DisplaySurface(aDoc,aBSplineSurface3,Quantity_NOC_HOTPINK);
2982 for (int i=0;i<=2;i++)
2984 DisplayCurve(aDoc,Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(i*10,0,0))), Quantity_NOC_RED,false);
2985 DisplayCurve(aDoc,Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(i*10,0,0))), Quantity_NOC_GREEN,false);
2988 Message += "SPL1 is Red; \n";
2989 Message += "SPL2 is Green; \n";
2990 Message += "aBSplineSurface1 is Yellow; ( GeomFill_StretchStyle )\n";
2991 Message += "aBSplineSurface2 is Salmon; ( GeomFill_CoonsStyle ) \n";
2992 Message += "aBSplineSurface3 is Hot pink; ( GeomFill_CurvedStyle ) \n";
2994 PostProcess(aDoc,ID_BUTTON_Test_38,TheDisplayType,Message);
2996 void GeomSources::gpTest39(CGeometryDoc* aDoc)
2998 DisplayType TheDisplayType = No2D3D;
2999 PreProcess(aDoc,TheDisplayType);
3000 //==============================================================
3002 TColgp_Array1OfPnt array1 (1,5); // sizing array
3003 array1.SetValue(1,gp_Pnt (-4,0,2 ));
3004 array1.SetValue(2,gp_Pnt (-5,1,0 ));
3005 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3006 array1.SetValue(4,gp_Pnt (-5,4,-7));
3007 array1.SetValue(5,gp_Pnt (-3,5,-12));
3009 TColgp_Array1OfPnt array2 (1,5); // sizing array
3010 array2.SetValue(1,gp_Pnt (-4,0, 2));
3011 array2.SetValue(2,gp_Pnt (-3,2,1 ));
3012 array2.SetValue(3,gp_Pnt (-1,5,0));
3013 array2.SetValue(4,gp_Pnt (2 ,7,-1));
3014 array2.SetValue(5,gp_Pnt (4 ,9,-1));
3016 TColgp_Array1OfPnt array3 (1,4); // sizing array
3017 array3.SetValue(1,gp_Pnt (-3,5, -12));
3018 array3.SetValue(2,gp_Pnt (-2,6,-7 ));
3019 array3.SetValue(3,gp_Pnt (0 ,8,-3));
3020 array3.SetValue(4,gp_Pnt (4 ,9,-1));
3022 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();
3023 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();
3024 Handle(Geom_BSplineCurve) SPL3 = GeomAPI_PointsToBSpline(array3).Curve();
3026 Handle(GeomAdaptor_HCurve) SPL1Adaptor = new GeomAdaptor_HCurve(SPL1);
3027 Handle(GeomFill_SimpleBound) B1 =
3028 new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular());
3029 Handle(GeomAdaptor_HCurve) SPL2Adaptor = new GeomAdaptor_HCurve(SPL2);
3030 Handle(GeomFill_SimpleBound) B2 =
3031 new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular());
3032 Handle(GeomAdaptor_HCurve) SPL3Adaptor = new GeomAdaptor_HCurve(SPL3);
3033 Handle(GeomFill_SimpleBound) B3 =
3034 new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular());
3035 Standard_Boolean NoCheck= Standard_False;
3037 Standard_Integer MaxDeg = 8;
3038 Standard_Integer MaxSeg = 2;
3039 GeomFill_ConstrainedFilling aConstrainedFilling(MaxDeg, MaxSeg);
3041 aConstrainedFilling.Init(B1,B2,B3,NoCheck);
3043 Handle(Geom_BSplineSurface) aBSplineSurface = aConstrainedFilling.Surface();
3045 //==============================================================
3046 TCollection_AsciiString Message (" \
3048 TColgp_Array1OfPnt array1 (1,5); // sizing array \n\
3050 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve(); \n\
3051 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve(); \n\
3052 Handle(Geom_BSplineCurve) SPL3 = GeomAPI_PointsToBSpline(array3).Curve(); \n\
3054 Handle(GeomAdaptor_HCurve) SPL1Adaptor = new GeomAdaptor_HCurve(SPL1); \n\
3055 Handle(GeomFill_SimpleBound) B1 = \n\
3056 new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular()); \n\
3057 Handle(GeomAdaptor_HCurve) SPL2Adaptor = new GeomAdaptor_HCurve(SPL2); \n\
3058 Handle(GeomFill_SimpleBound) B2 = \n\
3059 new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular()); \n\
3060 Handle(GeomAdaptor_HCurve) SPL3Adaptor = new GeomAdaptor_HCurve(SPL3); \n\
3061 Handle(GeomFill_SimpleBound) B3 = \n\
3062 new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular()); \n\
3063 Standard_Boolean NoCheck= Standard_False; \n\
3065 Standard_Integer MaxDeg = 8; \n");
3067 Standard_Integer MaxSeg = 2; \n\
3068 GeomFill_ConstrainedFilling aConstrainedFilling(MaxDeg, MaxSeg); \n\
3070 aConstrainedFilling.Init(B1,B2,B3,NoCheck); \n\
3072 Handle(Geom_BSplineSurface) aBSplineSurface = aConstrainedFilling.Surface(); \n\
3074 AddSeparator(aDoc,Message);
3075 //--------------------------------------------------------------
3077 TCollection_AsciiString aString;
3079 DisplaySurface(aDoc,aBSplineSurface,Quantity_NOC_YELLOW);
3080 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3081 DisplayCurve(aDoc,SPL2,Quantity_NOC_GREEN ,false);
3082 DisplayCurve(aDoc,SPL3,Quantity_NOC_BLUE1 ,false);
3084 Message += "SPL1 is Red; \n";
3085 Message += "SPL2 is Green; \n";
3086 Message += "SPL3 is Blue; \n";
3088 Message += "aBSplineSurface is Yellow; \n";
3090 PostProcess(aDoc,ID_BUTTON_Test_39,TheDisplayType,Message);
3093 void GeomSources::gpTest40(CGeometryDoc* aDoc)
3095 DisplayType TheDisplayType = No2D3D;
3096 PreProcess(aDoc,TheDisplayType);
3097 //==============================================================
3099 TColgp_Array1OfPnt array1 (1,5); // sizing array
3100 array1.SetValue(1,gp_Pnt (-4,0,2 ));
3101 array1.SetValue(2,gp_Pnt (-5,1,0 ));
3102 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3103 array1.SetValue(4,gp_Pnt (-5,4,-7));
3104 array1.SetValue(5,gp_Pnt (-3,5,-12));
3106 Handle(Geom_Curve) SPL1 =
3107 GeomAPI_PointsToBSpline(array1).Curve();
3109 GeomFill_Pipe aPipe(SPL1,1);
3111 Handle(Geom_Surface) aSurface= aPipe.Surface();
3112 Standard_CString aSurfaceEntityTypeName="Not Computed";
3113 if (!aSurface.IsNull())
3114 aSurfaceEntityTypeName = aSurface->DynamicType()->Name();
3116 Handle(Geom_Ellipse) E = GC_MakeEllipse( gp::XOY() ,3,1).Value();
3117 GeomFill_Pipe aPipe2(SPL1,E);
3119 Handle(Geom_Surface) aSurface2= aPipe2.Surface();
3120 Standard_CString aSurfaceEntityTypeName2="Not Computed";
3121 if (!aSurface2.IsNull()) {
3122 aSurfaceEntityTypeName2 = aSurface2->DynamicType()->Name();
3123 aSurface2->Translate(gp_Vec(5,0,0)); }
3125 Handle(Geom_TrimmedCurve) TC1 =
3126 GC_MakeSegment(gp_Pnt(1,1,1),gp_Pnt(5,5,5));
3127 Handle(Geom_TrimmedCurve) TC2 =
3128 GC_MakeSegment(gp_Pnt(1,1,0),gp_Pnt(4,5,6));
3129 GeomFill_Pipe aPipe3(SPL1,TC1,TC2);
3131 Handle(Geom_Surface) aSurface3 = aPipe3.Surface();
3132 Standard_CString aSurfaceEntityTypeName3="Not Computed";
3133 if (!aSurface3.IsNull())
3135 aSurfaceEntityTypeName3 = aSurface3->DynamicType()->Name();
3136 aSurface3->Translate(gp_Vec(10,0,0));
3139 //==============================================================
3140 TCollection_AsciiString Message (" \
3143 TColgp_Array1OfPnt array1 (1,5); // sizing array \n\
3144 array1.SetValue(1,gp_Pnt (-4,0,2 )); \n\
3145 array1.SetValue(2,gp_Pnt (-5,1,0 )); \n\
3146 array1.SetValue(3,gp_Pnt (-6,2,-2 )); \n\
3147 array1.SetValue(4,gp_Pnt (-5,4,-7)); \n\
3148 array1.SetValue(5,gp_Pnt (-3,5,-12)); \n\
3150 Handle(Geom_BSplineCurve) SPL1 = \n\
3151 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3153 GeomFill_Pipe aPipe(SPL1,1); \n\
3154 aPipe.Perform(); \n\
3155 Handle(Geom_Surface) aSurface= aPipe.Surface(); \n\
3156 Standard_CString aSurfaceEntityTypeName=\"Not Computed\"; \n\
3157 if (!aSurface.IsNull()) \n\
3158 aSurfaceEntityTypeName = aSurface->DynamicType()->Name(); \n\
3160 Handle(Geom_Ellipse) E = GC_MakeEllipse( gp::XOY() ,3,1).Value(); \n\
3161 GeomFill_Pipe aPipe2(SPL1,E); \n\
3162 aPipe2.Perform(); \n");
3164 Handle(Geom_Surface) aSurface2= aPipe2.Surface(); \n\
3165 Standard_CString aSurfaceEntityTypeName2=\"Not Computed\"; \n\
3166 if (!aSurface2.IsNull()) { \n\
3167 aSurfaceEntityTypeName2 = aSurface2->DynamicType()->Name(); \n\
3168 aSurface2->Translate(gp_Vec(5,0,0)); } \n\
3170 Handle(Geom_TrimmedCurve) TC1 = \n\
3171 GC_MakeSegment(gp_Pnt(1,1,1),gp_Pnt(5,5,5)); \n\
3172 Handle(Geom_TrimmedCurve) TC2 = \n\
3173 GC_MakeSegment(gp_Pnt(1,1,0),gp_Pnt(4,5,6)); \n\
3174 GeomFill_Pipe aPipe3(SPL1,TC1,TC2); \n\
3175 aPipe3.Perform(); \n\
3176 Handle(Geom_Surface) aSurface3 = aPipe3.Surface(); \n\
3177 Standard_CString aSurfaceEntityTypeName3=\"Not Computed\"; \n\
3178 if (!aSurface3.IsNull()) \n\
3180 aSurfaceEntityTypeName3 = aSurface3->DynamicType()->Name(); \n\
3181 aSurface3->Translate(gp_Vec(10,0,0)); \n\
3184 AddSeparator(aDoc,Message);
3185 //--------------------------------------------------------------
3187 if (!aSurface.IsNull())
3189 DisplaySurface(aDoc,aSurface,Quantity_NOC_YELLOW);
3191 if (!aSurface2.IsNull())
3193 DisplaySurface(aDoc,aSurface2,Quantity_NOC_YELLOW);
3195 if (!aSurface3.IsNull())
3197 DisplaySurface(aDoc,aSurface3,Quantity_NOC_YELLOW);
3200 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3202 Message += "SPL1 is Red; \n";
3205 TCollection_AsciiString Message2(aSurfaceEntityTypeName);
3206 TCollection_AsciiString Message3(aSurfaceEntityTypeName2);
3207 TCollection_AsciiString Message4(aSurfaceEntityTypeName3);
3209 Message += " aSurfaceEntityTypeName = ";Message+= Message2; Message += "\n";
3210 Message += " aSurfaceEntityTypeName2 = ";Message+= Message3; Message += "\n";
3211 Message += " aSurfaceEntityTypeName3 = ";Message+= Message4; Message += "\n";
3213 PostProcess(aDoc,ID_BUTTON_Test_40,TheDisplayType,Message);
3216 void GeomSources::gpTest41(CGeometryDoc* aDoc)
3218 DisplayType TheDisplayType = No2D3D;
3219 PreProcess(aDoc,TheDisplayType);
3220 //==============================================================
3222 TColgp_Array1OfPnt array1 (1,5);
3223 array1.SetValue(1,gp_Pnt (-4,0,2 ));
3224 array1.SetValue(2,gp_Pnt (-5,1,0 ));
3225 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3226 array1.SetValue(4,gp_Pnt (-5,4,-7));
3227 array1.SetValue(5,gp_Pnt (-3,5,-12));
3229 Handle(Geom_BSplineCurve) SPL1 =
3230 GeomAPI_PointsToBSpline(array1).Curve();
3231 Handle(Geom_Curve) FirstSect =
3232 GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value();
3234 GeomFill_Pipe aPipe(SPL1,FirstSect);
3237 Handle(Geom_BSplineSurface) aPipeSurface =
3238 Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface());
3239 Handle(Geom_BSplineSurface) anotherBSplineSurface =
3240 GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6);
3242 //==============================================================
3243 TCollection_AsciiString Message (" \
3245 TColgp_Array1OfPnt array1 (1,5); \n\
3246 array1.SetValue(1,gp_Pnt (-4,0,2 )); \n\
3247 array1.SetValue(2,gp_Pnt (-5,1,0 )); \n\
3248 array1.SetValue(3,gp_Pnt (-6,2,-2 )); \n\
3249 array1.SetValue(4,gp_Pnt (-5,4,-7)); \n\
3250 array1.SetValue(5,gp_Pnt (-3,5,-12)); \n\
3252 Handle(Geom_BSplineCurve) SPL1 = \n\
3253 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3254 Handle(Geom_Curve) FirstSect = \n\
3255 GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value(); \n\
3257 GeomFill_Pipe aPipe(SPL1,FirstSect); \n\
3258 aPipe.Perform(); \n\
3260 Handle(Geom_BSplineSurface) aPipeSurface = \n\
3261 Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface()); \n\
3262 Handle(Geom_BSplineSurface) anotherBSplineSurface = \n\
3263 GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6); \n\
3265 AddSeparator(aDoc,Message);
3266 //--------------------------------------------------------------
3268 if(!aPipeSurface.IsNull())
3270 DisplaySurface(aDoc,aPipeSurface,Quantity_NOC_YELLOW);
3273 if(!anotherBSplineSurface.IsNull())
3275 DisplaySurface(aDoc,anotherBSplineSurface,Quantity_NOC_HOTPINK);
3278 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3279 DisplayCurve(aDoc,FirstSect,Quantity_NOC_GREEN ,false);
3281 Message += "SPL1 is Red; \n";
3282 Message += "SPL2 is Green; \n";
3283 Message += "SPL3 is Blue; \n";
3284 Message += "aBSplineSurface is Yellow; \n";
3285 Message += "anotherBSplineSurface is Hot Pink; \n";
3287 PostProcess(aDoc,ID_BUTTON_Test_41,TheDisplayType,Message);
3291 void GeomSources::gpTest42(CGeometryDoc* aDoc)
3293 DisplayType TheDisplayType = No2D3D;
3294 PreProcess(aDoc,TheDisplayType);
3296 //==============================================================
3298 TColgp_Array2OfPnt array1(1,3,1,3);
3299 TColgp_Array2OfPnt array2(1,3,1,3);
3300 TColgp_Array2OfPnt array3(1,3,1,3);
3301 TColgp_Array2OfPnt array4(1,3,1,3);
3303 array1.SetValue(1,1,gp_Pnt(1,1,1));
3304 array1.SetValue(1,2,gp_Pnt(2,1,2));
3305 array1.SetValue(1,3,gp_Pnt(3,1,1));
3306 array1.SetValue(2,1,gp_Pnt(1,2,1));
3307 array1.SetValue(2,2,gp_Pnt(2,2,2));
3308 array1.SetValue(2,3,gp_Pnt(3,2,0));
3309 array1.SetValue(3,1,gp_Pnt(1,3,2));
3310 array1.SetValue(3,2,gp_Pnt(2,3,1));
3311 array1.SetValue(3,3,gp_Pnt(3,3,0));
3313 array2.SetValue(1,1,gp_Pnt(3,1,1));
3314 array2.SetValue(1,2,gp_Pnt(4,1,1));
3315 array2.SetValue(1,3,gp_Pnt(5,1,2));
3316 array2.SetValue(2,1,gp_Pnt(3,2,0));
3317 array2.SetValue(2,2,gp_Pnt(4,2,1));
3318 array2.SetValue(2,3,gp_Pnt(5,2,2));
3319 array2.SetValue(3,1,gp_Pnt(3,3,0));
3320 array2.SetValue(3,2,gp_Pnt(4,3,0));
3321 array2.SetValue(3,3,gp_Pnt(5,3,1));
3323 array3.SetValue(1,1,gp_Pnt(1,3,2));
3324 array3.SetValue(1,2,gp_Pnt(2,3,1));
3325 array3.SetValue(1,3,gp_Pnt(3,3,0));
3326 array3.SetValue(2,1,gp_Pnt(1,4,1));
3327 array3.SetValue(2,2,gp_Pnt(2,4,0));
3328 array3.SetValue(2,3,gp_Pnt(3,4,1));
3329 array3.SetValue(3,1,gp_Pnt(1,5,1));
3330 array3.SetValue(3,2,gp_Pnt(2,5,1));
3331 array3.SetValue(3,3,gp_Pnt(3,5,2));
3333 array4.SetValue(1,1,gp_Pnt(3,3,0));
3334 array4.SetValue(1,2,gp_Pnt(4,3,0));
3335 array4.SetValue(1,3,gp_Pnt(5,3,1));
3336 array4.SetValue(2,1,gp_Pnt(3,4,1));
3337 array4.SetValue(2,2,gp_Pnt(4,4,1));
3338 array4.SetValue(2,3,gp_Pnt(5,4,1));
3339 array4.SetValue(3,1,gp_Pnt(3,5,2));
3340 array4.SetValue(3,2,gp_Pnt(4,5,2));
3341 array4.SetValue(3,3,gp_Pnt(5,5,1));
3343 Handle(Geom_BezierSurface) BZ1 =
3344 new Geom_BezierSurface(array1);
3345 Handle(Geom_BezierSurface) BZ2 =
3346 new Geom_BezierSurface(array2);
3347 Handle(Geom_BezierSurface) BZ3 =
3348 new Geom_BezierSurface(array3);
3349 Handle(Geom_BezierSurface) BZ4 =
3350 new Geom_BezierSurface(array4);
3352 TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2);
3353 bezierarray.SetValue(1,1,BZ1);
3354 bezierarray.SetValue(1,2,BZ2);
3355 bezierarray.SetValue(2,1,BZ3);
3356 bezierarray.SetValue(2,2,BZ4);
3358 GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray);
3359 Handle(Geom_BSplineSurface) BSPLSURF ;
3362 BSPLSURF = new Geom_BSplineSurface(
3363 BB.Poles()->Array2(),
3364 BB.UKnots()->Array1(),
3365 BB.VKnots()->Array1(),
3366 BB.UMultiplicities()->Array1(),
3367 BB.VMultiplicities()->Array1(),
3370 BSPLSURF->Translate(gp_Vec(0,0,2));
3373 //==============================================================
3375 TCollection_AsciiString Message (" \
3377 TColgp_Array2OfPnt array1(1,3,1,3); \n\
3378 TColgp_Array2OfPnt array2(1,3,1,3); \n\
3379 TColgp_Array2OfPnt array3(1,3,1,3); \n\
3380 TColgp_Array2OfPnt array4(1,3,1,3); \n\
3382 // array1.SetValue( ... \n\
3384 Handle(Geom_BezierSurface) BZ1 = \n\
3385 new Geom_BezierSurface(array1); \n\
3386 Handle(Geom_BezierSurface) BZ2 = \n\
3387 new Geom_BezierSurface(array2); \n\
3388 Handle(Geom_BezierSurface) BZ3 = \n\
3389 new Geom_BezierSurface(array3); \n\
3390 Handle(Geom_BezierSurface) BZ4 = \n\
3391 new Geom_BezierSurface(array4); \n\
3393 TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2); \n\
3394 bezierarray.SetValue(1,1,BZ1); \n\
3395 bezierarray.SetValue(1,2,BZ2); \n\
3396 bezierarray.SetValue(2,1,BZ3); \n\
3397 bezierarray.SetValue(2,2,BZ4); \n\
3399 GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray); \n\
3400 Handle(Geom_BSplineSurface) BSPLSURF ; \n\
3401 if (BB.IsDone()){ \n\
3402 BSPLSURF = new Geom_BSplineSurface( \n\
3403 BB.Poles()->Array2(), \n\
3404 BB.UKnots()->Array1(), \n");
3406 BB.VKnots()->Array1(), \n\
3407 BB.UMultiplicities()->Array1(), \n\
3408 BB.VMultiplicities()->Array1(), \n\
3411 BSPLSURF->Translate(gp_Vec(0,0,2)); \n\
3414 AddSeparator(aDoc,Message);
3415 //--------------------------------------------------------------
3417 DisplaySurface(aDoc,BZ1,Quantity_NOC_RED);
3418 DisplaySurface(aDoc,BZ2,Quantity_NOC_GREEN);
3419 DisplaySurface(aDoc,BZ3,Quantity_NOC_BLUE1);
3420 DisplaySurface(aDoc,BZ4,Quantity_NOC_BROWN);
3423 DisplaySurface(aDoc,BSPLSURF,Quantity_NOC_HOTPINK);
3426 Message += "BZ1 is Red; \n";
3427 Message += "BZ2 is Green; \n";
3428 Message += "BZ3 is Blue; \n";
3429 Message += "BZ4 is Brown; \n";
3430 Message += "BSPLSURF is Hot Pink; \n";
3432 PostProcess(aDoc,ID_BUTTON_Test_42,TheDisplayType,Message);
3435 void GeomSources::gpTest43(CGeometryDoc* aDoc)
3437 DisplayType TheDisplayType = No2D3D;
3438 PreProcess(aDoc,TheDisplayType);
3439 //==============================================================
3441 TColgp_Array1OfPnt array1 (1,5);
3442 array1.SetValue(1,gp_Pnt (-4,5,5 ));
3443 array1.SetValue(2,gp_Pnt (-3,6,6 ));
3444 array1.SetValue(3,gp_Pnt (-1,7,7 ));
3445 array1.SetValue(4,gp_Pnt (0,8,8));
3446 array1.SetValue(5,gp_Pnt (2,9,9));
3447 Handle(Geom_BSplineCurve) SPL1 =
3448 GeomAPI_PointsToBSpline(array1).Curve();
3450 TColgp_Array1OfPnt array2 (1,5);
3451 array2.SetValue(1,gp_Pnt (-4,5,2 ));
3452 array2.SetValue(2,gp_Pnt (-3,6,3 ));
3453 array2.SetValue(3,gp_Pnt (-1,7,4 ));
3454 array2.SetValue(4,gp_Pnt (0,8,5));
3455 array2.SetValue(5,gp_Pnt (2,9,6));
3456 Handle(Geom_BSplineCurve) SPL2 =
3457 GeomAPI_PointsToBSpline(array2).Curve();
3459 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3460 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3461 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3462 Standard_Real offset = 1;
3463 Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset);
3465 Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset);
3467 Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset);
3469 //==============================================================
3470 TCollection_AsciiString Message (" \
3472 TColgp_Array1OfPnt array1 (1,5); \n\
3473 //array1.SetValue( ... \n\
3474 Handle(Geom_BSplineCurve) SPL1 = \n\
3475 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3477 TColgp_Array1OfPnt array2 (1,5); \n\
3478 // array2.SetValue( ... \n\
3480 Handle(Geom_BSplineCurve) SPL2 = \n\
3481 GeomAPI_PointsToBSpline(array2).Curve(); \n\
3483 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3484 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3485 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface(); \n\
3486 Standard_Real offset = 1; \n\
3487 Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3489 Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3491 Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3493 AddSeparator(aDoc,Message);
3494 //--------------------------------------------------------------
3496 DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_BLUE1);
3497 DisplaySurface(aDoc,GOS,Quantity_NOC_GREEN);
3498 DisplaySurface(aDoc,GOS1,Quantity_NOC_GREEN);
3499 DisplaySurface(aDoc,GOS2,Quantity_NOC_GREEN);
3501 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3502 DisplayCurve(aDoc,SPL2,Quantity_NOC_HOTPINK ,false);
3504 Message += "aGeomSurface is Blue; \n";
3505 Message += "GOS are Green; \n";
3507 PostProcess(aDoc,ID_BUTTON_Test_43,TheDisplayType,Message);
3510 void GeomSources::gpTest44(CGeometryDoc* aDoc)
3512 DisplayType TheDisplayType = No2D3D;
3513 PreProcess(aDoc,TheDisplayType);
3514 //==============================================================
3521 TColgp_Array1OfPnt array (1,5);
3522 array.SetValue(1,P1);
3523 array.SetValue(2,P2);
3524 array.SetValue(3,P3);
3525 array.SetValue(4,P4);
3526 array.SetValue(5,P5);
3527 Handle(Geom_BSplineCurve) aCurve =
3528 GeomAPI_PointsToBSpline(array).Curve();
3530 Handle(Geom_SurfaceOfLinearExtrusion) SOLE =
3531 new Geom_SurfaceOfLinearExtrusion(aCurve,aDir);
3533 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface =
3534 new Geom_RectangularTrimmedSurface(SOLE,-10,10,false);
3536 Standard_CString SOLEEntityTypeName="Not Computed";
3539 SOLEEntityTypeName = SOLE->DynamicType()->Name();
3542 //==============================================================
3544 TCollection_AsciiString Message (" \
3546 gp_Pnt P1(0,0,1); \n\
3547 gp_Pnt P2(1,2,2); \n\
3548 gp_Pnt P3(2,3,3); \n\
3549 gp_Pnt P4(4,3,4); \n\
3550 gp_Pnt P5(5,5,5); \n\
3551 TColgp_Array1OfPnt array (1,5); \n\
3552 array.SetValue(1,P1); \n\
3553 array.SetValue(2,P2); \n\
3554 array.SetValue(3,P3); \n\
3555 array.SetValue(4,P4); \n\
3556 array.SetValue(5,P5); \n\
3557 Handle(Geom_BSplineCurve) aCurve = \n\
3558 GeomAPI_PointsToBSpline(array).Curve(); \n\
3559 gp_Dir aDir(1,2,3); \n\
3560 Handle(Geom_SurfaceOfLinearExtrusion) SOLE = \n\
3561 new Geom_SurfaceOfLinearExtrusion(aCurve,aDir); \n\
3563 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface = \n\
3564 new Geom_RectangularTrimmedSurface(SOLE,-10,10,false); \n\
3566 Standard_CString SOLEEntityTypeName=\"Not Computed\"; \n\
3567 if (!SOLE.IsNull()) \n\
3569 SOLEEntityTypeName = SOLE->DynamicType()->Name(); \n\
3572 AddSeparator(aDoc,Message);
3573 //--------------------------------------------------------------
3575 DisplaySurface(aDoc,aTrimmedSurface,Quantity_NOC_GREEN);
3576 DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
3578 Message += "aCurve is Red; \n";
3579 Message += "aTrimmedSurface is Green; \n";
3581 TCollection_AsciiString Message2 (SOLEEntityTypeName);
3583 Message += " SOLEEntityTypeName = ";Message+= Message2; Message += "\n";
3585 PostProcess(aDoc,ID_BUTTON_Test_44,TheDisplayType,Message);
3588 void GeomSources::gpTest45(CGeometryDoc* aDoc)
3590 DisplayType TheDisplayType = No2D3D;
3591 PreProcess(aDoc,TheDisplayType);
3593 //==============================================================
3595 TColgp_Array1OfPnt array (1,5);
3596 array.SetValue(1,gp_Pnt (0,0,1));
3597 array.SetValue(2,gp_Pnt (1,2,2));
3598 array.SetValue(3,gp_Pnt (2,3,3));
3599 array.SetValue(4,gp_Pnt (4,3,4));
3600 array.SetValue(5,gp_Pnt (5,5,5));
3601 Handle(Geom_BSplineCurve) aCurve =
3602 GeomAPI_PointsToBSpline(array).Curve();
3603 Handle(Geom_SurfaceOfRevolution) SOR =
3604 new Geom_SurfaceOfRevolution(aCurve,gp::OX());
3606 Standard_CString SOREntityTypeName="Not Computed";
3608 SOREntityTypeName = SOR->DynamicType()->Name();
3610 //==============================================================
3611 TCollection_AsciiString Message (" \
3613 TColgp_Array1OfPnt array (1,5); \n\
3614 array.SetValue(1,gp_Pnt 0,0,1)); \n\
3615 array.SetValue(2,gp_Pnt (1,2,2)); \n\
3616 array.SetValue(3,gp_Pnt (2,3,3)); \n\
3617 array.SetValue(4,gp_Pnt (4,3,4)); \n\
3618 array.SetValue(5,gp_Pnt (5,5,5)); \n\
3619 Handle(Geom_BSplineCurve) aCurve = \n\
3620 GeomAPI_PointsToBSpline(array).Curve(); \n\
3621 Handle(Geom_SurfaceOfRevolution) SOR = \n\
3622 new Geom_SurfaceOfRevolution(aCurve,gp::OX()); \n\
3624 Standard_CString SOREntityTypeName=\"Not Computed\"; \n\
3625 if (!SOR.IsNull()) \n\
3626 SOREntityTypeName = SOR->DynamicType()->Name(); \n\
3628 AddSeparator(aDoc,Message);
3630 //--------------------------------------------------------------
3631 DisplaySurface(aDoc,SOR,Quantity_NOC_GREEN);
3632 DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
3634 Message += "aCurve is Red; \n";
3635 Message += "SOR is Green; \n";
3636 TCollection_AsciiString Message2 (SOREntityTypeName);
3637 Message += " SOREntityTypeName = ";Message+= Message2; Message += "\n";
3639 PostProcess(aDoc,ID_BUTTON_Test_45,TheDisplayType,Message);
3642 void GeomSources::gpTest46(CGeometryDoc* aDoc)
3644 DisplayType TheDisplayType = No2D3D;
3645 PreProcess(aDoc,TheDisplayType);
3646 //==============================================================
3648 TColgp_Array1OfPnt array1 (1,5);
3649 array1.SetValue(1,gp_Pnt (-4,5,5 ));
3650 array1.SetValue(2,gp_Pnt (-3,6,6 ));
3651 array1.SetValue(3,gp_Pnt (-1,6,7 ));
3652 array1.SetValue(4,gp_Pnt (0,8,8));
3653 array1.SetValue(5,gp_Pnt (2,9,9));
3654 Handle(Geom_BSplineCurve) SPL1 =
3655 GeomAPI_PointsToBSpline(array1).Curve();
3657 TColgp_Array1OfPnt array2 (1,5);
3658 array2.SetValue(1,gp_Pnt (-4,5,2 ));
3659 array2.SetValue(2,gp_Pnt (-3,6,3 ));
3660 array2.SetValue(3,gp_Pnt (-1,7,4 ));
3661 array2.SetValue(4,gp_Pnt (0,8,5));
3662 array2.SetValue(5,gp_Pnt (2,9,6));
3663 Handle(Geom_BSplineCurve) SPL2 =
3664 GeomAPI_PointsToBSpline(array2).Curve();
3666 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3667 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3668 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3670 Handle(Geom_BoundedSurface) aTranslatedGeomSurface =
3671 Handle(Geom_BoundedSurface)::DownCast(aGeomSurface->Copy());
3673 Standard_Real extension = 3;
3674 Standard_Integer continuity = 2;
3675 Standard_Boolean Udirection = Standard_True;
3676 Standard_Boolean after = Standard_True;
3677 GeomLib::ExtendSurfByLength (aTranslatedGeomSurface,
3678 extension,continuity,Udirection,after);
3680 //==============================================================
3681 TCollection_AsciiString Message (" \
3683 TColgp_Array1OfPnt array1 (1,5); \n\
3685 Handle(Geom_BSplineCurve) SPL1 = \n\
3686 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3688 TColgp_Array1OfPnt array2 (1,5); \n\
3690 Handle(Geom_BSplineCurve) SPL2 = \n\
3691 GeomAPI_PointsToBSpline(array2).Curve(); \n\
3693 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3694 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3695 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface(); \n\
3697 Handle(Geom_BoundedSurface) aTranslatedGeomSurface = \n\
3698 Handle(Geom_BoundedSurface)::DownCast(aGeomSurface->Copy()); \n\
3700 Standard_Real extension = 3; \n\
3701 Standard_Integer continuity = 2; \n\
3702 Standard_Boolean Udirection = Standard_True; \n\
3703 Standard_Boolean after = Standard_True; \n\
3704 GeomLib::ExtendSurfByLength (aTranslatedGeomSurface, \n\
3705 extension,continuity,Udirection,after); \n\
3707 AddSeparator(aDoc,Message);
3708 //--------------------------------------------------------------
3710 if (!aGeomSurface.IsNull())
3712 DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_HOTPINK);
3715 if (!aTranslatedGeomSurface.IsNull())
3717 DisplaySurface(aDoc,aTranslatedGeomSurface,Quantity_NOC_BLUE1);
3720 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3721 DisplayCurve(aDoc,SPL2,Quantity_NOC_GREEN ,false);
3723 Message += "aGeomSurface is Hot Pink; \n";
3724 Message += "aTranslatedGeomSurface is Blue; \n";
3725 Message += "SPL1 is Red; \n";
3726 Message += "SPL2 is Green; \n";
3728 PostProcess(aDoc,ID_BUTTON_Test_46,TheDisplayType,Message);
3731 void GeomSources::gpTest47(CGeometryDoc* aDoc)
3733 DisplayType TheDisplayType = No2D3D;
3734 PreProcess(aDoc,TheDisplayType);
3736 //==============================================================
3739 TColgp_Array1OfPnt array1 (1,5);
3740 array1.SetValue(1,gp_Pnt (-5,1,2));
3741 array1.SetValue(2,gp_Pnt (-5,2,2));
3742 array1.SetValue(3,gp_Pnt (-5.3,3,1));
3743 array1.SetValue(4,gp_Pnt (-5,4,1));
3744 array1.SetValue(5,gp_Pnt (-5,5,2));
3745 Handle(Geom_BSplineCurve) SPL1 =
3746 GeomAPI_PointsToBSpline(array1).Curve();
3748 TColgp_Array1OfPnt array2 (1,5);
3749 array2.SetValue(1,gp_Pnt (4,1,2));
3750 array2.SetValue(2,gp_Pnt (4,2,2));
3751 array2.SetValue(3,gp_Pnt (3.7,3,1));
3752 array2.SetValue(4,gp_Pnt (4,4,1));
3753 array2.SetValue(5,gp_Pnt (4,5,2));
3754 Handle(Geom_BSplineCurve) SPL2 =
3755 GeomAPI_PointsToBSpline(array2).Curve();
3757 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3759 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3760 Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface();
3762 TColgp_Array2OfPnt array3 (1,5,1,5);
3763 array3.SetValue(1,1,gp_Pnt (-4,-4,5));
3764 array3.SetValue(1,2,gp_Pnt (-4,-2,5));
3765 array3.SetValue(1,3,gp_Pnt (-4,0,4));
3766 array3.SetValue(1,4,gp_Pnt (-4,2,5));
3767 array3.SetValue(1,5,gp_Pnt (-4,4,5));
3769 array3.SetValue(2,1,gp_Pnt (-2,-4,4));
3770 array3.SetValue(2,2,gp_Pnt (-2,-2,4));
3771 array3.SetValue(2,3,gp_Pnt (-2,0,4));
3772 array3.SetValue(2,4,gp_Pnt (-2,2,4));
3773 array3.SetValue(2,5,gp_Pnt (-2,5,4));
3775 array3.SetValue(3,1,gp_Pnt (0,-4,3.5));
3776 array3.SetValue(3,2,gp_Pnt (0,-2,3.5));
3777 array3.SetValue(3,3,gp_Pnt (0,0,3.5));
3778 array3.SetValue(3,4,gp_Pnt (0,2,3.5));
3779 array3.SetValue(3,5,gp_Pnt (0,5,3.5));
3781 array3.SetValue(4,1,gp_Pnt (2,-4,4));
3782 array3.SetValue(4,2,gp_Pnt (2,-2,4));
3783 array3.SetValue(4,3,gp_Pnt (2,0,3.5));
3784 array3.SetValue(4,4,gp_Pnt (2,2,5));
3785 array3.SetValue(4,5,gp_Pnt (2,5,4));
3787 array3.SetValue(5,1,gp_Pnt (4,-4,5));
3788 array3.SetValue(5,2,gp_Pnt (4,-2,5));
3789 array3.SetValue(5,3,gp_Pnt (4,0,5));
3790 array3.SetValue(5,4,gp_Pnt (4,2,6));
3791 array3.SetValue(5,5,gp_Pnt (4,5,5));
3793 Handle(Geom_BSplineSurface) aSurf2 =
3794 GeomAPI_PointsToBSplineSurface(array3).Surface();
3796 GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2);
3797 //Quantity_Length dist = ESS.LowerDistance();
3799 ESS.NearestPoints(P1,P2);
3802 Handle(Geom_Curve) aCurve;
3803 Standard_Integer NbExtrema = ESS.NbExtrema();
3804 for(Standard_Integer k=1;k<=NbExtrema;k++){
3805 ESS.Points(k,P3,P4);
3806 aCurve= GC_MakeSegment(P3,P4).Value();
3807 DisplayCurve(aDoc,aCurve,Quantity_NOC_YELLOW3,false);
3810 //==============================================================
3812 TCollection_AsciiString Message (" \n\
3813 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3815 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3816 Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface(); \n\
3818 Handle(Geom_BSplineSurface) aSurf2 = \n\
3819 GeomAPI_PointsToBSplineSurface(array3).Surface(); \n\
3821 GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2); \n\
3822 Quantity_Length dist = ESS.LowerDistance(); \n\
3824 ESS.NearestPoints(P1,P2); \n\
3827 AddSeparator(aDoc,Message);
3828 Message += "aSurf1 is Green; \n";
3829 Message += "aSurf2 is Hot Pink; \n";
3830 Message += "Nearest points P1 and P2 are shown; \n";
3832 //--------------------------------------------------------------
3836 DisplaySurface(aDoc,aSurf1,Quantity_NOC_GREEN);
3837 DisplaySurface(aDoc,aSurf2,Quantity_NOC_HOTPINK);
3838 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3839 DisplayCurve(aDoc,SPL2,Quantity_NOC_AZURE ,false);
3841 DisplayPoint(aDoc,P1,Standard_CString("P1"));
3842 DisplayPoint(aDoc,P2,Standard_CString("P2"));
3844 PostProcess(aDoc,ID_BUTTON_Test_47,TheDisplayType,Message);
3847 void GeomSources::gpTest48(CGeometryDoc* aDoc)
3849 DisplayType TheDisplayType = a2DNo3D;
3850 PreProcess(aDoc,TheDisplayType);
3851 //==============================================================
3853 Standard_Real radius = 3;
3854 Handle(Geom2d_Circle) circle =
3855 new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius);
3857 Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5);
3859 Geom2dAdaptor_Curve GAC (C);
3862 TColgp_Array1OfPnt2d array (1,5); // sizing array
3863 array.SetValue(1,gp_Pnt2d (0,0));
3864 array.SetValue(2,gp_Pnt2d (1,2));
3865 array.SetValue(3,gp_Pnt2d (2,3));
3866 array.SetValue(4,gp_Pnt2d (4,3));
3867 array.SetValue(5,gp_Pnt2d (5,5));
3868 Handle(Geom2d_BSplineCurve) SPL1 =
3869 Geom2dAPI_PointsToBSpline(array);
3872 Handle(TColgp_HArray1OfPnt2d) harray =
3873 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
3874 harray->SetValue(1,gp_Pnt2d (13+ 0,0));
3875 harray->SetValue(2,gp_Pnt2d (13+ 1,2));
3876 harray->SetValue(3,gp_Pnt2d (13+ 2,3));
3877 harray->SetValue(4,gp_Pnt2d (13+ 4,3));
3878 harray->SetValue(5,gp_Pnt2d (13+ 5,5));
3879 Geom2dAPI_Interpolate anInterpolation(harray,Standard_True,0.01);
3880 anInterpolation.Perform();
3881 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();
3884 Geom2dAdaptor_Curve GACC (C);
3885 BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox);
3887 Standard_Real aCXmin, aCYmin, aCXmax, aCYmax;
3888 aCBox.Get( aCXmin, aCYmin, aCXmax,aCYmax);
3891 Geom2dAdaptor_Curve GAC1 (SPL1);
3892 BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box);
3894 Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax;
3895 aSPL1Box.Get( aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax);
3898 Geom2dAdaptor_Curve GAC2 (SPL2);
3899 BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box);
3901 Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax;
3902 aSPL2Box.Get( aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax);
3904 //==============================================================
3905 TCollection_AsciiString Message (" \
3907 Standard_Real radius = 3; \n\
3908 Handle(Geom2d_Circle) circle = \n\
3909 new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius); \n\
3911 Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5); \n\
3912 Geom2dAdaptor_Curve GAC (C); \n\
3914 Handle(Geom2d_BSplineCurve) SPL1 ; // SPL1 = ... \n\
3916 Handle(Geom2d_BSplineCurve) SPL2 ; // SPL2 = ... \n\
3918 Bnd_Box2d aCBox; \n\
3919 Geom2dAdaptor_Curve GACC (C); \n\
3920 BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox); \n\
3922 Standard_Real aCXmin, aCYmin, aCXmax, aCYmax; \n\
3923 aCBox.Get( aCXmin, aCYmin, aCXmax,aCYmax); \n\
3925 Bnd_Box2d aSPL1Box; \n\
3926 Geom2dAdaptor_Curve GAC1 (SPL1); \n\
3927 BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box); \n\
3929 Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax; \n\
3930 aSPL1Box.Get( aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax); \n");
3933 Bnd_Box2d aSPL2Box; \n\
3934 Geom2dAdaptor_Curve GAC2 (SPL2); \n\
3935 BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box); \n\
3937 Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax; \n\
3938 aSPL2Box.Get( aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax); \n\
3940 AddSeparator(aDoc,Message);
3941 //--------------------------------------------------------------
3943 DisplayCurve(aDoc,C ,5);
3944 DisplayCurve(aDoc,SPL1,6 );
3945 DisplayCurve(aDoc,SPL2,7 );
3947 DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmax),Standard_CString("aCXmin,aCYmax"));
3948 DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmax),Standard_CString("aCXmax,aCYmax"));
3949 DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmin),Standard_CString("aCXmin,aCYmin"));
3950 DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmin),Standard_CString("aCXmax,aCYmin"));
3952 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmax),gp_Pnt2d(aCXmax,aCYmax)).Value() ,4); // X,Ymax
3953 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmax,aCYmin)).Value() ,4); // X,Ymin
3954 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmin,aCYmax)).Value() ,4); // Xmin,Y
3955 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmax,aCYmin),gp_Pnt2d(aCXmax,aCYmax)).Value() ,4); // Xmax,Y
3957 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),Standard_CString("aSPL1Xmin,aSPL1Ymax"));
3958 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymax),Standard_CString("aSPL1Xmax,aSPL1Ymax"));
3959 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),Standard_CString("aSPL1Xmin,aSPL1Ymin"));
3960 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),Standard_CString("aSPL1Xmax,aSPL1Ymin"));
3962 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)).Value() ,4); // X,Ymax
3963 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymin)).Value() ,4); // X,Ymin
3964 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmin,aSPL1Ymax)).Value() ,4); // Xmin,Y
3965 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)).Value() ,4); // Xmax,Y
3967 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),Standard_CString("aSPL2Xmin,aSPL2Ymax"));
3968 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymax),Standard_CString("aSPL2Xmax,aSPL2Ymax"));
3969 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),Standard_CString("aSPL2Xmin,aSPL2Ymin"));
3970 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),Standard_CString("aSPL2Xmax,aSPL2Ymin"));
3972 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymax),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)).Value() ,4); // X,Ymax
3973 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymin)).Value() ,4); // X,Ymin
3974 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmin,aSPL2Ymax)).Value() ,4); // Xmin,Y
3975 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmax,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)).Value() ,4); // Xmax,Y
3977 PostProcess(aDoc,ID_BUTTON_Test_48,TheDisplayType,Message);
3981 void GeomSources::gpTest49(CGeometryDoc* aDoc)
3983 DisplayType TheDisplayType = No2D3D;
3984 PreProcess(aDoc,TheDisplayType);
3986 //==============================================================
3989 Standard_Real radius = 100;
3990 gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5));
3992 Handle(Geom_Circle) C =
3993 new Geom_Circle(anAxis,radius);
3994 GeomAdaptor_Curve GAC (C);
3995 BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox);
3997 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
3998 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
4000 //==============================================================
4002 TCollection_AsciiString Message (" \
4005 Standard_Real radius = 100; \n\
4006 gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5)); \n\
4008 Handle(Geom_Circle) C = \n\
4009 new Geom_Circle(anAxis,radius); \n\
4010 GeomAdaptor_Curve GAC (C); \n\
4011 BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox); \n\
4013 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ; \n\
4014 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax); \n\
4016 AddSeparator(aDoc,Message);
4017 //--------------------------------------------------------------
4019 DisplayCurve(aDoc,C,Quantity_NOC_BLUE1 ,false);
4021 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmin),Standard_CString("aXmin,aYmax,aZmin"));
4022 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmin),Standard_CString("aXmax,aYmax,aZmin"));
4023 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmin),Standard_CString("aXmin,aYmin,aZmin"));
4024 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmin),Standard_CString("aXmax,aYmin,aZmin"));
4026 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmax),Standard_CString("aXmin,aYmax,aZmax"));
4027 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmax),Standard_CString("aXmax,aYmax,aZmax"));
4028 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmax),Standard_CString("aXmin,aYmin,aZmax"));
4029 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmax),Standard_CString("aXmax,aYmin,aZmax"));
4031 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4032 gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMin
4033 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4034 gp_Pnt(aXmax,aYmin,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMin
4035 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4036 gp_Pnt(aXmin,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMin
4037 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4038 gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMin
4039 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4040 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMax
4041 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4042 gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMax
4043 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4044 gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMax
4045 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4046 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMax
4047 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4048 gp_Pnt(aXmin,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymin,Z
4049 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4050 gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymin,Z
4051 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4052 gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymax,Z
4053 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4054 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymax,Z
4056 PostProcess(aDoc,ID_BUTTON_Test_49,TheDisplayType,Message);
4059 void GeomSources::gpTest50(CGeometryDoc* aDoc)
4061 DisplayType TheDisplayType = No2D3D;
4062 PreProcess(aDoc,TheDisplayType);
4063 //==============================================================
4065 TColgp_Array1OfPnt array1 (1,5);
4066 array1.SetValue(1,gp_Pnt (-40,00,20 ));
4067 array1.SetValue(2,gp_Pnt (-70,20,20 ));
4068 array1.SetValue(3,gp_Pnt (-60,30,10 ));
4069 array1.SetValue(4,gp_Pnt (-40,30,-10));
4070 array1.SetValue(5,gp_Pnt (-30,50,-20));
4071 Handle(Geom_BSplineCurve) SPL1 =
4072 GeomAPI_PointsToBSpline(array1).Curve();
4074 TColgp_Array1OfPnt array2 (1,5);
4075 array2.SetValue(1,gp_Pnt (-40,0, 20));
4076 array2.SetValue(2,gp_Pnt (-20,20,0 ));
4077 array2.SetValue(3,gp_Pnt (20 ,30,-10));
4078 array2.SetValue(4,gp_Pnt (30 ,70,-20));
4079 array2.SetValue(5,gp_Pnt (40 ,90,-10));
4080 Handle(Geom_BSplineCurve) SPL2 =
4081 GeomAPI_PointsToBSpline(array2).Curve();
4083 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
4084 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
4085 Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface();
4086 GeomAdaptor_Surface GAS (aSurf);
4088 BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox);
4090 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
4091 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
4093 //==============================================================
4094 TCollection_AsciiString Message (" \
4096 TColgp_Array1OfPnt array1 (1,5); \n\
4097 array1.SetValue(1,gp_Pnt (-40, 0, 20)); \n\
4098 array1.SetValue(2,gp_Pnt (-70, 20, 20)); \n\
4099 array1.SetValue(3,gp_Pnt (-60, 30, 10)); \n\
4100 array1.SetValue(4,gp_Pnt (-40, 30,-10)); \n\
4101 array1.SetValue(5,gp_Pnt (-30, 50,-20)); \n\
4102 Handle(Geom_BSplineCurve) SPL1 = \n\
4103 GeomAPI_PointsToBSpline(array1).Curve(); \n\
4105 TColgp_Array1OfPnt array2 (1,5); \n\
4106 array2.SetValue(1,gp_Pnt (-40, 0, 20)); \n\
4107 array2.SetValue(2,gp_Pnt (-20, 20, 0)); \n\
4108 array2.SetValue(3,gp_Pnt ( 20, 30,-10)); \n\
4109 array2.SetValue(4,gp_Pnt ( 30, 70,-20)); \n\
4110 array2.SetValue(5,gp_Pnt ( 40, 90,-10)); \n\
4111 Handle(Geom_BSplineCurve) SPL2 = \n\
4112 GeomAPI_PointsToBSpline(array2).Curve(); \n\
4114 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
4115 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
4116 Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface(); \n\
4117 GeomAdaptor_Surface GAS (aSurf); \n\
4119 BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox); \n\
4121 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ; \n\
4122 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax); \n\
4124 AddSeparator(aDoc,Message);
4125 //--------------------------------------------------------------
4127 Quantity_NameOfColor aNameOfColor= Quantity_NOC_GREEN;
4128 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurf);
4129 aDoc->GetAISContext()->SetColor(aGraphicalSurface,aNameOfColor);
4130 aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
4131 aGraphicalSurface->Attributes()->UIsoAspect()->SetColor(aNameOfColor);
4132 aGraphicalSurface->Attributes()->VIsoAspect()->SetColor(aNameOfColor);
4134 aDoc->GetAISContext()->SetDisplayMode(aGraphicalSurface,1);
4135 aDoc->GetAISContext()->Display(aGraphicalSurface,false);
4136 // DisplaySurface(aDoc,aSurf,Quantity_NOC_GREEN);
4138 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4139 gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMin
4140 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4141 gp_Pnt(aXmax,aYmin,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMin
4142 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4143 gp_Pnt(aXmin,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMin
4144 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4145 gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMin
4146 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4147 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMax
4148 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4149 gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMax
4150 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4151 gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMax
4152 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4153 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMax
4154 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4155 gp_Pnt(aXmin,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymin,Z
4156 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4157 gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymin,Z
4158 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4159 gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymax,Z
4160 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4161 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymax,Z
4163 PostProcess(aDoc,ID_BUTTON_Test_50,TheDisplayType,Message);