Merge remote-tracking branch 'origin/dev2' into dev_native

This commit is contained in:
bubnikv 2018-09-25 15:33:51 +02:00
commit 6260e43f61
30 changed files with 785 additions and 443 deletions

View file

@ -29,7 +29,12 @@ std::string toString(const Model& model, bool holes = true) {
if(!objinst) continue;
Slic3r::TriangleMesh tmpmesh = rmesh;
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// CHECK_ME -> Is the following correct ?
tmpmesh.scale(objinst->get_scaling_factor());
#else
tmpmesh.scale(objinst->scaling_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
objinst->transform_mesh(&tmpmesh);
ExPolygons expolys = tmpmesh.horizontal_projection();
for(auto& expoly_complex : expolys) {
@ -87,7 +92,11 @@ void toSVG(SVG& svg, const Model& model) {
if(!objinst) continue;
Slic3r::TriangleMesh tmpmesh = rmesh;
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
tmpmesh.scale(objinst->get_scaling_factor());
#else
tmpmesh.scale(objinst->scaling_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
objinst->transform_mesh(&tmpmesh);
ExPolygons expolys = tmpmesh.horizontal_projection();
svg.draw(expolys);
@ -513,7 +522,12 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
Slic3r::TriangleMesh tmpmesh = rmesh;
ClipperLib::PolygonImpl pn;
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// CHECK_ME -> is the following correct ?
tmpmesh.scale(objinst->get_scaling_factor());
#else
tmpmesh.scale(objinst->scaling_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// TODO export the exact 2D projection
auto p = tmpmesh.convex_hull();
@ -527,20 +541,20 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
// Invalid geometries would throw exceptions when arranging
if(item.vertexCount() > 3) {
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// CHECK_ME -> is the following correct or it should take in account all three rotations ?
item.rotation(objinst->get_rotation(Z));
#else
item.rotation(objinst->rotation);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
item.translation({
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
ClipperLib::cInt(objinst->get_offset(X)/SCALING_FACTOR),
ClipperLib::cInt(objinst->get_offset(Y)/SCALING_FACTOR)
#else
ClipperLib::cInt(objinst->offset(0)/SCALING_FACTOR),
ClipperLib::cInt(objinst->offset(1)/SCALING_FACTOR)
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
});
ret.emplace_back(objinst, item);
}
@ -677,26 +691,21 @@ void applyResult(
// appropriately
auto off = item.translation();
Radians rot = item.rotation();
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
Vec3d foff(off.X*SCALING_FACTOR + batch_offset,
off.Y*SCALING_FACTOR,
0.0);
#else
Vec2d foff(off.X*SCALING_FACTOR + batch_offset, off.Y*SCALING_FACTOR);
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
// write the transformation data into the model instance
#if ENABLE_MODELINSTANCE_3D_ROTATION
// CHECK_ME -> Is the following correct ?
inst_ptr->set_rotation(Vec3d(0.0, 0.0, rot));
#else
inst_ptr->rotation = rot;
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_OFFSET
inst_ptr->set_rotation(Z, rot);
inst_ptr->set_offset(foff);
#else
Vec2d foff(off.X*SCALING_FACTOR + batch_offset, off.Y*SCALING_FACTOR);
// write the transformation data into the model instance
inst_ptr->rotation = rot;
inst_ptr->offset = foff;
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
}