feat(v3.5): perf caching + measure + flange/gear + feature tree + assembly constraints
CI / Build & Test (push) Failing after 1m31s
CI / Release Build (push) Failing after 31s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled

This commit is contained in:
茂之钳
2026-07-24 14:02:24 +00:00
parent f89f5f6bcd
commit 12db7d3e5a
17 changed files with 1487 additions and 2 deletions
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include "vde/brep/assembly.h"
#include "vde/core/point.h"
namespace vde::brep {
/// Constraint types for assembly
enum class ConstraintType {
Coincident, // Face-face coincident (align planes)
Concentric, // Cylinder-cylinder concentric (align axes)
Tangent, // Face-face tangent
Parallel, // Face-face parallel
Perpendicular,// Face-face perpendicular
Distance, // Face-face at fixed distance
Angle // Face-face at fixed angle
};
/// Apply a mate constraint between two assembly nodes
/// @param assembly Target assembly
/// @param node_a First node
/// @param node_b Second node (this one moves to satisfy constraint)
/// @param type Constraint type
/// @param value Optional value (for Distance/Angle constraints)
/// @return true if constraint applied successfully
[[nodiscard]] bool apply_constraint(
Assembly& assembly,
AssemblyNode* node_a,
AssemblyNode* node_b,
ConstraintType type,
double value = 0.0);
} // namespace vde::brep
+64
View File
@@ -0,0 +1,64 @@
#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
+67
View File
@@ -0,0 +1,67 @@
#pragma once
/**
* @file measure.h
* @brief B-Rep 测量工具
*
* 提供 B-Rep 实体的几何属性测量函数:
* - 体积(散度定理)
* - 表面积(三角剖分求和)
* - 质心
* - 两实体间最小距离
*
* @ingroup brep
*/
#include "vde/brep/brep.h"
#include "vde/core/point.h"
namespace vde::brep {
/**
* @brief 计算两个 B-Rep 实体间的最小距离
*
* 通过将两个实体 tessellate 为三角网格,
* 计算所有三角形对之间的最小距离。
*
* @param a 第一个 B-Rep 实体
* @param b 第二个 B-Rep 实体
* @return 最小距离(≥ 0)。若两实体相交则返回 0。
*/
[[nodiscard]] double distance(const BrepModel& a, const BrepModel& b);
/**
* @brief 计算 B-Rep 实体的表面积
*
* 将所有面 tessellate 为三角形,求和三角形面积。
*
* @param body B-Rep 实体
* @return 表面积(平方单位)
*/
[[nodiscard]] double surface_area(const BrepModel& body);
/**
* @brief 计算封闭 B-Rep 实体的体积
*
* 使用散度定理(divergence theorem):
*
* V = (1/3) Σ (面心 · 面法向量 * 三角形面积)
*
* 对 tessellated 网格的所有三角形求和。
*
* @param body 封闭 B-Rep 实体
* @return 体积(立方单位)
*
* @pre body 应为封闭实体(水密)
*/
[[nodiscard]] double volume(const BrepModel& body);
/**
* @brief 计算 B-Rep 实体的质心
*
* 使用 tessellated 网格计算面积加权质心。
*
* @param body B-Rep 实体
* @return 质心坐标
*/
[[nodiscard]] core::Point3D centroid(const BrepModel& body);
} // namespace vde::brep