Free Electron
TreeOp.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __vegetation_OperatorTree_h__
8 #define __vegetation_OperatorTree_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Handler to Sim and Draw a Tree
17 
18  @ingroup vegetation
19 *//***************************************************************************/
20 class FE_DL_EXPORT TreeOp:
21  public OperatorThreaded,
22  public Initialize<TreeOp>
23 {
24  public:
25 
26  TreeOp(void);
27 virtual ~TreeOp(void);
28 
29  void initialize(void);
30 
31  //* As HandlerI
32 virtual void handle(Record& a_rSignal);
33 
34  using OperatorThreaded::run;
35 
36 virtual void run(I32 a_id,sp<SpannedRange> a_spSpannedRange,
37  String a_stage);
38 
39  private:
40 
41  SpatialVector convertY(SpatialVector a_vector);
42 
43  SpatialVector unconvertY(SpatialVector a_vector);
44 
45  BWORD rebuild(void);
46  void rebuildPlants(I32 a_start,I32 a_count);
47 
48  BWORD updateInput(void);
49  void updateInputPlants(I32 a_start,I32 a_count);
50 
51  void replace(void);
52  void replacePlants(I32 a_start,I32 a_count);
53 
54  void regenerate(void);
55 
56  sp<SurfaceAccessibleI> m_spInputAccessible;
57  sp<SurfaceAccessibleI> m_spReplaceAccessible;
58  sp<SurfaceAccessibleI> m_spPayloadAccessible;
59 
60  BWORD m_yUp;
61  Real m_lastFrame;
62  I32 m_lastPointCount;
63  I32 m_lastPrimitiveCount;
64 
65  Real m_time;
66  String m_treeName;
67 
68  Forest m_forestRV;
69  Plant m_plantRV;
70  RecordArrayView<Plant> m_plantRAV;
71  sp<Scope> m_spScope;
72  sp<SignalerI> m_spSignalerI;
73 
74  Array< std::map<U32,U32> > m_plantPointMap;
75  Array<SpatialVector> m_plantOffset;
76  Array< Array<U32> > m_primitivesOfPlant;
77  Array< sp<PlantModelI> > m_modelOfPlant;
78 
79  Array< sp<HandlerI> > m_modifierArray;
80 
81  class TreeWorker: public Thread::Functor
82  {
83  public:
84  TreeWorker(sp< JobQueue<I32> > a_spJobQueue,
85  U32 a_id,String a_stage):
86  m_id(a_id),
87  m_stage(a_stage),
88  m_hpJobQueue(a_spJobQueue) {}
89 
90  virtual void operate(void);
91 
92  void setObject(sp<Counted> spCounted)
93  { m_hpTreeOp=sp<Component>(spCounted); }
94 
95  private:
96  U32 m_id;
97  String m_stage;
98  hp< JobQueue<I32> > m_hpJobQueue;
99  hp<TreeOp> m_hpTreeOp;
100  };
101 
102  sp< Gang<TreeWorker,I32> > m_spGang;
103  I32 m_bundleSize;
104 };
105 
106 } /* namespace ext */
107 } /* namespace fe */
108 
109 #endif /* __vegetation_OperatorTree_h__ */
110 
Handler to move curves away from a collider.
Definition: OperatorThreaded.h:20
kernel
Definition: namespace.dox:3
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
RecordView Iteration over a RecordArray.
Definition: RecordArrayView.h:37
Plant RecordView.
Definition: Plant.h:24
Safe handle for shared pointer.
Definition: Handled.h:61
Automatically reference-counted string container.
Definition: String.h:128
Wrapper for std::vector.
Definition: Array.h:21
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Handler to Sim and Draw a Tree.
Definition: TreeOp.h:20
Forest RecordView.
Definition: Forest.h:23