Exemplo n.º 1
0
Matrix periodic_function(Matrix* inputChannel,short numChannels){
	char buf[CHAR_BUFFER_SIZE];
	struct debugframe temp;
	static unsigned long long epoch = 0;
	int i,ret=1;
	
	while(ret){
		ret = rt_queue_read(io.debug_queue,&temp,sizeof(temp),TM_NONBLOCK);
		
		//If queue has no more messages to process
		//or has been deleted and hence become invalid
		if(ret == -EWOULDBLOCK || ret == -EINVAL)
			break;
		
		if(!epoch)
			epoch = temp.start_time;

		LOG("\nBlock name          : %s\n",temp.config_file);
		LOG("Block type          : %s\n",temp.block_name);

		LOG("Start               : %llu.%06llu us\n",
		      (temp.start_time - epoch) / 1000,
		      (temp.start_time - epoch) % 1000);
		LOG("End                 : %llu.%06llu us\n",
		      (temp.end_time - epoch) / 1000,
		      (temp.end_time - epoch) % 1000);
		LOG("Inputs              : %d\n",temp.input_num);
		for(i=0;i<temp.input_num;i++){
			matrix_print_pretty(&temp.input[i],temp.input_name[i],NULL);
			
			matrix_string(&temp.input[i], &buf);
			fprintf(log,"- %-11s: %s\n",temp.input_name[i],buf);
		}

		matrix_string(&temp.output, &buf);
		LOG("Output              : %s\n",buf);
	}
}
Exemplo n.º 2
0
void BlockBase::newMatrix(const QString& text, Matrix* M1)
{
    SettingsLock lock;
    char buf[CHAR_BUFFER_SIZE];
    matrix_string(M1,buf);

    QLineEdit* lineEdit = new QLineEdit(this);
    lineEdit->setText(buf);

    d_settingsLayout->addWidget(new QLabel(text,this),d_entryNum,0);
    d_settingsLayout->addWidget(lineEdit,d_entryNum,1);

    connect(lineEdit, SIGNAL(textChanged(QString)),
            this, SLOT(lineEditChange(QString)) );

    lineEdits[lineEdit]=M1;
    originalMatrix[M1]=*M1;

    d_entryNum++;
}
int main(int argc, char **argv)
{
  try
  {
    TCLAP::CmdLine cmd("Geometrically transforms a mesh", ' ', "1.0");

    TCLAP::ValueArg<std::string> log_filename("l","logfile", "Log file name (default is convert.log)", false, "convert.log", "string");
    cmd.add( log_filename );

    TCLAP::ValueArg<std::string> input_filetype("","inputtype", "Input file type. Can be\nauto - ViennaMesh automatically detects the file format (default)\nvtk - for VTK files\nmesh - for Netgen .mesh files\npoly - for Tetgen .poly files\ndeva - for GTS deva files", false, "auto", "string");
    cmd.add( input_filetype );

    TCLAP::ValueArg<std::string> output_filetype("","outputtype", "Output file type. Can be\nauto - ViennaMesh automatically detects the file format (default)\nvtk - for VTK files\nvmesh - for Vienna vmesh files", false, "auto", "string");
    cmd.add( output_filetype );


    TCLAP::ValueArg<std::string> matrix_string("m","matrix", "Translate matrix", false, "", "string");
    cmd.add( matrix_string );

    TCLAP::ValueArg<double> scale("s","scale", "Scale the mesh", false, 0.0, "double");
    cmd.add( scale );

    TCLAP::ValueArg<std::string> translate_string("t","translate", "Translate the mesh", false, "", "string");
    cmd.add( translate_string );



    TCLAP::UnlabeledValueArg<std::string> input_filename( "input-filename", "Input file name", true, "", "InputFile"  );
    cmd.add( input_filename );

    TCLAP::UnlabeledValueArg<std::string> output_filename( "output-filename", "Output file name", true, "", "OutputFile"  );
    cmd.add( output_filename );

    cmd.parse( argc, argv );


    viennamesh::logger().register_callback( new viennamesh::FileStreamCallback<viennamesh::FileStreamFormater>( log_filename.getValue() ) );

    viennamesh::algorithm_handle reader( new viennamesh::io::mesh_reader() );
    reader->set_input( "filename", input_filename.getValue() );
    if (input_filetype.isSet() && (input_filetype.getValue() != "auto"))
      reader->set_input( "file_type", input_filetype.getValue() );
    reader->run();


    int dimension = lexical_cast<int>(reader->get_output("mesh")->get_property("geometric_dimension").first);

    viennamesh::algorithm_handle transform( new viennamesh::affine_transform() );

    viennamesh::dynamic_point matrix(dimension*dimension, 0.0);

    for (int i = 0; i < dimension; ++i)
      matrix[dimension*i+i] = 1.0;

    if ( matrix_string.isSet() )
    {
      matrix = stringtools::vector_from_string<double>( matrix_string.getValue() );
    }
    else if (scale.isSet())
    {
      for (int i = 0; i < dimension*dimension; ++i)
        matrix[i] *= scale.getValue();
    }

    viennamesh::dynamic_point translate( dimension, 0.0 );
    if ( translate_string.isSet() )
    {
      translate = stringtools::vector_from_string<double>( translate_string.getValue() );
    }

    transform->set_input( "mesh", reader->get_output("mesh") );
    transform->set_output( "mesh", reader->get_output("mesh") );
    transform->set_input( "matrix", matrix );
    transform->set_input( "translate", translate );

    transform->run();


    viennamesh::algorithm_handle writer( new viennamesh::io::mesh_writer() );
    writer->set_input( "mesh", transform->get_output("mesh") );
    writer->set_input( "quantities", reader->get_output("quantities") );
    writer->set_input( "filename", output_filename.getValue() );
    if (output_filetype.isSet() && (output_filetype.getValue() != "auto"))
      writer->set_input( "file_type", output_filetype.getValue() );
    writer->run();
  }
  catch (TCLAP::ArgException &e)  // catch any exceptions
  {
    std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
  }

  return 0;
}