//----------------------------------------------------------------------------
void Mgc::FindIntersection (const Tetrahedron& rkT0, const Tetrahedron& rkT1,
    Mgc::TetrahedronConsumer& dest)
{
    // build planar faces of T0
    const int planePer=4;
    Plane akPlane[planePer];
    rkT0.GetPlanes(akPlane);
    
/* early-exit test for non-overlapping tets */
    if (1) {
        Plane ak1Plane[planePer];
        rkT1.GetPlanes(ak1Plane);
        if (allOutside(akPlane,planePer,rkT1) || allOutside(ak1Plane,planePer,rkT0))
            return; /* tets do not overlap */
    }
    
  /* Build filter to successively clip tets by each plane of T0,
      passing the final tets to the user's destination.
   */
    PlaneSplitTetrahedronConsumer cons0(akPlane[0],dest);
    PlaneSplitTetrahedronConsumer cons1(akPlane[1],cons0);
    PlaneSplitTetrahedronConsumer cons2(akPlane[2],cons1);
    PlaneSplitTetrahedronConsumer cons3(akPlane[3],cons2);
    
  /* Pass T1 through the filter chain */
    cons3.Add(rkT1);
}
//----------------------------------------------------------------------------
void Mgc::FindIntersection (const Tetrahedron& rkT0, const Tetrahedron& rkT1,
    vector<Tetrahedron>& rkIntr)
{
    // build planar faces of T0
    Plane akPlane[4];
    rkT0.GetPlanes(akPlane);

    // initial object to clip is T1
    rkIntr.clear();
    rkIntr.push_back(rkT1);

    // clip T1 against planes of T0
    for (int iP = 0; iP < 4; iP++)
    {
        vector<Tetrahedron> kInside;
        for (int iT = 0; iT < (int)rkIntr.size(); iT++)
            SplitAndDecompose(rkIntr[iT],akPlane[iP],kInside);
        rkIntr = kInside;
    }
}