void CylBase::matchCubeMeshEntries( const ChemCompt* compt,
	const CylBase& parent,
	unsigned int startIndex,
	double granularity,
	vector< VoxelJunction >& ret, 
	bool useCylinderCurve, bool useCylinderCap ) const
{
	const CubeMesh* other = dynamic_cast< const CubeMesh* >( compt );
	assert( other );
	const double EPSILON = 1e-18;
	Vec a( parent.x_ - x_, parent.y_ - y_, parent.z_ - z_ );
	Vec u;
	Vec v;
	a.orthogonalAxes( u, v );

	double h = selectGridSize( other->getDx(), parent.dia_/2, granularity );
	double lambda = length_ / numDivs_;

	unsigned int num = floor( 0.1 + lambda / h );
	// March along axis of cylinder.
	// q is the location of the point along axis.
	double rSlope = ( dia_ - parent.dia_ ) * 0.5 / length_;
	for ( unsigned int i = 0; i < numDivs_; ++i ) {
		vector< double >area( other->getNumEntries(), 0.0 );
		if ( useCylinderCurve ) {
			for ( unsigned int j = 0; j < num; ++j ) {
				unsigned int m = i * num + j;
				double frac = ( m * h + h/2.0 ) / length_;
				double q0 = x_ + a.a0() * frac;
				double q1 = y_ + a.a1() * frac;
				double q2 = z_ + a.a2() * frac;
				// get radius of cylinder at this point.
				double r = dia_/2.0;
				if ( !isCylinder_ ) // Use the more complicated conic value
				r = parent.dia_/2.0 + frac * rSlope;
				fillPointsOnCircle( u, v, Vec( q0, q1, q2 ),
							h, r, area, other );
			}
		}
		if ( useCylinderCap && i == numDivs_ - 1 ) {
			fillPointsOnDisc( u, v, Vec( x_, y_, z_ ), 
							h, dia_/2.0, area, other );
		}
		// Go through all cubeMesh entries and compute diffusion 
		// cross-section. Assume this is through a membrane, so the 
		// only factor relevant is area. Not the distance.
		for ( unsigned int k = 0; k < area.size(); ++k ) {
			if ( area[k] > EPSILON ) {
				ret.push_back( VoxelJunction( i + startIndex, k, area[k] ));
			}
		}
	}
}
Exemple #2
0
void CylMesh::matchCubeMeshEntries( const CubeMesh* other,
vector< VoxelJunction >& ret ) const
{
	const double EPSILON = 1e-18;
	Vec a( x1_ - x0_, y1_ - y0_, z1_ - z0_ );
	Vec u;
	Vec v;
	a.orthogonalAxes( u, v );

	double h = selectGridVolume( other->getDx() );

	unsigned int num = floor( 0.1 + diffLength_ / h );
	// March along axis of cylinder.
	// q is the location of the point along axis.
	for ( unsigned int i = 0; i < numEntries_; ++i ) {
		vector< double >area( other->getNumEntries(), 0.0 );
		for ( unsigned int j = 0; j < num; ++j ) {
			unsigned int m = i * num + j;
			double frac = ( m * h + h/2.0 ) / totLen_;
			double q0 = x0_ + a.a0() * frac;
			double q1 = y0_ + a.a1() * frac;
			double q2 = z0_ + a.a2() * frac;
			// get radius of cylinder at this point.
			double r = r0_ + ( m * h + h / 2.0 ) * rSlope_;
			fillPointsOnCircle( u, v, Vec( q0, q1, q2 ),
						h, r, area, other );
			}
		// Go through all cubeMesh entries and compute diffusion 
		// cross-section. Assume this is through a membrane, so the 
		// only factor relevant is area. Not the distance.
		for ( unsigned int k = 0; k < area.size(); ++k ) {
			if ( area[k] > EPSILON ) {
				ret.push_back( VoxelJunction( i, k, area[k] ) );
			}
		}
	}
}