Пример #1
0
int        main(int argc, const char *argv[])
{
  int accu = 0;
  for (size_t bite = 0; bite < 64; ++bite)
  {
    pong p;
    moost::Thread t1(p);
    moost::Thread t2(p);
    moost::Thread t3(p);
    moost::Thread t4(p);
    moost::Thread t5(p);
    moost::Thread t0(&ping);
    moost::Thread t01(&ping);
    moost::Thread t02(&ping);
    moost::Thread t03(&ping);
    moost::Thread t04(&ping);

    t0.join();
    t01.join();
    t02.join();
    t03.join();
    t04.join();
    t1.join();
    t2.join();
    t3.join();
    t4.join();
    t5.join();
    accu = i;
  }
  if (accu == 0)
    std::cout << "OK" << std::endl;
  else
    std::cout << "KO" << std::endl;
  return (0);
}
Пример #2
0
void runcint()
{
#endif
    string mystring("test string");

    if (!t01(mystring)) {
        fprintf(stderr,"fail to pass by reference\n");
        gSystem->Exit(1);
    }
    if (!t01val(mystring) ) {
        fprintf(stderr,"fail to pass by value\n");
        gSystem->Exit(1);
    }
    if (!t01p(&mystring) ) {
        fprintf(stderr,"fail to pass by address\n");
        gSystem->Exit(1);
    }
}
Пример #3
0
void MeshObject::MakeBox(float x,float y,float z,Material *mtl) {
	// Allocate arrays
	NumVertexes=24;
	NumTriangles=12;
	Vertexes=new Vertex[NumVertexes];
	Triangles=new Triangle[NumTriangles];
	if(mtl==0) mtl=new LambertMaterial;

	x*=0.5f;
	y*=0.5f;
	z*=0.5f;

	// Corners
	Vector3 p000(-x,-y,-z);
	Vector3 p001(-x,-y,z);
	Vector3 p010(-x,y,-z);
	Vector3 p011(-x,y,z);
	Vector3 p100(x,-y,-z);
	Vector3 p101(x,-y,z);
	Vector3 p110(x,y,-z);
	Vector3 p111(x,y,z);

	// Tex coords
	Vector3 t00(0.0f,0.0f,0.0f);
	Vector3 t01(0.0f,1.0f,0.0f);
	Vector3 t10(1.0f,0.0f,0.0f);
	Vector3 t11(1.0f,1.0f,0.0f);

	// Right
	Vertexes[0].Set(p101,Vector3::XAXIS,t00);
	Vertexes[1].Set(p100,Vector3::XAXIS,t10);
	Vertexes[2].Set(p110,Vector3::XAXIS,t11);
	Vertexes[3].Set(p111,Vector3::XAXIS,t01);
	Triangles[0].Init(&Vertexes[0],&Vertexes[1],&Vertexes[2],mtl);
	Triangles[1].Init(&Vertexes[0],&Vertexes[2],&Vertexes[3],mtl);

	// Left
	Vertexes[4].Set(p000,-Vector3::XAXIS,t00);
	Vertexes[5].Set(p001,-Vector3::XAXIS,t10);
	Vertexes[6].Set(p011,-Vector3::XAXIS,t11);
	Vertexes[7].Set(p010,-Vector3::XAXIS,t01);
	Triangles[2].Init(&Vertexes[4],&Vertexes[5],&Vertexes[6],mtl);
	Triangles[3].Init(&Vertexes[4],&Vertexes[6],&Vertexes[7],mtl);

	// Top
	Vertexes[8].Set(p011,Vector3::YAXIS,t00);
	Vertexes[9].Set(p111,Vector3::YAXIS,t10);
	Vertexes[10].Set(p110,Vector3::YAXIS,t11);
	Vertexes[11].Set(p010,Vector3::YAXIS,t01);
	Triangles[4].Init(&Vertexes[8],&Vertexes[9],&Vertexes[10],mtl);
	Triangles[5].Init(&Vertexes[8],&Vertexes[10],&Vertexes[11],mtl);

	// Bottom
	Vertexes[12].Set(p000,-Vector3::YAXIS,t00);
	Vertexes[13].Set(p100,-Vector3::YAXIS,t10);
	Vertexes[14].Set(p101,-Vector3::YAXIS,t11);
	Vertexes[15].Set(p001,-Vector3::YAXIS,t01);
	Triangles[6].Init(&Vertexes[12],&Vertexes[13],&Vertexes[14],mtl);
	Triangles[7].Init(&Vertexes[12],&Vertexes[14],&Vertexes[15],mtl);

	// Front
	Vertexes[16].Set(p001,Vector3::ZAXIS,t00);
	Vertexes[17].Set(p101,Vector3::ZAXIS,t10);
	Vertexes[18].Set(p111,Vector3::ZAXIS,t11);
	Vertexes[19].Set(p011,Vector3::ZAXIS,t01);
	Triangles[8].Init(&Vertexes[16],&Vertexes[17],&Vertexes[18],mtl);
	Triangles[9].Init(&Vertexes[16],&Vertexes[18],&Vertexes[19],mtl);

	// Back
	Vertexes[20].Set(p100,-Vector3::ZAXIS,t00);
	Vertexes[21].Set(p000,-Vector3::ZAXIS,t10);
	Vertexes[22].Set(p010,-Vector3::ZAXIS,t11);
	Vertexes[23].Set(p110,-Vector3::ZAXIS,t01);
	Triangles[10].Init(&Vertexes[20],&Vertexes[21],&Vertexes[22],mtl);
	Triangles[11].Init(&Vertexes[20],&Vertexes[22],&Vertexes[23],mtl);
}
Пример #4
0
void
poisson_blend(mve::FloatImage::ConstPtr src, mve::ByteImage::ConstPtr mask,
    mve::FloatImage::Ptr dest, float alpha) {

    assert(src->width() == mask->width() && mask->width() == dest->width());
    assert(src->height() == mask->height() && mask->height() == dest->height());
    assert(src->channels() == 3 && dest->channels() == 3);
    assert(mask->channels() == 1);
    assert(valid_mask(mask));

    const int n = dest->get_pixel_amount();
    const int width = dest->width();
    const int height = dest->height();
    const int channels = dest->channels();

    mve::Image<int>::Ptr indices = mve::Image<int>::create(width, height, 1);
    indices->fill(-1);
    int index = 0;
    for (int i = 0; i < n; ++i) {
        if (mask->at(i) != 0) {
            indices->at(i) = index;
            index++;
        }
    }
    const int nnz = index;

    std::vector<math::Vec3f> coefficients_b;
    coefficients_b.resize(nnz);

    std::vector<Eigen::Triplet<float, int> > coefficients_A;
    coefficients_A.reserve(nnz); //TODO better estimate...

    for (int i = 0; i < n; ++i) {
        const int row = indices->at(i);
        if (mask->at(i) == 126 || mask->at(i) == 128) {
            Eigen::Triplet<float, int> t(row, row, 1.0f);
            coefficients_A.push_back(t);

            coefficients_b[row] = math::Vec3f(&dest->at(i, 0));
        }

        if (mask->at(i) == 255) {
            const int i01 = indices->at(i - width);
            const int i10 = indices->at(i - 1);
            const int i11 = indices->at(i);
            const int i12 = indices->at(i + 1);
            const int i21 = indices->at(i + width);

            /* All neighbours should be eighter border conditions or part of the optimization. */
            assert(i01 != -1 && i10 != -1 && i11 != -1 && i12 != -1 && i21 != -1);

            Eigen::Triplet<float, int> t01(row, i01, 1.0f);

            Eigen::Triplet<float, int> t10(row, i10, 1.0f);
            Eigen::Triplet<float, int> t11(row, i11, -4.0f);
            Eigen::Triplet<float, int> t12(row, i12, 1.0f);

            Eigen::Triplet<float, int> t21(row, i21, 1.0f);

            Eigen::Triplet<float, int> triplets[] = {t01, t10, t11, t12, t21};

            coefficients_A.insert(coefficients_A.end(), triplets, triplets + 5);

            math::Vec3f l_d = simple_laplacian(i, dest);
            math::Vec3f l_s = simple_laplacian(i, src);

            coefficients_b[row] = (alpha * l_s + (1.0f - alpha) * l_d);
        }
    }

    SpMat A(nnz, nnz);
    A.setFromTriplets(coefficients_A.begin(), coefficients_A.end());

    Eigen::SparseLU<SpMat, Eigen::COLAMDOrdering<int> > solver;
    solver.compute(A);

    for (int channel = 0; channel < channels; ++channel) {
        Eigen::VectorXf b(nnz);
        for (std::size_t i = 0; i < coefficients_b.size(); ++i)
            b[i] = coefficients_b[i][channel];

        Eigen::VectorXf x(n);
        x = solver.solve(b);

        for (int i = 0; i < n; ++i) {
            int index = indices->at(i);
            if (index != -1) dest->at(i, channel) = x[index];
        }
    }
}
Пример #5
0
void shortReadIteratorSmokeTest() {
    t01();
    t02();
    t03();
}
Пример #6
0
bool Test_PageList::Execute()
{
    t01();
    return true;
}