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 | |
42cf5bc1 |
14 | |
15 | #include <Interface_Check.hxx> |
16 | #include <Interface_EntityIterator.hxx> |
17 | #include <RWStepGeom_RWSeamCurve.hxx> |
18 | #include <StepData_StepReaderData.hxx> |
19 | #include <StepData_StepWriter.hxx> |
7fd59977 |
20 | #include <StepGeom_Curve.hxx> |
21 | #include <StepGeom_HArray1OfPcurveOrSurface.hxx> |
22 | #include <StepGeom_PcurveOrSurface.hxx> |
23 | #include <StepGeom_PreferredSurfaceCurveRepresentation.hxx> |
7fd59977 |
24 | #include <StepGeom_SeamCurve.hxx> |
25 | |
b311480e |
26 | // --- Enum : PreferredSurfaceCurveRepresentation --- |
7fd59977 |
27 | static TCollection_AsciiString pscrPcurveS2(".PCURVE_S2."); |
28 | static TCollection_AsciiString pscrPcurveS1(".PCURVE_S1."); |
29 | static TCollection_AsciiString pscrCurve3d(".CURVE_3D."); |
30 | |
31 | RWStepGeom_RWSeamCurve::RWStepGeom_RWSeamCurve () {} |
32 | |
33 | void RWStepGeom_RWSeamCurve::ReadStep |
34 | (const Handle(StepData_StepReaderData)& data, |
35 | const Standard_Integer num, |
36 | Handle(Interface_Check)& ach, |
37 | const Handle(StepGeom_SeamCurve)& ent) const |
38 | { |
39 | |
40 | |
41 | // --- Number of Parameter Control --- |
42 | |
43 | if (!data->CheckNbParams(num,4,ach,"seam_curve")) return; |
44 | |
45 | // --- inherited field : name --- |
46 | |
47 | Handle(TCollection_HAsciiString) aName; |
48 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
49 | data->ReadString (num,1,"name",ach,aName); |
50 | |
51 | // --- inherited field : curve3d --- |
52 | |
53 | Handle(StepGeom_Curve) aCurve3d; |
54 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
55 | data->ReadEntity(num, 2,"curve_3d", ach, STANDARD_TYPE(StepGeom_Curve), aCurve3d); |
56 | |
57 | // --- inherited field : associatedGeometry --- |
58 | |
59 | Handle(StepGeom_HArray1OfPcurveOrSurface) aAssociatedGeometry; |
60 | StepGeom_PcurveOrSurface aAssociatedGeometryItem; |
61 | Handle(Standard_Transient) assgeomval; |
62 | Standard_Integer nsub3; |
63 | if (data->ReadSubList (num,3,"associated_geometry",ach,nsub3)) { |
64 | Standard_Integer nb3 = data->NbParams(nsub3); |
65 | aAssociatedGeometry = new StepGeom_HArray1OfPcurveOrSurface (1, nb3); |
66 | for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) { |
67 | //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed |
68 | if (data->ReadEntity (nsub3,i3,"associated_geometry",ach,aAssociatedGeometryItem)) |
69 | aAssociatedGeometry->SetValue(i3,aAssociatedGeometryItem); |
70 | if (i3 == 1) assgeomval = aAssociatedGeometryItem.Value(); |
71 | else if (assgeomval == aAssociatedGeometryItem.Value()) //:a9 abv |
72 | ach->AddFail ("Seam Curve with twice the same geom"); |
73 | } |
74 | } |
75 | |
76 | // --- inherited field : masterRepresentation --- |
77 | |
78 | StepGeom_PreferredSurfaceCurveRepresentation aMasterRepresentation = StepGeom_pscrCurve3d; |
79 | if (data->ParamType(num,4) == Interface_ParamEnum) { |
80 | Standard_CString text = data->ParamCValue(num,4); |
81 | if (pscrPcurveS2.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS2; |
82 | else if (pscrPcurveS1.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS1; |
83 | else if (pscrCurve3d.IsEqual(text)) aMasterRepresentation = StepGeom_pscrCurve3d; |
84 | else ach->AddFail("Enumeration preferred_surface_curve_representation has not an allowed value"); |
85 | } |
86 | else ach->AddFail("Parameter #4 (master_representation) is not an enumeration"); |
87 | |
88 | //--- Initialisation of the read entity --- |
89 | |
90 | |
91 | ent->Init(aName, aCurve3d, aAssociatedGeometry, aMasterRepresentation); |
92 | } |
93 | |
94 | |
95 | void RWStepGeom_RWSeamCurve::WriteStep |
96 | (StepData_StepWriter& SW, |
97 | const Handle(StepGeom_SeamCurve)& ent) const |
98 | { |
99 | |
100 | // --- inherited field name --- |
101 | |
102 | SW.Send(ent->Name()); |
103 | |
104 | // --- inherited field curve3d --- |
105 | |
106 | SW.Send(ent->Curve3d()); |
107 | |
108 | // --- inherited field associatedGeometry --- |
109 | |
110 | SW.OpenSub(); |
111 | for (Standard_Integer i3 = 1; i3 <= ent->NbAssociatedGeometry(); i3 ++) { |
112 | SW.Send(ent->AssociatedGeometryValue(i3).Value()); |
113 | } |
114 | SW.CloseSub(); |
115 | |
116 | // --- inherited field masterRepresentation --- |
117 | |
118 | switch(ent->MasterRepresentation()) { |
119 | case StepGeom_pscrPcurveS2 : SW.SendEnum (pscrPcurveS2); break; |
120 | case StepGeom_pscrPcurveS1 : SW.SendEnum (pscrPcurveS1); break; |
121 | case StepGeom_pscrCurve3d : SW.SendEnum (pscrCurve3d); break; |
122 | } |
123 | } |
124 | |
125 | |
126 | void RWStepGeom_RWSeamCurve::Share(const Handle(StepGeom_SeamCurve)& ent, Interface_EntityIterator& iter) const |
127 | { |
128 | |
129 | iter.GetOneItem(ent->Curve3d()); |
130 | |
131 | |
132 | Standard_Integer nbElem2 = ent->NbAssociatedGeometry(); |
133 | for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) { |
134 | iter.GetOneItem(ent->AssociatedGeometryValue(is2).Value()); |
135 | } |
136 | |
137 | } |
138 | |