14#include "arcane/core/MeshReaderMng.h"
16#include "arcane/utils/UniqueArray.h"
17#include "arcane/utils/ScopedPtr.h"
19#include "arcane/core/ISubDomain.h"
20#include "arcane/core/IMainFactory.h"
21#include "arcane/core/IMeshReader.h"
22#include "arcane/core/ServiceBuilder.h"
23#include "arcane/core/IPrimaryMesh.h"
24#include "arcane/core/XmlNode.h"
25#include "arcane/core/Properties.h"
26#include "arcane/core/IXmlDocumentHolder.h"
27#include "arcane/core/IParallelMng.h"
71 bool m_is_init =
false;
72 bool m_is_use_unit =
true;
101 return readMesh(mesh_name, file_name, pm);
116 std::size_t extension_pos = fview.find_last_of(
'.');
117 if (extension_pos == std::string_view::npos)
118 ARCANE_FATAL(
"file name '{0}' has no extension", file_name);
119 fview.remove_prefix(extension_pos + 1);
130 if (
mesh->isAllocated())
131 ARCANE_FATAL(
"Mesh '{0}' already exists and is allocated", mesh_name);
133 mesh->properties()->setBool(
"dump",
false);
135 String use_unit_str = (m_p->m_is_use_unit) ?
"true" :
"false";
136 String use_unit_xml =
"<?xml version=\"1.0\"?><file use-unit='" + use_unit_str +
"' />";
140 XmlNode mesh_xml_node = xml_doc->documentNode().documentElement();
144 bool use_internal_partition = pm->
isParallel();
145 for (
auto& reader_ref : m_p->readers()) {
152 use_internal_partition);
158 ARCANE_FATAL(
"Can not read mesh file '{0}'", file_name);
163 ARCANE_FATAL(
"No mesh reader is available for mesh file '{0}'", file_name);
174 m_p->m_is_use_unit = v;
183 return m_p->m_is_use_unit;
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Constant view of an array of type T.
virtual ITraceMng * traceMng() const =0
Trace manager.
virtual IPrimaryMesh * createMesh(ISubDomain *sub_domain, const String &name)=0
Creates or retrieves a mesh.
Interface of the service managing the reading of a mesh.
virtual bool allowExtension(const String &str)=0
Checks if the service supports files with the extension str.
virtual eReturnType readMeshFromFile(IPrimaryMesh *mesh, const XmlNode &mesh_element, const String &file_name, const String &dir_name, bool use_internal_partition)=0
Reads a mesh from a file.
@ RTError
Error during the operation.
@ RTOk
Operation successfully performed.
Interface of the parallelism manager for a subdomain.
virtual IParallelMng * sequentialParallelMng()=0
Returns a sequential parallelism manager.
virtual bool isParallel() const =0
Returns true if the execution is parallel.
Interface of the subdomain manager.
virtual IParallelMng * parallelMng()=0
Returns the parallelism manager.
virtual IMainFactory * mainFactory()=0
Main factory.
static IXmlDocumentHolder * loadFromBuffer(Span< const Byte > buffer, const String &name, ITraceMng *tm)
Loads an XML document.
IMesh * readMesh(const String &mesh_name, const String &file_name)
Reads the mesh whose file name is file_name.
void setUseMeshUnit(bool v)
If true, indicates that the unit system possibly present in the file format is used (true by default)...
bool isUseMeshUnit() const
Indicates whether the unit system present in the file is used.
Encapsulation of an automatically destructing pointer.
Utility class for instantiating a service of a given interface.
UniqueArray< Ref< InterfaceType > > createAllInstances()
Creates an instance of every service that implements InterfaceType.
Unicode character string.
Span< const Byte > bytes() const
Returns the conversion of the instance into UTF-8 encoding.
std::string_view toStdStringView() const
Returns an STL view of the current string.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --