コード例 #1
0
vector<int> Set::ConvertToVector(Set& set2,TNode* root){
   vector<int>vec;
   if(root!=NULL)
    {
        if(root->left)
            ConvertToVector(set2,root->left);
        vec.push_back(root->data);
        if(root->right)
            ConvertToVector(set2,root->right);
    }
    return vec;
}
コード例 #2
0
void SchedViz::Visit_Msg( const Semantics::Msg &message, TVTrace* trace ) {
	std::string messageName = message.name();
	DBGOUT("\tMessage: " << messageName << " -> ")

	// Create a new schedulable in the traceViz
	TVSchedulable* sched = new TVSchedulable( Message, messageName, true );
	// Determine the sending task
	Semantics::Transmits transmits = message.msgTransmitter();
	Semantics::Task sendingTask = transmits.sendingTask();
	// Determine the receiving tasks
	ReceivesSet receivesSet = message.msgListeners();

	// Loop through all of the scheduling info
	ExecInfoSet execSet = message.info();
	// Make sure there is one ( TTSchedule )
	if (execSet.size() == 1 ) {
		Semantics::ExecInfo execInfo = *execSet.begin();
		// Get the children of various types
		Semantics::Schedule schedChild = execInfo.Schedule_child();
		Semantics::Duration durationChild = execInfo.Duration_child();
		double duration = durationChild.exectimesecs();
		// See if child is a TTSchedule
		if ( Semantics::TTSchedule::meta == schedChild.type() ) {
			// Cast to a TTSchedule
			Semantics::TTSchedule ttSched = Semantics::TTSchedule::Cast( schedChild );
			// Grab the schedule info
			std::string schedule = ttSched.sched();
			// Convert the string to a nice vector
			std::vector< double > schedTimes = ConvertToVector( schedule );
			// Now create visual blocks for each sending
			std::vector< double >::iterator timesIter = schedTimes.begin();
			for ( ; timesIter != schedTimes.end(); timesIter++ ) {
				DBGOUT(*timesIter << " ")
				// Add an instance to the traceViz
				sched->AddInstance( trace, *timesIter, duration );
			}
		}
		// ExecInfo type not supported
		else {
			std::cout << "*** Message: ExecInfo type not currently supported.\n";
		}
	}
	// Debug some info
	else {
		std::cout << "*** Message: Not able to find appropriate ExecInfo.\n";
	}
	// Clean up the command output
	DBGOUT(std::endl)
}
コード例 #3
0
void SchedViz::Visit_Task( const Semantics::Task &task, TVSuperblock *superblock ) {
	std::string taskName = task.name();
	DBGOUT("\tTask: " << taskName << " -> ")

	// Need to create a Task trace
	TVTrace* trace = superblock->AddTrace( taskName );
	// Create a new schedulable in the traceViz
	TVSchedulable* sched = new TVSchedulable( Task, taskName, false );

	// Loop through all of the scheduling info
	ExecInfoSet execSet = task.info();
	// Make sure there is one ( TTSchedule )
	if (execSet.size() == 1 ) {
		Semantics::ExecInfo execInfo = *execSet.begin();
		// Get the children of various types
		Semantics::Schedule schedChild = execInfo.Schedule_child();
		Semantics::Duration durationChild = execInfo.Duration_child();
		double duration = durationChild.exectimesecs();
		// See if child is a TTSchedule
		if ( Semantics::TTSchedule::meta == schedChild.type() ) {
			// Cast to a TTSchedule
			Semantics::TTSchedule ttSched = Semantics::TTSchedule::Cast( schedChild );
			// Grab the schedule info
			std::string schedule = ttSched.sched();
			// Convert the string to a nice vector
			std::vector< double > schedTimes = ConvertToVector( schedule );
			// Now create visual blocks for each invocation
			std::vector< double >::iterator timesIter = schedTimes.begin();
			for ( ; timesIter != schedTimes.end(); timesIter++ ) {
				// Add the task as a trace to the traceViz
				DBGOUT(*timesIter << " ")
				// Add an instance to the traceViz
				sched->AddInstance( trace, *timesIter, duration );
			}
		}
		// ExecInfo type not supported
		else {
			std::cout << "*** Task: ExecInfo type not currently supported.\n";
		}
	}
	// Debug some info
	else {
		std::cout << "*** Task: Not able to find appropriate ExecInfo.\n";
	}
	// Clean up the output
	DBGOUT(std::endl)
}
コード例 #4
0
//---------------------------------------------------------------------------
std::vector<int> NeuralNet::GetConnections() const
{
  #define CHECK_ARCHITECTURE_165254
  #ifdef  CHECK_ARCHITECTURE_165254
  {
    //Read the original connection matrix
    const Array<int> a_copy = this->connectionMatrix;
    //I promise not to change this NeuralNet
    NeuralNet * n = const_cast<NeuralNet*>(this);
    const Array<int> a = n->getConnections();
    assert(a == a_copy);
  }
  #endif

  const std::vector<int> v = ConvertToVector(this->connectionMatrix);
  return v;
}
コード例 #5
0
void SchedViz::Visit_OChan( const Semantics::OChan &oChan, TVSuperblock *superblock ) {
	std::string oChanName = oChan.name();
	DBGOUT("\tOChan: " << oChanName << " -> ")
	// Need to create a OChan trace
	TVTrace* trace = superblock->AddTrace( oChanName );
	// Create a new schedulable in the traceViz
	TVSchedulable* sched = new TVSchedulable( Task, oChanName, false );

	// Setup the peripheral schedule
	ExecInfoSet execInfoSet = oChan.info();
	ExecInfoSet::iterator execInfoIter = execInfoSet.begin();
	// Make sure there is one ( TTSchedule )
	if (execInfoSet.size() == 1 ) {
		Semantics::Schedule schedChild = execInfoIter->Schedule_child();
		Semantics::Duration durationChild = execInfoIter->Duration_child();
		double duration = durationChild.exectimesecs();
		// See if child is a TTSchedule
		if ( Semantics::TTSchedule::meta == schedChild.type() ) {
			// Cast to a TTSchedule
			Semantics::TTSchedule ttSched = Semantics::TTSchedule::Cast( schedChild );
			// Grab the schedule info
			std::string schedule = ttSched.sched();
			// Convert the string to a nice vector
			std::vector< double > schedTimes = ConvertToVector( schedule );
			// Now create visual blocks for each invocation
			std::vector< double >::iterator timesIter = schedTimes.begin();
			for ( ; timesIter != schedTimes.end(); timesIter++ ) {
				// Add the task as a trace to the traceViz
				DBGOUT(*timesIter << " ")
				// Add an instance to the traceViz
				sched->AddInstance( trace, *timesIter, duration );
			}
		}
		// ExecInfo type not supported
		else {
			std::cout << "*** Task: ExecInfo type not currently supported.\n";
		}
	}
	// Clean up the output
	DBGOUT(std::endl)
}
コード例 #6
0
vector<Triangle*> PlyFileParser::ParseFile(string fileName, double scale, Vector3D translation)
{
    VertexCache.clear();
    ModelCache.clear();
    QString qfileName = QString::fromStdString(fileName);
    QFile qFile (qfileName);
    qFile.open(QIODevice::ReadOnly);

    QRegularExpression elementTag = QRegularExpression("(element)\\s(.*?)\\s([0-9]*)");
    QRegularExpression propertyTag = QRegularExpression("(property)\\s(.*?)\\s(.*)");
    QRegularExpression dataLine = QRegularExpression("[0-9\\.\\-]*[\\s\\n]");
    QRegularExpression endHeader = QRegularExpression("end.*");
    
    queue<ElementInfo> elementTypes;
    
    bool finishedParsingHeader = false;
    
    //QTextStream qCout (stdout);
    
    while (!qFile.atEnd())
    {
        QString line = qFile.readLine();
        
        QRegularExpressionMatch elementMatches = elementTag.match(line);

        if(!finishedParsingHeader)
        {
            if (elementMatches.hasMatch())
            {
                ElementInfo elementInfo;
                
                elementInfo.elementName = elementMatches.captured(2).toStdString();
                elementInfo.elementCount = elementMatches.captured(3).toInt();
                
                elementTypes.push(elementInfo);
            }
            
            QRegularExpressionMatch propertyMatch = propertyTag.match(line);
            
            if (propertyMatch.hasMatch())
            {
                PropertyInfo propertyInfo;
                propertyInfo.type = propertyMatch.captured(2).toStdString();
                propertyInfo.name = propertyMatch.captured(3).toStdString();
                
                elementTypes.front().properties.push(propertyInfo);
            }
        }
        else
        {
            ParseDataLine(line, elementTypes.front(), scale, translation);

            elementTypes.front().elementCount--;
            
            if (elementTypes.front().elementCount == 0)
            {
                elementTypes.pop();
            }
        }
        
        if(line.contains(QRegularExpression("end.*")))
        {
            finishedParsingHeader = true;
        }
        
        //qCout << line;
        //qCout.flush();
    }
    
    qFile.close();
    
    return ConvertToVector(ModelCache);
}
コード例 #7
0
//---------------------------------------------------------------------------
std::vector<double> NeuralNet::GetWeights() const
{
  const std::vector<double> v = ConvertToVector(this->weightMatrix);
  return v;
}