//-----------------------------------------------------------------------------
// Purpose: This functions sets up the list of objects to be clipped.  
//          Initially the list is passed in (typically a Selection set).  On 
//          subsequent "translation" updates the list is refreshed from the 
//          m_pOrigObjects list.
//   Input: pList - the list of objects (solids) to be clipped
//-----------------------------------------------------------------------------
void Clipper3D::SetClipObjects( CMapObjectList *pList )
{
    // check for an empty list
    if( !pList )
        return;

    // save the original list
    m_pOrigObjects = pList;

    // clear the clip results list
    ResetClipResults();

    //
    // copy solids into the clip list
    //
    POSITION pos = m_pOrigObjects->GetHeadPosition();
    while( pos )
    {
        CMapClass *pObject = m_pOrigObjects->GetNext( pos );
        if( !pObject )
            continue;

        if( pObject->IsMapClass( MAPCLASS_TYPE( CMapSolid ) ) )
        {
            AddToClipList( ( CMapSolid* )pObject, this );
        }

        pObject->EnumChildren( ENUMMAPCHILDRENPROC( AddToClipList ), DWORD( this ), MAPCLASS_TYPE( CMapSolid ) );
    }

    // the clipping list is not empty anymore
    m_bEmpty = FALSE;
}
//-----------------------------------------------------------------------------
// Purpose: Calls an enumerating function for each of our children that are of
//			of a given type, recursively enumerating their children also.
// Input  : pfn - Enumeration callback function. Called once per child.
//			dwParam - User data to pass into the enumerating callback.
//			Type - Unless NULL, only objects of the given type will be enumerated.
// Output : Returns FALSE if the enumeration was terminated early, TRUE if it completed.
//-----------------------------------------------------------------------------
BOOL CMapClass::EnumChildren(ENUMMAPCHILDRENPROC pfn, DWORD dwParam, MAPCLASSTYPE Type)
{
	POSITION p = Children.GetHeadPosition();
	while (p)
	{
		CMapClass *pChild = Children.GetNext(p);
		if (!Type || pChild->IsMapClass(Type))
		{
			if(!(*pfn)(pChild, dwParam))
			{
				return FALSE;
			}
		}

		// enum this child's children
		if (!pChild->EnumChildren(pfn, dwParam, Type))
		{
			return FALSE;
		}
	}

	return TRUE;
}