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_XYZ.hxx> |
42cf5bc1 |
20 | #include <IGESData_DirChecker.hxx> |
21 | #include <IGESData_Dump.hxx> |
22 | #include <IGESData_IGESDumper.hxx> |
23 | #include <IGESData_IGESReaderData.hxx> |
24 | #include <IGESData_IGESWriter.hxx> |
25 | #include <IGESData_ParamCursor.hxx> |
26 | #include <IGESData_ParamReader.hxx> |
27 | #include <IGESDimen_FlagNote.hxx> |
7fd59977 |
28 | #include <IGESDimen_GeneralNote.hxx> |
29 | #include <IGESDimen_HArray1OfLeaderArrow.hxx> |
42cf5bc1 |
30 | #include <IGESDimen_LeaderArrow.hxx> |
31 | #include <IGESDimen_ToolFlagNote.hxx> |
32 | #include <Interface_Check.hxx> |
33 | #include <Interface_CopyTool.hxx> |
34 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
35 | #include <Interface_Macros.hxx> |
42cf5bc1 |
36 | #include <Interface_ShareTool.hxx> |
42cf5bc1 |
37 | #include <Standard_DomainError.hxx> |
7fd59977 |
38 | |
39 | IGESDimen_ToolFlagNote::IGESDimen_ToolFlagNote () { } |
40 | |
41 | |
42 | void IGESDimen_ToolFlagNote::ReadOwnParams |
43 | (const Handle(IGESDimen_FlagNote)& ent, |
44 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
45 | { |
46 | //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down |
47 | |
48 | gp_XYZ lowerLeft; |
49 | Standard_Real angle; |
50 | Handle(IGESDimen_GeneralNote) note; |
51 | Standard_Integer nbval; |
52 | Handle(IGESDimen_HArray1OfLeaderArrow) leaders; |
53 | |
54 | PR.ReadXYZ (PR.CurrentList(1, 3), "Lower Left Corner Co-ords", lowerLeft); //szv#4:S4163:12Mar99 `st=` not needed |
55 | |
56 | PR.ReadReal(PR.Current(), "Rotation Angle", angle); //szv#4:S4163:12Mar99 `st=` not needed |
57 | |
58 | PR.ReadEntity(IR, PR.Current(), "General Note Entity", |
59 | STANDARD_TYPE(IGESDimen_GeneralNote), note); //szv#4:S4163:12Mar99 `st=` not needed |
60 | |
61 | Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Leaders", nbval); |
62 | if (st && nbval > 0) |
63 | { |
64 | leaders = new IGESDimen_HArray1OfLeaderArrow(1, nbval); |
65 | |
66 | for (Standard_Integer i = 1; i <= nbval; i++) |
67 | { |
68 | Handle(IGESDimen_LeaderArrow) anentity; |
69 | //st = PR.ReadEntity(IR, PR.Current(), "Leaders", |
70 | //STANDARD_TYPE(IGESDimen_LeaderArrow), anentity); //szv#4:S4163:12Mar99 moved in if |
71 | if (PR.ReadEntity(IR, PR.Current(), "Leaders", STANDARD_TYPE(IGESDimen_LeaderArrow), anentity)) |
72 | leaders->SetValue(i, anentity); |
73 | } |
74 | } |
75 | else if (nbval < 0) |
76 | PR.AddFail("Number of Leaders: Less than zero"); |
77 | |
78 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
79 | ent->Init(lowerLeft, angle, note, leaders); |
80 | } |
81 | |
82 | void IGESDimen_ToolFlagNote::WriteOwnParams |
83 | (const Handle(IGESDimen_FlagNote)& ent, IGESData_IGESWriter& IW) const |
84 | { |
85 | IW.Send(ent->LowerLeftCorner().X()); |
86 | IW.Send(ent->LowerLeftCorner().Y()); |
87 | IW.Send(ent->LowerLeftCorner().Z()); |
88 | IW.Send(ent->Angle()); |
89 | IW.Send(ent->Note()); |
90 | Standard_Integer upper = ent->NbLeaders(); |
91 | IW.Send(upper); |
92 | for (Standard_Integer i = 1; i <= upper; i ++) |
93 | IW.Send(ent->Leader(i)); |
94 | } |
95 | |
96 | void IGESDimen_ToolFlagNote::OwnShared |
97 | (const Handle(IGESDimen_FlagNote)& ent, Interface_EntityIterator& iter) const |
98 | { |
99 | iter.GetOneItem(ent->Note()); |
100 | Standard_Integer upper = ent->NbLeaders(); |
101 | for (Standard_Integer i = 1; i <= upper; i ++) |
102 | iter.GetOneItem(ent->Leader(i)); |
103 | } |
104 | |
105 | void IGESDimen_ToolFlagNote::OwnCopy |
106 | (const Handle(IGESDimen_FlagNote)& another, |
107 | const Handle(IGESDimen_FlagNote)& ent, Interface_CopyTool& TC) const |
108 | { |
109 | gp_XYZ lowerLeft = (another->LowerLeftCorner()).XYZ(); |
110 | Standard_Real angle = another->Angle(); |
111 | DeclareAndCast(IGESDimen_GeneralNote, note, |
112 | TC.Transferred(another->Note())); |
113 | Standard_Integer nbval = another->NbLeaders(); |
114 | |
115 | Handle(IGESDimen_HArray1OfLeaderArrow) leaders; |
116 | |
117 | if ( nbval > 0 ) |
118 | { |
119 | leaders = new IGESDimen_HArray1OfLeaderArrow(1, nbval); |
120 | for (Standard_Integer i = 1; i <= nbval; i++) |
121 | { |
122 | DeclareAndCast(IGESDimen_LeaderArrow, new_ent, |
123 | TC.Transferred(another->Leader(i))); |
124 | leaders->SetValue(i, new_ent); |
125 | } |
126 | } |
127 | ent->Init(lowerLeft, angle, note, leaders); |
128 | } |
129 | |
130 | IGESData_DirChecker IGESDimen_ToolFlagNote::DirChecker |
131 | (const Handle(IGESDimen_FlagNote)& /* ent */ ) const |
132 | { |
133 | IGESData_DirChecker DC (208, 0); |
134 | DC.Structure(IGESData_DefVoid); |
135 | DC.LineFont(IGESData_DefAny); |
136 | DC.LineWeight(IGESData_DefValue); |
137 | DC.Color(IGESData_DefAny); |
138 | DC.UseFlagRequired(1); |
139 | return DC; |
140 | } |
141 | |
142 | void IGESDimen_ToolFlagNote::OwnCheck |
143 | (const Handle(IGESDimen_FlagNote)& /* ent */, |
144 | const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const |
145 | { |
146 | } |
147 | |
148 | void IGESDimen_ToolFlagNote::OwnDump |
149 | (const Handle(IGESDimen_FlagNote)& ent, const IGESData_IGESDumper& dumper, |
0ebe5b0a |
150 | Standard_OStream& S, const Standard_Integer level) const |
7fd59977 |
151 | { |
152 | Standard_Integer sublevel = (level > 4) ? 1 : 0; |
153 | |
0ebe5b0a |
154 | S << "IGESDimen_FlagNote\n" |
155 | << "LowerLeftCorner : "; |
7fd59977 |
156 | IGESData_DumpXYZL(S,level, ent->LowerLeftCorner(), ent->Location()); |
0ebe5b0a |
157 | S << "\nRotation Angle: " << ent->Angle() << "\n" |
158 | << "General Note Entity : "; |
7fd59977 |
159 | dumper.Dump(ent->Note(),S, sublevel); |
0ebe5b0a |
160 | S << "\n" |
161 | << "Number of Leaders : " << ent->NbLeaders() << " Leaders : "; |
7fd59977 |
162 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbLeaders(),ent->Leader); |
0ebe5b0a |
163 | S << std::endl; |
7fd59977 |
164 | } |