diff --git a/BaseLib/FileFinder.h b/BaseLib/FileFinder.h index 79299b7aed411601743fd4f65bcfe2b70bda4dfc..13c924249dabeb0a801b6933f922f364d2f55a27 100644 --- a/BaseLib/FileFinder.h +++ b/BaseLib/FileFinder.h @@ -13,6 +13,11 @@ #ifndef FILEFINDER_H #define FILEFINDER_H +#include <iostream> +#include <fstream> +#include <string> +#include <list> + namespace BaseLib { /** * FileFinder stores a list of directories and will return the complete path @@ -40,10 +45,10 @@ public: * If the file is located in more than one of the directories in the search list, only the * first location will be returned. */ - std::string getPath(std::string filename) + std::string getPath(std::string filename) const { if (_directories.empty()) std::cout << "Error: FileFinder::getPath() -- directory list is empty." << std::endl; - for (std::list<std::string>::iterator it = _directories.begin(); it != _directories.end(); ++it) + for (std::list<std::string>::const_iterator it = _directories.begin(); it != _directories.end(); ++it) { std::string testDir(*it); std::ifstream is(testDir.append(filename).c_str()); diff --git a/BaseLib/Histogram.h b/BaseLib/Histogram.h new file mode 100644 index 0000000000000000000000000000000000000000..33906d38a633c93b715b8d28fab80748bd29b662 --- /dev/null +++ b/BaseLib/Histogram.h @@ -0,0 +1,164 @@ +/** \file + * \author Dmitri Naumov + * \date Apr. 2012 + * \brief Implementation of Histogram class. + * + */ + +#ifndef BASELIB_HISTOGRAM_H +#define BASELIB_HISTOGRAM_H + +#include <algorithm> +#include <cmath> +#include <iterator> +#include <ostream> +#include <vector> + +namespace BASELIB +{ + +/** Basic Histogram implementation. + * + * Creates histogram from input data of type \c T. + */ +template <typename T> +class Histogram +{ + public: + typedef typename std::vector<T> Data; ///< Underlying input data vector + /// type. + + public: + /** Creates histogram of the given element in the range \c [first, last). + * + * Input data is copied into \c std::vector. + * + * \param data Range of elements to create histogram from. + * \param nr_bins Number of bins in histogram. + * \param computeHistogram Compute histogram if set. If not set user must + * call \c update() before accessing data. + */ + template <typename InputIterator> + Histogram(InputIterator first, InputIterator last, const int nr_bins = 16, + const bool computeHistogram = true ) + : _data(first, last), _nr_bins(nr_bins) + { + std::sort(_data.begin(), _data.end()); + _histogram.resize(_nr_bins); + _min = _data.front(); + _max = _data.back(); + _bin_width = (_max - _min)/_nr_bins; + + _dirty = true; + if (computeHistogram) + update(); + } + + /** Creates histogram from \c std::vector. + * \param data Input vector. + * \param nr_bins Number of bins in histogram. + * \param computeHistogram Compute histogram if set. If not set user must call + * \c update() before accessing data. + */ + Histogram(std::vector<T> const& data, const unsigned int nr_bins = 16, + const bool computeHistogram = true) + : _data(data), _nr_bins(nr_bins) + { + std::sort(_data.begin(), _data.end()); + _histogram.resize(_nr_bins); + _min = _data.front(); + _max = _data.back(); + _bin_width = (_max - _min)/_nr_bins; + + _dirty = true; + if (computeHistogram) + update(); + } + + /** Updates histogram using sorted \c _data vector. + * + * Start histogram creation with first element. Then find first element in + * the next histogram bin. Number of elments in the bin is the difference + * between these two iterators. + * \verbatim + [0.1, 0.2, ..., 0.7 , ..., 0.7+binWidth = 0.9, 1.0 , ..., last] + it itEnd - 1 itEnd + \endverbatim + */ + void + update() + { + if (!_dirty) + return; + + _bin_width = (_max - _min)/_nr_bins; + + typedef typename Data::const_iterator DataCI; + DataCI it = _data.begin(); + DataCI itEnd; + for (unsigned int bin = 0; bin < _nr_bins; bin++) { + itEnd = std::upper_bound(it, (DataCI)_data.end(), + _min + (bin + 1) * _bin_width); + _histogram[bin] = std::distance(it, itEnd); + it = itEnd; + } + _dirty = false; + } + + void setMinimum(const T& minimum) { _min = minimum; _dirty = true; } + void setMaximum(const T& maximum) { _max = maximum; _dirty = true; } + + const Data& getSortedData() const { return _data; } + const std::vector<size_t>& getBinCounts() const { return _histogram; } + const unsigned int& getNrBins() const { return _nr_bins; } + const T& getMinimum() const { return _min; } + const T& getMaximum() const { return _max; } + const T& getBinWidth() const { return _bin_width; } + + void + prettyPrint(std::ostream& os, const unsigned int line_width = 16) const + { + const size_t count_max = *std::max_element(_histogram.begin(), _histogram.end()); + for (unsigned int bin = 0; bin < _nr_bins; ++bin) { + os << "[" << _min + bin * _bin_width << ", " << _min + (bin + 1) * _bin_width << ")\t"; + os << _histogram[bin] << "\t"; + + const int n_stars = std::ceil(line_width * ((double)_histogram[bin]/count_max)); + for (int star = 0; star < n_stars; star++) + os << "*"; + os << "\n"; + } + } + + protected: + Data _data; + const unsigned int _nr_bins; + std::vector<size_t> _histogram; + T _min, _max; ///< Minimum and maximum input data values. + T _bin_width; + + private: + bool _dirty; ///< When set \c update() will recompute histogram. + +}; + +/** Writes histogram to output stream. + * + * Writes histogram properties in this order: + * number of bins, minimum, maximum, bin0 count, ..., binN-1 count. + */ +template <typename T> +std::ostream& +operator<<(std::ostream& os, const Histogram<T>& h) +{ + os << h.getNrBins() << " " + << h.getMinimum() << " " + << h.getMaximum() << " "; + std::copy(h.getBinCounts().begin(), h.getBinCounts().end(), + std::ostream_iterator<T>(os, " ")); + return os << std::endl; +} + +} // namespace BASELIB + +#endif // BASELIB_HISTOGRAM_H diff --git a/CMakeLists.txt b/CMakeLists.txt index 4571173b771987f146abb8a601fdd21d0a739c00..0f1552d7d4b651424dd792ad1b1df65472d1d4ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,16 @@ ENDIF() # NOT OGS_NO_EXTERNAL_LIBS INCLUDE(scripts/cmake/ProjectSetup.cmake) INCLUDE(scripts/cmake/DocumentationSetup.cmake) +########################################################################### +### OGS version information. Adjust these if you release a new version. ### +########################################################################### +SET (OGS_VERSION_MAJOR 0) +SET (OGS_VERSION_MINOR 0) +SET (OGS_VERSION_PATCH 1) +SET (OGS_RELEASE_PERSONS "LB/TF/KR") +SET (OGS_VERSION "${OGS_VERSION_MAJOR}.${OGS_VERSION_MINOR}.${OGS_VERSION_PATCH}(${OGS_RELEASE_PERSONS})") +SET (OGS_DATE "2012-08-20") + ############### ### Options ### ############### @@ -68,3 +78,4 @@ IF(OGS_BUILD_GUI) ENDIF() CONFIGURE_FILE (BaseLib/BuildInfo.h.in ${PROJECT_BINARY_DIR}/BaseLib/BuildInfo.h) +CONFIGURE_FILE (BaseLib/Configure.h.in ${PROJECT_BINARY_DIR}/BaseLib/Configure.h) \ No newline at end of file diff --git a/FileIO/MeshIO.cpp b/FileIO/MeshIO.cpp index 0050c8b7e470928cfc159052d27d1c738cec3712..d158f9d29b29cbd96ca2c968da16a32b47ae8447 100644 --- a/FileIO/MeshIO.cpp +++ b/FileIO/MeshIO.cpp @@ -21,6 +21,8 @@ #include "Elements/Pyramid.h" #include "Elements/Prism.h" +#include "StringTools.h" + #include <iomanip> #include <sstream> @@ -99,7 +101,8 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) } } - MeshLib::Mesh* mesh (new MeshLib::Mesh(file_name, nodes, elements)); + + MeshLib::Mesh* mesh (new MeshLib::Mesh(BaseLib::getFileNameFromPath(file_name), nodes, elements)); mesh->setEdgeLengthRange(sqrt(edge_length[0]), sqrt(edge_length[1])); std::cout << "Nr. Nodes: " << nodes.size() << std::endl; diff --git a/FileIO/XmlIO/XmlGspInterface.cpp b/FileIO/XmlIO/XmlGspInterface.cpp index cce30af9102a5a87e8eec320e4a3f4352ce200fb..30598b8e40cfd0c9637f7eccf4457b0e0cafd71e 100644 --- a/FileIO/XmlIO/XmlGspInterface.cpp +++ b/FileIO/XmlIO/XmlGspInterface.cpp @@ -17,6 +17,7 @@ #include "XmlCndInterface.h" #include "MeshIO.h" +#include "Mesh.h" #include <QFileInfo> #include <QFile> @@ -96,11 +97,7 @@ int XmlGspInterface::readFile(const QString &fileName) fileList.at(i).toElement().text().toStdString(); FileIO::MeshIO meshIO; MeshLib::Mesh* msh = meshIO.loadMeshFromFile(msh_name); - QFileInfo fi(QString::fromStdString(msh_name)); - std::string name = fi.fileName().toStdString(); - _project->addMesh(msh, name); - //GridAdapter msh(fileList.at(i).toElement().text().toStdString()); - // TODO gridadapter to mesh-models + _project->addMesh(msh); } } @@ -154,14 +151,13 @@ int XmlGspInterface::write(std::ostream& stream) } // MSH - const std::map<std::string, MeshLib::Mesh*> msh_vec = _project->getMeshObjects(); - for (std::map<std::string, MeshLib::Mesh*>::const_iterator it(msh_vec.begin()); - it != msh_vec.end(); ++it) + const std::vector<MeshLib::Mesh*> msh_vec = _project->getMeshObjects(); + for (std::vector<MeshLib::Mesh*>::const_iterator it(msh_vec.begin()); it != msh_vec.end(); ++it) { // write mesh file - std::string fileName(path + it->first); FileIO::MeshIO meshIO; - meshIO.setMesh(it->second); + meshIO.setMesh(*it); + std::string fileName(path + (*it)->getName()); meshIO.writeToFile(fileName); // write entry in project file @@ -169,7 +165,7 @@ int XmlGspInterface::write(std::ostream& stream) root.appendChild(mshTag); QDomElement fileNameTag = doc.createElement("file"); mshTag.appendChild(fileNameTag); - QDomText fileNameText = doc.createTextNode(QString::fromStdString(it->first)); + QDomText fileNameText = doc.createTextNode(QString::fromStdString((*it)->getName())); fileNameTag.appendChild(fileNameText); } diff --git a/GeoLib/CMakeLists.txt b/GeoLib/CMakeLists.txt index f9a06b175738fb309384a8f1320d29d781d375ef..928424bb772476e11c952619d34093ae614e8cc1 100644 --- a/GeoLib/CMakeLists.txt +++ b/GeoLib/CMakeLists.txt @@ -1,8 +1,8 @@ # Source files -GET_SOURCE_FILES(SOURCES_GEOLIB) +GET_SOURCE_FILES(SOURCES_GeoLib) # Create the library -ADD_LIBRARY(GeoLib STATIC ${SOURCES_GEOLIB}) +ADD_LIBRARY(GeoLib STATIC ${SOURCES_GeoLib}) include_directories( diff --git a/Gui/DataExplorer.cmake b/Gui/DataExplorer.cmake index 4d0a78ad6353761cb1894317fc11662232cfe617..6c87a5f06e9f6b2fc1affc92fd22463e5386d024 100644 --- a/Gui/DataExplorer.cmake +++ b/Gui/DataExplorer.cmake @@ -1,17 +1,11 @@ # Source files SET( SOURCES mainwindow.cpp - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter/OGSFileConverter.cpp - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter/FileListDialog.cpp - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter/ConversionTools.cpp ) # Moc Header files SET( MOC_HEADERS mainwindow.h - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter/OGSFileConverter.h - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter/FileListDialog.h - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter/ConversionTools.h ) # Header files @@ -22,8 +16,6 @@ SET( HEADERS # UI files SET( UIS mainwindow.ui - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter/OGSFileConverter.ui - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter/FileList.ui ) @@ -38,8 +30,9 @@ INCLUDE( ${VTK_USE_FILE} ) # Include the headers which are generated by uic and moc # and include additional header INCLUDE_DIRECTORIES( + ${CMAKE_BINARY_DIR}/BaseLib + ${CMAKE_BINARY_DIR}/Gui/ ${CMAKE_BINARY_DIR}/Gui/Base - ${CMAKE_BINARY_DIR}/Gui/Gui ${CMAKE_BINARY_DIR}/Gui/DataView ${CMAKE_BINARY_DIR}/Gui/DataView/StratView ${CMAKE_BINARY_DIR}/Gui/DataView/DiagramView @@ -52,13 +45,13 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/MeshLib ${CMAKE_SOURCE_DIR}/MeshLibGEOTOOLS ${CMAKE_SOURCE_DIR}/FemLib + ${CMAKE_SOURCE_DIR}/OGS ${CMAKE_SOURCE_DIR}/Gui/Base ${CMAKE_SOURCE_DIR}/Gui/DataView ${CMAKE_SOURCE_DIR}/Gui/DataView/StratView ${CMAKE_SOURCE_DIR}/Gui/DataView/DiagramView ${CMAKE_SOURCE_DIR}/Gui/VtkVis ${CMAKE_SOURCE_DIR}/Gui/VtkAct - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter ) IF (Shapelib_FOUND) diff --git a/Gui/DataView/CondFromRasterDialog.cpp b/Gui/DataView/CondFromRasterDialog.cpp index cf2cf0c2cab714f1c7375f7d984a251e16d75d95..94247f2a81ad2fa9d2407d2bb506c3092de598ae 100644 --- a/Gui/DataView/CondFromRasterDialog.cpp +++ b/Gui/DataView/CondFromRasterDialog.cpp @@ -93,7 +93,8 @@ void CondFromRasterDialog::accept() } MeshLib::Mesh* new_mesh = const_cast<MeshLib::Mesh*>(mesh); DirectConditionGenerator dcg; - direct_values = dcg.directWithSurfaceIntegration(*new_mesh, raster_name, scaling_factor); + //TODO6: direct_values = dcg.directWithSurfaceIntegration(*new_mesh, raster_name, scaling_factor); + //dcg.writeToFile(direct_node_name); } //emit directNodesWritten(direct_node_name); diff --git a/Gui/DataView/DataView.cpp b/Gui/DataView/DataView.cpp index 8be904389fb75a02c032d02db3feb1aacfc85104..25d7e2cbd61fbcfd149676dc0801f455ea7eab13 100644 --- a/Gui/DataView/DataView.cpp +++ b/Gui/DataView/DataView.cpp @@ -53,7 +53,7 @@ void DataView::addMeshAction() FileIO::MeshIO meshIO; MeshLib::Mesh* msh = meshIO.loadMeshFromFile(name); if (msh) - static_cast<MshModel*>(this->model())->addMesh(msh, name); + static_cast<MshModel*>(this->model())->addMesh(msh); } } diff --git a/Gui/DataView/DirectConditionGenerator.cpp b/Gui/DataView/DirectConditionGenerator.cpp index d52e906d0ff0369828a32ee02ef27c4153fbc8e9..e4935581cd069fe07907221c66d91a6197d39a24 100644 --- a/Gui/DataView/DirectConditionGenerator.cpp +++ b/Gui/DataView/DirectConditionGenerator.cpp @@ -59,7 +59,7 @@ const std::vector< std::pair<size_t,double> >& DirectConditionGenerator::directT return _direct_values; } - +/* TODO6 const std::vector< std::pair<size_t,double> >& DirectConditionGenerator::directWithSurfaceIntegration(MeshLib::Mesh &mesh, const std::string &filename, double scaling) { double no_data_value (-9999); // TODO: get this from asc-reader! @@ -151,7 +151,7 @@ const std::vector< std::pair<size_t,double> >& DirectConditionGenerator::directW return _direct_values; } - +*/ int DirectConditionGenerator::writeToFile(const std::string &name) const { diff --git a/Gui/DataView/DirectConditionGenerator.h b/Gui/DataView/DirectConditionGenerator.h index c347af1844041128e2abe03fe2a94df8e4a78b4e..249268949b8c1c5011c75a3313e88bedb526ba81 100644 --- a/Gui/DataView/DirectConditionGenerator.h +++ b/Gui/DataView/DirectConditionGenerator.h @@ -21,7 +21,8 @@ public: const std::vector< std::pair<size_t,double> >& directToSurfaceNodes(const MeshLib::Mesh &mesh, const std::string &filename); - const std::vector< std::pair<size_t,double> >& directWithSurfaceIntegration(MeshLib::Mesh &mesh, const std::string &filename, double scaling); + //TODO6 + //const std::vector< std::pair<size_t,double> >& directWithSurfaceIntegration(MeshLib::Mesh &mesh, const std::string &filename, double scaling); int writeToFile(const std::string &name) const; diff --git a/Gui/DataView/ElementTreeModel.cpp b/Gui/DataView/ElementTreeModel.cpp index deb225910ab73779b58321467bde3a818414cfec..8ea65652abe7f9cb5f64c0783e2d871459928534 100644 --- a/Gui/DataView/ElementTreeModel.cpp +++ b/Gui/DataView/ElementTreeModel.cpp @@ -7,6 +7,7 @@ #include "OGSError.h" #include "TreeItem.h" #include "Mesh.h" +#include "Node.h" #include "Elements/Element.h" /** @@ -41,13 +42,13 @@ void ElementTreeModel::setElement(const MeshLib::Mesh* grid, const size_t elem_i elemItem->appendChild(typeItem); QList<QVariant> materialData; - materialData << "MaterialID: " << QString::number(elem->material); + materialData << "MaterialID: " << QString::number(elem->getValue()); TreeItem* matItem = new TreeItem(materialData, elemItem); elemItem->appendChild(matItem); QList<QVariant> volData; volData << "Area/Volume: " << - QString::number(grid->getCFEMesh()->getElementVector()[elem_index]->calcVolume()); + QString::number(grid->getElement(elem_index)->getContent()); TreeItem* volItem = new TreeItem(volData, elemItem); elemItem->appendChild(volItem); @@ -56,14 +57,15 @@ void ElementTreeModel::setElement(const MeshLib::Mesh* grid, const size_t elem_i TreeItem* nodeListItem = new TreeItem(nodeListData, elemItem); elemItem->appendChild(nodeListItem); - const std::vector<GeoLib::Point*>* nodes_vec = grid->getNodes(); - for (size_t i = 0; i < elem->nodes.size(); i++) + //const std::vector<MeshLib::Node*> nodes_vec = grid->getNodes(); + size_t nElemNodes = elem->getNNodes(); + for (size_t i = 0; i < nElemNodes; i++) { - const GeoLib::Point* pnt = (*nodes_vec)[elem->nodes[i]]; + const MeshLib::Node* node = elem->getNode(i); QList<QVariant> nodeData; - nodeData << "Node " + QString::number(elem->nodes[i]) << - QString::number((*pnt)[0]) << QString::number((*pnt)[1]) << - QString::number((*pnt)[2]); + nodeData << "Node " + QString::number(node->getID()) << + QString::number((*node)[0]) << QString::number((*node)[1]) << + QString::number((*node)[2]); TreeItem* nodeItem = new TreeItem(nodeData, nodeListItem); nodeListItem->appendChild(nodeItem); } diff --git a/Gui/DataView/LinearEditDialog.cpp b/Gui/DataView/LinearEditDialog.cpp index 5fac3f7ff03acb92691af67248a833f27b64419d..cd32e0d527c7ba91e987767c13450bc7743dfed8 100644 --- a/Gui/DataView/LinearEditDialog.cpp +++ b/Gui/DataView/LinearEditDialog.cpp @@ -42,7 +42,7 @@ void LinearEditDialog::on_comboBox_currentIndexChanged(int index) { size_t nRows = tableWidget->rowCount(); for (size_t i=0; i<nRows; i++) - tableWidget->item(i,0)->setText(QString::number(_line[i]->getData()[2])); + tableWidget->item(i,0)->setText(QString::number(_line[i]->getCoords()[2])); } } diff --git a/Gui/DataView/ListPropertiesDialog.cpp b/Gui/DataView/ListPropertiesDialog.cpp index eec0926d0c61b795fb4923939193cafc8ad49171..7b0712b413a1d1301b205b20db42114944318a90 100644 --- a/Gui/DataView/ListPropertiesDialog.cpp +++ b/Gui/DataView/ListPropertiesDialog.cpp @@ -62,11 +62,11 @@ void ListPropertiesDialog::setupDialog() { _min->setText(QString::number(minVal, 'f')); if (_prop->text().compare("date") == 0) - _min->setText(QString::fromStdString(date2string(minVal))); + _min->setText(QString::fromStdString(BaseLib::date2string(minVal))); _max->setText(QString::number(maxVal, 'f')); if (_prop->text().compare("date") == 0) - _max->setText(QString::fromStdString(date2string(maxVal))); + _max->setText(QString::fromStdString(BaseLib::date2string(maxVal))); } _propLabel.push_back(_prop); @@ -125,8 +125,8 @@ void ListPropertiesDialog::accept() { if (_propLabel[i]->text().compare("date") == 0) { - minVal = xmlDate2int(_minValue[i]->text().toStdString()); - maxVal = xmlDate2int(_maxValue[i]->text().toStdString()); + minVal = BaseLib::xmlDate2int(_minValue[i]->text().toStdString()); + maxVal = BaseLib::xmlDate2int(_maxValue[i]->text().toStdString()); } else { diff --git a/Gui/DataView/MshEditDialog.cpp b/Gui/DataView/MshEditDialog.cpp index 3bcb46d9ebba33a19924f18d79fffeebb0abf686..1fbb5eff95fea5069b76326a44a21c9484da1061 100644 --- a/Gui/DataView/MshEditDialog.cpp +++ b/Gui/DataView/MshEditDialog.cpp @@ -3,6 +3,7 @@ * 2010/11/09 KR Initial implementation */ +/* TODO6 #include "MshEditDialog.h" #include "OGSError.h" #include "StringTools.h" @@ -155,3 +156,4 @@ void MshEditDialog::getFileName() QDir dir = QDir(filename); settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); } +*/ \ No newline at end of file diff --git a/Gui/DataView/MshItem.cpp b/Gui/DataView/MshItem.cpp index d34b0b0ad0414993010f03baed7ed630b0744927..589dc9ca644a41e8a62bebefe0ea4fbface394ce 100644 --- a/Gui/DataView/MshItem.cpp +++ b/Gui/DataView/MshItem.cpp @@ -3,7 +3,6 @@ * 17/05/2010 KR Initial implementation */ -#include "GridAdapter.h" #include "MshItem.h" #include "VtkMeshSource.h" @@ -13,11 +12,11 @@ * \param parent The parent item in the tree * \param grid The mesh associated with this item */ -MshItem::MshItem(const QList<QVariant> &data, TreeItem* parent, GridAdapter* grid) +MshItem::MshItem(const QList<QVariant> &data, TreeItem* parent, MeshLib::Mesh* grid) : TreeItem(data, parent) { _meshSource = VtkMeshSource::New(); - _meshSource->SetGrid(grid); + _meshSource->SetMesh(grid); } MshItem::~MshItem() diff --git a/Gui/DataView/MshItem.h b/Gui/DataView/MshItem.h index 0d98b5b792d9959c37d69e258f3d597e958699b9..6cac3fef089c5e73cd3d7a35e312f7cb97655ee1 100644 --- a/Gui/DataView/MshItem.h +++ b/Gui/DataView/MshItem.h @@ -23,11 +23,11 @@ class MshItem : public TreeItem { public: /// Constructor, automatically generates VTK object of the given mesh. - MshItem(const QList<QVariant> &data, TreeItem* parent, GridAdapter* grid); + MshItem(const QList<QVariant> &data, TreeItem* parent, MeshLib::Mesh* grid); ~MshItem(); /// Returns the mesh as a GridAdapter. - const MeshLib::Mesh* getGrid() const { return this->_meshSource->GetGrid(); } + const MeshLib::Mesh* getMesh() const { return this->_meshSource->GetMesh(); } /// Returns the VTK object. VtkMeshSource* vtkSource() const { return _meshSource; } diff --git a/Gui/DataView/MshLayerMapper.cpp b/Gui/DataView/MshLayerMapper.cpp index 71a19184a4e74e88d62e7fd0fbfb3933844bec76..e93eb4800afbcc203188e8d0e83504b77411dd70 100644 --- a/Gui/DataView/MshLayerMapper.cpp +++ b/Gui/DataView/MshLayerMapper.cpp @@ -3,11 +3,11 @@ * 01/11/2010 KR Initial implementation */ +/* TODO6 #include "MshLayerMapper.h" #include "VtkRaster.h" #include "MshEditor.h" -#include "GridAdapter.h" #include "matrix_class.h" #include "msh_mesh.h" @@ -24,13 +24,8 @@ MeshLib::CFEMesh* MshLayerMapper::CreateLayers(const MeshLib::CFEMesh* mesh, << std::endl; return NULL; } -/* - if ((mesh->ele_vector[0]->GetElementType() != MshElemType::TRIANGLE) && (mesh->ele_vector[0]->GetElementType() != MshElemType::QUAD)) // check if mesh elements are triangles or quads - { - std::cout << "Error in MshLayerMapper::CreateLayers() - Method can only handle triangle- or quad-meshes... " << std::endl; - return NULL; - } - */ + + MeshLib::CFEMesh* new_mesh ( new MeshLib::CFEMesh() ); const size_t nNodes = mesh->nod_vector.size(); const size_t nElems = mesh->ele_vector.size(); @@ -411,3 +406,4 @@ MeshLib::CFEMesh* MshLayerMapper::blendLayersWithSurface(MeshLib::CFEMesh* mesh, return struct_mesh; } +*/ diff --git a/Gui/DataView/MshModel.cpp b/Gui/DataView/MshModel.cpp index fed3acb09e80b37dd018e967e221351c8e06b67e..89db5327b89d190930654716c4017cbfea7568cb 100644 --- a/Gui/DataView/MshModel.cpp +++ b/Gui/DataView/MshModel.cpp @@ -13,8 +13,12 @@ #include "TreeItem.h" #include "VtkMeshSource.h" -#include "msh_lib.h" +// MeshLib +#include "Node.h" +#include "Elements/Element.h" +#include "MshEnums.h" +// Qt #include <QFileInfo> #include <QString> #include <QTime> @@ -35,57 +39,44 @@ int MshModel::columnCount( const QModelIndex &parent /*= QModelIndex()*/ ) const return 3; } -void MshModel::addMesh(MeshLib::CFEMesh* mesh, std::string &name) +void MshModel::addMesh(MeshLib::Mesh* mesh) { - _project.addMesh(mesh, name); - GridAdapter* grid = new GridAdapter(mesh); - grid->setName(name); - this->addMeshObject(grid); -} - -void MshModel::addMesh(GridAdapter* mesh) -{ - MeshLib::CFEMesh* ogsmesh( const_cast<MeshLib::CFEMesh*>(mesh->getCFEMesh()) ); - std::string msh_name = mesh->getName(); - _project.addMesh(ogsmesh, msh_name); + _project.addMesh(mesh); this->addMeshObject(mesh); } -void MshModel::addMeshObject(GridAdapter* mesh) +void MshModel::addMeshObject(MeshLib::Mesh* mesh) { - std::string name(mesh->getName()); - std::cout << "name: " << name << std::endl; - QFileInfo fi(QString::fromStdString(name)); - name = fi.baseName().toStdString(); - mesh->setName(name); + std::cout << "name: " << mesh->getName() << std::endl; + QString display_name (QString::fromStdString(mesh->getName())); QList<QVariant> meshData; - meshData << QString::fromStdString(name) << ""; + meshData << display_name << ""; MshItem* newMesh = new MshItem(meshData, _rootItem, mesh); if (newMesh->vtkSource()) - newMesh->vtkSource()->SetName(fi.fileName()); + newMesh->vtkSource()->SetName(display_name); _rootItem->appendChild(newMesh); // display elements - const std::vector<GridAdapter::Element*>* elems = mesh->getElements(); - const size_t nElems (elems->size()); + const std::vector<MeshLib::Element*> elems = mesh->getElements(); + const size_t nElems (elems.size()); QString elem_type_string(""); MshElemType::type elem_type(MshElemType::INVALID); for (size_t i = 0; i < nElems; i++) { - const GridAdapter::Element* current_element = (*elems)[i]; + const MeshLib::Element* current_element (elems[i]); + MshElemType::type t (current_element->getType()); QList<QVariant> elemData; - - if (current_element->type != elem_type) + if (t != elem_type) { - elem_type = current_element->type; - elem_type_string = QString::fromStdString(MshElemType2String(current_element->type)); + elem_type = t; + elem_type_string = QString::fromStdString(MshElemType2String(t)); } QString nodestxt(""); - const size_t nNodes(current_element->nodes.size()); + const size_t nNodes(current_element->getNNodes()); for (size_t j = 0; j < nNodes; j++) - nodestxt.append(QString::number(current_element->nodes[j]) + ", "); + nodestxt.append(QString::number(current_element->getNode(j)->getID()) + ", "); elemData << "Element " + QString::number(i) << elem_type_string << nodestxt.left(nodestxt.length() - 2); @@ -98,13 +89,13 @@ void MshModel::addMeshObject(GridAdapter* mesh) emit meshAdded(this, this->index(_rootItem->childCount() - 1, 0, QModelIndex())); } -const GridAdapter* MshModel::getMesh(const QModelIndex &idx) const +const MeshLib::Mesh* MshModel::getMesh(const QModelIndex &idx) const { if (idx.isValid()) { MshItem* item = dynamic_cast<MshItem*>(this->getItem(idx)); if (item) - return item->getGrid(); + return item->getMesh(); else return NULL; } @@ -112,13 +103,13 @@ const GridAdapter* MshModel::getMesh(const QModelIndex &idx) const return NULL; } -const GridAdapter* MshModel::getMesh(const std::string &name) const +const MeshLib::Mesh* MshModel::getMesh(const std::string &name) const { for (int i = 0; i < _rootItem->childCount(); i++) { MshItem* item = static_cast<MshItem*>(_rootItem->child(i)); if (item->data(0).toString().toStdString().compare(name) == 0) - return item->getGrid(); + return item->getMesh(); } std::cout << "MshModel::getMesh() - No entry found with name \"" << name << "\"." << @@ -165,14 +156,10 @@ bool MshModel::removeMesh(const std::string &name) void MshModel::updateModel() { - const std::map<std::string, MeshLib::CFEMesh*> msh_vec = _project.getMeshObjects(); - for (std::map<std::string, MeshLib::CFEMesh*>::const_iterator it(msh_vec.begin()); - it != msh_vec.end(); ++it) - if (this->getMesh(it->first) == NULL) // if GridAdapter does not yet exist, create one. - { - std::string name = it->first; - addMeshObject(new GridAdapter(it->second)); - } + const std::vector<MeshLib::Mesh*> msh_vec = _project.getMeshObjects(); + for (std::vector<MeshLib::Mesh*>::const_iterator it(msh_vec.begin()); it != msh_vec.end(); ++it) + if (!this->getMesh((*it)->getName())) // if Mesh is not yet added to GUI, do it now + addMeshObject(*it); } VtkMeshSource* MshModel::vtkSource(const QModelIndex &idx) const diff --git a/Gui/DataView/MshModel.h b/Gui/DataView/MshModel.h index d61a15cfc8e55549ee939afb7532ac1631407f8d..9d7a586fc1b648fdb25e764650e3b6af50766589 100644 --- a/Gui/DataView/MshModel.h +++ b/Gui/DataView/MshModel.h @@ -33,9 +33,7 @@ public: public slots: /// Adds a new mesh - void addMesh(GridAdapter* mesh); - /// Adds a new mesh - void addMesh(MeshLib::Mesh* mesh, std::string &name); // needs only to be a slot for MshLayerMapper. Otherwise normal function would be okay. + void addMesh(MeshLib::Mesh* mesh); // needs only to be a slot for MshLayerMapper. Otherwise normal function would be okay. /// Returns the mesh with the given index. const MeshLib::Mesh* getMesh(const QModelIndex &idx) const; /// Returns the mesh with the given name. diff --git a/Gui/DataView/NetCdfConfigureDialog.cpp b/Gui/DataView/NetCdfConfigureDialog.cpp index c68ee0912b31cb2ae5d1459f0b599f57a76ba47a..a9e4bfca12c93deb9d01d36d4570afefc2325aaf 100644 --- a/Gui/DataView/NetCdfConfigureDialog.cpp +++ b/Gui/DataView/NetCdfConfigureDialog.cpp @@ -4,7 +4,6 @@ #include "NetCdfConfigureDialog.h" #include "VtkMeshConverter.h" -#include "GridAdapter.h" #include "VtkGeoImageSource.h" #include "VtkRaster.h" diff --git a/Gui/DataView/NetCdfConfigureDialog.h b/Gui/DataView/NetCdfConfigureDialog.h index c97f2433f09e71eec7f6bc56640a7b5af5e575cd..8c43863bc1106d4aa51a54c8b5d0ba0c86ea3ec5 100644 --- a/Gui/DataView/NetCdfConfigureDialog.h +++ b/Gui/DataView/NetCdfConfigureDialog.h @@ -12,7 +12,10 @@ #include <QDialog> #include "ui_NetCdfConfigure.h" -class GridAdapter; +namespace MeshLib { + class Mesh; +} + class VtkGeoImageSource; class NetCdfConfigureDialog : public QDialog, private Ui_NetCdfConfigure @@ -22,7 +25,7 @@ class NetCdfConfigureDialog : public QDialog, private Ui_NetCdfConfigure public: NetCdfConfigureDialog(const std::string &fileName, QDialog* parent = 0); ~NetCdfConfigureDialog(void); - GridAdapter* getMesh() { return _currentMesh; }; + MeshLib::Mesh* getMesh() { return _currentMesh; }; std::string getName(); VtkGeoImageSource* getRaster() { return _currentRaster; }; @@ -53,7 +56,7 @@ private: NcFile *_currentFile; NcVar *_currentVar; QDateTime _currentInitialDateTime; - GridAdapter* _currentMesh; + MeshLib::Mesh* _currentMesh; VtkGeoImageSource* _currentRaster; std::string _currentPath; }; diff --git a/Gui/DataView/ProcessModel.cpp b/Gui/DataView/ProcessModel.cpp index ed98be29a2fa3e4e2528e3e84831fb50d06cda20..2eb550089f9c3961c390d4bc4e7e0963e6a5d404 100644 --- a/Gui/DataView/ProcessModel.cpp +++ b/Gui/DataView/ProcessModel.cpp @@ -42,7 +42,7 @@ void ProcessModel::addConditionItem(FEMCondition* c) ProcessItem* processParent = this->getProcessParent(c->getProcessType()); if (processParent == NULL) { - ProcessInfo* pcs = new ProcessInfo(c->getProcessType(), c->getProcessPrimaryVariable(), NULL); + ProcessInfo* pcs = new ProcessInfo(c->getProcessType(), c->getProcessPrimaryVariable()/* TODO6, NULL*/); processParent = this->addProcess(pcs); } diff --git a/Gui/DataView/StationTreeView.cpp b/Gui/DataView/StationTreeView.cpp index 3fffe37a19113062d3ea18c6829f09976ac218e8..50a61103d2ce4cee93f3103fcdefbdef506fca5f 100644 --- a/Gui/DataView/StationTreeView.cpp +++ b/Gui/DataView/StationTreeView.cpp @@ -7,9 +7,9 @@ #include <QMenu> #include <iostream> -#include "GMSInterface.h" +//TODO6 #include "GMSInterface.h" #include "Station.h" -#include "StationIO.h" +//TODO6 #include "StationIO.h" #include "DiagramPrefsDialog.h" #include "ModelTreeItem.h" @@ -172,12 +172,14 @@ void StationTreeView::exportStation() QString temp_name; std::vector<std::string> temp_soil_names; temp_soil_names.push_back(""); // soil name vector needs to be initialised + /* TODO6 GMSInterface::writeBoreholeToGMS(static_cast<GeoLib::StationBorehole*>(static_cast< StationTreeModel *>( model())->stationFromIndex(index, temp_name)), fileName.toStdString(), temp_soil_names); + */ } } diff --git a/Gui/VtkAct/VtkCustomInteractorStyle.cpp b/Gui/VtkAct/VtkCustomInteractorStyle.cpp index 34cfc3397fa139646355fe69b0db81f2dad6591a..f2226e3938ae597a59975e7450dbcf214b8a47b0 100644 --- a/Gui/VtkAct/VtkCustomInteractorStyle.cpp +++ b/Gui/VtkAct/VtkCustomInteractorStyle.cpp @@ -179,7 +179,7 @@ void VtkCustomInteractorStyle::OnLeftButtonDown() ->GetInputConnection(0,0)->GetProducer(); VtkMeshSource* source = dynamic_cast<VtkMeshSource*>(data_set); if (source) - emit elementPicked(source->GetGrid(), picker->GetCellId()); + emit elementPicked(source->GetMesh(), picker->GetCellId()); selectedMapper->SetInputConnection(selected->GetProducerPort()); diff --git a/Gui/VtkVis/CMakeLists.txt b/Gui/VtkVis/CMakeLists.txt index 91a6c51e72acc544c783a0930791ada77f249ab9..c4a811311511acc0aed3534037a097a807b2a36e 100644 --- a/Gui/VtkVis/CMakeLists.txt +++ b/Gui/VtkVis/CMakeLists.txt @@ -137,6 +137,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/MathLib ${CMAKE_SOURCE_DIR}/FileIO ${CMAKE_SOURCE_DIR}/MeshLib + ${CMAKE_SOURCE_DIR}/OGS ${CMAKE_SOURCE_DIR}/Gui/Base ${CMAKE_SOURCE_DIR}/Gui/DataView ${CMAKE_BINARY_DIR}/Gui/DataView diff --git a/Gui/VtkVis/VtkConditionSource.cpp b/Gui/VtkVis/VtkConditionSource.cpp index c5771637341cf84d94ad87bc0858f05d2e4ce8ce..74383b4b09f62ec577fccd3103ae35ac7f7d12e7 100644 --- a/Gui/VtkVis/VtkConditionSource.cpp +++ b/Gui/VtkVis/VtkConditionSource.cpp @@ -135,7 +135,7 @@ int VtkConditionSource::RequestData( vtkInformation* request, vtkIdType vtk_id = static_cast<vtkIdType>(id); */ const GeoLib::Point* pnt = static_cast<const GeoLib::Point*>((*_cond_vec)[n]->getGeoObj()); - newPoints->InsertNextPoint(pnt->getData()); + newPoints->InsertNextPoint(pnt->getCoords()); newVerts->InsertNextCell(1, &pnt_id); if (type == FiniteElement::CONSTANT || type == FiniteElement::CONSTANT_NEUMANN) @@ -162,7 +162,7 @@ int VtkConditionSource::RequestData( vtkInformation* request, { size_t point_index = ply->getPointID(i); - newPoints->InsertNextPoint((*_points)[point_index]->getData()); + newPoints->InsertNextPoint((*_points)[point_index]->getCoords()); newLines->InsertCellPoint(pnt_id); distypes->InsertNextValue(dis_type_value); @@ -204,7 +204,7 @@ int VtkConditionSource::RequestData( vtkInformation* request, if (point_idx_map[point_index] == -1) { point_idx_map[point_index] = pnt_id; - newPoints->InsertNextPoint((*_points)[point_index]->getData()); + newPoints->InsertNextPoint((*_points)[point_index]->getCoords()); aPolygon->GetPointIds()->SetId(j, pnt_id); distypes->InsertNextValue(dis_type_value); @@ -237,7 +237,7 @@ int VtkConditionSource::RequestData( vtkInformation* request, for (size_t i=0; i<nValues; i++) { //vtkIdType pid = newPoints->InsertNextPoint((*_points)[dis_nodes[i]]->getData()); - vtkIdType pid = newPoints->InsertNextPoint((*_points)[i]->getData()); + vtkIdType pid = newPoints->InsertNextPoint((*_points)[i]->getCoords()); newVerts->InsertNextCell(1, &pid); scalars->InsertNextValue(dis_values[i]); distypes->InsertNextValue(dis_type_value); diff --git a/Gui/VtkVis/VtkMeshConverter.cpp b/Gui/VtkVis/VtkMeshConverter.cpp index 7455a035c526edac76ae3a654b07666a2afe618e..32a961e62f9800a08d6e52b6896c9502dd98173b 100644 --- a/Gui/VtkVis/VtkMeshConverter.cpp +++ b/Gui/VtkVis/VtkMeshConverter.cpp @@ -5,8 +5,15 @@ */ #include "VtkMeshConverter.h" - -#include "GridAdapter.h" +#include "Mesh.h" +#include "Node.h" +#include "Elements/Edge.h" +#include "Elements/Tri.h" +#include "Elements/Quad.h" +#include "Elements/Tet.h" +#include "Elements/Hex.h" +#include "Elements/Pyramid.h" +#include "Elements/Prism.h" // Conversion from Image to QuadMesh #include <vtkImageData.h> @@ -21,7 +28,7 @@ #include <vtkFloatArray.h> -GridAdapter* VtkMeshConverter::convertImgToMesh(vtkImageData* img, +MeshLib::Mesh* VtkMeshConverter::convertImgToMesh(vtkImageData* img, const double origin[3], const double scalingFactor, MshElemType::type elem_type, @@ -84,7 +91,7 @@ GridAdapter* VtkMeshConverter::convertImgToMesh(vtkImageData* img, node_idx_map[(i+2)*incHeight-1]=-1; } - GridAdapter* mesh = constructMesh(pixVal, node_idx_map, visNodes, origin, imgHeight, imgWidth, scalingFactor, elem_type, intensity_type); + MeshLib::Mesh* mesh = constructMesh(pixVal, node_idx_map, visNodes, origin, imgHeight, imgWidth, scalingFactor, elem_type, intensity_type); delete [] pixVal; delete [] visNodes; @@ -93,7 +100,7 @@ GridAdapter* VtkMeshConverter::convertImgToMesh(vtkImageData* img, return mesh; } -GridAdapter* VtkMeshConverter::convertImgToMesh(const double* img, +MeshLib::Mesh* VtkMeshConverter::convertImgToMesh(const double* img, const double origin[3], const size_t imgHeight, const size_t imgWidth, @@ -139,7 +146,7 @@ GridAdapter* VtkMeshConverter::convertImgToMesh(const double* img, node_idx_map[(i+2)*incHeight-1]=-1; } - GridAdapter* mesh = constructMesh(pixVal, node_idx_map, visNodes, origin, imgHeight, imgWidth, scalingFactor, elem_type, intensity_type); + MeshLib::Mesh* mesh = constructMesh(pixVal, node_idx_map, visNodes, origin, imgHeight, imgWidth, scalingFactor, elem_type, intensity_type); delete [] pixVal; delete [] visNodes; @@ -148,7 +155,7 @@ GridAdapter* VtkMeshConverter::convertImgToMesh(const double* img, return mesh; } -GridAdapter* VtkMeshConverter::constructMesh(const double* pixVal, +MeshLib::Mesh* VtkMeshConverter::constructMesh(const double* pixVal, int* node_idx_map, const bool* visNodes, const double origin[3], @@ -160,11 +167,13 @@ GridAdapter* VtkMeshConverter::constructMesh(const double* pixVal, { const size_t incHeight = imgHeight+1; const size_t incWidth = imgWidth+1; - GridAdapter* grid = new GridAdapter(); size_t node_idx_count(0); const double x_offset(origin[0] - scalingFactor/2.0); const double y_offset(origin[1] - scalingFactor/2.0); + std::vector<MeshLib::Node*> nodes; + std::vector<MeshLib::Element*> elements; + for (size_t i = 0; i < incWidth; i++) for (size_t j = 0; j < incHeight; j++) { @@ -179,9 +188,8 @@ GridAdapter* VtkMeshConverter::constructMesh(const double* pixVal, if (set_node) { double zValue = (intensity_type == UseIntensityAs::ELEVATION) ? pixVal[index] : 0.0; - grid->addNode(new GeoLib::Point(x_offset + (scalingFactor * j), - y_offset + (scalingFactor * i), - zValue)); + MeshLib::Node* node (new MeshLib::Node(x_offset + (scalingFactor * j), y_offset + (scalingFactor * i), zValue)); + nodes.push_back(node); node_idx_map[index] = node_idx_count; node_idx_count++; } @@ -197,105 +205,87 @@ GridAdapter* VtkMeshConverter::constructMesh(const double* pixVal, const int mat = (intensity_type != UseIntensityAs::MATERIAL) ? 0 : static_cast<int>(pixVal[index+incHeight]); if (elem_type == MshElemType::TRIANGLE) { - grid->addElement(createElement(elem_type, mat, node_idx_map[index], node_idx_map[index + 1], - node_idx_map[index + incHeight])); // upper left triangle - grid->addElement(createElement(elem_type, mat, node_idx_map[index + 1], - node_idx_map[index + incHeight + 1], - node_idx_map[index + incHeight])); // lower right triangle + MeshLib::Tri* tri1 (new MeshLib::Tri(nodes[node_idx_map[index]], nodes[node_idx_map[index + 1]], + nodes[node_idx_map[index + incHeight]], mat)); // upper left triangle + MeshLib::Tri* tri2 (new MeshLib::Tri(nodes[node_idx_map[index + 1]], nodes[node_idx_map[index + incHeight + 1]], + nodes[node_idx_map[index + incHeight]], mat)); // lower right triangle + elements.push_back(tri1); + elements.push_back(tri2); } if (elem_type == MshElemType::QUAD) { - grid->addElement(createElement(elem_type, mat, node_idx_map[index], node_idx_map[index + 1], - node_idx_map[index + incHeight + 1], - node_idx_map[index + incHeight])); + MeshLib::Quad* quad (new MeshLib::Quad(nodes[node_idx_map[index]], nodes[node_idx_map[index + 1]], + nodes[node_idx_map[index + incHeight + 1]], nodes[node_idx_map[index + incHeight]], mat)); + elements.push_back(quad); } } } - return grid; -} - -GridAdapter::Element* VtkMeshConverter::createElement(MshElemType::type t, int mat, size_t node1, size_t node2, size_t node3, size_t node4) -{ - GridAdapter::Element* elem = new GridAdapter::Element(); - elem->material = mat; - elem->type = t; - std::vector<size_t> nodes; - nodes.push_back(node1); - nodes.push_back(node2); - nodes.push_back(node3); - if (t == MshElemType::QUAD) - nodes.push_back(node4); - elem->nodes = nodes; - return elem; + return new MeshLib::Mesh("vtkImageData-Mesh", nodes, elements); } -GridAdapter* VtkMeshConverter::convertUnstructuredGrid(vtkUnstructuredGrid* grid) +MeshLib::Mesh* VtkMeshConverter::convertUnstructuredGrid(vtkUnstructuredGrid* grid) { if (!grid) return NULL; - GridAdapter* mesh = new GridAdapter(); - - const size_t nNodes = grid->GetPoints()->GetNumberOfPoints(); - const size_t nElems = grid->GetNumberOfCells(); - // set mesh nodes + const size_t nNodes = grid->GetPoints()->GetNumberOfPoints(); + std::vector<MeshLib::Node*> nodes(nNodes); double* coords = NULL; for (size_t i = 0; i < nNodes; i++) { coords = grid->GetPoints()->GetPoint(i); - mesh->addNode(new GeoLib::Point(coords[0], coords[1], coords[2])); + nodes[i] = new MeshLib::Node(coords[0], coords[1], coords[2]); } // set mesh elements - vtkCell* cell(NULL); + const size_t nElems = grid->GetNumberOfCells(); + std::vector<MeshLib::Element*> elements(nElems); vtkDataArray* scalars = grid->GetCellData()->GetScalars("MaterialIDs"); for (size_t i = 0; i < nElems; i++) { - GridAdapter::Element* elem = new GridAdapter::Element(); + MeshLib::Element* elem; + const size_t nElemNodes (grid->GetCell(i)->GetNumberOfPoints()); + std::vector<unsigned> node_ids(nElemNodes); + for (size_t j=0; j<nElemNodes; j++) + node_ids[j] = grid->GetCell(i)->GetPointId(j); + const unsigned material = (scalars) ? static_cast<int>(scalars->GetComponent(i,0)) : 0; - MshElemType::type elem_type = MshElemType::INVALID; int cell_type = grid->GetCellType(i); - switch (cell_type) { - case VTK_TRIANGLE: elem_type = MshElemType::TRIANGLE; + case VTK_TRIANGLE: + elem = new MeshLib::Tri(nodes[node_ids[0]], nodes[node_ids[1]], nodes[node_ids[2]], material); break; - case VTK_QUAD: elem_type = MshElemType::QUAD; + case VTK_QUAD: + elem = new MeshLib::Quad(nodes[node_ids[0]], nodes[node_ids[1]], nodes[node_ids[2]], nodes[node_ids[3]], material); break; - case VTK_TETRA: elem_type = MshElemType::TETRAHEDRON; + case VTK_TETRA: + elem = new MeshLib::Quad(nodes[node_ids[0]], nodes[node_ids[1]], nodes[node_ids[2]], nodes[node_ids[3]], material); break; - case VTK_HEXAHEDRON: elem_type = MshElemType::HEXAHEDRON; + case VTK_HEXAHEDRON: + elem = new MeshLib::Hex(nodes[node_ids[0]], nodes[node_ids[1]], nodes[node_ids[2]], nodes[node_ids[3]], + nodes[node_ids[4]], nodes[node_ids[5]], nodes[node_ids[6]], nodes[node_ids[7]], material); break; - case VTK_WEDGE: elem_type = MshElemType::PRISM; + case VTK_PYRAMID: + elem = new MeshLib::Pyramid(nodes[node_ids[0]], nodes[node_ids[1]], nodes[node_ids[2]], + nodes[node_ids[3]], nodes[node_ids[4]], material); break; - case VTK_PYRAMID: elem_type = MshElemType::PYRAMID; + case VTK_WEDGE: + elem = new MeshLib::Prism(nodes[node_ids[0]], nodes[node_ids[1]], nodes[node_ids[2]], + nodes[node_ids[3]], nodes[node_ids[4]], nodes[node_ids[5]], material); break; - } - - if (elem_type != MshElemType::INVALID) - { - elem->type = elem_type; - if (scalars) - elem->material = static_cast<int>(scalars->GetComponent(i,0)); - } - else - { + default: std::cout << "Error in GridAdapter::convertUnstructuredGrid() - Unknown mesh element type \"" << cell_type << "\" ..." << std::endl; return NULL; } - cell = grid->GetCell(i); - size_t nElemNodes = cell->GetNumberOfPoints(); - std::vector<size_t> nodes; - for (size_t j = 0; j < nElemNodes; j++) - nodes.push_back(cell->GetPointId(j)); - - elem->nodes = nodes; - mesh->addElement(elem); + elements[i] = elem; } - return mesh; + + return new MeshLib::Mesh("vtkUnstructuredGrid", nodes, elements); + } double VtkMeshConverter::getExistingValue(const double* img, size_t length) diff --git a/Gui/VtkVis/VtkMeshConverter.h b/Gui/VtkVis/VtkMeshConverter.h index ee748168c85afd81d1ecb60fcadf4085c1c4dd37..cc7ac38d18e8febf48d4c32c63808ad7be2fc8fb 100644 --- a/Gui/VtkVis/VtkMeshConverter.h +++ b/Gui/VtkVis/VtkMeshConverter.h @@ -7,9 +7,11 @@ #ifndef VTKMESHCONVERTER_H #define VTKMESHCONVERTER_H -//#include <utility> -//#include "MSHEnums.h" -#include "GridAdapter.h" +namespace MeshLib { + class Mesh; +} + +#include "MshEnums.h" class vtkImageData; // For conversion from Image to QuadMesh class vtkUnstructuredGrid; // For conversion vom vtk to ogs mesh @@ -35,7 +37,7 @@ public: * \param elem_type defines if elements of the new mesh should be triangles or quads (or hexes for 3D) * \param intensity_type defines how image intensities are interpreted */ - static GridAdapter* convertImgToMesh(vtkImageData* img, + static MeshLib::Mesh* convertImgToMesh(vtkImageData* img, const double origin[3], const double scalingFactor, MshElemType::type elem_type, @@ -46,7 +48,7 @@ public: * \param elem_type defines if elements of the new mesh should be triangles or quads (or hexes for 3D) * \param intensity_type defines how image intensities are interpreted */ - static GridAdapter* convertImgToMesh(const double* img, + static MeshLib::Mesh* convertImgToMesh(const double* img, const double origin[3], const size_t imgHeight, const size_t imgWidth, @@ -55,11 +57,11 @@ public: UseIntensityAs::type intensity_type); /// Converts a vtkUnstructuredGrid object to a CFEMesh - static GridAdapter* convertUnstructuredGrid(vtkUnstructuredGrid* grid); + static MeshLib::Mesh* convertUnstructuredGrid(vtkUnstructuredGrid* grid); private: /// Does the actual mesh generation based on the data given to the public methods. - static GridAdapter* constructMesh(const double* pixVal, + static MeshLib::Mesh* constructMesh(const double* pixVal, int* node_idx_map, const bool* visNodes, const double origin[3], @@ -69,11 +71,6 @@ private: MshElemType::type elem_type, UseIntensityAs::type intensity_type); - /// Creates a mesh element based on the given data. - static GridAdapter::Element* createElement(MshElemType::type t, int mat, - size_t node1, size_t node2, - size_t node3, size_t node4 = 0); - static double getExistingValue(const double* img, size_t length); }; diff --git a/Gui/VtkVis/VtkMeshSource.cpp b/Gui/VtkVis/VtkMeshSource.cpp index c6574d4a0fe91898ac559f7504f98920eac8e465..07a25601e3f410b7c7a70d1f13c2009c0a195f81 100644 --- a/Gui/VtkVis/VtkMeshSource.cpp +++ b/Gui/VtkVis/VtkMeshSource.cpp @@ -8,7 +8,9 @@ #include "VtkMeshSource.h" #include "Mesh.h" #include "Node.h" -#include "Element.h" +#include "Elements/Element.h" + +#include "Color.h" // ** VTK INCLUDES ** #include "vtkObjectFactory.h" @@ -56,31 +58,26 @@ void VtkMeshSource::PrintSelf( ostream& os, vtkIndent indent ) if (_grid == NULL) return; - const std::vector<GeoLib::Node*>* nodes = _grid->getNodes(); - const std::vector<MeshLib::Element*>* elems = _grid->getElements(); - if (nodes->empty() || elems->empty() ) + const std::vector<MeshLib::Node*> nodes = _grid->getNodes(); + const std::vector<MeshLib::Element*> elems = _grid->getElements(); + if (nodes.empty() || elems.empty() ) return; os << indent << "== VtkMeshSource ==" << "\n"; int i = 0; - for (std::vector<GeoLib::Point*>::const_iterator it = nodes->begin(); - it != nodes->end(); ++it) + for (std::vector<MeshLib::Node*>::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { - os << indent << "Point " << i << " (" << (*it)[0] << ", " << (*it)[1] << ", " << - (*it)[2] << ")" << std::endl; - i++; + os << indent << "Point " << i << " (" << (*it)[0] << ", " << (*it)[1] << ", " << (*it)[2] << ")" << std::endl; } i = 0; - for (std::vector<GridAdapter::Element*>::const_iterator it = elems->begin(); - it != elems->end(); ++it) + for (std::vector<MeshLib::Element*>::const_iterator it = elems.begin(); it != elems.end(); ++it) { os << indent << "Element " << i << ": "; - for (size_t t = 0; t < (*it)->nodes.size(); t++) - os << (*it)->nodes[t] << " "; + for (size_t t = 0; t < (*it)->getNNodes(); t++) + os << (*it)->getNode(t)->getID() << " "; os << std::endl; - i++; } } @@ -93,11 +90,11 @@ int VtkMeshSource::RequestData( vtkInformation* request, if (_grid == NULL) return 0; - const std::vector<GeoLib::Point*>* nodes = _grid->getNodes(); - const std::vector<GridAdapter::Element*>* elems = _grid->getElements(); + const std::vector<MeshLib::Node*> nodes = _grid->getNodes(); + const std::vector<MeshLib::Element*> elems = _grid->getElements(); - const size_t nPoints = nodes->size(); - const size_t nElems = elems->size(); + const size_t nPoints = _grid->getNNodes(); + const size_t nElems = _grid->getNElements(); if (nPoints == 0 || nElems == 0) return 0; @@ -114,7 +111,7 @@ int VtkMeshSource::RequestData( vtkInformation* request, gridPoints->Allocate(nPoints); // Generate mesh nodes for (size_t i = 0; i < nPoints; i++) - gridPoints->InsertPoint(i, (*(*nodes)[i])[0], (*(*nodes)[i])[1], (*(*nodes)[i])[2]); + gridPoints->InsertPoint(i, (*nodes[i])[0], (*nodes[i])[1], (*nodes[i])[2]); // Generate attribute vector for material groups vtkSmartPointer<vtkIntArray> materialIDs = vtkSmartPointer<vtkIntArray>::New(); @@ -126,11 +123,11 @@ int VtkMeshSource::RequestData( vtkInformation* request, for (size_t i = 0; i < nElems; i++) { int type(0); - const GridAdapter::Element* elem = (*elems)[i]; + const MeshLib::Element* elem = elems[i]; - switch (elem->type) + switch (elem->getType()) { - case MshElemType::LINE: + case MshElemType::EDGE: type = 3; break; case MshElemType::TRIANGLE: @@ -152,16 +149,16 @@ int VtkMeshSource::RequestData( vtkInformation* request, type = 14; break; default: // if none of the above can be applied - std::cout << "Error in VtkMeshSource::RequestData() - Unknown element type " << MshElemType2String(elem->type) << "." << std::endl; + std::cout << "Error in VtkMeshSource::RequestData() - Unknown element type " << MshElemType2String(elem->getType()) << "." << std::endl; return 0; } - materialIDs->InsertValue(i,(elem->material)); + materialIDs->InsertValue(i,(elem->getValue())); vtkIdList* point_ids = vtkIdList::New(); - const size_t nElemNodes (elem->nodes.size()); + const size_t nElemNodes (elem->getNNodes()); for (size_t j = 0; j < nElemNodes; j++) - point_ids->InsertNextId(elem->nodes[nElemNodes-1-j]); + point_ids->InsertNextId(elem->getNode(nElemNodes-1-j)->getID()); output->InsertNextCell(type, point_ids); } diff --git a/Gui/VtkVis/VtkMeshSource.h b/Gui/VtkVis/VtkMeshSource.h index e45a93321661d022dfad0c95c08f4ea04106be74..9f1f78ce0897e3183abc10f052cb697f01e003ae 100644 --- a/Gui/VtkVis/VtkMeshSource.h +++ b/Gui/VtkVis/VtkMeshSource.h @@ -33,10 +33,10 @@ public: const char* GetMaterialArrayName() const { return _matName; } /// Returns the base object of this grid - const MeshLib::Mesh* GetGrid() { return this->_grid; } + const MeshLib::Mesh* GetMesh() { return this->_grid; } /// Sets the grid object that should be visualized - void SetGrid(const MeshLib::Mesh* grid) { _grid = grid; } + void SetMesh(const MeshLib::Mesh* grid) { _grid = grid; } /// Prints the mesh data to an output stream. void PrintSelf(ostream& os, vtkIndent indent); diff --git a/Gui/VtkVis/VtkPointsSource.cpp b/Gui/VtkVis/VtkPointsSource.cpp index 17d91d3fbe762b6300d0e48d48d23c468c14c45a..8f753079cbc7e7c43aab6b51f04f00969a8d93f9 100644 --- a/Gui/VtkVis/VtkPointsSource.cpp +++ b/Gui/VtkVis/VtkPointsSource.cpp @@ -46,7 +46,7 @@ void VtkPointsSource::PrintSelf( ostream& os, vtkIndent indent ) for (std::vector<GeoLib::Point*>::const_iterator it = _points->begin(); it != _points->end(); ++it) { - const double* coords = (*it)->getData(); + const double* coords = (*it)->getCoords(); os << indent << "Point " << i << " (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")\n"; i++; diff --git a/Gui/VtkVis/VtkPolylinesSource.cpp b/Gui/VtkVis/VtkPolylinesSource.cpp index e58ec2ce6863b40620d901260ffa6c8a31d9ad50..b276730ceee4d8da404643db23c137b60dec1884 100644 --- a/Gui/VtkVis/VtkPolylinesSource.cpp +++ b/Gui/VtkVis/VtkPolylinesSource.cpp @@ -52,7 +52,7 @@ void VtkPolylinesSource::PrintSelf( ostream& os, vtkIndent indent ) for (int i = 0; i < numPoints; i++) { const GeoLib::Point* point = (**it)[i]; - const double* coords = point->getData(); + const double* coords = point->getCoords(); os << indent << "Point " << i << " (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")\n"; } @@ -105,7 +105,7 @@ int VtkPolylinesSource::RequestData( vtkInformation* request, for (int i = 0; i < numPoints; i++) { const GeoLib::Point* point = (*(*_polylines)[j])[i]; - const double* coords = point->getData(); + const double* coords = point->getCoords(); newPoints->InsertNextPoint(coords); } diff --git a/Gui/VtkVis/VtkStationSource.cpp b/Gui/VtkVis/VtkStationSource.cpp index 53347708fd5285e936de35a4b759ed135e5cc16d..85d77629cb7e06129da58882123d70ad00f8bf36 100644 --- a/Gui/VtkVis/VtkStationSource.cpp +++ b/Gui/VtkVis/VtkStationSource.cpp @@ -58,7 +58,7 @@ void VtkStationSource::PrintSelf( ostream& os, vtkIndent indent ) for (std::vector<GeoLib::Point*>::const_iterator it = _stations->begin(); it != _stations->end(); ++it) { - const double* coords = (*it)->getData(); + const double* coords = (*it)->getCoords(); os << indent << "Station " << i << " (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")\n"; i++; @@ -145,7 +145,7 @@ int VtkStationSource::RequestData( vtkInformation* request, for (size_t i = 1; i < nLayers; i++) { - double* pCoords = const_cast<double*>(profile[i]->getData()); + double* pCoords = const_cast<double*>(profile[i]->getCoords()); double loc[3] = { pCoords[0], pCoords[1], pCoords[2] }; newStations->InsertNextPoint(loc); station_ids->InsertNextValue(site_count); diff --git a/Gui/VtkVis/VtkSurfacesSource.cpp b/Gui/VtkVis/VtkSurfacesSource.cpp index a0447cc6882a56a0d9140d5d908f9e2fc80bd78d..1abab598b52e3c2e31e29e235542353bfb028db6 100644 --- a/Gui/VtkVis/VtkSurfacesSource.cpp +++ b/Gui/VtkVis/VtkSurfacesSource.cpp @@ -80,7 +80,7 @@ int VtkSurfacesSource::RequestData( vtkInformation* request, for (size_t i = 0; i < nPoints; i++) { - double* coords = const_cast<double*>((*surfacePoints)[i]->getData()); + double* coords = const_cast<double*>((*surfacePoints)[i]->getCoords()); newPoints->InsertNextPoint(coords); } diff --git a/Gui/VtkVis/VtkVisPipeline.cpp b/Gui/VtkVis/VtkVisPipeline.cpp index 6d02de329cefb894f8d904995ad3f6f046cddf83..6af4ac9eda09ebd7e02fd4f313a1bdf6bae7f8a6 100644 --- a/Gui/VtkVis/VtkVisPipeline.cpp +++ b/Gui/VtkVis/VtkVisPipeline.cpp @@ -14,10 +14,10 @@ //#include "Model.h" #include "ProcessModel.h" #include "GeoTreeModel.h" -#include "MeshQualityEquiAngleSkew.h" -#include "MeshQualityArea.h" -#include "MeshQualityVolume.h" -#include "MeshQualityShortestLongestRatio.h" +#include "MeshQuality/MeshQualityEquiAngleSkew.h" +#include "MeshQuality/MeshQualityArea.h" +#include "MeshQuality/MeshQualityVolume.h" +#include "MeshQuality/MeshQualityShortestLongestRatio.h" #include "MshItem.h" #include "MshModel.h" #include "StationTreeModel.h" @@ -458,7 +458,7 @@ void VtkVisPipeline::checkMeshQuality(VtkMeshSource* source, MshQualityType::typ { if (source) { - const MeshLib::CFEMesh* mesh = source->GetGrid()->getCFEMesh(); + const MeshLib::Mesh* mesh = source->GetMesh(); MeshLib::MeshQualityChecker* checker (NULL); if (t == MshQualityType::EDGERATIO) checker = new MeshLib::MeshQualityShortestLongestRatio(mesh); @@ -517,7 +517,7 @@ void VtkVisPipeline::checkMeshQuality(VtkMeshSource* source, MshQualityType::typ // *** construct and write histogram // simple suggestion: number of classes with Sturges criterion - size_t nclasses (static_cast<size_t>(1 + 3.3 * log (static_cast<float>((mesh->getElementVector()).size())))); + size_t nclasses (static_cast<size_t>(1 + 3.3 * log (static_cast<float>(mesh->getNElements())))); // bool ok; // size_t size (static_cast<size_t>(QInputDialog::getInt(NULL, "OGS-Histogram", "number of histogram classes/spins (min: 1, max: 10000)", static_cast<int>(nclasses), 1, 10000, 1, &ok))); // if (ok) ... @@ -526,7 +526,7 @@ void VtkVisPipeline::checkMeshQuality(VtkMeshSource* source, MshQualityType::typ std::ofstream out ("mesh_histogram.txt"); if (out) { out << "# histogram depicts mesh quality criterion " << MshQualityType2String(t) - << " for mesh " << source->GetGrid()->getName() << std::endl; + << " for mesh " << source->GetMesh()->getName() << std::endl; nclasses = histogram.getNrBins(); std::vector<size_t> const& bin_cnts(histogram.getBinCounts()); const double min (histogram.getMinimum()); diff --git a/Gui/VtkVis/VtkVisPipeline.h b/Gui/VtkVis/VtkVisPipeline.h index 93152b70be3900d1c58add8662aed743b0b925e8..f76030fff9e9dc82c48e5377497ea79a59821b2f 100644 --- a/Gui/VtkVis/VtkVisPipeline.h +++ b/Gui/VtkVis/VtkVisPipeline.h @@ -9,7 +9,7 @@ // ** INCLUDES ** #include "Color.h" -#include "Configure.h" +//TODO6 #include "Configure.h" #include "FEMCondition.h" #include "GeoType.h" #include "MSHEnums.h" diff --git a/Gui/VtkVis/VtkVisPipelineItem.h b/Gui/VtkVis/VtkVisPipelineItem.h index dc35c1ff980226a123a07645d8da64cddec9a7ca..f645acb7121a841d991685cbcb231531000fdf60 100644 --- a/Gui/VtkVis/VtkVisPipelineItem.h +++ b/Gui/VtkVis/VtkVisPipelineItem.h @@ -8,7 +8,7 @@ #define VTKVISPIPELINEITEM_H // ** INCLUDES ** -#include "Configure.h" +//TODO6 #include "Configure.h" #include "TreeItem.h" #include <QList> diff --git a/Gui/VtkVis/VtkVisPipelineView.cpp b/Gui/VtkVis/VtkVisPipelineView.cpp index edbf601c73b26f790e0ca591f1c70d96ef6a1a29..b28eaddb98cb44f14f90d4375fdc2c952b74097f 100644 --- a/Gui/VtkVis/VtkVisPipelineView.cpp +++ b/Gui/VtkVis/VtkVisPipelineView.cpp @@ -25,8 +25,7 @@ #include <QMessageBox> //image to mesh conversion -#include "msh_mesh.h" -#include "GridAdapter.h" +#include "Mesh.h" #include "VtkGeoImageSource.h" #include <vtkImageData.h> #include "MeshFromRasterDialog.h" @@ -181,7 +180,7 @@ void VtkVisPipelineView::constructMeshFromImage(QString msh_name, MshElemType::t double spacing[3]; imageSource->GetOutput()->GetSpacing(spacing); - GridAdapter* mesh = VtkMeshConverter::convertImgToMesh(imageSource->GetOutput(), origin, spacing[0], element_type, intensity_type); + MeshLib::Mesh* mesh = VtkMeshConverter::convertImgToMesh(imageSource->GetOutput(), origin, spacing[0], element_type, intensity_type); mesh->setName(msh_name.toStdString()); emit meshAdded(mesh); } @@ -210,7 +209,7 @@ void VtkVisPipelineView::convertVTKToOGSMesh() grid = vtkUnstructuredGrid::SafeDownCast(xmlReader->GetOutput()); } } - GridAdapter* mesh = VtkMeshConverter::convertUnstructuredGrid(grid); + MeshLib::Mesh* mesh = VtkMeshConverter::convertUnstructuredGrid(grid); mesh->setName(item->data(0).toString().toStdString()); emit meshAdded(mesh); } diff --git a/Gui/VtkVis/VtkVisPipelineView.h b/Gui/VtkVis/VtkVisPipelineView.h index 652f121398c394bf4b547d567f2f43fd9d281257..ca3d454f6b6528f8401da9019c192aada48bc6cc 100644 --- a/Gui/VtkVis/VtkVisPipelineView.h +++ b/Gui/VtkVis/VtkVisPipelineView.h @@ -78,7 +78,7 @@ signals: void itemSelected(VtkVisPipelineItem*); void actorSelected(vtkProp3D*); void dataObjectSelected(vtkDataObject*); - void meshAdded(GridAdapter*); + void meshAdded(MeshLib::Mesh*); }; #endif // VTKVISPIPELINEVIEW_H diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp index cd68e6bee0765371c0eadd8c3445b452bb82f5c0..987007650ea6597136277700f60dd42b60e08f4f 100644 --- a/Gui/mainwindow.cpp +++ b/Gui/mainwindow.cpp @@ -3,7 +3,7 @@ * 4/11/2009 LB Initial implementation * */ -#include "Configure.h" +//TODO6 #include "Configure.h" #include "mainwindow.h" // models @@ -20,7 +20,7 @@ #include "ConditionWriterDialog.h" #include "DiagramPrefsDialog.h" #include "FEMConditionSetupDialog.h" -#include "OGSFileConverter.h" +//TODO6 #include "OGSFileConverter.h" #include "GMSHPrefsDialog.h" #include "LineEditDialog.h" #include "ListPropertiesDialog.h" @@ -257,7 +257,7 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) SIGNAL(elementPicked(const GridAdapter *, const size_t)), mshTabWidget->elementView, SLOT(updateView())); - connect(vtkVisTabWidget->vtkVisPipelineView, SIGNAL(meshAdded(GridAdapter*)), + connect(vtkVisTabWidget->vtkVisPipelineView, SIGNAL(meshAdded(MeshLib::Mesh*)), _meshModels, SLOT(addMesh(GridAdapter*))); // Stack the data dock widgets together @@ -567,9 +567,9 @@ void MainWindow::loadFile(const QString &fileName) //#ifndef NDEBUG // QTime myTimer; // myTimer.start(); - // std::cout << "GEOLIB_Read_GeoLib ... " << std::flush; + // std::cout << "GeoLib_Read_GeoLib ... " << std::flush; //#endif - // GEOLIB_Read_GeoLib(base); //fileName.toStdString()); + // GeoLib_Read_GeoLib(base); //fileName.toStdString()); // cout << "Nr. Points: " << gli_points_vector.size() << endl; // cout << "Nr. Lines: " << polyline_vector.size() << endl; // cout << "Nr. Surfaces: " << surface_vector.size() << endl; @@ -1341,13 +1341,13 @@ void MainWindow::showDiagramPrefsDialog() prefs->show(); } } - +/* TODO6 void MainWindow::showFileConverterDialog() { OGSFileConverter dlg; dlg.exec(); } - +*/ void MainWindow::showGeoNameDialog(const std::string &geometry_name, const GeoLib::GEOTYPE object_type, size_t id) { std::string old_name = this->_geoModels->getElementNameByID(geometry_name, object_type, id); diff --git a/Gui/mainwindow.h b/Gui/mainwindow.h index f39928a186743e7e7865ecfd0226f4de74b95b4a..378ebf8deb5b12a11a675012b81a47cfcccf112a 100644 --- a/Gui/mainwindow.h +++ b/Gui/mainwindow.h @@ -90,7 +90,7 @@ protected slots: void showDiagramPrefsDialog(); /// Calls the diagram prefs dialog from the station list (i.e. for a specific station). void showDiagramPrefsDialog(QModelIndex &index); - void showFileConverterDialog(); + //TODO6 void showFileConverterDialog(); void showLineEditDialog(const std::string &geoName); void showGMSHPrefsDialog(); void showMshQualitySelectionDialog(VtkMeshSource* mshSource); @@ -129,7 +129,7 @@ private: QString curFile; DatabaseConnection* _db; - FileFinder _fileFinder; + BaseLib::FileFinder _fileFinder; GEOModels* _geoModels; MshModel* _meshModels; ElementTreeModel* _elementModel; diff --git a/Gui/mainwindow.ui b/Gui/mainwindow.ui index 375d7f501435f867067bd03b14811458390a8845..7df37a485f4ed4550a9fcd841b7586c50b039a2f 100644 --- a/Gui/mainwindow.ui +++ b/Gui/mainwindow.ui @@ -617,22 +617,6 @@ </hint> </hints> </connection> - <connection> - <sender>actionFile_Converter</sender> - <signal>triggered()</signal> - <receiver>MainWindowClass</receiver> - <slot>showFileConverterDialog()</slot> - <hints> - <hint type="sourcelabel"> - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel"> - <x>400</x> - <y>372</y> - </hint> - </hints> - </connection> </connections> <slots> <slot>open()</slot> @@ -646,6 +630,5 @@ <slot>FEMTestStart()</slot> <slot>showDiagramPrefsDialog()</slot> <slot>about()</slot> - <slot>showFileConverterDialog()</slot> </slots> </ui> diff --git a/MeshLib/CMakeLists.txt b/MeshLib/CMakeLists.txt index dede18852dd150ff2273557b9596d7845de0407b..420cf6ea8b33a4078c4b59deaaa52ed3dccfb575 100644 --- a/MeshLib/CMakeLists.txt +++ b/MeshLib/CMakeLists.txt @@ -3,7 +3,8 @@ GET_SOURCE_FILES(SOURCES_MESHLIB) SET ( SOURCES ${SOURCES_MESHLIB}) GET_SOURCE_FILES(SOURCES_ELEMENTS Elements) -SET ( SOURCES ${SOURCES} ${SOURCES_ELEMENTS}) +GET_SOURCE_FILES(SOURCES_QUALITY MeshQuality) +SET ( SOURCES ${SOURCES} ${SOURCES_ELEMENTS} ${SOURCES_QUALITY}) # Create the library ADD_LIBRARY(MeshLib STATIC ${SOURCES}) diff --git a/MeshLib/Mesh.h b/MeshLib/Mesh.h index ac7fe4dbe82c7dac506e2381f05a19caa0762718..a019665db98fe0142b891f73f7a8c6523cf0b53e 100644 --- a/MeshLib/Mesh.h +++ b/MeshLib/Mesh.h @@ -84,6 +84,9 @@ public: */ void setEdgeLengthRange(const double &min_length, const double &max_length); + /// Changes the name of the mesh. + void setName(const std::string &name) { this->_name = name; }; + protected: /// Checks the coordinates of all mesh nodes and removes identical nodes. Elements are adapted accordingly. void makeNodesUnique(); diff --git a/MeshLib/MeshQuality/MeshQualityArea.cpp b/MeshLib/MeshQuality/MeshQualityArea.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2c32d8f6ff78d65e1f7a6bfd24746591ca8e4cd1 --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityArea.cpp @@ -0,0 +1,56 @@ +/* + * MeshQualityArea.cpp + * + * 2011/03/17 KR Initial Implementation + */ + +#include "MeshQualityArea.h" +#include "MathTools.h" + +namespace MeshLib +{ +MeshQualityArea::MeshQualityArea(Mesh const* const mesh) + : MeshQualityChecker(mesh) +{} + +void MeshQualityArea::check() +{ + // get all elements of mesh + const std::vector<MeshLib::Element*> &elements(_mesh->getElements()); + + const size_t nElems(elements.size()); + for (size_t k(0); k < nElems; k++) + { + double area(std::numeric_limits<double>::max()); + const Element* elem (elements[k]); + + if (elem->getDimension() == 1) + { + _mesh_quality_measure[k] = -1.0; + continue; + } + else if (elem->getDimension() == 2) + { + area = elem->getContent(); + if (area < sqrt(fabs(std::numeric_limits<double>::min()))) errorMsg(elem, k); + } + else { + size_t nFaces(elem->getNFaces()); + + for (size_t i = 0; i < nFaces; i++) + { + const double sub_area (elem->getFace(i)->getContent()); + + if (sub_area < sqrt(fabs(std::numeric_limits<double>::min()))) + errorMsg(elem, k); + if (sub_area < area) area = sub_area; + } + } + // update _min and _max values + if (_min > area) _min = area; + if (_max < area) _max = area; + _mesh_quality_measure[k] = area; + } +} + +} // end namespace MeshLib diff --git a/MeshLib/MeshQuality/MeshQualityArea.h b/MeshLib/MeshQuality/MeshQualityArea.h new file mode 100644 index 0000000000000000000000000000000000000000..03380819a78e29fca1b0125d19bd40b688a2e018 --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityArea.h @@ -0,0 +1,24 @@ +/* + * MeshQualityArea.h + * + * 2011/03/17 KR Initial Implementation + */ + +#ifndef MESHQUALITYAREA_H_ +#define MESHQUALITYAREA_H_ + +#include "MeshQualityChecker.h" + +namespace MeshLib +{ +class MeshQualityArea : public MeshQualityChecker +{ +public: + MeshQualityArea(Mesh const* const mesh); + virtual ~MeshQualityArea() {} + + virtual void check (); +}; +} + +#endif /* MESHQUALITYAREA_H_ */ diff --git a/MeshLib/MeshQuality/MeshQualityChecker.cpp b/MeshLib/MeshQuality/MeshQualityChecker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..55be4660465a6d1c5a4fec5219d1be0f772f4478 --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityChecker.cpp @@ -0,0 +1,58 @@ +/* + * MeshQualityChecker.cpp + * + * Created on: Dec 8, 2010 + * Author: TF + */ + +#include "MeshQualityChecker.h" +#include "Node.h" +#include "Point.h" +#include <cmath> +#include <iostream> + +namespace MeshLib +{ +MeshQualityChecker::MeshQualityChecker(Mesh const* const mesh) : + _min (-1.0), _max (-1.0), _mesh (mesh) +{ + if (_mesh) + _mesh_quality_measure.resize (_mesh->getNElements(), -1.0); +} + +BASELIB::Histogram<double> MeshQualityChecker::getHistogram (size_t nclasses) const +{ + if (nclasses == 0) { + // simple suggestion: number of classes with Sturges criterion + nclasses = static_cast<size_t>(1 + 3.3 * log (static_cast<float>((_mesh->getNElements())))); + } + + return BASELIB::Histogram<double>(getMeshQuality(), nclasses, true); +} + +void MeshQualityChecker::errorMsg (const Element* elem, size_t idx) const +{ + std::cout << "Error in MeshQualityChecker::check() - " + << "Calculated value of element is below double precision minimum." << std::endl; + std::cout << "Points of " << MshElemType2String(elem->getType()) << "-Element " << idx << ": " << std::endl; + for (size_t i(0); i < elem->getNNodes(); i++) + std::cout << "\t Node " << i << " " << GeoLib::Point((elem->getNode(i))->getCoords()) << std::endl; +} + +std::vector<double> const& +MeshQualityChecker::getMeshQuality () const +{ + return _mesh_quality_measure; +} + +double MeshQualityChecker::getMinValue() const +{ + return _min; +} + +double MeshQualityChecker::getMaxValue() const +{ + return _max; +} + +} // end namespace MeshLib diff --git a/MeshLib/MeshQuality/MeshQualityChecker.h b/MeshLib/MeshQuality/MeshQualityChecker.h new file mode 100644 index 0000000000000000000000000000000000000000..9442ac18901cdf99ff47aef29cf6570c157afcf2 --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityChecker.h @@ -0,0 +1,45 @@ +/* + * MeshQualityChecker.h + * + * Created on: Dec 8, 2010 + * Author: TF + */ + +#ifndef MESHQUALITYCHECKER_H_ +#define MESHQUALITYCHECKER_H_ + +#include <vector> + +// BaseLib +#include "Histogram.h" + +// MSH +#include "Mesh.h" +#include "Elements/Element.h" + +namespace MeshLib +{ +class MeshQualityChecker +{ +public: + MeshQualityChecker(Mesh const* const mesh); + + virtual ~MeshQualityChecker () {} + + virtual void check () = 0; + std::vector<double> const& getMeshQuality () const; + double getMinValue() const; + double getMaxValue() const; + virtual BASELIB::Histogram<double> getHistogram (size_t nclasses = 0) const; + +protected: + void errorMsg (const Element* elem, size_t idx) const; + + double _min; + double _max; + Mesh const* const _mesh; + std::vector<double> _mesh_quality_measure; +}; +} + +#endif /* MESHQUALITYCHECKER_H_ */ diff --git a/MeshLib/MeshQuality/MeshQualityEquiAngleSkew.cpp b/MeshLib/MeshQuality/MeshQualityEquiAngleSkew.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c0ea1772be8ee90780c7906452b07709c9ebe690 --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityEquiAngleSkew.cpp @@ -0,0 +1,240 @@ +/* + * MeshQualityEquiAngleSkew.cpp + * + * Created on: Mar 17, 2011 + * Author: TF + */ + +#include "MeshQualityEquiAngleSkew.h" +#include "Node.h" + +#include "MathTools.h" + +#include <cmath> + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#ifndef M_PI_2 +#define M_PI_2 1.57079632679489661923 +#endif + +namespace MeshLib +{ +MeshQualityEquiAngleSkew::MeshQualityEquiAngleSkew(Mesh const* const mesh) : + MeshQualityChecker(mesh), M_PI_THIRD (M_PI / 3.0), TWICE_M_PI (2 * M_PI) +{} + +MeshQualityEquiAngleSkew::~MeshQualityEquiAngleSkew() +{} + +void MeshQualityEquiAngleSkew::check () +{ + // get all elements of mesh + const std::vector<MeshLib::Element*>& elements(_mesh->getElements()); + const size_t nElements (_mesh->getNElements()); + + for (size_t k(0); k < nElements; k++) + { + const Element* elem (elements[k]); + switch (elem->getType()) + { + case MshElemType::EDGE: + _mesh_quality_measure[k] = -1.0; + break; + case MshElemType::TRIANGLE: + _mesh_quality_measure[k] = checkTriangle (elem); + break; + case MshElemType::QUAD: + _mesh_quality_measure[k] = checkQuad (elem); + break; + case MshElemType::TETRAHEDRON: + _mesh_quality_measure[k] = checkTetrahedron (elem); + break; + case MshElemType::HEXAHEDRON: + _mesh_quality_measure[k] = checkHexahedron (elem); + break; + case MshElemType::PRISM: + _mesh_quality_measure[k] = checkPrism (elem); + break; + default: + break; + } + } +} + +double MeshQualityEquiAngleSkew::checkTriangle (Element const* const elem) const +{ + double const* const node0 (elem->getNode(0)->getCoords()); + double const* const node1 (elem->getNode(1)->getCoords()); + double const* const node2 (elem->getNode(2)->getCoords()); + + double min_angle (M_PI_2), max_angle (0.0); + getMinMaxAngleFromTriangle (node0, node1, node2, min_angle, max_angle); + + return 1.0 - + std::max((max_angle - M_PI_THIRD) / (M_PI - M_PI_THIRD), + (M_PI_THIRD - min_angle) / (M_PI_THIRD)); +} + +double MeshQualityEquiAngleSkew::checkQuad (Element const* const elem) const +{ + double const* const node0 (elem->getNode(0)->getCoords()); + double const* const node1 (elem->getNode(1)->getCoords()); + double const* const node2 (elem->getNode(2)->getCoords()); + double const* const node3 (elem->getNode(3)->getCoords()); + + double min_angle (TWICE_M_PI); + double max_angle (0.0); + + getMinMaxAngleFromQuad (node0, node1, node2, node3, min_angle, max_angle); + + return 1.0 - + std::max((max_angle - M_PI_2) / (M_PI - M_PI_2), (M_PI_2 - min_angle) / (M_PI_2)); +} + +double MeshQualityEquiAngleSkew::checkTetrahedron (Element const* const elem) const +{ + double const* const node0 (elem->getNode(0)->getCoords()); + double const* const node1 (elem->getNode(1)->getCoords()); + double const* const node2 (elem->getNode(2)->getCoords()); + double const* const node3 (elem->getNode(3)->getCoords()); + + double min_angle (M_PI_2); + double max_angle (0.0); + + // first triangle (0,1,2) + getMinMaxAngleFromTriangle(node0, node1, node2, min_angle, max_angle); + // second triangle (0,1,3) + getMinMaxAngleFromTriangle(node0, node1, node3, min_angle, max_angle); + // third triangle (0,2,3) + getMinMaxAngleFromTriangle(node0, node2, node3, min_angle, max_angle); + // fourth triangle (1,2,3) + getMinMaxAngleFromTriangle(node1, node2, node3, min_angle, max_angle); + + return 1.0 - std::max((max_angle - M_PI_2) / (M_PI - M_PI_THIRD), + (M_PI_THIRD - min_angle) / (M_PI_THIRD)); +} + +double MeshQualityEquiAngleSkew::checkHexahedron (Element const* const elem) const +{ + double const* const node0 (elem->getNode(0)->getCoords()); + double const* const node1 (elem->getNode(1)->getCoords()); + double const* const node2 (elem->getNode(2)->getCoords()); + double const* const node3 (elem->getNode(3)->getCoords()); + double const* const node4 (elem->getNode(4)->getCoords()); + double const* const node5 (elem->getNode(5)->getCoords()); + double const* const node6 (elem->getNode(6)->getCoords()); + double const* const node7 (elem->getNode(7)->getCoords()); + + double min_angle (2 * M_PI); + double max_angle (0.0); + + // first surface (0,1,2,3) + getMinMaxAngleFromQuad (node0, node1, node2, node3, min_angle, max_angle); + // second surface (0,3,7,4) + getMinMaxAngleFromQuad (node0, node3, node7, node4, min_angle, max_angle); + // third surface (4,5,6,7) + getMinMaxAngleFromQuad (node4, node5, node6, node7, min_angle, max_angle); + // fourth surface (5,1,2,6) + getMinMaxAngleFromQuad (node5, node1, node2, node6, min_angle, max_angle); + // fifth surface (5,1,0,4) + getMinMaxAngleFromQuad (node5, node1, node0, node4, min_angle, max_angle); + // sixth surface (6,2,3,7) + getMinMaxAngleFromQuad (node6, node2, node3, node7, min_angle, max_angle); + + return 1.0 - + std::max((max_angle - M_PI_2) / (M_PI - M_PI_2), (M_PI_2 - min_angle) / (M_PI_2)); +} + +double MeshQualityEquiAngleSkew::checkPrism (Element const* const elem) const +{ + double const* const node0 (elem->getNode(0)->getCoords()); + double const* const node1 (elem->getNode(1)->getCoords()); + double const* const node2 (elem->getNode(2)->getCoords()); + double const* const node3 (elem->getNode(3)->getCoords()); + double const* const node4 (elem->getNode(4)->getCoords()); + double const* const node5 (elem->getNode(5)->getCoords()); + + double min_angle_tri (2 * M_PI); + double max_angle_tri (0.0); + + // first triangle (0,1,2) + getMinMaxAngleFromTriangle (node0, node1, node2, min_angle_tri, max_angle_tri); + // second surface (3,4,5) + getMinMaxAngleFromTriangle (node3, node4, node5, min_angle_tri, max_angle_tri); + + double tri_criterion (1.0 - std::max((max_angle_tri - M_PI_2) / (M_PI - M_PI_THIRD), + (M_PI_THIRD - min_angle_tri) / (M_PI_THIRD))); + + double min_angle_quad (2 * M_PI); + double max_angle_quad (0.0); + // surface (0,3,4,1) + getMinMaxAngleFromQuad (node0, node3, node4, node1, min_angle_quad, max_angle_quad); + // surface (2,5,3,0) + getMinMaxAngleFromQuad (node2, node5, node3, node0, min_angle_quad, max_angle_quad); + // surface (1,2,5,4) + getMinMaxAngleFromQuad (node1, node2, node5, node4, min_angle_quad, max_angle_quad); + + double quad_criterion (1.0 - std::max((max_angle_quad - M_PI_2) / (M_PI - M_PI_2), + (M_PI_2 - min_angle_quad) / (M_PI_2))); + + return std::min (tri_criterion, quad_criterion); +} + +void MeshQualityEquiAngleSkew::getMinMaxAngleFromQuad ( + double const* const n0, double const* const n1, + double const* const n2, double const* const n3, + double &min_angle, double &max_angle) const +{ + double angle (MathLib::getAngle (n3, n0, n1)); + if (angle < min_angle) + min_angle = angle; + if (angle > max_angle) + max_angle = angle; + + angle = MathLib::getAngle (n0, n1, n2); + if (angle < min_angle) + min_angle = angle; + if (angle > max_angle) + max_angle = angle; + + angle = MathLib::getAngle (n1, n2, n3); + if (angle < min_angle) + min_angle = angle; + if (angle > max_angle) + max_angle = angle; + + angle = MathLib::getAngle (n2, n3, n0); + if (angle < min_angle) + min_angle = angle; + if (angle > max_angle) + max_angle = angle; +} + +void MeshQualityEquiAngleSkew::getMinMaxAngleFromTriangle(double const* const n0, + double const* const n1, + double const* const n2, + double &min_angle, + double &max_angle) const +{ + double angle (MathLib::getAngle (n2, n0, n1)); + if (angle < min_angle) + min_angle = angle; + if (angle > max_angle) + max_angle = angle; + + angle = MathLib::getAngle (n0, n1, n2); + if (angle < min_angle) + min_angle = angle; + if (angle > max_angle) + max_angle = angle; + + angle = MathLib::getAngle (n1, n2, n0); + if (angle < min_angle) + min_angle = angle; + if (angle > max_angle) + max_angle = angle; +} +} // end namespace MeshLib diff --git a/MeshLib/MeshQuality/MeshQualityEquiAngleSkew.h b/MeshLib/MeshQuality/MeshQualityEquiAngleSkew.h new file mode 100644 index 0000000000000000000000000000000000000000..7a0c704c4c59c643d4d4cec07b82912834b3b6e5 --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityEquiAngleSkew.h @@ -0,0 +1,42 @@ +/* + * MeshQualityEquiAngleSkew.h + * + * Created on: Mar 17, 2011 + * Author: TF + */ + +#ifndef MESHQUALITYEQUIANGLESKEW_H_ +#define MESHQUALITYEQUIANGLESKEW_H_ + +#include "MeshQualityChecker.h" + +namespace MeshLib +{ +class MeshQualityEquiAngleSkew : public MeshLib::MeshQualityChecker +{ +public: + MeshQualityEquiAngleSkew(Mesh const* const mesh); + virtual ~MeshQualityEquiAngleSkew(); + + virtual void check (); + +private: + double checkTriangle(Element const* const elem) const; + double checkQuad(Element const* const elem) const; + double checkTetrahedron(Element const* const elem) const; + double checkHexahedron(Element const* const elem) const; + double checkPrism (Element const* const elem) const; + void getMinMaxAngleFromQuad(double const* const n0, + double const* const n1, double const* const n2, + double const* const n3, double &min_angle, + double &max_angle) const; + void getMinMaxAngleFromTriangle(double const* const n0, + double const* const n1, double const* const n2, + double &min_angle, double &max_angle) const; + + const double M_PI_THIRD; + const double TWICE_M_PI; +}; +} + +#endif /* MESHQUALITYEQUIANGLESKEW_H_ */ diff --git a/MeshLib/MeshQuality/MeshQualityShortestLongestRatio.cpp b/MeshLib/MeshQuality/MeshQualityShortestLongestRatio.cpp new file mode 100644 index 0000000000000000000000000000000000000000..786c68fe269070dc1f6cccfc9ada2eabc2ecb24a --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityShortestLongestRatio.cpp @@ -0,0 +1,183 @@ +/* + * MeshQualityShortestLongestRatio.cpp + * + * Created on: Mar 3, 2011 + * Author: TF + */ + +#include "MeshQualityShortestLongestRatio.h" +#include "Node.h" +#include "MathTools.h" + +namespace MeshLib +{ +MeshQualityShortestLongestRatio::MeshQualityShortestLongestRatio( + Mesh const* const mesh) : + MeshQualityChecker(mesh) +{ +} + +void MeshQualityShortestLongestRatio::check() +{ + // get all elements of mesh + const std::vector<MeshLib::Element*>& elements(_mesh->getElements()); + const size_t nElements (_mesh->getNElements()); + for (size_t k(0); k < nElements; k++) + { + const Element* elem (elements[k]); + switch (elem->getType()) + { + case MshElemType::EDGE: + _mesh_quality_measure[k] = 1.0; + break; + case MshElemType::TRIANGLE: { + _mesh_quality_measure[k] = checkTriangle(elem->getNode(0), elem->getNode(1), elem->getNode(2)); + break; + } + case MshElemType::QUAD: { + _mesh_quality_measure[k] = checkQuad(elem->getNode(0), elem->getNode(1), elem->getNode(2), elem->getNode(3)); + break; + } + case MshElemType::TETRAHEDRON: { + _mesh_quality_measure[k] = checkTetrahedron(elem->getNode(0), elem->getNode(1), elem->getNode(2), elem->getNode(3)); + break; + } + case MshElemType::PRISM: { + std::vector<const GeoLib::Point*> pnts; + for (size_t j(0); j < 6; j++) + pnts.push_back(elem->getNode(j)); + _mesh_quality_measure[k] = checkPrism(pnts); + break; + } + case MshElemType::HEXAHEDRON: { + std::vector<const GeoLib::Point*> pnts; + for (size_t j(0); j < 8; j++) + pnts.push_back(elem->getNode(j)); + _mesh_quality_measure[k] = checkHexahedron(pnts); + break; + } + default: + std::cout << "MeshQualityShortestLongestRatio::check () check for element type " + << MshElemType2String(elem->getType()) + << " not implemented" << std::endl; + } + } +} + +double MeshQualityShortestLongestRatio::checkTriangle (GeoLib::Point const* const a, + GeoLib::Point const* const b, + GeoLib::Point const* const c) const +{ + double len0 (sqrt(MathLib::sqrDist (b,a))); + double len1 (sqrt(MathLib::sqrDist (b,c))); + double len2 (sqrt(MathLib::sqrDist (a,c))); + + if (len0 < len1 && len0 < len2) + { + if (len1 < len2) + return len0 / len2; + else + return len0 / len1; + } + else + { + if (len1 < len2) + { + if (len0 < len2) + return len1 / len2; + else + return len1 / len0; + } + else + { + if (len0 < len1) + return len2 / len1; + else + return len2 / len0; + } + } +} + +double MeshQualityShortestLongestRatio::checkQuad (GeoLib::Point const* const a, + GeoLib::Point const* const b, + GeoLib::Point const* const c, + GeoLib::Point const* const d) const +{ + double sqr_lengths[4] = {MathLib::sqrDist (b,a), + MathLib::sqrDist (c,b), + MathLib::sqrDist (d,c), + MathLib::sqrDist (a,d)}; + + // sort lengths - since this is a very small array we use bubble sort + for (size_t i(0); i < 4; i++) + for (size_t j(i + 1); j < 4; j++) + if (sqr_lengths[i] >= sqr_lengths[j]) + std::swap (sqr_lengths[i], sqr_lengths[j]); + + return sqrt(sqr_lengths[0]) / sqrt(sqr_lengths[3]); +} + +double MeshQualityShortestLongestRatio::checkTetrahedron (GeoLib::Point const* const a, + GeoLib::Point const* const b, + GeoLib::Point const* const c, + GeoLib::Point const* const d) const +{ + double sqr_lengths[6] = {MathLib::sqrDist (b,a), MathLib::sqrDist (c,b), + MathLib::sqrDist (c,a), MathLib::sqrDist (a,d), + MathLib::sqrDist (b,d), MathLib::sqrDist (c,d)}; + + // sort lengths - since this is a very small array we use bubble sort + for (size_t i(0); i < 6; i++) + for (size_t j(i + 1); j < 6; j++) + if (sqr_lengths[i] >= sqr_lengths[j]) + std::swap (sqr_lengths[i], sqr_lengths[j]); + + return sqrt(sqr_lengths[0]) / sqrt(sqr_lengths[5]); +} + +double MeshQualityShortestLongestRatio::checkPrism (std::vector<const GeoLib::Point*> const & pnts) const +{ + double sqr_lengths[9] = {MathLib::sqrDist (pnts[0],pnts[1]), + MathLib::sqrDist (pnts[1],pnts[2]), + MathLib::sqrDist (pnts[2],pnts[0]), + MathLib::sqrDist (pnts[3],pnts[4]), + MathLib::sqrDist (pnts[4],pnts[5]), + MathLib::sqrDist (pnts[5],pnts[3]), + MathLib::sqrDist (pnts[0],pnts[3]), + MathLib::sqrDist (pnts[1],pnts[4]), + MathLib::sqrDist (pnts[2],pnts[5])}; + + // sort lengths - since this is a very small array we use bubble sort + for (size_t i(0); i < 9; i++) + for (size_t j(i + 1); j < 9; j++) + if (sqr_lengths[i] >= sqr_lengths[j]) + std::swap (sqr_lengths[i], sqr_lengths[j]); + + return sqrt(sqr_lengths[0]) / sqrt(sqr_lengths[8]); +} + +double MeshQualityShortestLongestRatio::checkHexahedron (std::vector<const GeoLib::Point*> const & pnts) +const +{ + double sqr_lengths[12] = {MathLib::sqrDist (pnts[0],pnts[1]), + MathLib::sqrDist (pnts[1],pnts[2]), + MathLib::sqrDist (pnts[2],pnts[3]), + MathLib::sqrDist (pnts[3],pnts[0]), + MathLib::sqrDist (pnts[4],pnts[5]), + MathLib::sqrDist (pnts[5],pnts[6]), + MathLib::sqrDist (pnts[6],pnts[7]), + MathLib::sqrDist (pnts[7],pnts[4]), + MathLib::sqrDist (pnts[0],pnts[4]), + MathLib::sqrDist (pnts[1],pnts[5]), + MathLib::sqrDist (pnts[2],pnts[6]), + MathLib::sqrDist (pnts[3],pnts[7])}; + + // sort lengths - since this is a very small array we use bubble sort + for (size_t i(0); i < 12; i++) + for (size_t j(i + 1); j < 12; j++) + if (sqr_lengths[i] >= sqr_lengths[j]) + std::swap (sqr_lengths[i], sqr_lengths[j]); + + return sqrt(sqr_lengths[0]) / sqrt(sqr_lengths[11]); +} +} // end namespace MeshLib diff --git a/MeshLib/MeshQuality/MeshQualityShortestLongestRatio.h b/MeshLib/MeshQuality/MeshQualityShortestLongestRatio.h new file mode 100644 index 0000000000000000000000000000000000000000..f8c744078b8462ab0c029dec6a984419dbb1348a --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityShortestLongestRatio.h @@ -0,0 +1,41 @@ +/* + * MeshQualityShortestLongestRatio.h + * + * Created on: Mar 3, 2011 + * Author: TF + */ + +#ifndef MESHQUALITYSHORTESTLONGESTRATIO_H_ +#define MESHQUALITYSHORTESTLONGESTRATIO_H_ + +#include "MeshQualityChecker.h" +#include "Point.h" + +namespace MeshLib +{ +class MeshQualityShortestLongestRatio : public MeshQualityChecker +{ +public: + MeshQualityShortestLongestRatio(Mesh const* const mesh); + virtual ~MeshQualityShortestLongestRatio () {} + + virtual void check (); + +private: + double checkTriangle (GeoLib::Point const* const a, + GeoLib::Point const* const b, + GeoLib::Point const* const c) const; + double checkQuad (GeoLib::Point const* const a, + GeoLib::Point const* const b, + GeoLib::Point const* const c, + GeoLib::Point const* const d) const; + double checkTetrahedron (GeoLib::Point const* const a, + GeoLib::Point const* const b, + GeoLib::Point const* const c, + GeoLib::Point const* const d) const; + double checkPrism (std::vector<const GeoLib::Point*> const & pnts) const; + double checkHexahedron (std::vector<const GeoLib::Point*> const & pnts) const; +}; +} + +#endif /* MESHQUALITYSHORTESTLONGESTRATIO_H_ */ diff --git a/MeshLib/MeshQuality/MeshQualityVolume.cpp b/MeshLib/MeshQuality/MeshQualityVolume.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6fc4db0a2b0136e295cbc348f013a426bdd3399 --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityVolume.cpp @@ -0,0 +1,57 @@ +/* + * MeshQualityVolume.cpp + * + * Created on: Mar 3, 2011 + * Author: TF + */ + +#include "MeshQualityVolume.h" + +#include <iostream> + +namespace MeshLib +{ + +MeshQualityVolume::MeshQualityVolume(Mesh const* const mesh) : + MeshQualityChecker(mesh) +{ } + +void MeshQualityVolume::check() +{ + // get all elements of mesh + const std::vector<MeshLib::Element*>& elements(_mesh->getElements()); + + size_t error_count(0); + size_t nElements (_mesh->getNElements()); + + for (size_t k(0); k < nElements; k++) + { + const Element* elem (elements[k]); + MshElemType::type elem_type (elem->getType()); + if (elem_type == MshElemType::EDGE + || elem_type == MshElemType::TRIANGLE + || elem_type == MshElemType::QUAD) + { + _mesh_quality_measure[k] = -1.0; + continue; + } + + double volume (elem->getContent()); + if (volume > _max) + _max = volume; + if (volume < sqrt(fabs(std::numeric_limits<double>::min()))) { + errorMsg(elem, k); + error_count++; + } else if (volume < _min) + _min = volume; + _mesh_quality_measure[k] = volume; + } + + std::cout << "MeshQualityVolume::check() minimum: " << _min + << ", max_volume: " << _max << std::endl; + if (error_count > 0) + std::cout << "Warning: " << error_count << " elements with zero volume found." << + std::endl; +} + +} // end namespace MeshLib diff --git a/MeshLib/MeshQuality/MeshQualityVolume.h b/MeshLib/MeshQuality/MeshQualityVolume.h new file mode 100644 index 0000000000000000000000000000000000000000..f54368499cbd7b1d208ebd617f3fff980fe11874 --- /dev/null +++ b/MeshLib/MeshQuality/MeshQualityVolume.h @@ -0,0 +1,23 @@ +/* + * Created on: Mar 3, 2011 + * Author: TF + */ + +#ifndef MESHQUALITYVOLUME_H_ +#define MESHQUALITYVOLUME_H_ + +#include "MeshQualityChecker.h" + +namespace MeshLib +{ +class MeshQualityVolume : public MeshQualityChecker +{ +public: + MeshQualityVolume(Mesh const* const mesh); + virtual ~MeshQualityVolume() {} + + virtual void check (); +}; +} + +#endif /* MESHQUALITYVOLUME_H_ */ diff --git a/OGS/ProjectData.cpp b/OGS/ProjectData.cpp index 42f5ea3187435834b3b222ff236c268e1ad82c27..b5b9f1b1c5e49c749d2871d93485da7be6f1bab6 100644 --- a/OGS/ProjectData.cpp +++ b/OGS/ProjectData.cpp @@ -13,6 +13,8 @@ #include "ProjectData.h" #include "StringTools.h" +#include "Mesh.h" + ProjectData::ProjectData() : _geoObjects (NULL) {} @@ -20,35 +22,46 @@ ProjectData::ProjectData() ProjectData::~ProjectData() { delete _geoObjects; - for (std::map<std::string, MeshLib::Mesh*>::iterator it = _msh_vec.begin(); - it != _msh_vec.end(); ++it) - delete it->second; + for (std::vector<MeshLib::Mesh*>::iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) + delete *it; size_t nCond (_cond_vec.size()); for (size_t i = 0; i < nCond; i++) delete _cond_vec[i]; } -void ProjectData::addMesh(MeshLib::Mesh* mesh, std::string &name) +void ProjectData::addMesh(MeshLib::Mesh* mesh) { + std::string name = mesh->getName(); isUniqueMeshName(name); - _msh_vec[name] = mesh; + mesh->setName(name); + _msh_vec.push_back(mesh); } const MeshLib::Mesh* ProjectData::getMesh(const std::string &name) const { - return _msh_vec.find(name)->second; + for (std::vector<MeshLib::Mesh*>::const_iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) + if (name.compare((*it)->getName()) == 0) + return *it; + return NULL; } bool ProjectData::removeMesh(const std::string &name) { - delete _msh_vec[name]; - size_t result = _msh_vec.erase(name); - return result > 0; + for (std::vector<MeshLib::Mesh*>::const_iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) + if (name.compare((*it)->getName()) == 0) + { + delete *it; + _msh_vec.erase(it); + return true; + } + return false; } bool ProjectData::meshExists(const std::string &name) { - if (_msh_vec.count(name)>0) return true; + for (std::vector<MeshLib::Mesh*>::const_iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) + if (name.compare((*it)->getName()) == 0) + return true; return false; } diff --git a/OGS/ProjectData.h b/OGS/ProjectData.h index e9dc34aa926f3a3d383cdd0c333faf6d31611ab7..354c148a2c46969cd7e75de525d76e312c67f966 100644 --- a/OGS/ProjectData.h +++ b/OGS/ProjectData.h @@ -16,7 +16,10 @@ #include "FEMCondition.h" #include "FEMEnums.h" #include "GEOObjects.h" -#include "Mesh.h" + +namespace MeshLib { + class Mesh; +} /** * The ProjectData Object contains all the data needed for a certain project, i.e. all @@ -45,13 +48,13 @@ public: //** Mesh functionality **// /// Adds a new mesh - virtual void addMesh(MeshLib::Mesh* mesh, std::string &name); + virtual void addMesh(MeshLib::Mesh* mesh); /// Returns the mesh with the given name. const MeshLib::Mesh* getMesh(const std::string &name) const; /// Returns all the meshes with their respective names - const std::map<std::string, MeshLib::Mesh*>& getMeshObjects() const { return _msh_vec; } + const std::vector<MeshLib::Mesh*>& getMeshObjects() const { return _msh_vec; } /// Removes the mesh with the given name. virtual bool removeMesh(const std::string &name); @@ -102,7 +105,7 @@ public: private: GeoLib::GEOObjects* _geoObjects; - std::map<std::string, MeshLib::Mesh*> _msh_vec; + std::vector<MeshLib::Mesh*> _msh_vec; std::vector<ProcessInfo*> _pcs_vec; std::vector<FEMCondition*> _cond_vec; }; diff --git a/Utils/FileConverter/OGSFileConverter/CMakeLists.txt b/Utils/FileConverter/OGSFileConverter/CMakeLists.txt deleted file mode 100644 index 0e5aca298713f70d0bdc9658f9ee7feb72e32ad6..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/CMakeLists.txt +++ /dev/null @@ -1,89 +0,0 @@ -# Specify minimum CMake version -cmake_minimum_required(VERSION 2.6) - -# Project name -project( OGSFileConverter ) - -# Source files -SET( SOURCES - ConversionTools.cpp - FileListDialog.cpp - OGSFileConverter.cpp -) - -# Moc Header files -SET( MOC_HEADERS - ConversionTools.h - FileListDialog.h - OGSFileConverter.h -) - -# Header files -SET( HEADERS - -) - -# UI files -SET( UIS - FileList.ui - OGSFileConverter.ui -) - -# Run Qts user interface compiler uic on .ui files -QT4_WRAP_UI( UI_HEADERS ${UIS} ) - -# Run Qts meta object compiler moc on header files -QT4_WRAP_CPP( MOC_SOURCES ${MOC_HEADERS} ) - -# Include the headers which are generated by uic and moc -# and include additional header -INCLUDE_DIRECTORIES( - ${CMAKE_BINARY_DIR}/UTL/FileConverter/OGSFileConverter - ${CMAKE_SOURCE_DIR}/Utils/FileConverter/OGSFileConverter - ${CMAKE_SOURCE_DIR}/BaseLib - ${CMAKE_SOURCE_DIR}/FemLib - ${CMAKE_SOURCE_DIR}/FileIO - ${CMAKE_SOURCE_DIR}/GeoLib - ${CMAKE_SOURCE_DIR}/MathLib - ${CMAKE_SOURCE_DIR}/MeshLib - ${CMAKE_SOURCE_DIR}/Gui/Base - ${CMAKE_SOURCE_DIR}/Gui/DataView -) - -# Put moc files in a project folder -SOURCE_GROUP("UI Files" REGULAR_EXPRESSION "\\w*\\.ui") -SOURCE_GROUP("Moc Files" REGULAR_EXPRESSION "moc_.*") - -# Create the library -ADD_EXECUTABLE( OGSFileConverter - main.cpp - ${SOURCES} - ${HEADERS} - ${MOC_HEADERS} - ${MOC_SOURCES} - ${UIS} -) - -TARGET_LINK_LIBRARIES( OGSFileConverter - ${QT_LIBRARIES} - FileIO - GEO - FEM - QtDataView -) - -# Find installed Qt4 libraries and headers -find_package( Qt4 REQUIRED ) - -# Adds useful macros and variables -# this is needed to correctly link the qt libraries through target_link_libraries -INCLUDE( ${QT_USE_FILE} ) - -# Set build configuration types -# "RelWithDebInfo" and "MinSizeRelease" can be added here -set ( CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE TYPE INTERNAL FORCE ) - -# Set build directories -# Binaries are created in /bin and libraries in /lib -set( EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin ) -set( LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib ) diff --git a/Utils/FileConverter/OGSFileConverter/ConversionTools.cpp b/Utils/FileConverter/OGSFileConverter/ConversionTools.cpp deleted file mode 100644 index 7465d097d29af01fcd3f7ae034a7118144f2e3a2..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/ConversionTools.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/** - * \file ConversionTools.cpp - * 2012/04/11 KR Initial implementation - */ - -#include "ConversionTools.h" -#include "ProjectData.h" - -#include <iostream> -#include <fstream> - -// FEM Conditions -#include "BoundaryCondition.h" -#include "InitialCondition.h" -#include "SourceTerm.h" -#include "rf_bc_new.h" -#include "rf_ic_new.h" -#include "rf_st_new.h" -#include "FEMIO/BoundaryConditionIO.h" - -// Qt -#include <QFileInfo> - -void ConversionTools::getFEMConditionsFromASCIIFile(const QString &file_name, std::vector<FEMCondition*> &conditions) -{ - std::ifstream in(file_name.toStdString().data(), std::ios::in); - if (!in.good()) - { - std::cout << "Error in readASCIIConditionFile() - Could not open file." << std::endl; - return; - } - - QFileInfo fi(file_name); - GeoLib::GEOObjects geo_objects; - std::string geo_name(fi.baseName().toStdString() + ".gli"); - std::string file_path(fi.absolutePath().toStdString() + "/"); - FEMCondition::CondType type(FEMCondition::UNSPECIFIED); - std::string cond_tag(""); - if (fi.suffix().toLower() == "bc") - { - cond_tag = "#BOUNDARY_CONDITION"; - type = FEMCondition::BOUNDARY_CONDITION; - } - else if (fi.suffix().toLower() == "ic") - { - cond_tag = "#INITIAL_CONDITION"; - type = FEMCondition::INITIAL_CONDITION; - } - else if (fi.suffix().toLower() == "st") - { - cond_tag = "#SOURCE_TERM"; - type = FEMCondition::SOURCE_TERM; - } - - std::cout << "Reading " << fi.fileName().toStdString() << "..." << std::endl; - while (!in.eof()) - { - char buffer[256]; - in.getline(buffer, 256); - std::string line(buffer); - if (line.find("#STOP") != std::string::npos) - return; - if (line.find(cond_tag) != std::string::npos) - { - std::ios::pos_type position = in.tellg(); - if (type == FEMCondition::BOUNDARY_CONDITION) position = readBoundaryCondition(conditions, in, file_path, geo_objects, geo_name); - else if (type == FEMCondition::INITIAL_CONDITION) position = readInitialCondition(conditions, in, file_path, geo_objects, geo_name); - else if (type == FEMCondition::SOURCE_TERM) position = readSourceTerm(conditions, in, file_path, geo_objects, geo_name); - in.seekg(position, std::ios::beg); - } - } -} - -std::ios::pos_type ConversionTools::readBoundaryCondition(std::vector<FEMCondition*> &conditions, std::ifstream &in, const std::string &file_path, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name) -{ - Q_UNUSED(file_path); - CBoundaryCondition* bc(new CBoundaryCondition()); - bool valid; - std::ios::pos_type position = bc->Read(&in, geo_objects, geo_name, valid); - conditions.push_back(new BoundaryCondition(*bc, geo_name)); - delete bc; - return position; -} - -std::ios::pos_type ConversionTools::readInitialCondition(std::vector<FEMCondition*> &conditions, std::ifstream &in, const std::string &file_path, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name) -{ - Q_UNUSED(file_path); - CInitialCondition* ic = new CInitialCondition(); - std::ios::pos_type position = ic->Read(&in, geo_objects, geo_name); - conditions.push_back(new InitialCondition(*ic, geo_name)); - delete ic; - return position; -} - -std::ios::pos_type ConversionTools::readSourceTerm(std::vector<FEMCondition*> &conditions, std::ifstream &in, const std::string &file_path, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name) -{ - CSourceTerm* st(new CSourceTerm()); - std::ios::pos_type position = st->Read(&in, geo_objects, geo_name); - conditions.push_back(new SourceTerm(*st, geo_name)); - - if (st->getProcessDistributionType() == FiniteElement::DIRECT) - conditions[conditions.size()-1]->setDisValues( ConversionTools::getDirectNodeValues(file_path + st->fname) ); - - delete st; - return position; -} - -std::vector< std::pair<size_t, double> > ConversionTools::getDirectNodeValues(std::string file_name) -{ - std::vector< std::pair<size_t, double> > node_values; - SourceTerm::getDirectNodeValues(file_name, node_values); - return node_values; -} - -int ConversionTools::writeDirectValues(const FEMCondition &condition, const std::string &direct_value_file) -{ - std::ofstream out(direct_value_file.c_str()); - if (!out.good()) - { - std::cout << "Error in writeDirectValues() - Could not open file." << std::endl; - return 0; - } - - const std::vector<size_t> dis_nodes = condition.getDisNodes(); - const std::vector<double> dis_values = condition.getDisValues(); - const size_t nValues(dis_nodes.size()); - - if (nValues != dis_values.size() || nValues==0) - return 0; - - for (size_t i=0; i<nValues; i++) - out << dis_nodes[i] << "\t" << dis_values[i] << std::endl; - - return 1; -} - diff --git a/Utils/FileConverter/OGSFileConverter/ConversionTools.h b/Utils/FileConverter/OGSFileConverter/ConversionTools.h deleted file mode 100644 index 66c2910450849f3e30c969bb02668b81c9022b7c..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/ConversionTools.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * \file ConversionTools.h - * 2012/04/11 KR Initial implementation - */ - -#ifndef CONVERSIONTOOLS_H -#define CONVERSIONTOOLS_H - -#include <vector> -#include <QString> - -#include "FEMCondition.h" - -class ConversionTools -{ -public: - static void getFEMConditionsFromASCIIFile(const QString &file_name, std::vector<FEMCondition*> &conditions); - static int writeDirectValues(const FEMCondition &condition, const std::string &direct_value_file); - -private: - static std::ios::pos_type readBoundaryCondition(std::vector<FEMCondition*> &conditions, std::ifstream &in, const std::string &file_path, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name); - static std::ios::pos_type readInitialCondition (std::vector<FEMCondition*> &conditions, std::ifstream &in, const std::string &file_path, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name); - static std::ios::pos_type readSourceTerm (std::vector<FEMCondition*> &conditions, std::ifstream &in, const std::string &file_path, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name); - static std::vector< std::pair<size_t, double> > getDirectNodeValues(std::string file_name); - -}; - -#endif //CONVERSIONTOOLS_H diff --git a/Utils/FileConverter/OGSFileConverter/FileList.ui b/Utils/FileConverter/OGSFileConverter/FileList.ui deleted file mode 100644 index 432fa3f4d47235ece24f8a9c152ea82c64a03a71..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/FileList.ui +++ /dev/null @@ -1,154 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>FileList</class> - <widget class="QDialog" name="FileList"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>FileList</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="5" column="1" colspan="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="addButton"> - <property name="minimumSize"> - <size> - <width>30</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>30</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>+</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QPushButton" name="removeButton"> - <property name="minimumSize"> - <size> - <width>30</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>30</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>-</string> - </property> - </widget> - </item> - <item row="3" column="2"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="lineEdit"/> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="saveLabel"> - <property name="text"> - <string>Save as:</string> - </property> - </widget> - </item> - <item row="4" column="2"> - <widget class="QPushButton" name="browseButton"> - <property name="minimumSize"> - <size> - <width>30</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>30</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="1" column="0" rowspan="3" colspan="2"> - <widget class="QListView" name="listView"/> - </item> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Add source files:</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>FileList</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>FileList</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/Utils/FileConverter/OGSFileConverter/FileListDialog.cpp b/Utils/FileConverter/OGSFileConverter/FileListDialog.cpp deleted file mode 100644 index 520242b0d693af48906e585cc3316124df3487da..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/FileListDialog.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/** - * \file FileListDialog.cpp - * 2012/04/04 KR Initial implementation - */ - -#include "FileListDialog.h" - -#include "StringTools.h" -#include <QFileDialog> -#include <QSettings> -#include <QFileInfo> - -FileListDialog::FileListDialog(FileType input, FileType output, QWidget* parent) -: QDialog(parent), _input_file_type(input), _output_file_type(output) -{ - setupUi(this); - this->listView->setModel(&_allFiles); -} - -FileListDialog::~FileListDialog() -{ -} - -void FileListDialog::on_addButton_pressed() -{ - QSettings settings("UFZ", "OpenGeoSys-5"); - QString fileName = QFileDialog::getOpenFileName( this, "Select data file to open", - settings.value("lastOpenedOgsFileDirectory").toString(), - this->getFileTypeString(_input_file_type)); - - if (!fileName.isEmpty()) - { - QDir dir = QDir(fileName); - settings.setValue("lastOpenedOgsFileDirectory", dir.absolutePath()); - QStringList list = _allFiles.stringList(); - list.append(fileName); - _allFiles.setStringList(list); - } -} - -void FileListDialog::on_removeButton_pressed() -{ - QModelIndexList selected = this->listView->selectionModel()->selectedIndexes(); - - for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) - this->_allFiles.removeRow(it->row()); -} - -void FileListDialog::on_browseButton_pressed() -{ - QString guess_name(""); - if (!_allFiles.stringList().empty()) - guess_name = QString::fromStdString(BaseLib::getFileNameFromPath(_allFiles.stringList().at(0).toStdString())); - QSettings settings("UFZ", "OpenGeoSys-5"); - QFileInfo fi(settings.value("lastOpenedOgsFileDirectory").toString()); - QString fileName = QFileDialog::getSaveFileName( this, "Save as", - fi.absolutePath().append("/").append(guess_name), - this->getFileTypeString(_output_file_type)); - - if (!fileName.isEmpty()) - { - QDir dir = QDir(fileName); - settings.setValue("lastOpenedOgsFileDirectory", dir.absolutePath()); - this->lineEdit->setText(fileName); - } -} - -void FileListDialog::accept() -{ - emit fileLists(_allFiles.stringList(), lineEdit->text()); - this->done(QDialog::Accepted); -} - -void FileListDialog::reject() -{ - this->done(QDialog::Rejected); -} - -QString FileListDialog::getFileTypeString(FileType file_type) -{ - if (file_type==GML) return "OpenGeoSys geometry files (*.gml)"; - else if (file_type==CND) return "OpenGeoSys condition files (*.cnd)"; - else if (file_type==GLI) return "GeoSys geometry files (*.gli)"; - else if (file_type==BC) return "GeoSys boundary condition files (*.bc);; GeoSys initial condition files (*.ic);; GeoSys source term files (*.st)"; - else return "All files (*.*)"; -} \ No newline at end of file diff --git a/Utils/FileConverter/OGSFileConverter/FileListDialog.h b/Utils/FileConverter/OGSFileConverter/FileListDialog.h deleted file mode 100644 index 3a90f33cee847c4a0b73fedaad40ca0f07f7a544..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/FileListDialog.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * \file FileListDialog.h - * 2012/04/04 KR Initial implementation - */ - -#ifndef FILELISTDIALOG_H -#define FILELISTDIALOG_H - -#include "ui_FileList.h" -#include <QDialog> -#include <QStringListModel> - -class FileListDialog : public QDialog, private Ui_FileList -{ - Q_OBJECT - -public: - enum FileType { - GML, // xml-geometries - CND, // xml-fem-conditions - GLI, // ascii-geometries - BC // ascii-fem-conditions - }; - - FileListDialog(FileType input, FileType output, QWidget* parent = NULL); - ~FileListDialog(void); - -private: - QString getFileTypeString(FileType file_type); - - QStringListModel _allFiles; - const FileType _input_file_type; - const FileType _output_file_type; - -private slots: - void on_addButton_pressed(); - void on_removeButton_pressed(); - void on_browseButton_pressed(); - - /// Instructions if the OK-Button has been pressed. - void accept(); - - /// Instructions if the Cancel-Button has been pressed. - void reject(); - -signals: - void fileLists(const QStringList, const QString); -}; - -#endif //FILELISTDIALOG_H diff --git a/Utils/FileConverter/OGSFileConverter/OGSFileConverter.cpp b/Utils/FileConverter/OGSFileConverter/OGSFileConverter.cpp deleted file mode 100644 index 404ae5859a156eb9a9754c4826e9896c66360591..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/OGSFileConverter.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/** - * \file OGSFileConverter.cpp - * 2012/04/04 KR Initial implementation - */ - -#include "OGSFileConverter.h" -#include "FileListDialog.h" -#include "ConversionTools.h" -#include "OGSError.h" - -#include <QFileInfo> - -// conversion includes -#include "ProjectData.h" -#include "GEOObjects.h" -#include "OGSIOVer4.h" -#include "XmlIO/XmlCndInterface.h" -#include "XmlIO/XmlGmlInterface.h" -#include "StringTools.h" - -// old condition objects -#include "BoundaryCondition.h" -#include "InitialCondition.h" -#include "SourceTerm.h" -#include "rf_bc_new.h" -#include "rf_ic_new.h" -#include "rf_st_new.h" - -OGSFileConverter::OGSFileConverter(QWidget* parent) - : QDialog(parent) -{ - setupUi(this); -} - -OGSFileConverter::~OGSFileConverter() -{ -} - -void OGSFileConverter::convertGML2GLI(const QStringList &input, const QString &output) -{ - ProjectData project; - GeoLib::GEOObjects* geo_objects = new GeoLib::GEOObjects; - project.setGEOObjects(geo_objects); - - FileFinder fileFinder = createFileFinder(); - std::string schemaName(fileFinder.getPath("OpenGeoSysGLI.xsd")); - FileIO::XmlGmlInterface xml(&project, schemaName); - - for (QStringList::const_iterator it=input.begin(); it!=input.end(); ++it) - xml.readFile(*it); - - FileIO::writeAllDataToGLIFileV4(output.toStdString(), *geo_objects); - OGSError::box("File conversion finished"); -} - -void OGSFileConverter::convertGLI2GML(const QStringList &input, const QString &output) -{ - ProjectData project; - GeoLib::GEOObjects* geo_objects = new GeoLib::GEOObjects; - project.setGEOObjects(geo_objects); - - std::vector<std::string> merge_list; - for (QStringList::const_iterator it=input.begin(); it!=input.end(); ++it) - { - std::string unique_name; - std::vector<std::string> errors; - if (! FileIO::readGLIFileV4(it->toStdString(), geo_objects, unique_name, errors)) - { - for (size_t k(0); k<errors.size(); k++) - OGSError::box(QString::fromStdString(errors[k])); - } - else - merge_list.push_back(unique_name); - } - - if (!merge_list.empty()) - { - std::string merged_geo_name (merge_list[0]); - if (merge_list.size()>1) - { - merged_geo_name = BaseLib::getFileNameFromPath(output.toStdString()); - geo_objects->mergeGeometries(merge_list, merged_geo_name); - } - FileFinder fileFinder = createFileFinder(); - std::string schemaName(fileFinder.getPath("OpenGeoSysGLI.xsd")); - FileIO::XmlGmlInterface xml(&project, schemaName); - xml.setNameForExport(merged_geo_name); - xml.writeToFile(output.toStdString()); - } - OGSError::box("File conversion finished"); -} - -void OGSFileConverter::convertCND2BC(const QStringList &input, const QString &output) -{ - ProjectData project; - GeoLib::GEOObjects* geo_objects = new GeoLib::GEOObjects; - project.setGEOObjects(geo_objects); - - // HACK for enabling conversion of files without loading the associated geometry - std::vector<GeoLib::Point*> *fake_geo = new std::vector<GeoLib::Point*>; - fake_geo->push_back(new GeoLib::Point(0,0,0)); - std::string fake_name("conversionTestRun#1"); - geo_objects->addPointVec(fake_geo, fake_name); - - FileFinder fileFinder = createFileFinder(); - std::string schemaName(fileFinder.getPath("OpenGeoSysCond.xsd")); - FileIO::XmlCndInterface xml(&project, schemaName); - - std::vector<FEMCondition*> conditions; - - for (QStringList::const_iterator it=input.begin(); it!=input.end(); ++it) - xml.readFile(conditions, *it); - - if (!conditions.empty()) - { - project.addConditions(conditions); - QFileInfo fi(output); - FEMCondition::CondType type = FEMCondition::UNSPECIFIED; - if (fi.suffix().compare("bc") == 0) type = FEMCondition::BOUNDARY_CONDITION; - else if (fi.suffix().compare("ic") == 0) type = FEMCondition::INITIAL_CONDITION; - else if (fi.suffix().compare("st") == 0) type = FEMCondition::SOURCE_TERM; - - size_t count(0); - size_t nConds(conditions.size()); - for (size_t i=0; i<nConds; i++) - { - if (conditions[i]->getCondType() == type) - { - if (type == FEMCondition::BOUNDARY_CONDITION) - bc_list.push_back(new CBoundaryCondition(static_cast<BoundaryCondition*>(conditions[i]))); - else if (type == FEMCondition::INITIAL_CONDITION) - ic_vector.push_back(new CInitialCondition(static_cast<InitialCondition*>(conditions[i]))); - else if (type == FEMCondition::SOURCE_TERM) - st_vector.push_back(new CSourceTerm(static_cast<SourceTerm*>(conditions[i]))); - - if (conditions[i]->getProcessDistributionType() == FiniteElement::DIRECT) - { - std::string count_str (QString::number(count++).toStdString()); - std::string direct_value_file = fi.absolutePath().toStdString() + "/direct_values" + count_str + ".txt"; - st_vector[st_vector.size()-1]->fname = direct_value_file; - ConversionTools::writeDirectValues(*conditions[i], direct_value_file); - } - } - } - if (type == FEMCondition::BOUNDARY_CONDITION) - BCWrite(output.toStdString()); - else if (type == FEMCondition::INITIAL_CONDITION) - ICWrite(output.toStdString()); - else if (type == FEMCondition::SOURCE_TERM) - STWrite(output.toStdString()); - } - OGSError::box("File conversion finished"); -} - -void OGSFileConverter::convertBC2CND(const QStringList &input, const QString &output) -{ - ProjectData project; - std::vector<FEMCondition*> conditions; - for (QStringList::const_iterator it=input.begin(); it!=input.end(); ++it) - ConversionTools::getFEMConditionsFromASCIIFile(*it, conditions); - - if (!conditions.empty()) - { - project.addConditions(conditions); - FileFinder fileFinder = createFileFinder(); - std::string schemaName(fileFinder.getPath("OpenGeoSysCond.xsd")); - FileIO::XmlCndInterface xml(&project, schemaName); - xml.writeToFile(output.toStdString()); - } - OGSError::box("File conversion finished"); -} - -FileFinder OGSFileConverter::createFileFinder() -{ - FileFinder fileFinder; - fileFinder.addDirectory("."); - fileFinder.addDirectory(std::string(SOURCEPATH).append("/FileIO")); - return fileFinder; -} - -void OGSFileConverter::on_gml2gliButton_pressed() -{ - FileListDialog dlg(FileListDialog::GML, FileListDialog::GLI); - connect(&dlg, SIGNAL(fileLists(const QStringList, const QString)), - this, SLOT(convertGML2GLI(const QStringList, const QString))); - dlg.exec(); -} - -void OGSFileConverter::on_gli2gmlButton_pressed() -{ - FileListDialog dlg(FileListDialog::GLI, FileListDialog::GML); - connect(&dlg, SIGNAL(fileLists(const QStringList, const QString)), - this, SLOT(convertGLI2GML(const QStringList, const QString))); - dlg.exec(); -} - -void OGSFileConverter::on_bc2cndButton_pressed() -{ - FileListDialog dlg(FileListDialog::BC, FileListDialog::CND); - connect(&dlg, SIGNAL(fileLists(const QStringList, const QString)), - this, SLOT(convertBC2CND(const QStringList, const QString))); - dlg.exec(); -} - -void OGSFileConverter::on_cnd2bcButton_pressed() -{ - FileListDialog dlg(FileListDialog::CND, FileListDialog::BC); - connect(&dlg, SIGNAL(fileLists(const QStringList, const QString)), - this, SLOT(convertCND2BC(const QStringList, const QString))); - dlg.exec(); -} - -void OGSFileConverter::on_closeDialogButton_pressed() -{ - this->close(); -} - diff --git a/Utils/FileConverter/OGSFileConverter/OGSFileConverter.h b/Utils/FileConverter/OGSFileConverter/OGSFileConverter.h deleted file mode 100644 index 1d5d44834a42393eb5e6d7c15407aafb9670bce3..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/OGSFileConverter.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * \file OGSFileConverter.h - * 2012/04/04 KR Initial implementation - */ - -#ifndef OGSFILECONVERTER_H -#define OGSFILECONVERTER_H - -#include "ui_OGSFileConverter.h" -#include <QDialog> - -#include "FileFinder.h" - -class OGSFileConverter : public QDialog, private Ui_OGSFileConverter -{ - Q_OBJECT - -public: - OGSFileConverter(QWidget* parent = 0); - ~OGSFileConverter(void); - -private: - FileFinder createFileFinder(); - -private slots: - void convertGML2GLI(const QStringList &input, const QString &output); - void convertGLI2GML(const QStringList &input, const QString &output); - void convertCND2BC(const QStringList &input, const QString &output); - void convertBC2CND(const QStringList &input, const QString &output); - - void on_gml2gliButton_pressed(); - void on_gli2gmlButton_pressed(); - void on_bc2cndButton_pressed(); - void on_cnd2bcButton_pressed(); - void on_closeDialogButton_pressed(); - -signals: - -}; - -#endif //OGSFILECONVERTER_H diff --git a/Utils/FileConverter/OGSFileConverter/OGSFileConverter.ui b/Utils/FileConverter/OGSFileConverter/OGSFileConverter.ui deleted file mode 100644 index e02acdc3c40dae9d1c1e845949bbe44b32eea25d..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/OGSFileConverter.ui +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>OGSFileConverter</class> - <widget class="QDialog" name="OGSFileConverter"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>246</width> - <height>342</height> - </rect> - </property> - <property name="windowTitle"> - <string>OGS File Converter</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QGroupBox" name="geometryBox"> - <property name="title"> - <string>Geometry</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="gml2gliButton"> - <property name="text"> - <string>XML Geometry to ASCII Geometry</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="gli2gmlButton"> - <property name="text"> - <string>ASCII Geometry to XML Geometry</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="2" column="1"> - <widget class="QPushButton" name="closeDialogButton"> - <property name="text"> - <string>Close</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QGroupBox" name="conditionBox"> - <property name="title"> - <string>Conditions</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="cnd2bcButton"> - <property name="text"> - <string>XML to ASCII-Conditions</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="bc2cndButton"> - <property name="text"> - <string>ASCII-Conditions to XML</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/Utils/FileConverter/OGSFileConverter/main.cpp b/Utils/FileConverter/OGSFileConverter/main.cpp deleted file mode 100644 index 914a388330abc9723814ad5feed1c1666082dcbd..0000000000000000000000000000000000000000 --- a/Utils/FileConverter/OGSFileConverter/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "OGSFileConverter.h" -#include <QtGui/QApplication> - -int main(int argc, char* argv[]) -{ - QApplication app(argc, argv); - setlocale(LC_NUMERIC,"C"); - OGSFileConverter* fc = new OGSFileConverter(); - fc->setWindowTitle( fc->windowTitle() ); - fc->show(); - int returncode = app.exec(); - delete fc; - - return returncode; -}