summaryrefslogtreecommitdiff
path: root/src/IGESData/IGESData_FreeFormatEntity.cxx
blob: 33e733d30dbc60ae240038792d83e5e9649b79c5 (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
#include <IGESData_FreeFormatEntity.ixx>
#include <Interface_UndefinedContent.hxx>
#include <Interface_InterfaceError.hxx>
#include <IGESData_IGESEntity.hxx>
#include <TCollection_HAsciiString.hxx>
#include <Interface_Macros.hxx>



//  Donne un acces simple a la constitution d une UndefinedEntity :
//  Methodes de UndefinedContent, + Type & Form, + AddEntities (little gadget)


    IGESData_FreeFormatEntity::IGESData_FreeFormatEntity ()    {  }

    void  IGESData_FreeFormatEntity::SetTypeNumber
  (const Standard_Integer typenum)
{  InitTypeAndForm (typenum,0);  }

    void  IGESData_FreeFormatEntity::SetFormNumber
  (const Standard_Integer formnum)
{  InitTypeAndForm (TypeNumber(), formnum);  }


    Standard_Integer  IGESData_FreeFormatEntity::NbParams () const 
{  return UndefinedContent()->NbParams();  }

    Standard_Boolean  IGESData_FreeFormatEntity::ParamData
  (const Standard_Integer num, Interface_ParamType& ptype,
   Handle(IGESData_IGESEntity)& ent, Handle(TCollection_HAsciiString)& val) const 
{  return UndefinedContent()->ParamData (num,ptype,ent,val);  }


    Interface_ParamType  IGESData_FreeFormatEntity::ParamType
  (const Standard_Integer num) const 
{  return UndefinedContent()->ParamType(num);  }

    Standard_Boolean  IGESData_FreeFormatEntity::IsParamEntity
  (const Standard_Integer num) const 
{  return UndefinedContent()->IsParamEntity(num);  }

    Handle(IGESData_IGESEntity)  IGESData_FreeFormatEntity::ParamEntity
  (const Standard_Integer num) const
{
  return Handle(IGESData_IGESEntity)::DownCast
    (UndefinedContent()->ParamEntity(num));
}

    Standard_Boolean  IGESData_FreeFormatEntity::IsNegativePointer
  (const Standard_Integer num) const
{
  if (thenegptrs.IsNull()) return Standard_False;
  Standard_Integer nb = thenegptrs->Length();
  for (Standard_Integer i = 1; i <= nb; i ++)
    if (thenegptrs->Value(i) == num) return Standard_True;
  return Standard_False;
}

    Handle(TCollection_HAsciiString)  IGESData_FreeFormatEntity::ParamValue
  (const Standard_Integer num) const 
{  return UndefinedContent()->ParamValue(num);  }

    Handle(TColStd_HSequenceOfInteger)  IGESData_FreeFormatEntity::NegativePointers () const
      {  return thenegptrs;  }


    void  IGESData_FreeFormatEntity::AddLiteral
  (const Interface_ParamType ptype, const Handle(TCollection_HAsciiString)& val)
{  UndefinedContent()->AddLiteral (ptype,val);  }

    void  IGESData_FreeFormatEntity::AddLiteral
  (const Interface_ParamType ptype, const Standard_CString val)
{  UndefinedContent()->AddLiteral (ptype,new TCollection_HAsciiString(val));  }

    void  IGESData_FreeFormatEntity::AddEntity
  (const Interface_ParamType ptype,
   const Handle(IGESData_IGESEntity)& ent, const Standard_Boolean negative)
{
  UndefinedContent()->AddEntity (ptype,ent);
  if (!negative) return;
  if (thenegptrs.IsNull()) thenegptrs = new TColStd_HSequenceOfInteger();
  thenegptrs->Append(NbParams());
}

    void  IGESData_FreeFormatEntity::AddEntities
  (const Handle(IGESData_HArray1OfIGESEntity)& ents)
{
  if (ents.IsNull()) {
    AddLiteral ( Interface_ParamInteger, new TCollection_HAsciiString("0") );
    return;
  }
  AddLiteral ( Interface_ParamInteger, new TCollection_HAsciiString(ents->Length()) );
  Standard_Integer iup = ents->Upper();
  for (Standard_Integer i = ents->Lower(); i <= iup; i ++) {
    AddEntity (Interface_ParamIdent,ents->Value(i));
  }
}

    
    void  IGESData_FreeFormatEntity::AddNegativePointers
  (const Handle(TColStd_HSequenceOfInteger)& list)
{
  if (thenegptrs.IsNull()) thenegptrs = new TColStd_HSequenceOfInteger();
  thenegptrs->Append(list);
}

    void  IGESData_FreeFormatEntity::ClearNegativePointers ()
      {  thenegptrs.Nullify();  }


    void IGESData_FreeFormatEntity::WriteOwnParams
  (IGESData_IGESWriter& IW) const
{
//  Redefini de UndefinedEntity pour : NegativePointers
  Standard_Integer neg  = 0;
  Standard_Integer fneg = 0;
  if (!thenegptrs.IsNull())
    if (!thenegptrs->IsEmpty())  {  neg = thenegptrs->Value(1);  fneg = 1;  }

  Standard_Integer nb = UndefinedContent()->NbParams();
  for (Standard_Integer i = 1; i <= nb; i ++) {
    Interface_ParamType ptyp = UndefinedContent()->ParamType(i);
    if (ptyp == Interface_ParamVoid) IW.SendVoid();
    else if (UndefinedContent()->IsParamEntity(i)) {
      DeclareAndCast(IGESData_IGESEntity,anent,UndefinedContent()->ParamEntity(i));
//  Send Entity : Redefini
      if (i == neg) {
	IW.Send(anent,Standard_True);
	if (fneg >= thenegptrs->Length()) neg = 0;
	else  {  fneg ++;  neg = thenegptrs->Value(fneg);  }
      }
      else IW.Send(anent,Standard_False);
    }
    else IW.SendString (UndefinedContent()->ParamValue(i));
  }
}