Points: apply clang-formatting

This commit is contained in:
wmayer
2023-09-01 17:33:18 +02:00
committed by wwmayer
parent 047c39cb4c
commit c91b82db0b
32 changed files with 2829 additions and 2359 deletions

View File

@@ -22,10 +22,10 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cmath>
# include <iostream>
# include <QtConcurrentMap>
# include <boost/math/special_functions/fpclassify.hpp>
#include <QtConcurrentMap>
#include <boost/math/special_functions/fpclassify.hpp>
#include <cmath>
#include <iostream>
#endif
#include <Base/Matrix.h>
@@ -37,7 +37,7 @@
#ifdef _MSC_VER
# include <ppl.h>
#include <ppl.h>
#endif
using namespace Points;
@@ -46,16 +46,14 @@ using namespace std;
TYPESYSTEM_SOURCE(Points::PointKernel, Data::ComplexGeoData)
PointKernel::PointKernel(const PointKernel& pts)
: _Mtrx(pts._Mtrx)
, _Points(pts._Points)
{
}
: _Mtrx(pts._Mtrx)
, _Points(pts._Points)
{}
std::vector<const char*> PointKernel::getElementTypes() const
{
std::vector<const char*> temp;
//temp.push_back("Segment");
// temp.push_back("Segment");
return temp;
}
@@ -67,24 +65,25 @@ unsigned long PointKernel::countSubElements(const char* /*Type*/) const
Data::Segment* PointKernel::getSubElement(const char* /*Type*/, unsigned long /*n*/) const
{
//unsigned long i = 1;
// unsigned long i = 1;
//if (strcmp(Type,"Segment") == 0) {
// // not implemented
// assert(0);
// return 0;
//}
// if (strcmp(Type,"Segment") == 0) {
// // not implemented
// assert(0);
// return 0;
// }
return nullptr;
}
void PointKernel::transformGeometry(const Base::Matrix4D &rclMat)
void PointKernel::transformGeometry(const Base::Matrix4D& rclMat)
{
std::vector<value_type>& kernel = getBasicPoints();
#ifdef _MSC_VER
// Win32-only at the moment since ppl.h is a Microsoft library. Points is not using Qt so we cannot use QtConcurrent
// We could also rewrite Points to leverage SIMD instructions
// Other option: openMP. But with VC2013 results in high CPU usage even after computation (busy-waits for >100ms)
// Win32-only at the moment since ppl.h is a Microsoft library. Points is not using Qt so we
// cannot use QtConcurrent We could also rewrite Points to leverage SIMD instructions Other
// option: openMP. But with VC2013 results in high CPU usage even after computation (busy-waits
// for >100ms)
Concurrency::parallel_for_each(kernel.begin(), kernel.end(), [rclMat](value_type& value) {
value = rclMat * value;
});
@@ -95,31 +94,34 @@ void PointKernel::transformGeometry(const Base::Matrix4D &rclMat)
#endif
}
Base::BoundBox3d PointKernel::getBoundBox()const
Base::BoundBox3d PointKernel::getBoundBox() const
{
Base::BoundBox3d bnd;
#ifdef _MSC_VER
// Thread-local bounding boxes
Concurrency::combinable<Base::BoundBox3d> bbs;
// Cannot use a const_point_iterator here as it is *not* a proper iterator (fails the for_each template)
Concurrency::parallel_for_each(_Points.begin(), _Points.end(), [this, &bbs](const value_type& value) {
Base::Vector3d vertd(value.x, value.y, value.z);
bbs.local().Add(this->_Mtrx * vertd);
});
// Cannot use a const_point_iterator here as it is *not* a proper iterator (fails the for_each
// template)
Concurrency::parallel_for_each(_Points.begin(),
_Points.end(),
[this, &bbs](const value_type& value) {
Base::Vector3d vertd(value.x, value.y, value.z);
bbs.local().Add(this->_Mtrx * vertd);
});
// Combine each thread-local bounding box in the final bounding box
bbs.combine_each([&bnd](const Base::BoundBox3d& lbb) {
bnd.Add(lbb);
});
#else
for (const auto & it : *this) {
for (const auto& it : *this) {
bnd.Add(it);
}
#endif
return bnd;
}
void PointKernel::operator = (const PointKernel& Kernel)
void PointKernel::operator=(const PointKernel& Kernel)
{
if (this != &Kernel) {
// copy the mesh structure
@@ -128,7 +130,7 @@ void PointKernel::operator = (const PointKernel& Kernel)
}
}
unsigned int PointKernel::getMemSize () const
unsigned int PointKernel::getMemSize() const
{
return _Points.size() * sizeof(value_type);
}
@@ -136,10 +138,8 @@ unsigned int PointKernel::getMemSize () const
PointKernel::size_type PointKernel::countValid() const
{
size_type num = 0;
for (const auto & it : *this) {
if (!(boost::math::isnan(it.x) ||
boost::math::isnan(it.y) ||
boost::math::isnan(it.z))) {
for (const auto& it : *this) {
if (!(boost::math::isnan(it.x) || boost::math::isnan(it.y) || boost::math::isnan(it.z))) {
num++;
}
}
@@ -150,29 +150,26 @@ std::vector<PointKernel::value_type> PointKernel::getValidPoints() const
{
std::vector<PointKernel::value_type> valid;
valid.reserve(countValid());
for (const auto & it : *this) {
if (!(boost::math::isnan(it.x) ||
boost::math::isnan(it.y) ||
boost::math::isnan(it.z))) {
valid.emplace_back(
static_cast<float_type>(it.x),
static_cast<float_type>(it.y),
static_cast<float_type>(it.z));
for (const auto& it : *this) {
if (!(boost::math::isnan(it.x) || boost::math::isnan(it.y) || boost::math::isnan(it.z))) {
valid.emplace_back(static_cast<float_type>(it.x),
static_cast<float_type>(it.y),
static_cast<float_type>(it.z));
}
}
return valid;
}
void PointKernel::Save (Base::Writer &writer) const
void PointKernel::Save(Base::Writer& writer) const
{
if (!writer.isForceXML()) {
writer.Stream() << writer.ind()
<< "<Points file=\"" << writer.addFile(writer.ObjectName.c_str(), this) << "\" "
<< "mtrx=\"" << _Mtrx.toString() << "\"/>" << std::endl;
writer.Stream() << writer.ind() << "<Points file=\""
<< writer.addFile(writer.ObjectName.c_str(), this) << "\" "
<< "mtrx=\"" << _Mtrx.toString() << "\"/>" << std::endl;
}
}
void PointKernel::SaveDocFile (Base::Writer &writer) const
void PointKernel::SaveDocFile(Base::Writer& writer) const
{
Base::OutputStream str(writer.Stream());
uint32_t uCt = (uint32_t)size();
@@ -183,35 +180,35 @@ void PointKernel::SaveDocFile (Base::Writer &writer) const
}
}
void PointKernel::Restore(Base::XMLReader &reader)
void PointKernel::Restore(Base::XMLReader& reader)
{
clear();
reader.readElement("Points");
std::string file (reader.getAttribute("file") );
std::string file(reader.getAttribute("file"));
if (!file.empty()) {
// initiate a file read
reader.addFile(file.c_str(),this);
reader.addFile(file.c_str(), this);
}
if (reader.DocumentSchema > 3) {
std::string Matrix (reader.getAttribute("mtrx") );
std::string Matrix(reader.getAttribute("mtrx"));
_Mtrx.fromString(Matrix);
}
}
void PointKernel::RestoreDocFile(Base::Reader &reader)
void PointKernel::RestoreDocFile(Base::Reader& reader)
{
Base::InputStream str(reader);
uint32_t uCt = 0;
str >> uCt;
_Points.resize(uCt);
for (unsigned long i=0; i < uCt; i++) {
for (unsigned long i = 0; i < uCt; i++) {
float x;
float y;
float z;
str >> x >> y >> z;
_Points[i].Set(x,y,z);
_Points[i].Set(x, y, z);
}
}
@@ -223,7 +220,7 @@ void PointKernel::save(const char* file) const
void PointKernel::load(const char* file)
{
PointsAlgos::Load(*this,file);
PointsAlgos::Load(*this, file);
}
void PointKernel::save(std::ostream& out) const
@@ -234,38 +231,39 @@ void PointKernel::save(std::ostream& out) const
}
}
void PointKernel::getPoints(std::vector<Base::Vector3d> &Points,
std::vector<Base::Vector3d> &/*Normals*/,
double /*Accuracy*/, uint16_t /*flags*/) const
void PointKernel::getPoints(std::vector<Base::Vector3d>& Points,
std::vector<Base::Vector3d>& /*Normals*/,
double /*Accuracy*/,
uint16_t /*flags*/) const
{
unsigned long ctpoints = _Points.size();
Points.reserve(ctpoints);
for (unsigned long i=0; i<ctpoints; i++) {
for (unsigned long i = 0; i < ctpoints; i++) {
Points.push_back(this->getPoint(i));
}
}
// ----------------------------------------------------------------------------
PointKernel::const_point_iterator::const_point_iterator
(const PointKernel* kernel, std::vector<kernel_type>::const_iterator index)
: _kernel(kernel), _p_it(index)
PointKernel::const_point_iterator::const_point_iterator(
const PointKernel* kernel,
std::vector<kernel_type>::const_iterator index)
: _kernel(kernel)
, _p_it(index)
{
if(_p_it != kernel->_Points.end())
{
if (_p_it != kernel->_Points.end()) {
value_type vertd(_p_it->x, _p_it->y, _p_it->z);
this->_point = _kernel->_Mtrx * vertd;
}
}
PointKernel::const_point_iterator::const_point_iterator
(const PointKernel::const_point_iterator& fi) = default;
PointKernel::const_point_iterator::const_point_iterator(
const PointKernel::const_point_iterator& fi) = default;
PointKernel::const_point_iterator::~const_point_iterator() = default;
PointKernel::const_point_iterator&
PointKernel::const_point_iterator::operator=
(const PointKernel::const_point_iterator& pi) = default;
PointKernel::const_point_iterator::operator=(const PointKernel::const_point_iterator& pi) = default;
void PointKernel::const_point_iterator::dereference()
{
@@ -273,54 +271,50 @@ void PointKernel::const_point_iterator::dereference()
this->_point = _kernel->_Mtrx * vertd;
}
const PointKernel::const_point_iterator::value_type&
PointKernel::const_point_iterator::operator*()
const PointKernel::const_point_iterator::value_type& PointKernel::const_point_iterator::operator*()
{
dereference();
return this->_point;
}
const PointKernel::const_point_iterator::value_type*
PointKernel::const_point_iterator::operator->()
const PointKernel::const_point_iterator::value_type* PointKernel::const_point_iterator::operator->()
{
dereference();
return &(this->_point);
}
bool PointKernel::const_point_iterator::operator==(const PointKernel::const_point_iterator& pi) const
bool PointKernel::const_point_iterator::operator==(
const PointKernel::const_point_iterator& pi) const
{
return (this->_kernel == pi._kernel) && (this->_p_it == pi._p_it);
}
bool PointKernel::const_point_iterator::operator!=(const PointKernel::const_point_iterator& pi) const
bool PointKernel::const_point_iterator::operator!=(
const PointKernel::const_point_iterator& pi) const
{
return !operator==(pi);
}
PointKernel::const_point_iterator&
PointKernel::const_point_iterator::operator++()
PointKernel::const_point_iterator& PointKernel::const_point_iterator::operator++()
{
++(this->_p_it);
return *this;
}
PointKernel::const_point_iterator
PointKernel::const_point_iterator::operator++(int)
PointKernel::const_point_iterator PointKernel::const_point_iterator::operator++(int)
{
PointKernel::const_point_iterator tmp = *this;
++(this->_p_it);
return tmp;
}
PointKernel::const_point_iterator&
PointKernel::const_point_iterator::operator--()
PointKernel::const_point_iterator& PointKernel::const_point_iterator::operator--()
{
--(this->_p_it);
return *this;
}
PointKernel::const_point_iterator
PointKernel::const_point_iterator::operator--(int)
PointKernel::const_point_iterator PointKernel::const_point_iterator::operator--(int)
{
PointKernel::const_point_iterator tmp = *this;
--(this->_p_it);
@@ -328,17 +322,17 @@ PointKernel::const_point_iterator::operator--(int)
}
PointKernel::const_point_iterator
PointKernel::const_point_iterator::operator+ (difference_type off) const
PointKernel::const_point_iterator::operator+(difference_type off) const
{
PointKernel::const_point_iterator tmp = *this;
return (tmp+=off);
return (tmp += off);
}
PointKernel::const_point_iterator
PointKernel::const_point_iterator::operator- (difference_type off) const
PointKernel::const_point_iterator::operator-(difference_type off) const
{
PointKernel::const_point_iterator tmp = *this;
return (tmp-=off);
return (tmp -= off);
}
PointKernel::const_point_iterator&
@@ -356,7 +350,7 @@ PointKernel::const_point_iterator::operator-=(difference_type off)
}
PointKernel::difference_type
PointKernel::const_point_iterator::operator- (const PointKernel::const_point_iterator& right) const
PointKernel::const_point_iterator::operator-(const PointKernel::const_point_iterator& right) const
{
return this->_p_it - right._p_it;
}