b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
3 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
7fd59977 |
9 | // |
b311480e |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
7fd59977 |
12 | // |
b311480e |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
20 | //-------------------------------------------------------------------- |
7fd59977 |
21 | //-------------------------------------------------------------------- |
22 | |
23 | #include <IGESGraph_ToolUniformRectGrid.ixx> |
24 | #include <IGESData_ParamCursor.hxx> |
25 | #include <gp_XY.hxx> |
26 | #include <gp_Pnt2d.hxx> |
27 | #include <gp_Vec2d.hxx> |
28 | #include <IGESData_Dump.hxx> |
29 | |
30 | |
31 | IGESGraph_ToolUniformRectGrid::IGESGraph_ToolUniformRectGrid () { } |
32 | |
33 | |
34 | void IGESGraph_ToolUniformRectGrid::ReadOwnParams |
35 | (const Handle(IGESGraph_UniformRectGrid)& ent, |
36 | const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const |
37 | { |
38 | Standard_Integer nbPropertyValues; |
39 | Standard_Integer finite; |
40 | Standard_Integer line; |
41 | Standard_Integer weighted; |
42 | gp_XY gridPoint; |
43 | gp_XY gridSpacing; |
44 | Standard_Integer nbPointsX; |
45 | Standard_Integer nbPointsY; |
46 | |
47 | // Reading nbPropertyValues(Integer) |
48 | PR.ReadInteger(PR.Current(), "No. of property values", nbPropertyValues); |
49 | if (nbPropertyValues != 9) |
50 | PR.AddFail("No. of Property values : Value is not 9"); |
51 | |
52 | // Reading finite(Integer) |
53 | PR.ReadInteger(PR.Current(), "Finite/infinite grid flag", finite); |
54 | |
55 | // Reading line(Integer) |
56 | PR.ReadInteger(PR.Current(), "Line/point grid flag", line); |
57 | |
58 | // Reading weighted(Integer) |
59 | PR.ReadInteger(PR.Current(), "Weighted/unweighted grid flag", weighted); |
60 | |
61 | // Reading gridPoint(XY) |
62 | PR.ReadXY(PR.CurrentList(1, 2), "Grid point coordinates", gridPoint); |
63 | |
64 | // Reading gridSpacing(XY) |
65 | PR.ReadXY(PR.CurrentList(1, 2), "Grid Spacing coordinates", gridSpacing); |
66 | |
67 | // Reading nbPointsX(Integer) ?? even if not IsFinite ? |
68 | if (finite != 0 || PR.DefinedElseSkip()) |
69 | PR.ReadInteger |
70 | (PR.Current(), "No. of points/lines in X direction", nbPointsX); |
71 | |
72 | // Reading nbPointsY(Integer) |
73 | if (finite != 0 || PR.DefinedElseSkip()) |
74 | PR.ReadInteger |
75 | (PR.Current(), "No. of points/lines in Y direction", nbPointsY); |
76 | |
77 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
78 | ent->Init |
79 | (nbPropertyValues, finite, line, weighted, |
80 | gridPoint, gridSpacing, nbPointsX, nbPointsY); |
81 | } |
82 | |
83 | void IGESGraph_ToolUniformRectGrid::WriteOwnParams |
84 | (const Handle(IGESGraph_UniformRectGrid)& ent, IGESData_IGESWriter& IW) const |
85 | { |
86 | IW.Send( ent->NbPropertyValues() ); |
87 | IW.SendBoolean( ent->IsFinite() ); |
88 | IW.SendBoolean( ent->IsLine() ); |
89 | IW.SendBoolean( !ent->IsWeighted() ); |
90 | IW.Send( ent->GridPoint().X() ); |
91 | IW.Send( ent->GridPoint().Y() ); |
92 | IW.Send( ent->GridSpacing().X() ); |
93 | IW.Send( ent->GridSpacing().Y() ); |
94 | IW.Send( ent->NbPointsX() ); // ?? even if not IsFinite ?? |
95 | IW.Send( ent->NbPointsY() ); |
96 | } |
97 | |
98 | void IGESGraph_ToolUniformRectGrid::OwnShared |
99 | (const Handle(IGESGraph_UniformRectGrid)& /*ent*/, Interface_EntityIterator& /*iter*/) const |
100 | { |
101 | } |
102 | |
103 | void IGESGraph_ToolUniformRectGrid::OwnCopy |
104 | (const Handle(IGESGraph_UniformRectGrid)& another, |
105 | const Handle(IGESGraph_UniformRectGrid)& ent, Interface_CopyTool& /*TC*/) const |
106 | { |
107 | ent->Init |
108 | (9, (another->IsFinite() ? 1 : 0), (another->IsLine() ? 1 : 0), |
109 | (another->IsWeighted() ? 0 : 1), |
110 | another->GridPoint().XY(),another->GridSpacing().XY(), |
111 | another->NbPointsX(), another->NbPointsY()); |
112 | } |
113 | |
114 | Standard_Boolean IGESGraph_ToolUniformRectGrid::OwnCorrect |
115 | (const Handle(IGESGraph_UniformRectGrid)& ent) const |
116 | { |
117 | Standard_Boolean res = (ent->NbPropertyValues() != 9); |
118 | if (res) ent->Init |
119 | (9, (ent->IsFinite() ? 1 : 0), (ent->IsLine() ? 1 : 0), |
120 | (ent->IsWeighted() ? 0 : 1),ent->GridPoint().XY(),ent->GridSpacing().XY(), |
121 | ent->NbPointsX(), ent->NbPointsY()); // nbpropertyvalues=9 |
122 | return res; |
123 | } |
124 | |
125 | IGESData_DirChecker IGESGraph_ToolUniformRectGrid::DirChecker |
126 | (const Handle(IGESGraph_UniformRectGrid)& /*ent*/) const |
127 | { |
128 | IGESData_DirChecker DC (406, 22); |
129 | DC.Structure(IGESData_DefVoid); |
130 | DC.LineFont(IGESData_DefVoid); |
131 | DC.LineWeight(IGESData_DefVoid); |
132 | DC.Color(IGESData_DefVoid); |
133 | DC.BlankStatusIgnored(); |
134 | DC.UseFlagIgnored(); |
135 | DC.HierarchyStatusIgnored(); |
136 | return DC; |
137 | } |
138 | |
139 | void IGESGraph_ToolUniformRectGrid::OwnCheck |
140 | (const Handle(IGESGraph_UniformRectGrid)& ent, |
141 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
142 | { |
143 | if ( ent->IsFinite() != 0 && ent->IsFinite() != 1 ) |
144 | ach->AddFail("Finite/infinite grid flag : Value != 0/1"); |
145 | if ( ent->IsLine() != 0 && ent->IsLine() != 1 ) |
146 | ach->AddFail("Line/point grid flag : Value != 0/1"); |
147 | if ( ent->IsWeighted() != 0 && ent->IsWeighted() != 1 ) |
148 | ach->AddFail("Weighted/unweighted grid flag : Value != 0/1"); |
149 | if (ent->NbPropertyValues() != 9) |
150 | ach->AddFail("No. of Property values : Value != 9"); |
151 | } |
152 | |
153 | void IGESGraph_ToolUniformRectGrid::OwnDump |
154 | (const Handle(IGESGraph_UniformRectGrid)& ent, const IGESData_IGESDumper& /*dumper*/, |
155 | const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const |
156 | { |
157 | S << "IGESGraph_UniformRectGrid" << endl; |
158 | |
159 | S << "No. of property values : " << ent->NbPropertyValues() << endl; |
160 | S << "Grid : " << ( ent->IsFinite() ? "Finite" : "Infinite"); |
161 | S << " - Composed of " << ( ent->IsLine() ? "Lines" : "Points"); |
162 | S << " - " << ( ent->IsWeighted() ? "Weighted" : "Unweighted") << endl; |
163 | S << "Grid Point : "; |
164 | IGESData_DumpXY(S, ent->GridPoint()); |
165 | S << " Grid Spacing : "; |
166 | IGESData_DumpXY(S, ent->GridSpacing()); S << endl; |
167 | if (ent->IsFinite()) |
168 | S << "No. of points/lines in direction : X : " << ent->NbPointsX() |
169 | << " - Y : " << ent->NbPointsY() << endl; |
170 | } |