void BandWidgetTestWidget::handleRequest(Operations::Type type, int count, double value)
{
    this->count = count;
    this->value = value;

    switch (type) {
    case Operations::UPDATE_BANDWIDTH :
        if (count < tm.getRounds() || qAbs(bandWidth[count] > 0.01))
            return;

        tm.increaseRounds();
        if (tm.getRounds() >= SettingArgument::Setting().getBWTestTimes()) {
            ui->label->setText("Test end!");
            StatuButtons::statu()->setBandWidthStart(false);
        }
        else {
            ui->label->setText("Wait " + QString::number(tm.getRounds()+1) + "'s Result!");
        }

        addNewPoint();
        addTestResult();
        break;
    default:
        break;
    }
}
Esempio n. 2
0
	/**
	 * @param points Points used to construct the convex hull. Points inside the convex hull are accepted but will unused.
	 */
	template<class T> ConvexHull3D<T>::ConvexHull3D(const std::vector<Point3<T>> &points) :
		nextPointIndex(0),
		nextTriangleIndex(0)
	{
		//build tetrahedron
		std::set<unsigned int> pointsToExclude = buildTetrahedron(points);

		//add each point to the tetrahedron
		for(unsigned int i=0;i<points.size();i++)
		{
			if(pointsToExclude.find(i)==pointsToExclude.end())
			{
				addNewPoint(points[i]);
			}
		}
	}
Esempio n. 3
0
	/**
	 * @return Returns index of point added. If point doesn't make part of convex, result is zero.
	 */
	template<class T> unsigned int ConvexHull3D<T>::addNewPoint(const Point3<T> &newPoint)
	{
		std::vector<unsigned int> newTriangleIndexes;
		std::vector<unsigned int> removedTriangleIndexes;
		return addNewPoint(newPoint, newTriangleIndexes, removedTriangleIndexes);
	}
Esempio n. 4
0
	/**
	 * @return All indexes points used to build the tetrahedron
	 */
	template<class T> std::set<unsigned int> ConvexHull3D<T>::buildTetrahedron(const std::vector<Point3<T>> &points)
	{
		//1. initialize
		std::set<unsigned int> pointsUsed;

		//2. build a point (use first point)
		if(points.size()<1)
		{
			throw buildException(points, pointsUsed);
		}

		this->points[nextPointIndex++] = points[0];
		pointsUsed.insert(0);

		//3. build a line (find two distinct points)
		for(unsigned int i=1; i<points.size(); i++)
		{
			if(points[i]!=this->points[0])
			{
				this->points[nextPointIndex++] = points[i];
				pointsUsed.insert(i);
				break;
			}
		}

		if(pointsUsed.size()!=2)
		{
			throw buildException(points, pointsUsed);
		}

		//4. build triangles (find a point which doesn't belong to line).
		Vector3<T> lineVector = this->points[0].vector(this->points[1]);
		for(unsigned int i=1; i<points.size(); i++)
		{
			if(pointsUsed.find(i)!=pointsUsed.end())
			{ //point already used to build the tetrahedron
				continue;
			}

			Vector3<T> linesCrossProduct = lineVector.crossProduct(this->points[0].vector(points[i]));
			if(linesCrossProduct.X != (T)0.0 || linesCrossProduct.Y != (T)0.0 || linesCrossProduct.Z != (T)0.0)
			{
				this->points[nextPointIndex++] = points[i];
				pointsUsed.insert(i);
				break;
			}
		}

		if(pointsUsed.size()!=3)
		{
			throw buildException(points, pointsUsed);
		}

		unsigned int triangleIndex1 = nextTriangleIndex++;
		unsigned int triangleIndex2 = nextTriangleIndex++;
		indexedTriangles.insert(std::pair<unsigned int, IndexedTriangle3D<T>>(triangleIndex1, IndexedTriangle3D<T>(0, 1, 2)));
		indexedTriangles.insert(std::pair<unsigned int, IndexedTriangle3D<T>>(triangleIndex2, IndexedTriangle3D<T>(0, 2, 1)));
		nbTrianglesByPoint[0] = 2;
		nbTrianglesByPoint[1] = 2;
		nbTrianglesByPoint[2] = 2;

		//5. build tetrahedron (find a no coplanar point to the triangle)
		const Vector3<T> &firstTriangleNormal = this->indexedTriangles.find(0)->second.computeNormal(this->points);
		const Point3<T> &firstPoint = this->points.find(0)->second;
		for(unsigned int i=1;i<points.size();i++)
		{
			if(pointsUsed.find(i)!=pointsUsed.end())
			{ //point already used to build the tetrahedron
				continue;
			}

			const Vector3<T> &triangleToPoint = firstPoint.vector(points[i]);
			if(firstTriangleNormal.dotProduct(triangleToPoint) != (T)0.0)
			{
				addNewPoint(points[i]);
				pointsUsed.insert(i);
				break;
			}
		}

		if(pointsUsed.size()!=4)
		{
			throw buildException(points, pointsUsed);
		}

		return pointsUsed;
	}