Signed Distance Fields 1.0
PrimitiveManager Class Reference

Primitive management in the construction tree. More...

#include <sdf.h>

Public Member Functions

 PrimitiveManager ()
 Handle the writing of glsl primitives in an order respecting the dependency.
 
bool insertPrimitive (QString, QString, std::list< QString >=std::list< QString >())
 add a primitive in the shader, return true if the primitive is inserted, false otherwise (if the primitive was already in the list)
 
void setDependence (QString, std::list< QString > &)
 set the dependency of a given primitive
 
QString getUniqueName ()
 get a primitive name that is not in the primitives set yet
 
QString getPRIMITIVE ()
 return a glsl code of all primitives in an order respecting the dependency
 
QString getPRIMITIVE (std::list< QString >)
 return a glsl code of all primitives in an order respecting the dependency
 
QString printGLSL ()
 Write PRIMITIVE code with identation and newline to help the reading.
 

Protected Member Functions

QString getPRIMITIVE (QString, std::map< QString, bool > &)
 Return the glsl code of a primitive and it's dependency.
 

Protected Attributes

std::map< QString, std::pair< QString, std::list< QString > > > primitives
 A map with primitive names as key, and a pair of (primitive code, list of primitive dependency) as data.
 

Detailed Description

Primitive management in the construction tree.

Constructor & Destructor Documentation

◆ PrimitiveManager()

PrimitiveManager::PrimitiveManager ( )
explicit

Handle the writing of glsl primitives in an order respecting the dependency.

Author
Hubert-Brierre Pierre

Member Function Documentation

◆ getPRIMITIVE() [1/3]

QString PrimitiveManager::getPRIMITIVE ( )

return a glsl code of all primitives in an order respecting the dependency

Author
Hubert-Brierre Pierre

◆ getPRIMITIVE() [2/3]

QString PrimitiveManager::getPRIMITIVE ( QString name,
std::map< QString, bool > & primitivesWritten )
protected

Return the glsl code of a primitive and it's dependency.

Author
Hubert-Brierre Pierre
Parameters
nameThe primitive to write.
primitivesWrittenA map to manage the primitives (true if the primitive is already written, false if the primitive is encouter but not written, not in the map if the primitive is not encouter yet).

◆ getPRIMITIVE() [3/3]

QString PrimitiveManager::getPRIMITIVE ( std::list< QString > names)

return a glsl code of all primitives in an order respecting the dependency

Author
Hubert-Brierre Pierre

◆ getUniqueName()

QString PrimitiveManager::getUniqueName ( )

get a primitive name that is not in the primitives set yet

Author
Hubert-Brierre Pierre

◆ insertPrimitive()

bool PrimitiveManager::insertPrimitive ( QString name,
QString glslCode,
std::list< QString > dependency = std::list<QString>() )

add a primitive in the shader, return true if the primitive is inserted, false otherwise (if the primitive was already in the list)

Author
Hubert-Brierre Pierre
Parameters
nameName of the primitive.
glslCodeCode of the primitive.
dependencyList of name of primitive that need to be written before this one.

◆ printGLSL()

QString PrimitiveManager::printGLSL ( )

Write PRIMITIVE code with identation and newline to help the reading.

Author
Hubert-Brierre Pierre

◆ setDependence()

void PrimitiveManager::setDependence ( QString name,
std::list< QString > & dependency )

set the dependency of a given primitive

Author
Hubert-Brierre Pierre
Parameters
nameName of the primitive.
dependencyList of name of primitive that need to be written before this one.