45 #include <ACG/GL/GLState.hh> 50 #include "FileOpenVolumeMesh.hh" 52 #include <QVBoxLayout> 56 FileOpenVolumeMeshPlugin::FileOpenVolumeMeshPlugin() :
68 void FileOpenVolumeMeshPlugin::initializePlugin() {
70 if (!OpenFlipper::Options::nogui())
72 loadOptions_ =
new QWidget();
74 QVBoxLayout* llayout =
new QVBoxLayout();
75 llayout->setAlignment(Qt::AlignTop);
77 typeCheck_ =
new QComboBox();
78 typeCheck_->addItem(
"Autodetect");
79 typeCheck_->addItem(
"Polyhedral Mesh");
80 typeCheck_->addItem(
"Hexahedral Mesh");
81 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT 82 typeCheck_->addItem(
"Tetrahedral Mesh");
84 typeCheck_->setCurrentIndex(0);
85 loadCompMode_ =
new QCheckBox(
"Load PolyVolMesh format");
86 loadTopCheck_ =
new QCheckBox(
"Perform topology checks");
87 llayout->addWidget(typeCheck_);
88 llayout->addWidget(loadCompMode_);
89 llayout->addWidget(loadTopCheck_);
91 loadOptions_->setLayout(llayout);
93 saveOptions_ =
new QWidget();
95 QVBoxLayout* slayout =
new QVBoxLayout();
96 slayout->setAlignment(Qt::AlignTop);
98 saveCompMode_ =
new QCheckBox(
"Save in PolyVolMesh format");
99 slayout->addWidget(saveCompMode_);
101 saveOptions_->setLayout(slayout);
109 return QString(tr(
"Polyhedral Volume Mesh files ( *.ovm *.polyvolmesh *.tetmesh )"));
117 return QString(tr(
"Polyhedral Volume Mesh files ( *.ovm )"));
127 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT 136 int FileOpenVolumeMeshPlugin::loadObject(QString _filename) {
138 bool compatibility_mode =
false;
139 if(!OpenFlipper::Options::nogui()) {
140 compatibility_mode = loadCompMode_->isChecked();
143 bool topology_checks =
true;
144 if(!OpenFlipper::Options::nogui()) {
145 topology_checks = loadTopCheck_->isChecked();
149 bool hexMesh =
false;
151 if(!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 0) {
152 hexMesh = fileManager_.isHexahedralMesh(_filename.toStdString());
153 }
else if (!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 2) {
157 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT 158 bool tetMesh =
false;
159 if(!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 0) {
160 tetMesh = fileManager_.isTetrahedralMesh(_filename.toStdString());
161 }
else if (!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 3) {
164 #endif // ENABLE_TETRAHEDRALMESH_SUPPORT 176 if(compatibility_mode) {
178 loadMesh((
const char*) _filename.toLatin1(), *(obj->
mesh()), compatibility_mode,
182 if(!fileManager_.readFile(_filename.toStdString(), *(obj->
mesh()),
183 topology_checks,
true)) {
184 emit log(
LOGERR, QString(
"Could not open file %1!").arg(_filename));
194 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT 203 if(compatibility_mode) {
205 loadMesh((
const char*) _filename.toLatin1(), *(obj->
mesh()), compatibility_mode,
209 if(!fileManager_.readFile(_filename.toStdString(), *(obj->
mesh()),
210 topology_checks,
true)) {
211 emit log(
LOGERR, QString(
"Could not open file %1!").arg(_filename));
221 #endif // ENABLE_TETRAHEDRALMESH_SUPPORT 230 if(compatibility_mode) {
232 loadMesh((
const char*) _filename.toLatin1(), *(obj->
mesh()), compatibility_mode,
236 if(!fileManager_.readFile(_filename.toStdString(), *(obj->
mesh()),
237 topology_checks,
true)) {
238 emit log(
LOGERR, QString(
"Could not open file %1!").arg(_filename));
242 if (!OpenFlipper::Options::nogui())
262 emit openedFile(baseObj->
id());
271 bool FileOpenVolumeMeshPlugin::saveObject(
int _id, QString _filename) {
278 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT 285 if(!fileManager_.writeFile(_filename.toStdString(), *(mesh_obj->
mesh()))) {
286 emit log(
LOGERR, tr(
"Unable to save ") + _filename);
290 else if (hex_mesh_obj) {
294 if (!fileManager_.writeFile(_filename.toStdString(), *(hex_mesh_obj->
mesh()))) {
295 emit log(
LOGERR, tr(
"Unable to save ") + _filename);
299 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT 300 else if (tet_mesh_obj) {
304 if (!fileManager_.writeFile(_filename.toStdString(), *(tet_mesh_obj->
mesh()))) {
305 emit log(
LOGERR, tr(
"Unable to save ") + _filename);
309 #endif // ENABLE_TETRAHEDRALMESH_SUPPORT 314 emit log(
LOGERR, tr(
"saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
324 void FileOpenVolumeMeshPlugin::loadIniFileLast(
INIFile& _ini,
int _id) {
328 emit log(
LOGERR, tr(
"Cannot find object for id %1 in saveFile!").arg(_id));
338 object->materialNode()->set_base_color(col);
345 void FileOpenVolumeMeshPlugin::saveIniFile(
INIFile& _ini,
int _id) {
349 emit log(
LOGERR, tr(
"Cannot find object for id %1 in saveFile!").arg(_id));
356 _ini.
add_entryVec(object->
name(),
"BaseColor",
object->materialNode()->base_color());
#define DATA_POLYHEDRAL_MESH
TetrahedralMeshObject * tetrahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an TetrahedralMeshObject if possible.
virtual void setName(QString _name) override
path to the file from which the object is loaded ( defaults to "." )
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
PolyhedralMeshObject * polyhedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an PolyhedralMeshObject if possible.
bool get_entryVecf(VectorT &_val, const QString &_section, const QString &_key) const
Get a Vec_n_i (int)
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
#define DATA_TETRAHEDRAL_MESH
#define DATA_HEXAHEDRAL_MESH
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
QString filename() const
return the filename of the object
const DrawMode & getDrawMode(const std::string &_name)
Get a custom DrawMode.
void setObjectDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, const bool &_force=false)
Set the draw mode for the object.
QWidget * loadOptionsWidget(QString _currentFilter)
QString name() const
return the name of the object. The name defaults to NONAME if unset.
void add_entryVec(const QString &_section, const QString &_key, const VectorT &_value)
Addition of a Vec_n_something.
ACG::SceneGraph::VolumeMeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
QWidget * saveOptionsWidget(QString _currentFilter)
Class for the handling of simple configuration files.
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
MeshT * mesh()
return a pointer to the mesh
void setFromFileName(const QString &_filename)