Пример #1
0
//---------------------------------------------------------------------------------------
//
//  功能: 曲面绘制回调函数
//
//  输入参数:
//             AeccDisplayOrientation &viewMode
//              IAeccSurface* surface
//             IAcadBlock *pAnonymousBlock 
//
//  返回值:bool
//
// 作  者:  
//
//  日期: 2007/08
//
//  修改记录:无
//
//---------------------------------------------------------------------------------------
bool customSurfaceDraw( const AeccDisplayOrientation &viewMode,  IAeccSurface* surface,
					   IAcadBlock* pAnonymousBlock )
{
	HRESULT hr = S_OK;

	CComQIPtr<IAeccTinSurface> pSurfaceTin( const_cast<IAeccSurface*>(surface) );
	if ( pSurfaceTin ) {

		VARIANT varTriangles;
		hr = pSurfaceTin->get_OutputTriangles( &varTriangles );
		if ( SUCCEEDED(hr) ) {

			long nDoubles = 0;
			double *pdblArray = 0;
			variantToDoublesArray( varTriangles, &nDoubles, &pdblArray );
			if ( pdblArray ) {
				// 文本宽度
				const double dblWidthAndHeight = 10.0;

				// 每三个点构成一个三角形
				for ( int i = 0, nIndexTriangle = 0; i < nDoubles; i += 9, nIndexTriangle++ ) {

					//计算三角形的中线点
					double dblCenterPoint[3];
					dblCenterPoint[0] = (pdblArray[i  ] + pdblArray[i+3] + pdblArray[i+6]) / 3;
					dblCenterPoint[1] = (pdblArray[i+1] + pdblArray[i+4] + pdblArray[i+7]) / 3;
					dblCenterPoint[2] = (pdblArray[i+2] + pdblArray[i+5] + pdblArray[i+8]) / 3;
					VARIANT varCenterPoint;
					doublesToVariant( 3, dblCenterPoint, &varCenterPoint );

					// 文本转换
					CString strText;
					strText.Format( _T("%.0f"), dblCenterPoint[2] );
					CComBSTR bstrText( strText );

					// 将文本添加到匿名块
					IAcadMText *pIAcadMText = 0;
					hr = pAnonymousBlock->AddMText( varCenterPoint, dblWidthAndHeight, bstrText, &pIAcadMText );
					if ( SUCCEEDED(hr) ) {
						pIAcadMText->put_Height( dblWidthAndHeight );
						pIAcadMText->put_AttachmentPoint( acAttachmentPointMiddleCenter );
					}
					SafeArrayDestroy( *varCenterPoint.pparray );
				}
				free ( pdblArray );
			}
			SafeArrayDestroy( *varTriangles.pparray );
		}
	}
	return (true) ;
}
Пример #2
0
// 清除节点的所有子节点,并将strText作为文本节点添加为本节点的子节点
int CBpXMLNode::SetText(const wchar_t *szText)
{
	if (m_pDOMNode == NULL || szText == NULL)
		return XML_ERROR;

	try
	{
		_bstr_t bstrText(szText);
		m_pDOMNode->put_text(bstrText);
	}
	catch (...)
	{
		return XML_ERROR;	
	}
	return XML_OK;
}