Wildmeshing Toolkit
wmtk::components::utils Namespace Reference

Classes

struct  ComponentOptionsBase
 
class  PathResolver
 

Functions

attribute::MeshAttributeHandle get_attribute (const Mesh &m, const std::string &name)
 Get an attribute handle only by name. More...
 
attribute::MeshAttributeHandle get_attribute (const Mesh &m, const nlohmann::json &attribute)
 
std::vector< attribute::MeshAttributeHandleget_attributes (const Mesh &m, const nlohmann::json &attribute_names)
 
 WMTK_NLOHMANN_JSON_FRIEND_TO_JSON_PROTOTYPE (PathResolver)
 
 WMTK_NLOHMANN_JSON_FRIEND_FROM_JSON_PROTOTYPE (PathResolver)
 
fs::path resolve_path (const fs::path &root, const fs::path &path)
 
fs::path resolve_paths (const fs::path &root, const std::initializer_list< fs::path > &paths)
 
std::filesystem::path resolve_path_if_not_empty (const std::filesystem::path &root, const std::filesystem::path &path)
 Wraps resolve_path() but returns path directly if it is empty. More...
 
std::filesystem::path resolve_path (const std::filesystem::path &root, const std::filesystem::path &path)
 Wraps the path concatenation root / path. More...
 
std::filesystem::path resolve_paths (const std::filesystem::path &root, const std::initializer_list< std::filesystem::path > &paths)
 Call resolve_path() to concatenate several paths. More...
 

Function Documentation

◆ get_attribute() [1/2]

attribute::MeshAttributeHandle wmtk::components::utils::get_attribute ( const Mesh m,
const nlohmann::json attribute 
)

Definition at line 49 of file get_attributes.cpp.

References get_attribute(), and wmtk::log_and_throw_error().

Here is the call graph for this function:

◆ get_attribute() [2/2]

attribute::MeshAttributeHandle wmtk::components::utils::get_attribute ( const Mesh m,
const std::string &  name 
)

Get an attribute handle only by name.

If there is no or multiple attributes, an error is thrown.

Parameters
mMesh holding the attribute.
nameName of the attribute.

Definition at line 14 of file get_attributes.cpp.

References wmtk::Mesh::get_attribute_handle(), wmtk::Mesh::has_attribute(), wmtk::log_and_throw_error(), wmtk::utils::primitive_below(), and wmtk::Mesh::top_simplex_type().

Referenced by get_attribute(), and get_attributes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_attributes()

std::vector< attribute::MeshAttributeHandle > wmtk::components::utils::get_attributes ( const Mesh m,
const nlohmann::json attribute_names 
)

Definition at line 67 of file get_attributes.cpp.

References get_attribute().

Referenced by wmtk::components::gather_attributes(), and wmtk::components::wildmeshing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resolve_path() [1/2]

fs::path wmtk::components::utils::resolve_path ( const fs::path &  root,
const fs::path &  path 
)

Definition at line 10 of file resolve_path.cpp.

Referenced by wmtk::components::export_cache(), wmtk::components::import_cache(), resolve_path_if_not_empty(), resolve_paths(), and wmtk::components::run_components().

Here is the caller graph for this function:

◆ resolve_path() [2/2]

std::filesystem::path wmtk::components::utils::resolve_path ( const std::filesystem::path &  root,
const std::filesystem::path &  path 
)

Wraps the path concatenation root / path.

If path is absolute it is returned the way it is and root is ignored. If root is a file the containing folder is considered as root path.

Examples: root = "a/" path = "b.txt" returns: "a/b.txt"

root = "a/f.json" path = "o/b.txt" returns: "a/o/b.txt"

root = "a/" path = "/c/b.txt" returns: "/c/b.txt"

An exception is thrown if the root path does not exist.

Parameters
rootThe folder used as root. If it is a file the parent folder is used as root.
pathThe path that should be made absolute.
Returns
The absolute path.

◆ resolve_path_if_not_empty()

std::filesystem::path wmtk::components::utils::resolve_path_if_not_empty ( const std::filesystem::path &  root,
const std::filesystem::path &  path 
)

Wraps resolve_path() but returns path directly if it is empty.

Definition at line 38 of file resolve_path.cpp.

References resolve_path().

Here is the call graph for this function:

◆ resolve_paths() [1/2]

fs::path wmtk::components::utils::resolve_paths ( const fs::path &  root,
const std::initializer_list< fs::path > &  paths 
)

Definition at line 27 of file resolve_path.cpp.

References resolve_path().

Here is the call graph for this function:

◆ resolve_paths() [2/2]

std::filesystem::path wmtk::components::utils::resolve_paths ( const std::filesystem::path &  root,
const std::initializer_list< std::filesystem::path > &  paths 
)

Call resolve_path() to concatenate several paths.

The behavior resembles: root / path_1 / path_2 / path_3 / ...

◆ WMTK_NLOHMANN_JSON_FRIEND_FROM_JSON_PROTOTYPE()

wmtk::components::utils::WMTK_NLOHMANN_JSON_FRIEND_FROM_JSON_PROTOTYPE ( PathResolver  )

Definition at line 101 of file PathResolver.cpp.

◆ WMTK_NLOHMANN_JSON_FRIEND_TO_JSON_PROTOTYPE()

wmtk::components::utils::WMTK_NLOHMANN_JSON_FRIEND_TO_JSON_PROTOTYPE ( PathResolver  )

Definition at line 97 of file PathResolver.cpp.