Esempio n. 1
0
void
trace_component(struct image *img, struct image *status, struct component *c, int y, int x)
{
	struct vertex *u;
	CHAR ch;

	if (x < 0 || x >= img->w)          return;
	if (y < 0 || y >= img->h)          return;

	ch = img->d[y][x];
	if (status->d[y][x] != ST_EMPTY)   return;

	switch (ch) {
	case '-':
		if (!c) c = create_component(&connected_components);
		++seen;
		status->d[y][x] = seen;
		u = add_vertex_to_component(c, y, x, ch);
		printf("%c (%d,%d)\n", ch, y, x);
		trace_east(img, status, c, u, y, x+1);
		trace_west(img, status, c, u, y, x-1);
		break;
	case '|':
		if (!c) c = create_component(&connected_components);
		++seen;
		status->d[y][x] = seen;
		u = add_vertex_to_component(c, y, x, ch);
		printf("%c (%d,%d)\n", ch, y, x);
		trace_north(img, status, c, u, y-1, x);
		trace_south(img, status, c, u, y+1, x);
		break;
	}
}
Esempio n. 2
0
void RightHandSide2D::config_sfs_model()
{
  std::string builder_name = m_sfs_model_type;
  if (! boost::algorithm::starts_with(builder_name,"cf3." ) )
    builder_name = "cf3.dcm.equations.les."+builder_name;
  if (m_sfs_model) remove_component(*m_sfs_model);
  m_sfs_model = create_component("sfs_model",builder_name)->handle< EddyViscosityModel >();
}
Esempio n. 3
0
void Terms1D::config_riemann_solver()
{
  std::string builder_name = m_riemann_solver_type;
  if (! boost::algorithm::starts_with(builder_name,"cf3." ) )
    builder_name = "cf3.sdm.equations.navierstokes."+builder_name+"1D";
  if (m_riemann_solver) remove_component(*m_riemann_solver);
  m_riemann_solver = create_component("riemann_solver",builder_name)->handle< solver::RiemannSolver<Terms1D> >();
}
Esempio n. 4
0
void RightHandSide1D::config_riemann_solver()
{
  std::string builder_name = m_riemann_solver_type;
  if (! boost::algorithm::starts_with(builder_name,"cf3." ) )
    builder_name = "cf3.dcm.equations.euler."+builder_name+"1D";

  if (m_riemann_solver) remove_component(*m_riemann_solver);
  m_riemann_solver = create_component("riemann_solver",builder_name)->handle< solver::RiemannSolver<DATA,NDIM,NEQS> >();
}
Esempio n. 5
0
 dataflow(
     naming::id_type const & target
   , A0 && a0
 )
     : base_type(
         create_component(target
           , std::forward<A0>( a0 )
           , typename Action::direct_execution()
         )
     )
 {
 }
Esempio n. 6
0
void	init_preview(void)
{
	fprintf(stderr, "initializing preview\n");
	create_component(PREVIEW, &(g_data.preview), "preview");
	configure_preview_input();
	set_preview_input_port();
	create_pool_on_port(
			&(g_data.preview_input_port_pool),
			g_data.preview_input_port,
			preview_buffer_callback,
			"preview");
	flush_buffers();
}
Esempio n. 7
0
void	init_camera(void)
{
	fprintf(stderr, "initializing camera\n");
	create_component(CAMERA, &(g_data.camera), "camera");
	fetch_ports(g_data.camera);
	configure_camera(g_data.camera);
	set_preview_port(g_data.camera_preview_port);
	set_video_port(g_data.camera_video_port);
	create_pool_on_port(
			&(g_data.camera_video_port_pool),
			g_data.camera_video_port,
			video_buffer_callback,
			"video");
	enable_component(g_data.camera, "camera");
}
Esempio n. 8
0
/**
 * Creates a component for the specified attribute.
 *
 * This function will create the component if it doesn't already exist;
 * it aborts on error.
 *
 * @see create_component
 *
 * @param attr  The attribute of the component to create.
 * @param cid   The component ID of the component to create.
 */
