Example #1
0
Player Player::create( int bits, int size, int freq, int channelN ){
	STRONG_ASSERT( bits == 8 || bits == 16 && "Player::Player() : bitsPerSample must be 8 or 16." );
	STRONG_ASSERT( ( ( bits * freq * channelN / 8 / 16 ) < size ) && "Player::Player() : bufferSize is too small. at least 1/16s" );
	Player r;
	r.mImpl = NEW Impl( bits, size, freq, channelN, gManagerImpl->directSound() );
	return r;
}
Example #2
0
inline bool write_tensor( std::string const & fname,
                          std::vector<cube_p<T>> vols )
{
    ZI_ASSERT(vols.size()>0);

    FILE* fvol = fopen(fname.c_str(), "w");

    STRONG_ASSERT(fvol);

    F v;

    vec3i const & sz = size(*vols[0]);
    for ( auto& vol: vols )
    {
        ZI_ASSERT(size(*vol)==sz);
        for ( long_t z = 0; z < sz[0]; ++z )
            for ( long_t y = 0; y < sz[1]; ++y )
                for ( long_t x = 0; x < sz[2]; ++x )
                {
                    v = static_cast<T>((*vol)[z][y][x]);
                    static_cast<void>(fwrite(&v, sizeof(F), 1, fvol));
                }
    }

    fclose(fvol);

    return export_size_info(fname, sz, vols.size());
}
Example #3
0
Semaphore Semaphore::create( int startCount, int maxCount ){
	STRONG_ASSERT( startCount >= 0 );
	if ( maxCount < startCount ){
		maxCount = startCount;
	}
	Semaphore r;
	r.mImpl = new Impl( startCount, maxCount );
	return r;
}
Example #4
0
//Parent::ModeをParent::Modeに変換。下流シーケンスにParentを見せない。
Parent::Mode Parent::mode() const {
	Mode r = MODE_NONE;
	switch ( GrandParent::instance()->mode() ){
		case GrandParent::MODE_1P: r = MODE_1P; break;
		case GrandParent::MODE_2P: r = MODE_2P; break;
		default: STRONG_ASSERT( false ); break;
	}
	return r;
}
Example #5
0
	// pos is assumed to be a global coordinate.
	void set_patch( vec3i pos, volT vol )
	{
		STRONG_ASSERT((this->rng_).contains(pos));

		// [08/15/2014]
		// This condition can be relaxed.
		STRONG_ASSERT(size_of(vol) == this->FoV_);

		pos 	-= this->off_;			// local coordinate
		vec3i uc = pos - this->rad_;	// upper corner

		std::size_t ox = uc[0];
	    std::size_t oy = uc[1];
	    std::size_t oz = uc[2];
	    std::size_t sx = this->FoV_[0];
	    std::size_t sy = this->FoV_[1];
	    std::size_t sz = this->FoV_[2];

		(*(this->vol_))[boost::indices[range(ox,ox+sx)][range(oy,oy+sy)][range(oz,oz+sz)]] =
                    (*vol)[boost::indices[range(0,sx)][range(0,sy)][range(0,sz)]];
	}
Example #6
0
Dds::Dds(const File& image_file)
: size_(0), data_(0)
{
	STRONG_ASSERT(image_file.data());
	Size* size_candidate = new Size(0, 0);
	read_dds_size(image_file, size_candidate);
	size_ = size_candidate;

	unsigned* data_candidate = new unsigned[size_->max_index()];
	read_dds_data(image_file, *size_, data_candidate);
	data_ = data_candidate;
}
    void transpose_affinity( std::list<T>& affs )
    {
        STRONG_ASSERT(affs.size() == 3);

        T xaff = affs.front(); affs.pop_front();
        T yaff = affs.front(); affs.pop_front();
        T zaff = affs.front(); affs.pop_front();

        // x-affinity and y-affinity should be exchanged
        affs.push_back(volume_utils::transpose(yaff));
        affs.push_back(volume_utils::transpose(xaff));
        affs.push_back(volume_utils::transpose(zaff));
    }
