Adds a suffix to the filename of a given file path.
Adds a suffix to the filename of a given file path.This function appends a given suffix to the stem (base name without extension) of a file while preserving the original directory and file extension.
#pragma once
#include <filesystem>
#include <map>
#include <opencv2/imgcodecs.hpp>
#include <png.h>
{
{
};
static std::map<MeshType, std::string> mesh_type_as_string = {
{
};
static std::map<AssetExportFormat, std::vector<std::string> >
asset_export_format_as_string = {
{
_3DS, {
"Autodesk 3DS (legacy) - *.3ds",
"3ds",
"3ds"}},
{
_3MF, {
"The 3MF-File-Format - *.3mf",
"3mf",
"3mf"}},
{
ASSBIN, {
"Assimp Binary - *.assbin",
"assbin",
"assbin"}},
{
ASSXML, {
"Assxml Document - *.assxml",
"assxml",
"assxml"}},
{
FXBA, {
"Autodesk FBX (ascii) - *.fbx",
"fbxa",
"fbx"}},
{
FBX, {
"Autodesk FBX (binary) - *.fbx",
"fbx",
"fbx"}},
{
COLLADA, {
"COLLADA - Digital Asset Exchange Schema - *.dae",
"collada",
"dae"}},
{
X3D, {
"Extensible 3D - *.x3d",
"x3d",
"x3d"}},
{
GLTF, {
"GL Transmission Format - *.gltf",
"gltf",
"gltf"}},
{
GLB, {
"GL Transmission Format (binary) - *.glb",
"glb",
"glb"}},
{
GTLF2, {
"GL Transmission Format v. 2 - *.gltf",
"gltf2",
"gltf"}},
{
GLB2, {
"GL Transmission Format v. 2 (binary) - *.glb",
"glb2",
"glb"}},
{
PLY, {
"Stanford Polygon Library - *.ply",
"ply",
"ply"}},
{
PLYB, {
"Stanford Polygon Library (binary) - *.ply",
"plyb",
"ply"}},
{
STP, {
"Step Files - *.stp",
"stp",
"stp"}},
{
STL, {
"Stereolithography - *.stl",
"stl",
"stl"}},
{
STLB, {
"Stereolithography (binary) - *.stl",
"stlb",
"stl"}},
{
OBJ, {
"Wavefront OBJ format - *.obj",
"obj",
"obj"}},
{
OBJNOMTL, {
"Wavefront OBJ format without material file - *.obj",
"objnomtl",
"obj"}},
};
const Array &array,
float elevation_scaling = 0.2f,
const std::string &texture_fname = "",
const std::string &normal_map_fname = "",
float max_error = 5e-4f);
const Vec2<int> &export_shape = {64, 64},
const std::string chars_map = " .:-=+*#%@");
const Array &z,
int cubemap_resolution = 128,
float overlap = 0.25f,
int ir = 16,
bool splitted = false,
Array *p_cubemap = nullptr);
const std::vector<Array> &arrays,
int cmap,
bool hillshading = false);
const Array &array,
int depth = CV_8U);
const Array *p_r,
const Array *p_g = nullptr,
const Array *p_b = nullptr,
const Array *p_a = nullptr,
int depth = CV_8U);
const std::string &fname_extension,
const Array &array,
const Vec2<int> &tiling,
int leading_zeros = 0,
int depth = CV_8U,
bool overlapping_edges = false,
bool reverse_tile_y_indexing = false);
const std::filesystem::path &file_path,
const std::string &suffix);
}
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Definition algebra.hpp:28
void export_banner_png(const std::string &fname, const std::vector< Array > &arrays, int cmap, bool hillshading=false)
Exports a set of arrays as a banner PNG image file.
Definition export_banner_png.cpp:11
void export_splatmap_png(const std::string &fname, const Array *p_r, const Array *p_g=nullptr, const Array *p_b=nullptr, const Array *p_a=nullptr, int depth=CV_8U)
Exports four arrays as an RGBA PNG splatmap.
Definition export_splatmap.cpp:29
void export_as_cubemap(const std::string &fname, const Array &z, int cubemap_resolution=128, float overlap=0.25f, int ir=16, Cmap cmap=Cmap::GRAY, bool splitted=false, Array *p_cubemap=nullptr)
Exports a 2D array as a cubemap texture with continuity enforcement and overlapping regions.
Definition export_as_cubemap.cpp:174
void write_raw_16bit(const std::string &fname, const Array &array)
Exports an array to a 16-bit 'raw' file format, commonly used for Unity terrain imports.
Definition format_raw.cpp:15
std::filesystem::path add_filename_suffix(const std::filesystem::path &file_path, const std::string &suffix)
Definition helpers.cpp:9
bool export_asset(const std::string &fname, const Array &array, MeshType mesh_type=MeshType::TRI, AssetExportFormat export_format=AssetExportFormat::GLB2, float elevation_scaling=0.2f, const std::string &texture_fname="", const std::string &normal_map_fname="", float max_error=5e-4f)
Exports a heightmap to various 3D file formats.
Definition export_asset.cpp:27
void export_tiled(const std::string &fname_radical, const std::string &fname_extension, const Array &array, const Vec2< int > &tiling, int leading_zeros=0, int depth=CV_8U, bool overlapping_edges=false, bool reverse_tile_y_indexing=false)
Exports a 2D array as a set of grayscale PNG image tiles.
Definition export_tiled.cpp:12
void export_normal_map_png(const std::string &fname, const Array &array, int depth=CV_8U)
Exports the heightmap normal map as an 8-bit PNG file.
Definition export_normal_map.cpp:15
std::string export_as_ascii(const Array &array, const Vec2< int > &export_shape={64, 64}, const std::string chars_map=" .:-=+*#%@")
Export a 2D array as an ASCII-art string representation.
Definition export_as_ascii.cpp:12
AssetExportFormat
Enumeration for asset export formats supported by Assimp.
Definition export.hpp:64
@ FBX
Autodesk FBX (binary) - *.fbx.
Definition export.hpp:70
@ PLY
Stanford Polygon Library - *.ply.
Definition export.hpp:77
@ GLB2
GL Transmission Format v. 2 (binary) - *.glb.
Definition export.hpp:76
@ STL
Stereolithography - *.stl.
Definition export.hpp:80
@ _3MF
The 3MF-File-Format - *.3mf.
Definition export.hpp:66
@ ASSBIN
Assimp Binary - *.assbin.
Definition export.hpp:67
@ GTLF2
GL Transmission Format v. 2 - *.gltf.
Definition export.hpp:75
@ X3D
Extensible 3D - *.x3d.
Definition export.hpp:72
@ COLLADA
COLLADA - Digital Asset Exchange Schema - *.dae.
Definition export.hpp:71
@ STP
Step Files - *.stp.
Definition export.hpp:79
@ GLB
GL Transmission Format (binary) - *.glb.
Definition export.hpp:74
@ ASSXML
Assxml Document - *.assxml.
Definition export.hpp:68
@ FXBA
Autodesk FBX (ascii) - *.fbx.
Definition export.hpp:69
@ GLTF
GL Transmission Format - *.gltf.
Definition export.hpp:73
@ STLB
Stereolithography (binary) - *.stl.
Definition export.hpp:81
@ OBJ
Wavefront OBJ format - *.obj.
Definition export.hpp:82
@ PLYB
Stanford Polygon Library (binary) - *.ply.
Definition export.hpp:78
@ _3DS
Autodesk 3DS (legacy) - *.3ds.
Definition export.hpp:65
@ OBJNOMTL
Wavefront OBJ format without material file - *.obj.
Definition export.hpp:83
Cmap
Enumeration for different colormap types.
Definition colormaps.hpp:81
@ GRAY
Definition colormaps.hpp:83
MeshType
Enumeration for different mesh types.
Definition export.hpp:39
@ TRI_OPTIMIZED
Triangles with optimized Delaunay triangulation.
Definition export.hpp:40
@ TRI
Triangle elements.
Definition export.hpp:41
Array read_to_array(const std::string &fname)
Reads an image file and converts it to a 2D array.
Definition read_to_array.cpp:14
Header file for the Tensor class.