/*
Trace a forrest and create a polygon for each tree.
*/
bool
traceForrest(vector<Vertex<CParticleF>*>& forrest, vector<Edge<CParticleF>*>& edges)
{
	for (int i = 0; i < edges.size(); ++i)
	{
		edges[i]->type = Tr;
	}

	while (true)
	{

		bool bDone = true;
		for (int j = 0; j < edges.size(); ++j)
		{
			if (edges[j]->type == Tr)
			{
				vector<Edge<CParticleF>*> path = _trace(edges[j]);
				vector<MovingParticle*> points = ParticleSimulator::initializePolygon(path);
				bDone = false;
				break;
			}
		}
		if (bDone)
		{
			break;
		}
	}
	return true;
}
Пример #2
0
////////////////////////////////////////////////////////////////////////////////
//Traces the given message - Overloaded for including FileName and Line number
////////////////////////////////////////////////////////////////////////////////
void Tracer::_trace(
    const char* fileName,
    const Uint32 lineNum,
    const TraceComponentId traceComponent,
    const char* fmt,
    va_list argList)
{
    char* message;
    //
    // Allocate memory for the message string
    // Needs to be updated if additional info is added
    //
    message = new char[strlen(fileName) +
        _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8];
    sprintf(
       message,
       "[%u:%s:%s:%u]: ",
       System::getPID(),
       Threads::id().buffer,
       fileName,
       lineNum);

    _trace(traceComponent, message, fmt, argList);
    delete [] message;
}
Пример #3
0
    int LOG_MSG(const char *fmt, ...)
    {
        int ret;
        va_list ap;

        va_start(ap, fmt);
        ret = _trace(&log_lfi, fmt, ap);
        va_end(ap);

        return ret;
    }
Пример #4
0
    int TRACE_SHORTMSG(const char *fmt, ...)
    {
        int ret;
        va_list ap;

        va_start(ap, fmt);
        ret = _trace(&shortmessage_lfi, fmt, ap);
        va_end(ap);

        return ret;
    }
Пример #5
0
    int TRACE_CALLDEBUG(const char *fmt, ...)
    {
        int ret;
        va_list ap;

        va_start(ap, fmt);
        ret = _trace(&calldebug_lfi, fmt, ap);
        va_end(ap);

        return ret;
    }
Пример #6
0
PUBLIC void genimage()
{
        WORD pc = 0;
        int i;
        register Code *c;
        register WORD tag;
        asm_Module *m;
	VMRef curblock;

	curmod = module0;
	m = VMAddr(asm_Module,curmod);
	curblock = m->start;
	
	VMlock(curblock);

	code = VMAddr(Code,curblock);

	VMDirty(curblock);
	
        imageheader(simPc+4);		/* +4 for trailing 0 */

        codepos = 0;

        for(;;)
        {
        	tag = (c = code)->type;
        	
        	oldloc = c->loc;
        	    
		if( tag == s_newseg ) 
		{
	    		VMunlock(curblock);
			curblock = c->value.v;
		    	VMlock(curblock);
	    		code = VMAddr(Code,curblock);
	    		VMDirty(curblock);
		    	continue;
		}

		if ( tag == s_end )
		{
			VMunlock(curblock);
			m = VMAddr(asm_Module,curmod);
	                curmod = m->next;
	                if( NullRef(curmod) ) break;

	                m = VMAddr(asm_Module,curmod);

			curblock = m->start;
			VMlock(curblock);
			code = VMAddr(Code,curblock);
			VMDirty(curblock);
        	        continue;
		}

                if( pc != code->loc ) error("Phase error in Genimage");

                if( 0 <= tag && tag <= 15 )     /* a direct operation */
                {
			WORD pf;
                        WORD val = eval((WORD)code->vtype,code->value.w,(WORD)pc+code->size);
                        trace("%8x: Fn %2x %2x %8x",pc,tag,etype,val);
                        /* El Grando Kludgerama - under certain pathalogical
                           curcumstances we have to generate a value in
                           more bytes than strictly necessary to get the code
                           offsets to work. The following line sorts this out
                           for us.
                        */
                        pf=pfsize(val);

                        
                        if( pf < c->size ) 
			{
if(traceflags&db_kludge)
	_trace("%8x: Kludge fix %d -> %d type %d value %d vtype %d",pc,
		pfsize(val),(WORD)code->size,tag,val,(WORD)code->vtype);
				waste += c->size-pf;
				while( pf++ < code->size ) outbyte1(f_pfix);
			}
			else if( pf > code->size ) 
			{
_trace("pf %d c->size %d; code %x val %x",pf,c->size,tag,val);
				error("Code size error");
			}
			
                        encode( (WORD)(tag<<4), val, outbyte1);
                        goto next;
                }

                switch( (int)tag )
                {
		case s_newfile:
			strcpy(infile,(char *)code->value.w);
			break;

                case s_bss:
                        trace("%8x: BSS %d",pc,(WORD)code->size);
                        for( i = 0; i < code->size ; i++ ) outbyte(0);
                        break;

                case s_literal:
                        trace("%8x: CODE %d",pc,(WORD)code->size);
                        for( i = 0; i < code->size ; i++ )
                                outbyte(((UBYTE *)(&code->value.w))[i]);
                        break;

                case s_code:
                {
                	UBYTE *v = VMAddr(UBYTE,code->value.v);
                        trace("%8x: CODE %d",pc,(WORD)code->size);
                        for( i = 0; i < code->size ; i++ )
                                outbyte(v[i]);
                        break;
		}
		
                case s_init:
                        trace("%8x: INIT",pc);
                        if( NullRef(code->value.v) ) outword(0L);
                        else {
                                WORD next = VMAddr(Code,code->value.v)->loc;
                                outword((WORD)(next-pc));
                        }
                        break;

                case s_word:
                {
                        WORD val = eval((WORD)code->vtype,code->value.w,(WORD)pc);
                        trace("%8x: WORD %2x %8x",pc,etype,val);
                        if( asize(pc) != 0 ) warn("WORD not on word boundary");
                        /* default to val */
                        outword(val);
                        break;
                }

                case s_align:
                        trace("%8x: ALIGN %d",pc,(WORD)code->size);
                        waste += code->size;
                        for( i = 0 ; i < code->size ; i++ ) outbyte1(f_pfix);
                        break;

		case s_module:
                case s_global:
                case s_data:
                case s_common:
		case s_size:
		case s_ref:
                        break;

                }

        next:
                pc += code->size;
                code++;
        }
        
       outword(0L);	/* image trailer, replaces end.p */
}