コード例 #1
0
ファイル: BoxTest.cpp プロジェクト: PADrend/Geometry
void BoxTest::testGetters() {
	const Geometry::Box b1(-1.0f, 1.0f, -2.0f, 2.0f, -3.0f, 3.0f);
	const Geometry::Box b2;

	CPPUNIT_ASSERT(b1.getMaxX() == 1.0f);
	CPPUNIT_ASSERT(b1.getMax(Geometry::dimension_t::X) == 1.0f);
	CPPUNIT_ASSERT(b1.getMaxY() == 2.0f);
	CPPUNIT_ASSERT(b1.getMax(Geometry::dimension_t::Y) == 2.0f);
	CPPUNIT_ASSERT(b1.getMaxZ() == 3.0f);
	CPPUNIT_ASSERT(b1.getMax(Geometry::dimension_t::Z) == 3.0f);

	CPPUNIT_ASSERT(b1.getMinX() == -1.0f);
	CPPUNIT_ASSERT(b1.getMin(Geometry::dimension_t::X) == -1.0f);
	CPPUNIT_ASSERT(b1.getMinY() == -2.0f);
	CPPUNIT_ASSERT(b1.getMin(Geometry::dimension_t::Y) == -2.0f);
	CPPUNIT_ASSERT(b1.getMinZ() == -3.0f);
	CPPUNIT_ASSERT(b1.getMin(Geometry::dimension_t::Z) == -3.0f);

	CPPUNIT_ASSERT(b1.getExtentMax() == 6.0f);
	CPPUNIT_ASSERT(b1.getExtentMin() == 2.0f);

	CPPUNIT_ASSERT(b1.getExtentX() == 2.0f);
	CPPUNIT_ASSERT(b1.getExtent(Geometry::dimension_t::X) == 2.0f);
	CPPUNIT_ASSERT(b1.getExtentY() == 4.0f);
	CPPUNIT_ASSERT(b1.getExtent(Geometry::dimension_t::Y) == 4.0f);
	CPPUNIT_ASSERT(b1.getExtentZ() == 6.0f);
	CPPUNIT_ASSERT(b1.getExtent(Geometry::dimension_t::Z) == 6.0f);

	CPPUNIT_ASSERT(b1.getVolume() == 48.0f);
	CPPUNIT_ASSERT(b1.getSurfaceArea() == 88.0f);

	CPPUNIT_ASSERT(b1.getCenter() == Geometry::Vec3(0.0f, 0.0f, 0.0f));
	CPPUNIT_ASSERT(b1.getBoundingSphereRadius() == 0.5f * std::sqrt(56.0f));
}
コード例 #2
0
ファイル: RegionEvaluator.cpp プロジェクト: MeisterYeti/MinSG
void PolygonDensityEvaluator::calcPriority(Region * r)
{
	int testsPerAxis = getAttribute(Util::StringIdentifier("#Tests per axis"))->toUnsignedInt();
	Geometry::Box box = r->getBounds();

	PrioSplit px = calcPriority(Geometry::Helper::splitUpBox(box, testsPerAxis,1,1));
	PrioSplit py = calcPriority(Geometry::Helper::splitUpBox(box, 1,testsPerAxis,1));
	PrioSplit pz = calcPriority(Geometry::Helper::splitUpBox(box, 1,1,testsPerAxis));

	float volumePower = pow(box.getVolume(), getAttribute(Util::StringIdentifier("Volume Power"))->toFloat());
	px.prio *= volumePower;
	py.prio *= volumePower;
	pz.prio *= volumePower;

	float p = std::max(std::max(px.prio,py.prio),pz.prio);
	r->setAttribute(Util::StringIdentifier("PolygonDensityPrio"), GenericAttribute::createNumber<float>(p));

	float f = getAttribute(Util::StringIdentifier("Extent Power"))->toFloat();
	px.prio *= pow(box.getExtentX(),f);
	py.prio *= pow(box.getExtentY(),f);
	pz.prio *= pow(box.getExtentZ(),f);


	p = std::max(std::max(px.prio,py.prio),pz.prio);
	if(p==px.prio) {
		r->setAttribute(Util::StringIdentifier("PolygonDensitySplit"), GenericAttribute::createNumber<int>(0));
		r->setAttribute(Util::StringIdentifier("PolygonDensityRatio"), GenericAttribute::createNumber<float>(px.ratio));
	}
	else if(p==py.prio) {
		r->setAttribute(Util::StringIdentifier("PolygonDensitySplit"), GenericAttribute::createNumber<int>(1));
		r->setAttribute(Util::StringIdentifier("PolygonDensityRatio"), GenericAttribute::createNumber<float>(py.ratio));
	}
	else if(p==pz.prio) {
		r->setAttribute(Util::StringIdentifier("PolygonDensitySplit"), GenericAttribute::createNumber<int>(2));
		r->setAttribute(Util::StringIdentifier("PolygonDensityRatio"), GenericAttribute::createNumber<float>(pz.ratio));
	}
	else            FAIL();
}
コード例 #3
0
ファイル: RegionEvaluator.cpp プロジェクト: MeisterYeti/MinSG
float PolygonDensityEvaluator::calcDensity(const Geometry::Box & b)
{
	return countPolygons(b) / b.getVolume();
}