1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
20 #include <IGESData_DirChecker.hxx>
21 #include <IGESData_Dump.hxx>
22 #include <IGESData_IGESDumper.hxx>
23 #include <IGESData_IGESEntity.hxx>
24 #include <IGESData_IGESReaderData.hxx>
25 #include <IGESData_IGESWriter.hxx>
26 #include <IGESData_ParamCursor.hxx>
27 #include <IGESData_ParamReader.hxx>
28 #include <IGESDraw_CircArraySubfigure.hxx>
29 #include <IGESDraw_ToolCircArraySubfigure.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Standard_DomainError.hxx>
36 #include <TColStd_HArray1OfInteger.hxx>
38 IGESDraw_ToolCircArraySubfigure::IGESDraw_ToolCircArraySubfigure () { }
41 void IGESDraw_ToolCircArraySubfigure::ReadOwnParams
42 (const Handle(IGESDraw_CircArraySubfigure)& ent,
43 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
45 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
48 Handle(IGESData_IGESEntity) tempBase;
49 Standard_Real tempRadius, tempStAngle, tempDelAngle;
50 Standard_Integer tempNumLocs, tempFlag, tempListCount;
51 Handle(TColStd_HArray1OfInteger) tempNumPos;
53 //szv#4:S4163:12Mar99 `st=` not needed
54 PR.ReadEntity(IR, PR.Current(), "Base Entity", tempBase);
55 PR.ReadInteger(PR.Current(), "Number Of Instance Locations", tempNumLocs);
56 PR.ReadXYZ(PR.CurrentList(1, 3), "Imaginary Circle Center Coordinate", tempCenter);
57 PR.ReadReal(PR.Current(), "Radius Of Imaginary Circle", tempRadius);
58 PR.ReadReal(PR.Current(), "Start Angle in Radians", tempStAngle);
59 PR.ReadReal(PR.Current(), "Delta Angle in Radians", tempDelAngle);
61 //st = PR.ReadInteger(PR.Current(), "DO-DONT List Count", tempListCount); //szv#4:S4163:12Mar99 moved in if
62 if (PR.ReadInteger(PR.Current(), "DO-DONT List Count", tempListCount)) {
63 // Initialise HArray1 only if there is no error reading its Length
64 if (tempListCount > 0)
65 tempNumPos = new TColStd_HArray1OfInteger(1, tempListCount);
66 else if (tempListCount < 0)
67 PR.AddFail("DO-DONT List Count : Less than Zero");
70 PR.ReadInteger(PR.Current(), "DO-DONT Flag", tempFlag); //szv#4:S4163:12Mar99 `st=` not needed
72 // Read the HArray1 only if its Length was read without any Error
73 if (! tempNumPos.IsNull()) {
75 for (I = 1; I <= tempListCount; I++) {
76 Standard_Integer tempPosition;
77 //st = PR.ReadInteger(PR.Current(), "Number Of Position To Process",
78 //tempPosition); //szv#4:S4163:12Mar99 moved in if
79 if (PR.ReadInteger(PR.Current(), "Number Of Position To Process", tempPosition))
80 tempNumPos->SetValue(I, tempPosition);
84 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
86 (tempBase, tempNumLocs, tempCenter, tempRadius,
87 tempStAngle,tempDelAngle, tempFlag, tempNumPos);
90 void IGESDraw_ToolCircArraySubfigure::WriteOwnParams
91 (const Handle(IGESDraw_CircArraySubfigure)& ent, IGESData_IGESWriter& IW) const
93 IW.Send(ent->BaseEntity());
94 IW.Send(ent->NbLocations());
95 IW.Send(ent->CenterPoint().X());
96 IW.Send(ent->CenterPoint().Y());
97 IW.Send(ent->CenterPoint().Z());
98 IW.Send(ent->CircleRadius());
99 IW.Send(ent->StartAngle());
100 IW.Send(ent->DeltaAngle());
101 IW.Send(ent->ListCount());
102 IW.SendBoolean(ent->DoDontFlag());
103 // Send the HArray1 only if it is not empty (i.e. Null)
105 Standard_Integer up = ent->ListCount();
106 for (I = 1; I <= up; I++)
107 IW.Send(ent->ListPosition(I));
110 void IGESDraw_ToolCircArraySubfigure::OwnShared
111 (const Handle(IGESDraw_CircArraySubfigure)& /*ent*/, Interface_EntityIterator& /*iter*/) const
115 void IGESDraw_ToolCircArraySubfigure::OwnCopy
116 (const Handle(IGESDraw_CircArraySubfigure)& another,
117 const Handle(IGESDraw_CircArraySubfigure)& ent, Interface_CopyTool& TC) const
119 DeclareAndCast(IGESData_IGESEntity, tempBase,
120 TC.Transferred(another->BaseEntity()));
121 Standard_Integer tempNumLocs = another->NbLocations();
122 gp_XYZ tempCenter = (another->CenterPoint()).XYZ();
123 Standard_Real tempRadius = another->CircleRadius();
124 Standard_Real tempStAngle = another->StartAngle();
125 Standard_Real tempDelAngle = another->DeltaAngle();
126 Standard_Integer tempListCount = another->ListCount();
127 Standard_Integer tempFlag = another->DoDontFlag();
128 Handle(TColStd_HArray1OfInteger) tempNumPos;
129 if (! another->DisplayFlag()) {
130 tempNumPos = new TColStd_HArray1OfInteger(1, tempListCount);
132 for (I = 1; I <= tempListCount; I++) {
133 Standard_Integer tempPosition = another->ListPosition(I);
134 tempNumPos->SetValue(I, tempPosition);
138 ent->Init(tempBase, tempNumLocs, tempCenter, tempRadius,
139 tempStAngle, tempDelAngle, tempFlag, tempNumPos);
142 IGESData_DirChecker IGESDraw_ToolCircArraySubfigure::DirChecker
143 (const Handle(IGESDraw_CircArraySubfigure)& /*ent*/) const
145 IGESData_DirChecker DC(414, 0);
146 DC.Structure(IGESData_DefVoid);
147 DC.LineFont(IGESData_DefAny);
148 DC.LineWeight(IGESData_DefValue);
149 DC.Color(IGESData_DefAny);
150 DC.GraphicsIgnored(1);
155 void IGESDraw_ToolCircArraySubfigure::OwnCheck
156 (const Handle(IGESDraw_CircArraySubfigure)& /*ent*/,
157 const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const
161 void IGESDraw_ToolCircArraySubfigure::OwnDump
162 (const Handle(IGESDraw_CircArraySubfigure)& ent, const IGESData_IGESDumper& dumper,
163 Standard_OStream& S, const Standard_Integer level) const
165 Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;
167 S << "IGESDraw_CircArraySubfigure\n"
169 dumper.Dump(ent->BaseEntity(),S, tempSubLevel);
171 << "Total Number Of Possible Instance Locations : " << ent->NbLocations()
173 << "Imaginary Circle. Radius : " << ent->CircleRadius() << " Center : ";
174 IGESData_DumpXYZL(S, level, ent->CenterPoint(), ent->Location()); S << "\n";
175 S << "Start Angle (in radians) : " << ent->StartAngle() << " "
176 << "Delta Angle (in radians) : " << ent->DeltaAngle() << "\n"
177 << "Do-Dont Flag : ";
178 if (ent->DoDontFlag()) S << "Dont\n";
180 S << "The Do-Dont List : ";
181 IGESData_DumpVals(S,level,1, ent->ListCount(),ent->ListPosition);