CreoOtkPluging/ShrinkwrapManager.h
sladro e3b15ef745 优化Shrinkwrap接口 - 修复文件名权限问题并简化执行逻辑
- 新增安全文件名生成函数,基于源模型名清理非法字符
- 移除不必要的递归组件分析和差异计算逻辑
- 简化ExecuteShrinkwrapShell方法,直接调用顶层装配体API
- 解决output_file_path路径权限问题,自动保存到当前工作目录
- 更新文档记录核心优化内容

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-17 16:59:03 +08:00

107 lines
3.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "pfcGlobal.h"
#include "pfcSession.h"
#include "pfcModel.h"
#include "pfcSolid.h"
#include "pfcShrinkwrap.h"
#include "pfcAssembly.h"
#include "wfcAssembly.h"
#include "wfcSession.h"
#include "xstring.h"
#include "pfcExceptions.h"
#include <string>
#include <vector>
#include <map>
#include <memory>
// Simplified data structures for Shrinkwrap
// Shrinkwrap特定的数据结构
struct ShrinkwrapShellRequest {
std::string software_type = "creo";
std::string project_name = "Shrinkwrap Shell Export";
std::string method = "outer_shell";
int quality = 8; // 1-10, 质量等级
double chord_height = 0.1; // 弦高控制三角化误差(mm), 0.05-0.2
bool fill_holes = true; // 自动填孔
bool ignore_small_surfaces = true; // 忽略小表面
double small_surface_percentage = 0.5; // 小表面百分比阈值
std::string output_file_path; // 输出文件路径
std::string output_type = "solid_surface"; // "solid_surface" or "facet"
bool ignore_quilts = true; // 忽略面片
bool ignore_skeleton = true; // 忽略骨架
bool assign_mass_properties = false; // 分配质量属性
std::string preset = ""; // "fast", "balanced", "tight" or ""
int timeout_seconds = 30; // 超时时间(秒), 默认30秒最大300秒
};
struct ShrinkwrapShellParameters {
std::string method;
int quality;
double chord_height;
bool fill_holes;
bool ignore_small_surfaces;
double small_surface_percentage;
std::string output_type;
bool ignore_quilts;
bool ignore_skeleton;
bool assign_mass_properties;
std::string output_file_path;
std::string output_file_size;
std::string shrinkwrap_time;
std::string preset_used;
};
struct ShrinkwrapShellResult {
bool success = false;
ShrinkwrapShellParameters parameters;
std::string message;
std::string error_message;
};
// 会话信息结构复用CreoManager的设计模式
struct SessionInfo {
pfcSession_ptr session;
wfcWSession_ptr wSession;
bool is_valid;
std::string version;
std::string build;
};
class ShrinkwrapManager {
private:
static ShrinkwrapManager* instance;
ShrinkwrapManager() = default;
// 核心辅助方法
SessionInfo GetSessionInfo();
std::string StringToStdString(const xstring& xstr);
xstring StringToXString(const std::string& str);
std::string GetCurrentTimeString();
std::string CalculateFileSize(const std::string& file_path);
std::string GenerateSafePartName(pfcModel_ptr source_model);
// OTK Shrinkwrap执行方法
pfcModel_ptr ExecuteOTKShrinkwrap(pfcModel_ptr source_model,
const ShrinkwrapShellRequest& request);
// 质量属性计算
double CalculateModelVolume(pfcModel_ptr model);
public:
// 单例模式
static ShrinkwrapManager& Instance();
// 主要功能接口
ShrinkwrapShellResult ExecuteShrinkwrapShell(const ShrinkwrapShellRequest& request);
// 验证和辅助接口
bool ValidateRequest(const ShrinkwrapShellRequest& request, std::string& error_message);
std::string GetSupportedFormats();
bool IsCreoSessionAvailable();
// 预设参数处理
void ApplyPresetParameters(ShrinkwrapShellRequest& request);
};