0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / Interface / Interface_GTool.cxx
CommitLineData
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
7fd59977 14#include <Interface_GTool.ixx>
15
b311480e 16Interface_GTool::Interface_GTool () { }
7fd59977 17
18 Interface_GTool::Interface_GTool
19 (const Handle(Interface_Protocol)& proto, const Standard_Integer nb)
20 : theproto (proto) , thelib (proto)
21 { if (nb > 0) { thentnum.ReSize(nb); thentmod.ReSize(nb); } }
22
23
24 void Interface_GTool::SetSignType (const Handle(Interface_SignType)& sign)
25 { thesign = sign; }
26
27 Handle(Interface_SignType) Interface_GTool::SignType () const
28 { return thesign; }
29
30 Standard_CString Interface_GTool::SignValue
31 (const Handle(Standard_Transient)& ent,
32 const Handle(Interface_InterfaceModel)& model) const
33{
34 if (ent.IsNull()) return "";
35 if (thesign.IsNull()) return Interface_SignType::ClassName(ent->DynamicType()->Name());
36 return thesign->Value (ent,model);
37}
38
39 Standard_CString Interface_GTool::SignName () const
40{
41 if (thesign.IsNull()) return "Class Name";
42 return thesign->Name();
43}
44
45
46 void Interface_GTool::SetProtocol
47 (const Handle(Interface_Protocol)& proto, const Standard_Boolean enforce)
48{
49 if (proto == theproto && !enforce) return;
50 theproto = proto;
51 thelib.Clear();
52 thelib.AddProtocol (proto);
53}
54
55 Handle(Interface_Protocol) Interface_GTool::Protocol () const
56 { return theproto; }
57
58 Interface_GeneralLib& Interface_GTool::Lib ()
59 { return thelib; }
60
61 void Interface_GTool::Reservate
62 (const Standard_Integer nb, const Standard_Boolean enforce)
63{
64 Standard_Integer n = thentnum.NbBuckets();
65 if (n < nb && !enforce) return;
66 thentnum.ReSize (nb); thentmod.ReSize (nb);
67}
68
69 void Interface_GTool::ClearEntities ()
70 { thentnum.Clear(); thentmod.Clear(); }
71
72
73//=======================================================================
74//function : Select
75//purpose :
76//=======================================================================
77
78Standard_Boolean Interface_GTool::Select (const Handle(Standard_Transient)& ent,
79 Handle(Interface_GeneralModule)& gmod,
80 Standard_Integer& CN,
81 const Standard_Boolean enforce)
82{
bc650d41
G
83 const Handle(Standard_Type)& aType = ent->DynamicType();
84 Standard_Integer num = thentmod.FindIndex(aType);// (ent);
7fd59977 85 if (num == 0 || enforce) {
86 if (thelib.Select (ent,gmod,CN)) {
bc650d41
G
87 num = thentmod.Add (aType,gmod);
88 thentnum.Bind (aType,CN);
7fd59977 89 return Standard_True;
90 }
91 return Standard_False;
92 }
bc650d41
G
93 gmod = Handle(Interface_GeneralModule)::DownCast (thentmod.FindFromKey(aType));
94 CN = thentnum.Find (aType);
7fd59977 95 return Standard_True;
96}