mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	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
 | 
			
		||||
{
 | 
			
		||||
    Polygons polygons(this->holes.size() + 1);
 | 
			
		||||
    Polygons polygons;
 | 
			
		||||
    polygons.reserve(this->holes.size() + 1);
 | 
			
		||||
    polygons.push_back(this->contour);
 | 
			
		||||
    for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) {
 | 
			
		||||
        polygons.push_back(*it);
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +65,7 @@ ExPolygon::is_valid() const
 | 
			
		|||
bool
 | 
			
		||||
ExPolygon::contains_line(const Line* line) const
 | 
			
		||||
{
 | 
			
		||||
    Polylines pl(1);
 | 
			
		||||
    Polylines pl;
 | 
			
		||||
    pl.push_back(*line);
 | 
			
		||||
    
 | 
			
		||||
    Polylines pl_out;
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +86,8 @@ ExPolygon::contains_point(const Point* point) const
 | 
			
		|||
Polygons
 | 
			
		||||
ExPolygon::simplify_p(double tolerance) const
 | 
			
		||||
{
 | 
			
		||||
    Polygons pp(this->holes.size() + 1);
 | 
			
		||||
    Polygons pp;
 | 
			
		||||
    pp.reserve(this->holes.size() + 1);
 | 
			
		||||
    
 | 
			
		||||
    // contour
 | 
			
		||||
    Polygon p = this->contour;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ namespace Slic3r {
 | 
			
		|||
 | 
			
		||||
Polyline::operator Polylines() const
 | 
			
		||||
{
 | 
			
		||||
    Polylines polylines(1);
 | 
			
		||||
    Polylines polylines;
 | 
			
		||||
    polylines.push_back(*this);
 | 
			
		||||
    return polylines;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,6 +24,15 @@ Surface::is_bridge() const
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
#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*
 | 
			
		||||
Surface::to_SV_ref() {
 | 
			
		||||
    SV* sv = newSV(0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@ class Surface
 | 
			
		|||
    bool is_bridge() const;
 | 
			
		||||
    
 | 
			
		||||
    #ifdef SLIC3RXS
 | 
			
		||||
    void from_SV_check(SV* surface_sv);
 | 
			
		||||
    SV* to_SV_ref();
 | 
			
		||||
    SV* to_SV_clone_ref() const;
 | 
			
		||||
    #endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ SurfaceCollection::new(...)
 | 
			
		|||
        RETVAL->surfaces.resize(items-1);
 | 
			
		||||
        for (unsigned int i = 1; i < items; i++) {
 | 
			
		||||
            // 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:
 | 
			
		||||
        RETVAL
 | 
			
		||||
| 
						 | 
				
			
			@ -56,8 +56,9 @@ void
 | 
			
		|||
SurfaceCollection::append(...)
 | 
			
		||||
    CODE:
 | 
			
		||||
        for (unsigned int i = 1; i < items; i++) {
 | 
			
		||||
            // Note: a COPY of the input is stored
 | 
			
		||||
            THIS->surfaces.push_back(*(Surface *)SvIV((SV*)SvRV( ST(i) )));
 | 
			
		||||
            Surface surface;
 | 
			
		||||
            surface.from_SV_check( ST(i) );
 | 
			
		||||
            THIS->surfaces.push_back(surface);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue