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 | |
42cf5bc1 |
19 | #include <IGESData_DirChecker.hxx> |
20 | #include <IGESData_IGESDumper.hxx> |
21 | #include <IGESData_IGESReaderData.hxx> |
22 | #include <IGESData_IGESWriter.hxx> |
7fd59977 |
23 | #include <IGESData_ParamCursor.hxx> |
42cf5bc1 |
24 | #include <IGESData_ParamReader.hxx> |
7fd59977 |
25 | #include <IGESGeom_Direction.hxx> |
42cf5bc1 |
26 | #include <IGESGeom_Point.hxx> |
27 | #include <IGESSolid_SphericalSurface.hxx> |
28 | #include <IGESSolid_ToolSphericalSurface.hxx> |
29 | #include <Interface_Check.hxx> |
30 | #include <Interface_CopyTool.hxx> |
31 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
32 | #include <Interface_Macros.hxx> |
42cf5bc1 |
33 | #include <Interface_ShareTool.hxx> |
34 | #include <Message_Messenger.hxx> |
35 | #include <Standard_DomainError.hxx> |
7fd59977 |
36 | |
37 | IGESSolid_ToolSphericalSurface::IGESSolid_ToolSphericalSurface () { } |
38 | |
39 | |
40 | void IGESSolid_ToolSphericalSurface::ReadOwnParams |
41 | (const Handle(IGESSolid_SphericalSurface)& ent, |
42 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
43 | { |
44 | Handle(IGESGeom_Point) tempCenter; |
45 | Standard_Real tempRadius; |
46 | Handle(IGESGeom_Direction) tempAxis; // default Unparameterised |
47 | Handle(IGESGeom_Direction) tempRefdir; // default Unparameterised |
48 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
49 | |
50 | PR.ReadEntity(IR, PR.Current(), "Center point", |
51 | STANDARD_TYPE(IGESGeom_Point), tempCenter); //szv#4:S4163:12Mar99 `st=` not needed |
52 | |
53 | PR.ReadReal(PR.Current(), "Radius", tempRadius); //szv#4:S4163:12Mar99 `st=` not needed |
54 | |
55 | if (ent->FormNumber() == 1) // Parametrised surface |
56 | { |
57 | PR.ReadEntity(IR, PR.Current(), "Axis direction", |
58 | STANDARD_TYPE(IGESGeom_Direction), tempAxis); //szv#4:S4163:12Mar99 `st=` not needed |
59 | |
60 | PR.ReadEntity(IR, PR.Current(), "Reference direction", |
61 | STANDARD_TYPE(IGESGeom_Direction), tempRefdir); //szv#4:S4163:12Mar99 `st=` not needed |
62 | } |
63 | |
64 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
65 | ent->Init (tempCenter, tempRadius, tempAxis, tempRefdir); |
66 | |
67 | } |
68 | |
69 | void IGESSolid_ToolSphericalSurface::WriteOwnParams |
70 | (const Handle(IGESSolid_SphericalSurface)& ent, IGESData_IGESWriter& IW) const |
71 | { |
72 | IW.Send(ent->Center()); |
73 | IW.Send(ent->Radius()); |
74 | if (ent->IsParametrised()) |
75 | { |
76 | IW.Send(ent->Axis()); |
77 | IW.Send(ent->ReferenceDir()); |
78 | } |
79 | } |
80 | |
81 | void IGESSolid_ToolSphericalSurface::OwnShared |
82 | (const Handle(IGESSolid_SphericalSurface)& ent, Interface_EntityIterator& iter) const |
83 | { |
84 | iter.GetOneItem(ent->Center()); |
85 | iter.GetOneItem(ent->Axis()); |
86 | iter.GetOneItem(ent->ReferenceDir()); |
87 | } |
88 | |
89 | void IGESSolid_ToolSphericalSurface::OwnCopy |
90 | (const Handle(IGESSolid_SphericalSurface)& another, |
91 | const Handle(IGESSolid_SphericalSurface)& ent, Interface_CopyTool& TC) const |
92 | { |
93 | DeclareAndCast(IGESGeom_Point, tempCenter, |
94 | TC.Transferred(another->Center())); |
95 | Standard_Real tempRadius = another->Radius(); |
96 | if (another->IsParametrised()) |
97 | { |
98 | DeclareAndCast(IGESGeom_Direction, tempAxis, |
99 | TC.Transferred(another->Axis())); |
100 | DeclareAndCast(IGESGeom_Direction, tempRefdir, |
101 | TC.Transferred(another->ReferenceDir())); |
102 | ent->Init (tempCenter, tempRadius, tempAxis, tempRefdir); |
103 | } |
104 | else |
105 | { |
106 | Handle(IGESGeom_Direction) tempAxis; |
107 | Handle(IGESGeom_Direction) tempRefdir; |
108 | ent->Init (tempCenter, tempRadius, tempAxis, tempRefdir); |
109 | } |
110 | |
111 | } |
112 | |
113 | IGESData_DirChecker IGESSolid_ToolSphericalSurface::DirChecker |
114 | (const Handle(IGESSolid_SphericalSurface)& /*ent*/) const |
115 | { |
116 | IGESData_DirChecker DC(196, 0, 1); |
117 | |
118 | DC.Structure (IGESData_DefVoid); |
119 | DC.LineFont (IGESData_DefAny); |
120 | DC.Color (IGESData_DefAny); |
121 | |
122 | DC.BlankStatusIgnored (); |
123 | DC.SubordinateStatusRequired (1); |
124 | DC.HierarchyStatusIgnored (); |
125 | return DC; |
126 | } |
127 | |
128 | void IGESSolid_ToolSphericalSurface::OwnCheck |
129 | (const Handle(IGESSolid_SphericalSurface)& ent, |
130 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
131 | { |
132 | if (ent->Radius() <= 0.0) |
133 | ach->AddFail("Radius : Not Positive"); |
134 | Standard_Integer fn = 0; |
135 | if (ent->IsParametrised()) fn = 1; |
136 | if (fn != ent->FormNumber()) ach->AddFail |
137 | ("Parametrised Status Mismatches with Form Number"); |
138 | if (ent->Axis().IsNull()) if (ent->IsParametrised()) ach->AddFail |
139 | ("Parametrised Spherical Surface : no Axis is defined"); |
140 | } |
141 | |
142 | void IGESSolid_ToolSphericalSurface::OwnDump |
143 | (const Handle(IGESSolid_SphericalSurface)& ent, const IGESData_IGESDumper& dumper, |
144 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
145 | { |
04232180 |
146 | S << "IGESSolid_SphericalSurface" << Message_EndLine; |
7fd59977 |
147 | Standard_Integer sublevel = (level <= 4) ? 0 : 1; |
148 | |
149 | S << "Center : "; |
150 | dumper.Dump(ent->Center(),S, sublevel); |
04232180 |
151 | S << Message_EndLine; |
152 | S << "Radius : " << ent->Radius() << Message_EndLine; |
7fd59977 |
153 | if (ent->IsParametrised()) |
154 | { |
04232180 |
155 | S << "Surface is Parametrised" << Message_EndLine; |
7fd59977 |
156 | S << "Axis direction : "; |
157 | dumper.Dump(ent->Axis(),S, sublevel); |
04232180 |
158 | S << Message_EndLine; |
7fd59977 |
159 | S << "Reference direction : "; |
160 | dumper.Dump(ent->ReferenceDir(),S, sublevel); |
04232180 |
161 | S << Message_EndLine; |
7fd59977 |
162 | } |
04232180 |
163 | else S << "Surface is UnParametrised" << Message_EndLine; |
7fd59977 |
164 | } |