3#ifndef MR_PARSING_FOR_PB11_BINDINGS
14#define MR_FORMAT_REGISTRY_EXTERNAL_DECL( API_ATTR, ProcName ) \
15API_ATTR ProcName MR_CONCAT( get, ProcName )( const IOFilter& filter ); \
16API_ATTR ProcName MR_CONCAT( get, ProcName )( const std::string& extension ); \
17API_ATTR void MR_CONCAT( set, ProcName )( const IOFilter& filter, ProcName proc, int8_t priorityScore = 0 ); \
18API_ATTR const IOFilters& getFilters();
20#define MR_FORMAT_REGISTRY_DECL( ProcName ) MR_FORMAT_REGISTRY_EXTERNAL_DECL( MRMESH_API, ProcName )
22#define MR_FORMAT_REGISTRY_IMPL( ProcName ) \
23ProcName MR_CONCAT( get, ProcName )( const IOFilter& filter ) \
25 return FormatRegistry<ProcName>::getProcessor( filter ); \
27ProcName MR_CONCAT( get, ProcName )( const std::string& extension ) \
29 return FormatRegistry<ProcName>::getProcessor( extension ); \
31void MR_CONCAT( set, ProcName )( const IOFilter& filter, ProcName processor, int8_t priorityScore ) \
33 FormatRegistry<ProcName>::setProcessor( filter, processor, priorityScore ); \
35const IOFilters& getFilters() \
37 return FormatRegistry<ProcName>::getFilters(); \
48template <
typename Processor>
55 return get_().filters_;
61 const auto& processors = get_().processors_;
62 auto it = processors.find( filter );
63 if ( it != processors.end() )
72 const auto& processors = get_().processors_;
74 auto it = std::find_if( processors.begin(), processors.end(), [&extension] (
auto&& item )
76 const auto& [filter, _] = item;
77 return filter.isSupportedExtension( extension );
79 if ( it != processors.end() )
88 auto& processors = get_().processors_;
89 auto it = processors.find( filter );
90 if ( it != processors.end() )
92 it->second = processor;
96 processors.emplace( filter, processor );
98 auto& filters = get_().filterPriorityQueue_;
99 filters.emplace( priorityScore, filter );
100 get_().updateFilterList_();
114 void updateFilterList_()
117 filters_.reserve( filterPriorityQueue_.size() );
118 for (
const auto& [_, filter] : filterPriorityQueue_ )
119 filters_.emplace_back( filter );
122 std::map<IOFilter, Processor> processors_;
123 std::multimap<int8_t, IOFilter> filterPriorityQueue_;
124 std::vector<IOFilter> filters_;
151#define MR_ADD_MESH_LOADER( filter, loader ) \
152MR_ON_INIT { using namespace MR::MeshLoad; setMeshLoader( filter, { static_cast<MeshFileLoader>( loader ), static_cast<MeshStreamLoader>( loader ) } ); };
154#define MR_ADD_MESH_LOADER_WITH_PRIORITY( filter, loader, priority ) \
155MR_ON_INIT { using namespace MR::MeshLoad; setMeshLoader( filter, { static_cast<MeshFileLoader>( loader ), static_cast<MeshStreamLoader>( loader ) }, priority ); };
175#define MR_ADD_MESH_SAVER( filter, saver ) \
176MR_ON_INIT { using namespace MR::MeshSave; setMeshSaver( filter, { static_cast<MeshFileSaver>( saver ), static_cast<MeshStreamSaver>( saver ) } ); };
178#define MR_ADD_MESH_SAVER_WITH_PRIORITY( filter, saver, priority ) \
179MR_ON_INIT { using namespace MR::MeshSave; setMeshSaver( filter, { static_cast<MeshFileSaver>( saver ), static_cast<MeshStreamSaver>( saver ) }, priority ); };
197#define MR_ADD_LINES_LOADER( filter, loader ) \
198MR_ON_INIT { using namespace MR::LinesLoad; setLinesLoader( filter, { static_cast<LinesFileLoader>( loader ), static_cast<LinesStreamLoader>( loader ) } ); };
200#define MR_ADD_LINES_LOADER_WITH_PRIORITY( filter, loader, priority ) \
201MR_ON_INIT { using namespace MR::LinesLoad; setLinesLoader( filter, { static_cast<LinesFileLoader>( loader ), static_cast<LinesStreamLoader>( loader ) }, priority ); };
219#define MR_ADD_LINES_SAVER( filter, saver ) \
220MR_ON_INIT { using namespace MR::LinesSave; setLinesSaver( filter, { static_cast<LinesFileSaver>( saver ), static_cast<LinesStreamSaver>( saver ) } ); };
222#define MR_ADD_LINES_SAVER_WITH_PRIORITY( filter, saver, priority ) \
223MR_ON_INIT { using namespace MR::LinesSave; setLinesSaver( filter, { static_cast<LinesFileSaver>( saver ), static_cast<LinesStreamSaver>( saver ) }, priority ); };
241#define MR_ADD_POINTS_LOADER( filter, loader ) \
242MR_ON_INIT { using namespace MR::PointsLoad; setPointsLoader( filter, { static_cast<PointsFileLoader>( loader ), static_cast<PointsStreamLoader>( loader ) } ); };
260#define MR_ADD_POINTS_SAVER( filter, saver ) \
261MR_ON_INIT { using namespace MR::PointsSave; setPointsSaver( filter, { static_cast<PointsFileSaver>( saver ), static_cast<PointsStreamSaver>( saver ) } ); };
272#define MR_ADD_IMAGE_LOADER( filter, loader ) \
273MR_ON_INIT { using namespace MR::ImageLoad; setImageLoader( filter, loader ); };
275#define MR_ADD_IMAGE_LOADER_WITH_PRIORITY( filter, loader, priority ) \
276MR_ON_INIT { using namespace MR::ImageLoad; setImageLoader( filter, loader, priority ); };
287#define MR_ADD_IMAGE_SAVER( filter, saver ) \
288MR_ON_INIT { using namespace MR::ImageSave; setImageSaver( filter, saver ); };
290#define MR_ADD_IMAGE_SAVER_WITH_PRIORITY( filter, saver, priority ) \
291MR_ON_INIT { using namespace MR::ImageSave; setImageSaver( filter, saver, priority ); };
304#define MR_ADD_OBJECT_LOADER( filter, loader ) \
305MR_ON_INIT { using namespace MR::ObjectLoad; setObjectLoader( filter, loader ); };
316#define MR_ADD_OBJECT_SAVER( filter, saver ) \
317MR_ON_INIT { using namespace MR::ObjectSave; setObjectSaver( filter, saver ); };
321namespace AsyncObjectLoad
338#define MR_ADD_SCENE_LOADER( filter, loader ) \
339MR_ON_INIT { using namespace MR::SceneLoad; setSceneLoader( filter, loader ); };
341#define MR_ADD_SCENE_LOADER_WITH_PRIORITY( filter, loader, priority ) \
342MR_ON_INIT { using namespace MR::SceneLoad; setSceneLoader( filter, loader, priority ); };
353#define MR_ADD_SCENE_SAVER( filter, saver ) \
354MR_ON_INIT { using namespace MR::SceneSave; setSceneSaver( filter, saver ); };
356#define MR_ADD_SCENE_SAVER_WITH_PRIORITY( filter, saver, priority ) \
357MR_ON_INIT { using namespace MR::SceneSave; setSceneSaver( filter, saver, priority ); };
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
named object in the data model
Definition MRObject.h:60
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:576
std::vector< IOFilter > IOFilters
Definition MRIOFilters.h:32
std::function< void(Expected< std::vector< ObjectPtr > >)> PostLoadCallback
Definition MRIOFormatsRegistry.h:324
void(*)(const std::filesystem::path &, std::string *, PostLoadCallback, ProgressCallback) ObjectLoader
Definition MRIOFormatsRegistry.h:325
Expected< Image >(*)(const std::filesystem::path &) ImageLoader
Definition MRIOFormatsRegistry.h:268
Expected< void >(*)(const Image &, const std::filesystem::path &) ImageSaver
Definition MRIOFormatsRegistry.h:283
Expected< Polyline3 >(*)(std::istream &, ProgressCallback) LinesStreamLoader
Definition MRIOFormatsRegistry.h:187
Expected< Polyline3 >(*)(const std::filesystem::path &, ProgressCallback) LinesFileLoader
Definition MRIOFormatsRegistry.h:186
Expected< void >(*)(const Polyline3 &, std::ostream &, const SaveSettings &) LinesStreamSaver
Definition MRIOFormatsRegistry.h:209
Expected< void >(*)(const Polyline3 &, const std::filesystem::path &, const SaveSettings &) LinesFileSaver
Definition MRIOFormatsRegistry.h:208
Expected< void >(*)(const Mesh &, const std::filesystem::path &, const SaveSettings &) MeshFileSaver
Definition MRIOFormatsRegistry.h:164
Expected< void >(*)(const Mesh &, std::ostream &, const SaveSettings &) MeshStreamSaver
Definition MRIOFormatsRegistry.h:165
Expected< std::vector< ObjectPtr > >(*)(const std::filesystem::path &, std::string *, ProgressCallback) ObjectLoader
Definition MRIOFormatsRegistry.h:300
Expected< void >(*)(const Object &, const std::filesystem::path &, const ProgressCallback &) ObjectSaver
Definition MRIOFormatsRegistry.h:312
Expected< PointCloud >(*)(std::istream &, const PointsLoadSettings &) PointsStreamLoader
Definition MRIOFormatsRegistry.h:231
Expected< PointCloud >(*)(const std::filesystem::path &, const PointsLoadSettings &) PointsFileLoader
Definition MRIOFormatsRegistry.h:230
Expected< void >(*)(const PointCloud &, std::ostream &, const SaveSettings &) PointsStreamSaver
Definition MRIOFormatsRegistry.h:250
Expected< void >(*)(const PointCloud &, const std::filesystem::path &, const SaveSettings &) PointsFileSaver
Definition MRIOFormatsRegistry.h:249
Expected< ObjectPtr >(*)(const std::filesystem::path &, std::string *, ProgressCallback) SceneLoader
Definition MRIOFormatsRegistry.h:334
Expected< void >(*)(const Object &, const std::filesystem::path &, ProgressCallback) SceneSaver
Definition MRIOFormatsRegistry.h:349
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:58
std::shared_ptr< Object > ObjectPtr
Definition MRIOFormatsRegistry.h:295
MRMESH_API const IOFilters AllFilter
Definition MRIOFilters.h:17
Definition MRIOFormatsRegistry.h:190
LinesFileLoader fileLoad
Definition MRIOFormatsRegistry.h:191
LinesStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:192
Definition MRIOFormatsRegistry.h:212
LinesStreamSaver streamSave
Definition MRIOFormatsRegistry.h:214
LinesFileSaver fileSave
Definition MRIOFormatsRegistry.h:213
setting for mesh loading from external format, and locations of optional output data
Definition MRMeshLoadSettings.h:10
Definition MRIOFormatsRegistry.h:138
MeshFileLoader fileLoad
Definition MRIOFormatsRegistry.h:139
MeshStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:140
Definition MRIOFormatsRegistry.h:168
MeshStreamSaver streamSave
Definition MRIOFormatsRegistry.h:170
MeshFileSaver fileSave
Definition MRIOFormatsRegistry.h:169
Definition MRMesh/MRMesh.h:23
Definition MRMesh/MRPointCloud.h:16
Definition MRPointsLoadSettings.h:10
Definition MRIOFormatsRegistry.h:234
PointsFileLoader fileLoad
Definition MRIOFormatsRegistry.h:235
PointsStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:236
Definition MRIOFormatsRegistry.h:253
PointsFileSaver fileSave
Definition MRIOFormatsRegistry.h:254
PointsStreamSaver streamSave
Definition MRIOFormatsRegistry.h:255
determines how to save points/lines/mesh
Definition MRSaveSettings.h:14