1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18 // ptv and rln 14.09.2000 BUC60743
20 #include <IGESBasic_Group.hxx>
21 #include <IGESData_IGESEntity.hxx>
22 #include <Standard_DimensionMismatch.hxx>
23 #include <Standard_OutOfRange.hxx>
24 #include <Standard_Transient.hxx>
25 #include <Standard_Type.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(IGESBasic_Group,IGESData_IGESEntity)
29 IGESBasic_Group::IGESBasic_Group () { InitTypeAndForm(402,1); }
31 IGESBasic_Group::IGESBasic_Group
32 (const Standard_Integer nb)
34 InitTypeAndForm(402,1);
36 theEntities = new IGESData_HArray1OfIGESEntity (1,nb);
40 void IGESBasic_Group::Init
41 (const Handle(IGESData_HArray1OfIGESEntity)& allEntities)
43 // ptv and rln September 14, 2000 BUC60743
44 // Protection against empty groups
45 if (!allEntities.IsNull() && (allEntities->Lower() != 1))
46 throw Standard_DimensionMismatch("IGESBasic_Group : Init");
47 theEntities = allEntities;
48 if (FormNumber() == 0) InitTypeAndForm(402,1);
51 void IGESBasic_Group::SetOrdered (const Standard_Boolean mode)
53 Standard_Integer fn = FormNumber();
55 if (fn == 0 || fn == 1) InitTypeAndForm (402,14);
56 else if (fn == 7) InitTypeAndForm (402,15);
58 if (fn == 14) InitTypeAndForm (402,1);
59 else if (fn == 15) InitTypeAndForm (402,7);
63 void IGESBasic_Group::SetWithoutBackP (const Standard_Boolean mode)
65 Standard_Integer fn = FormNumber();
67 if (fn == 0 || fn == 1) InitTypeAndForm (402,7);
68 else if (fn == 14) InitTypeAndForm (402,15);
70 if (fn == 7) InitTypeAndForm (402,1);
71 else if (fn == 15) InitTypeAndForm (402,14);
75 Standard_Boolean IGESBasic_Group::IsOrdered () const
77 Standard_Integer fn = FormNumber();
81 Standard_Boolean IGESBasic_Group::IsWithoutBackP () const
83 Standard_Integer fn = FormNumber();
84 return (fn == 7 || fn == 15);
87 void IGESBasic_Group::SetUser
88 (const Standard_Integer type, const Standard_Integer form)
90 if (type <= 5000) throw Standard_OutOfRange("IGESBasic_Group::SetUser");
91 InitTypeAndForm (type,form);
95 void IGESBasic_Group::SetNb (const Standard_Integer nb)
97 Standard_Integer i, oldnb = NbEntities();
98 if (nb == oldnb || nb <= 0) return;
100 Handle(IGESData_HArray1OfIGESEntity) newents = new IGESData_HArray1OfIGESEntity(1,nb);
101 if (oldnb > nb) oldnb = nb;
102 for (i = 1; i <= oldnb; i ++) newents->SetValue (i,theEntities->Value(i));
103 theEntities = newents;
106 Standard_Integer IGESBasic_Group::NbEntities () const
107 { return(theEntities.IsNull() ? 0 : theEntities->Length()); }
109 Handle(IGESData_IGESEntity) IGESBasic_Group::Entity
110 (const Standard_Integer Index) const
111 { return theEntities->Value(Index); }
113 Handle(Standard_Transient) IGESBasic_Group::Value (const Standard_Integer Index) const
115 return Handle(Standard_Transient) (theEntities->Value(Index));
118 void IGESBasic_Group::SetValue
119 (const Standard_Integer Index, const Handle(IGESData_IGESEntity)& ent)
120 { theEntities->SetValue (Index,ent); }