1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
20 //--------------------------------------------------------------------
21 //--------------------------------------------------------------------
23 #include <IGESGeom_ToolTrimmedSurface.ixx>
24 #include <IGESData_ParamCursor.hxx>
25 #include <IGESData_IGESEntity.hxx>
26 #include <IGESGeom_CurveOnSurface.hxx>
27 #include <IGESGeom_HArray1OfCurveOnSurface.hxx>
28 #include <IGESData_Dump.hxx>
29 #include <Interface_Macros.hxx>
32 #include <Message_Msg.hxx>
33 #include <IGESData_Status.hxx>
35 //=======================================================================
36 //function : IGESGeom_ToolTrimmedSurface
38 //=======================================================================
40 IGESGeom_ToolTrimmedSurface::IGESGeom_ToolTrimmedSurface ()
45 //=======================================================================
46 //function : ReadOwnParams
48 //=======================================================================
50 void IGESGeom_ToolTrimmedSurface::ReadOwnParams
51 (const Handle(IGESGeom_TrimmedSurface)& ent,
52 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
55 // Building of messages
56 //========================================
57 //========================================
59 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
60 Standard_Integer aFlag;
61 Standard_Integer count;
62 Handle(IGESData_IGESEntity) aSurface;
63 Handle(IGESGeom_CurveOnSurface) anOuter;
64 Handle(IGESGeom_HArray1OfCurveOnSurface) anInner;
65 IGESData_Status aStatus;
67 //szv#4:S4163:12Mar99 `st=` not needed
68 if (!PR.ReadEntity(IR, PR.Current(), aStatus, aSurface)){
69 Message_Msg Msg169("XSTEP_169");
71 case IGESData_ReferenceError: {
72 Message_Msg Msg216 ("IGES_216");
73 Msg169.Arg(Msg216.Value());
76 case IGESData_EntityError: {
77 Message_Msg Msg217 ("IGES_217");
78 Msg169.Arg(Msg217.Value());
85 if (!PR.ReadInteger(PR.Current(), aFlag)){
86 Message_Msg Msg170("XSTEP_170");
89 //st = PR.ReadInteger(PR.Current(), Msg171, count); //szv#4:S4163:12Mar99 moved in if
92 st = PR.ReadEntity(IR, PR.Current(), "Surface to be trimmed", aSurface);
93 st = PR.ReadInteger(PR.Current(), "Outer boundary type", aFlag);
94 st = PR.ReadInteger(PR.Current(), "Number of inner boundary closed curves", count);
96 if (PR.ReadInteger(PR.Current(), count)) {
98 Message_Msg Msg171("XSTEP_171");
101 else if (count > 0) anInner =
102 new IGESGeom_HArray1OfCurveOnSurface(1, count);
105 Message_Msg Msg171("XSTEP_171");
109 if (!PR.ReadEntity(IR, PR.Current(), aStatus,
110 STANDARD_TYPE(IGESGeom_CurveOnSurface), anOuter,Standard_True)){
111 Message_Msg Msg172("XSTEP_172");
113 case IGESData_ReferenceError: {
114 Message_Msg Msg216 ("IGES_216");
115 Msg172.Arg(Msg216.Value());
118 case IGESData_EntityError: {
119 Message_Msg Msg217 ("IGES_217");
120 Msg172.Arg(Msg217.Value());
123 case IGESData_TypeError: {
124 Message_Msg Msg218 ("IGES_218");
125 Msg172.Arg(Msg218.Value());
131 } //szv#4:S4163:12Mar99 `st=` not needed
132 /* st = PR.ReadEntity(IR, PR.Current(), "Outer boundary curve",
133 STANDARD_TYPE(IGESGeom_CurveOnSurface), anOuter,Standard_True);
135 if (! anInner.IsNull()) {
137 for (I = 1; I <= count; I++ ) {
138 Handle(IGESGeom_CurveOnSurface) tempEnt;
139 //st = PR.ReadEntity(IR, PR.Current(), Msg173,
140 //STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt); //szv#4:S4163:12Mar99 moved in if
141 /* st = PR.ReadEntity(IR, PR.Current(), "Inner boundary curves",
142 STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt);
144 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt))
145 anInner->SetValue(I, tempEnt);
147 Message_Msg Msg173("XSTEP_173");
149 case IGESData_ReferenceError: {
150 Message_Msg Msg216 ("IGES_216");
151 Msg173.Arg(Msg216.Value());
154 case IGESData_EntityError: {
155 Message_Msg Msg217 ("IGES_217");
156 Msg173.Arg(Msg217.Value());
159 case IGESData_TypeError: {
160 Message_Msg Msg218 ("IGES_218");
161 Msg173.Arg(Msg218.Value());
171 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
172 ent->Init(aSurface, aFlag, anOuter, anInner);
176 //=======================================================================
177 //function : WriteOwnParams
179 //=======================================================================
181 void IGESGeom_ToolTrimmedSurface::WriteOwnParams
182 (const Handle(IGESGeom_TrimmedSurface)& ent, IGESData_IGESWriter& IW) const
184 Standard_Integer up = ent->NbInnerContours();
185 IW.Send(ent->Surface());
186 IW.Send(ent->OuterBoundaryType());
189 if (ent->OuterBoundaryType())
190 IW.Send(ent->OuterContour());
194 for (I = 1; I <= up; I ++)
195 IW.Send(ent->InnerContour(I));
199 //=======================================================================
200 //function : OwnShared
202 //=======================================================================
204 void IGESGeom_ToolTrimmedSurface::OwnShared(const Handle(IGESGeom_TrimmedSurface)& ent,
205 Interface_EntityIterator& iter) const
207 Standard_Integer up = ent->NbInnerContours();
208 iter.GetOneItem(ent->Surface());
209 iter.GetOneItem(ent->OuterContour());
211 for (I = 1; I <= up; I ++) iter.GetOneItem(ent->InnerContour(I));
215 //=======================================================================
218 //=======================================================================
220 void IGESGeom_ToolTrimmedSurface::OwnCopy(const Handle(IGESGeom_TrimmedSurface)& another,
221 const Handle(IGESGeom_TrimmedSurface)& ent,
222 Interface_CopyTool& TC) const
224 Handle(IGESGeom_HArray1OfCurveOnSurface) anInner;
226 DeclareAndCast(IGESData_IGESEntity, aSurface,
227 TC.Transferred(another->Surface()));
228 Standard_Integer aFlag = another->OuterBoundaryType();
229 DeclareAndCast(IGESGeom_CurveOnSurface, anOuter,
230 TC.Transferred(another->OuterContour()));
231 Standard_Integer count = another->NbInnerContours();
234 anInner = new IGESGeom_HArray1OfCurveOnSurface(1, count);
236 for (I = 1; I <= count; I++) {
237 DeclareAndCast(IGESGeom_CurveOnSurface, temp,
238 TC.Transferred(another->InnerContour(I)));
239 anInner->SetValue(I, temp);
243 ent->Init(aSurface, aFlag, anOuter, anInner);
247 //=======================================================================
248 //function : DirChecker
250 //=======================================================================
252 IGESData_DirChecker IGESGeom_ToolTrimmedSurface::DirChecker
253 (const Handle(IGESGeom_TrimmedSurface)& /* ent */ ) const
255 IGESData_DirChecker DC(144, 0);
256 DC.Structure(IGESData_DefVoid);
257 DC.LineFont(IGESData_DefAny);
258 // DC.LineWeight(IGESData_DefValue);
259 DC.Color(IGESData_DefAny);
260 DC.UseFlagRequired (0);
261 DC.HierarchyStatusIgnored();
267 //=======================================================================
268 //function : OwnCheck
270 //=======================================================================
272 void IGESGeom_ToolTrimmedSurface::OwnCheck(const Handle(IGESGeom_TrimmedSurface)& ent,
273 const Interface_ShareTool&,
274 Handle(Interface_Check)& ach) const
277 // Building of messages
278 //========================================
279 //Message_Msg Msg172("XSTEP_172");
280 //========================================
282 if (ent->OuterBoundaryType() != 0 && ent->OuterBoundaryType() != 1) {
283 Message_Msg Msg172("XSTEP_172");
284 ach->SendFail(Msg172);
289 //=======================================================================
292 //=======================================================================
294 void IGESGeom_ToolTrimmedSurface::OwnDump(const Handle(IGESGeom_TrimmedSurface)& ent,
295 const IGESData_IGESDumper& dumper,
296 const Handle(Message_Messenger)& S,
297 const Standard_Integer level) const
299 Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;
301 S << "IGESGeom_TrimmedSurface" << endl;
303 S << "Surface to be trimmed : ";
304 dumper.Dump(ent->Surface(),S, tempSubLevel);
306 S << "Boundary type : " << ent->OuterBoundaryType() << endl;
307 S << "Outer Boundary : ";
308 dumper.Dump(ent->OuterContour(),S, tempSubLevel);
310 S << "Inner Boundaries : ";
311 IGESData_DumpEntities(S,dumper ,level,1, ent->NbInnerContours(),ent->InnerContour);