mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-02 19:44:00 -06:00
Change method signature for slice()
This commit is contained in:
parent
878d587196
commit
67a7e4f769
3 changed files with 11 additions and 13 deletions
|
@ -161,8 +161,8 @@ void TriangleMesh::rotate(double angle, Point* center)
|
||||||
this->translate(+center->x, +center->y, 0);
|
this->translate(+center->x, +center->y, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Polygons>*
|
void
|
||||||
TriangleMesh::slice(const std::vector<double> &z)
|
TriangleMesh::slice(const std::vector<double> &z, std::vector<Polygons> &layers)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
This method gets called with a list of Z coordinates and outputs
|
This method gets called with a list of Z coordinates and outputs
|
||||||
|
@ -368,7 +368,7 @@ TriangleMesh::slice(const std::vector<double> &z)
|
||||||
}
|
}
|
||||||
|
|
||||||
// build loops
|
// build loops
|
||||||
std::vector<Polygons>* layers = new std::vector<Polygons>(z.size());
|
layers.resize(z.size());
|
||||||
for (std::vector<IntersectionLines>::iterator it = lines.begin(); it != lines.end(); ++it) {
|
for (std::vector<IntersectionLines>::iterator it = lines.begin(); it != lines.end(); ++it) {
|
||||||
int layer_idx = it - lines.begin();
|
int layer_idx = it - lines.begin();
|
||||||
#ifdef SLIC3R_DEBUG
|
#ifdef SLIC3R_DEBUG
|
||||||
|
@ -461,7 +461,7 @@ TriangleMesh::slice(const std::vector<double> &z)
|
||||||
for (IntersectionLinePtrs::iterator lineptr = loop.begin(); lineptr != loop.end(); ++lineptr) {
|
for (IntersectionLinePtrs::iterator lineptr = loop.begin(); lineptr != loop.end(); ++lineptr) {
|
||||||
p.points.push_back((*lineptr)->a);
|
p.points.push_back((*lineptr)->a);
|
||||||
}
|
}
|
||||||
(*layers)[layer_idx].push_back(p);
|
layers[layer_idx].push_back(p);
|
||||||
|
|
||||||
#ifdef SLIC3R_DEBUG
|
#ifdef SLIC3R_DEBUG
|
||||||
printf(" Discovered %s polygon of %d points\n", (p.is_counter_clockwise() ? "ccw" : "cw"), (int)p.points.size());
|
printf(" Discovered %s polygon of %d points\n", (p.is_counter_clockwise() ? "ccw" : "cw"), (int)p.points.size());
|
||||||
|
@ -487,8 +487,6 @@ TriangleMesh::slice(const std::vector<double> &z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return layers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TriangleMeshPtrs
|
TriangleMeshPtrs
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TriangleMesh
|
||||||
void translate(float x, float y, float z);
|
void translate(float x, float y, float z);
|
||||||
void align_to_origin();
|
void align_to_origin();
|
||||||
void rotate(double angle, Point* center);
|
void rotate(double angle, Point* center);
|
||||||
std::vector<Polygons>* slice(const std::vector<double> &z);
|
void slice(const std::vector<double> &z, std::vector<Polygons> &layers);
|
||||||
TriangleMeshPtrs split() const;
|
TriangleMeshPtrs split() const;
|
||||||
void merge(const TriangleMesh* mesh);
|
void merge(const TriangleMesh* mesh);
|
||||||
stl_file stl;
|
stl_file stl;
|
||||||
|
|
|
@ -129,20 +129,20 @@ SV*
|
||||||
TriangleMesh::slice(z)
|
TriangleMesh::slice(z)
|
||||||
std::vector<double>* z
|
std::vector<double>* z
|
||||||
CODE:
|
CODE:
|
||||||
std::vector<Polygons>* layers = THIS->slice(*z);
|
std::vector<Polygons> layers;
|
||||||
|
THIS->slice(*z, layers);
|
||||||
|
|
||||||
AV* layers_av = newAV();
|
AV* layers_av = newAV();
|
||||||
av_extend(layers_av, layers->size()-1);
|
av_extend(layers_av, layers.size()-1);
|
||||||
for (unsigned int i = 0; i < layers->size(); i++) {
|
for (unsigned int i = 0; i < layers.size(); i++) {
|
||||||
AV* polygons_av = newAV();
|
AV* polygons_av = newAV();
|
||||||
av_extend(polygons_av, (*layers)[i].size()-1);
|
av_extend(polygons_av, layers[i].size()-1);
|
||||||
unsigned int j = 0;
|
unsigned int j = 0;
|
||||||
for (Polygons::iterator it = (*layers)[i].begin(); it != (*layers)[i].end(); ++it) {
|
for (Polygons::iterator it = layers[i].begin(); it != layers[i].end(); ++it) {
|
||||||
av_store(polygons_av, j++, (*it).to_SV_clone_ref());
|
av_store(polygons_av, j++, (*it).to_SV_clone_ref());
|
||||||
}
|
}
|
||||||
av_store(layers_av, i, newRV_noinc((SV*)polygons_av));
|
av_store(layers_av, i, newRV_noinc((SV*)polygons_av));
|
||||||
}
|
}
|
||||||
delete layers;
|
|
||||||
RETVAL = (SV*)newRV_noinc((SV*)layers_av);
|
RETVAL = (SV*)newRV_noinc((SV*)layers_av);
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue