1 // Created on: 1993-04-05
2 // Created by: Christian CAILLET
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 #ifndef _Interface_ShareFlags_HeaderFile
18 #define _Interface_ShareFlags_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 
24 #include <Interface_BitMap.hxx>
25 #include <TColStd_HSequenceOfTransient.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Integer.hxx>
28 class Interface_InterfaceModel;
29 class Standard_DomainError;
30 class Standard_OutOfRange;
31 class Interface_GeneralLib;
32 class Interface_GTool;
33 class Interface_Protocol;
34 class Interface_Graph;
35 class Standard_Transient;
36 class Interface_EntityIterator;
37 
38 
39 //! This class only says for each Entity of a Model, if it is
40 //! Shared or not by one or more other(s) of this Model
41 //! It uses the General Service "Shared".
42 class Interface_ShareFlags
43 {
44 public:
45 
46   DEFINE_STANDARD_ALLOC
47 
48 
49   //! Creates a ShareFlags from a Model and builds required data
50   //! (flags) by calling the General Service Library given as
51   //! argument <lib>
52   Standard_EXPORT Interface_ShareFlags(const Handle(Interface_InterfaceModel)& amodel, const Interface_GeneralLib& lib);
53 
54   //! Same as above, but GeneralLib is detained by a GTool
55   Standard_EXPORT Interface_ShareFlags(const Handle(Interface_InterfaceModel)& amodel, const Handle(Interface_GTool)& gtool);
56 
57   //! Same as above, but GeneralLib is defined through a Protocol
58   Standard_EXPORT Interface_ShareFlags(const Handle(Interface_InterfaceModel)& amodel, const Handle(Interface_Protocol)& protocol);
59 
60   //! Same as above, but works with the GTool of the Model
61   Standard_EXPORT Interface_ShareFlags(const Handle(Interface_InterfaceModel)& amodel);
62 
63   //! Creates a ShareFlags by querying informations from a Graph
64   //! (remark that Graph also has a method IsShared)
65   Standard_EXPORT Interface_ShareFlags(const Interface_Graph& agraph);
66 
67   //! Returns the Model used for the evaluation
68   Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
69 
70   //! Returns True if <ent> is Shared by one or more other
71   //! Entity(ies) of the Model
72   Standard_EXPORT Standard_Boolean IsShared (const Handle(Standard_Transient)& ent) const;
73 
74   //! Returns the Entities which are not Shared (see their flags)
75   Standard_EXPORT Interface_EntityIterator RootEntities() const;
76 
77   //! Returns the count of root entities
78   Standard_EXPORT Standard_Integer NbRoots() const;
79 
80   //! Returns a root entity according its rank in the list of roots
81   //! By default, it returns the first one
82   Standard_EXPORT Handle(Standard_Transient) Root (const Standard_Integer num = 1) const;
83 
84 
85 
86 
87 protected:
88 
89 
90 
91 
92 
93 private:
94 
95 
96   //! Computes flags at Creation time
97   //!
98   //! Normally, gtool suffices. But if a Graph is created from a
99   //! GeneralLib directly, it cannot be used
100   //! If <gtool> is defined, it has priority
101   Standard_EXPORT void Evaluate (const Interface_GeneralLib& lib, const Handle(Interface_GTool)& gtool);
102 
103 
104   Handle(Interface_InterfaceModel) themodel;
105   Interface_BitMap theflags;
106   Handle(TColStd_HSequenceOfTransient) theroots;
107 
108 
109 };
110 
111 
112 
113 
114 
115 
116 
117 #endif // _Interface_ShareFlags_HeaderFile
118