// PhBImageTextureBase.H: PhBImageTextureBase nodes.

// This file has been generated using nodegen 0.5a.
// Restrict manual editing to the sections delimited by
// . the comments "utility includes" and "end of utility includes"
// . the comments "utility members" and "end of utility members"

#ifndef _PhBImageTextureBase_H_
#define _PhBImageTextureBase_H_

#include "xrml.H"
#include "PhBTexture.H"

// utility includes
#include "vector.H"
#include "ReadImage.H"
// end of utility includes

namespace xrml {
#define PhBImageTextureBaseTypeId 	"PhBImageTextureBase"
extern bool IsPhBImageTextureBase(SFNode*);

class PhBImageTextureBase:  public PhBTexture {
public:
  //
  virtual int major_version(void), minor_version(void);
  virtual bool is_leaf_class(void);
  
  PhBImageTextureBase();
  
  //
  virtual void     	render(void);
  
  // state values:
  // Do not assign directly unless you know very well what you are doing.
  MFString         	url;
  SFBool           	clamping;
  SFBool           	repeating;
  
  // set_<exposedField> eventIns: with forwarding and eventOut generation
  virtual void     	set_clamping(const SFBool&);
  virtual void     	set_repeating(const SFBool&);
  
  // field assignement: no forwarding or eventOut generation!
  virtual bool     	assign_url(const MFString&);
  virtual bool     	assign_clamping(const SFBool&);
  virtual bool     	assign_repeating(const SFBool&);
  
  // update status
  virtual bool     	url_is_updated(void);
  virtual void     	url_clear_update(void);
  virtual bool     	clamping_is_updated(void);
  virtual void     	clamping_clear_update(void);
  virtual bool     	repeating_is_updated(void);
  virtual void     	repeating_clear_update(void);
  
  // utility members
  // image map
  float *blackpixel;
  Image image;

  virtual long width(void) { return(image.width); }
  virtual long height(void) { return(image.height); }
  virtual long nrChannels(void) { return(image.channels); }
  virtual float *values(double u, double v, int *nrChannels);
  virtual void Dvalues(double u, double v, float *dX, float *dY, float *dZ);
  
protected:
  virtual float *getpixel(long i, long j);

  inline void util_init(void)
  { 
    blackpixel = NULL;
    image.map = 0; 
    image.width = image.height = image.channels = 0;
  }

  inline void util_clone(const PhBImageTextureBase& src)
  { 
    blackpixel = NULL;
    image.map = 0; 
    image.width = image.height = image.channels = 0;
  }

  inline void util_destruct(void) { if(blackpixel) delete[] blackpixel; }
};

// end of utility members
} // namespace xrml
#endif /*_PhBImageTextureBase_H_*/
