3#ifndef MR_PARSING_FOR_PB11_BINDINGS
15#define MR_FORMAT_REGISTRY_EXTERNAL_DECL( API_ATTR, ProcName ) \
16API_ATTR ProcName MR_CONCAT( get, ProcName )( const IOFilter& filter ); \
17API_ATTR ProcName MR_CONCAT( get, ProcName )( const std::string& extension ); \
18API_ATTR void MR_CONCAT( set, ProcName )( const IOFilter& filter, ProcName proc, int8_t priorityScore = 0 ); \
19API_ATTR const IOFilters& getFilters();
21#define MR_FORMAT_REGISTRY_DECL( ProcName ) MR_FORMAT_REGISTRY_EXTERNAL_DECL( MRMESH_API, ProcName )
23#define MR_FORMAT_REGISTRY_IMPL( ProcName ) \
24ProcName MR_CONCAT( get, ProcName )( const IOFilter& filter ) \
26 return FormatRegistry<ProcName>::getProcessor( filter ); \
28ProcName MR_CONCAT( get, ProcName )( const std::string& extension ) \
30 return FormatRegistry<ProcName>::getProcessor( extension ); \
32void MR_CONCAT( set, ProcName )( const IOFilter& filter, ProcName processor, int8_t priorityScore ) \
34 FormatRegistry<ProcName>::setProcessor( filter, processor, priorityScore ); \
36const IOFilters& getFilters() \
38 return FormatRegistry<ProcName>::getFilters(); \
49template <
typename Processor>
56 return get_().filters_;
62 const auto& processors = get_().processors_;
63 auto it = processors.find( filter );
64 if ( it != processors.end() )
73 const auto& processors = get_().processors_;
75 auto it = std::find_if( processors.begin(), processors.end(), [&extension] (
auto&& item )
77 const auto& [filter, _] = item;
78 return filter.isSupportedExtension( extension );
80 if ( it != processors.end() )
89 auto& processors = get_().processors_;
90 auto it = processors.find( filter );
91 if ( it != processors.end() )
93 it->second = processor;
97 processors.emplace( filter, processor );
99 auto& filters = get_().filterPriorityQueue_;
100 filters.emplace( priorityScore, filter );
101 get_().updateFilterList_();
115 void updateFilterList_()
118 filters_.reserve( filterPriorityQueue_.size() );
119 for (
const auto& [_, filter] : filterPriorityQueue_ )
120 filters_.emplace_back( filter );
123 std::map<IOFilter, Processor> processors_;
124 std::multimap<int8_t, IOFilter> filterPriorityQueue_;
125 std::vector<IOFilter> filters_;
152#define MR_ADD_MESH_LOADER( filter, loader ) \
153MR_ON_INIT { using namespace MR::MeshLoad; setMeshLoader( filter, { static_cast<MeshFileLoader>( loader ), static_cast<MeshStreamLoader>( loader ) } ); };
155#define MR_ADD_MESH_LOADER_WITH_PRIORITY( filter, loader, priority ) \
156MR_ON_INIT { using namespace MR::MeshLoad; setMeshLoader( filter, { static_cast<MeshFileLoader>( loader ), static_cast<MeshStreamLoader>( loader ) }, priority ); };
176#define MR_ADD_MESH_SAVER( filter, saver ) \
177MR_ON_INIT { using namespace MR::MeshSave; setMeshSaver( filter, { static_cast<MeshFileSaver>( saver ), static_cast<MeshStreamSaver>( saver ) } ); };
179#define MR_ADD_MESH_SAVER_WITH_PRIORITY( filter, saver, priority ) \
180MR_ON_INIT { using namespace MR::MeshSave; setMeshSaver( filter, { static_cast<MeshFileSaver>( saver ), static_cast<MeshStreamSaver>( saver ) }, priority ); };
198#define MR_ADD_LINES_LOADER( filter, loader ) \
199MR_ON_INIT { using namespace MR::LinesLoad; setLinesLoader( filter, { static_cast<LinesFileLoader>( loader ), static_cast<LinesStreamLoader>( loader ) } ); };
201#define MR_ADD_LINES_LOADER_WITH_PRIORITY( filter, loader, priority ) \
202MR_ON_INIT { using namespace MR::LinesLoad; setLinesLoader( filter, { static_cast<LinesFileLoader>( loader ), static_cast<LinesStreamLoader>( loader ) }, priority ); };
220#define MR_ADD_LINES_SAVER( filter, saver ) \
221MR_ON_INIT { using namespace MR::LinesSave; setLinesSaver( filter, { static_cast<LinesFileSaver>( saver ), static_cast<LinesStreamSaver>( saver ) } ); };
223#define MR_ADD_LINES_SAVER_WITH_PRIORITY( filter, saver, priority ) \
224MR_ON_INIT { using namespace MR::LinesSave; setLinesSaver( filter, { static_cast<LinesFileSaver>( saver ), static_cast<LinesStreamSaver>( saver ) }, priority ); };
242#define MR_ADD_POINTS_LOADER( filter, loader ) \
243MR_ON_INIT { using namespace MR::PointsLoad; setPointsLoader( filter, { static_cast<PointsFileLoader>( loader ), static_cast<PointsStreamLoader>( loader ) } ); };
261#define MR_ADD_POINTS_SAVER( filter, saver ) \
262MR_ON_INIT { using namespace MR::PointsSave; setPointsSaver( filter, { static_cast<PointsFileSaver>( saver ), static_cast<PointsStreamSaver>( saver ) } ); };
273#define MR_ADD_IMAGE_LOADER( filter, loader ) \
274MR_ON_INIT { using namespace MR::ImageLoad; setImageLoader( filter, loader ); };
276#define MR_ADD_IMAGE_LOADER_WITH_PRIORITY( filter, loader, priority ) \
277MR_ON_INIT { using namespace MR::ImageLoad; setImageLoader( filter, loader, priority ); };
288#define MR_ADD_IMAGE_SAVER( filter, saver ) \
289MR_ON_INIT { using namespace MR::ImageSave; setImageSaver( filter, saver ); };
291#define MR_ADD_IMAGE_SAVER_WITH_PRIORITY( filter, saver, priority ) \
292MR_ON_INIT { using namespace MR::ImageSave; setImageSaver( filter, saver, priority ); };
303#define MR_ADD_OBJECT_LOADER( filter, loader ) \
304MR_ON_INIT { using namespace MR::ObjectLoad; setObjectLoader( filter, loader ); };
315#define MR_ADD_OBJECT_SAVER( filter, saver ) \
316MR_ON_INIT { using namespace MR::ObjectSave; setObjectSaver( filter, saver ); };
320namespace AsyncObjectLoad
337#define MR_ADD_SCENE_LOADER( filter, loader ) \
338MR_ON_INIT { using namespace MR::SceneLoad; setSceneLoader( filter, loader ); };
340#define MR_ADD_SCENE_LOADER_WITH_PRIORITY( filter, loader, priority ) \
341MR_ON_INIT { using namespace MR::SceneLoad; setSceneLoader( filter, loader, priority ); };
352#define MR_ADD_SCENE_SAVER( filter, saver ) \
353MR_ON_INIT { using namespace MR::SceneSave; setSceneSaver( filter, saver ); };
355#define MR_ADD_SCENE_SAVER_WITH_PRIORITY( filter, saver, priority ) \
356MR_ON_INIT { using namespace MR::SceneSave; setSceneSaver( filter, saver, priority ); };
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:68
named object in the data model
Definition MRObject.h:60
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:600
std::vector< IOFilter > IOFilters
Definition MRIOFilters.h:32
std::function< void(Expected< LoadedObjects >)> PostLoadCallback
Definition MRIOFormatsRegistry.h:323
void(*)(const std::filesystem::path &, PostLoadCallback, const ProgressCallback &) ObjectLoader
Definition MRIOFormatsRegistry.h:324
Expected< Image >(*)(const std::filesystem::path &) ImageLoader
Definition MRIOFormatsRegistry.h:269
Expected< void >(*)(const Image &, const std::filesystem::path &) ImageSaver
Definition MRIOFormatsRegistry.h:284
Expected< Polyline3 >(*)(std::istream &, ProgressCallback) LinesStreamLoader
Definition MRIOFormatsRegistry.h:188
Expected< Polyline3 >(*)(const std::filesystem::path &, ProgressCallback) LinesFileLoader
Definition MRIOFormatsRegistry.h:187
Expected< void >(*)(const Polyline3 &, std::ostream &, const SaveSettings &) LinesStreamSaver
Definition MRIOFormatsRegistry.h:210
Expected< void >(*)(const Polyline3 &, const std::filesystem::path &, const SaveSettings &) LinesFileSaver
Definition MRIOFormatsRegistry.h:209
Expected< void >(*)(const Mesh &, const std::filesystem::path &, const SaveSettings &) MeshFileSaver
Definition MRIOFormatsRegistry.h:165
Expected< void >(*)(const Mesh &, std::ostream &, const SaveSettings &) MeshStreamSaver
Definition MRIOFormatsRegistry.h:166
Expected< LoadedObjects >(*)(const std::filesystem::path &, const ProgressCallback &) ObjectLoader
Definition MRIOFormatsRegistry.h:299
Expected< void >(*)(const Object &, const std::filesystem::path &, const ProgressCallback &) ObjectSaver
Definition MRIOFormatsRegistry.h:311
Expected< PointCloud >(*)(std::istream &, const PointsLoadSettings &) PointsStreamLoader
Definition MRIOFormatsRegistry.h:232
Expected< PointCloud >(*)(const std::filesystem::path &, const PointsLoadSettings &) PointsFileLoader
Definition MRIOFormatsRegistry.h:231
Expected< void >(*)(const PointCloud &, std::ostream &, const SaveSettings &) PointsStreamSaver
Definition MRIOFormatsRegistry.h:251
Expected< void >(*)(const PointCloud &, const std::filesystem::path &, const SaveSettings &) PointsFileSaver
Definition MRIOFormatsRegistry.h:250
Expected< LoadedObject >(*)(const std::filesystem::path &, const ProgressCallback &) SceneLoader
Definition MRIOFormatsRegistry.h:333
Expected< void >(*)(const Object &, const std::filesystem::path &, ProgressCallback) SceneSaver
Definition MRIOFormatsRegistry.h:348
tl::expected< T, E > Expected
Definition MRExpected.h:58
MRMESH_API const IOFilters AllFilter
Definition MRIOFilters.h:17
Definition MRIOFormatsRegistry.h:191
LinesFileLoader fileLoad
Definition MRIOFormatsRegistry.h:192
LinesStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:193
Definition MRIOFormatsRegistry.h:213
LinesStreamSaver streamSave
Definition MRIOFormatsRegistry.h:215
LinesFileSaver fileSave
Definition MRIOFormatsRegistry.h:214
setting for mesh loading from external format, and locations of optional output data
Definition MRMeshLoadSettings.h:10
Definition MRIOFormatsRegistry.h:139
MeshFileLoader fileLoad
Definition MRIOFormatsRegistry.h:140
MeshStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:141
Definition MRIOFormatsRegistry.h:169
MeshStreamSaver streamSave
Definition MRIOFormatsRegistry.h:171
MeshFileSaver fileSave
Definition MRIOFormatsRegistry.h:170
Definition MRMesh/MRMesh.h:23
Definition MRMesh/MRPointCloud.h:16
Definition MRMesh/MRPointsLoadSettings.h:10
Definition MRIOFormatsRegistry.h:235
PointsFileLoader fileLoad
Definition MRIOFormatsRegistry.h:236
PointsStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:237
Definition MRIOFormatsRegistry.h:254
PointsFileSaver fileSave
Definition MRIOFormatsRegistry.h:255
PointsStreamSaver streamSave
Definition MRIOFormatsRegistry.h:256
determines how to save points/lines/mesh
Definition MRMesh/MRSaveSettings.h:14