Commit a958df36 authored by Antti Soininen's avatar Antti Soininen
Browse files

Build server driven code beautification.

Re #19154
parent b036cb4c
......@@ -218,7 +218,8 @@ private:
/// Returns the volume.
double monteCarloVolume() const;
/// Returns the volume.
double singleShotMonteCarloVolume(const int shotSize, const size_t seed) const;
double singleShotMonteCarloVolume(const int shotSize,
const size_t seed) const;
/// Top rule [ Geometric scope of object]
std::unique_ptr<Rule> TopRule;
......
......@@ -1544,13 +1544,15 @@ double Object::volume() const {
double Object::monteCarloVolume() const {
using namespace boost::accumulators;
const int singleShotIterations = 10000;
accumulator_set<double, features<tag::mean, tag::error_of<tag::mean>>> accumulate;
accumulator_set<double, features<tag::mean, tag::error_of<tag::mean>>>
accumulate;
// For seeding the single shot runs.
boost::random::ranlux48 rnEngine;
// Warm up statistics.
for (int i = 0; i < 10; ++i) {
const auto seed = rnEngine();
const double volume = singleShotMonteCarloVolume(singleShotIterations, seed);
const double volume =
singleShotMonteCarloVolume(singleShotIterations, seed);
accumulate(volume);
}
const double relativeErrorTolerance = 1e-3;
......@@ -1558,7 +1560,8 @@ double Object::monteCarloVolume() const {
double currentError;
do {
const auto seed = rnEngine();
const double volume = singleShotMonteCarloVolume(singleShotIterations, seed);
const double volume =
singleShotMonteCarloVolume(singleShotIterations, seed);
accumulate(volume);
currentMean = mean(accumulate);
currentError = error_of<tag::mean>(accumulate);
......@@ -1575,7 +1578,8 @@ double Object::monteCarloVolume() const {
* @param seed A number to seed the random number generator.
* @returns The simulated volume of this object.
*/
double Object::singleShotMonteCarloVolume(const int shotSize, const size_t seed) const {
double Object::singleShotMonteCarloVolume(const int shotSize,
const size_t seed) const {
const auto &boundingBox = getBoundingBox();
if (boundingBox.isNull()) {
throw std::runtime_error("Cannot calculate volume: invalid bounding box.");
......@@ -1593,7 +1597,8 @@ double Object::singleShotMonteCarloVolume(const int shotSize, const size_t seed)
// the worst case.
blocksize = shotSize - (threadCount - 1) * blocksize;
}
boost::random::mt19937 rnEngine(static_cast<boost::random::mt19937::result_type>(seed));
boost::random::mt19937 rnEngine(
static_cast<boost::random::mt19937::result_type>(seed));
// All threads init their engine with the same seed.
// We discard the random numbers used by the other threads.
// This ensures reproducible results independent of the number
......
......@@ -871,9 +871,11 @@ public:
AutoPtr<Document> shapeDescription = new Document;
AutoPtr<Element> typeElement = shapeDescription->createElement("type");
typeElement->setAttribute("name", "testCuboid");
AutoPtr<Element> shapeElement = createCuboidTypeElement("cuboid-shape", width, height, thickness, shapeDescription);
AutoPtr<Element> shapeElement = createCuboidTypeElement(
"cuboid-shape", width, height, thickness, shapeDescription);
typeElement->appendChild(shapeElement);
AutoPtr<Element> algebraElement = shapeDescription->createElement("algebra");
AutoPtr<Element> algebraElement =
shapeDescription->createElement("algebra");
algebraElement->setAttribute("val", "cuboid-shape");
typeElement->appendChild(algebraElement);
ShapeFactory shapeFactory;
......@@ -888,9 +890,11 @@ public:
AutoPtr<Document> shapeDescription = new Document;
AutoPtr<Element> typeElement = shapeDescription->createElement("type");
typeElement->setAttribute("name", "testSphere");
AutoPtr<Element> shapeElement = createSphereTypeElement("sphere-shape", radius, shapeDescription);
AutoPtr<Element> shapeElement =
createSphereTypeElement("sphere-shape", radius, shapeDescription);
typeElement->appendChild(shapeElement);
AutoPtr<Element> algebraElement = shapeDescription->createElement("algebra");
AutoPtr<Element> algebraElement =
shapeDescription->createElement("algebra");
algebraElement->setAttribute("val", "sphere-shape");
typeElement->appendChild(algebraElement);
ShapeFactory shapeFactory;
......@@ -906,9 +910,11 @@ public:
AutoPtr<Document> shapeDescription = new Document;
AutoPtr<Element> typeElement = shapeDescription->createElement("type");
typeElement->setAttribute("name", "testCylinder");
AutoPtr<Element> shapeElement = createCylinderTypeElement("cylinder-shape", height, radius, shapeDescription);
AutoPtr<Element> shapeElement = createCylinderTypeElement(
"cylinder-shape", height, radius, shapeDescription);
typeElement->appendChild(shapeElement);
AutoPtr<Element> algebraElement = shapeDescription->createElement("algebra");
AutoPtr<Element> algebraElement =
shapeDescription->createElement("algebra");
algebraElement->setAttribute("val", "cylinder-shape");
typeElement->appendChild(algebraElement);
ShapeFactory shapeFactory;
......@@ -926,12 +932,15 @@ public:
AutoPtr<Document> shapeDescription = new Document;
AutoPtr<Element> typeElement = shapeDescription->createElement("type");
typeElement->setAttribute("name", "testShape");
AutoPtr<Element> shapeElement = createCuboidTypeElement("solid-cuboid", width, height, thickness, shapeDescription);
AutoPtr<Element> shapeElement = createCuboidTypeElement(
"solid-cuboid", width, height, thickness, shapeDescription);
typeElement->appendChild(shapeElement);
const double radius = 0.47 * std::min(std::min(width, height), thickness);
shapeElement = createSphereTypeElement("void-sphere", radius, shapeDescription);
shapeElement =
createSphereTypeElement("void-sphere", radius, shapeDescription);
typeElement->appendChild(shapeElement);
AutoPtr<Element> algebraElement = shapeDescription->createElement("algebra");
AutoPtr<Element> algebraElement =
shapeDescription->createElement("algebra");
algebraElement->setAttribute("val", "solid-cuboid (# void-sphere)");
typeElement->appendChild(algebraElement);
ShapeFactory shapeFactory;
......@@ -1429,11 +1438,15 @@ private:
return retVal;
}
static Poco::XML::AutoPtr<Poco::XML::Element> createCuboidTypeElement(const std::string &id, const double width, const double height, const double thickness, Poco::XML::AutoPtr<Poco::XML::Document> &document) {
static Poco::XML::AutoPtr<Poco::XML::Element>
createCuboidTypeElement(const std::string &id, const double width,
const double height, const double thickness,
Poco::XML::AutoPtr<Poco::XML::Document> &document) {
using namespace Poco::XML;
AutoPtr<Element> shapeElement = document->createElement("cuboid");
shapeElement->setAttribute("id", id);
AutoPtr<Element> element = document->createElement("left-front-bottom-point");
AutoPtr<Element> element =
document->createElement("left-front-bottom-point");
element->setAttribute("x", std::to_string(-width / 2));
element->setAttribute("y", std::to_string(-height / 2));
element->setAttribute("z", std::to_string(thickness / 2));
......@@ -1456,9 +1469,11 @@ private:
return shapeElement;
}
static Poco::XML::AutoPtr<Poco::XML::Element> createSphereTypeElement(const std::string &id, const double radius, Poco::XML::AutoPtr<Poco::XML::Document> &document) {
static Poco::XML::AutoPtr<Poco::XML::Element>
createSphereTypeElement(const std::string &id, const double radius,
Poco::XML::AutoPtr<Poco::XML::Document> &document) {
using namespace Poco::XML;
AutoPtr<Element>shapeElement = document->createElement("sphere");
AutoPtr<Element> shapeElement = document->createElement("sphere");
shapeElement->setAttribute("id", id);
AutoPtr<Element> element = document->createElement("centre");
element->setAttribute("x", "0.0");
......@@ -1471,9 +1486,12 @@ private:
return shapeElement;
}
static Poco::XML::AutoPtr<Poco::XML::Element> createCylinderTypeElement(const std::string &id, const double height, const double radius, Poco::XML::AutoPtr<Poco::XML::Document> &document) {
static Poco::XML::AutoPtr<Poco::XML::Element>
createCylinderTypeElement(const std::string &id, const double height,
const double radius,
Poco::XML::AutoPtr<Poco::XML::Document> &document) {
using namespace Poco::XML;
AutoPtr<Element>shapeElement = document->createElement("cylinder");
AutoPtr<Element> shapeElement = document->createElement("cylinder");
shapeElement->setAttribute("id", id);
AutoPtr<Element> element = document->createElement("centre-of-bottom-base");
element->setAttribute("x", std::to_string(-height / 2));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment