Free Electron
MapTree.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 __surface_MapTree_h__
8 #define __surface_MapTree_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Map of named subtrees
17 
18  @ingroup surface
19 
20  Each named partition is converted to an independent subtree.
21  This should effective when most searches are for one simple name at a time.
22  This could be very inefficient when patterns match many partitions at once.
23 
24  While the notion is like a map, the partitions have been converted to
25  consecutive indexes, so the subtrees are actually stored in an array.
26 *//***************************************************************************/
27 class FE_DL_EXPORT MapTree: public SpatialTreeBase
28 {
29  public:
30 
31  MapTree(void);
32 virtual ~MapTree(void);
33 
34 virtual void setRefinement(U32 a_refinement) { m_refinement=a_refinement; }
35 
36 virtual void populate(
37  const Vector3i* a_pElementArray,
38  const SpatialVector* a_pVertexArray,
39  const SpatialVector* a_pNormalArray,
40  const Vector2* a_pUVArray,
41  const Color* a_pColorArray,
42  const I32* a_pTriangleIndexArray,
43  const I32* a_pPointIndexArray,
44  const I32* a_pPrimitiveIndexArray,
45  const I32* a_pPartitionIndexArray,
46  U32 a_primitives,U32 a_vertices,
47  const SpatialVector& a_center,F32 a_radius);
48 virtual Real nearestPoint(const SpatialVector& a_origin,
49  Real a_maxDistance,BWORD a_anyHit,U32 a_hitLimit,
50  const sp<PartitionI>& a_rspPartition,
51  Array< sp<SpatialTreeI::Hit> >& a_rHitArray)
52  const;
53 virtual Real rayImpact(const SpatialVector& a_origin,
54  const SpatialVector& a_direction,
55  Real a_maxDistance,BWORD a_anyHit,U32 a_hitLimit,
56  const sp<PartitionI>& a_rspPartition,
57  Array< sp<SpatialTreeI::Hit> >& a_rHitArray)
58  const;
59 
60  private:
61 
62  void accumulateHits(Array< sp<SpatialTreeI::Hit> >& a_rDestination,
63  Array< sp<SpatialTreeI::Hit> >& a_rSource,
64  U32 a_hitLimit) const;
65 
66  std::vector< sp<SpatialTreeI> > m_treeArray;
67  std::vector< std::vector<Vector3i> > m_elementArrays;
68 
69  U32 m_refinement;
70 
71  void populateSubTree(I32 a_treeIndex);
72 
73  const Vector3i* m_pElementArray;
74  const SpatialVector* m_pVertexArray;
75  const SpatialVector* m_pNormalArray;
76  const Vector2* m_pUVArray;
77  const Color* m_pColorArray;
78  const I32* m_pTriangleIndexArray;
79  const I32* m_pPointIndexArray;
80  const I32* m_pPrimitiveIndexArray;
81  const I32* m_pPartitionIndexArray;
82  U32 m_primitives;
83  U32 m_vertices;
84  SpatialVector m_center;
85  F32 m_radius;
86 
87  class Populator: public Thread::Functor
88  {
89  public:
90  Populator(sp< JobQueue<I32> > a_spJobQueue,
91  U32 a_id,String a_stage):
92  m_spJobQueue(a_spJobQueue),
93  m_id(a_id) {}
94 
95  void operate(void);
96 
97  void setObject(sp<Component> spMapTree)
98  { m_spMapTree=spMapTree; }
99 
100  private:
101  sp< JobQueue<I32> > m_spJobQueue;
102  U32 m_id;
103  sp<MapTree> m_spMapTree;
104  };
105 };
106 
107 } /* namespace ext */
108 } /* namespace fe */
109 
110 #endif /* __surface_MapTree_h__ */
kernel
Definition: namespace.dox:3
Special vector for color (RGBA)
Definition: Color.h:21
Triangular storage using a simple array.
Definition: SpatialTreeBase.h:20
Automatically reference-counted string container.
Definition: String.h:128
Map of named subtrees.
Definition: MapTree.h:27
Wrapper for std::vector.
Definition: Array.h:21
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53