Back to index

tetex-bin  3.0
Public Member Functions | Static Public Member Functions | Protected Attributes
Function Class Reference

#include <Function.h>

Inheritance diagram for Function:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Function ()
virtual ~Function ()
GBool init (Dict *dict)
virtual Functioncopy ()=0
int getInputSize ()
int getOutputSize ()
virtual void transform (double *in, double *out)=0
virtual GBool isOk ()=0

Static Public Member Functions

static Functionparse (Object *funcObj)

Protected Attributes

int m
int n
double domain [funcMaxInputs][2]
double range [funcMaxOutputs][2]
GBool hasRange

Detailed Description

Definition at line 33 of file Function.h.


Constructor & Destructor Documentation

Definition at line 30 of file Function.cc.

                   {
}
Function::~Function ( ) [virtual]

Definition at line 33 of file Function.cc.

                    {
}

Member Function Documentation

virtual Function* Function::copy ( ) [pure virtual]

Implemented in PostScriptFunction, StitchingFunction, ExponentialFunction, SampledFunction, and IdentityFunction.

Here is the caller graph for this function:

Definition at line 49 of file Function.h.

{ return m; }

Here is the caller graph for this function:

Definition at line 50 of file Function.h.

{ return n; }

Here is the caller graph for this function:

GBool Function::init ( Dict dict)

Definition at line 81 of file Function.cc.

                               {
  Object obj1, obj2;
  int i;

  //----- Domain
  if (!dict->lookup("Domain", &obj1)->isArray()) {
    error(-1, "Function is missing domain");
    goto err2;
  }
  m = obj1.arrayGetLength() / 2;
  if (m > funcMaxInputs) {
    error(-1, "Functions with more than %d inputs are unsupported",
         funcMaxInputs);
    goto err2;
  }
  for (i = 0; i < m; ++i) {
    obj1.arrayGet(2*i, &obj2);
    if (!obj2.isNum()) {
      error(-1, "Illegal value in function domain array");
      goto err1;
    }
    domain[i][0] = obj2.getNum();
    obj2.free();
    obj1.arrayGet(2*i+1, &obj2);
    if (!obj2.isNum()) {
      error(-1, "Illegal value in function domain array");
      goto err1;
    }
    domain[i][1] = obj2.getNum();
    obj2.free();
  }
  obj1.free();

  //----- Range
  hasRange = gFalse;
  n = 0;
  if (dict->lookup("Range", &obj1)->isArray()) {
    hasRange = gTrue;
    n = obj1.arrayGetLength() / 2;
    if (n > funcMaxOutputs) {
      error(-1, "Functions with more than %d outputs are unsupported",
           funcMaxOutputs);
      goto err2;
    }
    for (i = 0; i < n; ++i) {
      obj1.arrayGet(2*i, &obj2);
      if (!obj2.isNum()) {
       error(-1, "Illegal value in function range array");
       goto err1;
      }
      range[i][0] = obj2.getNum();
      obj2.free();
      obj1.arrayGet(2*i+1, &obj2);
      if (!obj2.isNum()) {
       error(-1, "Illegal value in function range array");
       goto err1;
      }
      range[i][1] = obj2.getNum();
      obj2.free();
    }
  }
  obj1.free();

  return gTrue;

 err1:
  obj2.free();
 err2:
  obj1.free();
  return gFalse;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual GBool Function::isOk ( ) [pure virtual]

Implemented in PostScriptFunction, StitchingFunction, ExponentialFunction, SampledFunction, and IdentityFunction.

Here is the caller graph for this function:

Function * Function::parse ( Object funcObj) [static]

Definition at line 36 of file Function.cc.

                                         {
  Function *func;
  Dict *dict;
  int funcType;
  Object obj1;

  if (funcObj->isStream()) {
    dict = funcObj->streamGetDict();
  } else if (funcObj->isDict()) {
    dict = funcObj->getDict();
  } else if (funcObj->isName("Identity")) {
    return new IdentityFunction();
  } else {
    error(-1, "Expected function dictionary or stream");
    return NULL;
  }

  if (!dict->lookup("FunctionType", &obj1)->isInt()) {
    error(-1, "Function type is missing or wrong type");
    obj1.free();
    return NULL;
  }
  funcType = obj1.getInt();
  obj1.free();

  if (funcType == 0) {
    func = new SampledFunction(funcObj, dict);
  } else if (funcType == 2) {
    func = new ExponentialFunction(funcObj, dict);
  } else if (funcType == 3) {
    func = new StitchingFunction(funcObj, dict);
  } else if (funcType == 4) {
    func = new PostScriptFunction(funcObj, dict);
  } else {
    error(-1, "Unimplemented function type (%d)", funcType);
    return NULL;
  }
  if (!func->isOk()) {
    delete func;
    return NULL;
  }

  return func;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void Function::transform ( double *  in,
double *  out 
) [pure virtual]

Implemented in PostScriptFunction, StitchingFunction, ExponentialFunction, SampledFunction, and IdentityFunction.

Here is the caller graph for this function:


Member Data Documentation

double Function::domain[funcMaxInputs][2] [protected]

Definition at line 61 of file Function.h.

Definition at line 64 of file Function.h.

int Function::m [protected]

Definition at line 59 of file Function.h.

int Function::n [protected]

Definition at line 59 of file Function.h.

double Function::range[funcMaxOutputs][2] [protected]

Definition at line 63 of file Function.h.


The documentation for this class was generated from the following files: