1 // Created on: 1993-02-02
2 // Created by: Christian CAILLET
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Interface_ShareTool_HeaderFile
18 #define _Interface_ShareTool_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Type.hxx>
27 class Interface_HGraph;
28 class Standard_DomainError;
29 class Interface_InterfaceError;
30 class Interface_InterfaceModel;
31 class Interface_GeneralLib;
32 class Interface_GTool;
33 class Interface_Protocol;
34 class Interface_Graph;
35 class Interface_EntityIterator;
36 class Standard_Transient;
37 class Message_Messenger;
40 //! Builds the Graph of Dependancies, from the General Service
41 //! "Shared" -> builds for each Entity of a Model, the Shared and
42 //! Sharing Lists, and gives access to them.
43 //! Allows to complete with Implied References (which are not
44 //! regarded as Shared Entities, but are nevertheless Referenced),
45 //! this can be usefull for Reference Checking
46 class Interface_ShareTool
53 //! Creates a ShareTool from a Model and builds all required data,
54 //! by calling the General Service Library and Modules
55 //! (GeneralLib given as an argument)
56 Standard_EXPORT Interface_ShareTool(const Handle(Interface_InterfaceModel)& amodel, const Interface_GeneralLib& lib);
58 //! Same a above, but GeneralLib is detained by a GTool
59 Standard_EXPORT Interface_ShareTool(const Handle(Interface_InterfaceModel)& amodel, const Handle(Interface_GTool)& gtool);
61 //! Same a above, but GeneralLib is defined through a Protocol
62 //! Protocol is used to build the working library
63 Standard_EXPORT Interface_ShareTool(const Handle(Interface_InterfaceModel)& amodel, const Handle(Interface_Protocol)& protocol);
65 //! Same as above, but works with the GTool of the Model
66 Standard_EXPORT Interface_ShareTool(const Handle(Interface_InterfaceModel)& amodel);
68 //! Creates a ShareTool from an already defined Graph
69 //! Remark that the data of the Graph are copied
70 Standard_EXPORT Interface_ShareTool(const Interface_Graph& agraph);
72 //! Completes the Graph by Adding Implied References. Hence, they
73 //! are considered as Sharing References in all the other queries
74 Standard_EXPORT Interface_ShareTool(const Handle(Interface_HGraph)& ahgraph);
76 //! Returns the Model used for Creation (directly or for Graph)
77 Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
79 //! Returns the data used by the ShareTool to work
80 //! Can then be used directly (read only)
81 Standard_EXPORT const Interface_Graph& Graph() const;
83 //! Returns the Entities which are not Shared (their Sharing List
84 //! is empty) in the Model
85 Standard_EXPORT Interface_EntityIterator RootEntities() const;
87 //! Returns True if <ent> is Shared by other Entities in the Model
88 Standard_EXPORT Standard_Boolean IsShared (const Handle(Standard_Transient)& ent) const;
90 //! Returns the List of Entities Shared by a given Entity <ent>
91 Standard_EXPORT Interface_EntityIterator Shareds (const Handle(Standard_Transient)& ent) const;
93 //! Returns the List of Entities Sharing a given Entity <ent>
94 Standard_EXPORT Interface_EntityIterator Sharings (const Handle(Standard_Transient)& ent) const;
96 //! Returns the count of Sharing Entities of an Entity, which
97 //! are Kind of a given Type
98 Standard_EXPORT Standard_Integer NbTypedSharings (const Handle(Standard_Transient)& ent, const Handle(Standard_Type)& atype) const;
100 //! Returns the Sharing Entity of an Entity, which is Kind of a
101 //! given Type. Allows to access a Sharing Entity of a given type
102 //! when there is one and only one (current case)
103 Standard_EXPORT Handle(Standard_Transient) TypedSharing (const Handle(Standard_Transient)& ent, const Handle(Standard_Type)& atype) const;
105 //! Returns the complete list of entities shared by <ent> at any
106 //! level, including <ent> itself
107 //! If <ent> is the Model, considers the concatenation of
108 //! AllShared for each root
109 //! If <rootlast> is True (D), the list starts with lower level
110 //! entities and ends by the root. Else, the root is first and
111 //! the lower level entities are at end
112 Standard_EXPORT Interface_EntityIterator All (const Handle(Standard_Transient)& ent, const Standard_Boolean rootlast = Standard_True) const;
114 //! Utility method which Prints the content of an iterator
115 //! (by their Numbers)
116 Standard_EXPORT void Print (const Interface_EntityIterator& iter, const Handle(Message_Messenger)& S) const;
131 Handle(Interface_HGraph) theHGraph;
142 #endif // _Interface_ShareTool_HeaderFile