This page describes how to implement a mesh reader for Arcane.
A mesh reader is a service that implements the IMeshReader interface, described below:
class IMeshReader
{
public:
virtual bool allowExtension(const String& str) =0;
virtual eReturnType readMeshFromFile(IMesh* mesh,
const XmlNode& mesh_element,
const String& file_name,
const String& dir_name,
bool use_internal_partition) =0;
};
The first thing to do is therefore define a service class that implements this interface. Our class will be called 'SampleMeshReader' and will inherit from BasicService. This service will be named 'SampleMeshReaderService'
#include "arcane/BasicService.h"
#include "arcane/IMeshReader.h"
#include "arcane/FactoryService.h"
class SampleMeshReader
{
public:
public:
virtual bool allowExtension(
const String& str);
virtual eReturnType readMeshFromFile(
IMesh*
mesh,
bool use_internal_partition);
};
#define ARCANE_REGISTER_SUB_DOMAIN_FACTORY(aclass, ainterface, aname)
Registers a factory service for the class aclass.
Base class of a service linked to a subdomain.
Interface of the service managing the reading of a mesh.
Structure containing the information to create a service.
Unicode character string.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
The IMeshReader::allowExtension() method allows specifying the file extension that our reader will support. For example, this extension is 'vtu' for VTK files containing unstructured meshes. In our example, we will use the 'msh' extension. We will therefore implement the allowExtension() method as follows:
bool SampleMeshReader::allowExtension(
const String& str)
{
return str=='msh';
}
TODO: to continue