mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Return a reference to the actual item instead of a clone when accessing contents of a SurfaceCollection
This commit is contained in:
		
							parent
							
								
									f612d4c64e
								
							
						
					
					
						commit
						e485f0b130
					
				
					 3 changed files with 12 additions and 3 deletions
				
			
		|  | @ -23,6 +23,7 @@ class Surface | |||
|     unsigned short  thickness_layers;   // in layers
 | ||||
|     double          bridge_angle; | ||||
|     unsigned short  extra_perimeters; | ||||
|     bool            in_collection; | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -6,8 +6,6 @@ | |||
| %} | ||||
| 
 | ||||
| %name{Slic3r::Surface} class Surface { | ||||
|     %name{_clone} Surface(Surface& self); | ||||
|     ~Surface(); | ||||
|     ExPolygon* expolygon() | ||||
|         %code{% const char* CLASS = "Slic3r::ExPolygon::XS"; RETVAL = new ExPolygon(THIS->expolygon); %}; | ||||
|     double thickness() | ||||
|  | @ -36,6 +34,14 @@ _new(CLASS, expolygon, surface_type, thickness, thickness_layers, bridge_angle, | |||
|     OUTPUT: | ||||
|         RETVAL | ||||
| 
 | ||||
| void | ||||
| Surface::DESTROY() | ||||
|     CODE: | ||||
|         if (!THIS->in_collection) { | ||||
|             delete THIS; | ||||
|             THIS = NULL; | ||||
|         } | ||||
| 
 | ||||
| SurfaceType | ||||
| Surface::surface_type(...) | ||||
|     CODE: | ||||
|  |  | |||
|  | @ -19,6 +19,7 @@ SurfaceCollection::new(...) | |||
|         RETVAL->surfaces.resize(items-1); | ||||
|         for (unsigned int i = 1; i < items; i++) { | ||||
|             RETVAL->surfaces[i-1] = *(Surface *)SvIV((SV*)SvRV( ST(i) )); | ||||
|             RETVAL->surfaces[i-1].in_collection = true; | ||||
|         } | ||||
|     OUTPUT: | ||||
|         RETVAL | ||||
|  | @ -31,7 +32,7 @@ SurfaceCollection::arrayref() | |||
|         int i = 0; | ||||
|         for (Surfaces::iterator it = THIS->surfaces.begin(); it != THIS->surfaces.end(); ++it) { | ||||
|             SV* sv = newSV(0); | ||||
|             sv_setref_pv( sv, "Slic3r::Surface", new Surface(*it) ); | ||||
|             sv_setref_pv( sv, "Slic3r::Surface", &*it ); | ||||
|             av_store(av, i++, sv); | ||||
|         } | ||||
|         RETVAL = newRV_noinc((SV*)av); | ||||
|  | @ -43,6 +44,7 @@ SurfaceCollection::append(...) | |||
|     CODE: | ||||
|         for (unsigned int i = 1; i < items; i++) { | ||||
|             THIS->surfaces.push_back(*(Surface *)SvIV((SV*)SvRV( ST(i) ))); | ||||
|             THIS->surfaces.back().in_collection = true; | ||||
|         } | ||||
| 
 | ||||
| %} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci