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> |
7fd59977 |
21 | #include <IGESData_Dump.hxx> |
42cf5bc1 |
22 | #include <IGESData_IGESDumper.hxx> |
23 | #include <IGESData_IGESEntity.hxx> |
24 | #include <IGESData_IGESReaderData.hxx> |
25 | #include <IGESData_IGESWriter.hxx> |
26 | #include <IGESData_ParamCursor.hxx> |
27 | #include <IGESData_ParamReader.hxx> |
28 | #include <IGESSolid_SolidOfLinearExtrusion.hxx> |
29 | #include <IGESSolid_ToolSolidOfLinearExtrusion.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> |
7fd59977 |
37 | |
38 | IGESSolid_ToolSolidOfLinearExtrusion::IGESSolid_ToolSolidOfLinearExtrusion () |
39 | { } |
40 | |
41 | |
42 | void IGESSolid_ToolSolidOfLinearExtrusion::ReadOwnParams |
43 | (const Handle(IGESSolid_SolidOfLinearExtrusion)& ent, |
44 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
45 | { |
46 | Handle(IGESData_IGESEntity) tempEntity; |
47 | gp_XYZ tempDirection; |
48 | Standard_Real tempLength; |
49 | Standard_Real tempreal; |
50 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
51 | |
52 | PR.ReadEntity(IR, PR.Current(), "Curve Entity", tempEntity); //szv#4:S4163:12Mar99 `st=` not needed |
53 | |
54 | PR.ReadReal(PR.Current(), "Length of extrusion", tempLength); //szv#4:S4163:12Mar99 `st=` not needed |
55 | |
56 | if (PR.DefinedElseSkip()) |
57 | { |
58 | //st = PR.ReadReal(PR.Current(), "Extrusion direction (I)", tempreal); //szv#4:S4163:12Mar99 moved in if |
59 | if (PR.ReadReal(PR.Current(), "Extrusion direction (I)", tempreal)) |
60 | tempDirection.SetX(tempreal); |
61 | } |
62 | else tempDirection.SetX(0.0); |
63 | |
64 | if (PR.DefinedElseSkip()) |
65 | { |
66 | //st = PR.ReadReal(PR.Current(), "Extrusion direction (J)", tempreal); //szv#4:S4163:12Mar99 moved in if |
67 | if (PR.ReadReal(PR.Current(), "Extrusion direction (J)", tempreal)) |
68 | tempDirection.SetY(tempreal); |
69 | } |
70 | else tempDirection.SetY(0.0); |
71 | |
72 | if (PR.DefinedElseSkip()) |
73 | { |
74 | //st = PR.ReadReal(PR.Current(), "Extrusion direction (K)", tempreal); //szv#4:S4163:12Mar99 moved in if |
75 | if (PR.ReadReal(PR.Current(), "Extrusion direction (K)", tempreal)) |
76 | tempDirection.SetZ(tempreal); |
77 | } |
78 | else tempDirection.SetZ(1.0); |
79 | |
80 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
81 | ent->Init(tempEntity, tempLength, tempDirection); |
82 | Standard_Real eps = 1.E-05; |
83 | if (!tempDirection.IsEqual(ent->ExtrusionDirection().XYZ(),eps)) |
84 | PR.AddWarning("Extrusion Direction poorly unitary, normalized"); |
85 | } |
86 | |
87 | void IGESSolid_ToolSolidOfLinearExtrusion::WriteOwnParams |
88 | (const Handle(IGESSolid_SolidOfLinearExtrusion)& ent, IGESData_IGESWriter& IW) const |
89 | { |
90 | IW.Send(ent->Curve()); |
91 | IW.Send(ent->ExtrusionLength()); |
92 | IW.Send(ent->ExtrusionDirection().X()); |
93 | IW.Send(ent->ExtrusionDirection().Y()); |
94 | IW.Send(ent->ExtrusionDirection().Z()); |
95 | } |
96 | |
97 | void IGESSolid_ToolSolidOfLinearExtrusion::OwnShared |
98 | (const Handle(IGESSolid_SolidOfLinearExtrusion)& ent, Interface_EntityIterator& iter) const |
99 | { |
100 | iter.GetOneItem(ent->Curve()); |
101 | } |
102 | |
103 | void IGESSolid_ToolSolidOfLinearExtrusion::OwnCopy |
104 | (const Handle(IGESSolid_SolidOfLinearExtrusion)& another, |
105 | const Handle(IGESSolid_SolidOfLinearExtrusion)& ent, Interface_CopyTool& TC) const |
106 | { |
107 | DeclareAndCast(IGESData_IGESEntity, tempEntity, |
108 | TC.Transferred(another->Curve())); |
109 | Standard_Real tempLength = another->ExtrusionLength(); |
110 | gp_XYZ tempDirection = another->ExtrusionDirection().XYZ(); |
111 | ent->Init(tempEntity, tempLength, tempDirection); |
112 | } |
113 | |
114 | IGESData_DirChecker IGESSolid_ToolSolidOfLinearExtrusion::DirChecker |
115 | (const Handle(IGESSolid_SolidOfLinearExtrusion)& /* ent */ ) const |
116 | { |
117 | IGESData_DirChecker DC(164, 0); |
118 | |
119 | DC.Structure (IGESData_DefVoid); |
120 | DC.LineFont (IGESData_DefAny); |
121 | DC.Color (IGESData_DefAny); |
122 | |
123 | DC.UseFlagRequired (0); |
124 | DC.HierarchyStatusIgnored (); |
125 | return DC; |
126 | } |
127 | |
128 | void IGESSolid_ToolSolidOfLinearExtrusion::OwnCheck |
129 | (const Handle(IGESSolid_SolidOfLinearExtrusion)& ent, |
130 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
131 | { |
132 | if (ent->ExtrusionLength() <= 0.0) |
133 | ach->AddFail("Length of extrusion : Not Positive"); |
134 | } |
135 | |
136 | void IGESSolid_ToolSolidOfLinearExtrusion::OwnDump |
137 | (const Handle(IGESSolid_SolidOfLinearExtrusion)& ent, const IGESData_IGESDumper& dumper, |
138 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
139 | { |
140 | S << "IGESSolid_SolidOfLinearExtrusion" << endl; |
141 | |
142 | S << "Curve entity : "; |
143 | dumper.Dump(ent->Curve(),S, (level <= 4) ? 0 : 1); |
144 | S << endl; |
145 | S << "Extrusion length : " << ent->ExtrusionLength() << endl; |
146 | S << "Extrusion direction : "; |
147 | IGESData_DumpXYZL(S,level, ent->ExtrusionDirection(), ent->VectorLocation()); |
148 | S << endl; |
149 | } |