Namespaces | |
path | |
Classes | |
class | AutoResetEvent |
class | ErrorState |
class | MemoryStream |
class | UniquePtrConstMapWrapper |
class | UniquePtrConstVectorWrapper |
class | UniquePtrMapIterator |
class | UniquePtrMapWrapper |
class | UniquePtrVectorIterator |
class | UniquePtrVectorWrapper |
Typedefs | |
using | MeshConnectivityMap = std::vector< std::vector< Triangle > > |
Enumerations | |
enum | ETextOrientation : int { Left = 0, Center = 1, Right = 2 } |
Functions | |
bool NAPAPI | isTriangleMesh (const nap::MeshInstance &meshInstance) |
int NAPAPI | getTriangleCount (const MeshInstance &meshInstance) |
glm::vec3 NAPAPI | computeTriangleNormal (const TriangleData< glm::vec3 > &vertices) |
void NAPAPI | setTriangleIndices (nap::MeshShape &mesh, EDrawMode drawMode, int number, const std::array< int, 3 > &indices) |
void NAPAPI | computeBoundingBox (const nap::MeshInstance &mesh, nap::math::Box &outBox) |
math::Box NAPAPI | computeBoundingBox (const nap::MeshInstance &mesh) |
math::Box NAPAPI | computeBoundingBox (const nap::MeshInstance &mesh, const nap::MeshShape &shape) |
void NAPAPI | computeNormals (const nap::MeshInstance &mesh, const nap::VertexAttribute< glm::vec3 > &vertices, nap::VertexAttribute< glm::vec3 > &outNormals) |
void NAPAPI | reverseWindingOrder (nap::MeshInstance &mesh) |
void NAPAPI | generateIndices (nap::MeshShape &shape, int vertexCount, bool loop=false, int offset=0) |
void NAPAPI | computeConnectivity (const nap::MeshInstance &mesh, MeshConnectivityMap &outConnectivityMap) |
float NAPAPI | computeTriangleArea (const TriangleData< glm::vec3 > &vertices) |
float NAPAPI | computeArea (nap::MeshInstance &mesh, const nap::VertexAttribute< glm::vec3 > &vertices, std::vector< float > &outList) |
bool NAPAPI | intersect (const glm::vec3 &rayOrigin, const glm::vec3 &rayDirection, const TriangleData< glm::vec3 > &vertices, glm::vec3 &outCoordinates) |
glm::vec3 NAPAPI | computeBarycentric (const glm::vec3 &point, const TriangleData< glm::vec3 > &triangle) |
template<typename T > | |
T | interpolateVertexAttr (const TriangleData< T > &vertexValues, const glm::vec3 &barycentricCoordinates) |
bool | listDir (const char *directory, std::vector< std::string > &outFilenames, bool absolute=true) |
bool | isAbsolutePath (const std::string &path) |
std::string | getAbsolutePath (const std::string &relPath) |
std::string | getFileExtension (const std::string &filename) |
std::string | getFileName (const std::string &file) |
std::string | getFileDir (const std::string &file) |
std::string | getFileNameWithoutExtension (const std::string &file) |
void | stripFileExtension (std::string &file) |
std::string | stripFileExtension (const std::string &file) |
std::string | appendFileExtension (const std::string &file, const std::string &ext) |
bool | hasExtension (const std::string &file, const std::string &extension) |
bool | fileExists (const std::string &filename) |
bool | dirExists (const std::string &dirName) |
bool | ensureDirExists (const std::string &dirName) |
bool | makeDirs (const std::string &directory) |
bool | deleteFile (const std::string &path) |
void | writeStringToFile (const std::string &filename, const std::string &contents) |
std::string | toComparableFilename (const std::string &filename) |
bool | isFilenameEqual (const std::string &filenameA, const std::string &filenameB) |
bool | getFileModificationTime (const std::string &path, uint64_t &modTime) |
std::string | getExecutablePath () |
std::string | getExecutableDir () |
bool | changeDir (const std::string &newDir) |
bool | readFileToString (const std::string &filename, std::string &outBuffer, utility::ErrorState &err) |
std::string | findFileInDirectories (const std::string &filename, const std::vector< std::string > &dirs) |
std::string | joinPath (const std::vector< std::string > &parts) |
std::string | forceSeparator (const std::string &path) |
void | splitString (const std::string &string, const char delim, std::vector< std::string > &ioParts) |
std::vector< std::string > | splitString (const std::string &string, const char delim) |
template<typename T > | |
std::string | joinString (const T &list, const char *delim) |
void | writeString (std::ostream &stream, const std::string &text) |
std::string | readString (std::istream &stream) |
void | toLower (std::string &ioString) |
std::string | toLower (const std::string &string) |
std::string | stripNamespace (const std::string &str) |
void | tokenize (const std::string &str, std::list< std::string > &tokens, const std::string &delims, bool omitTokens=false) |
bool | startsWith (const std::string &string, const std::string &subString, bool caseSensitive=true) |
bool | endsWith (const std::string &string, const std::string &subString, bool caseSensitive=true) |
bool | contains (const std::string &string, const std::string &subString, bool caseSensitive=true) |
std::string | trim (const std::string &string) |
std::string | lTrim (const std::string &string) |
std::string | rTrim (const std::string &string) |
template<typename T > | |
std::string | addresStr (T thing) |
void | namedFormat (std::string &subject, const std::unordered_map< std::string, std::string > &rep) |
void | namedFormat (std::vector< std::string > &subjects, const std::unordered_map< std::string, std::string > &rep) |
std::string | replaceTemplateType (const std::string &typeName, const std::string &templateTypeName) |
void | replaceAllInstances (std::string &inString, const std::string &find, const std::string &replace) |
std::string | replaceAllInstances (const std::string &inString, const std::string &find, const std::string &replace) |
int | getLine (const std::string &buffer, size_t offset) |
template<typename... Args> | |
std::string | stringFormat (const char *format, Args &&... args) |
String utilities not offered by std::string
using MeshConnectivityMap = std::vector<std::vector<Triangle> > |
|
strong |
Controls the horizontal text draw orientation, vertical alignment is based on the character origin line This enum is serializable and can be used as a property
Enumerator | |
---|---|
Left | Draws text to the right of the horizontal coordinate. |
Center | Centers the text around the horizontal coordinate. |
Right | Draws the text to the left of the horizontal coordinate. |
std::string addresStr | ( | T | thing | ) |
Converts T in to a string using an std stringstream.
thing | the object to convert into a string |
std::string nap::utility::appendFileExtension | ( | const std::string & | file, |
const std::string & | ext | ||
) |
file | the file to add extension to |
ext | extension without preceding '.' |
bool nap::utility::changeDir | ( | const std::string & | newDir | ) |
Change current working directory
newDir | The working directory to change to |
float NAPAPI nap::utility::computeArea | ( | nap::MeshInstance & | mesh, |
const nap::VertexAttribute< glm::vec3 > & | vertices, | ||
std::vector< float > & | outList | ||
) |
Computes the area of every triangle in the mesh and stores the results in outList. The total is returned This call assumes the mesh has position vertex attribute data!
mesh | the mesh that contains the triangles |
vertices | the mesh vertex positions |
outList | a vector that contains the individual area of every triangle in the mesh |
glm::vec3 NAPAPI nap::utility::computeBarycentric | ( | const glm::vec3 & | point, |
const TriangleData< glm::vec3 > & | triangle | ||
) |
Computes the barycentric coordinates for a point with respect to a triangle
point | the position of the point in respect to the triangle |
triangle | the vertices of the triangle |
math::Box NAPAPI nap::utility::computeBoundingBox | ( | const nap::MeshInstance & | mesh | ) |
Computes the bounding box of a mesh using its associated position data Note that indices are not considered. This call loops over all available points regardless of whether they're drawn or not
mesh | the mesh to get the bounding box for |
math::Box NAPAPI nap::utility::computeBoundingBox | ( | const nap::MeshInstance & | mesh, |
const nap::MeshShape & | shape | ||
) |
Computes the bounding box of a single shape within a mesh using its associated position data. Note that the given shape must be part of the mesh.
mesh | the mesh that contains position data |
shape | the shape to compute the bounding box for |
outBox | the computed bounding box |
void NAPAPI nap::utility::computeBoundingBox | ( | const nap::MeshInstance & | mesh, |
nap::math::Box & | outBox | ||
) |
Computes the bounding box of a mesh using its associated position data. Note that indices are not considered. This call loops over all available points regardless of whether if they're drawn or not
mesh | the mesh to get the bounding box for |
outBox | the computed bounding box |
void NAPAPI nap::utility::computeConnectivity | ( | const nap::MeshInstance & | mesh, |
MeshConnectivityMap & | outConnectivityMap | ||
) |
Builds a 'map' that binds points (mesh index values) to faces The index in the array corresponds to a mesh vertex index (point). This call only works for meshes that have indices. When the mesh does not have indices this call asserts Try to avoid building the map regularly, it's a heavy operation This call asserts when the mesh is not a triangular mesh or has no indices associated with it
mesh | the mesh to get build the array from |
outConnectivityMap | the array that is populated with the triangles associated with a single index |
void NAPAPI nap::utility::computeNormals | ( | const nap::MeshInstance & | mesh, |
const nap::VertexAttribute< glm::vec3 > & | vertices, | ||
nap::VertexAttribute< glm::vec3 > & | outNormals | ||
) |
Automatically re-computes all the normals of a mesh When the mesh has indices the normal is computed based on connectivity Meshes without indices receive the triangular face normal
mesh | the triangular mesh |
vertices | the vertex position attribute |
outNormals | the recomputed normals, the normals have to be initialized and of the same length as the vertices |
float NAPAPI nap::utility::computeTriangleArea | ( | const TriangleData< glm::vec3 > & | vertices | ) |
vertices | the triangle vertex position data |
glm::vec3 NAPAPI nap::utility::computeTriangleNormal | ( | const TriangleData< glm::vec3 > & | vertices | ) |
Computes the normal that is associated with a triangular face. The normal is weighted (not normalized) This call asserts when the index is out of bounds.
vertices | mesh vertices |
bool nap::utility::contains | ( | const std::string & | string, |
const std::string & | subString, | ||
bool | caseSensitive = true |
||
) |
Checks if subString is present in string
string | the full string that could contain substring |
subString | part of the string that could be present in string |
caseSensitive | if the lookup is case sensitive or not |
bool nap::utility::deleteFile | ( | const std::string & | path | ) |
Delete the file at the specified path.
path | The path to the file to delete |
bool nap::utility::dirExists | ( | const std::string & | dirName | ) |
Check if a directory exists or not
dirName | name of the directory to check for |
bool nap::utility::endsWith | ( | const std::string & | string, |
const std::string & | subString, | ||
bool | caseSensitive = true |
||
) |
Checks if string ends with subString
string | the string to check |
subString | the part of the string to check for |
caseSensitive | if the lookup is case sensitive or now |
bool nap::utility::ensureDirExists | ( | const std::string & | dirName | ) |
Makes sure the given directory exists, attempts to create the directory if it does not exist, recursively
dirName | name of the directory to check for |
bool nap::utility::fileExists | ( | const std::string & | filename | ) |
Check whether a file exists or not.
filename | The absolute or relative file path to check for |
std::string nap::utility::findFileInDirectories | ( | const std::string & | filename, |
const std::vector< std::string > & | dirs | ||
) |
Find a file in one of the given directories.
file | The file to look for, including extension |
dirs | The directories to search in |
std::string nap::utility::forceSeparator | ( | const std::string & | path | ) |
Returns a file path with the correct path separator for the current platform.
path | path name to correct |
void NAPAPI nap::utility::generateIndices | ( | nap::MeshShape & | shape, |
int | vertexCount, | ||
bool | loop = false , |
||
int | offset = 0 |
||
) |
Generates a list of sequential indices from offset up to vertexCount + offset.
shape | The shape to generate indices for. |
vertexCount | number of indices to generate. |
loop | an extra index is added at the end, pointing to the the first one. Useful when creating a line loop. |
offset | The first index value. |
std::string nap::utility::getAbsolutePath | ( | const std::string & | relPath | ) |
Given a relative path, return an absolute path
relPath | The path to convert |
std::string nap::utility::getExecutableDir | ( | ) |
std::string nap::utility::getExecutablePath | ( | ) |
std::string nap::utility::getFileDir | ( | const std::string & | file | ) |
file | the filename |
std::string nap::utility::getFileExtension | ( | const std::string & | filename | ) |
Return the extension of the given filename. Eg. "my.directory/myFile.tar.gz" -> "gz"
filename | The filename to get the extension from |
bool nap::utility::getFileModificationTime | ( | const std::string & | path, |
uint64_t & | modTime | ||
) |
Get the modification time of the specified path
path | The path to the file |
modTime | The modification time of the file |
std::string nap::utility::getFileName | ( | const std::string & | file | ) |
file | the file to extract the name frame |
std::string nap::utility::getFileNameWithoutExtension | ( | const std::string & | file | ) |
file | path that is stripped |
int nap::utility::getLine | ( | const std::string & | buffer, |
size_t | offset | ||
) |
Based on a string and a character offset into this string, return the line number
buffer | The string to search |
offset | Character offset into the provided buffer |
int NAPAPI nap::utility::getTriangleCount | ( | const MeshInstance & | meshInstance | ) |
Returns the total number of triangles associated with a mesh.
meshInstance | the mesh to inspect. |
bool nap::utility::hasExtension | ( | const std::string & | file, |
const std::string & | extension | ||
) |
file | the file to check extension for |
extension | the file extension without preceding '.' |
T interpolateVertexAttr | ( | const TriangleData< T > & | vertexValues, |
const glm::vec3 & | barycentricCoordinates | ||
) |
Interpolates triangle vertex values based on barycentric u and v coordinates
vertexValues | the values associated with the triangle vertices |
barycentricCoordinates | the triangle barycentric coordinates (u,v,w) |
bool NAPAPI nap::utility::intersect | ( | const glm::vec3 & | rayOrigin, |
const glm::vec3 & | rayDirection, | ||
const TriangleData< glm::vec3 > & | vertices, | ||
glm::vec3 & | outCoordinates | ||
) |
Calculates the intersection of a ray and a triangle in 3 dimensions Based on the Moller Trumbore intersection algorithm: https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm Back-facing triangles relative to the ray direction are not considered
rayOrigin | the origin of the ray, often the world space position of a camera |
rayDirection | the direction of the ray from it's origin |
vertices | the triangle vertex positions |
outCoordinates | barycentric coordinates of point of intersection, where z is the scalar factor for the ray. |
bool nap::utility::isAbsolutePath | ( | const std::string & | path | ) |
Check if the given path is absolute
path | The path to check |
bool nap::utility::isFilenameEqual | ( | const std::string & | filenameA, |
const std::string & | filenameB | ||
) |
filenameA | filename to compare against filenameB. |
filenameB | filename to comapre against filenameA. |
bool NAPAPI nap::utility::isTriangleMesh | ( | const nap::MeshInstance & | meshInstance | ) |
Returns if the mesh is of type: TRIANGLES, TRIANGLE_STRIP or TRIANGLE_FAN
meshInstance | the mesh to check |
std::string nap::utility::joinPath | ( | const std::vector< std::string > & | parts | ) |
Join parts path parts using the correct path separator for the current platform
std::string joinString | ( | const T & | list, |
const char * | delim | ||
) |
Joins a list of strings together. For example: joinString({"one", "two", "three"}, ", ") -> becomes: "one, two, three"
list | The list of strings to join |
delim | The delimiter to inject between the elements |
bool nap::utility::listDir | ( | const char * | directory, |
std::vector< std::string > & | outFilenames, | ||
bool | absolute = true |
||
) |
List all files in a directory
directory | The directory to search in |
outFilenames | A vector of files to populate with filenames |
absolute | Whether to populate absolute filenames |
std::string nap::utility::lTrim | ( | const std::string & | string | ) |
Strips white space characters from the start(left) of a string
string | the string to remove white space characters from |
bool nap::utility::makeDirs | ( | const std::string & | directory | ) |
Attempts to create a directory with the given name, recursively. Creation will fail if the path is invalid or the directory already exists.
directory | path to the directory to create, absolute or relative. |
void nap::utility::namedFormat | ( | std::string & | subject, |
const std::unordered_map< std::string, std::string > & | rep | ||
) |
Replace all occurrences of the provided keys with their associated values in the given subject string. The keys in the subject string are to be wrapped in curly braces. Example: subject: My {animal}'s name is {name}, it's a good {animal}. replacement: {{"animal", "snake"}, {"name", "Donald"}} result: My snake's name is Donald, it's a good snake.
subject | The string to search and replace keys in. |
rep | The keys and values used in the replacement operation. |
void nap::utility::namedFormat | ( | std::vector< std::string > & | subjects, |
const std::unordered_map< std::string, std::string > & | rep | ||
) |
Replace all occurrences of the provided keys with their associated values in the given subject strings. The keys in the subject string are to be wrapped in curly braces. Example: subject: My {animal}'s name is {name}, it's a good {animal}. replacement: {{"animal", "snake"}, {"name", "Donald"}} result: My snake's name is Donald, it's a good snake.
subjects | The strings to search and replace keys in. |
rep | The keys and values used in the replacement operation. |
bool nap::utility::readFileToString | ( | const std::string & | filename, |
std::string & | outBuffer, | ||
utility::ErrorState & | err | ||
) |
Read the contents of a file into a string.
filename | Name of the file to read from |
outBuffer | The string in which the contents will be stored |
err | Will contain the error details if there were any problems. |
std::string nap::utility::readString | ( | std::istream & | stream | ) |
Reads a string form an input stream
stream | the stream to read the string from |
std::string nap::utility::replaceAllInstances | ( | const std::string & | inString, |
const std::string & | find, | ||
const std::string & | replace | ||
) |
Replace all instances of a string with a replacement string.
inString | The input string to search in |
find | The string to replace |
replace | The replacement string |
void nap::utility::replaceAllInstances | ( | std::string & | inString, |
const std::string & | find, | ||
const std::string & | replace | ||
) |
Replace all instances of search string with replacement
inString | The input string to search in |
find | The search string |
replace | The replacement string |
std::string nap::utility::replaceTemplateType | ( | const std::string & | typeName, |
const std::string & | templateTypeName | ||
) |
Given a templated type name, replace its template parameter with the provided template type.
typeName | The original templated type name, eg. "nap::MyType<SomeClass<float>>" |
templateTypeName | A replacement type name, eg. "float" |
void NAPAPI nap::utility::reverseWindingOrder | ( | nap::MeshInstance & | mesh | ) |
Reverses the winding order of all the triangle vertices in a mesh When a triangle has vertices A, B, C the new order will be C, B, A This call only works for triangle meshes that have indices associated with it This call asserts when the mesh is not a triangular mesh or the mesh has no indices
mesh | the mesh to reverse the index winding order for |
std::string nap::utility::rTrim | ( | const std::string & | string | ) |
Strips white space characters from the end(right) of a string string
string | the string to remove white space characters from |
void NAPAPI nap::utility::setTriangleIndices | ( | nap::MeshShape & | mesh, |
EDrawMode | drawMode, | ||
int | number, | ||
const std::array< int, 3 > & | indices | ||
) |
Sets the vertex indices associated with a triangle. Note that this function only works for meshes that are of type: TRIANGLES, TRIANGLE_STRIP or TRIANGLE_FAN This call asserts when the triangle number is out of bounds, the mesh has no indices or the draw mode is not of type triangle
mesh | the mesh to get the indices from |
number | the triangle number to get the for |
indices | the new indices |
std::vector<std::string> nap::utility::splitString | ( | const std::string & | string, |
const char | delim | ||
) |
void nap::utility::splitString | ( | const std::string & | string, |
const char | delim, | ||
std::vector< std::string > & | ioParts | ||
) |
bool nap::utility::startsWith | ( | const std::string & | string, |
const std::string & | subString, | ||
bool | caseSensitive = true |
||
) |
Checks if string starts with subString
string | the string to check |
subString | the part of the string to check for |
caseSensitive | if the lookup is case sensitive or not |
std::string nap::utility::stringFormat | ( | const char * | , |
Args &&... | args | ||
) |
Formats a string based on the incoming arguments example: utility::stringFormat("%s contains %d number of items", object.name().c_str(), i)
format | the string to format |
args | the arguments to replace |
std::string nap::utility::stripFileExtension | ( | const std::string & | file | ) |
file | the file to string the extension from |
void nap::utility::stripFileExtension | ( | std::string & | file | ) |
file | the file to strip the extension from |
std::string nap::utility::stripNamespace | ( | const std::string & | str | ) |
Strips all name space related identifiers from the given string.
str | the string to remove the namespace from |
std::string nap::utility::toComparableFilename | ( | const std::string & | filename | ) |
TODO: This may well be a platform independent 'toCanonicalFilename' or 'URI' as described here: https://en.wikipedia.org/wiki/File_URI_scheme
filename | the source filename. |
void nap::utility::tokenize | ( | const std::string & | str, |
std::list< std::string > & | tokens, | ||
const std::string & | delims, | ||
bool | omitTokens = false |
||
) |
Tokenize str into tokens.
str | the string to tokenize |
tokens | the tokens used to process the string |
delims | the delimiters used for the the tokenization process |
omitTokens | if the tokens are discarded from the result |
std::string nap::utility::toLower | ( | const std::string & | string | ) |
Converts all upper case characters in ioString to lower case characters
string | the input string that is converted |
void nap::utility::toLower | ( | std::string & | ioString | ) |
Converts all upper case characters in ioString to lower case characters
ioString | the input string that is converted to a lower case string |
std::string nap::utility::trim | ( | const std::string & | string | ) |
Strips white space characters from a string
string | the string to remove white space characters from |
void nap::utility::writeString | ( | std::ostream & | stream, |
const std::string & | text | ||
) |
Writes a string to an output stream
stream | the output stream to write to |
text | the string to write |
void nap::utility::writeStringToFile | ( | const std::string & | filename, |
const std::string & | contents | ||
) |
Dump a string to a file.
filename | The name of the file to write to. |
contents | The string to write |