Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::TetrahedralTree Class Reference

Helper class for searches in field maps. More...

#include <TetrahedralTree.hh>

Public Member Functions

 TetrahedralTree (const Vec3 &origin, const Vec3 &halfDimension)
 
 ~TetrahedralTree ()
 
void InsertMeshNode (Vec3 point, const int nodeIndex)
 
void InsertTetrahedron (const double elemBoundingBox[6], const int elemIndex)
 
std::vector< int > GetTetListInBlock (const Vec3 &point)
 

Detailed Description

Helper class for searches in field maps.

This class stores the mesh nodes and elements in an Octree data structure to optimize the element search operations

Author: Ali Sheharyar

Organization: Texas A&M University at Qatar

Definition at line 57 of file TetrahedralTree.hh.

Constructor & Destructor Documentation

◆ TetrahedralTree()

Garfield::TetrahedralTree::TetrahedralTree ( const Vec3 origin,
const Vec3 halfDimension 
)

TetrahedralTree.cc This class stores the mesh nodes and elements in an Octree data structure to optimize the element search operations

Author: Ali Sheharyar Organization: Texas A&M University at Qatar

Definition at line 14 of file TetrahedralTree.cc.

15 : m_origin(origin), m_halfDimension(halfDimension) {
16
17 min.x = origin.x - halfDimension.x;
18 min.y = origin.y - halfDimension.y;
19 min.z = origin.z - halfDimension.z;
20 max.x = origin.x + halfDimension.x;
21 max.y = origin.y + halfDimension.y;
22 max.z = origin.z + halfDimension.z;
23
24 // Initially, there are no children
25 for (int i = 0; i < 8; ++i) children[i] = NULL;
26}

◆ ~TetrahedralTree()

Garfield::TetrahedralTree::~TetrahedralTree ( )

Definition at line 28 of file TetrahedralTree.cc.

28 {
29 // Recursively destroy octants
30 for (int i = 0; i < 8; ++i) delete children[i];
31}

Member Function Documentation

◆ GetTetListInBlock()

std::vector< int > Garfield::TetrahedralTree::GetTetListInBlock ( const Vec3 point)

Definition at line 129 of file TetrahedralTree.cc.

129 {
130
131 const TetrahedralTree* octreeNode = GetBlockFromPoint(point);
132
133 if (octreeNode) {
134 return octreeNode->tetList;
135 }
136
137 return std::vector<int>();
138}
TetrahedralTree(const Vec3 &origin, const Vec3 &halfDimension)

Referenced by Garfield::ComponentFieldMap::FindElement13(), and Garfield::ComponentFieldMap::FindElement5().

◆ InsertMeshNode()

void Garfield::TetrahedralTree::InsertMeshNode ( Vec3  point,
const int  nodeIndex 
)

Definition at line 68 of file TetrahedralTree.cc.

68 {
69 // check if it is a leaf node
70 if (IsLeafNode()) {
71 // add the new point if the block is not full
72 if (!this->IsFull()) {
73 iBlockElems.push_back(OctreeBlockElem(point, nodeIndex));
74 } else {
75 // block is full, so we need to partition it.
76 // Split the current node and create new empty trees for each
77 // child octant.
78 for (int i = 0; i < 8; ++i) {
79 // Compute new bounding box for this child
80 Vec3 newOrigin = m_origin;
81 newOrigin.x += m_halfDimension.x * (i & 4 ? .5f : -.5f);
82 newOrigin.y += m_halfDimension.y * (i & 2 ? .5f : -.5f);
83 newOrigin.z += m_halfDimension.z * (i & 1 ? .5f : -.5f);
84 children[i] = new TetrahedralTree(newOrigin, m_halfDimension * .5f);
85 }
86
87 // move the nodes from the partitioned node (now marked as interior) to
88 // its children
89 while (!this->IsEmpty()) {
90 OctreeBlockElem bElem = iBlockElems.back();
91 iBlockElems.pop_back();
92 int octant = GetOctantContainingPoint(bElem.point);
93 children[octant]->InsertMeshNode(bElem.point, bElem.nodeIndex);
94 }
95
96 // insert the new node in the appropriate octant
97 children[GetOctantContainingPoint(point)]
98 ->InsertMeshNode(point, nodeIndex);
99 }
100 } else {
101 // We are at an interior node. Insert recursively into the
102 // appropriate child octant
103 int octant = GetOctantContainingPoint(point);
104 children[octant]->InsertMeshNode(point, nodeIndex);
105 }
106}
void InsertMeshNode(Vec3 point, const int nodeIndex)

Referenced by InsertMeshNode().

◆ InsertTetrahedron()

void Garfield::TetrahedralTree::InsertTetrahedron ( const double  elemBoundingBox[6],
const int  elemIndex 
)

Definition at line 108 of file TetrahedralTree.cc.

109 {
110
111 if (IsLeafNode()) {
112 // add the element to the list of this octant
113 tetList.push_back(elemIndex);
114 } else {
115 // check which child overlaps with the element's bounding box
116 for (int i = 0; i < 8; i++) {
117 Vec3 elem_min(elemBoundingBox[0], elemBoundingBox[1], elemBoundingBox[2]);
118 Vec3 elem_max(elemBoundingBox[3], elemBoundingBox[4], elemBoundingBox[5]);
119
120 if (children[i]->DoesBoxOverlap(elem_min, elem_max))
121 children[i]->InsertTetrahedron(elemBoundingBox, elemIndex);
122 }
123 }
124}
void InsertTetrahedron(const double elemBoundingBox[6], const int elemIndex)

Referenced by InsertTetrahedron().


The documentation for this class was generated from the following files: