Exemple #1
0
string Dice::toString()
{
	string diceString = static_cast<ostringstream*>( &(ostringstream() << base) )->str() + "+";
	diceString += static_cast<ostringstream*>( &(ostringstream() << dice) )->str() + "d";
	diceString += static_cast<ostringstream*>( &(ostringstream() << sides) )->str();
	return diceString;
}
Exemple #2
0
ostream& operator <<(ostream& outStream, const Classics &obj)
{
	outStream << string("C, ") << static_cast<ostringstream*>(&(ostringstream() << obj.currentStock))->str() << string(", ") << obj.director.firstName << string(" ")
		<< obj.director.lastName << string(", ") << obj.title << string(", ") << obj.majorActor.firstName
		<< " " << obj.majorActor.lastName << string(" ") << static_cast<ostringstream*>(&(ostringstream() << obj.month))->str() << string(" ") << static_cast<ostringstream*>(&(ostringstream() << obj.yearReleased))->str();
	return outStream;
}
//if viewing or editing, this will to fill in the extra data
void UnderGradAppPage::fillInData(Application* app,WindowApp *theApp) {
    theApp->uGradAppPage->edit = true;
    UndergradApp *editApp = dynamic_cast<UndergradApp*>(app);
    theApp->editUApp = editApp;

    gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(theApp->uGradAppPage->form->combo), (editApp->getCourse()).c_str());
    gtk_combo_box_set_active(GTK_COMBO_BOX(theApp->uGradAppPage->form->combo),0);

    gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->fName), (editApp->getStuFirst()).c_str());
    gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->lName), (editApp->getStuLast()).c_str());
    gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->email), (editApp->getStuEmail()).c_str());

    int nu = editApp->getStuMGPA();
    string mgpa = static_cast<ostringstream*>( &(ostringstream() << nu) )->str();

    int ni = editApp->getStuCGPA();
    string gpa = static_cast<ostringstream*>( &(ostringstream() << ni) )->str();

    int yr = editApp->getStuYrStanding();
    string year = static_cast<ostringstream*>( &(ostringstream() << yr) )->str();
    gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->cgpa), (gpa.c_str()) );

    gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->gpa), (mgpa.c_str()) );

    gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->major), (editApp->getStuMajor()).c_str());
    gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->year), (year.c_str()));
    gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->stuNum), (editApp->getStuID()).c_str());
    UnderGradAppPage::fillInRelated(theApp);
}
bool PlannerThread::adaptRules()
{
    string temp_str;
    vector<string> adapt_rules, adapt_noise;
    rulesFileOut.open(rulesFileName.c_str());
    if (!rulesFileOut.is_open())
    {
        yWarning("unable to open rules file!");
        return false;
    }
    for (int t = 0; t < rules.size(); ++t){
        temp_str = rules[t];
        while (true){
            if (temp_str.find(' ') != std::string::npos){
                temp_str.replace(temp_str.find(' '),1,"");
            }
            else if (temp_str.find('\n') != std::string::npos){
                temp_str.replace(temp_str.find('\n'),1,"");
            }
            else if (temp_str.find('\r') != std::string::npos){
                temp_str.replace(temp_str.find('\r'),1,"");
            }
            else {
                break;
            }
        }
        if (temp_str == next_action && next_action != ""){
            int p = 0;
            while (true){
                if (rules[t+p] == ""){
                    adapt_rules = split(rules[t+4], ' ');
                    adapt_rules[2] = static_cast<ostringstream*>( &(ostringstream() << (atof(adapt_rules[2].c_str())/2) ))->str();
                    temp_str = "";
                    for (int h = 0; h < adapt_rules.size(); ++h){
                         temp_str = temp_str + " " + adapt_rules[h];
                    }
                    rules[t+4] = temp_str;
                    adapt_noise = split(rules[t+p-1], ' ');
                    adapt_noise[2] = static_cast<ostringstream*>( &(ostringstream() << (atof(adapt_noise[2].c_str()) +atof(adapt_rules[2].c_str())) ))->str();
                    temp_str = "";
                    for (int h = 0; h < adapt_noise.size(); ++h){
                        temp_str = temp_str + " " + adapt_noise[h];
                    }
                    rules[t+p-1] = temp_str;
                    break;
                }
                p = p +1;
            }
            for (int y = 0; y < rules.size(); ++y){
                rulesFileOut << rules[y] << endl;
            }
            yInfo("rules adapted");
            break;
        }
    }
    rulesFileOut.close();
    return true;
}
/*(Storage override)
** Creates record and saves to DB using IStorage from base IdObj.
** Recursiveness not works for this class, no matter if true or false - here only for inheritance.
*/
void RegistrationStartDate::save(bool recursive)
{
	//create the record
	string record = string("<" + storage->TAG_OBJ + ">");
	record += string("<" + storage->TAG_SERIAL + "=\"" + static_cast<ostringstream*>(&(ostringstream() << SERIAL))->str() + "\">");
	record += string("<" + storage->TAG_ID + "=\"" + static_cast<ostringstream*>(&(ostringstream() << id))->str() + "\">");
	record += string("<" + TAG_DATE + "=\"" + date + "\">");
	record += string("<\\" + storage->TAG_OBJ + ">");
	storage->save(record);
}
Exemple #6
0
void MainWindow::on_button_remove_scientist_clicked() {
    int currentlySelectedScientistIndex = ui->table_scientists->currentIndex().row();

    Scientist currentlySelectedScientist = currentlyDisplayedScientists.at(currentlySelectedScientistIndex);

    int idToRemove = currentlySelectedScientist.getId();

    string stringIdToRemove = static_cast<ostringstream*>(&(ostringstream() << idToRemove) )->str();

    int answer = QMessageBox::question(this, "Confirm", "Are you sure?");

    if (answer == QMessageBox::No) {
        return;
    }

    bool success = sciService.remove(stringIdToRemove);

    if (success) {
        ui->input_filter_scientists->setText("");
        displayAllScientists();
        ui->statusBar->showMessage("Successfully removed scientist", 2500);
        ui->button_remove_scientist->setEnabled(false);
    } else {
        QMessageBox::warning(this, "FAIL", "Failed to remove scientist");
    }
}
void insert_header(int pointCloudSize, int index){

	string number = static_cast<ostringstream*>(&(ostringstream() << index)) ->str();
	string name = "out" + number + ".ply";
	
	ofstream outfile (name);
	if (outfile.is_open())
	{
		outfile << "ply\n";
		outfile << "format ascii 1.0\n";
		outfile << "element face 0";
		outfile << "property list uchar int vertex_indices\n";
		outfile << "element vertex " << pointCloudSize + 1 << "\n";
		outfile << "property float x\n";
		outfile << "property float y\n";
		outfile << "property float z\n";
		outfile << "property uchar diffuse_red\n";
		outfile << "property uchar diffuse_green\n";
		outfile << "property uchar diffuse_blue\n";
		outfile << "end_header\n";

		outfile << "0 0 0 255 0 0\n";

		outfile.close();
	}
	else cout << "Unable to open file";



}
Exemple #8
0
void RoadTransfer::createRoad(b2World* world, CCPoint point, int number)
{
    string str = static_cast<ostringstream*>( &(ostringstream() << number) )->str();
    str = "Floor/roadWall" + str + ".png";
    this->roadBar = CCSprite::create(str.c_str());
    this->roadBar->setPosition(point);
    this->initWithTexture(roadBar->getTexture());
    this->location = point;
    this->setPosition(point);
    b2BodyDef bodyDef1;
    bodyDef1.type = b2_staticBody;
    bodyDef1.position.Set(point.x/32,(point.y)/32);
    this->body = world->CreateBody(&bodyDef1);
    b2PolygonShape dynamicBox;
    dynamicBox.SetAsBox(roadBar->getContentSize().width/64, roadBar->getContentSize().height/70);
    b2FixtureDef fixtureDef1;
    fixtureDef1.shape = &dynamicBox;
    fixtureDef1.density = 10.0f;
    fixtureDef1.friction = 1;
    fixtureDef1.restitution = 0;
    this->body->CreateFixture(&fixtureDef1);
    b2Filter filter;
    filter.groupIndex = -2;
    body->GetFixtureList()[0].SetFilterData(filter);
    this->setPhysicsBody(body);
    this->body->SetGravityScale(0);
}
void SOMClusteringSpace::getPartitionConfiguration() {
  vector<int> indices;
  //Create equivalent indices
  for ( int i = 0; i < (int)assignation.size();i++) {
    int val = assignation.at(i);
    if ( belongs_to( val, indices ) == -1 ) {
      indices.push_back( val );
    }
  }
  for ( int i = 0; i < (int)indices.size(); i++ ) {
    string group_name("");
    group_name.append(patterns_prop_name).append("_");
    group_name.append(static_cast<ostringstream*>(&(ostringstream()<<i))->str() );
    pGraph->addSubGraph(group_name);
  }
  //Now, define the groups
  //IntegerProperty* group = theGraph->getLocalProperty<IntegerProperty>(patterns_prop_name);
  string group_name("");
  Iterator<node>* node_iter = pGraph->getNodes();
  while ( node_iter->hasNext() ) {
    node n = node_iter->next();
    int id = n.id;
    int val = assignation.at(id);
    int new_index = belongs_to( val, indices );
    group_name.append(patterns_prop_name).append("_").append(static_cast<ostringstream*>(&(ostringstream()<<new_index))->str() );
    pGraph->getSubGraph(group_name)->addNode(n);
  	//group->setNodeValue(n,new_index);
    //group_name = "";
  }
  delete node_iter;
}
Exemple #10
0
ReturnType getCamComp::onExecute()
{   	


	//if(pStorageface) cvReleaseMemStorage(&pStorageface);
	//PrintMessage("on execute \n ");
	
	if(capture!=NULL){
		numberFaces=mainFunction();
		std::ostringstream ossnumber;
		ossnumber<<numberFaces;
		stringnumberFaces=ossnumber.str();
		//cout<<"stringnumberfaces"<<stringnumberFaces<<std::endl;
        numberFacesOut.push(numberFaces);
		stringNumberFacesOut.push(stringnumberFaces);
		
		if (numberFaces==0)//sinon on continue d'envoyer les coord du dernier visage detecté
		{
			//PrintMessage("pas de visages \n");
			faceCoordinateOut.push("");

		}
		if (numberFaces!=0) 
			{	
			faceCoordinateOut.push(coordF);
			}
             

		

		if(numberFaces == oldNumberFaces){ if(pourcentFaces<100){pourcentFaces++;}}
		else { if(pourcentFaces>0){pourcentFaces--;}}
        
		if(pourcentFaces>pourcentPrecision)
		  {
		     string stringNumberFaces = static_cast<ostringstream*>( &(ostringstream() << numberFaces) )->str();
	       	 //numberFacesOut.push(stringNumberFaces);
			 oldNumberFaces=numberFaces;

			// PrintMessage("fonction bizare§§§§§§§§§§§§§§§§§§ \n" ); 
			 
            
             
			// voir si necessité d'une raz 
			

	       
		  }

	}
	else { 
		PrintMessage("capture nulle \n ");
	}
	//else{cout<<"capture null"<<std::endl;} 

	
	return OPROS_SUCCESS;
}
Exemple #11
0
void MainWindow::on_button_see_connections_computer_clicked() {
    int currentlySelectedComputerIndex = ui->computer_list_computer_connections->currentIndex().row();
    Computer currentlySelectedComputer = currentlyDisplayedComputers.at(currentlySelectedComputerIndex);
    int idOfComputer = currentlySelectedComputer.getId();
    string StringIdOfComputer = static_cast<ostringstream*>(&(ostringstream() << idOfComputer) )->str();
    vector<Scientist> scientists = sciService.getScientistsByComputerId(StringIdOfComputer);
    displayScientistsForComputerConnections(scientists);
    ui->button_see_connections_computer->setEnabled(false);
}
void ExperienceSystem::RenderScore()
{
	if(mUpdateScoreFlag)
		mUpdateScoreFlag--;
	else
	{
		mUpdateScoreFlag = 60;
		mPlayerScore += Resources::mEnemyList->GetEnemySpeedModifier();
	}

	Resources::mParafontFont->DrawTextAlignedRight(Resources::STR_SCORE_OSD +
												   string(static_cast<ostringstream*>
												   ( &(ostringstream() << GetPlayerScore()) )->str()), 5);
	Resources::mParafontFont->DrawTextAlignedRight(Resources::STR_HI_SCORE_OSD +
												   string(static_cast<ostringstream*>
												   ( &(ostringstream() << Resources::mSkillsSystem->GetHiScore()) )
												   ->str()), 35);
}
Exemple #13
0
void MainWindow::on_button_see_connections_scientist_clicked() {
    int currentlySelectedScientistIndex = ui->scientist_list_scientist_connections->currentIndex().row();
    Scientist currentlySelectedScientist = currentlyDisplayedScientists.at(currentlySelectedScientistIndex);
    int idOfScientist = currentlySelectedScientist.getId();
    string stringIdOfScientist = static_cast<ostringstream*>(&(ostringstream() << idOfScientist) )->str();
    vector<Computer> computers = compService.getComputersByScientistId(stringIdOfScientist);

    displayComputersForScientistConnections(computers);

    ui->button_see_connections_scientist->setEnabled(false);
}
bool OfertaLaboral::EsActiva()
{
    Tiempo* hoy = Tiempo::getInstance();
    string sddHoy = static_cast<ostringstream*>( &(ostringstream() << hoy->now()->getDia()) )->str();
    string smmHoy = static_cast<ostringstream*>( &(ostringstream() << hoy->now()->getMes()) )->str();
    string saaaaHoy = static_cast<ostringstream*>( &(ostringstream() << hoy->now()->getAnio()) )->str();
    string shoy = sddHoy + "/" + smmHoy + "/" + saaaaHoy;
    string sh = saaaaHoy + "-" + smmHoy + "-" + sddHoy + " 00:00";

    string sddCom = static_cast<ostringstream*>( &(ostringstream() << this->fechaComienzo->getDia()) )->str();
    string smmCom = static_cast<ostringstream*>( &(ostringstream() << this->fechaComienzo->getMes()) )->str();
    string saaaaCom = static_cast<ostringstream*>( &(ostringstream() << this->fechaComienzo->getAnio()) )->str();
    string sfechaComienzo = sddCom + "/" + smmCom + "/" + saaaaCom;
    string si = saaaaCom + "-" + smmCom + "-" + sddCom + " 00:00";

    string sddFin = static_cast<ostringstream*>( &(ostringstream() << this->fechaFin->getDia() -1) )->str();
    string smmFin = static_cast<ostringstream*>( &(ostringstream() << this->fechaFin->getMes()) )->str();
    string saaaaFin = static_cast<ostringstream*>( &(ostringstream() << this->fechaFin->getAnio()) )->str();
    string sfechaFin = sddFin + "/" + smmFin + "/" + saaaaFin;
    string sf = saaaaFin + "-" + smmFin + "-" + sddFin + " 00:00";

    struct tm tm;
    time_t tth, tti, ttf;

    strptime(sh.c_str(), "%Y-%m-%d %H:%M", &tm);
    tm.tm_mon = tm.tm_mon + 1;
    tm.tm_year = tm.tm_year + 1900;
    tth = mktime(&tm);

    strptime(si.c_str(), "%Y-%m-%d %H:%M", &tm);
    tm.tm_mon = tm.tm_mon + 1;
    tm.tm_year = tm.tm_year + 1900;
    tti = mktime(&tm);

    strptime(sf.c_str(), "%Y-%m-%d %H:%M", &tm);
    tm.tm_mon = tm.tm_mon + 1;
    tm.tm_year = tm.tm_year + 1900;
    ttf = mktime(&tm);

    double difIni = difftime(tth, tti);
    double difFin = difftime(tth, ttf);

    return ((difIni >= 0) && (difFin <= 0));
}
Exemple #15
0
void Character::setDefaultTransform(){
    CCAnimation *animation = CCAnimation::create();
    for (int i = 1; i <= 6; i++)
    {
        std::string str = static_cast<ostringstream*>(&(ostringstream() << i))->str();
        str = "Animation/Transformation/fx0" + str + ".png";
        animation->addSpriteFrameWithFileName(str.c_str());
    }
    animation->setDelayPerUnit(0.02);
    animation->setLoops(1);
    animation->setRestoreOriginalFrame(true);
    CCAnimate *action = CCAnimate::create(animation);
    this->getSprite()->runAction(CCSequence::create(action,
                                                    CCDelayTime::create(0.08),
                                                    CCCallFuncND::create(this,callfuncND_selector(Character::setSpriteWithIDCharac),(void*)(new int(defaultID))),
                                                    NULL));
}
void LoadFoodRemote::loadFood()
{

	ifstream remoteFoodDb("calories.csv");
	string value;
	int id = totalSimpleFood.size() + 1;

	while(getline(remoteFoodDb,value))
	{
		stringstream stream(value);
		string word;
		list<string> valueList;
		string searchKeys = "";
		string name = "";
		string calories;
		int count = 0;
		while (getline(stream, word, ',') && count <= 1)
		{
			if (count == 0)
			{
				name = word;
				stringstream stream2(word);
				string key = "";
				int count2 = 0;
				while(getline(stream2,key,' '))
				{
					if (count2 == 0)
						searchKeys = key;
					else
						searchKeys = searchKeys + "," + key;
					count2++;
				}
			}
			valueList.push_back(word);
			count++;
		}
		string dictKey = "s" + static_cast<ostringstream*>( &(ostringstream() << id) )->str();
		valueList.push_back(searchKeys);		
		totalSimpleFood[dictKey] = valueList;
		id++;
	}
}
TEST(Fastq, ReadFromFile)
{
    Fastq fq;
    unsigned int counter = 0;
    ifstream inStream("test_files/fastq_unittest.fastq");

    if (! inStream.is_open())
    {
        cerr << "Error opening test file test_files/fastq_unittest.fastq" << endl;
        exit(1);
    }

    while (fq.fillFromFile(inStream))
    {
        counter++;
        string expectedName = static_cast<ostringstream*>( &(ostringstream() << counter) )->str();
        EXPECT_EQ(0, fq.name().compare(expectedName));
        EXPECT_EQ(0, fq.seq().compare("ACGT"));
    }
}
void insert_point
	(double x, double y, double z, int b,
	int g, int r, int index){

		string number = static_cast<ostringstream*>(&(ostringstream() << index)) ->str();
		string name = "out" + number + ".ply";

		ofstream outfile;
		outfile.open(name,ios::app);
		outfile << x << " ";
		outfile << y << " ";
		outfile << z << " ";
		outfile << b << " ";
		outfile << g << " ";
		outfile << r << endl;
		outfile.close();

		//cout << x << " " << y << " " << z << " ";

}
ofxFeatureFinderObject ofxFeatureFinder::createObject() {
    
    std::vector<cv::KeyPoint> selectedKeypoints;
    cv::Mat selectedDescriptors;
    
    vector<ofPolyline>::iterator it;
    int i;
    // collect the selected keypoints
    for(i = 0; i < imageKeypoints.size(); i++ )
    {
        cv::KeyPoint keypt = imageKeypoints.at(i);
        
        for(it = regions.begin(); it != regions.end(); ++it){
            if ((*it).inside(keypt.pt.x, keypt.pt.y)) {
                
                selectedKeypoints.push_back(keypt);
                
                break;
            }
        }
    }
    
    if (selectedKeypoints.size() == 0) {
        return;
    }

    extractor = new cv::SurfDescriptorExtractor();
    extractor->compute(processImageMat, selectedKeypoints, selectedDescriptors);
    delete extractor;
    
    ofxFeatureFinderObject object = ofxFeatureFinderObject(regions, selectedKeypoints, selectedDescriptors);
    object.label = "new object " + static_cast<ostringstream*>( &(ostringstream() << objects.size()) )->str();
    objects.push_back(object);
    
    cout << "added object with " << selectedKeypoints.size() << " keypoints." << endl;

    this->clearRegions();
    
    return object;
}
bool PlannerThread::resetConfig()
{
    string line;
    int horizon;
    vector<string> config_data;
    configFile.open(configFileName.c_str());
    if (!configFile.is_open())
    {
        yWarning("unable to open config file!");
        return false;
    }
    while (getline(configFile, line)){
        config_data.push_back(line);
    }
    for (int i=0; i<config_data.size(); ++i){
        if (config_data[i].find("[PRADA]") != std::string::npos){
            horizon = 5;
            config_data[i+2] = "PRADA_horizon " + static_cast<ostringstream*>( &(ostringstream() << horizon) )->str();
            break;
        }
    }
    configFile.close();
    configFileOut.open(configFileName.c_str());
    if (!configFileOut.is_open())
    {
        yWarning("unable to open config file!");
        return false;
    }
    for (int i = 0; i<config_data.size();++i){
        configFileOut << config_data[i];
        configFileOut << '\n';
    }
    configFileOut.close();
    yInfo("config file reset");
    return true;
}
bool PlannerThread::increaseHorizon()
{
    int horizon;
    string line;
    vector<string> configData, temp_vect;
    configFile.open(configFileName.c_str());
    if (!configFile.is_open())
    {
        yWarning("unable to open config file!");
        return false;
    }
    while (getline(configFile, line)){
        configData.push_back(line);
    }
    for (int w = 0; w < configData.size(); ++w){ 
        if (configData[w].find("[PRADA]") != std::string::npos){
            temp_vect = split(configData[w+2], ' ');
            horizon = atoi(temp_vect[1].c_str());
            horizon = horizon + 1;
            configData[w+2] = "PRADA_horizon " + static_cast<ostringstream*>( &(ostringstream() << horizon) )->str();
            break;
        }
    }
    configFile.close();
    configFileOut.open(configFileName.c_str());
    if (!configFileOut.is_open())
    {
        yWarning("unable to open config file!");
        return false;
    }
    for (int w = 0; w < configData.size(); ++w){
        configFileOut << configData[w] << endl;
    }
    configFileOut.close();
    return true;
}
//event handler for the next button to go from one image to another
void callbackBtnNext(int state, void* dataPassed)
{
	//increase the file counter by 1
	countFile++;
	//if (countFile == 203)
	//	cout << "asd" << endl;
	//construct the next file names
	string countFileStr = static_cast<ostringstream*>( &(ostringstream() << countFile) )->str();
	nameImg = folderRoot + folderImg + "(" + countFileStr + ")" + fileExtImg;
	namePtsFile = folderRoot + folderPts + "(" + countFileStr + ")" + fileExtPts;
	nameResultsFile = folderWrite + prefixResultsFile + "(" + countFileStr + ")" + fileExtResult;
	nameResultsImg = folderWrite + prefixResultsFile + "(" + countFileStr + ")" + fileExtImg;

	//Read the image and store in a matrix
	//cout << nameImg << " is loading..." << endl;	
	//bgrMat = imread(nameImg, cv::IMREAD_COLOR);
	//cvtColor(bgrMat, hsvMat, CV_BGR2HSV);

	//Read the pts file and store x,y,z in a matrix
	//cout << namePtsFile << " is loading..." << endl;
	//Mat xyzMat = Mat::zeros(height, width, CV_64FC3);
	//readPtsDataFromFile(namePtsFile, xyzMat);

	//Calculate the variance of Y and the max diff of Y in patches
	//cout << "Patches are constructing..." << endl;
	//cout << "Variance and Difference in Y calulcation..." << endl;
	//varPatches = calculateVarianceYforPatches(xyzMat, size_patch);
	//diffPatches = calculateDifferenceMaxYforPatches(xyzMat, size_patch);

	//Calculate image patch histograms
	//cout << "Image patch histograms are building..." << endl;
	//histsBGR = calculateHistograms(bgrMat, SIZE_PATCH, CHANNELS, 3, SIZE_HIST, RANGES);
	//histsHS = calculateHistograms(hsvMat, size_patch, channels_hs, 2, size_hist_hs, ranges_hs, false);
	
	//show the original image
	//imshow(nameWindowMain, bgrMat);


	//Tracbar stuff
	//create slider for training sample threshold
	//createTrackbar( nameTrackbarVarYThreshold, nameWindowMain, &thresholdVarY, threshold_var_y_max, callbackTrackbarVarYThreshold );
	//createTrackbar( nameTrackbarDiffYThreshold, nameWindowMain, &thresholdDiffY, THRESHOLD_DIFF_Y_MAX, callbackTrackbarDiffYThreshold );
	//create next button to jump to the next image
	//createButton(nameBtnNext, callbackBtnNext, NULL);
	// Show some stuff
	//callbackTrackbarVarYThreshold( thresholdVarY, 0 );
	//callbackTrackbarDiffYThreshold( thresholdDiffY, 0 );

	//Read the image and store in a matrix
	cout << nameImg << " is loading..." << endl;	
	bgrMat = imread(nameImg, cv::IMREAD_COLOR);

	//Read the pts file and store x,y,z in a matrix
	cout << namePtsFile << " is loading..." << endl;
	Mat xyzMat = Mat::zeros(height, width, CV_64FC3);
	readPtsDataFromFile(namePtsFile, xyzMat);

	//convert the variance threshold value obtained from the trackbar to double
	thresholdVarYd = ((double)thresholdVarY)/threshold_var_y_divider;

	//Get ticks before algorithm
	double t = (double)getTickCount();

	//Mat classifiedMat = detectRoadSingleSVM(bgrMat, xyzMat, trainingBuffer, trainingBufferLib, model, weights, thresholdVarYd, false, distribution);
	Mat classifiedMat = detectRoad(bgrMat, xyzMat, trainingBuffer, means, covs, weights, thresholdVarYd, false, distribution);
	//Mat classifiedMat = detectRoadDebug(bgrMat, xyzMat, trainingBuffer, means, covs, weights, thresholdVarYd, false, distribution);
	//Mat classifiedMat = detectRoadBanded(bgrMat, xyzMat, trainingBuffer, means, covs, weights, thresholdVarYd, false, distribution);

	//cout << "Number of Training Sets : " << trainingBufferLib.size() << endl;
	//for (int i = 0; i < trainingBufferLib.size(); i++)
	//	cout << "Set " << i << " : " << trainingBufferLib[i].rows << endl;
	//for (int i = 0; i < trainingBufferLib.size(); i++)
	//	cout << "Set " << i << " : " << trainingBufferLib[i] << endl;

	//Get tocks after algorithm, find the difference and write in sec form
	t = ((double)getTickCount() - t)/getTickFrequency();
	cout << "Times passed in seconds: " << t << endl;

	//Show the classification result for the Y variance
	namedWindow(nameWindowClassifiedVar, CV_WINDOW_AUTOSIZE);
	imshow(nameWindowClassifiedVar, classifiedMat);

	//////////////////////////////////////////////////////////////////
	///////////////////// WRITING THE RESULTS ////////////////////////
	//////////////////////////////////////////////////////////////////

	//writing the classification results as image and/or text
	cout << "Writing to Image : " << nameResultsImg << endl;
	vector<int> output_params;
	output_params.push_back(CV_IMWRITE_PXM_BINARY);
	output_params.push_back(1);
	imwrite(nameResultsImg, classifiedMat, output_params);
	cout << "Writing to File: " << nameResultsFile << endl;
	writeResultDataToFile(nameResultsFile, classifiedMat);
	cout << "Done..." << endl;

}
int countFile = 1;
//File extensions
const string fileExtImg = ".ppm";
const string fileExtPts = ".pts";
//Folders
//const string folderRoot = "C:\\Users\\KBO\\Dropbox\\Academy\\Projects\\Road Detection, Extraction and Tracking\\Stereo Vision\\Stereo Road Detection\\Software\\RoadDetectionv3 - OpenCV - i7\\RoadDetection\\";
const string folderRoot = "C:\\Users\\KBO\\Documents\\GitHub\\";
const string folderPts = "Data\\Pts\\";
const string folderImg = "Data\\Color\\";
//File names
string nameImg = folderRoot + folderImg + "(1).ppm";
string namePtsFile = folderRoot + folderPts + "(1).pts";

