OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{bbs_3mf.cpp} Namespace Reference

Classes

struct  PublishedXmlProbe

Functions

template<typename F, typename S>
F bimap_cvt (const boost::bimap< F, S > &bmap, S s, const F &def_value)
template<typename F, typename S>
S bimap_cvt (const boost::bimap< F, S > &bmap, F f, const S &def_value)
FontProp::HorizontalAlign read_horizontal_align (const char **attributes, unsigned int num_attributes, const TextConfigurationSerialization::HorizontalAlignToName &horizontal_align_to_name)
FontProp::VerticalAlign read_vertical_align (const char **attributes, unsigned int num_attributes, const TextConfigurationSerialization::VerticalAlignToName &vertical_align_to_name)
Transform3d create_fix (const std::optional< Transform3d > &prev, const ModelVolume &volume)
bool to_xml (std::stringstream &stream, const EmbossShape::SvgFile &svg, const ModelVolume &volume, mz_zip_archive &archive, bool export_full_path)

Function Documentation

◆ bimap_cvt() [1/2]

template<typename F, typename S>
S Slic3r::anonymous_namespace{bbs_3mf.cpp}::bimap_cvt ( const boost::bimap< F, S > & bmap,
F f,
const S & def_value )
9882{
9883 const auto &map = bmap.left;
9884 auto found_item = map.find(f);
9885
9886 // only for back and forward compatibility
9887 assert(found_item != map.end());
9888 if (found_item == map.end())
9889 return def_value;
9890
9891 return found_item->second;
9892}
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124

References bimap_cvt(), Slic3r::F, and Slic3r::f().

Here is the call graph for this function:

◆ bimap_cvt() [2/2]

template<typename F, typename S>
F Slic3r::anonymous_namespace{bbs_3mf.cpp}::bimap_cvt ( const boost::bimap< F, S > & bmap,
S s,
const F & def_value )
9868 {
9869 const auto &map = bmap.right;
9870 auto found_item = map.find(s);
9871
9872 // only for back and forward compatibility
9873 assert(found_item != map.end());
9874 if (found_item == map.end())
9875 return def_value;
9876
9877 return found_item->second;
9878}

References bimap_cvt(), and Slic3r::F.

Referenced by bimap_cvt(), bimap_cvt(), read_horizontal_align(), and read_vertical_align().

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

◆ create_fix()

Transform3d Slic3r::anonymous_namespace{bbs_3mf.cpp}::create_fix ( const std::optional< Transform3d > & prev,
const ModelVolume & volume )
10071{
10072 // IMPROVE: check if volume was modified (translated, rotated OR scaled)
10073 // when no change do not calculate transformation only store original fix matrix
10074
10075 // Create transformation used after load actual stored volume
10076 // Orca: do not bake volume transformation into meshes
10077 // const Transform3d &actual_trmat = volume.get_matrix();
10078 const Transform3d& actual_trmat = Transform3d::Identity();
10079
10080 const auto &vertices = volume.mesh().its.vertices;
10081 Vec3d min = actual_trmat * vertices.front().cast<double>();
10082 Vec3d max = min;
10083 for (const Vec3f &v : vertices) {
10084 Vec3d vd = actual_trmat * v.cast<double>();
10085 for (size_t i = 0; i < 3; ++i) {
10086 if (min[i] > vd[i])
10087 min[i] = vd[i];
10088 if (max[i] < vd[i])
10089 max[i] = vd[i];
10090 }
10091 }
10092 Vec3d center = (max + min) / 2;
10093 Transform3d post_trmat = Transform3d::Identity();
10094 post_trmat.translate(center);
10095
10096 Transform3d fix_trmat = actual_trmat.inverse() * post_trmat;
10097 if (!prev.has_value())
10098 return fix_trmat;
10099
10100 // check whether fix somehow differ previous
10101 if (fix_trmat.isApprox(Transform3d::Identity(), 1e-5))
10102 return *prev;
10103
10104 return *prev * fix_trmat;
10105}
const TriangleMesh & mesh() const
Definition Model.hpp:892
indexed_triangle_set its
Definition TriangleMesh.hpp:164
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96
void center(ExPolygonsWithIds &e)
Definition Emboss.cpp:1382
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65

References Slic3r::center(), create_fix(), Slic3r::TriangleMesh::its, and Slic3r::ModelVolume::mesh().

Referenced by create_fix().

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

◆ read_horizontal_align()

FontProp::HorizontalAlign Slic3r::anonymous_namespace{bbs_3mf.cpp}::read_horizontal_align ( const char ** attributes,
unsigned int num_attributes,
const TextConfigurationSerialization::HorizontalAlignToName & horizontal_align_to_name )
9964 {
9965 std::string horizontal_align_str = bbs_get_attribute_value_string(attributes, num_attributes, HORIZONTAL_ALIGN_ATTR);
9966
9967 // Back compatibility
9968 // PS 2.6.0 do not have align
9969 if (horizontal_align_str.empty())
9971
9972 // Back compatibility
9973 // PS 2.6.1 store indices(0|1|2) instead of text for align
9974 if (horizontal_align_str.length() == 1) {
9975 int horizontal_align_int = 0;
9976 if(boost::spirit::qi::parse(horizontal_align_str.c_str(), horizontal_align_str.c_str() + 1, boost::spirit::qi::int_, horizontal_align_int))
9977 return static_cast<FontProp::HorizontalAlign>(horizontal_align_int);
9978 }
9979
9980 return bimap_cvt(horizontal_align_to_name, std::string_view(horizontal_align_str), FontProp::HorizontalAlign::center);
9981}
std::string bbs_get_attribute_value_string(const char **attributes, unsigned int attributes_size, const char *attribute_key)
Definition bbs_3mf.cpp:538
static constexpr const char * HORIZONTAL_ALIGN_ATTR
Definition bbs_3mf.cpp:464
F bimap_cvt(const boost::bimap< F, S > &bmap, S s, const F &def_value)
Definition bbs_3mf.cpp:9868
HorizontalAlign
Definition TextConfiguration.hpp:49
@ center
Definition TextConfiguration.hpp:49

References bbs_get_attribute_value_string(), bimap_cvt(), Slic3r::FontProp::center, HORIZONTAL_ALIGN_ATTR, and read_horizontal_align().

Referenced by read_horizontal_align().

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

◆ read_vertical_align()

FontProp::VerticalAlign Slic3r::anonymous_namespace{bbs_3mf.cpp}::read_vertical_align ( const char ** attributes,
unsigned int num_attributes,
const TextConfigurationSerialization::VerticalAlignToName & vertical_align_to_name )
9984 {
9985 std::string vertical_align_str = bbs_get_attribute_value_string(attributes, num_attributes, VERTICAL_ALIGN_ATTR);
9986
9987 // Back compatibility
9988 // PS 2.6.0 do not have align
9989 if (vertical_align_str.empty())
9991
9992 // Back compatibility
9993 // PS 2.6.1 store indices(0|1|2) instead of text for align
9994 if (vertical_align_str.length() == 1) {
9995 int vertical_align_int = 0;
9996 if(boost::spirit::qi::parse(vertical_align_str.c_str(), vertical_align_str.c_str() + 1, boost::spirit::qi::int_, vertical_align_int))
9997 return static_cast<FontProp::VerticalAlign>(vertical_align_int);
9998 }
9999
10000 return bimap_cvt(vertical_align_to_name, std::string_view(vertical_align_str), FontProp::VerticalAlign::center);
10001}
static constexpr const char * VERTICAL_ALIGN_ATTR
Definition bbs_3mf.cpp:465
VerticalAlign
Definition TextConfiguration.hpp:50
@ center
Definition TextConfiguration.hpp:50

References bbs_get_attribute_value_string(), bimap_cvt(), Slic3r::FontProp::center, read_vertical_align(), and VERTICAL_ALIGN_ATTR.

Referenced by read_vertical_align().

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

◆ to_xml()

bool Slic3r::anonymous_namespace{bbs_3mf.cpp}::to_xml ( std::stringstream & stream,
const EmbossShape::SvgFile & svg,
const ModelVolume & volume,
mz_zip_archive & archive,
bool export_full_path )
10108{
10109 if (svg.path_in_3mf.empty())
10110 return true; // EmbossedText OR unwanted store .svg file into .3mf (protection of copyRight)
10111
10112 if (!svg.path.empty()) {
10113 auto file_path =get_dealed_platform_path(svg.path);
10114 std::string input_file = xml_escape(export_full_path ? svg.path : file_path.filename().string());
10115 stream << SVG_FILE_PATH_ATTR << "=\"" << xml_escape_double_quotes_attribute_value(input_file) << "\" ";
10116 }
10118
10119 std::shared_ptr<std::string> file_data = svg.file_data;
10120 assert(file_data != nullptr);
10121 if (file_data == nullptr && !svg.path.empty()) file_data = read_from_disk(svg.path);
10122 if (file_data == nullptr) {
10123 BOOST_LOG_TRIVIAL(warning) << "Can't write SVG file no filedata";
10124 return false;
10125 }
10126 const std::string &file_data_str = *file_data;
10127
10128 return mz_zip_writer_add_mem(&archive, svg.path_in_3mf.c_str(),
10129 (const void *) file_data_str.c_str(), file_data_str.size(), MZ_DEFAULT_COMPRESSION);
10130}
static constexpr const char * SVG_FILE_PATH_IN_3MF_ATTR
Definition bbs_3mf.cpp:478
static constexpr const char * SVG_FILE_PATH_ATTR
Definition bbs_3mf.cpp:477
boost::filesystem::path get_dealed_platform_path(std::string path_str)
Definition bbs_3mf.cpp:8249
std::unique_ptr< std::string > read_from_disk(const std::string &path)
Definition NSVGUtils.cpp:112
std::string xml_escape(std::string text, bool is_marked)
Definition utils.cpp:1586
std::string xml_escape_double_quotes_attribute_value(std::string text)
Definition utils.cpp:1616
std::string path
Definition EmbossShape.hpp:92
std::string path_in_3mf
Definition EmbossShape.hpp:97
std::shared_ptr< std::string > file_data
Definition EmbossShape.hpp:104

References Slic3r::EmbossShape::SvgFile::file_data, Slic3r::get_dealed_platform_path(), Slic3r::EmbossShape::SvgFile::path, Slic3r::EmbossShape::SvgFile::path_in_3mf, Slic3r::read_from_disk(), SVG_FILE_PATH_ATTR, SVG_FILE_PATH_IN_3MF_ATTR, to_xml(), Slic3r::xml_escape(), and Slic3r::xml_escape_double_quotes_attribute_value().

Referenced by to_xml().

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