/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #include "PrcCommon.h" #include "OdDgn2PdfExportWithPrcStart.h" #include "PdfExport.h" #include "DgHostAppServices.h" #include "PrcDefaultContextForDGN.h" #include "DgDatabase.h" #include "DgModel.h" #include "DgElementIterator.h" #include "AppServices/PrcHostAppServices.h" #include "Dg3DObject.h" #include "DgArc.h" #include "DgCone.h" #include "DgMesh.h" #include "DgCellHeader.h" #include "DgBRepEntityPE.h" #include "MemoryStream.h" #include "DynamicLinker.h" using namespace TD_PDF_2D_EXPORT; OdDgElementId addSphere( const OdGePoint3d& ptCenter, double dSize, OdUInt32 uColorIndex, OdDgModelPtr& pModel ) { OdDgElementId idRet; OdDgSolidPtr pSphere = OdDgSolid::createObject(); idRet = pModel->addElement( pSphere ); pSphere->setNonPlanarFlag(true); pSphere->setNotSnappableFlag(true); pSphere->setType( OdDgSolid::kSolidRevolution ); pSphere->setColorIndex(uColorIndex); OdDg3dObjectHelper helper( pSphere ); OdGeMatrix3d matRot; OdGeMatrix3d matRot1; OdGeQuaternion quatRot; OdDgArc3dPtr pBoundary1 = OdDgArc3d::createObject(); pBoundary1->setOrigin( ptCenter ); pBoundary1->setPrimaryAxis( dSize/2.0 ); pBoundary1->setSecondaryAxis( dSize/2.0 ); pBoundary1->setStartAngle( 0 ); pBoundary1->setSweepAngle( OdaPI ); pBoundary1->setColorIndex(uColorIndex); helper.addToBoundary( pBoundary1 ); OdDgArc3dPtr pBoundary2 = OdDgArc3d::createObject(); pBoundary2->setOrigin( ptCenter ); pBoundary2->setPrimaryAxis( dSize/2.0 ); pBoundary2->setSecondaryAxis( dSize/2.0 ); pBoundary2->setStartAngle( 0 ); pBoundary2->setSweepAngle( OdaPI ); pBoundary2->setColorIndex(uColorIndex); helper.addToBoundary( pBoundary2 ); matRot.setToRotation(OdaPI2, OdGeVector3d::kYAxis); matRot1.setToRotation(OdaPI2, OdGeVector3d::kZAxis); matRot = matRot*matRot1; matRot.transposeIt(); quatRot.set(matRot); OdDgArc3dPtr pRule = OdDgArc3d::createObject(); pRule->setOrigin( ptCenter ); pRule->setPrimaryAxis( dSize/2.0 ); pRule->setSecondaryAxis( dSize/2.0 ); pRule->setStartAngle( 0 ); pRule->setSweepAngle( Oda2PI ); pRule->setRotation( quatRot ); pRule->setColorIndex(uColorIndex); helper.addToRule( pRule ); return idRet; } OdDgElementId addBox( const OdGePoint3d& ptCenter, double dSize, OdUInt32 uColorIndex, OdDgModelPtr& pModel ) { OdDgElementId idRet; OdDgMeshFaceLoopsPtr pBox = OdDgMeshFaceLoops::createObject(); idRet = pModel->addElement( pBox ); pBox->setColorIndex( uColorIndex ); pBox->setPointsNumber( 8 ); pBox->setPoint( 0, ptCenter - OdGeVector3d::kYAxis * dSize/2.0 - OdGeVector3d::kXAxis * dSize / 2.0 ); pBox->setPoint( 1, ptCenter - OdGeVector3d::kYAxis * dSize/2.0 - OdGeVector3d::kZAxis * dSize / 2.0 ); pBox->setPoint( 2, ptCenter - OdGeVector3d::kYAxis * dSize/2.0 + OdGeVector3d::kXAxis * dSize / 2.0 ); pBox->setPoint( 3, ptCenter - OdGeVector3d::kYAxis * dSize/2.0 + OdGeVector3d::kZAxis * dSize / 2.0 ); pBox->setPoint( 4, ptCenter + OdGeVector3d::kYAxis * dSize/2.0 - OdGeVector3d::kXAxis * dSize / 2.0 ); pBox->setPoint( 5, ptCenter + OdGeVector3d::kYAxis * dSize/2.0 - OdGeVector3d::kZAxis * dSize / 2.0 ); pBox->setPoint( 6, ptCenter + OdGeVector3d::kYAxis * dSize/2.0 + OdGeVector3d::kXAxis * dSize / 2.0 ); pBox->setPoint( 7, ptCenter + OdGeVector3d::kYAxis * dSize/2.0 + OdGeVector3d::kZAxis * dSize / 2.0 ); OdDgMeshFaceLoops::VerticesArray vertices; vertices.resize( 4 ); pBox->setFacesNumber( 6 ); vertices[ 0 ].m_pointIndex = 0; vertices[ 1 ].m_pointIndex = 1; vertices[ 2 ].m_pointIndex = 2; vertices[ 3 ].m_pointIndex = 3; pBox->setFace( 0, vertices ); vertices[ 0 ].m_pointIndex = 0; vertices[ 1 ].m_pointIndex = 1; vertices[ 2 ].m_pointIndex = 5; vertices[ 3 ].m_pointIndex = 4; pBox->setFace( 1, vertices ); vertices[ 0 ].m_pointIndex = 1; vertices[ 1 ].m_pointIndex = 2; vertices[ 2 ].m_pointIndex = 6; vertices[ 3 ].m_pointIndex = 5; pBox->setFace( 2, vertices ); vertices[ 0 ].m_pointIndex = 2; vertices[ 1 ].m_pointIndex = 3; vertices[ 2 ].m_pointIndex = 7; vertices[ 3 ].m_pointIndex = 6; pBox->setFace( 3, vertices ); vertices[ 0 ].m_pointIndex = 3; vertices[ 1 ].m_pointIndex = 0; vertices[ 2 ].m_pointIndex = 4; vertices[ 3 ].m_pointIndex = 7; pBox->setFace( 4, vertices ); vertices[ 0 ].m_pointIndex = 4; vertices[ 1 ].m_pointIndex = 5; vertices[ 2 ].m_pointIndex = 6; vertices[ 3 ].m_pointIndex = 7; pBox->setFace( 5, vertices ); return idRet; } OdDgElementId addCylinder( const OdGePoint3d& ptCenter, double dSize, OdUInt32 uColorIndex, OdDgModelPtr& pModel ) { OdDgElementId idRet; OdDgConePtr pCone = OdDgCone::createObject(); pCone->setCenter1( ptCenter - OdGeVector3d::kZAxis * dSize/2.0); pCone->setCenter2( ptCenter + OdGeVector3d::kZAxis * dSize/2.0); pCone->setRadius1( dSize/2.0 ); pCone->setRadius2( dSize/2.0 ); pCone->setColorIndex( uColorIndex ); idRet = pModel->addElement( pCone ); return idRet; } OdDgElementId addSmartSolid( const OdGePoint3d& ptCenter, double dSize, OdUInt32 uColorIndex, OdDgModelPtr& pModel ) { const OdUInt8 pX_B[] = { 0x50, 0x53, 0x00, 0x00, 0x00, 0x33, 0x3A, 0x20, 0x54, 0x52, 0x41, 0x4E, 0x53, 0x4D, 0x49, 0x54 , 0x20, 0x46, 0x49, 0x4C, 0x45, 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x62, 0x79 , 0x20, 0x6D, 0x6F, 0x64, 0x65, 0x6C, 0x6C, 0x65, 0x72, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F , 0x6E, 0x20, 0x31, 0x38, 0x30, 0x30, 0x31, 0x39, 0x37, 0x00, 0x00, 0x00, 0x11, 0x53, 0x43, 0x48 , 0x5F, 0x31, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5F, 0x31, 0x32, 0x30, 0x30, 0x36, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x0C, 0x00, 0x02, 0x00, 0x00, 0x00, 0x17, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01 , 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x40, 0x8F, 0x40, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3E, 0x45 , 0x79, 0x8E, 0xE2, 0x30, 0x8C, 0x3A, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01 , 0x01, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x01, 0x00, 0x08, 0x00, 0x09, 0x00, 0x01, 0x00 , 0x46, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00 , 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0A, 0x00 , 0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x0D, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01 , 0x00, 0x02, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0C, 0x00, 0x01, 0x00, 0x33 , 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x01, 0x00, 0x01 , 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0xBF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x1F, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x09, 0x00, 0x0F, 0x00 , 0x01, 0x00, 0x01, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xF0, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02 , 0x00, 0x0C, 0x00, 0x01, 0x00, 0x10, 0x56, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0C, 0x00 , 0x11, 0xC2, 0xBC, 0x92, 0x8F, 0x99, 0x6E, 0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x13, 0x00 , 0x07, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x51, 0x00, 0x00, 0x00, 0x01, 0x00, 0x11, 0x00 , 0x00, 0x00, 0x16, 0x00, 0x14, 0x00, 0x09, 0x00, 0x01, 0x00, 0x01, 0x00, 0x15, 0x00, 0x16, 0x00 , 0x17, 0x00, 0x11, 0x00, 0x12, 0x00, 0x01, 0x00, 0x18, 0x00, 0x12, 0x00, 0x12, 0x00, 0x01, 0x00 , 0x19, 0x00, 0x09, 0x00, 0x01, 0x00, 0x01, 0x2B, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x06 , 0x00, 0x16, 0xC2, 0xBC, 0x92, 0x8F, 0x99, 0x6E, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x09, 0x00, 0x01 , 0x00, 0x0F, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x51, 0x00, 0x00, 0x00, 0x01, 0x00, 0x16 , 0x00, 0x00, 0x00, 0x17, 0x00, 0x14, 0x00, 0x13, 0x00, 0x01, 0x00, 0x01, 0x00, 0x11, 0x00, 0x01 , 0x00, 0x1B, 0x00, 0x11, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x1C, 0x00, 0x1A, 0x00, 0x1A, 0x00, 0x01 , 0x00, 0x1D, 0x00, 0x13, 0x00, 0x01, 0x00, 0x01, 0x2B, 0x00, 0x1F, 0x00, 0x0F, 0x00, 0x00, 0x00 , 0x0A, 0x00, 0x01, 0x00, 0x13, 0x00, 0x01, 0x00, 0x07, 0x00, 0x01, 0x2B, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xF0, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x1C , 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0x00, 0x1A, 0x00, 0x0D, 0x00, 0x01, 0x00, 0x11, 0x00, 0x1D , 0x00, 0x01, 0x00, 0x1E, 0x00, 0x1D, 0x00, 0x1D, 0x00, 0x01, 0x00, 0x1A, 0x00, 0x13, 0x00, 0x01 , 0x00, 0x01, 0x2D, 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x1D, 0x00 , 0x1F, 0x00, 0x01, 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x09, 0x00, 0x20, 0xC2, 0xBC, 0x92 , 0x8F, 0x99, 0x6E, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x0B, 0x00, 0x1E, 0x00, 0x05, 0x00, 0x21, 0x2B , 0x00, 0x01, 0x00, 0x01, 0x00, 0x0D, 0x00, 0x0B, 0x00, 0x10, 0x00, 0x51, 0x00, 0x00, 0x00, 0x01 , 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x14, 0x00, 0x1F, 0x00, 0x01, 0x00, 0x01, 0x00, 0x22 , 0x00, 0x15, 0x00, 0x23, 0x00, 0x0E, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x02, 0x00, 0x15, 0xC2, 0xBC , 0x92, 0x8F, 0x99, 0x6E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1F, 0x00, 0x18, 0x00, 0x05, 0x00, 0x06 , 0x2B, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x1F, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x0B, 0x00 , 0x00, 0x00, 0x0F, 0x00, 0x22, 0xC2, 0xBC, 0x92, 0x8F, 0x99, 0x6E, 0x00, 0x00, 0x00, 0x1F, 0x00 , 0x01, 0x00, 0x24, 0x00, 0x05, 0x00, 0x0E, 0x2B, 0x00, 0x01, 0x00, 0x01, 0x00, 0x1F, 0x00, 0x01 , 0x00, 0x10, 0x00, 0x32, 0x00, 0x21, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x1F, 0x00, 0x01 , 0x00, 0x0E, 0x00, 0x01, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xF0, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00 , 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00 , 0x01, 0x00, 0x08, 0x00, 0x0B, 0x00, 0x32, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00 , 0x0B, 0x00, 0x21, 0x00, 0x06, 0x00, 0x01, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x51, 0x00, 0x00, 0x00, 0x01, 0x00, 0x22, 0x00, 0x00, 0x00, 0x13, 0x00, 0x14, 0x00, 0x0B , 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x20, 0x00, 0x25, 0x00, 0x0F, 0x00, 0x24, 0x00, 0x00 , 0x00, 0x0E, 0x00, 0x01, 0x00, 0x19, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x11, 0x00, 0x19, 0x00, 0x01 , 0x00, 0x24, 0x00, 0x19, 0x00, 0x19, 0x00, 0x01, 0x00, 0x12, 0x00, 0x09, 0x00, 0x01, 0x00, 0x01 , 0x2D, 0x00, 0x50, 0x00, 0x00, 0x00, 0x01, 0x00, 0x14, 0x00, 0x26, 0x00, 0x27, 0x00, 0x00, 0x23 , 0x28, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x52, 0x00, 0x00, 0x00, 0x02, 0x00, 0x25 , 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x4F, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x27 , 0x42, 0x53, 0x49, 0x5F, 0x45, 0x6E, 0x74, 0x69, 0x74, 0x79, 0x49, 0x64, 0x00, 0x51, 0x00, 0x00 , 0x00, 0x01, 0x00, 0x15, 0x00, 0x00, 0x00, 0x15, 0x00, 0x14, 0x00, 0x0D, 0x00, 0x01, 0x00, 0x01 , 0x00, 0x20, 0x00, 0x11, 0x00, 0x28, 0x00, 0x0F, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x01 , 0x00, 0x12, 0x00, 0x0D, 0x00, 0x1C, 0x00, 0x52, 0x00, 0x00, 0x00, 0x02, 0x00, 0x28, 0x00, 0x00 , 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x52, 0x00, 0x00, 0x00, 0x02, 0x00, 0x23, 0x00, 0x00 , 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x52, 0x00, 0x00, 0x00, 0x02, 0x00, 0x1B, 0x00, 0x00 , 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x52, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x00, 0x00 , 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x13, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x05, 0x00, 0x01 , 0x00, 0x02, 0x00, 0x01, 0x00, 0x08, 0x00, 0x05, 0x53, 0x00, 0x4A, 0x00, 0x00, 0x00, 0x14, 0x00 , 0x0A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x16, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00 , 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00 , 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00 , 0x01, 0x00, 0x01 }; OdStreamBufPtr pBuf = OdMemoryStream::createNew(); pBuf->putBytes(pX_B, sizeof(pX_B)); pBuf->rewind(); OdDgCellHeader3dPtr cell = OdDgCellHeader3d::createObject(); // pCell must be DBRO entity. pModel->addElement( cell ); //rotate and scale the cell OdGeMatrix3d transformation; transformation.setToScaling( dSize*0.5); cell->setTransformation( transformation ); //origin cell->setOrigin( ptCenter ); cell->setColorIndex( uColorIndex ); OdDgBRepEntityPEPtr(cell)->fillSmartSolid(*cell, *pBuf); OdDgElementIteratorPtr pIter = cell->createIterator(); for(; !pIter->done(); pIter->step()) { OdDgElementPtr pElm = pIter->item().openObject(OdDg::kForWrite); if( pElm->isKindOf(OdDgGraphicsElement::desc()) ) { OdDgGraphicsElementPtr pGraph = pElm; pGraph->setColorIndex( uColorIndex ); } } return cell->elementId(); } void fillDatabase(OdDgDatabasePtr &pDb) { // get active dgn model. OdDgModelPtr pActiveModel = pDb->getActiveModelId().openObject(OdDg::kForWrite); // Create red dgn solid sphere. OdDgElementId idSphere = addSphere( OdGePoint3d(0.0,0.0,0.0), 10.0, 3, pActiveModel ); // Create green dgn mesh box. OdDgElementId idBox = addBox( OdGePoint3d(11.0,0.0,0.0), 10.0, 2, pActiveModel ); // Create blue dgn cone cylinder. OdDgElementId idCylinder = addCylinder( OdGePoint3d(0.0,-20.0,0.0), 10.0, 1, pActiveModel ); // Create yellow dgn smart solid. OdDgElementId idSmartSolid = addSmartSolid( OdGePoint3d(11.0,-20.0,0.0), 10.0, 4, pActiveModel ); // Transform 3d objects. OdGeMatrix3d matRot; matRot.setToRotation(OdaPI/4, OdGeVector3d::kXAxis); OdDgGraphicsElementPtr pSphereElm = idSphere.openObject(OdDg::kForWrite); pSphereElm->transformBy( matRot); OdDgGraphicsElementPtr pBoxElm = idBox.openObject(OdDg::kForWrite); pBoxElm->transformBy( matRot); OdDgGraphicsElementPtr pCylinderElm = idCylinder.openObject(OdDg::kForWrite); pCylinderElm->transformBy( matRot); OdDgGraphicsElementPtr pSmartSolidElm = idSmartSolid.openObject(OdDg::kForWrite); pSmartSolidElm->transformBy( matRot); // Zoom to extents. pActiveModel->fitToView(); pSphereElm = 0; pBoxElm = 0; pCylinderElm = 0; pSmartSolidElm = 0; } void fillLayoutList(OdArray &layouts, OdDgDatabasePtr &pDb) { OdDgModelTablePtr pModelTable = pDb->getModelTable(); if (!pModelTable.isNull()) { OdDgElementIteratorPtr pIter = pModelTable->createIterator(); for ( ; !pIter->done(); pIter->step() ) { OdDgModelPtr pModel = OdDgModel::cast( pIter->item().openObject() ); if ( pModel.get() ) { layouts.push_back(pModel->getName()); } } } } void OdDgn2PdfSimpleExample(OdDgHostAppServices &svcs, OdString pdfPath, PDFExportParams::PRCSupport flags, bool shouldUseSingleViewMode, void (*fillerfunc)(OdDgDatabasePtr &pDb)) { /******************************************************************/ /* Create a Pdf export module */ /******************************************************************/ OdPdfExportModulePtr pModule = ::odrxDynamicLinker()->loadApp(OdPdfExportModuleName, false); ::odrxDynamicLinker()->loadApp(OdPrcModuleName, false); ::odrxDynamicLinker()->loadApp(OdDgn2PrcExportModuleName, false); ::odrxDynamicLinker()->loadModule(L"TG_Db", false); /******************************************************************/ /* Create a database and load the drawing into it. */ /******************************************************************/ OdDgDatabasePtr pDb = svcs.createDatabase(); fillerfunc(pDb); { /****************************************************************/ /* Initialize the conversion parameters */ /****************************************************************/ PDFExportParams params; OdPdfExportPtr exporter = pModule->create(); params.setDatabase(pDb); params.setVersion(OdPDF::kPDFAuto); OdString pdfName = pdfPath; params.setOutput(::odrxSystemServices()->createFile(pdfName, Oda::kFileWrite, Oda::kShareDenyNo, Oda::kCreateAlways)); params.setExportFlags(PDFExportParams::kDefault); params.setTitle("Batch PDF File"); params.setAuthor("Dgn2PrcExportTest"); params.setCreator("Open Design Alliance"); params.setPRCMode(flags); OdPrcContextForPdfExportPtr pContext = odCreatePrcAllInSingleViewContextForDGN(); params.setPRCContext(pContext); /****************************************************************/ /* Initialize the conversion parameters: Layouts */ /****************************************************************/ fillLayoutList(params.layouts(), pDb); params.pageParams().resize(1, OdGsPageParams()); /****************************************************************/ /* Export */ /****************************************************************/ OdUInt32 errCode = exporter->exportPdf(params); if (errCode != 0) { OdString errMes = exporter->exportPdfErrorCode(errCode); printf("\nexportPdf error returned : 0x%x. \n%s", (unsigned)errCode, (const char*)errMes); } } } void OdDgn2PdfSimpleExample(OdDgHostAppServices &svcs, OdString pdfPath) { OdDgn2PdfSimpleExample(svcs, pdfPath, PDFExportParams::kAsMesh, true, fillDatabase); } #define ODPRCEXPORTCASE(name, description, callmethod) void callmethod(OdDgHostAppServices &svcs, OdString pdfPath); #include "ExampleCases.h" void OdDgn2PdfExportWithPrcStart(OdDgHostAppServices &svcs, OdString pdfPath, ExportMode emode) { #define ODPRCEXPORTCASE(name, description, callmethod) if (emode == k##name) callmethod(svcs, pdfPath); else #include "ExampleCases.h" ODA_ASSERT(false); }