46#include "VolumeMeshConvert.hh"
53#include <QActionGroup>
61void VolumeMeshConvertPlugin::pluginsInitialized()
64 emit setSlotDescription(
"convertToHexMesh(int)",
65 "Convert a polyhedral Mesh to a hexahedral mesh."
66 " Does not check if input mesh actually has the right topology."
67 " Return the ID of the new mesh or -1 in case of error."
68 " The old mesh remains unchanged.",
69 QStringList(
"object_id"),
70 QStringList(
"id of an the input object"));
71 emit setSlotDescription(
"convertToTetMesh(int)",
72 "Convert a polyhedral Mesh to a tetrahedral mesh."
73 " Does not check if input mesh actually has the right topology."
74 " Return the ID of the new mesh or -1 in case of error."
75 " The old mesh remains unchanged.",
76 QStringList(
"object_id"),
77 QStringList(
"id of an the input object"));
78 emit setSlotDescription(
"convertToPolyhedralMesh(int)",
79 "Convert a hex or tet mesh to a PolyhedralMesh."
80 " Return the ID of the new mesh or -1 in case of error."
81 " The old mesh remains unchanged.",
82 QStringList(
"object_id"),
83 QStringList(
"id of an the input object"));
85 if(! OpenFlipper::Options::gui())
89 toolbar_ =
new QToolBar(tr(
"Volume Mesh conversion"));
91 grp_ =
new QActionGroup(toolbar_);
94 actionToHex_ =
new QAction(tr(
"&Convert Polyhedral to Hexahedral mesh"), grp_);
95 actionToTet_ =
new QAction(tr(
"&Convert Polyhedral to Tetrahedral mesh"), grp_);
96 actionToPoly_ =
new QAction(tr(
"&Convert Tet or Hex mesh to Polyhedral mesh"), grp_);
100 actionToHex_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"VolumeConvertToHex.png"));
101 actionToTet_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"VolumeConvertToTet.png"));
102 actionToPoly_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"VolumeConvertToPoly.png"));
105 toolbar_->addAction(actionToHex_);
106 toolbar_->addAction(actionToTet_);
107 toolbar_->addAction(actionToPoly_);
109 connect( grp_, SIGNAL( triggered(QAction*) ),
this, SLOT(
handleQAction(QAction*)) );
112 emit addToolbar( toolbar_ );
117 std::vector<int> _ids;
120 for(
const auto id: _ids)
123 if (_action == actionToHex_)
124 out_id = convertToHexMesh(
id);
125 else if (_action == actionToPoly_)
126 out_id = convertToPolyhedralMesh(
id);
127 else if (_action == actionToTet_)
128 out_id = convertToTetMesh(
id);
133 emit log(
LOGERR,
"VolumeMeshConvert: failed to convert object " + QString::number(
id));
135 emit log(
LOGINFO,
"VolumeMeshConvert: successfully converted object"
136 + QString::number(
id) +
" to new object " + QString::number(out_id));
141int VolumeMeshConvertPlugin::convertToHexMesh(
int _id)
161int VolumeMeshConvertPlugin::convertToTetMesh(
int _id)
176 auto *tm =
static_cast<TetrahedralMesh::ParentT*
>(tmo->
mesh());
186int VolumeMeshConvertPlugin::convertToPolyhedralMesh(
int _id)
198 pmo->
setName(
"Polyhedral conv. of " + hmo->
name());
200 auto *tm =
static_cast<TetrahedralMesh::ParentT*
>(tmo->
mesh());
202 pmo->
setName(
"Polyhedral conv. of " + tmo->
name());
#define DATA_HEXAHEDRAL_MESH
#define DATA_POLYHEDRAL_MESH
#define DATA_TETRAHEDRAL_MESH
QString name() const
return the name of the object. The name defaults to NONAME if unset.
void handleQAction(QAction *)
convert Converts polyhedralmesh to hex/tet mesh and vice versa depending on the Action that was calle...
void initializePlugin() override
BaseInterface.
MeshT * mesh()
return a pointer to the mesh
void setName(QString _name)
Set the name of the Object.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
PolyhedralMeshObject * polyhedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an PolyhedralMeshObject if possible.
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
TetrahedralMeshObject * tetrahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an TetrahedralMeshObject if possible.
bool getTargetIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a target object.