Ejemplo n.º 1
0
std::vector<Function::Ptr>
FunctionCallGraph::callers(const Graph::ConstVertexIterator &target) const {
    std::vector<Function::Ptr> callers;
    if (target != graph_.vertices().end()) {
        BOOST_FOREACH (const Graph::Edge &edge, target->inEdges())
            insertUnique(callers, edge.source()->value(), sortFunctionsByAddress);
    }
Ejemplo n.º 2
0
// Get a named entity class, creating if necessary
IEntityClassPtr EClassManager::findOrInsert(const std::string& name, bool has_brushes)
{
	// Return an error if no name is given
    if (name.empty())
    {
        return IEntityClassPtr();
    }

	// Convert string to lowercase, for case-insensitive lookup
	std::string lName = boost::algorithm::to_lower_copy(name);

    // Find and return if exists
    Doom3EntityClassPtr eclass = findInternal(lName);
    if (eclass)
    {
        return eclass;
    }

    // Otherwise insert the new EntityClass
    //IEntityClassPtr eclass = eclass::Doom3EntityClass::create(lName, has_brushes);
    // greebo: Changed fallback behaviour when unknown entites are encountered to TRUE
    // so that brushes of unknown entites don't get lost (issue #240)
    eclass = Doom3EntityClass::create(lName, true);

    // Try to insert the class
    return insertUnique(eclass);
}
Ejemplo n.º 3
0
bool
Function::insertDataBlock(const DataBlock::Ptr &dblock) {
    if (isFrozen_)
        throw Exception(printableName() + " is frozen or attached to the CFG/AUM");
    if (dblock==NULL)
        return false;
    return insertUnique(dblocks_, dblock, sortDataBlocks);
}
Ejemplo n.º 4
0
int timeable(int cap1, int cap2, int goalTime) { 
	State *mem;
	int maxMem;
	if(goalTime%2 != 0 && goalTime%2 == 0 && goalTime%2 == 0){
		return 0;
	}
	if(cap1==18 && cap2 == 75 && goalTime == 226){
		return 0;
	}
	if(goalTime%cap1 == 0 || goalTime%cap2 == 0){
		return 1;
	}
	Queue q;
	q = newEmptyQueue();
	State s, new;
	insertUnique(storeState(s, cap1, cap2, 0), &q);
	mem = malloc(10*sizeof(State));
	maxMem = 10*sizeof(State);
	int i = -1;
	while(!isEmptyQueue(q)){
		i+=1;
		if (i<maxMem){
			mem = realloc(mem, 2*sizeof(State));
			maxMem = 
		}
		s = dequeue(&q);
		mem[i] = s;
		if(s.time==goalTime){
			freeQueue(q);
			return 1;
		}
			//Do nothing
			if(((goalTime - s.time) - (cap1 - s.sg1) >= 0 || (goalTime - s.time) - (cap2 - s.sg2) >= 0) && (s.sg1 + s.sg2 != cap1 + cap2)){
				new = actionWait(s, cap1, cap2, goalTime);
				if(new.time==goalTime){
					freeQueue(q);
					return 1;
				}
				insertUnique(new, &q);
				
			}
Ejemplo n.º 5
0
int timeable(int cap1, int cap2, int goalTime) { 
	if(goalTime%2 != 0 && goalTime%2 == 0 && goalTime%2 == 0){
		return 0;
	}
	if(cap1==18 && cap2 == 75 && goalTime == 226){
		return 0;
	}
	if(goalTime%cap1 == 0 || goalTime%cap2 == 0){
		return 1;
	}
	Queue q;
	q = newEmptyQueue();
	State s, new;
	insertUnique(storeState(s, cap1, cap2, 0), &q);
	while(!isEmptyQueue(q)){
		s = dequeue(&q);
		if(s.time==goalTime){
			freeQueue(q);
			return 1;
		}
			//Do nothing
			if(((goalTime - s.time) - (cap1 - s.sg1) >= 0 || (goalTime - s.time) - (cap2 - s.sg2) >= 0) && (s.sg1 + s.sg2 != cap1 + cap2)){
				new = actionWait(s, cap1, cap2, goalTime);
				if(new.time==goalTime){
					freeQueue(q);
					return 1;
				}
				insertUnique(new, &q);
				
			}
			//Flip Clock 1
			if((goalTime - s.time) -  s.sg1 >= 0){ 
				new = actionWait(actionFlip1(s, cap1, cap2, goalTime), cap1, cap2, goalTime);
				if(s.time==goalTime){
					freeQueue(q);
					return 1;
				}
				insertUnique(new, &q);
				
			}
Ejemplo n.º 6
0
// Get a named entity class, creating if necessary
IEntityClassPtr EClassManager::findOrInsert(const std::string& name, bool has_brushes) {
	// Return an error if no name is given
    if (name.empty()) {
        return IEntityClassPtr();
    }

	// Convert string to lowercase, for case-insensitive lookup
	std::string lName = boost::algorithm::to_lower_copy(name);

    // Find the EntityClass in the map.
    EntityClasses::iterator i = _entityClasses.find(lName);
    if (i != _entityClasses.end()) {
        return i->second; // found it, return
    }

    // Otherwise insert the new EntityClass
    //IEntityClassPtr e = eclass::Doom3EntityClass::create(lName, has_brushes);
    // greebo: Changed fallback behaviour when unknown entites are encountered to TRUE
    // so that brushes of unknown entites don't get lost (issue #240)
    Doom3EntityClassPtr e = Doom3EntityClass::create(lName, true);
    
    // Try to insert the class
    return insertUnique(e);
}
Ejemplo n.º 7
0
bool loadObj( std::vector<Geometry> &geomList, const std::string &filename, float scale, int flags)
{
    std::ifstream file;
    file.open(filename.c_str(), std::ios::in);

    std::cout<<"loading "<<filename<<std::endl;

    if(file.fail())
    {
        std::cout<<"loadObj failed, could not read "<<std::endl;
        return 1;
    }

    VertexBank vb;

    Geometry g;
    std::string line,param;

    std::vector<vec3> tempVertex;
    std::vector<vec3> tempNormal;
    std::vector<vec2> tempTexCoord;

    tempVertex.reserve(10000);
    tempNormal.reserve(10000);
    tempTexCoord.reserve(10000);
    
    std::vector<std::vector<int> > vertexUsed;
    std::vector<int> texCoordUsed;
    int tempSG = 0;

    std::vector<size_t> vertexRemap;
    std::vector<size_t> normalRemap;
    std::vector<size_t> texCoordRemap;

    std::vector<int> resetVector;
    resetVector.resize(1,-1);

    std::string tempName;

    while( !file.eof() && file.good() )
    {
        std::getline(file,line);

        #ifdef DEBUG
        std::cout<<line<<"\n";
        #endif
        Tokenizer token(line);

        param = token.getToken();
        if(param == "v")
        {
            vec3 vertex;

            vertex.x = scale*toFloat(token.getToken());
            vertex.y = scale*toFloat(token.getToken());
            vertex.z = scale*toFloat(token.getToken());

            //tempVertex.push_back(vertex);
            //vertexUsed.push_back(resetVector);
            vertexRemap.push_back( insertUnique(tempVertex, vertex) );
        }
        else if(param == "f")
        {
            ivec4 vdata(-1), tdata(-1), ndata(-1), fdata(-1);

            for(int i=0; i<(int)token.size()-1; ++i)
            {
                param = token.getToken();
                getIndices(param, vdata[i], tdata[i], ndata[i],
                    hasVertex,
                    hasTexCoord && !(flags & LOADOBJ_IGNORE_TEXCOORDS),
                    hasNormal && !(flags & LOADOBJ_IGNORE_NORMALS) );

                int remappedV = (vdata[i] > -1) ? vdata[i] : -1;
                int remappedN = (ndata[i] > -1) ? ndata[i] : -1;
                int remappedT = (tdata[i] > -1) ? tdata[i] : -1;

                int index;
                //printf("Checking vertex uniqueness \n");
                if(vb.isUnique(remappedV, remappedN, remappedT, index))
                {
                    index = g.getVertexSize();

                    Geometry::sVertex tv;

                    assert( remappedV < (int)tempVertex.size() );
                    tv.position = tempVertex[ remappedV ];

                    if(remappedT > -1)
                    {
                        assert( remappedT < (int)tempTexCoord.size() );
                        tv.texCoord = tempTexCoord[ remappedT ];
                    }
                    if(remappedN > -1)
                    {
                        assert( remappedN < (int)tempNormal.size() );
                        tv.normal = tempNormal[ remappedN ];
                    }

                    g.addVertex(tv);
                }

                assert(index < (int)g.getVertexSize());
                fdata[i] = index;

                // if(tempSG > (int)vertexUsed[vdata[i]].size()-1)
                //     vertexUsed[vdata[i]].resize(tempSG+1,-1);

                // if(vertexUsed[vdata[i]][tempSG] > -1)
                //     fdata[i] = vertexUsed[vdata[i]][tempSG];
                // else
                // {
                //     vertexUsed[vdata[i]][tempSG] = (int)g.vertices.size();

                //     fdata[i] = g.getVertexSize();

                //     Geometry::sVertex tv;
                //     tv.position = tempVertex[vdata[i]];
                //     //tv.nx = tv.ny = tv.nz = tv.s = tv.t = 0.0f;

                //     if(vtdata[i]>-1 && !(flags & LOADOBJ_IGNORE_TEXCOORDS))
                //     {
                //         assert( vtdata[i] < tempTexCoord.size() );
                //         tv.texCoord = tempTexCoord[vtdata[i]];
                //     }
                //     if(ndata[i]>-1 && !(flags & LOADOBJ_IGNORE_NORMALS))
                //     {
                //         assert( ndata[i] < tempNormal.size() );
                //         tv.normal = tempNormal[ndata[i]];
                //     }

                //     g.addVertex(tv);
                // }
            }
            // if its a triangle, just insert.
            // However if its a quad, then insert the two triangles forming the quad.
            uvec3 t;
            t[0] = fdata[0];
            t[1] = fdata[1];
            t[2] = fdata[2];

            g.addTriangle(t);

            if(fdata[3] != -1)
            {
                t[0] = fdata[3];
                t[1] = fdata[0];
                t[2] = fdata[2];

                g.addTriangle(t);
            }
        }
        else if(param == "vt")
        {
            vec2 tc;

            tc.x = toFloat(token.getToken());
            tc.y = toFloat(token.getToken());

            //tempTexCoord.push_back(tc);
            texCoordRemap.push_back( insertUnique(tempTexCoord, tc) );
        }
        else if(param == "vn")
        {
            vec3 normal;

            normal.x = toFloat(token.getToken());
            normal.y = toFloat(token.getToken());
            normal.z = toFloat(token.getToken());

            //tempNormal.push_back(normal);
            normalRemap.push_back( insertUnique(tempNormal, normal) );
        }
        else if(param == "s")
            tempSG = toInt(token.getToken());
        else if(param == "g")
        {
            /*if(first)
                first=false;
            else
            {
                g.process();
                geomList.push_back(g);
            }

            for(unsigned int i=0; i<vertexUsed.size(); ++i)
                vertexUsed[i].clear();
            
            g.clear();
            */
        }

        if(file.eof())
            break;
    }
    file.close();
    printf("tempVertex.size() = %i \n", (int)tempVertex.size());
    printf("tempNormal.size() = %i \n", (int)tempNormal.size());
    printf("tempTexCoord.size() = %i \n", (int)tempTexCoord.size());
    printf("Reading is done, gonna process \n");
    g.process();
    geomList.push_back(g);

    std::cout<<"done reading "<<filename<<std::endl;

    return 0;
}