summaryrefslogtreecommitdiff
path: root/src/IGESSolid/IGESSolid_ToolSolidAssembly.cxx
blob: 4084da92829d118f62ace9f93345ac1e6b1e5e4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//--------------------------------------------------------------------
//
//  File Name : IGESSolid_SolidAssembly.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESSolid_ToolSolidAssembly.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESGeom_TransformationMatrix.hxx>
#include <IGESData_HArray1OfIGESEntity.hxx>
#include <IGESGeom_HArray1OfTransformationMatrix.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESSolid_ToolSolidAssembly::IGESSolid_ToolSolidAssembly ()    {  }


void  IGESSolid_ToolSolidAssembly::ReadOwnParams
  (const Handle(IGESSolid_SolidAssembly)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
  //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
  Standard_Integer nbitems; //szv#4:S4163:12Mar99 `i` moved in for
  //Handle(IGESData_IGESEntity) anent; //szv#4:S4163:12Mar99 moved down
  //Handle(IGESGeom_TransformationMatrix) amatr; //szv#4:S4163:12Mar99 moved down
  Handle(IGESData_HArray1OfIGESEntity) tempItems;
  Handle(IGESGeom_HArray1OfTransformationMatrix) tempMatrices;

  Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Items", nbitems);
  if (st && nbitems > 0)
    {
      tempItems = new IGESData_HArray1OfIGESEntity(1, nbitems);
      tempMatrices = new IGESGeom_HArray1OfTransformationMatrix(1, nbitems);

      Handle(IGESData_IGESEntity) anent;
      Standard_Integer i; // svv Jan 10 2000 : porting on DEC
      for (i = 1; i <= nbitems; i++)
	{
          //st = PR.ReadEntity(IR,PR.Current(), "Solid assembly items", anent); //szv#4:S4163:12Mar99 moved in if
	  if (PR.ReadEntity(IR,PR.Current(), "Solid assembly items", anent))
	    tempItems->SetValue(i, anent);
	}

      Handle(IGESGeom_TransformationMatrix) amatr;
      for (i = 1; i <= nbitems; i++)
	{
          //st = PR.ReadEntity(IR,PR.Current(), "Matrices",
			     //STANDARD_TYPE(IGESGeom_TransformationMatrix),
			     //amatr, Standard_True); //szv#4:S4163:12Mar99 moved in if
          if (PR.ReadEntity(IR,PR.Current(), "Matrices",
			    STANDARD_TYPE(IGESGeom_TransformationMatrix), amatr, Standard_True))
	    tempMatrices->SetValue(i, amatr);
	}
    }
  else  PR.AddFail("Number of Items : Not Positive");

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init (tempItems, tempMatrices);
}

void  IGESSolid_ToolSolidAssembly::WriteOwnParams
  (const Handle(IGESSolid_SolidAssembly)& ent, IGESData_IGESWriter& IW) const
{
  Standard_Integer nbitems = ent->NbItems();
  Standard_Integer i;

  IW.Send(nbitems);
  for (i = 1; i <= nbitems; i ++)
    IW.Send(ent->Item(i));
  for (i = 1; i <= nbitems; i ++)
    IW.Send(ent->TransfMatrix(i));
}

void  IGESSolid_ToolSolidAssembly::OwnShared
  (const Handle(IGESSolid_SolidAssembly)& ent, Interface_EntityIterator& iter) const
{
  Standard_Integer nbitems = ent->NbItems();
  Standard_Integer i;
  for (i = 1; i <= nbitems; i ++)    iter.GetOneItem(ent->Item(i));
  for (i = 1; i <= nbitems; i ++)    iter.GetOneItem(ent->TransfMatrix(i));
}

void  IGESSolid_ToolSolidAssembly::OwnCopy
  (const Handle(IGESSolid_SolidAssembly)& another,
   const Handle(IGESSolid_SolidAssembly)& ent, Interface_CopyTool& TC) const
{
  Standard_Integer nbitems, i;
  Handle(IGESData_IGESEntity) anent;

  nbitems = another->NbItems();
  Handle(IGESData_HArray1OfIGESEntity) tempItems = new
    IGESData_HArray1OfIGESEntity(1, nbitems);
  Handle(IGESGeom_HArray1OfTransformationMatrix) tempMatrices = new
    IGESGeom_HArray1OfTransformationMatrix(1, nbitems);

  for (i=1; i<=nbitems; i++)
    {
      DeclareAndCast(IGESData_IGESEntity, localent,
		     TC.Transferred(another->Item(i)));
      tempItems->SetValue(i, localent);
    }
  for (i=1; i<=nbitems; i++)
    {
      DeclareAndCast(IGESGeom_TransformationMatrix, newlocalent,
		     TC.Transferred(another->TransfMatrix(i)));
      tempMatrices->SetValue(i, newlocalent);
    }

  ent->Init(tempItems, tempMatrices);
}

IGESData_DirChecker  IGESSolid_ToolSolidAssembly::DirChecker
  (const Handle(IGESSolid_SolidAssembly)& /* ent */ ) const
{
  IGESData_DirChecker DC(184, 0,1);

  DC.Structure  (IGESData_DefVoid);
  DC.LineFont   (IGESData_DefAny);
  DC.Color      (IGESData_DefAny);

  DC.UseFlagRequired (2);
  DC.GraphicsIgnored (1);
  return DC;
}

void  IGESSolid_ToolSolidAssembly::OwnCheck
  (const Handle(IGESSolid_SolidAssembly)& /* ent */,
   const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
{
}

void  IGESSolid_ToolSolidAssembly::OwnDump
  (const Handle(IGESSolid_SolidAssembly)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level) const
{
//  Standard_Integer upper = ent->NbItems();

  S << "IGESSolid_SolidAssembly" << endl;

  S << "Items : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbItems(),ent->Item);
  S << endl;
  S << "Matrices : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbItems(),ent->TransfMatrix);
  S << endl;
}