46 #include "VolumeMeshConvert.hh" 59 void VolumeMeshConvertPlugin::pluginsInitialized()
62 emit setSlotDescription(
"convertToHexMesh(int)",
63 "Convert a polyhedral Mesh to a hexahedral mesh." 64 " Does not check if input mesh actually has the right topology." 65 " Return the ID of the new mesh or -1 in case of error." 66 " The old mesh remains unchanged.",
67 QStringList(
"object_id"),
68 QStringList(
"id of an the input object"));
69 emit setSlotDescription(
"convertToTetMesh(int)",
70 "Convert a polyhedral Mesh to a tetrahedral mesh." 71 " Does not check if input mesh actually has the right topology." 72 " Return the ID of the new mesh or -1 in case of error." 73 " The old mesh remains unchanged.",
74 QStringList(
"object_id"),
75 QStringList(
"id of an the input object"));
76 emit setSlotDescription(
"convertToPolyhedralMesh(int)",
77 "Convert a hex or tet mesh to a PolyhedralMesh." 78 " Return the ID of the new mesh or -1 in case of error." 79 " The old mesh remains unchanged.",
80 QStringList(
"object_id"),
81 QStringList(
"id of an the input object"));
83 if(! OpenFlipper::Options::gui())
87 toolbar_ =
new QToolBar(tr(
"Volume Mesh conversion"));
89 grp_ =
new QActionGroup(toolbar_);
92 actionToHex_ =
new QAction(tr(
"&Convert Polyhedral to Hexahedral mesh"), grp_);
93 actionToTet_ =
new QAction(tr(
"&Convert Polyhedral to Tetrahedral mesh"), grp_);
94 actionToPoly_ =
new QAction(tr(
"&Convert Tet or Hex mesh to Polyhedral mesh"), grp_);
98 actionToHex_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"VolumeConvertToHex.png"));
99 actionToTet_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"VolumeConvertToTet.png"));
100 actionToPoly_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"VolumeConvertToPoly.png"));
103 toolbar_->addAction(actionToHex_);
104 toolbar_->addAction(actionToTet_);
105 toolbar_->addAction(actionToPoly_);
107 connect( grp_, SIGNAL( triggered(QAction*) ),
this, SLOT(
handleQAction(QAction*)) );
110 emit addToolbar( toolbar_ );
115 std::vector<int> _ids;
118 for(
const auto id: _ids)
121 if (_action == actionToHex_)
122 out_id = convertToHexMesh(
id);
123 else if (_action == actionToPoly_)
124 out_id = convertToPolyhedralMesh(
id);
125 else if (_action == actionToTet_)
126 out_id = convertToTetMesh(
id);
131 emit log(
LOGERR,
"VolumeMeshConvert: failed to convert object " + QString::number(
id));
133 emit log(
LOGINFO,
"VolumeMeshConvert: successfully converted object" 134 + QString::number(
id) +
" to new object " + QString::number(out_id));
139 int VolumeMeshConvertPlugin::convertToHexMesh(
int _id)
158 int VolumeMeshConvertPlugin::convertToTetMesh(
int _id)
177 int VolumeMeshConvertPlugin::convertToPolyhedralMesh(
int _id)
196 newObj->
setName(
"Polyhedral conv. of " + oldObj->
name());
#define DATA_POLYHEDRAL_MESH
void handleQAction(QAction *)
convert Converts polyhedralmesh to hex/tet mesh and vice versa depending on the Action that was calle...
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.
#define DATA_TETRAHEDRAL_MESH
#define DATA_HEXAHEDRAL_MESH
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
void initializePlugin() override
BaseInterface.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
TetrahedralMesh * tetrahedralMesh(BaseObjectData *_object)
Get an TetrahedralMesh from an object.
PolyhedralMesh * polyhedralMesh(BaseObjectData *_object)
Get an PolyhedralMesh from an object.
bool getTargetIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a target object.