void
makeall_make_component(Attribute *attr, ComponentID cid)
{
  int state;

  if (! component_ok(attr, cid)) {

    printf(" + creating %s ... ", cid_name(cid));
    fflush(stdout);
    (void) create_component(attr, cid);

    state = component_state(attr, cid);
    if (!(state == ComponentLoaded || state == ComponentUnloaded)) {
      printf("FAILED\n");
      fprintf(stderr, "ERROR. Aborted.\n");
      exit(1);
    }

    printf("OK\n");
  }

}
Esempio n. 9
0
solver::Action& InitialConditions::create_initial_condition(const std::string& name, const std::string& type, const std::vector<URI>& regions)
{
  Handle<solver::Action> ic = create_component(name,type)->handle<solver::Action>();

  Handle<Field> solution = follow_link(solver().field_manager().get_child(sdm::Tags::solution()))->handle<Field>();

  ic->options().set( sdm::Tags::solver() , m_solver);
  ic->options().set( sdm::Tags::mesh(), m_mesh);
  ic->options().set( "solution_field", solution);

  if( regions.empty() ) // if user did not specify, then use the one from the solver
  {
    ic->options().set("regions" , solver().options().value< std::vector<common::URI> >("regions") );
  }
  else
  {
    ic->options().set("regions" , regions);
  }

  ic->options().set( sdm::Tags::physical_model() , m_physical_model);

  return *ic;
}
Esempio n. 10
0
/**
 * Ensures that a component is loaded and ready.
 *
 * The state of the component specified should be ComponentLoaded
 * once this function has run (assuming all is well). If the
 * component is unloaded, the function will try to load it. If the
 * component is defined, the function MAY try to create it. If the
 * component is undefined, nothing will be done.
 *
 * There are flags in attributes.c that control the behaviour of
 * this function (e.g. if failure to ensure causes the program
 * to abort).
 *
 * @see CL_ENSURE_COMPONENT_KEEP_SILENT
 * @see CL_ENSURE_COMPONENT_EXITS
 * @see CL_ENSURE_COMPONENT_ALLOW_CREATION
 *
 * @param attribute     The Attribute object to work with.
 * @param cid           The identifier of the Component to "ensure".
 * @param try_creation  Boolean. True = attempt to create a
 *                      component that does not exist. False = don't.
 *                      This behaviour only applies when
 *                      ALLOW_COMPONENT CREATION is defined; otherwise
 *                      component creation will never be attempted.
 * @return              A pointer to the specified component (or NULL
 *                      if the component cannot be "ensured").
 */
Component *
ensure_component(Attribute *attribute, ComponentID cid, int try_creation)
{
  Component *comp = NULL;
  
  if ((comp = attribute->any.components[cid]) == NULL) {

    /*  component is undeclared */
    fprintf(stderr, "attributes:ensure_component(): Warning:\n"
            "  Undeclared component: %s\n", cid_name(cid));
#ifdef CL_ENSURE_COMPONENT_EXITS
    exit(1);
#endif
    return NULL;
  }
  else {
    switch (comp_component_state(comp)) {

    case ComponentLoaded:
      /*  already here, so do nothing */
      break;

    case ComponentUnloaded:
      (void) load_component(attribute, cid); /* try to load the component */
      if (comp_component_state(comp) != ComponentLoaded) {
#ifndef CL_ENSURE_COMPONENT_KEEP_SILENT
        fprintf(stderr, "attributes:ensure_component(): Warning:\n"
                "  Can't load %s component of %s\n", 
                cid_name(cid), attribute->any.name);
#endif
#ifdef CL_ENSURE_COMPONENT_EXITS
        exit(1);
#endif
        return NULL;
      }
      break;

    case ComponentDefined:        /*  try to create the component */

      if (try_creation != 0) {

#ifdef CL_ENSURE_COMPONENT_ALLOW_CREATION

        (void) create_component(attribute, cid);
        if (comp_component_state(comp) != ComponentLoaded) {
#ifndef CL_ENSURE_COMPONENT_KEEP_SILENT
          fprintf(stderr, "attributes:ensure_component(): Warning:\n"
                  "  Can't load or create %s component of %s\n", 
                  cid_name(cid), attribute->any.name);
#endif
#ifdef CL_ENSURE_COMPONENT_EXITS
          exit(1);
#endif
          return NULL;
        }
#else
        fprintf(stderr, "Sorry, but this program is not set up to allow the\n"
                "creation of corpus components. Please refer to the manuals\n"
                "or use the ''makeall'' tool.\n");
#ifdef CL_ENSURE_COMPONENT_EXITS
        exit(1);
#endif
        return NULL;
#endif

      }
      else {
#ifndef CL_ENSURE_COMPONENT_KEEP_SILENT
        fprintf(stderr, "attributes:ensure_component(): Warning:\n"
                "  I'm not allowed to create %s component of %s\n", 
                  cid_name(cid), attribute->any.name);
#endif
#ifdef CL_ENSURE_COMPONENT_EXITS
        exit(1);
#endif
        return NULL;
      }
      break;

    case ComponentUndefined:      /*  don't have this, -> error */
      fprintf(stderr, "attributes:ensure_component(): Warning:\n"
              "  Can't ensure undefined/illegal %s component of %s\n", 
              cid_name(cid), attribute->any.name);
#ifdef CL_ENSURE_COMPONENT_EXITS
      exit(1);
#endif
      break;

    default:
      fprintf(stderr, "attributes:ensure_component(): Warning:\n"
              "  Illegal state of  %s component of %s\n", 
              cid_name(cid), attribute->any.name);
#ifdef CL_ENSURE_COMPONENT_EXITS
      exit(1);
#endif
      break;
    }
  }
  return comp;
}
Esempio n. 11
0
void ModulePromGroup::set_svg(const std::string& svg) {
	if(!component) create_component(svg.c_str());
	else ((SVGComponent*)component)->set(svg.c_str());
}