Example #8
0
void Manager::create( 
void* hwnd, 
int w, 
int h,
bool fullScreen,
bool vSync,
bool antiAlias ){
	STRONG_ASSERT( !gManagerImpl );
	gManagerImpl = NEW ManagerImpl( 
		static_cast< HWND >( hwnd ), 
		w, 
		h,
		fullScreen,
		vSync,
		antiAlias );
}
Example #9
0
    void do_backward(size_t n, cube_p<real> const & g)
    {
        //STRONG_ASSERT(fwd_done_[n]);
        fwd_done_[n] = false;

        if ( func_ )
        {
            //STRONG_ASSERT(g);
            STRONG_ASSERT(fs_[n]);
            // if ( !fs_[n] )
            // {
            //     std::cout << "N: " << n <<
            //         ( nodes::is_output() ? " output\n" : "no\n");
            //     STRONG_ASSERT(0);
            // }
            func_.apply_grad(*g,*fs_[n]);
            biases_[n]->update(sum(*g),patch_sz_);
            fs_[n].reset();
        }
        bwd_dispatch_.dispatch(n,g,nodes::manager());
    }
Example #10
0
inline bool write( std::string const & fname, cube_p<T> vol )
{
    FILE* fvol = fopen(fname.c_str(), "w");

    STRONG_ASSERT(fvol);

    vec3i const & sz = size(*vol);
    F v;

    for ( long_t z = 0; z < sz[0]; ++z )
        for ( long_t y = 0; y < sz[1]; ++y )
            for ( long_t x = 0; x < sz[2]; ++x )
            {
                v = static_cast<T>((*vol)[z][y][x]);
                static_cast<void>(fwrite(&v, sizeof(F), 1, fvol));
            }

    fclose(fvol);

    return export_size_info(fname, sz);
}
Example #11
0
inline cube_p<T> read( std::string const & fname, vec3i const & sz )
{
    FILE* fvol = fopen(fname.c_str(), "r");

    STRONG_ASSERT(fvol);

    auto ret = get_cube<T>(sz);
    F v;

    for ( long_t z = 0; z < sz[0]; ++z )
        for ( long_t y = 0; y < sz[1]; ++y )
            for ( long_t x = 0; x < sz[2]; ++x )
            {
                static_cast<void>(fread(&v, sizeof(F), 1, fvol));
                (*ret)[z][y][x] = static_cast<T>(v);
            }

    fclose(fvol);

    return ret;
}
Example #12
0
void Framework::create(){
	STRONG_ASSERT( !gImpl );
	gImpl = NEW Impl();
}
Example #13
0
void Manager::create( void* wh ){
	STRONG_ASSERT( !gManagerImpl );
	gManagerImpl = NEW ManagerImpl( static_cast< HWND >( wh ) );
}
Example #14
0
void Semaphore::increase( int v ){
	STRONG_ASSERT( v > 0 );
	mImpl->increase( v );
}
Example #15
0
float Vector2::operator[]( int i ) const {
	STRONG_ASSERT( i >= 0 && i < 2 );
	return ( &x )[ i ];
}
Example #16
0
void Manager::create( int w, int h, bool window ){
	STRONG_ASSERT( !gManagerImpl );
	gManagerImpl = new KinectManagerImpl( w, h );
}
Example #17
0
	void set_value( vec3i pos, elemT val )
	{
		STRONG_ASSERT((this->gbb_).contains(pos));
		pos -= this->off_; // local coordinate		
		(*(this->vol_))[pos[0]][pos[1]][pos[2]] = val;
	}
