Commit 22213811 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Refactoring: Meshes/Readers/EntityShape.h moved to Meshes/VTKTraits.h

parent 52d44ee0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ class MeshFunctionVTKWriter

public:
   MeshFunctionVTKWriter( std::ostream& str,
                          Meshes::Writers::VTKFileFormat format = Meshes::Writers::VTKFileFormat::ASCII )
                          Meshes::VTK::FileFormat format = Meshes::VTK::FileFormat::ascii )
   : Meshes::Writers::VTKWriter< MeshType >( str, format )
   {}

@@ -45,9 +45,9 @@ public:
                        const String& functionName )
   {
      if( MeshFunction::getEntitiesDimension() == 0 )
         this->writeDataArray( function.getData(), functionName, 1, Meshes::Writers::VTKDataType::PointData );
         this->writeDataArray( function.getData(), functionName, 1, Meshes::VTK::DataType::PointData );
      else
         this->writeDataArray( function.getData(), functionName, 1, Meshes::Writers::VTKDataType::CellData );
         this->writeDataArray( function.getData(), functionName, 1, Meshes::VTK::DataType::CellData );
   }
};

@@ -56,7 +56,7 @@ class MeshFunctionVTKWriter< MeshFunction, false >
{
public:
   MeshFunctionVTKWriter( std::ostream& str,
                          Meshes::Writers::VTKFileFormat format = Meshes::Writers::VTKFileFormat::ASCII )
                          Meshes::VTK::FileFormat format = Meshes::VTK::FileFormat::ascii )
   {}

   bool write( const MeshFunction& function,
+3 −3
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ class VectorFieldVTKWriter

public:
   VectorFieldVTKWriter( std::ostream& str,
                         Meshes::Writers::VTKFileFormat format = Meshes::Writers::VTKFileFormat::ASCII )
                         Meshes::VTK::FileFormat format = Meshes::VTK::FileFormat::ascii )
   : Meshes::Writers::VTKWriter< MeshType >( str, format )
   {}

@@ -60,9 +60,9 @@ public:

      // write the buffer
      if( VectorField::getEntitiesDimension() == 0 )
         this->writeDataArray( buffer, fieldName, 3, Meshes::Writers::VTKDataType::PointData );
         this->writeDataArray( buffer, fieldName, 3, Meshes::VTK::DataType::PointData );
      else
         this->writeDataArray( buffer, fieldName, 3, Meshes::Writers::VTKDataType::CellData );
         this->writeDataArray( buffer, fieldName, 3, Meshes::VTK::DataType::CellData );
   }
};

+11 −11
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
#include <sstream>

#include <TNL/Meshes/MeshBuilder.h>
#include <TNL/Meshes/Readers/EntityShape.h>
#include <TNL/Meshes/VTKTraits.h>

namespace TNL {
namespace Meshes {
@@ -124,20 +124,20 @@ public:
      //cout << "There are " << verticesInCell << " vertices in cell ..." << std::endl;

      if( meshDimension == 1 && verticesInCell == 2 )
         cellShape = EntityShape::Line;
         cellShape = VTK::EntityShape::Line;
      else if( meshDimension == 2 ) {
         if( verticesInCell == 3 )
            cellShape = EntityShape::Triangle;
            cellShape = VTK::EntityShape::Triangle;
         else if( verticesInCell == 4 )
            cellShape = EntityShape::Quad;
            cellShape = VTK::EntityShape::Quad;
      }
      else if( meshDimension == 3 ) {
         if( verticesInCell == 4 )
            cellShape = EntityShape::Tetra;
            cellShape = VTK::EntityShape::Tetra;
         else if( verticesInCell == 8 )
            cellShape = EntityShape::Hexahedron;
            cellShape = VTK::EntityShape::Hexahedron;
      }
      if( cellShape == EntityShape::Vertex ) {
      if( cellShape == VTK::EntityShape::Vertex ) {
         std::cerr << "Unknown cell topology: mesh dimension is " << meshDimension << ", number of vertices in cells is " << verticesInCell << "." << std::endl;
         return false;
      }
@@ -251,7 +251,7 @@ public:
      return worldDimension;
   }

