Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106921978
tree.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Apr 2, 13:44
Size
4 KB
Mime Type
text/x-c++
Expires
Fri, Apr 4, 13:44 (2 d)
Engine
blob
Format
Raw Data
Handle
25281989
Attached To
rCADDMESH CADD_mesher
tree.hh
View Options
/**
* @file tree.hh
* @author Till Junge <junge@lsmspc42.epfl.ch>
* @date Wed Apr 25 10:37:27 2012
*
* @brief
*
* @section LICENSE
*
* <insert lisence here>
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __CADD_MESH_TREE_HH__
#define __CADD_MESH_TREE_HH__
#include "common.hh"
#include "point_container.hh"
#include <cmath>
#include "lattice.hh"
#include "domain.hh"
#include <fstream>
template
<
Uint
DIM
>
class
Tree
;
template
<
Uint
DIM
>
class
Tree
{
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public
:
/*! \param centre coordinates of origin. Can be \a NULL
* \param size_ of the initial rectangle in multiples of lattices
* \param lattice_
* \param domain_ */
Tree
(
const
Real
*
centre
,
Uint
size_
,
Lattice
<
DIM
>
*
lattice_
,
Domain
<
DIM
>
*
domain_
);
virtual
~
Tree
();
/* ------------------------------------------------------------------------ */
/* Iterator */
/* ------------------------------------------------------------------------ */
class
iterator
{
public
:
iterator
(
const
Tree
&
my_tree_
);
iterator
operator
++
();
Uint
*
operator
*
();
bool
operator
==
(
const
iterator
&
other
);
bool
operator
!=
(
const
iterator
&
other
)
{
return
!
(
*
this
==
other
);};
const
iterator
end
();
private
:
const
Tree
&
my_tree
;
Uint
fixed_dir
;
Uint
step
[
DIM
-
1
];
Uint
side
;
Uint
start
,
stop
;
bool
at_end
;
Uint
coords
[
DIM
];
};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public
:
iterator
getIterator
(){
return
iterator
(
*
this
);};
/// function to print the contain of the class
virtual
void
printself
(
std
::
ostream
&
stream
,
int
indent
=
0
)
const
;
/*!just splits the domain and calls fill_work on the children
* \param points this is where the points will be saved*/
void
fill
(
PointContainer
<
DIM
>
&
points
);
void
dump
(
std
::
string
file_name
=
"tree_diagnostic"
);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public
:
Uint
getNbBoxes
(){
return
this
->
nb_boxes
;}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private
:
/*! Private constructor is used for procreation
* \param south_west coordinates of sout-west corner of the new rectangle
* \param size_ of the initial rectangle in multiples of lattices
* \param lattice_
* \param domain_
* \param neighbours_ bitmask. for each direction, stores wheter there is a
* neigbour at the upper limit. E.g., 01 means that this
* rectangle has a neighbour to the right but none to
* on top
*/
Tree
(
Real
*
south_west_
,
Uint
size_
,
Lattice
<
DIM
>
*
lattice_
,
Domain
<
DIM
>
*
domain_
,
Uint
neighbours_
);
void
dump
(
std
::
ostream
&
stream
);
/*! splits the rectangle and sets the right neighbours */
void
split
();
/*! checks whether a rectangle needs to be split*/
bool
doIHaveToSplit
();
/*! self explanatory*/
void
create_points
(
PointContainer
<
DIM
>
&
points
);
/*! for debugging only */
bool
hasCornerInOrigin
();
Real
south_west
[
DIM
];
Uint
size
;
Domain
<
DIM
>
*
domain
;
Lattice
<
DIM
>
*
lattice
;
Uint
neighbours
;
std
::
vector
<
Tree
<
DIM
>
*>
children
;
Uint
level
;
static
unsigned
int
nb_boxes
;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
template
<
Uint
DIM
>
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
const
Tree
<
DIM
>
&
_this
)
{
_this
.
printself
(
stream
);
return
stream
;
}
#endif
/* __CADD_MESH_TREE_HH__ */
Event Timeline
Log In to Comment