95 lines
2.5 KiB
C++
95 lines
2.5 KiB
C++
#pragma once
|
||
|
||
#include <wfcSession.h>
|
||
#include <wfcGlobal.h>
|
||
#include <pfcExport.h>
|
||
#include <string>
|
||
#include <vector>
|
||
|
||
// Creo状态信息结构
|
||
struct CreoStatus {
|
||
bool is_connected = false;
|
||
std::string version;
|
||
std::string build;
|
||
std::string working_directory;
|
||
int session_id = 0;
|
||
};
|
||
|
||
// 模型状态信息结构
|
||
struct ModelStatus {
|
||
bool has_model = false;
|
||
std::string name;
|
||
std::string filename;
|
||
std::string type;
|
||
std::string software; // 从OTK API获取,不设默认值
|
||
std::string version; // 从OTK API获取,不设默认值
|
||
std::string connection_time;
|
||
bool is_assembly = false;
|
||
int total_parts = 0;
|
||
int assembly_levels = 0;
|
||
std::string file_size;
|
||
std::string connection_status;
|
||
std::string open_time;
|
||
};
|
||
|
||
// 导出结果结构
|
||
struct ExportResult {
|
||
bool success = false;
|
||
std::string export_path;
|
||
std::string file_size;
|
||
std::string format;
|
||
std::string export_time;
|
||
std::string software;
|
||
std::string original_file;
|
||
std::string dirname;
|
||
std::string filename;
|
||
std::string error_message;
|
||
};
|
||
|
||
// Creo管理器类
|
||
class CreoManager {
|
||
public:
|
||
static CreoManager& Instance();
|
||
|
||
// 状态检测
|
||
CreoStatus GetCreoStatus();
|
||
ModelStatus GetModelStatus();
|
||
|
||
// 基础操作
|
||
bool ShowMessage(const std::string& message);
|
||
|
||
// 导出功能
|
||
ExportResult ExportModelToSTEP(const std::string& export_path, const std::string& geom_flags = "solids");
|
||
|
||
// 辅助功能
|
||
std::string GetCurrentTimeString();
|
||
std::string GetCurrentTimeStringISO();
|
||
std::string GetFileSize(const std::string& filepath);
|
||
int SafeCalculateAssemblyLevels(wfcWAssembly_ptr assembly);
|
||
|
||
// 文件大小统计
|
||
std::string GetModelFileSize(pfcModel_ptr model);
|
||
std::string CalculateAssemblyTotalSize(pfcModel_ptr model);
|
||
double ParseMBFromSizeString(const std::string& size_str);
|
||
|
||
private:
|
||
CreoManager() = default;
|
||
~CreoManager() = default;
|
||
CreoManager(const CreoManager&) = delete;
|
||
CreoManager& operator=(const CreoManager&) = delete;
|
||
|
||
// 辅助函数
|
||
std::string XStringToString(const xstring& xstr);
|
||
xstring StringToXString(const std::string& str);
|
||
|
||
// 会话管理(避免重复代码)
|
||
struct SessionInfo {
|
||
pfcSession_ptr session;
|
||
wfcWSession_ptr wSession;
|
||
bool is_valid;
|
||
std::string version;
|
||
std::string build;
|
||
};
|
||
SessionInfo GetSessionInfo();
|
||
};
|