53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <map>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
#include <wfcAssembly.h>
|
|
#include "CreoManager.h"
|
|
|
|
// 层级统计请求结构
|
|
struct HierarchyStatisticsRequest {
|
|
std::string project_name; // 可选的项目名称,默认使用当前模型名
|
|
std::string subassembly_path; // 可选的子装配体路径,如 "top.asm/sub.asm"
|
|
};
|
|
|
|
// 层级统计结果结构
|
|
struct HierarchyStatisticsResult {
|
|
bool success = false;
|
|
std::string message;
|
|
std::string model_name; // 当前模型名称
|
|
std::string model_type; // 模型类型 (assembly/part)
|
|
int total_levels = 0; // 总层级数
|
|
std::map<int, int> level_statistics; // key: 层级号, value: 该层级的直接子节点数量
|
|
std::string analysis_time; // 分析时间
|
|
std::string error_message;
|
|
};
|
|
|
|
// 层级统计分析器类
|
|
class HierarchyStatisticsAnalyzer {
|
|
public:
|
|
static HierarchyStatisticsAnalyzer& Instance();
|
|
|
|
// 执行层级统计分析
|
|
HierarchyStatisticsResult AnalyzeHierarchyStatistics(const HierarchyStatisticsRequest& request);
|
|
|
|
private:
|
|
HierarchyStatisticsAnalyzer() = default;
|
|
~HierarchyStatisticsAnalyzer() = default;
|
|
|
|
// 禁止拷贝
|
|
HierarchyStatisticsAnalyzer(const HierarchyStatisticsAnalyzer&) = delete;
|
|
HierarchyStatisticsAnalyzer& operator=(const HierarchyStatisticsAnalyzer&) = delete;
|
|
|
|
// 递归分析装配体层级
|
|
void AnalyzeAssemblyLevel(wfcWAssembly_ptr assembly, int level, std::map<int, int>& statistics, int& maxLevel);
|
|
|
|
// 根据路径查找子装配体
|
|
wfcWAssembly_ptr FindSubassemblyByPath(wfcWAssembly_ptr root_assembly, const std::string& path, const std::string& model_name);
|
|
|
|
// 获取当前时间字符串
|
|
std::string GetCurrentTimeString();
|
|
};
|