Mesh file reader for legacy VTK format. More...
Classes | |
| class | VtkMesh |
| class | VtkStructuredGrid |
Public Types | |
| enum | eMeshType { VTK_MT_Unknown , VTK_MT_StructuredGrid , VTK_MT_UnstructuredGrid } |
Public Member Functions | |
| VtkMeshIOService (ITraceMng *tm) | |
| void | build () |
| bool | readMesh (IPrimaryMesh *mesh, const String &file_name, const String &dir_name, bool use_internal_partition) |
| Allows starting the reading of a vtk file. | |
| Public Member Functions inherited from Arcane::TraceAccessor | |
| TraceAccessor (ITraceMng *m) | |
| Constructs an accessor via the trace manager m. | |
| TraceAccessor (const TraceAccessor &rhs) | |
| Copy constructor. | |
| TraceAccessor & | operator= (const TraceAccessor &rhs) |
| Copy assignment operator. | |
| virtual | ~TraceAccessor () |
| Frees resources. | |
| ITraceMng * | traceMng () const |
| Trace manager. | |
| TraceMessage | info () const |
| Flow for an information message. | |
| TraceMessage | pinfo () const |
| Flow for a parallel information message. | |
| TraceMessage | info (char category) const |
| Flow for an information message of a given category. | |
| TraceMessage | pinfo (char category) const |
| Flow for a parallel information message of a given category. | |
| TraceMessage | info (bool v) const |
| Flow for an information message. | |
| TraceMessage | warning () const |
| Flow for a warning message. | |
| TraceMessage | pwarning () const |
| TraceMessage | error () const |
| Flow for an error message. | |
| TraceMessage | perror () const |
| TraceMessage | log () const |
| Flow for a log message. | |
| TraceMessage | plog () const |
| Flow for a log message. | |
| TraceMessage | logdate () const |
| Flow for a log message preceded by the date. | |
| TraceMessage | fatal () const |
| Flow for a fatal error message. | |
| TraceMessage | pfatal () const |
| Flow for a parallel fatal error message. | |
| TraceMessageDbg | debug (Trace::eDebugLevel=Trace::Medium) const |
| Flow for a debug message. | |
| Trace::eDebugLevel | configDbgLevel () const |
| Debug level of the configuration file. | |
| TraceMessage | info (Int32 verbose_level) const |
| Flow for an information message of a given level. | |
| TraceMessage | linfo () const |
| Flow for an information message with the local information level of this instance. | |
| TraceMessage | linfo (Int32 relative_level) const |
| Flow for an information message with the local information level of this instance. | |
| void | fatalMessage (const StandaloneTraceMessage &o) const |
Private Member Functions | |
| bool | _readStructuredGrid (IPrimaryMesh *mesh, VtkFile &, bool use_internal_partition) |
| Allows reading a vtk file containing a STRUCTURED_GRID. | |
| bool | _readUnstructuredGrid (IPrimaryMesh *mesh, VtkFile &vtk_file, bool use_internal_partition) |
| Allows reading a vtk file containing an UNSTRUCTURED_GRID. | |
| void | _readCellVariable (IMesh *mesh, VtkFile &vtk_file, const String &name_str, Integer nb_cell) |
| Allows creating a cell variable from the information in the vtk file. | |
| void | _readItemGroup (IMesh *mesh, VtkFile &vtk_file, const String &name_str, Integer nb_item, eItemKind ik, ConstArrayView< Int32 > local_id) |
| Allows creating an item group. | |
| void | _readNodeGroup (IMesh *mesh, VtkFile &vtk_file, const String &name, Integer nb_item) |
| Allows creating a node group. | |
| void | _createFaceGroup (IMesh *mesh, const String &name, Int32ConstArrayView faces_lid) |
| Allows creating a face group named "name" composed of faces having the IDs included in "faces_lid". | |
| bool | _readData (IMesh *mesh, VtkFile &vtk_file, bool use_internal_partition, eItemKind cell_kind, Int32ConstArrayView local_id, Integer nb_node) |
| Allows reading supplementary data (POINT_DATA / CELL_DATA). | |
| void | _readNodesUnstructuredGrid (IMesh *mesh, VtkFile &vtk_file, Array< Real3 > &node_coords) |
| Read nodes and their coordinates. | |
| void | _readCellsUnstructuredGrid (IMesh *mesh, VtkFile &vtk_file, Array< Int32 > &cells_nb_node, Array< ItemTypeId > &cells_type, Array< Int64 > &cells_connectivity) |
| Read cells and their connectivity. | |
| void | _readFacesMesh (IMesh *mesh, const String &file_name, const String &dir_name, bool use_internal_partition) |
| Allows reading the truc.vtkfaces.vtk file (if it exists). | |
| bool | _readMetadata (IMesh *mesh, VtkFile &vtk_file) |
| Read metadata. | |
Additional Inherited Members | |
| Protected Member Functions inherited from Arcane::TraceAccessor | |
| void | _setLocalVerboseLevel (Int32 v) |
| Int32 | _localVerboseLevel () const |
Mesh file reader for legacy VTK format.
This is a preliminary version that only supports DATASETs of type STRUCTURED_GRID or UNSTRUCTURED_GRID. Furthermore, the reader and writer have only been partially tested.
The VTK file header must be:
Where X.X is the VTK file version (support for VTK files <= 4.2).
It is possible to specify a set of variables in the file. In this case, their values are read simultaneously with the mesh and are used to initialize the variables. Currently, only cell values are supported.
Since VTK does not support the concept of a group, it is possible to specify a group as a variable (CELL_DATA). By convention, if the variable starts with the string 'GROUP_', then it is a group. The variable must be declared as follows: \begincode CELL_DATA n SCALARS GROUP_m int 1 LOOKUP_TABLE default with n being the number of cells, and m being the group name. A cell belongs to the group if the data value is different from 0.
Currently, point groups CANNOT be specified.
To specify face groups, a VTK file is required additional, identical to the original file but containing the description of the faces instead of the cells. By convention, if the currently read file is named 'toto.vtk', the file describing the faces will be 'toto.vtkfaces.vtk'. This file is optional.
Definition at line 102 of file VtkMeshIOService.cc.
| enum Arcane::VtkMeshIOService::eMeshType |
Definition at line 117 of file VtkMeshIOService.cc.
|
inlineexplicit |
Definition at line 107 of file VtkMeshIOService.cc.
|
private |
Allows creating a face group named "name" composed of faces having the IDs included in "faces_lid".
| mesh | The mesh to fill |
| name | The name of the group to create |
| faces_lid | The IDs of the faces to include in the group |
Definition at line 1718 of file VtkMeshIOService.cc.
References Arcane::TraceAccessor::info(), and Arcane::ConstArrayView< T >::size().
Referenced by _readStructuredGrid().
|
private |
Read cells and their connectivity.
Returns by filling cells_nb_node, cells_type, and cells_connectivity.
| mesh | The mesh to fill |
| vtk_file | Reference to a VtkFile object |
| cells_nb_node | Number of nodes per cell |
| cells_type | Type of each cell |
| cells_connectivity | Connectivity between cells |
Definition at line 1034 of file VtkMeshIOService.cc.
References _readMetadata(), ARCANE_THROW, Arcane::VtkFile::checkString(), Arcane::VtkFile::getInt(), Arcane::VtkFile::getNextLine(), Arcane::TraceAccessor::info(), and Arcane::Array< T >::resize().
Referenced by _readFacesMesh(), and _readUnstructuredGrid().
|
private |
Allows creating a cell variable from the information in the vtk file.
| mesh | The mesh to fill |
| vtk_file | Reference to a VtkFile object |
| var_name | The name of the variable to create |
| nb_cell | The number of cells |
Definition at line 1738 of file VtkMeshIOService.cc.
References _readMetadata(), Arcane::VtkFile::getDouble(), and Arcane::TraceAccessor::info().
Referenced by _readData().
|
private |
Allows reading supplementary data (POINT_DATA / CELL_DATA).
| mesh | The mesh to fill |
| file_name | The vtk file name (with extension) |
| use_internal_partition | Should the internal partitioner be used or not |
| cell_kind | Type of mesh cells |
| local_id | Array containing the local_id of the cells |
| nb_node | Number of nodes |
Definition at line 1442 of file VtkMeshIOService.cc.
References Arcane::IVariableMng::_internalApi(), _readCellVariable(), _readItemGroup(), _readNodeGroup(), Arcane::IVariableMngInternal::addAutoDestroyVariable(), Arcane::IParallelMng::broadcastMemoryBuffer(), Arcane::XmlNode::children(), Arcane::IParallelMng::commRank(), Arcane::IItemFamily::createGroup(), Arcane::TraceAccessor::debug(), Arcane::XmlNode::documentElement(), Arcane::TraceAccessor::error(), Arcane::TraceAccessor::fatal(), Arcane::VtkFile::getNextLine(), Arcane::IK_Cell, Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), Arcane::IXmlDocumentHolder::loadFromBuffer(), Arcane::ConstArrayView< T >::size(), Arcane::String::substring(), Arcane::TraceAccessor::traceMng(), and Arcane::String::utf8().
Referenced by _readFacesMesh(), _readStructuredGrid(), and _readUnstructuredGrid().
|
private |
Allows reading the truc.vtkfaces.vtk file (if it exists).
| mesh | The mesh to fill |
| file_name | The vtk file name (with extension) |
| dir_name | The file path |
| use_internal_partition | Should the internal partitioner be used or not |
Definition at line 1338 of file VtkMeshIOService.cc.
References _readCellsUnstructuredGrid(), _readData(), _readNodesUnstructuredGrid(), Arcane::VtkFile::checkString(), Arcane::IParallelMng::commRank(), Arcane::TraceAccessor::error(), Arcane::IMeshUtilities::getFacesLocalIdFromConnectivity(), Arcane::VtkFile::getNextLine(), Arcane::IK_Face, Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), Arcane::String::localstr(), Arcane::Array< T >::resize(), and Arcane::AbstractArray< T >::size().
Referenced by readMesh().
|
private |
Allows creating an item group.
| mesh | The mesh to fill |
| vtk_file | Reference to a VtkFile object |
| name | The name of the group to create |
| nb_item | Number of items to read and include in the group |
| ik | Type of items read |
| local_id | Array containing the local_ids of the cells |
Definition at line 1767 of file VtkMeshIOService.cc.
References _readMetadata(), Arcane::Array< T >::add(), Arcane::IItemFamily::createGroup(), Arcane::VtkFile::getInt(), Arcane::TraceAccessor::info(), and Arcane::AbstractArray< T >::size().
Referenced by _readData().
Read metadata.
Definition at line 1122 of file VtkMeshIOService.cc.
References Arcane::VtkFile::getNextLine(), Arcane::VtkFile::isEmptyNextLine(), and Arcane::VtkFile::isEqualString().
Referenced by _readCellsUnstructuredGrid(), _readCellVariable(), _readItemGroup(), _readNodeGroup(), _readNodesUnstructuredGrid(), and _readStructuredGrid().
|
private |
Allows creating a node group.
| mesh | The mesh to fill |
| vtk_file | Reference to a VtkFile object |
| name | The name of the group to create |
| nb_item | Number of items to read and include in the group |
Definition at line 1798 of file VtkMeshIOService.cc.
References _readMetadata(), Arcane::Array< T >::add(), Arcane::IItemFamily::createGroup(), Arcane::VtkFile::getInt(), Arcane::IK_Node, Arcane::TraceAccessor::info(), and Arcane::AbstractArray< T >::size().
Referenced by _readData().
|
private |
Read nodes and their coordinates.
| mesh | The mesh to fill |
| vtk_file | Reference to a VtkFile object |
| node_coords | The array to fill with node coordinates |
Definition at line 963 of file VtkMeshIOService.cc.
References _readMetadata(), ARCANE_THROW, Arcane::VtkFile::checkString(), Arcane::VtkFile::getDouble(), Arcane::VtkFile::getFloat(), Arcane::VtkFile::getInt(), Arcane::VtkFile::getNextLine(), Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), and Arcane::Array< T >::resize().
Referenced by _readFacesMesh(), and _readUnstructuredGrid().
|
private |
Allows reading a vtk file containing a STRUCTURED_GRID.
| mesh | The mesh to be filled |
| vtk_file | Reference to a VtkFile object |
| use_internal_partition | Should the internal partitioner be used or not |
Definition at line 684 of file VtkMeshIOService.cc.
References _createFaceGroup(), _readData(), _readMetadata(), Arcane::Array< T >::add(), ARCANE_FATAL, ARCANE_THROW, Arcane::VtkFile::checkString(), ENUMERATE_FACE, ENUMERATE_NODE, Arcane::TraceAccessor::error(), Arcane::VtkFile::getDouble(), Arcane::VtkFile::getFloat(), Arcane::VtkFile::getInt(), Arcane::VtkFile::getNextLine(), Arcane::IK_Cell, Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), Arcane::Item::localId(), Arcane::ItemWithNodes::nodes(), and Arcane::Item::uniqueId().
Referenced by readMesh().
|
private |
Allows reading a vtk file containing an UNSTRUCTURED_GRID.
| mesh | The mesh to fill |
| vtk_file | Reference to a VtkFile object |
| use_internal_partition | Should we use the internal partitioner or not |
Definition at line 1230 of file VtkMeshIOService.cc.
References _readCellsUnstructuredGrid(), _readData(), _readNodesUnstructuredGrid(), Arcane::UnstructuredMeshAllocateBuildInfo::addCell(), Arcane::UnstructuredMeshAllocateBuildInfo::allocateMesh(), ARCANE_FATAL, Arcane::TraceAccessor::debug(), Arcane::ItemTypeInfo::dimension(), ENUMERATE_NODE, Arcane::IK_Cell, Arcane::UnstructuredMeshAllocateBuildInfo::preAllocate(), Arcane::MessagePassing::ReduceMax, Arcane::Array< T >::resize(), Arcane::UnstructuredMeshAllocateBuildInfo::setMeshDimension(), Arcane::AbstractArray< T >::size(), Arcane::Array< T >::subView(), Arcane::ItemTypeMng::typeFromId(), and Arcane::Item::uniqueId().
Referenced by readMesh().
|
inline |
Definition at line 113 of file VtkMeshIOService.cc.
| bool Arcane::VtkMeshIOService::readMesh | ( | IPrimaryMesh * | mesh, |
| const String & | file_name, | ||
| const String & | dir_name, | ||
| bool | use_internal_partition ) |
Allows starting the reading of a vtk file.
| mesh | The mesh to be filled |
| file_name | The name of the vtk file (with extension) |
| dir_name | The file path |
| use_internal_partition | Should the internal partitioner be used or not |
Definition at line 585 of file VtkMeshIOService.cc.
References _readFacesMesh(), _readStructuredGrid(), _readUnstructuredGrid(), Arcane::VtkFile::checkString(), Arcane::TraceAccessor::debug(), Arcane::TraceAccessor::error(), Arcane::VtkFile::getNextLine(), Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), and Arcane::String::localstr().
Referenced by Arcane::VtkLegacyCaseMeshReader::Builder::allocateMeshItems(), and Arcane::VtkMeshReader::readMeshFromFile().