TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Octree_Int.h
1/****************************************************************************
2* Copyright (c) 2024, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15#ifndef Octree_Int_included
16#define Octree_Int_included
17
18#include <TRUSTArrays.h>
19#include <TRUSTTab.h>
20#include <ArrOfBit.h>
21
22template <typename _SIZE_> struct IntBoxData;
23
24/*! @brief : Un octree permettant de retrouver des objets ponctuels ou parallelipipediques dans un espace 1D, 2D ou 3D et des coordonnees entieres
25 */
26template <typename _SIZE_>
28{
29public:
30 using int_t = _SIZE_;
31 using ArrOfInt_t = ArrOfInt_T<_SIZE_>;
32 using IntTab_t = IntTab_T<_SIZE_>;
33 using ArrOfDouble_t= ArrOfDouble_T<_SIZE_>;
34 using DoubleTab_t = DoubleTab_T<_SIZE_>;
35 using ArrsOfInt_t = ArrsOfInt_T<_SIZE_>;
37 using AOFlagS_ = TRUST_Vector<AOFlag_>; // A vector of arrays of small values (flags here)
38
39
40 void build(const int dimension, const IntTab_t& elements_boxes);
41 int_t search_elements(int x, int y, int z, int_t& floor_elements_index) const;
42 int_t search_elements_box(int xmin, int ymin, int zmin, int xmax, int ymax, int zmax, ArrOfInt_t& elements) const;
43 void reset();
44
45 inline const ArrOfInt_t& floor_elements() const { return floor_elements_; }
46
47 // Le plus grand int autorise pour les coordonnees (du type 2^n - 1)
48 static const int coord_max_;
49 // Premier int de la moitie superieure de l'octree root (si coord_max_=2^n-1, half_width_=2^(n-1))
50 static const int root_octree_half_width_;
51
52protected:
53 int_t build_octree_recursively(const int octree_center_x, const int octree_center_y, const int octree_center_z,
54 const int octree_half_width,
55 const IntTab_t& elements_boxes,
56 ArrsOfInt_t& vect_elements_list,
57 const int level,
58 AOFlagS_& tmp_elem_flags);
59 int_t build_octree_floor(const ArrOfInt_t& elements_list);
60 int_t search_octree_floor(int x_pos, int y_pos, int z_pos) const;
61 void search_elements_box_floor(IntBoxData<_SIZE_>& boxdata, int_t octree_floor_id) const;
62 void search_elements_box_recursively(IntBoxData<_SIZE_>& boxdata, int_t octree_id, int cx, int cy, int cz, int half_width) const;
63
64 // Un octree peut etre soit vide, soit subdivise en nb_octrees autres octrees,
65 // soit un octree_floor contenant une liste d'elements.
67
68 static inline int_t octree_id(int_t index, Octree_Type type);
69 static inline int_t octree_index(int_t octree_id, Octree_Type type);
71
72 // Octree_id du cube principal : peut etre EMPTY, OCTREE ou FLOOR
74 // Nombre d'elements stockes (dimension(0) du tableau elements_boxes)
76 // Tableau contenant tous les cubes qui sont divises en sous-cubes
77 // octree_structure_(i, j) decrit le contenu du sous-cube j du cube d'index i.
78 // pour 0 <= j < nombre de sous-cubes par cube.
79 // On appelle "octree_id" une valeur X=octree_structure_(i,j) (identifiant octree)
80 // L'octree id encode a la fois le type de l'octree et l'index ou
81 // il se trouve dans les tableaux (voir octree_id(int, Octree_Type))
83
84 // Tableau contenant la liste des elements de chaque sous-cube final non subdivise.
85 // Si X < 0, on note i_debut = -X-1.
86 // floor_elements_(i_debut) = n = nombre d'elements dans ce sous-cube
87 // floor_elements_[i_debut+j] = numero d'un element qui coupe ce sous-cube pour 1 <= j <= n
89};
90
91#endif
: Un octree permettant de retrouver des objets ponctuels ou parallelipipediques dans un espace 1D,...
Definition Octree_Int.h:28
int_t search_octree_floor(int x_pos, int y_pos, int z_pos) const
renvoie l'octree_id de l'octree_floor contenant le sommet (x,y,z) (peut renvoyer l'octree EMPTY)
ArrOfDouble_T< _SIZE_ > ArrOfDouble_t
Definition Octree_Int.h:33
static Octree_Type octree_type(int_t octree_id)
Renvoie le type d'un octree en fonction de son octree_id.
void search_elements_box_recursively(IntBoxData< _SIZE_ > &boxdata, int_t octree_id, int cx, int cy, int cz, int half_width) const
cherche recursivement les elements inclus dans la boite boxdata pour l'octree_id donne,...
int_t search_elements_box(int xmin, int ymin, int zmin, int xmax, int ymax, int zmax, ArrOfInt_t &elements) const
cherche les elements ayant potentiellement une intersection non vide avec la boite xmin....
ArrOfInt_T< _SIZE_ > ArrOfInt_t
Definition Octree_Int.h:31
IntTab_T< _SIZE_ > IntTab_t
Definition Octree_Int.h:32
ArrOfInt_t floor_elements_
Definition Octree_Int.h:88
int_t build_octree_recursively(const int octree_center_x, const int octree_center_y, const int octree_center_z, const int octree_half_width, const IntTab_t &elements_boxes, ArrsOfInt_t &vect_elements_list, const int level, AOFlagS_ &tmp_elem_flags)
octree_center_i est le premier int de la moitie superieure de l'octree dans la direction i.
static const int root_octree_half_width_
Definition Octree_Int.h:50
static int_t octree_id(int_t index, Octree_Type type)
construction d'un octree_id (voir octree_structure_)
TRUSTArray< int, _SIZE_ > AOFlag_
Definition Octree_Int.h:36
int_t root_octree_id_
Definition Octree_Int.h:73
IntTab_t octree_structure_
Definition Octree_Int.h:82
DoubleTab_T< _SIZE_ > DoubleTab_t
Definition Octree_Int.h:34
ArrsOfInt_T< _SIZE_ > ArrsOfInt_t
Definition Octree_Int.h:35
int_t search_elements(int x, int y, int z, int_t &floor_elements_index) const
renvoie la liste des elements contenant potentiellement le point (x,y,z) On renvoie n=nombre d'elemen...
static int_t octree_index(int_t octree_id, Octree_Type type)
calcul de l'index de l'octree dans octree_structure ou floor_elements en fonction du type de l'octree...
void search_elements_box_floor(IntBoxData< _SIZE_ > &boxdata, int_t octree_floor_id) const
ajoute des elements de l'octree_floor a boxdata.
const ArrOfInt_t & floor_elements() const
Definition Octree_Int.h:45
TRUST_Vector< AOFlag_ > AOFlagS_
Definition Octree_Int.h:37
static const int coord_max_
Definition Octree_Int.h:48
int_t build_octree_floor(const ArrOfInt_t &elements_list)
construit un octree_floor avec la liste d'elements donnee et renvoie l'octree_id de cet octree_floor
void build(const int dimension, const IntTab_t &elements_boxes)
construction de l'octree.
Represents a an array of int/int64/double/... values.
Definition TRUSTArray.h:81
classe TRUST_Vector