Inherited from NItem,
Inherited by NULL
Friend class ModelManager,
Description
XModel封装了一个完整模型的所有信息。一个模型主要包含三个层次的信息,第一个层次是装配信息,即零部件与零部件的装配关系,便于用户对整个模型的访问与管理;第二个层次是几何拓扑信息,一个零部件包含若干顶层几何体,而顶层几何体又分别包含若干下一级几何体(如体包含若干面,面包含若干边,边包含最多两个顶点);第三个层次是网格信息,模型的几何面在视图上都以离散的三角片(三角单元)表达,几何边在视图上以离散的线段(线单元)表达,几何顶点以离散的点(点单元)表达,在截面视图上,以离散的体单元表达截面细节。可参考模型的结构示意图。
XModel与大多数其他数据对象不一样,它本身包含了若干对象管理器,包括部件管理器、几何管理器、节点管理器、网格管理器,在一个模型内,部件(包括装配体)、几何实体(体、线、面、点)、节点、网格都有各自唯一的ID,这些管理器不能被XDocument直接访问,因此访问节点、网格、几何实体与部件都首先需要访问XModel,然后再通过XModel提供的接口访问具体的数据对象。
XT从底层构建了undo、redo机制,这套机制对访问和修改数据对象做了区分,其中访问通过getItem接口完成,数据的改动可通过3个接口完成,其中createItem用于增加数据,removeItem用于删除数据,checkOutItem用于修改已有的数据。XModel内部数据的访问和改动也完全遵守这套机制,createNode、createPart、createElement、createGeometry用于增加数据,removeNode、removeElement、removePart、removeGeometry用于删除数据,checkOutNode、checkOutElement、checkOutPart、checkOutGeometry用于修改已有的数据。
为了更方便的访问遍历特定拓扑类型的几何,XModel在几何管理器中为每个拓扑类型都构建了一套哈希表,通过指定拓扑类型,XModel就可以直接绑定其相应的访问迭代器。
XModel可以为不同部件设置不同的角色,不同角色的部件被置于不同的装配树根节点下,装配树根节点在创建XModel对象时自动生成,它的ID为0,因此不能通过ModelCompoenentManager来访问它,只能通过getAssemblyRoot接口访问。目前部件支持Normal和Auxiliary两种角色。
Members
Public interface
-
-
void
init(OpnRecorder * rec = NULL)
const XPart *
getPart(ulong id)const
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
XGeometry *
createGeometry(TypeID t,ulong id = 0,XGeometry * parent = 0)
-
XNode *
createNode(const real * coord,ulong nid = 0)
XAssembly *
createAssembly(const char * name, ulong id, XAssembly * parent, bool bAuxiliary = false)
XPart *
createPart(const char * name, ulong id, XAssembly * parent, bool bAuxiliary = false)
-
void
moveNode(const XNode * n, const real * coord)
-
XElement *
createElement(TypeID et, const NodePtr* pNodes,ulong eid = 0,XGeometry * entity = 0, bool bUpdateNodeElemLink = true)
void
removeElement(XElement * pElement, bool bDeleteFreeNode = true)
void
replaceElemNode(XElement* pElem,const XNode * old, const XNode * new_node,bool notDetachOld = false)
-
void
setElemNode(XElement* pElem,int index, const XNode * new_node)
-
-
-
-
-
-
-
void
setCellFacets(const XElement ** facets, int cnt, XElement* pElem)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
void
write(XBinaryIO * io) const
-
void
save(const char * fname) const
bool
load(const char * fname)
void
saveH5(const char * fname) const
bool
loadH5(const char * fname)
ErrorCode
read(XBinaryIO * io)
-
void
write(XH5IO * io, H5Obj * grp) const
bool
read(XH5IO * io, H5Obj * grp)
-
-
-
-
-
-
-
-
-
-
Private interface
-
-
-
-
-
ErrorCode
readAssembly(XBinaryIO * io, TreeNode * pItem = 0)
-
-
-
-
XBoundBox m_dBoundBox
模型的包围盒
const XAssembly * m_pAssemblyRoot
模型装配树根节点
const XAssembly * m_pAuxiliaryRoot
模型辅助树根节点
XMemPool * m_pHashPool
模型哈希内存池,被模型内部的各种管理器共享使用
XMemPool * m_pGeneralPool
模型通用内存池
real m_dTScale
模型特征尺度,近似等于模型包围盒的最大尺寸,在很多计算的场合用于将坐标归一化处理
bool m_bGLDataReady
模型视图数据是否构建好的标志
bool m_bVisible
模型是否可见
int m_iDomainHdlIDBase
模型的起始域ID,由于模型内部的管理器并不是单一管理器,在需要undo、redo的场合,以该ID索引模型内部对象数据的变动。
OpnRecorder * m_pRecorder
模型数据操作记录器
NodeManager * m_pNodeMgr
模型节点管理器,由模型构建,非单一管理器
ElementManager * m_pElemMgr
模型单元管理器,由模型构建,非单一管理器
GeometryManager * m_pElsetMgr
模型几何管理器,由模型构建,非单一管理器
PartManager * m_pPartMgr
模型部件管理器,由模型构建,非单一管理器
PartSnapshotManager * m_pPSSMgr
部件快照管理器,单一管理器,外部构建
XModel(ulong mid)
function: 构造函数
parameters:
[i]ulong mid: 模型ID
return value: 无
~XModel()
function: 析构函数
parameters: NULL
return value: 无
void init(OpnRecorder * rec = NULL)
const XPart * getPart(ulong id)const
function: 访问模型部件
parameters:
[i]ulong id: 部件ID
return value: 模型部件指针
XNode * checkOutNode(const XNode * n)
function: 以可修改的模式访问模型节点
parameters:
[i]const XNode * n: 节点常指针(不可修改)
return value: 节点指针(可修改)
XElement * checkOutElement(const XElement * e)
function: 以可修改的模式访问模型单元
parameters:
[i]const XElement * e: 单元常指针(不可修改)
return value: 单元指针(可修改)
XElement * checkOutElement(ulong id)
function: 以可修改的模式访问模型单元
parameters:
[i]ulong id: 单元ID
return value: 单元指针(可修改)
XPart * checkOutPart(ulong id)
function: 以可修改的模式访问模型部件
parameters:
[i]ulong id: 部件ID
return value: 部件指针(可修改)
XPart * checkOutPart(const XPart * p)
function: 以可修改的模式访问模型节点
parameters:
[i]const XPart * p: 节点常指针(不可修改)
return value: 节点指针(可修改)
void bindPartSnapshotManager(PartSnapshotManager * pssMgr)
PartManager * getPartManager()
function: 获取模型部件管理器
parameters: NULL
return value: 模型部件管理器
NodeManager * getNodeManager()
function: 获取模型节点管理器
parameters: NULL
return value:
ElementManager * getElemManager()
function: 获取模型单元管理器
parameters: NULL
return value:
GeometryManager * getGeometryManager()
function: 获取模型几何管理器
parameters: NULL
return value:
const XAssembly * getAssemblyRoot() const
function: 获取模型装配树根节点
parameters: NULL
return value: 模型装配树根节点
const XAssembly * getAuxiliaryRoot() const
function: 获取模型辅助树根节点
parameters: NULL
return value: 模型辅助树根节点
const XGeometry * getGeometry(ulong id)const
XGeometry * checkOutGeometry(ulong id)
XGeometry * checkOutGeometry(const XGeometry *g)
void bindPartIterator(HashIterator * pIter) const
function: 绑定模型部件遍历迭代器
parameters:
[i]HashIterator * pIter: 部件遍历迭代器
return value: 无
void bindNodeIterator(HashIterator * pIter)const
function: 绑定模型节点遍历迭代器
parameters:
[i]HashIterator * pIter: 节点遍历迭代器
return value: 无
void bindElementIterator(HashIterator * pIter)const
function: 绑定模型单元遍历迭代器
parameters:
[i]HashIterator * pIter: 单元遍历迭代器
return value: 无
void bindGeometryIterator(HashIterator * pIter)const
function: 绑定模型几何遍历迭代器
parameters:
[i]HashIterator * pIter: 几何遍历迭代器
return value: 无
void bindGeometryIterator(HashIterator * pIter,TypeID gt)const
void removeGeometry(const XGeometry * g)
function: 删除模型几何对象
parameters:
[i]const XGeometry * g: 模型几何对象
return value: 无
XGeometry * createGeometry(TypeID t,ulong id = 0,XGeometry * parent = 0)
function: 创建模型几何对象
parameters:
[i]TypeID t: 拓扑类型
[i]ulong id = 0: 几何ID,为0时将使用管理器记录的NextID
[i]XGeometry * parent = 0: 父拓扑
return value: 模型几何对象
XNode * createNode(const real * coord,ulong nid = 0)
function: 创建模型节点
parameters:
[i]const real * coord: 节点坐标
[i]ulong nid = 0: 节点ID,为0时将使用管理器记录的NextID
return value: 模型节点对象指针
XAssembly * createAssembly(const char * name, ulong id, XAssembly * parent, bool bAuxiliary = false)
function: 创建模型装配体
parameters:
[i]const char * name: 装配体名字
[i] ulong id: 装配体ID,为0时将使用部件管理器记录的NextID
[i] XAssembly * parent: 父装配体
[i] bool bAuxiliary = false: 是否为辅助对象,默认否
return value: 装配体对象指针
XPart * createPart(const char * name, ulong id, XAssembly * parent, bool bAuxiliary = false)
function: 创建模型部件对象
parameters:
[i]const char * name: 部件名字
[i] ulong id: 部件ID,为0时将使用部件管理器记录的NextID
[i] XAssembly * parent: 父装配体,为空时父装配体自动被设置为相应的根节点
[i] bool bAuxiliary = false: 是否为辅助对象,默认否
return value: 模型部件对象指针
void removeNode(const XNode * pNode)
function: 删除模型节点
parameters:
[i]const XNode * pNode: 模型节点
return value: 无
void moveNode(const XNode * n, const real * coord)
NodePtr getNode(ulong id) const
XElement * createElement(TypeID et, const NodePtr* pNodes,ulong eid = 0,XGeometry * entity = 0, bool bUpdateNodeElemLink = true)
function: 创建模型单元对象
parameters:
[i]TypeID et: 单元类型
[i] const NodePtr* pNodes: 单元节点指针数组
[i]ulong eid = 0: 单元ID,为0时将使用单元管理器记录的NextID
[i]XGeometry * entity = 0: 单元所属几何对象
[i] bool bUpdateNodeElemLink = true: 是否更新节点的单元链接表
return value: 模型单元对象指针
void removeElement(XElement * pElement, bool bDeleteFreeNode = true)
function: 删除模型单元
parameters:
[i]XElement * pElement: 单元指针
[i] bool bDeleteFreeNode = true: 是否删除自由节点(节点的单元链接表为空)
return value: 无
void replaceElemNode(XElement* pElem,const XNode * old, const XNode * new_node,bool notDetachOld = false)
function: 替换单元节点
parameters:
[i]XElement* pElem: 单元指针
[i]const XNode * old: 被替换的单元节点
[i] const XNode * new_node: 替换后的单元节点
[i]bool notDetachOld = false: 是否不解除替换前的节点单元绑定关系,默认解除
return value: 无
void resetElemNodes(XElement* pElem,const XNode ** ns)
function: 重置单元节点
parameters:
[i]XElement* pElem: 单元指针
[i]const XNode ** ns: 单元节点数组
return value: 无
void setElemNode(XElement* pElem,int index, const XNode * new_node)
function: 设置单元节点
parameters:
[i]XElement* pElem: 单元指针
[i]int index: 节点序号
[i] const XNode * new_node: 单元节点指针
return value: 无
void updateNodeElementLink(bool bKeepOld)
function: 更新节点的单元链接表
parameters:
[i]bool bKeepOld: 是否保持已有的单元链接表而不是完全重建
return value: 无
void updateNodeElementLink(vector<const XPart *> * parts, bool bKeepOld)
void updateNodeElementLink(vector<const XGeometry *> * geoms, bool bKeepOld)
void addCellFacet(ElemPtr pFacet, XElement * cell)
void removeCellFacet(ElemPtr facet, XElement * cell)
function: 删除Cell单元的面
parameters:
[i]ElemPtr facet: Cell面单元(一般为Polygon或者Polyline单元)
[i] XElement * cell: Cell单元
return value: 无
void setPolylineNodes(const XNode ** ns, int cnt, XElement* pElem)
function: 设置多折线单元的节点
parameters:
[i]const XNode ** ns: 节点数组
[i] int cnt: 节点个数
[i] XElement* pElem:多折线单元指针
return value: 无
void setPolygonNodes(const XNode ** ns, int cnt, XElement* pElem)
function: 设置多边形单元的节点
parameters:
[i]const XNode ** ns: 节点数组
[i] int cnt: 节点个数
[i] XElement* pElem: 多边形单元指针
return value: 无
void setCellFacets(const XElement ** facets, int cnt, XElement* pElem)
function: 设置Cell单元的面信息
parameters:
[i]const XElement ** facets: Cell单元面数组
[i] int cnt: 面的个数
[i] XElement* pElem: Cell单元数组
return value: 无
ElemPtr getElement(ulong id) const
void removePart(const XPart * pPart)
function: 删除模型部件
parameters:
[i]const XPart * pPart: 模型部件指针
return value: 无
int getPartCount(bool bExcludeAsb = true) const
function: 获取模型部件个数
parameters:
[i]bool bExcludeAsb = true: 是否包含装配体
return value: 模型部件个数
int getElementCount()const
function: 获取模型单元个数
parameters: NULL
return value: 模型单元个数
int getNodeCount()const
function: 获取模型节点个数
parameters: NULL
return value: 模型节点个数
int getSurfaceElementCount()const
function: 获取模型面单元个数
parameters: NULL
return value: 模型面单元个数
int getGeometryCount(TypeID gt)const
int getGeometryCount() const
function: 获取全部模型几何对象个数
parameters: NULL
return value: 全部模型几何对象个数
void attachElemToGeom(XGeometry * g, XElement * el)
void detachElemFromGeom(XGeometry * g, XElement * el)
void attachPartToAssembly(XAssembly * asb, XPart * p)
function: 绑定装配体与部件的从属关系
parameters:
[i]XAssembly * asb: 模型装配体对象
[i] XPart * p: 模型部件对象
return value: 无
void detachPartFromAssembly(XAssembly * asb, XPart * p)
function: 解除装配体与部件的从属关系
parameters:
[i]XAssembly * asb: 模型装配体对象
[i] XPart * p: 模型部件对象
return value: 无
void attachPartSnapshot(XPart * p, XPartSnapshot * asb)
void detachPartSnapshot(XPart * p, XPartSnapshot * asb)
void attachGeomToPart(XGeometry * g, XPart * p)
void detachGeomFromPart(XGeometry * g, XPart * p)
void attachGeomChild(XGeometry * g, const XGeometry * child)
function: 绑定几何对象的拓扑从属关系
parameters:
[i]XGeometry * g: 模型几何父对象
[i] const XGeometry * child: 模型几何子对象
return value: 无
void detachGeomChild(XGeometry * g, const XGeometry * child)
function: 解除几何对象的拓扑从属关系
parameters:
[i]XGeometry * g: 模型几何父对象
[i] const XGeometry * child: 模型几何子对象
return value: 无
void clear()
function: 清空模型并重置模型为初始状态
parameters: NULL
return value: 无
void clearViewData()
function: 清空模型视图数据
parameters: NULL
return value: 无
void updateViewData()
function: 更新构建模型视图数据
parameters: NULL
return value: 无
bool isViewDataReady() const
ulong getNextGeometryId()
ulong getNextElementId()
ulong getNextNodeId()
const XBoundBox & getBoundBox() const
function: 获取模型的包围盒
parameters: NULL
return value: 模型的包围盒
void normalizeBoundBox(const real * origin, real scale)
function: 归一化模型包围盒
parameters:
[i]const real * origin: 归一化基准点
[i] real scale: 归一化系数
return value: 无
void restoreBoundBox(const real * origin, real scale)
void updateBoundBox()
function: 更新模型包围盒
parameters: NULL
return value: 无
void setPartVisible(ulong id,bool bVisible)
function: 设置部件的可见性
parameters:
[i]ulong id: 部件ID
[i]bool bVisible: 是否可见
return value: 无
void setGeomVisible(ulong id, bool bVisible)
function: 设置几何对象的可见性
parameters:
[i]ulong id: 几何对象ID
[i] bool bVisible: 是否可见
return value: 无
XVertex* getVertexByNode(XNode * pNode)
void createDefaultPart()
void write(XBinaryIO * io) const
function: 将模型数据写入到二进制文件中
parameters:
[i]XBinaryIO * io: 二进制文件句柄
return value:
void save(const char * fname) const
function: 将模型数据保存到文件中
parameters:
[i]const char * fname: 文件路径
return value: 无
bool load(const char * fname)
void saveH5(const char * fname) const
bool loadH5(const char * fname)
ErrorCode read(XBinaryIO * io)
void write(XH5IO * io, H5Obj * grp) const
bool read(XH5IO * io, H5Obj * grp)
void copy(XModel * mdl)
bool isVisible() const
void setVisible(bool b)
function: 设置模型的可见性
parameters:
[i]bool b: 是否可见
return value: 无
void updateAfterRenumber(TypeID tid)
void setGLDataReady(bool bReady)
function: 设置模型视图数据是否准备完毕
parameters:
[i]bool bReady: 模型视图数据是否准备完成
return value: 无
real getNormalizedScale()
function: 获取模型归一化系数
parameters: NULL
return value: 模型归一化系数
void setNormalizedScale(real s)
function: 设置模型归一化系数
parameters:
[i]real s: 模型归一化系数
return value: 无
OpnRecorder * getRecorder()
function: 获取模型数据操作记录器
parameters: NULL
return value: 模型数据操作记录器
void updateFaceColorByPart(const XPart * p)
function: 根据所属部件更新面的颜色
parameters:
[i]const XPart * p: 模型部件对象
return value:无
void setGeomVisible(const XGeometry * g, bool bVisible)
function: 设置几何可见性
parameters:
[i]const XGeometry * g: 模型几何对象
[i] bool bVisible: 是否可见
return value: 无
void writeNodes(XBinaryIO * io) const
ErrorCode readNodes(XBinaryIO * io,int cnt)
void writeElements(XBinaryIO * io) const
ErrorCode readElements(XBinaryIO * io)
void writeAssembly(XBinaryIO * io, TreeNode * pItem = 0) const
ErrorCode readAssembly(XBinaryIO * io, TreeNode * pItem = 0)