diff --git a/Source/EBGeometry_PLY.hpp b/Source/EBGeometry_PLY.hpp index bb7b6f4a..e8178e65 100644 --- a/Source/EBGeometry_PLY.hpp +++ b/Source/EBGeometry_PLY.hpp @@ -85,16 +85,16 @@ class PLY @return m_vertexProperties at provided property */ std::vector& - getVertexProperties(const std::string a_property) noexcept; + getVertexProperties(const std::string a_property); /*! @brief Get the vertex properties @param[in] a_property Which property to fetch - @note Function will fail if the property does not exist + @note Function will fail if the property does not exist @return m_vertexProperties at provided property */ const std::vector& - getVertexProperties(const std::string a_property) const noexcept; + getVertexProperties(const std::string a_property) const; /*! @brief Get the face properties @@ -103,7 +103,7 @@ class PLY @return m_faceProperties at provided property */ std::vector& - getFaceProperties(const std::string a_property) noexcept; + getFaceProperties(const std::string a_property); /*! @brief Get the vertex properties @@ -112,7 +112,7 @@ class PLY @return m_vertexProperties at provided property */ const std::vector& - getFaceProperties(const std::string a_property) const noexcept; + getFaceProperties(const std::string a_property) const; /*! @brief Set vertex properties @@ -120,7 +120,7 @@ class PLY @param[in] a_data Property data */ void - setVertexProperties(const std::string a_property, const std::vector& a_data) noexcept; + setVertexProperties(const std::string a_property, const std::vector& a_data); /*! @brief Set face properties @@ -128,7 +128,7 @@ class PLY @param[in] a_data Property data */ void - setFaceProperties(const std::string a_property, const std::vector& a_data) noexcept; + setFaceProperties(const std::string a_property, const std::vector& a_data); /*! @brief Turn the PLY mesh into a DCEL mesh. @@ -139,7 +139,7 @@ class PLY std::shared_ptr> convertToDCEL() const noexcept; -protected: + //protected: /*! @brief PLY object ID. */ diff --git a/Source/EBGeometry_PLYImplem.hpp b/Source/EBGeometry_PLYImplem.hpp index 77061e12..ea5201ea 100644 --- a/Source/EBGeometry_PLYImplem.hpp +++ b/Source/EBGeometry_PLYImplem.hpp @@ -80,42 +80,42 @@ PLY::getFacets() const noexcept template std::vector& -PLY::getVertexProperties(const std::string a_property) noexcept +PLY::getVertexProperties(const std::string a_property) { return m_vertexProperties.at(a_property); } template const std::vector& -PLY::getVertexProperties(const std::string a_property) const noexcept +PLY::getVertexProperties(const std::string a_property) const { return m_vertexProperties.at(a_property); } template std::vector& -PLY::getFaceProperties(const std::string a_property) noexcept +PLY::getFaceProperties(const std::string a_property) { return m_faceProperties.at(a_property); } template const std::vector& -PLY::getFaceProperties(const std::string a_property) const noexcept +PLY::getFaceProperties(const std::string a_property) const { return m_faceProperties.at(a_property); } template void -PLY::setVertexProperties(const std::string a_property, const std::vector& a_data) noexcept +PLY::setVertexProperties(const std::string a_property, const std::vector& a_data) { m_vertexProperties[a_property] = a_data; } template void -PLY::setFaceProperties(const std::string a_property, const std::vector& a_data) noexcept +PLY::setFaceProperties(const std::string a_property, const std::vector& a_data) { m_faceProperties[a_property] = a_data; } diff --git a/Source/EBGeometry_ParserImplem.hpp b/Source/EBGeometry_ParserImplem.hpp index 515515c2..2cde075c 100644 --- a/Source/EBGeometry_ParserImplem.hpp +++ b/Source/EBGeometry_ParserImplem.hpp @@ -556,9 +556,11 @@ Parser::readPLY(const std::string& a_filename) noexcept } } - // Copy properties to PLY object using the setter methods + // Copy properties to PLY object using the setter methods, skipping x/y/z coordinates for (const auto& propName : vertexPropertyNames) { - ply.setVertexProperties(propName, vertexProps[propName]); + if (propName != "x" && propName != "y" && propName != "z") { + ply.setVertexProperties(propName, vertexProps[propName]); + } } for (const auto& propName : facePropertyNames) { @@ -835,9 +837,11 @@ Parser::readPLY(const std::string& a_filename) noexcept } } - // Copy properties to PLY object using the setter methods + // Copy properties to PLY object using the setter methods, skipping x/y/z coordinates for (const auto& propName : vertexPropertyNames) { - ply.setVertexProperties(propName, vertexProps[propName]); + if (propName != "x" && propName != "y" && propName != "z") { + ply.setVertexProperties(propName, vertexProps[propName]); + } } for (const auto& propName : facePropertyNames) { @@ -889,6 +893,7 @@ Parser::readVTK(const std::string& a_filename) noexcept case Parser::Encoding::ASCII: { std::ifstream filestream(a_filename); + std::cout << "reading ascii" << std::endl; if (filestream.is_open()) { std::string line; @@ -1025,6 +1030,8 @@ Parser::readVTK(const std::string& a_filename) noexcept size_t numData; sstream >> numData; + std::cout << "getting point data" << std::endl; + // Read point data arrays while (std::getline(filestream, line)) { std::stringstream ss(line); @@ -1062,6 +1069,23 @@ Parser::readVTK(const std::string& a_filename) noexcept vtk.setPointDataScalars(arrayName, scalarData); } + else if (dataKeyword == "FIELD") { + // Skip FIELD arrays within POINT_DATA + std::string fieldName; + size_t numArrays; + ss >> fieldName >> numArrays; + for (size_t f = 0; f < numArrays; f++) { + std::string fieldArrayName, dataType; + size_t numComponents, numTuples; + filestream >> fieldArrayName >> numComponents >> numTuples >> dataType; + std::getline(filestream, line); + for (size_t v = 0; v < numComponents * numTuples; v++) { + std::string dummy; + filestream >> dummy; + } + std::getline(filestream, line); + } + } else if (dataKeyword == "CELL_DATA") { // Back up - we've hit the next section filestream.seekg(-static_cast(line.length()) - 1, std::ios_base::cur); @@ -1109,6 +1133,28 @@ Parser::readVTK(const std::string& a_filename) noexcept vtk.setCellDataScalars(arrayName, scalarData); } + else if (dataKeyword == "FIELD") { + // Skip FIELD arrays within CELL_DATA + std::string fieldName; + size_t numArrays; + ss >> fieldName >> numArrays; + for (size_t f = 0; f < numArrays; f++) { + std::string fieldArrayName, dataType; + size_t numComponents, numTuples; + filestream >> fieldArrayName >> numComponents >> numTuples >> dataType; + std::getline(filestream, line); + for (size_t v = 0; v < numComponents * numTuples; v++) { + std::string dummy; + filestream >> dummy; + } + std::getline(filestream, line); + } + } + else if (dataKeyword == "POINT_DATA") { + // Back up - we've hit the next section + filestream.seekg(-static_cast(line.length()) - 1, std::ios_base::cur); + break; + } } } } @@ -1311,6 +1357,8 @@ Parser::readVTK(const std::string& a_filename) noexcept size_t numData; sstream >> numData; + std::cout << "getting point data" << std::endl; + // Read point data arrays while (std::getline(filestream, line)) { std::stringstream ss(line); diff --git a/Source/EBGeometry_VTK.hpp b/Source/EBGeometry_VTK.hpp index a3918427..cd70bcda 100644 --- a/Source/EBGeometry_VTK.hpp +++ b/Source/EBGeometry_VTK.hpp @@ -86,7 +86,7 @@ class VTK @return m_pointDataScalars at provided name */ std::vector& - getPointDataScalars(const std::string a_name) noexcept; + getPointDataScalars(const std::string a_name); /*! @brief Get the point data scalars @@ -95,7 +95,7 @@ class VTK @return m_pointDataScalars at provided name */ const std::vector& - getPointDataScalars(const std::string a_name) const noexcept; + getPointDataScalars(const std::string a_name) const; /*! @brief Get the cell data scalars @@ -104,7 +104,7 @@ class VTK @return m_cellDataScalars at provided name */ std::vector& - getCellDataScalars(const std::string a_name) noexcept; + getCellDataScalars(const std::string a_name); /*! @brief Get the cell data scalars @@ -113,7 +113,7 @@ class VTK @return m_cellDataScalars at provided name */ const std::vector& - getCellDataScalars(const std::string a_name) const noexcept; + getCellDataScalars(const std::string a_name) const; /*! @brief Set point data scalars @@ -121,7 +121,7 @@ class VTK @param[in] a_data Array data */ void - setPointDataScalars(const std::string a_name, const std::vector& a_data) noexcept; + setPointDataScalars(const std::string a_name, const std::vector& a_data); /*! @brief Set cell data scalars @@ -129,7 +129,7 @@ class VTK @param[in] a_data Array data */ void - setCellDataScalars(const std::string a_name, const std::vector& a_data) noexcept; + setCellDataScalars(const std::string a_name, const std::vector& a_data); /*! @brief Turn the VTK mesh into a DCEL mesh. @@ -140,7 +140,7 @@ class VTK std::shared_ptr> convertToDCEL() const noexcept; -protected: + //protected: /*! @brief VTK object ID. */ diff --git a/Source/EBGeometry_VTKImplem.hpp b/Source/EBGeometry_VTKImplem.hpp index 4c11fc1a..bf36457d 100644 --- a/Source/EBGeometry_VTKImplem.hpp +++ b/Source/EBGeometry_VTKImplem.hpp @@ -80,42 +80,42 @@ VTK::getFacets() const noexcept template std::vector& -VTK::getPointDataScalars(const std::string a_name) noexcept +VTK::getPointDataScalars(const std::string a_name) { return m_pointDataScalars.at(a_name); } template const std::vector& -VTK::getPointDataScalars(const std::string a_name) const noexcept +VTK::getPointDataScalars(const std::string a_name) const { return m_pointDataScalars.at(a_name); } template std::vector& -VTK::getCellDataScalars(const std::string a_name) noexcept +VTK::getCellDataScalars(const std::string a_name) { return m_cellDataScalars.at(a_name); } template const std::vector& -VTK::getCellDataScalars(const std::string a_name) const noexcept +VTK::getCellDataScalars(const std::string a_name) const { return m_cellDataScalars.at(a_name); } template void -VTK::setPointDataScalars(const std::string a_name, const std::vector& a_data) noexcept +VTK::setPointDataScalars(const std::string a_name, const std::vector& a_data) { m_pointDataScalars[a_name] = a_data; } template void -VTK::setCellDataScalars(const std::string a_name, const std::vector& a_data) noexcept +VTK::setCellDataScalars(const std::string a_name, const std::vector& a_data) { m_cellDataScalars[a_name] = a_data; }