Signed Distance Fields 1.0
SDFNode Class Referenceabstract

Base signed distance node. More...

#include <sdf.h>

Inheritance diagram for SDFNode:
SDFBinary SDFPrimitive SDFUnary SDFBEIS SDFContact SDFDifference SDFInterpolation SDFIntersection SDFLod SDFMorph SDFUnion SDFVolume SDF3DNoisePrimitive SDFBlob SDFConvex SDFCuboctahedron SDFDodecahedron SDFEgg SDFEuclidean SDFExtrusionInterpolation SDFExtrusionNoise SDFFromPlanar SDFHeightField SDFHyperDisc SDFHyperEdge SDFHyperEllipsoid SDFHyperSphere SDFHyperTorus SDFIcosahedron SDFIcosidodecahedron SDFQuadricCylinder SDFQuadricSweptSphere SDFRhombicDodecahedron SDFRotational SDFSpheroid SDFTerrain SDFTerrainLoD SDFTerrainLoDContinuous SDFTerrainLoDContinuousBEIS SDFTestHeightfieldBinaire SDFVirtualHeightField SDFVoxel SDF3DNoise SDF3DNoiseNoLOD SDFAddSphere SDFBoundingBox SDFBoundingSphere SDFClone SDFCloneDirectionOverlapX SDFCloneDirectionX SDFCloneDirectionXY SDFCloneRevolution SDFColor SDFFrame SDFFrames SDFInstance SDFLodSphere SDFNoise SDFPlanarSymmetry SDFRevolutionSymmetry SDFRotate SDFRound SDFScale SDFTaper SDFTranslate SDFTriplanar SDFTurbulence SDFTwist SDFUniformScale SDFUniformSphere SDFVoxelize SDFWarpTurbulence

Public Member Functions

 SDFNode ()
 Create a generic node.
 
virtual ~SDFNode ()
 Destructor.
 
virtual double Signed (const Vector &) const
 Compute the signed distance.
 
virtual double BID (const Vector &) const
 Compute a lower bound of the signed distance.
 
virtual Vector Gradient (const Vector &) const
 Compute the gradient of the field.
 
virtual bool Inside (const Vector &) const
 Check if a point is inside or outside.
 
virtual Color GetColor (const Vector &) const
 Computes the color.
 
virtual int Memory () const
 Return the size of a sub-tree.
 
virtual double K () const
 Return the Lipschitz constant of the node.
 
virtual double K (const Box &) const
 Return the local Lipschitz constant.
 
Box GetBox () const
 Return the bounding box of the node.
 
virtual int Nodes () const
 Compute the number of nodes in the sub-tree.
 
virtual QString GetShader (PrimitiveManager *, std::list< QString > *, bool *=nullptr) const
 Compute the GLSL code to render the node.
 
virtual QString GetCostShader (PrimitiveManager *, std::list< QString > *, bool *=nullptr) const
 Compute the GLSL code to compute the cost of a call to sdf.
 
virtual QString GetGradientShader (PrimitiveManager *, std::list< QString > *, bool *=nullptr) const
 Compute the GLSL code to compute the gradient the sdf.
 
virtual QString GetMaterialShader (PrimitiveManager *, std::list< QString > *, bool *=nullptr) const
 Compute the GLSL code to compute the material the sdf at a given point 'p' with a given normal 'n'.
 
virtual void ComputeCostBID (const Vector &)
 Compute the number of reccursive calls to BID() and Signed().
 
virtual void ComputeCostSigned (const Vector &)
 Compute the number of reccursive calls to Signed().
 

Static Public Member Functions

static void ResetReccursiveCalls ()
 Reset the reccursive call property of the tree.
 
static int ReccursiveCalls ()
 Returns the number of reccursive calls to Value() and BID().
 
static void addReccursiveCalls (int)
 Add a nulber to the nbreccursiveCalls.
 
static SDFNodeStalactite (const Vector &p, const double &h, const double &r, bool noise=true, Random &random=Random::R239, const double &largeur=0.25, const double &espacement=0.61)
 Procedural parameterized stalactite.
 
static SDFNodeSpherePieces ()
 Sphere carved, placed on a cylinder. Nice scene for testing sharp features reconstruction.
 

Protected Attributes

Box box = Box::Infinity
 Box bounding the surface.
 
double k = 1.0
 Lipschitz constant.
 
int cost = 1
 Relative computation cost.
 

Static Protected Attributes

static constexpr double Epsilon = 0.01
 Small constant used for bounding volumes.
 
static int reccursiveCalls = 0
 Recursive calls to BID or Value.
 

Detailed Description

Base signed distance node.

Member Function Documentation

◆ addReccursiveCalls()

void SDFNode::addReccursiveCalls ( int incr)
static

Add a nulber to the nbreccursiveCalls.

Author
Hubert-Brierre Pierre

◆ BID()

double SDFNode::BID ( const Vector & p) const
virtual

Compute a lower bound of the signed distance.

The bound is not continuous, not even monotonous, but is faster to compute than the actual distance.

Author
Hubert-Brierre Pierre
Parameters
pPoint.

Reimplemented in SDFBEIS, SDFIntersection, and SDFUnion.

◆ ComputeCostBID()

void SDFNode::ComputeCostBID ( const Vector & p)
virtual

Compute the number of reccursive calls to BID() and Signed().

Author
Hubert-Brierre Pierre

Reimplemented in SDFBEIS, SDFIntersection, and SDFUnion.

◆ ComputeCostSigned()

void SDFNode::ComputeCostSigned ( const Vector & p)
virtual

Compute the number of reccursive calls to Signed().

Author
Hubert-Brierre Pierre

Reimplemented in SDFBEIS, SDFBinary, SDFExtrusionAxis, SDFExtrusionQuadric, SDFFrame, SDFFrames, SDFFromPlanar, SDFInterpolation, SDFPrimitive, SDFRotate, SDFScale, SDFTranslate, SDFUnary, and SDFUniformScale.

◆ GetColor()

Color SDFNode::GetColor ( const Vector & p) const
virtual

Computes the color.

Parameters
pPoint.

Reimplemented in SDFUnion.

◆ GetCostShader()

◆ GetGradientShader()

QString SDFNode::GetGradientShader ( PrimitiveManager * primitives,
std::list< QString > * dependency,
bool * valid_glsl = nullptr ) const
virtual

◆ GetMaterialShader()

QString SDFNode::GetMaterialShader ( PrimitiveManager * primitives,
std::list< QString > * dependency,
bool * valid_glsl = nullptr ) const
virtual

Compute the GLSL code to compute the material the sdf at a given point 'p' with a given normal 'n'.

Author
HUEBRT-BRIERRE Pierre

Reimplemented in SDFBEIS, SDFCloneRevolution, SDFDifference, SDFPrimitive, SDFTerrainLoDContinuous, SDFUnary, and SDFUnion.

◆ GetShader()

◆ Gradient()

◆ Inside()

bool SDFNode::Inside ( const Vector & p) const
virtual

Check if a point is inside or outside.

Parameters
pPoint.

◆ K() [1/2]

double SDFNode::K ( ) const
virtual

Return the Lipschitz constant of the node.

By default, nodes are considered as signed Euclidean distance functions, and the Lipschitz constant is λ=1.

Reimplemented in SDFLodSphere.

◆ K() [2/2]

double SDFNode::K ( const Box & b) const
virtual

Return the local Lipschitz constant.

Parameters
bBox

Reimplemented in SDFBinary, and SDFUnary.

◆ ReccursiveCalls()

int SDFNode::ReccursiveCalls ( )
static

Returns the number of reccursive calls to Value() and BID().

Author
Hubert-Brierre Pierre

◆ ResetReccursiveCalls()

void SDFNode::ResetReccursiveCalls ( )
static

Reset the reccursive call property of the tree.

