Rotate_extrude not closing[fixed]

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Rotate_extrude not closing[fixed]

Neon22
This post was updated on .
I've been working on this handle maker which uses profiles for the handle shapes.
Its all working rather well but f6 wont generate an object.
http://www.thingiverse.com/thing:923244

Can anyone see what I'm doing wrong ?

I thought it was to do with the profiles I'm sending to rotate_extrude not being closed.
I've tried profiles with the inner perimeter open. as well as closed.
The included profiles (in the scad) are open.
I get the same error:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! 
Expr: e->incident_sface() != SFace_const_handle() 
File: /data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h 
Line: 326 
various styles


Now I think its something to do with how I'm using the if-then-else construct and returning shapes internally.
Here is a shorter test script that exposes the problem.
There are two "module handle()"s defined. one is commented.
The commented one works and the uncommented one does not. The difference is to do with the if statement which I have removed from the commented out version.
Here:
straight = [[-8.618015,-177.150395],[-5.943126,-177.111681],[-0.048642,-176.553429],[3.107426,-175.872235],
			[5.870164,-174.812469],[7.840163,-173.291234],[8.403071,-172.331661],[8.618015,-171.225635],
			[8.618015,168.849595],[8.419897,170.484719],[7.901103,172.060079],[6.942488,173.520198],
			[5.424905,174.809595],[3.229209,175.872792],[0.236254,176.654311],[-3.673106,177.098671],
			[-8.618015,177.150395]];
finger =[[-19.755717,-177.194280],[-15.207974,-177.111965],[-5.192635,-176.458529],[0.164808,-175.727099],
			[4.848461,-174.624239],[6.725044,-173.909705],[8.178094,-173.073731],[9.122582,-172.106792],
			[9.473478,-170.999360],[9.072381,-153.913984],[7.748662,-120.675156],[3.518541,-26.385338],
			[-0.846526,70.573712],[-2.338928,107.149079],[-2.976182,128.905610],[-2.768154,134.659568],
			[-2.078743,139.383965],[-0.976327,143.212236],[0.470712,146.277818],[2.193995,148.714148],
			[4.125142,150.654664],[8.337511,153.581997],[12.560777,156.127314],[14.505548,157.590308],
			[16.247903,159.358108],[17.719464,161.564152],[18.851849,164.341875],[19.576681,167.824716],
			[19.825577,172.146110],[19.549209,172.930770],[18.756078,173.640478],[15.810825,174.845571],
			[11.372425,175.782442],[5.823483,176.472147],[-7.075600,177.194280],[-19.825577,177.180410]];

Faceted = 12;
profile_scale = 25.4/90; //made in inkscape in mm


// helper functions to determine the X,Y dimensions of the profiles
function max_x(profile_list) = max([ for (x = profile_list) max(x[0])]);
function max_y(profile_list) = max([ for (x = profile_list) max(x[1])]);

module create_hole(length, z_pos, hole_dia, halfway=false, smooth=32) {
	// create cylinder representing hole
	half = halfway ? 1 : 2; // only drill halfway through
	translate([-length/2-0.5,0,z_pos]) //0.5 for overlap and safe boolean
			rotate([0,90,0])
				cylinder(d=hole_dia,h=length/half+1,$fn=smooth); //+1 for overlap and safe boolean
}


// module handle (profile_list, new_height, new_width) {
	// p_max_x = max_x(profile_list) * profile_scale; // the width of profile is 2x this
	// p_max_y = max_y(profile_list) * profile_scale; // the height of profile is 2x this
	// y_scale = new_height/(p_max_y*2); // calculate scale to make handle desired height
	////we scale the profile to the desired width
	// x_scale = new_width/(p_max_x*4); // calculate scale to make handle desired width 
	// rotate_extrude($fn=Faceted) {
		// scale([x_scale,y_scale,1])
		// translate([p_max_x, p_max_y, 0]) // scale profile
		// scale([profile_scale, -profile_scale, 1])
			// polygon(profile_list);
	// }
// }


module handle (profile_list, new_height, new_width, shift="scale") {
	p_max_x = max_x(profile_list) * profile_scale; // the width of profile is 2x this
	p_max_y = max_y(profile_list) * profile_scale; // the height of profile is 2x this
	y_scale = new_height/(p_max_y*2); // calculate scale to make handle desired height
	//echo(p_max_x=p_max_x, p_max_y=p_max_y);
	//echo(new_height=new_height,y_scale=y_scale);
	if (shift=="shift") { // shift the profile preserving its absolute profile shape
		x_scale = 1;  // shift profile
		if (new_width/2 <= p_max_x*2) {
			echo("make wider or scale");
			translate([-60,-5,10]) rotate([90,0,0]) 
			text("make wider or scale"); 
		};
		rotate_extrude($fn=Faceted) {
			scale([x_scale,y_scale,1])
			translate([new_width/2-p_max_x, p_max_y, 0]) // shift profile
			scale([profile_scale, -profile_scale, 1])
				polygon(profile_list);
		}
		// core to fill in hole in middle of shifted profile
		cylinder(h=new_height, r=new_width/2-(p_max_x*2) +0.5, $fn=Faceted);
	} else { // or we scale the profile to the desired width
		x_scale = new_width/(p_max_x*4); // calculate scale to make handle desired width 
		rotate_extrude($fn=Faceted) {
			scale([x_scale,y_scale,1])
			translate([p_max_x, p_max_y, 0]) // scale profile
			scale([profile_scale, -profile_scale, 1])
				polygon(profile_list);
		}
	}
}


height=60;
width=12;
hole_depth=12;
difference() {
	handle(finger, height, width);
	#translate([0,0,-1])
		cylinder(d=3, h=hole_depth+1, $fn=6);
	}
You'll see the problem when you press F6 in OpenSCAD.
What am I missing ? explicit union's maybe ?
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Rotate_extrude not closing

tp3
Von: Neon22 <[hidden email]>
> http://www.thingiverse.com/thing:923244
>
> Can anyone see what I'm doing wrong ?
>
No, I guess the thing is not yet published, so I'm only getting 404 error.

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: Rotate_extrude not closing

Neon22
OK I published it
also the test code I included is simpler...
Cheers...

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Rotate_extrude not closing[fixed]

Neon22
ok fixed it.
The profile has no central hole. I shift the profile so that the leftmost edge is the center of the object. However CGAL can't cope with this.
So ow I shift it so there is a 0.1mm dia hole through the center and then I add a cylinder to overlap this to make it manifold.

So my problem was caused by the rotate_extrude operator and my lack of a central hole.
Cheers...