1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <Prs2d_Symmetry.ixx>
20 Prs2d_Symmetry::Prs2d_Symmetry( const Handle(Graphic2d_GraphicObject)& aGO,
21 const Standard_Real aX,
22 const Standard_Real aY,
23 const Standard_Real aLength,
24 const Standard_Real anAngle )
26 : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle )
30 void Prs2d_Symmetry::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) {
32 Standard_Boolean IsIn = Standard_False;
34 if ( !myGOPtr->IsTransformed() )
35 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
37 Standard_ShortReal minx, miny, maxx, maxy;
38 MinMax( minx, maxx, miny, maxy );
39 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
43 DrawLineAttrib( aDrawer );
44 Standard_ShortReal X1 = myX - myLength/2,
46 X2 = myX + myLength/2,
48 X3 = myX - myLength/3,
49 Y3 = myY - myLength/3,
50 X4 = myX + myLength/3,
53 Y5 = myY + myLength/3,
57 gp_Pnt2d PP1( X1, Y1 ),
64 PP1.Rotate( PPR, myAngle );
65 PP2.Rotate( PPR, myAngle );
66 PP3.Rotate( PPR, myAngle );
67 PP4.Rotate( PPR, myAngle );
68 PP5.Rotate( PPR, myAngle );
69 PP6.Rotate( PPR, myAngle );
71 X1 = Standard_ShortReal( PP1.X() );
72 Y1 = Standard_ShortReal( PP1.Y() );
73 X2 = Standard_ShortReal( PP2.X() );
74 Y2 = Standard_ShortReal( PP2.Y() );
75 X3 = Standard_ShortReal( PP3.X() );
76 Y3 = Standard_ShortReal( PP3.Y() );
77 X4 = Standard_ShortReal( PP4.X() );
78 Y4 = Standard_ShortReal( PP4.Y() );
79 X5 = Standard_ShortReal( PP5.X() );
80 Y5 = Standard_ShortReal( PP5.Y() );
81 X6 = Standard_ShortReal( PP6.X() );
82 Y6 = Standard_ShortReal( PP6.Y() );
84 if ( myGOPtr->IsTransformed () ) {
85 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
89 aTrsf.Transforms( a1, b1 );
90 X1 = Standard_ShortReal( a1 );
91 Y1 = Standard_ShortReal( b1 );
94 aTrsf.Transforms( a1, b1 );
95 X2 = Standard_ShortReal( a1 );
96 Y2 = Standard_ShortReal( b1 );
99 aTrsf.Transforms( a1, b1 );
100 X3 = Standard_ShortReal( a1 );
101 Y3 = Standard_ShortReal( b1 );
104 aTrsf.Transforms( a1, b1 );
105 X4 = Standard_ShortReal( a1 );
106 Y4 = Standard_ShortReal( b1 );
109 aTrsf.Transforms( a1, b1 );
110 X5 = Standard_ShortReal( a1 );
111 Y5 = Standard_ShortReal( b1 );
114 aTrsf.Transforms( a1, b1 );
115 X6 = Standard_ShortReal( a1 );
116 Y6 = Standard_ShortReal( b1 );
118 aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 );
119 aDrawer->MapSegmentFromTo( X3, Y3, X4, Y4 );
120 aDrawer->MapSegmentFromTo( X5, Y5, X6, Y6 );
125 void Prs2d_Symmetry::Save(Aspect_FStream& aFStream) const