本文整理汇总了C++中BoundingBoxf3::translate方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBoxf3::translate方法的具体用法?C++ BoundingBoxf3::translate怎么用?C++ BoundingBoxf3::translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBoxf3
的用法示例。
在下文中一共展示了BoundingBoxf3::translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
SVGExport::writeSVG(const std::string &outputfile)
{
// align to origin taking raft into account
BoundingBoxf3 bb = this->mesh.bounding_box();
if (this->config.raft_layers > 0) {
bb.min.x -= this->config.raft_offset.value;
bb.min.y -= this->config.raft_offset.value;
bb.max.x += this->config.raft_offset.value;
bb.max.y += this->config.raft_offset.value;
}
this->mesh.translate(-bb.min.x, -bb.min.y, -bb.min.z); // align to origin
bb.translate(-bb.min.x, -bb.min.y, -bb.min.z); // align to origin
const Sizef3 size = bb.size();
// if we are generating a raft, first_layer_height will not affect mesh slicing
const float lh = this->config.layer_height.value;
const float first_lh = this->config.first_layer_height.value;
// generate the list of Z coordinates for mesh slicing
// (we slice each layer at half of its thickness)
std::vector<float> slice_z, layer_z;
{
const float first_slice_lh = (this->config.raft_layers > 0) ? lh : first_lh;
slice_z.push_back(first_slice_lh/2);
layer_z.push_back(first_slice_lh);
}
while (layer_z.back() + lh/2 <= this->mesh.stl.stats.max.z) {
slice_z.push_back(layer_z.back() + lh/2);
layer_z.push_back(layer_z.back() + lh);
}
// perform the slicing
std::vector<ExPolygons> layers;
TriangleMeshSlicer(&this->mesh).slice(slice_z, &layers);
// generate a solid raft if requested
if (this->config.raft_layers > 0) {
ExPolygons raft = offset_ex(layers.front(), scale_(this->config.raft_offset));
for (int i = this->config.raft_layers; i >= 1; --i) {
layer_z.insert(layer_z.begin(), first_lh + lh * (i-1));
layers.insert(layers.begin(), raft);
}
// prepend total raft height to all sliced layers
for (int i = this->config.raft_layers; i < layer_z.size(); ++i)
layer_z[i] += first_lh + lh * (this->config.raft_layers-1);
}
// generate support material
std::vector<Points> support_material(layers.size());
if (this->config.support_material) {
// generate a grid of points according to the configured spacing,
// covering the entire object bounding box
Points support_material_points;
for (coordf_t x = bb.min.x; x <= bb.max.x; x += this->config.support_material_spacing) {
for (coordf_t y = bb.min.y; y <= bb.max.y; y += this->config.support_material_spacing) {
support_material_points.push_back(Point(scale_(x), scale_(y)));
}
}
// check overhangs, starting from the upper layer, and detect which points apply
// to each layer
ExPolygons overhangs;
for (int i = layer_z.size()-1; i >= 0; --i) {
overhangs = diff_ex(union_(overhangs, layers[i+1]), layers[i]);
for (Points::const_iterator it = support_material_points.begin(); it != support_material_points.end(); ++it) {
for (ExPolygons::const_iterator e = overhangs.begin(); e != overhangs.end(); ++e) {
if (e->contains(*it)) {
support_material[i].push_back(*it);
break;
}
}
}
}
}
double support_material_radius = this->config.support_material_extrusion_width.get_abs_value(this->config.layer_height)/2;
FILE* f = fopen(outputfile.c_str(), "w");
fprintf(f,
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"
"<svg width=\"%f\" height=\"%f\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:slic3r=\"http://slic3r.org/namespaces/slic3r\" viewport-fill=\"black\">\n"
"<!-- Generated using Slic3r %s http://slic3r.org/ -->\n"
, size.x, size.y, SLIC3R_VERSION);
for (size_t i = 0; i < layer_z.size(); ++i) {
fprintf(f, "\t<g id=\"layer%zu\" slic3r:z=\"%0.4f\">\n", i, layer_z[i]);
for (ExPolygons::const_iterator it = layers[i].begin(); it != layers[i].end(); ++it) {
std::string pd;
Polygons pp = *it;
for (Polygons::const_iterator mp = pp.begin(); mp != pp.end(); ++mp) {
std::ostringstream d;
d << "M ";
for (Points::const_iterator p = mp->points.begin(); p != mp->points.end(); ++p) {
d << unscale(p->x) << " ";
d << unscale(p->y) << " ";
}
d << "z";
//.........这里部分代码省略.........