Skip to content

Instantly share code, notes, and snippets.

@arnholm
Last active October 4, 2020 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnholm/eda3f740da4f101421a8141b2446a4df to your computer and use it in GitHub Desktop.
Save arnholm/eda3f740da4f101421a8141b2446a4df to your computer and use it in GitHub Desktop.

3d hull from an array of solids

// AngelCAD code.

shape@ main_shape(as_args@ args)
{
   array<solid@> spheres;
   for(int i=-1; i<=1; i+=2) 
      for(int j=-1; j<=1; j+=2) 
         for(int k=-1; k<=1; k+=2) 
            spheres.push_back(translate(10*i,10*j,10*k)*sphere(1.0));
   
   return hull3d(spheres);
}

void main()
{
   shape@ obj = main_shape(GetArgs());
   obj.write_xcsg(GetInputFullPath(),secant_tolerance:0.002);
}

$ xcsg --stl hull_array.xcsg
xcsg processing: hull_array.xcsg
processing solid: hull3d
...completed CSG tree: 1 boolean operations to process.
...starting boolean operations
...completed boolean operations in 0.032 [sec] 
...result model contains 1 lump.
...lump 1: 744 vertices, 1484 polygon faces.
...Polyhedron is water-tight (edge use-count check OK)
...Polyhedron has no degenerated faces (face area check OK)
...Polyhedron has 0 non-triangular faces
...Exporting results 
Created STL file     : hull_array.stl
xcsg finished using 0h 0m 0.053s
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment