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

Added a bit more of debugging stuff and code cleanup in ActiveMesh::ImportVTK_Volumetric().

parent b6ce7238
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -488,11 +488,16 @@ int ActiveMesh::ImportVTK_Volumetric(const char *filename,bool saveAlsoTetrahedr
}


void PrintVector(const Vector3d<float>& v)
{
	std::cout << "(" << v.x << "," << v.y << "," << v.z << ")\n";
}

bool FindIndexInSkeletons(const std::vector<struct mesh_t>& Ftree, //filopodia container
                          const std::vector<bool>& which,          //consider-only flag
                          const unsigned int index,                //the segment index to search
                          const unsigned int stop_idx,             //up to filopodium index idx
                          const unsigned int stop_pos,             //and up to pos/offset within it
                          const unsigned int index,                //the vertex index to search
                          const unsigned int stop_idx,             //up to filopodium index idx (skeleton id)
                          const unsigned int stop_pos,             //and up to pos/offset within it (skeleton offset)
                          unsigned int &ret_idx,unsigned int &ret_pos) //return filopodium index, next occurence position of the (same) index
{
	//search for index in segFromPoint lists from the Ftree,
@@ -512,7 +517,7 @@ bool FindIndexInSkeletons(const std::vector<struct mesh_t>& Ftree, //filopodia c
	//besides for vertex indicies, we also check the spatial positions of the
	//considered points and their distance...
	//
	//position of the 'index' point
	//coordinate/position of the 'index' point
	const Vector3FC& indexPos=Ftree[stop_idx].fPoints[index];
	Vector3FC testPos;

@@ -536,7 +541,11 @@ bool FindIndexInSkeletons(const std::vector<struct mesh_t>& Ftree, //filopodia c

			//also check the distance...
			testPos=filoMesh.fPoints[filoMesh.segFromPoint[i]];
			//std::cout << "  testing vector: "; PrintVector(testPos);
			//std::cout << "reference vector: "; PrintVector(indexPos);
			testPos-=indexPos;
			//std::cout << "sq. distance = " << testPos.LenQ() << "\n";
			//std::cout << "    distance = " << testPos.Len() << "\n";
			if (testPos.LenQ() < 0.0000000001f  //is distance less than 10^-5 ?
			   && (idx < stop_idx || i < stop_pos))
			{
@@ -650,8 +659,8 @@ int ActiveMesh::ImportVTK_Ftree(const char *filename,unsigned int idx,

		//... and save them
		Vector3FC v1(x,y,z);
		//v1*=100.f;
		filoMesh->fPoints.push_back(v1);
		//std::cout << "reading coordinate: "; PrintVector(v1);

		--itemCount;
	}
@@ -745,13 +754,12 @@ int ActiveMesh::ImportVTK_Ftree(const char *filename,unsigned int idx,
	file.ignore(10240,'\n'); //ignore LOOKUP_TABLE

	//read the radii
	v1=0;
	while (itemCount > 0 && file >> x)
	{
		filoMesh->segFromRadius.push_back(x*radiusCorrection);
		//std::cout << "reading radius: " << x*radiusCorrection << "\n";

		--itemCount;
		++v1;
	}

	file.close();
@@ -838,6 +846,9 @@ int ActiveMesh::ImportVTK_Ftree(const char *filename,unsigned int idx,
			//(but only if the mother skeleton continues)
			if ((ret_pos+1) < Ftree[ret_idx].segFromRadius.size())
			{
#ifdef DEBUG_BRANCHING
				std::cout << "going to shorten the offspring skeleton\n";
#endif
				//determine "branching triangle" vertices
				const unsigned int A=Ftree[ret_idx].segFromPoint[ret_pos];
				const unsigned int B=Ftree[ret_idx].segToPoint[ret_pos];