本文整理汇总了C++中ModelObject::add_instance方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelObject::add_instance方法的具体用法?C++ ModelObject::add_instance怎么用?C++ ModelObject::add_instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelObject
的用法示例。
在下文中一共展示了ModelObject::add_instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
Model::duplicate_objects_grid(size_t x, size_t y, coordf_t dist)
{
if (this->objects.size() > 1) throw std::runtime_error("Grid duplication is not supported with multiple objects");
if (this->objects.empty()) throw std::runtime_error("No objects!");
ModelObject* object = this->objects.front();
object->clear_instances();
Sizef3 size = object->bounding_box().size();
for (size_t x_copy = 1; x_copy <= x; ++x_copy) {
for (size_t y_copy = 1; y_copy <= y; ++y_copy) {
ModelInstance* instance = object->add_instance();
instance->offset.x = (size.x + dist) * (x_copy-1);
instance->offset.y = (size.y + dist) * (y_copy-1);
}
}
}
示例2: while
void
Model::convert_multipart_object()
{
if (this->objects.empty()) return;
ModelObject* object = this->add_object();
object->input_file = this->objects.front()->input_file;
for (const ModelObject* o : this->objects) {
for (const ModelVolume* v : o->volumes) {
ModelVolume* v2 = object->add_volume(*v);
v2->name = o->name;
}
}
for (const ModelInstance* i : this->objects.front()->instances)
object->add_instance(*i);
while (this->objects.size() > 1)
this->delete_object(0);
}