310 lines
6.9 KiB
C++
310 lines
6.9 KiB
C++
#include "ProcessCal.h"
|
|
#include "Stdafx.h"
|
|
#include <map>
|
|
#include "stdlib.h"
|
|
#include <iosfwd>
|
|
#include "DataDefine.h"
|
|
//#include <io.h>
|
|
#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<int> id;
|
|
// for(map<int, PROCESS_INFORMATION>::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<int> ProcessCal::GetAllInletPointIDsFromMap()
|
|
{
|
|
|
|
std::vector<int> ids;
|
|
// map<int,PROCESS_INFORMATION>::iterator iter = mapProcess.begin();
|
|
// for(;iter != mapProcess.end(); iter++)
|
|
// {
|
|
// int id = iter->first;
|
|
// if(id / 1000000 == 40)
|
|
// {
|
|
// ids.push_back(id);
|
|
// }
|
|
// }
|
|
return ids;
|
|
}
|
|
|
|
vector<int> ProcessCal::GetAllLimitAngIDsFromMap()
|
|
{
|
|
vector<int> ids;
|
|
// map<int,PROCESS_INFORMATION>::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<int> ids = GetAllInletPointIDsFromMap();
|
|
// for(int i = 0; i < ids.size(); i++)
|
|
// {
|
|
// CloseProcess(ids[i]);
|
|
// }
|
|
}
|
|
|
|
void ProcessCal::CloseAllLimitAng()
|
|
{
|
|
// vector<int> 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<int> ids )
|
|
{
|
|
// for(int i = 0; i < ids.size(); i++)
|
|
// {
|
|
// CreateProcessCal(ids[i], 0);
|
|
// }
|
|
}
|
|
|
|
vector<int> ProcessCal::GetAllInletPointIDsFromXmlFile()
|
|
{
|
|
vector<int> 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<int> ProcessCal::GetAllLimitAngIDsFromXmlFile()
|
|
{
|
|
vector<int> 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;
|
|
}
|
|
|