OCC.Voxel module

Data structuire and visualization engine for voxel modeling.

class Handle_Voxel_Prs(*args)

Bases: OCC.AIS.Handle_AIS_InteractiveObject

static DownCast()
GetObject()
IsNull()
Nullify()
thisown

The membership flag

class SwigPyIterator(*args, **kwargs)

Bases: object

advance()
copy()
decr()
distance()
equal()
incr()
next()
previous()
thisown

The membership flag

value()
class Voxel_BoolDS(*args)

Bases: OCC.Voxel.Voxel_DS

  • An empty constructor.
Return type:None
  • A constructor initializing the voxel model. (x, y, z) - the start point of the box. (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions.
Parameters:
Return type:

None

Destroy()
  • A destructor of the voxel model.
Return type:None
Get()
  • Returns the value of voxel with co-ordinates (ix, iy, iz).
Parameters:
Return type:

bool

Set()
  • Defines a value for voxel with co-ordinates (ix, iy, iz). Initial state of the model is so that all voxels have value 0 (false), and this data doesn’t occupy memory. Memory for data is allocating during setting non-zero values (true).
Parameters:
  • ix (int) –
  • iy (int) –
  • iz (int) –
  • data (bool) – default value is Standard_True
Return type:

None

SetZero()
  • The method sets all values equal to 0 (false) and releases the memory.
Return type:None
thisown

The membership flag

class Voxel_BooleanOperation(*args)

Bases: object

  • An empty constructor.
Return type:None
Cut()
  • Cuts two cubes of voxels. It modifies the first cube of voxels. It returns false in case of different dimension of the cube, different number of voxels.
Parameters:
  • theVoxels1 (Voxel_BoolDS &) –
  • theVoxels2 (Voxel_BoolDS &) –
Return type:

bool

  • Cuts two cubes of voxels. It modifies the first cube of voxels. It returns false in case of different dimension of the cube, different number of voxels. It subtracts the value of corresponding voxels and puts the result to theVoxels1.
Parameters:
  • theVoxels1 (Voxel_ColorDS &) –
  • theVoxels2 (Voxel_ColorDS &) –
Return type:

bool

  • Cuts two cubes of voxels. It modifies the first cube of voxels. It returns false in case of different dimension of the cube, different number of voxels. It subtracts the value of corresponding voxels and puts the result to theVoxels1.
Parameters:
  • theVoxels1 (Voxel_FloatDS &) –
  • theVoxels2 (Voxel_FloatDS &) –
Return type:

bool

Fuse()
  • Fuses two cubes of voxels. It modifies the first cube of voxels. It returns false in case of different dimension of the cube, different number of voxels.
Parameters:
  • theVoxels1 (Voxel_BoolDS &) –
  • theVoxels2 (Voxel_BoolDS &) –
Return type:

bool

  • Fuses two cubes of voxels. It modifies the first cube of voxels. It returns false in case of different dimension of the cube, different number of voxels. It summerizes the value of corresponding voxels and puts the result to theVoxels1. If the result exceeds 15 or becomes greater, it keeps 15.
Parameters:
  • theVoxels1 (Voxel_ColorDS &) –
  • theVoxels2 (Voxel_ColorDS &) –
Return type:

bool

  • Fuses two cubes of voxels. It modifies the first cube of voxels. It returns false in case of different dimension of the cube, different number of voxels. It summerizes the value of corresponding voxels and puts the result to theVoxels1.
Parameters:
  • theVoxels1 (Voxel_FloatDS &) –
  • theVoxels2 (Voxel_FloatDS &) –
Return type:

bool

thisown

The membership flag

class Voxel_CollisionDetection(*args)

Bases: object

  • An empty constructor.
Return type:None
  • A constructor. It defines deflection of triangulation for the shapes. As lower the deflection is, as proper the triangulation is generated. Also, it defines number of splits along X, Y and Z axes for generation of voxels. As greater the numbers are, as greater number of voxels is used for detection of collision.
Parameters:
Return type:

None

AddShape()
  • Adds a shape. Returns an index of the shape.
Parameters:shape (TopoDS_Shape &) –
Return type:int
Compute()
  • Computes the collisions. This method may be called many times if, for example, the shapes are being moved.
Return type:bool
Destroy()
  • A destructor.
Return type:None
GetCollisions()
  • Returns the collided voxels.
Return type:Voxel_BoolDS
HasCollisions()
  • Returns true if a collision is detected.
Return type:bool
KeepCollisions()
  • Doesn’t clean the collision points on new call to the method Compute(). It allows to see the collisions for a moving shape.
Parameters:keep (bool) –
Return type:None
ReplaceShape()
  • Replaces a shape by another one. <ishape> is an index of the shape. This method is useful for moving shape, for example.
Parameters:
  • ishape (int) –
  • shape (TopoDS_Shape &) –
Return type:

bool

SetBoundaryBox()
  • Defines a user-defined boundary box for generation of voxels. If this method is not called, the algorithm calculates the boundary box itself.
Parameters:box (Bnd_Box &) –
Return type:None
SetDeflection()
  • Defines the deflection of triangulation of shapes.
Parameters:deflection (float) –
Return type:None
SetNbVoxels()
  • Defines the number of voxels along X, Y and Z axes.
Parameters:
Return type:

None

SetUsageOfVolume()
  • Defines usage of volume of shapes in collision detection algorithm. Beware, usage of volume a little bit decreases the speed of algorithm.
Parameters:usage (bool) –
Return type:None
Voxelize()
  • Prepares data for computation of collisions. It checks the inner parameters (number of voxels along X, Y and Z axes) and voxelizes the shapes. If the shape is not changed since the last call to this method, this method may be not called for this shape. <ishape> - is the index of the shape for processing by this method. If it is equal to -1, all shapes will be processed.
Parameters:ishape (int) – default value is -1
Return type:bool
thisown

The membership flag

class Voxel_ColorDS(*args)

Bases: OCC.Voxel.Voxel_DS

  • An empty constructor.
Return type:None
  • A constructor initializing the voxel model. (x, y, z) - the start point of the box. (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions.
Parameters:
Return type:

None

Destroy()
  • A destructor of the voxel model.
Return type:None
Get()
  • Returns the value of voxel with co-ordinates (ix, iy, iz).
Parameters:
Return type:

Standard_Byte

Set()
  • Defines a value for voxel with co-ordinates (ix, iy, iz). Only the first four bits are used! Initial state of the model is so that all voxels have value 0x0000, and this data doesn’t occupy memory. Memory for data is allocating during setting non-zero values (0x0101, for example).
Parameters:
  • ix (int) –
  • iy (int) –
  • iz (int) –
  • data (Standard_Byte) –
Return type:

None

SetZero()
  • The method sets all values equal to 0 (false) and releases the memory.
Return type:None
thisown

The membership flag

class Voxel_DS(*args)

Bases: object

  • An empty constructor.
Return type:None
  • A constructor initializing the voxel model. (x, y, z) - the start point of the box. (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions.
Parameters:
Return type:

None

GetCenter()
  • Returns the center point of a voxel with co-ordinates (ix, iy, iz).
Parameters:
  • ix (int) –
  • iy (int) –
  • iz (int) –
  • xc (float &) –
  • yc (float &) –
  • zc (float &) –
Return type:

None

GetNbX()
Return type:int
GetNbY()
Return type:int
GetNbZ()
Return type:int
GetOrigin()
  • Returns the origin point of a voxel with co-ordinates (ix, iy, iz).
Parameters:
  • ix (int) –
  • iy (int) –
  • iz (int) –
  • x0 (float &) –
  • y0 (float &) –
  • z0 (float &) –
Return type:

None

GetVoxel()
  • Finds a voxel corresponding to a 3D point. Returns true if it is found.
Parameters:
  • x (float) –
  • y (float) –
  • z (float) –
  • ix (int &) –
  • iy (int &) –
  • iz (int &) –
Return type:

bool

GetVoxelX()
  • Returns x-index of a voxel corresponding to x-coordinate.
Parameters:
  • x (float) –
  • ix (int &) –
Return type:

bool

GetVoxelY()
  • Returns y-index of a voxel corresponding to y-coordinate.
Parameters:
  • y (float) –
  • iy (int &) –
Return type:

bool

GetVoxelZ()
  • Returns z-index of a voxel corresponding to z-coordinate.
Parameters:
  • z (float) –
  • iz (int &) –
Return type:

bool

GetX()
Return type:float
GetXLen()
Return type:float
GetY()
Return type:float
GetYLen()
Return type:float
GetZ()
Return type:float
GetZLen()
Return type:float
Init()
  • Initialization of the voxel model. (x, y, z) - the start point of the box. (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. The methods below return initial data of the voxel model.
Parameters:
Return type:

void

thisown

The membership flag

class Voxel_FastConverter(*args)

Bases: object

  • A constructor for conversion of a shape into a cube of boolean voxels. It allocates the voxels in memory. ‘nbthreads’ defines the number of threads used to convert the shape.
Parameters:
  • shape (TopoDS_Shape &) –
  • voxels (Voxel_BoolDS &) –
  • deflection (float) – default value is 0.1
  • nbx (int) – default value is 10
  • nby (int) – default value is 10
  • nbz (int) – default value is 10
  • nbthreads (int) – default value is 1
  • useExistingTriangulation (bool) – default value is Standard_False
Return type:

None

  • A constructor for conversion of a shape into a cube of colored voxels. It allocates the voxels in memory. ‘nbthreads’ defines the number of threads used to convert the shape.
Parameters:
  • shape (TopoDS_Shape &) –
  • voxels (Voxel_ColorDS &) –
  • deflection (float) – default value is 0.1
  • nbx (int) – default value is 10
  • nby (int) – default value is 10
  • nbz (int) – default value is 10
  • nbthreads (int) – default value is 1
  • useExistingTriangulation (bool) – default value is Standard_False
Return type:

None

  • A constructor for conversion of a shape into a cube of boolean voxels split into 8 sub-voxels recursively. It allocates the voxels in memory. ‘nbthreads’ defines the number of threads used to convert the shape.
Parameters:
  • shape (TopoDS_Shape &) –
  • voxels (Voxel_ROctBoolDS &) –
  • deflection (float) – default value is 0.1
  • nbx (int) – default value is 10
  • nby (int) – default value is 10
  • nbz (int) – default value is 10
  • nbthreads (int) – default value is 1
  • useExistingTriangulation (bool) – default value is Standard_False
Return type:

None

Convert()
  • Converts a shape into a voxel representation. It sets to 0 the outside volume of the shape and 1 for surfacic part of the shape. ‘ithread’ is the index of the thread for current call of ::Convert(). Start numeration of ‘ithread’ with 1, please.
Parameters:
  • progress (int &) –
  • ithread (int) – default value is 1
Return type:

bool

ConvertUsingSAT()
  • Converts a shape into a voxel representation using separating axis theorem. It sets to 0 the outside volume of the shape and 1 for surfacic part of the shape. ‘ithread’ is the index of the thread for current call of ::Convert(). Start numeration of ‘ithread’ with 1, please.
Parameters:
  • progress (int &) –
  • ithread (int) – default value is 1
Return type:

bool

Destroy()
  • A destructor.
Return type:None
FillInVolume()
  • Fills-in volume of the shape by a value.
Parameters:
  • inner (Standard_Byte) –
  • ithread (int) – default value is 1
Return type:

bool

  • Fills-in volume of the shape by a value. Uses the topological information from the provided shape to judge whether points are inside the shape or not (only when processing vertical faces). The inner value has to be positive.
Parameters:
  • inner (Standard_Byte) –
  • shape (TopoDS_Shape &) –
  • ithread (int) – default value is 1
Return type:

bool

thisown

The membership flag

class Voxel_FloatDS(*args)

Bases: OCC.Voxel.Voxel_DS

  • An empty constructor.
Return type:None
  • A constructor initializing the voxel model. (x, y, z) - the start point of the box. (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions.
Parameters:
Return type:

None

Destroy()
  • A destructor of the voxel model.
Return type:None
Get()
  • Returns the value of voxel with co-ordinates (ix, iy, iz).
Parameters:
Return type:

Standard_ShortReal

Set()
  • Defines a value for voxel with co-ordinates (ix, iy, iz). Initial state of the model is so that all voxels have value 0.0f, and this data doesn’t occupy memory. Memory for data is allocating during setting non-zero values.
Parameters:
  • ix (int) –
  • iy (int) –
  • iz (int) –
  • data (Standard_ShortReal) –
Return type:

None

SetZero()
  • The method sets all values equal to 0 (false) and releases the memory.
Return type:None
thisown

The membership flag

class Voxel_OctBoolDS(*args)

Bases: OCC.Voxel.Voxel_DS

  • An empty constructor.
Return type:None
  • A constructor initializing the voxel model. (x, y, z) - the start point of the box. (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions.
Parameters:
Return type:

None

Destroy()
  • A destructor of the voxel model.
Return type:None
Get()
  • Returns the value of voxel with co-ordinates (ix, iy, iz). Warning!: the returned value may not coincide with the value of its 8 sub-voxels. Use the method ::IsSplit() to check whether a voxel has sub-voxels.
Parameters:
Return type:

bool

  • Returns the value of a sub-voxel of a voxel with co-ordinates (ix, iy, iz). If the voxel is not split, it returns the value of the voxel. Range of sub-voxels is 0 - 7.
Parameters:
Return type:

bool

IsSplit()
  • Returns true if the voxel is split into 8 sub-voxels.
Parameters:
Return type:

bool

OptimizeMemory()
  • The method searches voxels with equal-value of sub-voxels and removes them (remaining the value for the voxel).
Return type:None
Set()
  • Defines a value for voxel with co-ordinates (ix, iy, iz). If the voxel is split into 8 sub-voxels, the split disappears. Initial state of the model is so that all voxels have value 0 (false), and this data doesn’t occupy memory. Memory for data is allocating during setting non-zero values (true).
Parameters:
Return type:

None

  • Defines a value for a sub-voxel of a voxel with co-ordinates (ix, iy, iz). If the voxel is not split into 8 sub-voxels yet, this method splits the voxel. Range of sub-voxels is 0 - 7.
Parameters:
Return type:

None

SetZero()
  • The method sets all values equal to 0 (false) and releases the memory.
Return type:None
thisown

The membership flag

class Voxel_Prs(*args)

Bases: OCC.AIS.AIS_InteractiveObject

  • An empty constructor.
Return type:None
Destroy()
  • A destructor of presentation data.
Return type:None
GetHandle()
Highlight()
  • Highlights a voxel. It doesn’t re-computes the whole interactive object, but only marks a voxels as ‘highlighted’. The voxel becomes highlighted on next swapping of buffers. In order to unhighlight a voxel, set ix = iy = iz = -1.
Parameters:
Return type:

None

SetBoolVoxels()
  • <theVoxels> is a Voxel_BoolDS* object.
Parameters:theVoxels (Standard_Address) –
Return type:None
SetColorRange()
  • Defines min-max values for visualization of voxels of ColorDS structure. By default, min value = 1, max value = 15 (all non-zero values).
Parameters:
  • theMinValue (Standard_Byte) –
  • theMaxValue (Standard_Byte) –
Return type:

None

SetColorVoxels()
  • <theVoxels> is a Voxel_ColorDS* object.
Parameters:theVoxels (Standard_Address) –
Return type:None
SetColors()
  • Defines the color of points, quadrangles… for ColorDS. For ColorDS the size of array is 0 .. 15. 0 - means no color, this voxel is not drawn.
Parameters:theColors (Handle_Quantity_HArray1OfColor &) –
Return type:None
SetDegenerateMode()
  • Simplifies visualization of voxels in case of view rotation, panning and zooming.
Parameters:theDegenerate (bool) –
Return type:None
SetDisplayMode()
  • Sets a display mode for voxels.
Parameters:theMode (Voxel_VoxelDisplayMode) –
Return type:None
SetPointSize()
  • Defines the size of points for all types of voxels.
Parameters:theSize (float) –
Return type:None
SetQuadrangleSize()
  • Defines the size of quadrangles in per cents (0 .. 100).
Parameters:theSize (int) –
Return type:None
SetROctBoolVoxels()
  • <theVoxels> is a Voxel_ROctBoolDS* object.
Parameters:theVoxels (Standard_Address) –
Return type:None
SetSizeRange()
  • Defines the displayed area of voxels. By default, the range is equal to the box of voxels (all voxels are displayed).
Parameters:
  • theDisplayedXMin (float) –
  • theDisplayedXMax (float) –
  • theDisplayedYMin (float) –
  • theDisplayedYMax (float) –
  • theDisplayedZMin (float) –
  • theDisplayedZMax (float) –
Return type:

None

SetSmoothPoints()
  • Switches visualization of points from smooth to rough.
Parameters:theSmooth (bool) –
Return type:None
SetTriangulation()
  • Sets a triangulation for visualization.
Parameters:theTriangulation (Handle_Poly_Triangulation &) –
Return type:None
SetUsageOfGLlists()
  • GL lists accelerate view rotation, panning and zooming operations, but it takes additional memory… It is up to the user of this interactive object to decide whether he has enough memory and may use GL lists or he is lack of memory and usage of GL lists is not recommended. By default, usage of GL lists is on. Also, as I noticed, the view without GL lists looks more precisely.
Parameters:theUsage (bool) –
Return type:None
thisown

The membership flag

class Voxel_ROctBoolDS(*args)

Bases: OCC.Voxel.Voxel_DS

  • An empty constructor.
Return type:None
  • A constructor initializing the voxel model. (x, y, z) - the start point of the box. (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions.
Parameters:
Return type:

None

Deepness()
  • Returns the deepness of splits of a voxel. 0 - no splits (::IsSplit() being called would return false). 1 - the voxel is split into 8 sub-voxels. 2 - the voxels is split into 8 sub-voxels, and each of the sub-voxels is split into 8 sub-sub-voxels. 3 - …
Parameters:
Return type:

int

Destroy()
  • A destructor of the voxel model.
Return type:None
Get()
  • Returns the value of voxel with co-ordinates (ix, iy, iz). Warning!: the returned value may not coincide with the value of its 8 sub-voxels. Use the method ::IsSplit() to check whether a voxel has sub-voxels.
Parameters:
Return type:

bool

  • Returns the value of a sub-voxel of a voxel with co-ordinates (ix, iy, iz). If the voxel is not split, it returns the value of the voxel. Range of sub-voxels is 0 - 7.
Parameters:
Return type:

bool

  • Returns the value of a sub-voxel of a sub-voxel of a voxel with co-ordinates (ix, iy, iz). If the voxel is not split, it returns the value of the voxel. Range of sub-voxels is 0 - 7.
Parameters:
Return type:

bool

GetCenter()
  • Returns the center point of a sub-voxel with co-ordinates (ix, iy, iz, i).
Parameters:
  • ix (int) –
  • iy (int) –
  • iz (int) –
  • i (int) –
  • xc (float &) –
  • yc (float &) –
  • zc (float &) –
Return type:

None

  • Returns the center point of a sub-voxel with co-ordinates (ix, iy, iz, i, j).
Parameters:
  • ix (int) –
  • iy (int) –
  • iz (int) –
  • i (int) –
  • j (int) –
  • xc (float &) –
  • yc (float &) –
  • zc (float &) –
Return type:

None

IsSplit()
  • Returns true if the voxel is split into 8 sub-voxels.
Parameters:
Return type:

bool

OptimizeMemory()
  • The method searches voxels with equal-value of sub-voxels and removes them (remaining the value for the voxel).
Return type:None
Set()
  • Defines a value for voxel with co-ordinates (ix, iy, iz). If the voxel is split into 8 sub-voxels, the split disappears. Initial state of the model is so that all voxels have value 0 (false), and this data doesn’t occupy memory. Memory for data is allocating during setting non-zero values (true).
Parameters:
Return type:

None

  • Defines a value for a sub-voxel of a voxel with co-ordinates (ix, iy, iz). If the voxel is not split into 8 sub-voxels yet, this method splits the voxel. Range of sub-voxels is 0 - 7.
Parameters:
Return type:

None

  • Defines a value for a sub-voxel of a sub-voxel of a voxel with co-ordinates (ix, iy, iz). If the voxel is not split into 8 sub-voxels yet, this method splits the voxel. Range of sub-voxels is 0 - 7.
Parameters:
Return type:

None

SetZero()
  • The method sets all values equal to 0 (false) and releases the memory.
Return type:None
thisown

The membership flag

class Voxel_Reader(*args)

Bases: object

  • An empty constructor.
Return type:None
GetBoolVoxels()
  • Returns a pointer to the read 1bit voxels.
Return type:Standard_Address
GetColorVoxels()
  • Returns a pointer to the read 4bit voxels.
Return type:Standard_Address
GetFloatVoxels()
  • Returns a pointer to the read 4bytes voxels.
Return type:Standard_Address
IsBoolVoxels()
  • Informs the user about the type of voxels he has read.
Return type:bool
IsColorVoxels()
  • Informs the user about the type of voxels he has read.
Return type:bool
IsFloatVoxels()
  • Informs the user about the type of voxels he has read.
Return type:bool
Read()
  • Reads the voxels from disk
Parameters:file (TCollection_ExtendedString &) –
Return type:bool
thisown

The membership flag

class Voxel_Selector(*args)

Bases: object

  • An empty constructor.
Return type:None
  • A constructor of the selector, which initializes the classes by a view, where the user selects the voxels.
Parameters:view (Handle_V3d_View &) –
Return type:None
Detect()
  • Detects a voxel under the mouse cursor.
Parameters:
  • winx (int) –
  • winy (int) –
  • ix (int &) –
  • iy (int &) –
  • iz (int &) –
Return type:

bool

Init()
  • Initializes the selector by a view, where the user selects the voxels.
Parameters:view (Handle_V3d_View &) –
Return type:None
SetVoxels()
  • Defines the voxels (1bit).
Parameters:voxels (Voxel_BoolDS &) –
Return type:None
  • Defines the voxels (4bit).
Parameters:voxels (Voxel_ColorDS &) –
Return type:None
  • Defines the voxels (1bit recursive splitting).
Parameters:voxels (Voxel_ROctBoolDS &) –
Return type:None
thisown

The membership flag

class Voxel_SplitData(*args)

Bases: object

  • An empty constructor.
Return type:None
GetSplitData()
  • Gives access to the next split data.
Return type:Standard_Address
GetValues()
  • Gives access to the values.
Return type:Standard_Address
thisown

The membership flag

class Voxel_Writer(*args)

Bases: object

  • An empty constructor.
Return type:None
SetFormat()
  • Defines the file format for voxels. ASCII - slow and occupies more space on disk. BINARY - fast and occupies less space on disk.
Parameters:format (Voxel_VoxelFileFormat) –
Return type:None
SetVoxels()
  • Defines the voxels (1bit).
Parameters:voxels (Voxel_BoolDS &) –
Return type:None
  • Defines the voxels (4bit).
Parameters:voxels (Voxel_ColorDS &) –
Return type:None
  • Defines the voxels (4bytes).
Parameters:voxels (Voxel_FloatDS &) –
Return type:None
Write()
  • Writes the voxels on disk using the defined format and file name.
Parameters:file (TCollection_ExtendedString &) –
Return type:bool
thisown

The membership flag

new_instancemethod(func, inst, cls)
register_handle(handle, base_object)

Inserts the handle into the base object to prevent memory corruption in certain cases