Author
Hubert-Brierre Pierre

◆ Signed()

double SDFNode::Signed ( const Vector & p) const
virtual

Compute the signed distance.

Parameters
pPoint.

Reimplemented in SDF3DNoise, SDF3DNoiseNoLOD, SDF3DNoisePrimitive, SDFAddSphere, SDFBEIS, SDFBlob, SDFBoundingBox, SDFBoundingSphere, SDFBox, SDFBoxOpt, SDFBubble, SDFCage, SDFCapsule, SDFCircleArc, SDFClone, SDFCloneDirectionOverlapX, SDFCloneDirectionX, SDFCloneDirectionXY, SDFCloneRevolution, SDFCone, SDFContact, SDFConvex, SDFConvexSmooth, SDFCubicCurve, SDFCuboctahedron, SDFCylinder, SDFCylinderCage, SDFCylinderNoise, SDFDifference, SDFDifferenceShell, SDFDisc, SDFDodecahedron, SDFEgg, SDFEuclidean, SDFExtrudedEllipse, SDFExtrusionAxis, SDFExtrusionCubic, SDFExtrusionInterpolation, SDFExtrusionNoise, SDFExtrusionQuadric, SDFFrame, SDFFrames, SDFHeightField, SDFHemiSphere, SDFHemiSphereDisc, SDFHexagonal, SDFHyperDisc, SDFHyperEdge, SDFHyperEllipsoid, SDFHyperSphere, SDFHyperTorus, SDFIcosahedron, SDFIcosidodecahedron, SDFInstance, SDFInterpolation, SDFIntersection, SDFIntersectionShell, SDFLens, SDFLink, SDFLod, SDFLodSphere, SDFMesh, SDFMeshClamped, SDFMorph, SDFNoise, SDFOctahedron, SDFPlanarSymmetry, SDFPlane, SDFPolygonExtruded, SDFPrimitive, SDFPyramid, SDFQuadricCurve, SDFQuadricCurveNoise, SDFQuadricCylinder, SDFQuadricSweptSphere, SDFQuadricTube, SDFRectangle, SDFRevolution, SDFRevolutionSymmetry, SDFRhombicDodecahedron, SDFRotate, SDFRotational, SDFRound, SDFScale, SDFScales, SDFSector, SDFSegment, SDFSegmentNoiseRadial, SDFSlab, SDFSmoothDifference, SDFSmoothIntersection, SDFSmoothUnion, SDFSmoothUnionExp, SDFSmoothUnionSphereLOD, SDFSorQuadricTube, SDFSphere, SDFSphereCage, SDFSphereNoiseRadial, SDFSpheroid, SDFTaper, SDFTerrain, SDFTerrainLoD, SDFTerrainLoDContinuous, SDFTerrainLoDContinuousBEIS, SDFTestHeightfieldBinaire, SDFTetra, SDFTorus, SDFTranslate, SDFTriangle, SDFTriplanar, SDFTubular, SDFTurbulence, SDFTwist, SDFUnary, SDFUniformScale, SDFUniformSphere, SDFUnion, SDFUnionR, SDFVerticalCylinder, SDFVirtualHeightField, SDFVolume, SDFVoronoi, SDFVoxel, SDFVoxelize, and SDFWarpTurbulence.

◆ Stalactite()

SDFNode * SDFNode::Stalactite ( const Vector & p,
const double & h,
const double & r,
bool noise = true,
Random & random = Random::R239,
const double & largeur = 0.25,
const double & espacement = 0.61 )
static

Procedural parameterized stalactite.

Author
Lucie Fournier
Parameters
p: position (en haut) de la stalactite
h: la hauteur (longueur) de la stalactite
r: le rayon (en haut) de la stalactite
noise: si on ajoute ou non le bruit
random: pour les tirages aleatoires
largeur: difference de largeur entre les differentes spheres de la stalactite
espacement: force de l'espacement differentiel entre les differentes spheres de la stalactite