Exemple #1
0
 value_type getAnimUpperBound( const Time &time ) const
 {
     return convertVoid( 
         ISingularProperty::animSampleUpperBound( time ) );
 }
Exemple #2
0
 value_type getAnimUpperBound( seconds_t secs ) const
 {
     return convertVoid( 
              ISingularProperty::animSampleUpperBound( secs ) );
 }
Exemple #3
0
 value_type get() const
 {
     return convertVoid( ISingularProperty::restSample() );
 }
Exemple #4
0
 value_type getAnim( size_t samp ) const
 {
     return convertVoid( ISingularProperty::animSample( samp ) );
 }
std::shared_ptr<GContainer> Transformation::transform(std::shared_ptr<GContainer>* inputs)
{
  auto target = this->factory.lock()->makeInstance(this->targetRepresentation);

  for (auto operation : this->operations)
  {
    switch (operation->type)
    {
      case (DEFAULT):
        target->set(operation->targetDimension, operation->value);
        break;
      case (USE):
      {
        auto value = inputs[operation->sourceIndex]->get(operation->sourceDimension);

        if (value == nullptr)
        {
          return nullptr;
        }
        else
        {
          target->set(operation->targetDimension, value);
        }
        break;
      }
      case (FORMULA):
      {
	int nvars = operation->varmap.size();

	if (nvars <= 0) {
	  /* no mapping set -> use single variable mode by adding it to map */
          operation->varmap.insert(std::make_pair(operation->varname, 
		std::make_pair(operation->sourceDimension, operation->sourceIndex)));
	  nvars++;
	}

        mu::Parser parser;
        parser.SetExpr(operation->formula);

	void *in_raw;
        double in[nvars];
	int i = 0;
	for(auto const &var: operation->varmap) {
	        in_raw = inputs[var.second.second]->get(var.second.first);
		in[i] = convertDouble(in_raw, operation->valueType);
		parser.DefineVar(var.first, &in[i]);
		i++;
	}

        const double out = parser.Eval();
        target->set(operation->targetDimension, 
		convertVoid(out, operation->valueType));
      }
        break;
      default:
        //TODO
        break;
    }
  }

  return target;
}