mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-27 18:51:11 -06:00
Fixed conflicts after merging with branch eigenize
This commit is contained in:
commit
66ce638439
211 changed files with 4309 additions and 4920 deletions
|
|
@ -1352,8 +1352,8 @@ namespace Slic3r {
|
|||
double angle_z = (rotation.axis() == Eigen::Vector3d::UnitZ()) ? rotation.angle() : -rotation.angle();
|
||||
#endif
|
||||
|
||||
instance.offset.x = offset_x;
|
||||
instance.offset.y = offset_y;
|
||||
instance.offset(0) = offset_x;
|
||||
instance.offset(1) = offset_y;
|
||||
instance.scaling_factor = sx;
|
||||
instance.rotation = angle_z;
|
||||
}
|
||||
|
|
@ -1485,7 +1485,7 @@ namespace Slic3r {
|
|||
stl_facet& facet = stl.facet_start[i];
|
||||
for (unsigned int v = 0; v < 3; ++v)
|
||||
{
|
||||
::memcpy((void*)&facet.vertex[v].x, (const void*)&geometry.vertices[geometry.triangles[src_start_id + ii + v] * 3], 3 * sizeof(float));
|
||||
::memcpy(facet.vertex[v].data(), (const void*)&geometry.vertices[geometry.triangles[src_start_id + ii + v] * 3], 3 * sizeof(float));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1802,7 +1802,7 @@ namespace Slic3r {
|
|||
}
|
||||
|
||||
Eigen::Affine3f transform;
|
||||
transform = Eigen::Translation3f((float)instance->offset.x, (float)instance->offset.y, 0.0f) * Eigen::AngleAxisf((float)instance->rotation, Eigen::Vector3f::UnitZ()) * Eigen::Scaling((float)instance->scaling_factor);
|
||||
transform = Eigen::Translation3f((float)instance->offset(0), (float)instance->offset(1), 0.0f) * Eigen::AngleAxisf((float)instance->rotation, Eigen::Vector3f::UnitZ()) * Eigen::Scaling((float)instance->scaling_factor);
|
||||
build_items.emplace_back(instance_id, transform.matrix());
|
||||
|
||||
stream << " </" << OBJECT_TAG << ">\n";
|
||||
|
|
@ -1845,9 +1845,9 @@ namespace Slic3r {
|
|||
for (int i = 0; i < stl.stats.shared_vertices; ++i)
|
||||
{
|
||||
stream << " <" << VERTEX_TAG << " ";
|
||||
stream << "x=\"" << stl.v_shared[i].x << "\" ";
|
||||
stream << "y=\"" << stl.v_shared[i].y << "\" ";
|
||||
stream << "z=\"" << stl.v_shared[i].z << "\" />\n";
|
||||
stream << "x=\"" << stl.v_shared[i](0) << "\" ";
|
||||
stream << "y=\"" << stl.v_shared[i](1) << "\" ";
|
||||
stream << "z=\"" << stl.v_shared[i](2) << "\" />\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ void AMFParserContext::endElement(const char * /* name */)
|
|||
for (size_t i = 0; i < m_volume_facets.size();) {
|
||||
stl_facet &facet = stl.facet_start[i/3];
|
||||
for (unsigned int v = 0; v < 3; ++ v)
|
||||
memcpy(&facet.vertex[v].x, &m_object_vertices[m_volume_facets[i ++] * 3], 3 * sizeof(float));
|
||||
memcpy(facet.vertex[v].data(), &m_object_vertices[m_volume_facets[i ++] * 3], 3 * sizeof(float));
|
||||
}
|
||||
stl_get_size(&stl);
|
||||
m_volume->mesh.repair();
|
||||
|
|
@ -498,8 +498,8 @@ void AMFParserContext::endDocument()
|
|||
for (const Instance &instance : object.second.instances)
|
||||
if (instance.deltax_set && instance.deltay_set) {
|
||||
ModelInstance *mi = m_model.objects[object.second.idx]->add_instance();
|
||||
mi->offset.x = instance.deltax;
|
||||
mi->offset.y = instance.deltay;
|
||||
mi->offset(0) = instance.deltax;
|
||||
mi->offset(1) = instance.deltay;
|
||||
mi->rotation = instance.rz_set ? instance.rz : 0.f;
|
||||
mi->scaling_factor = instance.scale_set ? instance.scale : 1.f;
|
||||
}
|
||||
|
|
@ -761,9 +761,9 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c
|
|||
for (size_t i = 0; i < stl.stats.shared_vertices; ++ i) {
|
||||
stream << " <vertex>\n";
|
||||
stream << " <coordinates>\n";
|
||||
stream << " <x>" << stl.v_shared[i].x << "</x>\n";
|
||||
stream << " <y>" << stl.v_shared[i].y << "</y>\n";
|
||||
stream << " <z>" << stl.v_shared[i].z << "</z>\n";
|
||||
stream << " <x>" << stl.v_shared[i](0) << "</x>\n";
|
||||
stream << " <y>" << stl.v_shared[i](1) << "</y>\n";
|
||||
stream << " <z>" << stl.v_shared[i](2) << "</z>\n";
|
||||
stream << " </coordinates>\n";
|
||||
stream << " </vertex>\n";
|
||||
}
|
||||
|
|
@ -804,8 +804,8 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c
|
|||
" <scale>%lf</scale>\n"
|
||||
" </instance>\n",
|
||||
object_id,
|
||||
instance->offset.x,
|
||||
instance->offset.y,
|
||||
instance->offset(0),
|
||||
instance->offset(1),
|
||||
instance->rotation,
|
||||
instance->scaling_factor);
|
||||
//FIXME missing instance->scaling_factor
|
||||
|
|
|
|||
|
|
@ -57,14 +57,14 @@ bool load_obj(const char *path, Model *model, const char *object_name_in)
|
|||
continue;
|
||||
stl_facet &facet = stl.facet_start[i_face ++];
|
||||
size_t num_normals = 0;
|
||||
stl_normal normal = { 0.f };
|
||||
stl_normal normal(stl_normal::Zero());
|
||||
for (unsigned int v = 0; v < 3; ++ v) {
|
||||
const ObjParser::ObjVertex &vertex = data.vertices[i++];
|
||||
memcpy(&facet.vertex[v].x, &data.coordinates[vertex.coordIdx*4], 3 * sizeof(float));
|
||||
memcpy(facet.vertex[v].data(), &data.coordinates[vertex.coordIdx*4], 3 * sizeof(float));
|
||||
if (vertex.normalIdx != -1) {
|
||||
normal.x += data.normals[vertex.normalIdx*3];
|
||||
normal.y += data.normals[vertex.normalIdx*3+1];
|
||||
normal.z += data.normals[vertex.normalIdx*3+2];
|
||||
normal(0) += data.normals[vertex.normalIdx*3];
|
||||
normal(1) += data.normals[vertex.normalIdx*3+1];
|
||||
normal(2) += data.normals[vertex.normalIdx*3+2];
|
||||
++ num_normals;
|
||||
}
|
||||
}
|
||||
|
|
@ -74,33 +74,27 @@ bool load_obj(const char *path, Model *model, const char *object_name_in)
|
|||
facet2.vertex[0] = facet.vertex[0];
|
||||
facet2.vertex[1] = facet.vertex[2];
|
||||
const ObjParser::ObjVertex &vertex = data.vertices[i++];
|
||||
memcpy(&facet2.vertex[2].x, &data.coordinates[vertex.coordIdx * 4], 3 * sizeof(float));
|
||||
memcpy(facet2.vertex[2].data(), &data.coordinates[vertex.coordIdx * 4], 3 * sizeof(float));
|
||||
if (vertex.normalIdx != -1) {
|
||||
normal.x += data.normals[vertex.normalIdx*3];
|
||||
normal.y += data.normals[vertex.normalIdx*3+1];
|
||||
normal.z += data.normals[vertex.normalIdx*3+2];
|
||||
normal(0) += data.normals[vertex.normalIdx*3];
|
||||
normal(1) += data.normals[vertex.normalIdx*3+1];
|
||||
normal(2) += data.normals[vertex.normalIdx*3+2];
|
||||
++ num_normals;
|
||||
}
|
||||
if (num_normals == 4) {
|
||||
// Normalize an average normal of a quad.
|
||||
float len = sqrt(facet.normal.x*facet.normal.x + facet.normal.y*facet.normal.y + facet.normal.z*facet.normal.z);
|
||||
float len = facet.normal.norm();
|
||||
if (len > EPSILON) {
|
||||
normal.x /= len;
|
||||
normal.y /= len;
|
||||
normal.z /= len;
|
||||
normal /= len;
|
||||
facet.normal = normal;
|
||||
facet2.normal = normal;
|
||||
}
|
||||
}
|
||||
} else if (num_normals == 3) {
|
||||
// Normalize an average normal of a triangle.
|
||||
float len = sqrt(facet.normal.x*facet.normal.x + facet.normal.y*facet.normal.y + facet.normal.z*facet.normal.z);
|
||||
if (len > EPSILON) {
|
||||
normal.x /= len;
|
||||
normal.y /= len;
|
||||
normal.z /= len;
|
||||
facet.normal = normal;
|
||||
}
|
||||
float len = facet.normal.norm();
|
||||
if (len > EPSILON)
|
||||
facet.normal = normal / len;
|
||||
}
|
||||
}
|
||||
stl_get_size(&stl);
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ bool load_prus(const char *path, Model *model)
|
|||
float trafo[3][4] = { 0 };
|
||||
double instance_rotation = 0.;
|
||||
double instance_scaling_factor = 1.f;
|
||||
Pointf instance_offset(0., 0.);
|
||||
Vec2d instance_offset(0., 0.);
|
||||
bool trafo_set = false;
|
||||
unsigned int group_id = (unsigned int)-1;
|
||||
unsigned int extruder_id = (unsigned int)-1;
|
||||
|
|
@ -207,8 +207,8 @@ bool load_prus(const char *path, Model *model)
|
|||
for (size_t c = 0; c < 3; ++ c)
|
||||
trafo[r][c] += mat_trafo(r, c);
|
||||
}
|
||||
instance_offset.x = position[0] - zero[0];
|
||||
instance_offset.y = position[1] - zero[1];
|
||||
instance_offset(0) = position[0] - zero[0];
|
||||
instance_offset(1) = position[1] - zero[1];
|
||||
trafo[2][3] = position[2] / instance_scaling_factor;
|
||||
trafo_set = true;
|
||||
}
|
||||
|
|
@ -260,8 +260,8 @@ bool load_prus(const char *path, Model *model)
|
|||
mesh.repair();
|
||||
// Transform the model.
|
||||
stl_transform(&stl, &trafo[0][0]);
|
||||
if (std::abs(stl.stats.min.z) < EPSILON)
|
||||
stl.stats.min.z = 0.;
|
||||
if (std::abs(stl.stats.min(2)) < EPSILON)
|
||||
stl.stats.min(2) = 0.;
|
||||
// Add a mesh to a model.
|
||||
if (mesh.facets_count() > 0)
|
||||
mesh_valid = true;
|
||||
|
|
@ -309,11 +309,11 @@ bool load_prus(const char *path, Model *model)
|
|||
assert(res_normal == 3);
|
||||
int res_outer_loop = line_reader.next_line_scanf(" outer loop");
|
||||
assert(res_outer_loop == 0);
|
||||
int res_vertex1 = line_reader.next_line_scanf(" vertex %f %f %f", &facet.vertex[0].x, &facet.vertex[0].y, &facet.vertex[0].z);
|
||||
int res_vertex1 = line_reader.next_line_scanf(" vertex %f %f %f", &facet.vertex[0](0), &facet.vertex[0](1), &facet.vertex[0](2));
|
||||
assert(res_vertex1 == 3);
|
||||
int res_vertex2 = line_reader.next_line_scanf(" vertex %f %f %f", &facet.vertex[1].x, &facet.vertex[1].y, &facet.vertex[1].z);
|
||||
int res_vertex2 = line_reader.next_line_scanf(" vertex %f %f %f", &facet.vertex[1](0), &facet.vertex[1](1), &facet.vertex[1](2));
|
||||
assert(res_vertex2 == 3);
|
||||
int res_vertex3 = line_reader.next_line_scanf(" vertex %f %f %f", &facet.vertex[2].x, &facet.vertex[2].y, &facet.vertex[2].z);
|
||||
int res_vertex3 = line_reader.next_line_scanf(" vertex %f %f %f", &facet.vertex[2](0), &facet.vertex[2](1), &facet.vertex[2](2));
|
||||
assert(res_vertex3 == 3);
|
||||
int res_endloop = line_reader.next_line_scanf(" endloop");
|
||||
assert(res_endloop == 0);
|
||||
|
|
@ -324,9 +324,9 @@ bool load_prus(const char *path, Model *model)
|
|||
break;
|
||||
}
|
||||
// The facet normal has been parsed as a single string as to workaround for not a numbers in the normal definition.
|
||||
if (sscanf(normal_buf[0], "%f", &facet.normal.x) != 1 ||
|
||||
sscanf(normal_buf[1], "%f", &facet.normal.y) != 1 ||
|
||||
sscanf(normal_buf[2], "%f", &facet.normal.z) != 1) {
|
||||
if (sscanf(normal_buf[0], "%f", &facet.normal(0)) != 1 ||
|
||||
sscanf(normal_buf[1], "%f", &facet.normal(1)) != 1 ||
|
||||
sscanf(normal_buf[2], "%f", &facet.normal(2)) != 1) {
|
||||
// Normal was mangled. Maybe denormals or "not a number" were stored?
|
||||
// Just reset the normal and silently ignore it.
|
||||
memset(&facet.normal, 0, sizeof(facet.normal));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue