b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
7fd59977 |
19 | #include <gp_Pnt2d.hxx> |
42cf5bc1 |
20 | #include <gp_XY.hxx> |
21 | #include <IGESData_DirChecker.hxx> |
7fd59977 |
22 | #include <IGESData_Dump.hxx> |
42cf5bc1 |
23 | #include <IGESData_IGESDumper.hxx> |
24 | #include <IGESData_IGESReaderData.hxx> |
25 | #include <IGESData_IGESWriter.hxx> |
26 | #include <IGESData_ParamCursor.hxx> |
27 | #include <IGESData_ParamReader.hxx> |
28 | #include <IGESDimen_LeaderArrow.hxx> |
29 | #include <IGESDimen_ToolLeaderArrow.hxx> |
30 | #include <Interface_Check.hxx> |
31 | #include <Interface_CopyTool.hxx> |
32 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
33 | #include <Interface_Macros.hxx> |
42cf5bc1 |
34 | #include <Interface_ShareTool.hxx> |
35 | #include <Message_Messenger.hxx> |
36 | #include <Standard_DomainError.hxx> |
37 | #include <TColgp_HArray1OfXY.hxx> |
7fd59977 |
38 | |
39 | IGESDimen_ToolLeaderArrow::IGESDimen_ToolLeaderArrow () { } |
40 | |
41 | |
42 | void IGESDimen_ToolLeaderArrow::ReadOwnParams |
43 | (const Handle(IGESDimen_LeaderArrow)& ent, |
44 | const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const |
45 | { |
46 | //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down |
47 | |
48 | Standard_Real arrowHeadHeight; |
49 | Standard_Real arrowHeadWidth; |
50 | Standard_Real zDepth; |
51 | gp_XY arrowHead; |
52 | Handle(TColgp_HArray1OfXY) segmentTails; |
53 | Standard_Integer nbval; |
54 | |
55 | Standard_Boolean st = PR.ReadInteger( PR.Current(), "Count of Segments", nbval); |
56 | if (st && nbval > 0) |
57 | segmentTails = new TColgp_HArray1OfXY(1,nbval); |
58 | else PR.AddFail("Count of Segments: Not Positive"); |
59 | |
60 | //szv#4:S4163:12Mar99 `st=` not needed |
61 | PR.ReadReal(PR.Current(), "Arrow Head Height", arrowHeadHeight); |
62 | PR.ReadReal(PR.Current(), "Arrow Head Width", arrowHeadWidth); |
63 | PR.ReadReal(PR.Current(), "Z Depth", zDepth); |
64 | PR.ReadXY(PR.CurrentList(1, 2), "Arrow Head Position", arrowHead); |
65 | |
66 | if (! segmentTails.IsNull()) |
67 | { |
68 | for (Standard_Integer i = 1; i <= nbval; i++) |
69 | { |
70 | gp_XY tempXY; |
71 | //st = PR.ReadXY(PR.CurrentList(1, 2), "Segment Co-ords.", tempXY); //szv#4:S4163:12Mar99 moved in if |
72 | if (PR.ReadXY(PR.CurrentList(1, 2), "Segment Co-ords.", tempXY)) |
73 | segmentTails->SetValue(i, tempXY); |
74 | } |
75 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
76 | ent->Init (arrowHeadHeight, arrowHeadWidth, zDepth, arrowHead, segmentTails); |
77 | } //segmentTails.IsNull() crash in ent->Init( ... |
78 | |
79 | } |
80 | |
81 | void IGESDimen_ToolLeaderArrow::WriteOwnParams |
82 | (const Handle(IGESDimen_LeaderArrow)& ent, IGESData_IGESWriter& IW) const |
83 | { |
84 | Standard_Integer upper = ent->NbSegments(); |
85 | IW.Send(upper); |
86 | IW.Send(ent->ArrowHeadHeight()); |
87 | IW.Send(ent->ArrowHeadWidth()); |
88 | IW.Send(ent->ZDepth()); |
89 | IW.Send(ent->ArrowHead().X()); |
90 | IW.Send(ent->ArrowHead().Y()); |
91 | for (Standard_Integer i = 1; i <= upper; i++) |
92 | { |
93 | IW.Send((ent->SegmentTail(i)).X()); |
94 | IW.Send((ent->SegmentTail(i)).Y()); |
95 | } |
96 | } |
97 | |
98 | void IGESDimen_ToolLeaderArrow::OwnShared |
99 | (const Handle(IGESDimen_LeaderArrow)& /* ent */, Interface_EntityIterator& /* iter */) const |
100 | { |
101 | } |
102 | |
103 | void IGESDimen_ToolLeaderArrow::OwnCopy |
104 | (const Handle(IGESDimen_LeaderArrow)& another, |
105 | const Handle(IGESDimen_LeaderArrow)& ent, Interface_CopyTool& /* TC */) const |
106 | { |
107 | Standard_Integer nbval = another->NbSegments(); |
108 | Standard_Real arrowHeadHeight = another->ArrowHeadHeight(); |
109 | Standard_Real arrowHeadWidth = another->ArrowHeadWidth(); |
110 | Standard_Real zDepth = another->ZDepth(); |
111 | gp_XY arrowHead = another->ArrowHead().XY(); |
112 | |
113 | Handle(TColgp_HArray1OfXY) segmentTails = new TColgp_HArray1OfXY(1, nbval); |
114 | |
115 | for (Standard_Integer i = 1; i <= nbval; i++) |
116 | { |
117 | segmentTails->SetValue(i, (another->SegmentTail(i)).XY()); |
118 | } |
119 | |
120 | ent->Init(arrowHeadHeight, arrowHeadWidth, zDepth, arrowHead, segmentTails); |
121 | ent->SetFormNumber (another->FormNumber()); |
122 | } |
123 | |
124 | IGESData_DirChecker IGESDimen_ToolLeaderArrow::DirChecker |
125 | (const Handle(IGESDimen_LeaderArrow)& /* ent */ ) const |
126 | { |
127 | IGESData_DirChecker DC (214, 1, 12); |
128 | DC.Structure(IGESData_DefVoid); |
129 | DC.LineFont(IGESData_DefAny); |
130 | DC.LineWeight(IGESData_DefValue); |
131 | DC.Color(IGESData_DefAny); |
132 | DC.UseFlagRequired(1); |
133 | DC.HierarchyStatusIgnored(); |
134 | return DC; |
135 | } |
136 | |
137 | void IGESDimen_ToolLeaderArrow::OwnCheck |
138 | (const Handle(IGESDimen_LeaderArrow)& /* ent */, |
139 | const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const |
140 | { |
141 | } |
142 | |
143 | void IGESDimen_ToolLeaderArrow::OwnDump |
144 | (const Handle(IGESDimen_LeaderArrow)& ent, const IGESData_IGESDumper& /* dumper */, |
145 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
146 | { |
147 | S << "IGESDimen_LeaderArrow" << endl; |
148 | S << "Number of Segments : " << ent->NbSegments() << endl; |
149 | S << "Arrowhead Height : " << ent->ArrowHeadHeight() << endl; |
150 | S << "Arrowhead Width : " << ent->ArrowHeadWidth() << endl; |
151 | S << "Z depth : " << ent->ZDepth() << endl; |
152 | S << "Arrowhead co-ords : "; |
153 | IGESData_DumpXYLZ(S,level,ent->ArrowHead(),ent->Location(),ent->ZDepth()); |
154 | S << endl << "Segment Tails : "; |
155 | IGESData_DumpListXYLZ(S ,level,1, ent->NbSegments(),ent->SegmentTail, |
156 | ent->Location(), ent->ZDepth()); |
157 | S << endl; |
158 | } |