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_CopyMap.hxx> |
7fd59977 |
16 | #include <Interface_InterfaceError.hxx> |
42cf5bc1 |
17 | #include <Interface_InterfaceModel.hxx> |
18 | #include <Standard_Transient.hxx> |
19 | #include <Standard_Type.hxx> |
7fd59977 |
20 | |
92efcf78 |
21 | IMPLEMENT_STANDARD_RTTIEXT(Interface_CopyMap,Interface_CopyControl) |
22 | |
b311480e |
23 | // CopyMap : rien de plus qu une Map passive |
b311480e |
24 | Interface_CopyMap::Interface_CopyMap |
7fd59977 |
25 | (const Handle(Interface_InterfaceModel)& amodel) |
26 | : theres (0,amodel->NbEntities()) |
27 | { themod = amodel; } |
28 | |
29 | |
30 | void Interface_CopyMap::Clear () |
31 | { |
32 | Standard_Integer nb = theres.Upper(); |
33 | Handle(Standard_Transient) bid; // Null |
34 | for (Standard_Integer i = 1; i <= nb; i ++) theres.SetValue(i,bid); |
35 | } |
36 | |
37 | Handle(Interface_InterfaceModel) Interface_CopyMap::Model () const |
38 | { return themod; } |
39 | |
40 | void Interface_CopyMap::Bind |
41 | (const Handle(Standard_Transient)& ent, |
42 | const Handle(Standard_Transient)& res) |
43 | { |
44 | Standard_Integer num = themod->Number(ent); |
9775fa61 |
45 | if (num == 0 || num > theres.Upper()) throw Interface_InterfaceError("CopyMap : Bind, Starting Entity not issued from Starting Model"); |
46 | if (!theres.Value(num).IsNull()) throw Interface_InterfaceError("CopyMap : Bind, Starting Entity already bound"); |
7fd59977 |
47 | theres.SetValue(num,res); |
48 | } |
49 | |
50 | |
51 | Standard_Boolean Interface_CopyMap::Search |
52 | (const Handle(Standard_Transient)& ent, |
53 | Handle(Standard_Transient)& res) const |
54 | { |
55 | Standard_Integer num = themod->Number(ent); |
56 | if (num == 0) return Standard_False; |
57 | res = theres.Value(num); |
58 | return (!res.IsNull()); |
59 | } |