//Results
//Change algorithm params to string
string nBinsStr = static_cast<ostringstream*>( &(ostringstream() << n_bins) )->str();
string sizePatchStr = static_cast<ostringstream*>( &(ostringstream() << size_patch) )->str();
string nSamplesMinStr = static_cast<ostringstream*>( &(ostringstream() << n_samples_min) )->str();
string nClustersMaxStr = static_cast<ostringstream*>( &(ostringstream() << n_clusters_max) )->str();
string nClustersInitialStr = static_cast<ostringstream*>( &(ostringstream() << n_clusters_initial) )->str();
string nClustersNewStr = static_cast<ostringstream*>( &(ostringstream() << n_clusters_new) )->str();
string thresholdUpdateStr = static_cast<ostringstream*>( &(ostringstream() << threshold_update_mahalanobis) )->str();
string thresholdClassifyStr = static_cast<ostringstream*>( &(ostringstream() << threshold_classify_mahalanobis) )->str();
//Result folder
string folderWrite = "results\\";
//Result File name prefix
//string prefixResultsFile = "hs_" + nBinsStr + "bins_" + sizePatchStr + "pchs_" + nSamplesMinStr + "nsmpsmin_" + nClustersMaxStr + "_" + nClustersInitialStr + "_" + nClustersNewStr + "_clst_max_init_new_" + thresholdUpdateStr + "thrUpd_" + thresholdClassifyStr + "thrClsfy_";
string prefixResultsFile = "hs_" + nBinsStr + "bins_" + sizePatchStr + "pchs_" + nSamplesMinStr + "nsmpsmin_" + nClustersMaxStr + "_clst_max_" + thresholdUpdateStr + "thrUpd_" + thresholdClassifyStr + "thrClsfy_";
//Result file extension
const string fileExtResult = ".txt";
//Result file names
string GenericWindow::toString(int myInt)
{
    return static_cast<ostringstream*>( &(ostringstream() << myInt) )->str();
}
Exemple #25
0
// call this to solve the equations and save results to files
// the system will determine the number of steps; all we need is to provide a step length
// returns the system in the state the Leapfrog algoritm leaves it in (or nullptr if that algorithm is not used)
vector<SolarSystem*>* Solvers::Solve(double step)
{
	clock_t start, finish; // timers
	int n = this->_system->nSteps();

	if (this->_useRK4)
	{
		start = clock(); // start timer

		for (int i = 0; i < n; i++) // for each time step
		{
			this->_rk4->plotCurrentStep(i, step); // if we want to plot this step, do it
			RK4(step); // perform step
		}

		// Timing part: End ...
		finish = clock();
		this->rk4Time = (double)(finish - start) / CLOCKS_PER_SEC; // To convert this into seconds !
	}

	if (this->_useLeapfrog)
	{
		start = clock(); // start timer

		for (int i = 0; i < n; i++) // for each time step
		{
			this->_leapfrog->plotCurrentStep(i, step); // if we want to plot this step, do its
			Leapfrog(step); // perform step
		}

		// Timing part: End ...
		finish = clock();
		this->leapfrogTime = (double)(finish - start) / CLOCKS_PER_SEC; // To convert this into seconds !
	}

	if (this->_useEuler)
	{
		start = clock(); // start timer

		for (int i = 0; i < n; i++) // for each time step
		{
			this->_euler->plotCurrentStep(i, step); // if we want to plot this step, do it
			Euler(step); // perform step
		}

		// Timing part: End ...
		finish = clock();
		this->eulerTime = (double)(finish - start) / CLOCKS_PER_SEC; // To convert this into seconds !
	}

	// put systems we want to return in here
	vector<SolarSystem*>* returnSystems = new vector<SolarSystem*>();

	if (this->_useLeapfrog)
	{
		// plot to file (independent of dimension)
		for (int i = 0; i < this->_leapfrog->dim(); i++)
		{
			ostringstream fname = ostringstream();
			fname << "sim_" << this->_leapfrog->name << "_pos" << i << ".dat";
			this->_leapfrog->plotDim(i, fname.str());
		}

		// make sure the system is up to date
		this->_leapfrog->calculate();

		// add to list of systems to return
		returnSystems->push_back(this->_leapfrog);
	}

	if (this->_useRK4)
	{
		// plot to file (independent of dimension)
		for (int i = 0; i < this->_rk4->dim(); i++)
		{
			ostringstream fname = ostringstream();
			fname << "sim_" << this->_rk4->name << "_pos" << i << ".dat";
			this->_rk4->plotDim(i, fname.str());
		}

		// make sure the system is up to date
		this->_rk4->calculate();

		// add to list of systems to return
		returnSystems->push_back(this->_rk4);
	}

	if (this->_useEuler)
	{
		// plot to file (independent of dimension)
		for (int i = 0; i < this->_euler->dim(); i++)
		{
			ostringstream fname = ostringstream();
			fname << "sim_" << this->_euler->name << "_pos" << i << ".dat";
			this->_euler->plotDim(i, fname.str());
		}

		// make sure the system is up to date
		this->_euler->calculate();

		// add to list of systems to return
		returnSystems->push_back(this->_euler);
	}

	cout << "DONE!" << endl << endl;

	this->totalTime = this->leapfrogTime + this->rk4Time + this->eulerTime;

	return returnSystems;
}
Exemple #26
0
/** \brief Convert a int into a string
      * \param n is the number to be converted
      * \return n as string
      */
