Hi all,
I have a class derived from AcDbBlockReference. In the worldDraw, viewportDraw and saveAs methods I have to set the clipping boundaries according to the spatial filter in the blocks extension dictionary.
The following code works well if the block was in the WCS origin but fails if the block was not in the origin while clipping.
Therefore I need something like the transformation matrix of the clipping points recieved from pSpatial->getDefinition.
(I tried pSpatial->getVolume but didn't understand the returned values)
if ( (dictId=pBlock->extensionDictionary()) != AcDbObjectId::kNull)
{
AcDbDictionary *pDict;
if (Acad::eOk == acdbOpenObject(pDict, dictId, AcDb::kForRead))
{
AcDbDictionary *pFilter;
if (Acad::eOk == pDict->getAt("ACAD_FILTER", (AcDbObject*&)pFilter, AcDb::kForRead))
{
AcDbSpatialFilter *pSpatial;
if (Acad::eOk == pFilter->getAt("SPATIAL", (AcDbObject*&)pSpatial, AcDb::kForRead))
{
AcGePoint2dArray pnts;
AcGeVector3d normal;
double elevation, frontClip, backClip;
Adesk::Boolean enabled;
if (Acad::eOk == pSpatial->getDefinition(pnts, normal, elevation, frontClip, backClip, enabled))
{
if (enabled == Adesk::kTrue)
{
AcGeMatrix2d mat2d(mat.convertToLocal(normal, pBlock->position()));
AcGiClipBoundary cb;
cb.m_vNormal = normal;
cb.m_ptPoint = pBlock->position();
cb.m_bDrawBoundary = Adesk::kFalse;
for(i = 0; i < pnts.logicalLength(); i++) cb.m_aptPoints.append(pnts);
cb.m_xToClipSpace = mat;
cb.m_xInverseBlockRefXForm = mat;
// No Z clipping
cb.m_bClippingBack = cb.m_bClippingFront = false;
cb.m_dFrontClipZ = cb.m_dBackClipZ = 0.;
cb.m_bDrawBoundary = Adesk::kFalse;
wd->geometry().pushClipBoundary(&cb);
}
}
pSpatial->close();
}
pFilter->close();
}
pDict->close();
}
}
Best regards,
Christian