Ejemplo n.º 1
0
TLens::TLens(const Math::VectorPair3 &p,
             double roc0, double ap_radius0,
             double roc1, double ap_radius1,
             double thickness0,
             const QSharedPointer<TGlass> &glass0,
             const QSharedPointer<TGlass> &env)
    : TGroup(p),
      _last_pos(0),
      _surfaces(_surfaces_storage),
      _next_mat(env)
{
    _surfaces.reserve(2);
    add_surface(roc0, ap_radius0, thickness0, glass0);
    add_surface(roc1, ap_radius1, 0, env);
}
Ejemplo n.º 2
0
void add_objects_for_new_grid()
{
	reset_old_geometry();
	add_void_maps();
	add_void_contours();
	if(!showOneSurface || numberOfSurfaces<1 ) add_surface();
}
Ejemplo n.º 3
0
TLens::TLens(const Math::VectorPair3 &p,
             const QSharedPointer<TCurveBase> &curve0,
             const QSharedPointer<TShapeBase> &shape0,
             const QSharedPointer<TCurveBase> &curve1,
             const QSharedPointer<TShapeBase> &shape1,
             double thickness0,
             const QSharedPointer<TGlass> &glass0,
             const QSharedPointer<TGlass> &env)
    : TGroup(p),
      _last_pos(0),
      _surfaces(_surfaces_storage),
      _next_mat(env)
{
    _surfaces.reserve(2);
    add_surface(curve0, shape0, thickness0, glass0);
    add_surface(curve1, shape1, 0, env);
}
	void surface_fractal_terrain::generate_mesh(const std::vector<std::vector<double> > &height, int size, double sidelen) {
		double scale = sidelen / size, delta = 1.0 / size;
		std::vector<point3D> vertices;

#define __id(i, j) ((i) * (size + 1) + (j))
		for (int i = 0; i <= size; ++i) {
			for (int j = 0; j <= size; ++j) {
				vertices.push_back(point3D(i * scale, j * scale, height[i][j]));
			}
		}
		setup_vertex(vertices);
		for (int i = 0; i < size; ++i) {
			for (int j = 0; j < size; ++j) {
				double u = i * delta, v = j * delta;

				add_surface(__id(i, j), __id(i + 1, j), __id(i, j + 1)).set_UV(point2D(u, v), point2D(u + delta, v), point2D(u, v + delta));
				add_surface(__id(i + 1, j), __id(i + 1, j + 1), __id(i, j + 1)).set_UV(point2D(u + delta, v), point2D(u + delta, v + delta), point2D(u, v + delta));
			}
		}
#undef __id
		setup_tree();
		interpolate_normal();
	}
Ejemplo n.º 5
0
void Define_Grid()
{
	free_grid_all();
	/*
	free_contours_all();
	free_planes_mapped_all();
	*/

	grid = define_grid(NumPoints,limits);
	if(grid)
	{
		if(!showOneSurface || numberOfSurfaces<1 ) add_surface();
		free_iso_all();
		limits.MinMax[0][3] = grid->limits.MinMax[0][3];
		limits.MinMax[1][3] = grid->limits.MinMax[1][3];
	}
}
Ejemplo n.º 6
0
void Define_Iso(gdouble isovalue)
{
	free_iso_all();
	set_status_label_info("IsoSurface","Computing");

	/* printf("DefineIso newSUrface = %d\n",newSurface);*/
	if(grid)
	{
		if(newSurface || numberOfSurfaces<1 ) 
			if(!showOneSurface || numberOfSurfaces<1 ) add_surface();
		newSurface = FALSE;
		isopositive=define_iso_surface(grid,isovalue, grid->mapped );
		if(fabs(isovalue)>1e-13)
		isonegative=define_iso_surface(grid,-isovalue, grid->mapped );
		if(isopositive != NULL || isonegative != NULL) set_status_label_info("IsoSurface","Ok");
	}
	RebuildSurf = TRUE;
}
Ejemplo n.º 7
0
unsigned int TLens::add_surface(double roc, double radius,
                                double thickness,
                                const QSharedPointer<TGlass> &glass)
{
    TCurveBase* curve;;

    if (roc == 0.)
        curve = &flat;
    else
        curve = new TSphere(roc);

    TDisk* disk = new TDisk(radius);

    QSharedPointer<TCurveBase> pCurve(curve);
    QSharedPointer<TDisk> pDisk(disk);

    return add_surface(pCurve, pDisk, thickness, glass);
}
Ejemplo n.º 8
0
meshmap_t Greedy::make_mesh(const Chunk& chunk)
{
	meshmap_t meshes;

	add_surface(chunk, meshes, surface, Plane::XY, Side::top);
	add_surface(chunk, meshes, surface, Plane::XY, Side::bottom);
	add_surface(chunk, meshes, surface, Plane::XZ, Side::top);
	add_surface(chunk, meshes, surface, Plane::XZ, Side::bottom);
	add_surface(chunk, meshes, surface, Plane::YZ, Side::top);
	add_surface(chunk, meshes, surface, Plane::YZ, Side::bottom);

	return meshes;
}
Ejemplo n.º 9
0
int		set_philo_sdl_text(t_philo *philo, char *text)
{
  SDL_Surface	*sdl_black;
  SDL_Surface	*sdl_text;

  sdl_black = SDL_CreateRGBSurface(0, SCREEN_WIDTH,
				   philo->window->fontSize + 1,
				   32, 0, 0, 0, 0);
  if (sdl_black == NULL)
    return (1);
  add_surface(philo->window, sdl_black, 1,
	      philo->id * philo->window->fontSize + 1);
  SDL_FreeSurface(sdl_black);
  sdl_text = write_text(philo->window,
			text, 1,
			philo->id * philo->window->fontSize + 1);
  SDL_FreeSurface(sdl_text);
  SDL_Flip(philo->window->screen);
  return (0);
}
Ejemplo n.º 10
0
void setup() {
   set_light(50);
   set_theft_handler( HOSPITAL );
   set_save_file("%savedir%/%N%bed4");

/* DESCRIPTIONS */

   set_orientation(%orientation%);
  set_quit_handler(%out%);

   set_short("bedroom");
   set_base_desc( "a small bedroom" );
   add_surface( "floor", "finished pine board" );
   add_surface( "ceiling", "plain plaster" );
   add_surface( "%0% wall", "plain plaster" );
   add_surface( "%2% wall", "plain plaster" );
   add_surface( "%4% wall", "plain plaster" );
   add_surface( "%6% wall", "plain plaster" );

/* EXITS */

   add_exit( "%4%", PATH +"%N%landing2", "door" );
   modify_exit("%4%", ({ "door short", "livingroom door" }));
Ejemplo n.º 11
0
Archivo: step.c Proyecto: AkaBlood/ogs5
/* ---------------------------------------------------------------------- */
int
P_step (LDBLE step_fraction)
/* ---------------------------------------------------------------------- */
{
/*
 *   zero global solution, add solution or mixture, add exchange,
 *   add surface, add gas phase, add solid solutions,
 *   set temperature, and add reaction. 
 *   Ensure all elements
 *   included in any of these are present in small amounts.
 *   Save result as n_user -1.
 */
  LDBLE difftemp;
  int step_number;
  struct pp_assemblage *pp_assemblage_save = NULL;
  struct s_s_assemblage *s_s_assemblage_save = NULL;

  if (svnid == NULL)
    fprintf (stderr, " ");

/*
 *   Zero out global solution data
 */

  xsolution_zero ();
/*
 *   Set reaction to zero
 */
  step_x = 0.0;
  step_number = reaction_step;
/*
 *   Mixing or solution
 */
  if (use.mix_ptr != NULL)
  {
    add_mix (use.mix_ptr);
  }
  else if (use.solution_ptr != NULL)
  {
    add_solution (use.solution_ptr, 1.0, 1.0);
  }
  else
  {
    input_error++;
    error_msg ("Neither mixing nor an initial solution have "
	       "been defined in reaction step.", STOP);
  }
/*
 *   Reaction
 */
  if (use.irrev_ptr != NULL)
  {
    add_reaction (use.irrev_ptr, step_number, step_fraction);
  }
/*
 *   Kinetics
 */
  if (use.kinetics_ptr != NULL)
  {
    add_kinetics (use.kinetics_ptr);
    /*
       master_ptr =master_bsearch("S(6)");
       output_msg(OUTPUT_MESSAGE,"Added kinetics, S(6) %e\n", master_ptr->total);
       master_ptr =master_bsearch("S");
       output_msg(OUTPUT_MESSAGE,"Added kinetics, S %e\n", master_ptr->total);
     */
  }
/*
 *   Exchange
 */
  if (use.exchange_ptr != NULL)
  {
    add_exchange (use.exchange_ptr);
  }
/*
 *   Surface
 */
  if (use.surface_ptr != NULL)
  {
    add_surface (use.surface_ptr);
  }
/*
 *   Gases
 */
  if (use.gas_phase_ptr != NULL)
  {
    add_gas_phase (use.gas_phase_ptr);
  }
/*
 *   Temperature
 */
  if (use.temperature_ptr != NULL)
  {
    add_temperature (use.temperature_ptr, step_number);
  }
  if ((state == TRANSPORT) && (transport_step != 0) &&
      (cell > 0) && (cell != count_cells + 1))
  {
    difftemp = tc_x - cell_data[cell - 1].temp;
    cell_data[cell - 1].temp += difftemp / tempr;
    tc_x = cell_data[cell - 1].temp;
  }
/*
 *   Pure phases and solid solutions are added to avoid
 *   zero or negative concentrations
 */
/*
 *   Pure phases
 */
  if (use.pp_assemblage_ptr != NULL)
  {
    pp_assemblage_save =
      (struct pp_assemblage *) PHRQ_malloc (sizeof (struct pp_assemblage));
    if (pp_assemblage_save == NULL)
      malloc_error ();
    pp_assemblage_copy (use.pp_assemblage_ptr, pp_assemblage_save,
			use.pp_assemblage_ptr->n_user);
    add_pp_assemblage (use.pp_assemblage_ptr);
  }
/*
 *   Solid solutions
 */
  if (use.s_s_assemblage_ptr != NULL)
  {
    s_s_assemblage_save =
      (struct s_s_assemblage *) PHRQ_malloc (sizeof (struct s_s_assemblage));
    if (s_s_assemblage_save == NULL)
      malloc_error ();
    s_s_assemblage_copy (use.s_s_assemblage_ptr, s_s_assemblage_save,
			 use.s_s_assemblage_ptr->n_user);
    add_s_s_assemblage (use.s_s_assemblage_ptr);
  }
/*
 *   Check that elements are available for gas components,
 *   pure phases, and solid solutions
 */
  if (use.gas_phase_ptr != NULL)
  {
    gas_phase_check (use.gas_phase_ptr);
  }
  if (use.pp_assemblage_ptr != NULL)
  {
    pp_assemblage_check (use.pp_assemblage_ptr);
  }
  if (use.s_s_assemblage_ptr != NULL)
  {
    s_s_assemblage_check (use.s_s_assemblage_ptr);
  }
/*
 *   Check that element moles are >= zero
 */
  if (solution_check () == MASS_BALANCE)
  {
    /* reset moles and deltas */
    if (use.pp_assemblage_ptr != NULL)
    {
      pp_assemblage_free (use.pp_assemblage_ptr);
      pp_assemblage_copy (pp_assemblage_save, use.pp_assemblage_ptr,
			  use.pp_assemblage_ptr->n_user);
      pp_assemblage_free (pp_assemblage_save);
      pp_assemblage_save =
	(struct pp_assemblage *) free_check_null (pp_assemblage_save);
    }
    if (use.s_s_assemblage_ptr != NULL)
    {
      s_s_assemblage_free (use.s_s_assemblage_ptr);
      s_s_assemblage_copy (s_s_assemblage_save, use.s_s_assemblage_ptr,
			   use.s_s_assemblage_ptr->n_user);
      s_s_assemblage_free (s_s_assemblage_save);
      s_s_assemblage_save =
	(struct s_s_assemblage *) free_check_null (s_s_assemblage_save);
    }
    return (MASS_BALANCE);
  }
/*
 *   Copy global into solution n_user = -1
 */
  xsolution_save (-1);
  step_save_surf (-1);
  step_save_exch (-1);
/*
 *   Clean up temporary space
 */
  if (pp_assemblage_save != NULL)
  {
    pp_assemblage_free (pp_assemblage_save);
    pp_assemblage_save =
      (struct pp_assemblage *) free_check_null (pp_assemblage_save);
  }
  if (s_s_assemblage_save != NULL)
  {
    s_s_assemblage_free (s_s_assemblage_save);
    s_s_assemblage_save =
      (struct s_s_assemblage *) free_check_null (s_s_assemblage_save);
  }
  return (OK);
}
Ejemplo n.º 12
0
//*******************************************
void Recpack::EMINDplate::create(const EVector& uaxis, const EVector& vaxis,
				double U, double V, double W, 
				double flange_width, double flange_height) {
  //*****************************************


  const double Pi = 4*atan(1);
  double t22 = tan(Pi/8.);
  double s22 = 1./cos(Pi/8.);

  _axis["U"] = uaxis;
  _axis["V"] = vaxis;
  EVector waxis = crossprod(uaxis, vaxis);
  _axis["W"] = waxis;

  _parameters["U"] = fabs(U);
  _parameters["V"] = fabs(V);
  _parameters["W"] = fabs(W);
  _parameters["fw"] = flange_width;
  _parameters["fh"] = flange_height;

  double UU = fabs(U);
  double VV = fabs(V);
  double WW = fabs(W);
  
  fw = flange_width;
  fh = flange_height - UU;
  
  EVector deltaU = uaxis*UU;
  EVector deltaV = vaxis*VV;
  EVector deltaW = waxis*WW;
  double rt2 = sqrt(2.0);

  EVector deltaS = (uaxis * (UU + VV*t22)/2. + vaxis * (VV + UU*t22)/2.);
  EVector deltaT =(-uaxis * (UU + VV*t22)/2. + vaxis * (VV + UU*t22)/2.);
  double SS = 0.5*sqrt((UU*UU + VV*VV)*s22*s22 - 4*UU*VV*t22);

  EVector saxis = deltaS/sqrt(dot(deltaS,deltaS));
  EVector taxis = deltaT/sqrt(dot(deltaT,deltaT));

  EVector deltaQ = deltaS - VV/UU* fw/(rt2)*taxis;
  EVector deltaR = deltaT - VV/UU* fw/(rt2)*saxis;
  double QQ = sqrt(dot(deltaQ,deltaQ));
  double RR = sqrt(dot(deltaR,deltaR));
  EVector qaxis = 1./QQ * deltaQ;
  EVector raxis = 1./RR * deltaR;


  // S1 bottom
  add_surface("outer", new Rectangle(_position-deltaV,vaxis,waxis,WW,t22*VV + UU/2.));
  // S2 top
  add_surface("outer", new Rectangle(_position+deltaV,vaxis,waxis,WW,t22*VV + UU/2.));
  // S3 bottom-side -
  add_surface("outer", new Rectangle(_position-deltaS,saxis,waxis,WW,t22*VV));
  // S4 bottom-side +
  add_surface("outer", new Rectangle(_position-deltaT,taxis,waxis,WW,t22*VV));
  // S5 top-side +
  add_surface("outer", new Rectangle(_position+deltaQ,qaxis,taxis,
				     t22*VV + fw/rt2, WW));
  // S6 top-side -
  add_surface("outer", new Rectangle(_position+deltaR,raxis,saxis,
				     t22*VV + fw/rt2, WW));
  // S7 side - 
  add_surface("outer", new Rectangle(_position-deltaU-vaxis*(t22*UU-fh)/2.,
				     uaxis,vaxis,(t22*VV + fh)/2.0,WW));
  // S8 side + 
  add_surface("outer", new Rectangle(_position+deltaU-vaxis*(t22*UU-fh)/2.,
				     uaxis,vaxis,(t22*VV + fh)/2.0,WW));

  // S9 back
  add_surface("outer", new MINDsection(_position-deltaW,waxis,uaxis,UU,VV,fw,fh));
  // S10 front
  add_surface("outer", new MINDsection(_position+deltaW,waxis,uaxis,UU,VV,fw,fh));
  
  // S11 flange tip +
  add_surface("outer", new Rectangle(_position+ uaxis*(UU + fw) + 
				     vaxis*0.5*(VV*t22 - fw + fh), 
				     uaxis, vaxis,0.5*(VV*t22 - fw - fh),
				     WW));
  // S12 flange tip -
  add_surface("outer", new Rectangle(_position- uaxis*(UU + fw) + 
				     vaxis*0.5*(VV*t22 - fw + fh), 
				     uaxis, vaxis,0.5*(VV*t22 - fw - fh),
				     WW));
  // S13 flange bottom + 
  add_surface("outer", new Rectangle(_position + uaxis*(UU + fw/2.) + 
				     vaxis*fh, vaxis, uaxis, fw/2., WW));
  // S13 flange bottom -
  add_surface("outer", new Rectangle(_position - uaxis*(UU + fw/2.) + 
				     vaxis*fh, vaxis, uaxis, fw/2., WW));
  // _size = uaxis*(UU + fw) + vaxis*VV + waxis*WW;

}
Ejemplo n.º 13
0
bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {

	String sname = p_name;

	if (p_name == "blend_shape/names") {

		PoolVector<String> sk = p_value;
		int sz = sk.size();
		PoolVector<String>::Read r = sk.read();
		for (int i = 0; i < sz; i++)
			add_blend_shape(r[i]);
		return true;
	}

	if (p_name == "blend_shape/mode") {

		set_blend_shape_mode(BlendShapeMode(int(p_value)));
		return true;
	}

	if (sname.begins_with("surface_")) {

		int sl = sname.find("/");
		if (sl == -1)
			return false;
		int idx = sname.substr(8, sl - 8).to_int() - 1;
		String what = sname.get_slicec('/', 1);
		if (what == "material")
			surface_set_material(idx, p_value);
		else if (what == "name")
			surface_set_name(idx, p_value);
		return true;
	}

	if (!sname.begins_with("surfaces"))
		return false;

	int idx = sname.get_slicec('/', 1).to_int();
	String what = sname.get_slicec('/', 2);

	if (idx == surfaces.size()) {

		//create
		Dictionary d = p_value;
		ERR_FAIL_COND_V(!d.has("primitive"), false);

		if (d.has("arrays")) {
			//old format
			ERR_FAIL_COND_V(!d.has("morph_arrays"), false);
			add_surface_from_arrays(PrimitiveType(int(d["primitive"])), d["arrays"], d["morph_arrays"]);

		} else if (d.has("array_data")) {

			PoolVector<uint8_t> array_data = d["array_data"];
			PoolVector<uint8_t> array_index_data;
			if (d.has("array_index_data"))
				array_index_data = d["array_index_data"];

			ERR_FAIL_COND_V(!d.has("format"), false);
			uint32_t format = d["format"];

			uint32_t primitive = d["primitive"];

			ERR_FAIL_COND_V(!d.has("vertex_count"), false);
			int vertex_count = d["vertex_count"];

			int index_count = 0;
			if (d.has("index_count"))
				index_count = d["index_count"];

			Vector<PoolVector<uint8_t> > blend_shapes;

			if (d.has("blend_shape_data")) {
				Array blend_shape_data = d["blend_shape_data"];
				for (int i = 0; i < blend_shape_data.size(); i++) {
					PoolVector<uint8_t> shape = blend_shape_data[i];
					blend_shapes.push_back(shape);
				}
			}

			ERR_FAIL_COND_V(!d.has("aabb"), false);
			AABB aabb = d["aabb"];

			Vector<AABB> bone_aabb;
			if (d.has("skeleton_aabb")) {
				Array baabb = d["skeleton_aabb"];
				bone_aabb.resize(baabb.size());

				for (int i = 0; i < baabb.size(); i++) {
					bone_aabb[i] = baabb[i];
				}
			}

			add_surface(format, PrimitiveType(primitive), array_data, vertex_count, array_index_data, index_count, aabb, blend_shapes, bone_aabb);
		} else {
			ERR_FAIL_V(false);
		}

		if (d.has("material")) {

			surface_set_material(idx, d["material"]);
		}
		if (d.has("name")) {
			surface_set_name(idx, d["name"]);
		}

		return true;
	}

	return false;
}
Ejemplo n.º 14
0
int main ( int argc, char** argv )
{
	std::cout << "Starting\n";
    initalize();

    //TODO add resource load error handling
    add_surface("spaceb", load_surface("gray_space.png",1)   );
    add_surface("spacem", load_surface("gray_space.png",1)   );
    add_surface("spacef", load_surface("gray_space.png",1)   );

    for(int i=-2; i < 20+2; i++)
        meta::objects.push_back(new psrect_static(200*i, 200, 200, 200));
//meta::objects.push_back(new psrect_static(320, 20, 320, 20));

//meta::objects.push_back(new psrect_static(0, -400,1, 1000));
//meta::objects.push_back(new psrect_static(1000, -400, 1, 1000));

    meta::objects.push_back(new rocket(2000,-100, 50,70));

    //load_map("test.json");

    float32 timeStep = 1.0f / 30.0f;
    int32 velocityIterations = 6;
    int32 positionIterations = 2;

    FPSmanager manager;
    SDL_initFramerate(&manager);
    SDL_setFramerate(&manager, 30);

    // program main loop
    bool done = false;
    while (!done)
    {
        SDL_framerateDelay(&manager);

        // message processing loop
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            // check for messages
            switch (event.type)
            {
                // exit if the window is closed
            case SDL_QUIT:
                done = true;
                break;

                // check for keypresses
            case SDL_KEYDOWN:
                // exit if ESCAPE is pressed
                if (event.key.keysym.sym == SDLK_ESCAPE)
                    done = true;
                break;


            } // end switch
        } // end of message processing

        // DRAWING STARTS HERE
        // clear screen
        //SDL_FillRect(meta::screen, 0, SDL_MapRGB(meta::screen->format, 0, 0, 0 ));
        SDL_FillRect(meta::screen, 0, SDL_MapRGB(meta::screen->format, meta::background_red , meta::background_green, meta::background_blue ));

        draw_background();

        // Instruct the world to perform a single step of simulation.
        // It is generally best to keep the time step and iterations fixed.
        meta::world.Step(timeStep, velocityIterations, positionIterations);

        update_objects();
        meta::world.DrawDebugData();

        // DRAWING ENDS HERE

        // finally, update the screen :)
        SDL_Flip(meta::screen);
    } // end main loop

    // all is well ;)
    printf("Exited cleanly\n");
    return 0;
}
Ejemplo n.º 15
0
bool Mesh::_set(const StringName& p_name, const Variant& p_value) {

	String sname=p_name;

	if (p_name=="morph_target/names") {

		DVector<String> sk=p_value;
		int sz = sk.size();
		DVector<String>::Read r = sk.read();
		for(int i=0;i<sz;i++)
			add_morph_target(r[i]);
		return true;
	}

	if (p_name=="morph_target/mode") {

		set_morph_target_mode(MorphTargetMode(int(p_value)));
		return true;
	}

	if (sname.begins_with("surface_")) {

		int sl=sname.find("/");
		if (sl==-1)
			return false;
		int idx=sname.substr(8,sl-8).to_int()-1;
		String what = sname.get_slice("/",1);
		if (what=="material")
			surface_set_material(idx,p_value);
		else if (what=="name")
			surface_set_name(idx,p_value);
		return true;
	}

	if (sname=="custom_aabb/custom_aabb") {

		set_custom_aabb(p_value);
		return true;
	}

	if (!sname.begins_with("surfaces"))
		return false;


	int idx=sname.get_slice("/",1).to_int();
	String what=sname.get_slice("/",2);

	if (idx==surfaces.size()) {

		if (what=="custom") {
			add_custom_surface(p_value);
			return true;

		}		

		//create
		Dictionary d=p_value;
		ERR_FAIL_COND_V(!d.has("primitive"),false);
		ERR_FAIL_COND_V(!d.has("arrays"),false);
		ERR_FAIL_COND_V(!d.has("morph_arrays"),false);

		bool alphasort = d.has("alphasort") && bool(d["alphasort"]);


		add_surface(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"],alphasort);
		if (d.has("material")) {

			surface_set_material(idx,d["material"]);
		}
		if (d.has("name")) {
			surface_set_name(idx,d["name"]);
		}


		return true;
	}

	if (what=="custom_aabb") {

		surface_set_custom_aabb(idx,p_value);
		return true;
	}

	return false;
}