Пример #1
0
	void gen2()
	{
		const int unit = 64;
		resetGlobalIdx();
		Operand pz(IntPtr, unit);
		Operand px(IntPtr, unit);
		Operand py(IntPtr, unit);
		std::string name = "add128";
		Function f(name, Void, pz, px, py);
		beginFunc(f);
		Operand x = load(px);
		Operand y = load(py);
		x = zext(x, 128);
		y = zext(y, 128);
		x = add(x, y);
		Operand L = trunc(x, 64);
		store(L, pz);
		Operand xH = load(getelementptr(px, makeImm(32, 1)));
		Operand yH = load(getelementptr(py, makeImm(32, 1)));
		x = trunc(lshr(x, 64), 64);
		x = add(x, xH);
		x = add(x, yH);
		store(x, getelementptr(pz, makeImm(32, 1)));
		
		ret(Void);
		endFunc();
	}
Пример #2
0
void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
{
    // Add zones and modifiers for motion action

    if
    (
        pointZones().size() > 0
     || faceZones().size() > 0
     || cellZones().size() > 0
    )
    {
        Info<< "void linearValveLayersFvMesh::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        if (topoChanger_.size() == 0)
        {
            FatalErrorIn
            (
                "void linearValveLayersFvMesh::addZonesAndModifiers()"
            )   << "Mesh modifiers not read properly"
                << abort(FatalError);
        }

        return;
    }

    Info<< "Time = " << time().timeName() << endl
        << "Adding zones and modifiers to the mesh" << endl;

    // Add zones
    List<pointZone*> pz(1);
    List<faceZone*> fz(4);
    List<cellZone*> cz(0);


    // Add an empty zone for cut points

    pz[0] = new pointZone
    (
        "cutPointZone",
        labelList(0),
        0,
        pointZones()
    );


    // Do face zones for slider

    // Inner slider
    const word innerSliderName(motionDict_.subDict("slider").lookup("inside"));
    const polyPatch& innerSlider =
        boundaryMesh()[boundaryMesh().findPatchID(innerSliderName)];

    labelList isf(innerSlider.size());

    forAll (isf, i)
    {
        isf[i] = innerSlider.start() + i;
    }
Пример #3
0
GLuint FileAssociatedTexture::getOrCreateCube(
	const QString & fileNames
,   OpenGLFunctions & gl
,	const GLenum mag_filter
,	const GLenum min_filter)
{
    if (s_texturesByFilePath.contains(fileNames))
        return s_texturesByFilePath[fileNames];

    QString px(fileNames); px.replace("?", "px");
    QString nx(fileNames); nx.replace("?", "nx");
    QString py(fileNames); py.replace("?", "py");
    QString ny(fileNames); ny.replace("?", "ny");
    QString pz(fileNames); pz.replace("?", "pz");
    QString nz(fileNames); nz.replace("?", "nz");

    QStringList files = QStringList() << px << nx << py << ny << pz << nz;
    QStringList absolutes;
    foreach(const QString & file, files)
    {
        QFileInfo fi(file);
        if (!fi.exists())
        {
            qWarning() << file << " does not exist: texture has no associated file.";
            return -1;
        }
        absolutes << fi.absoluteFilePath();
    }
Пример #4
0
void Foam::mixerGgiFvMesh::addZonesAndModifiers()
{
    // Add zones and modifiers for motion action

    if (cellZones().size() > 0)
    {
        Info<< "void mixerGgiFvMesh::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        return;
    }

    Info<< "Time = " << time().timeName() << endl
        << "Adding zones and modifiers to the mesh" << endl;

    // Add zones
    List<pointZone*> pz(0);
    List<faceZone*> fz(0);
    List<cellZone*> cz(1);

    // Copy the face zones associated with the GGI interfaces
    if (faceZones().size() > 0)
    {
        // Copy face zones
        Info << "Copying existing face zones" << endl;

        fz.setSize(faceZones().size());

        forAll (faceZones(), i)
        {
            fz[i] = faceZones()[i].clone(faceZones()).ptr();
        }
Пример #5
0
void CCuboid::GetGripperPositions(std::list<GripData> *list, bool just_for_endof)
{
	gp_Pnt o = m_pos.Location();
	gp_Pnt px(o.XYZ() + m_pos.XDirection().XYZ() * m_x);
	gp_Pnt py(o.XYZ() + m_pos.YDirection().XYZ() * m_y);
	gp_Dir z_dir = m_pos.XDirection() ^ m_pos.YDirection();
	gp_Pnt pz(o.XYZ() + z_dir.XYZ() * m_z);
	gp_Pnt m2(o.XYZ() + m_pos.XDirection().XYZ() * m_x + m_pos.YDirection().XYZ() * m_y/2);
	gp_Pnt m3(o.XYZ() + m_pos.XDirection().XYZ() * m_x/2 + m_pos.YDirection().XYZ() * m_y);
	gp_Pnt m8(o.XYZ() + m_pos.YDirection().XYZ() * m_y/2 + z_dir.XYZ() * m_z);
	gp_Pnt pxy(o.XYZ() + m_pos.XDirection().XYZ() * m_x + m_pos.YDirection().XYZ() * m_y);
	gp_Pnt pxz(o.XYZ() + m_pos.XDirection().XYZ() * m_x + z_dir.XYZ() * m_z);
	gp_Pnt pyz(o.XYZ() + m_pos.YDirection().XYZ() * m_y + z_dir.XYZ() * m_z);
	gp_Pnt pxyz(o.XYZ() + m_pos.XDirection().XYZ() * m_x  + m_pos.YDirection().XYZ() * m_y + z_dir.XYZ() * m_z);
	list->push_back(GripData(GripperTypeTranslate,o.X(),o.Y(),o.Z(),NULL));
	list->push_back(GripData(GripperTypeRotateObject,px.X(),px.Y(),px.Z(),NULL));
	list->push_back(GripData(GripperTypeRotateObject,py.X(),py.Y(),py.Z(),NULL));
	list->push_back(GripData(GripperTypeRotateObject,pz.X(),pz.Y(),pz.Z(),NULL));
	list->push_back(GripData(GripperTypeScale,pxyz.X(),pxyz.Y(),pxyz.Z(),NULL));
	list->push_back(GripData(GripperTypeRotate,pxy.X(),pxy.Y(),pxy.Z(),NULL));
	list->push_back(GripData(GripperTypeRotate,pxz.X(),pxz.Y(),pxz.Z(),NULL));
	list->push_back(GripData(GripperTypeRotate,pyz.X(),pyz.Y(),pyz.Z(),NULL));
	list->push_back(GripData(GripperTypeObjectScaleX,m2.X(),m2.Y(),m2.Z(),NULL));
	list->push_back(GripData(GripperTypeObjectScaleY,m3.X(),m3.Y(),m3.Z(),NULL));
	list->push_back(GripData(GripperTypeObjectScaleZ,m8.X(),m8.Y(),m8.Z(),NULL));
}
Пример #6
0
// this usually reports size that is too large
RectF MeasureTextStandard(Graphics *g, Font *f, const WCHAR *s, int len)
{
    RectF bbox;
    PointF pz(0,0);
    g->MeasureString(s, len, f, pz, &bbox);
    return bbox;
}
Пример #7
0
int collide(int *a, int *b)
{
	 // sanity checking
	 if (a == 000 || b == 000)
		  return -1; // bad args
	 if (b[0] < 1)
		  return -2; // x at 0
	 if (b[1] < 1)
		  return -3; // y at 0
	 if (b[2] < 1)
		  return -4; // z at 0
	 if (b[0] > xres)
		  return -5; // x at max
	 if (b[0] > yres)
		  return -6; // y at max
	 if (b[0] > zres)
		  return -7; // z at max

	 int vec[3] = {(b[0]-a[0]), (b[1]-a[1]), (b[2]-a[2])}; // vector
	 int result = 0;

	 /* below is a fairly basic algo to keep checking until there is no conflict
	  * may be optimizable
	  */
	 do
	 {
		  result = 0;
		  if (vec[0] > 0)
		  {
				result += px(&b[0]);
		  }
		  if (vec[1] > 0)
		  {
				result += py(&b[1]);
		  }
		  if (vec[2] > 0)
		  {
				result += pz(&b[2]);
		  }
		  if (vec[0] < 0)
		  {
				result += nx(&b[0]);
		  }
		  if (vec[1] < 0)
		  {
				result += ny(&b[1]);
		  }
		  if (vec[2] < 0)
		  {
				result += nz(&b[2]);
		  }
		  vec[0] = (b[0]-a[0]);
		  vec[1] = (b[1]-a[1]);
		  vec[2] = (b[2]-a[2]); // recalc. should eliminate unnecessary checks
	 }
	 while (result != 0);

	 return 0;
}
Пример #8
0
Point3D& Point3D::operator %(Point3D&& p) const
{
    point_t px(std::move(p.__x)), py(std::move(p.__y)), pz(std::move(p.__z));
    p.__x = __y * pz - __z * py;
    p.__y = __z * px - __x * pz;
    p.__z = __x * py - __y * px;
    return p;
}
Пример #9
0
int CCylinder::GetCentrePoints(double* pos, double* pos2)
{
	gp_Pnt o = m_pos.Location();
	gp_Dir z_dir = m_pos.XDirection() ^ m_pos.YDirection();
	gp_Pnt pz(o.XYZ() + z_dir.XYZ() * m_height);
	extract(o, pos);
	extract(pz, pos2);
	return 2;
}
Пример #10
0
 void CubicLattice< NPnt<5> > :: initPoints(){
    for (int i = 0; i < mWidth; ++i){
       for (int j = 0; j < mHeight; ++j){
           for (int k = 0; k < mDepth; ++k){
               int tidx = idx(i,j,k); 
               mPoint[ tidx ]  = Ro::null( px(i),  py(j),  pz(k) ); 
           }
       }
    }
 }
Пример #11
0
void Starfield::Draw(Graphics::Renderer *renderer)
{
	if (AreShadersEnabled()) {
		glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
	} else {
		glDisable(GL_POINT_SMOOTH); //too large if smoothing is on
		glPointSize(1.0f);
	}

	// XXX would be nice to get rid of the Pi:: stuff here
	if (!Pi::game || Pi::player->GetFlightState() != Ship::HYPERSPACE) {
		renderer->DrawStaticMesh(m_model);
	} else {
		/* HYPERSPACING!!!!!!!!!!!!!!!!!!! */
		/* all this j**z isn't really necessary, since the player will
		 * be in the root frame when hyperspacing... */
		matrix4x4d m, rot;
		Frame::GetFrameTransform(Pi::game->GetSpace()->GetRootFrame(), Pi::player->GetFrame(), m);
		m.ClearToRotOnly();
		Pi::player->GetRotMatrix(rot);
		m = rot.InverseOf() * m;
		vector3d pz(m[2], m[6], m[10]);

		// roughly, the multiplier gets smaller as the duration gets larger.
		// the time-looking bits in this are completely arbitrary - I figured
		// it out by tweaking the numbers until it looked sort of right
		double mult = 0.0015 / (Pi::player->GetHyperspaceDuration() / (60.0*60.0*24.0*7.0));

		double hyperspaceProgress = Pi::game->GetHyperspaceProgress();

		//XXX this is a lot of lines
		if (m_hyperVtx == 0) {
			m_hyperVtx = new vector3f[BG_STAR_MAX * 2];
			m_hyperCol = new Color[BG_STAR_MAX * 2];
		}
		VertexArray *va = m_model->GetSurface(0)->GetVertices();
		for (int i=0; i<BG_STAR_MAX; i++) {
			
			vector3f v(va->position[i]);
			v += vector3f(pz*hyperspaceProgress*mult);

			m_hyperVtx[i*2] = va->position[i] + v;
			m_hyperCol[i*2] = va->diffuse[i];

			m_hyperVtx[i*2+1] = v;
			m_hyperCol[i*2+1] = va->diffuse[i];
		}
		Pi::renderer->DrawLines(BG_STAR_MAX*2, m_hyperVtx, m_hyperCol);
	}

	if (AreShadersEnabled()) {
		glDisable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
	}
}
Пример #12
0
 void CubicLattice< NPnt<5> > :: initPoints(){
    for (int i = 0; i < mWidth; ++i){
       for (int j = 0; j < mHeight; ++j){
           for (int k = 0; k < mDepth; ++k){
               int tidx = idx(i,j,k); 
               mPoint[ tidx ]  = nga::Round::point(px(i),  py(j),  pz(k) ); 
              // mPoint[tidx].print();
           }
       }
    }
 }
Пример #13
0
void vtest1() {
    int legend[] = {3, 1, 1, 0};
    BSArenaPuzzle pz(10, legend);
    std::cout << pz << std::endl;
    pz.apply_result(BSPoint(2, 3), BSArena::r_milk);
    pz.apply_result(BSPoint(3, 2), BSArena::r_milk);
    pz.apply_result(BSPoint(3, 3), BSArena::r_continue_in_that_direction);
    pz.apply_result(BSPoint(3, 5), BSArena::r_drowned);
    std::cout << "____________" << std::endl;
    std::cout << pz << std::endl;
    std::cout << "___SEARCH___" << std::endl;
    BSPoint p = pz.find_fire();
}
Пример #14
0
void utest4() {
    int legend[] = {4, 2, 2, 0};
    BSArenaPuzzle pz(10, legend);
    std::cout << pz << std::endl;
    pz.apply_result(BSPoint(3, 3), BSArena::r_continue_in_that_direction);
    pz.apply_result(BSPoint(6, 6), BSArena::r_continue_in_that_direction);
    std::cout << pz << std::endl;
    std::cout << "===" << std::endl;
    BSPoint p = pz.find_fire();
    std::cout << "===" << std::endl;
    std::cout << p << std::endl;
    std::cout << "===" << std::endl;
}
Пример #15
0
void Foam::linearValveFvMesh::addZonesAndModifiers()
{
    // Add zones and modifiers for motion action

    if
    (
        pointZones().size()
     || faceZones().size()
     || cellZones().size()
     || topoChanger_.size()
    )
    {
        Info<< "void linearValveFvMesh::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        return;
    }

    Info<< "Time = " << time().timeName() << endl
        << "Adding zones and modifiers to the mesh" << endl;

    // Add zones
    List<pointZone*> pz(1);

    // Add an empty zone for cut points

    pz[0] = new pointZone
    (
        "cutPointZone",
        labelList(0),
        0,
        pointZones()
    );


    // Do face zones for slider

    List<faceZone*> fz(3);

    // Inner slider
    const word innerSliderName(motionDict_.subDict("slider").lookup("inside"));
    const polyPatch& innerSlider = boundaryMesh()[innerSliderName];

    labelList isf(innerSlider.size());

    forAll(isf, i)
    {
        isf[i] = innerSlider.start() + i;
    }
Пример #16
0
void HGear::GetGripperPositions(std::list<GripData> *list, bool just_for_endof){
	gp_Pnt o = m_pos.Location();
	double acting_radius = (double)(m_module * m_num_teeth)/2;
	gp_Pnt px(o.XYZ() + m_pos.XDirection().XYZ() * acting_radius);
	gp_Pnt py(o.XYZ() + m_pos.YDirection().XYZ() * acting_radius);
	gp_Dir z_dir = m_pos.XDirection() ^ m_pos.YDirection();
	gp_Pnt pz(o.XYZ() + z_dir.XYZ() * acting_radius);
	gp_Pnt pxyz(o.XYZ() + m_pos.XDirection().XYZ() * acting_radius  + m_pos.YDirection().XYZ() * acting_radius + z_dir.XYZ() * acting_radius);
	list->push_back(GripData(GripperTypeTranslate,o.X(),o.Y(),o.Z(),NULL));
	list->push_back(GripData(GripperTypeRotateObject,px.X(),px.Y(),px.Z(),NULL));
	list->push_back(GripData(GripperTypeRotateObject,py.X(),py.Y(),py.Z(),NULL));
	list->push_back(GripData(GripperTypeRotateObject,pz.X(),pz.Y(),pz.Z(),NULL));
	list->push_back(GripData(GripperTypeScale,pxyz.X(),pxyz.Y(),pxyz.Z(),NULL));
}
Пример #17
0
void CCylinder::GetGripperPositions(std::list<GripData> *list, bool just_for_endof)
{
	gp_Pnt o = m_pos.Location();
	gp_Pnt px(o.XYZ() + m_pos.XDirection().XYZ() * m_radius);
	gp_Dir z_dir = m_pos.XDirection() ^ m_pos.YDirection();
	gp_Pnt pyz(o.XYZ() + m_pos.YDirection().XYZ() * m_radius + z_dir.XYZ() * m_height);
	gp_Pnt pmxz(o.XYZ() + m_pos.XDirection().XYZ() * (-m_radius) + z_dir.XYZ() * m_height);
	gp_Pnt pz(o.XYZ() + z_dir.XYZ() * m_height);
	list->push_back(GripData(GripperTypeTranslate,o.X(),o.Y(),o.Z(),NULL));
	list->push_back(GripData(GripperTypeObjectScaleXY,px.X(),px.Y(),px.Z(),NULL));
	list->push_back(GripData(GripperTypeRotateObject,pyz.X(),pyz.Y(),pyz.Z(),NULL));
	list->push_back(GripData(GripperTypeRotateObject,pmxz.X(),pmxz.Y(),pmxz.Z(),NULL));
	list->push_back(GripData(GripperTypeObjectScaleZ,pz.X(),pz.Y(),pz.Z(),NULL));
}
Пример #18
0
string Particle::toString() const {
	stringstream out;
	out << "Particle information" << "\n";
	out << setw(30) << "energy" << setw(30) << "px" << setw(30) << "py" << setw(30) << "pz" << "\n";
	out << setw(30) << energy() << setw(30) << px() << setw(30) << py() << setw(30) << pz() << "\n";
	out << setw(30) << "phi" << setw(30) << "eta" << setw(30) << "theta" << setw(30) << "  " << "\n";
	out << setw(30) << phi() << setw(30) << eta()  << setw(30) << theta() << setw(30) << " " << "\n";
	out << setw(30) << "momentum" << setw(30) << "E_T" << setw(30) << "p_T" << setw(30) << "  " << "\n";
	out << setw(30) << momentum() << setw(30) << et() << setw(30) << pt() << setw(30) << "  " << "\n";
	out << setw(30) << "m_dyn" << setw(30) << "m_fix" << setw(30) << "charge" << setw(30) << "  " << "\n";
	out << setw(30) << massFromEnergyAndMomentum() << setw(30) <<  mass() << setw(30) << charge() << setw(30) << "  " << "\n";
	out << setw(30) << "d0 =" << setw(30) << "d0_bs" << setw(30) << "  " << setw(30) << "  " << "\n";
	out << setw(30) << d0() << setw(30) << d0_wrtBeamSpot() << setw(30) << "  " << setw(30) << "  " << "\n";
	return out.str();
}
Пример #19
0
	void gen1()
	{
		const int bit = 1024;
		resetGlobalIdx();
		Operand pz(IntPtr, bit);
		Operand px(IntPtr, bit);
		Operand py(IntPtr, bit);
		std::string name = "add" + cybozu::itoa(bit);
		Function f(name, Void, pz, px, py);
		beginFunc(f);
		Operand x = load(px);
		Operand y = load(py);
		x = add(x, y);
		store(x, pz);
		ret(Void);
		endFunc();
	}
Пример #20
0
bool CCone::Stretch2(const double *p, const double* shift, gp_Ax2& new_pos, double& new_r1, double& new_r2, double& new_height)
{
	gp_Pnt vp = make_point(p);
	gp_Vec vshift = make_vector(shift);

	gp_Pnt o = m_pos.Location();
	gp_Pnt px(o.XYZ() + m_pos.XDirection().XYZ() * m_r1);
	gp_Dir z_dir = m_pos.XDirection() ^ m_pos.YDirection();
	gp_Pnt py(o.XYZ() + m_pos.YDirection().XYZ() * m_r1);
	gp_Pnt pyz(o.XYZ() + m_pos.YDirection().XYZ() * m_r2 + z_dir.XYZ() * m_height);
	gp_Pnt pmxz(o.XYZ() + m_pos.XDirection().XYZ() * (-m_r2) + z_dir.XYZ() * m_height);
	gp_Pnt pz(o.XYZ() + z_dir.XYZ() * m_height);
	gp_Pnt pxz(o.XYZ() + m_pos.XDirection().XYZ() * m_r2 + z_dir.XYZ() * m_height);

	bool make_a_new_cone = false;

	if(px.IsEqual(vp, wxGetApp().m_geom_tol)){
		px = px.XYZ() + vshift.XYZ();
		double new_x = gp_Vec(px.XYZ()) * gp_Vec(m_pos.XDirection()) - gp_Vec(o.XYZ()) * gp_Vec(m_pos.XDirection());
		double new_y = gp_Vec(px.XYZ()) * gp_Vec(m_pos.YDirection()) - gp_Vec(o.XYZ()) * gp_Vec(m_pos.YDirection());
		new_r1 = sqrt(new_x * new_x + new_y * new_y);
		if(fabs(new_r1 - m_r2) > 0.000000001){
			make_a_new_cone = true;
		}
	}
	else if(pxz.IsEqual(vp, wxGetApp().m_geom_tol)){
		pxz = pxz.XYZ() + vshift.XYZ();
		double new_x = gp_Vec(pxz.XYZ()) * gp_Vec(m_pos.XDirection()) - gp_Vec(o.XYZ()) * gp_Vec(m_pos.XDirection());
		double new_y = gp_Vec(pxz.XYZ()) * gp_Vec(m_pos.YDirection()) - gp_Vec(o.XYZ()) * gp_Vec(m_pos.YDirection());
		new_r2 = sqrt(new_x * new_x + new_y * new_y);
		if(fabs(m_r1 - new_r2) > 0.000000001){
			make_a_new_cone = true;
		}
	}
	else if(pz.IsEqual(vp, wxGetApp().m_geom_tol)){
		pz = pz.XYZ() + vshift.XYZ();
		new_height = gp_Vec(pz.XYZ()) * gp_Vec(z_dir) - gp_Vec(o.XYZ()) * gp_Vec(z_dir);
		if(new_height > 0){
			make_a_new_cone = true;
		}
	}

	return make_a_new_cone;
}
void Foam::multiMixerFvMesh::addZonesAndModifiers()
{
    // Add zones and modifiers for motion action

    if
    (
        pointZones().size() > 0
     || faceZones().size() > 0
     || cellZones().size() > 0
    )
    {
        Info<< "void multiMixerFvMesh::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        if (topoChanger_.size() == 0  && useTopoSliding())
        {
            FatalErrorIn
            (
                "void multiMixerFvMesh::addZonesAndModifiers()"
            )   << "Mesh modifiers not read properly"
                << abort(FatalError);
        }

        return;
    }

    Info<< "Time = " << time().timeName() << endl
        << "Adding zones and modifiers to the mesh.  " << rotors_.size()
        << " sliders found" << endl;

    DynamicList<pointZone*> pz(rotors_.size());
    DynamicList<faceZone*> fz(3*rotors_.size());
    DynamicList<cellZone*> cz(rotors_.size());

    // Create region split: mark every cell with its topological region
    regionSplit rs(*this);

    Info << "Adding point, face and cell zones" << endl;
    forAll (rotors_, rotorI)
    {
        rotors_[rotorI].addZones(pz, fz, cz, rs);
    }
Пример #22
0
bool CCylinder::Stretch(const double *p, const double* shift, void* data)
{
	gp_Pnt vp = make_point(p);
	gp_Vec vshift = make_vector(shift);

	gp_Pnt o = m_pos.Location();
	gp_Pnt px(o.XYZ() + m_pos.XDirection().XYZ() * m_radius);
	gp_Dir z_dir = m_pos.XDirection() ^ m_pos.YDirection();
	gp_Pnt pz(o.XYZ() + z_dir.XYZ() * m_height);

	bool make_a_new_cylinder = false;

	if(px.IsEqual(vp, wxGetApp().m_geom_tol)){
		px = px.XYZ() + vshift.XYZ();
		double new_x = gp_Vec(px.XYZ()) * gp_Vec(m_pos.XDirection()) - gp_Vec(o.XYZ()) * gp_Vec(m_pos.XDirection());
		double new_y = gp_Vec(px.XYZ()) * gp_Vec(m_pos.YDirection()) - gp_Vec(o.XYZ()) * gp_Vec(m_pos.YDirection());
		make_a_new_cylinder = true;
		m_radius = sqrt(new_x * new_x + new_y * new_y);
	}
	else if(pz.IsEqual(vp, wxGetApp().m_geom_tol)){
		pz = pz.XYZ() + vshift.XYZ();
		double new_height = gp_Vec(pz.XYZ()) * gp_Vec(z_dir) - gp_Vec(o.XYZ()) * gp_Vec(z_dir);
		if(new_height > 0){
			make_a_new_cylinder = true;
			m_height = new_height;
		}
	}

	if(make_a_new_cylinder)
	{
		CCylinder* new_object = new CCylinder(m_pos, m_radius, m_height, m_title.c_str(), m_color, m_opacity);
		new_object->CopyIDsFrom(this);
		HEEKSOBJ_OWNER->Add(new_object, NULL);
		HEEKSOBJ_OWNER->Remove(this);
		wxGetApp().m_marked_list->Clear(true);
		wxGetApp().m_marked_list->Add(new_object, true);
	}

	return true;
}
void Foam::simpleEngineTopoFvMesh::addZonesAndModifiers()
{
    // Add the zones and mesh modifiers to operate piston and valve motion

    if
    (
        pointZones().size() > 0
     || faceZones().size() > 0
     || cellZones().size() > 0
    )
    {
        Info<< "void Foam::simpleEngineTopoFvMesh::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        if (topoChanger_.size() == 0)
        {
            FatalErrorIn
            (
                "void simpleEngineTopoFvMesh::addZonesAndModifiers()"
            )   << "Mesh modifiers not read properly"
                << abort(FatalError);
        }

        return;
    }

    Info<< "Time = " << engineTime_.theta() << endl
        << "Adding zones to the engine mesh" << endl;

    List<pointZone*> pz(nValves());
    List<faceZone*> fz(6*nValves() + 1);
    List<cellZone*> cz(0);

    label nPointZones = 0;
    label nFaceZones = 0;

    for (label valveI = 0; valveI < nValves(); valveI++)
    {
        // If both sides of the interface exist, add sliding interface
        // for a valve
        if
        (
            valves_[valveI].curtainInCylinderPatchID().active()
         && valves_[valveI].curtainInPortPatchID().active()
        )
        {
            Info<< "Adding sliding interface zones for curtain of valve "
                << valveI + 1 << endl;

            pz[nPointZones] =
                new pointZone
                (
                    "cutPointsV" + Foam::name(valveI + 1),
                    labelList(0),
                    nPointZones,
                    pointZones()
                );
            nPointZones++;

            const polyPatch& cylCurtain =
                boundaryMesh()
                    [valves_[valveI].curtainInCylinderPatchID().index()];

            labelList cylCurtainLabels(cylCurtain.size(), cylCurtain.start());

            forAll (cylCurtainLabels, i)
            {
                cylCurtainLabels[i] += i;
            }

            fz[nFaceZones] =
                new faceZone
                (
                    "curtainCylZoneV" + Foam::name(valveI + 1),
                    cylCurtainLabels,
                    boolList(cylCurtainLabels.size(), false),
                    nFaceZones,
                    faceZones()
                );
            nFaceZones++;

            const polyPatch& portCurtain =
                boundaryMesh()
                    [valves_[valveI].curtainInPortPatchID().index()];

            labelList portCurtainLabels
            (
                portCurtain.size(),
                portCurtain.start()
            );

            forAll (portCurtainLabels, i)
            {
                portCurtainLabels[i] += i;
            }

            fz[nFaceZones] =
                new faceZone
                (
                    "curtainPortZoneV" + Foam::name(valveI + 1),
                    portCurtainLabels,
                    boolList(portCurtainLabels.size(), false),
                    nFaceZones,
                    faceZones()
                );
            nFaceZones++;

            // Add empty zone for cut faces
            fz[nFaceZones] =
                new faceZone
                (
                    "cutFaceZoneV" + Foam::name(valveI + 1),
                    labelList(0),
                    boolList(0, false),
                    nFaceZones,
                    faceZones()
                );
            nFaceZones++;

            // Create a detach zone
            if
            (
                valves_[valveI].detachInCylinderPatchID().active()
             && valves_[valveI].detachInPortPatchID().active()
             && valves_[valveI].detachFaces().size() > 0
            )
            {
                Info<< "Adding detach boundary for valve "
                    << valveI + 1 << endl;

                const vectorField& areas = Sf().internalField();

                const labelList& df = valves_[valveI].detachFaces();

                boolList flip(df.size(), false);

                const vector& pistonAxis = piston().cs().axis();

                forAll (df, dfI)
                {
                    if (isInternalFace(df[dfI]))
                    {
                        if ((areas[df[dfI]] & pistonAxis) > 0)
                        {
                            flip[dfI] = true;
                        }
                    }
                    else
                    {
                        FatalErrorIn
                        (
                            "void simpleEngineTopoFvMesh::"
                            "addZonesAndModifiers()"
                        )   << "found boundary face in valve detach definition"
                            << " for valve " << valveI + 1
                            << ".  This is not allowed.  Detach faces: "
                            << df << " nInternalFaces: " << nInternalFaces()
                            << abort(FatalError);
                    }
                }

                // Add detach face zone
                fz[nFaceZones] =
                    new faceZone
                    (
                        "detachFaceZoneV" + Foam::name(valveI + 1),
                        df,
                        flip,
                        nFaceZones,
                        faceZones()
                    );
                nFaceZones++;
            }
        }
Пример #24
0
    osg::Node* createCube(unsigned int mask)
    {
        osg::Geode* geode = new osg::Geode;

        osg::Geometry* geometry = new osg::Geometry;
        geode->addDrawable(geometry);

        osg::Vec3Array* vertices = new osg::Vec3Array;
        geometry->setVertexArray(vertices);

        osg::Vec3Array* normals = new osg::Vec3Array;
        geometry->setNormalArray(normals, osg::Array::BIND_PER_VERTEX);

        osg::Vec4Array* colours = new osg::Vec4Array;
        geometry->setColorArray(colours, osg::Array::BIND_OVERALL);
        colours->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));


        osg::Vec3 origin(0.0f,0.0f,0.0f);
        osg::Vec3 dx(2.0f,0.0f,0.0f);
        osg::Vec3 dy(0.0f,1.0f,0.0f);
        osg::Vec3 dz(0.0f,0.0f,1.0f);

        osg::Vec3 px(1.0f,0.0,0.0f);
        osg::Vec3 nx(-1.0f,0.0,0.0f);
        osg::Vec3 py(0.0f,1.0f,0.0f);
        osg::Vec3 ny(0.0f,-1.0f,0.0f);
        osg::Vec3 pz(0.0f,0.0f,1.0f);
        osg::Vec3 nz(0.0f,0.0f,-1.0f);

        if (mask & FRONT_FACE)
        {
            // front face
            vertices->push_back(origin);
            vertices->push_back(origin+dx);
            vertices->push_back(origin+dx+dz);
            vertices->push_back(origin+dz);
            normals->push_back(ny);
            normals->push_back(ny);
            normals->push_back(ny);
            normals->push_back(ny);
        }

        if (mask & BACK_FACE)
        {
            // back face
            vertices->push_back(origin+dy);
            vertices->push_back(origin+dy+dz);
            vertices->push_back(origin+dy+dx+dz);
            vertices->push_back(origin+dy+dx);
            normals->push_back(py);
            normals->push_back(py);
            normals->push_back(py);
            normals->push_back(py);
        }

        if (mask & LEFT_FACE)
        {
            // left face
            vertices->push_back(origin+dy);
            vertices->push_back(origin);
            vertices->push_back(origin+dz);
            vertices->push_back(origin+dy+dz);
            normals->push_back(nx);
            normals->push_back(nx);
            normals->push_back(nx);
            normals->push_back(nx);
        }

        if (mask & RIGHT_FACE)
        {
            // right face
            vertices->push_back(origin+dx+dy);
            vertices->push_back(origin+dx+dy+dz);
            vertices->push_back(origin+dx+dz);
            vertices->push_back(origin+dx);
            normals->push_back(px);
            normals->push_back(px);
            normals->push_back(px);
            normals->push_back(px);
        }

        if (mask & TOP_FACE)
        {
            // top face
            vertices->push_back(origin+dz);
            vertices->push_back(origin+dz+dx);
            vertices->push_back(origin+dz+dx+dy);
            vertices->push_back(origin+dz+dy);
            normals->push_back(pz);
            normals->push_back(pz);
            normals->push_back(pz);
            normals->push_back(pz);
        }

        if (mask & BOTTOM_FACE)
        {
            // bottom face
            vertices->push_back(origin);
            vertices->push_back(origin+dy);
            vertices->push_back(origin+dx+dy);
            vertices->push_back(origin+dx);
            normals->push_back(nz);
            normals->push_back(nz);
            normals->push_back(nz);
            normals->push_back(nz);
        }

        geometry->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, vertices->size()));

        return geode;
    }
void Foam::layerAR::addZonesAndModifiers()
{
    // Add the zones and mesh modifiers to operate piston motion

    if
    (
        pointZones().size() > 0
     || faceZones().size() > 0
     || cellZones().size() > 0
    )
    {
        Info<< "void layerAR::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        if (topoChanger_.size() == 0)
        {
            FatalErrorIn
            (
                "void layerAR::addZonesAndModifiers()"
            )   << "Mesh modifiers not read properly"
                << abort(FatalError);
        }

        setVirtualPistonPosition();
        checkAndCalculate();

        return;
    }

    checkAndCalculate();

    Info<< "Time = " << engTime().theta() << endl
        << "Adding zones to the engine mesh" << endl;

    //fz = 1: faces where layer are added/removed
    //pz = 2: points below the virtual piston faces and head points

    List<pointZone*> pz(2);
    List<faceZone*> fz(1);
    List<cellZone*> cz(0);

    label nPointZones = 0;
    label nFaceZones = 0;

    // Add the piston zone
    if (piston().patchID().active() && offSet() > SMALL)
    {

        // Piston position

        label pistonPatchID = piston().patchID().index();

        scalar zPist = max(boundary()[pistonPatchID].patch().localPoints()).z();

        scalar zPistV = zPist + offSet();

        labelList zone1(faceCentres().size());
        boolList flipZone1(faceCentres().size(), false);
        label nZoneFaces1 = 0;

        bool foundAtLeastOne = false;
        scalar zHigher = GREAT;
        scalar dh = GREAT;
        scalar dl = GREAT;

        forAll (faceCentres(), faceI)
        {
            scalar zc = faceCentres()[faceI].z();
            vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
            scalar dd = n & vector(0,0,1);

            if (dd > 0.1)
            {
                if (zPistV - zc > 0 && zPistV - zc < dl)
                {
                    dl = zPistV - zc;
                }

                if (zc - zPistV > 0 && zc - zPistV < dh)
                {
                    zHigher = zc;
                    dh = zc - zHigher;
                }

                if
                (
                    zc > zPistV - delta()
                    && zc < zPistV + delta()
                )
                {
                    foundAtLeastOne = true;
                    if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
                    {
                        flipZone1[nZoneFaces1] = true;
                    }

                    zone1[nZoneFaces1] = faceI;
                    nZoneFaces1++;
                }
            }
        }
Пример #26
0
void PseudoJet::ScaleMomentum(double factor)
{
    reset_momentum(px() * factor, py() * factor, pz() * factor, e());
}
Пример #27
0
Momentum PseudoJet::Pz() const
{
    return pz() * GeV;
}
Пример #28
0
/*
 *           sum ((xi - x0) ^ 2)
 *variance = ------------------- - (m - x0) ^ 2
 *             sum (ni)
 *
 */
void LapDetector::process(void)
{
    QList<Zone*> filledZones;
    qreal average(0);
    QMap<int, int> classes;

    for (int i(0); i < zones->size(); i++)
    {
        int zsize(zones->at(i)->size());

        for (int j(0); j < zsize; j++)
        {
            Zone* pz(zones->at(i)->at(j));
            qreal disp(pz->dispersion());

            if (! qFuzzyCompare(disp, 0.0))
            {
                filledZones.append(pz);
                average += disp;

                int cl = qRound(disp);
                if (classes.contains(cl))
                {
                    qDebug() << "cl : "<< cl << classes[cl];
                    int& val = classes[cl];
                    val++;
                }
                else
                {
                    classes[cl] = 1;
                }
            }
        }
    }

    QList<int> values(classes.values());
    qSort(values);

    int maxValue(values.last());
    QList<int> keys(classes.keys(maxValue));
    qSort(keys);
    qDebug() << "max : " << maxValue << "keys : " << keys;

    int diff(average);
    int i(0);
    bool found(false);

    while (i < keys.size() && ! found)
    {
        int newDiff = qAbs(average - classes[keys.at(i)]);

        if (i == 0 || diff >= newDiff)
        {
            diff = newDiff;
            i++;
        }
        else
        {
            found = true;
        }
    }

    if (found || i == 1)
        realAvg = keys.at(i - 1);
    else
        realAvg = average;

    qDebug() << "realAvg : " << realAvg;
    this->delimLaps();

}
void Foam::simpleTwoStroke::addZonesAndModifiers()
{
    // Add the zones and mesh modifiers to operate piston motion

    if
    (
        pointZones().size() > 0
        || faceZones().size() > 0
        || cellZones().size() > 0
    )
    {
        Info<< "Time = " << engTime().theta() << endl;
        Info<< "void simpleTwoStroke::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        if (topoChanger_.size() == 0)
        {
            FatalErrorIn
            (
                "void simpleTwoStroke::addZonesAndModifiers()"
            )   << "Mesh modifiers not read properly"
                << abort(FatalError);
        }

        setVirtualPistonPosition();
        checkAndCalculate();

        return;


    }

    Info << "checkAndCalculate()" << endl;
    checkAndCalculate();

    Info<< "Time = " << engTime().theta() << endl
        << "Adding zones to the engine mesh" << endl;


    //fz = 4: virtual piston, outSidePort, insidePort, cutFaceZone
    //pz = 2: piston points, cutPointZone
    //cz = 1: moving mask

    List<pointZone*> pz(3);
    List<faceZone*> fz(4);
    List<cellZone*> cz(1);

    label nPointZones = 0;
    label nFaceZones = 0;
    label nCellZones = 0;

    // Add the piston zone
    if (piston().patchID().active())
    {

        // Piston position

        Info << "Adding face zone for piston layer addition/removal" << endl;

        label pistonPatchID = piston().patchID().index();

        scalar zPist =
            max(boundary()[pistonPatchID].patch().localPoints()).z();

        scalar zPistV = zPist + offSet();

        labelList zone1(faceCentres().size());
        boolList flipZone1(faceCentres().size(), false);
        label nZoneFaces1 = 0;

        bool foundAtLeastOne = false;
        scalar zHigher = GREAT;
        scalar dh = GREAT;
        scalar dl = GREAT;

        forAll (faceCentres(), faceI)
        {
            // The points have to be in the cylinder and not in the ports....

            scalar zc = faceCentres()[faceI].z();

            scalar xc = faceCentres()[faceI].x();
            scalar yc = faceCentres()[faceI].y();

            vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
            scalar dd = n & vector(0,0,1);

            if(sqrt(sqr(xc)+sqr(yc)) <  0.5 * engTime().bore().value())
            {
                if (dd > 0.1)
                {
                    if (zPistV - zc > 0 && zPistV - zc < dl)
                    {
                        dl = zPistV - zc;
                    }

                    if (zc - zPistV > 0 && zc - zPistV < dh)
                    {
                        zHigher = zc;
                        dh = zc - zHigher;
                    }

                    if
                    (
                        zc > zPistV - delta()
                        && zc < zPistV + delta()
                    )
                    {
                        foundAtLeastOne = true;
                        if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
                        {
                            flipZone1[nZoneFaces1] = true;
                        }

                        zone1[nZoneFaces1] = faceI;
                        nZoneFaces1++;
                    }
                }
            }
        }
Пример #30
0
void test_fire() {
    BSArenaKey ky(10, legend);
    BSArenaPuzzle pz(10, legend);
    BSArena::result r;

    int c(0);
    time_t st;
    st = time(&st);
    int error(-1);

//    std::ifstream file("logic-demo.log");
    std::ofstream file("logic-demo.log");
//    std::streambuf* cout_sbuf = std::cout.rdbuf(); // save original sbuf
    std::cout.rdbuf(file.rdbuf());

    while(error == -1) {

        file.seekp(0);
        file << "OK";

        ky.load_legend(legend);
        ky.auto_setup();
        pz.load_legend(legend);
        pz.clean();

        ++c;
        long dt = time(NULL) - st;

        std::cerr << "=======" <<
                     " (count=" << c << "; dt=" << dt << ") " <<
                     "==========" << std::endl;

        for (int i(0); i<1000; ++i) {
            file << "\n\n=======" << i <<
                         " (count=" << c << "; dt=" << dt << ") " <<
                         "==========\n\n" << std::endl;

            BSPoint p = pz.find_fire();
            file << "======FIRE TO " << p <<
                         " (count=" << c << "; dt=" << dt << ") " <<
                         std::endl;
            r = ky.apply_fire(p);
            file << "======RESULT " << r <<
                         " (count=" << c << "; dt=" << dt << ") " <<
                         std::endl;

            switch(r) {
                case BSArena::r_milk:            // мимо
                    break;
                case BSArena::r_already_fired:   // сюда уже стреляли
                    error = r;
                    break;
                case BSArena::r_wasted_effort:   // мимо, но вам и так должно быть известно, что здесь ничего нет
                    error = r;
                    break;
                case BSArena::r_continue_in_that_direction: // ранен, продолжайте добивать
                    break;
                case BSArena::r_drowned:         // утонул
                    break;
                case BSArena::r_game_over:       // добит последний, игра окончена
                    break;
                default:
                    error = r;
                    break;
            }

            if (error != -1) break;

            pz.apply_result(p, r);

            if (r == BSArena::r_game_over) break;
        }
        if (r != BSArena::r_game_over) {
            file << "\n====== 1000 (!!!) ======\n";
            break;
        }
        if (error != -1) {
            file << "\n====== error(r) = " << error << " (!!!) ======\n";
            break;
        }
        file << "DONE.\n\n\n";
    }

    file << "DONE AND EXIT (NORMAL / ERROR FOUND).\n\n\n";

}