52 #include <ACG/GL/GLState.hh> 57 #include "FileOpenVolumeMesh.hh" 59 #if QT_VERSION >= 0x050000 65 FileOpenVolumeMeshPlugin::FileOpenVolumeMeshPlugin() :
77 void FileOpenVolumeMeshPlugin::initializePlugin() {
79 loadOptions_ =
new QWidget();
81 QVBoxLayout* llayout =
new QVBoxLayout();
82 llayout->setAlignment(Qt::AlignTop);
84 typeCheck_ =
new QComboBox();
85 typeCheck_->addItem(
"Autodetect");
86 typeCheck_->addItem(
"Polyhedral Mesh");
87 typeCheck_->addItem(
"Hexahedral Mesh");
88 #ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT 89 typeCheck_->addItem(
"Tetrahedral Mesh");
91 typeCheck_->setCurrentIndex(0);
92 loadCompMode_ =
new QCheckBox(
"Load PolyVolMesh format");
93 loadTopCheck_ =
new QCheckBox(
"Perform topology checks");
94 llayout->addWidget(typeCheck_);
95 llayout->addWidget(loadCompMode_);
96 llayout->addWidget(loadTopCheck_);
98 loadOptions_->setLayout(llayout);
100 saveOptions_ =
new QWidget();
102 QVBoxLayout* slayout =
new QVBoxLayout();
103 slayout->setAlignment(Qt::AlignTop);
105 saveCompMode_ =
new QCheckBox(
"Save in PolyVolMesh format");
106 slayout->addWidget(saveCompMode_);
108 saveOptions_->setLayout(slayout);
115 return QString(tr(
"Polyhedral Volume Mesh files ( *.ovm *.polyvolmesh *.tetmesh )"));
123 return QString(tr(
"Polyhedral Volume Mesh files ( *.ovm )"));
133 #ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT 134 type |= DATA_TETRAHEDRAL_MESH;
142 int FileOpenVolumeMeshPlugin::loadObject(QString _filename) {
144 bool compatibility_mode =
false;
145 if(!OpenFlipper::Options::nogui()) {
146 compatibility_mode = loadCompMode_->isChecked();
149 bool topology_checks =
true;
150 if(!OpenFlipper::Options::nogui()) {
151 topology_checks = loadTopCheck_->isChecked();
155 bool hexMesh =
false;
156 bool tetMesh =
false;
158 if(!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 0) {
159 hexMesh = fileManager_.isHexahedralMesh(_filename.toStdString());
160 }
else if (!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 2) {
164 #ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT 165 if(!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 0) {
166 tetMesh = fileManager_.isTetrahedralMesh(_filename.toStdString());
167 }
else if (!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 3) {
170 #endif // ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT 182 if(compatibility_mode) {
184 loadMesh((
const char*) _filename.toLatin1(), *(obj->
mesh()), compatibility_mode,
188 if(!fileManager_.readFile(_filename.toStdString(), *(obj->
mesh()),
189 topology_checks,
true)) {
190 emit log(
LOGERR, QString(
"Could not open file %1!").arg(_filename));
200 #ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT 203 emit addEmptyObject(DATA_TETRAHEDRAL_MESH,
id);
204 TetrahedralMeshObject* obj(0);
209 if(compatibility_mode) {
211 loadMesh((
const char*) _filename.toLatin1(), *(obj->mesh()), compatibility_mode,
215 if(!fileManager_.readFile(_filename.toStdString(), *(obj->mesh()),
216 topology_checks,
true)) {
217 emit log(
LOGERR, QString(
"Could not open file %1!").arg(_filename));
222 obj->meshNode()->set_scaling(0.8);
227 #endif // ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT 236 if(compatibility_mode) {
238 loadMesh((
const char*) _filename.toLatin1(), *(obj->
mesh()), compatibility_mode,
242 if(!fileManager_.readFile(_filename.toStdString(), *(obj->
mesh()),
243 topology_checks,
true)) {
244 emit log(
LOGERR, QString(
"Could not open file %1!").arg(_filename));
265 emit openedFile(baseObj->
id());
274 bool FileOpenVolumeMeshPlugin::saveObject(
int _id, QString _filename) {
281 #ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT 282 TetrahedralMeshObject* tet_mesh_obj = PluginFunctions::tetrahedralMeshObject(obj);
288 if(!fileManager_.writeFile(_filename.toStdString(), *(mesh_obj->
mesh()))) {
289 emit log(
LOGERR, tr(
"Unable to save ") + _filename);
293 else if (hex_mesh_obj) {
297 if (!fileManager_.writeFile(_filename.toStdString(), *(hex_mesh_obj->
mesh()))) {
298 emit log(
LOGERR, tr(
"Unable to save ") + _filename);
302 #ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT 303 else if (tet_mesh_obj) {
307 if (!fileManager_.writeFile(_filename.toStdString(), *(tet_mesh_obj->mesh()))) {
308 emit log(
LOGERR, tr(
"Unable to save ") + _filename);
312 #endif // ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT 317 emit log(
LOGERR, tr(
"saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
327 void FileOpenVolumeMeshPlugin::loadIniFileLast(
INIFile& _ini,
int _id) {
331 emit log(
LOGERR, tr(
"Cannot find object for id %1 in saveFile!").arg(_id));
341 object->materialNode()->set_base_color(col);
348 void FileOpenVolumeMeshPlugin::saveIniFile(
INIFile& _ini,
int _id) {
352 emit log(
LOGERR, tr(
"Cannot find object for id %1 in saveFile!").arg(_id));
359 _ini.
add_entryVec(object->
name(),
"BaseColor",
object->materialNode()->base_color());
376 #if QT_VERSION < 0x050000
const DrawMode & getDrawMode(const std::string &_name)
Get a custom DrawMode.
ACG::SceneGraph::VolumeMeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
void setObjectDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, const bool &_force=false)
Set the draw mode for the object.
QString filename() const
return the filename of the object
bool getObject(int _identifier, BSplineCurveObject *&_object)
QWidget * saveOptionsWidget(QString _currentFilter)
void add_entryVec(const QString &_section, const QString &_key, const VectorT &_value)
Addition of a Vec_n_something.
#define DATA_POLYHEDRAL_MESH
MeshT * mesh()
return a pointer to the mesh
bool get_entryVecf(VectorT &_val, const QString &_section, const QString &_key) const
Get a Vec_n_i (int)
void setFromFileName(const QString &_filename)
#define DATA_HEXAHEDRAL_MESH
QWidget * loadOptionsWidget(QString _currentFilter)
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
Class for the handling of simple configuration files.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
PolyhedralMeshObject * polyhedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an PolyhedralMeshObject if possible.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.