Warnings on vc14 were eliminated
[occt.git] / src / IGESDimen / IGESDimen_ToolWitnessLine.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_Pnt.hxx>
42cf5bc1 20#include <gp_XY.hxx>
21#include <IGESData_DirChecker.hxx>
7fd59977 22#include <IGESData_Dump.hxx>
42cf5bc1 23#include <IGESData_IGESDumper.hxx>
24#include <IGESData_IGESReaderData.hxx>
25#include <IGESData_IGESWriter.hxx>
26#include <IGESData_LineFontEntity.hxx>
27#include <IGESData_ParamCursor.hxx>
28#include <IGESData_ParamReader.hxx>
29#include <IGESDimen_ToolWitnessLine.hxx>
30#include <IGESDimen_WitnessLine.hxx>
31#include <Interface_Check.hxx>
32#include <Interface_CopyTool.hxx>
33#include <Interface_EntityIterator.hxx>
7fd59977 34#include <Interface_Macros.hxx>
42cf5bc1 35#include <Interface_ShareTool.hxx>
36#include <Message_Messenger.hxx>
37#include <Standard_DomainError.hxx>
38#include <TColgp_HArray1OfXY.hxx>
7fd59977 39
40IGESDimen_ToolWitnessLine::IGESDimen_ToolWitnessLine () { }
41
42
43void IGESDimen_ToolWitnessLine::ReadOwnParams
44 (const Handle(IGESDimen_WitnessLine)& ent,
45 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
46{
47 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
48
49 Standard_Integer datatype;
50 Standard_Real zDisplacement;
51 Standard_Integer nbval;
52 Handle(TColgp_HArray1OfXY) dataPoints;
53
54 PR.ReadInteger(PR.Current(), "Interpretation Flag", datatype); //szv#4:S4163:12Mar99 `st=` not needed
55
56 Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of data points", nbval);
57 if (st && nbval > 0)
58 dataPoints = new TColgp_HArray1OfXY(1, nbval);
59 else PR.AddFail("Number of data points: Not Positive");
60
61 PR.ReadReal(PR.Current(), "Common Z Displacement", zDisplacement); //szv#4:S4163:12Mar99 `st=` not needed
62
63 if (! dataPoints.IsNull())
64 for (Standard_Integer i = 1; i <= nbval; i++)
65 {
66 gp_XY tempXY;
67 PR.ReadXY(PR.CurrentList(1, 2), "Data Points", tempXY); //szv#4:S4163:12Mar99 `st=` not needed
68 dataPoints->SetValue(i, tempXY);
69 }
70
71 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
72 ent->Init(datatype, zDisplacement, dataPoints);
73}
74
75void IGESDimen_ToolWitnessLine::WriteOwnParams
76 (const Handle(IGESDimen_WitnessLine)& ent, IGESData_IGESWriter& IW) const
77{
78 Standard_Integer upper = ent->NbPoints();
79 IW.Send(ent->Datatype());
80 IW.Send(upper);
81 IW.Send(ent->ZDisplacement());
82 for (Standard_Integer i = 1; i <= upper; i++)
83 {
84 IW.Send((ent->Point(i)).X());
85 IW.Send((ent->Point(i)).Y());
86 }
87}
88
89void IGESDimen_ToolWitnessLine::OwnShared
90 (const Handle(IGESDimen_WitnessLine)& /* ent */, Interface_EntityIterator& /* iter */) const
91{
92}
93
94void IGESDimen_ToolWitnessLine::OwnCopy
95 (const Handle(IGESDimen_WitnessLine)& another,
96 const Handle(IGESDimen_WitnessLine)& ent, Interface_CopyTool& /* TC */) const
97{
98 Standard_Integer datatype = another->Datatype();
99 Standard_Integer nbval = another->NbPoints();
100 Standard_Real zDisplacement = another->ZDisplacement();
101
102 Handle(TColgp_HArray1OfXY) dataPoints = new TColgp_HArray1OfXY(1, nbval);
103
104 for (Standard_Integer i = 1; i <= nbval; i++)
105 {
106 gp_Pnt tempPnt = (another->Point(i));
107 gp_XY tempPnt2d(tempPnt.X(), tempPnt.Y());
108 dataPoints->SetValue(i, tempPnt2d);
109 }
110 ent->Init(datatype, zDisplacement, dataPoints);
111}
112
113Standard_Boolean IGESDimen_ToolWitnessLine::OwnCorrect
114 (const Handle(IGESDimen_WitnessLine)& ent) const
115{
116 Standard_Boolean res = (ent->RankLineFont() != 1);
117 if (res) {
118 Handle(IGESData_LineFontEntity) nulfont;
119 ent->InitLineFont(nulfont,1);
120 }
121 if (ent->Datatype() == 1) return res;
122// Forcer DataType = 1 -> reconstruire
123 Standard_Integer nb = ent->NbPoints();
124 if (nb == 0) return Standard_False; // rien pu faire (est-ce possible ?)
125 Handle(TColgp_HArray1OfXY) pts = new TColgp_HArray1OfXY(1,nb);
126 for (Standard_Integer i = 1; i <= nb; i ++)
127 pts->SetValue(i,gp_XY (ent->Point(i).X(),ent->Point(i).Y()) );
128 ent->Init (1,ent->ZDisplacement(),pts);
129 return Standard_True;
130}
131
132IGESData_DirChecker IGESDimen_ToolWitnessLine::DirChecker
133 (const Handle(IGESDimen_WitnessLine)& /* ent */ ) const
134{
135 IGESData_DirChecker DC (106, 40);
136 DC.Structure(IGESData_DefVoid);
137 DC.LineFont(IGESData_DefValue);
138 DC.LineWeight(IGESData_DefValue);
139 DC.Color(IGESData_DefAny);
140 DC.UseFlagRequired(1);
141 DC.HierarchyStatusIgnored();
142 return DC;
143}
144
145void IGESDimen_ToolWitnessLine::OwnCheck
146 (const Handle(IGESDimen_WitnessLine)& ent,
147 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
148{
149 if (ent->RankLineFont() != 1)
150 ach->AddFail("Line Font Pattern != 1");
151 if (ent->Datatype() != 1)
152 ach->AddFail("Interpretation Flag != 1");
153 if (ent->NbPoints() < 3)
154 ach->AddFail("Number of data points < 3");
155 if (ent->NbPoints()%2 == 0)
156 ach->AddFail("Number of data points is not odd");
157}
158
159void IGESDimen_ToolWitnessLine::OwnDump
160 (const Handle(IGESDimen_WitnessLine)& ent, const IGESData_IGESDumper& /* dumper */,
161 const Handle(Message_Messenger)& S, const Standard_Integer level) const
162{
163 S << "IGESDimen_WitnessLine" << endl;
164 S << "Data Type : " << ent->Datatype() << " ";
165 S << "Number of Data Points : " << ent->NbPoints() << " ";
166 S << "Common Z displacement : " << ent->ZDisplacement() << endl;
167 S << "Data Points : ";
168 IGESData_DumpListXYLZ(S ,level,1, ent->NbPoints(),ent->Point,
169 ent->Location(), ent->ZDisplacement());
170 S << endl;
171}