MeshLib C++ Docs
Loading...
Searching...
No Matches
MRSubfeatures.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMesh/MRFeatures.h"
4
5#include <functional>
6
7namespace MR::Features
8{
9
10// Describes a single feature produced by `forEachSubfeature()`.
11struct SubfeatureInfo
12{
13 // A user-friendly name.
14 std::string_view name;
15
16 // Whether the feature has infinite length.
17 bool isInfinite = false;
18
19 // Call this to create this subfeature.
20 // Pass the same feature you passed to `forEachSubfeature()`, or a DIFFERENT one to create the same kind of subfeature relative to that.
21 std::function<Primitives::Variant( const Features::Primitives::Variant& feature )> create;
22};
23
24// A user callback for `forEachSubfeature()`.
25using SubfeatureFunc = std::function<void( const SubfeatureInfo& info )>;
26
27// Decomposes a feature to its subfeatures, by calling `func()` on each subfeature.
28// This only returns the direct subfeatures. You can call this recursively to obtain all features,
29// but beware of duplicates (there's no easy way to filter them).
30MRMESH_API void forEachSubfeature( const Features::Primitives::Variant& feature, const SubfeatureFunc& func );
31
32}
#define MRMESH_API
Definition MRMeshFwd.h:80
Definition MRFeatures.h:20
MRMESH_API void forEachSubfeature(const Features::Primitives::Variant &feature, const SubfeatureFunc &func)