0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / IGESBasic / IGESBasic_ToolSingleParent.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 <IGESBasic_ToolSingleParent.ixx>
20 #include <IGESData_ParamCursor.hxx>
21 #include <IGESData_IGESEntity.hxx>
22 #include <IGESData_HArray1OfIGESEntity.hxx>
23 #include <IGESData_Dump.hxx>
24 #include <Interface_Macros.hxx>
25
26 // MGE 03/08/98
27 #include <Message_Msg.hxx>
28 #include <IGESData_Status.hxx>
29
30
31 IGESBasic_ToolSingleParent::IGESBasic_ToolSingleParent ()    {  }
32
33
34 void  IGESBasic_ToolSingleParent::ReadOwnParams
35   (const Handle(IGESBasic_SingleParent)& ent,
36    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
37 {
38   // MGE 03/08/98
39   // Building of messages
40   //========================================
41   Message_Msg Msg207("XSTEP_207");
42   //========================================
43
44   Standard_Integer tempNbParentEntities;
45   Handle(IGESData_IGESEntity) tempParent;
46   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
47   Standard_Integer nbval = 0;
48   Handle(IGESData_HArray1OfIGESEntity)  tempChildren;
49   IGESData_Status aStatus;
50
51   if(!PR.ReadInteger (PR.Current(),tempNbParentEntities)){ //szv#4:S4163:12Mar99 `st=` not needed
52     Message_Msg Msg204("XSTEP_204");
53     PR.SendFail(Msg204);
54   }
55   //st = PR.ReadInteger(PR.Current(), Msg205, nbval); //szv#4:S4163:12Mar99 moved down
56
57 //  st = PR.ReadInteger (PR.Current(),"Number of Parent entities",tempNbParentEntities);
58 //  st = PR.ReadInteger(PR.Current(), "Count of Children", nbval);
59   if (!PR.ReadInteger(PR.Current(), nbval)){
60     Message_Msg Msg205("XSTEP_205");
61     PR.SendFail(Msg205);
62     nbval = -1;
63   }
64   if (!PR.ReadEntity(IR,PR.Current(),aStatus,tempParent)){ //szv#4:S4163:12Mar99 `st=` not needed
65   //st = PR.ReadEntity(IR,PR.Current(),"ParentEntity",tempParent);
66     Message_Msg Msg206("XSTEP_206");
67     switch(aStatus) {
68     case IGESData_ReferenceError: {  
69       Message_Msg Msg216 ("IGES_216");
70       Msg206.Arg(Msg216.Value());
71       PR.SendFail(Msg206);
72       break; }
73     case IGESData_EntityError: {
74       Message_Msg Msg217 ("IGES_217");
75       Msg206.Arg(Msg217.Value());
76       PR.SendFail(Msg206);
77       break; }
78     default:{
79     }
80     }
81   }
82
83   if (nbval > 0) PR.ReadEnts (IR,PR.CurrentList(nbval),Msg207,tempChildren); //szv#4:S4163:12Mar99 `st=` not needed
84   //st = PR.ReadEnts (IR,PR.CurrentList(nbval),"Child Entities",tempChildren);
85   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
86   ent->Init(tempNbParentEntities,tempParent,tempChildren);
87 }
88
89 void  IGESBasic_ToolSingleParent::WriteOwnParams
90   (const Handle(IGESBasic_SingleParent)& ent, IGESData_IGESWriter& IW) const
91 {
92   Standard_Integer upper = ent->NbChildren();
93   IW.Send(ent->NbParentEntities());
94   IW.Send(upper);
95   IW.Send(ent->SingleParent());
96   for (Standard_Integer i = 1; i <= upper; i ++)
97     IW.Send(ent->Child(i));
98 }
99
100 void  IGESBasic_ToolSingleParent::OwnShared
101   (const Handle(IGESBasic_SingleParent)& ent, Interface_EntityIterator& iter) const
102 {
103   iter.GetOneItem(ent->SingleParent());
104   Standard_Integer upper = ent->NbChildren();
105   for (Standard_Integer i = 1; i <= upper; i ++)
106     iter.GetOneItem(ent->Child(i));
107 }
108
109 void  IGESBasic_ToolSingleParent::OwnCopy
110   (const Handle(IGESBasic_SingleParent)& another,
111    const Handle(IGESBasic_SingleParent)& ent, Interface_CopyTool& TC) const
112 {
113   Standard_Integer aNbParentEntities = another->NbParentEntities();
114   DeclareAndCast(IGESData_IGESEntity,aparent,
115                  TC.Transferred(another->SingleParent()));
116   Standard_Integer upper = another->NbChildren();
117   Handle(IGESData_HArray1OfIGESEntity)  EntArray = new
118     IGESData_HArray1OfIGESEntity(1,upper);
119   for (Standard_Integer i = 1; i <= upper; i ++)
120     {
121       DeclareAndCast
122         (IGESData_IGESEntity,myentity,TC.Transferred(another->Child(i)));
123       EntArray->SetValue(i,myentity);
124     }
125   ent->Init(aNbParentEntities,aparent,EntArray);
126 }
127
128 Standard_Boolean  IGESBasic_ToolSingleParent::OwnCorrect
129   (const Handle(IGESBasic_SingleParent)& ent) const
130 {
131   if (ent->NbParentEntities() == 1) return Standard_False;
132   Standard_Integer nb = ent->NbChildren();
133   Handle(IGESData_HArray1OfIGESEntity)  EntArray = new
134     IGESData_HArray1OfIGESEntity (1,nb);
135   for (Standard_Integer i = 1; i <= nb; i ++)
136     EntArray->SetValue(i,ent->Child(i));
137   ent->Init (1,ent->SingleParent(),EntArray);
138   return Standard_True;    // nbparents = 1
139 }
140
141 IGESData_DirChecker  IGESBasic_ToolSingleParent::DirChecker
142   (const Handle(IGESBasic_SingleParent)& /* ent */ ) const
143 {
144   IGESData_DirChecker DC(402,9);  //Form no = 9 & Type = 402
145   DC.Structure(IGESData_DefVoid);
146   DC.GraphicsIgnored();
147   DC.BlankStatusIgnored();
148   DC.HierarchyStatusIgnored();
149   return DC;
150 }
151
152 void  IGESBasic_ToolSingleParent::OwnCheck
153   (const Handle(IGESBasic_SingleParent)& ent,
154    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
155 {
156    // MGE 03/08/98
157   // Building of messages
158   //========================================
159 //  Message_Msg Msg204("XSTEP_204");
160   //========================================
161   if (ent->NbParentEntities() != 1){
162     Message_Msg Msg204("XSTEP_204");
163     ach->SendFail(Msg204);
164   }
165 }
166
167 void  IGESBasic_ToolSingleParent::OwnDump
168   (const Handle(IGESBasic_SingleParent)& ent, const IGESData_IGESDumper& dumper,
169    const Handle(Message_Messenger)& S, const Standard_Integer level) const
170 {
171   S << "IGESBasic_SingleParent" << endl;
172
173   S << "Number of ParentEntities : " << ent->NbParentEntities() << endl;
174   S << "ParentEntity : ";
175   dumper.Dump(ent->SingleParent(),S,(level <= 4) ? 0 : 1);
176   S << endl;
177   S << "Children : ";
178   IGESData_DumpEntities(S,dumper ,level,1, ent->NbChildren(),ent->Child);
179   S << endl;
180 }