3#ifndef MR_PARSING_FOR_ANY_BINDINGS
18#define MR_FORMAT_REGISTRY_EXTERNAL_DECL( API_ATTR, ProcName ) \
19API_ATTR ProcName MR_CONCAT( get, ProcName )( const IOFilter& filter ); \
20API_ATTR ProcName MR_CONCAT( get, ProcName )( const std::string& extension ); \
21API_ATTR void MR_CONCAT( set, ProcName )( const IOFilter& filter, ProcName proc, int8_t priorityScore = 0 ); \
22API_ATTR const IOFilters& getFilters();
24#define MR_FORMAT_REGISTRY_DECL( ProcName ) MR_FORMAT_REGISTRY_EXTERNAL_DECL( MRMESH_API, ProcName )
26#define MR_FORMAT_REGISTRY_IMPL( ProcName ) \
27ProcName MR_CONCAT( get, ProcName )( const IOFilter& filter ) \
29 return FormatRegistry<ProcName>::getProcessor( filter ); \
31ProcName MR_CONCAT( get, ProcName )( const std::string& extension ) \
33 return FormatRegistry<ProcName>::getProcessor( extension ); \
35void MR_CONCAT( set, ProcName )( const IOFilter& filter, ProcName processor, int8_t priorityScore ) \
37 FormatRegistry<ProcName>::setProcessor( filter, processor, priorityScore ); \
39const IOFilters& getFilters() \
41 return FormatRegistry<ProcName>::getFilters(); \
52template <
typename Processor>
59 return get_().filters_;
65 const auto& processors = get_().processors_;
66 auto it = processors.find( filter );
67 if ( it != processors.end() )
76 const auto& processors = get_().processors_;
78 auto it = std::find_if( processors.begin(), processors.end(), [&extension] (
auto&& item )
80 const auto& [filter, _] = item;
81 return filter.isSupportedExtension( extension );
83 if ( it != processors.end() )
92 auto& processors = get_().processors_;
93 auto it = processors.find( filter );
94 if ( it != processors.end() )
96 it->second = processor;
100 processors.emplace( filter, processor );
102 auto& filters = get_().filterPriorityQueue_;
103 filters.emplace( priorityScore, filter );
104 get_().updateFilterList_();
118 void updateFilterList_()
121 filters_.reserve( filterPriorityQueue_.size() );
122 for (
const auto& [_, filter] : filterPriorityQueue_ )
123 filters_.emplace_back( filter );
126 std::map<IOFilter, Processor> processors_;
127 std::multimap<int8_t, IOFilter> filterPriorityQueue_;
128 std::vector<IOFilter> filters_;
155#define MR_ADD_MESH_LOADER( filter, loader ) \
156MR_ON_INIT { using namespace MR::MeshLoad; setMeshLoader( filter, { static_cast<MeshFileLoader>( loader ), static_cast<MeshStreamLoader>( loader ) } ); };
158#define MR_ADD_MESH_LOADER_WITH_PRIORITY( filter, loader, priority ) \
159MR_ON_INIT { using namespace MR::MeshLoad; setMeshLoader( filter, { static_cast<MeshFileLoader>( loader ), static_cast<MeshStreamLoader>( loader ) }, priority ); };
191#define MR_ADD_MESH_SAVER( filter, saver, caps ) \
192MR_ON_INIT { using namespace MR::MeshSave; setMeshSaver( filter, { static_cast<MeshFileSaver>( saver ), static_cast<MeshStreamSaver>( saver ), caps } ); };
194#define MR_ADD_MESH_SAVER_WITH_PRIORITY( filter, saver, caps, priority ) \
195MR_ON_INIT { using namespace MR::MeshSave; setMeshSaver( filter, { static_cast<MeshFileSaver>( saver ), static_cast<MeshStreamSaver>( saver ), caps }, priority ); };
213#define MR_ADD_LINES_LOADER( filter, loader ) \
214MR_ON_INIT { using namespace MR::LinesLoad; setLinesLoader( filter, { static_cast<LinesFileLoader>( loader ), static_cast<LinesStreamLoader>( loader ) } ); };
216#define MR_ADD_LINES_LOADER_WITH_PRIORITY( filter, loader, priority ) \
217MR_ON_INIT { using namespace MR::LinesLoad; setLinesLoader( filter, { static_cast<LinesFileLoader>( loader ), static_cast<LinesStreamLoader>( loader ) }, priority ); };
235#define MR_ADD_LINES_SAVER( filter, saver ) \
236MR_ON_INIT { using namespace MR::LinesSave; setLinesSaver( filter, { static_cast<LinesFileSaver>( saver ), static_cast<LinesStreamSaver>( saver ) } ); };
238#define MR_ADD_LINES_SAVER_WITH_PRIORITY( filter, saver, priority ) \
239MR_ON_INIT { using namespace MR::LinesSave; setLinesSaver( filter, { static_cast<LinesFileSaver>( saver ), static_cast<LinesStreamSaver>( saver ) }, priority ); };
257#define MR_ADD_POINTS_LOADER( filter, loader ) \
258MR_ON_INIT { using namespace MR::PointsLoad; setPointsLoader( filter, { static_cast<PointsFileLoader>( loader ), static_cast<PointsStreamLoader>( loader ) } ); };
276#define MR_ADD_POINTS_SAVER( filter, saver ) \
277MR_ON_INIT { using namespace MR::PointsSave; setPointsSaver( filter, { static_cast<PointsFileSaver>( saver ), static_cast<PointsStreamSaver>( saver ) } ); };
288#define MR_ADD_IMAGE_LOADER( filter, loader ) \
289MR_ON_INIT { using namespace MR::ImageLoad; setImageLoader( filter, loader ); };
291#define MR_ADD_IMAGE_LOADER_WITH_PRIORITY( filter, loader, priority ) \
292MR_ON_INIT { using namespace MR::ImageLoad; setImageLoader( filter, loader, priority ); };
303#define MR_ADD_IMAGE_SAVER( filter, saver ) \
304MR_ON_INIT { using namespace MR::ImageSave; setImageSaver( filter, saver ); };
306#define MR_ADD_IMAGE_SAVER_WITH_PRIORITY( filter, saver, priority ) \
307MR_ON_INIT { using namespace MR::ImageSave; setImageSaver( filter, saver, priority ); };
318#define MR_ADD_OBJECT_LOADER( filter, loader ) \
319MR_ON_INIT { using namespace MR::ObjectLoad; setObjectLoader( filter, loader ); };
330#define MR_ADD_OBJECT_SAVER( filter, saver ) \
331MR_ON_INIT { using namespace MR::ObjectSave; setObjectSaver( filter, saver ); };
335namespace AsyncObjectLoad
352#define MR_ADD_SCENE_LOADER( filter, loader ) \
353MR_ON_INIT { using namespace MR::SceneLoad; setSceneLoader( filter, loader ); };
355#define MR_ADD_SCENE_LOADER_WITH_PRIORITY( filter, loader, priority ) \
356MR_ON_INIT { using namespace MR::SceneLoad; setSceneLoader( filter, loader, priority ); };
367#define MR_ADD_SCENE_SAVER( filter, saver ) \
368MR_ON_INIT { using namespace MR::SceneSave; setSceneSaver( filter, saver ); };
370#define MR_ADD_SCENE_SAVER_WITH_PRIORITY( filter, saver, priority ) \
371MR_ON_INIT { using namespace MR::SceneSave; setSceneSaver( filter, saver, priority ); };
375namespace DistanceMapLoad
382#define MR_ADD_DISTANCE_MAP_LOADER( filter, loader ) \
383MR_ON_INIT { using namespace MR::DistanceMapLoad; setDistanceMapLoader( filter, loader ); };
385#define MR_ADD_DISTANCE_MAP_LOADER_WITH_PRIORITY( filter, loader, priority ) \
386MR_ON_INIT { using namespace MR::DistanceMapLoad; setDistanceMapLoader( filter, loader, priority ); };
390namespace DistanceMapSave
397#define MR_ADD_DISTANCE_MAP_SAVER( filter, saver ) \
398MR_ON_INIT { using namespace MR::DistanceMapSave; setDistanceMapSaver( filter, saver ); };
400#define MR_ADD_DISTANCE_MAP_SAVER_WITH_PRIORITY( filter, saver, priority ) \
401MR_ON_INIT { using namespace MR::DistanceMapSave; setDistanceMapSaver( filter, saver, priority ); };
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
Definition MRDistanceMap.h:24
named object in the data model
Definition MRObject.h:62
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:732
std::vector< IOFilter > IOFilters
Definition MRIOFilters.h:32
std::function< void(Expected< LoadedObjects >)> PostLoadCallback
Definition MRIOFormatsRegistry.h:338
void(*)(const std::filesystem::path &, PostLoadCallback, const ProgressCallback &) ObjectLoader
Definition MRIOFormatsRegistry.h:339
Expected< DistanceMap >(*)(const std::filesystem::path &path, const DistanceMapLoadSettings &settings) DistanceMapLoader
Definition MRIOFormatsRegistry.h:378
Expected< void >(*)(const DistanceMap &distanceMap, const std::filesystem::path &path, const DistanceMapSaveSettings &settings) DistanceMapSaver
Definition MRIOFormatsRegistry.h:393
Expected< Image >(*)(const std::filesystem::path &) ImageLoader
Definition MRIOFormatsRegistry.h:284
Expected< void >(*)(const Image &, const std::filesystem::path &) ImageSaver
Definition MRIOFormatsRegistry.h:299
Expected< Polyline3 >(*)(std::istream &, const LinesLoadSettings &) LinesStreamLoader
Definition MRIOFormatsRegistry.h:203
Expected< Polyline3 >(*)(const std::filesystem::path &, const LinesLoadSettings &) LinesFileLoader
Definition MRIOFormatsRegistry.h:202
Expected< void >(*)(const Polyline3 &, std::ostream &, const SaveSettings &) LinesStreamSaver
Definition MRIOFormatsRegistry.h:225
Expected< void >(*)(const Polyline3 &, const std::filesystem::path &, const SaveSettings &) LinesFileSaver
Definition MRIOFormatsRegistry.h:224
Expected< void >(*)(const Mesh &, const std::filesystem::path &, const SaveSettings &) MeshFileSaver
Definition MRIOFormatsRegistry.h:168
Expected< void >(*)(const Mesh &, std::ostream &, const SaveSettings &) MeshStreamSaver
Definition MRIOFormatsRegistry.h:169
Expected< LoadedObjects >(*)(const std::filesystem::path &, const ProgressCallback &) ObjectLoader
Definition MRIOFormatsRegistry.h:314
Expected< void >(*)(const Object &, const std::filesystem::path &, const Settings &) ObjectSaver
Definition MRIOFormatsRegistry.h:326
Expected< PointCloud >(*)(std::istream &, const PointsLoadSettings &) PointsStreamLoader
Definition MRIOFormatsRegistry.h:247
Expected< PointCloud >(*)(const std::filesystem::path &, const PointsLoadSettings &) PointsFileLoader
Definition MRIOFormatsRegistry.h:246
Expected< void >(*)(const PointCloud &, std::ostream &, const SaveSettings &) PointsStreamSaver
Definition MRIOFormatsRegistry.h:266
Expected< void >(*)(const PointCloud &, const std::filesystem::path &, const SaveSettings &) PointsFileSaver
Definition MRIOFormatsRegistry.h:265
Expected< LoadedObject >(*)(const std::filesystem::path &, const ProgressCallback &) SceneLoader
Definition MRIOFormatsRegistry.h:348
Expected< void >(*)(const Object &, const std::filesystem::path &, const ObjectSave::Settings &) SceneSaver
Definition MRIOFormatsRegistry.h:363
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:28
MRMESH_API const IOFilters AllFilter
settings for loading distance maps from external formats
Definition MRDistanceMapParams.h:189
determines how to save distance maps
Definition MRDistanceMapParams.h:198
Definition MRIOFilters.h:17
setting for polyline loading from external format, and locations of optional output data
Definition MRLinesLoadSettings.h:10
Definition MRIOFormatsRegistry.h:206
LinesFileLoader fileLoad
Definition MRIOFormatsRegistry.h:207
LinesStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:208
Definition MRIOFormatsRegistry.h:228
LinesStreamSaver streamSave
Definition MRIOFormatsRegistry.h:230
LinesFileSaver fileSave
Definition MRIOFormatsRegistry.h:229
setting for mesh loading from external format, and locations of optional output data
Definition MRMeshLoadSettings.h:11
Definition MRIOFormatsRegistry.h:142
MeshFileLoader fileLoad
Definition MRIOFormatsRegistry.h:143
MeshStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:144
describes optional abilities of a MeshSaver
Definition MRIOFormatsRegistry.h:173
bool storesVertexColors
true if the saver serializes per-vertex mesh colors, false if per-vertex colors are not saved
Definition MRIOFormatsRegistry.h:175
Definition MRIOFormatsRegistry.h:179
MeshStreamSaver streamSave
saver in a std::ostream
Definition MRIOFormatsRegistry.h:184
MeshFileSaver fileSave
saver in a file given by its path
Definition MRIOFormatsRegistry.h:181
MeshSaverCapabilities capabilities
Definition MRIOFormatsRegistry.h:186
Definition MRMesh/MRMesh.h:23
Definition MRObjectSaveSettings.h:11
Definition MRMesh/MRPointCloud.h:17
Definition MRMesh/MRPointsLoadSettings.h:10
Definition MRIOFormatsRegistry.h:250
PointsFileLoader fileLoad
Definition MRIOFormatsRegistry.h:251
PointsStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:252
Definition MRIOFormatsRegistry.h:269
PointsFileSaver fileSave
Definition MRIOFormatsRegistry.h:270
PointsStreamSaver streamSave
Definition MRIOFormatsRegistry.h:271
determines how to save points/lines/mesh
Definition MRMesh/MRSaveSettings.h:17