Пример #1
0
void BCIDataSet::buildInstance(int epoch, int t0)
{
  if(cache.hasInstance(epoch, t0))
  {
    tempInstance = cache.getInstance(epoch, t0);
  }
  else
  {
    Eigen::MatrixXd original = extractInstance(epoch, t0);
    if(decimated)
    {
      Decimator decimator(downSamplingFactor);
      Eigen::MatrixXd decimatedSignal = decimator.decimate(original);
      if(comp)
      {
        Eigen::VectorXd uncompressed = toVector(decimatedSignal);
        tempInstance = compressor.compress(uncompressed);
      }
      else
        tempInstance = toVector(decimatedSignal);
    }
    else
    {
      if(comp)
      {
        Eigen::VectorXd uncompressed = toVector(original);
        tempInstance = compressor.compress(uncompressed);
      }
      else
        tempInstance = toVector(original);
    }
    if(cache.hasSpace())
      cache.cacheInstance(epoch, t0, tempInstance);
  }
}
////////////////////////////////////////////////////////////////////////////////
// Update the controller
void GazeboQuadrotorAerodynamics::Update()
{
  // Get simulator time
  Time current_time = world->GetSimTime();
  Time dt = current_time - last_time_;
  last_time_ = current_time;
  if (dt <= 0.0) return;

  // Get new commands/state
  callback_queue_.callAvailable();

  // fill input vector u for drag model
  geometry_msgs::Quaternion orientation;
  fromQuaternion(link->GetWorldPose().rot, orientation);
  model_.setOrientation(orientation);

  geometry_msgs::Twist twist;
  fromVector(link->GetWorldLinearVel(), twist.linear);
  fromVector(link->GetWorldAngularVel(), twist.angular);
  model_.setTwist(twist);

  // update the model
  model_.update(dt.Double());

  // get wrench from model
  Vector3 force, torque;
  toVector(model_.getWrench().force, force);
  toVector(model_.getWrench().torque, torque);

  // set force and torque in gazebo
  link->AddRelativeForce(force);
  link->AddRelativeTorque(torque - link->GetInertial()->GetCoG().Cross(force));
}
Пример #3
0
static void
cmd_curve(svg_state_t *state, const float *c, const float *d, const float *e)
{
  FT_Vector C,D,E;
  toVector(&C, c);
  toVector(&D, d);
  toVector(&E, e);

  if(state->inpath)
    FT_Stroker_CubicTo(state->stroker, &C, &D, &E);
}
Пример #4
0
/**
 * Invokes the constructor with the given JArguments.
 * Allocates a new local reference.
 *
 * @throws JNIException if an error occurs while trying to invoke the constructor.
 * @throws a matching C++ proxy, if a java exception is thrown by the constructor.
 *
 */
jobject JConstructor::invoke( const JArguments& arguments ) {


  /* Get the methodID for the constructor matching the given arguments.
   */
//  cout << "JConstructor::invoke - Retrieving the methodID..." << endl;
  jmethodID methodID = getMethodID( mClass, arguments );
//  cout << "JConstructor::invoke - Retrieved the methodID." << endl;

  /* Call the constructor
   */
//  cout << "JConstructor::invoke - Attaching..." << endl;
  JNIEnv* env = helper::attach();
//  cout << "JConstructor::invoke - Attached." << endl;
 
//  cout << "JConstructor::invoke - Creating the object..." << endl;
  jobject result;
	vector<jvalue> argArray = toVector( arguments );

	if (argArray.size() > 0)
		result = env->NewObjectA( mClass->getClass(), methodID, &argArray[ 0 ] );
	else
		result = env->NewObject( mClass->getClass(), methodID );
//  cout << "JConstructor::invoke - Created the object..." << endl;

  /* Catch any java exception that occured during the method call,
   * and throw it as a C++ exception.
   */
//  cout << "JConstructor::invoke - Checking for exceptions..." << endl;
  helper::catchAndThrow();
//  cout << "JConstructor::invoke - Found no exceptions." << endl;

  return result;
}
static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContextBase& context)
{
    if (exec->argumentCount() != 2)
        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
    
    WebGLUniformLocation* location = JSWebGLUniformLocation::toWrapped(exec->uncheckedArgument(0));
    if (!location && !exec->uncheckedArgument(0).isUndefinedOrNull())
        return throwTypeError(exec);
    
    RefPtr<Int32Array> webGLArray = toInt32Array(exec->uncheckedArgument(1));
    
    ExceptionCode ec = 0;
    if (webGLArray) {
        switch (f) {
        case f_uniform1v:
            context.uniform1iv(location, webGLArray.get(), ec);
            break;
        case f_uniform2v:
            context.uniform2iv(location, webGLArray.get(), ec);
            break;
        case f_uniform3v:
            context.uniform3iv(location, webGLArray.get(), ec);
            break;
        case f_uniform4v:
            context.uniform4iv(location, webGLArray.get(), ec);
            break;
        default:
            break;
        }
        
        setDOMException(exec, ec);
        return jsUndefined();
    }
    
    
    Vector<int, 64> array;
    if (!toVector(exec, exec->uncheckedArgument(1), array))
        return throwTypeError(exec);
    
    switch (f) {
    case f_uniform1v:
        context.uniform1iv(location, array.data(), array.size(), ec);
        break;
    case f_uniform2v:
        context.uniform2iv(location, array.data(), array.size(), ec);
        break;
    case f_uniform3v:
        context.uniform3iv(location, array.data(), array.size(), ec);
        break;
    case f_uniform4v:
        context.uniform4iv(location, array.data(), array.size(), ec);
        break;
    default:
        break;
    }
    
    setDOMException(exec, ec);
    return jsUndefined();
}
bool doubleTouchThread::testAchievement2(skinContactList *_sCL)
{
    // Search for a suitable contact:
    for(skinContactList::iterator it=_sCL->begin(); it!=_sCL->end(); it++)
    {
        if(cntctSkinPart == it -> getSkinPart())
        {
            iencsS->getEncoders(encsS->data());
            Vector qS=encsS->subVector(0,12);
            armS->setAng(qS*iCub::ctrl::CTRL_DEG2RAD);

            iencsM->getEncoders(encsM->data());
            Vector qM=encsM->subVector(0,12);
            armM->setAng(qM*iCub::ctrl::CTRL_DEG2RAD);

            Matrix cntctH0_final = findH0(*it);

            /**
            * WRITE ON FILE: ITERATOR, ABSOLUTE TIME, YARP TIMESTAMP
            * ROBOT, COLOR, TASKTYPE, ENCODERS SLAVE, ENCODERS MASTER, 
            * TARGET TAXEL REFERENCE FRAME, FINAL TAXEL REFERENCE FRAME,
            * INDEX HN
            */
            printMessage(0,"SUCCESS!!!! Self Touch Accomplished! Iterator: %i\n",iter);
            printMessage(1,"Encoders Slave:  %s\n", qS.toString(3,3).c_str());
            printMessage(1,"Encoders Master: %s\n", qM.toString(3,3).c_str());
            printMessage(0,"Target Position: %s\n", cntctH0.subcol(0,3,3).toString(3,3).c_str());
            printMessage(0,"Final  Position: %s\n", cntctH0_final.subcol(0,3,3).toString(3,3).c_str());

            ofstream outputfile;
            outputfile.open (filename.c_str(),ios::app);
            outputfile  << iter << "\t" << fixed << Time::now() << "\t"
                        << robot  << "\t" << color << "\t" << curTaskType << "\t"
                        << qS.toString(3,3) << "\t" << qM.toString(3,3) << "\t"
                        << toVector(cntctH0).toString(3,3) << "\t"
                        << toVector(cntctH0_final).toString(3,3);
            outputfile  << "\t" << toVector(slv->probl->limb.getHN()).toString(3,3);
            outputfile  << endl;
            outputfile.close();
            iter++;

            return true;
        }
    }
    return false;
}
Пример #7
0
std::string Components::Position::toString() const
{
    std::ostringstream ss;
    ss << "Components::Position[debugName = \"" << getDebugName() << "\", "
       << "parent = " << getParent() << "\", "
       << "position = " << toVector() << "]";
    return ss.str();
}
Пример #8
0
MARG::MARG(const MARGConfiguration& configuration,
	     const Readout::MARG& readout,
		 const Temperature& temperature_difference,
		 const Calibration& calibration)
{
#ifdef USE_TEMPERATURE_COMPENSATION
	const int16_t temperature_offset[2] = {
		(int16_t)((temperature_difference.degreesCelsius() * LSM9DS0_OFFSET_PER_CELSIUS_G) / configuration.gScaleMdps()),
		(int16_t)((temperature_difference.degreesCelsius() * LSM9DS0_OFFSET_PER_CELSIUS_A) / configuration.aScaleMg())
	};
	const float temperature_scale[2] = {
		(float)temperature_difference.degreesCelsius() * sensitivity_per_celsius_g,
		(float)temperature_difference.degreesCelsius() * sensitivity_per_celsius_a
	};
#else
	const int16_t temperature_offset[2] = { 0, 0 };
	const float temperature_scale[2] = { 1, 1 };
#endif

	const Vector<int16_t> raw_offset_adjusted[2] = {
		readout.g - calibration.g_offset - temperature_offset[0],
		readout.a - calibration.a_offset - temperature_offset[1]
	};
	const Vector<float> scale_adjusted[2] = {
		calibration.g_scale * (1 + temperature_scale[0]),
		calibration.a_scale * (1 + temperature_scale[1])
	};

	g_ = toVector(raw_offset_adjusted[0] * scale_adjusted[0], configuration.gScaleMdps() / 1000 * M_PI / 180);
	a_ = toVector(raw_offset_adjusted[1] * scale_adjusted[1], configuration.aScaleMg() / 1000);
	m_ = toVector(readout.m * calibration.m_rotation - calibration.m_offset, configuration.mScaleMgauss() / 1000);
	
	if (calibration.hasInvertedPlacement()) {
		a_.setX(-a_.x());
		a_.setY(-a_.y());
	}
	if (!calibration.hasInvertedPlacement()) {
		g_.setX(-g_.x());
		g_.setY(-g_.y());
	}

	g_.setX(-g_.x());
	g_.setY(-g_.y());
	g_.setZ(-g_.z());
}
static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecState* exec, WebGLRenderingContext* context)
{
    if (exec->argumentCount() != 3)
        return throwSyntaxError(exec);

    if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(&JSWebGLUniformLocation::s_info))
        return throwTypeError(exec);
    WebGLUniformLocation* location = toWebGLUniformLocation(exec->argument(0));

    if (exec->hadException())    
        return jsUndefined();
        
    bool transpose = exec->argument(1).toBoolean(exec);
    if (exec->hadException())    
        return jsUndefined();
        
    RefPtr<Float32Array> webGLArray = toFloat32Array(exec->argument(2));
    if (exec->hadException())    
        return jsUndefined();
        
    ExceptionCode ec = 0;
    if (webGLArray) {
        switch (f) {
        case f_uniformMatrix2fv:
            context->uniformMatrix2fv(location, transpose, webGLArray.get(), ec);
            break;
        case f_uniformMatrix3fv:
            context->uniformMatrix3fv(location, transpose, webGLArray.get(), ec);
            break;
        case f_uniformMatrix4fv:
            context->uniformMatrix4fv(location, transpose, webGLArray.get(), ec);
            break;
        }
        
        setDOMException(exec, ec);
        return jsUndefined();
    }

    Vector<float, 64> array;
    if (!toVector(exec, exec->argument(2), array))
        return throwTypeError(exec);

    switch (f) {
    case f_uniformMatrix2fv:
        context->uniformMatrix2fv(location, transpose, array.data(), array.size(), ec);
        break;
    case f_uniformMatrix3fv:
        context->uniformMatrix3fv(location, transpose, array.data(), array.size(), ec);
        break;
    case f_uniformMatrix4fv:
        context->uniformMatrix4fv(location, transpose, array.data(), array.size(), ec);
        break;
    }

    setDOMException(exec, ec);
    return jsUndefined();
}
Пример #10
0
	PointerType::operator TypePtr() const {
		NodeManager& mgr = elementType.getNodeManager();
		IRBuilder builder(mgr);

		auto& ext = mgr.getLangBasic();

		// build a tuple representing this pointer
		return builder.tupleType(toVector(ReferenceType::create(ArrayType::create(elementType), mConst, mVolatile).as<TypePtr>(), ext.getInt8().as<TypePtr>()));
	}
