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 | // |
973c2be1 |
7 | // This library is free software; you can redistribute it and / or modify it |
8 | // under the terms of the GNU Lesser General Public version 2.1 as published |
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 | |
19 | #include <IGESGraph_ToolUniformRectGrid.ixx> |
20 | #include <IGESData_ParamCursor.hxx> |
21 | #include <gp_XY.hxx> |
22 | #include <gp_Pnt2d.hxx> |
23 | #include <gp_Vec2d.hxx> |
24 | #include <IGESData_Dump.hxx> |
25 | |
26 | |
27 | IGESGraph_ToolUniformRectGrid::IGESGraph_ToolUniformRectGrid () { } |
28 | |
29 | |
30 | void IGESGraph_ToolUniformRectGrid::ReadOwnParams |
31 | (const Handle(IGESGraph_UniformRectGrid)& ent, |
32 | const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const |
33 | { |
34 | Standard_Integer nbPropertyValues; |
35 | Standard_Integer finite; |
36 | Standard_Integer line; |
37 | Standard_Integer weighted; |
38 | gp_XY gridPoint; |
39 | gp_XY gridSpacing; |
1d47d8d0 |
40 | Standard_Integer nbPointsX = 0; |
41 | Standard_Integer nbPointsY = 0; |
7fd59977 |
42 | |
43 | // Reading nbPropertyValues(Integer) |
44 | PR.ReadInteger(PR.Current(), "No. of property values", nbPropertyValues); |
45 | if (nbPropertyValues != 9) |
46 | PR.AddFail("No. of Property values : Value is not 9"); |
47 | |
48 | // Reading finite(Integer) |
49 | PR.ReadInteger(PR.Current(), "Finite/infinite grid flag", finite); |
50 | |
51 | // Reading line(Integer) |
52 | PR.ReadInteger(PR.Current(), "Line/point grid flag", line); |
53 | |
54 | // Reading weighted(Integer) |
55 | PR.ReadInteger(PR.Current(), "Weighted/unweighted grid flag", weighted); |
56 | |
57 | // Reading gridPoint(XY) |
58 | PR.ReadXY(PR.CurrentList(1, 2), "Grid point coordinates", gridPoint); |
59 | |
60 | // Reading gridSpacing(XY) |
61 | PR.ReadXY(PR.CurrentList(1, 2), "Grid Spacing coordinates", gridSpacing); |
62 | |
63 | // Reading nbPointsX(Integer) ?? even if not IsFinite ? |
64 | if (finite != 0 || PR.DefinedElseSkip()) |
65 | PR.ReadInteger |
66 | (PR.Current(), "No. of points/lines in X direction", nbPointsX); |
67 | |
68 | // Reading nbPointsY(Integer) |
69 | if (finite != 0 || PR.DefinedElseSkip()) |
70 | PR.ReadInteger |
71 | (PR.Current(), "No. of points/lines in Y direction", nbPointsY); |
72 | |
73 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
74 | ent->Init |
75 | (nbPropertyValues, finite, line, weighted, |
76 | gridPoint, gridSpacing, nbPointsX, nbPointsY); |
77 | } |
78 | |
79 | void IGESGraph_ToolUniformRectGrid::WriteOwnParams |
80 | (const Handle(IGESGraph_UniformRectGrid)& ent, IGESData_IGESWriter& IW) const |
81 | { |
82 | IW.Send( ent->NbPropertyValues() ); |
83 | IW.SendBoolean( ent->IsFinite() ); |
84 | IW.SendBoolean( ent->IsLine() ); |
85 | IW.SendBoolean( !ent->IsWeighted() ); |
86 | IW.Send( ent->GridPoint().X() ); |
87 | IW.Send( ent->GridPoint().Y() ); |
88 | IW.Send( ent->GridSpacing().X() ); |
89 | IW.Send( ent->GridSpacing().Y() ); |
90 | IW.Send( ent->NbPointsX() ); // ?? even if not IsFinite ?? |
91 | IW.Send( ent->NbPointsY() ); |
92 | } |
93 | |
94 | void IGESGraph_ToolUniformRectGrid::OwnShared |
95 | (const Handle(IGESGraph_UniformRectGrid)& /*ent*/, Interface_EntityIterator& /*iter*/) const |
96 | { |
97 | } |
98 | |
99 | void IGESGraph_ToolUniformRectGrid::OwnCopy |
100 | (const Handle(IGESGraph_UniformRectGrid)& another, |
101 | const Handle(IGESGraph_UniformRectGrid)& ent, Interface_CopyTool& /*TC*/) const |
102 | { |
103 | ent->Init |
104 | (9, (another->IsFinite() ? 1 : 0), (another->IsLine() ? 1 : 0), |
105 | (another->IsWeighted() ? 0 : 1), |
106 | another->GridPoint().XY(),another->GridSpacing().XY(), |
107 | another->NbPointsX(), another->NbPointsY()); |
108 | } |
109 | |
110 | Standard_Boolean IGESGraph_ToolUniformRectGrid::OwnCorrect |
111 | (const Handle(IGESGraph_UniformRectGrid)& ent) const |
112 | { |
113 | Standard_Boolean res = (ent->NbPropertyValues() != 9); |
114 | if (res) ent->Init |
115 | (9, (ent->IsFinite() ? 1 : 0), (ent->IsLine() ? 1 : 0), |
116 | (ent->IsWeighted() ? 0 : 1),ent->GridPoint().XY(),ent->GridSpacing().XY(), |
117 | ent->NbPointsX(), ent->NbPointsY()); // nbpropertyvalues=9 |
118 | return res; |
119 | } |
120 | |
121 | IGESData_DirChecker IGESGraph_ToolUniformRectGrid::DirChecker |
122 | (const Handle(IGESGraph_UniformRectGrid)& /*ent*/) const |
123 | { |
124 | IGESData_DirChecker DC (406, 22); |
125 | DC.Structure(IGESData_DefVoid); |
126 | DC.LineFont(IGESData_DefVoid); |
127 | DC.LineWeight(IGESData_DefVoid); |
128 | DC.Color(IGESData_DefVoid); |
129 | DC.BlankStatusIgnored(); |
130 | DC.UseFlagIgnored(); |
131 | DC.HierarchyStatusIgnored(); |
132 | return DC; |
133 | } |
134 | |
135 | void IGESGraph_ToolUniformRectGrid::OwnCheck |
136 | (const Handle(IGESGraph_UniformRectGrid)& ent, |
137 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
138 | { |
139 | if ( ent->IsFinite() != 0 && ent->IsFinite() != 1 ) |
140 | ach->AddFail("Finite/infinite grid flag : Value != 0/1"); |
141 | if ( ent->IsLine() != 0 && ent->IsLine() != 1 ) |
142 | ach->AddFail("Line/point grid flag : Value != 0/1"); |
143 | if ( ent->IsWeighted() != 0 && ent->IsWeighted() != 1 ) |
144 | ach->AddFail("Weighted/unweighted grid flag : Value != 0/1"); |
145 | if (ent->NbPropertyValues() != 9) |
146 | ach->AddFail("No. of Property values : Value != 9"); |
147 | } |
148 | |
149 | void IGESGraph_ToolUniformRectGrid::OwnDump |
150 | (const Handle(IGESGraph_UniformRectGrid)& ent, const IGESData_IGESDumper& /*dumper*/, |
151 | const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const |
152 | { |
153 | S << "IGESGraph_UniformRectGrid" << endl; |
154 | |
155 | S << "No. of property values : " << ent->NbPropertyValues() << endl; |
156 | S << "Grid : " << ( ent->IsFinite() ? "Finite" : "Infinite"); |
157 | S << " - Composed of " << ( ent->IsLine() ? "Lines" : "Points"); |
158 | S << " - " << ( ent->IsWeighted() ? "Weighted" : "Unweighted") << endl; |
159 | S << "Grid Point : "; |
160 | IGESData_DumpXY(S, ent->GridPoint()); |
161 | S << " Grid Spacing : "; |
162 | IGESData_DumpXY(S, ent->GridSpacing()); S << endl; |
163 | if (ent->IsFinite()) |
164 | S << "No. of points/lines in direction : X : " << ent->NbPointsX() |
165 | << " - Y : " << ent->NbPointsY() << endl; |
166 | } |