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>
12 GeomSources::GeomSources()
16 GeomSources::~GeomSources()
19 void GeomSources::PreProcess(CGeometryDoc* aDoc,DisplayType aDisplayType)
21 if (aDisplayType == No2D3D )
23 aDoc->GetAISContext()->EraseAll (Standard_True);
27 if (aDisplayType == a2DNo3D)
29 aDoc->GetISessionContext()->EraseAll (Standard_True);
33 if (aDisplayType != No2D3D && aDisplayType != a2D3D)
38 if (aDisplayType != a2DNo3D && aDisplayType != a2D3D)
43 if (aDisplayType == a2D3D)
45 aDoc->GetAISContext()->EraseAll (Standard_True);
46 aDoc->GetISessionContext()->EraseAll (Standard_True);
47 aDoc->Put3DOnTop(false);
48 aDoc->Put2DOnTop(false);
51 // send the message Title Horizontally to the child of doc main frame
52 CGeometryApp* TheAppli = (CGeometryApp*)AfxGetApp();
53 CMainFrame* TheMainFrame= (CMainFrame*)TheAppli->m_pMainWnd;
54 ::SendMessage(TheMainFrame->m_hWndMDIClient, WM_MDITILE, 0, 0);
58 void GeomSources::PostProcess (CGeometryDoc* aDoc, UINT anID, DisplayType aDisplayType,
59 const TCollection_AsciiString& theString, Standard_Boolean UpdateViewer, Standard_Real Coef)
61 Standard_CString aString = theString.ToCString();
64 if (aDisplayType == No2D3D || aDisplayType == a2D3D)
66 aDoc->Fit3DViews(Coef);
69 if (aDisplayType == a2DNo3D || aDisplayType == a2D3D)
75 TCollection_AsciiString Message("Results are ");
79 case No2DNo3D: Message = "All results are in this box \n";
81 case No2D3D: Message += "only in 3D \n";
83 case a2DNo3D: Message += "only in 2d \n";
85 case a2D3D: Message += "in both 2D and 3D \n";
88 Message += "====================================\n";
91 CString text(Message.ToCString());
92 aDoc->myCResultDialog.SetText(text);
95 if (! s.LoadString( anID ))
96 AfxMessageBox (L"Error Loading String: ");
98 CString Title = s.Left( s.Find( '\n' ));
100 aDoc->myCResultDialog.SetTitle(Title);
101 aDoc->SetTitle(Title);
104 void GeomSources::AddSeparator(CGeometryDoc* /*aDoc*/,TCollection_AsciiString& aMessage)
106 aMessage+= "------------------------------------------------------------------------\n";
108 void GeomSources::DisplayPoint (CGeometryDoc* theDoc,
109 const gp_Pnt2d& thePoint,
111 Standard_Boolean theToUpdateViewer,
112 Standard_Real theXoffset,
113 Standard_Real theYoffset,
114 Standard_Real theTextScale)
116 Handle(ISession_Point) aGraphicPoint = new ISession_Point (thePoint);
117 theDoc->GetISessionContext()->Display (aGraphicPoint, Standard_False);
119 Handle(AIS_TextLabel) aLabel = new AIS_TextLabel();
120 aLabel->SetText (theText);
121 aLabel->SetPosition (gp_Pnt (thePoint.X() + theXoffset, thePoint.Y() + theYoffset, 0.0));
122 //aLabel->SetHeight (theTextScale);
124 theDoc->GetISessionContext()->Display (aLabel, theToUpdateViewer);
127 void GeomSources::DisplayPoint (CGeometryDoc* theDoc,
128 const gp_Pnt& thePoint,
130 Standard_Boolean theToUpdateViewer,
131 Standard_Real theXoffset,
132 Standard_Real theYoffset,
133 Standard_Real theZoffset,
134 Standard_Real theTextScale)
136 Handle(ISession_Point) aGraphicPoint = new ISession_Point (thePoint);
137 theDoc->GetAISContext()->Display (aGraphicPoint, Standard_False);
139 Handle(AIS_TextLabel) aLabel = new AIS_TextLabel();
140 aLabel->SetText (theText);
141 aLabel->SetPosition (gp_Pnt (thePoint.X() + theXoffset, thePoint.Y() + theYoffset, thePoint.Z() + theZoffset));
142 //aLabel->SetHeight (theTextScale);
144 theDoc->GetAISContext()->Display (aLabel, theToUpdateViewer);
147 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
148 Handle(Geom2d_Curve) aCurve,
149 Standard_Integer aColorIndex,
150 Standard_Boolean UpdateViewer)
152 Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
153 aGraphicCurve->SetColorIndex(aColorIndex) ;
154 aDoc->GetISessionContext()->Display(aGraphicCurve,UpdateViewer);
157 void GeomSources::DisplayCurveAndCurvature(CGeometryDoc* aDoc,
158 Handle(Geom2d_Curve) aCurve,
159 Standard_Integer aColorIndex,
160 Standard_Boolean UpdateViewer)
162 Handle(ISession2D_Curve) aGraphicCurve = new ISession2D_Curve(aCurve);
163 aGraphicCurve->SetDisplayCurbure(Standard_True) ;
164 aGraphicCurve->SetDiscretisation(20);
165 aGraphicCurve->SetColorIndex(aColorIndex) ;
166 aDoc->GetISessionContext()->Display(aGraphicCurve,UpdateViewer);
169 void GeomSources::DisplayCurve (CGeometryDoc* theDoc,
170 Handle(Geom_Curve) theCurve,
171 Quantity_NameOfColor theNameOfColor,
172 Standard_Boolean theToUpdateViewer)
174 Handle(ISession_Curve) aGraphicCurve = new ISession_Curve (theCurve);
175 aGraphicCurve->Attributes()->SetLineAspect (new Prs3d_LineAspect (theNameOfColor, Aspect_TOL_SOLID, 1.0));
176 theDoc->GetAISContext()->Display (aGraphicCurve, theToUpdateViewer);
179 void GeomSources::DisplayCurve(CGeometryDoc* aDoc,
180 Handle(Geom_Curve) aCurve,
181 Standard_Boolean UpdateViewer)
183 Handle(ISession_Curve) aGraphicCurve = new ISession_Curve(aCurve);
184 aDoc->GetAISContext()->Display(aGraphicCurve,UpdateViewer);
187 void GeomSources::DisplaySurface (CGeometryDoc* theDoc,
188 Handle(Geom_Surface) theSurface,
189 Quantity_NameOfColor theNameOfColor,
190 Standard_Boolean theToUpdateViewer)
192 const Handle(AIS_InteractiveContext)& aCtx = theDoc->GetAISContext();
193 Handle(Prs3d_ShadingAspect) aShadeAspect = new Prs3d_ShadingAspect();
194 Handle(Prs3d_LineAspect) aLineAspect = new Prs3d_LineAspect (theNameOfColor, Aspect_TOL_SOLID, 1.0);
195 Handle(Prs3d_IsoAspect) anIsoAspect = new Prs3d_IsoAspect (theNameOfColor, Aspect_TOL_SOLID, 1.0,
196 aCtx->DefaultDrawer()->UIsoAspect()->Number());
197 aShadeAspect->SetColor (theNameOfColor);
199 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface (theSurface);
200 const Handle(Prs3d_Drawer)& aDrawer = aGraphicalSurface->Attributes();
201 aDrawer->SetShadingAspect (aShadeAspect);
202 aDrawer->SetLineAspect (aLineAspect);
203 aDrawer->SetFreeBoundaryAspect (aLineAspect);
204 aDrawer->SetUIsoAspect (anIsoAspect);
205 aDrawer->SetVIsoAspect (anIsoAspect);
206 aCtx->Display (aGraphicalSurface, theToUpdateViewer);
209 void GeomSources::DisplaySurface(CGeometryDoc* aDoc,
210 Handle(Geom_Surface) aSurface,
211 Standard_Boolean UpdateViewer)
213 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
214 aDoc->GetAISContext()->Display(aGraphicalSurface,UpdateViewer);
217 void GeomSources::ResetView(CGeometryDoc* aDoc)
219 Handle(V3d_View) aView = aDoc->GetAISContext()->CurrentViewer()->ActiveViews().First();
223 // Function name : GeomSources::gpTest1
225 // Return type : void
226 // Argument : CGeometryDoc* aDoc
227 void GeomSources::gpTest1(CGeometryDoc* aDoc)
229 DisplayType TheDisplayType = No2D3D;
230 PreProcess(aDoc,TheDisplayType);
231 //==============================================================
236 Standard_Real result = A.DotCross(B,C);
238 //==============================================================
239 TCollection_AsciiString Message ("\
244 Standard_Real result = A.DotCross(B,C); \n\
246 AddSeparator(aDoc,Message);
247 //--------------------------------------------------------------
249 DisplayPoint(aDoc,gp_Pnt(A),"A (1,2,3)",false,0.1);
250 DisplayPoint(aDoc,gp_Pnt(B),"B (2,2,2)",false,0.1);
251 DisplayPoint(aDoc,gp_Pnt(C),"C (3,2,3)",false,0.1);
253 // to add a numeric value in a TCollectionAsciiString
254 TCollection_AsciiString Message2 (result);
256 Message+= " result = ";
258 PostProcess(aDoc,ID_BUTTON_Test_1,TheDisplayType,Message);
261 // Function name : GeomSources::gpTest2
263 // Return type : void
264 // Argument : CGeometryDoc* aDoc
265 void GeomSources::gpTest2(CGeometryDoc* aDoc)
267 DisplayType TheDisplayType = No2D3D;
268 PreProcess(aDoc,TheDisplayType);
269 //==============================================================
273 //==============================================================
274 TCollection_AsciiString Message ("\
276 gp_Pnt P1(1,2,3); \n\
278 AddSeparator(aDoc,Message);
279 //--------------------------------------------------------------
280 DisplayPoint(aDoc,P1,"P1 (1,2,3)",false,30);
281 PostProcess(aDoc,ID_BUTTON_Test_2,TheDisplayType,Message,Standard_False);
286 // Function name : GeomSources::gpTest3
288 // Return type : void
289 // Argument : CGeometryDoc* aDoc
290 void GeomSources::gpTest3(CGeometryDoc* aDoc)
292 DisplayType TheDisplayType = No2D3D;
293 PreProcess(aDoc,TheDisplayType);
294 //==============================================================
299 //==============================================================
300 TCollection_AsciiString Message ("\
305 AddSeparator(aDoc,Message);
306 //--------------------------------------------------------------
307 DisplayPoint(aDoc,P2,"P2 (1,2,3)",false,30);
308 PostProcess(aDoc,ID_BUTTON_Test_3,TheDisplayType,Message,Standard_False);
313 // Function name : GeomSources::gpTest4
315 // Return type : void
316 // Argument : CGeometryDoc* aDoc
317 void GeomSources::gpTest4(CGeometryDoc* aDoc)
319 DisplayType TheDisplayType = No2D3D;
320 PreProcess(aDoc,TheDisplayType);
321 //==============================================================
323 gp_Pnt P3 = gp::Origin();
324 Standard_Real TheX = P3.X();
325 Standard_Real TheY = P3.Y();
326 Standard_Real TheZ = P3.Z();
329 //==============================================================
330 TCollection_AsciiString Message ("\
332 gp_Pnt P3 = gp::Origin(); \n\
333 Standard_Real TheX = P3.X(); \n\
334 Standard_Real TheY = P3.Y(); \n\
335 Standard_Real TheZ = P3.Z(); \n\
337 AddSeparator(aDoc,Message);
338 //--------------------------------------------------------------
339 DisplayPoint(aDoc,P3,"P3 = gp::Origin()",false,30);
341 TCollection_AsciiString Message2 (TheX);
342 TCollection_AsciiString Message3 (TheY);
343 TCollection_AsciiString Message4 (TheZ);
345 Message += " TheX = ";
347 Message += " TheY = ";
349 Message += " TheZ = ";
353 PostProcess(aDoc,ID_BUTTON_Test_4,TheDisplayType,Message,Standard_False);
358 // Function name : GeomSources::gpTest5
360 // Return type : void
361 // Argument : CGeometryDoc* aDoc
362 void GeomSources::gpTest5(CGeometryDoc* aDoc)
364 DisplayType TheDisplayType = No2D3D;
365 PreProcess(aDoc,TheDisplayType);
366 //==============================================================
371 Standard_Real alpha = 3;
372 Standard_Real beta = 7;
373 PB.BaryCenter(alpha,P2,beta);
375 //==============================================================
376 TCollection_AsciiString Message ("\
378 gp_Pnt P1(1,2,3); \n\
379 gp_Pnt P2(3,4,5); \n\
381 Standard_Real alpha = 3; \n\
382 Standard_Real beta = 7; \n\
383 PB.BaryCenter(alpha,P2,beta); \n\
386 AddSeparator(aDoc,Message);
387 //--------------------------------------------------------------
389 DisplayPoint(aDoc,P1,"P1",false,0.2);
390 DisplayPoint(aDoc,P2,"P2",false,0.2);
391 DisplayPoint(aDoc,PB,"PB = barycenter ( 3 * P1 , 7 * P2) ",false,0.2);
393 TCollection_AsciiString Message2 (PB.X());
394 TCollection_AsciiString Message3 (PB.Y());
395 TCollection_AsciiString Message4 (PB.Z());
404 PostProcess(aDoc,ID_BUTTON_Test_5,TheDisplayType,Message);
408 // Function name : GeomSources::gpTest6
410 // Return type : void
411 // Argument : CGeometryDoc* aDoc
412 void GeomSources::gpTest6(CGeometryDoc* aDoc)
414 DisplayType TheDisplayType = No2D3D;
415 PreProcess(aDoc,TheDisplayType);
416 //==============================================================
418 // Compute a 3d point P as BaryCenter of an array of point
424 TColgp_Array1OfPnt array (1,5); // sizing array
425 array.SetValue(1,P1);
426 array.SetValue(2,P2);
427 array.SetValue(3,P3);
428 array.SetValue(4,P4);
429 array.SetValue(5,P5);
431 Standard_Real Tolerance = 8; // ajout de la tolerance
432 GProp_PEquation PE (array,Tolerance);
434 gp_Pnt P; // P declaration
435 Standard_Boolean IsPoint;
447 if (PE.IsLinear()){ /*... */ }
448 if (PE.IsPlanar()){ /*... */ }
449 if (PE.IsSpace()) { /*... */ }
451 //==============================================================
452 TCollection_AsciiString Message ("\
455 // Compute a 3d point P as BaryCenter of an array of point \n\
456 gp_Pnt P1(0,0,5); \n\
457 gp_Pnt P2(1,2,3); \n\
458 gp_Pnt P3(2,3,-2); \n\
459 gp_Pnt P4(4,3,5); \n\
460 gp_Pnt P5(5,5,4); \n\
461 TColgp_Array1OfPnt array (1,5); // sizing array \n\
462 array.SetValue(1,P1); \n\
463 array.SetValue(2,P2); \n\
464 array.SetValue(3,P3); \n\
465 array.SetValue(4,P4); \n\
466 array.SetValue(5,P5); \n\
468 Standard_Real Tolerance = 8; // ajout de la tolerance \n\
469 GProp_PEquation PE (array,Tolerance); \n\
471 gp_Pnt P; // P declaration \n\
472 Standard_Boolean IsPoint; \n\
473 if (PE.IsPoint()){IsPoint = true; \n\
474 P = PE .Point();} \n\
475 else { IsPoint = false; } \n\
476 if (PE.IsLinear()){ /*... */ } \n\
477 if (PE.IsPlanar()){ /*... */ } \n\
478 if (PE.IsSpace()) { /*... */ } \n\
480 AddSeparator(aDoc,Message);
481 //--------------------------------------------------------------
483 TCollection_AsciiString PointName("P");
486 for(Standard_Integer i= array.Lower();i <= array.Upper(); i++)
488 TCollection_AsciiString TheString (i);
489 TheString = PointName+ TheString;
490 DisplayPoint(aDoc,array(i),TheString.ToCString(),false,0.5);
493 DisplayPoint(aDoc,P,"P",false,0.5);
494 TCollection_AsciiString Message2 (P.X());
495 TCollection_AsciiString Message3 (P.Y());
496 TCollection_AsciiString Message4 (P.Z());
498 Message += " IsPoint = ";
501 Message += "True --> ";
504 Message += Message2; Message += " , ";
505 Message += Message3; Message += " , ";
506 Message += Message4; Message += " ); \n";
509 Message += "False\n";
511 Message += " IsLinear = ";
513 Message += "True \n";
515 Message += "False\n";
517 Message += " IsPlanar = ";
519 Message += "True \n";
521 Message += "False\n";
523 Message += " IsSpace = ";
526 Message += "True \n";
528 Message += "False\n";
530 PostProcess(aDoc,ID_BUTTON_Test_6,TheDisplayType,Message);
533 // Function name : GeomSources::gpTest7
535 // Return type : void
536 // Argument : CGeometryDoc* aDoc
537 void GeomSources::gpTest7(CGeometryDoc* aDoc)
539 DisplayType TheDisplayType = a2DNo3D;
540 PreProcess(aDoc,TheDisplayType);
541 //==============================================================
547 Handle(Geom2d_Curve) C =
548 GCE2d_MakeArcOfCircle (P1,P2,P3).Value();
550 Standard_Real FirstParameter = C->FirstParameter();
551 Standard_Real LastParameter = C->LastParameter();
552 Standard_Real MiddleParameter = (FirstParameter+LastParameter)/2;
553 Standard_Real param = MiddleParameter; //in radians
558 // we recover point P and the vector V
560 //==============================================================
561 TCollection_AsciiString Message ("\
564 gp_Pnt2d P1(0,5); \n\
565 gp_Pnt2d P2(5.5,1); \n\
566 gp_Pnt2d P3(-2,2); \n\
568 Handle(Geom2d_TrimmedCurve) C = \n\
569 GCE2d_MakeArcOfCircle (P1,P2,P3).Value(); \n\
571 Standard_Real FirstParameter = C->FirstParameter(); \n\
572 Standard_Real LastParameter = C->LastParameter(); \n\
573 Standard_Real MiddleParameter = \n\
574 (FirstParameter+LastParameter)/2; \n\
575 Standard_Real param = MiddleParameter; //in radians \n\
579 C->D1(param,P,V); \n\
580 // we recover point P and the vector V \n\
582 AddSeparator(aDoc,Message);
583 //--------------------------------------------------------------
585 DisplayCurve(aDoc,C);
586 Handle(ISession_Direction) aDirection = new ISession_Direction(P,V);
587 aDoc->GetISessionContext()->Display(aDirection, Standard_False);
589 DisplayPoint(aDoc,P,"P",false,0.5);
591 PostProcess(aDoc,ID_BUTTON_Test_7,TheDisplayType,Message);
594 // Function name : GeomSources::gpTest8
596 // Return type : void
597 // Argument : CGeometryDoc* aDoc
598 void GeomSources::gpTest8(CGeometryDoc* aDoc)
600 DisplayType TheDisplayType = a2DNo3D;
601 PreProcess(aDoc,TheDisplayType);
602 //==============================================================
604 Standard_Real radius = 5;
605 Handle(Geom2d_Circle) C =
606 new Geom2d_Circle(gp::OX2d(),radius);
607 Standard_Real param = 1.2*M_PI;
608 Geom2dLProp_CLProps2d CLP
609 (C,param,2,Precision::PConfusion());
612 // D is the Tangent direction at parameter 1.2*PI
614 //==============================================================
615 TCollection_AsciiString Message (" \
617 Standard_Real radius = 5; \n\
618 Handle(Geom2d_Circle) C = \n\
619 new Geom2d_Circle(gp::OX2d(),radius); \n\
620 Standard_Real param = 1.2*PI; \n\
621 Geom2dLProp_CLProps2d CLP \n\
622 (C,param,2,Precision::PConfusion()); \n\
625 // D is the Tangent direction at parameter 1.2*PI \n\
627 AddSeparator(aDoc,Message);
628 //--------------------------------------------------------------
629 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
630 aDoc->GetISessionContext()->Display(aCurve,Standard_False);
631 Handle(ISession_Direction) aDirection = new ISession_Direction(gp_Pnt2d(0,0),D,2);
632 aDoc->GetISessionContext()->Display(aDirection,Standard_False);
634 TCollection_AsciiString Message2 (D.X());
635 TCollection_AsciiString Message3 (D.Y());
638 Message += Message2; Message += " , ";
639 Message += Message3; Message += " ); \n";
641 PostProcess(aDoc,ID_BUTTON_Test_8,TheDisplayType,Message);
644 // Function name : GeomSources::gpTest9
646 // Return type : void
647 // Argument : CGeometryDoc* aDoc
648 void GeomSources::gpTest9(CGeometryDoc* aDoc)
650 DisplayType TheDisplayType = a2DNo3D;
651 PreProcess(aDoc,TheDisplayType);
653 //==============================================================
655 Standard_Real radius = 5;
656 Handle(Geom2d_Circle) C =
657 new Geom2d_Circle(gp::OX2d(),radius);
658 Geom2dAdaptor_Curve GAC (C);
659 Standard_Real startparam = 10*M_PI/180;
660 Standard_Real abscissa = 45*M_PI/180;
662 C->D0(startparam,P1);
663 // abscissa is the distance along the curve from startparam
664 GCPnts_AbscissaPoint AP (GAC, abscissa, startparam);
666 if (AP.IsDone()){C->D0(AP.Parameter(),P2);}
667 // P is now correctly set
669 //==============================================================
670 TCollection_AsciiString Message (" \n\
673 Standard_Real radius = 5; \n\
674 Handle(Geom2d_Circle) C = \n\
675 new Geom2d_Circle(gp::OX2d(),radius); \n\
676 Geom2dAdaptor_Curve GAC (C); \n\
677 Standard_Real startparam = 10*PI180; \n\
678 Standard_Real abscissa = 45*PI180; \n\
680 C->D0(startparam,P1); \n\
681 // abscissa is the distance along the curve from startparam \n\
682 GCPnts_AbscissaPoint AP (GAC, abscissa, startparam); \n\
684 if (AP.IsDone()){C->D0(AP.Parameter(),P2);} \n\
685 // P is now correctly set \n\
688 AddSeparator(aDoc,Message);
689 //--------------------------------------------------------------
690 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
691 aDoc->GetISessionContext()->Display(aCurve,Standard_False);
693 DisplayPoint(aDoc,P1,"P1");
694 if (AP.IsDone()) DisplayPoint(aDoc,P2,"P2");
696 TCollection_AsciiString Message2 (P1.X());
697 TCollection_AsciiString Message3 (P1.Y());
699 TCollection_AsciiString Message4 (P2.X());
700 TCollection_AsciiString Message5 (P2.Y());
703 Message += Message2; Message += " , ";
704 Message += Message3; Message += " ); \n";
707 Message += Message4; Message += " , ";
708 Message += Message5; Message += " ); \n";
709 PostProcess(aDoc,ID_BUTTON_Test_9,TheDisplayType,Message);
712 // Function name : GeomSources::gpTest10
714 // Return type : void
715 // Argument : CGeometryDoc* aDoc
716 void GeomSources::gpTest10(CGeometryDoc* aDoc)
718 DisplayType TheDisplayType = a2DNo3D;
719 PreProcess(aDoc,TheDisplayType);
720 //==============================================================
723 Standard_Real radius = 5;
724 Handle(Geom2d_Circle) C =
725 new Geom2d_Circle(gp::OX2d(),radius);
726 Geom2dAdaptor_Curve GAC (C);
727 Standard_Real abscissa = 3;
728 GCPnts_UniformAbscissa UA (GAC,abscissa);
729 TColgp_SequenceOfPnt2d aSequence;
732 Standard_Real N = UA.NbPoints();
733 Standard_Integer count = 1;
734 for(;count<=N;count++)
736 C->D0(UA.Parameter(count),P);
737 //Standard_Real Parameter = UA.Parameter(count);
738 // append P in a Sequence
742 Standard_Real Abscissa = UA.Abscissa();
744 //==============================================================
745 TCollection_AsciiString Message (" \
748 Standard_Real radius = 5; \n\
749 Handle(Geom2d_Circle) C = \n\
750 new Geom2d_Circle(gp::OX2d(),radius); \n\
751 Geom2dAdaptor_Curve GAC (C); \n\
752 Standard_Real abscissa = 3; \n\
753 GCPnts_UniformAbscissa UA (GAC,abscissa); \n\
754 TColgp_SequenceOfPnt2d aSequence; \n\
757 Standard_Real N = UA.NbPoints(); \n\
758 Standard_Integer count = 1; \n\
759 for(;count<=N;count++) \n\
761 C->D0(UA.Parameter(count),P); \n\
762 Standard_Real Parameter = UA.Parameter(count); \n\
763 // append P in a Sequence \n\
764 aSequence.Append(P); \n\
767 Standard_Real Abscissa = UA.Abscissa(); \n\
769 AddSeparator(aDoc,Message);
770 //--------------------------------------------------------------
771 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(C);
772 aDoc->GetISessionContext()->Display(aCurve,Standard_False);
774 TCollection_AsciiString aString;
775 for (Standard_Integer i=1;i<= aSequence.Length();i++)
778 TCollection_AsciiString Message2 (i);
779 TCollection_AsciiString Message3 (UA.Parameter(i));
783 aString +=": Parameter : ";
786 // First and Last texts are displayed with an Y offset, point 4 is upper
787 Standard_Real YOffset = -0.3;
788 YOffset += 0.2 * ( i == 1 );
789 YOffset += 0.4 * ( i == 4 );
790 YOffset += -0.2 * ( i == aSequence.Length() );
792 DisplayPoint(aDoc,aSequence(i),aString.ToCString(),false,0.5,YOffset,0.04);
795 TCollection_AsciiString Message3 (Abscissa);
797 Message += "Abscissa = ";
801 PostProcess(aDoc,ID_BUTTON_Test_10,TheDisplayType,Message);
804 // Function name : GeomSources::gpTest11
806 // Return type : void
807 // Argument : CGeometryDoc* aDoc
808 void GeomSources::gpTest11(CGeometryDoc* aDoc)
810 DisplayType TheDisplayType = No2D3D;
811 PreProcess(aDoc,TheDisplayType);
812 //==============================================================
814 Standard_Real radius = 5;
815 Handle(Geom_SphericalSurface) SP =
816 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);
819 gp_Pnt P = SP->Value(u,v);
821 //==============================================================
822 TCollection_AsciiString Message (" \
824 Standard_Real radius = 5; \n\
825 Handle(Geom_SphericalSurface) SP = \n\
826 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius); \n\
827 Standard_Real u = 2; \n\
828 Standard_Real v = 3; \n\
829 gp_Pnt P = SP->Value(u,v); \n\
831 AddSeparator(aDoc,Message);
832 //--------------------------------------------------------------
834 DisplaySurface(aDoc,SP);
835 DisplayPoint(aDoc,P,"P",false,0.5);
836 TCollection_AsciiString Message2 (P.X());
837 TCollection_AsciiString Message3 (P.Y());
845 PostProcess(aDoc,ID_BUTTON_Test_11,TheDisplayType,Message);
848 // Function name : GeomSources::gpTest12
850 // Return type : void
851 // Argument : CGeometryDoc* aDoc
852 void GeomSources::gpTest12(CGeometryDoc* aDoc)
854 DisplayType TheDisplayType = No2D3D;
855 PreProcess(aDoc,TheDisplayType);
856 //==============================================================
859 Standard_Real distance, radius = 5;
860 Handle(Geom_Curve) C = new Geom_Circle(gp::XOY(),radius);
861 GeomAPI_ProjectPointOnCurve PPC (P,C);
862 N = PPC.NearestPoint();
863 Standard_Integer NbResults = PPC.NbPoints();
867 for(Standard_Integer i = 1;i<=NbResults;i++)
870 distance = PPC.Distance(i);
871 // do something with Q or distance here
875 //==============================================================
876 TCollection_AsciiString Message (" \
878 gp_Pnt N,Q,P(1,2,3); \n\
879 Standard_Real distance, radius = 5; \n\
880 Handle(Geom_Circle) C = new Geom_Circle(gp::XOY(),radius); \n\
881 GeomAPI_ProjectPointOnCurve PPC (P,C); \n\
882 N = PPC.NearestPoint(); \n\
883 Standard_Integer NbResults = PPC.NbPoints(); \n\
886 for(Standard_Integer i = 1;i<=NbResults;i++){ \n\
887 Q = PPC.Point(i); \n\
888 distance = PPC.Distance(i); \n\
889 // do something with Q or distance here \n\
893 AddSeparator(aDoc,Message);
894 //--------------------------------------------------------------
896 TCollection_AsciiString aString;
898 DisplayPoint(aDoc,P,"P",false,0.5);
900 TCollection_AsciiString Message2 (PPC.LowerDistance());
902 aString = "N : at Distance : ";
905 DisplayPoint(aDoc,N,aString.ToCString(),false,0.5,0,-0.5);
906 DisplayCurve(aDoc,C,Quantity_NOC_YELLOW,false);
910 for(Standard_Integer i = 1;i<=NbResults;i++)
913 distance = PPC.Distance(i);
914 TCollection_AsciiString Message3 (i);
915 TCollection_AsciiString Message4 (distance);
919 aString +=": at Distance : ";
921 DisplayPoint(aDoc,Q,aString.ToCString(),false,0.5);
925 PostProcess(aDoc,ID_BUTTON_Test_12,TheDisplayType,Message);
928 // Function name : GeomSources::gpTest13
930 // Return type : void
931 // Argument : CGeometryDoc* aDoc
932 void GeomSources::gpTest13(CGeometryDoc* aDoc)
934 DisplayType TheDisplayType = No2D3D;
935 PreProcess(aDoc,TheDisplayType);
937 //==============================================================
940 Standard_Real distance, radius = 5;
941 Handle(Geom_SphericalSurface) SP =
942 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius);
943 GeomAPI_ProjectPointOnSurf PPS(P,SP);
944 N = PPS.NearestPoint();
945 Standard_Integer NbResults = PPS.NbPoints();
948 for(Standard_Integer i = 1;i<=NbResults;i++)
951 distance = PPS.Distance(i);
952 // do something with Q or distance here
956 //==============================================================
957 TCollection_AsciiString Message (" \
959 gp_Pnt N,Q,P(7,8,9); \n\
960 Standard_Real distance, radius = 5; \n\
961 Handle(Geom_SphericalSurface) SP = \n\
962 new Geom_SphericalSurface(gp_Ax3(gp::XOY()),radius); \n\
963 GeomAPI_ProjectPointOnSurf PPS(P,SP); \n\
964 N = PPS.NearestPoint(); \n\
965 Standard_Integer NbResults = PPS.NbPoints(); \n\
967 for(Standard_Integer i = 1;i<=NbResults;i++){ \n\
968 Q = PPS.Point(i); \n\
969 distance = PPS.Distance(i); \n\
970 // do something with Q or distance here \n\
974 AddSeparator(aDoc,Message);
975 //--------------------------------------------------------------
976 TCollection_AsciiString aString;
978 DisplayPoint(aDoc,P,"P",false,0.5);
979 TCollection_AsciiString Message2 (PPS.LowerDistance());
981 aString = "N : at Distance : "; aString += Message2;
982 DisplayPoint(aDoc,N,aString.ToCString(),false,0.5,0,-0.6);
984 Handle(ISession_Surface) aSurface = new ISession_Surface(SP);
985 Handle(Prs3d_Drawer) CurDrawer = aSurface->Attributes();
986 CurDrawer->SetOwnLineAspects();
987 CurDrawer->UIsoAspect()->SetNumber(10);
988 CurDrawer->VIsoAspect()->SetNumber(10);
989 aDoc->GetAISContext()->SetLocalAttributes(aSurface, CurDrawer, Standard_False);
990 aDoc->GetAISContext()->Display(aSurface, Standard_False);
994 for(Standard_Integer i = 1;i<=NbResults;i++)
998 distance = PPS.Distance(i);
999 TCollection_AsciiString Message3 (i);
1000 TCollection_AsciiString Message4 (distance);
1003 aString += Message3;
1004 aString +=": at Distance : ";
1005 aString += Message4;
1007 DisplayPoint(aDoc,Q,aString.ToCString(),false,0.5);
1010 PostProcess(aDoc,ID_BUTTON_Test_13,TheDisplayType,Message);
1013 // Function name : GeomSources::gpTest14
1015 // Return type : void
1016 // Argument : CGeometryDoc* aDoc
1017 void GeomSources::gpTest14(CGeometryDoc* aDoc)
1019 DisplayType TheDisplayType = No2D3D;
1020 PreProcess(aDoc,TheDisplayType);
1021 //==============================================================
1024 gp_Ax3 theAxe(gp::XOY());
1026 Standard_Real MinorRadius = 5;
1027 Standard_Real MajorRadius = 8;
1028 gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius);
1029 IntAna_IntConicQuad ICQ
1030 (EL,PL,Precision::Angular(),Precision::Confusion());
1032 Standard_Integer NbResults = ICQ.NbPoints();
1034 for(Standard_Integer i = 1;i<=NbResults;i++){
1036 // do something with P here
1041 //==============================================================
1042 TCollection_AsciiString Message (" \
1045 gp_Pln PL (gp_Ax3(gp::XOY())); \n\
1046 Standard_Real MinorRadius = 5; \n\
1047 Standard_Real MajorRadius = 8; \n\
1048 gp_Elips EL (gp::YOZ(),MajorRadius,MinorRadius); \n\
1049 IntAna_IntConicQuad ICQ \n\
1050 (EL,PL,Precision::Angular(),Precision::Confusion()); \n\
1051 if (ICQ.IsDone()){ \n\
1052 Standard_Integer NbResults = ICQ.NbPoints(); \n\
1053 if (NbResults>0){ \n\
1054 for(Standard_Integer i = 1;i<=NbResults;i++){ \n\
1055 P = ICQ.Point(i); \n\
1056 // do something with P here \n\
1061 AddSeparator(aDoc,Message);
1062 //--------------------------------------------------------------
1064 Handle(Geom_Plane) aPlane = GC_MakePlane(PL).Value();
1065 Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);
1067 DisplaySurface(aDoc,aSurface);
1069 Handle(Geom_Curve) anEllips = GC_MakeEllipse(EL).Value();
1070 DisplayCurve(aDoc,anEllips,Quantity_NOC_YELLOW,false);
1072 TCollection_AsciiString aString;
1076 Standard_Integer NbResults = ICQ.NbPoints();
1079 for(Standard_Integer i = 1;i<=NbResults;i++)
1082 TCollection_AsciiString Message2(i);
1085 aString = "P";aString += Message2;
1086 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1091 PostProcess(aDoc,ID_BUTTON_Test_14,TheDisplayType,Message);
1094 // Function name : GeomSources::gpTest15
1096 // Return type : void
1097 // Argument : CGeometryDoc* aDoc
1098 void GeomSources::gpTest15(CGeometryDoc* aDoc)
1100 DisplayType TheDisplayType = No2D3D;
1101 PreProcess(aDoc,TheDisplayType);
1102 //==============================================================
1109 P1Copy.Transform(TRSF);
1111 //==============================================================
1112 TCollection_AsciiString Message (" \
1114 gp_Pnt P1(1,2,3); \n\
1115 gp_Pnt P1Copy = P1; \n\
1116 gp_Pnt P2(5,4,6); \n\
1118 TRSF.SetMirror(P2); \n\
1119 P1Copy.Transform(TRSF); \n\
1121 AddSeparator(aDoc,Message);
1122 //--------------------------------------------------------------
1124 DisplayPoint(aDoc,P1Copy,"P1Copy",false,0.5);
1125 DisplayPoint(aDoc,P1,"P1",false,0.5);
1126 DisplayPoint(aDoc,P2,"P2",false,0.5);
1128 PostProcess(aDoc,ID_BUTTON_Test_15,TheDisplayType,Message);
1131 // Function name : GeomSources::gpTest16
1133 // Return type : void
1134 // Argument : CGeometryDoc* aDoc
1135 void GeomSources::gpTest16(CGeometryDoc* aDoc)
1137 DisplayType TheDisplayType = No2D3D;
1138 PreProcess(aDoc,TheDisplayType);
1139 //==============================================================
1149 Standard_Boolean result =
1150 V1.IsOpposite(V2,Precision::Angular());
1151 // result should be true
1153 //==============================================================
1154 TCollection_AsciiString Message (" \
1156 gp_Pnt P1(1,2,3); \n\
1157 gp_Pnt P2(5,4,6); \n\
1158 gp_Vec V1 (P1,P2); \n\
1160 gp_Pnt P3(10,4,7); \n\
1161 gp_Pnt P4(2,0,1); \n\
1162 gp_Vec V2 (P3,P4); \n\
1164 Standard_Boolean result = \n\
1165 V1.IsOpposite(V2,Precision::Angular()); \n\
1166 // result should be true \n\
1168 AddSeparator(aDoc,Message);
1169 //--------------------------------------------------------------
1171 DisplayPoint(aDoc,P1,"P1",false,0.5);
1172 DisplayPoint(aDoc,P2,"P2",false,0.5);
1173 DisplayPoint(aDoc,P3,"P3",false,0.5);
1174 DisplayPoint(aDoc,P4,"P4",false,0.5);
1176 Handle(ISession_Direction) aDirection1 = new ISession_Direction(P1,V1);
1177 aDoc->GetAISContext()->Display(aDirection1, Standard_False);
1179 Handle(ISession_Direction) aDirection2 = new ISession_Direction(P3,V2);
1180 aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1182 Message += "result = ";
1183 if (result) Message += "True \n"; else Message += "False \n";
1185 PostProcess(aDoc,ID_BUTTON_Test_16,TheDisplayType,Message);
1188 // Function name : GeomSources::gpTest17
1190 // Return type : void
1191 // Argument : CGeometryDoc* aDoc
1192 void GeomSources::gpTest17(CGeometryDoc* aDoc)
1194 DisplayType TheDisplayType = No2D3D;
1195 PreProcess(aDoc,TheDisplayType);
1196 //==============================================================
1200 Standard_Real ang = D1.Angle(D2);
1201 // the result is in radians in the range [0,PI]
1203 //==============================================================
1204 TCollection_AsciiString Message (" \
1206 gp_Dir D1(1,2,3); \n\
1207 gp_Dir D2(3,4,5); \n\
1208 Standard_Real ang = D1.Angle(D2); \n\
1209 // the result is in radians in the range [0,PI] \n\
1211 AddSeparator(aDoc,Message);
1212 //--------------------------------------------------------------
1214 Handle(ISession_Direction) aDirection1 = new ISession_Direction(gp_Pnt(0,0,0),D1,3);
1215 aDoc->GetAISContext()->Display(aDirection1, Standard_False);
1217 Handle(ISession_Direction) aDirection2 = new ISession_Direction(gp_Pnt(0,0,0),D2,3);
1218 aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1220 std::cout<<" D1.Angle(D2) : "<<ang<<std::endl;
1222 TCollection_AsciiString Message2 (ang);
1223 TCollection_AsciiString Message3 (ang/M_PI/180);
1225 Message += " ang = ";
1226 Message += Message2;
1227 Message += " radian \n";
1228 Message += " ang/PI180 = ";
1229 Message += Message3;
1230 Message += " degree \n";
1232 PostProcess(aDoc,ID_BUTTON_Test_17,TheDisplayType,Message);
1235 // Function name : GeomSources::gpTest18
1237 // Return type : void
1238 // Argument : CGeometryDoc* aDoc
1239 void GeomSources::gpTest18(CGeometryDoc* aDoc)
1241 DisplayType TheDisplayType = a2DNo3D;
1242 PreProcess(aDoc,TheDisplayType);
1243 //==============================================================
1248 gp_Parab2d Para(A,6);
1249 // P is the vertex point
1250 // P and D give the axis of symmetry
1251 // 6 is the focal length of the parabola
1253 //==============================================================
1254 TCollection_AsciiString Message (" \
1256 gp_Pnt2d P(2,3); \n\
1257 gp_Dir2d D(4,5); \n\
1258 gp_Ax22d A(P,D); \n\
1259 gp_Parab2d Para(A,6); \n\
1260 // P is the vertex point \n\
1261 // P and D give the axis of symmetry \n\
1262 // 6 is the focal length of the parabola \n\
1264 AddSeparator(aDoc,Message);
1265 //--------------------------------------------------------------
1267 DisplayPoint(aDoc,P,"P",false,0.5,0,3);
1269 Handle(ISession_Direction) aDirection = new ISession_Direction(P,D,200);
1270 aDoc->GetISessionContext()->Display(aDirection,Standard_False);
1271 Handle(Geom2d_Parabola) aParabola = GCE2d_MakeParabola(Para);
1272 Handle(Geom2d_TrimmedCurve) aTrimmedCurve = new Geom2d_TrimmedCurve(aParabola,-100,100);
1273 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aTrimmedCurve);
1274 //aCurve->SetColorIndex(3);
1275 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1277 Message += " The entity A of type gp_Ax22d is not displayable \n ";
1278 Message += " The entity D of type gp_Dir2d is displayed as a vector \n ( mean with a length != 1 ) \n ";
1279 PostProcess(aDoc,ID_BUTTON_Test_18,TheDisplayType,Message);
1282 // Function name : GeomSources::gpTest19
1284 // Return type : void
1285 // Argument : CGeometryDoc* aDoc
1286 void GeomSources::gpTest19(CGeometryDoc* aDoc)
1288 DisplayType TheDisplayType = No2D3D;
1289 PreProcess(aDoc,TheDisplayType);
1290 //==============================================================
1295 Standard_Boolean IsDirectA = A.Direct();
1297 gp_Dir AXDirection = A.XDirection() ;
1298 gp_Dir AYDirection = A.YDirection() ;
1303 // axis3 is now left handed
1304 Standard_Boolean IsDirectA2 = A2.Direct();
1306 gp_Dir A2XDirection = A2.XDirection() ;
1307 gp_Dir A2YDirection = A2.YDirection() ;
1309 //==============================================================
1310 TCollection_AsciiString Message (" \
1312 gp_Pnt P1(2,3,4); \n\
1313 gp_Dir D(4,5,6); \n\
1315 Standard_Boolean IsDirectA = A.Direct(); \n\
1317 gp_Dir AXDirection = A.XDirection() ; \n\
1318 gp_Dir AYDirection = A.YDirection() ; \n\
1320 gp_Pnt P2(5,3,4); \n\
1321 gp_Ax3 A2(P2,D); \n\
1323 // axis3 is now left handed \n\
1324 Standard_Boolean IsDirectA2 = A2.Direct(); \n\
1326 gp_Dir A2XDirection = A2.XDirection() ; \n\
1327 gp_Dir A2YDirection = A2.YDirection() ; \n\
1329 AddSeparator(aDoc,Message);
1330 //--------------------------------------------------------------
1332 // Set style for vector lines
1333 Handle(Prs3d_LineAspect) anAxesAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
1335 DisplayPoint(aDoc,P1,"P1",false,0.1);
1336 Handle(ISession_Direction) aDirection = new ISession_Direction(P1,D,2);
1337 aDoc->GetAISContext()->Display(aDirection, Standard_False);
1339 Handle(ISession_Direction) aDirection2 = new ISession_Direction(P1,AXDirection,2);
1340 aDirection2->SetText("A.XDirection");
1341 aDirection2->SetLineAspect (anAxesAspect);
1342 aDoc->GetAISContext()->Display(aDirection2, Standard_False);
1343 Handle(ISession_Direction) aDirection3 = new ISession_Direction(P1,AYDirection,2);
1344 aDirection3->SetText("A.YDirection");
1345 aDirection3->SetLineAspect (anAxesAspect);
1346 aDoc->GetAISContext()->Display(aDirection3, Standard_False);
1348 DisplayPoint(aDoc,P2,"P2",false,0.1);
1349 Handle(ISession_Direction) aDirection4 = new ISession_Direction(P2,D,2);
1350 aDoc->GetAISContext()->Display(aDirection4, Standard_False);
1352 Handle(ISession_Direction) aDirection5 = new ISession_Direction(P2,A2XDirection,2);
1353 aDirection5->SetText("A2 XDirection");
1354 aDirection5->SetLineAspect (anAxesAspect);
1355 aDoc->GetAISContext()->Display(aDirection5, Standard_False);
1356 Handle(ISession_Direction) aDirection6 = new ISession_Direction(P2,A2YDirection,2);
1357 aDirection6->SetText("A2 YDirection");
1358 aDirection6->SetLineAspect (anAxesAspect);
1359 aDoc->GetAISContext()->Display(aDirection6, Standard_False);
1361 Message += "IsDirectA = ";
1363 Message += "True = Right Handed \n";
1365 Message += "False = Left Handed \n";
1367 Message += "IsDirectA2 = ";
1369 Message += "True = Right Handed \n";
1371 Message += "False = Left Handed \n";
1373 PostProcess(aDoc,ID_BUTTON_Test_19,TheDisplayType,Message);
1376 // Function name : GeomSources::gpTest20
1378 // Return type : void
1379 // Argument : CGeometryDoc* aDoc
1380 void GeomSources::gpTest20(CGeometryDoc* aDoc)
1382 DisplayType TheDisplayType = a2DNo3D;
1383 PreProcess(aDoc,TheDisplayType);
1384 //==============================================================
1386 TColgp_Array1OfPnt2d array (1,5); // sizing array
1387 array.SetValue(1,gp_Pnt2d (0,0));
1388 array.SetValue(2,gp_Pnt2d (1,2));
1389 array.SetValue(3,gp_Pnt2d (2,3));
1390 array.SetValue(4,gp_Pnt2d (4,3));
1391 array.SetValue(5,gp_Pnt2d (5,5));
1392 Handle(Geom2d_BSplineCurve) SPL1 =
1393 Geom2dAPI_PointsToBSpline(array);
1395 Handle(TColgp_HArray1OfPnt2d) harray =
1396 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1397 harray->SetValue(1,gp_Pnt2d (7+ 0,0));
1398 harray->SetValue(2,gp_Pnt2d (7+ 1,2));
1399 harray->SetValue(3,gp_Pnt2d (7+ 2,3));
1400 harray->SetValue(4,gp_Pnt2d (7+ 4,3));
1401 harray->SetValue(5,gp_Pnt2d (7+ 5,5));
1402 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);
1403 anInterpolation.Perform();
1404 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();
1406 Handle(TColgp_HArray1OfPnt2d) harray2 =
1407 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1408 harray2->SetValue(1,gp_Pnt2d (11+ 0,0));
1409 harray2->SetValue(2,gp_Pnt2d (11+ 1,2));
1410 harray2->SetValue(3,gp_Pnt2d (11+ 2,3));
1411 harray2->SetValue(4,gp_Pnt2d (11+ 4,3));
1412 harray2->SetValue(5,gp_Pnt2d (11+ 5,5));
1413 Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01);
1414 anInterpolation2.Perform();
1415 Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve();
1416 // redefined C++ operator allows these assignments
1418 //==============================================================
1419 TCollection_AsciiString Message (" \
1421 TColgp_Array1OfPnt2d array (1,5); // sizing array \n\
1422 array.SetValue(1,gp_Pnt2d (0,0)); \n\
1423 array.SetValue(2,gp_Pnt2d (1,2)); \n\
1424 array.SetValue(3,gp_Pnt2d (2,3)); \n\
1425 array.SetValue(4,gp_Pnt2d (4,3)); \n\
1426 array.SetValue(5,gp_Pnt2d (5,5)); \n\
1427 Handle(Geom2d_BSplineCurve) SPL1 = \n\
1428 Geom2dAPI_PointsToBSpline(array); \n\
1430 Handle(TColgp_HArray1OfPnt2d) harray = \n\
1431 new TColgp_HArray1OfPnt2d (1,5); // sizing harray \n\
1432 harray->SetValue(1,gp_Pnt2d (7+ 0,0)); \n\
1433 harray->SetValue(2,gp_Pnt2d (7+ 1,2)); \n\
1434 harray->SetValue(3,gp_Pnt2d (7+ 2,3)); \n\
1435 harray->SetValue(4,gp_Pnt2d (7+ 4,3)); \n\
1436 harray->SetValue(5,gp_Pnt2d (7+ 5,5)); \n\
1437 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01); \n\
1438 anInterpolation.Perform(); \n\
1439 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve(); \n\
1441 Handle(TColgp_HArray1OfPnt2d) harray2 = \n\
1442 new TColgp_HArray1OfPnt2d (1,5); // sizing harray \n");
1444 harray2->SetValue(1,gp_Pnt2d (11+ 0,0)); \n\
1445 harray2->SetValue(2,gp_Pnt2d (11+ 1,2)); \n\
1446 harray2->SetValue(3,gp_Pnt2d (11+ 2,3)); \n\
1447 harray2->SetValue(4,gp_Pnt2d (11+ 4,3)); \n\
1448 harray2->SetValue(5,gp_Pnt2d (11+ 5,5)); \n\
1449 Geom2dAPI_Interpolate anInterpolation2(harray2,Standard_True,0.01); \n\
1450 anInterpolation2.Perform(); \n\
1451 Handle(Geom2d_BSplineCurve) SPL3 = anInterpolation2.Curve(); \n\
1452 // redefined C++ operator allows these assignments \n\
1454 AddSeparator(aDoc,Message);
1455 //--------------------------------------------------------------
1456 TCollection_AsciiString aString;
1457 for(int i = array.Lower();i<=array.Upper();i++)
1459 gp_Pnt2d P = array(i);
1460 TCollection_AsciiString Message2 (i);
1461 aString = "array ";aString += Message2;
1462 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1464 for( int i = harray->Lower();i<=harray->Upper();i++)
1466 gp_Pnt2d P = harray->Value(i);
1467 TCollection_AsciiString Message2 (i);
1468 aString = "harray ";aString += Message2;
1469 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1471 for( int i = harray2->Lower();i<=harray2->Upper();i++)
1473 gp_Pnt2d P = harray2->Value(i);
1474 TCollection_AsciiString Message2 (i);
1475 aString = "harray2 ";aString += Message2;
1476 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1481 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1482 aCurve->SetColorIndex(3);
1483 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1486 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL1.IsNull()", L"CasCade Error", MB_ICONERROR);
1490 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL2);
1491 aCurve2->SetColorIndex(5);
1492 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1495 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL2.IsNull()", L"CasCade Error", MB_ICONERROR);
1499 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL3);
1500 aCurve2->SetColorIndex(6);
1501 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1504 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL3.IsNull()", L"CasCade Error", MB_ICONERROR);
1506 Message += " SPL1 is Red \n";
1507 Message += " SPL2 is Blue \n";
1508 Message += " SPL3 is Yellow \n";
1510 PostProcess(aDoc,ID_BUTTON_Test_20,TheDisplayType,Message);
1513 void GeomSources::gpTest21(CGeometryDoc* aDoc)
1515 DisplayType TheDisplayType = a2DNo3D;
1516 PreProcess(aDoc,TheDisplayType);
1518 //==============================================================
1520 gp_Pnt2d P1(-184, 101);
1521 gp_Pnt2d P2(20 ,84);
1522 Standard_Real aheight = 1;
1523 FairCurve_Batten B (P1,P2,aheight);
1524 B.SetAngle1(22*M_PI/180);
1525 B.SetAngle2(44*M_PI/180);
1526 FairCurve_AnalysisCode anAnalysisCode;
1527 B.Compute(anAnalysisCode);
1528 Handle(Geom2d_BSplineCurve) C = B.Curve();
1530 //==============================================================
1531 TCollection_AsciiString Message (" \
1533 gp_Pnt2d P1(-184, 101); \n\
1534 gp_Pnt2d P2(20 ,84); \n\
1535 Standard_Real aheight = 1; \n\
1536 FairCurve_Batten B (P1,P2,aheight); \n\
1537 B.SetAngle1(22*PI180); \n\
1538 B.SetAngle2(44*PI180); \n\
1539 FairCurve_AnalysisCode anAnalysisCode; \n\
1540 B.Compute(anAnalysisCode); \n\
1541 Handle(Geom2d_BSplineCurve) C = B.Curve(); \n\
1543 AddSeparator(aDoc,Message);
1544 //--------------------------------------------------------------
1546 DisplayCurveAndCurvature(aDoc,C,6,Standard_False);
1548 PostProcess(aDoc,ID_BUTTON_Test_21,TheDisplayType,Message);
1551 void GeomSources::gpTest22(CGeometryDoc* aDoc)
1553 DisplayType TheDisplayType = a2DNo3D;
1554 PreProcess(aDoc,TheDisplayType);
1556 //==============================================================
1558 gp_Pnt2d P1(-184, 41);
1559 gp_Pnt2d P2(20 ,24);
1560 Standard_Real aheight = 1;
1561 FairCurve_MinimalVariation MV (P1,P2,aheight);
1562 MV.SetAngle1(22*M_PI/180);
1563 MV.SetAngle2(44*M_PI/180);
1565 FairCurve_AnalysisCode anAnalysisCode;
1566 MV.Compute(anAnalysisCode);
1568 Handle(Geom2d_BSplineCurve) C = MV.Curve();
1570 //==============================================================
1571 TCollection_AsciiString Message (" \
1573 gp_Pnt2d P1(-184, 41); \n\
1574 gp_Pnt2d P2(20 ,24); \n\
1575 Standard_Real aheight = 1; \n\
1576 FairCurve_MinimalVariation MV (P1,P2,aheight); \n\
1577 MV.SetAngle1(22*PI180); \n\
1578 MV.SetAngle2(44*PI180); \n\
1580 FairCurve_AnalysisCode anAnalysisCode; \n\
1581 MV.Compute(anAnalysisCode); \n\
1583 Handle(Geom2d_BSplineCurve) C = MV.Curve(); \n\
1585 AddSeparator(aDoc,Message);
1586 //--------------------------------------------------------------
1588 DisplayCurveAndCurvature(aDoc,C,7,Standard_False);
1589 DisplayPoint(aDoc,P1,"P1",false,0.5);
1590 DisplayPoint(aDoc,P2,"P2",false,0.5);
1592 PostProcess(aDoc,ID_BUTTON_Test_22,TheDisplayType,Message);
1595 // Function name : GeomSources::gpTest23
1597 // Return type : void
1598 // Argument : CGeometryDoc* aDoc
1599 void GeomSources::gpTest23(CGeometryDoc* aDoc)
1601 DisplayType TheDisplayType = a2DNo3D;
1602 PreProcess(aDoc,TheDisplayType);
1603 //==============================================================
1605 Standard_Real major = 12;
1606 Standard_Real minor = 4;
1607 gp_Ax2d axis = gp::OX2d();
1608 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor);
1609 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2);
1611 // The segment goes in the direction Vfrom P1
1612 // to the point projected on this line by P2
1613 // In the example (0,6).
1614 Handle(Geom2d_BSplineCurve) SPL =
1615 Geom2dConvert::CurveToBSplineCurve(TC);
1617 //==============================================================
1618 TCollection_AsciiString Message (" \
1620 Standard_Real major = 12; \n\
1621 Standard_Real minor = 4; \n\
1622 gp_Ax2d axis = gp::OX2d(); \n\
1623 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse (axis,major,minor); \n\
1625 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve(E,-1,2); \n\
1627 // The segment goes in the direction Vfrom P1 \n\
1628 // to the point projected on this line by P2 \n\
1629 // In the example (0,6). \n\
1630 Handle(Geom2d_BSplineCurve) SPL = \n\
1631 Geom2dConvert::CurveToBSplineCurve(TC); \n\
1633 AddSeparator(aDoc,Message);
1634 //--------------------------------------------------------------
1636 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
1637 aCurve->SetColorIndex(3); // Red
1638 aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
1639 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1641 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(SPL);
1642 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1644 PostProcess(aDoc,ID_BUTTON_Test_23,TheDisplayType,Message);
1647 // Function name : GeomSources::gpTest24
1649 // Return type : void
1650 // Argument : CGeometryDoc* aDoc
1651 void GeomSources::gpTest24(CGeometryDoc* aDoc)
1653 DisplayType TheDisplayType = a2D3D;
1654 PreProcess(aDoc,TheDisplayType);
1655 //==============================================================
1657 Standard_Real radius = 5;
1658 gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0));
1660 Handle(Geom2d_Circle) circ2d =
1661 new Geom2d_Circle(ax2d,radius);
1663 gp_Ax2d circ2dXAxis = circ2d->XAxis();
1665 // create a 3D curve in a given plane
1666 Handle(Geom_Curve) C3D =
1667 GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY())));
1668 Handle(Geom_Circle) C3DCircle =
1669 Handle(Geom_Circle)::DownCast(C3D);
1671 gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis();
1673 // project it to a 2D curve in another plane
1675 gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 ));
1677 Handle(Geom2d_Curve) C2D =
1678 GeomAPI::To2d(C3D,ProjectionPlane);
1680 Handle(Geom2d_Circle) C2DCircle =
1681 Handle(Geom2d_Circle)::DownCast(C2D);
1682 gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis();
1684 //==============================================================
1685 TCollection_AsciiString Message (" \
1687 Standard_Real radius = 5; \n\
1688 gp_Ax2d ax2d(gp_Pnt2d(2,3),gp_Dir2d(1,0)); \n\
1690 Handle(Geom2d_Circle) circ2d = \n\
1691 new Geom2d_Circle(ax2d,radius); \n\
1693 gp_Ax2d circ2dXAxis = circ2d->XAxis(); \n\
1695 // create a 3D curve in a given plane \n\
1696 Handle(Geom_Curve) C3D = \n\
1697 GeomAPI::To3d(circ2d,gp_Pln(gp_Ax3(gp::XOY()))); \n\
1698 Handle(Geom_Circle) C3DCircle = \n\
1699 Handle(Geom_Circle)::DownCast(C3D); \n\
1701 gp_Ax1 C3DCircleXAxis = C3DCircle->XAxis(); \n\
1703 // project it to a 2D curve in another plane \n\
1705 gp_Pln ProjectionPlane(gp_Pnt(1,1,0),gp_Dir( 1,1,1 )); \n\
1707 Handle(Geom2d_Curve) C2D = \n\
1708 GeomAPI::To2d(C3D,ProjectionPlane); \n\
1710 Handle(Geom2d_Circle) C2DCircle = \n\
1711 Handle(Geom2d_Circle)::DownCast(C2D); \n\
1712 gp_Ax2d C2DCircleXAxis = C2DCircle->XAxis(); \n\
1714 AddSeparator(aDoc,Message);
1715 //--------------------------------------------------------------
1716 Handle(Geom_Plane) aPlane = GC_MakePlane(gp_Pln(gp_Ax3(gp::XOY()))).Value();
1717 Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-8.,8.,-12.,12.);
1718 DisplaySurface(aDoc,aSurface);
1720 Handle(Geom_Plane) aProjectionPlane = GC_MakePlane(ProjectionPlane).Value();
1721 Handle(Geom_RectangularTrimmedSurface) aProjectionPlaneSurface=
1722 new Geom_RectangularTrimmedSurface(aProjectionPlane,-8.,8.,-12.,12.);
1724 DisplaySurface(aDoc,aProjectionPlaneSurface);
1726 Standard_CString aC3DEntityTypeName = C3D->DynamicType()->Name();
1727 Standard_CString aC2DEntityTypeName = C2D->DynamicType()->Name();
1729 Message += " C3D->DynamicType()->Name() = ";
1730 Message += aC3DEntityTypeName; Message += " \n";
1731 Message += " C2D->DynamicType()->Name() = ";
1732 Message += aC2DEntityTypeName; Message += " \n";
1734 DisplayCurve(aDoc,circ2d,4,false);
1735 DisplayCurve(aDoc,C3D,Quantity_NOC_YELLOW,false);
1736 DisplayCurve(aDoc,C2D,5,false);
1738 Handle(ISession_Direction) aC3DCircleXAxisDirection = new ISession_Direction(C3DCircleXAxis.Location(),C3DCircleXAxis.Direction(),5.2);
1739 aDoc->GetAISContext()->Display(aC3DCircleXAxisDirection, Standard_False);
1741 Handle(ISession_Direction) acirc2dXAxisDirection = new ISession_Direction(circ2dXAxis.Location(),circ2dXAxis.Direction(),5.2);
1742 aDoc->GetISessionContext()->Display(acirc2dXAxisDirection, Standard_False);
1744 Handle(ISession_Direction) aC2DCircleXAxisDirection = new ISession_Direction(C2DCircleXAxis.Location(),C2DCircleXAxis.Direction(),5.2);
1745 aDoc->GetISessionContext()->Display(aC2DCircleXAxisDirection, Standard_False);
1747 PostProcess(aDoc,ID_BUTTON_Test_24,TheDisplayType,Message);
1750 // Function name : GeomSources::gpTest25
1752 // Return type : void
1753 // Argument : CGeometryDoc* aDoc
1754 void GeomSources::gpTest25(CGeometryDoc* aDoc)
1756 DisplayType TheDisplayType = a2DNo3D;
1757 PreProcess(aDoc,TheDisplayType);
1759 //==============================================================
1761 Handle(TColgp_HArray1OfPnt2d) harray =
1762 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
1763 harray->SetValue(1,gp_Pnt2d (0,0));
1764 harray->SetValue(2,gp_Pnt2d (-3,1));
1765 harray->SetValue(3,gp_Pnt2d (-2,5));
1766 harray->SetValue(4,gp_Pnt2d (2,9));
1767 harray->SetValue(5,gp_Pnt2d (-4,14));
1769 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01);
1770 anInterpolation.Perform();
1771 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve();
1775 gp_Dir2d V1 = gp::DY2d();
1776 Handle(Geom2d_TrimmedCurve) TC1 =
1777 GCE2d_MakeSegment(P1,V1,P2);
1779 Standard_Real tolerance = Precision::Confusion();
1780 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance);
1781 Standard_Integer NbPoints =ICC.NbPoints();
1784 for (Standard_Integer k = 1;k<=NbPoints;k++)
1787 // do something with each intersection point
1790 //==============================================================
1791 TCollection_AsciiString Message (" \
1793 Handle(TColgp_HArray1OfPnt2d) harray = \n\
1794 new TColgp_HArray1OfPnt2d (1,5); // sizing harray \n\
1795 harray->SetValue(1,gp_Pnt2d (0,0)); \n\
1796 harray->SetValue(2,gp_Pnt2d (-3,1)); \n\
1797 harray->SetValue(3,gp_Pnt2d (-2,5)); \n\
1798 harray->SetValue(4,gp_Pnt2d (2,9)); \n\
1799 harray->SetValue(5,gp_Pnt2d (-4,14)); \n\
1801 Geom2dAPI_Interpolate anInterpolation(harray,Standard_False,0.01); \n\
1802 anInterpolation.Perform(); \n\
1803 Handle(Geom2d_BSplineCurve) SPL = anInterpolation.Curve(); \n\
1805 gp_Pnt2d P1(-1,-2); \n\
1806 gp_Pnt2d P2(0,15); \n\
1807 gp_Dir2d V1 = gp::DY2d(); \n\
1808 Handle(Geom2d_TrimmedCurve) TC1= \n\
1809 GCE2d_MakeSegment(P1,V1,P2); \n\
1811 Standard_Real tolerance = Precision::Confusion(); \n\
1812 Geom2dAPI_InterCurveCurve ICC (SPL,TC1,tolerance); \n\
1813 Standard_Integer NbPoints =ICC.NbPoints(); \n\
1815 for (Standard_Integer k = 1;k<=NbPoints;k++) \n\
1817 PK = ICC.Point(k); \n\
1818 // do something with each intersection point \n\
1821 AddSeparator(aDoc,Message);
1822 //--------------------------------------------------------------
1824 Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL);
1825 aCurve1->SetDisplayPole(Standard_False);
1826 aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
1827 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC1);
1828 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1830 TCollection_AsciiString aString;
1831 for (Standard_Integer i = 1;i<=NbPoints;i++)
1834 // do something with each intersection point
1835 TCollection_AsciiString Message2 (i);
1836 TCollection_AsciiString Message3 (PK.X());
1837 TCollection_AsciiString Message4 (PK.Y());
1839 aString += Message2;
1841 DisplayPoint(aDoc,PK,aString.ToCString(),false,0.5);
1844 Message += Message2;
1846 Message += Message3;
1848 Message += Message4;
1852 PostProcess(aDoc,ID_BUTTON_Test_25,TheDisplayType,Message);
1855 // Function name : GeomSources::gpTest26
1857 // Return type : void
1858 // Argument : CGeometryDoc* aDoc
1859 void GeomSources::gpTest26(CGeometryDoc* aDoc)
1861 DisplayType TheDisplayType = a2DNo3D;
1862 PreProcess(aDoc,TheDisplayType);
1864 //==============================================================
1866 //----------- Build TC1 -----------------------
1867 gp_Pnt2d P1(0,0); gp_Pnt2d P2(2,6);
1868 gp_Dir2d V1 = gp::DY2d();
1869 Handle(Geom2d_TrimmedCurve) TC1 = GCE2d_MakeSegment(P1,V1,P2);
1870 Standard_Real FP1 = TC1->FirstParameter();
1871 Standard_Real LP1 = TC1->LastParameter();
1872 //----------- Build TC2 -----------------------
1873 gp_Pnt2d P3(-9,6.5); gp_Dir2d V2 = gp::DX2d();
1874 Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2);
1875 Standard_Real FP2 = TC1->FirstParameter();
1876 Standard_Real LP2 = TC1->LastParameter();
1877 //----------- Extrema TC1 / TC2 ---------------
1878 Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2);
1879 Standard_Real shortestdistance =-1;
1880 if (ECC.NbExtrema() != 0) shortestdistance = ECC.LowerDistance();
1881 //----------- Build SPL1 ----------------------
1882 TColgp_Array1OfPnt2d array (1,5); // sizing array
1883 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));
1884 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));
1885 array.SetValue(5,gp_Pnt2d (-3,5));
1886 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);
1887 Standard_Real FPSPL1 = SPL1->FirstParameter();
1888 Standard_Real LPSPL1 = SPL1->LastParameter();
1889 //----------- Extrema TC1 / SPL1 -------------
1890 Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1);
1891 Standard_Real SPL1shortestdistance =-1;
1892 if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance();
1893 Standard_Integer NbExtrema = ECC2.NbExtrema();
1894 TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2);
1895 for(int i=1;i <= NbExtrema; i++)
1898 ECC2.Points(i,P1x,P2x);
1899 aSolutionArray(i,1) = P1x;
1900 aSolutionArray(i,2) = P2x;
1903 //==============================================================
1904 TCollection_AsciiString Message (" \
1905 //----------- Build TC1 ----------------------- \n\
1906 gp_Pnt2d P1(0,0); gp_Pnt2d P2(2,6); \n\
1907 gp_Dir2d V1 = gp::DY2d(); \n\
1908 Handle(Geom2d_TrimmedCurve) TC1 = GCE2d_MakeSegment(P1,V1,P2); \n\
1909 Standard_Real FP1 = TC1->FirstParameter(); \n\
1910 Standard_Real LP1 = TC1->LastParameter(); \n\
1911 //----------- Build TC2 ----------------------- \n\
1912 gp_Pnt2d P3(-9,6.5); gp_Dir2d V2 = gp::DX2d(); \n\
1913 Handle(Geom2d_TrimmedCurve) TC2 = GCE2d_MakeSegment(P3,V2,P2); \n\
1914 Standard_Real FP2 = TC1->FirstParameter(); \n\
1915 Standard_Real LP2 = TC1->LastParameter(); \n\
1916 //----------- Extrema TC1 / TC2 --------------- \n\
1917 Geom2dAPI_ExtremaCurveCurve ECC (TC1,TC2, FP1,LP1, FP2,LP2); \n\
1918 Standard_Real shortestdistance =-1; \n\
1919 if (ECC.NbExtrema() != 0) shortestdistance = ECC.LowerDistance(); \n\
1920 //----------- Build SPL1 ---------------------- \n\
1921 TColgp_Array1OfPnt2d array (1,5); // sizing array \n\
1922 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2)); \n\
1923 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3)); \n\
1924 array.SetValue(5,gp_Pnt2d (-3,5)); \n\
1925 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array); \n\
1926 Standard_Real FPSPL1 = SPL1->FirstParameter(); \n");
1928 Standard_Real LPSPL1 = SPL1->LastParameter(); \n\
1929 //----------- Extrema TC1 / SPL1 ------------- \n\
1930 Geom2dAPI_ExtremaCurveCurve ECC2 (TC1,SPL1, FP1,LP1, FPSPL1,LPSPL1); \n\
1931 Standard_Real SPL1shortestdistance =-1; \n\
1932 if (ECC2.NbExtrema()!=0) SPL1shortestdistance = ECC2.LowerDistance(); \n\
1933 Standard_Integer NbExtrema = ECC2.NbExtrema(); \n\
1934 TColgp_Array2OfPnt2d aSolutionArray(1,NbExtrema,1,2); \n\
1935 for(int i=1;i <= NbExtrema; i++) { \n\
1937 ECC2.Points(i,P1,P2); \n\
1938 aSolutionArray(i,1) = P1; aSolutionArray(i,2) = P2; } \n";
1939 AddSeparator(aDoc,Message);
1940 //--------------------------------------------------------------
1942 TCollection_AsciiString aString;
1943 for(int i = array.Lower();i<=array.Upper();i++)
1945 TCollection_AsciiString Message2 (i);
1946 gp_Pnt2d P = array(i);
1948 aString += Message2;
1949 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
1954 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(SPL1);
1955 aCurve->SetDisplayPole(Standard_False);
1956 aCurve->SetColorIndex(3);
1957 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
1960 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"SPL1.IsNull()", L"CasCade Error", MB_ICONERROR);
1962 Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(TC1);
1963 aCurve1->SetColorIndex(6);
1964 aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
1965 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(TC2);
1966 aCurve2->SetColorIndex(5);
1967 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
1969 for(int i=1;i <= NbExtrema; i++)
1971 gp_Pnt2d P1x =aSolutionArray(i,1);
1973 TCollection_AsciiString Message2 (i);
1975 aString += Message2;
1976 DisplayPoint(aDoc,P1x,aString.ToCString(),false,0.7*i);
1978 gp_Pnt2d P2x = aSolutionArray(i,2);
1980 Handle(Geom2d_TrimmedCurve) SolutionCurve =
1981 GCE2d_MakeSegment(P1x,P2x);
1982 Handle(ISession2D_Curve) aSolutionCurve = new ISession2D_Curve(SolutionCurve);
1983 aDoc->GetISessionContext()->Display(aSolutionCurve, Standard_False);
1986 Message += "TC1 is Yellow ,TC2 is Blue ,SPL1 is Red \n";
1987 Message += "ECC.NbExtrema() = ";
1988 Message += ECC.NbExtrema();
1989 Message += " shortestdistance = ";
1990 Message+= shortestdistance;
1992 Message += "ECC2.NbExtrema() = ";
1993 Message += NbExtrema;
1994 Message += " SPL1shortestdistance = ";
1995 Message+= SPL1shortestdistance;
1998 PostProcess(aDoc,ID_BUTTON_Test_26,TheDisplayType,Message);
2001 // Function name : GeomSources::gpTest27
2003 // Return type : void
2004 // Argument : CGeometryDoc* aDoc
2005 void GeomSources::gpTest27(CGeometryDoc* aDoc)
2007 DisplayType TheDisplayType = a2DNo3D;
2008 PreProcess(aDoc,TheDisplayType);
2009 //==============================================================
2011 TColgp_Array1OfPnt2d array (1,5); // sizing array
2012 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2));
2013 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3));
2014 array.SetValue(5,gp_Pnt2d (-3,5));
2015 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array);
2017 Standard_Real dist = 1;
2018 Handle(Geom2d_OffsetCurve) OC =
2019 new Geom2d_OffsetCurve(SPL1,dist);
2020 Standard_Boolean result = OC->IsCN(2);
2021 Standard_Real dist2 = 1.5;
2022 Handle(Geom2d_OffsetCurve) OC2 =
2023 new Geom2d_OffsetCurve(SPL1,dist2);
2024 Standard_Boolean result2 = OC2->IsCN(2);
2026 //==============================================================
2027 TCollection_AsciiString Message (" \
2029 TColgp_Array1OfPnt2d array (1,5); // sizing array \n\
2030 array.SetValue(1,gp_Pnt2d (-4,0)); array.SetValue(2,gp_Pnt2d (-7,2)); \n\
2031 array.SetValue(3,gp_Pnt2d (-6,3)); array.SetValue(4,gp_Pnt2d (-4,3)); \n\
2032 array.SetValue(5,gp_Pnt2d (-3,5)); \n\
2033 Handle(Geom2d_BSplineCurve) SPL1 = Geom2dAPI_PointsToBSpline(array); \n\
2035 Standard_Real dist = 1; \n\
2036 Handle(Geom2d_OffsetCurve) OC = \n\
2037 new Geom2d_OffsetCurve(SPL1,dist); \n\
2038 Standard_Boolean result = OC->IsCN(2); \n\
2040 Standard_Real dist2 = 1.5; \n\
2041 Handle(Geom2d_OffsetCurve) OC2 = \n\
2042 new Geom2d_OffsetCurve(SPL1,dist2); \n\
2043 Standard_Boolean result2 = OC2->IsCN(2); \n\
2045 AddSeparator(aDoc,Message);
2046 //--------------------------------------------------------------
2047 Handle(ISession2D_Curve) aCurve1 = new ISession2D_Curve(SPL1);
2048 aCurve1->SetColorIndex(6);
2049 aDoc->GetISessionContext()->Display(aCurve1, Standard_False);
2050 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(OC);
2051 aCurve2->SetColorIndex(5);
2052 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2053 Handle(ISession2D_Curve) aCurve3 = new ISession2D_Curve(OC2);
2054 aCurve3->SetColorIndex(3);
2055 aDoc->GetISessionContext()->Display(aCurve3, Standard_False);
2058 Message += "SPL1 is Yellow \n";
2059 Message += "OC is Blue \n";
2060 Message += "OC2 is Red \n\n";
2061 Message += " Warning, Continuity is not guaranteed : \n ";
2063 Message += " result = True \n";
2065 Message += " result = False \n";
2067 Message += " result2 = True \n";
2069 Message += " result2 = False \n";
2071 PostProcess(aDoc,ID_BUTTON_Test_27,TheDisplayType,Message);
2074 // Function name : GeomSources::gpTest28
2076 // Return type : void
2077 // Argument : CGeometryDoc* aDoc
2078 void GeomSources::gpTest28(CGeometryDoc* aDoc)
2080 DisplayType TheDisplayType = a2DNo3D;
2081 PreProcess(aDoc,TheDisplayType);
2082 //==============================================================
2086 gp_Lin2d L = gce_MakeLin2d(P1,P2);
2087 // assignment by overloaded operator
2089 //==============================================================
2090 TCollection_AsciiString Message (" \
2092 gp_Pnt2d P1(1,2); \n\
2093 gp_Pnt2d P2(4,5); \n\
2094 gp_Lin2d L = gce_MakeLin2d(P1,P2); \n\
2095 // assignment by overloaded operator \n\
2097 AddSeparator(aDoc,Message);
2098 //--------------------------------------------------------------
2100 DisplayPoint(aDoc,P1,"P1",false,0.5);
2101 DisplayPoint(aDoc,P2,"P2",false,0.5);
2103 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-3,8);
2104 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2105 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2107 PostProcess(aDoc,ID_BUTTON_Test_28,TheDisplayType,Message);
2110 // Function name : GeomSources::gpTest29
2112 // Return type : void
2113 // Argument : CGeometryDoc* aDoc
2114 void GeomSources::gpTest29(CGeometryDoc* aDoc)
2116 DisplayType TheDisplayType = a2DNo3D;
2117 PreProcess(aDoc,TheDisplayType);
2119 //==============================================================
2124 GccAna_Pnt2dBisec B(P1,P2);
2127 L = B.ThisSolution();
2130 //==============================================================
2131 TCollection_AsciiString Message (" \
2133 gp_Pnt2d P1(1,2); \n\
2134 gp_Pnt2d P2(4,5); \n\
2136 GccAna_Pnt2dBisec B(P1,P2); \n\
2139 L = B.ThisSolution(); \n\
2142 AddSeparator(aDoc,Message);
2143 //--------------------------------------------------------------
2145 DisplayPoint(aDoc,P1,"P1",false,0.5);
2146 DisplayPoint(aDoc,P2,"P2",false,0.5);
2150 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-8,8);
2151 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aLine);
2152 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2155 if (B.IsDone()) Message += " \n B Is Done ";
2156 else Message += " \n B Is not Done ";
2157 PostProcess(aDoc,ID_BUTTON_Test_29,TheDisplayType,Message);
2160 // Function name : GeomSources::gpTest30
2162 // Return type : void
2163 // Argument : CGeometryDoc* aDoc
2164 void GeomSources::gpTest30(CGeometryDoc* aDoc)
2166 DisplayType TheDisplayType =a2DNo3D ;
2167 PreProcess(aDoc,TheDisplayType);
2169 //==============================================================
2174 gp_Pnt2d P4 (10,10);
2175 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);
2176 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);
2177 GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion());
2180 Standard_Integer NbSol = LT.NbSolutions();
2181 for(Standard_Integer k=1; k<=NbSol; k++)
2183 gp_Lin2d L = LT.ThisSolution(k);
2184 // do something with L
2188 //==============================================================
2189 TCollection_AsciiString Message (" \
2191 gp_Pnt2d P1 (2,3); \n\
2192 gp_Pnt2d P2 (4,4); \n\
2193 gp_Pnt2d P3 (6,7); \n\
2194 gp_Pnt2d P4 (10,10); \n\
2195 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3); \n\
2196 GccEnt_QualifiedCirc QC = GccEnt::Outside(C); \n\
2197 GccAna_Lin2d2Tan LT (QC,P4,Precision::Confusion()); \n\
2198 Standard_Integer NbSol; \n\
2199 if (LT.IsDone()) \n\
2201 NbSol = LT.NbSolutions(); \n\
2202 for(Standard_Integer k=1; k<=NbSol; k++) \n\
2204 gp_Lin2d L = LT.ThisSolution(k); \n\
2205 // do something with L \n\
2209 AddSeparator(aDoc,Message);
2210 //--------------------------------------------------------------
2212 DisplayPoint(aDoc,P1,"P1",false,0.5,-1,0.1);
2213 DisplayPoint(aDoc,P2,"P2",false,0.5,-0.7,0.1);
2214 DisplayPoint(aDoc,P3,"P3",false,0.5,-0.5,0.1);
2215 DisplayPoint(aDoc,P4,"P4",false,0.5,0,0.1);
2217 Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2218 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2219 aCurve->SetColorIndex(5);
2220 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2224 Standard_Integer NbSol = LT.NbSolutions();
2225 for(Standard_Integer k=1; k<=NbSol; k++)
2227 gp_Lin2d L = LT.ThisSolution(k);
2228 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-10,20);
2229 Handle(ISession2D_Curve) aCurveN = new ISession2D_Curve(aLine);
2230 aDoc->GetISessionContext()->Display(aCurveN, Standard_False);
2233 Message += " C is Blue \n\n";
2234 Message += "LT.IsDone() = ";
2235 if (LT.IsDone()) Message += "True \n"; else Message += "False \n";
2236 TCollection_AsciiString Message2 (LT.NbSolutions());
2237 Message += "NbSol = "; Message += Message2 ; Message += "\n";
2239 PostProcess(aDoc,ID_BUTTON_Test_30,TheDisplayType,Message);
2242 // Function name : GeomSources::gpTest31
2244 // Return type : void
2245 // Argument : CGeometryDoc* aDoc
2246 void GeomSources::gpTest31(CGeometryDoc* aDoc)
2248 DisplayType TheDisplayType = a2DNo3D;
2249 PreProcess(aDoc,TheDisplayType);
2251 //==============================================================
2256 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3);
2257 GccEnt_QualifiedCirc QC = GccEnt::Outside(C);
2259 gp_Pnt2d P5 (12,-3);
2260 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1);
2261 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L);
2262 Standard_Real radius = 2;
2263 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion());
2264 Standard_Real parsol,pararg;
2265 gp_Pnt2d tangentpoint1,tangentpoint2;
2269 Standard_Integer NbSol = TR.NbSolutions();
2270 for (Standard_Integer k=1; k<=NbSol; k++)
2272 circ = TR.ThisSolution(k);
2273 // find the solution circle
2274 TR.Tangency1(k,parsol,pararg,tangentpoint1);
2275 // find the first tangent point
2276 TR.Tangency2(k,parsol,pararg,tangentpoint2);
2277 // find the second tangent point
2281 //==============================================================
2282 TCollection_AsciiString Message;
2285 gp_Pnt2d P1 (9,6); \n\
2286 gp_Pnt2d P2 (10,4); \n\
2287 gp_Pnt2d P3 (6,7); \n\
2288 gp_Circ2d C = gce_MakeCirc2d (P1,P2,P3); \n\
2289 GccEnt_QualifiedCirc QC = GccEnt::Outside(C); \n\
2290 gp_Pnt2d P4 (-2,7); \n\
2291 gp_Pnt2d P5 (12,-3); \n\
2292 gp_Lin2d L = GccAna_Lin2d2Tan(P4,P5,Precision::Confusion()).ThisSolution(1); \n\
2293 GccEnt_QualifiedLin QL = GccEnt::Unqualified(L); \n\
2294 Standard_Real radius = 2; \n\
2295 GccAna_Circ2d2TanRad TR (QC,QL,radius,Precision::Confusion()); \n\
2296 Standard_Real parsol,pararg; \n\
2297 gp_Pnt2d tangentpoint1,tangentpoint2; \n\
2299 if (TR.IsDone()) \n\
2301 Standard_Integer NbSol = TR.NbSolutions(); \n\
2302 for (Standard_Integer k=1; k<=NbSol; k++) \n\
2305 circ = TR.ThisSolution(k); \n\
2306 // find the solution circle \n\
2307 TR.Tangency1(k,parsol,pararg,tangentpoint1); \n\
2308 // find the first tangent point \n\
2309 TR.Tangency2(k,parsol,pararg,tangentpoint2); \n\
2310 // find the second tangent point \n\
2314 AddSeparator(aDoc,Message);
2316 //--------------------------------------------------------------
2317 DisplayPoint(aDoc,P1,"P1",false,0.3);
2318 DisplayPoint(aDoc,P2,"P2",false,0.3);
2319 DisplayPoint(aDoc,P3,"P3",false,0.3);
2320 DisplayPoint(aDoc,P4,"P4",false,0.3);
2321 DisplayPoint(aDoc,P5,"P5",false,0.3);
2323 Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(C);
2324 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(aCircle);
2325 aCurve->SetColorIndex(3);
2327 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2328 Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment(L,-2,20);
2329 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(aLine);
2330 aCurve2->SetColorIndex(5);
2331 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2335 Standard_Integer NbSol = TR.NbSolutions();
2336 for (Standard_Integer k=1; k<=NbSol; k++)
2338 circ = TR.ThisSolution(k);
2339 Handle(Geom2d_Circle) aCircleN = new Geom2d_Circle(circ);
2340 Handle(ISession2D_Curve) aCurveN = new ISession2D_Curve(aCircleN);
2341 aDoc->GetISessionContext()->Display(aCurveN, Standard_False);
2343 // find the solution circle
2344 TR.Tangency1(k,parsol,pararg,tangentpoint1);
2345 // find the first tangent point
2346 TR.Tangency2(k,parsol,pararg,tangentpoint2);
2347 // find the second tangent point
2348 DisplayPoint(aDoc,tangentpoint1,"tangentpoint1",false,0.3);
2349 DisplayPoint(aDoc,tangentpoint2,"tangentpoint2",false,0.3);
2352 Message += "C is Red \n";
2353 Message += "L is Blue \n";
2354 PostProcess(aDoc,ID_BUTTON_Test_31,TheDisplayType,Message);
2357 // Function name : GeomSources::gpTest32
2359 // Return type : void
2360 // Argument : CGeometryDoc* aDoc
2361 void GeomSources::gpTest32(CGeometryDoc* aDoc)
2363 DisplayType TheDisplayType = a2DNo3D;
2364 PreProcess(aDoc,TheDisplayType);
2366 //==============================================================
2368 Standard_Real major = 12;
2369 Standard_Real minor = 4;
2370 gp_Ax2d axis = gp::OX2d();
2371 gp_Elips2d EE(axis,major,minor);
2372 Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,M_PI/4);
2374 //==============================================================
2375 TCollection_AsciiString Message (" \
2377 Standard_Real major = 12; \n\
2378 Standard_Real minor = 4; \n\
2379 gp_Ax2d axis = gp::OX2d(); \n\
2380 gp_Elips2d EE(axis,major,minor); \n\
2381 Handle(Geom2d_TrimmedCurve) arc = GCE2d_MakeArcOfEllipse(EE,0.0,PI/4); \n\
2383 AddSeparator(aDoc,Message);
2384 //--------------------------------------------------------------
2385 Handle(Geom2d_Ellipse) E = GCE2d_MakeEllipse(EE);
2386 Handle(ISession2D_Curve) aCurve = new ISession2D_Curve(E);
2387 aCurve->SetColorIndex(3);
2388 aCurve->SetTypeOfLine(Aspect_TOL_DOTDASH);
2390 aDoc->GetISessionContext()->Display(aCurve, Standard_False);
2391 Handle(ISession2D_Curve) aCurve2 = new ISession2D_Curve(arc);
2392 aDoc->GetISessionContext()->Display(aCurve2, Standard_False);
2393 TCollection_AsciiString Message2 (M_PI);
2394 Message += " PI = ";Message+= Message2;
2396 PostProcess(aDoc,ID_BUTTON_Test_32,TheDisplayType,Message);
2399 // Function name : GeomSources::gpTest33
2401 // Return type : void
2402 // Argument : CGeometryDoc* aDoc
2403 void GeomSources::gpTest33(CGeometryDoc* aDoc)
2405 DisplayType TheDisplayType = No2D3D;
2406 PreProcess(aDoc,TheDisplayType);
2408 //==============================================================
2415 TColgp_Array1OfPnt array (1,5); // sizing array
2416 array.SetValue(1,P1);
2417 array.SetValue(2,P2);
2418 array.SetValue(3,P3);
2419 array.SetValue(4,P4);
2420 array.SetValue(5,P5);
2421 Handle(TColgp_HArray1OfPnt) harray =
2422 new TColgp_HArray1OfPnt (1,5); // sizing harray
2423 harray->SetValue(1,P1.Translated(gp_Vec(4,0,0)));
2424 harray->SetValue(2,P2.Translated(gp_Vec(4,0,0)));
2425 harray->SetValue(3,P3.Translated(gp_Vec(4,0,0)));
2426 harray->SetValue(4,P4.Translated(gp_Vec(4,0,0)));
2427 harray->SetValue(5,P5.Translated(gp_Vec(4,0,0)));
2428 Handle(Geom_BSplineCurve) SPL1 =
2429 GeomAPI_PointsToBSpline(array).Curve();
2431 GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation());
2432 anInterpolation.Perform();
2434 Handle(Geom_BSplineCurve) SPL2;
2435 if (anInterpolation.IsDone())
2436 SPL2 = anInterpolation.Curve();
2438 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"The Interpolation is Not done", L"CasCade Warning", MB_ICONWARNING);
2440 //==============================================================
2441 TCollection_AsciiString Message (" \
2443 gp_Pnt P1(0,0,1); \n\
2444 gp_Pnt P2(1,2,2); \n\
2445 gp_Pnt P3(2,3,3); \n\
2446 gp_Pnt P4(4,3,4); \n\
2447 gp_Pnt P5(5,5,5); \n\
2448 TColgp_Array1OfPnt array (1,5); // sizing array \n\
2449 array.SetValue(1,P1); \n\
2450 array.SetValue(2,P2); \n\
2451 array.SetValue(3,P3); \n\
2452 array.SetValue(4,P4); \n\
2453 array.SetValue(5,P5); \n\
2454 Handle(TColgp_HArray1OfPnt) harray = \n\
2455 new TColgp_HArray1OfPnt (1,5); // sizing harray \n\
2456 harray->SetValue(1,P1.Translated(gp_Vec(4,0,0))); \n\
2457 harray->SetValue(2,P2.Translated(gp_Vec(4,0,0))); \n\
2458 harray->SetValue(3,P3.Translated(gp_Vec(4,0,0))); \n\
2459 harray->SetValue(4,P4.Translated(gp_Vec(4,0,0))); \n\
2460 harray->SetValue(5,P5.Translated(gp_Vec(4,0,0))); \n\
2461 Handle(Geom_BSplineCurve) SPL1 = \n\
2462 GeomAPI_PointsToBSpline(array).Curve(); \n");
2465 GeomAPI_Interpolate anInterpolation(harray,Standard_False,Precision::Approximation()); \n\
2466 anInterpolation.Perform(); \n\
2468 Handle(Geom_BSplineCurve) SPL2; \n\
2469 if (anInterpolation.IsDone()) \n\
2470 SPL2 = anInterpolation.Curve(); \n\
2472 MessageBox(0,\"The Interpolation is Not done\",\"CasCade Warning\",MB_ICONWARNING); \n\
2474 AddSeparator(aDoc,Message);
2476 //--------------------------------------------------------------
2478 TCollection_AsciiString aString;
2479 for(Standard_Integer i = array.Lower();i<=array.Upper();i++)
2482 TCollection_AsciiString Message2 (i);
2483 gp_Pnt P = array(i);
2486 aString += Message2;
2487 if (i == 1) aString += " (array) ";
2488 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);\
2491 aString += Message2;
2492 if (i == 1) aString += " (harray) ";
2493 DisplayPoint(aDoc,P.Translated(gp_Vec(4,0,0)),aString.ToCString(),false,0.5);\
2497 Handle(ISession_Curve) aCurve = new ISession_Curve(SPL1);
2498 aDoc->GetAISContext()->SetDisplayMode(aCurve,1, Standard_False);
2499 aDoc->GetAISContext()->Display(aCurve, Standard_False);
2501 if (anInterpolation.IsDone())
2503 Handle(ISession_Curve) aCurve2 = new ISession_Curve(SPL2);
2504 aDoc->GetAISContext()->SetDisplayMode(aCurve2,1, Standard_False);
2505 aDoc->GetAISContext()->Display(aCurve2, Standard_False);
2508 PostProcess(aDoc,ID_BUTTON_Test_33,TheDisplayType,Message);
2511 // Function name : GeomSources::gpTest34
2513 // Return type : void
2514 // Argument : CGeometryDoc* aDoc
2515 void GeomSources::gpTest34(CGeometryDoc* aDoc)
2517 DisplayType TheDisplayType = No2D3D;
2518 PreProcess(aDoc,TheDisplayType);
2520 //==============================================================
2522 TColgp_Array1OfPnt array (1,5); // sizing array
2523 array.SetValue(1,gp_Pnt(0,0,1));
2524 array.SetValue(2,gp_Pnt(1,2,2));
2525 array.SetValue(3,gp_Pnt(2,3,3));
2526 array.SetValue(4,gp_Pnt(4,4,4));
2527 array.SetValue(5,gp_Pnt(5,5,5));
2529 GProp_PEquation PE (array,1.5 );
2543 //==============================================================
2544 TCollection_AsciiString Message (" \
2546 TColgp_Array1OfPnt array (1,5); // sizing array \n\
2547 array.SetValue(1,gp_Pnt(0,0,1)); \n\
2548 array.SetValue(2,gp_Pnt(1,2,2)); \n\
2549 array.SetValue(3,gp_Pnt(2,3,3)); \n\
2550 array.SetValue(4,gp_Pnt(4,4,4)); \n\
2551 array.SetValue(5,gp_Pnt(5,5,5)); \n\
2553 GProp_PEquation PE (array,1.5 ); \n\
2555 if (PE.IsPoint()){ /* ... */ } \n\
2557 if (PE.IsLinear()) { L = PE.Line(); } \n\
2558 if (PE.IsPlanar()){ /* ... */ } \n\
2559 if (PE.IsSpace()) { /* ... */ } \n\
2561 AddSeparator(aDoc,Message);
2562 //--------------------------------------------------------------
2563 TCollection_AsciiString aString;
2564 for(Standard_Integer i = array.Lower();i<=array.Upper();i++)
2566 TCollection_AsciiString Message2 (i);
2567 gp_Pnt P = array(i);
2570 aString += Message2;
2571 DisplayPoint(aDoc,P,aString.ToCString(),false,0.5);
2574 Message += " PE.IsPoint() = ";
2576 Message += "True \n";
2578 Message += "False\n";
2580 if (PE.IsLinear()) {
2581 Message += " PE.IsLinear() = True \n";
2583 Handle(Geom_Line) aLine = new Geom_Line(L);
2584 Handle(Geom_TrimmedCurve) aTrimmedCurve = new Geom_TrimmedCurve(aLine,-10,10);
2585 Handle(ISession_Curve) aCurve = new ISession_Curve(aTrimmedCurve);
2586 aDoc->GetAISContext()->Display(aCurve, Standard_False);
2589 Message += "PE.IsLinear() = False \n";
2591 Message += " PE.IsPlanar() = ";
2593 Message += "True \n";
2595 Message += "False\n";
2597 Message += " PE.IsSpace() = ";
2599 Message += "True \n";
2601 Message += "False\n";
2603 PostProcess(aDoc,ID_BUTTON_Test_34,TheDisplayType,Message);
2606 // Function name : GeomSources::gpTest35
2608 // Return type : void
2609 // Argument : CGeometryDoc* aDoc
2610 void GeomSources::gpTest35(CGeometryDoc* aDoc)
2612 DisplayType TheDisplayType = No2D3D;
2613 PreProcess(aDoc,TheDisplayType);
2615 //==============================================================
2619 Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value();
2622 Standard_Real radius1 = 3;
2623 Standard_Real radius2 = 2;
2624 Handle(Geom_Surface) aSurface =
2625 GC_MakeConicalSurface(P3,P4,radius1,radius2).Value();
2626 GeomAPI_IntCS CS (aCurve,aSurface);
2627 Handle(Geom_Curve) segment;
2629 Standard_Integer NbSeg = 0;
2630 Standard_Integer NbPoints = 0;
2633 NbSeg = CS.NbSegments();
2634 for (Standard_Integer k=1; k<=NbSeg; k++)
2636 segment = CS.Segment(k);
2637 // do something with the segment
2640 NbPoints = CS.NbPoints();
2641 for (int k=1; k<=NbPoints; k++)
2643 gp_Pnt aPoint=CS.Point(k);
2644 // do something with the point
2648 //==============================================================
2649 TCollection_AsciiString Message (" \
2651 gp_Pnt P1(-5,-5,0); \n\
2652 gp_Pnt P2(9,9,9); \n\
2653 Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value(); \n\
2654 gp_Pnt P3(3,0,0); \n\
2655 gp_Pnt P4(3,0,10); \n\
2656 Standard_Real radius1 = 3; \n\
2657 Standard_Real radius2 = 2; \n\
2658 Handle(Geom_Surface) aSurface = \n\
2659 GC_MakeConicalSurface(P3,P4,radius1,radius2).Value(); \n\
2660 GeomAPI_IntCS CS (aCurve,aSurface); \n\
2661 Handle(Geom_Curve) segment; \n\
2663 Standard_Integer NbSeg; \n\
2664 Standard_Integer NbPoints; \n\
2667 NbSeg = CS.NbSegments(); \n\
2668 for (Standard_Integer k=1; k<=NbSeg; k++) \n\
2670 segment = CS.Segment(k); \n\
2671 // do something with the segment \n\
2674 NbPoints = CS.NbPoints(); \n\
2675 for (k=1; k<=NbPoints; k++) \n\
2677 gp_Pnt aPoint=CS.Point(k); \n\
2678 // do something with the point \n\
2682 AddSeparator(aDoc,Message);
2684 //--------------------------------------------------------------
2686 Handle(ISession_Curve) aCurve2 = new ISession_Curve(aCurve);
2687 aDoc->GetAISContext()->Display(aCurve2, Standard_False);
2689 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface= new Geom_RectangularTrimmedSurface(aSurface,-50.,50.,false);
2691 DisplaySurface(aDoc,aTrimmedSurface);
2693 TCollection_AsciiString aString;
2697 NbSeg = CS.NbSegments();
2698 for (k=1; k<=NbSeg; k++)
2700 TCollection_AsciiString Message2 (k);
2701 segment = CS.Segment(k);
2702 aString = "S_";aString += Message2;
2703 Handle(ISession_Curve) aCurveN = new ISession_Curve(segment);
2704 aDoc->GetAISContext()->Display(aCurveN, Standard_False);
2707 for ( k=1; k<=NbPoints; k++)
2709 TCollection_AsciiString Message2 (k);
2710 gp_Pnt aPoint=CS.Point(k);
2711 aString = "P_";aString += Message2;
2712 DisplayPoint(aDoc,aPoint,aString.ToCString(),false,0.5);
2713 // do something with the point
2716 TCollection_AsciiString Message2 (NbSeg);
2717 TCollection_AsciiString Message3 (NbPoints);
2719 Message += "NbSeg = "; Message += Message2 ; Message += "\n";
2720 Message += "NbPoints = "; Message += Message3 ; Message += "\n";
2722 PostProcess(aDoc,ID_BUTTON_Test_35,TheDisplayType,Message);
2725 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2727 // Function name : GeomSources::gpTest36
2729 // Return type : void
2730 // Argument : CGeometryDoc* aDoc
2731 void GeomSources::gpTest36(CGeometryDoc* aDoc)
2733 DisplayType TheDisplayType = No2D3D;
2734 PreProcess(aDoc,TheDisplayType);
2735 //==============================================================
2737 gp_Pnt centre (5,5,0); gp_Pnt axispoint (9,9,0);
2738 Standard_Real radius = 3;
2739 Handle(Geom_Circle) circle =
2740 GC_MakeCircle(centre,axispoint,radius);
2742 Handle(Geom_Geometry) aRotatedEntity = circle->Rotated(gp::OZ(),M_PI/4);
2743 Standard_CString aRotatedEntityTypeName = aRotatedEntity->DynamicType()->Name();
2745 Handle(Geom_Geometry) aMirroredEntity = aRotatedEntity->Mirrored(gp::ZOX());
2746 Standard_CString aMirroredEntityTypeName = aMirroredEntity->DynamicType()->Name();
2748 gp_Pnt scalepoint (4,8,0);
2749 Standard_Real scalefactor = 0.2;
2750 Handle(Geom_Geometry) aScaledEntity =
2751 aMirroredEntity->Scaled(scalepoint, scalefactor);
2752 Standard_CString aScaledEntityTypeName = aScaledEntity->DynamicType()->Name();
2754 Handle (Geom_Transformation) GT = GC_MakeTranslation (centre, scalepoint);
2755 gp_Trsf TR = GT->Trsf();
2757 gp_Vec aTranslationVector(TR.TranslationPart ());
2758 Handle(Geom_Geometry) aTranslatedEntity =
2759 aScaledEntity->Translated( aTranslationVector );
2760 Standard_CString aTranslatedEntityTypeName = aTranslatedEntity->DynamicType()->Name();
2762 gp_Mat matrix = TR.HVectorialPart();
2763 Standard_Real value = matrix.Determinant();
2765 //==============================================================
2766 TCollection_AsciiString Message (" \
2768 gp_Pnt centre (5,5,0); gp_Pnt axispoint (9,9,0); \n\
2769 Standard_Real radius = 3; \n\
2770 Handle(Geom_Circle) circle = \n\
2771 GC_MakeCircle(centre,axispoint,radius); \n\
2773 Handle(Geom_Geometry) aRotatedEntity = circle->Rotated(gp::OZ(),PI/4); \n\
2774 Standard_CString aRotatedEntityTypeName = aRotatedEntity->DynamicType()->Name(); \n\
2776 Handle(Geom_Geometry) aMirroredEntity = aRotatedEntity->Mirrored(gp::ZOX()); \n\
2777 Standard_CString aMirroredEntityTypeName = aMirroredEntity->DynamicType()->Name(); \n\
2779 gp_Pnt scalepoint (4,8,0); \n\
2780 Standard_Real scalefactor = 0.2; \n\
2781 Handle(Geom_Geometry) aScaledEntity = \n\
2782 aMirroredEntity->Scaled(scalepoint, scalefactor); \n\
2783 Standard_CString aScaledEntityTypeName = aScaledEntity->DynamicType()->Name(); \n\
2785 Handle (Geom_Transformation) GT = GC_MakeTranslation (centre, scalepoint); \n\
2786 gp_Trsf TR = GT->Trsf(); \n\
2789 gp_Vec aTranslationVector(TR.TranslationPart ()); \n\
2790 Handle(Geom_Geometry) aTranslatedEntity = \n\
2791 aScaledEntity->Translated( aTranslationVector ); \n\
2792 Standard_CString aTranslatedEntityTypeName = aTranslatedEntity->DynamicType()->Name(); \n\
2794 gp_Mat matrix = TR.HVectorialPart(); \n\
2795 Standard_Real value = matrix.Determinant(); \n\
2797 AddSeparator(aDoc,Message);
2798 //--------------------------------------------------------------
2800 DisplayPoint(aDoc,centre,"centre",false,0.5);
2801 DisplayPoint(aDoc,axispoint,"axispoint",false,0.5);
2802 DisplayPoint(aDoc,scalepoint,"scalepoint",false,0.5);
2804 DisplayCurve(aDoc,circle, Quantity_NOC_RED,false);
2805 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aRotatedEntity),Quantity_NOC_PEACHPUFF, false);
2806 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aMirroredEntity), Quantity_NOC_YELLOWGREEN,false);
2807 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aScaledEntity), Quantity_NOC_GREEN,false);
2808 DisplayCurve(aDoc,Handle(Geom_Curve)::DownCast(aTranslatedEntity),Quantity_NOC_WHITE,false);
2810 TCollection_AsciiString Message0 (M_PI);
2811 Message += " PI = ";
2814 Message += " circle is Red; aRotatedEntity is Peach; aMirroredEntity is Yellow Green\n";
2815 Message += " aScaleEntity is Green; aTranslatedEntity is White\n\n";
2817 TCollection_AsciiString Message2 (aTranslationVector.X());
2818 TCollection_AsciiString Message3 (aTranslationVector.Y());
2819 TCollection_AsciiString Message4 (aTranslationVector.Z());
2820 Message += " aTranslationVector ( ";
2821 Message += Message2; Message += " , ";
2822 Message += Message3; Message += " , ";
2823 Message += Message4; Message += " ); \n";
2825 TCollection_AsciiString Message5 (value);
2826 Message += " value = ";Message+= Message5; Message += "\n";
2828 TCollection_AsciiString Message6 (aRotatedEntityTypeName);
2829 TCollection_AsciiString Message7 (aMirroredEntityTypeName);
2830 TCollection_AsciiString Message8 (aScaledEntityTypeName);
2831 TCollection_AsciiString Message9 (aTranslatedEntityTypeName);
2833 Message += " aRotatedEntityTypeName = ";Message+= Message6; Message += "\n";
2834 Message += " aMirroredEntityTypeName = ";Message+= Message7; Message += "\n";
2835 Message += " aScaledEntityTypeName = ";Message+= Message8; Message += "\n";
2836 Message += " aTranslatedEntityTypeName = ";Message+= Message9; Message += "\n";
2838 PostProcess(aDoc,ID_BUTTON_Test_36,TheDisplayType,Message);
2841 // Function name : GeomSources::gpTest37
2843 // Return type : void
2844 // Argument : CGeometryDoc* aDoc
2845 void GeomSources::gpTest37(CGeometryDoc* aDoc)
2847 DisplayType TheDisplayType = No2D3D;
2848 PreProcess(aDoc,TheDisplayType);
2849 //==============================================================
2851 TColgp_Array1OfPnt anArrayofPnt (1,5); // sizing array
2852 anArrayofPnt.SetValue(1,gp_Pnt(0,0,1));
2853 anArrayofPnt.SetValue(2,gp_Pnt(1,2,2));
2854 anArrayofPnt.SetValue(3,gp_Pnt(2,3,3));
2855 anArrayofPnt.SetValue(4,gp_Pnt(4,3,4));
2856 anArrayofPnt.SetValue(5,gp_Pnt(5,5,5));
2858 Standard_Real Tolerance = 1;
2861 GProp_PEquation PE (anArrayofPnt,Tolerance);
2862 if (PE.IsPlanar()) { P = PE.Plane();}
2864 if (PE.IsPoint()) { /* ... */ }
2865 if (PE.IsLinear()) { /* ... */ }
2866 if (PE.IsPlanar()) { P = PE.Plane();}
2867 if (PE.IsSpace()) { /* ... */ }
2869 //==============================================================
2870 TCollection_AsciiString Message (" \
2872 TColgp_Array1OfPnt anArrayofPnt (1,5); // sizing array \n\
2873 anArrayofPnt.SetValue(1,gp_Pnt(0,0,1)); \n\
2874 anArrayofPnt.SetValue(2,gp_Pnt(1,2,2)); \n\
2875 anArrayofPnt.SetValue(3,gp_Pnt(2,3,3)); \n\
2876 anArrayofPnt.SetValue(4,gp_Pnt(4,3,4)); \n\
2877 anArrayofPnt.SetValue(5,gp_Pnt(5,5,5)); \n\
2879 Standard_Real Tolerance = 1; \n\
2882 GProp_PEquation PE (anArrayofPnt,Tolerance); \n\
2883 if (PE.IsPlanar()) { P = PE.Plane();} \n\
2885 if (PE.IsPoint()) { /* ... */ } \n\
2886 if (PE.IsLinear()) { /* ... */ } \n\
2887 if (PE.IsPlanar()) { P = PE.Plane();} \n\
2888 if (PE.IsSpace()) { /* ... */ } \n\
2890 AddSeparator(aDoc,Message);
2891 //--------------------------------------------------------------
2893 TCollection_AsciiString aString;
2894 for(Standard_Integer i = anArrayofPnt.Lower();i<=anArrayofPnt.Upper();i++){
2895 TCollection_AsciiString Message2(i);
2896 gp_Pnt aP = anArrayofPnt(i);
2898 aString += Message2;
2899 DisplayPoint(aDoc,aP,aString.ToCString(),false,0.5);
2902 Message += " PE.IsPoint() = "; if (PE.IsPoint()) Message += "True \n"; else Message += "False\n";
2903 Message += " PE.IsLinear() = "; if (PE.IsLinear()) Message += "True \n"; else Message += "False\n";
2905 if (PE.IsPlanar()) {
2906 Message += " PE.IsPlanar() = True \n";
2908 Handle(Geom_Plane) aPlane = new Geom_Plane(P);
2909 Handle(Geom_RectangularTrimmedSurface) aSurface= new Geom_RectangularTrimmedSurface(aPlane,-4.,4.,-4.,4.);
2911 DisplaySurface(aDoc,aSurface);
2915 Message += " PE.IsPlanar() = False \n";
2917 Message += " PE.IsSpace() = "; if (PE.IsSpace() ) Message += "True \n"; else Message += "False\n";
2919 PostProcess(aDoc,ID_BUTTON_Test_37,TheDisplayType,Message);
2922 void GeomSources::gpTest38(CGeometryDoc* aDoc)
2924 DisplayType TheDisplayType = No2D3D;
2925 PreProcess(aDoc,TheDisplayType);
2926 //==============================================================
2928 TColgp_Array1OfPnt array1 (1,5); // sizing array
2929 array1.SetValue(1,gp_Pnt (-4,0,2 )); array1.SetValue(2,gp_Pnt (-7,2,2 ));
2930 array1.SetValue(3,gp_Pnt (-6,3,1 )); array1.SetValue(4,gp_Pnt (-4,3,-1));
2931 array1.SetValue(5,gp_Pnt (-3,5,-2));
2932 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();
2934 TColgp_Array1OfPnt array2 (1,5); // sizing array
2935 array2.SetValue(1,gp_Pnt (-4,0, 2)); array2.SetValue(2,gp_Pnt (-2,2,0 ));
2936 array2.SetValue(3,gp_Pnt (2 ,3,-1)); array2.SetValue(4,gp_Pnt (3 ,7,-2));
2937 array2.SetValue(5,gp_Pnt (4 ,9,-1));
2938 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();
2940 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
2941 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
2942 Handle(Geom_BSplineSurface) aBSplineSurface1 = aGeomFill1.Surface();
2944 Type = GeomFill_CoonsStyle;
2945 GeomFill_BSplineCurves aGeomFill2(
2946 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(10,0,0))),
2947 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(10,0,0))),Type);
2948 Handle(Geom_BSplineSurface) aBSplineSurface2 = aGeomFill2.Surface();
2949 Type = GeomFill_CurvedStyle;
2950 GeomFill_BSplineCurves aGeomFill3(
2951 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(20,0,0))),
2952 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(20,0,0))),Type);
2953 Handle(Geom_BSplineSurface) aBSplineSurface3 = aGeomFill3.Surface();
2955 //==============================================================
2956 TCollection_AsciiString Message (" \
2958 TColgp_Array1OfPnt array1 (1,5); // sizing array \n\
2959 array1.SetValue(1,gp_Pnt (-4,0,2 )); array1.SetValue(2,gp_Pnt (-7,2,2 )); \n\
2960 array1.SetValue(3,gp_Pnt (-6,3,1 )); array1.SetValue(4,gp_Pnt (-4,3,-1)); \n\
2961 array1.SetValue(5,gp_Pnt (-3,5,-2)); \n\
2962 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve(); \n\
2964 TColgp_Array1OfPnt array2 (1,5); // sizing array \n\
2965 array2.SetValue(1,gp_Pnt (-4,0, 2)); array2.SetValue(2,gp_Pnt (-2,2,0 )); \n\
2966 array2.SetValue(3,gp_Pnt (2 ,3,-1)); array2.SetValue(4,gp_Pnt (3 ,7,-2)); \n\
2967 array2.SetValue(5,gp_Pnt (4 ,9,-1)); \n\
2968 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve(); \n\
2970 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
2971 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
2972 Handle(Geom_BSplineSurface) aBSplineSurface1 = aGeomFill1.Surface(); \n\
2974 Type = GeomFill_CoonsStyle; \n\
2975 GeomFill_BSplineCurves aGeomFill2( \n");
2977 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(10,0,0))), \n\
2978 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(10,0,0))),Type); \n\
2979 Handle(Geom_BSplineSurface) aBSplineSurface2 = aGeomFill2.Surface(); \n\
2980 Type = GeomFill_CurvedStyle; \n\
2981 GeomFill_BSplineCurves aGeomFill3( \n\
2982 Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(20,0,0))), \n\
2983 Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(20,0,0))),Type); \n\
2984 Handle(Geom_BSplineSurface) aBSplineSurface3 = aGeomFill3.Surface(); \n\
2986 AddSeparator(aDoc,Message);
2987 //--------------------------------------------------------------
2989 // Trace des frontieres. -> FreeBoundaryAspect
2990 // Trace des isoparametriques. --> UIsoAspect()
2992 DisplaySurface(aDoc,aBSplineSurface1,Quantity_NOC_YELLOW);
2993 DisplaySurface(aDoc,aBSplineSurface2,Quantity_NOC_SALMON);
2994 DisplaySurface(aDoc,aBSplineSurface3,Quantity_NOC_HOTPINK);
2996 for (int i=0;i<=2;i++)
2998 DisplayCurve(aDoc,Handle(Geom_BSplineCurve)::DownCast(SPL1->Translated(gp_Vec(i*10,0,0))), Quantity_NOC_RED,false);
2999 DisplayCurve(aDoc,Handle(Geom_BSplineCurve)::DownCast(SPL2->Translated(gp_Vec(i*10,0,0))), Quantity_NOC_GREEN,false);
3002 Message += "SPL1 is Red; \n";
3003 Message += "SPL2 is Green; \n";
3004 Message += "aBSplineSurface1 is Yellow; ( GeomFill_StretchStyle )\n";
3005 Message += "aBSplineSurface2 is Salmon; ( GeomFill_CoonsStyle ) \n";
3006 Message += "aBSplineSurface3 is Hot pink; ( GeomFill_CurvedStyle ) \n";
3008 PostProcess(aDoc,ID_BUTTON_Test_38,TheDisplayType,Message);
3010 void GeomSources::gpTest39(CGeometryDoc* aDoc)
3012 DisplayType TheDisplayType = No2D3D;
3013 PreProcess(aDoc,TheDisplayType);
3014 //==============================================================
3016 TColgp_Array1OfPnt array1 (1,5); // sizing array
3017 array1.SetValue(1,gp_Pnt (-4,0,2 ));
3018 array1.SetValue(2,gp_Pnt (-5,1,0 ));
3019 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3020 array1.SetValue(4,gp_Pnt (-5,4,-7));
3021 array1.SetValue(5,gp_Pnt (-3,5,-12));
3023 TColgp_Array1OfPnt array2 (1,5); // sizing array
3024 array2.SetValue(1,gp_Pnt (-4,0, 2));
3025 array2.SetValue(2,gp_Pnt (-3,2,1 ));
3026 array2.SetValue(3,gp_Pnt (-1,5,0));
3027 array2.SetValue(4,gp_Pnt (2 ,7,-1));
3028 array2.SetValue(5,gp_Pnt (4 ,9,-1));
3030 TColgp_Array1OfPnt array3 (1,4); // sizing array
3031 array3.SetValue(1,gp_Pnt (-3,5, -12));
3032 array3.SetValue(2,gp_Pnt (-2,6,-7 ));
3033 array3.SetValue(3,gp_Pnt (0 ,8,-3));
3034 array3.SetValue(4,gp_Pnt (4 ,9,-1));
3036 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve();
3037 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve();
3038 Handle(Geom_BSplineCurve) SPL3 = GeomAPI_PointsToBSpline(array3).Curve();
3040 Handle(GeomAdaptor_Curve) SPL1Adaptor = new GeomAdaptor_Curve(SPL1);
3041 Handle(GeomFill_SimpleBound) B1 =
3042 new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular());
3043 Handle(GeomAdaptor_Curve) SPL2Adaptor = new GeomAdaptor_Curve(SPL2);
3044 Handle(GeomFill_SimpleBound) B2 =
3045 new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular());
3046 Handle(GeomAdaptor_Curve) SPL3Adaptor = new GeomAdaptor_Curve(SPL3);
3047 Handle(GeomFill_SimpleBound) B3 =
3048 new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular());
3049 Standard_Boolean NoCheck= Standard_False;
3051 Standard_Integer MaxDeg = 8;
3052 Standard_Integer MaxSeg = 2;
3053 GeomFill_ConstrainedFilling aConstrainedFilling(MaxDeg, MaxSeg);
3055 aConstrainedFilling.Init(B1,B2,B3,NoCheck);
3057 Handle(Geom_BSplineSurface) aBSplineSurface = aConstrainedFilling.Surface();
3059 //==============================================================
3060 TCollection_AsciiString Message (" \
3062 TColgp_Array1OfPnt array1 (1,5); // sizing array \n\
3064 Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(array1).Curve(); \n\
3065 Handle(Geom_BSplineCurve) SPL2 = GeomAPI_PointsToBSpline(array2).Curve(); \n\
3066 Handle(Geom_BSplineCurve) SPL3 = GeomAPI_PointsToBSpline(array3).Curve(); \n\
3068 Handle(GeomAdaptor_Curve) SPL1Adaptor = new GeomAdaptor_Curve(SPL1); \n\
3069 Handle(GeomFill_SimpleBound) B1 = \n\
3070 new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular()); \n\
3071 Handle(GeomAdaptor_Curve) SPL2Adaptor = new GeomAdaptor_Curve(SPL2); \n\
3072 Handle(GeomFill_SimpleBound) B2 = \n\
3073 new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular()); \n\
3074 Handle(GeomAdaptor_Curve) SPL3Adaptor = new GeomAdaptor_Curve(SPL3); \n\
3075 Handle(GeomFill_SimpleBound) B3 = \n\
3076 new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular()); \n\
3077 Standard_Boolean NoCheck= Standard_False; \n\
3079 Standard_Integer MaxDeg = 8; \n");
3081 Standard_Integer MaxSeg = 2; \n\
3082 GeomFill_ConstrainedFilling aConstrainedFilling(MaxDeg, MaxSeg); \n\
3084 aConstrainedFilling.Init(B1,B2,B3,NoCheck); \n\
3086 Handle(Geom_BSplineSurface) aBSplineSurface = aConstrainedFilling.Surface(); \n\
3088 AddSeparator(aDoc,Message);
3089 //--------------------------------------------------------------
3091 TCollection_AsciiString aString;
3093 DisplaySurface(aDoc,aBSplineSurface,Quantity_NOC_YELLOW);
3094 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3095 DisplayCurve(aDoc,SPL2,Quantity_NOC_GREEN ,false);
3096 DisplayCurve(aDoc,SPL3,Quantity_NOC_BLUE1 ,false);
3098 Message += "SPL1 is Red; \n";
3099 Message += "SPL2 is Green; \n";
3100 Message += "SPL3 is Blue; \n";
3102 Message += "aBSplineSurface is Yellow; \n";
3104 PostProcess(aDoc,ID_BUTTON_Test_39,TheDisplayType,Message);
3107 void GeomSources::gpTest40(CGeometryDoc* aDoc)
3109 DisplayType TheDisplayType = No2D3D;
3110 PreProcess(aDoc,TheDisplayType);
3111 //==============================================================
3113 TColgp_Array1OfPnt array1 (1,5); // sizing array
3114 array1.SetValue(1,gp_Pnt (-4,0,2 ));
3115 array1.SetValue(2,gp_Pnt (-5,1,0 ));
3116 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3117 array1.SetValue(4,gp_Pnt (-5,4,-7));
3118 array1.SetValue(5,gp_Pnt (-3,5,-12));
3120 Handle(Geom_Curve) SPL1 =
3121 GeomAPI_PointsToBSpline(array1).Curve();
3123 GeomFill_Pipe aPipe(SPL1,1);
3125 Handle(Geom_Surface) aSurface= aPipe.Surface();
3126 Standard_CString aSurfaceEntityTypeName="Not Computed";
3127 if (!aSurface.IsNull())
3128 aSurfaceEntityTypeName = aSurface->DynamicType()->Name();
3130 Handle(Geom_Ellipse) E = GC_MakeEllipse( gp::XOY() ,3,1).Value();
3131 GeomFill_Pipe aPipe2(SPL1,E);
3133 Handle(Geom_Surface) aSurface2= aPipe2.Surface();
3134 Standard_CString aSurfaceEntityTypeName2="Not Computed";
3135 if (!aSurface2.IsNull()) {
3136 aSurfaceEntityTypeName2 = aSurface2->DynamicType()->Name();
3137 aSurface2->Translate(gp_Vec(5,0,0)); }
3139 Handle(Geom_TrimmedCurve) TC1 =
3140 GC_MakeSegment(gp_Pnt(1,1,1),gp_Pnt(5,5,5));
3141 Handle(Geom_TrimmedCurve) TC2 =
3142 GC_MakeSegment(gp_Pnt(1,1,0),gp_Pnt(4,5,6));
3143 GeomFill_Pipe aPipe3(SPL1,TC1,TC2);
3145 Handle(Geom_Surface) aSurface3 = aPipe3.Surface();
3146 Standard_CString aSurfaceEntityTypeName3="Not Computed";
3147 if (!aSurface3.IsNull())
3149 aSurfaceEntityTypeName3 = aSurface3->DynamicType()->Name();
3150 aSurface3->Translate(gp_Vec(10,0,0));
3153 //==============================================================
3154 TCollection_AsciiString Message (" \
3157 TColgp_Array1OfPnt array1 (1,5); // sizing array \n\
3158 array1.SetValue(1,gp_Pnt (-4,0,2 )); \n\
3159 array1.SetValue(2,gp_Pnt (-5,1,0 )); \n\
3160 array1.SetValue(3,gp_Pnt (-6,2,-2 )); \n\
3161 array1.SetValue(4,gp_Pnt (-5,4,-7)); \n\
3162 array1.SetValue(5,gp_Pnt (-3,5,-12)); \n\
3164 Handle(Geom_BSplineCurve) SPL1 = \n\
3165 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3167 GeomFill_Pipe aPipe(SPL1,1); \n\
3168 aPipe.Perform(); \n\
3169 Handle(Geom_Surface) aSurface= aPipe.Surface(); \n\
3170 Standard_CString aSurfaceEntityTypeName=\"Not Computed\"; \n\
3171 if (!aSurface.IsNull()) \n\
3172 aSurfaceEntityTypeName = aSurface->DynamicType()->Name(); \n\
3174 Handle(Geom_Ellipse) E = GC_MakeEllipse( gp::XOY() ,3,1).Value(); \n\
3175 GeomFill_Pipe aPipe2(SPL1,E); \n\
3176 aPipe2.Perform(); \n");
3178 Handle(Geom_Surface) aSurface2= aPipe2.Surface(); \n\
3179 Standard_CString aSurfaceEntityTypeName2=\"Not Computed\"; \n\
3180 if (!aSurface2.IsNull()) { \n\
3181 aSurfaceEntityTypeName2 = aSurface2->DynamicType()->Name(); \n\
3182 aSurface2->Translate(gp_Vec(5,0,0)); } \n\
3184 Handle(Geom_TrimmedCurve) TC1 = \n\
3185 GC_MakeSegment(gp_Pnt(1,1,1),gp_Pnt(5,5,5)); \n\
3186 Handle(Geom_TrimmedCurve) TC2 = \n\
3187 GC_MakeSegment(gp_Pnt(1,1,0),gp_Pnt(4,5,6)); \n\
3188 GeomFill_Pipe aPipe3(SPL1,TC1,TC2); \n\
3189 aPipe3.Perform(); \n\
3190 Handle(Geom_Surface) aSurface3 = aPipe3.Surface(); \n\
3191 Standard_CString aSurfaceEntityTypeName3=\"Not Computed\"; \n\
3192 if (!aSurface3.IsNull()) \n\
3194 aSurfaceEntityTypeName3 = aSurface3->DynamicType()->Name(); \n\
3195 aSurface3->Translate(gp_Vec(10,0,0)); \n\
3198 AddSeparator(aDoc,Message);
3199 //--------------------------------------------------------------
3201 if (!aSurface.IsNull())
3203 DisplaySurface(aDoc,aSurface,Quantity_NOC_YELLOW);
3205 if (!aSurface2.IsNull())
3207 DisplaySurface(aDoc,aSurface2,Quantity_NOC_YELLOW);
3209 if (!aSurface3.IsNull())
3211 DisplaySurface(aDoc,aSurface3,Quantity_NOC_YELLOW);
3214 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3216 Message += "SPL1 is Red; \n";
3219 TCollection_AsciiString Message2(aSurfaceEntityTypeName);
3220 TCollection_AsciiString Message3(aSurfaceEntityTypeName2);
3221 TCollection_AsciiString Message4(aSurfaceEntityTypeName3);
3223 Message += " aSurfaceEntityTypeName = ";Message+= Message2; Message += "\n";
3224 Message += " aSurfaceEntityTypeName2 = ";Message+= Message3; Message += "\n";
3225 Message += " aSurfaceEntityTypeName3 = ";Message+= Message4; Message += "\n";
3227 PostProcess(aDoc,ID_BUTTON_Test_40,TheDisplayType,Message);
3230 void GeomSources::gpTest41(CGeometryDoc* aDoc)
3232 DisplayType TheDisplayType = No2D3D;
3233 PreProcess(aDoc,TheDisplayType);
3234 //==============================================================
3236 TColgp_Array1OfPnt array1 (1,5);
3237 array1.SetValue(1,gp_Pnt (-4,0,2 ));
3238 array1.SetValue(2,gp_Pnt (-5,1,0 ));
3239 array1.SetValue(3,gp_Pnt (-6,2,-2 ));
3240 array1.SetValue(4,gp_Pnt (-5,4,-7));
3241 array1.SetValue(5,gp_Pnt (-3,5,-12));
3243 Handle(Geom_BSplineCurve) SPL1 =
3244 GeomAPI_PointsToBSpline(array1).Curve();
3245 Handle(Geom_Curve) FirstSect =
3246 GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value();
3248 GeomFill_Pipe aPipe(SPL1,FirstSect);
3251 Handle(Geom_BSplineSurface) aPipeSurface =
3252 Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface());
3253 Handle(Geom_BSplineSurface) anotherBSplineSurface =
3254 GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6);
3256 //==============================================================
3257 TCollection_AsciiString Message (" \
3259 TColgp_Array1OfPnt array1 (1,5); \n\
3260 array1.SetValue(1,gp_Pnt (-4,0,2 )); \n\
3261 array1.SetValue(2,gp_Pnt (-5,1,0 )); \n\
3262 array1.SetValue(3,gp_Pnt (-6,2,-2 )); \n\
3263 array1.SetValue(4,gp_Pnt (-5,4,-7)); \n\
3264 array1.SetValue(5,gp_Pnt (-3,5,-12)); \n\
3266 Handle(Geom_BSplineCurve) SPL1 = \n\
3267 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3268 Handle(Geom_Curve) FirstSect = \n\
3269 GC_MakeSegment(gp_Pnt(-4,0,2),gp_Pnt(-4,0,10)).Value(); \n\
3271 GeomFill_Pipe aPipe(SPL1,FirstSect); \n\
3272 aPipe.Perform(); \n\
3274 Handle(Geom_BSplineSurface) aPipeSurface = \n\
3275 Handle(Geom_BSplineSurface)::DownCast(aPipe.Surface()); \n\
3276 Handle(Geom_BSplineSurface) anotherBSplineSurface = \n\
3277 GeomConvert::SplitBSplineSurface(aPipeSurface,1,2,3,6); \n\
3279 AddSeparator(aDoc,Message);
3280 //--------------------------------------------------------------
3282 if(!aPipeSurface.IsNull())
3284 DisplaySurface(aDoc,aPipeSurface,Quantity_NOC_YELLOW);
3287 if(!anotherBSplineSurface.IsNull())
3289 DisplaySurface(aDoc,anotherBSplineSurface,Quantity_NOC_HOTPINK);
3292 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3293 DisplayCurve(aDoc,FirstSect,Quantity_NOC_GREEN ,false);
3295 Message += "SPL1 is Red; \n";
3296 Message += "SPL2 is Green; \n";
3297 Message += "SPL3 is Blue; \n";
3298 Message += "aBSplineSurface is Yellow; \n";
3299 Message += "anotherBSplineSurface is Hot Pink; \n";
3301 PostProcess(aDoc,ID_BUTTON_Test_41,TheDisplayType,Message);
3305 void GeomSources::gpTest42(CGeometryDoc* aDoc)
3307 DisplayType TheDisplayType = No2D3D;
3308 PreProcess(aDoc,TheDisplayType);
3310 //==============================================================
3312 TColgp_Array2OfPnt array1(1,3,1,3);
3313 TColgp_Array2OfPnt array2(1,3,1,3);
3314 TColgp_Array2OfPnt array3(1,3,1,3);
3315 TColgp_Array2OfPnt array4(1,3,1,3);
3317 array1.SetValue(1,1,gp_Pnt(1,1,1));
3318 array1.SetValue(1,2,gp_Pnt(2,1,2));
3319 array1.SetValue(1,3,gp_Pnt(3,1,1));
3320 array1.SetValue(2,1,gp_Pnt(1,2,1));
3321 array1.SetValue(2,2,gp_Pnt(2,2,2));
3322 array1.SetValue(2,3,gp_Pnt(3,2,0));
3323 array1.SetValue(3,1,gp_Pnt(1,3,2));
3324 array1.SetValue(3,2,gp_Pnt(2,3,1));
3325 array1.SetValue(3,3,gp_Pnt(3,3,0));
3327 array2.SetValue(1,1,gp_Pnt(3,1,1));
3328 array2.SetValue(1,2,gp_Pnt(4,1,1));
3329 array2.SetValue(1,3,gp_Pnt(5,1,2));
3330 array2.SetValue(2,1,gp_Pnt(3,2,0));
3331 array2.SetValue(2,2,gp_Pnt(4,2,1));
3332 array2.SetValue(2,3,gp_Pnt(5,2,2));
3333 array2.SetValue(3,1,gp_Pnt(3,3,0));
3334 array2.SetValue(3,2,gp_Pnt(4,3,0));
3335 array2.SetValue(3,3,gp_Pnt(5,3,1));
3337 array3.SetValue(1,1,gp_Pnt(1,3,2));
3338 array3.SetValue(1,2,gp_Pnt(2,3,1));
3339 array3.SetValue(1,3,gp_Pnt(3,3,0));
3340 array3.SetValue(2,1,gp_Pnt(1,4,1));
3341 array3.SetValue(2,2,gp_Pnt(2,4,0));
3342 array3.SetValue(2,3,gp_Pnt(3,4,1));
3343 array3.SetValue(3,1,gp_Pnt(1,5,1));
3344 array3.SetValue(3,2,gp_Pnt(2,5,1));
3345 array3.SetValue(3,3,gp_Pnt(3,5,2));
3347 array4.SetValue(1,1,gp_Pnt(3,3,0));
3348 array4.SetValue(1,2,gp_Pnt(4,3,0));
3349 array4.SetValue(1,3,gp_Pnt(5,3,1));
3350 array4.SetValue(2,1,gp_Pnt(3,4,1));
3351 array4.SetValue(2,2,gp_Pnt(4,4,1));
3352 array4.SetValue(2,3,gp_Pnt(5,4,1));
3353 array4.SetValue(3,1,gp_Pnt(3,5,2));
3354 array4.SetValue(3,2,gp_Pnt(4,5,2));
3355 array4.SetValue(3,3,gp_Pnt(5,5,1));
3357 Handle(Geom_BezierSurface) BZ1 =
3358 new Geom_BezierSurface(array1);
3359 Handle(Geom_BezierSurface) BZ2 =
3360 new Geom_BezierSurface(array2);
3361 Handle(Geom_BezierSurface) BZ3 =
3362 new Geom_BezierSurface(array3);
3363 Handle(Geom_BezierSurface) BZ4 =
3364 new Geom_BezierSurface(array4);
3366 TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2);
3367 bezierarray.SetValue(1,1,BZ1);
3368 bezierarray.SetValue(1,2,BZ2);
3369 bezierarray.SetValue(2,1,BZ3);
3370 bezierarray.SetValue(2,2,BZ4);
3372 GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray);
3373 Handle(Geom_BSplineSurface) BSPLSURF ;
3376 BSPLSURF = new Geom_BSplineSurface(
3377 BB.Poles()->Array2(),
3378 BB.UKnots()->Array1(),
3379 BB.VKnots()->Array1(),
3380 BB.UMultiplicities()->Array1(),
3381 BB.VMultiplicities()->Array1(),
3384 BSPLSURF->Translate(gp_Vec(0,0,2));
3387 //==============================================================
3389 TCollection_AsciiString Message (" \
3391 TColgp_Array2OfPnt array1(1,3,1,3); \n\
3392 TColgp_Array2OfPnt array2(1,3,1,3); \n\
3393 TColgp_Array2OfPnt array3(1,3,1,3); \n\
3394 TColgp_Array2OfPnt array4(1,3,1,3); \n\
3396 // array1.SetValue( ... \n\
3398 Handle(Geom_BezierSurface) BZ1 = \n\
3399 new Geom_BezierSurface(array1); \n\
3400 Handle(Geom_BezierSurface) BZ2 = \n\
3401 new Geom_BezierSurface(array2); \n\
3402 Handle(Geom_BezierSurface) BZ3 = \n\
3403 new Geom_BezierSurface(array3); \n\
3404 Handle(Geom_BezierSurface) BZ4 = \n\
3405 new Geom_BezierSurface(array4); \n\
3407 TColGeom_Array2OfBezierSurface bezierarray(1,2,1,2); \n\
3408 bezierarray.SetValue(1,1,BZ1); \n\
3409 bezierarray.SetValue(1,2,BZ2); \n\
3410 bezierarray.SetValue(2,1,BZ3); \n\
3411 bezierarray.SetValue(2,2,BZ4); \n\
3413 GeomConvert_CompBezierSurfacesToBSplineSurface BB (bezierarray); \n\
3414 Handle(Geom_BSplineSurface) BSPLSURF ; \n\
3415 if (BB.IsDone()){ \n\
3416 BSPLSURF = new Geom_BSplineSurface( \n\
3417 BB.Poles()->Array2(), \n\
3418 BB.UKnots()->Array1(), \n");
3420 BB.VKnots()->Array1(), \n\
3421 BB.UMultiplicities()->Array1(), \n\
3422 BB.VMultiplicities()->Array1(), \n\
3425 BSPLSURF->Translate(gp_Vec(0,0,2)); \n\
3428 AddSeparator(aDoc,Message);
3429 //--------------------------------------------------------------
3431 DisplaySurface(aDoc,BZ1,Quantity_NOC_RED);
3432 DisplaySurface(aDoc,BZ2,Quantity_NOC_GREEN);
3433 DisplaySurface(aDoc,BZ3,Quantity_NOC_BLUE1);
3434 DisplaySurface(aDoc,BZ4,Quantity_NOC_BROWN);
3437 DisplaySurface(aDoc,BSPLSURF,Quantity_NOC_HOTPINK);
3440 Message += "BZ1 is Red; \n";
3441 Message += "BZ2 is Green; \n";
3442 Message += "BZ3 is Blue; \n";
3443 Message += "BZ4 is Brown; \n";
3444 Message += "BSPLSURF is Hot Pink; \n";
3446 PostProcess(aDoc,ID_BUTTON_Test_42,TheDisplayType,Message);
3449 void GeomSources::gpTest43(CGeometryDoc* aDoc)
3451 DisplayType TheDisplayType = No2D3D;
3452 PreProcess(aDoc,TheDisplayType);
3453 //==============================================================
3455 TColgp_Array1OfPnt array1 (1,5);
3456 array1.SetValue(1,gp_Pnt (-4,5,5 ));
3457 array1.SetValue(2,gp_Pnt (-3,6,6 ));
3458 array1.SetValue(3,gp_Pnt (-1,7,7 ));
3459 array1.SetValue(4,gp_Pnt (0,8,8));
3460 array1.SetValue(5,gp_Pnt (2,9,9));
3461 Handle(Geom_BSplineCurve) SPL1 =
3462 GeomAPI_PointsToBSpline(array1).Curve();
3464 TColgp_Array1OfPnt array2 (1,5);
3465 array2.SetValue(1,gp_Pnt (-4,5,2 ));
3466 array2.SetValue(2,gp_Pnt (-3,6,3 ));
3467 array2.SetValue(3,gp_Pnt (-1,7,4 ));
3468 array2.SetValue(4,gp_Pnt (0,8,5));
3469 array2.SetValue(5,gp_Pnt (2,9,6));
3470 Handle(Geom_BSplineCurve) SPL2 =
3471 GeomAPI_PointsToBSpline(array2).Curve();
3473 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3474 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3475 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3476 Standard_Real offset = 1;
3477 Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset);
3479 Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset);
3481 Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset);
3483 //==============================================================
3484 TCollection_AsciiString Message (" \
3486 TColgp_Array1OfPnt array1 (1,5); \n\
3487 //array1.SetValue( ... \n\
3488 Handle(Geom_BSplineCurve) SPL1 = \n\
3489 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3491 TColgp_Array1OfPnt array2 (1,5); \n\
3492 // array2.SetValue( ... \n\
3494 Handle(Geom_BSplineCurve) SPL2 = \n\
3495 GeomAPI_PointsToBSpline(array2).Curve(); \n\
3497 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3498 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3499 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface(); \n\
3500 Standard_Real offset = 1; \n\
3501 Handle(Geom_OffsetSurface) GOS = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3503 Handle(Geom_OffsetSurface) GOS1 = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3505 Handle(Geom_OffsetSurface) GOS2 = new Geom_OffsetSurface(aGeomSurface, offset); \n\
3507 AddSeparator(aDoc,Message);
3508 //--------------------------------------------------------------
3510 DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_BLUE1);
3511 DisplaySurface(aDoc,GOS,Quantity_NOC_GREEN);
3512 DisplaySurface(aDoc,GOS1,Quantity_NOC_GREEN);
3513 DisplaySurface(aDoc,GOS2,Quantity_NOC_GREEN);
3515 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3516 DisplayCurve(aDoc,SPL2,Quantity_NOC_HOTPINK ,false);
3518 Message += "aGeomSurface is Blue; \n";
3519 Message += "GOS are Green; \n";
3521 PostProcess(aDoc,ID_BUTTON_Test_43,TheDisplayType,Message);
3524 void GeomSources::gpTest44(CGeometryDoc* aDoc)
3526 DisplayType TheDisplayType = No2D3D;
3527 PreProcess(aDoc,TheDisplayType);
3528 //==============================================================
3535 TColgp_Array1OfPnt array (1,5);
3536 array.SetValue(1,P1);
3537 array.SetValue(2,P2);
3538 array.SetValue(3,P3);
3539 array.SetValue(4,P4);
3540 array.SetValue(5,P5);
3541 Handle(Geom_BSplineCurve) aCurve =
3542 GeomAPI_PointsToBSpline(array).Curve();
3544 Handle(Geom_SurfaceOfLinearExtrusion) SOLE =
3545 new Geom_SurfaceOfLinearExtrusion(aCurve,aDir);
3547 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface =
3548 new Geom_RectangularTrimmedSurface(SOLE,-10,10,false);
3550 Standard_CString SOLEEntityTypeName="Not Computed";
3553 SOLEEntityTypeName = SOLE->DynamicType()->Name();
3556 //==============================================================
3558 TCollection_AsciiString Message (" \
3560 gp_Pnt P1(0,0,1); \n\
3561 gp_Pnt P2(1,2,2); \n\
3562 gp_Pnt P3(2,3,3); \n\
3563 gp_Pnt P4(4,3,4); \n\
3564 gp_Pnt P5(5,5,5); \n\
3565 TColgp_Array1OfPnt array (1,5); \n\
3566 array.SetValue(1,P1); \n\
3567 array.SetValue(2,P2); \n\
3568 array.SetValue(3,P3); \n\
3569 array.SetValue(4,P4); \n\
3570 array.SetValue(5,P5); \n\
3571 Handle(Geom_BSplineCurve) aCurve = \n\
3572 GeomAPI_PointsToBSpline(array).Curve(); \n\
3573 gp_Dir aDir(1,2,3); \n\
3574 Handle(Geom_SurfaceOfLinearExtrusion) SOLE = \n\
3575 new Geom_SurfaceOfLinearExtrusion(aCurve,aDir); \n\
3577 Handle(Geom_RectangularTrimmedSurface) aTrimmedSurface = \n\
3578 new Geom_RectangularTrimmedSurface(SOLE,-10,10,false); \n\
3580 Standard_CString SOLEEntityTypeName=\"Not Computed\"; \n\
3581 if (!SOLE.IsNull()) \n\
3583 SOLEEntityTypeName = SOLE->DynamicType()->Name(); \n\
3586 AddSeparator(aDoc,Message);
3587 //--------------------------------------------------------------
3589 DisplaySurface(aDoc,aTrimmedSurface,Quantity_NOC_GREEN);
3590 DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
3592 Message += "aCurve is Red; \n";
3593 Message += "aTrimmedSurface is Green; \n";
3595 TCollection_AsciiString Message2 (SOLEEntityTypeName);
3597 Message += " SOLEEntityTypeName = ";Message+= Message2; Message += "\n";
3599 PostProcess(aDoc,ID_BUTTON_Test_44,TheDisplayType,Message);
3602 void GeomSources::gpTest45(CGeometryDoc* aDoc)
3604 DisplayType TheDisplayType = No2D3D;
3605 PreProcess(aDoc,TheDisplayType);
3607 //==============================================================
3609 TColgp_Array1OfPnt array (1,5);
3610 array.SetValue(1,gp_Pnt (0,0,1));
3611 array.SetValue(2,gp_Pnt (1,2,2));
3612 array.SetValue(3,gp_Pnt (2,3,3));
3613 array.SetValue(4,gp_Pnt (4,3,4));
3614 array.SetValue(5,gp_Pnt (5,5,5));
3615 Handle(Geom_BSplineCurve) aCurve =
3616 GeomAPI_PointsToBSpline(array).Curve();
3617 Handle(Geom_SurfaceOfRevolution) SOR =
3618 new Geom_SurfaceOfRevolution(aCurve,gp::OX());
3620 Standard_CString SOREntityTypeName="Not Computed";
3622 SOREntityTypeName = SOR->DynamicType()->Name();
3624 //==============================================================
3625 TCollection_AsciiString Message (" \
3627 TColgp_Array1OfPnt array (1,5); \n\
3628 array.SetValue(1,gp_Pnt 0,0,1)); \n\
3629 array.SetValue(2,gp_Pnt (1,2,2)); \n\
3630 array.SetValue(3,gp_Pnt (2,3,3)); \n\
3631 array.SetValue(4,gp_Pnt (4,3,4)); \n\
3632 array.SetValue(5,gp_Pnt (5,5,5)); \n\
3633 Handle(Geom_BSplineCurve) aCurve = \n\
3634 GeomAPI_PointsToBSpline(array).Curve(); \n\
3635 Handle(Geom_SurfaceOfRevolution) SOR = \n\
3636 new Geom_SurfaceOfRevolution(aCurve,gp::OX()); \n\
3638 Standard_CString SOREntityTypeName=\"Not Computed\"; \n\
3639 if (!SOR.IsNull()) \n\
3640 SOREntityTypeName = SOR->DynamicType()->Name(); \n\
3642 AddSeparator(aDoc,Message);
3644 //--------------------------------------------------------------
3645 DisplaySurface(aDoc,SOR,Quantity_NOC_GREEN);
3646 DisplayCurve(aDoc,aCurve,Quantity_NOC_RED ,false);
3648 Message += "aCurve is Red; \n";
3649 Message += "SOR is Green; \n";
3650 TCollection_AsciiString Message2 (SOREntityTypeName);
3651 Message += " SOREntityTypeName = ";Message+= Message2; Message += "\n";
3653 PostProcess(aDoc,ID_BUTTON_Test_45,TheDisplayType,Message);
3656 void GeomSources::gpTest46(CGeometryDoc* aDoc)
3658 DisplayType TheDisplayType = No2D3D;
3659 PreProcess(aDoc,TheDisplayType);
3660 //==============================================================
3662 TColgp_Array1OfPnt array1 (1,5);
3663 array1.SetValue(1,gp_Pnt (-4,5,5 ));
3664 array1.SetValue(2,gp_Pnt (-3,6,6 ));
3665 array1.SetValue(3,gp_Pnt (-1,6,7 ));
3666 array1.SetValue(4,gp_Pnt (0,8,8));
3667 array1.SetValue(5,gp_Pnt (2,9,9));
3668 Handle(Geom_BSplineCurve) SPL1 =
3669 GeomAPI_PointsToBSpline(array1).Curve();
3671 TColgp_Array1OfPnt array2 (1,5);
3672 array2.SetValue(1,gp_Pnt (-4,5,2 ));
3673 array2.SetValue(2,gp_Pnt (-3,6,3 ));
3674 array2.SetValue(3,gp_Pnt (-1,7,4 ));
3675 array2.SetValue(4,gp_Pnt (0,8,5));
3676 array2.SetValue(5,gp_Pnt (2,9,6));
3677 Handle(Geom_BSplineCurve) SPL2 =
3678 GeomAPI_PointsToBSpline(array2).Curve();
3680 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3681 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3682 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface();
3684 Handle(Geom_BoundedSurface) aTranslatedGeomSurface =
3685 Handle(Geom_BoundedSurface)::DownCast(aGeomSurface->Copy());
3687 Standard_Real extension = 3;
3688 Standard_Integer continuity = 2;
3689 Standard_Boolean Udirection = Standard_True;
3690 Standard_Boolean after = Standard_True;
3691 GeomLib::ExtendSurfByLength (aTranslatedGeomSurface,
3692 extension,continuity,Udirection,after);
3694 //==============================================================
3695 TCollection_AsciiString Message (" \
3697 TColgp_Array1OfPnt array1 (1,5); \n\
3699 Handle(Geom_BSplineCurve) SPL1 = \n\
3700 GeomAPI_PointsToBSpline(array1).Curve(); \n\
3702 TColgp_Array1OfPnt array2 (1,5); \n\
3704 Handle(Geom_BSplineCurve) SPL2 = \n\
3705 GeomAPI_PointsToBSpline(array2).Curve(); \n\
3707 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3708 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3709 Handle(Geom_BSplineSurface) aGeomSurface = aGeomFill1.Surface(); \n\
3711 Handle(Geom_BoundedSurface) aTranslatedGeomSurface = \n\
3712 Handle(Geom_BoundedSurface)::DownCast(aGeomSurface->Copy()); \n\
3714 Standard_Real extension = 3; \n\
3715 Standard_Integer continuity = 2; \n\
3716 Standard_Boolean Udirection = Standard_True; \n\
3717 Standard_Boolean after = Standard_True; \n\
3718 GeomLib::ExtendSurfByLength (aTranslatedGeomSurface, \n\
3719 extension,continuity,Udirection,after); \n\
3721 AddSeparator(aDoc,Message);
3722 //--------------------------------------------------------------
3724 if (!aGeomSurface.IsNull())
3726 DisplaySurface(aDoc,aGeomSurface,Quantity_NOC_HOTPINK);
3729 if (!aTranslatedGeomSurface.IsNull())
3731 DisplaySurface(aDoc,aTranslatedGeomSurface,Quantity_NOC_BLUE1);
3734 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3735 DisplayCurve(aDoc,SPL2,Quantity_NOC_GREEN ,false);
3737 Message += "aGeomSurface is Hot Pink; \n";
3738 Message += "aTranslatedGeomSurface is Blue; \n";
3739 Message += "SPL1 is Red; \n";
3740 Message += "SPL2 is Green; \n";
3742 PostProcess(aDoc,ID_BUTTON_Test_46,TheDisplayType,Message);
3745 void GeomSources::gpTest47(CGeometryDoc* aDoc)
3747 DisplayType TheDisplayType = No2D3D;
3748 PreProcess(aDoc,TheDisplayType);
3750 //==============================================================
3753 TColgp_Array1OfPnt array1 (1,5);
3754 array1.SetValue(1,gp_Pnt (-5,1,2));
3755 array1.SetValue(2,gp_Pnt (-5,2,2));
3756 array1.SetValue(3,gp_Pnt (-5.3,3,1));
3757 array1.SetValue(4,gp_Pnt (-5,4,1));
3758 array1.SetValue(5,gp_Pnt (-5,5,2));
3759 Handle(Geom_BSplineCurve) SPL1 =
3760 GeomAPI_PointsToBSpline(array1).Curve();
3762 TColgp_Array1OfPnt array2 (1,5);
3763 array2.SetValue(1,gp_Pnt (4,1,2));
3764 array2.SetValue(2,gp_Pnt (4,2,2));
3765 array2.SetValue(3,gp_Pnt (3.7,3,1));
3766 array2.SetValue(4,gp_Pnt (4,4,1));
3767 array2.SetValue(5,gp_Pnt (4,5,2));
3768 Handle(Geom_BSplineCurve) SPL2 =
3769 GeomAPI_PointsToBSpline(array2).Curve();
3771 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
3773 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
3774 Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface();
3776 TColgp_Array2OfPnt array3 (1,5,1,5);
3777 array3.SetValue(1,1,gp_Pnt (-4,-4,5));
3778 array3.SetValue(1,2,gp_Pnt (-4,-2,5));
3779 array3.SetValue(1,3,gp_Pnt (-4,0,4));
3780 array3.SetValue(1,4,gp_Pnt (-4,2,5));
3781 array3.SetValue(1,5,gp_Pnt (-4,4,5));
3783 array3.SetValue(2,1,gp_Pnt (-2,-4,4));
3784 array3.SetValue(2,2,gp_Pnt (-2,-2,4));
3785 array3.SetValue(2,3,gp_Pnt (-2,0,4));
3786 array3.SetValue(2,4,gp_Pnt (-2,2,4));
3787 array3.SetValue(2,5,gp_Pnt (-2,5,4));
3789 array3.SetValue(3,1,gp_Pnt (0,-4,3.5));
3790 array3.SetValue(3,2,gp_Pnt (0,-2,3.5));
3791 array3.SetValue(3,3,gp_Pnt (0,0,3.5));
3792 array3.SetValue(3,4,gp_Pnt (0,2,3.5));
3793 array3.SetValue(3,5,gp_Pnt (0,5,3.5));
3795 array3.SetValue(4,1,gp_Pnt (2,-4,4));
3796 array3.SetValue(4,2,gp_Pnt (2,-2,4));
3797 array3.SetValue(4,3,gp_Pnt (2,0,3.5));
3798 array3.SetValue(4,4,gp_Pnt (2,2,5));
3799 array3.SetValue(4,5,gp_Pnt (2,5,4));
3801 array3.SetValue(5,1,gp_Pnt (4,-4,5));
3802 array3.SetValue(5,2,gp_Pnt (4,-2,5));
3803 array3.SetValue(5,3,gp_Pnt (4,0,5));
3804 array3.SetValue(5,4,gp_Pnt (4,2,6));
3805 array3.SetValue(5,5,gp_Pnt (4,5,5));
3807 Handle(Geom_BSplineSurface) aSurf2 =
3808 GeomAPI_PointsToBSplineSurface(array3).Surface();
3810 GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2);
3811 //Standard_Real dist = ESS.LowerDistance();
3813 ESS.NearestPoints(P1,P2);
3816 Handle(Geom_Curve) aCurve;
3817 Standard_Integer NbExtrema = ESS.NbExtrema();
3818 for(Standard_Integer k=1;k<=NbExtrema;k++){
3819 ESS.Points(k,P3,P4);
3820 aCurve= GC_MakeSegment(P3,P4).Value();
3821 DisplayCurve(aDoc,aCurve,Quantity_NOC_YELLOW3,false);
3824 //==============================================================
3826 TCollection_AsciiString Message (" \n\
3827 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
3829 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
3830 Handle(Geom_BSplineSurface) aSurf1 = aGeomFill1.Surface(); \n\
3832 Handle(Geom_BSplineSurface) aSurf2 = \n\
3833 GeomAPI_PointsToBSplineSurface(array3).Surface(); \n\
3835 GeomAPI_ExtremaSurfaceSurface ESS(aSurf1,aSurf2); \n\
3836 Standard_Real dist = ESS.LowerDistance(); \n\
3838 ESS.NearestPoints(P1,P2); \n\
3841 AddSeparator(aDoc,Message);
3842 Message += "aSurf1 is Green; \n";
3843 Message += "aSurf2 is Hot Pink; \n";
3844 Message += "Nearest points P1 and P2 are shown; \n";
3846 //--------------------------------------------------------------
3850 DisplaySurface(aDoc,aSurf1,Quantity_NOC_GREEN);
3851 DisplaySurface(aDoc,aSurf2,Quantity_NOC_HOTPINK);
3852 DisplayCurve(aDoc,SPL1,Quantity_NOC_RED ,false);
3853 DisplayCurve(aDoc,SPL2,Quantity_NOC_AZURE ,false);
3855 DisplayPoint(aDoc,P1,Standard_CString("P1"));
3856 DisplayPoint(aDoc,P2,Standard_CString("P2"));
3858 PostProcess(aDoc,ID_BUTTON_Test_47,TheDisplayType,Message);
3861 void GeomSources::gpTest48(CGeometryDoc* aDoc)
3863 DisplayType TheDisplayType = a2DNo3D;
3864 PreProcess(aDoc,TheDisplayType);
3865 //==============================================================
3867 Standard_Real radius = 3;
3868 Handle(Geom2d_Circle) circle =
3869 new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius);
3871 Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5);
3873 Geom2dAdaptor_Curve GAC (C);
3876 TColgp_Array1OfPnt2d array (1,5); // sizing array
3877 array.SetValue(1,gp_Pnt2d (0,0));
3878 array.SetValue(2,gp_Pnt2d (1,2));
3879 array.SetValue(3,gp_Pnt2d (2,3));
3880 array.SetValue(4,gp_Pnt2d (4,3));
3881 array.SetValue(5,gp_Pnt2d (5,5));
3882 Handle(Geom2d_BSplineCurve) SPL1 =
3883 Geom2dAPI_PointsToBSpline(array);
3886 Handle(TColgp_HArray1OfPnt2d) harray =
3887 new TColgp_HArray1OfPnt2d (1,5); // sizing harray
3888 harray->SetValue(1,gp_Pnt2d (13+ 0,0));
3889 harray->SetValue(2,gp_Pnt2d (13+ 1,2));
3890 harray->SetValue(3,gp_Pnt2d (13+ 2,3));
3891 harray->SetValue(4,gp_Pnt2d (13+ 4,3));
3892 harray->SetValue(5,gp_Pnt2d (13+ 5,5));
3893 Geom2dAPI_Interpolate anInterpolation(harray,Standard_True,0.01);
3894 anInterpolation.Perform();
3895 Handle(Geom2d_BSplineCurve) SPL2 = anInterpolation.Curve();
3898 Geom2dAdaptor_Curve GACC (C);
3899 BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox);
3901 Standard_Real aCXmin, aCYmin, aCXmax, aCYmax;
3902 aCBox.Get( aCXmin, aCYmin, aCXmax,aCYmax);
3905 Geom2dAdaptor_Curve GAC1 (SPL1);
3906 BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box);
3908 Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax;
3909 aSPL1Box.Get( aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax);
3912 Geom2dAdaptor_Curve GAC2 (SPL2);
3913 BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box);
3915 Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax;
3916 aSPL2Box.Get( aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax);
3918 //==============================================================
3919 TCollection_AsciiString Message (" \
3921 Standard_Real radius = 3; \n\
3922 Handle(Geom2d_Circle) circle = \n\
3923 new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(-7,2),gp_Dir2d(1,0)),radius); \n\
3925 Handle(Geom2d_TrimmedCurve) C = new Geom2d_TrimmedCurve(circle,1,5); \n\
3926 Geom2dAdaptor_Curve GAC (C); \n\
3928 Handle(Geom2d_BSplineCurve) SPL1 ; // SPL1 = ... \n\
3930 Handle(Geom2d_BSplineCurve) SPL2 ; // SPL2 = ... \n\
3932 Bnd_Box2d aCBox; \n\
3933 Geom2dAdaptor_Curve GACC (C); \n\
3934 BndLib_Add2dCurve::Add (GACC,Precision::Approximation(),aCBox); \n\
3936 Standard_Real aCXmin, aCYmin, aCXmax, aCYmax; \n\
3937 aCBox.Get( aCXmin, aCYmin, aCXmax,aCYmax); \n\
3939 Bnd_Box2d aSPL1Box; \n\
3940 Geom2dAdaptor_Curve GAC1 (SPL1); \n\
3941 BndLib_Add2dCurve::Add (GAC1,Precision::Approximation(),aSPL1Box); \n\
3943 Standard_Real aSPL1Xmin,aSPL1Ymin,aSPL1Xmax,aSPL1Ymax; \n\
3944 aSPL1Box.Get( aSPL1Xmin, aSPL1Ymin, aSPL1Xmax,aSPL1Ymax); \n");
3947 Bnd_Box2d aSPL2Box; \n\
3948 Geom2dAdaptor_Curve GAC2 (SPL2); \n\
3949 BndLib_Add2dCurve::Add (GAC2,Precision::Approximation(),aSPL2Box); \n\
3951 Standard_Real aSPL2Xmin,aSPL2Ymin,aSPL2Xmax,aSPL2Ymax; \n\
3952 aSPL2Box.Get( aSPL2Xmin, aSPL2Ymin, aSPL2Xmax,aSPL2Ymax); \n\
3954 AddSeparator(aDoc,Message);
3955 //--------------------------------------------------------------
3957 DisplayCurve(aDoc,C ,5);
3958 DisplayCurve(aDoc,SPL1,6 );
3959 DisplayCurve(aDoc,SPL2,7 );
3961 DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmax),Standard_CString("aCXmin,aCYmax"));
3962 DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmax),Standard_CString("aCXmax,aCYmax"));
3963 DisplayPoint(aDoc,gp_Pnt2d(aCXmin,aCYmin),Standard_CString("aCXmin,aCYmin"));
3964 DisplayPoint(aDoc,gp_Pnt2d(aCXmax,aCYmin),Standard_CString("aCXmax,aCYmin"));
3966 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmax),gp_Pnt2d(aCXmax,aCYmax)).Value() ,4); // X,Ymax
3967 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmax,aCYmin)).Value() ,4); // X,Ymin
3968 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmin,aCYmin),gp_Pnt2d(aCXmin,aCYmax)).Value() ,4); // Xmin,Y
3969 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aCXmax,aCYmin),gp_Pnt2d(aCXmax,aCYmax)).Value() ,4); // Xmax,Y
3971 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),Standard_CString("aSPL1Xmin,aSPL1Ymax"));
3972 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymax),Standard_CString("aSPL1Xmax,aSPL1Ymax"));
3973 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),Standard_CString("aSPL1Xmin,aSPL1Ymin"));
3974 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),Standard_CString("aSPL1Xmax,aSPL1Ymin"));
3976 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)).Value() ,4); // X,Ymax
3977 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymin)).Value() ,4); // X,Ymin
3978 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),gp_Pnt2d(aSPL1Xmin,aSPL1Ymax)).Value() ,4); // Xmin,Y
3979 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),gp_Pnt2d(aSPL1Xmax,aSPL1Ymax)).Value() ,4); // Xmax,Y
3981 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymax),Standard_CString("aSPL2Xmin,aSPL2Ymax"));
3982 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymax),Standard_CString("aSPL2Xmax,aSPL2Ymax"));
3983 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmin,aSPL1Ymin),Standard_CString("aSPL2Xmin,aSPL2Ymin"));
3984 DisplayPoint(aDoc,gp_Pnt2d(aSPL1Xmax,aSPL1Ymin),Standard_CString("aSPL2Xmax,aSPL2Ymin"));
3986 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymax),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)).Value() ,4); // X,Ymax
3987 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymin)).Value() ,4); // X,Ymin
3988 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmin,aSPL2Ymin),gp_Pnt2d(aSPL2Xmin,aSPL2Ymax)).Value() ,4); // Xmin,Y
3989 DisplayCurve(aDoc,GCE2d_MakeSegment(gp_Pnt2d(aSPL2Xmax,aSPL2Ymin),gp_Pnt2d(aSPL2Xmax,aSPL2Ymax)).Value() ,4); // Xmax,Y
3991 PostProcess(aDoc,ID_BUTTON_Test_48,TheDisplayType,Message);
3995 void GeomSources::gpTest49(CGeometryDoc* aDoc)
3997 DisplayType TheDisplayType = No2D3D;
3998 PreProcess(aDoc,TheDisplayType);
4000 //==============================================================
4003 Standard_Real radius = 100;
4004 gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5));
4006 Handle(Geom_Circle) C =
4007 new Geom_Circle(anAxis,radius);
4008 GeomAdaptor_Curve GAC (C);
4009 BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox);
4011 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
4012 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
4014 //==============================================================
4016 TCollection_AsciiString Message (" \
4019 Standard_Real radius = 100; \n\
4020 gp_Ax2 anAxis(gp_Pnt(0,0,0),gp_Dir(1,2,-5)); \n\
4022 Handle(Geom_Circle) C = \n\
4023 new Geom_Circle(anAxis,radius); \n\
4024 GeomAdaptor_Curve GAC (C); \n\
4025 BndLib_Add3dCurve::Add (GAC,Precision::Approximation(),aBox); \n\
4027 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ; \n\
4028 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax); \n\
4030 AddSeparator(aDoc,Message);
4031 //--------------------------------------------------------------
4033 DisplayCurve(aDoc,C,Quantity_NOC_BLUE1 ,false);
4035 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmin),Standard_CString("aXmin,aYmax,aZmin"));
4036 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmin),Standard_CString("aXmax,aYmax,aZmin"));
4037 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmin),Standard_CString("aXmin,aYmin,aZmin"));
4038 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmin),Standard_CString("aXmax,aYmin,aZmin"));
4040 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmax,aZmax),Standard_CString("aXmin,aYmax,aZmax"));
4041 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmax,aZmax),Standard_CString("aXmax,aYmax,aZmax"));
4042 DisplayPoint(aDoc,gp_Pnt(aXmin,aYmin,aZmax),Standard_CString("aXmin,aYmin,aZmax"));
4043 DisplayPoint(aDoc,gp_Pnt(aXmax,aYmin,aZmax),Standard_CString("aXmax,aYmin,aZmax"));
4045 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4046 gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMin
4047 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4048 gp_Pnt(aXmax,aYmin,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMin
4049 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4050 gp_Pnt(aXmin,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMin
4051 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4052 gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMin
4053 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4054 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMax
4055 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4056 gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMax
4057 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4058 gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMax
4059 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4060 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMax
4061 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4062 gp_Pnt(aXmin,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymin,Z
4063 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4064 gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymin,Z
4065 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4066 gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymax,Z
4067 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4068 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymax,Z
4070 PostProcess(aDoc,ID_BUTTON_Test_49,TheDisplayType,Message);
4073 void GeomSources::gpTest50(CGeometryDoc* aDoc)
4075 DisplayType TheDisplayType = No2D3D;
4076 PreProcess(aDoc,TheDisplayType);
4077 //==============================================================
4079 TColgp_Array1OfPnt array1 (1,5);
4080 array1.SetValue(1,gp_Pnt (-40,00,20 ));
4081 array1.SetValue(2,gp_Pnt (-70,20,20 ));
4082 array1.SetValue(3,gp_Pnt (-60,30,10 ));
4083 array1.SetValue(4,gp_Pnt (-40,30,-10));
4084 array1.SetValue(5,gp_Pnt (-30,50,-20));
4085 Handle(Geom_BSplineCurve) SPL1 =
4086 GeomAPI_PointsToBSpline(array1).Curve();
4088 TColgp_Array1OfPnt array2 (1,5);
4089 array2.SetValue(1,gp_Pnt (-40,0, 20));
4090 array2.SetValue(2,gp_Pnt (-20,20,0 ));
4091 array2.SetValue(3,gp_Pnt (20 ,30,-10));
4092 array2.SetValue(4,gp_Pnt (30 ,70,-20));
4093 array2.SetValue(5,gp_Pnt (40 ,90,-10));
4094 Handle(Geom_BSplineCurve) SPL2 =
4095 GeomAPI_PointsToBSpline(array2).Curve();
4097 GeomFill_FillingStyle Type = GeomFill_StretchStyle;
4098 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type);
4099 Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface();
4100 GeomAdaptor_Surface GAS (aSurf);
4102 BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox);
4104 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ;
4105 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax);
4107 //==============================================================
4108 TCollection_AsciiString Message (" \
4110 TColgp_Array1OfPnt array1 (1,5); \n\
4111 array1.SetValue(1,gp_Pnt (-40, 0, 20)); \n\
4112 array1.SetValue(2,gp_Pnt (-70, 20, 20)); \n\
4113 array1.SetValue(3,gp_Pnt (-60, 30, 10)); \n\
4114 array1.SetValue(4,gp_Pnt (-40, 30,-10)); \n\
4115 array1.SetValue(5,gp_Pnt (-30, 50,-20)); \n\
4116 Handle(Geom_BSplineCurve) SPL1 = \n\
4117 GeomAPI_PointsToBSpline(array1).Curve(); \n\
4119 TColgp_Array1OfPnt array2 (1,5); \n\
4120 array2.SetValue(1,gp_Pnt (-40, 0, 20)); \n\
4121 array2.SetValue(2,gp_Pnt (-20, 20, 0)); \n\
4122 array2.SetValue(3,gp_Pnt ( 20, 30,-10)); \n\
4123 array2.SetValue(4,gp_Pnt ( 30, 70,-20)); \n\
4124 array2.SetValue(5,gp_Pnt ( 40, 90,-10)); \n\
4125 Handle(Geom_BSplineCurve) SPL2 = \n\
4126 GeomAPI_PointsToBSpline(array2).Curve(); \n\
4128 GeomFill_FillingStyle Type = GeomFill_StretchStyle; \n\
4129 GeomFill_BSplineCurves aGeomFill1(SPL1,SPL2,Type); \n\
4130 Handle(Geom_BSplineSurface) aSurf = aGeomFill1.Surface(); \n\
4131 GeomAdaptor_Surface GAS (aSurf); \n\
4133 BndLib_AddSurface::Add (GAS,Precision::Approximation(),aBox); \n\
4135 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ; \n\
4136 aBox.Get( aXmin, aYmin,aZmin, aXmax,aYmax,aZmax); \n\
4138 AddSeparator(aDoc,Message);
4139 //--------------------------------------------------------------
4141 Quantity_NameOfColor aNameOfColor= Quantity_NOC_GREEN;
4142 Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurf);
4143 aDoc->GetAISContext()->SetColor (aGraphicalSurface, aNameOfColor, Standard_False);
4144 aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
4145 aGraphicalSurface->Attributes()->UIsoAspect()->SetColor(aNameOfColor);
4146 aGraphicalSurface->Attributes()->VIsoAspect()->SetColor(aNameOfColor);
4148 aDoc->GetAISContext()->SetDisplayMode (aGraphicalSurface, 1, Standard_False);
4149 aDoc->GetAISContext()->Display(aGraphicalSurface,false);
4150 // DisplaySurface(aDoc,aSurf,Quantity_NOC_GREEN);
4152 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4153 gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMin
4154 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4155 gp_Pnt(aXmax,aYmin,aZmin)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMin
4156 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4157 gp_Pnt(aXmin,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMin
4158 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4159 gp_Pnt(aXmax,aYmax,aZmin)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMin
4160 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmax),
4161 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymax,ZMax
4162 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4163 gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // X,Ymin,ZMax
4164 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmax),
4165 gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Y,ZMax
4166 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmax),
4167 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Y,ZMax
4168 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmin,aZmin),
4169 gp_Pnt(aXmin,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymin,Z
4170 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmin,aZmin),
4171 gp_Pnt(aXmax,aYmin,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymin,Z
4172 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmin,aYmax,aZmin),
4173 gp_Pnt(aXmin,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmin,Ymax,Z
4174 DisplayCurve(aDoc,GC_MakeSegment(gp_Pnt(aXmax,aYmax,aZmin),
4175 gp_Pnt(aXmax,aYmax,aZmax)).Value() ,Quantity_NOC_RED); // Xmax,Ymax,Z
4177 PostProcess(aDoc,ID_BUTTON_Test_50,TheDisplayType,Message);