//-------------------------------------------------------------------
//-------------------------------------------------------------------
//
// Simple shape generation program  for TetElement 3D Prototype System
//  
// Primary Authors: 
//        Jessica K. Hodgins (jkh@cc.gatech.edu)
//        James F. O'Brien (obrienj@cc.gatech.edu)
// 
// (C) Copyright James F. O'Brien, 1998, 1999
// (C) Copyright Georgia Institute of Technology, 1998, 1999
//-------------------------------------------------------------------
//-------------------------------------------------------------------
//
// RCS Revision History
//
// $Log: netgenToState.C,v $
// Revision 1.1.1.1  2003/03/17 09:31:52  adamb
// Initial Revision
//
// Revision 1.1  2001/09/29 07:00:55  adamb
// Initial revision
//
// Revision 2.2  2001/03/21 21:53:27  job
// Established TetLib as separate from Fracture and SoundGen Projects.
//
// Revision 2.1  2000/01/06 20:38:15  obrienj
// Forced checkin with hacked explosions.
//
// Revision 2.0  1999/12/18 19:48:23  obrienj
// Forced check-in prior to working on explosions.
//
// Revision 1.4  1999/08/25 17:30:50  obrienj
// Check point (Post SG99)
//
// Revision 1.3  1999/05/20  19:37:32  obrienj
// Prior to code restructure -- forced checkin
//
// Revision 1.3  1999/05/20  19:37:32  obrienj
// Prior to code restructure -- forced checkin
//
// Revision 1.2  1999/04/23  18:17:35  obrienj
// Working version for SIGGRAPH paper
//
// Revision 1.1  1998/12/20  05:17:21  obrienj
// Initial revision
//
//-------------------------------------------------------------------
//-------------------------------------------------------------------

#include <cstdlib>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;

//----------------------------------------------

#include <bfastVector.H>
#include <vector>


//-------------------------------------------------------------------

inline static
istream &eatChar(char c,istream &buf) {
  char r;
  buf >> r;
  if (strncasecmp(&c,&r,1)) {
    buf.clear(buf.rdstate() | ios::failbit);
  }
  return buf;
}

inline static
istream &eatStr(const char *s,istream &buf) {
  while (*s != '\0') {
    eatChar(*s,buf);
    s++;
  }
  return buf;
}


//---------------------------------------------------------------------
//---------------------------------------------------------------------

class SimpleTet {
public:
  int indices[4];
  inline int &operator[](const unsigned int &i) { return indices[i];};
  inline int operator[](const unsigned int &i) const { return indices[i];};
};

int main(int argc, char *argv[]) {

  std::vector<BfastVector3> nodes;
  std::vector<SimpleTet> tets;

  unsigned int numN = 0;
  unsigned int numE = 0;
  int i = 0;

  char tmp[4000];
  ios::fmtflags orgFlags = cin.setf(ios::skipws); // ignore white space

  do {
    cin >> tmp;
  }
  while (strcasecmp (tmp , "volumeelements"));
  
  if (cin.fail()) {
    cerr << "didn't find volumeelements? \n";
    exit(-1);
  }
  
  cin >> numE;
  tets.resize(numE);

  int junk;
  for (i=0; i<numE; i++) {
    cin >> junk >> junk >> tets[i][1] >> tets[i][0] >> tets[i][2] >> tets[i][3];
    tets[i][0] -= 1;
    tets[i][1] -= 1;
    tets[i][2] -= 1;
    tets[i][3] -= 1;
  }

  if (cin.fail()) {
    cerr << "didn't find the right number of volumeelements? \n";
    exit(-1);
  }

  do {
    cin >> tmp;
  }
  while (strcasecmp (tmp , "points"));
  
  if (cin.fail()) {
    cerr << "didn't find points? \n";
    exit(-1);
  }

  cin >> numN;
  nodes.resize(numN);

  for (i=0; i<numN; i++) {
    cin >> nodes[i][0] >> nodes[i][1] >> nodes[i][2];
  }

  if (cin.fail()) {
    cerr << "didn't find the right number of points? \n";
    exit(-1);
  }
  
  for (unsigned int i=0; i<nodes.size(); i++) {
    cout<<"v "<<nodes[i][0]<<" "<<nodes[i][1]<<" "<<nodes[i][2]<<endl;
  }

  for (unsigned int i=0; i<tets.size(); i++) {
    cout<<"t "<<tets[i][0]<<" "<<tets[i][1]<<" "<<tets[i][2]<<" "<<tets[i][3]<<endl;
  }

  return 0;
}
	
      