Пример #11
0
	TypePtr StaticVariableExtension::wrapStaticType(const TypePtr& type) const {
		IRBuilder builder(type.getNodeManager());
		return builder.structType(
				builder.stringValue("__static_var"),
				builder.parents(),
				toVector(
						builder.namedType("initialized", builder.getLangBasic().getBool()),
						builder.namedType("value", type)
				)
		);
	}
Пример #12
0
static void
cmd_lineto(svg_state_t *state)
{
  float pt[2];
  svg_mtx_vec_mul(pt, state->ctm, state->cur);

  FT_Vector v;
  toVector(&v, pt);
  if(state->inpath)
    FT_Stroker_LineTo(state->stroker, &v);
}
Пример #13
0
AxisHelper::AxisHelper( float sizeIn )
    : Line( nullptr, nullptr, THREE::LinePieces ), size( sizeIn ) {

    geometry = Geometry::create();

    geometry->vertices = toVector(
                             Vector3(), Vector3( size, 0, 0 ),
                             Vector3(), Vector3( 0, size, 0 ),
                             Vector3(), Vector3( 0, 0, size )
                         );

    geometry->colors = toVector(
                           Color( 0xff0000 ), Color( 0xffaa00 ),
                           Color( 0x00ff00 ), Color( 0xaaff00 ),
                           Color( 0x0000ff ), Color( 0x00aaff )
                       );

    material = LineBasicMaterial::create(
                   Material::Parameters().add( "vertexColors", THREE::VertexColors )
               );
}
static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecState* exec, WebGLRenderingContextBase& context)
{
    if (exec->argumentCount() != 3)
        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
    
    WebGLUniformLocation* location = JSWebGLUniformLocation::toWrapped(exec->uncheckedArgument(0));
    if (!location && !exec->uncheckedArgument(0).isUndefinedOrNull())
        return throwTypeError(exec);
    
    bool transpose = exec->uncheckedArgument(1).toBoolean(exec);
    if (exec->hadException())    
        return jsUndefined();
    
    RefPtr<Float32Array> webGLArray = toFloat32Array(exec->uncheckedArgument(2));
    
    ExceptionCode ec = 0;
    if (webGLArray) {
        switch (f) {
        case f_uniformMatrix2fv:
            context.uniformMatrix2fv(location, transpose, webGLArray.get(), ec);
            break;
        case f_uniformMatrix3fv:
            context.uniformMatrix3fv(location, transpose, webGLArray.get(), ec);
            break;
        case f_uniformMatrix4fv:
            context.uniformMatrix4fv(location, transpose, webGLArray.get(), ec);
            break;
        }
        
        setDOMException(exec, ec);
        return jsUndefined();
    }
    
    Vector<float, 64> array;
    if (!toVector(exec, exec->uncheckedArgument(2), array))
        return throwTypeError(exec);
    
    switch (f) {
    case f_uniformMatrix2fv:
        context.uniformMatrix2fv(location, transpose, array.data(), array.size(), ec);
        break;
    case f_uniformMatrix3fv:
        context.uniformMatrix3fv(location, transpose, array.data(), array.size(), ec);
        break;
    case f_uniformMatrix4fv:
        context.uniformMatrix4fv(location, transpose, array.data(), array.size(), ec);
        break;
    }
    
    setDOMException(exec, ec);
    return jsUndefined();
}
Пример #15
0
void GameScreen::selectTarget(sf::Vector2i s)
{
	m_selectedTarget = s;
	m_targettingSprite.moveOnSquare(s);

	std::vector<Square> possibleMoves = m_game.getPossibleDisplacements(toSquare(m_selectedPiece), toSquare(s));
	std::vector<sf::Vector2i> possibleMoves2;
	for(unsigned int i = 0; i < possibleMoves.size(); ++i)
	{
		possibleMoves2.push_back(toVector(possibleMoves[i]));
	}
	m_highlighter.setHighlights(possibleMoves2);
}
Пример #16
0
void initCube(Cube* c){
    float r = randFloat();
    if(r < 0.7){
        c->x = randFloat() * 400.0f - 200.0f;
        c->y = 250.0f;
    }else if(r < 0.8){
        c->x = 250.0f;
        c->y = randFloat() * 400.0f - 200.0f;
    }else if(r < 0.9){
        c->x = -250.0f;
        c->y = randFloat() * 400.0f - 200.0f;
    }else{
        c->x = randFloat() * 400.0f - 200.0f;
        c->y = -250.0f;
    }

    c->z  = 0.0f;

    GLfloat v  = randFloat() * 1.0f + 1.0f;

    if(randFloat() < 0.5){
        GLfloat th = randFloat() * 3.14 * 2;
        c->vx = v * cos(th);
        c->vy = v * sin(th);
        c->color.r = 1.0f;
        c->color.g = 1.0f;
        c->color.b = 0.0f;
    }else{
/*         GLfloat dx  = player.x - c->x; */
/*         GLfloat dy  = player.y - c->y; */
/*         GLfloat len = sqrt(dx * dx + dy * dy); */
/*         c->vx = dx / len * v; */
/*         c->vy = dy / len * v; */
        toVector(player.x, player.y, c->x, c->y, &(c->vx), &(c->vy));
        c->vx *= v;
        c->vy *= v;
        c->color.r = 0.0f;
        c->color.g = 1.0f;
        c->color.b = 0.0f;
    }

/*     if(randFloat() < 0.5){ */
/*         c->vy = randFloat() * 1.0f + 1.0f; */
/*     }else{ */
/*         c->vy = randFloat() * 1.0f - 2.0f; */
/*     } */
    c->vz = 0.0f;
    c->size = (randFloat() * 3.0f) * (randFloat() * 3.0f) + 4.0f;
    c->cnt = 0;
/*     printf("%f\n", randFloat()); */
}
Пример #17
0
void movePlayer(void* ptr){
    Player *p = ptr;

    p->cnt++;

    GLfloat vx, vy;
    toVector(p->distX, p->distY, p->x, p->y, &vx, &vy);
    p->x += vx * p->v;
    p->y += vy * p->v;
    // p->x = p->v * cos((float)p->cnt * 3.14f / 1001.0f) * 100;
    // p->y = p->v * sin((float)p->cnt * 3.14f / 1001.0f) * 100;
    // p->z = sin(3.14f / 11.0f * p->cnt) * 100;
    p->z = 0.0f;
}
Пример #18
0
std::vector<cv::Rect> MxArray::toVector() const
{
    if (isNumeric()) {
        std::vector<cv::Rect> vr;
        if (numel() == 4)
            vr.push_back(toRect());
        else
            toMat(CV_32S).reshape(4, 0).copyTo(vr);
        return vr;
    }
    else {
        return toVector(
            std::const_mem_fun_ref_t<cv::Rect, MxArray>(&MxArray::toRect));
    }
}
Пример #19
0
static void
cmd_move(svg_state_t *state)
{
  float pt[2];
  FT_Vector v;
  svg_mtx_vec_mul(pt, state->ctm, state->cur);
  toVector(&v, pt);

  if(state->inpath) {
    FT_Stroker_LineTo(state->stroker, &v);
  } else {
    FT_Stroker_BeginSubPath(state->stroker, &v, 0);
    state->inpath = 1;
  }
}
Пример #20
0
std::vector<cv::Vec4f> MxArray::toVector() const
{
    if (isNumeric()) {
        std::vector<cv::Vec4f> vv;
        if (numel() == 4)
            vv.push_back(toVec<float,4>());
        else
            toMat(CV_32F).reshape(4, 0).copyTo(vv);
        return vv;
    }
    else {
        return toVector(
            std::const_mem_fun_ref_t<cv::Vec4f, MxArray>(
                &MxArray::toVec<float,4>));
    }
}
Пример #21
0
std::vector<cv::Point2f> MxArray::toVector() const
{
    if (isNumeric()) {
        std::vector<cv::Point2f> vp;
        if (numel() == 2)
            vp.push_back(toPoint2f());
        else
            toMat(CV_32F).reshape(2, 0).copyTo(vp);
        return vp;
    }
    else {
        return toVector(
            std::const_mem_fun_ref_t<cv::Point2f, MxArray>(
                &MxArray::toPoint_<float>));
    }
}
Пример #22
0
std::vector<cv::Point3d> MxArray::toVector() const
{
    if (isNumeric()) {
        std::vector<cv::Point3d> vp;
        if (numel() == 3)
            vp.push_back(toPoint3_<double>());
        else
            toMat(CV_64F).reshape(3, 0).copyTo(vp);
        return vp;
    }
    else {
        return toVector(
            std::const_mem_fun_ref_t<cv::Point3d, MxArray>(
                &MxArray::toPoint3_<double>));
    }
}
Пример #23
0
std::vector<cv::Vec3i> MxArray::toVector() const
{
    if (isNumeric()) {
        std::vector<cv::Vec3i> vv;
        if (numel() == 3)
            vv.push_back(toVec<int,3>());
        else
            toMat(CV_32S).reshape(3, 0).copyTo(vv);
        return vv;
    }
    else {
        return toVector(
            std::const_mem_fun_ref_t<cv::Vec3i, MxArray>(
                &MxArray::toVec<int,3>));
    }
}
Пример #24
0
boost::optional<utils::net::NetworkPath> buildRemote(const utils::VirtualPrintable& source, const Host& targetHost, const utils::compiler::Compiler& compiler) {
	// create a temporary local source file
	char sourceFile[] = P_tmpdir "/srcXXXXXX";
	int src = mkstemp(sourceFile);
	assert_ne(src, -1);
	close(src);

	// write source to file
	std::fstream srcFile(sourceFile, std::fstream::out);
	srcFile << source << "\n";
	srcFile.close();

	// build remotely
	auto res = buildRemote(toVector(nfs::NetworkPath(sourceFile)), "binary", targetHost, compiler);

	// delete source file
	if(boost::filesystem::exists(sourceFile)) { boost::filesystem::remove(sourceFile); }
	return res;
}
Пример #25
0
	ArrayType::operator GenericTypePtr() const {
		NodeManager& nm = elementType.getNodeManager();
		IRBuilder builder(nm);

		TypePtr num;
		if (!size) {
			num = GenericType::get(nm, "inf");
		} else if(auto lit = size.isa<LiteralPtr>()) {
			assert_pred1(builder.getLangBasic().isUIntInf, lit->getType());
			num = NumericType::get(nm, lit);
		} else if (auto var = size.isa<VariablePtr>()) {
			assert_pred1(builder.getLangBasic().isUIntInf, var->getType());
			num = NumericType::get(nm, var);
		} else {
			num = size.as<TypeVariablePtr>();
		}

		return GenericType::get(nm, "array", ParentList(), toVector(elementType, num));
	}
