253 lines
4.5 KiB
C++
253 lines
4.5 KiB
C++
#pragma once
|
|
#include <set>
|
|
#include "AecDbEwCable.h"
|
|
#include "AecDbEarthWormFitting.h"
|
|
|
|
namespace PIPECABLE
|
|
{
|
|
enum ETYPE
|
|
{
|
|
eHOLDER = 0, // 支架
|
|
eHANGER, // 吊架
|
|
eBOSS, // 管位
|
|
eNone,
|
|
};
|
|
|
|
const TCHAR gSplitCHAR = 0x0B;
|
|
const TCHAR gSubSplitCHAR = 0x0F;
|
|
|
|
// 支吊架所使用的布线脚本
|
|
struct SubCabling
|
|
{
|
|
int m_nFloor; // 放置第几层
|
|
int m_nCount; // 敷设几条
|
|
int m_nClr; // 颜色
|
|
double m_dDn; // 曲率半径
|
|
double m_dSpace; // 线缆间距
|
|
double m_dD; // 外径
|
|
CString m_linetype; // 线型
|
|
CString m_sModel; // 型号
|
|
CString m_sFactory; // 厂家
|
|
|
|
///
|
|
// 由于Cabling结构在每个支/吊架脚本中都存在,
|
|
// 此变量用来标识一个支/吊架是否已经敷设好了线缆
|
|
bool m_bValid;
|
|
///
|
|
|
|
SubCabling();
|
|
|
|
SubCabling(const SubCabling &cab);
|
|
|
|
SubCabling(const int &floor
|
|
, const int &count
|
|
, const int &clr
|
|
, const int &no
|
|
, const double &Dn
|
|
, const double &space
|
|
, const double &D
|
|
, LPCTSTR linetype
|
|
, LPCTSTR model
|
|
, LPCTSTR factory);
|
|
|
|
CString toString();
|
|
|
|
bool fromString(LPCTSTR psz);
|
|
|
|
static CString flag();
|
|
|
|
struct _comp
|
|
{
|
|
bool operator () (const SubCabling& a, const SubCabling& b) const
|
|
{
|
|
return a.m_nFloor < b.m_nFloor;
|
|
}
|
|
};
|
|
};
|
|
|
|
struct Cabling
|
|
{
|
|
std::vector<SubCabling> m_cables;
|
|
|
|
Cabling();
|
|
|
|
Cabling(const Cabling &cabling);
|
|
|
|
bool hasCabling() const;
|
|
|
|
CString toString();
|
|
|
|
bool fromString(LPCTSTR psz);
|
|
|
|
void sort();
|
|
|
|
void initSubCabling(const int &row);
|
|
|
|
static CString flag();
|
|
};
|
|
|
|
// 支架脚本
|
|
struct HOLDER
|
|
{
|
|
// 参数具体涵义,参看 toString()函数实现
|
|
int m_nRow;
|
|
int m_nPos;
|
|
int m_nNo;
|
|
int m_id3DEqu;
|
|
double m_dVSpace;
|
|
double m_dDistFrTop;
|
|
double m_dW;
|
|
double m_dt;
|
|
double m_dHSpace;
|
|
double m_dL;
|
|
CString m_sMaterial;
|
|
CString m_sSpec;
|
|
|
|
Cabling m_cabling; // 布线信息
|
|
|
|
/// 下面数据fromString()得到,但是在toString()方法中,还是需要传入这两个数据
|
|
int m_nRoomIdx;
|
|
CString m_sOffset;
|
|
///
|
|
HOLDER();
|
|
|
|
HOLDER(const HOLDER &holder);
|
|
|
|
bool fromString(LPCTSTR psz);
|
|
|
|
CString toString(const int &iRoom, const CString &sOffset);
|
|
|
|
static CString flag() { return _T("HOLDER"); }
|
|
};
|
|
|
|
// 吊架脚本
|
|
struct HANGER
|
|
{
|
|
// 参数具体涵义,参看 toString()函数实现
|
|
int m_nRow;
|
|
int m_nNo;
|
|
int m_id3DEqu;
|
|
double m_dVSpace;
|
|
double m_dHSpace;
|
|
double m_dDistFrTop;
|
|
double m_dL;
|
|
double m_dW;
|
|
double m_dt;
|
|
double m_dX;
|
|
CString m_sMaterial;
|
|
CString m_sSpec;
|
|
|
|
Cabling m_cabling; // 布线信息
|
|
|
|
/// 下面数据fromString()得到,但是在toString()方法中,还是需要传入这两个数据
|
|
int m_nRoomIdx;
|
|
CString m_sOffset;
|
|
///
|
|
|
|
HANGER();
|
|
|
|
HANGER(const HANGER &hanger);
|
|
|
|
bool fromString(LPCTSTR psz);
|
|
|
|
CString toString(const int &iRoom, const CString &sOffset);
|
|
|
|
static CString flag() { return _T("HANGER"); }
|
|
};
|
|
|
|
// 管位脚本
|
|
struct BOSS
|
|
{
|
|
// 参数具体涵义,参看 toString()函数实现
|
|
int m_nPos;
|
|
int m_nPipeColor;
|
|
int m_nKind;
|
|
int m_nRows;
|
|
int m_id3DEqu;
|
|
int m_nNo;
|
|
double m_dD;
|
|
double m_dX;
|
|
double m_dW;
|
|
double m_dH;
|
|
double m_dL;
|
|
double m_dPD;
|
|
double m_dDn;
|
|
double m_dt;
|
|
double m_dWeight;
|
|
double m_dh;
|
|
CString m_sSpec;
|
|
CString m_sMertial;
|
|
CString m_sCurrSys;
|
|
CString m_linetypeString;
|
|
/// 下面数据fromString()得到,但是在toString()方法中,还是需要传入这两个数据
|
|
int m_nRoomIdx;
|
|
CString m_sOffset;
|
|
///
|
|
|
|
BOSS();
|
|
|
|
BOSS(const BOSS &boss);
|
|
|
|
bool fromString(LPCTSTR psz);
|
|
|
|
CString toString(const int &iRoom, const CString &sOffset);
|
|
|
|
static CString flag() { return _T("BOSS"); }
|
|
};
|
|
|
|
|
|
}
|
|
|
|
namespace PIPECABLE
|
|
{
|
|
template <class T>
|
|
struct _comp
|
|
{
|
|
bool operator () (const T& a, const T& b)const
|
|
{
|
|
return a.m_nNo < b.m_nNo;
|
|
}
|
|
};
|
|
|
|
|
|
typedef std::set<HOLDER, _comp<HOLDER>> HolderSet;
|
|
typedef std::set<HANGER, _comp<HANGER>> HangerSet;
|
|
typedef std::set<BOSS, _comp<BOSS>> BossSet;
|
|
|
|
bool analyEwScript(LPCTSTR psz, LPCTSTR flag, std::vector<CString> &items);
|
|
|
|
// 连接线缆(用在 显示线缆 命令)
|
|
void connectPipeCable(std::map<CString, AcDbObjectIdArray*> &mapPosNoToIds);
|
|
|
|
// 为AecDbEarthWormFitting生成线缆
|
|
void generateCable(AcArray<LineSeg> &arLnSegs
|
|
, AcGePoint3dArray &arPtsBk
|
|
, const SubCabling &sb
|
|
, AcDbVoidPtrArray &ar);
|
|
|
|
template <class T>
|
|
typename std::set<T, _comp<T>>::iterator findItem(const int &no, std::set<T, _comp<T>> &ts)
|
|
{
|
|
T tt;
|
|
tt.m_nNo = no;
|
|
return ts.find(tt);
|
|
}
|
|
|
|
template <class T>
|
|
bool analyEwAddin(LPCTSTR psz, typename std::set<T, _comp<T>> &ss)
|
|
{
|
|
std::vector<CString> items(0);
|
|
analyEwScript(psz, T::flag(), items);
|
|
|
|
T t;
|
|
for (size_t i = 0; i < items.size(); ++i)
|
|
{
|
|
if (t.fromString(items[i]))
|
|
ss.insert(t);
|
|
}
|
|
|
|
return !ss.empty();
|
|
}
|
|
|
|
}
|