0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / IGESSolid / IGESSolid_ToolSolidAssembly.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 <IGESSolid_ToolSolidAssembly.ixx>
20 #include <IGESData_ParamCursor.hxx>
21 #include <IGESData_IGESEntity.hxx>
22 #include <IGESGeom_TransformationMatrix.hxx>
23 #include <IGESData_HArray1OfIGESEntity.hxx>
24 #include <IGESGeom_HArray1OfTransformationMatrix.hxx>
25 #include <IGESData_Dump.hxx>
26 #include <Interface_Macros.hxx>
27
28
29 IGESSolid_ToolSolidAssembly::IGESSolid_ToolSolidAssembly ()    {  }
30
31
32 void  IGESSolid_ToolSolidAssembly::ReadOwnParams
33   (const Handle(IGESSolid_SolidAssembly)& ent,
34    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
35 {
36   //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
37   Standard_Integer nbitems; //szv#4:S4163:12Mar99 `i` moved in for
38   //Handle(IGESData_IGESEntity) anent; //szv#4:S4163:12Mar99 moved down
39   //Handle(IGESGeom_TransformationMatrix) amatr; //szv#4:S4163:12Mar99 moved down
40   Handle(IGESData_HArray1OfIGESEntity) tempItems;
41   Handle(IGESGeom_HArray1OfTransformationMatrix) tempMatrices;
42
43   Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Items", nbitems);
44   if (st && nbitems > 0)
45     {
46       tempItems = new IGESData_HArray1OfIGESEntity(1, nbitems);
47       tempMatrices = new IGESGeom_HArray1OfTransformationMatrix(1, nbitems);
48
49       Handle(IGESData_IGESEntity) anent;
50       Standard_Integer i; // svv Jan 10 2000 : porting on DEC
51       for (i = 1; i <= nbitems; i++)
52         {
53           //st = PR.ReadEntity(IR,PR.Current(), "Solid assembly items", anent); //szv#4:S4163:12Mar99 moved in if
54           if (PR.ReadEntity(IR,PR.Current(), "Solid assembly items", anent))
55             tempItems->SetValue(i, anent);
56         }
57
58       Handle(IGESGeom_TransformationMatrix) amatr;
59       for (i = 1; i <= nbitems; i++)
60         {
61           //st = PR.ReadEntity(IR,PR.Current(), "Matrices",
62                              //STANDARD_TYPE(IGESGeom_TransformationMatrix),
63                              //amatr, Standard_True); //szv#4:S4163:12Mar99 moved in if
64           if (PR.ReadEntity(IR,PR.Current(), "Matrices",
65                             STANDARD_TYPE(IGESGeom_TransformationMatrix), amatr, Standard_True))
66             tempMatrices->SetValue(i, amatr);
67         }
68     }
69   else  PR.AddFail("Number of Items : Not Positive");
70
71   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
72   ent->Init (tempItems, tempMatrices);
73 }
74
75 void  IGESSolid_ToolSolidAssembly::WriteOwnParams
76   (const Handle(IGESSolid_SolidAssembly)& ent, IGESData_IGESWriter& IW) const
77 {
78   Standard_Integer nbitems = ent->NbItems();
79   Standard_Integer i;
80
81   IW.Send(nbitems);
82   for (i = 1; i <= nbitems; i ++)
83     IW.Send(ent->Item(i));
84   for (i = 1; i <= nbitems; i ++)
85     IW.Send(ent->TransfMatrix(i));
86 }
87
88 void  IGESSolid_ToolSolidAssembly::OwnShared
89   (const Handle(IGESSolid_SolidAssembly)& ent, Interface_EntityIterator& iter) const
90 {
91   Standard_Integer nbitems = ent->NbItems();
92   Standard_Integer i;
93   for (i = 1; i <= nbitems; i ++)    iter.GetOneItem(ent->Item(i));
94   for (i = 1; i <= nbitems; i ++)    iter.GetOneItem(ent->TransfMatrix(i));
95 }
96
97 void  IGESSolid_ToolSolidAssembly::OwnCopy
98   (const Handle(IGESSolid_SolidAssembly)& another,
99    const Handle(IGESSolid_SolidAssembly)& ent, Interface_CopyTool& TC) const
100 {
101   Standard_Integer nbitems, i;
102   Handle(IGESData_IGESEntity) anent;
103
104   nbitems = another->NbItems();
105   Handle(IGESData_HArray1OfIGESEntity) tempItems = new
106     IGESData_HArray1OfIGESEntity(1, nbitems);
107   Handle(IGESGeom_HArray1OfTransformationMatrix) tempMatrices = new
108     IGESGeom_HArray1OfTransformationMatrix(1, nbitems);
109
110   for (i=1; i<=nbitems; i++)
111     {
112       DeclareAndCast(IGESData_IGESEntity, localent,
113                      TC.Transferred(another->Item(i)));
114       tempItems->SetValue(i, localent);
115     }
116   for (i=1; i<=nbitems; i++)
117     {
118       DeclareAndCast(IGESGeom_TransformationMatrix, newlocalent,
119                      TC.Transferred(another->TransfMatrix(i)));
120       tempMatrices->SetValue(i, newlocalent);
121     }
122
123   ent->Init(tempItems, tempMatrices);
124 }
125
126 IGESData_DirChecker  IGESSolid_ToolSolidAssembly::DirChecker
127   (const Handle(IGESSolid_SolidAssembly)& /* ent */ ) const
128 {
129   IGESData_DirChecker DC(184, 0,1);
130
131   DC.Structure  (IGESData_DefVoid);
132   DC.LineFont   (IGESData_DefAny);
133   DC.Color      (IGESData_DefAny);
134
135   DC.UseFlagRequired (2);
136   DC.GraphicsIgnored (1);
137   return DC;
138 }
139
140 void  IGESSolid_ToolSolidAssembly::OwnCheck
141   (const Handle(IGESSolid_SolidAssembly)& /* ent */,
142    const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
143 {
144 }
145
146 void  IGESSolid_ToolSolidAssembly::OwnDump
147   (const Handle(IGESSolid_SolidAssembly)& ent, const IGESData_IGESDumper& dumper,
148    const Handle(Message_Messenger)& S, const Standard_Integer level) const
149 {
150 //  Standard_Integer upper = ent->NbItems();
151
152   S << "IGESSolid_SolidAssembly" << endl;
153
154   S << "Items : ";
155   IGESData_DumpEntities(S,dumper ,level,1, ent->NbItems(),ent->Item);
156   S << endl;
157   S << "Matrices : ";
158   IGESData_DumpEntities(S,dumper ,level,1, ent->NbItems(),ent->TransfMatrix);
159   S << endl;
160 }