MorphoGraphX  2.0-1-227
Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
mgx::MeshExport Class Reference

#include <SystemProcessSave.hpp>

+ Inheritance diagram for mgx::MeshExport:

Public Member Functions

 MeshExport (const Process &proc)
 
bool run ()
 Runs the process. More...
 
bool run (Mesh *mesh, const QString &filename, const QString &type, bool transform)
 Export a mesh. More...
 
QIcon icon () const
 
bool initialize (QWidget *parent)
 Initialize the process. More...
 
bool savePLY (Mesh *mesh, const QString &filename, bool transform, bool binary=false)
 
- Public Member Functions inherited from mgx::Process
 Process (const Process &p)
 Copy constructor. More...
 
virtual ~Process ()
 Virtual destructor. More...
 
void actingFile (const QString &filename, bool project_file=false)
 Method to be called anytime a file is acted on (i.e. More...
 
QString actingFile () const
 Get the file currently defining the path of the system. More...
 
QString pythonCall (const QStringList &parms) const
 Return the python call describing the current process. More...
 
int stackCount () const
 Number of stacks available to the process. More...
 
Stackstack (int i)
 Returns the ith stack, or 0 if there is no such stack. More...
 
StackcurrentStack ()
 Returns the current stack (i.e. More...
 
StackotherStack ()
 Returns the other stack (i.e. More...
 
int currentStackId () const
 Return the id (i.e. More...
 
int otherStackId () const
 Return the id (i.e. More...
 
void setCurrentStackId (int i)
 Change which stack is current. More...
 
bool setCurrentStack (int id, const QString &store)
 
bool takeSnapshot (QString filename, float overSampling=1.0f, int width=0, int height=0, int quality=95, bool expand_frustum=false)
 Save screen shot to a file. More...
 
bool setStatus (const QString &msg, bool alsoPrint=true)
 Display a message in the status bar
More...
 
bool systemCommand (int command, const QStringList &parms)
 Run a system command. More...
 
MGXCameracamera ()
 Get the camera. More...
 
std::pair< stack_iterator, stack_iteratorstacks ()
 Iterate over all the stacks. More...
 
std::pair< const_stack_iterator, const_stack_iteratorstacks () const
 Iterate over all the stacks. More...
 
StackaddStack ()
 Add a new stack to the process. More...
 
bool deleteStack (int i)
 Delete the stack of given id. More...
 
int meshCount () const
 Returns the number of mesh available to the process. More...
 
Meshmesh (int i)
 Returns the ith mesh. More...
 
MeshcurrentMesh ()
 Returns the current mesh (i.e. More...
 
MeshotherMesh ()
 Returns the other mesh (i.e. More...
 
int currentMeshId () const
 Returns the id (i.e. More...
 
int otherMeshId () const
 Returns the id (i.e. More...
 
void setCurrentMeshId (int i)
 Change which mesh is current. More...
 
std::pair< mesh_iterator, mesh_iteratormeshes ()
 Iterate over all the meshs. More...
 
std::pair< const_mesh_iterator, const_mesh_iteratormeshes () const
 Iterate over all the meshs. More...
 
MeshaddMesh (const Stack *stack)
 Add a mesh to the process for the given stack. More...
 
bool deleteMesh (int i)
 Remove a mesh from the process. More...
 
int selectedLabel () const
 Get the current selected label. More...
 
void setSelectedLabel (int label)
 Change the current selected label. More...
 
float globalBrightness ()
 Return the current setting for the global brightness level. More...
 
float globalContrast ()
 Return the current setting for the global contrast level. More...
 
void setGlobalBrightness (float value)
 Change the current setting for the global brightness level. More...
 
void setGlobalContrast (float value)
 Change the current setting for the global contrast level. More...
 
bool meshSelection () const
 Returns if the user has mesh selection active. More...
 
bool lineBorderSelection () const
 Returns is the user has line border selection active. More...
 
bool updateState ()
 Update the Gui of MorphoGraphX. More...
 
bool updateViewer ()
 Tell the viewer to redraw. More...
 
bool loadView (const QString &fileName)
 Load viewfile. More...
 
bool saveView (const QString &fileName)
 Save viewfile. More...
 
bool setErrorMessage (const QString &str)
 Set an error message that will be displayed if the process returns false. More...
 
QString errorMessage () const
 Get the current error message. More...
 
void setWarningMessage (const QString &str)
 Set a warning message that will be displayed if the process returns true. More...
 
QString warningMessage () const
 Get the current warning message. More...
 
void userCancel () const
 Throw an exception informing the system that the user canceled the current process. More...
 
const QString & file () const
 Get the name of the file that was used to load the current process (i.e. More...
 
Clipclip1 ()
 Return the object defining the first clipping region. More...
 
Clipclip2 ()
 Return the object defining the second clipping region. More...
 
Clipclip3 ()
 Return the object defining the third clipping region. More...
 
const Clipclip1 () const
 Return the object defining the first clipping region. More...
 
const Clipclip2 () const
 Return the object defining the second clipping region. More...
 
const Clipclip3 () const
 Return the object defining the third clipping region. More...
 
CuttingSurfacecuttingSurface ()
 Return the cutting surface. More...
 
const CuttingSurfacecuttingSurface () const
 Return the cutting surface. More...
 
ProcessmakeProcess (const QString &processName)
 Creates a process object by name. More...
 
template<typename ProcessT >
bool getProcess (const QString &processName, ProcessT *&p)
 Gets process. More...
 
bool setCurrentParms ()
 Set the parms from the GUI. More...
 
bool runProcess (Process &proc, QStringList &parms) throw ()
 Launch a process with generic arguments. More...
 
bool runProcess (const QString &processName, QStringList &parms) throw ()
 Launch a process by name. More...
 
virtual bool finalize (QWidget *)
 This is an optional method that is called from the main thread before the process is run. More...
 
CheckState checkState ()
 Call this function and convert the result to a boolean. More...
 
- Public Member Functions inherited from mgx::ProcessParms
 ProcessParms ()
 
virtual ~ProcessParms ()
 
QString name () const
 Process name that is using the parameters. More...
 
QString description () const
 Process description. More...
 
QStringList parmNames () const
 List of named parameters. More...
 
QStringList parmDescs () const
 List of parameters descriptions. More...
 
QStringList parmDefaults () const
 List of default parms. More...
 
ParmChoiceList parmChoice () const
 Allows the parameter to have a pick list in the GUI. More...
 
QIcon icon () const
 Icon to use to represent the process in the GUI. More...
 
QString parm (const QString &name) const
 Get a single parameter value by name. More...
 
const QStringList & getParms ()
 Get the list of parameter values. More...
 
bool setName (const QString &name)
 Set the name. More...
 
bool setDesc (const QString &description)
 Set the description. More...
 
bool addParm (const QString &parmName, const QString &desc, const QString &def, const QStringList &choices=QStringList())
 Add a parameter to the list. More...
 
bool insertParm (const QString &parmName, const QString &desc, const QString &def, int pos, const QStringList &choices=QStringList())
 Insert a parameter to the list. More...
 
bool setParm (const QString &parmName, const QString &parm)
 Set the parameter's value. More...
 
bool setParms (const QStringList &parms)
 Set all the parameter values. More...
 
bool setParmDesc (const QString &parmName, const QString &desc)
 Set the parameter's description. More...
 
bool setParmDefault (const QString &parmName, const QString &def)
 Set the parameter's default value. More...
 
bool setParmChoices (const QString &parmName, const QStringList &choices)
 Set the parameter's choices. More...
 
bool setIcon (const QIcon &icon)
 Set the icon. More...
 
QStringList parmList (const QString &key=QString()) const
 Return a list of parameter names. More...
 

Protected Slots

void selectMeshFile ()
 
void selectMeshType (const QString &type)
 

Protected Member Functions

QString properFile (QString filename, const QString &type) const
 
void setMeshFile (const QString &filename)
 
Point3d savedPos (Point3d pos, bool transform, const Stack *stack)
 
bool saveText (Mesh *mesh, const QString &filename, bool transform)
 
bool saveCells (Mesh *mesh, const QString &filename, bool transform)
 
bool saveMeshEdit (Mesh *mesh, const QString &filename, bool transform)
 
bool saveMeshSTL (Mesh *mesh, const QString &filename, bool transform)
 
bool saveVTU (Mesh *mesh, const QString &filename, bool transform, bool binary=false)
 
bool saveOBJ (Mesh *mesh, const QString &filename, bool transform)
 
- Protected Member Functions inherited from mgx::Process
bool stackCheck (int checks, int which)
 Check stack properties. More...
 
bool storeCheck (int checks, int which)
 Check store properties. More...
 
bool meshCheck (int checks, int which)
 Check mesh properties. More...
 
QString stackError (int checks, int which)
 Generate a standardised string describing how the stack should be to not generate an error. More...
 
QString storeError (int checks, int which)
 Generate a standardised string describing how the store should be to not generate an error. More...
 
QString meshError (int checks, int which)
 Generate a standardised string describing how the mesh should be to not generate an error. More...
 

Protected Attributes

QDialog * dlg
 
Ui_ExportMeshDialog * ui
 
bool extendedPLY
 

Additional Inherited Members

- Public Types inherited from mgx::Process
enum  ProcessAction { PROCESS_RUN, PROCESS_STEP, PROCESS_REWIND }
 Enumeration for process flow control. More...
 
enum  StackCheckType {
  STACK_ANY, STACK_NON_EMPTY, STACK_VISIBLE, STACK_EMPTY,
  STACK_SCALED, STACK_TRANSFORMED, STACK_NON_SCALED, STACK_NON_TRANSFORMED
}
 Enumeration for the bitfield that identifies stack properties. More...
 
enum  StoreCheckType {
  STORE_ANY, STORE_NON_EMPTY, STORE_VISIBLE, STORE_EMPTY,
  STORE_LABEL, STORE_NON_LABEL, STORE_SCALED, STORE_TRANSFORMED,
  STORE_NON_SCALED, STORE_NON_TRANSFORMED, STORE_WORK, STORE_MAIN
}
 Enumeration for the bitfield that identifies store properties. More...
 
enum  MeshCheckType {
  MESH_ANY, MESH_NON_EMPTY, MESH_VISIBLE, MESH_HEAT,
  MESH_LABEL, MESH_NORMAL, MESH_SIGNAL, MESH_TEXTURE,
  MESH_IMAGE, MESH_SHOW_MESH, MESH_SHOW_SURF, MESH_ALL,
  MESH_BORDER, MESH_CELLMAP, MESH_CELLS, MESH_IMG_TEX,
  MESH_SCALED, MESH_TRANSFORMED, MESH_EMPTY, MESH_NON_CELLS,
  MESH_NON_IMG_TEX, MESH_NON_SCALED, MESH_NON_TRANSFORMED, MESH_USE_PARENTS
}
 Enumeration for the bitfield that identifies mesh properties. More...
 
enum  CheckType { CHECK_STACK, CHECK_STORE, CHECK_MESH }
 Enumeration of the type of checks that can be performed. More...
 
enum  CheckWhich { CHECK_CURRENT }
 
typedef std::vector< Stack * >::iterator stack_iterator
 
typedef std::vector< Stack * >::const_iterator const_stack_iterator
 
typedef std::vector< Mesh * >::iterator mesh_iterator
 
typedef std::vector< Mesh * >::const_iterator const_mesh_iterator
 
- Signals inherited from mgx::Process
void systemCommandGui (mgx::Process *, int, QStringList)
 
void systemCommandProcess (mgx::Process *, int, QStringList)
 
- Static Public Member Functions inherited from mgx::ProcessParms
static QStringList booleanChoice ()
 Helper function that provides a list of choices for a boolean argument. More...
 
static QStringList storeChoice ()
 Helper function that provides a list of choices for choosing from the main or work stack. More...
 
static QStringList stackChoice ()
 Helper function that provides a list of choices for choosing between stack 1 and 2. More...
 
static QStringList meshChoice ()
 Helper function that provides a list of choices for choosing between stack 1 and 2. More...
 
static QStringList dimensionChoice ()
 Helper function that provides a list of choices for choosing the dimension. More...
 
static QStringList dimChoice ()
 Helper function that provides a list of choices for choosing the dimension. More...
 
- Public Attributes inherited from mgx::Process
PrivateProcess * p
 
- Static Public Attributes inherited from mgx::Process
static unsigned int processVersion
 
static std::vector< Colorf > & LabelColors
 

Detailed Description

Export a mesh on various formats: PLY format, VTK format, "text" format, "cells" format, MeshEdit format, STL format or OBJ format.

We will here describe the file formats, or at least how MorphoGraphX uses them.

PLY format

The PLY format is fully described on the website of the Paul Bourke: http://paulbourke.net/dataformats/ply/

It is also available on Wikipedia: https://en.wikipedia.org/wiki/PLY_(file_format)

MorphoGraphX exports only the two kind of elements described as mandatory: vertex and face.

In the case of a cell mesh, each vertex contains only its position (x,y,z). Otherwise, vertices also have their label.

In any case, each face contains the list of 0-based index into the vertex elements that form the face, and the label marking which cell the face is a part of. Vertices are oriented counter-clockwise.

VTK format

MorphoGraphX save VTU format, which are XML files for unstructure grids.

The file format is quite complex, and fully described in the VTK book and website.

MorphoGraphX stores the following properties in addition to the mandatory ones:

For each vertex: 'Signal' (float32), 'Normals' (3 floats32), 'Color' (float32) and 'Label' (int32)

For each "cell" (e.g. triangles or 2D cells): 'Label' (int32)

MorphoGraphX also adds a DataArray to store the heat per VTU "cell". The name is either "Cell Heat" or "Wall Heat".

At last, an extra DataArray is created, store the heat per label instead of per cell.

"text" format

The text format is a trivial ASCII file format. The file contains:

n
vertex 0
vertex 1
...
vertex n-1
neighbors 0
neighbors 1
...
neighbors n-1

Each vertex is described as:

id x y z label

Each neighborhood is described as:

id m id_1 id_2 ... id_m

Where id is the id of the current vertex, m the number of neighbors, and id_1, id_2 are vertex ids as described before. The vertex must be ordered counter-clockwise.

"cells" format

This format is very similar to the "text" format. Only each vertex is described as:

id x z y label type

Where type is j for junctions and c for cell centers.

MeshEdit format

This file format is the one used by the MeshEdit software. In MorphoGraphX, the file has the following format

MeshVersionFormatted 1
Dimension 3
Vertices
vertex 1
vertex 2
...
vertex n
Triangles
triangle 1
triangle 2
...
triangle m
End

Each vertex is described as:

x y z label

And each triangle is described as:

v0 v1 v2 label

Again, the vertices must be ordered counter-clockwise.

STL format

The STL file format is the one used in many CAD software, including Abaqus.

In MorphoGraphX, the mesh is stored as a single solid called "mgx". The file structure is:

solid mgx
facet 1
facet 2
...
facet n
endsolid mgx

Where each facet is described as:

facet normal nx ny nz
  outer loop
    vertex vx1 vy1 vz1
    vertex vx2 vy2 vz2
    vertex vx3 vy3 vz3
  endloop
endfacet

OBJ format

MorphoGraphX can also export files in the WaveFront's OBJ file format.

The file has the following structure:

# Triangular mesh created by MorphoGraphX
# Length unit: µm
# Vertices
vertex 1
vertex 2
...
vertex n
# Triangles
triangle 1
triangle 2
...
triangle m

Each vertex is stored as:

v x y z
vn nx ny nz

And each triangle as:

f v1 v2 v3

where v1, v2 and v3 are 1-based index in the vertex array. Also, the vertices are oriented counter-clockwise.

Definition at line 433 of file SystemProcessSave.hpp.

Constructor & Destructor Documentation

◆ MeshExport()

mgx::MeshExport::MeshExport ( const Process proc)
inline

Definition at line 436 of file SystemProcessSave.hpp.

Member Function Documentation

◆ icon()

QIcon mgx::MeshExport::icon ( ) const
inline

Definition at line 458 of file SystemProcessSave.hpp.

◆ initialize()

bool mgx::MeshExport::initialize ( QWidget *  )
virtual

Initialize the process.

Called from the main (GUI) thread before the process is run. If there is an active GUI, then parent will be set.

The process can use the method to update the argument list with a dialog. If the arguments are updates, the process should return true

Parameters
parentPointer to the parent widget if there is an active GUI.
Returns
false if the process is not to run afterwards

Reimplemented from mgx::Process.

◆ properFile()

QString mgx::MeshExport::properFile ( QString  filename,
const QString &  type 
) const
protected

◆ run() [1/2]

bool mgx::MeshExport::run ( )
virtual

Runs the process.

Returns
false if process failed, true otherwise (FIXME: what kind of fail do we care about?)

Reimplemented from mgx::Process.

◆ run() [2/2]

bool mgx::MeshExport::run ( Mesh mesh,
const QString &  filename,
const QString &  type,
bool  transform 
)

Export a mesh.

Parameters
meshMesh to be exported
filenameFile to save the mesh into
typeType (format) of the export.
transformSave the transformed positions

◆ saveCells()

bool mgx::MeshExport::saveCells ( Mesh mesh,
const QString &  filename,
bool  transform 
)
protected

◆ savedPos()

Point3d mgx::MeshExport::savedPos ( Point3d  pos,
bool  transform,
const Stack stack 
)
protected

◆ saveMeshEdit()

bool mgx::MeshExport::saveMeshEdit ( Mesh mesh,
const QString &  filename,
bool  transform 
)
protected

◆ saveMeshSTL()

bool mgx::MeshExport::saveMeshSTL ( Mesh mesh,
const QString &  filename,
bool  transform 
)
protected

◆ saveOBJ()

bool mgx::MeshExport::saveOBJ ( Mesh mesh,
const QString &  filename,
bool  transform 
)
protected

◆ savePLY()

bool mgx::MeshExport::savePLY ( Mesh mesh,
const QString &  filename,
bool  transform,
bool  binary = false 
)

◆ saveText()

bool mgx::MeshExport::saveText ( Mesh mesh,
const QString &  filename,
bool  transform 
)
protected

◆ saveVTU()

bool mgx::MeshExport::saveVTU ( Mesh mesh,
const QString &  filename,
bool  transform,
bool  binary = false 
)
protected

◆ selectMeshFile

void mgx::MeshExport::selectMeshFile ( )
protectedslot

◆ selectMeshType

void mgx::MeshExport::selectMeshType ( const QString &  type)
protectedslot

◆ setMeshFile()

void mgx::MeshExport::setMeshFile ( const QString &  filename)
protected

Member Data Documentation

◆ dlg

QDialog* mgx::MeshExport::dlg
protected

Definition at line 479 of file SystemProcessSave.hpp.

◆ extendedPLY

bool mgx::MeshExport::extendedPLY
protected

Definition at line 482 of file SystemProcessSave.hpp.

◆ ui

Ui_ExportMeshDialog* mgx::MeshExport::ui
protected

Definition at line 480 of file SystemProcessSave.hpp.


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