Commit fd70404b authored by Vladimír Ulman's avatar Vladimír Ulman
Browse files

ADD, minLength: introduced ActiveMesh::calcFiloLength()

parent 5d1a35e4
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -562,6 +562,47 @@ bool FindIndexInSkeletons(const std::vector<struct mesh_t>& Ftree, //filopodia c
	return(false);
}

//calculates overall length of a given filopodium branch
//(and report if LENGTH_DEBUG is enabled)
//#define LENGTH_DEBUG
float ActiveMesh::calcFiloLength(unsigned int idx)
{
	//handle the undecided case...
	if (idx == 999999) return -1.f;

	//read-only shortcut to the requested filopodium branch
	const mesh_t& filoMesh=Ftree[idx];

	//sweep all segments of this filopodium and sum up their lenghts
	double length=0.0;

	#ifdef LENGTH_DEBUG
	std::cout << "filo " << idx << ": ";
	#endif
	for (size_t i=0; i < filoMesh.segFromPoint.size(); ++i)
	{
		//shortcuts to the end-points of the current segment
		const Vector3FC& fPoint = filoMesh.fPoints[filoMesh.segFromPoint[i]];
		const Vector3FC& tPoint = filoMesh.fPoints[filoMesh.segToPoint[i]];

		const float xx=tPoint.x - fPoint.x;
		const float yy=tPoint.y - fPoint.y;
		const float zz=tPoint.z - fPoint.z;
		const float segLen=sqrtf(xx*xx + yy*yy + zz*zz);

		#ifdef LENGTH_DEBUG
		std::cout << RoundTo(segLen)/1000.f << ",";
		#endif

		length+=segLen;
	}
	#ifdef LENGTH_DEBUG
	std::cout << std::endl;
	#endif

	return (float)length;
}

//enable to see debug outputs for filopodia reading from VTKs
//#define DEBUG_BRANCHING

+3 −0
Original line number Diff line number Diff line
@@ -108,6 +108,9 @@ class ActiveMesh
	 */
	void PopulateSurfTriangles_Ftree(const unsigned int idx,const bool enforce=false);

	///calculates overall length of a given filopodium branch
	float calcFiloLength(unsigned int idx);

	///renders filopodium first aside, then overlays the given mask
	void RenderMask_filo(i3d::Image3d<i3d::GRAY16>& mask,const unsigned int idx,
		const unsigned short color=100,const bool showTriangles=false,