9ff74a90ee9c8f66a2dbff716f779749717d4799
[occt.git] / src / IGESDimen / IGESDimen_LeaderArrow.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
19 #include <gp_GTrsf.hxx>
20 #include <gp_Pnt.hxx>
21 #include <gp_Pnt2d.hxx>
22 #include <gp_XY.hxx>
23 #include <IGESDimen_LeaderArrow.hxx>
24 #include <Standard_DimensionMismatch.hxx>
25 #include <Standard_OutOfRange.hxx>
26 #include <Standard_Type.hxx>
27
28 IMPLEMENT_STANDARD_RTTIEXT(IGESDimen_LeaderArrow,IGESData_IGESEntity)
29
30 IGESDimen_LeaderArrow::IGESDimen_LeaderArrow ()    {  }
31
32     void  IGESDimen_LeaderArrow::Init
33   (const Standard_Real height, const Standard_Real width,
34    const Standard_Real depth,  const gp_XY&        position,
35    const Handle(TColgp_HArray1OfXY)& segments)
36 {
37   if (segments->Lower() != 1)
38     Standard_DimensionMismatch::Raise("IGESDimen_LeaderArrow : Init");
39   theArrowHeadHeight = height;
40   theArrowHeadWidth  = width;
41   theZDepth          = depth ;
42   theArrowHead       = position;
43   theSegmentTails    = segments;
44   InitTypeAndForm(214,FormNumber());
45 // FormNumber precises the Type of the Arrow (1-12)
46 }
47
48     void  IGESDimen_LeaderArrow::SetFormNumber (const Standard_Integer form)
49 {
50   if (form < 1 || form > 12) Standard_OutOfRange::Raise
51     ("IGESDimen_LeaderArrow : SetFormNumber");
52   InitTypeAndForm(214,form);
53 }
54
55     Standard_Integer  IGESDimen_LeaderArrow::NbSegments () const 
56 {
57   return theSegmentTails->Length();
58 }
59
60     Standard_Real  IGESDimen_LeaderArrow::ArrowHeadHeight () const 
61 {
62   return theArrowHeadHeight;
63 }
64
65     Standard_Real  IGESDimen_LeaderArrow::ArrowHeadWidth () const 
66 {
67   return theArrowHeadWidth;
68 }
69
70     Standard_Real  IGESDimen_LeaderArrow::ZDepth () const 
71 {
72   return theZDepth;
73 }
74
75     gp_Pnt2d  IGESDimen_LeaderArrow::ArrowHead () const 
76 {
77   gp_Pnt2d AHPnt2d(theArrowHead);
78   return AHPnt2d;
79 }
80
81     gp_Pnt  IGESDimen_LeaderArrow::TransformedArrowHead () const 
82 {
83   gp_XYZ point(theArrowHead.X(), theArrowHead.Y(), ZDepth());
84   if (HasTransf()) Location().Transforms(point);
85   return gp_Pnt(point);
86 }
87
88     gp_Pnt2d  IGESDimen_LeaderArrow::SegmentTail
89   (const Standard_Integer Index) const 
90 {
91   gp_Pnt2d STPnt2d(theSegmentTails->Value(Index));
92   return STPnt2d;
93 }
94
95     gp_Pnt  IGESDimen_LeaderArrow::TransformedSegmentTail
96   (const Standard_Integer Index) const 
97 {
98   gp_XY point2d = theSegmentTails->Value(Index);
99   gp_XYZ point(point2d.X(), point2d.Y(), ZDepth());
100   if (HasTransf()) Location().Transforms(point);
101   return gp_Pnt(point);
102 }