2 Replies Latest reply on Feb 3, 2017 5:24 AM by btempleton1982

# Determine if an art object is hidden due to being clipped

Does anyone have any experience with determining if an art object is not visible due to being within a clipping mask, but outside the visible area of the mask?

I've been playing around with the GeometrySuite with some success, but not getting quite what I want.

Are there any suite functions available for this check?

Does anyone have an algorithm already that works?

• ###### 1. Re: Determine if an art object is hidden due to being clipped

DoIntersectEffect for them;

GetSelectedArt( &matches, &count);

if ( count ==0)

{

//no intersection, the object is outside

}

• ###### 2. Re: Determine if an art object is hidden due to being clipped

Alright, I'm gonna put this here. I'm using wrapper classes for a lot of the SDK functions, but I think it's pretty obvious what's going on. It works, but it's probably not optimized. There may be corner cases where it fails too. Use at your own risk!

bool BtArtHandle::OverlapsRect(AIRealRect rect) const
{
AIRealRect artRect;
if (!ClippedBounds(artRect))
{
artRect = Bounds();
}
return sAIRealMath->AIRealRectOverlap(&artRect, &rect);
}

bool BtArtHandle::ClippedBounds(AIRealRect& result) const
{
bool boundsValid = false;
BtArtHandle enclosingClipArt = GetEnclosingClipArt();

while (!enclosingClipArt.Null())
{
AIRealRect clipRect = enclosingClipArt.Bounds();
AIRealRect thisRect;
if (boundsValid)
{
thisRect = result;
}
else
{
thisRect = Bounds();
}

boundsValid = sAIRealMath->AIRealRectIntersect(&clipRect, &thisRect, &result);
if (boundsValid)
{
enclosingClipArt = enclosingClipArt.Parent().GetEnclosingClipArt();
}
else
{
return boundsValid;
}
}

return boundsValid;
}

BtArtHandle BtArtHandle::GetEnclosingClipArt() const
{
BtArtHandle layerGroup(BtLayer(Layer()).GetLayerGroupArt());
BtArtHandle parent = Parent();

if (*this != layerGroup && parent != layerGroup)
{
if (parent.IsClippingGroup())
{
BtArtHandle sibling = parent.FirstChild();
do
{