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 typeCheck_->setCurrentIndex(0);
89 loadCompMode_ =
new QCheckBox(
"Load PolyVolMesh format");
90 loadTopCheck_ =
new QCheckBox(
"Perform topology checks");
91 llayout->addWidget(typeCheck_);
92 llayout->addWidget(loadCompMode_);
93 llayout->addWidget(loadTopCheck_);
95 loadOptions_->setLayout(llayout);
97 saveOptions_ =
new QWidget();
99 QVBoxLayout* slayout =
new QVBoxLayout();
100 slayout->setAlignment(Qt::AlignTop);
102 saveCompMode_ =
new QCheckBox(
"Save in PolyVolMesh format");
103 slayout->addWidget(saveCompMode_);
105 saveOptions_->setLayout(slayout);
112 return QString(tr(
"Polyhedral Volume Mesh files ( *.ovm *.polyvolmesh *.tetmesh )"));
120 return QString(tr(
"Polyhedral Volume Mesh files ( *.ovm )"));
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) {
153 }
else if (!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 2) {
167 if(compatibility_mode) {
169 loadMesh((
const char*) _filename.toLatin1(), *(obj->mesh()), compatibility_mode,
173 if(!fileManager_.
readFile(_filename.toStdString(), *(obj->mesh()),
174 topology_checks,
true)) {
175 emit log(
LOGERR, QString(
"Could not open file %1!").arg(_filename));
182 obj->meshNode()->set_scaling(0.8);
192 if(compatibility_mode) {
194 loadMesh((
const char*) _filename.toLatin1(), *(obj->mesh()), compatibility_mode,
198 if(!fileManager_.
readFile(_filename.toStdString(), *(obj->mesh()),
199 topology_checks,
true)) {
200 emit log(
LOGERR, QString(
"Could not open file %1!").arg(_filename));
207 obj->meshNode()->set_scaling(0.8);
221 emit openedFile(baseObj->
id());
230 bool FileOpenVolumeMeshPlugin::saveObject(
int _id, QString _filename) {
239 obj->setFromFileName(_filename);
240 obj->setName(obj->filename());
241 if(!fileManager_.
writeFile(_filename.toStdString(), *(mesh_obj->
mesh()))) {
242 emit log(
LOGERR, tr(
"Unable to save ") + _filename);
246 else if (hex_mesh_obj) {
248 obj->setFromFileName(_filename);
249 obj->setName(obj->filename());
250 if (!fileManager_.
writeFile(_filename.toStdString(), *(hex_mesh_obj->
mesh()))) {
251 emit log(
LOGERR, tr(
"Unable to save ") + _filename);
259 emit log(
LOGERR, tr(
"saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
269 void FileOpenVolumeMeshPlugin::loadIniFileLast(
INIFile& _ini,
int _id) {
273 emit log(
LOGERR, tr(
"Cannot find object for id %1 in saveFile!").arg(_id));
283 object->materialNode()->set_base_color(col);
290 void FileOpenVolumeMeshPlugin::saveIniFile(
INIFile& _ini,
int _id) {
294 emit log(
LOGERR, tr(
"Cannot find object for id %1 in saveFile!").arg(_id));
301 _ini.
add_entryVec(object->
name(),
"BaseColor",
object->materialNode()->base_color());
318 #if QT_VERSION < 0x050000
bool readFile(const std::string &_filename, MeshT &_mesh, bool _topologyCheck=true, bool _computeBottomUpIncidences=true) const
Read a mesh from a file.
MeshT * mesh()
return a pointer to the mesh
QString name() const
return the name of the object. The name defaults to NONAME if unset.
QString filename() const
return the filename of the object
#define DATA_POLYHEDRAL_MESH
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
bool getObject(int _identifier, BSplineCurveObject *&_object)
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
void setFromFileName(const QString &_filename)
const DrawMode & getDrawMode(const std::string &_name)
Get a custom DrawMode.
QWidget * loadOptionsWidget(QString _currentFilter)
void add_entryVec(const QString &_section, const QString &_key, const VectorT &_value)
Addition of a Vec_n_something.
PolyhedralMeshObject * polyhedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an PolyhedralMeshObject if possible.
Class for the handling of simple configuration files.
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
#define DATA_HEXAHEDRAL_MESH
QWidget * saveOptionsWidget(QString _currentFilter)
bool isHexahedralMesh(const std::string &_filename) const
Test whether given file contains a hexahedral mesh.
void setObjectDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, const bool &_force=false)
Set the draw mode for the object.
bool writeFile(const std::string &_filename, const MeshT &_mesh) const
Write a mesh to a file.
bool get_entryVecf(VectorT &_val, const QString &_section, const QString &_key) const
Get a Vec_n_i (int)