Garfield++ 3.0
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 min.x = origin.x - halfDimension.x;
17 min.y = origin.y - halfDimension.y;
18 min.z = origin.z - halfDimension.z;
19 max.x = origin.x + halfDimension.x;
20 max.y = origin.y + halfDimension.y;
21 max.z = origin.z + halfDimension.z;
22
23 // Initially, there are no children
24 for (int i = 0; i < 8; ++i) children[i] = nullptr;
25}

◆ ~TetrahedralTree()

Garfield::TetrahedralTree::~TetrahedralTree ( )

Definition at line 27 of file TetrahedralTree.cc.

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

Member Function Documentation

◆ GetTetListInBlock()

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

Definition at line 127 of file TetrahedralTree.cc.

127 {
128 const TetrahedralTree* octreeNode = GetBlockFromPoint(point);
129
130 if (octreeNode) {
131 return octreeNode->tetList;
132 }
133
134 return std::vector<int>();
135}
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 67 of file TetrahedralTree.cc.

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

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

Referenced by InsertTetrahedron().


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