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