973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
7fd59977 |
13 | |
7fd59977 |
14 | |
42cf5bc1 |
15 | #include <Interface_Check.hxx> |
7fd59977 |
16 | #include <Interface_EntityIterator.hxx> |
42cf5bc1 |
17 | #include <RWStepVisual_RWViewVolume.hxx> |
18 | #include <StepData_StepReaderData.hxx> |
19 | #include <StepData_StepWriter.hxx> |
20 | #include <StepGeom_CartesianPoint.hxx> |
21 | #include <StepVisual_CentralOrParallel.hxx> |
22 | #include <StepVisual_PlanarBox.hxx> |
7fd59977 |
23 | #include <StepVisual_ViewVolume.hxx> |
7fd59977 |
24 | #include <TCollection_AsciiString.hxx> |
25 | |
b311480e |
26 | // --- Enum : CentralOrParallel --- |
7fd59977 |
27 | static TCollection_AsciiString copCentral(".CENTRAL."); |
28 | static TCollection_AsciiString copParallel(".PARALLEL."); |
29 | |
30 | RWStepVisual_RWViewVolume::RWStepVisual_RWViewVolume () {} |
31 | |
32 | void RWStepVisual_RWViewVolume::ReadStep |
33 | (const Handle(StepData_StepReaderData)& data, |
34 | const Standard_Integer num, |
35 | Handle(Interface_Check)& ach, |
36 | const Handle(StepVisual_ViewVolume)& ent) const |
37 | { |
38 | |
39 | |
40 | // --- Number of Parameter Control --- |
41 | |
42 | if (!data->CheckNbParams(num,9,ach,"view_volume")) return; |
43 | |
44 | // --- own field : projectionType --- |
45 | |
46 | StepVisual_CentralOrParallel aProjectionType = StepVisual_copCentral; |
47 | if (data->ParamType(num,1) == Interface_ParamEnum) { |
48 | Standard_CString text = data->ParamCValue(num,1); |
49 | if (copCentral.IsEqual(text)) aProjectionType = StepVisual_copCentral; |
50 | else if (copParallel.IsEqual(text)) aProjectionType = StepVisual_copParallel; |
51 | else ach->AddFail("Enumeration central_or_parallel has not an allowed value"); |
52 | } |
53 | else ach->AddFail("Parameter #1 (projection_type) is not an enumeration"); |
54 | |
55 | // --- own field : projectionPoint --- |
56 | |
57 | Handle(StepGeom_CartesianPoint) aProjectionPoint; |
58 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
59 | data->ReadEntity(num, 2,"projection_point", ach, STANDARD_TYPE(StepGeom_CartesianPoint), aProjectionPoint); |
60 | |
61 | // --- own field : viewPlaneDistance --- |
62 | |
63 | Standard_Real aViewPlaneDistance; |
64 | //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed |
65 | data->ReadReal (num,3,"view_plane_distance",ach,aViewPlaneDistance); |
66 | |
67 | // --- own field : frontPlaneDistance --- |
68 | |
69 | Standard_Real aFrontPlaneDistance; |
70 | //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed |
71 | data->ReadReal (num,4,"front_plane_distance",ach,aFrontPlaneDistance); |
72 | |
73 | // --- own field : frontPlaneClipping --- |
74 | |
75 | Standard_Boolean aFrontPlaneClipping; |
76 | //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed |
77 | data->ReadBoolean (num,5,"front_plane_clipping",ach,aFrontPlaneClipping); |
78 | |
79 | // --- own field : backPlaneDistance --- |
80 | |
81 | Standard_Real aBackPlaneDistance; |
82 | //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed |
83 | data->ReadReal (num,6,"back_plane_distance",ach,aBackPlaneDistance); |
84 | |
85 | // --- own field : backPlaneClipping --- |
86 | |
87 | Standard_Boolean aBackPlaneClipping; |
88 | //szv#4:S4163:12Mar99 `Standard_Boolean stat7 =` not needed |
89 | data->ReadBoolean (num,7,"back_plane_clipping",ach,aBackPlaneClipping); |
90 | |
91 | // --- own field : viewVolumeSidesClipping --- |
92 | |
93 | Standard_Boolean aViewVolumeSidesClipping; |
94 | //szv#4:S4163:12Mar99 `Standard_Boolean stat8 =` not needed |
95 | data->ReadBoolean (num,8,"view_volume_sides_clipping",ach,aViewVolumeSidesClipping); |
96 | |
97 | // --- own field : viewWindow --- |
98 | |
99 | Handle(StepVisual_PlanarBox) aViewWindow; |
100 | //szv#4:S4163:12Mar99 `Standard_Boolean stat9 =` not needed |
101 | data->ReadEntity(num, 9,"view_window", ach, STANDARD_TYPE(StepVisual_PlanarBox), aViewWindow); |
102 | |
103 | //--- Initialisation of the read entity --- |
104 | |
105 | |
106 | ent->Init(aProjectionType, aProjectionPoint, aViewPlaneDistance, aFrontPlaneDistance, aFrontPlaneClipping, aBackPlaneDistance, aBackPlaneClipping, aViewVolumeSidesClipping, aViewWindow); |
107 | } |
108 | |
109 | |
110 | void RWStepVisual_RWViewVolume::WriteStep |
111 | (StepData_StepWriter& SW, |
112 | const Handle(StepVisual_ViewVolume)& ent) const |
113 | { |
114 | |
115 | // --- own field : projectionType --- |
116 | |
117 | switch(ent->ProjectionType()) { |
118 | case StepVisual_copCentral : SW.SendEnum (copCentral); break; |
119 | case StepVisual_copParallel : SW.SendEnum (copParallel); break; |
120 | } |
121 | |
122 | // --- own field : projectionPoint --- |
123 | |
124 | SW.Send(ent->ProjectionPoint()); |
125 | |
126 | // --- own field : viewPlaneDistance --- |
127 | |
128 | SW.Send(ent->ViewPlaneDistance()); |
129 | |
130 | // --- own field : frontPlaneDistance --- |
131 | |
132 | SW.Send(ent->FrontPlaneDistance()); |
133 | |
134 | // --- own field : frontPlaneClipping --- |
135 | |
136 | SW.SendBoolean(ent->FrontPlaneClipping()); |
137 | |
138 | // --- own field : backPlaneDistance --- |
139 | |
140 | SW.Send(ent->BackPlaneDistance()); |
141 | |
142 | // --- own field : backPlaneClipping --- |
143 | |
144 | SW.SendBoolean(ent->BackPlaneClipping()); |
145 | |
146 | // --- own field : viewVolumeSidesClipping --- |
147 | |
148 | SW.SendBoolean(ent->ViewVolumeSidesClipping()); |
149 | |
150 | // --- own field : viewWindow --- |
151 | |
152 | SW.Send(ent->ViewWindow()); |
153 | } |
154 | |
155 | |
156 | void RWStepVisual_RWViewVolume::Share(const Handle(StepVisual_ViewVolume)& ent, Interface_EntityIterator& iter) const |
157 | { |
158 | |
159 | iter.GetOneItem(ent->ProjectionPoint()); |
160 | |
161 | |
162 | iter.GetOneItem(ent->ViewWindow()); |
163 | } |
164 | |