gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
OctreeInternals.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef OCTREE_INTERNALS_H
7 #define OCTREE_INTERNALS_H
8 
9 #include <vector>
10 
11 // file of function prototypes and macro constants
12 typedef void (*BBFunction)(void *, double *, double *);
13 typedef int (*InEleFunction)(void *, double *);
14 typedef void (*CentroidFunction)(void *, double *);
15 
16 // structure for list of elements in an octant
17 typedef struct elem {
18  void *region; // the pointer to a mesh Db region
19  double centroid[3]; // centroid of element bounding box inside of the octant
20  double minPt[3]; // corner of element bounding box nearest the origin
21  double maxPt[3]; // corner of elem bound box furthest from the origin
22  struct elem *next; // link to next item in list, NULL if end
23 } Elem;
24 typedef Elem *ELink;
25 
26 // stucture for octant buckets
27 struct bucket {
28  double minPt[3]; // the point with the smallest coordinates
29  double maxPt[3]; // the point with the biggest coordinates
30  int numElements; // number of elements contained by bucket
31  int precision; // the level of precision of the bucket
32  ELink lhead; // list of elements in bucket, if NULL -> no elements
33  std::vector<void *> listBB; // list of elements in bucket by Bounding Box
34  struct bucket *next; // link to ragged digit extensions to bucket array
35  struct bucket *parent; // link to the parent bucket
36 };
37 typedef struct bucket octantBucket;
38 
39 // structure for global information and requirment
40 struct global {
41  int numBuckets; // number of octant buckets in initial grid array
42  int maxElements; // max. number of elements allowed in an octant
43  int maxPrecision; // current maximum octant precision for model
44  double origin[3]; // smallest x,y, z of model's bounding box
45  double size[3]; // size in x, y, z of model bounding box
47  std::vector<void *> listAllElements;
48 };
49 typedef struct global globalInfo;
50 
51 class Octree {
52 public:
58 };
59 
60 void refineOctants(octantBucket *buckets, globalInfo *globalPara);
61 
62 int addElement2Bucket(octantBucket *bucket, void *element, double *minBB,
63  double *maxBB, double *ele_centroid,
64  globalInfo *globalPara);
66 int initializeOctantBuckets(double *orig, double *size, int maxElem,
67  octantBucket **buckets, globalInfo **globalPara);
69 octantBucket *findElementBucket(octantBucket *buckets, double *pt);
70 void *searchElement(octantBucket *buckets, double *pt, globalInfo *globalPara,
71  BBFunction BBElement, InEleFunction xyzInElement);
72 int xyzInElementBB(double *xyz, void *region, BBFunction BBElement);
73 void insertOneBB(void *, double *, double *, octantBucket *);
74 void *searchAllElements(octantBucket *_buckets_head, double *_pt,
75  globalInfo *_globalPara, BBFunction BBElement,
76  InEleFunction xyzInElement,
77  std::vector<void *> *_elements);
78 
79 #endif
Octree::function_inElement
InEleFunction function_inElement
Definition: OctreeInternals.h:56
checkElementInBucket
int checkElementInBucket(octantBucket *bucket, void *element)
Definition: OctreeInternals.cpp:191
refineOctants
void refineOctants(octantBucket *buckets, globalInfo *globalPara)
CentroidFunction
void(* CentroidFunction)(void *, double *)
Definition: OctreeInternals.h:14
global
Definition: OctreeInternals.h:40
xyzInElementBB
int xyzInElementBB(double *xyz, void *region, BBFunction BBElement)
Definition: OctreeInternals.cpp:354
elem::next
struct elem * next
Definition: OctreeInternals.h:22
searchAllElements
void * searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, BBFunction BBElement, InEleFunction xyzInElement, std::vector< void * > *_elements)
Definition: OctreeInternals.cpp:396
bucket
Definition: OctreeInternals.h:27
findElementBucket
octantBucket * findElementBucket(octantBucket *buckets, double *pt)
Definition: OctreeInternals.cpp:204
elem::maxPt
double maxPt[3]
Definition: OctreeInternals.h:21
bucket::minPt
double minPt[3]
Definition: OctreeInternals.h:28
InEleFunction
int(* InEleFunction)(void *, double *)
Definition: OctreeInternals.h:13
Octree::function_BB
BBFunction function_BB
Definition: OctreeInternals.h:55
Elem
struct elem Elem
insertOneBB
void insertOneBB(void *, double *, double *, octantBucket *)
Definition: OctreeInternals.cpp:371
Octree::info
globalInfo * info
Definition: OctreeInternals.h:53
bucket::lhead
ELink lhead
Definition: OctreeInternals.h:32
elem::region
void * region
Definition: OctreeInternals.h:18
bucket::numElements
int numElements
Definition: OctreeInternals.h:30
global::maxElements
int maxElements
Definition: OctreeInternals.h:42
bucket::next
struct bucket * next
Definition: OctreeInternals.h:34
Octree::root
octantBucket * root
Definition: OctreeInternals.h:54
Octree::function_centroid
CentroidFunction function_centroid
Definition: OctreeInternals.h:57
element
Definition: shapeFunctions.h:12
Octree
Definition: OctreeInternals.h:51
bucket::parent
struct bucket * parent
Definition: OctreeInternals.h:35
BBFunction
void(* BBFunction)(void *, double *, double *)
Definition: OctreeInternals.h:12
bucket::listBB
std::vector< void * > listBB
Definition: OctreeInternals.h:33
bucket::maxPt
double maxPt[3]
Definition: OctreeInternals.h:29
global::size
double size[3]
Definition: OctreeInternals.h:45
ELink
Elem * ELink
Definition: OctreeInternals.h:24
subdivideOctantBucket
int subdivideOctantBucket(octantBucket *bucket, globalInfo *globalPara)
Definition: OctreeInternals.cpp:236
elem::minPt
double minPt[3]
Definition: OctreeInternals.h:20
global::numBuckets
int numBuckets
Definition: OctreeInternals.h:41
bucket::precision
int precision
Definition: OctreeInternals.h:31
initializeOctantBuckets
int initializeOctantBuckets(double *orig, double *size, int maxElem, octantBucket **buckets, globalInfo **globalPara)
Definition: OctreeInternals.cpp:13
addElement2Bucket
int addElement2Bucket(octantBucket *bucket, void *element, double *minBB, double *maxBB, double *ele_centroid, globalInfo *globalPara)
Definition: OctreeInternals.cpp:111
elem::centroid
double centroid[3]
Definition: OctreeInternals.h:19
global::ptrToPrevElement
void * ptrToPrevElement
Definition: OctreeInternals.h:46
global::maxPrecision
int maxPrecision
Definition: OctreeInternals.h:43
global::origin
double origin[3]
Definition: OctreeInternals.h:44
elem
Definition: OctreeInternals.h:17
global::listAllElements
std::vector< void * > listAllElements
Definition: OctreeInternals.h:47
searchElement
void * searchElement(octantBucket *buckets, double *pt, globalInfo *globalPara, BBFunction BBElement, InEleFunction xyzInElement)
Definition: OctreeInternals.cpp:290