File I/O

mechanica.io

alias of mechanica.mechanica.MxIO

class mechanica.MxIO

Mechanica import/export interface

static fromFile3DF(filePath: std::string const &) Mx3DFStructure *

Load a 3D format file

Parameters

filePath (string) – path of file

Return type

Mx3DFStructure

Returns

Mx3DFStructure* 3D format data container

static toFile3DF(format: std::string const &, filePath: std::string const &, pRefinements: unsigned int const & = 0) HRESULT

Export engine state to a 3D format file

Parameters
  • format (string) – format of file

  • filePath (string) – path of file

  • pRefinements (int) – mesh refinements applied when generating meshes

Return type

int

Returns

HRESULT

static toFile(saveFilePath: std::string const &) HRESULT

Save a simulation to file

Parameters

saveFilePath (string) – absolute path to file

Return type

int

Returns

HRESULT

static toString() std::string

Return a simulation state as a JSON string

Return type

string

Returns

std::string

static mapImportParticleId(pId: unsigned int const &) int

Get the id of a particle according to import data that corresponds to a particle id of current data.

Only valid between initialization and the first simulation step, after which the import summary data is purged.

Parameters

pId (int) – id of particle in exported data

Return type

int

Returns

int >=0 if particle is found; -1 otherwise

static mapImportParticleTypeId(pId: unsigned int const &) int

Get the id of a particle type according to import data that corresponds to a particle type id of current data.

Only valid between initialization and the first simulation step, after which the import summary data is purged.

Parameters

pId (int) – id of particle type in exported data

Return type

int

Returns

int >=0 if particle type is found; -1 otherwise

class mechanica.Mx3DFRenderData
property color
class mechanica.Mx3DFStructure

Container for relevant data found in a 3D data file.

The structure object owns all constituent data.

Recursively adds/removes constituent data and all child data. However, the structure enforces no rules on the constituent container data. For example, when an edge is added, all constituent vertices are added. However, no assignment is made to ensure that the parent edge is properly stored in the parent container of the vertices, neither are parent edges added when a vertex is added.

property centroid: mechanica.mechanica.MxVector3f

Centroid of all constituent data

property vertices: mechanica.mechanica.vectorMx3DFVertexData_p

Constituent vertices

property edges: mechanica.mechanica.vectorMx3DFEdgeData_p

Constituent edges

property faces: mechanica.mechanica.vectorMx3DFFaceData_p

Constituent faces

property meshes: mechanica.mechanica.vectorMx3DFMeshData_p

Constituent meshes

property num_vertices: int

Number of constituent vertices

property num_edges: int

Number of constituent edges

property num_faces: int

Number of constituent faces

property num_meshes: int

Number of constituent meshes

property vRadiusDef

Default radius applied to vertices when generating meshes from point clouds

fromFile(filePath: std::string const &) HRESULT

Load from file

Parameters

filePath (string) – file absolute path

Return type

int

Returns

HRESULT

toFile(format: std::string const &, filePath: std::string const &) HRESULT

Write to file

Parameters
  • format (string) – output format of file

  • filePath (string) – file absolute path

Return type

int

Returns

HRESULT

flush() HRESULT

Flush stucture. All scheduled processes are executed.

extend(s: Mx3DFStructure) HRESULT

Extend a structure

Parameters

s (Mx3DFStructure) – stucture to extend with

clear() HRESULT

Clear all data of the structure

Return type

int

Returns

HRESULT

has(*args) bool

Overload 1:

Test whether a vertex is a constituent

Parameters

v (Mx3DFVertexData) – vertex to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 2:

Test whether an edge is a constituent

Parameters

e (Mx3DFEdgeData) – edge to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 3:

Test whether a face is a constituent

Parameters

f (Mx3DFFaceData) – face to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 4:

Test whether a mesh is a constituent

Parameters

m (Mx3DFMeshData) – mesh to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false

add(*args) void

Overload 1:

Add a vertex

Parameters

v (Mx3DFVertexData) – vertex to add


Overload 2:

Add an edge and all constituent data

Parameters

e (Mx3DFEdgeData) – edge to add


Overload 3:

Add a face and all constituent data

Parameters

f (Mx3DFFaceData) – face to add


Overload 4:

Add a mesh and all constituent data

Parameters

m (Mx3DFMeshData) – mesh to add

remove(*args) void

Overload 1:

Remove a vertex

Parameters

v (Mx3DFVertexData) – vertex to remove


Overload 2:

Remove a edge and all constituent data

Parameters

e (Mx3DFEdgeData) – edge to remove


Overload 3:

Remove a face and all constituent data

Parameters

f (Mx3DFFaceData) – face to remove


Overload 4:

Remove a mesh and all constituent data

Parameters

m (Mx3DFMeshData) – mesh to remove

translate(displacement: MxVector3f) HRESULT

Translate the structure by a displacement

Parameters

displacement (MxVector3f) –

Return type

int

Returns

HRESULT

translateTo(position: MxVector3f) HRESULT

Translate the structure to a position

Parameters

position (MxVector3f) –

Return type

int

Returns

HRESULT

rotateAt(rotMat: MxMatrix3f, rotPt: MxVector3f) HRESULT

Rotate the structure about a point

Parameters
Return type

int

Returns

HRESULT

rotate(rotMat: MxMatrix3f) HRESULT

Rotate the structure about its centroid

Parameters

rotMat (MxMatrix3f) –

Return type

int

Returns

HRESULT

scaleFrom(*args) HRESULT

Overload 1:

Scale the structure about a point

Parameters
Return type

int

Returns

HRESULT


Overload 2:

Scale the structure uniformly about a point

Parameters
Return type

int

Returns

HRESULT

scale(*args) HRESULT

Overload 1:

Scale the structure about its centroid

Parameters

scales (MxVector3f) –

Return type

int

Returns

HRESULT


Overload 2:

Scale the structure uniformly about its centroid

Parameters

scale (float) –

Return type

int

Returns

HRESULT

class mechanica.Mx3DFMeshData

3D data file mesh data

property structure

Parent structure

property id

ID, if any. Unique to its structure and type

property name

Mesh name

property renderData

Rendering data

property vertices: mechanica.mechanica.vectorMx3DFVertexData_p

Constituent vertices

property edges: mechanica.mechanica.vectorMx3DFEdgeData_p

Constituent edges

property faces: mechanica.mechanica.vectorMx3DFFaceData_p

Constituent faces

property num_vertices: int

Number of constituent vertices

property num_edges: int

Number of constituent edges

property num_faces: int

Number of constituent faces

property centroid: mechanica.mechanica.MxVector3f

Centroid of all constituent data

has(*args) bool

Overload 1:

Test whether a vertex is a constituent

Parameters

v (Mx3DFVertexData) – vertex to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 2:

Test whether an edge is a constituent

Parameters

e (Mx3DFEdgeData) – edge to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 3:

Test whether a face is a constituent

Parameters

f (Mx3DFFaceData) – face to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false

_in(s: mechanica.mechanica.Mx3DFStructure) bool

Test whether in a structure

Parameters

s (Mx3DFStructure) – structure to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false

is_in(*args, **kwargs) bool

Alias of :meth:_in

translate(displacement: MxVector3f) HRESULT

Translate the mesh by a displacement

Parameters

displacement (MxVector3f) –

Return type

int

Returns

HRESULT

translateTo(position: MxVector3f) HRESULT

Translate the mesh to a position

Parameters

position (MxVector3f) –

Return type

int

Returns

HRESULT

rotateAt(rotMat: MxMatrix3f, rotPt: MxVector3f) HRESULT

Rotate the mesh about a point

Parameters
Return type

int

Returns

HRESULT

rotate(rotMat: MxMatrix3f) HRESULT

Rotate the mesh about its centroid

Parameters

rotMat (MxMatrix3f) –

Return type

int

Returns

HRESULT

scaleFrom(*args) HRESULT

Overload 1:

Scale the mesh about a point

