void QgsCoordinateTransform::transformInPlace(
  QVector<float> &x, QVector<float> &y, QVector<float> &z,
  TransformDirection direction ) const
{
  if ( !d->mIsValid || d->mShortCircuit )
    return;

  Q_ASSERT( x.size() == y.size() );

  // Apparently, if one has a std::vector, it is valid to use the
  // address of the first element in the vector as a pointer to an
  // array of the vectors data, and hence easily interface with code
  // that wants C-style arrays.

  try
  {
    //copy everything to double vectors since proj needs double
    int vectorSize = x.size();
    QVector<double> xd( x.size() );
    QVector<double> yd( y.size() );
    QVector<double> zd( z.size() );

    double *destX = xd.data();
    double *destY = yd.data();
    double *destZ = zd.data();

    const float *srcX = x.constData();
    const float *srcY = y.constData();
    const float *srcZ = z.constData();

    for ( int i = 0; i < vectorSize; ++i )
    {
      *destX++ = static_cast< double >( *srcX++ );
      *destY++ = static_cast< double >( *srcY++ );
      *destZ++ = static_cast< double >( *srcZ++ );
    }

    transformCoords( x.size(), &xd[0], &yd[0], &zd[0], direction );

    //copy back
    float *destFX = x.data();
    float *destFY = y.data();
    float *destFZ = z.data();
    const double *srcXD = xd.constData();
    const double *srcYD = yd.constData();
    const double *srcZD = zd.constData();
    for ( int i = 0; i < vectorSize; ++i )
    {
      *destFX++ = static_cast< float >( *srcXD++ );
      *destFY++ = static_cast< float >( *srcYD++ );
      *destFZ++ = static_cast< float >( *srcZD++ );
    }
  }
  catch ( QgsCsException & )
  {
    // rethrow the exception
    QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
    throw;
  }
}
void Point3D_Recons::projectRays_(const vector<Feature>& features, vector<Ray>& directions) {
  directions.clear();
  
  for (unsigned int i = 0; i < features.size(); i++) {
    unsigned int camera = features[i].cameraId;
    unsigned int pose = features[i].poseId;
    RealPoint2D zd(features[i].x, features[i].y);
    
    const RealPoint2D zu = cali_.rectify(camera, zd); 	RealPoint3D<float> tmp(zu.u(), zu.v(), 1.0f);
    Matrix<float> K = (cali_.getCamera(camera)).K();  	Matrix<float> inv_K;	inverseMat33(K, inv_K);
    RealPoint3D<float> r_tmp; 				mulMat33Vect3(inv_K, tmp, r_tmp);
    
    Matrix<float> Rc = (cali_.getCamera(camera)).R();
    RealPoint3D<float> r;				mulMat33Vect3(Rc, r_tmp, r);
    float rnorm = sqrt(r.norm2()); 
    RealPoint3D<float> r_norm = r/rnorm;
    
    Ray ray;
    ray.cameraId = camera;
    ray.poseId 	 = pose;
    ray.obs 	 = zd;
    ray.dir  	 = r_norm;

    ray.inlier = features[i].inlier;
    directions.push_back(ray);
  }
}
示例#3
0
void QgsCoordinateTransform::transformInPlace(
    QVector<float>& x, QVector<float>& y, QVector<float>& z,
    TransformDirection direction ) const
{
    if ( mShortCircuit || !mInitialisedFlag )
        return;

    Q_ASSERT( x.size() == y.size() );

    // Apparently, if one has a std::vector, it is valid to use the
    // address of the first element in the vector as a pointer to an
    // array of the vectors data, and hence easily interface with code
    // that wants C-style arrays.

    try
    {
        //copy everything to double vectors since proj needs double
        int vectorSize = x.size();
        QVector<double> xd( x.size() );
        QVector<double> yd( y.size() );
        QVector<double> zd( z.size() );
        for ( int i = 0; i < vectorSize; ++i )
        {
            xd[i] = x[i];
            yd[i] = y[i];
            zd[i] = z[i];
        }
        transformCoords( x.size(), &xd[0], &yd[0], &zd[0], direction );

        //copy back
        for ( int i = 0; i < vectorSize; ++i )
        {
            x[i] = xd[i];
            y[i] = yd[i];
            z[i] = zd[i];
        }
    }
    catch ( QgsCsException & )
    {
        // rethrow the exception
        QgsDebugMsg( "rethrowing exception" );
        throw;
    }
}
示例#4
0
void lb_zoltan(PSTopology top, LBMethod method, unsigned int dimen, list_type& pl)
{
        const par::communicator& comm = par::comm_world();

        float ver;
        Zoltan_Initialize(0, 0, &ver);

        struct Zoltan_Struct *zz;

        // Create ZData (moves pl into zd)
        ZData zd(par::comm_world(), std::move(pl));

        // Allocate the Zoltan data
        zz = Zoltan_Create(zd.comm.raw());

        // Set some default sane parameters
        if (method == LBMethod::RCB)
                Zoltan_Set_Param(zz, "LB_METHOD", "RCB");
        else
                throw std::runtime_error("Unknown load balancing method");

        // Zoltan_Set_Param(zz, "KEEP_CUTS", "1");
        // Zoltan_Set_Param(zz, "LB_APPROACH", "REPARTITION");
        // Zoltan_Set_Param(zz, "MIGRATE_ONLY_PROC_CHANGES", "1");
        Zoltan_Set_Param(zz, "AUTO_MIGRATE", "TRUE");
        // Set higher for more debugging output
        Zoltan_Set_Param(zz, "DEBUG_LEVEL", "0");

        // Set partition query methods
        Zoltan_Set_Num_Obj_Fn(zz, pl_num_obj,
                              static_cast<void *>(&zd));
        Zoltan_Set_Obj_List_Fn(zz, pl_obj_list,
                               static_cast<void *>(&zd));
        Zoltan_Set_Num_Geom_Fn(zz, pl_num_geom,
                               static_cast<void *>(&zd));
        Zoltan_Set_Geom_Multi_Fn(zz, pl_geom_multi,
                                 static_cast<void *>(&zd));

        // Migration query methods
        Zoltan_Set_Mid_Migrate_PP_Fn(zz, pl_mid_migrate_pp,
                                     static_cast<void *>(&zd));
        Zoltan_Set_Obj_Size_Multi_Fn(zz, pl_obj_size_multi,
                                     static_cast<void *>(&zd));
        Zoltan_Set_Pack_Obj_Multi_Fn(zz, pl_pack_obj_multi,
                                     static_cast<void *>(&zd));
        Zoltan_Set_Unpack_Obj_Multi_Fn(zz, pl_unpack_obj_multi,
                                       static_cast<void *>(&zd));

        int
                zerr,
                changes,
                num_gid_entries, num_lid_entries,
                num_import,
                *import_procs,
                *import_to_part,
                num_export,
                *export_procs,
                *export_to_part;
        unsigned int
                *import_global_ids,
                *import_local_ids,
                *export_global_ids,
                *export_local_ids;

        zerr = Zoltan_LB_Partition(zz,
                                   &changes,
                                   &num_gid_entries,
                                   &num_lid_entries,
                                   &num_import,
                                   &import_global_ids,
                                   &import_local_ids,
                                   &import_procs,
                                   &import_to_part,
                                   &num_export,
                                   &export_global_ids,
                                   &export_local_ids,
                                   &export_procs,
                                   &export_to_part);

        if (zerr != ZOLTAN_OK) comm.abort("Zoltan error", 1);

        // Move the data back again out of the struct
        pl = std::move(zd.list);

        Zoltan_Destroy(&zz);
}
示例#5
0
Transformation Boonas:: parseParams(int start, int argc, char** argv, Transformation matrix) 
{
	QString currIn;
	
	for(int i = start; i < (argc - 1); i += 2) // iterate through parameters skiping every other
	{
		if(strcmp(argv[i], "XT") == 0)
		{
			currIn = argv[i + 1];
			matrix = xt(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YT") == 0)
		{
			currIn = argv[i + 1];
			matrix = yt(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "ZT") == 0)
		{
			currIn = argv[i + 1];
			matrix = zt(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "XS") == 0)
		{
			currIn = argv[i + 1];
			matrix = xs(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YS") == 0)
		{
			currIn = argv[i + 1];
			matrix = ys(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "ZS") == 0)
		{
			currIn = argv[i + 1];
			matrix = zs(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "US") == 0)
		{
			currIn = argv[i + 1];
			matrix = us(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "XD") == 0)
		{
			currIn = argv[i + 1];
			matrix = xd(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YD") == 0)
		{
			currIn = argv[i + 1];
			matrix = yd(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "ZD") == 0)
		{
			currIn = argv[i + 1];
			matrix = zd(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "XR") == 0)
		{
			currIn = argv[i + 1];
			matrix = xr(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YR") == 0)
		{
			currIn = argv[i + 1];
			matrix = yr(currIn.toFloat(), matrix);
		}
		else // MUST BE ZR
		{
			currIn = argv[i + 1];
			matrix = zr(currIn.toFloat(), matrix);
		}
	}
	
	return matrix;
}
示例#6
0
void Boonas::doZrm(QString outfile, float angleOfRot, float divisions) // angle of rot is in degrees 
{
	Transformation matrix;
	outfile.append(".polyTemp");
	float x, y, z, w;
	bool again = true;
	QFile* theOutDestination;
	theOutDestination = new QFile(outfile);
	theOutDestination -> remove();
	theOutDestination -> open(QIODevice::ReadWrite | QIODevice::Text);
	QTextStream outStream( theOutDestination );
	
	matrix = zd(angleOfRot, matrix);
	
	for(int i = 0; i < divisions; i++) // do it for the total number of divisions
	{
		again = true;
		orig -> reset();
		//write to file
		do // do this loop while ther is more in orig
		{
			
			cursor = orig -> getCurrent(); // cursor is current
			cursor -> reset();
			
			//change color respectively for each object
			x = cursor -> getX(); 
			y = cursor -> getY();
			z = cursor -> getZ();
			
			if(colorValue != 0)
			{
				delete colorValue;
				colorValue = 0;
			}
			colorValue = new Point(x, y, z);
			
			cursor -> advance();
			
			x = cursor -> getX(); 
			y = cursor -> getY();
			z = cursor -> getZ();
			
			if(!(orig -> isNotLast()))
			{
				again = false;
			}
			
			outStream << "newObject" << endl;
			
			// put out color vector
			outStream << colorValue -> x() << " " << colorValue -> y() << " "<< colorValue -> z() << " 1" << endl;
			
			do
			{
				x = cursor -> getX(); // get point
				y = cursor -> getY();
				z = cursor -> getZ();
				w = cursor -> getW();
				outStream << x << " " << y << " " << z << " " << w << endl;
				//qDebug() << "runing through before mult then after";
				//qDebug() << x << " " << y << " " << z << " " << w;
				cursor -> advance();
			}
			while(cursor -> hasNext()); // run through the points and mult!
			
			x = cursor -> getX(); // get point
			y = cursor -> getY();
			z = cursor -> getZ();
			w = cursor -> getW();
			outStream << x << " " << y << " " << z << " " << w << endl;
			
			
			cursor -> reset();
			
			orig -> advance(); // advance what were working with
		}
		while(again);
		
		//do rotate
		doMult(matrix);
	}
	
	return;
}