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