summaryrefslogtreecommitdiff
path: root/src/IGESDraw/IGESDraw_ToolPlanar.cxx
blob: 83c30f11d68f816824d2081564a7859357c4378b (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//--------------------------------------------------------------------
//
//  File Name : IGESDraw_Planar.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

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


IGESDraw_ToolPlanar::IGESDraw_ToolPlanar ()    {  }


void IGESDraw_ToolPlanar::ReadOwnParams
  (const Handle(IGESDraw_Planar)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{ 
  Standard_Boolean                          st;
  Standard_Integer                          nbval;

  Standard_Integer                          nbMatrices; 
  Handle(IGESGeom_TransformationMatrix)     transformationMatrix; 
  Handle(IGESData_HArray1OfIGESEntity) entities; 

  // Reading nbMatrices(Integer)
  st = PR.ReadInteger(PR.Current(), "No. of Transformation matrices", nbMatrices);
  if ( nbMatrices != 1 )
    PR.AddFail("No. of Transformation matrices != 1");

  // Reading nbval(Integer)
  st = PR.ReadInteger(PR.Current(), "No. of Entities in this plane", nbval);
  if (!st) nbval = 0; //szv#4:S4163:12Mar99 was bug: `nbval == 0`
  if (nbval <= 0) PR.AddFail ("No. of Entities in this plane : Not Positive");

  // Reading transformationMatrix(Instance of TransformationMatrix or Null)
  st = PR.ReadEntity(IR,PR.Current(), "Instance of TransformationMatrix",
		     STANDARD_TYPE(IGESGeom_TransformationMatrix), transformationMatrix,
		     Standard_True);

  if (nbval > 0)
    st = PR.ReadEnts (IR, PR.CurrentList(nbval), "Planar Entities", entities);
/*
    {
      entities = new IGESData_HArray1OfIGESEntity(1, nbval);
      // Reading entities(HArray1OfIGESEntity)
      Handle(IGESData_IGESEntity) tempEntity;
      for (Standard_Integer i = 1; i <= nbval; i++)
	{
          st = PR.ReadEntity(IR, PR.Current(), "Plane entity", tempEntity);
	  if (st) entities->SetValue(i, tempEntity);
	}
    }
*/

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(nbMatrices,transformationMatrix, entities);
}

void IGESDraw_ToolPlanar::WriteOwnParams
  (const Handle(IGESDraw_Planar)& ent, IGESData_IGESWriter& IW)  const
{ 
  Standard_Integer Up  = ent->NbEntities();
  IW.Send( ent->NbMatrices() );
  IW.Send( Up );

  IW.Send( ent->TransformMatrix() );

  for ( Standard_Integer i = 1; i <= Up; i++)
    IW.Send( ent->Entity(i) );
}

void  IGESDraw_ToolPlanar::OwnShared
  (const Handle(IGESDraw_Planar)& ent, Interface_EntityIterator& iter) const
{
  Standard_Integer Up  = ent->NbEntities();
  iter.GetOneItem( ent->TransformMatrix() );
  for ( Standard_Integer i = 1; i <= Up; i++)
    iter.GetOneItem( ent->Entity(i) );
}

void IGESDraw_ToolPlanar::OwnCopy
  (const Handle(IGESDraw_Planar)& another,
   const Handle(IGESDraw_Planar)& ent, Interface_CopyTool& TC) const
{
  Standard_Integer                          nbval;
  Standard_Integer                          nbMatrices; 
  Handle(IGESData_HArray1OfIGESEntity) entities; 
 
  nbval                = another->NbEntities();
  nbMatrices           = another->NbMatrices();
  DeclareAndCast(IGESGeom_TransformationMatrix, transformationMatrix, 
                 TC.Transferred(another->TransformMatrix()));

  entities = new IGESData_HArray1OfIGESEntity(1, nbval);
  for (Standard_Integer i = 1; i <= nbval; i++)
    {
      DeclareAndCast(IGESData_IGESEntity, tempEntity, 
                     TC.Transferred(another->Entity(i)));
      entities->SetValue( i, tempEntity );
    }

  ent->Init(nbMatrices, transformationMatrix, entities);
}

Standard_Boolean  IGESDraw_ToolPlanar::OwnCorrect
  (const Handle(IGESDraw_Planar)& ent) const
{
  if (ent->NbMatrices() == 1) return Standard_False;
//  Forcer NbMNatrices a 1 -> Reconstruire
  Standard_Integer nb = ent->NbEntities();
  Handle(IGESData_HArray1OfIGESEntity) ents =
    new IGESData_HArray1OfIGESEntity(1,nb);
  for (Standard_Integer i = 1; i <= nb; i ++)
    ents->SetValue(i,ent->Entity(i));
  ent->Init (1,ent->TransformMatrix(),ents);
  return Standard_True;
}

IGESData_DirChecker IGESDraw_ToolPlanar::DirChecker
  (const Handle(IGESDraw_Planar)& /*ent*/)  const
{ 
  IGESData_DirChecker DC (402, 16);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefVoid);
  DC.LineWeight(IGESData_DefVoid);
  DC.Color(IGESData_DefVoid);
  DC.BlankStatusIgnored();
  DC.UseFlagRequired(5);
  DC.HierarchyStatusIgnored();
  return DC;
}

void IGESDraw_ToolPlanar::OwnCheck
  (const Handle(IGESDraw_Planar)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
{
  if ( ent->NbMatrices() != 1 )
    ach->AddFail("No. of Transformation matrices : Value != 1");
}

void IGESDraw_ToolPlanar::OwnDump
  (const Handle(IGESDraw_Planar)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level)  const
{
  Standard_Integer sublevel = (level <= 4) ? 0 : 1;

  S << "IGESDraw_Planar" << endl;

  S << "No. of Transformation Matrices : " << ent->NbMatrices() << "  ";
  S << "i.e. : ";
  if ( ent->TransformMatrix().IsNull() )
    S << "Null Handle";
  else
    dumper.OwnDump (ent->TransformMatrix(),S, sublevel);
  S << endl;
  S << "Array of Entities on the specified plane : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbEntities(),ent->Entity);
  S << endl;
}