Signed Distance Fields 1.0
SDFPolygon2 Class Reference

Euclidean signed distance field for a planar polygon. More...

#include <sdf.h>

Inheritance diagram for SDFPolygon2:
SDFEuclidean2 Polygon2 SDFPrimitive2 SDFNode2

Public Member Functions

 SDFPolygon2 (const Polygon2 &, bool=false, double=0.0)
 Create a polygon primitive.
 
 SDFPolygon2 (const QVector< Vector2 > &, bool=false, double=0.0)
 Create a polygon.
 
virtual ~SDFPolygon2 ()
 Destructor.
 
double Signed (const Vector2 &) const
 Compute the signed Euclidean distance function.
 
QString GetShader (PrimitiveManager *, std::list< QString > *, bool *) const
 Compute the GLSL code to render the node.
 
virtual int Memory () const
 Return the size of a sub-tree.
 
virtual SDFNode2Copy () const
 Deep copy.
 
- Public Member Functions inherited from SDFEuclidean2
 SDFEuclidean2 ()
 Create an Euclidean primitive.
 
virtual ~SDFEuclidean2 ()
 Destructor.
 
- Public Member Functions inherited from SDFPrimitive2
 SDFPrimitive2 ()
 Create a primitive.
 
virtual ~SDFPrimitive2 ()
 Destructor.
 
virtual QString GetCostShader (PrimitiveManager *, std::list< QString > *, bool *) const
 Compute the GLSL code to compute the cost of a call to sdf.
 
virtual void ComputeCostSigned (const Vector2 &)
 Compute the number of reccursive calls to Signed().
 
- Public Member Functions inherited from SDFNode2
 SDFNode2 ()
 Create a generic node.
 
virtual ~SDFNode2 ()
 Destructor.
 
virtual Vector2 Gradient (const Vector2 &) const
 Compute the gradient of the field.
 
virtual bool Inside (const Vector2 &) const
 Check if a point is inside or outside.
 
virtual QString GetGradientShader (PrimitiveManager *, std::list< QString > *, bool *=nullptr) const
 Compute the GLSL code to compute the gradient the sdf.
 
virtual double K () const
 Return the Lipschitz constant of the node.
 
Box2 GetBox () const
 Return the bounding box of the node.
 
virtual int Nodes () const
 Compute the number of nodes in the sub-tree.
 

Protected Attributes

double thickness
 Thickness.
 
bool hollow
 Hollow flag.
 
- Protected Attributes inherited from SDFNode2
Box2 box = Box2::Infinity
 Box bounding the surface.
 
double k = 1.0
 Lipschitz constant.
 
int cost = 1
 Cost of the node.
 

Additional Inherited Members

- Static Protected Attributes inherited from SDFNode2
static constexpr double Epsilon = 0.01
 Small constant used for bounding volumes.
 

Detailed Description

Euclidean signed distance field for a planar polygon.

Author
Lucie Fournier

Constructor & Destructor Documentation

◆ SDFPolygon2() [1/2]

SDFPolygon2::SDFPolygon2 ( const Polygon2 & p,
bool h = false,
double t = 0.0 )
explicit

Create a polygon primitive.

Parameters
pPolygon.
hHollow parameter.
tThickness.

◆ SDFPolygon2() [2/2]

SDFPolygon2::SDFPolygon2 ( const QVector< Vector2 > & q,
bool h = false,
double t = 0.0 )
explicit

Create a polygon.

Parameters
qArray of points.
hHollow parameter.
tThickness.

Member Function Documentation

◆ GetShader()

QString SDFPolygon2::GetShader ( PrimitiveManager * primitives,
std::list< QString > * dependency,
bool * valid_glsl ) const
virtual

Compute the GLSL code to render the node.

Author
Hubert-Brierre Pierre

Reimplemented from SDFNode2.

◆ Memory()

int SDFPolygon2::Memory ( ) const
virtual

Return the size of a sub-tree.

Reimplemented from SDFNode2.

◆ Signed()

double SDFPolygon2::Signed ( const Vector2 & p) const
virtual

Compute the signed Euclidean distance function.

By default compute the signed distance to the bounding box of the primitive.

Parameters
pPoint.

Internally, call Polygon2::Signed(const Vector2&).

Reimplemented from SDFEuclidean2.