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 <RWStepGeom_RWSurfacePatch.hxx> |
18 | #include <StepData_StepReaderData.hxx> |
19 | #include <StepData_StepWriter.hxx> |
20 | #include <StepGeom_BoundedSurface.hxx> |
7fd59977 |
21 | #include <StepGeom_SurfacePatch.hxx> |
42cf5bc1 |
22 | #include <StepGeom_TransitionCode.hxx> |
7fd59977 |
23 | #include <TCollection_AsciiString.hxx> |
24 | |
7fd59977 |
25 | // --- Enum : TransitionCode --- |
26 | static TCollection_AsciiString tcDiscontinuous(".DISCONTINUOUS."); |
27 | static TCollection_AsciiString tcContSameGradientSameCurvature(".CONT_SAME_GRADIENT_SAME_CURVATURE."); |
28 | static TCollection_AsciiString tcContSameGradient(".CONT_SAME_GRADIENT."); |
29 | static TCollection_AsciiString tcContinuous(".CONTINUOUS."); |
30 | |
31 | RWStepGeom_RWSurfacePatch::RWStepGeom_RWSurfacePatch () {} |
32 | |
33 | void RWStepGeom_RWSurfacePatch::ReadStep |
34 | (const Handle(StepData_StepReaderData)& data, |
35 | const Standard_Integer num, |
36 | Handle(Interface_Check)& ach, |
37 | const Handle(StepGeom_SurfacePatch)& ent) const |
38 | { |
39 | |
40 | |
41 | // --- Number of Parameter Control --- |
42 | |
43 | if (!data->CheckNbParams(num,5,ach,"surface_patch")) return; |
44 | |
45 | // --- own field : parentSurface --- |
46 | |
47 | Handle(StepGeom_BoundedSurface) aParentSurface; |
48 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
49 | data->ReadEntity(num, 1,"parent_surface", ach, STANDARD_TYPE(StepGeom_BoundedSurface), aParentSurface); |
50 | |
51 | // --- own field : uTransition --- |
52 | |
53 | StepGeom_TransitionCode aUTransition = StepGeom_tcDiscontinuous; |
54 | if (data->ParamType(num,2) == Interface_ParamEnum) { |
55 | Standard_CString text = data->ParamCValue(num,2); |
56 | if (tcDiscontinuous.IsEqual(text)) aUTransition = StepGeom_tcDiscontinuous; |
57 | else if (tcContSameGradientSameCurvature.IsEqual(text)) aUTransition = StepGeom_tcContSameGradientSameCurvature; |
58 | else if (tcContSameGradient.IsEqual(text)) aUTransition = StepGeom_tcContSameGradient; |
59 | else if (tcContinuous.IsEqual(text)) aUTransition = StepGeom_tcContinuous; |
60 | else ach->AddFail("Enumeration transition_code has not an allowed value"); |
61 | } |
62 | else ach->AddFail("Parameter #2 (u_transition) is not an enumeration"); |
63 | |
64 | // --- own field : vTransition --- |
65 | |
66 | StepGeom_TransitionCode aVTransition = StepGeom_tcDiscontinuous; |
67 | if (data->ParamType(num,3) == Interface_ParamEnum) { |
68 | Standard_CString text = data->ParamCValue(num,3); |
69 | if (tcDiscontinuous.IsEqual(text)) aVTransition = StepGeom_tcDiscontinuous; |
70 | else if (tcContSameGradientSameCurvature.IsEqual(text)) aVTransition = StepGeom_tcContSameGradientSameCurvature; |
71 | else if (tcContSameGradient.IsEqual(text)) aVTransition = StepGeom_tcContSameGradient; |
72 | else if (tcContinuous.IsEqual(text)) aVTransition = StepGeom_tcContinuous; |
73 | else ach->AddFail("Enumeration transition_code has not an allowed value"); |
74 | } |
75 | else ach->AddFail("Parameter #3 (v_transition) is not an enumeration"); |
76 | |
77 | // --- own field : uSense --- |
78 | |
79 | Standard_Boolean aUSense; |
80 | //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed |
81 | data->ReadBoolean (num,4,"u_sense",ach,aUSense); |
82 | |
83 | // --- own field : vSense --- |
84 | |
85 | Standard_Boolean aVSense; |
86 | //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed |
87 | data->ReadBoolean (num,5,"v_sense",ach,aVSense); |
88 | |
89 | //--- Initialisation of the read entity --- |
90 | |
91 | |
92 | ent->Init(aParentSurface, aUTransition, aVTransition, aUSense, aVSense); |
93 | } |
94 | |
95 | |
96 | void RWStepGeom_RWSurfacePatch::WriteStep |
97 | (StepData_StepWriter& SW, |
98 | const Handle(StepGeom_SurfacePatch)& ent) const |
99 | { |
100 | |
101 | // --- own field : parentSurface --- |
102 | |
103 | SW.Send(ent->ParentSurface()); |
104 | |
105 | // --- own field : uTransition --- |
106 | |
107 | switch(ent->UTransition()) { |
108 | case StepGeom_tcDiscontinuous : SW.SendEnum (tcDiscontinuous); break; |
109 | case StepGeom_tcContSameGradientSameCurvature : SW.SendEnum (tcContSameGradientSameCurvature); break; |
110 | case StepGeom_tcContSameGradient : SW.SendEnum (tcContSameGradient); break; |
111 | case StepGeom_tcContinuous : SW.SendEnum (tcContinuous); break; |
112 | } |
113 | |
114 | // --- own field : vTransition --- |
115 | |
116 | switch(ent->VTransition()) { |
117 | case StepGeom_tcDiscontinuous : SW.SendEnum (tcDiscontinuous); break; |
118 | case StepGeom_tcContSameGradientSameCurvature : SW.SendEnum (tcContSameGradientSameCurvature); break; |
119 | case StepGeom_tcContSameGradient : SW.SendEnum (tcContSameGradient); break; |
120 | case StepGeom_tcContinuous : SW.SendEnum (tcContinuous); break; |
121 | } |
122 | |
123 | // --- own field : uSense --- |
124 | |
125 | SW.SendBoolean(ent->USense()); |
126 | |
127 | // --- own field : vSense --- |
128 | |
129 | SW.SendBoolean(ent->VSense()); |
130 | } |
131 | |
132 | |
133 | void RWStepGeom_RWSurfacePatch::Share(const Handle(StepGeom_SurfacePatch)& ent, Interface_EntityIterator& iter) const |
134 | { |
135 | |
136 | iter.GetOneItem(ent->ParentSurface()); |
137 | } |
138 | |