// -*- C++ -*-
#ifndef RIPOLYGON_H
#define RIPOLYGON_H
/* Copyright 1996 
 * Mon Jun  2 17:28:37 1997  Brian Smits  (bes@phoenix.cs.utah.edu)
 * 
 * RiPolygon.H
 * 
 *	
 * 
 * $Id: RiPolygon.H,v 1.6 1998/10/30 22:11:32 bes Exp $ 
 * 
 */
#ifndef RICOMMON_H
#include <RiCommon.H>
#endif

#ifndef RIOBJECTBUILDER_H
#include <RiObjectBuilder.H>
#endif

#ifndef RIMATERIAL_H
#include <RiMaterial.H>
#endif

#include <rw/tvordvec.h>

/***************************************************************
CLASS
    RiPolygonBuilder
     Takes a series of points representing a polygon and Builds a set of
     objects.

DESCRIPTION
     This class handles all problems with input data, such as collinear points,
     Identical points, Non-coplanar polygons, etc and returns a set of objects
     that best represents it.  Non-coplanar polygons are chopped up arbitrarily.

****************************************************************/

class RiPolygonBuilder : public RiObjectBuilder {
  public:
    // GROUP: Constructors and assignment
    //// Default Constructor
    RiPolygonBuilder(Products wanted = noneFlag);
    //// Destructor
    virtual ~RiPolygonBuilder() {};
				// GROUP: Members
				//// Set the material to be used for all subsequent polygons until
				//   a new material is set
    void		SetMaterial(RiMaterial *);
    				//// Set a normal to be used FOR THIS POLYGON ONLY
				// stays valid until it is set again, and should be set before
				// the AddPoint associated with it
    void		SetNormal(const RiUnitVector3 &normal);
    				//// Set a uv to be used FOR THIS POLYGON ONLY
				// stays valid until it is set again, and should be set before
				// the AddPoint associated with it
    void		SetUV(const RiVector2 &uv);
				//// Add another point on the polygon.  Assumes they are
				// added in counter-clockwise order.
    void		AddPoint(const RiVector3 &point);
				//// Build the objects.
    virtual bool  	Build();
				//// Data adopted
    bool  	 BuildTriMesh(int numVertices, int numTris, RiVector3 *verts, RiUnitVector3 *norms,
			      RiVector2 *uvs, int *vertexIndices);
  private:
    ////Copy Constructor  NOT IMPLEMENTED
    RiPolygonBuilder(const RiPolygonBuilder &);
    //// Assignment  NOT IMPLEMENTED
    RiPolygonBuilder &operator=(const RiPolygonBuilder &);
				////
    RWTValOrderedVector<RiVector3>    	 pnt;
				////
    RWTValOrderedVector<RiUnitVector3>   norms;
				////
    RWTValOrderedVector<RiVector2>    	 uvs;
				////
    RiUnitVector3  normal;
				////
    RiVector2	   uv;
				////
    bool  	   normalFlag;
				////
    bool	   uvFlag;
				////
    RiMaterial  			*material;
};


#endif /* RIPOLYGON_H */

