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 //--------------------------------------------------------------------
19 #include <IGESData_DirChecker.hxx>
20 #include <IGESData_Dump.hxx>
21 #include <IGESData_IGESDumper.hxx>
22 #include <IGESData_IGESEntity.hxx>
23 #include <IGESData_IGESReaderData.hxx>
24 #include <IGESData_IGESWriter.hxx>
25 #include <IGESData_ParamCursor.hxx>
26 #include <IGESData_ParamReader.hxx>
27 #include <IGESData_Status.hxx>
28 #include <IGESGeom_CurveOnSurface.hxx>
29 #include <IGESGeom_HArray1OfCurveOnSurface.hxx>
30 #include <IGESGeom_ToolTrimmedSurface.hxx>
31 #include <IGESGeom_TrimmedSurface.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 <Message_Messenger.hxx>
38 #include <Message_Msg.hxx>
39 #include <Standard_DomainError.hxx>
42 //=======================================================================
43 //function : IGESGeom_ToolTrimmedSurface
45 //=======================================================================
46 IGESGeom_ToolTrimmedSurface::IGESGeom_ToolTrimmedSurface ()
51 //=======================================================================
52 //function : ReadOwnParams
54 //=======================================================================
56 void IGESGeom_ToolTrimmedSurface::ReadOwnParams
57 (const Handle(IGESGeom_TrimmedSurface)& ent,
58 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
61 // Building of messages
62 //========================================
63 //========================================
65 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
66 Standard_Integer aFlag;
67 Standard_Integer count;
68 Handle(IGESData_IGESEntity) aSurface;
69 Handle(IGESGeom_CurveOnSurface) anOuter;
70 Handle(IGESGeom_HArray1OfCurveOnSurface) anInner;
71 IGESData_Status aStatus;
73 //szv#4:S4163:12Mar99 `st=` not needed
74 if (!PR.ReadEntity(IR, PR.Current(), aStatus, aSurface)){
75 Message_Msg Msg169("XSTEP_169");
77 case IGESData_ReferenceError: {
78 Message_Msg Msg216 ("IGES_216");
79 Msg169.Arg(Msg216.Value());
82 case IGESData_EntityError: {
83 Message_Msg Msg217 ("IGES_217");
84 Msg169.Arg(Msg217.Value());
91 if (!PR.ReadInteger(PR.Current(), aFlag)){
92 Message_Msg Msg170("XSTEP_170");
95 //st = PR.ReadInteger(PR.Current(), Msg171, count); //szv#4:S4163:12Mar99 moved in if
98 st = PR.ReadEntity(IR, PR.Current(), "Surface to be trimmed", aSurface);
99 st = PR.ReadInteger(PR.Current(), "Outer boundary type", aFlag);
100 st = PR.ReadInteger(PR.Current(), "Number of inner boundary closed curves", count);
102 if (PR.ReadInteger(PR.Current(), count)) {
104 Message_Msg Msg171("XSTEP_171");
105 PR.SendFail (Msg171);
107 else if (count > 0) anInner =
108 new IGESGeom_HArray1OfCurveOnSurface(1, count);
111 Message_Msg Msg171("XSTEP_171");
115 if (!PR.ReadEntity(IR, PR.Current(), aStatus,
116 STANDARD_TYPE(IGESGeom_CurveOnSurface), anOuter,Standard_True)){
117 Message_Msg Msg172("XSTEP_172");
119 case IGESData_ReferenceError: {
120 Message_Msg Msg216 ("IGES_216");
121 Msg172.Arg(Msg216.Value());
124 case IGESData_EntityError: {
125 Message_Msg Msg217 ("IGES_217");
126 Msg172.Arg(Msg217.Value());
129 case IGESData_TypeError: {
130 Message_Msg Msg218 ("IGES_218");
131 Msg172.Arg(Msg218.Value());
137 } //szv#4:S4163:12Mar99 `st=` not needed
138 /* st = PR.ReadEntity(IR, PR.Current(), "Outer boundary curve",
139 STANDARD_TYPE(IGESGeom_CurveOnSurface), anOuter,Standard_True);
141 if (! anInner.IsNull()) {
143 for (I = 1; I <= count; I++ ) {
144 Handle(IGESGeom_CurveOnSurface) tempEnt;
145 //st = PR.ReadEntity(IR, PR.Current(), Msg173,
146 //STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt); //szv#4:S4163:12Mar99 moved in if
147 /* st = PR.ReadEntity(IR, PR.Current(), "Inner boundary curves",
148 STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt);
150 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt))
151 anInner->SetValue(I, tempEnt);
153 Message_Msg Msg173("XSTEP_173");
155 case IGESData_ReferenceError: {
156 Message_Msg Msg216 ("IGES_216");
157 Msg173.Arg(Msg216.Value());
160 case IGESData_EntityError: {
161 Message_Msg Msg217 ("IGES_217");
162 Msg173.Arg(Msg217.Value());
165 case IGESData_TypeError: {
166 Message_Msg Msg218 ("IGES_218");
167 Msg173.Arg(Msg218.Value());
177 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
178 ent->Init(aSurface, aFlag, anOuter, anInner);
182 //=======================================================================
183 //function : WriteOwnParams
185 //=======================================================================
187 void IGESGeom_ToolTrimmedSurface::WriteOwnParams
188 (const Handle(IGESGeom_TrimmedSurface)& ent, IGESData_IGESWriter& IW) const
190 Standard_Integer up = ent->NbInnerContours();
191 IW.Send(ent->Surface());
192 IW.Send(ent->OuterBoundaryType());
195 if (ent->OuterBoundaryType())
196 IW.Send(ent->OuterContour());
200 for (I = 1; I <= up; I ++)
201 IW.Send(ent->InnerContour(I));
205 //=======================================================================
206 //function : OwnShared
208 //=======================================================================
210 void IGESGeom_ToolTrimmedSurface::OwnShared(const Handle(IGESGeom_TrimmedSurface)& ent,
211 Interface_EntityIterator& iter) const
213 Standard_Integer up = ent->NbInnerContours();
214 iter.GetOneItem(ent->Surface());
215 iter.GetOneItem(ent->OuterContour());
217 for (I = 1; I <= up; I ++) iter.GetOneItem(ent->InnerContour(I));
221 //=======================================================================
224 //=======================================================================
226 void IGESGeom_ToolTrimmedSurface::OwnCopy(const Handle(IGESGeom_TrimmedSurface)& another,
227 const Handle(IGESGeom_TrimmedSurface)& ent,
228 Interface_CopyTool& TC) const
230 Handle(IGESGeom_HArray1OfCurveOnSurface) anInner;
232 DeclareAndCast(IGESData_IGESEntity, aSurface,
233 TC.Transferred(another->Surface()));
234 Standard_Integer aFlag = another->OuterBoundaryType();
235 DeclareAndCast(IGESGeom_CurveOnSurface, anOuter,
236 TC.Transferred(another->OuterContour()));
237 Standard_Integer count = another->NbInnerContours();
240 anInner = new IGESGeom_HArray1OfCurveOnSurface(1, count);
242 for (I = 1; I <= count; I++) {
243 DeclareAndCast(IGESGeom_CurveOnSurface, temp,
244 TC.Transferred(another->InnerContour(I)));
245 anInner->SetValue(I, temp);
249 ent->Init(aSurface, aFlag, anOuter, anInner);
253 //=======================================================================
254 //function : DirChecker
256 //=======================================================================
258 IGESData_DirChecker IGESGeom_ToolTrimmedSurface::DirChecker
259 (const Handle(IGESGeom_TrimmedSurface)& /* ent */ ) const
261 IGESData_DirChecker DC(144, 0);
262 DC.Structure(IGESData_DefVoid);
263 DC.LineFont(IGESData_DefAny);
264 // DC.LineWeight(IGESData_DefValue);
265 DC.Color(IGESData_DefAny);
266 DC.UseFlagRequired (0);
267 DC.HierarchyStatusIgnored();
273 //=======================================================================
274 //function : OwnCheck
276 //=======================================================================
278 void IGESGeom_ToolTrimmedSurface::OwnCheck(const Handle(IGESGeom_TrimmedSurface)& ent,
279 const Interface_ShareTool&,
280 Handle(Interface_Check)& ach) const
283 // Building of messages
284 //========================================
285 //Message_Msg Msg172("XSTEP_172");
286 //========================================
288 if (ent->OuterBoundaryType() != 0 && ent->OuterBoundaryType() != 1) {
289 Message_Msg Msg172("XSTEP_172");
290 ach->SendFail(Msg172);
295 //=======================================================================
298 //=======================================================================
300 void IGESGeom_ToolTrimmedSurface::OwnDump(const Handle(IGESGeom_TrimmedSurface)& ent,
301 const IGESData_IGESDumper& dumper,
302 const Handle(Message_Messenger)& S,
303 const Standard_Integer level) const
305 Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;
307 S << "IGESGeom_TrimmedSurface" << endl;
309 S << "Surface to be trimmed : ";
310 dumper.Dump(ent->Surface(),S, tempSubLevel);
312 S << "Boundary type : " << ent->OuterBoundaryType() << endl;
313 S << "Outer Boundary : ";
314 dumper.Dump(ent->OuterContour(),S, tempSubLevel);
316 S << "Inner Boundaries : ";
317 IGESData_DumpEntities(S,dumper ,level,1, ent->NbInnerContours(),ent->InnerContour);