a0fe75063efb6f5b8f9fea2a8747146aba6d9aba
[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     throw Standard_DimensionMismatch("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) throw Standard_OutOfRange("IGESDimen_LeaderArrow : SetFormNumber");
51   InitTypeAndForm(214,form);
52 }
53
54     Standard_Integer  IGESDimen_LeaderArrow::NbSegments () const 
55 {
56   return theSegmentTails->Length();
57 }
58
59     Standard_Real  IGESDimen_LeaderArrow::ArrowHeadHeight () const 
60 {
61   return theArrowHeadHeight;
62 }
63
64     Standard_Real  IGESDimen_LeaderArrow::ArrowHeadWidth () const 
65 {
66   return theArrowHeadWidth;
67 }
68
69     Standard_Real  IGESDimen_LeaderArrow::ZDepth () const 
70 {
71   return theZDepth;
72 }
73
74     gp_Pnt2d  IGESDimen_LeaderArrow::ArrowHead () const 
75 {
76   gp_Pnt2d AHPnt2d(theArrowHead);
77   return AHPnt2d;
78 }
79
80     gp_Pnt  IGESDimen_LeaderArrow::TransformedArrowHead () const 
81 {
82   gp_XYZ point(theArrowHead.X(), theArrowHead.Y(), ZDepth());
83   if (HasTransf()) Location().Transforms(point);
84   return gp_Pnt(point);
85 }
86
87     gp_Pnt2d  IGESDimen_LeaderArrow::SegmentTail
88   (const Standard_Integer Index) const 
89 {
90   gp_Pnt2d STPnt2d(theSegmentTails->Value(Index));
91   return STPnt2d;
92 }
93
94     gp_Pnt  IGESDimen_LeaderArrow::TransformedSegmentTail
95   (const Standard_Integer Index) const 
96 {
97   gp_XY point2d = theSegmentTails->Value(Index);
98   gp_XYZ point(point2d.X(), point2d.Y(), ZDepth());
99   if (HasTransf()) Location().Transforms(point);
100   return gp_Pnt(point);
101 }