1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13 
14 
15 #include <IFSelect_ContextModif.hxx>
16 #include <IGESBasic_Group.hxx>
17 #include <IGESData_HArray1OfIGESEntity.hxx>
18 #include <IGESData_IGESEntity.hxx>
19 #include <IGESData_IGESModel.hxx>
20 #include <IGESSelect_AddGroup.hxx>
21 #include <Interface_Check.hxx>
22 #include <Interface_CopyTool.hxx>
23 #include <Interface_EntityIterator.hxx>
24 #include <Interface_Macros.hxx>
25 #include <Standard_Type.hxx>
26 #include <TCollection_AsciiString.hxx>
27 
IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_AddGroup,IGESSelect_ModelModifier)28 IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_AddGroup,IGESSelect_ModelModifier)
29 
30 IGESSelect_AddGroup::IGESSelect_AddGroup ()
31     : IGESSelect_ModelModifier (Standard_True)    {  }
32 
Performing(IFSelect_ContextModif & ctx,const Handle (IGESData_IGESModel)& target,Interface_CopyTool &) const33 void  IGESSelect_AddGroup::Performing (IFSelect_ContextModif& ctx,
34                                        const Handle(IGESData_IGESModel)& target,
35                                        Interface_CopyTool& /*TC*/) const
36 {
37   if (ctx.IsForAll()) {
38     ctx.CCheck(0)->AddFail ("Add Group : Selection required not defined");
39     return;
40   }
41   Interface_EntityIterator list = ctx.SelectedResult();
42   Standard_Integer i = 0 , nb = list.NbEntities();
43   if (nb == 0) {
44     ctx.CCheck(0)->AddWarning ("Add Group : No entity selected");
45     return;
46   }
47   if (nb == 1) {
48     ctx.CCheck(0)->AddWarning ("Add Group : ONE entity selected");
49     return;
50   }
51   Handle(IGESData_HArray1OfIGESEntity) arr =
52     new IGESData_HArray1OfIGESEntity(1,nb);
53   for (ctx.Start(); ctx.More(); ctx.Next()) {
54     DeclareAndCast(IGESData_IGESEntity,ent,ctx.ValueResult());
55     i ++;
56     arr->SetValue(i,ent);
57   }
58   Handle(IGESBasic_Group) gr = new IGESBasic_Group;
59   gr->Init (arr);
60   target->AddEntity(gr);
61 }
62 
63 
Label() const64     TCollection_AsciiString  IGESSelect_AddGroup::Label () const
65       {  return TCollection_AsciiString ("Add Group");  }
66