   EntityShape
   VTK::EntityShape
   getCellShape() const
   {
      return cellShape;
@@ -288,13 +288,13 @@ public:
protected:
   String fileName;
   int meshDimension, worldDimension;
   EntityShape cellShape = EntityShape::Vertex;
   VTK::EntityShape cellShape = VTK::EntityShape::Vertex;

   void reset()
   {
      fileName = "";
      meshDimension = worldDimension = 0;
      cellShape = EntityShape::Vertex;
      cellShape = VTK::EntityShape::Vertex;
   }
};

+12 −12
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@

#include <TNL/String.h>
#include <TNL/Object.h>
#include <TNL/Meshes/Readers/EntityShape.h>
#include <TNL/Meshes/VTKTraits.h>

namespace TNL {
namespace Meshes {
@@ -42,11 +42,11 @@ public:
         globalIndexType = localIndexType = idType = parsedMeshType[ 4 ];
         // populate entity types (not necessary for GridTypeResolver, but while we're at it...)
         if( meshDimension == 1 )
            cellShape = EntityShape::Line;
            cellShape = VTK::EntityShape::Line;
         else if( meshDimension == 2 )
            cellShape = EntityShape::Quad;
            cellShape = VTK::EntityShape::Quad;
         else if( meshDimension == 3 )
            cellShape = EntityShape::Hexahedron;
            cellShape = VTK::EntityShape::Hexahedron;
      }
      else if( meshType == "Meshes::Mesh" ) {
         const std::vector< String > parsedMeshConfig = parseObjectType( parsedMeshType[ 1 ] );
@@ -72,15 +72,15 @@ public:
         idType = parsedMeshConfig[ 6 ];

         if( topology == "MeshEdgeTopology" )
            cellShape = EntityShape::Line;
            cellShape = VTK::EntityShape::Line;
         else if( topology == "MeshTriangleTopology" )
            cellShape = EntityShape::Triangle;
            cellShape = VTK::EntityShape::Triangle;
         else if( topology == "MeshQuadrilateralTopology" )
            cellShape = EntityShape::Quad;
            cellShape = VTK::EntityShape::Quad;
         else if( topology == "MeshTetrahedronTopology" )
            cellShape = EntityShape::Tetra;
            cellShape = VTK::EntityShape::Tetra;
         else if( topology == "MeshHexahedronTopology" )
            cellShape = EntityShape::Hexahedron;
            cellShape = VTK::EntityShape::Hexahedron;
         else {
            std::cerr << "Detected topology '" << topology << "' is not supported." << std::endl;
            return false;
@@ -120,7 +120,7 @@ public:
      return worldDimension;
   }

   EntityShape
   VTK::EntityShape
   getCellShape() const
   {
      return cellShape;
@@ -155,7 +155,7 @@ protected:
   String meshType;
   int meshDimension = 0;
   int worldDimension = 0;
   EntityShape cellShape = EntityShape::Vertex;
   VTK::EntityShape cellShape = VTK::EntityShape::Vertex;
   String realType;
   String globalIndexType;
   String localIndexType;
@@ -166,7 +166,7 @@ protected:
      fileName = "";
      meshType = "";
      meshDimension = worldDimension = 0;
      cellShape = EntityShape::Vertex;
      cellShape = VTK::EntityShape::Vertex;
      realType = localIndexType = globalIndexType = idType = "";
   }
};
+10 −10
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
#include <vector>

#include <TNL/Meshes/MeshBuilder.h>
#include <TNL/Meshes/Readers/EntityShape.h>
#include <TNL/Meshes/VTKTraits.h>
#include <TNL/Exceptions/NotImplementedError.h>

namespace TNL {
@@ -107,7 +107,7 @@ public:

      // read entity types
      long int entitiesRead = 0;
      std::map< int, EntityShape > entityTypes;
      std::map< int, VTK::EntityShape > entityTypes;
      while( entitiesRead < numberOfEntities ) {
         if( ! inputFile ) {
            std::cerr << "VTKReader: unable to read enough entity types, the file may be invalid or corrupted." << std::endl;
@@ -120,7 +120,7 @@ public:
         iss.clear();
         iss.str( line );
         iss >> typeId;
         const EntityShape type = (EntityShape) typeId;
         const VTK::EntityShape type = (VTK::EntityShape) typeId;
         const int dimension = getEntityDimension( type );

         // check entity type
@@ -128,7 +128,7 @@ public:
            entityTypes.emplace( std::make_pair( dimension, type ) );
         else if( entityTypes[ dimension ] != type ) {
            std::cerr << "Mixed unstructured meshes are not supported. There are elements of dimension " << dimension
                      << " with type " << entityTypes[ dimension ] << " and " << type << ". "
                      << " with type " << VTK::getShapeName( entityTypes[ dimension ] ) << " and " << VTK::getShapeName( type ) << ". "
                      << "The type of all entities with the same dimension must be the same." << std::endl;
            this->reset();
            return false;
@@ -156,7 +156,7 @@ public:
      using PointType = typename MeshType::PointType;
      using CellSeedType = typename MeshBuilder::CellSeedType;

      const EntityShape cellType = TopologyToEntityShape< typename MeshType::template EntityTraits< MeshType::getMeshDimension() >::EntityTopology >::shape;
      const VTK::EntityShape cellType = VTK::TopologyToEntityShape< typename MeshType::template EntityTraits< MeshType::getMeshDimension() >::EntityTopology >::shape;
      MeshBuilder meshBuilder;

      std::ifstream inputFile( fileName.getString() );
@@ -232,7 +232,7 @@ public:
      iss >> numberOfEntities;

      // read entity types, count cells
      std::vector< EntityShape > entityTypes;
      std::vector< VTK::EntityShape > entityTypes;
      entityTypes.resize( numberOfEntities );
      IndexType numberOfCells = 0;
      for( IndexType entityIndex = 0; entityIndex < numberOfEntities; entityIndex++ ) {
@@ -247,7 +247,7 @@ public:
         iss.clear();
         iss.str( line );
         iss >> typeId;
         entityTypes[ entityIndex ] = (EntityShape) typeId;
         entityTypes[ entityIndex ] = (VTK::EntityShape) typeId;
         const int dimension = getEntityDimension( entityTypes[ entityIndex ] );
         if( dimension == MeshType::getMeshDimension() )
            numberOfCells++;
@@ -310,7 +310,7 @@ public:
      return worldDimension;
   }

   EntityShape
   VTK::EntityShape
   getCellShape() const
   {
      return cellShape;
@@ -350,14 +350,14 @@ protected:

   String fileName;
   int meshDimension, worldDimension;
   EntityShape cellShape = EntityShape::Vertex;
   VTK::EntityShape cellShape = VTK::EntityShape::Vertex;
   std::string realType;

   void reset()
   {
      fileName = "";
      meshDimension = worldDimension = 0;
      cellShape = EntityShape::Vertex;
      cellShape = VTK::EntityShape::Vertex;
      realType = "";
   }

Loading