aff5997d |
1 | // BaseDriver.cpp: implementation of the BaseDriver class. |
2 | // |
3 | ////////////////////////////////////////////////////////////////////// |
4 | |
5 | #include "BaseDriver.h" |
6 | |
7 | #include <TDF_Reference.hxx> |
8 | #include <TDF_ChildIterator.hxx> |
9 | |
10 | #define SLOW |
11 | #ifdef SLOW |
12 | #include <OSD_Timer.hxx> |
13 | #include <BRepPrimAPI_MakeSphere.hxx> |
14 | #include <BRepAlgoAPI_Fuse.hxx> |
15 | #endif |
16 | |
17 | IMPLEMENT_STANDARD_HANDLE(BaseDriver,TFunction_Driver) |
18 | IMPLEMENT_STANDARD_RTTIEXT(BaseDriver,TFunction_Driver) |
19 | |
20 | // Constructor |
21 | BaseDriver::BaseDriver() |
22 | { |
23 | |
24 | } |
25 | |
26 | // Returns the arguments of the function |
27 | void BaseDriver::Arguments(TDF_LabelList& args) const |
28 | { |
29 | // Append all arguments. |
30 | TDF_ChildIterator itr(Label().FindChild(1), false); |
31 | for (; itr.More(); itr.Next()) |
32 | { |
33 | Handle(TDF_Reference) ref; |
34 | if (itr.Value().FindAttribute(TDF_Reference::GetID(), ref)) |
35 | args.Append(ref->Get()); |
36 | } |
37 | } |
38 | |
39 | |
40 | // Returns the results of the function |
41 | void BaseDriver::Results(TDF_LabelList& res) const |
42 | { |
43 | // Append all results |
44 | TDF_ChildIterator itr(Label().FindChild(2), false); |
45 | for (; itr.More(); itr.Next()) |
46 | { |
47 | Handle(TDF_Reference) ref; |
48 | if (itr.Value().FindAttribute(TDF_Reference::GetID(), ref)) |
49 | res.Append(ref->Get()); |
50 | } |
51 | } |
52 | |
53 | // Execution. |
54 | Standard_Integer BaseDriver::Execute(Handle(TFunction_Logbook)& log) const |
55 | { |
56 | #ifdef SLOW |
57 | // Make a boolean operation to slow down the function |
58 | TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(100.0, 2.0 * M_PI / 3.0); |
59 | TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(gp_Pnt(10, 10, 10), 100.0, 2.0 * M_PI / 3.0); |
60 | BRepAlgoAPI_Fuse fuser(S1, S2); |
61 | fuser.Build(); |
62 | #endif |
63 | |
64 | // Empty... should be implemented in descendent classes |
65 | return 0; |
66 | } |