Fixed some obvious mistakes and applied strict type checking to SurfaceCollections too
This commit is contained in:
parent
a831f5b176
commit
3a3e53b59b
5 changed files with 20 additions and 7 deletions
|
@ -6,7 +6,8 @@ namespace Slic3r {
|
||||||
|
|
||||||
ExPolygon::operator Polygons() const
|
ExPolygon::operator Polygons() const
|
||||||
{
|
{
|
||||||
Polygons polygons(this->holes.size() + 1);
|
Polygons polygons;
|
||||||
|
polygons.reserve(this->holes.size() + 1);
|
||||||
polygons.push_back(this->contour);
|
polygons.push_back(this->contour);
|
||||||
for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) {
|
for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) {
|
||||||
polygons.push_back(*it);
|
polygons.push_back(*it);
|
||||||
|
@ -64,7 +65,7 @@ ExPolygon::is_valid() const
|
||||||
bool
|
bool
|
||||||
ExPolygon::contains_line(const Line* line) const
|
ExPolygon::contains_line(const Line* line) const
|
||||||
{
|
{
|
||||||
Polylines pl(1);
|
Polylines pl;
|
||||||
pl.push_back(*line);
|
pl.push_back(*line);
|
||||||
|
|
||||||
Polylines pl_out;
|
Polylines pl_out;
|
||||||
|
@ -85,7 +86,8 @@ ExPolygon::contains_point(const Point* point) const
|
||||||
Polygons
|
Polygons
|
||||||
ExPolygon::simplify_p(double tolerance) const
|
ExPolygon::simplify_p(double tolerance) const
|
||||||
{
|
{
|
||||||
Polygons pp(this->holes.size() + 1);
|
Polygons pp;
|
||||||
|
pp.reserve(this->holes.size() + 1);
|
||||||
|
|
||||||
// contour
|
// contour
|
||||||
Polygon p = this->contour;
|
Polygon p = this->contour;
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Slic3r {
|
||||||
|
|
||||||
Polyline::operator Polylines() const
|
Polyline::operator Polylines() const
|
||||||
{
|
{
|
||||||
Polylines polylines(1);
|
Polylines polylines;
|
||||||
polylines.push_back(*this);
|
polylines.push_back(*this);
|
||||||
return polylines;
|
return polylines;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,15 @@ Surface::is_bridge() const
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SLIC3RXS
|
#ifdef SLIC3RXS
|
||||||
|
void
|
||||||
|
Surface::from_SV_check(SV* surface_sv)
|
||||||
|
{
|
||||||
|
if (!sv_isa(surface_sv, "Slic3r::Surface") && !sv_isa(surface_sv, "Slic3r::Surface::Ref"))
|
||||||
|
CONFESS("Not a valid Slic3r::Surface object");
|
||||||
|
// a XS Surface was supplied
|
||||||
|
*this = *(Surface *)SvIV((SV*)SvRV( surface_sv ));
|
||||||
|
}
|
||||||
|
|
||||||
SV*
|
SV*
|
||||||
Surface::to_SV_ref() {
|
Surface::to_SV_ref() {
|
||||||
SV* sv = newSV(0);
|
SV* sv = newSV(0);
|
||||||
|
|
|
@ -21,6 +21,7 @@ class Surface
|
||||||
bool is_bridge() const;
|
bool is_bridge() const;
|
||||||
|
|
||||||
#ifdef SLIC3RXS
|
#ifdef SLIC3RXS
|
||||||
|
void from_SV_check(SV* surface_sv);
|
||||||
SV* to_SV_ref();
|
SV* to_SV_ref();
|
||||||
SV* to_SV_clone_ref() const;
|
SV* to_SV_clone_ref() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,7 +22,7 @@ SurfaceCollection::new(...)
|
||||||
RETVAL->surfaces.resize(items-1);
|
RETVAL->surfaces.resize(items-1);
|
||||||
for (unsigned int i = 1; i < items; i++) {
|
for (unsigned int i = 1; i < items; i++) {
|
||||||
// Note: a COPY of the input is stored
|
// Note: a COPY of the input is stored
|
||||||
RETVAL->surfaces[i-1] = *(Surface *)SvIV((SV*)SvRV( ST(i) ));
|
RETVAL->surfaces[i-1].from_SV_check(ST(i));
|
||||||
}
|
}
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
|
@ -56,8 +56,9 @@ void
|
||||||
SurfaceCollection::append(...)
|
SurfaceCollection::append(...)
|
||||||
CODE:
|
CODE:
|
||||||
for (unsigned int i = 1; i < items; i++) {
|
for (unsigned int i = 1; i < items; i++) {
|
||||||
// Note: a COPY of the input is stored
|
Surface surface;
|
||||||
THIS->surfaces.push_back(*(Surface *)SvIV((SV*)SvRV( ST(i) )));
|
surface.from_SV_check( ST(i) );
|
||||||
|
THIS->surfaces.push_back(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue