OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Emboss.hpp File Reference
#include <string>
#include <map>
#include <utility>
#include <cassert>
#include <cstddef>
#include <functional>
#include <cstdint>
#include <vector>
#include <set>
#include <optional>
#include <memory>
#include <admesh/stl.h>
#include "Point.hpp"
#include "Polygon.hpp"
#include "ExPolygon.hpp"
#include "EmbossShape.hpp"
#include "BoundingBox.hpp"
#include "TextConfiguration.hpp"
Include dependency graph for Emboss.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Slic3r::Emboss::Glyph
struct  Slic3r::Emboss::FontFile
 keep information from file about font (store file data itself) More...
struct  Slic3r::Emboss::FontFile::Info
struct  Slic3r::Emboss::FontFileWithCache
 Add caching for shape of glyphs. More...
class  Slic3r::Emboss::IProject3d
 Project spatial point. More...
class  Slic3r::Emboss::IProjection
 Project 2d point into space Could be plane, sphere, cylindric, ... More...
class  Slic3r::Emboss::ProjectZ
class  Slic3r::Emboss::ProjectScale
class  Slic3r::Emboss::ProjectTransform
class  Slic3r::Emboss::OrthoProject3d
class  Slic3r::Emboss::OrthoProject
struct  Slic3r::Emboss::TextLine
 Define polygon for draw letters. More...

Namespaces

namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/
namespace  Slic3r::Emboss
 class with only static function add ability to engraved OR raised text OR polygons onto model surface

Typedefs

using Slic3r::Emboss::Glyphs = std::map<int, Glyph>
using Slic3r::Emboss::TextLines = std::vector<TextLine>

Functions

EmbossStyles Slic3r::Emboss::get_font_list ()
 Collect fonts registred inside OS.
std::optional< std::wstring > Slic3r::Emboss::get_font_path (const std::wstring &font_face_name)
 OS dependent function to get location of font by its name descriptor.
std::unique_ptr< FontFile > Slic3r::Emboss::create_font_file (const char *file_path)
 Load font file into buffer.
std::unique_ptr< FontFile > Slic3r::Emboss::create_font_file (std::unique_ptr< std::vector< unsigned char > > data)
std::optional< Glyph > Slic3r::Emboss::letter2glyph (const FontFile &font, unsigned int font_index, int letter, float flatness)
 convert letter into polygons
HealedExPolygons Slic3r::Emboss::text2shapes (FontFileWithCache &font, const char *text, const FontProp &font_prop, const std::function< bool()> &was_canceled=[]() {return false;})
 Convert text into polygons.
ExPolygonsWithIds Slic3r::Emboss::text2vshapes (FontFileWithCache &font, const std::wstring &text, const FontProp &font_prop, const std::function< bool()> &was_canceled=[]() {return false;})
unsigned Slic3r::Emboss::get_count_lines (const std::wstring &ws)
 Sum of character '
'.
unsigned Slic3r::Emboss::get_count_lines (const std::string &text)
unsigned Slic3r::Emboss::get_count_lines (const ExPolygonsWithIds &shape)
HealedExPolygons Slic3r::Emboss::heal_polygons (const Polygons &shape, bool is_non_zero=true, unsigned max_iteration=10)
 Fix duplicit points and self intersections in polygons. Also try to reduce amount of points and remove useless polygon parts.
bool Slic3r::Emboss::heal_expolygons (ExPolygons &shape, unsigned max_iteration=10)
 NOTE: call Slic3r::union_ex before this call.
bool Slic3r::Emboss::divide_segments_for_close_point (ExPolygons &expolygons, double distance)
 Divide line segments in place near to point (which could lead to self intersection due to preccision) Remove same neighbors Note: Possible part of heal shape.
void Slic3r::Emboss::apply_transformation (const std::optional< float > &angle, const std::optional< float > &distance, Transform3d &transformation)
 Use data from font property to modify transformation.
bool Slic3r::Emboss::is_italic (const FontFile &font, unsigned int font_index)
 Read information from naming table of font file search for italic (or oblique), bold italic (or bold oblique).
std::string Slic3r::Emboss::create_range_text (const std::string &text, const FontFile &font, unsigned int font_index, bool *exist_unknown=nullptr)
 Create unique character set from string with filtered from text with only character from font.
double Slic3r::Emboss::get_text_shape_scale (const FontProp &fp, const FontFile &ff)
 Calculate scale for glyph shape convert from shape points to mm.
const FontFile::Info & Slic3r::Emboss::get_font_info (const FontFile &font, const FontProp &prop)
 getter of font info by collection defined in prop
int Slic3r::Emboss::get_line_height (const FontFile &font, const FontProp &prop)
 Read from font file and properties height of line with spacing.
double Slic3r::Emboss::get_align_y_offset_in_mm (FontProp::VerticalAlign align, unsigned count_lines, const FontFile &ff, const FontProp &fp)
 Calculate Vertical align.
indexed_triangle_set Slic3r::Emboss::polygons2model (const ExPolygons &shape2d, const IProjection &projection)
 Create triangle model for text.
Vec3d Slic3r::Emboss::suggest_up (const Vec3d normal, double up_limit=0.9)
 Suggest wanted up vector of embossed text by emboss direction.
std::optional< float > Slic3r::Emboss::calc_up (const Transform3d &tr, double up_limit=0.9)
 By transformation calculate angle between suggested and actual up vector.
Transform3d Slic3r::Emboss::create_transformation_onto_surface (const Vec3d &position, const Vec3d &normal, double up_limit=0.9)
 Create transformation for emboss text object to lay on surface point.
PolygonPoints Slic3r::Emboss::sample_slice (const TextLine &slice, const BoundingBoxes &bbs, double scale)
 Sample slice polygon by bounding boxes centers slice start point has shape_center_x coor.
double Slic3r::Emboss::calculate_angle (int32_t distance, PolygonPoint polygon_point, const Polygon &polygon)
 Calculate angle for polygon point.
std::vector< double > Slic3r::Emboss::calculate_angles (int32_t distance, const PolygonPoints &polygon_points, const Polygon &polygon)
void Slic3r::translate (ExPolygonsWithIds &e, const Point &p)
BoundingBox Slic3r::get_extents (const ExPolygonsWithIds &e)
void Slic3r::center (ExPolygonsWithIds &e)
ExPolygons Slic3r::union_with_delta (EmbossShape &shape, float delta, unsigned max_heal_iteration)

Variables

static const float Slic3r::Emboss::UNION_DELTA = 50.0f
static const unsigned Slic3r::Emboss::UNION_MAX_ITERATIN = 10
const unsigned Slic3r::Emboss::ENTER_UNICODE = static_cast<unsigned>('\n')

Class Documentation

◆ Slic3r::Emboss::Glyph

struct Slic3r::Emboss::Glyph
Collaboration diagram for Slic3r::Emboss::Glyph:
Class Members
int advance_width =0
int left_side_bearing =0
ExPolygons shape

◆ Slic3r::Emboss::FontFile::Info

struct Slic3r::Emboss::FontFile::Info
Class Members
int ascent
int descent
int linegap
int unit_per_em

◆ Slic3r::Emboss::TextLine

struct Slic3r::Emboss::TextLine

Define polygon for draw letters.

Collaboration diagram for Slic3r::Emboss::TextLine:
Class Members
Polygon polygon
PolygonPoint start
float y