3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
csg_voxels.cpp

This example generates the detail for the further 3D printing using the voxels. The CSG principles demonstrated.

// This example generates the detail for the further 3D printing using the voxels. The CSG principles demonstrated.
#include <CoreAPI.h>
//@config: Debug
using namespace coat;
EXPORT
int main() {
// create new volume and set 20x density - 20 voxels per 1 unit (mm)
auto current = Scene::sculptRoot().addChild("Detail").density(20);
// get the volume object to refer later
auto volume = current.Volume();
// turn to voxels
volume.toVoxels();
// add the sphere, diameter 16, dense (40 divisions)
sphere().diameter(16).add(volume);
// the cylinder that will be use to clip the top and bottom of the figure
cylinder clip;
clip.height(10).diameter(20);
//move down 9mm and subtract
clip.y(-9).subtract(volume);
//move up 9mm (back) and additionally 7 mm up and subtract
clip.y(9 + 7).subtract(volume);
// add the base of the figure. pay attention, we create temporary object using the cylinder() and operate,
// this is a bit different from the clip object that we used twice
cylinder().height(1.25).diameterBottom(19.0).diameterTop(18.5).add(volume);
// make hole at the top
cylinder().height(8).diameter(6).y(4).subtract(volume);
// make hole through all the object
cylinder().height(8).diameter(3).y(-2).subtract(volume);
// we relax once to improve sharp borders quality
volume.relaxVoxels(1);
return 0;
}
The class allows to operate over voxels/surface on the relatively low-level.
Definition CoreAPI.h:1947
void toVoxels()
turn to voxels, auto-voxelize
The cylinder.
Definition CorePrimAPI.h:876
cylinder & diameterTop(const float &d)
set the top diameter.
cylinder & height(const float &_height)
set the height in the z-axis.
cylinder & diameter(const float &d)
set the diameter.
cylinder & diameterBottom(const float &r)
set the bottom diameter.
void subtract(Volume &v)
subtract the prim from scene
prim & y(float y)
shift the primitive along the y - axis
void add(Volume &v)
add the prim into scene
The sphere.
Definition CorePrimAPI.h:620
sphere & diameter(const float &d)
set the diameter of the sphere.
The coat namespace used for most 3DCoat API calls except low-level internal structures.
Definition CoreAPI.h:43