3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
coat::Volume Class Reference

The class allows to operate over voxels/surface on the relatively low-level. More...

#include <CoreAPI.h>

Public Member Functions

 Volume (VoxTreeBranch *tb)
 
 Volume (VolumeObject *vo)
 
 Volume (const Volume &vol)
 
bool valid () const
 checks if object is valid
 
bool isSurface () const
 Check if in surface mode.
 
bool isVoxelized () const
 Check if in voxel mode.
 
void toSurface ()
 turn to surface mode, the triangles will be tangentially relaxed
 
void toVoxels ()
 turn to voxels, auto-voxelize
 
void mergeMesh (Mesh &mesh, const mat4 &transform=mat4::Identity, BoolOpType op=BOOL_MERGE)
 merge the mesh into scene
 
void insertMesh (Mesh &mesh, const mat4 &transform=mat4::Identity)
 insert the mesh into the volume, in case of voxels this is identical to addMesh, in case of surface, mesh will be inserted without booleans
 
void addMesh (Mesh &mesh, const mat4 &transform=mat4::Identity)
 add the mesh to volume (boolean)
 
void subtractMesh (Mesh &mesh, const mat4 &transform=mat4::Identity)
 subtract the mesh from volume (boolean)
 
void intersectWithMesh (Mesh &mesh, const mat4 &transform=mat4::Identity)
 intersect the volume with the mesh (boolean)
 
void mergeMeshWithTexture (Mesh &mesh, const mat4 &transform=mat4::Identity, BoolOpType op=BOOL_MERGE)
 merge the mesh with facture, the volume polygons will be hidden, just the texture will be shown (like leafs in TreesGenerator)
 
VolumemakeVoxelFigure (std::function< float(vec3)> densityFunction, const list< vec3 > &growCenters, bool Subtract=false, bool useTempLocation=false, bool overHidden=false, bool useColor=false)
 This function is fast (generally realtime) way to fill the volume with voxels. Voxel Brush Engune completely based on this routine.
 
float getExactDencity (int x, int y, int z, bool fromBackup, VolumeCache &cache_ref)
 returns the exact voxel density in local space at the exact integer location
 
float getInterpolatedValue (const vec3 &pos, bool fromBackup)
 returns interolated voxels density
 
void scanCells (const std::function< void(VolumeCell *vc)> &fn, bool multithreaded=false)
 run through all volume cells
 
void scanCells (const std::function< void(VolumeCellAttrib *vc)> &fn, bool multithreaded=false)
 run through all volume cells
 
void scanCells (const std::function< void(VolumeCellAttrib *vc, const tri_DWORD &T)> &fn, bool multithreaded=false)
 run through all volume cells
 
void scanCells (const std::function< void(VolumeCell *vc, const tri_DWORD &T)> &fn, bool multithreaded=false)
 run through all volume cells
 
void scanTriangles (const std::function< void(const MCVertex &v1, const MCVertex &v2, const MCVertex &v3)> &fn, bool multithreaded=false)
 run through all triangles
 
void scanTriangles (const std::function< void(const Vector3D &v1, const Vector3D &v2, const Vector3D &v3)> &fn, bool multithreaded=false)
 run through all triangles
 
int getPolycount ()
 get the volume triangles count
 
float getVolume ()
 get the volume of this object in world coordinates
 
float getSquare ()
 reg the square of this object in world coordinates
 
boundbox calcLocalSpaceAABB ()
 Calculate the Axis - Aligned Bound Box of the object in local space.
 
boundbox calcWorldSpaceAABB ()
 Calculate the Axis - Aligned Bound Box of the object in world space.
 
VoxTreeBranch * tree ()
 returns the low-level object (VoxTreeBranch) for all low-level operations
 
VolumeObject * vo ()
 returns the low-level object (VolumeObject) for all low-level operations
 
VolumeCell * cell (int cx, int cy, int cz, bool create, bool backup)
 get the cell by cell coordinates, each cell is 8*8*8
 
VolumeCellAttrib * attributes (int cx, int cy, int cz, bool create, bool backup)
 get the cell attributes by cell coordinates, each cell is 8*8*8, generally it is kept as VolumeCell::Attr
 
void dirty (int cx, int cy, int cz)
 mark the cell as dirty. This is required if you
 
void setOpacity (float Opacity)
 set the volume opacity
 
void relaxGpu (const vec3 &center, float Radius, float degree)
 fast voxel-based relax within the sphere with the gradual falloff. It works only in voxel mode.
 
void relaxVoxels (int count)
 relax the whole volume, works only for voxels
 
void relaxSurface (float degree, bool tangent=false, bool keep_sharp_boolean_edges=false)
 relax the object in surface mode
 
void relaxOpenEdges (int nTimes)
 relax the open edges of the mesh, it is applicable only to the surface mode
 
SceneElement inScene ()
 Get the Volume placement in the scene.
 
void clear ()
 Clear and pass to the Undo queue.
 
void clearNoUndo ()
 Clear quickly, without affecting the Undo queue.
 
void assignShader (const char *shaderName)
 set the shader for the Volume
 
void setBoolShaderProperty (const char *property, bool value)
 
void setFloatShaderProperty (const char *property, float value)
 
void setColorShaderProperty (const char *property, DWORD value)
 
void removeFacesByWeight (std::function< float(const vec3 &)> weight)
 Remove all faces where all the function returns the value < 0 for all the vertices over the face.
 
void closeHoles (int maxSize)
 Close the holes.
 
void removeUndercuts ()
 remove undercuts for the current volume
 
void basRelief (const vec3 &start_point=vec3::Zero)
 perform the bas-relief for the current volume
 
void generateMoldingCurves ()
 generate the automatic molding curves
 
void automaticMolding ()
 perform the automatic molding
 
void curveBasedMolding ()
 perform the curve-based mold
 
void subtractWithoutUndecuts ()
 subtract the current undercutted object from the preliminary generated molding shapes
 
SceneElement generateMoldingTest ()
 generate the figure that fills the gap between the molding shapes

 
SceneElement findMoldingTop ()
 find the top molding shape (that was previously generated)
 
SceneElement findMoldingBottom ()
 find the bottom molding shape (that was previously generated)
 
SceneElement findMoldingTest ()
 find the test molding test shape (that was previously generated)
 
void removeMoldingShapes ()
 remove all molding intermediate shapes, tests, etc.
 
void assignLiveBooleans (int operation)
 Apply the live booleans over the sculpt mesh, it is available for voxels only.
 
void collapseBollTree ()
 collapse the boolean tree, it is available for this volume
 

Static Public Member Functions

static void enableVoxelsColoring (bool enable=true)
 enable or disable the voxel-based coloring. It is applied wherever possible - merging models, brushing, creating parametric voxel figures, etc
 
static void color (DWORD CL)
 set the default color to fill voxels if the voxel coloring enabled
 
static void color (float r, float g, float b, float a)
 assign the color for the voxel operations
 
static void color (float r, float g, float b)
 assign the color for the voxel operations
 
static void color (const char *colorid)
 assign the color for the voxel operations
 
static void gloss (float value)
 assign the gloss for the voxel operations, it will work only if the color already assigned
 
static void roughness (float value)
 assign the roughness for the voxel operations, it will work only if the color already assigned
 
static void metal (float value)
 the metalliclty value for the voxel operations, it will work only if the color already assigned
 
static bool checkIfMoldingLicenseAvailable ()
 check if molding allowed
 
static void setMoldingParams (const vec3 &direction, float tapering_angle=0, float undercuts_density=1.0f, float decimation_limit_millions=10, bool perform_subtraction=true)
 set the parameters for the molding
 
static void setAutomaticMoldingBox ()
 set the molding bound box to be automatic
 
static void setMoldingBox (float width, float length, float thickness)
 set the molding bound box to be user-defined, not automatic
 
static void setMoldingBorder (float width=0)
 set the molding border around the parting line to fade to the plane, if it is zero, the final shape will not fade to plane
 

Protected Attributes

VoxTreeBranch * tb
 
VolumeObject * Obj
 

Friends

class SceneElement
 

Detailed Description

The class allows to operate over voxels/surface on the relatively low-level.

Examples
GeneratorExample.cpp, and TreesGenerator.cpp.

Member Function Documentation

◆ addMesh()

void coat::Volume::addMesh ( Mesh mesh,
const mat4 transform = mat4::Identity 
)

add the mesh to volume (boolean)

Parameters
meshthe mesh reference
transformthe transform applied

◆ assignLiveBooleans()

void coat::Volume::assignLiveBooleans ( int  operation)

Apply the live booleans over the sculpt mesh, it is available for voxels only.

Parameters
operation0 - stop live booleans, 1 - subtract from the parent, 2 - intersect, 3 - union

◆ assignShader()

void coat::Volume::assignShader ( const char *  shaderName)

set the shader for the Volume

Parameters
shaderNamethe shader name as it is shown in the shader's hint
Examples
TreesGenerator.cpp.

◆ attributes()

VolumeCellAttrib * coat::Volume::attributes ( int  cx,
int  cy,
int  cz,
bool  create,
bool  backup 
)

get the cell attributes by cell coordinates, each cell is 8*8*8, generally it is kept as VolumeCell::Attr

Parameters
cxcell x
cycell y
czcell z
createpass true if you want to create the cell if it does not exist
backupdrop the cell to backup (if not already dropped)
Returns
the pointer to the VolumeCellAttrib

◆ basRelief()

void coat::Volume::basRelief ( const vec3 start_point = vec3::Zero)

perform the bas-relief for the current volume

Parameters
start_pointthe cut point

◆ calcLocalSpaceAABB()

boundbox coat::Volume::calcLocalSpaceAABB ( )

Calculate the Axis - Aligned Bound Box of the object in local space.

Returns
the boundary as comms::cBounds

◆ calcWorldSpaceAABB()

boundbox coat::Volume::calcWorldSpaceAABB ( )

Calculate the Axis - Aligned Bound Box of the object in world space.

Returns
the boundary as comms::cBounds

◆ cell()

VolumeCell * coat::Volume::cell ( int  cx,
int  cy,
int  cz,
bool  create,
bool  backup 
)

get the cell by cell coordinates, each cell is 8*8*8

Parameters
cxcell x
cycell y
czcell z
createpass true if you want to create the cell if it does not exist
backupdrop the cell to backup (if not already dropped)
Returns
the pointer to the VolumeCell

◆ checkIfMoldingLicenseAvailable()

static bool coat::Volume::checkIfMoldingLicenseAvailable ( )
static

check if molding allowed

Returns
true if the molding license available

◆ closeHoles()

void coat::Volume::closeHoles ( int  maxSize)

Close the holes.

Parameters
maxSizemax hole size (edges over the primeter)

◆ color() [1/3]

static void coat::Volume::color ( const char *  colorid)
static

assign the color for the voxel operations

Parameters
coloridthe color in any suitable form: "RGB", "ARGB", "RRGGBB", "AARRGGBB", "#RGB", "#ARGB", "#RRGGBB", "#AARRGGBB", any web-color common name as "red", "green", "purple", google "webcolors"

◆ color() [2/3]

static void coat::Volume::color ( float  r,
float  g,
float  b 
)
static

assign the color for the voxel operations

Parameters
rred value 0..255
ggreen value 0..255
bblue value 0..255

◆ color() [3/3]

static void coat::Volume::color ( float  r,
float  g,
float  b,
float  a 
)
static

assign the color for the voxel operations

Parameters
rred value 0..255
ggreen value 0..255
bblue value 0..255
aalpha value 0..255

◆ dirty()

void coat::Volume::dirty ( int  cx,
int  cy,
int  cz 
)

mark the cell as dirty. This is required if you

Parameters
cx
cy
cz

◆ enableVoxelsColoring()

static void coat::Volume::enableVoxelsColoring ( bool  enable = true)
static

enable or disable the voxel-based coloring. It is applied wherever possible - merging models, brushing, creating parametric voxel figures, etc

Parameters
enabletrue to enable

◆ findMoldingBottom()

SceneElement coat::Volume::findMoldingBottom ( )

find the bottom molding shape (that was previously generated)

Returns
the bottom shape reference

◆ findMoldingTest()

SceneElement coat::Volume::findMoldingTest ( )

find the test molding test shape (that was previously generated)

Returns
the test shape reference

◆ findMoldingTop()

SceneElement coat::Volume::findMoldingTop ( )

find the top molding shape (that was previously generated)

Returns
the top shape reference

◆ generateMoldingTest()

SceneElement coat::Volume::generateMoldingTest ( )

generate the figure that fills the gap between the molding shapes

Returns
the generated scene element reference

◆ getExactDencity()

float coat::Volume::getExactDencity ( int  x,
int  y,
int  z,
bool  fromBackup,
VolumeCache cache_ref 
)

returns the exact voxel density in local space at the exact integer location

Parameters
xX-coordinate
yY-coordinate (up)
zZ-coordinate
fromBackuptake the values from the backup (kept before the modifications started)
cache_refdefine the variable coat::VolumeCache and pass there (in same thread) to speed up access;
Returns
the density 0..1

◆ getInterpolatedValue()

float coat::Volume::getInterpolatedValue ( const vec3 pos,
bool  fromBackup 
)

returns interolated voxels density

Parameters
posposition in local space
fromBackuptake from the backup
Returns
linearly interplated value of the density

◆ getPolycount()

int coat::Volume::getPolycount ( )

get the volume triangles count

Returns
triangles count

◆ getSquare()

float coat::Volume::getSquare ( )

reg the square of this object in world coordinates

Returns
square

◆ getVolume()

float coat::Volume::getVolume ( )

get the volume of this object in world coordinates

Returns
volume

◆ gloss()

static void coat::Volume::gloss ( float  value)
static

assign the gloss for the voxel operations, it will work only if the color already assigned

Parameters
valuethe [0..1] value of the gloss

◆ inScene()

SceneElement coat::Volume::inScene ( )

Get the Volume placement in the scene.

Returns
the SceneElement

◆ insertMesh()

void coat::Volume::insertMesh ( Mesh mesh,
const mat4 transform = mat4::Identity 
)

insert the mesh into the volume, in case of voxels this is identical to addMesh, in case of surface, mesh will be inserted without booleans

Parameters
meshthe mesh reference
transformthe transform applied

◆ intersectWithMesh()

void coat::Volume::intersectWithMesh ( Mesh mesh,
const mat4 transform = mat4::Identity 
)

intersect the volume with the mesh (boolean)

Parameters
meshthe mesh reference
transformthe transform applied

◆ isSurface()

bool coat::Volume::isSurface ( ) const

Check if in surface mode.

Returns
true if in surface mode

◆ isVoxelized()

bool coat::Volume::isVoxelized ( ) const

Check if in voxel mode.

Returns
true if in voxel mode

◆ makeVoxelFigure()

Volume & coat::Volume::makeVoxelFigure ( std::function< float(vec3)>  densityFunction,
const list< vec3 > &  growCenters,
bool  Subtract = false,
bool  useTempLocation = false,
bool  overHidden = false,
bool  useColor = false 
)

This function is fast (generally realtime) way to fill the volume with voxels. Voxel Brush Engune completely based on this routine.

Parameters
densityFunctionthe function should return the value 0..1, where 0 means empty, 1-filled, 0.5 means we are on the surface. Be careful, function should be limited in space. Coordinates passed in volume's local space.
growCentersthe list of points where function is not zero - that are grow centers
Subtracttrue if you need to subtract, in this case you return value that will be subtracted from the volume
useTempLocationif true all your modifications will be applied after you will finish all chnages
overHiddenif true the function will work as Hide tool (Subtract taken into account)
useColorif true the voxel color will be used
Returns
returns itself for the chain-like reference.

◆ mergeMesh()

void coat::Volume::mergeMesh ( Mesh mesh,
const mat4 transform = mat4::Identity,
BoolOpType  op = BOOL_MERGE 
)

merge the mesh into scene

Parameters
meshthe Mesh reference
transformthe transform applied
opthe type of the merge
Examples
GeneratorExample.cpp, and TreesGenerator.cpp.

◆ mergeMeshWithTexture()

void coat::Volume::mergeMeshWithTexture ( Mesh mesh,
const mat4 transform = mat4::Identity,
BoolOpType  op = BOOL_MERGE 
)

merge the mesh with facture, the volume polygons will be hidden, just the texture will be shown (like leafs in TreesGenerator)

Parameters
meshthe mesh that refers texture
transformthe transform applied
opthe boolean operation

◆ metal()

static void coat::Volume::metal ( float  value)
static

the metalliclty value for the voxel operations, it will work only if the color already assigned

Parameters
valuethe [0..1] metal value

◆ relaxGpu()

void coat::Volume::relaxGpu ( const vec3 center,
float  Radius,
float  degree 
)

fast voxel-based relax within the sphere with the gradual falloff. It works only in voxel mode.

Parameters
centerthe center of
Radiusthe radius of the influence
degreethe relax degree, < 1
Examples
TreesGenerator.cpp.

◆ relaxOpenEdges()

void coat::Volume::relaxOpenEdges ( int  nTimes)

relax the open edges of the mesh, it is applicable only to the surface mode

Parameters
nTimesamount of iterations

◆ relaxSurface()

void coat::Volume::relaxSurface ( float  degree,
bool  tangent = false,
bool  keep_sharp_boolean_edges = false 
)

relax the object in surface mode

Parameters
degreethe degree of smoothing, it may be >1 for the stronger relax
tangentuse tangent relax
keep_sharp_boolean_edgeskeep the sharp edges appeared due to bolean operations

◆ relaxVoxels()

void coat::Volume::relaxVoxels ( int  count)

relax the whole volume, works only for voxels

Parameters
countthe count of relax steps

◆ removeFacesByWeight()

void coat::Volume::removeFacesByWeight ( std::function< float(const vec3 &)>  weight)

Remove all faces where all the function returns the value < 0 for all the vertices over the face.

Parameters
weightthe function, should return < 0 where you need to remove the whole face, > 0 where you need to keep the face. Coordinate is in global space.

◆ roughness()

static void coat::Volume::roughness ( float  value)
static

assign the roughness for the voxel operations, it will work only if the color already assigned

Parameters
valuethe [0..1] value of the roughness

◆ scanCells() [1/4]

void coat::Volume::scanCells ( const std::function< void(VolumeCell *vc)> &  fn,
bool  multithreaded = false 
)

run through all volume cells

Parameters
fncallback/lambda, VolumeCell pointer passed there
multithreadeduse multi-threading

◆ scanCells() [2/4]

void coat::Volume::scanCells ( const std::function< void(VolumeCell *vc, const tri_DWORD &T)> &  fn,
bool  multithreaded = false 
)

run through all volume cells

Parameters
fncallback/lambda, VolumeCell pointer and space placement passed there
multithreadeduse multi-threading

◆ scanCells() [3/4]

void coat::Volume::scanCells ( const std::function< void(VolumeCellAttrib *vc)> &  fn,
bool  multithreaded = false 
)

run through all volume cells

Parameters
fncallback/lambda, VolumeCellAttrib pointer passed there
multithreadeduse multi-threading

◆ scanCells() [4/4]

void coat::Volume::scanCells ( const std::function< void(VolumeCellAttrib *vc, const tri_DWORD &T)> &  fn,
bool  multithreaded = false 
)

run through all volume cells

Parameters
fncallback/lambda, VolumeCellAttrib pointer and space placement passed there
multithreadeduse multi-threading

◆ scanTriangles() [1/2]

void coat::Volume::scanTriangles ( const std::function< void(const MCVertex &v1, const MCVertex &v2, const MCVertex &v3)> &  fn,
bool  multithreaded = false 
)

run through all triangles

Parameters
fnthe callback/lambda
multithreadeduse multi-threading

◆ scanTriangles() [2/2]

void coat::Volume::scanTriangles ( const std::function< void(const Vector3D &v1, const Vector3D &v2, const Vector3D &v3)> &  fn,
bool  multithreaded = false 
)

run through all triangles

Parameters
fnthe callback/lambda
multithreadeduse multi-threading

◆ setMoldingBorder()

static void coat::Volume::setMoldingBorder ( float  width = 0)
static

set the molding border around the parting line to fade to the plane, if it is zero, the final shape will not fade to plane

Parameters
widththe width in mm or other default units

◆ setMoldingBox()

static void coat::Volume::setMoldingBox ( float  width,
float  length,
float  thickness 
)
static

set the molding bound box to be user-defined, not automatic

Parameters
widththe width of the box
lengththe length of the box
thicknessthe thickness of the box

◆ setMoldingParams()

static void coat::Volume::setMoldingParams ( const vec3 direction,
float  tapering_angle = 0,
float  undercuts_density = 1.0f,
float  decimation_limit_millions = 10,
bool  perform_subtraction = true 
)
static

set the parameters for the molding

Parameters
directionthe molding direction
tapering_anglethe tapering angle in degrees
undercuts_densitythe additional density for the undercuts
decimation_limit_millionsdecimate the final shape if it has triangles count more than this value
perform_subtractionset false if no need to subtract the molding from the molding shapes

◆ setOpacity()

void coat::Volume::setOpacity ( float  Opacity)

set the volume opacity

Parameters
Opacitythe 0..1 opacity value

◆ subtractMesh()

void coat::Volume::subtractMesh ( Mesh mesh,
const mat4 transform = mat4::Identity 
)

subtract the mesh from volume (boolean)

Parameters
meshthe mesh reference
transformthe transform applied

◆ tree()

VoxTreeBranch * coat::Volume::tree ( )

returns the low-level object (VoxTreeBranch) for all low-level operations

Returns
the VoxTreeBranch* pointer

◆ valid()

bool coat::Volume::valid ( ) const

checks if object is valid

Returns
true if the volume exists

◆ vo()

VolumeObject * coat::Volume::vo ( )

returns the low-level object (VolumeObject) for all low-level operations

Returns
the VolumeObject* pointer

The documentation for this class was generated from the following file: