-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unioning spheres ends up with too many polygons #5
Comments
What are you trying to do with so many spheres? :) To reduce the runtime you can enable optimization. This is still a work in progress. But it should work in your case. For me it reduced the runtime to about 10-20 seconds. Here's an example: import eu.mihosoft.vrl.v3d.CSG;
import eu.mihosoft.vrl.v3d.FileUtil;
import eu.mihosoft.vrl.v3d.Sphere;
import eu.mihosoft.vrl.v3d.Transform;
import java.io.IOException;
import java.nio.file.Paths;
/**
*
* @author Michael Hoffer <info@michaelhoffer.de>
*/
public class Spheres {
public CSG toCSG() {
double maxR = 10;
double w = 30;
double h = 30;
double d = 30;
// optimization reduces runtime dramatically
CSG.setDefaultOptType(CSG.OptType.POLYGON_BOUND);
CSG spheres = null;
for(int i = 0;i<70;i++) {
CSG s = new Sphere(Math.random()*maxR).toCSG().
transformed(
Transform.unity().
translate(
Math.random()*w,
Math.random()*h,
Math.random()*d));
if (spheres == null) {
spheres = s;
} else {
spheres = spheres.union(s);
}
}
return spheres;
}
public static void main(String[] args) throws IOException {
FileUtil.write(Paths.get("spheres.stl"), new Spheres().toCSG().toStlString());
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After unioning about 70 spheres together, I end up with a lot of polygons, as shown this image:
It also takes 5+ minutes to do all of the unions. Do you have any ideas on how to speed this up/clean up the end result? Thanks!
The text was updated successfully, but these errors were encountered: