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