Commit f61ec71a authored by Ján Bobot's avatar Ján Bobot Committed by Jakub Klinkovský
Browse files

Modified MeshReader to handle reading Polygonal meshes

parent 1c33ec48
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ class EntitySeed
      using HashType        = EntitySeedHash< EntitySeed >;
      using KeyEqual        = EntitySeedEq< EntitySeed >;

      //this function is here only for compatibility with MeshReader
      void setCornersCount( const LocalIndexType& cornersCount ) {}

      static constexpr LocalIndexType getCornersCount()
      {
         return SubvertexTraits::count;
@@ -81,6 +84,9 @@ class EntitySeed< MeshConfig, Topologies::Vertex >
      using HashType        = EntitySeedHash< EntitySeed >;
      using KeyEqual        = EntitySeedEq< EntitySeed >;

      //this function is here only for compatibility with MeshReader
      void setCornersCount( const LocalIndexType& cornersCount ) {}

      static constexpr LocalIndexType getCornersCount()
      {
         return 1;
+1 −0
Original line number Diff line number Diff line
@@ -199,6 +199,7 @@ public:
               for( std::size_t i = 0; i < NumberOfCells; i++ ) {
                  CellSeedType& seed = meshBuilder.getCellSeed( i );
                  const std::size_t offsetEnd = offsets[ i ];
                  seed.setCornersCount( offsetEnd - offsetStart );
                  for( std::size_t o = offsetStart; o < offsetEnd; o++ )
                     seed.setCornerId( o - offsetStart, connectivity[ o ] );
                  offsetStart = offsetEnd;
+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ resolveCellTopology( Reader& reader, Functor&& functor )
         return resolveSpaceDimension< Topologies::Tetrahedron >( reader, std::forward<Functor>(functor) );
      case VTK::EntityShape::Hexahedron:
         return resolveSpaceDimension< Topologies::Hexahedron >( reader, std::forward<Functor>(functor) );
      case VTK::EntityShape::Polygon:
         return resolveSpaceDimension< Topologies::Polygon >( reader, std::forward<Functor>(functor) );
      default:
         std::cerr << "unsupported cell topology: " << VTK::getShapeName( reader.getCellShape() ) << std::endl;
         return false;
+8 −0
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ struct MeshEntitiesVTKWriter
      const int verticesPerEntity = VerticesPerEntity< EntityType >::count;;
      for( Index i = 0; i < entitiesCount; i++ ) {
         const auto& entity = mesh.template getEntity< EntityType >( i );
         //TODO: polygons require verticesPerEntity to be aquired like below
         //const Index verticesPerEntity = entity.template getSubentitiesCount< 0 >();
         writeInt( format, str, verticesPerEntity );
         for( int j = 0; j < verticesPerEntity; j++ )
            writeInt( format, str, entity.template getSubentityIndex< 0 >( j ) );
@@ -445,6 +447,12 @@ VTKWriter< Mesh >::writeEntities( const Mesh& mesh )
   const int verticesPerEntity = VerticesPerEntity< EntityType >::count;
   const std::uint64_t cellsListSize = cellsCount * ( verticesPerEntity + 1 );

   //TODO: polygons need cellsListSize computed like this, but code doesnt compile, 
   //      because function writeEntities is also used for grids, that don't contain function getSubentitiesCount
   /*IndexType cellsListSize = cellsCount;
   for(IndexType index = 0; index < cellsCount; index++)
      cellsListSize += mesh.template getSubentitiesCount< EntityDimension, 0 >( index );*/

   str << std::endl << "CELLS " << cellsCount << " " << cellsListSize << std::endl;
   EntitiesWriter< EntityDimension >::exec( mesh, str, format );

+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ struct MeshEntitiesVTUCollector
      const Index verticesPerEntity = VerticesPerEntity< EntityType >::count;;
      for( Index i = 0; i < entitiesCount; i++ ) {
         const auto& entity = mesh.template getEntity< EntityType >( i );
         //TODO: polygons require verticesPerEntity to be aquired like below
         //const Index verticesPerEntity = entity.template getSubentitiesCount< 0 >();
         for( Index j = 0; j < verticesPerEntity; j++ )
            connectivity.push_back( entity.template getSubentityIndex< 0 >( j ) );
         offsets.push_back( connectivity.size() );
Loading