Exemplo n.º 1
0
void
parse_output (const struct target_opts* options, struct target_status* status)
{
    char* out_name;
    FILE* data;

    assert (0 != status);
    assert (0 != options->argv [0]);
    out_name = output_name (options->argv [0]);

    data = fopen (out_name, "r");

    if (0 == data) {
        if (ENOENT != errno)
            warn ("Error opening %s: %s\n", out_name, strerror (errno));
        status->status = ST_NO_OUTPUT;
    }
    else {
        if (0 == options->data_dir || '\0' == *options->data_dir) {
            /* If there is not an input directory, look at the assertion tags */

            if (!options->compat)
                check_test (data, status);
            else
                check_compat_test (data, status);
        }
        else {
            /* Otherwise, diff against the output file */
            check_example (options->data_dir, out_name, data, status);
        }
        fclose (data);
    }
    free (out_name);
}
Exemplo n.º 2
0
static void
output_name_type( fields *info, FILE *outptr, int level, 
			char *map[], int nmap, char *tag )
{
	newstr ntag;
	int i, j, n=0, code, nfields;
	newstr_init( &ntag );
	nfields = fields_num( info );
	for ( j=0; j<nmap; ++j ) {
		for ( i=0; i<nfields; ++i ) {
			code = extract_name_and_info( &ntag, &(info->tag[i]) );
			if ( strcasecmp( ntag.data, map[j] ) ) continue;
			if ( n==0 )
				fprintf( outptr, "<%s><b:NameList>\n", tag );
			if ( code != NAME )
				output_name_nomangle( outptr, info->data[i].data );
			else 
				output_name( outptr, info->data[i].data );
			fields_setused( info, i );
			n++;
		}
	}
	newstr_free( &ntag );
	if ( n )
		fprintf( outptr, "</b:NameList></%s>\n", tag );
}
static ptype_list* max_delay(befig_list* befig)
{
   bereg_list* bereg;
   bebus_list* bebus;
   beout_list* beout;
   float max_delay=-1;
   float delay, ck;
   char* name=NULL;
   
   
   /*delay ot yet calculate for output*/
   for (beout=befig->BEOUT; beout; beout=beout->NEXT) {
      delay=loc_eval_delay(beout->ABL, getcapacitancelax(beout->NAME));
      /*not to erase input values*/
      putdelay(output_name(beout->NAME),delay);
      if (delay>max_delay) {max_delay=delay; name=beout->NAME;}
   }
   
   for (bebus=befig->BEBUS; bebus; bebus=bebus->NEXT) {
      delay=loc_eval_bus(bebus->BIABL,getcapacitancelax(bebus->NAME));
      /*not to erase input values*/
      putdelay(output_name(bebus->NAME),delay);
      if (delay>max_delay) {max_delay=delay; name=bebus->NAME;}
   }   
   
   /*calculate for register values*/
   for (bereg=befig->BEREG; bereg; bereg=bereg->NEXT) {
      delay=eval_value_reg(bereg->BIABL);   
      ck=eval_clock_reg(bereg->BIABL);
      /*not to erase input values*/
      putdelay(output_name(bereg->NAME),delay);
      delay-=ck;                                    /*take care of ck setup time*/
      if (delay>max_delay) {max_delay=delay; name=bereg->NAME;}
   }   
   

   return addptype(NULL, (long)max_delay, name);
}
Exemplo n.º 4
0
extern double critical_delay(lofig_list* lofig)
{
    losig_list* losig;
    char* signame;

    losig=critical_output(lofig);

    if (!losig->NAMECHAIN) {
        fprintf(stderr,"critical_delay: no losig name\n");
        autexit(1);
    }
    signame=losig->NAMECHAIN->DATA;

    if (losig->TYPE==EXTERNAL) return getdelay(output_name(signame));
    return getdelay(signame);
}
Exemplo n.º 5
0
Symbol *
addsym(char *name)
{
    Symbol key, *s;

    key.name = name;
    s = (Symbol *) hashtabsearch(htab, (void *) &key);
    if (s == NULL) {
	s = (Symbol *) emalloc(sizeof(*s));
	s->name = name;
	s->gen_name = estrdup(name);
	output_name(s->gen_name);
	s->stype = SUndefined;
	hashtabadd(htab, s);
    }
    return s;
}
Exemplo n.º 6
0
const std::string UScreen::GetMonitorName(int output_number = 0) const
{
  if (output_number < 0 || output_number >= gdk_screen_get_n_monitors(screen_))
  {
    LOG_WARN(logger) << "UScreen::GetMonitorName: Invalid monitor number" << output_number;
    return "";
  }

  glib::String output_name(gdk_screen_get_monitor_plug_name(screen_, output_number));
  if (!output_name)
  {
    LOG_WARN(logger) << "UScreen::GetMonitorName: Failed to get monitor name for monitor" << output_number;
    return "";
  }

  return output_name.Str();
}
Exemplo n.º 7
0
void CmdVelMuxNodelet::reloadConfiguration(yocs_cmd_vel_mux::reloadConfig &config, uint32_t unused_level)
{
  std::string yaml_cfg_file;
  ros::NodeHandle &nh = this->getPrivateNodeHandle();
  if( config.yaml_cfg_file == "" )
  {
    // typically fired on startup, so look for a parameter to set a default
    nh.getParam("yaml_cfg_file", yaml_cfg_file);
  }
  else
  {
    yaml_cfg_file = config.yaml_cfg_file;
  }

  /*********************
  ** Yaml File Parsing
  **********************/
  std::ifstream ifs(yaml_cfg_file.c_str(), std::ifstream::in);
  if (ifs.good() == false)
  {
    NODELET_ERROR_STREAM("CmdVelMux : configuration file not found [" << yaml_cfg_file << "]");
    return;
  }
  // probably need to bring the try catches back here
  YAML::Node doc;
#ifdef HAVE_NEW_YAMLCPP
  doc = YAML::Load(ifs);
#else
  YAML::Parser parser(ifs);
  parser.GetNextDocument(doc);
#endif

  /*********************
  ** Output Publisher
  **********************/
  std::string output_name("output");
#ifdef HAVE_NEW_YAMLCPP
  if ( doc["publisher"] ) {
    doc["publisher"] >> output_name;
  }
#else
  const YAML::Node *node = doc.FindValue("publisher");
  if ( node != NULL ) {
    *node >> output_name;
  }
Exemplo n.º 8
0
int main(int argc, char* argv[]) {
    ImageRGB input_image;
    ImageRGB output_image;

    std::string input_name("input.jpg");
    std::string output_name("output.jpg");

    try {
        mirage::img::JPEG::read(input_image, input_name);

        output_image.resize(input_image._dimension);

        ImageRGB::pixel_type p1,p2,p_end;
        ImageRGB::value_type black(0,0,0);
        ImageRGB::value_type green(0,255,0);
        int threshold = 50;
        for(p1=input_image.begin(),p2=output_image.begin(),p_end=input_image.end();
            p1 != p_end;
            ++p1,++p2) {
            ImageRGB::value_type& v1 = *p1;
            
            if (v1._green > v1._blue && v1._green > v1._red) {
                int temp = v1._blue < v1._red ? v1._blue : v1._red;
                if (v1._green - temp > threshold)
                    *p2 = green;
                else
                    *p2 = black;
            }
            else
                *p2 = black;
        }

        mirage::img::JPEG::write(output_image, output_name, 70);
    }
    catch(mirage::Exception::Any& e) {
        std::cerr << "Error : " <<  e.what() << std::endl;
    }
    catch(...) {
        std::cerr << "Unknown error" << std::endl;
    }
    return 0;
}
Exemplo n.º 9
0
extern losig_list* critical_output(lofig_list* lofig)
{
    double delay, max_delay=-1;
    losig_list* output=NULL, *losig;
    char* signame;

    for (losig=lofig->LOSIG; losig; losig=losig->NEXT) {
        if (!losig->NAMECHAIN) {
            fprintf(stderr,"critical_output: no losig name\n");
            autexit(1);
        }
        signame=losig->NAMECHAIN->DATA;
        if (losig->TYPE==EXTERNAL) delay=getdelay(output_name(signame));
        else delay=getdelay(signame);
        if (delay>max_delay) {
            max_delay=delay;
            output=losig;
        }
    }

    return output;
}
Exemplo n.º 10
0
static void
output_names( fields *f, FILE *outptr, int level )
{
	convert   names[] = {
	  { "author",                              "AUTHOR",          0, MARC_AUTHORITY },
	  { "editor",                              "EDITOR",          0, MARC_AUTHORITY },
	  { "annotator",                           "ANNOTATOR",       0, MARC_AUTHORITY },
	  { "artist",                              "ARTIST",          0, MARC_AUTHORITY },
	  { "author",                              "2ND_AUTHOR",      0, MARC_AUTHORITY },
	  { "author",                              "3RD_AUTHOR",      0, MARC_AUTHORITY },
	  { "author",                              "SUB_AUTHOR",      0, MARC_AUTHORITY },
	  { "author",                              "COMMITTEE",       0, MARC_AUTHORITY },
	  { "author",                              "COURT",           0, MARC_AUTHORITY },
	  { "author",                              "LEGISLATIVEBODY", 0, MARC_AUTHORITY },
	  { "author of afterword, colophon, etc.", "AFTERAUTHOR",     0, MARC_AUTHORITY },
	  { "author of introduction, etc.",        "INTROAUTHOR",     0, MARC_AUTHORITY },
	  { "cartographer",                        "CARTOGRAPHER",    0, MARC_AUTHORITY },
	  { "collaborator",                        "COLLABORATOR",    0, MARC_AUTHORITY },
	  { "commentator",                         "COMMENTATOR",     0, MARC_AUTHORITY },
	  { "compiler",                            "COMPILER",        0, MARC_AUTHORITY },
	  { "degree grantor",                      "DEGREEGRANTOR",   0, MARC_AUTHORITY },
	  { "director",                            "DIRECTOR",        0, MARC_AUTHORITY },
	  { "event",                               "EVENT",           0, NO_AUTHORITY   },
	  { "inventor",                            "INVENTOR",        0, MARC_AUTHORITY },
	  { "organizer of meeting",                "ORGANIZER",       0, MARC_AUTHORITY },
	  { "patent holder",                       "ASSIGNEE",        0, MARC_AUTHORITY },
	  { "performer",                           "PERFORMER",       0, MARC_AUTHORITY },
	  { "producer",                            "PRODUCER",        0, MARC_AUTHORITY },
	  { "recipient",                           "RECIPIENT",       0, MARC_AUTHORITY },
	  { "redactor",                            "REDACTOR",        0, MARC_AUTHORITY },
	  { "reporter",                            "REPORTER",        0, MARC_AUTHORITY },
	  { "sponsor",                             "SPONSOR",         0, MARC_AUTHORITY },
	  { "translator",                          "TRANSLATOR",      0, MARC_AUTHORITY },
	  { "writer",                              "WRITER",          0, MARC_AUTHORITY },
	};
	int i, n, nfields, ntypes = sizeof( names ) / sizeof( convert );
	int f_asis, f_corp, f_conf;
	newstr role;

	newstr_init( &role );
	nfields = fields_num( f );
	for ( n=0; n<ntypes; ++n ) {
		for ( i=0; i<nfields; ++i ) {
			if ( fields_level( f, i )!=level ) continue;
			if ( f->data[i].len==0 ) continue;
			f_asis = f_corp = f_conf = 0;
			newstr_strcpy( &role, f->tag[i].data );
			if ( newstr_findreplace( &role, ":ASIS", "" )) f_asis=1;
			if ( newstr_findreplace( &role, ":CORP", "" )) f_corp=1;
			if ( newstr_findreplace( &role, ":CONF", "" )) f_conf=1;
			if ( strcasecmp( role.data, names[n].internal ) )
				continue;
			if ( f_asis ) {
				output_tag( outptr, lvl2indent(level),               "name",     NULL, TAG_OPEN,      TAG_NEWLINE, NULL );
				output_fil( outptr, lvl2indent(incr_level(level,1)), "namePart", f, i, TAG_OPENCLOSE, TAG_NEWLINE, NULL );
			} else if ( f_corp ) {
				output_tag( outptr, lvl2indent(level),               "name",     NULL, TAG_OPEN,      TAG_NEWLINE, "type", "corporate", NULL );
				output_fil( outptr, lvl2indent(incr_level(level,1)), "namePart", f, i, TAG_OPENCLOSE, TAG_NEWLINE, NULL );
			} else if ( f_conf ) {
				output_tag( outptr, lvl2indent(level),               "name",     NULL, TAG_OPEN,      TAG_NEWLINE, "type", "conference", NULL );
				output_fil( outptr, lvl2indent(incr_level(level,1)), "namePart", f, i, TAG_OPENCLOSE, TAG_NEWLINE, NULL );
			} else {
				output_name(outptr, f->data[i].data, level);
			}
			output_tag( outptr, lvl2indent(incr_level(level,1)), "role", NULL, TAG_OPEN, TAG_NEWLINE, NULL );
			if ( names[n].code & MARC_AUTHORITY )
				output_tag( outptr, lvl2indent(incr_level(level,2)), "roleTerm", names[n].mods, TAG_OPENCLOSE, TAG_NEWLINE, "authority", "marcrelator", "type", "text", NULL );
			else
				output_tag( outptr, lvl2indent(incr_level(level,2)), "roleTerm", names[n].mods, TAG_OPENCLOSE, TAG_NEWLINE, "type", "text", NULL );
			output_tag( outptr, lvl2indent(incr_level(level,1)), "role", NULL, TAG_CLOSE, TAG_NEWLINE, NULL );
			output_tag( outptr, lvl2indent(level),               "name", NULL, TAG_CLOSE, TAG_NEWLINE, NULL );
			fields_setused( f, i );
		}
	}
	newstr_free( &role );
}
Exemplo n.º 11
0
string colmap::compare(){

	string ret("");

	indexed_points *ds1_ip = dynamic_cast<indexed_points*>(dataset1);
	indexed_points *ds2_ip = dynamic_cast<indexed_points*>(dataset2);

	if(ds1_ip == NULL || ds2_ip == NULL)
		return string("Improper Datasets");

	for(int j=1; j<=2; j++){
				
		long double max = get_max_value(j);
		long double min = get_min_value(j);

		long double range = max - min;

		int x_size = 0;
		int y_size = 0;
		int z_size = 0;

		if(j == 1){
			x_size = ds1_ip->get_dim().sizes[0];
			y_size = ds1_ip->get_dim().sizes[1];
			z_size = ds1_ip->get_dim().sizes[2];
		}	
		else{
			x_size = ds2_ip->get_dim().sizes[0];
			y_size = ds2_ip->get_dim().sizes[1];
			z_size = ds2_ip->get_dim().sizes[2];;
		}

		CImg<unsigned char> imgOut(x_size, y_size, z_size, 3, 0);

		for(int x=0; x<x_size; x++){
			for(int y=0; y<y_size; y++){
				for(int z=0; z<z_size; z++){

					layout loc;
					loc.arr_size = 3;
					loc.sizes = new int[3];
					loc.sizes[0] = x;
					loc.sizes[1] = y;
					loc.sizes[2] = z;

					long double pt_val;

					if(j == 1)
						pt_val = ds1_ip->get_indexed_point(loc).vals[var_ds1];
					else if(j == 2)
						pt_val = ds2_ip->get_indexed_point(loc).vals[var_ds2];

					rgb_color col = get_color_single_sided(pt_val, range, min);

					imgOut(x, y_size - y - 1, z, 0) = col.r;
					imgOut(x, y_size - y - 1, z, 1) = col.g;
					imgOut(x, y_size - y - 1, z, 2) = col.b;
				}
			}
		}

		//Construct file name
		string output_name(outprefix);
		output_name += "_colmap";

		if(j == 1){
			output_name += "_FIRST_";
			output_name += "var1_";
			output_name += itoa(var_ds1);	
		}
		else if(j == 2){
			output_name += "_SECOND_";
			output_name += "var2_";
			output_name += itoa(var_ds2);
		}

		output_name += ".bmp";

		ret += output_name + " ";

		imgOut.save_bmp(output_name.c_str());

	}

	return ret;

}
Exemplo n.º 12
0
string difmap_wkey::compare(){

	indexed_points *ds1_ip = dynamic_cast<indexed_points*>(dataset1);
	indexed_points *ds2_ip = dynamic_cast<indexed_points*>(dataset2);

	if(ds1_ip == NULL || ds2_ip == NULL)
		return string("Improper Datasets");

	string ret("");

	if(!check_card_match()){
		ret = "No Output";
		return ret;
	}

	long double max = get_max_dif();
	long double min = get_min_dif();

	long double range = fabs( max - min );

	CImg<unsigned char> imgOut( ds1_ip->get_dim().sizes[0] + border_width + key_width, 
								ds1_ip->get_dim().sizes[1],
								ds1_ip->get_dim().sizes[2], 
								3, 0 );	

	//Write difference map to image
	for(int x=0; x<ds1_ip->get_dim().sizes[0]; x++){
		for(int y=0; y<ds1_ip->get_dim().sizes[1]; y++){
			for(int z=0; z<ds1_ip->get_dim().sizes[2]; z++){
				//TODO: loop over every dep_var

				layout loc;
				loc.arr_size = 3;
				loc.sizes = new int[3];
				loc.sizes[0] = x;
				loc.sizes[1] = y;
				loc.sizes[2] = z;

				long double pt_val = fabs( ds1_ip->get_indexed_point(loc).vals[var_ds1]
										   - ds2_ip->get_indexed_point(loc).vals[var_ds2] );

				rgb_color col = get_color_double_sided(pt_val, range, min, 0);

				imgOut(x, ds1_ip->get_dim().sizes[1] - y - 1, z, 0) = col.r;
				imgOut(x, ds1_ip->get_dim().sizes[1] - y - 1, z, 1) = col.g;
				imgOut(x, ds1_ip->get_dim().sizes[1] - y - 1, z, 2) = col.b;
			}
		}
	}


	//Determine if one dataset is always larger
	int large_ds;
	if( 0 >= min && 0 <= max )
		large_ds = -1;
	else{

		layout loc;
		loc.arr_size = 3;
		loc.sizes = new int[3];
		loc.sizes[0] = 0;
		loc.sizes[1] = 0;
		loc.sizes[2] = 0;

		if(ds1_ip->get_indexed_point(loc).vals[var_ds1] 
			> ds2_ip->get_indexed_point(loc).vals[var_ds2]){

			large_ds = 1;
		}
		else
			large_ds = 2;
	}

	//Write border
	int border_start = ds1_ip->get_dim().sizes[0];

	for(int y=0; y < ds1_ip->get_dim().sizes[1]; y++){
		for(int x=border_start; x < border_start + border_width; x++){
			for(int z=0; z<ds1_ip->get_dim().sizes[2]; z++){

				imgOut( x, y, z, 0 ) = border_color.r;
				imgOut( x, y, z, 1 ) = border_color.g;
				imgOut( x, y, z, 2 ) = border_color.b;
			}
		}
	}

	//Write key
	int x_start = ds1_ip->get_dim().sizes[0] + border_width;

	long double k_height = ds1_ip->get_dim().sizes[1];
	long double unit = range / (k_height-1.0);

	for(int y=0; y<ds1_ip->get_dim().sizes[1]; y++){
		for(int x=x_start; x < x_start + key_width; x++){
			for(int z=0; z<ds1_ip->get_dim().sizes[2]; z++){
				rgb_color col = get_color_double_sided(min+unit*y, range, min, 0);

				imgOut( x, ds1_ip->get_dim().sizes[1] - y - 1, z, 0 ) = col.r;
				imgOut( x, ds1_ip->get_dim().sizes[1] - y - 1, z, 1 ) = col.g;
				imgOut( x, ds1_ip->get_dim().sizes[1] - y - 1, z, 2 ) = col.b;
			}
		}
	}

	//Construct file name
	string output_name(outprefix);
	output_name += "_difmap_wkey_";
	output_name += "var1_";
	output_name += itoa(var_ds1);
	output_name += "_var2_";
	output_name += itoa(var_ds2);

	//Write info to txt file
	output_info(output_name + ".txt", max, min, large_ds);

	//Write image
	imgOut.save_bmp((output_name + ".bmp").c_str());

	ret = output_name;
	return ret;
}
Exemplo n.º 13
0
extern void save_xsch(FILE* xsch_stream, lofig_list* lofig, ptype_list* long_path, int color_mode)
{
   long color;
   ptype_list* ptype, *ptype2=NULL;
   float delay=0, delay_out=0;
   char mes[1024];
   char* signame = NULL;
   locon_list* locon;
   losig_list* losig;
   float gradient=1;
   int count;
   loins_list* loins;
   char *source, *dest=NULL, *last_sig;
   chain_list* chain, *loinschain=NULL;
   chain_list* lofigchain;
   losig_list* losig_aux;

   /*build gradient*/
   if (long_path && color_mode==XSCH_GRADIENT) {
      /*get time of last entry*/
      count=1;
      for (ptype=long_path; ptype->NEXT; ptype=ptype->NEXT) count++;
      
      if (!ptype->DATA) {
         fprintf(stderr,"save_xsch: compute error\n");
         exit(1);
      }
      delay=ptype->TYPE;
      gradient=delay/((float)XSCH_COLOR_MAX);
   }
   
   /*color for signals*/
   for (losig=lofig->LOSIG; losig; losig=losig->NEXT) {

      if (!losig->NAMECHAIN || !losig->NAMECHAIN->DATA) {
         fprintf(stderr,"save_xsch: no name for signal\n");
         exit(1);
      }
      signame=losig->NAMECHAIN->DATA;
      
      if (isvdd(signame) || isvss(signame)) continue;
      
      if (losig->TYPE==EXTERNAL) {
         /*search external output*/
         ptype=getptype(losig->USER,LOFIGCHAIN);
         for (lofigchain=ptype->DATA; lofigchain; lofigchain=lofigchain->NEXT) {
            locon=lofigchain->DATA;
            if (locon->TYPE==EXTERNAL && locon->DIRECTION!=IN) break;
         }
         if (lofigchain) delay=getdelay(output_name(signame));
         else delay=getdelay(signame);
      }   
      else delay=getdelay(signame);
      
      switch (color_mode) {
      case XSCH_GRADIENT: color=gradient_color(delay,gradient); break;
      case XSCH_CRITICAL_PATH: default: color=XSCH_NEUTRAL_COLOR; break;
      }
      
      flush_losig(xsch_stream, signame, color, delay, losig->TYPE);
      
   }
   
   
   /*color for instances*/
   for (loins=lofig->LOINS; loins; loins=loins->NEXT) {
      /*search signal output*/
      for (locon=loins->LOCON; locon; locon=locon->NEXT) {
         if (locon->DIRECTION==UNKNOWN) {
            fprintf(stderr,"BEH: 'linkage %s' in figure '%s' isn't accepted\n",
            locon->NAME,loins->INSNAME);
            exit(1);
         }
         if (locon->DIRECTION==OUT || locon->DIRECTION==INOUT 
           || locon->DIRECTION==TRISTATE || locon->DIRECTION==TRANSCV) break;
      }
      if (!locon) {
         fprintf(stderr,"save_xsch: no output found for '%s'\n",loins->INSNAME);
         exit(1);
      }
      losig=locon->SIG;
      signame=losig->NAMECHAIN->DATA;
      
      delay=getdelay(loins->INSNAME);
     
      switch (color_mode) {
      case XSCH_GRADIENT: color=gradient_color(delay,gradient); break;
      case XSCH_CRITICAL_PATH: default:
         /*is instance in critical path?*/
         for (ptype=long_path; ptype; ptype=ptype->NEXT) {
            if ((char*)ptype->DATA!=signame) continue;
          /*if output and input signals belong to critical path, then instance belongs*/
            for (locon=loins->LOCON; locon; locon=locon->NEXT) {
               if (locon->DIRECTION==OUT || locon->DIRECTION==TRISTATE) continue;
               losig_aux=locon->SIG;
               /*is signal in critical path?*/
               for (ptype2=long_path; ptype2; ptype2=ptype2->NEXT) {
                  if ((char*)ptype2->DATA==losig_aux->NAMECHAIN->DATA) break;
               }
               if (ptype2) break;
            }
            ptype=ptype2;  /*found?*/
            break;
         }
         
         /*build critical path list*/
         if (ptype) loinschain=addchain(loinschain,loins);
     
         if (ptype) color=XSCH_RED_COLOR;
         else color=XSCH_NEUTRAL_COLOR;
      }
      flush_loins(xsch_stream, loins->INSNAME, color, delay);
      
   }
   

   /*color for connectors*/
   for (locon=lofig->LOCON; locon; locon=locon->NEXT) {

      if (isvdd(locon->NAME) || isvss(locon->NAME)) continue;
      
      switch (locon->DIRECTION) {
      case IN: 
         delay_out=getdelay(locon->NAME);
         sprintf(mes, "%d ps",(int)delay_out);
         break;
      case OUT: case TRISTATE: 
         delay_out=getdelay(output_name(locon->NAME));
         sprintf(mes, "%d ps",(int)delay_out);
         break;
      case INOUT: case TRANSCV: 
         delay=getdelay(locon->NAME);
         delay_out=getdelay(output_name(locon->NAME));
         sprintf(mes, "%d ps on input; %d ps on output",(int)delay,(int)delay_out);
         break;
      }

      switch (color_mode) {
      case XSCH_GRADIENT: color=gradient_color(delay_out,gradient); break;
      case XSCH_CRITICAL_PATH: default:
         /* seek if signal is in a long path*/
         for (ptype=long_path; ptype; ptype=ptype->NEXT) {
            if ((char*)ptype->DATA==locon->NAME) break;
         }
   
         if (ptype) color=XSCH_RED_COLOR;
         else color=XSCH_NEUTRAL_COLOR;
      }
      flush_stream_special(xsch_stream, locon->NAME, color, mes);
   }  


   /*critical path*/
   if (loinschain && long_path && color_mode==XSCH_CRITICAL_PATH) {
      source=NULL;
      last_sig=NULL;
      for (ptype=long_path; ptype; ptype=ptype->NEXT) {
         signame=ptype->DATA;
         for (chain=loinschain; chain; chain=chain->NEXT) {
            loins=chain->DATA;
            /*search signal output*/
            for (locon=loins->LOCON; locon; locon=locon->NEXT) {
               if (locon->DIRECTION==OUT || locon->DIRECTION==INOUT 
                || locon->DIRECTION==TRISTATE || locon->DIRECTION==TRANSCV) {
                  losig=locon->SIG;
                  if (losig->NAMECHAIN->DATA==signame) {
                     dest=loins->INSNAME;
                     break;
                  }
               }   
            }
            if (locon) break;
         }  
         /*if no instance found it is external connector. it has the same name than signal*/
         if (!locon) dest=signame;
      
         if (source)
            flush_path(xsch_stream, source, last_sig, dest, XSCH_RED_COLOR, delay, INTERNAL);
      
         source=dest;
         last_sig=signame;
      }
      
      /*for last signal search output*/
      if (losig) {
         ptype=getptype(losig->USER,LOFIGCHAIN);
         for (chain=ptype->DATA; chain; chain=chain->NEXT) {
            locon=chain->DATA;
            /*port of circuit*/
            if (locon->TYPE==EXTERNAL) {dest=locon->NAME; break;}
            loins=locon->ROOT;
            /*register input if no error*/
            if (locon->DIRECTION==IN || locon->DIRECTION==INOUT || locon->DIRECTION==TRANSCV)
            {dest=loins->INSNAME; break;}
         }
         flush_path(xsch_stream, source, signame, dest, XSCH_RED_COLOR, delay, losig->TYPE);
      }
      
   }

   freechain(loinschain);
}
Exemplo n.º 14
0
int main (int argc, char* argv[])
{
	ApplicationsLib::LogogSetup logog_setup;

	TCLAP::CmdLine cmd(
		"Creates a layered 3D OGS mesh from an existing 2D OGS mesh and raster "
		"files representing subsurface layers. Supported raster formats are "
		"ArcGIS ascii rasters (*.asc) and Surfer Grids (*.grd)."
		"",
		' ',
		"1.0");

	TCLAP::ValueArg<std::string> mesh_arg("i", "input-mesh-file",
		"The name of the file containing the 2D input mesh.", true, "", "input file name");
	cmd.add(mesh_arg);

	TCLAP::ValueArg<std::string> mesh_out_arg("o", "output-mesh-file",
		"The name of the file to which the resulting 3D mesh will be written.",
		true, "", "output file name");
	cmd.add(mesh_out_arg);

	TCLAP::ValueArg<std::string> raster_path_arg("r", "raster-list", 
		"An ascii-file containing a list of raster files, starting from top (DEM) to bottom.",
		true, "", "list of raster files");
	cmd.add(raster_path_arg);

	double min_thickness (std::numeric_limits<double>::epsilon());
	TCLAP::ValueArg<double> min_thickness_arg("t", "thickness",
		"The minimum thickness of a layer to be integrated at any given location.",
		false, min_thickness, "minimum layer thickness");
	cmd.add(min_thickness_arg);

	cmd.parse(argc, argv);

	if (min_thickness_arg.isSet())
	{
		min_thickness = min_thickness_arg.getValue();
		if (min_thickness < 0)
		{
			ERR("Minimum layer thickness must be non-negative value.");
			return EXIT_FAILURE;
		}
	}

	INFO("Reading mesh \"%s\" ... ", mesh_arg.getValue().c_str());
	std::unique_ptr<MeshLib::Mesh> const sfc_mesh (FileIO::readMeshFromFile(mesh_arg.getValue()));
	if (!sfc_mesh) {
		ERR("Error reading mesh \"%s\".", mesh_arg.getValue().c_str());
		return EXIT_FAILURE;
	}
	if (sfc_mesh->getDimension() != 2) {
		ERR("Input mesh needs to be a 2D mesh.");
		return EXIT_FAILURE;
	}
	INFO("done.");

	std::vector<std::string> raster_paths;
	if (readRasterPaths(raster_path_arg.getValue(), raster_paths) != 0)
		return EXIT_FAILURE;

	MeshLib::MeshLayerMapper mapper;
	if (auto rasters = FileIO::readRasters(raster_paths))
	{
		if (!mapper.createLayers(*sfc_mesh, *rasters, min_thickness))
			return EXIT_FAILURE;
	}
	else
		return EXIT_FAILURE;

	std::string output_name (mesh_out_arg.getValue());
	if (!BaseLib::hasFileExtension("vtu", output_name))
		output_name.append(".vtu");
	INFO("Writing mesh \"%s\" ... ", output_name.c_str());
	FileIO::writeMeshToFile(*(mapper.getMesh("SubsurfaceMesh").release()), output_name);
	INFO("done.");

	return EXIT_SUCCESS;
}