示例#1
0
bool fillRegularVolumeInfo( VolumeInformation& info )
{
    const Vector3ui& blockSize = info.maximumBlockSize - info.overlap * 2;
    if( !checkCompatibility( info.voxels, blockSize ))
        return false;

    const float maxDim = float( info.voxels.find_max( ));

    info.maximumBlockSize = blockSize + info.overlap * 2;
    info.dataType = DT_UINT8;
    info.compCount = 1;
    info.isBigEndian = false;
    info.worldSpacePerVoxel = 1.0f / maxDim;
    info.worldSize = Vector3f( info.voxels[0], info.voxels[1],
                                info.voxels[2] ) / maxDim;

    // Find the depth of hierarchy
    const Vector3ui numBlocks = info.voxels / blockSize;
    Vector3ui blocksSize = numBlocks;

    const uint32_t xDepth = std::log2( blocksSize[0] );
    const uint32_t yDepth = std::log2( blocksSize[1] );
    const uint32_t zDepth = std::log2( blocksSize[2] );

    const uint32_t depth = std::min( xDepth, std::min( yDepth, zDepth ));
    blocksSize = blocksSize / ( 1u << depth );

    info.rootNode = RootNode(  depth + 1,
                               blocksSize );
    return true;
}
示例#2
0
文件: events.cpp 项目: hernando/Livre
RemoteInformation deserializeDataSourceData( const ::zeq::Event& event )
{
    if( event.getType() != EVENT_DATASOURCE_DATA )
        return RemoteInformation();

    auto data = GetVolumeInformation( event.getData( ));
    RemoteInformation info;
    livre::VolumeInformation& vi = info.second;

    info.first.low() = data->eventLow();
    info.first.high() = data->eventHigh();
    vi.isBigEndian = data->isBigEndian();
    vi.compCount = data->compCount();
    vi.dataType = DataType( data->dataType( ));
    vi.overlap = _deserializeVector3< unsigned >( data->overlap( ));
    vi.maximumBlockSize = _deserializeVector3< unsigned >(
                                 data->maximumBlockSize( ));
    vi.minPos = _deserializeVector3< float >( data->minPos( ));
    vi.maxPos = _deserializeVector3< float >( data->maxPos( ));
    vi.voxels = _deserializeVector3< unsigned >( data->voxels( ));
    vi.worldSize = _deserializeVector3< float >( data->worldSize( ));
    vi.boundingBox.getMin() = _deserializeVector3< float >(
                                     data->boundingBoxMin( ));
    vi.boundingBox.getMax() = _deserializeVector3< float >(
                                     data->boundingBoxMax( ));
    vi.worldSpacePerVoxel = data->worldSpacePerVoxel();

    const Vector3ui& blockSize = vi.maximumBlockSize - vi.overlap * 2;
    Vector3ui blocksSize = vi.voxels / blockSize;
    blocksSize = blocksSize / ( 1u << data->depth( ));

    vi.rootNode = RootNode( data->depth(), blocksSize );
    return info;
}
示例#3
0
void
CachedExtentTree::DumpInOrder() const
{
	TRACE("\n");
	_DumpInOrder(RootNode());
	TRACE("\n");
}
示例#4
0
bool fillRegularVolumeInfo( VolumeInformation& info )
{
    info.worldSpacePerVoxel = 1.0f / float( info.voxels.find_max( ));
    info.worldSize = Vector3f( info.voxels[0], info.voxels[1],
                               info.voxels[2] ) * info.worldSpacePerVoxel;

    // Create the rootNode of the LOD hierarchy
    const Vector3ui blockSize = info.maximumBlockSize - info.overlap * 2;
    const Vector3ui numBlocks(
                std::ceil( float( info.voxels.x( )) / blockSize.x( )),
                std::ceil( float( info.voxels.y( )) / blockSize.y( )),
                std::ceil( float( info.voxels.z( )) / blockSize.z( ))
                );
    const Vector3ui lodLevels(
                std::ceil( std::log2( numBlocks.x( ))),
                std::ceil( std::log2( numBlocks.y( ))),
                std::ceil( std::log2( numBlocks.z( )))
                );
    const uint32_t depth = lodLevels.find_min();
    const Vector3ui rootNodeBlocksCount(
                std::ceil( float( info.voxels.x() >> depth ) / blockSize.x( )),
                std::ceil( float( info.voxels.y() >> depth ) / blockSize.y( )),
                std::ceil( float( info.voxels.z() >> depth ) / blockSize.z( ))
                );
    info.rootNode = RootNode( depth + 1, rootNodeBlocksCount );
    return true;
}
示例#5
0
文件: Volume.cpp 项目: DonCN/haiku
status_t
Volume::Unmount()
{
	TRACE("Volume::Unmount()\n");

	TRACE("Volume::Unmount(): Putting root node\n");
	put_vnode(fFSVolume, RootNode()->ID());
	TRACE("Volume::Unmount(): Deleting the block cache\n");
	block_cache_delete(fBlockCache, !IsReadOnly());
	TRACE("Volume::Unmount(): Closing device\n");
	close(fDevice);

	TRACE("Volume::Unmount(): Done\n");
	return B_OK;
}
//
// Scene::Scene						- Chapter 16, page 539
//
//    Note: The shared_ptr<IRenderer> was added to allow for both D3D9 and D3D11 renderer implementations.
//          The book only describes D3D11, so to find all the differences, just search for m_Renderer!
//
SceneManager::SceneManager(std::shared_ptr<IRenderer> renderer)
{
	m_Root.reset(TYW_NEW RootNode());
	m_Renderer = renderer;
	

	m_LightManager = TYW_NEW LightManager;

	//D3DXCreateMatrixStack(0, &m_MatrixStack);

	// [mrmike] - event delegates were added post-press
//	IEventManager* pEventMgr = IEventManager::Get();
//	pEventMgr->VAddListener(MakeDelegate(this, &Scene::NewRenderComponentDelegate), EvtData_New_Render_Component::sk_EventType);
//	pEventMgr->VAddListener(MakeDelegate(this, &Scene::DestroyActorDelegate), EvtData_Destroy_Actor::sk_EventType);
//	pEventMgr->VAddListener(MakeDelegate(this, &Scene::MoveActorDelegate), EvtData_Move_Actor::sk_EventType);
//	pEventMgr->VAddListener(MakeDelegate(this, &Scene::ModifiedRenderComponentDelegate), EvtData_Modified_Render_Component::sk_EventType);
}
示例#7
0
status_t
Volume::Unmount()
{
	TRACE("Volume::Unmount()\n");

	status_t status = fJournal->Uninit();

	delete fJournal;
	delete fJournalInode;

	TRACE("Volume::Unmount(): Putting root node\n");
	put_vnode(fFSVolume, RootNode()->ID());
	TRACE("Volume::Unmount(): Deleting the block cache\n");
	block_cache_delete(fBlockCache, !IsReadOnly());
	TRACE("Volume::Unmount(): Closing device\n");
	close(fDevice);

	TRACE("Volume::Unmount(): Done\n");
	return status;
}
示例#8
0
void
CachedExtentTree::Delete()
{
	_Delete(RootNode());
	Clear();
}
示例#9
0
文件: LZ78e.c 项目: darkf/LZF
//--------// main() function //---------------------------------------------//
int main(int argc, char* argv[]){
	/* general variables */
	int retrieve_buffer = 0;	
	unsigned char data;                     /* retrieve data from stdin           */
	int byte_counter = 0;          /* counts bytes received from stdin   */
	unsigned int index_counter = 0;         /* counts factors created             */
	node_t trie = RootNode();
	node_t *parent_node = &trie;
	node_t *temp_node = &trie;
	dict_t dict = EmptyDict();
	dict_t *dict_ptr = &dict;

	unsigned char* output;
	size_t t_memblock = 0;
	/* last-factor variables */
	unsigned char data_buffer;              /* retains data when EOF is reached   */
	int is_added = FALSE;          /* indicates if data_buffer is added  */
	
	while((retrieve_buffer = fgetc(stdin)) != EOF){
		//fprintf(stderr, "%02x  ", retrieve_buffer);
		data = (unsigned char) retrieve_buffer;
		byte_counter++;

		/* update current parent_node */
		parent_node = temp_node;

		/* if data is a member of current parent_node:
		 * set the node that representing data as next parent_node
		 */

		if((temp_node = SearchNode(parent_node, data)) != NULL){
			/* set data to data_buffer */
			is_added = FALSE;
			data_buffer = data;
			continue;
		}
		
		/* if data is not a member of current parent_node:
		 * create a child node to represent data,
		 * and create the associated dictionary element
		 */

		index_counter++;
		temp_node = AddNode(parent_node, data, index_counter);
		dict_ptr = AddDict(dict_ptr, temp_node, parent_node->index);
		is_added = TRUE;
		
		/* reset parent_node */
		temp_node = &trie;
	}

	/* create factor for data_buffer if required  */
	if(is_added == FALSE){
		
		/* temp_node is NULL if data_buffer is not member of parent_node,
		 * indicating parent_node needs to be reset
		 */

		if(temp_node == NULL){
			parent_node = &trie;
		}

		index_counter++;
		temp_node = AddNode(parent_node, data_buffer, index_counter);
		dict_ptr = AddDict(dict_ptr, temp_node, parent_node->index);
	}


	/* skip the first element of the dictionary */
	output = PrintDict(dict.next, index_counter);
	t_memblock = (index_counter * 4) + WIDTH_HEADER + 1;
	fwrite(output, sizeof(char), t_memblock, stdout);
	

	#if DEBUG
	{
		char temp_char;
		int k = 0;
		while(k < t_memblock){
			temp_char = output[k];
			fprintf(stderr, "output = %02x\n", temp_char);
			k++;
		}
	}
	#endif
	

	#if SUMMARY
	{ /* SUMMARY INFO */
		fprintf(stderr, "encode: %6d bytes input\n", byte_counter);
		fprintf(stderr, "encode: %6d factors generated\n", index_counter);
		fprintf(stderr, "encode: %6zu bytes output\n", t_memblock);
	}
	#endif
	

	free(output);
	output = NULL;
	return 0;
}