Exemplo n.º 1
0
void CubeMesh::defineIntersection( const CubeMesh* other,
		double& xmin, double &xmax,
		double& ymin, double &ymax,
		double& zmin, double &zmax )
	   	const
{
	const double meshSlop = 0.2;
	xmin = ( x0_ > other->x0_ ) ? x0_ : other->x0_;	
	xmax = ( x1_ < other->x1_ ) ? x1_ : other->x1_;	
	ymin = ( y0_ > other->y0_ ) ? y0_ : other->y0_;	
	ymax = ( y1_ < other->y1_ ) ? y1_ : other->y1_;	
	zmin = ( z0_ > other->z0_ ) ? z0_ : other->z0_;	
	zmax = ( z1_ < other->z1_ ) ? z1_ : other->z1_;	
	// Align to coarser mesh
	double temp = ( xmin - x0_) / dx_;
	if ( temp - floor( temp ) > meshSlop )
		xmin = floor( temp ) * dx_;
	temp = ( ymin - y0_) / dy_;
	if ( temp - floor( temp ) > meshSlop )
		ymin = floor( temp ) * dy_;
	temp = ( zmin - z0_) / dz_;
	if ( temp - floor( temp ) > meshSlop )
		zmin = floor( temp ) * dz_;

	// Provide 1 voxel padding all around.
	xmin -= dx_;
	xmax += dx_;
	ymin -= dy_;
	ymax += dy_;
	zmin -= dz_;
	zmax += dz_;
	swapIfBackward( xmin, xmax );
	swapIfBackward( ymin, ymax );
	swapIfBackward( zmin, zmax );
}
Exemplo n.º 2
0
/**
 * This assumes that dx, dy, dz are the quantities to preserve, over 
 * numEntries.
 * So when the compartment changes volume, so does numEntries. dx, dy, dz
 * do not change, some of the sub-cuboids will partially be outside.
 */
void CubeMesh::updateCoords()
{
	swapIfBackward( x0_, x1_ );
	swapIfBackward( y0_, y1_ );
	swapIfBackward( z0_, z1_ );
	if ( preserveNumEntries_ ) {
		dx_ = ( x1_ - x0_ ) / nx_;
		dy_ = ( y1_ - y0_ ) / ny_;
		dz_ = ( z1_ - z0_ ) / nz_;
	} else {
		nx_ = round( (x1_ - x0_) / dx_ );
		ny_ = round( (y1_ - y0_) / dy_ );
		nz_ = round( (z1_ - z0_) / dz_ );
	
		if ( nx_ == 0 ) nx_ = 1;
		if ( ny_ == 0 ) ny_ = 1;
		if ( nz_ == 0 ) nz_ = 1;
	}

	/// Temporarily fill out the whole cube for m2s and s2m. These
	// will change for none-cube geometries.
	unsigned int size = nx_ * ny_ * nz_;
	m2s_.resize( size );
	s2m_.resize( size );
	for ( unsigned int i = 0; i < size; ++i ) {
		m2s_[i] = s2m_[i] = i;
	}

	// Fill out surface vector
	surface_.resize( 0 );
	/*
	if ( numDims() == 0 ) {
		surface_.push_back( 0 );
	} else if ( numDims() == 1 ) {
		surface_.push_back( 0 );
		if ( size > 1 )
			surface_.push_back( size - 1 );
	} else if ( numDims() == 2 ) {
		fillTwoDimSurface();
	} else if ( numDims() == 3 ) {
		fillThreeDimSurface();
	}
	*/
	fillThreeDimSurface();

	// volume_ = ( x1_ - x0_ ) * ( y1_ - y0_ ) * ( z1_ - z0_ );
	assert( size >= 0 );

	buildStencil();
}