e02ca96da65463370e95d65f196809455402bb68
[occt.git] / src / IGESDimen / IGESDimen_ToolSectionedArea.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
19 #include <gp_Pnt.hxx>
20 #include <gp_XYZ.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_HArray1OfIGESEntity.hxx>
24 #include <IGESData_IGESDumper.hxx>
25 #include <IGESData_IGESEntity.hxx>
26 #include <IGESData_IGESReaderData.hxx>
27 #include <IGESData_IGESWriter.hxx>
28 #include <IGESData_ParamCursor.hxx>
29 #include <IGESData_ParamReader.hxx>
30 #include <IGESDimen_SectionedArea.hxx>
31 #include <IGESDimen_ToolSectionedArea.hxx>
32 #include <Interface_Check.hxx>
33 #include <Interface_CopyTool.hxx>
34 #include <Interface_EntityIterator.hxx>
35 #include <Interface_Macros.hxx>
36 #include <Interface_ShareTool.hxx>
37 #include <Standard_DomainError.hxx>
38
39 IGESDimen_ToolSectionedArea::IGESDimen_ToolSectionedArea ()    {  }
40
41
42 void IGESDimen_ToolSectionedArea::ReadOwnParams
43   (const Handle(IGESDimen_SectionedArea)& ent,
44    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
45 {
46   Handle(IGESData_IGESEntity) extCurve;
47   Standard_Integer tempPattern, nbislands;
48   gp_XYZ passPnt;
49   Standard_Real tempDistance, tempAngle;
50   Handle(IGESData_HArray1OfIGESEntity) tempIslands;
51   Handle(IGESData_IGESEntity) anent;
52   //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
53
54   //szv#4:S4163:12Mar99 `st=` not needed
55   PR.ReadEntity(IR, PR.Current(), "Exterior curve", extCurve, (ent->FormNumber() == 1));
56   PR.ReadInteger(PR.Current(), "Fill pattern", tempPattern);
57   PR.ReadXYZ(PR.CurrentList(1, 3), "Passing point", passPnt);
58   PR.ReadReal(PR.Current(), "Distance between lines", tempDistance);
59
60   if (PR.DefinedElseSkip())
61     PR.ReadReal(PR.Current(), "Angle between line and X axis", tempAngle); //szv#4:S4163:12Mar99 `st=` not needed
62   else
63     tempAngle = M_PI / 4.0;
64
65   Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of island curves", nbislands);
66   if (st && nbislands > 0)
67     PR.ReadEnts (IR,PR.CurrentList(nbislands),"Island curves",tempIslands); //szv#4:S4163:12Mar99 `st=` not needed
68 /*
69     {
70       tempIslands = new IGESData_HArray1OfIGESEntity(1, nbislands);
71       for (Standard_Integer i=1; i<=nbislands; i++)
72         {
73           st = PR.ReadEntity(IR, PR.Current(), "Island curves", anent);
74           if (st) tempIslands->SetValue(i, anent);
75         }
76     }
77 */
78
79   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
80   ent->Init
81     (extCurve, tempPattern, passPnt, tempDistance, tempAngle, tempIslands);
82 }
83
84 void IGESDimen_ToolSectionedArea::WriteOwnParams
85   (const Handle(IGESDimen_SectionedArea)& ent, IGESData_IGESWriter& IW) const
86 {
87   Standard_Integer i, length = ent->NbIslands();
88   IW.Send(ent->ExteriorCurve());
89   IW.Send(ent->Pattern());
90   IW.Send(ent->PassingPoint().X());
91   IW.Send(ent->PassingPoint().Y());
92   IW.Send(ent->PassingPoint().Z());
93   IW.Send(ent->Distance());
94   IW.Send(ent->Angle());
95   IW.Send(length);
96   for (i = 1; i <= length; i ++)
97     IW.Send(ent->IslandCurve(i));
98 }
99
100 void  IGESDimen_ToolSectionedArea::OwnShared
101   (const Handle(IGESDimen_SectionedArea)& ent, Interface_EntityIterator& iter) const
102 {
103   Standard_Integer i, length = ent->NbIslands();
104   iter.GetOneItem(ent->ExteriorCurve());
105   for (i = 1; i <= length; i ++)
106     iter.GetOneItem(ent->IslandCurve(i));
107 }
108
109 void IGESDimen_ToolSectionedArea::OwnCopy
110   (const Handle(IGESDimen_SectionedArea)& another,
111    const Handle(IGESDimen_SectionedArea)& ent, Interface_CopyTool& TC) const
112 {
113   DeclareAndCast(IGESData_IGESEntity, extCurve,
114                  TC.Transferred(another->ExteriorCurve()));
115   Standard_Integer tempPattern = another->Pattern();
116   gp_XYZ passPnt = (another->PassingPoint()).XYZ();
117   Standard_Real tempDistance = another->Distance();
118   Standard_Real tempAngle = another->Angle();
119   Handle(IGESData_HArray1OfIGESEntity) tempIslands;
120   Standard_Integer nbislands = another->NbIslands();
121   if (nbislands > 0)
122     {
123       tempIslands = new IGESData_HArray1OfIGESEntity(1, nbislands);
124       for (Standard_Integer i=1; i<=nbislands; i++)
125         {
126           DeclareAndCast(IGESData_IGESEntity, anent,
127                          TC.Transferred(another->IslandCurve(i)));
128           tempIslands->SetValue(i, anent);
129         }
130     }
131   ent->Init(extCurve, tempPattern, passPnt,
132             tempDistance, tempAngle, tempIslands);
133   ent->SetInverted (another->IsInverted());
134 }
135
136 IGESData_DirChecker IGESDimen_ToolSectionedArea::DirChecker
137   (const Handle(IGESDimen_SectionedArea)& /* ent */ ) const
138 {
139   IGESData_DirChecker DC(230, 0,1);
140   DC.Structure(IGESData_DefVoid);
141   DC.LineFont(IGESData_DefAny);
142   DC.LineWeight(IGESData_DefValue);
143   DC.Color(IGESData_DefAny);
144
145   DC.UseFlagRequired (1);
146
147   return DC;
148 }
149
150 void IGESDimen_ToolSectionedArea::OwnCheck
151   (const Handle(IGESDimen_SectionedArea)& /* ent */,
152    const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
153 {
154 }
155
156 void IGESDimen_ToolSectionedArea::OwnDump
157   (const Handle(IGESDimen_SectionedArea)& ent, const IGESData_IGESDumper& dumper,
158    Standard_OStream& S, const Standard_Integer level) const
159 {
160   Standard_Integer sublevel = (level <= 4) ? 0 : 1;
161
162   S << "IGESDimen_SectionedArea\n"
163     << (ent->IsInverted() ? "Inverted Cross Hatches" : "Standard Cross Hatches")
164     << " - Exterior curve : ";
165   dumper.Dump(ent->ExteriorCurve(),S, sublevel);
166   S << "\n"
167     << "Fill pattern code : " << ent->Pattern() << "\n"
168     << "Passing point : ";
169   IGESData_DumpXYZL(S,level, ent->PassingPoint(), ent->Location());  S << "\n";
170   S << "Distance between lines : " << ent->Distance() << "\n"
171     << "Angle between lines and X axis : " << ent->Angle() << "\n"
172     << "Island Curve : ";
173   IGESData_DumpEntities(S,dumper ,level,1, ent->NbIslands(),ent->IslandCurve);
174   S << "\n";
175 }