当前位置: 首页>>代码示例>>C++>>正文


C++ BoundingBoxf3::merge方法代码示例

本文整理汇总了C++中BoundingBoxf3::merge方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBoxf3::merge方法的具体用法?C++ BoundingBoxf3::merge怎么用?C++ BoundingBoxf3::merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundingBoxf3的用法示例。


在下文中一共展示了BoundingBoxf3::merge方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: vector

void
ModelObject::center_around_origin()
{
    // calculate the displacements needed to 
    // center this object around the origin
	BoundingBoxf3 bb;
	for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v)
		if (! (*v)->modifier)
			bb.merge((*v)->mesh.bounding_box());
    
    // first align to origin on XYZ
    Vectorf3 vector(-bb.min.x, -bb.min.y, -bb.min.z);
    
    // then center it on XY
    Sizef3 size = bb.size();
    vector.x -= size.x/2;
    vector.y -= size.y/2;
    
    this->translate(vector);
    this->origin_translation.translate(vector);
    
    if (!this->instances.empty()) {
        for (ModelInstancePtrs::const_iterator i = this->instances.begin(); i != this->instances.end(); ++i) {
            // apply rotation and scaling to vector as well before translating instance,
            // in order to leave final position unaltered
            Vectorf3 v = vector.negative();
            v.rotate((*i)->rotation, (*i)->offset);
            v.scale((*i)->scaling_factor);
            (*i)->offset.translate(v.x, v.y);
        }
        this->invalidate_bounding_box();
    }
}
开发者ID:jdfr,项目名称:Slic3r,代码行数:33,代码来源:Model.cpp

示例2: transform_bounding_box

BoundingBoxf3 ModelInstance::transform_bounding_box(const BoundingBoxf3 &bbox, bool dont_translate) const
{
    // rotate around mesh origin
    double c = cos(this->rotation);
    double s = sin(this->rotation);
    Pointf3 pts[4] = {
        bbox.min,
        bbox.max,
        Pointf3(bbox.min.x, bbox.max.y, bbox.min.z),
        Pointf3(bbox.max.x, bbox.min.y, bbox.max.z)
    };
    BoundingBoxf3 out;
    for (int i = 0; i < 4; ++ i) {
        Pointf3 &v = pts[i];
        double xold = v.x;
        double yold = v.y;
        v.x = float(c * xold - s * yold);
        v.y = float(s * xold + c * yold);
        v.x *= this->scaling_factor;
        v.y *= this->scaling_factor;
        v.z *= this->scaling_factor;
        if (!dont_translate) {
            v.x += this->offset.x;
            v.y += this->offset.y;
        }
        out.merge(v);
    }
    return out;
}
开发者ID:jiripech,项目名称:Slic3r,代码行数:29,代码来源:Model.cpp

示例3: transform_mesh_bounding_box

BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mesh, bool dont_translate) const
{
    // rotate around mesh origin
    double c = cos(this->rotation);
    double s = sin(this->rotation);
    BoundingBoxf3 bbox;
    for (int i = 0; i < mesh->stl.stats.number_of_facets; ++ i) {
        const stl_facet &facet = mesh->stl.facet_start[i];
        for (int j = 0; j < 3; ++ j) {
            stl_vertex v = facet.vertex[j];
            double xold = v.x;
            double yold = v.y;
            v.x = float(c * xold - s * yold);
            v.y = float(s * xold + c * yold);
            v.x *= float(this->scaling_factor);
            v.y *= float(this->scaling_factor);
            v.z *= float(this->scaling_factor);
            if (!dont_translate) {
                v.x += this->offset.x;
                v.y += this->offset.y;
            }
            bbox.merge(Pointf3(v.x, v.y, v.z));
        }
    }
    return bbox;
}
开发者ID:jiripech,项目名称:Slic3r,代码行数:26,代码来源:Model.cpp

示例4:

