Blob 1.0
|
The BlobTree model. More...
#include <blobtree.h>
Public Member Functions | |
BlobTree (TreeNode *=nullptr, const double &=0.5) | |
Creates a BlobTree. More... | |
virtual | ~BlobTree () |
Destroys the BlobTree structure, recursively exploring the nodes of the BlobTree. | |
BlobTree (const BlobTree &) | |
Overloaded. | |
BlobTree & | operator= (const BlobTree &) |
Overloaded. | |
TreeNode * | GetRoot () const |
Returns the root. More... | |
double | GetThreshold () const |
Returns the threshold value. More... | |
virtual double | Value (const Vector &) const |
Computes the field function value at a point. More... | |
virtual Vector | Gradient (const Vector &) const |
Computes the gradient of the field function at a point. More... | |
virtual void | IntensityGradient (const Vector &, double &, Vector &) const |
Overloaded to minimize function calls. More... | |
virtual double | Volume (int=5) const |
Computes the volume of the BlobTree. More... | |
virtual double | Volume (const Box &, int) const |
Compute the volume of a BlobTree object. More... | |
virtual double | Volume (const Box &, int, double &) const |
Compute the volume of a BlobTree object. More... | |
virtual Sphere | Center (int) const |
Computes the gravity center of the BlobTree. More... | |
virtual Sphere | Center (const Box &, int) const |
Compute the center of gravity of the BlobTree. More... | |
virtual BlobTree * | Copy () const |
Deep copy. More... | |
virtual double | K () const |
Computes the Lipschitz constant over the whole domain. More... | |
virtual double | K (int) const |
Computes the Lipschitz constant. More... | |
virtual double | K (const Box &) const |
Computes the Lipschitz constant of the field function in a limited region of space. More... | |
virtual double | K (const Ray &) const |
Computes the Lipschitz constant of the function along a ray. More... | |
virtual double | K (const Segment &) const |
Computes the Lipschitz constant along a segment. More... | |
virtual double | K (const RayStep &) const |
Computes the Lipschitz constant along an optimized ray-stepping segment. More... | |
virtual double | K (const Sphere &) const |
Computes the Lipschitz constant in a sphere. More... | |
virtual bool | SphereTrace (const Ray &, const double &, const double &, const double &, double &, int &, const double &=1e-4) const |
Find the first intersection between a ray and an implicit surface on a given interval, using sphere tracing. More... | |
virtual bool | SphereTrace (const Ray &, const double &, const double &, const double &, const double &, double &, int &, const double &=1e-4) const |
Find the first intersection between a ray and an implicit surface on a given interval, using sphere tracing. More... | |
virtual bool | SphereBoxTrace (const Ray &, const double &, const double &, const double &, double &, int &, const double &=1e-4) const |
Find the first intersection between a ray and an implicit surface on a given interval, using sphere tracing. More... | |
virtual bool | SphereSegmentTrace (const Ray &, const double &, const double &, const double &, double &, int &, const double &=1e-4) const |
Find the first intersection between a ray and an implicit surface on a given interval, using sphere tracing. More... | |
virtual bool | RayStepSegmentTrace (const Ray &, const double &, const double &, const double &, double &, int &, const double &=1e-4) const |
Find the first intersection between a ray and the implicit surface. | |
virtual bool | BinarySearch (const Ray &ray, const double &a, const double &b, double &t, int &x, const double &=1e-4, bool=false) const |
Compute the intersection with a ray, using binary search. More... | |
virtual bool | BinarySearch (const Ray &ray, const double &a, const double &b, const Vector &pa, const Vector &pb, const double &va, const double &vb, double &t, int &, const double &=1e-4, bool=false) const |
Compute the intersection with a ray, using binary search. More... | |
virtual Box | GetBox () const |
Return the bounding box of the BlobTree structure. More... | |
virtual Voxel | EmptyVoxels (int) const |
Step along the ray. More... | |
virtual Color | GetMaterial (const Vector &, const Vector &=Vector::Null) const |
Computes the surface parameters at a point. More... | |
BlobTree * | Cut (const Box &) const |
Cuts the BlobTree to simplify its structure inside a box. More... | |
void | Rotate (const Matrix &) |
Creates a union node at the top node of the BlobTree. More... | |
void | Translate (const Vector &) |
Creates a union node at the top node of the BlobTree. More... | |
void | Scale (const Vector &) |
Creates a union node at the top node of the BlobTree. More... | |
void | Blend (TreeNode *) |
Creates a union node at the top node of the BlobTree. More... | |
void | Difference (TreeNode *) |
Creates a difference node at the top node of the BlobTree. More... | |
void | Intersection (TreeNode *) |
Creates an intersection node at the top node of the BlobTree. More... | |
void | Union (TreeNode *) |
Creates a union node at the top node of the BlobTree. More... | |
BlobTree * | CenterBox () |
Centers the BlobTree at the origin. | |
BlobTree * | ScaleBox () |
Scales the BlobTree to a unit bounding box. More... | |
int | Memory () const |
Compute the size of the BlobTree. | |
int | Nodes () const |
Compute the number of nodes of the BlobTree. | |
int | Depth () const |
Compute the depth of the BlobTree. | |
Static Public Member Functions | |
static void | ResetCalls () |
Reset the number of function calls. | |
static int | Calls () |
Get the number of function calls. More... | |
static int | Oversteps () |
Return the number of overstep fails. | |
static TreeNode * | SplineVertex (const Vector &, const double &, const Vector &, const double &, const Vector &, const double &, const Vector &, const double &, const double &, int) |
Create a spline of TreeVertex primitives. More... | |
static BlobTree * | CreateCandlestick () |
Create a candlestick. | |
static BlobTree * | CreateAmphora (const double &=0.02) |
Creates an amphora. More... | |
static BlobTree * | CreateVase () |
Creates a vase. | |
static BlobTree * | CreateBear () |
Creates a soft-toy like bear. | |
static BlobTree * | CreateBird () |
Creates a soft-toy like bird. | |
static BlobTree * | CreateElk () |
Creates a soft-toy like elk. | |
static BlobTree * | CreateFlask () |
Create a liquor flask. | |
static BlobTree * | CreateFlaskGlass (bool=false, bool=false) |
Creates a flask. More... | |
static BlobTree * | ChessRook () |
Creates a rook. | |
static BlobTree * | ChessQueen () |
Creates a queen. | |
static BlobTree * | ChessKing () |
Creates a king. | |
static BlobTree * | CreateCube () |
Sphere pierced by three boxes. | |
static BlobTree * | Column (bool=false) |
Create a colum. More... | |
static BlobTree * | CreateCandle () |
Candle. | |
static BlobTree * | ScotchGlass () |
A simple glass. | |
static BlobTree * | WaterGlass () |
Creates a simple water glass. | |
static BlobTree * | Mechanic () |
Create a mechanical shape. | |
static BlobTree * | Candelabra () |
Creates the candelabra. | |
static BlobTree * | Chandelier3 () |
Create a candlestick. | |
static BlobTree * | ChampagneGlass () |
Create a simple twisted shape. | |
static BlobTree * | Stalactite (const Vector &, const double &, const double &) |
Create a stalactite. More... | |
Protected Attributes | |
double | T |
Threshold value. | |
TreeNode * | root |
Root node. | |
Static Protected Attributes | |
static int | calls = 0 |
Number of calls to Value(). | |
static int | oversteps = 0 |
Number of oversteps failed in ray marching. | |
The BlobTree model.
|
explicit |
Creates a BlobTree.
node | Root node. |
T | Threshold. |
|
virtual |
Compute the intersection with a ray, using binary search.
ray | The ray. |
a,b | Interval. |
pa,pb | Points. |
va,vb | Field function values. |
t | Intersection depth. |
x | Returned number of steps. |
e | Epsilon value. |
uk | Boolean, local segment Lipschitz bound if true, global Lipschitz bound otherwise. |
|
virtual |
Compute the intersection with a ray, using binary search.
ray | The ray. |
a,b | Interval. |
t | Intersection depth. |
x | Returned number of steps. |
e | Epsilon value. |
uk | Boolean, local segment Lipschitz bound if true, global Lipschitz bound otherwise. |
void BlobTree::Blend | ( | TreeNode * | node | ) |
Creates a union node at the top node of the BlobTree.
node | Sub-tree node. |
|
static |
Get the number of function calls.
This function returns the number of calls to BlobTree::Value() since the creation of the BlobTree. It can be reset to using ResetCalls().
Compute the center of gravity of the BlobTree.
box | Initial box. |
depth | Recursion depth. |
|
virtual |
Computes the gravity center of the BlobTree.
This function returns a sphere, the center is the center of gravity, and the radius is the volume.
depth | Recursion depth. |
|
static |
Create a colum.
type | Carvings, set to true if carvings are wanted. |
|
virtual |
Deep copy.
|
static |
Creates an amphora.
thickness | The thickness of the amphora. |
|
static |
Creates a flask.
type | Creates a hole in the flask is set to true |
side | Adds the handle. |
Cuts the BlobTree to simplify its structure inside a box.
b | Box. |
void BlobTree::Difference | ( | TreeNode * | node | ) |
Creates a difference node at the top node of the BlobTree.
node | Sub-tree node. |
|
virtual |
Step along the ray.
Compute a voxel whose cells are defined as empty if the statisfy the Lipschitz condition, or (possibly) non empty otherwise.
n | Maximum subdivision. |
|
virtual |
Return the bounding box of the BlobTree structure.
Reimplemented from AnalyticScalarField.
|
virtual |
Computes the surface parameters at a point.
p | Point. |
n | Normal. |
Reimplemented from AnalyticScalarField.
TreeNode * BlobTree::GetRoot | ( | ) | const |
Returns the root.
double BlobTree::GetThreshold | ( | ) | const |
Returns the threshold value.
Computes the gradient of the field function at a point.
p | Point. |
Reimplemented from AnalyticScalarField.
|
virtual |
Overloaded to minimize function calls.
p | Point. |
intensity | Returned field value. |
normal | Returned gradient. |
void BlobTree::Intersection | ( | TreeNode * | node | ) |
Creates an intersection node at the top node of the BlobTree.
node | Sub-tree node. |
|
virtual |
Computes the Lipschitz constant over the whole domain.
Reimplemented from AnalyticScalarField.
|
virtual |
Computes the Lipschitz constant of the field function in a limited region of space.
The implementation prunes the whole tree data structure, combining the Lipschitz constants of the nodes as needed if the bounding box of the node intersects the argument box.
b | The box. |
Reimplemented from AnalyticScalarField.
|
virtual |
Computes the Lipschitz constant of the function along a ray.
The implementation prunes the whole tree data structure, combining the Lipschitz constants of the nodes on the fly as needed.
ray | The ray. |
|
virtual |
Computes the Lipschitz constant along an optimized ray-stepping segment.
s | The ray-stepping segment. |
|
virtual |
Computes the Lipschitz constant along a segment.
s | The segment. |
Reimplemented from AnalyticScalarField.
|
virtual |
Computes the Lipschitz constant in a sphere.
s | The sphere. |
Reimplemented from AnalyticScalarField.
|
virtual |
Computes the Lipschitz constant.
Divides the domain into a grid, and compute the maximum of the local constants.
void BlobTree::Rotate | ( | const Matrix & | r | ) |
Creates a union node at the top node of the BlobTree.
r | Rotation matrix. |
void BlobTree::Scale | ( | const Vector & | s | ) |
Creates a union node at the top node of the BlobTree.
s | Scaling vector. |
BlobTree * BlobTree::ScaleBox | ( | ) |
Scales the BlobTree to a unit bounding box.
This is a convenience function, which simply computes the bounding box of the blobtree and inserts a new scaling node.
|
virtual |
Find the first intersection between a ray and an implicit surface on a given interval, using sphere tracing.
ray | The ray |
a,b | Interval where intersection is tracked. |
c | Acceleration factor defining the stepping distance increase factor [1.0,100.0], using 1.5 is fine. |
s | Returned number of steps. |
t | Nearest root, if exists |
epsilon | Precision for detecting ray-surface intersection. |
The function is almost the same as normal sphere-tracing. Instead of marching along the ray with valid steps, the magnitude of the step is slighly over estimated by a factor e.
|
virtual |
Find the first intersection between a ray and an implicit surface on a given interval, using sphere tracing.
ray | The ray |
a,b | Interval where intersection is tracked. |
c | Acceleration factor defining the stepping distance increase factor [1.0,100.0], using 1.5 is fine. |
s | Returned number of steps. |
t | Nearest root, if exists |
epsilon | Precision for detecting ray-surface intersection. |
The function is almost the same as normal sphere-tracing. Instead of marching along the ray with valid steps, the magnitude of the step is slighly over estimated by a factor e.
|
virtual |
Find the first intersection between a ray and an implicit surface on a given interval, using sphere tracing.
ray | The ray |
k | Lipschitz constant. |
a,b | Interval where intersection is tracked. |
e | Overstep factor, should be within interval [1.0,2.0], using 1.25 is fine. |
s | Returned number of steps. |
t | Nearest root, if exists |
epsilon | Precision for detecting ray-surface intersection. |
The function is almost the same as normal sphere-tracing. Instead of marching along the ray with valid steps, the magnitude of the step is slighly over estimated by a factor e.
|
virtual |
Find the first intersection between a ray and an implicit surface on a given interval, using sphere tracing.
ray | The ray |
k | Lipschitz constant. |
a,b | Interval where intersection is tracked. |
s | Return number of steps. |
t | Nearest root, if exists |
epsilon | Precision for detecting ray-surface intersection. |
Simply march along the ray using adaptive steps depending on the magnitude of the field function at point samples. Intersection occurs if the absolute value of the field function gets lower than epsilon.
In practice, if the Lipschitz constant is unknown, it may be accurately defined with the member function BlobTree::K(const Ray&). Thus, the code could be as follows:
Reimplemented from AnalyticScalarField.
|
static |
Create a spline of TreeVertex primitives.
a,b | Control points. |
na,nb | Control directions. |
ra,rb | Control radii. |
fa,fb | Control length of directions. |
It | Intensity. |
n | Number of elements. |
|
static |
Create a stalactite.
a | Starting position. |
length | Targent length of the stalactite, the generated model be slightly shorter. |
r | Initial radius. |
void BlobTree::Translate | ( | const Vector & | t | ) |
Creates a union node at the top node of the BlobTree.
t | Translation vector. |
void BlobTree::Union | ( | TreeNode * | node | ) |
Creates a union node at the top node of the BlobTree.
node | Sub-tree node. |
|
virtual |
Computes the field function value at a point.
If the root of the BlobTree is empty, this function returns -T.
p | Point. |
Reimplemented from AnalyticScalarField.
|
virtual |
Compute the volume of a BlobTree object.
box | Cube where volume computations will be performed. |
depth | Recursion depth. |
|
virtual |
Compute the volume of a BlobTree object.
box | Cube where volume computations will be performed. |
depth | Recursion depth. |
e | Error, i.e., amount of volume that could not be classified as inside or outside. |
|
virtual |
Computes the volume of the BlobTree.
Create an octree subdivision of space and check the differents cells of the octree using a Lipschitz criterion to determine whether cells are inside, outside or straddling the object.
depth | Recursion depth in the creation of the octree. |