1 // DCA_Presentation.cpp: implementation of the DCA_Presentation class.
2 // Geometry Direct Construction Algorithms
3 //////////////////////////////////////////////////////////////////////
6 #include "DCA_Presentation.h"
8 #include <gce_MakeCirc.hxx>
9 #include <gce_MakeElips.hxx>
10 #include <gce_MakeParab.hxx>
11 #include <gce_MakePln.hxx>
12 #include <gce_MakeHypr.hxx>
13 #include <gce_MakeLin.hxx>
14 #include <gce_MakeCylinder.hxx>
15 #include <gce_MakeCone.hxx>
23 #include <gp_Circ.hxx>
25 #include <gp_Cylinder.hxx>
26 #include <gp_Torus.hxx>
27 #include <gp_Sphere.hxx>
29 #include <GC_MakeTrimmedCylinder.hxx>
30 #include <GC_MakeCylindricalSurface.hxx>
31 #include <GC_MakeTrimmedCone.hxx>
32 #include <OCCDemo_Presentation.h>
33 #include <AIS_Point.hxx>
34 #include <AIS_Shape.hxx>
35 #include <Precision.hxx>
37 #include <Geom_Line.hxx>
38 #include <Geom_Vector.hxx>
39 #include <Geom_CartesianPoint.hxx>
40 #include <Geom_Circle.hxx>
41 #include <Geom_Ellipse.hxx>
42 #include <Geom_Parabola.hxx>
43 #include <Geom_Hyperbola.hxx>
44 #include <Geom_Plane.hxx>
45 #include <Geom_ToroidalSurface.hxx>
46 #include <Geom_ConicalSurface.hxx>
47 #include <Geom_SphericalSurface.hxx>
48 #include <Geom_CylindricalSurface.hxx>
49 #include <Geom_TrimmedCurve.hxx>
50 #include <Geom_RectangularTrimmedSurface.hxx>
51 #include <TCollection_AsciiString.hxx>
59 // Initialization of global variable with an instance of this class
60 OCCDemo_Presentation* OCCDemo_Presentation::Current = new DCA_Presentation;
62 // Initialization of array of samples
63 const DCA_Presentation::PSampleFuncType DCA_Presentation::SampleFuncs[] =
65 &DCA_Presentation::sampleLine,
66 &DCA_Presentation::sampleParabola,
67 &DCA_Presentation::sampleHyperbola,
68 &DCA_Presentation::sampleCircle,
69 &DCA_Presentation::sampleEllipse,
70 &DCA_Presentation::samplePlane,
71 &DCA_Presentation::sampleCylindricalSurface,
72 &DCA_Presentation::sampleSphericalSurface,
73 &DCA_Presentation::sampleToroidalSurface,
74 &DCA_Presentation::sampleConicalSurface,
77 //////////////////////////////////////////////////////////////////////
78 // Construction/Destruction
79 //////////////////////////////////////////////////////////////////////
81 DCA_Presentation::DCA_Presentation()
84 myNbSamples = sizeof(SampleFuncs)/sizeof(PSampleFuncType);
85 setName ("Direct Construction Algorithms");
89 //////////////////////////////////////////////////////////////////////
91 //////////////////////////////////////////////////////////////////////
93 void DCA_Presentation::DoSample()
95 getAISContext()->EraseAll();
96 if (myIndex >=0 && myIndex < myNbSamples)
97 (this->*SampleFuncs[myIndex])();
100 //////////////////////////////////////////////////////////////////////
102 //////////////////////////////////////////////////////////////////////
104 // global data used by various samples
105 static gp_Pnt aCenterPoint(120, 0, 0);
107 //================================================================
108 // Function : DCA_Presentation::sampleLine
110 //================================================================
111 void DCA_Presentation::sampleLine()
113 Standard_CString aTitle = "Construction of lines";
115 TCollection_AsciiString aText(
116 " // Define two points" EOL
117 " gp_Pnt aPoint(-350, 0, 0);" EOL
118 " gp_Pnt aPoint1(600, 0, 0);" EOL EOL
120 " // Create a line between two points" EOL
121 " gp_Lin aLin = gce_MakeLin(aPoint, aPoint1);" EOL
123 Comment(aTitle,aText);
126 gp_Pnt aPoint(-350, 0, 0);
127 gp_Pnt aPoint1(600, 0, 0);
129 // Create a line between two points
130 gp_Lin aLin = gce_MakeLin(aPoint,aPoint1);
135 if(WAIT_A_LITTLE) return;
137 Handle(Geom_Line) aLine = new Geom_Line(aLin);
138 Handle(Geom_TrimmedCurve) aCurve =
139 new Geom_TrimmedCurve(aLine, -50, aPoint.Distance(aPoint1)+50);
143 //================================================================
144 // Function : DCA_Presentation::sampleParabola
146 //================================================================
147 void DCA_Presentation::sampleParabola()
149 Standard_CString aTitle = " Construction of parabols";
150 getAISContext()->EraseAll();
151 TCollection_AsciiString aText(
152 " //define direction vectors" EOL
153 " gp_Dir aDir(1,0,0);" EOL
154 " gp_Dir aDir1(0,1,0);" EOL
156 " //define two points" EOL
157 " gp_Pnt aPointParab(80 ,0 ,-200);" EOL
158 " gp_Pnt aFocalPointParab(80 ,0 ,-100);" EOL
160 " //define coordinate system and an axis" EOL
161 " gp_Ax2 anAx2(aPointParab, aDir);" EOL
162 " gp_Ax1 anAx1(aPointParab, aDir1); " EOL
164 " //METHOD1.(coordinate system, focal_length)" EOL
165 " Standard_Real aFocalLength = 50;" EOL
166 " gp_Parab aParab = gce_MakeParab(anAx2,aFocalLength);" EOL
168 " //METHOD2.(axis,point)" EOL
169 " gp_Parab aParab1 = gce_MakeParab(anAx1,aFocalPointParab);" EOL
172 Comment(aTitle,aText);
174 //define direction vectors
179 gp_Pnt aPointParab(80 ,0 ,-200);
180 gp_Pnt aFocalPointParab(80 ,0 ,-100);
182 //define coordinate system and an axis
183 gp_Ax2 anAx2(aPointParab, aDir);
184 gp_Ax1 anAx1(aPointParab, aDir1);
186 //METHOD1.(coordinate system, focal_length)
187 Standard_Real aFocalLength = 50;
188 gp_Parab aParab = gce_MakeParab(anAx2,aFocalLength);
190 //METHOD2.(axis,point)
191 gp_Parab aParab1 = gce_MakeParab(anAx1,aFocalPointParab);
193 //output first parabola
194 drawPoint(aPointParab);
195 drawVector(aPointParab,gp_Vec(aDir)*150,Quantity_Color(Quantity_NOC_WHITE));
197 if(WAIT_A_LITTLE) return;
199 Handle(Geom_Line) aFocalLenLin = new Geom_Line(gce_MakeLin(aPointParab, gp_Dir(0,0,1)));
200 Handle(Geom_TrimmedCurve) aTrim = new Geom_TrimmedCurve(aFocalLenLin, -aFocalLength/2, aFocalLength/2);
203 if(WAIT_A_LITTLE) return;
205 Handle(Geom_Parabola) aParabola = new Geom_Parabola(aParab);
206 Handle(Geom_TrimmedCurve) aParabTrimmed =
207 new Geom_TrimmedCurve(aParabola,-300,300,Standard_True);
208 drawCurve(aParabTrimmed);
210 if(WAIT_A_LITTLE) return;
212 getAISContext()->EraseAll();
214 //output second parabola
215 drawPoint(aPointParab);
216 drawVector(aPointParab,gp_Vec(aDir1)*150,Quantity_Color(Quantity_NOC_WHITE));
217 drawPoint(aFocalPointParab);
219 if(WAIT_A_LITTLE) return;
221 Handle(Geom_Parabola) aParabola1 = new Geom_Parabola(aParab1);
222 Handle(Geom_TrimmedCurve) aParabTrimmed1 = new Geom_TrimmedCurve(aParabola1,-300,300,Standard_True);
223 drawCurve(aParabTrimmed1);
225 //================================================================
226 // Function : DCA_Presentation::sampleHyperbola
228 //================================================================
229 void DCA_Presentation::sampleHyperbola()
231 Standard_CString aTitle = " Construction of hyperbols ";
232 TCollection_AsciiString aText(
233 " //define direction vectors" EOL
234 " gp_Dir aDir(1,0,0);" EOL
236 " //define four points" EOL
237 " gp_Pnt aPointHypr(100 ,0 ,-200);" EOL
238 " gp_Pnt aPointHypr1(100 ,0 ,-300);" EOL
239 " gp_Pnt aPointHypr2(100 ,0 ,-100);" EOL
240 " gp_Pnt aPointHypr3(100 ,100 ,-300);" EOL
243 " gp_Ax2 anAxHypr(aPointHypr, aDir);" EOL
245 " //define radii" EOL
246 " Standard_Real MajorRadius=100;" EOL
247 " Standard_Real MinorRadius=80;" EOL
249 " //METHOD1.(axis,major and minor radiuses)" EOL
250 " gp_Hypr aHypr1 = gce_MakeHypr(anAxHypr, MajorRadius, MinorRadius);" EOL
252 " //METHOD2.(three points)" EOL
253 " gp_Hypr aHypr2 = gce_MakeHypr(aPointHypr2, aPointHypr3, aPointHypr1);" EOL
255 Comment(aTitle,aText);
257 //define direction vectors
261 gp_Pnt aPointHypr(100 ,0 ,-200);
262 gp_Pnt aPointHypr1(100 ,0 ,-300);
263 gp_Pnt aPointHypr2(100 ,0 ,-100);
264 gp_Pnt aPointHypr3(100 ,100 ,-300);
267 gp_Ax2 anAxHypr(aPointHypr, aDir);
270 Standard_Real MajorRadius=100;
271 Standard_Real MinorRadius=80;
273 //METHOD1.(axis,major and minor radiuses)
274 gp_Hypr aHypr1 = gce_MakeHypr(anAxHypr, MajorRadius, MinorRadius);
276 //METHOD2.(three points)
277 gp_Hypr aHypr2 = gce_MakeHypr(aPointHypr2, aPointHypr3, aPointHypr1);
280 //output first hyperbola
281 drawPoint(aPointHypr);
282 drawVector(aPointHypr,gp_Vec(aDir)*200,Quantity_Color(Quantity_NOC_WHITE));
284 if(WAIT_A_LITTLE) return;
286 Handle(Geom_Hyperbola) aHyperbola1 = new Geom_Hyperbola(aHypr1);
287 Handle(Geom_TrimmedCurve) aHyprTrimmed =
288 new Geom_TrimmedCurve(aHyperbola1,-3,4,Standard_True);
289 drawCurve(aHyprTrimmed);
291 if(WAIT_A_LITTLE) return;
293 getAISContext()->EraseAll();
295 //output seconf hyperbola
296 //output points and vector
297 drawPoint(aPointHypr1);
298 drawPoint(aPointHypr2);
299 drawPoint(aPointHypr3);
301 if(WAIT_A_LITTLE) return;
303 drawVector(aPointHypr1,gp_Vec(aPointHypr1,aPointHypr2)*3,Quantity_Color(Quantity_NOC_WHITE));
305 if(WAIT_A_LITTLE) return;
307 //output of display MajorRadius (yellow color)
308 Handle(Geom_Line) aLine = new Geom_Line(gce_MakeLin(aPointHypr1,aPointHypr2));
309 Handle(Geom_TrimmedCurve) aTrimmed1 =
310 new Geom_TrimmedCurve(aLine, 0, aPointHypr1.Distance(aPointHypr2));
311 drawCurve(aTrimmed1,Quantity_Color(Quantity_NOC_YELLOW));
313 if(WAIT_A_LITTLE) return;
315 //output of display MinorRadius (yellow color)
316 Handle(Geom_Line) aLine1 = new Geom_Line(gce_MakeLin(aPointHypr3, gp_Dir(0,-1,0)));
317 Handle(Geom_TrimmedCurve) aTrimmed2 = new Geom_TrimmedCurve(aLine1, 0,100);
318 drawCurve(aTrimmed2,Quantity_Color(Quantity_NOC_YELLOW));
320 if(WAIT_A_LITTLE) return;
323 Handle(Geom_Hyperbola) aHyperbola2 = new Geom_Hyperbola(aHypr2);
324 Handle(Geom_TrimmedCurve) aHyprTrimmed1 =
325 new Geom_TrimmedCurve(aHyperbola2,-2,2,Standard_True);
326 drawCurve(aHyprTrimmed1);
328 //================================================================
329 // Function : DCA_Presentation::sampleCircle
331 //================================================================
332 void DCA_Presentation::sampleCircle()
334 Standard_CString aTitle = " Construction of Circle";
335 TCollection_AsciiString aText(
336 " //define direction vectors" EOL
337 " gp_Dir aDir(1,0,0);" EOL
340 " gp_Ax2 anAx2(aCenterPoint, aDir);" EOL
342 " //define points" EOL
343 " gp_Pnt aCirclePoint1(0,420,0);" EOL
344 " gp_Pnt aCirclePoint2(0,120,300);" EOL
345 " gp_Pnt aCirclePoint3(0,-200,0);" EOL
346 " gp_Pnt aCirclePoint4(120,0,100);" EOL
348 " //define base circle" EOL
349 " //define radius" EOL
350 " Standard_Real radius = 300;" EOL
351 " gp_Circ aCircle(anAx2, radius);" EOL
353 " // METHOD 1.(point,vector,radius)" EOL
354 " gp_Circ aCirc = gce_MakeCirc (aCenterPoint, aDir, radius);" EOL
356 " // METHOD 2.(three points)" EOL
357 " gp_Circ aCirc1 = gce_MakeCirc(aCirclePoint1, aCirclePoint2, aCirclePoint3);" EOL
359 " // METHOD 3.(circle,point)" EOL
360 " gp_Circ aCirc2 = gce_MakeCirc(aCircle, aCirclePoint4);" EOL
362 Comment(aTitle,aText);
364 //define direction vectors
368 gp_Ax2 anAx2(aCenterPoint, aDir);
371 gp_Pnt aCirclePoint1(0,420,0);
372 gp_Pnt aCirclePoint2(0,120,300);
373 gp_Pnt aCirclePoint3(0,-200,0);
374 gp_Pnt aCirclePoint4(120,0,100);
378 Standard_Real radius = 300;
379 gp_Circ aCircle(anAx2, radius);
381 // METHOD 1.(point,vector,radius)
382 gp_Circ aCirc = gce_MakeCirc (aCenterPoint, aDir, radius);
384 // METHOD 2.(three points)
385 gp_Circ aCirc1 = gce_MakeCirc(aCirclePoint1, aCirclePoint2, aCirclePoint3);
387 // METHOD 3.(circle,point)
388 gp_Circ aCirc2 = gce_MakeCirc(aCircle, aCirclePoint4);
391 // METHOD 1.(output of display)
393 //output point and vector
394 drawPoint(aCenterPoint);
395 drawVector(aCenterPoint,gp_Vec(aDir)*400,Quantity_Color(Quantity_NOC_WHITE));
396 if(WAIT_A_LITTLE) return;
399 Handle(Geom_Line) aLine = new Geom_Line(gce_MakeLin (aCenterPoint,gp_Dir(0,0,1)));
400 Handle(Geom_TrimmedCurve) aTrimmed = new Geom_TrimmedCurve(aLine,0,300);
401 drawCurve(aTrimmed,Quantity_Color(Quantity_NOC_WHITE));
403 if(WAIT_A_LITTLE) return;
406 drawCurve(new Geom_Circle(aCirc));
408 if(WAIT_A_LITTLE) return;
410 getAISContext()->EraseAll();
412 // METHOD 2.(output of display)
415 drawPoint(aCirclePoint1);
416 drawPoint(aCirclePoint2);
417 drawPoint(aCirclePoint3);
419 if(WAIT_A_LITTLE) return;
422 drawCurve(new Geom_Circle(aCirc1),Quantity_Color(Quantity_NOC_RED));
424 if(WAIT_A_LITTLE) return;
426 getAISContext()->EraseAll();
428 // METHOD 3.(output of display)
430 //output point and base circle
431 drawPoint(aCirclePoint4);
432 drawCurve(new Geom_Circle(aCircle),Quantity_Color(Quantity_NOC_WHITE));
434 if(WAIT_A_LITTLE) return;
437 drawCurve(new Geom_Circle(aCirc2),Quantity_Color(Quantity_NOC_RED));
439 //================================================================
440 // Function : DCA_Presentation::sampleEllipse
442 //================================================================
443 void DCA_Presentation::sampleEllipse()
445 Standard_CString aTitle = " Construction of Ellipse";
446 TCollection_AsciiString aText(
447 " //define direction vectors" EOL
448 " gp_Dir aDir(1,0,0);" EOL
451 " gp_Ax2 anAx2(aCenterPoint, aDir);" EOL
453 " //define points" EOL
454 " gp_Pnt aEllipsPoint1(120,0,300);" EOL
455 " gp_Pnt aEllipsPoint2(120,120,0);" EOL
457 " //define radiuses" EOL
458 " Standard_Real MajorRadius = 300;" EOL
459 " Standard_Real MinorRadius = 120;" EOL
461 " //METHOD 1.(axis,two radiuses)" EOL
462 " gp_Elips aElips = gce_MakeElips(anAx2, MajorRadius, MinorRadius);" EOL
464 " //METHOD 2 (three points) " EOL
465 " gp_Elips aElips1 = gce_MakeElips(aEllipsPoint1, aEllipsPoint2, aCenterPoint);" EOL
467 Comment(aTitle,aText);
469 //define direction vectors
473 gp_Ax2 anAx2(aCenterPoint, aDir);
476 gp_Pnt aEllipsPoint1(120,0,300);
477 gp_Pnt aEllipsPoint2(120,120,0);
480 Standard_Real MajorRadius = 300;
481 Standard_Real MinorRadius = 120;
483 //METHOD 1.(axis,two radiuses)
484 gp_Elips aElips = gce_MakeElips(anAx2, MajorRadius, MinorRadius);
486 //METHOD 2 (three points)
487 gp_Elips aElips1 = gce_MakeElips(aEllipsPoint1, aEllipsPoint2, aCenterPoint);
490 //METHOD 1 .(output of display)
491 //output point and vector
492 drawPoint(aCenterPoint);
493 drawVector(aCenterPoint,gp_Vec(aDir)*400,Quantity_Color(Quantity_NOC_WHITE));
495 if(WAIT_A_LITTLE) return;
497 //output first ellipse
498 drawCurve(new Geom_Ellipse(aElips));
500 if(WAIT_A_LITTLE) return;
502 getAISContext()->EraseAll();
504 //METHOD 2 .(output of display)
505 drawPoint(aCenterPoint);
506 drawPoint(aEllipsPoint1);
507 drawPoint(aEllipsPoint2);
509 if(WAIT_A_LITTLE) return;
514 gce_MakeLin aMakeLin(aCenterPoint,aDir1);
515 gp_Lin aLine = aMakeLin.Value();
518 gce_MakeLin aMakeLin1(aCenterPoint,aDir2);
519 gp_Lin aLine1 = aMakeLin1.Value();
522 Handle(Geom_Line) aLineMajorRadius = new Geom_Line(aLine);
523 Handle(Geom_TrimmedCurve) aTrimmed =
524 new Geom_TrimmedCurve(aLineMajorRadius,0,120);
525 drawCurve(aTrimmed,Quantity_Color(Quantity_NOC_WHITE));
527 if(WAIT_A_LITTLE) return;
530 Handle(Geom_Line) aLineMinorrRadius = new Geom_Line(aLine1);
531 Handle(Geom_TrimmedCurve) aTrimmed1 =
532 new Geom_TrimmedCurve(aLineMinorrRadius,0,300);
533 drawCurve(aTrimmed1,Quantity_Color(Quantity_NOC_WHITE));
535 if(WAIT_A_LITTLE) return;
537 //output second ellipse
538 drawCurve(new Geom_Ellipse(aElips1),Quantity_Color(Quantity_NOC_RED));
540 //================================================================
541 // Function : DCA_Presentation::samplePlane
543 //================================================================
544 void DCA_Presentation::samplePlane()
546 Standard_CString aTitle = "Construction of Plane ";
547 TCollection_AsciiString aText(
548 " //define direction vector" EOL
549 " gp_Dir aDir(1,0,0);" EOL
552 " gp_Ax2 anAx2(aCenterPoint,aDir);" EOL
554 " //define three points" EOL
555 " gp_Pnt aPointPlane1(0,0,0);" EOL
556 " gp_Pnt aPointPlane2(0,-120,0);" EOL
557 " gp_Pnt aPointPlane3(0,50 , -100);" EOL
559 " //METHOD 1.(axis)" EOL
560 " gp_Pln aPlane = gce_MakePln(anAx2);" EOL
562 " //METHOD 2 (three points) " EOL
563 " gp_Pln aPlane1 = gce_MakePln(aPointPlane1,aPointPlane2,aPointPlane3);" EOL
565 Comment(aTitle,aText);
567 //define direction vector
571 gp_Ax2 anAx2(aCenterPoint,aDir);
573 //define three points
574 gp_Pnt aPointPlane1(0,0,0);
575 gp_Pnt aPointPlane2(0,-120,0);
576 gp_Pnt aPointPlane3(0,50 , -100);
579 gp_Pln aPlane = gce_MakePln(anAx2);
581 //METHOD 2 (three points)
582 gp_Pln aPlane1 = gce_MakePln(aPointPlane1,aPointPlane2,aPointPlane3);
585 //METHOD 1. (output of display)
586 drawPoint(aCenterPoint);
587 drawVector(aCenterPoint,gp_Vec(aDir)*400,Quantity_Color(Quantity_NOC_WHITE));
589 if(WAIT_A_LITTLE) return;
591 Handle(Geom_Plane) aPln = new Geom_Plane(aPlane);
592 Handle(Geom_RectangularTrimmedSurface) aPlnTrimmed =
593 new Geom_RectangularTrimmedSurface(aPln,-300,300,-300,300,Standard_True,Standard_True);
594 drawSurface(aPlnTrimmed);
596 if(WAIT_A_LITTLE) return;
598 getAISContext()->EraseAll();
600 //METHOD 2.(output of display)
601 drawPoint(aPointPlane1);
602 drawPoint(aPointPlane2);
603 drawPoint(aPointPlane3);
605 if(WAIT_A_LITTLE) return;
607 Handle(Geom_Plane) aPln1 = new Geom_Plane(aPlane1);
608 Handle(Geom_RectangularTrimmedSurface) aPlnTrimmed1 =
609 new Geom_RectangularTrimmedSurface(aPln1,-200,300,-200,300,Standard_True,Standard_True);
610 drawSurface(aPlnTrimmed1);
613 //================================================================
614 // Function : OCCDemo_Presentation::sampleCylindricalSurface
616 //================================================================
617 void DCA_Presentation::sampleCylindricalSurface()
619 Standard_CString aTitle = " Construction of CylindricalSurface ";
620 TCollection_AsciiString aText(
621 " //define direction vectors" EOL
622 " gp_Dir aDir(1,0,0);" EOL
624 " //define points " EOL
625 " gp_Pnt aCylinderPoint1(0,20,-20);" EOL
626 " gp_Pnt aCylinderPoint2(0,20,-100);" EOL
627 " gp_Pnt aCylinderPoint3(120,20,-100);" EOL
628 " gp_Pnt aCylinderPoint4(120,20,100);" EOL
630 " //define axises" EOL
631 " gp_Ax3 anAx3(aCenterPoint,aDir);" EOL
633 " //define base cylinder" EOL
634 " Standard_Real rad = 10;" EOL
635 " gp_Cylinder aCylinder(anAx3,rad);" EOL
637 " //define base circle" EOL
638 " Standard_Real Radius = 100;" EOL
639 " gp_Circ aCirc(anAx3.Ax2(),Radius);" EOL
641 " //METHOD 1.(axis,radius) " EOL
642 " gp_Cylinder aCyl = gce_MakeCylinder (anAx3.Ax2(),Radius);" EOL
644 " //METHOD 2.(three points) " EOL
645 " gp_Cylinder aCyl1 = gce_MakeCylinder(aCylinderPoint2,aCylinderPoint3,aCylinderPoint1);" EOL
647 " //METHOD 3.(point,base cylinder)" EOL
648 " gp_Cylinder aCyl2 = gce_MakeCylinder(aCylinder,aCylinderPoint4);" EOL
650 " //METHOD 4.(base circle)" EOL
651 " gp_Cylinder aCyl3 = gce_MakeCylinder(aCirc);" EOL
653 Comment(aTitle,aText);
655 //define direction vectors
659 gp_Pnt aCylinderPoint1(0,20,-20);
660 gp_Pnt aCylinderPoint2(0,20,-100);
661 gp_Pnt aCylinderPoint3(120,20,-100);
662 gp_Pnt aCylinderPoint4(120,20,100);
665 gp_Ax3 anAx3(aCenterPoint,aDir);
667 //define base cylinder
668 Standard_Real rad = 10;
669 gp_Cylinder aCylinder(anAx3,rad);
672 Standard_Real Radius = 100;
673 gp_Circ aCirc(anAx3.Ax2(),Radius);
675 //METHOD 1.(axis,radius)
676 gp_Cylinder aCyl = gce_MakeCylinder (anAx3.Ax2(),Radius);
678 //METHOD 2.(three points)
679 gp_Cylinder aCyl1 = gce_MakeCylinder(aCylinderPoint2,aCylinderPoint3,aCylinderPoint1);
681 //METHOD 3.(point,base cylinder)
682 gp_Cylinder aCyl2 = gce_MakeCylinder(aCylinder,aCylinderPoint4);
684 //METHOD 4.(base circle)
685 gp_Cylinder aCyl3 = gce_MakeCylinder(aCirc);
688 //METHOD 1.(output of dispay)
689 drawPoint(aCenterPoint);
690 drawVector(aCenterPoint,gp_Vec(aDir)*400,Quantity_Color(Quantity_NOC_WHITE));
691 if(WAIT_A_LITTLE) return;
694 gce_MakeLin aMakeLin(aCenterPoint,aDir1);
695 gp_Lin aLin = aMakeLin.Value();
696 Handle(Geom_Line) aLine = new Geom_Line(aLin);
697 Handle(Geom_TrimmedCurve) aTrimmed = new Geom_TrimmedCurve(aLine,-100,0);
698 drawCurve(aTrimmed,Quantity_Color(Quantity_NOC_WHITE));
699 if(WAIT_A_LITTLE) return;
701 Handle(Geom_CylindricalSurface) aCylSurface =
702 new Geom_CylindricalSurface(aCyl);
703 Handle(Geom_RectangularTrimmedSurface) aCylTrimmed =
704 new Geom_RectangularTrimmedSurface(aCylSurface,0,2*PI,-200,300,Standard_True,Standard_True);
705 drawSurface(aCylTrimmed);
706 if(WAIT_A_LITTLE) return;
707 getAISContext()->EraseAll();
709 //METHOD 2.(output of dispay)
711 drawPoint(aCylinderPoint1);
712 drawPoint(aCylinderPoint2);
713 drawPoint(aCylinderPoint3);
714 if(WAIT_A_LITTLE) return;
716 drawVector(aCylinderPoint2,gp_Vec(aCylinderPoint2,aCylinderPoint3)*3,Quantity_Color(Quantity_NOC_WHITE));
717 if(WAIT_A_LITTLE) return;
719 Handle(Geom_Line) aLine1 = new Geom_Line(gce_MakeLin(aCylinderPoint1,aDir1));
720 Handle(Geom_TrimmedCurve) aTrimmed1 = new Geom_TrimmedCurve(aLine1,-80,0);
721 drawCurve(aTrimmed1,Quantity_Color(Quantity_NOC_WHITE));
722 if(WAIT_A_LITTLE) return;
724 Handle(Geom_CylindricalSurface) aCylSurface1 =
725 new Geom_CylindricalSurface(aCyl1);
726 Handle(Geom_RectangularTrimmedSurface) aCylTrimmed1 =
727 new Geom_RectangularTrimmedSurface(aCylSurface1,0,2*PI,-300,100,Standard_True,Standard_True);
728 drawSurface(aCylTrimmed1);
729 if(WAIT_A_LITTLE) return;
730 getAISContext()->EraseAll();
732 //METHOD 3.(output of dispay)
733 //output base cylinder
734 Handle(Geom_CylindricalSurface) aCylSurf = new Geom_CylindricalSurface(aCylinder);
735 Handle(Geom_RectangularTrimmedSurface) aCylTrimmed2 =
736 new Geom_RectangularTrimmedSurface(aCylSurf,0,2*PI,-200,200,Standard_True,Standard_True);
737 drawSurface(aCylTrimmed2 ,Quantity_Color(Quantity_NOC_WHITE));
739 drawPoint(aCylinderPoint4);
740 if(WAIT_A_LITTLE) return;
742 Handle(Geom_CylindricalSurface) aCylSurface2 =
743 new Geom_CylindricalSurface(aCyl2);
744 Handle(Geom_RectangularTrimmedSurface) aCylTrimmed3 =
745 new Geom_RectangularTrimmedSurface(aCylSurface2,0,2*PI,-200,200,Standard_True,Standard_True);
746 drawSurface(aCylTrimmed3);
747 if(WAIT_A_LITTLE) return;
748 getAISContext()->EraseAll();
749 //METHOD 4.(output of dispay)
750 drawPoint(aCenterPoint);
751 drawVector(aCenterPoint,gp_Vec(aDir)*400,Quantity_Color(Quantity_NOC_WHITE));
753 drawCurve(new Geom_Circle(aCirc),Quantity_Color(Quantity_NOC_WHITE));
754 if(WAIT_A_LITTLE) return;
756 Handle(Geom_CylindricalSurface) aCylSurface3 =
757 new Geom_CylindricalSurface(aCyl3);
758 Handle(Geom_RectangularTrimmedSurface) aCylTrimmed4 =
759 new Geom_RectangularTrimmedSurface(aCylSurface3,0,2*PI,-200,200,Standard_True,Standard_True);
760 drawSurface(aCylTrimmed4);
762 //================================================================
763 // Function : DCA_Presentation::sampleToroidalSurface
765 //================================================================
766 void DCA_Presentation::sampleToroidalSurface()
768 Standard_CString aTitle = " Construction of ToroidalSurface ";
769 TCollection_AsciiString aText(
770 " //define direction vectors" EOL
771 " gp_Dir aDir(1,0,0);" EOL
772 " //define toroidal surface's axis" EOL
773 " gp_Ax3 anAx3(aCenterPoint, aDir);" EOL
775 " //define two radiuses" EOL
776 " Standard_Real MajorRadius = 200;" EOL
777 " Standard_Real MinorRadius = 100;" EOL
780 " gp_Torus aTorus(anAx3, MajorRadius, MinorRadius);" EOL
782 Comment(aTitle,aText);
784 //define direction vectors
786 //define toroidal surface's axis
787 gp_Ax3 anAx3(aCenterPoint, aDir);
789 //define two radiuses
790 Standard_Real MajorRadius = 200;
791 Standard_Real MinorRadius = 100;
794 gp_Torus aTorus(anAx3, MajorRadius, MinorRadius);
796 //display shapes in the viewer
797 drawPoint(aCenterPoint);
798 drawVector(aCenterPoint,gp_Vec(aDir)*400,Quantity_Color(Quantity_NOC_WHITE));
800 if(WAIT_A_LITTLE) return;
803 Handle(Geom_Line) R1 = new Geom_Line(gce_MakeLin(aCenterPoint, gp_Dir(0,1,0)));
804 Handle(Geom_TrimmedCurve) aTrimmedR1 = new Geom_TrimmedCurve(R1,0,MajorRadius);
805 drawCurve(aTrimmedR1, Quantity_Color(Quantity_NOC_WHITE));
806 drawCurve(new Geom_Circle(anAx3.Ax2(), MajorRadius));
808 if(WAIT_A_LITTLE) return;
810 // output MinorRadius as a circle
811 gp_Ax2 aMinorRadAx(aTrimmedR1->EndPoint(), gp_Dir(0,0,1));
812 Handle(Geom_Circle) aMinorRadCirc = new Geom_Circle(aMinorRadAx, MinorRadius);
813 drawCurve(aMinorRadCirc);
815 if(WAIT_A_LITTLE) return;
818 drawSurface(new Geom_ToroidalSurface(aTorus));
821 //================================================================
822 // Function : DCA_Presentation::sampleConicalSurface
824 //================================================================
825 void DCA_Presentation::sampleConicalSurface()
827 Standard_CString aTitle = " Construction of ConicalSurface";
828 TCollection_AsciiString aText(
829 " //define direction vectors" EOL
830 " gp_Dir aDir(1,0,0);" EOL
832 " //define points" EOL
833 " gp_Pnt aPoint_1(0,0,0);" EOL
834 " gp_Pnt aPoint_2(240,0,0);" EOL
835 " gp_Pnt aPoint_3(0,-50,0);" EOL
836 " gp_Pnt aPoint_4(100,-60,0);" EOL
837 " gp_Pnt aConePnt(120,-100,0);" EOL
838 " gp_Pnt aConePnt1(0,-50,0);" EOL
839 " gp_Pnt aConePnt2(0,-100,0);" EOL
841 " //define axises" EOL
842 " gp_Ax2 anAx2(aCenterPoint,aDir);" EOL
843 " gp_Ax1 anAx1(aCenterPoint,aDir);" EOL
845 " //define radiuses" EOL
846 " Standard_Real Radius1 = 100;" EOL
847 " Standard_Real Radius2 = 50;" EOL
848 " Standard_Real Radius3 = 70;" EOL
850 " //define angle" EOL
851 " Standard_Real Angle = PI/6;" EOL
853 " //METHOD 1.(axis,two points)" EOL
854 " gp_Cone aCone1 = gce_MakeCone(anAx1, aConePnt1, aConePnt);" EOL
856 " //METHOD 2.(two points,two radiuses)" EOL
857 " gp_Cone aCone2 = gce_MakeCone(aConePnt2,aConePnt,Radius2,Radius1);" EOL
859 " //METHOD 3.(axis,angle,radius)" EOL
860 " gp_Cone aCone3 = gce_MakeCone(anAx2,Angle,Radius3);" EOL
862 " //METHOD 4.(four points)" EOL
863 " gp_Cone aCone4 = gce_MakeCone (aPoint_1,aPoint_2,aPoint_3,aPoint_4);" EOL
866 Comment(aTitle,aText);
868 //define direction vectors
872 gp_Pnt aPoint_1(0,0,0);
873 gp_Pnt aPoint_2(240,0,0);
874 gp_Pnt aPoint_3(0,-50,0);
875 gp_Pnt aPoint_4(100,-60,0);
876 gp_Pnt aConePnt(120,-100,0);
877 gp_Pnt aConePnt1(0,-50,0);
878 gp_Pnt aConePnt2(0,-100,0);
881 gp_Ax2 anAx2(aCenterPoint,aDir);
882 gp_Ax1 anAx1(aCenterPoint,aDir);
885 Standard_Real Radius1 = 100;
886 Standard_Real Radius2 = 50;
887 Standard_Real Radius3 = 70;
890 Standard_Real Angle = PI/6;
892 //METHOD 1.(axis,two points)
893 gp_Cone aCone1 = gce_MakeCone(anAx1, aConePnt1, aConePnt);
895 //METHOD 2.(two points,two radiuses)
896 gp_Cone aCone2 = gce_MakeCone(aConePnt2,aConePnt,Radius2,Radius1);
898 //METHOD 3.(axis,angle,radius)
899 gp_Cone aCone3 = gce_MakeCone(anAx2,Angle,Radius3);
901 //METHOD 4.(four points)
902 gp_Cone aCone4 = gce_MakeCone (aPoint_1,aPoint_2,aPoint_3,aPoint_4);
905 //METHOD1.(output of display)
907 drawPoint(aCenterPoint);
908 drawVector(aCenterPoint,gp_Vec(aDir)*400,Quantity_Color(Quantity_NOC_WHITE));
910 if(WAIT_A_LITTLE) return;
914 drawPoint(aConePnt1);
917 //output first radius
918 Handle(Geom_Line) aLine = new Geom_Line(gce_MakeLin(aConePnt,aDir1));
919 Handle(Geom_TrimmedCurve) aTrimmed = new Geom_TrimmedCurve(aLine,0,100);
920 drawCurve(aTrimmed,Quantity_Color(Quantity_NOC_WHITE));
922 //output second radius
923 Handle(Geom_Line) aLine1 = new Geom_Line(gce_MakeLin(aConePnt1,aDir1));
924 Handle(Geom_TrimmedCurve) aTrimmed1 = new Geom_TrimmedCurve(aLine1,0,50);
925 drawCurve(aTrimmed1,Quantity_Color(Quantity_NOC_WHITE));
927 if(WAIT_A_LITTLE) return;
929 //output ruling of cone
930 Handle(Geom_Line) aLine2 = new Geom_Line(gce_MakeLin(aConePnt,aConePnt1));
931 Handle(Geom_TrimmedCurve) aTrimmed2 =
932 new Geom_TrimmedCurve(aLine2,0,aConePnt.Distance(aConePnt1));
933 drawCurve(aTrimmed2,Quantity_Color(Quantity_NOC_RED));
935 if(WAIT_A_LITTLE) return;
938 Handle(Geom_ConicalSurface) aConSurface1 = new Geom_ConicalSurface(aCone1);
939 Handle(Geom_RectangularTrimmedSurface) aConTrimmed1 =
940 new Geom_RectangularTrimmedSurface(aConSurface1,0,2*PI,-50,450,Standard_True,Standard_True);
941 drawSurface(aConTrimmed1);
943 if(WAIT_A_LITTLE) return;
945 getAISContext()->EraseAll();
947 //METHOD2.(output of display)
948 drawPoint(aConePnt2);
951 if(WAIT_A_LITTLE) return;
953 drawVector(aConePnt2,gp_Vec(aConePnt2,aConePnt)*2,Quantity_Color(Quantity_NOC_WHITE));
955 if(WAIT_A_LITTLE) return;
957 //output of first radius
958 Handle(Geom_Line) aLineR1 = new Geom_Line(gce_MakeLin (aConePnt,aDir1));
959 Handle(Geom_TrimmedCurve) aTrimmedR1 = new Geom_TrimmedCurve(aLineR1,0,Radius1);
960 drawCurve(aTrimmedR1,Quantity_Color(Quantity_NOC_WHITE));
962 //output of second radius
963 Handle(Geom_Line) aLineR2 = new Geom_Line(gce_MakeLin (aConePnt2,aDir1));
964 Handle(Geom_TrimmedCurve) aTrimmedR2 = new Geom_TrimmedCurve(aLineR2,0,Radius2);
965 drawCurve(aTrimmedR2,Quantity_Color(Quantity_NOC_WHITE));
968 Handle(Geom_ConicalSurface) aConSurface2 = new Geom_ConicalSurface(aCone2);
969 Handle(Geom_RectangularTrimmedSurface) aConTrimmed2 =
970 new Geom_RectangularTrimmedSurface(aConSurface2,0,2*PI,-120,400,Standard_True,Standard_True);
971 drawSurface(aConTrimmed2);
973 if(WAIT_A_LITTLE) return;
975 getAISContext()->EraseAll();
977 //METHOD3.(output of display)
978 drawPoint(aCenterPoint);
979 drawVector(aCenterPoint,gp_Vec(aDir)*400,Quantity_Color(Quantity_NOC_WHITE));
981 if(WAIT_A_LITTLE) return;
984 Handle(Geom_Line) aLine3 = new Geom_Line(gce_MakeLin (aCenterPoint,aDir1));
985 Handle(Geom_TrimmedCurve) aTrimmed3 = new Geom_TrimmedCurve(aLine3,0,70);
986 drawCurve(aTrimmed3 ,Quantity_Color(Quantity_NOC_WHITE));
989 Handle(Geom_ConicalSurface) aConSurface3 = new Geom_ConicalSurface(aCone3);
990 Handle(Geom_RectangularTrimmedSurface) aConTrimmed =
991 new Geom_RectangularTrimmedSurface(aConSurface3,0,2*PI,-300,300,Standard_True,Standard_True);
992 drawSurface(aConTrimmed);
994 if(WAIT_A_LITTLE) return;
996 getAISContext()->EraseAll();
998 //METHOD4.(output of display)
1001 drawPoint(aPoint_1);
1002 drawPoint(aPoint_2);
1003 drawPoint(aPoint_3);
1004 drawPoint(aPoint_4);
1006 if(WAIT_A_LITTLE) return;
1009 drawVector(aPoint_1,gp_Vec(aPoint_1,aPoint_2)*2,Quantity_Color(Quantity_NOC_WHITE));
1011 if(WAIT_A_LITTLE) return;
1013 //output ruling of cone
1014 Handle(Geom_Line) aLine4 = new Geom_Line(gce_MakeLin (aPoint_3,aPoint_4));
1015 Handle(Geom_TrimmedCurve) aTrimmed4 =
1016 new Geom_TrimmedCurve(aLine4,0,aPoint_3.Distance(aPoint_4));
1017 drawCurve(aTrimmed4 ,Quantity_Color(Quantity_NOC_RED));
1019 if(WAIT_A_LITTLE) return;
1021 //output first radius
1022 Handle(Geom_Line) aLine5 = new Geom_Line(gce_MakeLin (aPoint_3,aDir1));
1023 Handle(Geom_TrimmedCurve) aTrimmed5 = new Geom_TrimmedCurve(aLine5,0,50);
1024 drawCurve(aTrimmed5 ,Quantity_Color(Quantity_NOC_WHITE));
1026 if(WAIT_A_LITTLE) return;
1028 //output second radius
1029 Handle(Geom_Line) aLine6 = new Geom_Line(gce_MakeLin (aPoint_4,aDir1));
1030 Handle(Geom_TrimmedCurve) aTrimmed6 = new Geom_TrimmedCurve(aLine6,0,60);
1031 drawCurve(aTrimmed6 ,Quantity_Color(Quantity_NOC_WHITE));
1033 if(WAIT_A_LITTLE) return;
1036 Handle(Geom_ConicalSurface) aConSurface4 = new Geom_ConicalSurface(aCone4);
1037 Handle(Geom_RectangularTrimmedSurface) aConTrimmed4 =
1038 new Geom_RectangularTrimmedSurface(aConSurface4,0,2*PI,-300,300,Standard_True,Standard_True);
1039 drawSurface(aConTrimmed4);
1042 //================================================================
1043 // Function : DCA_Presentation::sampleSphericalSurface
1045 //================================================================
1046 void DCA_Presentation::sampleSphericalSurface()
1048 Standard_CString aTitle = " Construction of SphericalSurface";
1049 TCollection_AsciiString aText(
1050 " //define direction vector" EOL
1051 " gp_Dir aDir(1,0,0);" EOL
1053 " //define axises" EOL
1054 " gp_Ax3 anAx3(aCenterPoint,aDir);" EOL
1056 " //define radius" EOL
1057 " Standard_Real Radius = 300;" EOL
1059 " //make sphere" EOL
1060 " gp_Sphere aSphere(anAx3,Radius);" EOL
1062 Comment(aTitle,aText);
1064 //define direction vector
1068 gp_Ax3 anAx3(aCenterPoint,aDir);
1071 Standard_Real Radius = 300;
1074 gp_Sphere aSphere(anAx3,Radius);
1077 drawPoint(aCenterPoint);
1078 drawVector(aCenterPoint,gp_Vec(aDir)*400,Quantity_Color(Quantity_NOC_WHITE));
1080 if(WAIT_A_LITTLE) return;
1082 drawSurface(new Geom_SphericalSurface(aSphere));
1087 //================================================================
1088 // Function : DCA_Presentation::Comment
1090 //================================================================
1091 void DCA_Presentation::Comment(const Standard_CString theTitle,
1092 TCollection_AsciiString &theText)
1094 setResultTitle(theTitle);
1095 setResultText(theText.ToCString());