/*===========================================================================
 *
 * File:	Dxffile.H
 * Author:	Dave Humphrey (uesp@m0use.net)
 * Created On:	Friday, June 22, 2001
 *
 * Defines the CDxfFile class for handling DXF AutoCad files.
 *
 *=========================================================================*/
#ifndef __DXFFILE_H
#define __DXFFILE_H


/*===========================================================================
 *
 * Begin Required Include Files
 *
 *=========================================================================*/
  #include "common/file/genfile.h"
/*===========================================================================
 *		End of Required Include Files
 *=========================================================================*/


/*===========================================================================
 *
 * Begin Class CDxfFile Definition
 *
 * Handles simple input/output of AutoCad DXF files.
 *
 *=========================================================================*/
class CDxfFile : public CGenFile {

  /*---------- Begin Private Class Members ----------------------*/
private:


  /*---------- Begin Protected Class Methods --------------------*/
protected:


  /*---------- Begin Public Class Methods -----------------------*/
public:

	/* Class Constructors/Destructors */
  //CDxffile();
  //virtual ~CDxffile() { Destroy(); }
  //virtual void Destroy (void);

	
  boolean StartEntities (void);
  boolean EndEntities	(void);
  boolean EndFile	(void);

	/* Polyline commands */
  boolean StartPolyline   (const int Flags);
  boolean StartPolyline   (void);
  boolean Start3DPolyline (void);
  boolean EndPolyline     (void);
  boolean WriteVertexL    (const float X, const float Y, const float Z, const int Flags, const int LayerNumber);
  boolean WriteVertex     (const float X, const float Y, const float Z, const int Flags);
  boolean WriteVertex     (const float X, const float Y, const float Z);
  boolean Write3DVertex   (const float X, const float Y, const float Z);
  boolean Write3DVertexL  (const float X, const float Y, const float Z, const int LayerNumber);

	/* Layer commands */
  boolean WriteLayer (const int LayerNumber);

 };
/*===========================================================================
 *		End of Class CDxfFile Definition
 *=========================================================================*/


/*===========================================================================
 *
 * Begin CDxffile Inline Methods
 *
 *=========================================================================*/

	/* Polyline commands */
inline boolean CDxfFile::StartPolyline   (const int Flags) { return Printf("  0\nPOLYLINE\n  6\nCONTINUOUS\n 66\n  1\n 70\n%d\n", Flags); }
inline boolean CDxfFile::Start3DPolyline (void)		   { return StartPolyline(8); }
inline boolean CDxfFile::StartPolyline   (void)		   { return Printf("  0\nPOLYLINE\n  6\nCONTINUOUS\n 66\n  1\n"); }
inline boolean CDxfFile::EndPolyline	 (void)		   { return Printf("  0\nSEQEND\n"); }

inline boolean CDxfFile::WriteVertex     (const float X, const float Y, const float Z, const int Flags) { 
  return Printf ("  0\nVERTEX\n 70\n%d\n 10\n%f\n 20\n%f\n 30\n%f\n", Flags, X, Y, Z);
 }

inline boolean CDxfFile::WriteVertexL    (const float X, const float Y, const float Z, const int Flags, const int LayerNumber) { 
  return Printf ("  0\nVERTEX\n 70\n%d\n  8\n%d\n 10\n%f\n 20\n%f\n 30\n%f\n", Flags, LayerNumber, X, Y, Z);
 }

inline boolean CDxfFile::WriteVertex     (const float X, const float Y, const float Z) {
  return Printf ("  0\nVERTEX\n 10\n%f\n 20\n%f\n 30\n%f\n", X, Y, Z);
 }

inline boolean CDxfFile::Write3DVertex   (const float X, const float Y, const float Z) {
  return WriteVertex(X, Y, Z, 32);
 }

inline boolean CDxfFile::Write3DVertexL  (const float X, const float Y, const float Z, const int LayerNumber) {
  return WriteVertexL(X, Y, Z, 32, LayerNumber);
 }

	/* Section commands */
inline boolean CDxfFile::StartEntities  (void) { return Printf("  0\nSECTION\n  2\nENTITIES\n"); } 
inline boolean CDxfFile::EndEntities    (void) { return Printf("  0\nENDSEC\n"); } 
inline boolean CDxfFile::EndFile	(void) { return Printf("  0\nEOF\n"); }

	/* Layer commands */
inline boolean CDxfFile::WriteLayer (const int LayerNumber) { return Printf("  8\n%d\n", LayerNumber); }

/*===========================================================================
 *		End of CDxffile Inline Methods
 *=========================================================================*/


#endif
/*===========================================================================
 *		End of File Dxffile.H
 *=========================================================================*/