419 lines
13 KiB
C++
419 lines
13 KiB
C++
/***********************************************************************************************************************
|
|
*
|
|
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
|
|
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
|
|
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
|
|
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
|
|
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
|
|
* scope and manner of such use.
|
|
*
|
|
***********************************************************************************************************************/
|
|
|
|
#include <A3DSDKIncludes.h>
|
|
#include "PRC2XML.h"
|
|
|
|
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseMultipleVertex(const A3DTopoMultipleVertex* pVertex, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoMultipleVertexData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoMultipleVertexData, sData);
|
|
|
|
_TiXmlElement* vertex = new _TiXmlElement("A3DTopoMultipleVertexData");
|
|
traverseSource(pVertex, vertex);
|
|
|
|
A3DStatus iRet = A3DTopoMultipleVertexGet(pVertex, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
traversePoints("m_pPts",sData.m_uiSize, sData.m_pPts, vertex);
|
|
A3DTopoMultipleVertexGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
vertex->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(vertex);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseUniqueVertex(const A3DTopoUniqueVertex* pVertex, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoUniqueVertexData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoUniqueVertexData, sData);
|
|
|
|
_TiXmlElement* vertex = new _TiXmlElement("A3DTopoUniqueVertexData");
|
|
traverseSource(pVertex, vertex);
|
|
|
|
A3DStatus iRet = A3DTopoUniqueVertexGet(pVertex, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
traversePoint("m_sPoint", sData.m_sPoint, vertex);
|
|
setDoubleAttribute(vertex, "m_dTolerance", sData.m_dTolerance);
|
|
A3DTopoUniqueVertexGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
vertex->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(vertex);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseVertex(const A3DTopoVertex* pVertex, _TiXmlElement* setting)
|
|
{
|
|
A3DEEntityType eType;
|
|
A3DStatus iRet = A3DEntityGetType(pVertex, &eType);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
switch(eType)
|
|
{
|
|
case kA3DTypeTopoMultipleVertex:
|
|
iRet = stTraverseMultipleVertex(pVertex, setting);
|
|
break;
|
|
case kA3DTypeTopoUniqueVertex:
|
|
iRet = stTraverseUniqueVertex(pVertex, setting);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseEdge(const A3DTopoEdge* pEdge, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoEdgeData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoEdgeData, sData);
|
|
|
|
_TiXmlElement* edge = new _TiXmlElement("A3DTopoEdgeData");
|
|
traverseSource(pEdge, edge);
|
|
|
|
A3DStatus iRet = A3DTopoEdgeGet(pEdge, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
setDoubleAttribute(edge, "m_dTolerance", sData.m_dTolerance);
|
|
edge->SetAttribute("m_bHasTrimDomain", (int) sData.m_bHasTrimDomain);
|
|
|
|
if(sData.m_p3dCurve)
|
|
traverseCurve(sData.m_p3dCurve, edge);
|
|
if(sData.m_bHasTrimDomain)
|
|
traverseInterval(&sData.m_sInterval, edge);
|
|
|
|
if(sData.m_pStartVertex)
|
|
stTraverseVertex(sData.m_pStartVertex, edge);
|
|
if(sData.m_pEndVertex)
|
|
stTraverseVertex(sData.m_pEndVertex, edge);
|
|
|
|
A3DTopoEdgeGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
edge->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(edge);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseCoEdge(const A3DTopoCoEdge* pCoEdge, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoCoEdgeData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoCoEdgeData, sData);
|
|
|
|
_TiXmlElement* coedge = new _TiXmlElement("A3DTopoCoEdgeData");
|
|
traverseSource(pCoEdge, coedge);
|
|
|
|
A3DStatus iRet = A3DTopoCoEdgeGet(pCoEdge, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
if(sData.m_pEdge)
|
|
stTraverseEdge(sData.m_pEdge, coedge);
|
|
if(sData.m_pUVCurve)
|
|
traverseCurve(sData.m_pUVCurve, coedge);
|
|
|
|
//_SetAttributePtr(coedge, "m_pNeighbor", sData.m_pNeighbor);
|
|
coedge->SetAttribute("m_pNeighbor", sData.m_pNeighbor ? "true" : "false");
|
|
coedge->SetAttribute("m_ucOrientationUVWithLoop", (int) sData.m_ucOrientationUVWithLoop);
|
|
coedge->SetAttribute("m_ucOrientationWithLoop", (int) sData.m_ucOrientationWithLoop);
|
|
A3DTopoCoEdgeGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
coedge->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(coedge);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseLoop(const A3DTopoLoop* pLoop, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoLoopData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoLoopData, sData);
|
|
|
|
_TiXmlElement* loop = new _TiXmlElement("A3DTopoLoopData");
|
|
traverseSource(pLoop, loop);
|
|
|
|
A3DStatus iRet = A3DTopoLoopGet(pLoop, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
loop->SetAttribute("m_ucOrientationWithSurface", (int)(sData.m_ucOrientationWithSurface));
|
|
for(A3DUns32 ui = 0; ui < sData.m_uiCoEdgeSize; ++ui)
|
|
iRet = stTraverseCoEdge(sData.m_ppCoEdges[ui], loop);
|
|
A3DTopoLoopGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
loop->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(loop);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseFace(const A3DTopoFace* pFace, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoFaceData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoFaceData, sData);
|
|
|
|
_TiXmlElement* face = new _TiXmlElement("A3DTopoFaceData");
|
|
traverseSource(pFace, face);
|
|
|
|
A3DStatus iRet = A3DTopoFaceGet(pFace, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
face->SetAttribute("m_bHasTrimDomain", (int)(sData.m_bHasTrimDomain));
|
|
face->SetAttribute("m_uiOuterLoopIndex", (int)(sData.m_uiOuterLoopIndex));
|
|
setDoubleAttribute(face, "m_dTolerance", sData.m_dTolerance);
|
|
|
|
traverseSurface(sData.m_pSurface, face);
|
|
|
|
if(sData.m_bHasTrimDomain)
|
|
traverseDomain(&sData.m_sSurfaceDomain, face);
|
|
|
|
for(A3DUns32 ui = 0; ui < sData.m_uiLoopSize; ++ui)
|
|
iRet = stTraverseLoop(sData.m_ppLoops[ui], face);
|
|
|
|
A3DTopoFaceGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
face->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(face);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseShell(const A3DTopoShell* pShell, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoShellData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoShellData, sData);
|
|
|
|
_TiXmlElement* shell = new _TiXmlElement("A3DTopoShellData");
|
|
traverseSource(pShell, shell);
|
|
|
|
A3DStatus iRet = A3DTopoShellGet(pShell, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
shell->SetAttribute("closed", (int)(sData.m_bClosed));
|
|
|
|
for(A3DUns32 ui = 0; ui < sData.m_uiFaceSize; ++ui)
|
|
iRet = stTraverseFace(sData.m_ppFaces[ui], shell);
|
|
|
|
traverseUChars("m_pucOrientationWithShell",sData.m_uiFaceSize,sData.m_pucOrientationWithShell,shell);
|
|
|
|
A3DTopoShellGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
shell->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(shell);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseConnex(const A3DTopoConnex* pConnex, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoConnexData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoConnexData, sData);
|
|
|
|
_TiXmlElement* connex = new _TiXmlElement("A3DTopoConnexData");
|
|
traverseSource(pConnex, connex);
|
|
|
|
A3DStatus iRet = A3DTopoConnexGet(pConnex, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
for(A3DUns32 ui = 0; ui < sData.m_uiShellSize; ++ui)
|
|
iRet = stTraverseShell(sData.m_ppShells[ui], connex);
|
|
A3DTopoConnexGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
connex->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(connex);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
A3DStatus traverseBrepData(const A3DTopoBrepData* pBrepData, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoBrepDataData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoBrepDataData, sData);
|
|
|
|
_TiXmlElement* brepdata = new _TiXmlElement("A3DTopoBrepDataData");
|
|
setAttributePRC2XMLID(pBrepData, brepdata);
|
|
traverseSource(pBrepData, brepdata);
|
|
unsigned char ucBehavior;
|
|
traverseBodyContent(pBrepData, brepdata,ucBehavior);
|
|
|
|
A3DStatus iRet = A3DTopoBrepDataGet(pBrepData, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
for(A3DUns32 ui = 0; ui < sData.m_uiConnexSize; ++ui)
|
|
iRet = stTraverseConnex(sData.m_ppConnexes[ui], brepdata);
|
|
|
|
if(ucBehavior !=0)
|
|
iRet = traverseBoundingBox(&sData.m_sBoundingBox, brepdata);
|
|
|
|
A3DTopoBrepDataGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
brepdata->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(brepdata);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
static A3DStatus stTraverseWireEdge(const A3DTopoWireEdge* pWireEdge, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoWireEdgeData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoWireEdgeData, sData);
|
|
|
|
_TiXmlElement* wireedge = new _TiXmlElement("A3DTopoWireEdgeData");
|
|
traverseSource(pWireEdge, wireedge);
|
|
|
|
A3DStatus iRet = A3DTopoWireEdgeGet(pWireEdge, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
wireedge->SetAttribute("m_bHasTrimDomain", (int) sData.m_bHasTrimDomain);
|
|
|
|
if(sData.m_p3dCurve)
|
|
traverseCurve(sData.m_p3dCurve, wireedge);
|
|
|
|
if(sData.m_bHasTrimDomain)
|
|
traverseInterval(&sData.m_sInterval, wireedge);
|
|
|
|
A3DTopoWireEdgeGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
wireedge->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(wireedge);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
A3DStatus traverseSingleWireBody(const A3DTopoSingleWireBody* pSingleWireBody, _TiXmlElement* setting)
|
|
{
|
|
A3DTopoSingleWireBodyData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoSingleWireBodyData, sData);
|
|
|
|
_TiXmlElement* singlewirebody = new _TiXmlElement("A3DTopoSingleWireBodyData");
|
|
traverseSource(pSingleWireBody, singlewirebody);
|
|
unsigned char ucBehavior;
|
|
traverseBodyContent(pSingleWireBody, singlewirebody, ucBehavior);
|
|
|
|
A3DStatus iRet = A3DTopoSingleWireBodyGet(pSingleWireBody, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
iRet = stTraverseWireEdge(sData.m_pWireEdge, singlewirebody);
|
|
A3DTopoSingleWireBodyGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
singlewirebody->SetAttribute("error", A3DMiscGetErrorMsg(iRet));
|
|
}
|
|
|
|
setting->LinkEndChild(singlewirebody);
|
|
return iRet;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
A3DStatus traverseBodyContent(const A3DTopoBody* pBody, _TiXmlElement* setting, unsigned char &ucBehavior)
|
|
{
|
|
A3DInt32 iErr = A3D_SUCCESS;
|
|
A3DTopoBodyData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoBodyData, sData);
|
|
|
|
iErr = A3DTopoBodyGet(pBody, &sData);
|
|
if(iErr == A3D_SUCCESS)
|
|
{
|
|
_TiXmlElement* bodydata = new _TiXmlElement("A3DTopoBodyData");
|
|
|
|
ucBehavior = (unsigned char) sData.m_ucBehaviour;
|
|
bodydata->SetAttribute("m_ucBehaviour", (int) sData.m_ucBehaviour);
|
|
|
|
if(sData.m_pContext)
|
|
{
|
|
traverseTopoContext(sData.m_pContext, bodydata);
|
|
setting->LinkEndChild(bodydata);
|
|
}
|
|
|
|
A3DTopoBodyGet(NULL, &sData);
|
|
}
|
|
|
|
return A3D_SUCCESS;
|
|
}
|
|
|
|
//######################################################################################################################
|
|
A3DStatus traverseTopoContext(const A3DTopoContext* pContext, _TiXmlElement* setting)
|
|
{
|
|
A3DStatus iRet = A3D_SUCCESS;
|
|
A3DTopoContextData sData;
|
|
A3D_INITIALIZE_DATA(A3DTopoContextData, sData);
|
|
|
|
_TiXmlElement* topocontext = new _TiXmlElement("A3DTopoContextData");
|
|
traverseSource(pContext, topocontext);
|
|
|
|
iRet = A3DTopoContextGet(pContext, &sData);
|
|
if(iRet == A3D_SUCCESS)
|
|
{
|
|
topocontext->SetAttribute("m_ucBehaviour", sData.m_ucBehaviour);
|
|
topocontext->SetDoubleAttribute("m_dGranularity", sData.m_dGranularity);
|
|
topocontext->SetDoubleAttribute("m_dTolerance", sData.m_dTolerance);
|
|
topocontext->SetAttribute("m_bHaveSmallestFaceThickness", sData.m_bHaveSmallestFaceThickness ? "true" : "false");
|
|
topocontext->SetDoubleAttribute("m_dSmallestThickness", sData.m_dSmallestThickness);
|
|
topocontext->SetAttribute("m_bHaveScale", sData.m_bHaveScale ? "true" : "false");
|
|
topocontext->SetDoubleAttribute("m_dScale", sData.m_dScale);
|
|
|
|
A3DTopoContextGet(NULL, &sData);
|
|
}
|
|
else
|
|
{
|
|
topocontext->SetAttribute("error", iRet);
|
|
}
|
|
|
|
setting->LinkEndChild(topocontext);
|
|
return iRet;
|
|
}
|