3DCoat Core API
The 3DCoat API documentation.
No Matches

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

// This example generates the detail for the further 3D printing using the surface mode. The CSG principles demonstrated.
#include <CoreAPI.h>
//@config: Debug
using namespace coat;
// The general problem of surface mode - boolean operations are less stable that in voxels.
// So you need to avoid booleans of objects with identical planes intersections.
int main() {
// create new volume, don't need to set density as in voxels
auto current = Scene::sculptRoot().addChild("Detail");
// get the volume object to refer later
auto volume = current.Volume();
// turn to surface mode
// set the details level for the more consistent polygons density
// add the sphere, diameter 16, dense (30 divisions)
// the cylinder that will be use to clip the top and bottom of the figure
cylinder clip;
//move down 9mm and subtract. We move 9mm (not 10) to avoid planes exact intersection,
//because exact intersection is problematic for the surface mode.
//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
// make hole at the top
// make hole through all the object
// no need to relax at the end because the surface is clean
return 0;
The class allows to operate over voxels/surface on the relatively low-level.
Definition CoreAPI.h:615
void toSurface()
turn to surface mode, the triangles will be tangentially relaxed
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.
prim & details(const float det_level)
set the detail level
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:14