Files
ViewDesignEngine/include/vde/brep/feature_tree.h
T

65 lines
1.4 KiB
C++
Raw Normal View History

#pragma once
#include "vde/brep/brep.h"
#include <string>
#include <vector>
#include <memory>
#include <functional>
namespace vde::brep {
/// Feature operation types
enum class FeatureType {
PrimitiveBox,
PrimitiveCylinder,
PrimitiveSphere,
Extrude,
Fillet,
Chamfer,
Shell,
BooleanUnion,
BooleanDifference,
BooleanIntersection
};
/// Parameters for a feature operation
struct FeatureParams {
std::vector<double> values; // numeric params
std::vector<int> int_values; // integer params
std::string name; // operation name
};
/// One node in the feature tree
struct FeatureNode {
FeatureType type;
FeatureParams params;
std::vector<std::unique_ptr<FeatureNode>> children;
/// Evaluate this feature (rebuild geometry from parameters)
[[nodiscard]] BrepModel evaluate() const;
};
/// Feature tree with undo/redo support
class FeatureHistory {
public:
/// Apply a feature operation
void apply(const BrepModel& input, FeatureType type, const FeatureParams& params);
/// Undo last operation
[[nodiscard]] bool undo();
/// Redo last undone operation
[[nodiscard]] bool redo();
/// Get current model
[[nodiscard]] const BrepModel& current() const;
/// Number of operations in history
[[nodiscard]] size_t size() const { return states_.size(); }
private:
std::vector<BrepModel> states_;
size_t current_idx_ = 0;
};
} // namespace vde::brep