/*
0         1         2         3         4         5         6         7
01234567890123456789012345678901234567890123456789012345678901234567890123456789
--------------------------------------------------------------------------------
-- Description : Geometric object collision part
--------------------------------------------------------------------------------
-- Creation date : 22 aug 1996               Author : FPI
--------------------------------------------------------------------------------
*/
 
#include "acp_base.h"
#include "MTH.h"
#include "MEC.h"
#include "GMT.h"
#include "GEO.h"
#include "GLI.h"
 
#include "COL/CollGOUt.h"
 
/*
--------------------------------------------------------------------------------
-- Description : Get if there is an surfacic element in geometric object
--------------------------------------------------------------------------------
-- Creation date : 12 feb 1997               Author : FPI
--------------------------------------------------------------------------------
*/
 
/* test si il existe un element surfacique */
ACP_tdxBool COL_fn_bGetSurfaceInGeometricObject ( ACP_tdxHandleOfObject _hGeometricObject )
{
  ACP_tdxIndex xElementIndex;
 
  /* pour les elements */
  for ( xElementIndex = 0 ; xElementIndex < _hGeometricObject->xNbElements ; xElementIndex++ )
  {
    switch ( _hGeometricObject->d_xListOfElementsTypes[xElementIndex] )
    {
#ifdef USE_ALTIMAPS
      case GEO_C_xElementAltimap :
#endif /*USE_ALTIMAPS*/
      case GEO_C_xElementIndexedTriangles :
/*      case GEO_C_xElementFaceMapDescriptors :*/
      case GEO_C_xElementSpheres :
      case GEO_C_xElementAlignedBoxes :
                                        return TRUE;
    }
  }
 
  return FALSE;
}
 
/*
--------------------------------------------------------------------------------
-- Description : Get if the geometric object is composed of sphere and point only
--------------------------------------------------------------------------------
-- Creation date : 26 feb 1997               Author : FPI
--------------------------------------------------------------------------------
*/
 
/* test si il n y a que des spheres et des points */
/* pour corriger la desoptimisation des editeurs */
ACP_tdxBool COL_fn_bGetSphereAndPointOnlyInGeometricObject ( ACP_tdxHandleOfObject _hGeometricObject )
{
  ACP_tdxIndex xElementIndex;
  GEO_tdstElementIndexedTriangles *p_stElementIndexedTriangles;
/*  GEO_tdstElementFaceMapDescriptors *p_stElementFaceMapDescriptors;*/
  GEO_tdstElementAlignedBoxes *p_stElementAlignedBoxes;
 
  /* pour les elements */
  for ( xElementIndex = 0 ; xElementIndex < _hGeometricObject->xNbElements ; xElementIndex++ )
  {
    switch ( _hGeometricObject->d_xListOfElementsTypes[xElementIndex] )
    {
      case GEO_C_xElementIndexedTriangles :
        p_stElementIndexedTriangles = (GEO_tdstElementIndexedTriangles *)(_hGeometricObject->d_stListOfElements[xElementIndex]);
        if ( p_stElementIndexedTriangles->xNbFaces > 0 )
        {
          return FALSE;
        }
      break;
 
/*
      case GEO_C_xElementFaceMapDescriptors :
        p_stElementFaceMapDescriptors = (GEO_tdstElementFaceMapDescriptors *)(_hGeometricObject->d_stListOfElements[xElementIndex]);
        if ( p_stElementFaceMapDescriptors->xNbFaces > 0 )
        {
          return FALSE;
        }
      break;
*/
 
      case GEO_C_xElementAlignedBoxes :
        p_stElementAlignedBoxes = (GEO_tdstElementAlignedBoxes *)(_hGeometricObject->d_stListOfElements[xElementIndex]);
        if ( p_stElementAlignedBoxes->xNbAlignedBoxes > 0 )
        {
          return FALSE;
        }
      break;
 
      default :
      break;
    }
  }
 
  return TRUE;
}
