1 #include <Prs2d_Cylindric.ixx>
3 Prs2d_Cylindric::Prs2d_Cylindric( const Handle(Graphic2d_GraphicObject)& aGO,
4 const Standard_Real aX,
5 const Standard_Real aY,
6 const Standard_Real aLength,
7 const Standard_Real anAngle )
9 : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle )
13 void Prs2d_Cylindric::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) {
15 Standard_Boolean IsIn = Standard_False;
17 if ( !myGOPtr->IsTransformed() )
18 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
20 Standard_ShortReal minx, miny, maxx, maxy;
21 MinMax( minx, maxx, miny, maxy );
22 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
26 DrawLineAttrib( aDrawer );
28 Standard_ShortReal X1 = Standard_ShortReal( myX - myLength/2 ),
29 Y1 = Standard_ShortReal( myY - myLength/2 ),
30 X4 = Standard_ShortReal( myX + myLength/2 ),
32 X2 = Standard_ShortReal( X1 + myLength/2 ),
33 Y2 = Standard_ShortReal( myY + myLength/2 ),
35 X3 = Standard_ShortReal( X4 + myLength/2 ),
37 gp_Pnt2d thePnt1( X1, Y1);
38 gp_Vec2d theVec( thePnt1, gp_Pnt2d( X3, Y3 ) );
40 thePnt1.Translate( theVec );
41 Standard_ShortReal theRad = Standard_ShortReal( myLength/2*Sin(Standard_PI / 3) );
42 Standard_ShortReal Xc = Standard_ShortReal(thePnt1.X()),
43 Yc = Standard_ShortReal(thePnt1.Y());
45 gp_Pnt2d P1( X1, Y1 ),
51 P1.Rotate( PR, myAngle );
52 P2.Rotate( PR, myAngle );
53 P3.Rotate( PR, myAngle );
54 P4.Rotate( PR, myAngle );
55 PC.Rotate( PR, myAngle );
56 X1 = Standard_ShortReal( P1.X() );
57 Y1 = Standard_ShortReal( P1.Y() );
58 X2 = Standard_ShortReal( P2.X() );
59 Y2 = Standard_ShortReal( P2.Y() );
60 X3 = Standard_ShortReal( P3.X() );
61 Y3 = Standard_ShortReal( P3.Y() );
62 X4 = Standard_ShortReal( P4.X() );
63 Y4 = Standard_ShortReal( P4.Y() );
64 Xc = Standard_ShortReal( PC.X() );
65 Yc = Standard_ShortReal( PC.Y() );
66 if ( myGOPtr->IsTransformed () ) {
67 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
71 aTrsf.Transforms( a1, b1 );
72 X1 = Standard_ShortReal( a1 );
73 Y1 = Standard_ShortReal( b1 );
76 aTrsf.Transforms( a1, b1 );
77 X2 = Standard_ShortReal( a1 );
78 Y2 = Standard_ShortReal( b1 );
81 aTrsf.Transforms( a1, b1 );
82 X3 = Standard_ShortReal( a1 );
83 Y3 = Standard_ShortReal( b1 );
86 aTrsf.Transforms( a1, b1 );
87 X4 = Standard_ShortReal( a1 );
88 Y4 = Standard_ShortReal( b1 );
91 aTrsf.Transforms( a1, b1 );
92 Xc = Standard_ShortReal( a1 );
93 Yc = Standard_ShortReal( b1 );
95 aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 );
96 aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 );
97 aDrawer->MapArcFromTo( Xc, Yc, theRad, 0.0, Standard_ShortReal( 2. * Standard_PI ) );
101 void Prs2d_Cylindric::Save(Aspect_FStream& aFStream) const