1731 lines
36 KiB
C++
1731 lines
36 KiB
C++
#pragma execution_character_set("utf-8")
|
||
#include "Stdafx.h"
|
||
#include "DllImportOccModeling.h"
|
||
//#include "OCCViewer.h"
|
||
#include "ScBRepLib.h"
|
||
//#include "OffsetGenerate.h"
|
||
#include "OffsetGenerate1.h"
|
||
#include<iostream>
|
||
#include "gp_Trsf.hxx"
|
||
#include "DataDefine.h"
|
||
#include "BaseAlgo.h"
|
||
#include <BRepMesh_IncrementalMesh.hxx>
|
||
#include <algorithm>
|
||
#include <GCPnts_UniformDeflection.hxx>
|
||
#include <QList>
|
||
//OCCViewer myOCCViewer;
|
||
extern OCCStructDataMD dataMD;
|
||
|
||
namespace OCCModeling
|
||
{
|
||
/*******************************************Display ***************************************/
|
||
//初始化数据
|
||
DLLEXPORT void ReInitData()
|
||
{
|
||
dataMD.InitList();
|
||
Cal.Init();
|
||
}
|
||
|
||
DLLEXPORT BOOL AddObjAppendage(int cmdID, vector<int> order, vector<Appendage> &apd)
|
||
{
|
||
int norder = order.size();
|
||
int napd = apd.size();
|
||
bool bfindcurobj = false;
|
||
for (int i = 0; i < norder; i++)
|
||
{
|
||
int curobjid = order[i];
|
||
if (napd > 0 && bfindcurobj == false)
|
||
{
|
||
for (int di = 0; di < napd; di++)
|
||
{
|
||
if (apd[di].ID == curobjid)
|
||
{
|
||
if (dataMD.CheckAppendage(cmdID, apd[di]) == TRUE)
|
||
{
|
||
bfindcurobj = true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
DLLEXPORT OCCStructDataMD *GetDataMD()
|
||
{
|
||
return &dataMD;
|
||
}
|
||
|
||
DLLEXPORT BOOL AddObjSpace(int cmdID,
|
||
vector<int> order,
|
||
vector<Space> &sp)
|
||
{
|
||
int norder = order.size();
|
||
int ns = sp.size();
|
||
bool bfindcurobj=false;
|
||
for (int i = 0; i < norder; i++)
|
||
{
|
||
int curobjid = order[i];
|
||
if (ns > 0 && bfindcurobj == false)
|
||
{
|
||
for (int di = 0; di < ns; di++)
|
||
{
|
||
if (sp[di].ID == curobjid)
|
||
{
|
||
if (dataMD.CheckSpace(cmdID, sp[di]) == TRUE)
|
||
{
|
||
bfindcurobj = true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return TRUE;
|
||
|
||
}
|
||
|
||
DLLEXPORT BOOL AddObjHull(int cmdID,
|
||
vector<int> order,
|
||
vector<Hull> &hull)
|
||
// int norder, int order[] ,)
|
||
{
|
||
int norder = order.size();
|
||
int nh = hull.size();
|
||
bool bfindcurobj=false;
|
||
for (int i = 0; i < norder; i++)
|
||
{
|
||
int curobjid = order[i];
|
||
if (nh > 0 && bfindcurobj == false)
|
||
{
|
||
for (int di = 0; di < nh; di++)
|
||
{
|
||
if (hull[di].ID == curobjid)
|
||
{
|
||
// if(dataMD.m_mapShellSurf.find(curobjid)!=dataMD.m_mapShellSurf.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if (dataMD.CheckHull(cmdID, hull[di]) == TRUE)
|
||
{
|
||
bfindcurobj = true;
|
||
// dataMD.ShellHydrostaticCalculation();
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
// dataMD.errorinfo="添加外板面图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
//<2F><><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
DLLEXPORT BOOL AddCalObj(int cmdID,int norder, int order[] ,
|
||
int ndel, int del[],
|
||
int npnts, Point3D pnts[],
|
||
int npnt, HydroInletPoint pnt[],
|
||
int ncrv, HydroLimitAng ang[],int nmargin, MarginLine marginpnts[],
|
||
int nopen, ImmersionOpen opens[])
|
||
{
|
||
int curobjid;
|
||
bool bfindcurobj=false;
|
||
|
||
if(norder>0)
|
||
{
|
||
if(npnts>0 && bfindcurobj==false)//点处理过程验证加生成
|
||
{
|
||
for(int pi=0;pi<npnts;pi++)
|
||
{
|
||
/*if(pnts[pi].ID==curobjid)
|
||
{*/
|
||
if(dataMD.m_mapPoints.find(pnts[pi].ID)!=dataMD.m_mapPoints.end())
|
||
{
|
||
dataMD.DelObj(cmdID,pnts[pi].ID);
|
||
}
|
||
if(dataMD.AddTopoPoint(cmdID,pnts[pi])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
//break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加点图元失败 ";
|
||
return FALSE;
|
||
}
|
||
//break;
|
||
//}
|
||
}
|
||
}
|
||
if (npnt > 0)
|
||
{
|
||
//先删除进水点,然后重新添加
|
||
vector<int> ivec;
|
||
map<int,HydroInletPoint>::iterator it=dataMD.m_mapInletPoint.begin();
|
||
for (; it!=dataMD.m_mapInletPoint.end();it++ )
|
||
{
|
||
//dataMD.DelObj(-1,it->first);
|
||
ivec.push_back(it->first);
|
||
}
|
||
for (vector<int>::size_type ix = 0; ix != ivec.size(); ++ix)
|
||
{
|
||
dataMD.DelObj(-1,ivec[ix]);
|
||
}
|
||
}
|
||
if (ncrv > 0)
|
||
{
|
||
//先删除静倾角,然后重新添加
|
||
vector<int> ivec;
|
||
map<int,HydroLimitAng>::iterator it=dataMD.m_mapLimitAng.begin();
|
||
for (; it!=dataMD.m_mapLimitAng.end();it++ )
|
||
{
|
||
//dataMD.DelObj(-1,it->first);
|
||
ivec.push_back(it->first);
|
||
}
|
||
for (vector<int>::size_type ix = 0; ix != ivec.size(); ++ix)
|
||
{
|
||
dataMD.DelObj(-1,ivec[ix]);
|
||
}
|
||
}
|
||
if (nmargin > 0)
|
||
{
|
||
vector<int> ivecm;
|
||
map<int,MarginLine>::iterator it = dataMD.m_mapMarginLine.begin();
|
||
for (;it!=dataMD.m_mapMarginLine.end();it++)
|
||
ivecm.push_back(it->first);
|
||
for (vector<int>::size_type ix = 0; ix != ivecm.size(); ++ix)
|
||
{
|
||
dataMD.DelObj(-1,ivecm[ix]);
|
||
}
|
||
}
|
||
if (nopen > 0)
|
||
{
|
||
vector<int> iveco;
|
||
map<int,ImmersionOpen>::iterator it = dataMD.m_mapImmersionOpen.begin();
|
||
for (;it!=dataMD.m_mapImmersionOpen.end();it++)
|
||
iveco.push_back(it->first);
|
||
for (vector<int>::size_type ix = 0; ix != iveco.size(); ++ix)
|
||
{
|
||
dataMD.DelObj(-1,iveco[ix]);
|
||
}
|
||
}
|
||
for(int i=0;i< norder;i++)
|
||
{
|
||
curobjid=order[i];
|
||
bfindcurobj=false;
|
||
if(npnt>0 && bfindcurobj==false)//静水力点处理过程验证加生成
|
||
{
|
||
for(int pi=0;pi<npnt;pi++)
|
||
{
|
||
if(pnt[pi].ID==curobjid)
|
||
{
|
||
if(dataMD.AddTopoInletPoint(cmdID,pnt[pi])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if(ncrv>0 && bfindcurobj==false)//线处理过程
|
||
{
|
||
for(int ci=0;ci<ncrv;ci++)
|
||
{
|
||
if(ang[ci].ID==curobjid)
|
||
{
|
||
if(dataMD.AddLimitAng(cmdID,ang[ci])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加线图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if(nmargin>0 && bfindcurobj==false)//限界线
|
||
{
|
||
if(dataMD.AddMarginLine(nmargin,marginpnts[0])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
|
||
//for(int pi=0;pi<nmargin;pi++)
|
||
//{
|
||
|
||
// //if(marginpnts[pi].ID==curobjid)
|
||
// //{
|
||
// // /*if(dataMD.AddTopoInletPoint(cmdID,marginpnts[pi])==TRUE)
|
||
// // {
|
||
// // bfindcurobj=true;
|
||
// // break;
|
||
// // }
|
||
// // else
|
||
// // {
|
||
// // return FALSE;
|
||
// // }*/
|
||
// // break;
|
||
// //}
|
||
//}
|
||
}
|
||
if(nopen>0 && bfindcurobj==false)//浸水开口
|
||
{
|
||
for(int pi=0;pi<nopen;pi++)
|
||
{
|
||
if(opens[pi].ID==curobjid)
|
||
{
|
||
if(dataMD.AddImmersionOpen(cmdID,opens[pi])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(ndel>0 && bfindcurobj==false)//删除处理过程
|
||
{
|
||
for(int deli=0;deli<ndel;deli++)
|
||
{
|
||
if(del[deli]==curobjid)
|
||
{
|
||
bfindcurobj=true;
|
||
dataMD.DelObj(cmdID,curobjid);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if(bfindcurobj==false)//修改处理过程
|
||
{
|
||
|
||
dataMD.ModifyObj(cmdID,curobjid);
|
||
bfindcurobj=true;
|
||
}
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
//添加对象,按顺序执行,order[]表示需要添加的所有对象ID的数组,del[]表示需要删除的所有对象ID的数组
|
||
BOOL AddObjPriv(int cmdID,
|
||
vector<int> order,
|
||
vector<Point3D>& pnt,
|
||
vector<Curve>& crv,
|
||
vector<Surface>& srf,
|
||
vector<Solid>& sld
|
||
/*int norder, int order[] ,
|
||
int ndel, int del[],
|
||
int npnt,Point3D pnt[],
|
||
int ncrv,Curve crv[],
|
||
int nsrf,Surface srf[],
|
||
int nsld,Solid sld[],
|
||
int nmds, MainDeckSurf mds[],
|
||
int nss, ShellSurf ss[],
|
||
int nds, DeckSurf ds[],
|
||
int nbs, BoundSurf bs[],
|
||
int nsds, SubdivSurf sds[],
|
||
int nocr, OpenCargoRegion ocr[],
|
||
int nsp, Space sp[],
|
||
int napd, Appendage apd[],
|
||
int nh, Hull h[],
|
||
int nrenameObj, RenameObject renameObj[]*/
|
||
)
|
||
{
|
||
int curobjid;
|
||
bool bfindcurobj=false;
|
||
int norder = order.size();
|
||
int npnt = pnt.size();
|
||
int ncrv = crv.size();
|
||
int nsrf = srf.size();
|
||
int nsld = sld.size();
|
||
if(norder>0)
|
||
{
|
||
for(int i=0;i< norder;i++)
|
||
{
|
||
curobjid=order[i];
|
||
bfindcurobj=false;
|
||
|
||
//点处理过程验证加生成
|
||
if(npnt>0 && bfindcurobj==false)
|
||
{
|
||
for(int pi=0;pi<npnt;pi++)
|
||
{
|
||
if(pnt[pi].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapPoints.find(curobjid)!=dataMD.m_mapPoints.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
//}
|
||
if(dataMD.AddTopoPoint(cmdID,pnt[pi])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加点图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//线处理过程
|
||
if(ncrv>0 && bfindcurobj==false)
|
||
{
|
||
for(int ci=0;ci<ncrv;ci++)
|
||
{
|
||
if(crv[ci].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapCurves.find(curobjid)!=dataMD.m_mapCurves.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
//}
|
||
if(dataMD.CheckCurve(cmdID,crv[ci])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加线图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//面处理过程
|
||
if(nsrf>0 && bfindcurobj==false)
|
||
{
|
||
for(int si=0;si<nsrf;si++)
|
||
{
|
||
if(srf[si].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapSurfaces.find(curobjid)!=dataMD.m_mapSurfaces.end())
|
||
//{
|
||
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
//}
|
||
if(dataMD.CheckSurface(cmdID,srf[si])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加面图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//体处理过程
|
||
if(nsld>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nsld;di++)
|
||
{
|
||
if(sld[di].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapSolids.find(curobjid)!=dataMD.m_mapSolids.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if(dataMD.CheckSolid(cmdID,sld[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加体图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
/*
|
||
//主甲板面
|
||
if(nmds>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nmds;di++)
|
||
{
|
||
if(mds[di].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapMainDeckSurf.find(curobjid)!=dataMD.m_mapMainDeckSurf.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if(dataMD.CheckMainDeckSurf(cmdID,mds[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
dataMD.ShellHydrostaticCalculation();
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加主甲板面图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//外板面
|
||
if(nss>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nss;di++)
|
||
{
|
||
if(ss[di].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapShellSurf.find(curobjid)!=dataMD.m_mapShellSurf.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if(dataMD.CheckShellSurf(cmdID,ss[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
dataMD.ShellHydrostaticCalculation();
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加外板面图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
//主船体
|
||
if(nh>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nh;di++)
|
||
{
|
||
if(h[di].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapShellSurf.find(curobjid)!=dataMD.m_mapShellSurf.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if(dataMD.CheckHull(cmdID,h[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
//dataMD.ShellHydrostaticCalculation();
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加外板面图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
//平台面
|
||
if(nds>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nds;di++)
|
||
{
|
||
if(ds[di].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapDeckSurf.find(curobjid)!=dataMD.m_mapDeckSurf.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if(dataMD.CheckDeckSurf(cmdID,ds[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加平台面图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
//上建外围面
|
||
if(nbs>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nbs;di++)
|
||
{
|
||
if(bs[di].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapBoundSurf.find(curobjid)!=dataMD.m_mapBoundSurf.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if(dataMD.CheckBoundSurf(cmdID,bs[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加上建外围面图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//分舱面
|
||
if(nsds>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nsds;di++)
|
||
{
|
||
if(sds[di].ID==curobjid)
|
||
{
|
||
if(dataMD.m_mapSubdivSurf.find(curobjid)!=dataMD.m_mapSubdivSurf.end())
|
||
{
|
||
dataMD.DelObj(cmdID,curobjid);
|
||
|
||
}
|
||
if(dataMD.CheckSubdivSurf(cmdID,sds[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加分舱面图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//开敞客货区
|
||
if(nocr>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nocr;di++)
|
||
{
|
||
if(ocr[di].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapOpenCargoRegion.find(curobjid)!=dataMD.m_mapOpenCargoRegion.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if(dataMD.CheckOpenCargoRegion(cmdID,ocr[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加开敞客货区图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//舱室
|
||
if(nsp>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nsp;di++)
|
||
{
|
||
if(sp[di].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapSpace.find(curobjid)!=dataMD.m_mapSpace.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if(dataMD.CheckSpace(cmdID,sp[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
//if(true//*sp [di].Type == 2 || sp[di].Type == 3//)// 计算舱室
|
||
|
||
//{
|
||
// TopoDS_Shape solid = dataMD.m_mapAllTopoShapes[sp[di].ID];//找到舱室
|
||
// processCal.StartProcessCal(sp[di].ID, solid, 0);
|
||
//}
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加舱室图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//附体
|
||
if(napd>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<napd;di++)
|
||
{
|
||
if(apd[di].ID==curobjid)
|
||
{
|
||
//if(dataMD.m_mapAppendage.find(curobjid)!=dataMD.m_mapAppendage.end())
|
||
//{
|
||
// dataMD.DelObj(cmdID,curobjid);
|
||
|
||
//}
|
||
if(dataMD.CheckAppendage(cmdID,apd[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加附体图元失败 ";
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//重命名
|
||
if(nrenameObj>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<nrenameObj;di++)
|
||
{
|
||
if(renameObj[di].ID==curobjid)
|
||
{
|
||
if(dataMD.CheckRename(cmdID,renameObj[di])==TRUE)
|
||
{
|
||
bfindcurobj=true;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
//删除处理过程
|
||
if(ndel>0 && bfindcurobj==false)
|
||
{
|
||
for(int deli=0;deli<ndel;deli++)
|
||
{
|
||
if(del[deli]==curobjid)
|
||
{
|
||
bfindcurobj=true;
|
||
dataMD.DelObj(cmdID,curobjid);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
//修改处理过程
|
||
if(bfindcurobj==false)
|
||
{
|
||
|
||
dataMD.ModifyObj(cmdID,curobjid);
|
||
bfindcurobj=true;
|
||
}*/
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
DLLEXPORT BOOL DeleteObj(int cmdID,
|
||
vector<int> order,
|
||
vector<int> del
|
||
)
|
||
{
|
||
int norder=order.size();
|
||
int ndel=del.size();
|
||
bool bfindcurobj=false;
|
||
for(int i=0;i<norder;i++)
|
||
{
|
||
int curobjid=order[i];
|
||
if(ndel>0 && bfindcurobj==false)
|
||
{
|
||
for(int di=0;di<ndel;di++)
|
||
{
|
||
if(del[di]==curobjid)
|
||
{
|
||
bfindcurobj=true;
|
||
dataMD.DelObj(cmdID,curobjid);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
//添加对象
|
||
DLLEXPORT BOOL AddObj(int cmdID,
|
||
vector<int> order,
|
||
vector<Point3D>& pnt,
|
||
vector<Curve>& crv,
|
||
vector<Surface>& srf,
|
||
vector<Solid>& sld
|
||
/*int norder, int order[] ,
|
||
int ndel, int del[],
|
||
int npnt,Point3D pnt[],
|
||
int ncrv,Curve crv[],
|
||
int nsrf,Surface srf[],
|
||
int nsld,Solid sld[],
|
||
int nmds, MainDeckSurf mds[],
|
||
int nss, ShellSurf ss[],
|
||
int nds, DeckSurf ds[],
|
||
int nbs, BoundSurf bs[],
|
||
int nsds, SubdivSurf sds[],
|
||
int nocr, OpenCargoRegion ocr[],
|
||
int nsp, Space sp[],
|
||
int napd, Appendage apd[],
|
||
int nh, Hull h[],
|
||
int nrenameObj, RenameObject renameObj[]*/
|
||
)
|
||
{
|
||
// // EnterCriticalSection(&myOCCViewer.m_CS);
|
||
// BOOL ret = AddObjPriv(cmdID,norder, order,
|
||
// ndel, del,
|
||
// npnt, pnt,
|
||
// ncrv, crv,
|
||
// nsrf, srf,
|
||
// nsld, sld,
|
||
// nmds, mds,
|
||
// nss, ss,
|
||
// nds, ds,
|
||
// nbs, bs,
|
||
// nsds, sds,
|
||
// nocr, ocr,
|
||
// nsp, sp,
|
||
// napd, apd,
|
||
// nh, h,
|
||
// nrenameObj, renameObj
|
||
// );
|
||
bool ret = AddObjPriv(cmdID, order, pnt, crv, srf,sld);
|
||
|
||
// LeaveCriticalSection(&myOCCViewer.m_CS);
|
||
return ret;
|
||
}
|
||
DLLEXPORT bool InitCalData(int npnt, HydroInletPoint pnt[],
|
||
int ncrv, HydroLimitAng ang[],
|
||
int nmargin, MarginLine marginpnts[],int nopen, ImmersionOpen opens[])
|
||
{
|
||
if(npnt>0 )//进水点处理过程
|
||
{
|
||
for(int si=0;si<npnt;si++)
|
||
{
|
||
|
||
if(dataMD.m_mapInletPoint.find(pnt[si].ID)!=dataMD.m_mapInletPoint.end())
|
||
{
|
||
dataMD.m_mapInletPoint.erase(dataMD.m_mapInletPoint.find(pnt[si].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapInletPoint.insert(make_pair(pnt[si].ID,pnt[si]));
|
||
dataMD.m_mapAllNames.insert(make_pair(pnt[si].ID ,pnt[si].Name));
|
||
}
|
||
}
|
||
}
|
||
if(ncrv>0 )//极限静倾角处理过程
|
||
{
|
||
for(int si=0;si<ncrv;si++)
|
||
{
|
||
|
||
if(dataMD.m_mapLimitAng.find(ang[si].ID)!=dataMD.m_mapLimitAng.end())
|
||
{
|
||
dataMD.m_mapLimitAng.erase(dataMD.m_mapLimitAng.find(ang[si].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapLimitAng.insert(make_pair(ang[si].ID,ang[si]));
|
||
dataMD.m_mapAllNames.insert(make_pair(ang[si].ID ,ang[si].Name));
|
||
}
|
||
}
|
||
}
|
||
if(nmargin>0 )//限界线处理过程
|
||
{
|
||
for(int si=0;si<nmargin;si++)
|
||
{
|
||
|
||
if(dataMD.m_mapMarginLine.find(marginpnts[si].ID)!=dataMD.m_mapMarginLine.end())
|
||
{
|
||
dataMD.m_mapMarginLine.erase(dataMD.m_mapMarginLine.find(marginpnts[si].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapMarginLine.insert(make_pair(marginpnts[si].ID,marginpnts[si]));
|
||
dataMD.m_mapAllNames.insert(make_pair(marginpnts[si].ID,marginpnts[si].Name));
|
||
}
|
||
}
|
||
}
|
||
if(nopen>0 )//浸水开口处理过程
|
||
{
|
||
for(int si=0;si<nopen;si++)
|
||
{
|
||
|
||
if(dataMD.m_mapImmersionOpen.find(opens[si].ID)!=dataMD.m_mapImmersionOpen.end())
|
||
{
|
||
dataMD.m_mapImmersionOpen.erase(dataMD.m_mapImmersionOpen.find(opens[si].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapImmersionOpen.insert(make_pair(opens[si].ID,opens[si]));
|
||
dataMD.m_mapAllNames.insert(make_pair(opens[si].ID ,opens[si].Name));
|
||
}
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
//初始化几何模型数据
|
||
//DLLEXPORT bool InitData(int npnt, Point3D pnt[],
|
||
// int ncrv, Curve crv[]
|
||
/*,
|
||
int nsrf, Surface srf[],
|
||
int nsld, Solid sld[],
|
||
int nmds, MainDeckSurf mds[],
|
||
int nss, ShellSurf ss[],
|
||
int nds, DeckSurf ds[],
|
||
int nbs, BoundSurf bs[],
|
||
int nsds, SubdivSurf sds[],
|
||
int nocr, OpenCargoRegion ocr[],
|
||
int nsp, Space sp[],
|
||
int napd, Appendage apd[],
|
||
int nh, Hull h[]*/
|
||
//)
|
||
DLLEXPORT bool InitHullData(
|
||
vector<Hull>& h,
|
||
vector<Space>& sp,
|
||
vector<Appendage>& apd
|
||
)
|
||
{
|
||
int nh = h.size();
|
||
int nsp = sp.size();
|
||
int napd = apd.size();
|
||
if(nh>0)//主船体
|
||
{
|
||
for(int di=0;di<nh;di++)
|
||
{
|
||
if(dataMD.m_mapHull.find(h[di].ID)!=dataMD.m_mapHull.end())
|
||
{
|
||
dataMD.m_mapHull.erase(dataMD.m_mapHull.find(h[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapHull.insert(make_pair(h[di].ID,h[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(h[di].ID ,h[di].Name));
|
||
}
|
||
}
|
||
}
|
||
if(nsp>0)//舱室
|
||
{
|
||
for(int di=0;di<nsp;di++)
|
||
{
|
||
if(dataMD.m_mapSpace.find(sp[di].ID)!=dataMD.m_mapSpace.end())
|
||
{
|
||
dataMD.m_mapSpace.erase(dataMD.m_mapSpace.find(sp[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapSpace.insert(make_pair(sp[di].ID,sp[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(sp[di].ID ,sp[di].Name));
|
||
}
|
||
}
|
||
}
|
||
if(napd>0)//附体
|
||
{
|
||
for(int di=0;di<napd;di++)
|
||
{
|
||
if(dataMD.m_mapAppendage.find(apd[di].ID)!=dataMD.m_mapAppendage.end())
|
||
{
|
||
dataMD.m_mapAppendage.erase(dataMD.m_mapAppendage.find(apd[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapAppendage.insert(make_pair(apd[di].ID,apd[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(apd[di].ID ,apd[di].Name));
|
||
}
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
DLLEXPORT bool InitData(vector<Point3D>& pnt,
|
||
vector<Curve>& crv,
|
||
vector<Surface>& srf,
|
||
vector<Solid>& sld
|
||
/*,
|
||
int nsrf, Surface srf[],
|
||
int nsld, Solid sld[],
|
||
int nmds, MainDeckSurf mds[],
|
||
int nss, ShellSurf ss[],
|
||
int nds, DeckSurf ds[],
|
||
int nbs, BoundSurf bs[],
|
||
int nsds, SubdivSurf sds[],
|
||
int nocr, OpenCargoRegion ocr[],
|
||
int nsp, Space sp[],
|
||
int napd, Appendage apd[],
|
||
int nh, Hull h[]*/
|
||
)
|
||
|
||
{
|
||
int npnt = pnt.size();
|
||
int ncrv = crv.size();
|
||
int nsrf = srf.size();
|
||
int nsld = sld.size();
|
||
if(npnt>0)
|
||
{
|
||
for(int pi=0;pi<npnt;pi++)
|
||
{
|
||
if(dataMD.m_mapPoints.find(pnt[pi].ID)!=dataMD.m_mapPoints.end())
|
||
{
|
||
dataMD.m_mapPoints.erase(dataMD.m_mapPoints.find(pnt[pi].ID));
|
||
}
|
||
else
|
||
{
|
||
if(dataMD.AddTopoPoint(-1,pnt[pi])==TRUE)
|
||
{
|
||
}
|
||
else
|
||
{
|
||
//dataMD.errorinfo="添加点图元失败 ";
|
||
return FALSE;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(ncrv>0 )//线处理过程
|
||
{
|
||
for(int ci=0;ci<ncrv;ci++)
|
||
{
|
||
|
||
if(dataMD.m_mapCurves.find(crv[ci].ID)!=dataMD.m_mapCurves.end())
|
||
{
|
||
dataMD.m_mapCurves.erase(dataMD.m_mapCurves.find(crv[ci].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapCurves.insert(make_pair(crv[ci].ID,crv[ci]));
|
||
dataMD.m_mapAllNames.insert(make_pair(crv[ci].ID ,crv[ci].Name));
|
||
}
|
||
}
|
||
}
|
||
|
||
if(nsrf>0 )//面处理过程
|
||
{
|
||
for(int si=0;si<nsrf;si++)
|
||
{
|
||
|
||
if(dataMD.m_mapSurfaces.find(srf[si].ID)!=dataMD.m_mapSurfaces.end())
|
||
{
|
||
dataMD.m_mapSurfaces.erase(dataMD.m_mapSurfaces.find(srf[si].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapSurfaces.insert(make_pair(srf[si].ID,srf[si]));
|
||
dataMD.m_mapAllNames.insert(make_pair(srf[si].ID ,srf[si].Name));
|
||
}
|
||
}
|
||
}
|
||
|
||
int a = 0;
|
||
|
||
if(nsld>0 )//体处理过程
|
||
{
|
||
for(int di=0;di<nsld;di++)
|
||
{
|
||
if(dataMD.m_mapSolids.find(sld[di].ID)!=dataMD.m_mapSolids.end())
|
||
{
|
||
dataMD.m_mapSolids.erase(dataMD.m_mapSolids.find(sld[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapSolids.insert(make_pair(sld[di].ID,sld[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(sld[di].ID ,sld[di].Name));
|
||
}
|
||
}
|
||
}
|
||
/*
|
||
if(nmds>0 )//主甲板面
|
||
{
|
||
for(int di=0;di<nmds;di++)
|
||
{
|
||
if(dataMD.m_mapMainDeckSurf.find(mds[di].ID)!=dataMD.m_mapMainDeckSurf.end())
|
||
{
|
||
dataMD.m_mapMainDeckSurf.erase(dataMD.m_mapMainDeckSurf.find(mds[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapMainDeckSurf.insert(make_pair(mds[di].ID,mds[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(mds[di].ID ,mds[di].Name));
|
||
}
|
||
}
|
||
}
|
||
if(nss>0)//外板面
|
||
{
|
||
for(int di=0;di<nss;di++)
|
||
{
|
||
if(dataMD.m_mapShellSurf.find(ss[di].ID)!=dataMD.m_mapShellSurf.end())
|
||
{
|
||
dataMD.m_mapShellSurf.erase(dataMD.m_mapShellSurf.find(ss[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapShellSurf.insert(make_pair(ss[di].ID,ss[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(ss[di].ID ,ss[di].Name));
|
||
}
|
||
}
|
||
}
|
||
if(nh>0)//主船体
|
||
{
|
||
for(int di=0;di<nh;di++)
|
||
{
|
||
if(dataMD.m_mapHull.find(h[di].ID)!=dataMD.m_mapHull.end())
|
||
{
|
||
dataMD.m_mapHull.erase(dataMD.m_mapHull.find(h[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapHull.insert(make_pair(h[di].ID,h[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(h[di].ID ,h[di].Name));
|
||
}
|
||
}
|
||
}
|
||
if(nds>0)//平台面
|
||
{
|
||
for(int di=0;di<nds;di++)
|
||
{
|
||
if(dataMD.m_mapDeckSurf.find(ds[di].ID)!=dataMD.m_mapDeckSurf.end())
|
||
{
|
||
dataMD.m_mapDeckSurf.erase(dataMD.m_mapDeckSurf.find(ds[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapDeckSurf.insert(make_pair(ds[di].ID,ds[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(ds[di].ID ,ds[di].Name));
|
||
}
|
||
}
|
||
}
|
||
|
||
if(nbs>0)//上建外围面
|
||
{
|
||
for(int di=0;di<nbs;di++)
|
||
{
|
||
if(dataMD.m_mapBoundSurf.find(bs[di].ID)!=dataMD.m_mapBoundSurf.end())
|
||
{
|
||
dataMD.m_mapBoundSurf.erase(dataMD.m_mapBoundSurf.find(bs[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapBoundSurf.insert(make_pair(bs[di].ID,bs[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(bs[di].ID ,bs[di].Name));
|
||
}
|
||
}
|
||
}
|
||
|
||
if(nsds>0)//分舱面
|
||
{
|
||
for(int di=0;di<nsds;di++)
|
||
{
|
||
if(dataMD.m_mapSubdivSurf.find(sds[di].ID)!=dataMD.m_mapSubdivSurf.end())
|
||
{
|
||
dataMD.m_mapSubdivSurf.erase(dataMD.m_mapSubdivSurf.find(sds[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapSubdivSurf.insert(make_pair(sds[di].ID,sds[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(sds[di].ID ,sds[di].Name));
|
||
}
|
||
}
|
||
}
|
||
if(nocr>0)//开敞客货区``
|
||
{
|
||
for(int di=0;di<nocr;di++)
|
||
{
|
||
if(dataMD.m_mapOpenCargoRegion.find(ocr[di].ID)!=dataMD.m_mapOpenCargoRegion.end())
|
||
{
|
||
dataMD.m_mapOpenCargoRegion.erase(dataMD.m_mapOpenCargoRegion.find(ocr[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapOpenCargoRegion.insert(make_pair(ocr[di].ID,ocr[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(ocr[di].ID ,ocr[di].Name));
|
||
}
|
||
}
|
||
}
|
||
if(nsp>0)//舱室
|
||
{
|
||
for(int di=0;di<nsp;di++)
|
||
{
|
||
if(dataMD.m_mapSpace.find(sp[di].ID)!=dataMD.m_mapSpace.end())
|
||
{
|
||
dataMD.m_mapSpace.erase(dataMD.m_mapSpace.find(sp[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapSpace.insert(make_pair(sp[di].ID,sp[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(sp[di].ID ,sp[di].Name));
|
||
}
|
||
}
|
||
}
|
||
if(napd>0)//附体
|
||
{
|
||
for(int di=0;di<napd;di++)
|
||
{
|
||
if(dataMD.m_mapAppendage.find(apd[di].ID)!=dataMD.m_mapAppendage.end())
|
||
{
|
||
dataMD.m_mapAppendage.erase(dataMD.m_mapAppendage.find(apd[di].ID));
|
||
}
|
||
else
|
||
{
|
||
dataMD.m_mapAppendage.insert(make_pair(apd[di].ID,apd[di]));
|
||
dataMD.m_mapAllNames.insert(make_pair(apd[di].ID ,apd[di].Name));
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
|
||
return TRUE;
|
||
}
|
||
DLLEXPORT void RemoveObj(int nid, int id[] )
|
||
{
|
||
if(nid >0)
|
||
{
|
||
for(int i=0;i<nid;i++)
|
||
{
|
||
dataMD.DelObj(-1,id[i]);
|
||
}
|
||
}
|
||
}
|
||
|
||
DLLEXPORT void UnRedo(int flag, int cmdID)
|
||
{
|
||
dataMD.UnRedo(flag,cmdID);
|
||
}
|
||
|
||
DLLEXPORT void ResetPrincipal(double loa,double lpp, double b, double d,double t, double f0x,int iFrame, int nfrm, Frame frm[],
|
||
int nsta, Station sta[],int nwl, WaterlinePos wl[],int nbl,ButtocklinePos bl[])
|
||
{
|
||
dataMD.ResetPrincipal(loa,lpp,b,d,t,f0x,iFrame,nfrm,frm,nsta,sta,nwl,wl,nbl,bl);
|
||
}
|
||
DLLEXPORT void SetPrincipal(double loa,double lpp, double b, double d,double t, double f0x,int iFrame, int nfrm, Frame frm[],
|
||
int nsta, Station sta[],int nwl, WaterlinePos wl[],int nbl,ButtocklinePos bl[])
|
||
{
|
||
|
||
}
|
||
/// </summary>
|
||
/// <param name="upperDeckID">上甲板ID</param>
|
||
/// <param name="foldingLinesID">折角线ID</param>
|
||
/// <param name="isBilge">舭部是否升高</param>
|
||
/// <param name="BilgeHC">舭部升高值(m)</param>
|
||
/// <param name="shiptype">船型</param>
|
||
/// <param name="asymmetricType">是否非对称船型</param>
|
||
/// <param name="ids">返回型值表对应ID</param>
|
||
/// <param name="lens">每个ID对应PNTS中的长度</param>
|
||
/// <param name="pnts">型值点数组</param>
|
||
DLLEXPORT int GetOffsetTableData(int upperDeckID, int foldingLinesID[], int isBilge, double BilgeHC, int shiptype, int asymmetricType,
|
||
int ids[], int lens[], OffsetTablePoint *pnts)
|
||
{
|
||
OffsetGenerate1 offger;
|
||
return offger.GetOffsetTableData(upperDeckID,foldingLinesID,isBilge,BilgeHC,shiptype,asymmetricType,ids,lens,pnts);
|
||
}
|
||
|
||
/********************************* Check *********************************************/
|
||
BOOL CheckPointPriv(Point3D *pnt)
|
||
{
|
||
if(pnt->Type ==0)//普通点
|
||
{
|
||
return dataMD.CheckSimplePoint(pnt);
|
||
}
|
||
else if(pnt->Type ==1)//线上点
|
||
{
|
||
return dataMD.CheckOnLinePoint(pnt);
|
||
}
|
||
else if(pnt->Type ==2)//交点
|
||
{
|
||
return dataMD.CheckCrossPoint(pnt);
|
||
}
|
||
else if(pnt->Type ==3)//线面交点
|
||
{
|
||
return dataMD.CheckLineFacePoint(pnt);
|
||
}
|
||
else if(pnt->Type ==9)//镜像点认为是普通点 //20161228 by czb
|
||
{
|
||
return dataMD.CheckSimplePoint(pnt);
|
||
}
|
||
else if(pnt->Type ==10)//引用线上节点C/N=?
|
||
{
|
||
return dataMD.CheckLineRefPoint(pnt);
|
||
}
|
||
else if(pnt->Type ==11)//实体点对应的点 //20170501 by czb
|
||
{
|
||
return dataMD.CheckSimplePoint(pnt);
|
||
}
|
||
else
|
||
{
|
||
dataMD.errorinfo="无法生成此类点图元 ";
|
||
return FALSE;
|
||
}
|
||
return TRUE;
|
||
}
|
||
DLLEXPORT BOOL CheckPoint(Point3D *pnt)
|
||
{
|
||
// EnterCriticalSection(&myOCCViewer.m_CS);
|
||
bool b = CheckPointPriv(pnt);
|
||
// LeaveCriticalSection(&myOCCViewer.m_CS);
|
||
return b;
|
||
}
|
||
|
||
DLLEXPORT const char* GetErrInfo()
|
||
{
|
||
return dataMD.errorinfo.c_str();
|
||
}
|
||
|
||
/***************************************** Interaction *****************************************/
|
||
|
||
DLLEXPORT double GetS(int id)
|
||
{
|
||
return dataMD.GetS(id);
|
||
}
|
||
|
||
DLLEXPORT double GetV(int id)
|
||
{
|
||
return dataMD.GetV(id);
|
||
}
|
||
|
||
DLLEXPORT double GetTonnageV1()
|
||
{
|
||
return dataMD.GetTonnageV1();
|
||
}
|
||
|
||
DLLEXPORT bool SaveTopoToStep(char* path,int ids[])
|
||
{
|
||
return dataMD.SaveTopoToStep(path,ids);
|
||
}
|
||
//20161227 by czb,新增
|
||
DLLEXPORT bool SaveTopoToStep2(char* path)
|
||
{
|
||
return dataMD.SaveTopoToStep2(path);
|
||
}
|
||
//20161214 by czb,新增
|
||
DLLEXPORT void GetOCIDXOfTopo(int ids[])
|
||
{
|
||
return dataMD.GetOCIDXOfTopo(ids);
|
||
}
|
||
DLLEXPORT bool SaveTopoToBrep(char* path)
|
||
{
|
||
return dataMD.SaveTopoToBrep(path);
|
||
}
|
||
DLLEXPORT bool LoadTopoFromStep(char* path,QVector<int> ids)
|
||
{
|
||
return dataMD.LoadTopoFromStep(path,ids);
|
||
}
|
||
DLLEXPORT bool CreateInterHullXml()
|
||
{
|
||
//实现1计算接口
|
||
//从数据结构中找到船壳,按配置文件中设置的z的间隔进行剪切获得属性 设置的z在
|
||
/*if (type == 1)
|
||
{*/
|
||
//Cal.CreateHull();
|
||
//Cal.CreateCalXML();
|
||
//Cal.CreateSectionXML();
|
||
//Cal.CreateHeelHullXML();
|
||
//Cal.CreateTrimXML();
|
||
return true;
|
||
// }else if (type == 2)
|
||
//{
|
||
// if (Cal.topoSolid.IsNull())
|
||
// CreateHull();
|
||
|
||
|
||
}
|
||
|
||
DLLEXPORT bool CreateHullSolid()
|
||
{
|
||
//Cal.CreateHull();
|
||
return true;
|
||
}
|
||
DLLEXPORT bool CreateInterCompXml()
|
||
{
|
||
//Cal.CreateCompCalXML();
|
||
return true;
|
||
}
|
||
DLLEXPORT bool SetCompartmentPara(int ComID,int CStatus)
|
||
{
|
||
//Cal.SetCompPara(ComID,CStatus);
|
||
return true;
|
||
}
|
||
|
||
DLLEXPORT int GetMarginLineleData(int lens[], OffsetTablePoint *pnts)
|
||
{
|
||
OffsetGenerate1 offger;
|
||
return offger.GetMarginLineleData(lens, pnts);
|
||
}
|
||
|
||
DLLEXPORT bool CreateCXml()
|
||
{
|
||
//Cal.CreateHull();
|
||
//Cal.CreateProfileCalXML();
|
||
return true;
|
||
}
|
||
|
||
DLLEXPORT double GetImmersionOpenPos(double X, double Y, double oppositZ)
|
||
{
|
||
return dataMD.GetImmersionOpenPos(X, Y, oppositZ);
|
||
}
|
||
DLLEXPORT bool SetHullPara(int zCnt,double zStep[],int xCnt,double xStep[],int heelCnt,double heelStep[],double heelC[],
|
||
double heelFMax,double heelFMin,double heelDai,int trimCnt,double trimStep[],
|
||
double trimFMax,double trimFMin,double trimDai,int startType)
|
||
{
|
||
vector<double> zVec;
|
||
vector<double> xVec;
|
||
vector<double> heelVec;
|
||
vector<double> trimVec;
|
||
vector<double> heelCVec;
|
||
|
||
bool bShell = dataMD.m_mapMainDeckSurf.size()==1 && dataMD.m_mapShellSurf.size()==1;
|
||
|
||
TopoDS_Shape solid;// = dataMD.CreateHull();
|
||
|
||
for(int i = 0; i < zCnt; i++)
|
||
{
|
||
zVec.push_back(zStep[i]);
|
||
}
|
||
|
||
for(int i = 0; i < xCnt; i++)
|
||
{
|
||
xVec.push_back(xStep[i]);
|
||
}
|
||
|
||
for(int i = 0; i < heelCnt; i++)
|
||
{
|
||
heelVec.push_back(heelStep[i]);
|
||
heelCVec.push_back(heelC[i]);
|
||
}
|
||
|
||
for(int i = 0; i < trimCnt; i++)
|
||
{
|
||
trimVec.push_back(trimStep[i]);
|
||
}
|
||
|
||
bool bZstep = Cal.CheckZStep(zVec);
|
||
bool bXstep = Cal.CheckXStep(xVec);
|
||
bool bHeel = Cal.CheckHeel(heelVec, heelCVec, heelFMax, heelFMin, heelDai);
|
||
bool bTrim = Cal.CheckTrim(trimVec, trimFMax, trimFMin, trimDai);
|
||
|
||
//写xml
|
||
if(!bZstep)
|
||
{
|
||
dataMD.SetCalParaXml("ZSTEP", zVec);
|
||
}
|
||
if(!bXstep)
|
||
{
|
||
dataMD.SetCalParaXml("XSTEP", xVec);
|
||
}
|
||
if(!bHeel)
|
||
{
|
||
dataMD.SetCalParaXml("HEEL", heelVec, heelCVec, heelFMax, heelFMin, heelDai);
|
||
}
|
||
if(!bTrim)
|
||
{
|
||
dataMD.SetCalParaXml("TRIM", trimVec, trimFMax, trimFMin, trimDai);
|
||
}
|
||
|
||
//水平切
|
||
if(!bZstep)
|
||
{
|
||
Cal.SetZStep(zVec);
|
||
if(startType)
|
||
{
|
||
processCal.StartProcessCal(0, solid, 0);
|
||
}
|
||
}
|
||
|
||
//横剖切
|
||
if(!bXstep)
|
||
{
|
||
Cal.SetXStep(xVec);
|
||
if(startType)
|
||
{
|
||
processCal.StartProcessCal(1, solid, 0);
|
||
processCal.StartProcessCal(4, solid, 0);
|
||
}
|
||
}
|
||
else if(!bZstep)
|
||
{
|
||
if(startType)
|
||
{
|
||
processCal.StartProcessCal(1, solid, 0);
|
||
}
|
||
}
|
||
|
||
//水平旋转切
|
||
if(!bHeel)
|
||
{
|
||
Cal.SetHeel(heelVec, heelCVec,heelFMax, heelFMin, heelDai);
|
||
if(startType)
|
||
{
|
||
processCal.StartProcessCal(2, solid, 0);
|
||
}
|
||
}
|
||
|
||
//横剖旋转切
|
||
if(!bTrim)
|
||
{
|
||
Cal.SetTrim(trimVec, trimFMax, trimFMin, trimDai);
|
||
if(startType)
|
||
{
|
||
processCal.StartProcessCal(3, solid, 0);
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
DLLEXPORT void LoadCalculationXML(char* path)
|
||
{
|
||
//dataMD.LoadCalculationXML(path);
|
||
}
|
||
DLLEXPORT void SaveCalculationXML(char* path)
|
||
{
|
||
//dataMD.SaveCalculationXML(path);
|
||
}
|
||
DLLEXPORT void CloseCalulation()
|
||
{
|
||
dataMD.CloseCalculation();
|
||
}
|
||
//进水点计算接口
|
||
DLLEXPORT void SetInletPoint(int delpnts,Point3D delpnt[],int addpnts,Point3D addpnt[], int updCnt, int oldIDs[], Point3D newIDs[])
|
||
{
|
||
dataMD.SetInletPoint(delpnts, delpnt, addpnts, addpnt, updCnt, oldIDs, newIDs);
|
||
}
|
||
//极限静倾角计算接口
|
||
DLLEXPORT void SetDeckBilgePoint(int Cnt, Point3D addDeck[], Point3D addBilge[])
|
||
{
|
||
dataMD.SetDeckBilgePoint(Cnt, addDeck, addBilge);
|
||
}
|
||
//导出船壳计算数据文件
|
||
DLLEXPORT bool ExportHullCalFile(string fileName, string path, vector<int>& hullIDs)
|
||
{
|
||
return dataMD.ExportHull(fileName, path, hullIDs);
|
||
}
|
||
//导出舱室计算数据文件
|
||
DLLEXPORT bool ExportSpaceCalFile(string fileName, string path, vector<int>&spaceIDs)
|
||
{
|
||
return dataMD.ExportSpace(fileName, path, spaceIDs);
|
||
}
|
||
|
||
//导出舱室计算数据文件
|
||
DLLEXPORT bool ExportSolidCalFile(char* fileNameWithExtension, char* path, int count, int ids[])//20190601 added by czb
|
||
{
|
||
return dataMD.ExportSolidSTL(fileNameWithExtension, path, count, ids);
|
||
}
|
||
|
||
//导出计算数据文件
|
||
//DLLEXPORT void ExportIGES(char* fileName)
|
||
//{
|
||
// dataMD.ExportIGES(fileName);
|
||
//}
|
||
|
||
//获取曲线首尾端点和肋位或站位点 type=1,肋位;type=2,站位
|
||
DLLEXPORT int GetCurvePointByFS(int curveID, int xlen, double xSet[], int lens[], Point3D *pnts)
|
||
{
|
||
return dataMD.GetCurvePointByFS(curveID, xlen, xSet, lens, pnts);
|
||
}
|
||
|
||
DLLEXPORT int GetCurvePointByFSEx(int curveID, int xlen, vector<double>& xSet,vector<Point3D>& pnts)
|
||
{
|
||
return dataMD.GetCurvePointByFSEx(curveID, xlen, xSet, pnts);
|
||
}
|
||
|
||
// 数据接口 Lvxj
|
||
//导入型值表文件
|
||
DLLEXPORT void ImportOffsetData(bool bImportCtrlPnt,float xSubSectionLen)
|
||
{
|
||
dataMD.ImportOffsetData(bImportCtrlPnt,xSubSectionLen);
|
||
}
|
||
//导出型值表文件
|
||
DLLEXPORT void ExportOffsetData(double* shipSize,double* expParam, int* expType)
|
||
{
|
||
dataMD.ExportOffsetData(shipSize,expParam,expType);
|
||
}
|
||
//导入CAD文件
|
||
DLLEXPORT void ImportCAD(char* fileName)
|
||
{
|
||
dataMD.ImportCAD(fileName);
|
||
}
|
||
//导入IGES文件
|
||
DLLEXPORT long ImportIGES(char* fileName, int impType, float*transfromParams)
|
||
{
|
||
return dataMD.ImportIGES(fileName,impType,transfromParams);
|
||
}
|
||
//转换CAD型线
|
||
DLLEXPORT void TransfCADLine(int selectedCnt, int* selectLst, int lineType, float* fCADPar,int lens[], Point3D *pnts)
|
||
{
|
||
dataMD.TransfCADLine(selectedCnt, selectLst, lineType, fCADPar,lens, pnts);
|
||
}
|
||
//计算两条线交点
|
||
DLLEXPORT int GetIntersectPnt(int selectedCnt, int* selectLst,double*pPnt)
|
||
{
|
||
return dataMD.GetIntersectPnt(selectedCnt, selectLst,pPnt);
|
||
}
|
||
//导出IGES文件
|
||
DLLEXPORT void ExportIGES(char* fileName,int expOption,int selectCnt,int*selectLst)
|
||
{
|
||
dataMD.ExportIGES(fileName,expOption,selectCnt,selectLst);
|
||
}
|
||
|
||
|
||
DLLEXPORT bool SetObjVisibel(std::vector<int>& ids,int value)
|
||
{
|
||
for (auto id :ids)
|
||
{
|
||
SetObjVisibel(id,value);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
DLLEXPORT bool SetObjVisibel(int id,int value)
|
||
{
|
||
double type = id / MAX_SIZE_OF_OBJECT_GROUP;
|
||
if (type < 1)
|
||
{
|
||
for (auto &it : dataMD.m_mapPoints)
|
||
{
|
||
if (it.second.ID == id)
|
||
{
|
||
it.second.Visible = value;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else if (type >= 1 && type < 2)
|
||
{
|
||
for (auto &it : dataMD.m_mapCurves)
|
||
{
|
||
if (it.second.ID == id)
|
||
{
|
||
it.second.Visible = value;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else if (type >= 2 && type < 3)
|
||
{
|
||
for (auto &it : dataMD.m_mapSurfaces)
|
||
{
|
||
if (it.second.ID == id)
|
||
{
|
||
it.second.Visible = value;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else if (type >= 3 && type < 4)
|
||
{
|
||
for (auto &it : dataMD.m_mapSolids)
|
||
{
|
||
if (it.second.ID == id)
|
||
{
|
||
it.second.Visible = value;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else if (type >= 10 && type < 11)
|
||
{
|
||
}
|
||
else if (type >= 11 && type < 12)
|
||
{
|
||
}
|
||
else if (type >= 12 && type < 13)
|
||
{
|
||
}
|
||
else if (type >= 13 && type < 14)
|
||
{
|
||
}
|
||
else if (type >= 14 && type < 15)
|
||
{
|
||
}
|
||
else if (type >= 15 && type < 16)
|
||
{
|
||
}
|
||
else if (type >= 16 && type < 17)
|
||
{
|
||
for (auto &it : dataMD.m_mapSpace)
|
||
{
|
||
if (it.second.ID == id)
|
||
{
|
||
it.second.Visible = value;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else if (type >= 17 && type < 18)
|
||
{
|
||
for (auto &it : dataMD.m_mapAppendage)
|
||
{
|
||
if (it.second.ID == id)
|
||
{
|
||
it.second.Visible = value;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else if (type >= 18 && type < 19)
|
||
{
|
||
for (auto &it : dataMD.m_mapHull)
|
||
{
|
||
if (it.second.ID == id)
|
||
{
|
||
it.second.Visible = value;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
return true;
|
||
|
||
}
|
||
|
||
}
|