// this returns the bounding box of the *transformed* instances
BoundingBoxf3
Model::bounding_box() const
{
    BoundingBoxf3 bb;
    for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) {
        bb.merge((*o)->bounding_box());
    }
    return bb;
}
开发者ID:jdfr,项目名称:Slic3r,代码行数:10,代码来源:Model.cpp

示例5: transform_bounding_box

BoundingBoxf3 ModelInstance::transform_bounding_box(const BoundingBoxf3 &bbox, bool dont_translate) const
{
    // rotate around mesh origin
    double c = cos(this->rotation);
    double s = sin(this->rotation);
    double cx = cos(this->x_rotation);
    double sx = sin(this->x_rotation);
    double cy = cos(this->y_rotation);
    double sy = sin(this->y_rotation);
    Pointf3 pts[4] = {
        bbox.min,
        bbox.max,
        Pointf3(bbox.min.x, bbox.max.y, bbox.min.z),
        Pointf3(bbox.max.x, bbox.min.y, bbox.max.z)
    };
    BoundingBoxf3 out;
    for (int i = 0; i < 4; ++ i) {
        Pointf3 &v = pts[i];
        double xold = v.x;
        double yold = v.y;
        double zold = v.z;
        // Rotation around x axis.
        v.z = float(sx * yold + cx * zold);
        yold = v.y = float(cx * yold - sx * zold);
        zold = v.z;
        // Rotation around y axis.
        v.x = float(cy * xold + sy * zold);
        v.z = float(-sy * xold + cy * zold);
        xold = v.x;
        // Rotation around z axis.
        v.x = float(c * xold - s * yold);
        v.y = float(s * xold + c * yold);
        v.x *= this->scaling_factor * this->scaling_vector.x;
        v.y *= this->scaling_factor * this->scaling_vector.y;
        v.z *= this->scaling_factor * this->scaling_vector.z;
        if (!dont_translate) {
            v.x += this->offset.x;
            v.y += this->offset.y;
        }
        out.merge(v);
    }
    return out;
}
开发者ID:jdfr,项目名称:Slic3r,代码行数:43,代码来源:Model.cpp

示例6: transform_mesh_bounding_box

BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mesh, bool dont_translate) const
{
    // rotate around mesh origin
    double c = cos(this->rotation);
    double s = sin(this->rotation);
    double cx = cos(this->x_rotation);
    double sx = sin(this->x_rotation);
    double cy = cos(this->y_rotation);
    double sy = sin(this->y_rotation);
    BoundingBoxf3 bbox;
    for (int i = 0; i < mesh->stl.stats.number_of_facets; ++ i) {
        const stl_facet &facet = mesh->stl.facet_start[i];
        for (int j = 0; j < 3; ++ j) {
            stl_vertex v = facet.vertex[j];
            double xold = v.x;
            double yold = v.y;
            double zold = v.z;
            // Rotation around x axis.
            v.z = float(sx * yold + cx * zold);
            yold = v.y = float(cx * yold - sx * zold);
            zold = v.z;
            // Rotation around y axis.
            v.x = float(cy * xold + sy * zold);
            v.z = float(-sy * xold + cy * zold);
            xold = v.x;
            // Rotation around z axis.
            v.x = float(c * xold - s * yold);
            v.y = float(s * xold + c * yold);
            v.x *= float(this->scaling_factor * this->scaling_vector.x);
            v.y *= float(this->scaling_factor * this->scaling_vector.y);
            v.z *= float(this->scaling_factor * this->scaling_vector.z);
            if (!dont_translate) {
                v.x += this->offset.x;
                v.y += this->offset.y;
                if (this->y_rotation || this->x_rotation)
                    v.z += -(mesh->stl.stats.min.z);
            }
            bbox.merge(Pointf3(v.x, v.y, v.z));
        }
    }
    return bbox;
}
开发者ID:jdfr,项目名称:Slic3r,代码行数:42,代码来源:Model.cpp


注:本文中的BoundingBoxf3::merge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。