• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Determine if an art object is hidden due to being clipped

Engaged ,
Jan 25, 2017 Jan 25, 2017

Copy link to clipboard

Copied

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?

TOPICS
SDK

Views

589

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Participant ,
Jan 25, 2017 Jan 25, 2017

Copy link to clipboard

Copied

What about this?

copy mask and masked object;

DoIntersectEffect for them;

GetSelectedArt( &matches, &count);

if ( count ==0)

{

//no intersection, the object is outside

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

LATEST

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

            {

                if (sibling.ClipMask())

                {

                    return sibling;

                }

                sibling = sibling.Sibling();

            } while (!sibling.Null());

        }

       

        return parent.GetEnclosingClipArt();

    }

   

    return BtArtHandle();

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines