void UpsamplingParaDlg::runProjection()
{
	cout << "void UpsamplingParaDlg::runProjection()" << endl;
	m_paras->upsampling.setValue("Run Projection", BoolValue(true));
	area->runUpsampling();
	m_paras->upsampling.setValue("Run Projection", BoolValue(false));
	area->dataMgr.recomputeQuad();
	area->updateGL();
}
Exemplo n.º 2
0
Bool DIR_ItrRemove(Iterator * itr)
{
    Bool ok = False;
    DirIterator * di = CAST(itr,DirIterator,itr);
    DirType type = di->entry.type;
    size_t dirlen = STRBUF_Length(&di->dirName);
    if (STRBUF_Alloc(&di->dirName, dirlen+STRBUF_Length(&di->fileName)+1)) {
        Str fullName;
        Bool isDir;
        STRBUF_AppendChar(&di->dirName, FILE_SEPARATOR_CHAR);
        STRBUF_AppendBuf(&di->dirName, &di->fileName);
        fullName = STRBUF_Text(&di->dirName);
        if (type == DTypeUnknown) {
            isDir = FILE_IsDir(fullName);
        } else {
            isDir = BoolValue(type == DTypeDir);
        }
        if (isDir) {
            ok = FILE_RmDir(fullName, True);
        } else {
            ok = FILE_Delete(fullName);
        }
        STRBUF_SetLength(&di->dirName, dirlen);
        di->entry.dir = STRBUF_Text(&di->dirName);
    }
    return ok;
}
Exemplo n.º 3
0
/**
 * Returns the next pseudorandom, uniformly distributed 32-bit integer
 * value from this random number generator's sequence. 
 */
I32s RANDOM_NextI32(Random * r)
{
    Bool unlock = BoolValue(r->syn && MUTEX_Lock(&r->mutex)); 
    I32s next =  NEXT_RANDOM(r,32); 
    if (unlock) MUTEX_Unlock(&r->mutex);
    return next;
}
Exemplo n.º 4
0
/**
 * Generates unique file name. Makes sure such file does not exist.
 * There's still non-zero probability that two processes would step 
 * on each other, but hell with it :)
 */
void FILE_MakeUnique(Char * name, size_t fixedPart, size_t randomPart) 
{
    Bool exists;
    do {
        FILE_TempName(name + fixedPart, randomPart);
        exists = BoolValue(!FILE_NonExist(name));
    } while (exists);
}
Exemplo n.º 5
0
QScriptValue IRichParameterSet_prototype_setBool(QScriptContext* c,QScriptEngine* e)
{
	RichParameterSet* rset = qscriptvalue_cast<RichParameterSet*>(c->thisObject());
	QString varname = c->argument(0).toString();
	bool val = c->argument(1).toBool();
	rset->setValue(varname,BoolValue(val));
	return e->undefinedValue();
}
Exemplo n.º 6
0
/**
 * Returns the seed that can be used to restart the current pseudorandom 
 * number sequence from its current point.
 */
Seed RANDOM_GetState(const Random * r)
{
    Seed state = (Seed)0;
    if (r->rng.rng_state) {
        Bool unlock = BoolValue(r->syn && MUTEX_Lock((Mutex*)(&r->mutex))); 
        state = (*(r->rng.rng_state))(r->ctx);
        if (unlock) MUTEX_Unlock((Mutex*)(&r->mutex));
    }
    return state;
}
Exemplo n.º 7
0
/**
 * Checks the gzip header of a zf stream opened for reading.  Assumes that 
 * the stream zf has already been created sucessfully; zf->in->avail_in is 
 * zero for the first time, but may be non-zero for concatenated .gz files.
 */
STATIC Bool ZipSkipHeader(Zip * zf)
{
    int method; /* method byte */
    int flags;  /* flags byte */
    int len;    /* buyes read so far */
    int c;

    /* check the gzip magic header */
    if ((c = ZipGetByte(zf)) != GzMagic[0]) {
        ZipPushBack(zf);
        TRACE("ZIP: no magic[0]\n");
        return False;
    } else if ((c = ZipGetByte(zf)) != GzMagic[1]) {
        ZipPushBack(zf);
        ZipPushBack(zf);
        TRACE("ZIP: no magic[1]\n");
        return False;
    }

    method = ZipGetByte(zf);
    flags = ZipGetByte(zf);
    if (method != Z_DEFLATED || (flags & GZ_RESERVED) != 0) {
        TRACE("ZIP: unsupported method/flags\n");
        return False;
    }

    /* discard time, xflags and OS code: */
    for (len = 0; len<6; len++) (void)ZipGetByte(zf);

    /* skip the extra field */
    if ((flags & GZ_EXTRA_FIELD) != 0) { 
        len  =  ZipGetByte(zf);
        len +=  ZipGetByte(zf)<<8;

        /* len is garbage if EOF but the loop below will quit anyway */
        while (len-- != 0 && ZipGetByte(zf) != EOF) NOTHING;
    }

    /* skip the original file name */
    if ((flags & GZ_ORIG_NAME) != 0) { 
        while ((c = ZipGetByte(zf)) != 0  && c != EOF) NOTHING;
    }

    /* skip the .gz file comment */
    if ((flags & GZ_COMMENT) != 0) {   
        while ((c = ZipGetByte(zf)) != 0  && c != EOF) NOTHING;
    }

    /* skip the header crc */
    if ((flags & GZ_HEAD_CRC) != 0) {  
        for (len=0; len<2; len++) (void)ZipGetByte(zf);
    }

    return BoolValue((zf->zflags & (ZIP_IN_ERR | ZIP_IN_EOF)) == 0);
}
Exemplo n.º 8
0
/**
 * Sets the seed of this random number generator. 
 */
Seed RANDOM_SetSeed(Random * r, Seed s)
{
    Bool unlock = BoolValue(r->syn && MUTEX_Lock(&r->mutex)); 
    r->seed = s;
    (*(r->rng.rng_seed))(r->ctx, s);
#ifndef __KERNEL__
    r->haveNextGaussian = False;
#endif /* __KERNEL__ */
    if (unlock) MUTEX_Unlock(&r->mutex);
    return s;
}
Exemplo n.º 9
0
/**
 * Returns a pseudorandom, uniformly distributed 32-bit integer value
 * between 0 (inclusive) and the specified value (exclusive), drawn 
 * from this random number generator's sequence.
 */
I32s RANDOM_NextInt32(Random * r, int n)
{
    Bool unlock = BoolValue(r->syn && MUTEX_Lock(&r->mutex)); 
    I32s bits, val;
    ASSERT(n>0);

    if ((n & -n) == n) { /* i.e., n is a power of 2 */
        I64s next = (I64s)NEXT_RANDOM(r,31);
        if (unlock) MUTEX_Unlock(&r->mutex);
        return (I32s)((n * next) >> 31);
    }
Exemplo n.º 10
0
/**
 * Removes the directory. If recurse parameter is True, also removes 
 * all files and subdirectories, otherwise it fails if directory is not
 * empty.
 */
Bool FILE_RmDir(Str dir, Bool recurse) 
{
    if (FILE_IsDir(dir)) {
        if (recurse) {
            FILE_List(dir, RmDirCB, NULL);
        }
#ifdef _WIN32
        return RemoveDirectory(dir);
#else
        return BoolValue(Rmdir(dir) == 0);
#endif /* WIN32 */
    }
    return False;
}
Exemplo n.º 11
0
/*virtual*/ void DiscrepancyNorm::Deserialize (const std::string& serialization_data) {

	std::stringstream ss(serialization_data);

	try {
		ss >> _factor >> _inplace;
		Arguments params = GetParameterSignature();
		DoubleValue(params[0]).SetData (_factor);
		BoolValue(params[1]).SetData (_inplace);
		Initialize (params);
	} catch (...) {
		throw exception::DeserializationException("Edge/DiscrepancyNorm deserialization failed.");
	}
}
Exemplo n.º 12
0
/**
 * Determines if the calling thread has WRITE access to the resource 
 * protected by the lock.
 */
Bool RWLOCK_CanWrite(const RWLock * lock) 
{
    if (lock->locks > 0 && (lock->flags & RWLOCK_FLAG_EXCLUSIVE_LOCK)) {
        const RWEntry * entry = RWLOCK_FindStaticEntry(lock);
        if (!entry && lock->entriesInUse > STATIC_ENTRIES) {
            /* must synchronize access to the "extended" entries */
            RWLOCK_GrabMutex(lock);
            entry = RWLOCK_FindExtEntry(lock);
            RWLOCK_ReleaseMutex(lock);
        }
        return BoolValue(entry != NULL);
    }
    return False;
}
Exemplo n.º 13
0
void OptionsManager::Load()
{
	TiXmlDocument doc;
	std::string file;

	file.append(XML_FOLDER);
	file.append("Options.xml");

	int ret = doc.LoadFile(file.c_str());
	assert(ret != 0);

	TiXmlElement* optionsElement = doc.FirstChildElement();
	for (auto a = optionsElement->FirstAttribute(); a; a = a->Next())
	{
		if (IsEqual(a->Name(), "fullscreen"))
		{
			m_fullscreen = a->BoolValue();
		}
	}
}
Exemplo n.º 14
0
/**
 * Sends all the data compressed so far to the underlying stream.
 */
STATIC Bool ZipFlush2(Zip * zf, int flush)
{
    if (zf->out) {
        int zerr = Z_OK;
        Bool done = False;

        ASSERT(!zf->out->avail_in);
        zf->out->avail_in = 0; /* should be zero already anyway */

        for (;;) {
            int len = zf->bufsize - zf->out->avail_out;
            if (len != 0) {
                if (FILE_Write(zf->f, zf->outbuf, len) != len) {
                    zf->zflags |= ZIP_OUT_ERR;
                    return False;
                }

                zf->out->next_out = zf->outbuf;
                zf->out->avail_out = zf->bufsize;
            }

            if (done) break;
            zerr = deflate(zf->out, flush);

            /* ignore the second of two consecutive flushes */
            if (len == 0 && zerr == Z_BUF_ERROR) zerr = Z_OK;

            /* deflate has finished flushing only when it hasn't used 
             * up all the available space in the output buffer
             */
            if (zf->out->avail_out || zerr == Z_STREAM_END) {
                done = True;
            }
            if (zerr != Z_OK && zerr != Z_STREAM_END) break;
        }
        return BoolValue(FILE_Flush(zf->f) && (zerr == Z_STREAM_END));
    }
    return True;
}
Exemplo n.º 15
0
CPPPrimitiveValue CPPBoolType::BitwiseOr(const CPPPrimitiveValue& inLeftValue,const CPPPrimitiveValue& inRightValue)
{
	return BoolValue(inLeftValue.mBoolValue | inRightValue.mBoolValue);
}
Exemplo n.º 16
0
/**
 * Returns True if RNG supports the notion of state.
 */
Bool RANDOM_HasState(const Random * r)
{
    return BoolValue(r->rng.rng_state != NULL);
}
Exemplo n.º 17
0
CPPPrimitiveValue CPPBoolType::ExclusiveOr(const CPPPrimitiveValue& inLeftValue,const CPPPrimitiveValue& inRightValue)
{
	return BoolValue(inLeftValue.mBoolValue ^ inRightValue.mBoolValue);
}
Exemplo n.º 18
0
CPPPrimitiveValue CPPBoolType::UnaryMinus(const CPPPrimitiveValue& inValue)
{
	return BoolValue(-(inValue.mBoolValue ? 1:0) == 1 ? true:false);
}
Exemplo n.º 19
0
TypedValue	&
TypedValue::operator || (TypedValue &t2)
{
	return Bool((BoolValue(nullptr) && t2.BoolValue(nullptr)));
}
Exemplo n.º 20
0
STATIC Bool QUEUE_ItrHasNext(Iterator * itr)
{
    QueueIterator * qi = CAST(itr,QueueIterator,itr);
    return BoolValue(qi->next != NULL);
}
Exemplo n.º 21
0
Bool WKI_IsDone(WorkItem * w)
{
    ASSERT(!(w->flags & WKI_DETACHED));
    return BoolValue(w->flags & WKI_DONE);
}
void UpsamplingParaDlg::applyPlayVideo()
{
	m_paras->glarea.setValue("SnapShot Each Iteration", BoolValue(true));
	m_paras->glarea.setValue("No Snap Radius",BoolValue(true));

	CMesh* samples = area->dataMgr.getCurrentSamples();

	int begin_index = video_begin_index;
	int end_index = video_end_index;

	if (begin_index > end_index)
	{
		end_index = samples->vn - 1;
	}

	if (end_index >= samples->vn)
	{
		end_index = samples->vn - 1;
	}

	double speed = video_speed;
	double step_size = 2;

	int current_index = begin_index;
	int last_index = current_index;

	for (int i = current_index+1; i < samples->vert.size(); i++)
	{
		samples->vert[i].is_skel_ignore = true;
	}



	while(current_index < end_index)
	{
		area->saveSnapshot();
		area->updateGL();

		step_size *= speed;
		step_size += 1;
		current_index += step_size;

		if (current_index >= samples->vert.size())
		{
			break;
		}

		for (int i = last_index; i < current_index; i++)
		{
			samples->vert[i].is_skel_ignore = false;
		}

		last_index = current_index;
	}

	for (int i = 0; i < end_index; i++)
	{
		samples->vert[i].is_skel_ignore = false;
	}
	area->saveSnapshot();
	area->updateGL();

}
void UpsamplingParaDlg::setUsingThresholdProcess(bool _val)
{
	m_paras->upsampling.setValue("Using Threshold Process", BoolValue(_val));
}
void NormalParaDlg::isAPCA(bool _val)
{
	m_paras->norSmooth.setValue("Run Anistropic PCA", BoolValue(_val));
}
Exemplo n.º 25
0
CPPPrimitiveValue CPPBoolType::Multiply(const CPPPrimitiveValue& inLeftValue,const CPPPrimitiveValue& inRightValue)
{
	return BoolValue((AsInt(inLeftValue) * AsInt(inRightValue)) == 0 ? false:true);
}
Exemplo n.º 26
0
CPPPrimitiveValue CPPBoolType::NotEqual(const CPPPrimitiveValue& inLeftValue,const CPPPrimitiveValue& inRightValue)
{
	return BoolValue(AsInt(inLeftValue) != AsInt(inRightValue));
}
Exemplo n.º 27
0
/**
 * These simple functions check various flags
 */
Bool WKI_IsCanceled(WorkItem * w)
{
    ASSERT(!(w->flags & WKI_DETACHED));
    return BoolValue(w->flags & WKI_CANCELED);
}
Exemplo n.º 28
0
CPPPrimitiveValue CPPBoolType::UnaryPlus(const CPPPrimitiveValue& inValue)
{
	return BoolValue(inValue.mBoolValue);
}
Exemplo n.º 29
0
STATIC Bool SocketFlush(File * f)
{
    return BoolValue(!SocketEof(f));
}
Exemplo n.º 30
0
CPPPrimitiveValue CPPBoolType::Divide(const CPPPrimitiveValue& inLeftValue,const CPPPrimitiveValue& inRightValue)
{
	return BoolValue((AsInt(inLeftValue) / AsInt(inRightValue)) == 0 ? false:true);
}