Example #18
0
void Sprite::create(){
	STRONG_ASSERT( !gSpriteImpl );
	gSpriteImpl = new SpriteImpl( gManagerImpl->chain() );
}
Example #19
0
	void increase( int value ){
		LONG prev;
		ReleaseSemaphore( mHandle, value, &prev );
		STRONG_ASSERT( prev + value <= mMaxCount );
	}
Example #20
0
Framework::Framework(){
	//別スレッドからの呼び出しは許さない
	STRONG_ASSERT( WindowCreator::isMainThread() && "you must call from MAIN thread" );
}
Example #21
0
void Parent::moveTo( NextSequence next ){
	STRONG_ASSERT( mNextSequence == NEXT_NONE );
	mNextSequence = next;
}
Example #22
0
Player Player::create( Wave wave ){
	STRONG_ASSERT( wave.isReady() && "Player::Player() : loading hasn't finished." );
	Player r;
	r.mImpl = NEW Impl( wave.mImpl, gManagerImpl->directSound() );
	return r;
}
Example #23
0
void Parent::update( GrandParent* parent ){
	if ( mClear ){
		mClear->update( this );
	}else if ( mReady ){
		mReady->update( this );
	}else if ( mPause ){
		mPause->update( this );
	}else if ( mPlay ){
		mPlay->update( this );
	}else if ( mFailure ){
		mFailure->update( this );
	}else if ( mJudge ){
		mJudge->update( this );
	}else{
		HALT( "bakana!" ); //ありえない
	}
	//遷移判定
	switch ( mNextSequence ){
		case NEXT_CLEAR:
			STRONG_ASSERT( !mClear && !mReady && !mPause && mPlay && !mFailure && !mJudge );
			SAFE_DELETE( mPlay );
			mClear = new Clear();
			++mStageID; //次のステージへ
			break;
		case NEXT_READY:
			STRONG_ASSERT( !mReady && !mPause && !mPlay && ( mFailure || mClear ||  mJudge ) );
			SAFE_DELETE( mFailure );
			SAFE_DELETE( mClear );
			SAFE_DELETE( mJudge );
			mReady = new Ready();
			break;
		case NEXT_PAUSE:
			STRONG_ASSERT( !mClear && !mReady && !mPause && mPlay && !mFailure && !mJudge );
			SAFE_DELETE( mPlay );
			mPause = new Pause();
			break;
		case NEXT_PLAY:
			STRONG_ASSERT( !mClear && ( mReady || mPause ) && !mPlay && !mFailure && !mJudge );
			SAFE_DELETE( mReady );
			SAFE_DELETE( mPause );
			mPlay = new Play();
			break;
		case NEXT_FAILURE:
			STRONG_ASSERT( !mClear && !mReady && !mPause && mPlay && !mFailure && !mJudge );
			SAFE_DELETE( mPlay );
			mFailure = new Failure();
			--mLife;
			break;
		case NEXT_JUDGE:
			STRONG_ASSERT( !mClear && !mReady && !mPause && mPlay && !mFailure && !mJudge );
			SAFE_DELETE( mPlay );
			mJudge = new Judge();
			break;
		case NEXT_ENDING:
			STRONG_ASSERT( mClear && !mReady && !mPause && !mPlay && !mFailure && !mJudge );
			SAFE_DELETE( mClear );
			parent->moveTo( GrandParent::NEXT_ENDING );
			break;
		case NEXT_GAME_OVER:
			STRONG_ASSERT( !mClear && !mReady && !mPause && !mPlay && mFailure && !mJudge );
			SAFE_DELETE( mFailure );
			parent->moveTo( GrandParent::NEXT_GAME_OVER );
			break;
		case NEXT_TITLE:
			STRONG_ASSERT( !mClear && !mReady && ( mPause || mJudge ) && !mPlay && !mFailure );
			SAFE_DELETE( mPause );
			SAFE_DELETE( mJudge );
			parent->moveTo( GrandParent::NEXT_TITLE );
			break;
	}
	mNextSequence = NEXT_NONE;
}