//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionsToOtherViews(RimCase& gridCase, std::vector<RimIntersection*> intersections)
{
    for (RimIntersection* intersection : intersections)
    {
        for (Rim3dView* const view : gridCase.views())
        {
            RimGridView* currGridView = dynamic_cast<RimGridView*>(view);
            RimGridView* parentView = nullptr;
            intersection->firstAncestorOrThisOfType(parentView);

            if (currGridView && parentView != nullptr && parentView != currGridView)
            {
                RimIntersectionCollection* destCollection = currGridView->crossSectionCollection();

                RimIntersection* copy = dynamic_cast<RimIntersection*>(intersection->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
                CVF_ASSERT(copy);

                destCollection->appendIntersectionAndUpdate(copy);

                // Resolve references after object has been inserted into the project data model
                copy->resolveReferencesRecursively();
                copy->updateConnectedEditors();
            }
        }
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionBoxesToOtherViews(RimCase& gridCase, std::vector<RimIntersectionBox*> intersectionBoxes)
{
    for (RimIntersectionBox* intersectionBox : intersectionBoxes)
    {
        for (Rim3dView* const view : gridCase.views())
        {
            RimGridView* currGridView = dynamic_cast<RimGridView*>(view);
            RimGridView* parentView = nullptr;
            intersectionBox->firstAncestorOrThisOfType(parentView);

            if (currGridView && parentView != nullptr && parentView != currGridView)
            {
                RimIntersectionCollection* destCollection = currGridView->crossSectionCollection();

                RimIntersectionBox* copy = dynamic_cast<RimIntersectionBox*>(intersectionBox->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
                CVF_ASSERT(copy);

                destCollection->appendIntersectionBoxAndUpdate(copy);
            }
        }
    }
}