In the following example, the clip boundary is pushed onto the clip boundary stack before anything is drawn and popped off again once the drawing for this object is complete:
Adesk::Boolean
MyObject::subWorldDraw(AcGiWorldDraw* pDraw)
{
AcGiWorldGeometry * pGeom = &pDraw->geometry();
pGeom->pushModelTransform(myTransform());
AcGiClipBoundary cb;
cb.m_bDrawBoundary = true;
cb.m_vNormal = AcGeVector3d::kZAxis;
cb.m_ptPoint = AcGePoint3d::kOrigin;
// Two points treated as a rectangle, three creates a triangle
cb.m_aptPoints.append(AcGePoint2d(0,0));
cb.m_aptPoints.append(AcGePoint2d(5,5));
// We are clipping in our own space
cb.m_xToClipSpace.setToIdentity();
cb.m_xInverseBlockRefXForm = myTransform().inverse();
// No Z clipping
cb.m_bClippingBack = cb.m_bClippingFront = false;
cb.m_dFrontClipZ = cb.m_dBackClipZ = 0.;
Adesk::Boolean bPopClipBoundary = pGeom->pushClipBoundary(&cb);
// Draw something
pGeom->circle(...);
pGeom->popModelTransform();
if(bPopClipBoundary){ pGeom->popClipBoundary(); }
return true; // world-only
}
Since this clipping is a complex operation, some AcGi implementations might not support it fully. In this case, the AcGi implementation may return false from pushClipBoundary(), and you should not call popClipBoundary().