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

ADD: ActiveMesh::UpdateMeshBBox().

parent df55cba4
Loading
Loading
Loading
Loading
+32 −0
Original line number Original line Diff line number Diff line
@@ -1357,6 +1357,38 @@ void ActiveMesh::RenderOneTimeTexture(const i3d::Image3d<i3d::GRAY16>& mask,
}
}




void ActiveMesh::UpdateMeshBBox(Vector3F& min,Vector3F& max)
{
	//first, for the cell body
	for (unsigned int i=0; i < Pos.size(); ++i)
	{
		min.x=std::min(min.x,Pos[i].x);
		min.y=std::min(min.y,Pos[i].y);
		min.z=std::min(min.z,Pos[i].z);

		max.x=std::max(max.x,Pos[i].x);
		max.y=std::max(max.y,Pos[i].y);
		max.z=std::max(max.z,Pos[i].z);
	}

	//second, for all filopodia
	for (size_t f=0; f < Ftree.size(); ++f)
	{
		const mesh_t& filoMesh=Ftree[f];
		for (unsigned int i=0; i < filoMesh.Pos.size(); ++i)
		{
			min.x=std::min(min.x,filoMesh.Pos[i].x);
			min.y=std::min(min.y,filoMesh.Pos[i].y);
			min.z=std::min(min.z,filoMesh.Pos[i].z);

			max.x=std::max(max.x,filoMesh.Pos[i].x);
			max.y=std::max(max.y,filoMesh.Pos[i].y);
			max.z=std::max(max.z,filoMesh.Pos[i].z);
		}
	}
}


void ActiveMesh::CenterMesh(const float safeConstant)
void ActiveMesh::CenterMesh(const float safeConstant)
{
{
	//calc geom. centre,
	//calc geom. centre,
+11 −0
Original line number Original line Diff line number Diff line
@@ -146,6 +146,17 @@ class ActiveMesh
	///if needed, it shifts all mesh coordinates by the \e shift vector
	///if needed, it shifts all mesh coordinates by the \e shift vector
	void TranslateMesh(const Vector3F& shift);
	void TranslateMesh(const Vector3F& shift);


	/**
	 * scans all mesh coordinates and checks if some falls
	 * outside the \e min <-> \e max interval, and updates
	 * (increases) the interval in the respective coordinate axis.
	 *
	 * NB: If you initiate \e min and \e max with, for instance,
	 * mesh body centre, this update will give you current bounding
	 * box of the mesh.
	 */
	void UpdateMeshBBox(Vector3F& min,Vector3F& max);

	/**
	/**
	 * sets the optimal size and translation vectors (defined below),
	 * sets the optimal size and translation vectors (defined below),
	 * it does not alter the mesh
	 * it does not alter the mesh