Example #1
0
	void ClipLine(int *indices)
	{
		int mask = 0;
		int clip_mask[2] = { 0, 0 };

		for (int i = 0; i < 2; ++i)
		{
			clip_mask[i] = CalcClipMask(Vertices[i]);
			mask |= clip_mask[i];
		}

		if (mask == 0)
			return;

		float t0 = 0;
		float t1 = 0;

		// Mark unused in case of early termination
		// of the macros below. (When fully clipped)
		indices[0] = SKIP_FLAG;
		indices[1] = SKIP_FLAG;

		LINE_CLIP(CLIP_POS_X_BIT, -1,  0,  0, 1);
		LINE_CLIP(CLIP_NEG_X_BIT,  1,  0,  0, 1);
		LINE_CLIP(CLIP_POS_Y_BIT,  0, -1,  0, 1);
		LINE_CLIP(CLIP_NEG_Y_BIT,  0,  1,  0, 1);
		LINE_CLIP(CLIP_POS_Z_BIT,  0,  0, -1, 1);
		LINE_CLIP(CLIP_NEG_Z_BIT,  0,  0,  1, 1);

		// Restore the old values as this line
		// was not fully clipped.
		indices[0] = 0;
		indices[1] = 1;

		int numVertices = 2;

		if (clip_mask[0])
		{
			indices[0] = numVertices;
			AddInterpolatedVertex(t0, 0, 1, numVertices);
		}

		if (clip_mask[1])
		{
			indices[1] = numVertices;
			AddInterpolatedVertex(t1, 1, 0, numVertices);
		}
	}
Example #2
0
void SWCTreeSmoother::SmoothRecursively(std::vector<SWCGraphVertex*>& rOrigVertexList,
										std::vector<SWCGraphVertex*>& rSmoothVertexList, 
										SWCGraphVertex* pParentOrigVertex,
										SWCGraphVertex* pChildOrigVertex,
										SWCGraphVertex* pParentSmoothVertex,
										int nSlidingWndSizeForSmoothing)
{
	// Declerations.
	SWCGraphVertex* pChildSmoothVertex;
	std::vector<SWCGraphVertex*>::iterator VertexIter;
	
	// Continue on downsampling if this is not a bifurcation or an end point.
	do
	{
		pChildSmoothVertex = AddInterpolatedVertex(rOrigVertexList,
												   rSmoothVertexList,
												   pChildOrigVertex,
												   pParentSmoothVertex,
												   nSlidingWndSizeForSmoothing);
		
		pParentOrigVertex = pChildOrigVertex;
		pParentSmoothVertex = pChildSmoothVertex;
		
		if(pParentOrigVertex->Children.size() == 1)
		{
			pChildOrigVertex = pParentOrigVertex->Children.front();
		}
		
	}while( pParentOrigVertex->Children.size() == 1 );
	
	// Stop if this is an end point. If it is a bifurcation,
	// call the same function for each children of this node.
	if( pParentOrigVertex->Children.size() > 1 )
	{
		for(VertexIter = pParentOrigVertex->Children.begin();
			VertexIter != pParentOrigVertex->Children.end();
			VertexIter++)
		{
			SmoothRecursively(rOrigVertexList, rSmoothVertexList, 
							  pParentOrigVertex, (*VertexIter),
							  pParentSmoothVertex, 
							  nSlidingWndSizeForSmoothing);
		}
	}
}