paralleization of transformation and bounding box calculation
This commit is contained in:
@@ -16,6 +16,19 @@ set(Points_LIBS
|
||||
FreeCADApp
|
||||
)
|
||||
|
||||
if (BUILD_QT5)
|
||||
include_directories(
|
||||
${Qt5Concurrent_INCLUDE_DIRS}
|
||||
)
|
||||
list(APPEND Points_LIBS
|
||||
${Qt5Concurrent_LIBRARIES}
|
||||
)
|
||||
else()
|
||||
include_directories(
|
||||
${QT_QTCORE_INCLUDE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
generate_from_xml(PointsPy)
|
||||
|
||||
SET(Points_SRCS
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <QtConcurrentMap>
|
||||
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Matrix.h>
|
||||
@@ -39,10 +40,14 @@
|
||||
#include "PointsAlgos.h"
|
||||
#include "PointsPy.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <ppl.h>
|
||||
#endif
|
||||
|
||||
using namespace Points;
|
||||
using namespace std;
|
||||
|
||||
TYPESYSTEM_SOURCE(Points::PointKernel, Data::ComplexGeoData);
|
||||
TYPESYSTEM_SOURCE(Points::PointKernel, Data::ComplexGeoData)
|
||||
|
||||
std::vector<const char*> PointKernel::getElementTypes(void) const
|
||||
{
|
||||
@@ -73,15 +78,31 @@ Data::Segment* PointKernel::getSubElement(const char* /*Type*/, unsigned long /*
|
||||
void PointKernel::transformGeometry(const Base::Matrix4D &rclMat)
|
||||
{
|
||||
std::vector<value_type>& kernel = getBasicPoints();
|
||||
for (std::vector<value_type>::iterator it = kernel.begin(); it != kernel.end(); ++it)
|
||||
*it = rclMat * (*it);
|
||||
QtConcurrent::blockingMap(kernel, [rclMat](value_type& value) {
|
||||
rclMat.multVec(value, value);
|
||||
});
|
||||
}
|
||||
|
||||
Base::BoundBox3d PointKernel::getBoundBox(void)const
|
||||
{
|
||||
Base::BoundBox3d bnd;
|
||||
|
||||
#ifdef _WIN32
|
||||
// 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);
|
||||
});
|
||||
// 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_point_iterator it = begin(); it != end(); ++it)
|
||||
bnd.Add(*it);
|
||||
#endif
|
||||
return bnd;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,13 +39,15 @@
|
||||
#include "Properties.h"
|
||||
#include "PointsPy.h"
|
||||
|
||||
#include <QtConcurrentMap>
|
||||
|
||||
using namespace Points;
|
||||
using namespace std;
|
||||
|
||||
TYPESYSTEM_SOURCE(Points::PropertyGreyValue, App::PropertyFloat);
|
||||
TYPESYSTEM_SOURCE(Points::PropertyGreyValueList, App::PropertyLists);
|
||||
TYPESYSTEM_SOURCE(Points::PropertyNormalList, App::PropertyLists);
|
||||
TYPESYSTEM_SOURCE(Points::PropertyCurvatureList , App::PropertyLists);
|
||||
TYPESYSTEM_SOURCE(Points::PropertyGreyValue, App::PropertyFloat)
|
||||
TYPESYSTEM_SOURCE(Points::PropertyGreyValueList, App::PropertyLists)
|
||||
TYPESYSTEM_SOURCE(Points::PropertyNormalList, App::PropertyLists)
|
||||
TYPESYSTEM_SOURCE(Points::PropertyCurvatureList , App::PropertyLists)
|
||||
|
||||
PropertyGreyValueList::PropertyGreyValueList()
|
||||
{
|
||||
@@ -387,9 +389,9 @@ void PropertyNormalList::transformGeometry(const Base::Matrix4D &mat)
|
||||
aboutToSetValue();
|
||||
|
||||
// Rotate the normal vectors
|
||||
for (int ii=0; ii<getSize(); ii++) {
|
||||
set1Value(ii, rot * operator[](ii));
|
||||
}
|
||||
QtConcurrent::blockingMap(_lValueList, [rot](Base::Vector3f& value) {
|
||||
rot.multVec(value, value);
|
||||
});
|
||||
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
using namespace Points;
|
||||
|
||||
TYPESYSTEM_SOURCE(Points::PropertyPointKernel , App::PropertyComplexGeoData);
|
||||
TYPESYSTEM_SOURCE(Points::PropertyPointKernel , App::PropertyComplexGeoData)
|
||||
|
||||
PropertyPointKernel::PropertyPointKernel()
|
||||
: _cPoints(new PointKernel())
|
||||
@@ -70,10 +70,7 @@ const Data::ComplexGeoData* PropertyPointKernel::getComplexData() const
|
||||
|
||||
Base::BoundBox3d PropertyPointKernel::getBoundingBox() const
|
||||
{
|
||||
Base::BoundBox3d box;
|
||||
for (PointKernel::const_iterator it = _cPoints->begin(); it != _cPoints->end(); ++it)
|
||||
box.Add(*it);
|
||||
return box;
|
||||
return _cPoints->getBoundBox();
|
||||
}
|
||||
|
||||
PyObject *PropertyPointKernel::getPyObject(void)
|
||||
|
||||
Reference in New Issue
Block a user