Commit | Line | Data |
---|---|---|
973c2be1 | 1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 2 | // |
973c2be1 | 3 | // This file is part of Open CASCADE Technology software library. |
b311480e | 4 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 10 | // |
973c2be1 | 11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. | |
b311480e | 13 | |
42cf5bc1 | 14 | |
15 | #include <Interface_EntityIterator.hxx> | |
16 | #include <Interface_GeneralLib.hxx> | |
7fd59977 | 17 | #include <Interface_GeneralModule.hxx> |
42cf5bc1 | 18 | #include <Interface_Graph.hxx> |
19 | #include <Interface_GTool.hxx> | |
20 | #include <Interface_InterfaceModel.hxx> | |
7fd59977 | 21 | #include <Interface_IntList.hxx> |
42cf5bc1 | 22 | #include <Interface_Protocol.hxx> |
23 | #include <Interface_ReportEntity.hxx> | |
24 | #include <Interface_ShareFlags.hxx> | |
7fd59977 | 25 | #include <Standard_DomainError.hxx> |
42cf5bc1 | 26 | #include <Standard_OutOfRange.hxx> |
27 | #include <Standard_Transient.hxx> | |
7fd59977 | 28 | |
b311480e | 29 | Interface_ShareFlags::Interface_ShareFlags |
7fd59977 | 30 | (const Handle(Interface_InterfaceModel)& amodel, |
31 | const Interface_GeneralLib& lib) | |
32 | : theflags (amodel->NbEntities()) | |
33 | { | |
34 | Handle(Interface_GTool) gtool; // null | |
35 | themodel = amodel; | |
36 | Evaluate(lib,gtool); | |
37 | } | |
38 | ||
39 | Interface_ShareFlags::Interface_ShareFlags | |
40 | (const Handle(Interface_InterfaceModel)& amodel, | |
41 | const Handle(Interface_GTool)& gtool) | |
42 | : theflags (amodel->NbEntities()) | |
43 | { | |
44 | themodel = amodel; | |
45 | Evaluate(gtool->Lib(),gtool); | |
46 | } | |
47 | ||
48 | Interface_ShareFlags::Interface_ShareFlags | |
49 | (const Handle(Interface_InterfaceModel)& amodel, | |
50 | const Handle(Interface_Protocol)& protocol) | |
51 | : theflags (amodel->NbEntities()) | |
52 | { | |
53 | Handle(Interface_GTool) gtool; // null | |
54 | themodel = amodel; | |
55 | Evaluate(Interface_GeneralLib(protocol),gtool); | |
56 | } | |
57 | ||
58 | Interface_ShareFlags::Interface_ShareFlags | |
59 | (const Handle(Interface_InterfaceModel)& amodel) | |
60 | : theflags (amodel->NbEntities()) | |
61 | { | |
62 | Handle(Interface_GTool) gtool = themodel->GTool(); | |
63 | gtool->Reservate(amodel->NbEntities()); | |
64 | themodel = amodel; | |
65 | Evaluate (gtool->Lib(),gtool); | |
66 | } | |
67 | ||
68 | Interface_ShareFlags::Interface_ShareFlags (const Interface_Graph& agraph) | |
bc650d41 G |
69 | : theflags (agraph.Model()->NbEntities()) |
70 | { | |
71 | themodel = agraph.Model(); | |
72 | Standard_Integer nb = themodel->NbEntities(); | |
73 | if (nb == 0) return; | |
74 | theroots = new TColStd_HSequenceOfTransient(); | |
75 | for (Standard_Integer i = 1; i <= nb; i ++) { | |
76 | // Resultat obtenu depuis le Graph | |
77 | Handle(Standard_Transient) ent = themodel->Value(i); | |
78 | Handle(TColStd_HSequenceOfTransient) list = agraph.GetSharings(ent); | |
79 | ||
80 | if (!list.IsNull() && list->Length() > 0) theflags.SetTrue(i); | |
81 | else theroots->Append (ent); | |
82 | } | |
83 | } | |
7fd59977 | 84 | |
85 | ||
86 | void Interface_ShareFlags::Evaluate | |
87 | (const Interface_GeneralLib& lib, const Handle(Interface_GTool)& gtool) | |
88 | { | |
89 | Standard_Boolean patool = gtool.IsNull(); | |
90 | Standard_Integer nb = themodel->NbEntities(); | |
91 | if (nb == 0) return; | |
92 | theroots = new TColStd_HSequenceOfTransient(); | |
93 | Standard_Integer i; // svv Jan11 2000 : porting on DEC | |
94 | for (i = 1; i <= nb; i ++) { | |
95 | ||
96 | // ATTENTION : Si Entite non chargee donc illisible, basculer sur son | |
97 | // "Contenu" equivalent | |
98 | Handle(Standard_Transient) ent = themodel->Value(i); | |
99 | if (themodel->IsRedefinedContent(i)) ent = themodel->ReportEntity(i)->Content(); | |
100 | ||
101 | // Resultat obtenu via GeneralLib | |
102 | Interface_EntityIterator iter; | |
103 | Handle(Interface_GeneralModule) module; | |
104 | Standard_Integer CN; | |
105 | if (patool) { | |
106 | if (lib.Select(ent,module,CN)) module->FillShared(themodel,CN,ent,iter); | |
107 | } else { | |
108 | if (gtool->Select(ent,module,CN)) module->FillShared(themodel,CN,ent,iter); | |
109 | } | |
110 | ||
111 | // Entites partagees par <ent> : reste a noter chacune comme "Shared" | |
112 | for (iter.Start(); iter.More(); iter.Next()) { | |
113 | Standard_Integer num = themodel->Number(iter.Value()); | |
114 | theflags.SetTrue(num); // Et Voila | |
115 | } | |
116 | } | |
117 | for (i = 1; i <= nb; i ++) { | |
118 | if (!theflags.Value(i)) theroots->Append (themodel->Value(i)); | |
119 | } | |
120 | } | |
121 | ||
122 | ||
123 | Handle(Interface_InterfaceModel) Interface_ShareFlags::Model () const | |
124 | { return themodel; } | |
125 | ||
126 | Standard_Boolean Interface_ShareFlags::IsShared | |
127 | (const Handle(Standard_Transient)& ent) const | |
128 | { | |
129 | Standard_Integer num = themodel->Number(ent); | |
9775fa61 | 130 | if (num == 0 || num > themodel->NbEntities()) throw Standard_DomainError("Interface ShareFlags : IsShared"); |
7fd59977 | 131 | return theflags.Value(num); |
132 | } | |
133 | ||
134 | Interface_EntityIterator Interface_ShareFlags::RootEntities () const | |
135 | { | |
136 | Interface_EntityIterator iter (theroots); | |
137 | return iter; | |
138 | } | |
139 | ||
140 | Standard_Integer Interface_ShareFlags::NbRoots () const | |
141 | { return (theroots.IsNull() ? 0 : theroots->Length()); } | |
142 | ||
143 | Handle(Standard_Transient) Interface_ShareFlags::Root | |
144 | (const Standard_Integer num) const | |
145 | { return theroots->Value(num); } |