3#ifndef MR_PARSING_FOR_ANY_BINDINGS
17#define MR_FORMAT_REGISTRY_EXTERNAL_DECL( API_ATTR, ProcName ) \
18API_ATTR ProcName MR_CONCAT( get, ProcName )( const IOFilter& filter ); \
19API_ATTR ProcName MR_CONCAT( get, ProcName )( const std::string& extension ); \
20API_ATTR void MR_CONCAT( set, ProcName )( const IOFilter& filter, ProcName proc, int8_t priorityScore = 0 ); \
21API_ATTR const IOFilters& getFilters();
23#define MR_FORMAT_REGISTRY_DECL( ProcName ) MR_FORMAT_REGISTRY_EXTERNAL_DECL( MRMESH_API, ProcName )
25#define MR_FORMAT_REGISTRY_IMPL( ProcName ) \
26ProcName MR_CONCAT( get, ProcName )( const IOFilter& filter ) \
28 return FormatRegistry<ProcName>::getProcessor( filter ); \
30ProcName MR_CONCAT( get, ProcName )( const std::string& extension ) \
32 return FormatRegistry<ProcName>::getProcessor( extension ); \
34void MR_CONCAT( set, ProcName )( const IOFilter& filter, ProcName processor, int8_t priorityScore ) \
36 FormatRegistry<ProcName>::setProcessor( filter, processor, priorityScore ); \
38const IOFilters& getFilters() \
40 return FormatRegistry<ProcName>::getFilters(); \
51template <
typename Processor>
58 return get_().filters_;
64 const auto& processors = get_().processors_;
65 auto it = processors.find( filter );
66 if ( it != processors.end() )
75 const auto& processors = get_().processors_;
77 auto it = std::find_if( processors.begin(), processors.end(), [&extension] (
auto&& item )
79 const auto& [filter, _] = item;
80 return filter.isSupportedExtension( extension );
82 if ( it != processors.end() )
91 auto& processors = get_().processors_;
92 auto it = processors.find( filter );
93 if ( it != processors.end() )
95 it->second = processor;
99 processors.emplace( filter, processor );
101 auto& filters = get_().filterPriorityQueue_;
102 filters.emplace( priorityScore, filter );
103 get_().updateFilterList_();
117 void updateFilterList_()
120 filters_.reserve( filterPriorityQueue_.size() );
121 for (
const auto& [_, filter] : filterPriorityQueue_ )
122 filters_.emplace_back( filter );
125 std::map<IOFilter, Processor> processors_;
126 std::multimap<int8_t, IOFilter> filterPriorityQueue_;
127 std::vector<IOFilter> filters_;
154#define MR_ADD_MESH_LOADER( filter, loader ) \
155MR_ON_INIT { using namespace MR::MeshLoad; setMeshLoader( filter, { static_cast<MeshFileLoader>( loader ), static_cast<MeshStreamLoader>( loader ) } ); };
157#define MR_ADD_MESH_LOADER_WITH_PRIORITY( filter, loader, priority ) \
158MR_ON_INIT { using namespace MR::MeshLoad; setMeshLoader( filter, { static_cast<MeshFileLoader>( loader ), static_cast<MeshStreamLoader>( loader ) }, priority ); };
190#define MR_ADD_MESH_SAVER( filter, saver, caps ) \
191MR_ON_INIT { using namespace MR::MeshSave; setMeshSaver( filter, { static_cast<MeshFileSaver>( saver ), static_cast<MeshStreamSaver>( saver ), caps } ); };
193#define MR_ADD_MESH_SAVER_WITH_PRIORITY( filter, saver, caps, priority ) \
194MR_ON_INIT { using namespace MR::MeshSave; setMeshSaver( filter, { static_cast<MeshFileSaver>( saver ), static_cast<MeshStreamSaver>( saver ), caps }, priority ); };
212#define MR_ADD_LINES_LOADER( filter, loader ) \
213MR_ON_INIT { using namespace MR::LinesLoad; setLinesLoader( filter, { static_cast<LinesFileLoader>( loader ), static_cast<LinesStreamLoader>( loader ) } ); };
215#define MR_ADD_LINES_LOADER_WITH_PRIORITY( filter, loader, priority ) \
216MR_ON_INIT { using namespace MR::LinesLoad; setLinesLoader( filter, { static_cast<LinesFileLoader>( loader ), static_cast<LinesStreamLoader>( loader ) }, priority ); };
234#define MR_ADD_LINES_SAVER( filter, saver ) \
235MR_ON_INIT { using namespace MR::LinesSave; setLinesSaver( filter, { static_cast<LinesFileSaver>( saver ), static_cast<LinesStreamSaver>( saver ) } ); };
237#define MR_ADD_LINES_SAVER_WITH_PRIORITY( filter, saver, priority ) \
238MR_ON_INIT { using namespace MR::LinesSave; setLinesSaver( filter, { static_cast<LinesFileSaver>( saver ), static_cast<LinesStreamSaver>( saver ) }, priority ); };
256#define MR_ADD_POINTS_LOADER( filter, loader ) \
257MR_ON_INIT { using namespace MR::PointsLoad; setPointsLoader( filter, { static_cast<PointsFileLoader>( loader ), static_cast<PointsStreamLoader>( loader ) } ); };
275#define MR_ADD_POINTS_SAVER( filter, saver ) \
276MR_ON_INIT { using namespace MR::PointsSave; setPointsSaver( filter, { static_cast<PointsFileSaver>( saver ), static_cast<PointsStreamSaver>( saver ) } ); };
287#define MR_ADD_IMAGE_LOADER( filter, loader ) \
288MR_ON_INIT { using namespace MR::ImageLoad; setImageLoader( filter, loader ); };
290#define MR_ADD_IMAGE_LOADER_WITH_PRIORITY( filter, loader, priority ) \
291MR_ON_INIT { using namespace MR::ImageLoad; setImageLoader( filter, loader, priority ); };
302#define MR_ADD_IMAGE_SAVER( filter, saver ) \
303MR_ON_INIT { using namespace MR::ImageSave; setImageSaver( filter, saver ); };
305#define MR_ADD_IMAGE_SAVER_WITH_PRIORITY( filter, saver, priority ) \
306MR_ON_INIT { using namespace MR::ImageSave; setImageSaver( filter, saver, priority ); };
317#define MR_ADD_OBJECT_LOADER( filter, loader ) \
318MR_ON_INIT { using namespace MR::ObjectLoad; setObjectLoader( filter, loader ); };
329#define MR_ADD_OBJECT_SAVER( filter, saver ) \
330MR_ON_INIT { using namespace MR::ObjectSave; setObjectSaver( filter, saver ); };
334namespace AsyncObjectLoad
351#define MR_ADD_SCENE_LOADER( filter, loader ) \
352MR_ON_INIT { using namespace MR::SceneLoad; setSceneLoader( filter, loader ); };
354#define MR_ADD_SCENE_LOADER_WITH_PRIORITY( filter, loader, priority ) \
355MR_ON_INIT { using namespace MR::SceneLoad; setSceneLoader( filter, loader, priority ); };
366#define MR_ADD_SCENE_SAVER( filter, saver ) \
367MR_ON_INIT { using namespace MR::SceneSave; setSceneSaver( filter, saver ); };
369#define MR_ADD_SCENE_SAVER_WITH_PRIORITY( filter, saver, priority ) \
370MR_ON_INIT { using namespace MR::SceneSave; setSceneSaver( filter, saver, priority ); };
374namespace DistanceMapLoad
381#define MR_ADD_DISTANCE_MAP_LOADER( filter, loader ) \
382MR_ON_INIT { using namespace MR::DistanceMapLoad; setDistanceMapLoader( filter, loader ); };
384#define MR_ADD_DISTANCE_MAP_LOADER_WITH_PRIORITY( filter, loader, priority ) \
385MR_ON_INIT { using namespace MR::DistanceMapLoad; setDistanceMapLoader( filter, loader, priority ); };
389namespace DistanceMapSave
396#define MR_ADD_DISTANCE_MAP_SAVER( filter, saver ) \
397MR_ON_INIT { using namespace MR::DistanceMapSave; setDistanceMapSaver( filter, saver ); };
399#define MR_ADD_DISTANCE_MAP_SAVER_WITH_PRIORITY( filter, saver, priority ) \
400MR_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:728
std::vector< IOFilter > IOFilters
Definition MRIOFilters.h:32
std::function< void(Expected< LoadedObjects >)> PostLoadCallback
Definition MRIOFormatsRegistry.h:337
void(*)(const std::filesystem::path &, PostLoadCallback, const ProgressCallback &) ObjectLoader
Definition MRIOFormatsRegistry.h:338
Expected< DistanceMap >(*)(const std::filesystem::path &path, const DistanceMapLoadSettings &settings) DistanceMapLoader
Definition MRIOFormatsRegistry.h:377
Expected< void >(*)(const DistanceMap &distanceMap, const std::filesystem::path &path, const DistanceMapSaveSettings &settings) DistanceMapSaver
Definition MRIOFormatsRegistry.h:392
Expected< Image >(*)(const std::filesystem::path &) ImageLoader
Definition MRIOFormatsRegistry.h:283
Expected< void >(*)(const Image &, const std::filesystem::path &) ImageSaver
Definition MRIOFormatsRegistry.h:298
Expected< Polyline3 >(*)(std::istream &, const LinesLoadSettings &) LinesStreamLoader
Definition MRIOFormatsRegistry.h:202
Expected< Polyline3 >(*)(const std::filesystem::path &, const LinesLoadSettings &) LinesFileLoader
Definition MRIOFormatsRegistry.h:201
Expected< void >(*)(const Polyline3 &, std::ostream &, const SaveSettings &) LinesStreamSaver
Definition MRIOFormatsRegistry.h:224
Expected< void >(*)(const Polyline3 &, const std::filesystem::path &, const SaveSettings &) LinesFileSaver
Definition MRIOFormatsRegistry.h:223
Expected< void >(*)(const Mesh &, const std::filesystem::path &, const SaveSettings &) MeshFileSaver
Definition MRIOFormatsRegistry.h:167
Expected< void >(*)(const Mesh &, std::ostream &, const SaveSettings &) MeshStreamSaver
Definition MRIOFormatsRegistry.h:168
Expected< LoadedObjects >(*)(const std::filesystem::path &, const ProgressCallback &) ObjectLoader
Definition MRIOFormatsRegistry.h:313
Expected< void >(*)(const Object &, const std::filesystem::path &, const ProgressCallback &) ObjectSaver
Definition MRIOFormatsRegistry.h:325
Expected< PointCloud >(*)(std::istream &, const PointsLoadSettings &) PointsStreamLoader
Definition MRIOFormatsRegistry.h:246
Expected< PointCloud >(*)(const std::filesystem::path &, const PointsLoadSettings &) PointsFileLoader
Definition MRIOFormatsRegistry.h:245
Expected< void >(*)(const PointCloud &, std::ostream &, const SaveSettings &) PointsStreamSaver
Definition MRIOFormatsRegistry.h:265
Expected< void >(*)(const PointCloud &, const std::filesystem::path &, const SaveSettings &) PointsFileSaver
Definition MRIOFormatsRegistry.h:264
Expected< LoadedObject >(*)(const std::filesystem::path &, const ProgressCallback &) SceneLoader
Definition MRIOFormatsRegistry.h:347
Expected< void >(*)(const Object &, const std::filesystem::path &, ProgressCallback) SceneSaver
Definition MRIOFormatsRegistry.h:362
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:25
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:205
LinesFileLoader fileLoad
Definition MRIOFormatsRegistry.h:206
LinesStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:207
Definition MRIOFormatsRegistry.h:227
LinesStreamSaver streamSave
Definition MRIOFormatsRegistry.h:229
LinesFileSaver fileSave
Definition MRIOFormatsRegistry.h:228
setting for mesh loading from external format, and locations of optional output data
Definition MRMeshLoadSettings.h:11
Definition MRIOFormatsRegistry.h:141
MeshFileLoader fileLoad
Definition MRIOFormatsRegistry.h:142
MeshStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:143
describes optional abilities of a MeshSaver
Definition MRIOFormatsRegistry.h:172
bool storesVertexColors
true if the saver serializes per-vertex mesh colors, false if per-vertex colors are not saved
Definition MRIOFormatsRegistry.h:174
Definition MRIOFormatsRegistry.h:178
MeshStreamSaver streamSave
saver in a std::ostream
Definition MRIOFormatsRegistry.h:183
MeshFileSaver fileSave
saver in a file given by its path
Definition MRIOFormatsRegistry.h:180
MeshSaverCapabilities capabilities
Definition MRIOFormatsRegistry.h:185
Definition MRMesh/MRMesh.h:23
Definition MRMesh/MRPointCloud.h:17
Definition MRMesh/MRPointsLoadSettings.h:10
Definition MRIOFormatsRegistry.h:249
PointsFileLoader fileLoad
Definition MRIOFormatsRegistry.h:250
PointsStreamLoader streamLoad
Definition MRIOFormatsRegistry.h:251
Definition MRIOFormatsRegistry.h:268
PointsFileSaver fileSave
Definition MRIOFormatsRegistry.h:269
PointsStreamSaver streamSave
Definition MRIOFormatsRegistry.h:270
determines how to save points/lines/mesh
Definition MRMesh/MRSaveSettings.h:14