Ejemplo n.º 1
0
void SegMeshLoader::loadGroupsFromObj()
{
	// Read obj file
	QFile file(entireMesh->path);
	if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
	QTextStream inF(&file);

	int fidx = 0;
	while( !inF.atEnd() )
	{
		QString line = inF.readLine();
		if(line.isEmpty()) continue;

		if (line.startsWith("g"))
		{
			QStringList groupLine = line.split(" ");

			QString gid;
			if(!groupLine.isEmpty()) gid = groupLine.at(1);
			else gid = QString::number(groupFaces.size());

			while(true)
			{
				QString line = inF.readLine();
				if(!line.startsWith("f")) break;

				groupFaces[gid].push_back(fidx++);
			}
		}
	}

}
TEST_F(FourierTransformerGPUTest, BackwardTestMatrixSizes)
{
	ComplexMatrix 	inT(ftfftw->rows_,ftfftw->colsHS_),
				  	inF(3,3);
	RealMatrix 	outT(ftfftw->rows_,ftfftw->rows_),
				outF(7,9);

	// ASSERT_THROW(ftfftw->backward(inT,outF), std::invalid_argument);
	ASSERT_THROW(ftfftw->backward(inF,outT), std::invalid_argument);
	// ASSERT_THROW(ftfftw->backward(inF,outF), std::invalid_argument);
	ASSERT_NO_THROW(ftfftw->backward(inT,outT));
}
Ejemplo n.º 3
0
QSegMesh * QMeshDoc::importObject(QString fileName)
{
	// Get object name from file path
	QFileInfo fInfo (fileName);

	if(!fileName.size() || !fInfo.exists())
	{
		emit(printMessage(QString("Error: invalid file (%1).").arg(fileName)));
		return NULL;
	}

	QString newObjId = fInfo.fileName();
	newObjId.chop(4);
	global_id++;
	newObjId += QString("-%1").arg(global_id);

	// Create a new QSegMesh
	QSegMesh * newMesh = new QSegMesh();
	all_objects[ newObjId ] = newMesh;

	// Reading QSegMesh
	newMesh->read(fileName);

	// Set global ID for the mesh and all its segments
	newMesh->setObjectName(newObjId);
	
	// Try to load the controller and groups with the same filename
	// Setup controller file name
	fileName.chop(3);fileName += "ctrl";

	if(QFileInfo(fileName).exists())
	{
		// Load controller
		newMesh->ptr["controller"] = new Controller(newMesh, true, fileName);
		Controller * ctrl = (Controller *)newMesh->ptr["controller"];

		fileName.chop(4);fileName += "grp";
		if(QFileInfo(fileName).exists())
		{
			std::ifstream inF(qPrintable(fileName), std::ios::in);
			ctrl->loadGroups(inF);
			inF.close();
		}
	}
	else
	{
		newMesh->ptr["controller"] = new Controller(newMesh);
	}

	return newMesh;
}
Ejemplo n.º 4
0
int main(int argc, char const ** argv)
{
    // Check arguments.
    if (argc != 2) {
        std::cerr << "Wrong argument count!" << std::endl
                  << "USAGE: sequence_length SEQUENCE.fasta" << std::endl;
        return 1;
    }

    // Open file.
    std::fstream inF(argv[1], std::ios::in | std::ios::binary);
    if (!inF.good())
    {
        std::cerr << "ERROR: Could not open " << argv[1] << " for reading.\n";
        return 1;
    }

    // Create RecordReader.
    seqan::RecordReader<std::fstream, seqan::SinglePass<> > reader(inF);

    // Read sequence file and print sequence lengths.
    size_t total = 0;
    seqan::CharString id;
    seqan::CharString seq;
    while (!atEnd(reader))
    {
        if (readRecord(id, seq, reader, seqan::Fasta()) != 0)
        {
            std::cerr << "ERROR: Problem reading file " << argv[1] << ".\n";
            return 1;
        }

        std::cout << id << "\t" << length(seq) << "\n";
        total += length(seq);
    }
    std::cout << "sum\t" << total << std::endl;

    return 0;
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: mgazz/so
void* coppia(void* arg)
{
	int id = (int)arg;
	int sala_scelta;
	/*printf("coppia [%d] creato\n",id);*/
	int tipo;
	tipo= rand()%2;
	if (tipo==NF) //tipo non fumatore
	{
		printf("coppia [%d] tipo NF\n",id);
		sala_scelta=inNF(id);
		printf("coppia [%d] tipo NF entrata in sala %d\n",id,sala_scelta);
		sleep(rand()%5+5);
		outNF(id,sala_scelta);
	}
	else if (tipo==F) { //ultimo fumatore
		printf("coppia [%d] tipo F\n",id);
		inF(id);
		sleep(rand()%5);
		outF(id);
	}
	pthread_exit(NULL);
}