0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[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_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>
35
36 IGESDimen_ToolSectionedArea::IGESDimen_ToolSectionedArea ()    {  }
37
38
39 void IGESDimen_ToolSectionedArea::ReadOwnParams
40   (const Handle(IGESDimen_SectionedArea)& ent,
41    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
42 {
43   Handle(IGESData_IGESEntity) extCurve;
44   Standard_Integer tempPattern, nbislands;
45   gp_XYZ passPnt;
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
50
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);
56
57   if (PR.DefinedElseSkip())
58     PR.ReadReal(PR.Current(), "Angle between line and X axis", tempAngle); //szv#4:S4163:12Mar99 `st=` not needed
59   else
60     tempAngle = M_PI / 4.0;
61
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
65 /*
66     {
67       tempIslands = new IGESData_HArray1OfIGESEntity(1, nbislands);
68       for (Standard_Integer i=1; i<=nbislands; i++)
69         {
70           st = PR.ReadEntity(IR, PR.Current(), "Island curves", anent);
71           if (st) tempIslands->SetValue(i, anent);
72         }
73     }
74 */
75
76   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
77   ent->Init
78     (extCurve, tempPattern, passPnt, tempDistance, tempAngle, tempIslands);
79 }
80
81 void IGESDimen_ToolSectionedArea::WriteOwnParams
82   (const Handle(IGESDimen_SectionedArea)& ent, IGESData_IGESWriter& IW) const
83 {
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());
92   IW.Send(length);
93   for (i = 1; i <= length; i ++)
94     IW.Send(ent->IslandCurve(i));
95 }
96
97 void  IGESDimen_ToolSectionedArea::OwnShared
98   (const Handle(IGESDimen_SectionedArea)& ent, Interface_EntityIterator& iter) const
99 {
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));
104 }
105
106 void IGESDimen_ToolSectionedArea::OwnCopy
107   (const Handle(IGESDimen_SectionedArea)& another,
108    const Handle(IGESDimen_SectionedArea)& ent, Interface_CopyTool& TC) const
109 {
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();
118   if (nbislands > 0)
119     {
120       tempIslands = new IGESData_HArray1OfIGESEntity(1, nbislands);
121       for (Standard_Integer i=1; i<=nbislands; i++)
122         {
123           DeclareAndCast(IGESData_IGESEntity, anent,
124                          TC.Transferred(another->IslandCurve(i)));
125           tempIslands->SetValue(i, anent);
126         }
127     }
128   ent->Init(extCurve, tempPattern, passPnt,
129             tempDistance, tempAngle, tempIslands);
130   ent->SetInverted (another->IsInverted());
131 }
132
133 IGESData_DirChecker IGESDimen_ToolSectionedArea::DirChecker
134   (const Handle(IGESDimen_SectionedArea)& /* ent */ ) const
135 {
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);
141
142   DC.UseFlagRequired (1);
143
144   return DC;
145 }
146
147 void IGESDimen_ToolSectionedArea::OwnCheck
148   (const Handle(IGESDimen_SectionedArea)& /* ent */,
149    const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
150 {
151 }
152
153 void IGESDimen_ToolSectionedArea::OwnDump
154   (const Handle(IGESDimen_SectionedArea)& ent, const IGESData_IGESDumper& dumper,
155    Standard_OStream& S, const Standard_Integer level) const
156 {
157   Standard_Integer sublevel = (level <= 4) ? 0 : 1;
158
159   S << "IGESDimen_SectionedArea\n"
160     << (ent->IsInverted() ? "Inverted Cross Hatches" : "Standard Cross Hatches")
161     << " - Exterior curve : ";
162   dumper.Dump(ent->ExteriorCurve(),S, sublevel);
163   S << "\n"
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);
171   S << "\n";
172 }