string static intToStr(int n){
    return static_cast<ostringstream*>( &(ostringstream() << n) )->str();
}
Exemple #27
0
const char* IllegalPlacement::what() const throw() {
    ostringstream stream = ostringstream("");
    stream << runtime_error::what() << "Position " << x << ", " << y
           << "is invalid." << endl;
    return stream.str().c_str();
}
void CommunitySpace::getFinalAssignation( string group_prop_name ) {
    int i;
    int level = 1;
    IntegerProperty* g_assignation = originalGraph->getLocalProperty<IntegerProperty>(group_prop_name);
    ColorProperty* color = originalGraph->getLocalProperty<ColorProperty>("viewColor");
    int communities = theGraph->numberOfNodes();
    //cout << "Calculating final assignation for " << communities << " communities." << endl;
    string group_name("");
    for ( i = 0; i < communities; i++ ) {
        group_name.append(group_prefix).append("_").append(static_cast<ostringstream*>(&(ostringstream()<<i))->str() );
        hierarchy[i] = originalGraph->addSubGraph(group_name);
        group_name = "";
    }
    calculateColorTable(communities);
    color->setAllEdgeValue(Color(0,0,0,5));
    Iterator<node>* nodes = originalGraph->getNodes();
    while ( nodes->hasNext() ) {
        node n = nodes->next();
        i = n.id;
        int index = finalAssignation[0][i];
        while ( level < (int)finalAssignation.size() ) {
            int nindex = finalAssignation[level][index];
            index = nindex;
            level++;
        }
        level = 1;
        addNodeToGroup(index, n, g_assignation, color);
    }
    delete nodes;
}
Exemple #29
0
bool STEPWrapper::convert(BRLCADWrapper *dot_g)
{
    MAP_OF_PRODUCT_NAME_TO_ENTITY_ID name2id_map;
    MAP_OF_ENTITY_ID_TO_PRODUCT_NAME id2name_map;
    MAP_OF_ENTITY_ID_TO_PRODUCT_ID id2productid_map;
    MAP_OF_PRODUCT_NAME_TO_ENTITY_ID::iterator niter = name2id_map.end();

    if (!dot_g) {
	return false;
    }

    this->dotg = dot_g;

    int num_ents = instance_list->InstanceCount();
    for (int i = 0; i < num_ents; i++) {
	SDAI_Application_instance *sse = instance_list->GetSTEPentity(i);
	if (sse == NULL) {
	    continue;
	}
	std::string name = sse->EntityName();
	std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))std::tolower);

	if ((sse->STEPfile_id > 0) && (sse->IsA(SCHEMA_NAMESPACE::e_shape_definition_representation))) {
	    ShapeDefinitionRepresentation *sdr = dynamic_cast<ShapeDefinitionRepresentation *>(Factory::CreateObject(this, (SDAI_Application_instance *)sse));

	    if (!sdr) {
		bu_exit(1, "ERROR: unable to allocate a 'ShapeDefinitionRepresentation' entity\n");
	    } else {
		int sdr_id = sdr->GetId();
		std::string pname  = sdr->GetProductName();
		int product_id = sdr->GetProductId();

		id2productid_map[sdr_id] = product_id;

		if (pname.empty()) {
		    std::string str = "ShapeDefinitionRepresentation@";
		    str = dotg->GetBRLCADName(str);
		    id2name_map[sdr_id] = pname;
		} else {
		    std::string temp = pname;
		    int index = 2;
		    while ((niter=name2id_map.find(temp)) != name2id_map.end()) {
			temp = pname + "_" + static_cast<ostringstream*>( &(ostringstream() << (index++)) )->str();
		    }
		    pname = temp;
		    if ((niter=name2id_map.find(pname)) == name2id_map.end()) {
			id2name_map[sdr_id] = pname;
			name2id_map[pname] = product_id;
			id2name_map[product_id] = pname;
		    }
		}

		AdvancedBrepShapeRepresentation *aBrep = sdr->GetAdvancedBrepShapeRepresentation();
		if (aBrep) {
		    if (pname.empty()) {
			std::string str = "product@";
			pname = dotg->GetBRLCADName(str);
			id2name_map[aBrep->GetId()] = pname;
			id2name_map[product_id] = pname;
		    } else {
			id2name_map[aBrep->GetId()] = pname;
			id2name_map[product_id] = pname;
		    }
		    id2productid_map[aBrep->GetId()] = product_id;

		    if (Verbose()) {
			if (!pname.empty()) {
			    std::cerr << std::endl << "     Generating Product -" << pname ;
			} else {
			    std::cerr << std::endl << "     Generating Product";
			}
		    }

		    LocalUnits::length = aBrep->GetLengthConversionFactor();
		    LocalUnits::planeangle = aBrep->GetPlaneAngleConversionFactor();
		    LocalUnits::solidangle = aBrep->GetSolidAngleConversionFactor();
		    ON_Brep *onBrep = aBrep->GetONBrep();
		    if (!onBrep) {
			delete sdr;
			bu_exit(1, "ERROR: failure creating advanced boundary representation from %s\n", stepfile.c_str());
		    } else {
			ON_TextLog tl;

			if (!onBrep->IsValid(&tl)) {
			    bu_log("WARNING: %s is not valid\n", name.c_str());
			}

			//onBrep->SpSplitClosedFaces();
			//ON_Brep *tbrep = TightenBrep(onBrep);

			mat_t mat;
			MAT_IDN(mat);

			Axis2Placement3D *axis = aBrep->GetAxis2Placement3d();
			if (axis != NULL) {
			    //assign matrix values
			    double translate_to[3];
			    const double *toXaxis = axis->GetXAxis();
			    const double *toYaxis = axis->GetYAxis();
			    const double *toZaxis = axis->GetZAxis();
			    mat_t rot_mat;

			    VMOVE(translate_to,axis->GetOrigin());
			    VSCALE(translate_to,translate_to,LocalUnits::length);

			    MAT_IDN(rot_mat);
			    VMOVE(&rot_mat[0], toXaxis);
			    VMOVE(&rot_mat[4], toYaxis);
			    VMOVE(&rot_mat[8], toZaxis);
			    bn_mat_inv(mat, rot_mat);
			    MAT_DELTAS_VEC(mat, translate_to);
			}

			dotg->WriteBrep(pname, onBrep,mat);

			delete onBrep;
		    }
		} else { // must be an assembly
		    if (pname.empty()) {
			std::string str = "assembly@";
			pname = dotg->GetBRLCADName(str);
		    }
		    ShapeRepresentation *aSR = sdr->GetShapeRepresentation();
		    if (aSR) {
			int sr_id = aSR->GetId();
			id2name_map[sr_id] = pname;
			id2name_map[product_id] = pname;
			id2productid_map[sr_id] = product_id;
		    }
		}
		Factory::DeleteObjects();
	    }
	}
    }
    /*
     * Pickup BREP related to SHAPE_REPRESENTATION through SHAPE_REPRESENTATION_RELATIONSHIP
     *
     * like the following found in OpenBook Part 'C':
     *    #21281=SHAPE_DEFINITION_REPRESENTATION(#21280,#21270);
     *        #21280=PRODUCT_DEFINITION_SHAPE('','SHAPE FOR C.',#21279);
     *            #21279=PRODUCT_DEFINITION('design','',#21278,#21275);
     *                #21278=PRODUCT_DEFINITION_FORMATION_WITH_SPECIFIED_SOURCE('1','LAST_VERSION',#21277,.MADE.);
     *                    #21277=PRODUCT('C','C','NOT SPECIFIED',(#21276));
     *        #21270=SHAPE_REPRESENTATION('',(#21259),#21267);
     *            #21259=AXIS2_PLACEMENT_3D('DANTE_BX_CPU_TOP_1',#21256,#21257,#21258);
     *            #21267=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#21266))
     *                GLOBAL_UNIT_ASSIGNED_CONTEXT((#21260,#21264,#21265))REPRESENTATION_CONTEXT('ID1','3'));
     *
     *    #21271=SHAPE_REPRESENTATION_RELATIONSHIP('','',#21270,#21268);
     *        #21268=ADVANCED_BREP_SHAPE_REPRESENTATION('',(#21254),#21267);
     *    #21272=SHAPE_REPRESENTATION_RELATIONSHIP('','',#21270,#21269);
     *        #21269=MANIFOLD_SURFACE_SHAPE_REPRESENTATION('',(#21255),#21267);
     *
     */
    for (int i = 0; i < num_ents; i++) {
	SDAI_Application_instance *sse = instance_list->GetSTEPentity(i);
	if (sse == NULL) {
	    continue;
	}
	std::string name = sse->EntityName();
	std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))std::tolower);

	if ((sse->STEPfile_id > 0) && (sse->IsA(SCHEMA_NAMESPACE::e_shape_representation_relationship))) {
	    ShapeRepresentationRelationship *srr = dynamic_cast<ShapeRepresentationRelationship *>(Factory::CreateObject(this, (SDAI_Application_instance *)sse));

	    if (srr) {
		ShapeRepresentation *aSR = dynamic_cast<ShapeRepresentation *>(srr->GetRepresentationRelationshipRep_1());
		AdvancedBrepShapeRepresentation *aBrep = dynamic_cast<AdvancedBrepShapeRepresentation *>(srr->GetRepresentationRelationshipRep_2());
		if (!aBrep) { //try rep_1
		    aBrep = dynamic_cast<AdvancedBrepShapeRepresentation *>(srr->GetRepresentationRelationshipRep_1());
		    aSR = dynamic_cast<ShapeRepresentation *>(srr->GetRepresentationRelationshipRep_2());
		}
		if ((aSR) && (aBrep)) {
		    int sr_id = aSR->GetId();
		    MAP_OF_ENTITY_ID_TO_PRODUCT_ID::iterator it = id2productid_map.find(sr_id);
		    if (it != id2productid_map.end()) { // product found
			int product_id = (*it).second;
			int brep_id = aBrep->GetId();

			it = id2productid_map.find(brep_id);
			if (it == id2productid_map.end()) { // brep not loaded yet so lets do that here.
			    string pname = id2name_map[product_id];
			    id2productid_map[brep_id] = product_id;

			    if (Verbose()) {
				if (!pname.empty()) {
				    std::cerr << std::endl << "     Generating Product -" << pname ;
				} else {
				    std::cerr << std::endl << "     Generating Product";
				}
			    }

			    LocalUnits::length = aBrep->GetLengthConversionFactor();
			    LocalUnits::planeangle = aBrep->GetPlaneAngleConversionFactor();
			    LocalUnits::solidangle = aBrep->GetSolidAngleConversionFactor();
			    ON_Brep *onBrep = aBrep->GetONBrep();
			    if (!onBrep) {
				bu_exit(1, "ERROR: failure creating advanced boundary representation from %s\n", stepfile.c_str());
			    } else {
				ON_TextLog tl;

				if (!onBrep->IsValid(&tl)) {
				    bu_log("WARNING: %s is not valid\n", name.c_str());
				}

				//onBrep->SpSplitClosedFaces();
				//ON_Brep *tbrep = TightenBrep(onBrep);

				mat_t mat;
				MAT_IDN(mat);

				Axis2Placement3D *axis = aBrep->GetAxis2Placement3d();
				if (axis != NULL) {
				    //assign matrix values
				    double translate_to[3];
				    const double *toXaxis = axis->GetXAxis();
				    const double *toYaxis = axis->GetYAxis();
				    const double *toZaxis = axis->GetZAxis();
				    mat_t rot_mat;

				    VMOVE(translate_to,axis->GetOrigin());
				    VSCALE(translate_to,translate_to,LocalUnits::length);

				    MAT_IDN(rot_mat);
				    VMOVE(&rot_mat[0], toXaxis);
				    VMOVE(&rot_mat[4], toYaxis);
				    VMOVE(&rot_mat[8], toZaxis);
				    bn_mat_inv(mat, rot_mat);
				    MAT_DELTAS_VEC(mat, translate_to);
				}

				dotg->WriteBrep(pname, onBrep,mat);

				delete onBrep;
			    }
			}
		    }
		}
		Factory::DeleteObjects();
	    }
	}
    }
    if (Verbose()) {
	std::cerr << std::endl << "     Generating BRL-CAD hierarchy." << std::endl;
    }

    for (int i = 0; i < num_ents; i++) {
	SDAI_Application_instance *sse = instance_list->GetSTEPentity(i);
	if (sse == NULL) {
	    continue;
	}
	std::string name = sse->EntityName();
	std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))std::tolower);

	if ((sse->STEPfile_id > 0) && (sse->IsA(SCHEMA_NAMESPACE::e_context_dependent_shape_representation))) {
	    ContextDependentShapeRepresentation *aCDSR = dynamic_cast<ContextDependentShapeRepresentation *>(Factory::CreateObject(this, (SDAI_Application_instance *)sse));
	    if (aCDSR) {
		int rep_1_id = aCDSR->GetRepresentationRelationshipRep_1()->GetId();
		int rep_2_id = aCDSR->GetRepresentationRelationshipRep_2()->GetId();
		int pid_1 = id2productid_map[rep_1_id];
		int pid_2 = id2productid_map[rep_2_id];
		Axis2Placement3D *axis1 = NULL;
		Axis2Placement3D *axis2 = NULL;
		if ((id2name_map.find(rep_1_id) != id2name_map.end()) && (id2name_map.find(rep_2_id) != id2name_map.end())) {
		    string comb = id2name_map[rep_1_id];
		    string member = id2name_map[rep_2_id];
		    mat_t mat;
		    MAT_IDN(mat);

		    ProductDefinition *relatingProduct = aCDSR->GetRelatingProductDefinition();
		    ProductDefinition *relatedProduct = aCDSR->GetRelatedProductDefinition();
		    if (relatingProduct && relatedProduct) {
			string relatingName = relatingProduct->GetProductName();
			int relatingID = relatingProduct->GetProductId();
			string relatedName = relatedProduct->GetProductName();
			int relatedID = relatedProduct->GetProductId();

			if ((relatingID == pid_1) && (relatedID == pid_2)) {
			    axis1 = aCDSR->GetTransformItem_1();
			    axis2 = aCDSR->GetTransformItem_2();
			    comb = id2name_map[rep_1_id];
			    member = id2name_map[rep_2_id];
			} else if ((relatingID == pid_2) && (relatedID == pid_1)) {
			    axis1 = aCDSR->GetTransformItem_2();
			    axis2 = aCDSR->GetTransformItem_1();
			    comb = id2name_map[rep_2_id];
			    member = id2name_map[rep_1_id];
			} else {
			    std::cerr << "Error: Found Representation Relationship Rep_1(name=" << comb << ",Id=" << rep_1_id << ")" << std::endl;
			    std::cerr << "Error: Found Representation Relationship Rep_2(name=" << member << ",Id=" << rep_2_id << ")" << std::endl;
			    std::cerr << "Error: but Relating ProductDefinition (name=" << relatingName << ",Id=" << relatingID << ")"  << std::endl;
			    std::cerr << "Error:     Related ProductDefinition (name=" << relatedName << ",Id=" << relatedID << ")"  << std::endl;
			}
		    }

		    if ((axis1 != NULL) && (axis2 != NULL)) {
			mat_t to_mat;
			mat_t from_mat;
			mat_t toinv_mat;

			//assign matrix values
			double translate_to[3];
			double translate_from[3];
			const double *toXaxis = axis1->GetXAxis();
			const double *toYaxis = axis1->GetYAxis();
			const double *toZaxis = axis1->GetZAxis();
			const double *fromXaxis = axis2->GetXAxis();
			const double *fromYaxis = axis2->GetYAxis();
			const double *fromZaxis = axis2->GetZAxis();
			VMOVE(translate_to,axis1->GetOrigin());
			VSCALE(translate_to,translate_to,LocalUnits::length);

			VMOVE(translate_from,axis2->GetOrigin());
			VSCALE(translate_from,translate_from,-LocalUnits::length);

			// undo from trans/rot
			MAT_IDN(from_mat);
			VMOVE(&from_mat[0], fromXaxis);
			VMOVE(&from_mat[4], fromYaxis);
			VMOVE(&from_mat[8], fromZaxis);
			MAT_DELTAS_VEC(from_mat, translate_from);

			// do to trans/rot
			MAT_IDN(to_mat);
			VMOVE(&to_mat[0], toXaxis);
			VMOVE(&to_mat[4], toYaxis);
			VMOVE(&to_mat[8], toZaxis);
			bn_mat_inv(toinv_mat, to_mat);
			MAT_DELTAS_VEC(toinv_mat, translate_to);

			bn_mat_mul(mat, toinv_mat, from_mat);
		    }

		    dotg->AddMember(comb,member,mat);
		}
		Factory::DeleteObjects();
	    }
	}
    }
    if (!dotg->WriteCombs()) {
	std::cerr << "Error writing BRL-CAD hierarchy." << std::endl;
    }

    return true;
}
Exemple #30
0
 void countValiditemsInPart(std::string string_input ,int line_number) //Plus the number of items (if found)
  {
	  input_line = string_input;
	  std::string sub_input  = input_line;
	  //cout<<input_line <<endl;

	  number_itemfound = 0;
	  pos = 0;
	  resetItemsTempPosition(); //set all item in the line to npos

	  countItemToken(pos); //accounting token in the line
	  Items* found_token =  fetchFirstToken(input_line.size(),pos); //fetch the first token

	  //cout << found_token->getName() <<endl;
	  if(!call_stack.empty() && !call_stack.back()->beginFlag ) //look for the beginning line
	  {
		  //cout << "LOOK FOR THE BEGINNING LINE1" <<endl;
		  pos = processTokenWithBeginChar(pos);
		  //cout << "GET BEGIN :" <<pos <<endl;
	  }
	  else if(!call_stack.empty() && call_stack.back()->beginFlag) //look for the end line
	  {

		 //cout << "LOOK FOR THE END LINE1" <<endl;
		 pos = processTokenWithEndChar(pos);
		 //cout << "GET END : "<<pos <<endl;
	  }

	  if (found_token != NULL)
	  {
		  //cout<< "token is not null!" << found_token->line_position <<endl;
		  if(found_token->beginChar == "" && ( call_stack.back()->beginFlag|| call_stack.empty()) )
		  {
			  //cout << "plus1-nochar "<< found_token->getName() << " "<< pos << " n:"<< found_token->beginChar << endl;
			  plusItem(found_token);
			  pos = found_token->line_position; //set the new position
		  }
		  else if(found_token->beginChar != "" && call_stack.back()->beginFlag )
		  {
		  }
		  else if(call_stack.back()->beginFlag)
		  {
			  pos = found_token->line_position;
		  }
	  }

	  //cout<< " move pos to:" <<pos <<endl;

	  while(pos != std::string::npos)
	  {
		  countItemToken(pos+1);
		 found_token =  fetchFirstToken(input_line.size(),pos+1); //fetch the next token

		 if(found_token != NULL)
		 {
			 pos = found_token->line_position;

		 }

		 if(!call_stack.empty() && !call_stack.back()->beginFlag ) //look for the beginning line
		 {
			 //cout << "LOOK FOR THE BEGINNING LINE2" <<endl;
			 pos = processTokenWithBeginChar(pos + 1);
		 }
		 else if(!call_stack.empty() && call_stack.back()->beginFlag) //look for the end line
		 {
			 //cout << "LOOK FOR THE END LINE2" <<endl;
			 pos = processTokenWithEndChar(pos + 1);
			 //processTokenWithEndChar(pos + 1);
		 }

		 if (found_token != NULL)
		 {
			 if(found_token->beginChar =="" && (call_stack.back()->beginFlag || call_stack.empty()) )
			 {
				 plusItem(found_token);
				 if(pos < found_token->line_position)
				 pos = found_token->line_position; //set the new position
				 //cout<<" ok plus nochar the found token " << pos<< found_token->getName() << endl;
			 }
			 else if(found_token->beginChar != "" && call_stack.back()->beginFlag )
			 {
				 //cout<<" ok plus char the found token " << pos<< found_token->getName() << endl;
			 }
			 else if( !call_stack.back()->beginFlag )
			 {
				 //cout<<"break!"<<endl;
				 break;
			 }
		 }
		 else
		 {
			 break;
		 }
	  }


	  //cout << call_stack.size() <<endl;
	  if(number_itemfound > 1)
	  {
		  string line_string = static_cast<ostringstream*>( &(ostringstream() << line_number) )->str();
		  warning_message += "\nWarning: multiple items found in one line :" + line_string + " " +input_line;
	  }

  }