0022627: Change OCCT memory management defaults
[occt.git] / src / IGESBasic / IGESBasic_Group.cxx
1 //--------------------------------------------------------------------
2 //
3 //  File Name : IGESBasic_Group.cxx
4 //  Date      :
5 //  Author    : CKY / Contract Toubro-Larsen
6 //  Copyright : MATRA-DATAVISION 1993
7 //
8 //--------------------------------------------------------------------
9
10 // ptv and rln 14.09.2000 BUC60743
11
12 #include <IGESBasic_Group.ixx>
13 #include <Standard_DimensionMismatch.hxx>
14 #include <Standard_OutOfRange.hxx>
15
16
17     IGESBasic_Group::IGESBasic_Group ()    {  InitTypeAndForm(402,1);  }
18
19     IGESBasic_Group::IGESBasic_Group
20   (const Standard_Integer nb)
21 {
22   InitTypeAndForm(402,1);
23   if (nb <= 0) return;
24   theEntities = new IGESData_HArray1OfIGESEntity (1,nb);
25 }
26
27
28     void IGESBasic_Group::Init
29   (const Handle(IGESData_HArray1OfIGESEntity)& allEntities)
30 {
31   // ptv and rln September 14, 2000 BUC60743
32   // Protection against empty groups
33   if (!allEntities.IsNull() && (allEntities->Lower() != 1))
34     Standard_DimensionMismatch::Raise("IGESBasic_Group : Init");
35   theEntities   = allEntities;
36   if (FormNumber() == 0) InitTypeAndForm(402,1);
37 }
38
39     void  IGESBasic_Group::SetOrdered (const Standard_Boolean mode)
40 {
41   Standard_Integer fn = FormNumber();
42   if (mode) {
43     if (fn == 0 || fn == 1) InitTypeAndForm (402,14);
44     else if (fn == 7)       InitTypeAndForm (402,15);
45   } else {
46     if      (fn == 14)      InitTypeAndForm (402,1);
47     else if (fn == 15)      InitTypeAndForm (402,7);
48   }
49 }
50
51     void  IGESBasic_Group::SetWithoutBackP (const Standard_Boolean mode)
52 {
53   Standard_Integer fn = FormNumber();
54   if (mode) {
55     if (fn == 0 || fn == 1) InitTypeAndForm (402,7);
56     else if (fn == 14)      InitTypeAndForm (402,15);
57   } else {
58     if      (fn == 7)       InitTypeAndForm (402,1);
59     else if (fn == 15)      InitTypeAndForm (402,14);
60   }
61 }
62
63     Standard_Boolean IGESBasic_Group::IsOrdered () const
64 {
65   Standard_Integer fn = FormNumber();
66   return (fn > 7);
67 }
68
69     Standard_Boolean IGESBasic_Group::IsWithoutBackP () const
70 {
71   Standard_Integer fn = FormNumber();
72   return (fn == 7 || fn == 15);
73 }
74
75     void  IGESBasic_Group::SetUser
76   (const Standard_Integer type, const Standard_Integer form)
77 {
78   if (type <= 5000) Standard_OutOfRange::Raise("IGESBasic_Group::SetUser");
79   InitTypeAndForm (type,form);
80 }
81
82
83     void  IGESBasic_Group::SetNb (const Standard_Integer nb)
84 {
85   Standard_Integer i, oldnb = NbEntities();
86   if (nb == oldnb || nb <= 0) return;
87
88   Handle(IGESData_HArray1OfIGESEntity) newents = new IGESData_HArray1OfIGESEntity(1,nb);
89   if (oldnb > nb) oldnb = nb;
90   for (i = 1; i <= oldnb; i ++) newents->SetValue (i,theEntities->Value(i));
91   theEntities = newents;
92 }
93
94     Standard_Integer IGESBasic_Group::NbEntities () const
95       {  return(theEntities.IsNull() ? 0 : theEntities->Length());  }
96
97     Handle(IGESData_IGESEntity) IGESBasic_Group::Entity
98   (const Standard_Integer Index) const
99       {  return theEntities->Value(Index);  }
100
101     Handle(Standard_Transient)  IGESBasic_Group::Value
102   (const Standard_Integer Index) const
103       {  return theEntities->Value(Index);  }
104
105     void  IGESBasic_Group::SetValue
106   (const Standard_Integer Index, const Handle(IGESData_IGESEntity)& ent)
107       {  theEntities->SetValue (Index,ent);  }