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 //--------------------------------------------------------------------
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_IGESDumper.hxx>
24 #include <IGESData_IGESReaderData.hxx>
25 #include <IGESData_IGESWriter.hxx>
26 #include <IGESData_ParamReader.hxx>
27 #include <IGESDimen_SectionedArea.hxx>
28 #include <IGESDimen_ToolSectionedArea.hxx>
29 #include <Interface_Check.hxx>
30 #include <Interface_CopyTool.hxx>
31 #include <Interface_EntityIterator.hxx>
32 #include <Interface_Macros.hxx>
33 #include <Interface_ShareTool.hxx>
34 #include <Standard_DomainError.hxx>
36 IGESDimen_ToolSectionedArea::IGESDimen_ToolSectionedArea () { }
39 void IGESDimen_ToolSectionedArea::ReadOwnParams
40 (const Handle(IGESDimen_SectionedArea)& ent,
41 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
43 Handle(IGESData_IGESEntity) extCurve;
44 Standard_Integer tempPattern, nbislands;
46 Standard_Real tempDistance, tempAngle;
47 Handle(IGESData_HArray1OfIGESEntity) tempIslands;
48 Handle(IGESData_IGESEntity) anent;
49 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
51 //szv#4:S4163:12Mar99 `st=` not needed
52 PR.ReadEntity(IR, PR.Current(), "Exterior curve", extCurve, (ent->FormNumber() == 1));
53 PR.ReadInteger(PR.Current(), "Fill pattern", tempPattern);
54 PR.ReadXYZ(PR.CurrentList(1, 3), "Passing point", passPnt);
55 PR.ReadReal(PR.Current(), "Distance between lines", tempDistance);
57 if (PR.DefinedElseSkip())
58 PR.ReadReal(PR.Current(), "Angle between line and X axis", tempAngle); //szv#4:S4163:12Mar99 `st=` not needed
60 tempAngle = M_PI / 4.0;
62 Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of island curves", nbislands);
63 if (st && nbislands > 0)
64 PR.ReadEnts (IR,PR.CurrentList(nbislands),"Island curves",tempIslands); //szv#4:S4163:12Mar99 `st=` not needed
67 tempIslands = new IGESData_HArray1OfIGESEntity(1, nbislands);
68 for (Standard_Integer i=1; i<=nbislands; i++)
70 st = PR.ReadEntity(IR, PR.Current(), "Island curves", anent);
71 if (st) tempIslands->SetValue(i, anent);
76 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
78 (extCurve, tempPattern, passPnt, tempDistance, tempAngle, tempIslands);
81 void IGESDimen_ToolSectionedArea::WriteOwnParams
82 (const Handle(IGESDimen_SectionedArea)& ent, IGESData_IGESWriter& IW) const
84 Standard_Integer i, length = ent->NbIslands();
85 IW.Send(ent->ExteriorCurve());
86 IW.Send(ent->Pattern());
87 IW.Send(ent->PassingPoint().X());
88 IW.Send(ent->PassingPoint().Y());
89 IW.Send(ent->PassingPoint().Z());
90 IW.Send(ent->Distance());
91 IW.Send(ent->Angle());
93 for (i = 1; i <= length; i ++)
94 IW.Send(ent->IslandCurve(i));
97 void IGESDimen_ToolSectionedArea::OwnShared
98 (const Handle(IGESDimen_SectionedArea)& ent, Interface_EntityIterator& iter) const
100 Standard_Integer i, length = ent->NbIslands();
101 iter.GetOneItem(ent->ExteriorCurve());
102 for (i = 1; i <= length; i ++)
103 iter.GetOneItem(ent->IslandCurve(i));
106 void IGESDimen_ToolSectionedArea::OwnCopy
107 (const Handle(IGESDimen_SectionedArea)& another,
108 const Handle(IGESDimen_SectionedArea)& ent, Interface_CopyTool& TC) const
110 DeclareAndCast(IGESData_IGESEntity, extCurve,
111 TC.Transferred(another->ExteriorCurve()));
112 Standard_Integer tempPattern = another->Pattern();
113 gp_XYZ passPnt = (another->PassingPoint()).XYZ();
114 Standard_Real tempDistance = another->Distance();
115 Standard_Real tempAngle = another->Angle();
116 Handle(IGESData_HArray1OfIGESEntity) tempIslands;
117 Standard_Integer nbislands = another->NbIslands();
120 tempIslands = new IGESData_HArray1OfIGESEntity(1, nbislands);
121 for (Standard_Integer i=1; i<=nbislands; i++)
123 DeclareAndCast(IGESData_IGESEntity, anent,
124 TC.Transferred(another->IslandCurve(i)));
125 tempIslands->SetValue(i, anent);
128 ent->Init(extCurve, tempPattern, passPnt,
129 tempDistance, tempAngle, tempIslands);
130 ent->SetInverted (another->IsInverted());
133 IGESData_DirChecker IGESDimen_ToolSectionedArea::DirChecker
134 (const Handle(IGESDimen_SectionedArea)& /* ent */ ) const
136 IGESData_DirChecker DC(230, 0,1);
137 DC.Structure(IGESData_DefVoid);
138 DC.LineFont(IGESData_DefAny);
139 DC.LineWeight(IGESData_DefValue);
140 DC.Color(IGESData_DefAny);
142 DC.UseFlagRequired (1);
147 void IGESDimen_ToolSectionedArea::OwnCheck
148 (const Handle(IGESDimen_SectionedArea)& /* ent */,
149 const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
153 void IGESDimen_ToolSectionedArea::OwnDump
154 (const Handle(IGESDimen_SectionedArea)& ent, const IGESData_IGESDumper& dumper,
155 Standard_OStream& S, const Standard_Integer level) const
157 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
159 S << "IGESDimen_SectionedArea\n"
160 << (ent->IsInverted() ? "Inverted Cross Hatches" : "Standard Cross Hatches")
161 << " - Exterior curve : ";
162 dumper.Dump(ent->ExteriorCurve(),S, sublevel);
164 << "Fill pattern code : " << ent->Pattern() << "\n"
165 << "Passing point : ";
166 IGESData_DumpXYZL(S,level, ent->PassingPoint(), ent->Location()); S << "\n";
167 S << "Distance between lines : " << ent->Distance() << "\n"
168 << "Angle between lines and X axis : " << ent->Angle() << "\n"
169 << "Island Curve : ";
170 IGESData_DumpEntities(S,dumper ,level,1, ent->NbIslands(),ent->IslandCurve);