Пример #26
0
	insieme::core::TypePtr autoReturnType(NodeManager& nodeMan, const CompoundStmtPtr& body) {
		auto debug = false;
		if(debug) { std::cout << "{{{{{{ autoReturnType ----\n"; }

		// find all returns
		TypePtr newReturnType = nodeMan.getLangBasic().getUnit();
		auto returns = analysis::getFreeNodes(body, NT_ReturnStmt, toVector(NT_LambdaExpr, NT_JobExpr, NT_ReturnStmt));
		if(debug) { std::cout << "{{{{{{{{{{{{{ Returns: " << returns << "\n"; }

		// if no returns, unit is fine
		if(!returns.empty()) {
			auto typeList = ::transform(returns, [](const NodePtr& ret) { return ret.as<ReturnStmtPtr>()->getReturnExpr()->getType(); });
			if(debug) { std::cout << "{{{{{{{{{{{{{ typeList: " << typeList << "\n"; }

			newReturnType = types::getSmallestCommonSuperType(typeList);
			if(debug) { std::cout << "{{{{{{{{{{{{{ returnType: " << newReturnType << "\n"; }

			assert_true(newReturnType) << "Return type deduction, multiple return types have no common supertype.";
		}

		return newReturnType;
	}
Пример #27
0
bytevector BaseNode::serialize() const {
    //Prepare the result.
    bytevector result;

    //Insert the correct type
    if(getType() == BaseNode::NODE) {
        result.push_back(0);
    } else {
        result.push_back(1);
    }

    //Insert the 4 bytes indicating the length.
    IntLeaf length(getLength(), 4);
    bytevector lengthData = length.toVector();
    result.insert(result.end(), lengthData.begin(), lengthData.end());

    //Insert the actual data.
    bytevector data = toVector();
    result.insert(result.end(), data.begin(), data.end());

    //Return the result.
    return result;
}
Пример #28
0
std::vector<cv::Point3f> MxArray::toVector() const
{
    return toVector(
        std::const_mem_fun_ref_t<cv::Point3f, MxArray>(&MxArray::toPoint3f));
}
static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContextBase& context)
{
    if (exec->argumentCount() != 2)
        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
    
    WebGLUniformLocation* location = 0;
    long index = -1;
    
    if (functionForUniform(f)) {
        location = JSWebGLUniformLocation::toWrapped(exec->uncheckedArgument(0));
        if (!location && !exec->uncheckedArgument(0).isUndefinedOrNull())
            return throwTypeError(exec);
    } else
        index = exec->uncheckedArgument(0).toInt32(exec);
    
    if (exec->hadException())
        return jsUndefined();
    
    RefPtr<Float32Array> webGLArray = toFloat32Array(exec->uncheckedArgument(1));
    if (exec->hadException())    
        return jsUndefined();
    
    ExceptionCode ec = 0;
    if (webGLArray) {
        switch (f) {
        case f_uniform1v:
            context.uniform1fv(location, webGLArray.get(), ec);
            break;
        case f_uniform2v:
            context.uniform2fv(location, webGLArray.get(), ec);
            break;
        case f_uniform3v:
            context.uniform3fv(location, webGLArray.get(), ec);
            break;
        case f_uniform4v:
            context.uniform4fv(location, webGLArray.get(), ec);
            break;
        case f_vertexAttrib1v:
            context.vertexAttrib1fv(index, webGLArray.get());
            break;
        case f_vertexAttrib2v:
            context.vertexAttrib2fv(index, webGLArray.get());
            break;
        case f_vertexAttrib3v:
            context.vertexAttrib3fv(index, webGLArray.get());
            break;
        case f_vertexAttrib4v:
            context.vertexAttrib4fv(index, webGLArray.get());
            break;
        }
        
        setDOMException(exec, ec);
        return jsUndefined();
    }
    
    Vector<float, 64> array;
    if (!toVector(exec, exec->uncheckedArgument(1), array))
        return throwTypeError(exec);
    
    switch (f) {
    case f_uniform1v:
        context.uniform1fv(location, array.data(), array.size(), ec);
        break;
    case f_uniform2v:
        context.uniform2fv(location, array.data(), array.size(), ec);
        break;
    case f_uniform3v:
        context.uniform3fv(location, array.data(), array.size(), ec);
        break;
    case f_uniform4v:
        context.uniform4fv(location, array.data(), array.size(), ec);
        break;
    case f_vertexAttrib1v:
        context.vertexAttrib1fv(index, array.data(), array.size());
        break;
    case f_vertexAttrib2v:
        context.vertexAttrib2fv(index, array.data(), array.size());
        break;
    case f_vertexAttrib3v:
        context.vertexAttrib3fv(index, array.data(), array.size());
        break;
    case f_vertexAttrib4v:
        context.vertexAttrib4fv(index, array.data(), array.size());
        break;
    }
    
    setDOMException(exec, ec);
    return jsUndefined();
}
Пример #30
0
	core::TypePtr DataItem::toDataItemType(const core::TypePtr& type) {
		core::IRBuilder builder(type->getNodeManager());
		return builder.genericType(DATA_ITEM_TYPE_NAME, toVector(type));
	}