///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995-1996 Virtual Design All Rights Reserved.
//
// Permission to use,  copy,  modify,  and  distribute  this  software and its
// documentation for NON-COMMERCIAL purposes and without fee is hereby granted.
//
// VIRTUAL DESIGN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
// OF THE SOFTWARE, EITHER EXPRESS  OR  IMPLIED,  INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
// OR NON-INFRINGEMENT. VIRTUAL DESIGN SHALL  NOT  BE LIABLE FOR ANY DAMAGES
// SUFFERED BY  LICENSEE AS A RESULT OF USING,  MODIFYING OR DISTRIBUTING THIS
// SOFTWARE OR ITS DERIVATIVES.
//
// THIS SOFTWARE  IS   NOT  DESIGNED  OR  INTENDED FOR USE OR RESALE AS ONLINE
// OR NOT ONLINE CONTROL  EQUIPMENT IN HAZARDOUS  ENVIRONMENTS REQUIRING  FAIL-
// SAFE PERFORMANCE,  SUCH  AS  IN   THE   OPERATION   OF  NUCLEAR  FACILITIES,
// AIRCRAFT   NAVIGATION  OR  COMMUNICATION  SYSTEMS,  AIR   TRAFFIC   CONTROL,
// DIRECT LIFE  SUPPORT  MACHINES, OR WEAPONS SYSTEMS, IN  WHICH  THE  FAILURE
// OF  THE SOFTWARE COULD  LEAD DIRECTLY  TO DEATH, PERSONAL INJURY, OR SEVERE
// PHYSICAL OR ENVIRONMENTAL  DAMAGE ("HIGH RISK ACTIVITIES").  VIRTUAL DESIGN
// SPECIFICALLY DISCLAIMS  ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH
// RISK ACTIVITIES.
///////////////////////////////////////////////////////////////////////////////

/** Classe de test d'un cube d'arête p_size centrée à l'origine.
 *  pour le test le cube n'est qu'en définition filaire.
 *  La classe cube n'est qu'une classe qui initialise le maillage.
 *  @author Guillaume Pelletier.
 *  @version 1.0
 */



class Cube extends Objet3D
 {

 public Cube( float p_size )
  {
  Sommet3DH [] l_sommetsCube= {new Sommet3DH( 1.0f, -1.0f, -1.0f, 1.0f ),
                               new Sommet3DH( 1.0f, -1.0f,  0.0f, 1.0f ),
                               new Sommet3DH( 1.0f, -1.0f,  1.0f, 1.0f ),
                               new Sommet3DH( 1.0f,  1.0f, -1.0f, 1.0f ),
                               new Sommet3DH( 1.0f,  1.0f,  0.0f, 1.0f ),
                               new Sommet3DH( 1.0f,  1.0f,  1.0f, 1.0f ),
                               new Sommet3DH(-1.0f,  1.0f, -1.0f, 1.0f ),
                               new Sommet3DH(-1.0f,  1.0f,  0.0f, 1.0f ),
                               new Sommet3DH(-1.0f,  1.0f,  1.0f, 1.0f ),
                               new Sommet3DH(-1.0f, -1.0f, -1.0f, 1.0f ),
                               new Sommet3DH(-1.0f, -1.0f,  0.0f, 1.0f ),
                               new Sommet3DH(-1.0f, -1.0f,  1.0f, 1.0f ),
                               new Sommet3DH( 0.0f,  0.0f, -1.0f, 1.0f ),
                               new Sommet3DH( 0.0f,  0.0f,  1.0f, 1.0f )};

  ArcD [] l_arcsCube= { new ArcD(13,1) ,new ArcD(1,2)  ,
                        new ArcD(2,3)  ,new ArcD(3,14) ,
                        new ArcD(1,4)  ,new ArcD(2,5)  ,
                        new ArcD(3,6)  ,new ArcD(13,4) ,
                        new ArcD(4,5)  ,new ArcD(5,6)  ,
                        new ArcD(6,14) ,new ArcD(4,7)  ,
                        new ArcD(5,8)  ,new ArcD(6,9)  ,
                        new ArcD(13,7) ,new ArcD(7,8)  ,
                        new ArcD(8,9)  ,new ArcD(9,14) ,
                        new ArcD(7,10) ,new ArcD(8,11) ,
                        new ArcD(9,12) ,new ArcD(13,10),
                        new ArcD(10,11),new ArcD(11,12),
                        new ArcD(12,14),new ArcD(10,1) ,
                        new ArcD(11,2 ),new ArcD(12,3) };


  int l_cardsommets = 14 ,
      l_cardarcs    = 28 ,
      l_cardfaces   = 0  ;

  try
   {
   m_data.init(l_cardsommets, l_cardarcs, l_cardfaces);
   }
  catch ( OutOfMemoryError l_e )
   {
   System.out.println("Erreur d'allocation de la maille.");
   return ;
   }

 // copie des données des sommets.
 for ( int l_i = 0 ; l_i < l_cardsommets ; l_i ++ )
   {
   m_data.m_sommets[l_i] = new Sommet3DH( l_sommetsCube[l_i].m_x * p_size,
                                          l_sommetsCube[l_i].m_y * p_size,
                                          l_sommetsCube[l_i].m_z * p_size,
                                          l_sommetsCube[l_i].m_w ) ;

   }

 // copie des données des arcs.
 for ( int l_i = 0 ; l_i < l_cardarcs ; l_i ++ )
   {
   m_data.m_arcs[l_i]= new ArcD( l_arcsCube[l_i].m_sini,
                                 l_arcsCube[l_i].m_sfin ) ;
   }

  }

 }