Parameters
Return type

int

Returns

HRESULT


Overload 2:

Scale the mesh uniformly about a point

Parameters
Return type

int

Returns

HRESULT

scale(*args) HRESULT

Overload 1:

Scale the structure about its centroid

Parameters

scales (MxVector3f) –

Return type

int

Returns

HRESULT


Overload 2:

Scale the structure uniformly about its centroid

Parameters

scale (float) –

Return type

int

Returns

HRESULT

class mechanica.Mx3DFFaceData

3D data file face data

property structure

Parent structure

property normal

Face normal

property id

ID, if any. Unique to its structure and type

property vertices: mechanica.mechanica.vectorMx3DFVertexData_p

Constituent vertices

property edges: mechanica.mechanica.vectorMx3DFEdgeData_p

Constituent edges

property meshes: mechanica.mechanica.vectorMx3DFMeshData_p

Parent meshes

property num_vertices: int

Number of constituent vertices

property num_edges: int

Number of constituent edges

property num_meshes: int

Number of parent meshes

has(*args) bool

Overload 1:

Test whether a vertex is a constituent

Parameters

v (Mx3DFVertexData) – vertex to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 2:

Test whether an edge is a constituent

Parameters

e (Mx3DFEdgeData) – edge to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false

_in(*args) bool

Overload 1:

Test whether in a mesh

Parameters

m (Mx3DFMeshData) – mesh to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 2:

Test whether in a structure

Parameters

s (Mx3DFStructure) – structure to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false

is_in(*args, **kwargs) bool

Alias of :meth:_in

class mechanica.Mx3DFEdgeData(_va: mechanica.mechanica.Mx3DFVertexData, _vb: mechanica.mechanica.Mx3DFVertexData)

3D data file edge data

property structure

Parent structure

property id

ID, if any. Unique to its structure and type

property vertices: mechanica.mechanica.vectorMx3DFVertexData_p

Constituent vertices

property faces: mechanica.mechanica.vectorMx3DFFaceData_p

Constituent faces

property meshes: mechanica.mechanica.vectorMx3DFMeshData_p

Parent meshes

property num_vertices: int

Number of constituent vertices

property num_faces: int

Number of parent faces

property num_meshes: int

Number of parent meshes

has(v: mechanica.mechanica.Mx3DFVertexData) bool

Test whether a vertex is a constituent

Parameters

v (Mx3DFVertexData) – vertex to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false

_in(*args) bool

Overload 1:

Test whether in a face

Parameters

f (Mx3DFFaceData) – face to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 2:

Test whether in a mesh

Parameters

m (Mx3DFMeshData) – mesh to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 3:

Test whether in a structure

Parameters

s (Mx3DFStructure) – structure to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false

is_in(*args, **kwargs) bool

Alias of :meth:_in

class mechanica.Mx3DFVertexData(_position: mechanica.mechanica.MxVector3f, _structure: Optional[mechanica.mechanica.Mx3DFStructure] = None)

3D data file vertex data

property structure

Parent structure

property position

Global position

property id

ID, if any. Unique to its structure and type

property edges: mechanica.mechanica.vectorMx3DFEdgeData_p

Parent edges

property faces: mechanica.mechanica.vectorMx3DFFaceData_p

Parent faces

property meshes: mechanica.mechanica.vectorMx3DFMeshData_p

Parent meshes

property num_edges: int

Number of parent edges

property num_faces: int

Number of parent faces

property num_meshes: int

Number of parent meshes

_in(*args) bool

Overload 1:

Test whether in an edge

Parameters

e (Mx3DFEdgeData) – edge to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 2:

Test whether in a face

Parameters

f (Mx3DFFaceData) – face to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 3:

Test whether in a mesh

Parameters

m (Mx3DFMeshData) – mesh to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false


Overload 4:

Test whether in a structure

Parameters

s (Mx3DFStructure) – structure to test

Return type

boolean

Returns

true

Return type

boolean

Returns

false

is_in(*args, **kwargs) bool

Alias of :meth:_in