Blob 1.0
|
The BlobTree model. More...
#include <blobtree.h>
Public Member Functions | |
BlobTree (TreeNode *=nullptr, const double &=0.5) | |
Creates a BlobTree. | |
virtual | ~BlobTree () |
Destroys the BlobTree structure, recursively exploring the nodes of the BlobTree. | |
BlobTree (const BlobTree &) | |
Overloaded. | |
BlobTree & | operator= (const BlobTree &) |
Overloaded. | |
double | GetThreshold () const |
Returns the threshold value. | |
virtual double | Value (const Vector &) const |
Computes the field function value at a point. | |
virtual Vector | Gradient (const Vector &) const |
Computes the gradient of the field function at a point. | |
virtual void | IntensityGradient (const Vector &, double &, Vector &) const |
Overloaded to minimize function calls. | |
virtual BlobTree * | Copy () const |
Deep copy. | |
virtual double | K () const |
Computes the Lipschitz constant over the whole domain. | |
virtual double | K (int) const |
Computes the Lipschitz constant. | |
virtual double | K (const Box &) const |
Computes the Lipschitz constant of the field function in a limited region of space. | |
virtual double | K (const Ray &) const |
Computes the Lipschitz constant of the function along a ray. | |
virtual double | K (const Segment &) const |
Computes the Lipschitz constant along a segment. | |
virtual double | K (const RayStep &) const |
Computes the Lipschitz constant along an optimized ray-stepping segment. | |
virtual double | K (const Sphere &) const |
Computes the Lipschitz constant in a sphere. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
virtual Box | GetBox () const |
Return the bounding box of the BlobTree structure. | |
virtual double | Omega (const Vector &) const |
Return the squared distance to the compact support of the BlobTree. | |
virtual Voxel | EmptyVoxels (int) const |
Compute a voxel whose cells are defined as empty if the statisfy the Lipschitz condition, or (possibly) non empty otherwise. | |
virtual Color | GetMaterial (const Vector &, const Vector &=Vector::Null) const |
Computes the surface parameters at a point. | |
BlobTree * | Cut (const Box &) const |
Cuts the BlobTree to simplify its structure inside a box. | |
void | Rotate (const Matrix &) |
Creates a union node at the top node of the BlobTree. | |
void | Translate (const Vector &) |
Creates a union node at the top node of the BlobTree. | |
void | Scale (const Vector &) |
Creates a union node at the top node of the BlobTree. | |
void | Blend (TreeNode *) |
Creates a blending node at the top node of the BlobTree. | |
void | Difference (TreeNode *) |
Creates a difference node at the top node of the BlobTree. | |
void | Intersection (TreeNode *) |
Creates an intersection node at the top node of the BlobTree. | |
void | Union (TreeNode *) |
Creates a union node at the top node of the BlobTree. | |
BlobTree * | CenterBox () |
Centers the BlobTree at the origin. | |
BlobTree * | ScaleBox () |
Scales the BlobTree to a unit bounding box. | |
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. | |
static int | Oversteps () |
Return the number of overstep fails. | |
static BlobTree * | CreateCandlestick () |
Create a candlestick. | |
static BlobTree * | CreateAmphora (const double &=0.02) |
Creates an amphora. | |
static BlobTree * | CreateVase () |
Creates a vase. | |
static BlobTree * | CreateBear (bool=false) |
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. | |
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. | |
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 TreeNode * | Stalactite (const Vector &, const double &, const double &) |
Create a stalactite. | |
Protected Attributes | |
double | T = 0.5 |
Threshold value. | |
TreeNode * | root = nullptr |
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. |
double BlobTree::GetThreshold | ( | ) | const |
Returns the threshold value.
|
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.
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. |
|
virtual |
Deep copy.
|
virtual |
Computes the Lipschitz constant over the whole domain.
Reimplemented from AnalyticScalarField.
|
virtual |
Computes the Lipschitz constant.
Divides the domain into a grid, and compute the maximum of the local constants.
|
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 a segment.
s | The segment. |
Reimplemented from AnalyticScalarField.
|
virtual |
Computes the Lipschitz constant along an optimized ray-stepping segment.
s | The ray-stepping segment. |
|
virtual |
Computes the Lipschitz constant in a sphere.
s | The sphere. |
Reimplemented from AnalyticScalarField.
|
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.
|
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 |
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 |
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. |
|
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 |
Return the bounding box of the BlobTree structure.
Reimplemented from AnalyticScalarField.
|
virtual |
Return the squared distance to the compact support of the BlobTree.
Some primitives such as TreeTwist return the squared distance to the bounding box as a default proxy.
p | Point. |
|
virtual |
Compute a voxel whose cells are defined as empty if the statisfy the Lipschitz condition, or (possibly) non empty otherwise.
n | Maximum subdivision. |
|
virtual |
Computes the surface parameters at a point.
p | Point. |
n | Normal. |
Reimplemented from AnalyticScalarField.
Cuts the BlobTree to simplify its structure inside a box.
b | Box. |
void BlobTree::Rotate | ( | const Matrix & | r | ) |
Creates a union node at the top node of the BlobTree.
r | Rotation matrix. |
void BlobTree::Translate | ( | const Vector & | t | ) |
Creates a union node at the top node of the BlobTree.
t | Translation vector. |
void BlobTree::Scale | ( | const Vector & | s | ) |
Creates a union node at the top node of the BlobTree.
s | Scaling vector. |
void BlobTree::Blend | ( | TreeNode * | node | ) |
Creates a blending node at the top node of the BlobTree.
node | Sub-tree. |
void BlobTree::Difference | ( | TreeNode * | node | ) |
Creates a difference node at the top node of the BlobTree.
node | Sub-tree. |
void BlobTree::Intersection | ( | TreeNode * | node | ) |
Creates an intersection node at the top node of the BlobTree.
node | Sub-tree. |
void BlobTree::Union | ( | TreeNode * | node | ) |
Creates a union node at the top node of the BlobTree.
node | Sub-tree. |
BlobTree * BlobTree::ScaleBox | ( | ) |
|
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().
|
static |
Creates an amphora.
thickness | The thickness of the amphora. |
|
static |
Creates a soft-toy like bear.
symmetry | Boolean, set to false so avoid symmetry operator, true using a TreeCloneFrame |
|
static |
Creates a flask.
type | Creates a hole in the flask is set to true |
side | Adds the handle. |
|
static |
Create a colum.
type | Carvings, set to true if carvings are wanted. |