#include "ProcessCal.h" #include "Stdafx.h" #include #include "stdlib.h" #include #include "DataDefine.h" //#include #include "pugixml.hpp" #include "Geometry.h" ProcessCal::ProcessCal(void) { //保存路径的数组 //char path[1000]; //路径的长度 // int fileLen=GetModuleFileName(NULL,path,1000); // string p = path; // int index = p.rfind('\\'); // currentPath = p.substr(0,index+1); } ProcessCal::~ProcessCal(void) { } bool ProcessCal::CloseProcess( int compID ) { //结束进程 // if(IsExistProcess(compID)) // { // PROCESS_INFORMATION process = this->mapProcess[compID]; // DWORD ExitCode; // ExitCode=STILL_ACTIVE; // GetExitCodeProcess(process.hProcess,&ExitCode); // if(ExitCode==STILL_ACTIVE) // { // TerminateProcess( process.hProcess, 4 ); // } // this->mapProcess.erase(compID); // } return true; } bool ProcessCal::WriteBrep( int compID, int flag ,TopoDS_Shape shape ) { //写brep /* string filepath = tempPath + iToString(compID) + ".brep"; if(compID < 5) { return true; } DeleteFile((tempPath + iToString(compID) + ".brep").c_str()); DeleteFile((tempPath + iToString(compID) + ".xml").c_str()); if(shape.IsNull())//删除文件 { //if(isExistFile(filepath)) //{ // DeleteFile((tempPath + iToString(compID) + ".brep").c_str()); // DeleteFile((tempPath + iToString(compID) + ".xml").c_str()); //} } else { BRepTools::Write(shape, filepath.c_str()); }*/ return true; } bool ProcessCal::CreateProcessCal( int compID, int flag) { // STARTUPINFO si; //一些必备参数设置 // memset(&si, 0, sizeof(STARTUPINFO)); // si.cb = sizeof(STARTUPINFO); // si.dwFlags = STARTF_USESHOWWINDOW; // si.wShowWindow = SW_SHOW; // PROCESS_INFORMATION pi; //必备参数设置结束 // string str= CreateTempPath() + "Hydrostatic.exe " + iToString(compID) + " " +iToString(flag); // //CreateProcess(NULL,(LPSTR)str.c_str(),NULL,NULL,FALSE,NULL /*NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW*/,NULL,NULL,&si,&pi); // this->mapProcess.insert(make_pair(compID, pi)); return true; } bool ProcessCal::StartProcessCal( int compID, TopoDS_Shape shape, int flag ) { /*CloseProcess(compID); WriteBrep(compID, flag, shape); CreateProcessCal(compID, flag);*/ return true; } bool ProcessCal::StartProcessCal( int OldID, int ID, Point3D p, int flag) { //return true; //CloseProcess(OldID); //WriteInletPointBrep(OldID, ID, p); //if(OldID == 0 && ID > 0)// 新增点 //{ // CreateProcessCal(ID, flag); //} //else if(OldID > 0 && ID < 0) //删除点 //{ // CreateProcessCal(OldID, flag); //} //else if(OldID > 0 && ID > 0) // 修改点 //{ // CreateProcessCal(ID, flag); //} return true; } bool ProcessCal::StartProcessCal( int ID, Point3D pD, Point3D pB, int flag ) { //CreateProcessCal(ID, flag); return true; } void ProcessCal::CloseALLProcess() { // vector id; // for(map::iterator iter = mapProcess.begin(); iter != mapProcess.end(); iter++) // { // PROCESS_INFORMATION process = iter->second; // DWORD ExitCode; // ExitCode=STILL_ACTIVE; // GetExitCodeProcess(process.hProcess,&ExitCode); // if(ExitCode==STILL_ACTIVE) // { // TerminateProcess( process.hProcess, 4 ); // } // } // mapProcess.clear(); } bool ProcessCal::IsExistProcess(int id) { return false; //return mapProcess.find(id) != mapProcess.end(); } bool ProcessCal::WriteInletPointBrep( int OldID, int ID, Point3D p) { //写brep /* string filepath = tempPath + iToString(ID) + ".brep"; //删除原文件 if(OldID > 0) { DeleteFile((tempPath + iToString(OldID) + ".brep").c_str()); } //写新文件 if(ID > 0) { pugi::xml_document doc; pugi::xml_node root; pugi::xml_node node; root = doc.document_element(); node = doc.append_child("Point"); node.append_attribute("Y") = p.Y; node.append_attribute("Z") = p.Z; node.append_attribute("OldID") = OldID; doc.save_file(filepath.c_str()); } */ return true; } vector ProcessCal::GetAllInletPointIDsFromMap() { std::vector ids; // map::iterator iter = mapProcess.begin(); // for(;iter != mapProcess.end(); iter++) // { // int id = iter->first; // if(id / 1000000 == 40) // { // ids.push_back(id); // } // } return ids; } vector ProcessCal::GetAllLimitAngIDsFromMap() { vector ids; // map::iterator iter = mapProcess.begin(); // for(;iter != mapProcess.end(); iter++) // { // int id = iter->first; // if(id / 1000000 == 41) // { // ids.push_back(id); // } // } return ids; } void ProcessCal::CloseAllInletPoint() { // vector ids = GetAllInletPointIDsFromMap(); // for(int i = 0; i < ids.size(); i++) // { // CloseProcess(ids[i]); // } } void ProcessCal::CloseAllLimitAng() { // vector ids = GetAllLimitAngIDsFromMap(); // for(int i = 0; i < ids.size(); i++) // { // CloseProcess(ids[i]); // } } bool ProcessCal::WriteLimitAngBrep( int ID ,Point3D pD, Point3D pB ) { //写brep // string filepath = tempPath + iToString(ID) + ".brep"; // //写新文件 // if(ID > 0) // { // pugi::xml_document doc; // pugi::xml_node root; // pugi::xml_node node; // root = doc.document_element(); // root = doc.append_child("Point"); // if(pD.ID > 0) // { // node = root.append_child("DeckPoint"); // node.append_attribute("Y") = pD.Y; // node.append_attribute("Z") = pD.Z; // } // if(pB.ID > 0) // { // node = root.append_child("BilgePoint"); // node.append_attribute("Y") = pB.Y; // node.append_attribute("Z") = pB.Z; // } // doc.save_file(filepath.c_str()); // } return true; } void ProcessCal::StartAllProcess( vector ids ) { // for(int i = 0; i < ids.size(); i++) // { // CreateProcessCal(ids[i], 0); // } } vector ProcessCal::GetAllInletPointIDsFromXmlFile() { vector ids; // string strPathTmp = tempPath + "40*.xml"; // long lFile; // string sAddPath; // struct _finddata_t sDate; // lFile = _findfirst(strPathTmp.c_str(), &sDate); // if (lFile == -1) // { // return ids; // } // do // { // // 删除文件 // string name = string(sDate.name); // string idstr = name.substr(0, strlen(name.c_str()) - 4); // int id = atoi(idstr.c_str()); // ids.push_back(id); // } while (_findnext(lFile, &sDate) == 0) ; return ids; } vector ProcessCal::GetAllLimitAngIDsFromXmlFile() { vector ids; // string strPathTmp = tempPath + "41*.xml"; // long lFile; // string sAddPath; // struct _finddata_t sDate; // lFile = _findfirst(strPathTmp.c_str(), &sDate); // if (lFile == -1) // { // return ids; // } // do // { // // 删除文件 // string name = string(sDate.name); // string idstr = name.substr(0, strlen(name.c_str()) - 4); // int id = atoi(idstr.c_str()); // ids.push_back(id); // } while (_findnext(lFile, &sDate) == 0) ; return ids; }