All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -52,10 +52,12 @@ public:
|
||||
add_varargs_method("open", &Module::open);
|
||||
add_varargs_method("insert", &Module::importer);
|
||||
add_varargs_method("export", &Module::exporter);
|
||||
add_varargs_method("show",
|
||||
&Module::show,
|
||||
"show(points,[string]) -- Add the points to the active document or "
|
||||
"create one if no document exists. Returns document object.");
|
||||
add_varargs_method(
|
||||
"show",
|
||||
&Module::show,
|
||||
"show(points,[string]) -- Add the points to the active document or "
|
||||
"create one if no document exists. Returns document object."
|
||||
);
|
||||
initialize("This module is the Points module."); // register with Python
|
||||
}
|
||||
|
||||
@@ -97,9 +99,11 @@ private:
|
||||
}
|
||||
else if (file.hasExtension("e57")) {
|
||||
auto setting = readE57Settings();
|
||||
reader = std::make_unique<E57Reader>(std::get<0>(setting),
|
||||
std::get<1>(setting),
|
||||
std::get<2>(setting));
|
||||
reader = std::make_unique<E57Reader>(
|
||||
std::get<0>(setting),
|
||||
std::get<1>(setting),
|
||||
std::get<2>(setting)
|
||||
);
|
||||
}
|
||||
else if (file.hasExtension("ply")) {
|
||||
reader = std::make_unique<PlyReader>();
|
||||
@@ -121,13 +125,15 @@ private:
|
||||
if (reader->isStructured()) {
|
||||
pcFeature = new Points::StructuredCustom();
|
||||
|
||||
App::PropertyInteger* width =
|
||||
static_cast<App::PropertyInteger*>(pcFeature->getPropertyByName("Width"));
|
||||
App::PropertyInteger* width = static_cast<App::PropertyInteger*>(
|
||||
pcFeature->getPropertyByName("Width")
|
||||
);
|
||||
if (width) {
|
||||
width->setValue(reader->getWidth());
|
||||
}
|
||||
App::PropertyInteger* height =
|
||||
static_cast<App::PropertyInteger*>(pcFeature->getPropertyByName("Height"));
|
||||
App::PropertyInteger* height = static_cast<App::PropertyInteger*>(
|
||||
pcFeature->getPropertyByName("Height")
|
||||
);
|
||||
if (height) {
|
||||
height->setValue(reader->getHeight());
|
||||
}
|
||||
@@ -139,10 +145,9 @@ private:
|
||||
pcFeature->Points.setValue(reader->getPoints());
|
||||
// add gray values
|
||||
if (reader->hasIntensities()) {
|
||||
Points::PropertyGreyValueList* prop =
|
||||
static_cast<Points::PropertyGreyValueList*>(
|
||||
pcFeature->addDynamicProperty("Points::PropertyGreyValueList",
|
||||
"Intensity"));
|
||||
Points::PropertyGreyValueList* prop = static_cast<Points::PropertyGreyValueList*>(
|
||||
pcFeature->addDynamicProperty("Points::PropertyGreyValueList", "Intensity")
|
||||
);
|
||||
if (prop) {
|
||||
prop->setValues(reader->getIntensities());
|
||||
}
|
||||
@@ -150,7 +155,8 @@ private:
|
||||
// add colors
|
||||
if (reader->hasColors()) {
|
||||
App::PropertyColorList* prop = static_cast<App::PropertyColorList*>(
|
||||
pcFeature->addDynamicProperty("App::PropertyColorList", "Color"));
|
||||
pcFeature->addDynamicProperty("App::PropertyColorList", "Color")
|
||||
);
|
||||
if (prop) {
|
||||
prop->setValues(reader->getColors());
|
||||
}
|
||||
@@ -158,7 +164,8 @@ private:
|
||||
// add normals
|
||||
if (reader->hasNormals()) {
|
||||
Points::PropertyNormalList* prop = static_cast<Points::PropertyNormalList*>(
|
||||
pcFeature->addDynamicProperty("Points::PropertyNormalList", "Normal"));
|
||||
pcFeature->addDynamicProperty("Points::PropertyNormalList", "Normal")
|
||||
);
|
||||
if (prop) {
|
||||
prop->setValues(reader->getNormals());
|
||||
}
|
||||
@@ -219,9 +226,11 @@ private:
|
||||
}
|
||||
else if (file.hasExtension("e57")) {
|
||||
auto setting = readE57Settings();
|
||||
reader = std::make_unique<E57Reader>(std::get<0>(setting),
|
||||
std::get<1>(setting),
|
||||
std::get<2>(setting));
|
||||
reader = std::make_unique<E57Reader>(
|
||||
std::get<0>(setting),
|
||||
std::get<1>(setting),
|
||||
std::get<2>(setting)
|
||||
);
|
||||
}
|
||||
else if (file.hasExtension("ply")) {
|
||||
reader = std::make_unique<PlyReader>();
|
||||
@@ -246,13 +255,15 @@ private:
|
||||
if (reader->isStructured()) {
|
||||
pcFeature = new Points::StructuredCustom();
|
||||
|
||||
App::PropertyInteger* width =
|
||||
static_cast<App::PropertyInteger*>(pcFeature->getPropertyByName("Width"));
|
||||
App::PropertyInteger* width = static_cast<App::PropertyInteger*>(
|
||||
pcFeature->getPropertyByName("Width")
|
||||
);
|
||||
if (width) {
|
||||
width->setValue(reader->getWidth());
|
||||
}
|
||||
App::PropertyInteger* height =
|
||||
static_cast<App::PropertyInteger*>(pcFeature->getPropertyByName("Height"));
|
||||
App::PropertyInteger* height = static_cast<App::PropertyInteger*>(
|
||||
pcFeature->getPropertyByName("Height")
|
||||
);
|
||||
if (height) {
|
||||
height->setValue(reader->getHeight());
|
||||
}
|
||||
@@ -264,10 +275,9 @@ private:
|
||||
pcFeature->Points.setValue(reader->getPoints());
|
||||
// add gray values
|
||||
if (reader->hasIntensities()) {
|
||||
Points::PropertyGreyValueList* prop =
|
||||
static_cast<Points::PropertyGreyValueList*>(
|
||||
pcFeature->addDynamicProperty("Points::PropertyGreyValueList",
|
||||
"Intensity"));
|
||||
Points::PropertyGreyValueList* prop = static_cast<Points::PropertyGreyValueList*>(
|
||||
pcFeature->addDynamicProperty("Points::PropertyGreyValueList", "Intensity")
|
||||
);
|
||||
if (prop) {
|
||||
prop->setValues(reader->getIntensities());
|
||||
}
|
||||
@@ -275,7 +285,8 @@ private:
|
||||
// add colors
|
||||
if (reader->hasColors()) {
|
||||
App::PropertyColorList* prop = static_cast<App::PropertyColorList*>(
|
||||
pcFeature->addDynamicProperty("App::PropertyColorList", "Color"));
|
||||
pcFeature->addDynamicProperty("App::PropertyColorList", "Color")
|
||||
);
|
||||
if (prop) {
|
||||
prop->setValues(reader->getColors());
|
||||
}
|
||||
@@ -283,7 +294,8 @@ private:
|
||||
// add normals
|
||||
if (reader->hasNormals()) {
|
||||
Points::PropertyNormalList* prop = static_cast<Points::PropertyNormalList*>(
|
||||
pcFeature->addDynamicProperty("Points::PropertyNormalList", "Normal"));
|
||||
pcFeature->addDynamicProperty("Points::PropertyNormalList", "Normal")
|
||||
);
|
||||
if (prop) {
|
||||
prop->setValues(reader->getNormals());
|
||||
}
|
||||
@@ -331,8 +343,8 @@ private:
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
PyObject* item = (*it).ptr();
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||
App::DocumentObject* obj =
|
||||
static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
App::DocumentObject* obj
|
||||
= static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
if (obj->isDerivedFrom<Points::Feature>()) {
|
||||
// get relative placement
|
||||
Points::Feature* fea = static_cast<Points::Feature*>(obj);
|
||||
@@ -354,32 +366,36 @@ private:
|
||||
}
|
||||
|
||||
// get additional properties if there
|
||||
App::PropertyInteger* width =
|
||||
dynamic_cast<App::PropertyInteger*>(fea->getPropertyByName("Width"));
|
||||
App::PropertyInteger* width = dynamic_cast<App::PropertyInteger*>(
|
||||
fea->getPropertyByName("Width")
|
||||
);
|
||||
if (width) {
|
||||
writer->setWidth(width->getValue());
|
||||
}
|
||||
App::PropertyInteger* height =
|
||||
dynamic_cast<App::PropertyInteger*>(fea->getPropertyByName("Height"));
|
||||
App::PropertyInteger* height = dynamic_cast<App::PropertyInteger*>(
|
||||
fea->getPropertyByName("Height")
|
||||
);
|
||||
if (height) {
|
||||
writer->setHeight(height->getValue());
|
||||
}
|
||||
// get gray values
|
||||
Points::PropertyGreyValueList* grey =
|
||||
dynamic_cast<Points::PropertyGreyValueList*>(
|
||||
fea->getPropertyByName("Intensity"));
|
||||
Points::PropertyGreyValueList* grey = dynamic_cast<Points::PropertyGreyValueList*>(
|
||||
fea->getPropertyByName("Intensity")
|
||||
);
|
||||
if (grey) {
|
||||
writer->setIntensities(grey->getValues());
|
||||
}
|
||||
// get colors
|
||||
App::PropertyColorList* col =
|
||||
dynamic_cast<App::PropertyColorList*>(fea->getPropertyByName("Color"));
|
||||
App::PropertyColorList* col = dynamic_cast<App::PropertyColorList*>(
|
||||
fea->getPropertyByName("Color")
|
||||
);
|
||||
if (col) {
|
||||
writer->setColors(col->getValues());
|
||||
}
|
||||
// get normals
|
||||
Points::PropertyNormalList* nor =
|
||||
dynamic_cast<Points::PropertyNormalList*>(fea->getPropertyByName("Normal"));
|
||||
Points::PropertyNormalList* nor = dynamic_cast<Points::PropertyNormalList*>(
|
||||
fea->getPropertyByName("Normal")
|
||||
);
|
||||
if (nor) {
|
||||
writer->setNormals(nor->getValues());
|
||||
}
|
||||
@@ -390,8 +406,10 @@ private:
|
||||
break;
|
||||
}
|
||||
else {
|
||||
Base::Console().message("'%s' is not a point object, export will be ignored.\n",
|
||||
obj->Label.getValue());
|
||||
Base::Console().message(
|
||||
"'%s' is not a point object, export will be ignored.\n",
|
||||
obj->Label.getValue()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <ppl.h>
|
||||
# include <ppl.h>
|
||||
#endif
|
||||
|
||||
using namespace Points;
|
||||
@@ -93,9 +93,7 @@ void PointKernel::transformGeometry(const Base::Matrix4D& rclMat)
|
||||
value = rclMat * value;
|
||||
});
|
||||
#else
|
||||
QtConcurrent::blockingMap(kernel, [rclMat](value_type& value) {
|
||||
rclMat.multVec(value, value);
|
||||
});
|
||||
QtConcurrent::blockingMap(kernel, [rclMat](value_type& value) { rclMat.multVec(value, value); });
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -108,9 +106,7 @@ void PointKernel::moveGeometry(const Base::Vector3d& vec)
|
||||
value += offset;
|
||||
});
|
||||
#else
|
||||
QtConcurrent::blockingMap(kernel, [offset](value_type& value) {
|
||||
value += offset;
|
||||
});
|
||||
QtConcurrent::blockingMap(kernel, [offset](value_type& value) { value += offset; });
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -123,16 +119,12 @@ Base::BoundBox3d PointKernel::getBoundBox() const
|
||||
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);
|
||||
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) {
|
||||
bnd.Add(it);
|
||||
@@ -185,9 +177,11 @@ std::vector<PointKernel::value_type> PointKernel::getValidPoints() const
|
||||
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));
|
||||
valid.emplace_back(
|
||||
static_cast<float_type>(it.x),
|
||||
static_cast<float_type>(it.y),
|
||||
static_cast<float_type>(it.z)
|
||||
);
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
@@ -264,10 +258,12 @@ 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);
|
||||
@@ -280,7 +276,8 @@ void PointKernel::getPoints(std::vector<Base::Vector3d>& Points,
|
||||
|
||||
PointKernel::const_point_iterator::const_point_iterator(
|
||||
const PointKernel* kernel,
|
||||
std::vector<kernel_type>::const_iterator index)
|
||||
std::vector<kernel_type>::const_iterator index
|
||||
)
|
||||
: _kernel(kernel)
|
||||
, _p_it(index)
|
||||
{
|
||||
@@ -291,18 +288,22 @@ PointKernel::const_point_iterator::const_point_iterator(
|
||||
}
|
||||
|
||||
PointKernel::const_point_iterator::const_point_iterator(
|
||||
const PointKernel::const_point_iterator& fi) = default;
|
||||
const PointKernel::const_point_iterator& fi
|
||||
) = default;
|
||||
|
||||
PointKernel::const_point_iterator::const_point_iterator(PointKernel::const_point_iterator&& fi) =
|
||||
default;
|
||||
PointKernel::const_point_iterator::const_point_iterator(
|
||||
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& PointKernel::const_point_iterator::operator=(
|
||||
const PointKernel::const_point_iterator& pi
|
||||
) = default;
|
||||
|
||||
PointKernel::const_point_iterator&
|
||||
PointKernel::const_point_iterator::operator=(PointKernel::const_point_iterator&& pi) = default;
|
||||
PointKernel::const_point_iterator& PointKernel::const_point_iterator::operator=(
|
||||
PointKernel::const_point_iterator&& pi
|
||||
) = default;
|
||||
|
||||
void PointKernel::const_point_iterator::dereference()
|
||||
{
|
||||
@@ -322,14 +323,12 @@ const PointKernel::const_point_iterator::value_type* PointKernel::const_point_it
|
||||
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);
|
||||
}
|
||||
@@ -360,36 +359,33 @@ PointKernel::const_point_iterator PointKernel::const_point_iterator::operator--(
|
||||
return tmp;
|
||||
}
|
||||
|
||||
PointKernel::const_point_iterator
|
||||
PointKernel::const_point_iterator::operator+(difference_type off) const
|
||||
PointKernel::const_point_iterator PointKernel::const_point_iterator::operator+(difference_type off) const
|
||||
{
|
||||
PointKernel::const_point_iterator tmp = *this;
|
||||
return (tmp += off);
|
||||
}
|
||||
|
||||
PointKernel::const_point_iterator
|
||||
PointKernel::const_point_iterator::operator-(difference_type off) const
|
||||
PointKernel::const_point_iterator PointKernel::const_point_iterator::operator-(difference_type off) const
|
||||
{
|
||||
PointKernel::const_point_iterator tmp = *this;
|
||||
return (tmp -= off);
|
||||
}
|
||||
|
||||
PointKernel::const_point_iterator&
|
||||
PointKernel::const_point_iterator::operator+=(difference_type off)
|
||||
PointKernel::const_point_iterator& PointKernel::const_point_iterator::operator+=(difference_type off)
|
||||
{
|
||||
(this->_p_it) += off;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PointKernel::const_point_iterator&
|
||||
PointKernel::const_point_iterator::operator-=(difference_type off)
|
||||
PointKernel::const_point_iterator& PointKernel::const_point_iterator::operator-=(difference_type off)
|
||||
{
|
||||
(this->_p_it) -= off;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PointKernel::difference_type
|
||||
PointKernel::const_point_iterator::operator-(const PointKernel::const_point_iterator& right) const
|
||||
PointKernel::difference_type PointKernel::const_point_iterator::operator-(
|
||||
const PointKernel::const_point_iterator& right
|
||||
) const
|
||||
{
|
||||
return this->_p_it - right._p_it;
|
||||
}
|
||||
|
||||
@@ -103,10 +103,12 @@ public:
|
||||
this->_Points.swap(pts);
|
||||
}
|
||||
|
||||
void getPoints(std::vector<Base::Vector3d>& Points,
|
||||
std::vector<Base::Vector3d>& Normals,
|
||||
double Accuracy,
|
||||
uint16_t flags = 0) const override;
|
||||
void getPoints(
|
||||
std::vector<Base::Vector3d>& Points,
|
||||
std::vector<Base::Vector3d>& Normals,
|
||||
double Accuracy,
|
||||
uint16_t flags = 0
|
||||
) const override;
|
||||
void transformGeometry(const Base::Matrix4D& rclMat) override;
|
||||
void moveGeometry(const Base::Vector3d& vec);
|
||||
Base::BoundBox3d getBoundBox() const override;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <FCConfig.h>
|
||||
|
||||
#ifdef FC_OS_LINUX
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
@@ -67,9 +67,11 @@ void PointsAlgos::Load(PointKernel& points, const char* FileName)
|
||||
|
||||
void PointsAlgos::LoadAscii(PointKernel& points, const char* FileName)
|
||||
{
|
||||
boost::regex rx("^\\s*([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)\\s*$");
|
||||
boost::regex rx(
|
||||
"^\\s*([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)\\s*$"
|
||||
);
|
||||
// boost::regex rx("(\\b[0-9]+\\.([0-9]+\\b)?|\\.[0-9]+\\b)");
|
||||
// boost::regex
|
||||
// rx("^\\s*(-?[0-9]*)\\.([0-9]+)\\s+(-?[0-9]*)\\.([0-9]+)\\s+(-?[0-9]*)\\.([0-9]+)\\s*$");
|
||||
@@ -285,9 +287,11 @@ protected:
|
||||
{
|
||||
return _end - _cur;
|
||||
}
|
||||
pos_type seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode mode = std::ios::in | std::ios::out) override
|
||||
pos_type seekoff(
|
||||
std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode mode = std::ios::in | std::ios::out
|
||||
) override
|
||||
{
|
||||
(void)mode;
|
||||
int p_pos = -1;
|
||||
@@ -313,8 +317,10 @@ protected:
|
||||
|
||||
return ((p_pos + off) - _beg);
|
||||
}
|
||||
pos_type seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override
|
||||
pos_type seekpos(
|
||||
std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override
|
||||
{
|
||||
(void)which;
|
||||
return seekoff(pos, std::ios_base::beg);
|
||||
@@ -333,8 +339,12 @@ private:
|
||||
|
||||
// NOLINTBEGIN
|
||||
// Taken from https://github.com/PointCloudLibrary/pcl/blob/master/io/src/lzf.cpp
|
||||
unsigned int
|
||||
lzfDecompress(const void* const in_data, unsigned int in_len, void* out_data, unsigned int out_len)
|
||||
unsigned int lzfDecompress(
|
||||
const void* const in_data,
|
||||
unsigned int in_len,
|
||||
void* out_data,
|
||||
unsigned int out_len
|
||||
)
|
||||
{
|
||||
unsigned char const* ip = static_cast<const unsigned char*>(in_data);
|
||||
unsigned char* op = static_cast<unsigned char*>(out_data);
|
||||
@@ -698,10 +708,12 @@ void PlyReader::read(const std::string& filename)
|
||||
if (alpha != max_size) {
|
||||
a = static_cast<float>(data(i, alpha));
|
||||
}
|
||||
colors.emplace_back(static_cast<float>(r) / 255.0F,
|
||||
static_cast<float>(g) / 255.0F,
|
||||
static_cast<float>(b) / 255.0F,
|
||||
static_cast<float>(a) / 255.0F);
|
||||
colors.emplace_back(
|
||||
static_cast<float>(r) / 255.0F,
|
||||
static_cast<float>(g) / 255.0F,
|
||||
static_cast<float>(b) / 255.0F,
|
||||
static_cast<float>(a) / 255.0F
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (types[red] == "float") {
|
||||
@@ -718,12 +730,14 @@ void PlyReader::read(const std::string& filename)
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t PlyReader::readHeader(std::istream& in,
|
||||
std::string& format,
|
||||
std::size_t& offset,
|
||||
std::vector<std::string>& fields,
|
||||
std::vector<std::string>& types,
|
||||
std::vector<int>& sizes)
|
||||
std::size_t PlyReader::readHeader(
|
||||
std::istream& in,
|
||||
std::string& format,
|
||||
std::size_t& offset,
|
||||
std::vector<std::string>& fields,
|
||||
std::vector<std::string>& types,
|
||||
std::vector<int>& sizes
|
||||
)
|
||||
{
|
||||
std::string line;
|
||||
std::string element;
|
||||
@@ -921,12 +935,14 @@ void PlyReader::readAscii(std::istream& inp, std::size_t offset, Eigen::MatrixXd
|
||||
}
|
||||
}
|
||||
|
||||
void PlyReader::readBinary(bool swapByteOrder,
|
||||
std::istream& inp,
|
||||
std::size_t offset,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data)
|
||||
void PlyReader::readBinary(
|
||||
bool swapByteOrder,
|
||||
std::istream& inp,
|
||||
std::size_t offset,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data
|
||||
)
|
||||
{
|
||||
Eigen::Index numPoints = data.rows();
|
||||
Eigen::Index numFields = data.cols();
|
||||
@@ -1173,8 +1189,7 @@ void PcdReader::read(const std::string& filename)
|
||||
}
|
||||
}
|
||||
else if (types[rgba] == "F") {
|
||||
static_assert(sizeof(float) == sizeof(uint32_t),
|
||||
"float and uint32_t have different sizes");
|
||||
static_assert(sizeof(float) == sizeof(uint32_t), "float and uint32_t have different sizes");
|
||||
for (Eigen::Index i = 0; i < numPoints; i++) {
|
||||
float f = static_cast<float>(data(i, rgba));
|
||||
uint32_t packed {};
|
||||
@@ -1187,11 +1202,13 @@ void PcdReader::read(const std::string& filename)
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t PcdReader::readHeader(std::istream& in,
|
||||
std::string& format,
|
||||
std::vector<std::string>& fields,
|
||||
std::vector<std::string>& types,
|
||||
std::vector<int>& sizes)
|
||||
std::size_t PcdReader::readHeader(
|
||||
std::istream& in,
|
||||
std::string& format,
|
||||
std::vector<std::string>& fields,
|
||||
std::vector<std::string>& types,
|
||||
std::vector<int>& sizes
|
||||
)
|
||||
{
|
||||
std::string line;
|
||||
std::vector<std::string> counts;
|
||||
@@ -1286,11 +1303,13 @@ void PcdReader::readAscii(std::istream& inp, Eigen::MatrixXd& data)
|
||||
}
|
||||
}
|
||||
|
||||
void PcdReader::readBinary(bool transpose,
|
||||
std::istream& inp,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data)
|
||||
void PcdReader::readBinary(
|
||||
bool transpose,
|
||||
std::istream& inp,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data
|
||||
)
|
||||
{
|
||||
Eigen::Index numPoints = data.rows();
|
||||
Eigen::Index numFields = data.cols();
|
||||
@@ -1484,16 +1503,21 @@ private:
|
||||
for (int i = 0; i < prototype.childCount(); ++i) {
|
||||
e57::Node node(prototype.get(i));
|
||||
if ((node.type() == e57::E57_FLOAT) || (node.type() == e57::E57_SCALED_INTEGER)) {
|
||||
if (readCartesian(node, proto)) {}
|
||||
else if (readNormal(node, proto)) {}
|
||||
else if (readItensity(node, proto)) {}
|
||||
if (readCartesian(node, proto)) {
|
||||
}
|
||||
else if (readNormal(node, proto)) {
|
||||
}
|
||||
else if (readItensity(node, proto)) {
|
||||
}
|
||||
else {
|
||||
readOther(node, proto);
|
||||
}
|
||||
}
|
||||
else if (node.type() == e57::E57_INTEGER) {
|
||||
if (readColor(node, proto)) {}
|
||||
else if (readCartesianInvalidState(node, proto)) {}
|
||||
if (readColor(node, proto)) {
|
||||
}
|
||||
else if (readCartesianInvalidState(node, proto)) {
|
||||
}
|
||||
else {
|
||||
readOther(node, proto);
|
||||
}
|
||||
@@ -1507,26 +1531,41 @@ private:
|
||||
{
|
||||
if (node.elementName() == "cartesianX") {
|
||||
proto.cnt_xyz++;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.xData.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.xData.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
else if (node.elementName() == "cartesianY") {
|
||||
proto.cnt_xyz++;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.yData.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.yData.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
else if (node.elementName() == "cartesianZ") {
|
||||
proto.cnt_xyz++;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.zData.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.zData.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1537,26 +1576,41 @@ private:
|
||||
{
|
||||
if (node.elementName() == "nor:normalX") {
|
||||
proto.cnt_nor++;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.xNormal.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.xNormal.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
else if (node.elementName() == "nor:normalY") {
|
||||
proto.cnt_nor++;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.yNormal.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.yNormal.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
else if (node.elementName() == "nor:normalZ") {
|
||||
proto.cnt_nor++;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.zNormal.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.zNormal.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1567,10 +1621,15 @@ private:
|
||||
{
|
||||
if (node.elementName() == "cartesianInvalidState") {
|
||||
proto.inv_state = true;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.state.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.state.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1581,26 +1640,41 @@ private:
|
||||
{
|
||||
if (node.elementName() == "colorRed") {
|
||||
proto.cnt_rgb++;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.redData.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.redData.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
if (node.elementName() == "colorGreen") {
|
||||
proto.cnt_rgb++;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.greenData.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.greenData.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
if (node.elementName() == "colorBlue") {
|
||||
proto.cnt_rgb++;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.blueData.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.blueData.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1611,10 +1685,15 @@ private:
|
||||
{
|
||||
if (node.elementName() == "intensity") {
|
||||
proto.inty = true;
|
||||
proto.sdb
|
||||
.emplace_back(imfi, node.elementName(), proto.intensity.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.intensity.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1623,15 +1702,23 @@ private:
|
||||
|
||||
void readOther(const e57::Node& node, Proto& proto)
|
||||
{
|
||||
proto.sdb.emplace_back(imfi, node.elementName(), proto.nil.data(), buf_size, true, true
|
||||
proto.sdb.emplace_back(
|
||||
imfi,
|
||||
node.elementName(),
|
||||
proto.nil.data(),
|
||||
buf_size,
|
||||
true,
|
||||
true
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
void processProto(e57::CompressedVectorNode& cvn,
|
||||
const Proto& proto,
|
||||
bool hasPlacement,
|
||||
const Base::Placement& plm)
|
||||
void processProto(
|
||||
e57::CompressedVectorNode& cvn,
|
||||
const Proto& proto,
|
||||
bool hasPlacement,
|
||||
const Base::Placement& plm
|
||||
)
|
||||
{
|
||||
if (proto.cnt_xyz != 3) {
|
||||
throw Base::BadFormatError("Missing channels xyz");
|
||||
@@ -1680,8 +1767,12 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
Base::Vector3d
|
||||
getCoord(const Proto& proto, size_t index, bool hasPlacement, const Base::Placement& plm) const
|
||||
Base::Vector3d getCoord(
|
||||
const Proto& proto,
|
||||
size_t index,
|
||||
bool hasPlacement,
|
||||
const Base::Placement& plm
|
||||
) const
|
||||
{
|
||||
Base::Vector3d pt;
|
||||
pt.x = proto.xData[index];
|
||||
@@ -1693,8 +1784,12 @@ private:
|
||||
return pt;
|
||||
}
|
||||
|
||||
Base::Vector3f
|
||||
getNormal(const Proto& proto, size_t index, bool hasPlacement, const Base::Rotation& rot) const
|
||||
Base::Vector3f getNormal(
|
||||
const Proto& proto,
|
||||
size_t index,
|
||||
bool hasPlacement,
|
||||
const Base::Rotation& rot
|
||||
) const
|
||||
{
|
||||
Base::Vector3f pt;
|
||||
pt.x = proto.xNormal[index];
|
||||
|
||||
@@ -97,19 +97,23 @@ public:
|
||||
void read(const std::string& filename) override;
|
||||
|
||||
private:
|
||||
std::size_t readHeader(std::istream&,
|
||||
std::string& format,
|
||||
std::size_t& offset,
|
||||
std::vector<std::string>& fields,
|
||||
std::vector<std::string>& types,
|
||||
std::vector<int>& sizes);
|
||||
std::size_t readHeader(
|
||||
std::istream&,
|
||||
std::string& format,
|
||||
std::size_t& offset,
|
||||
std::vector<std::string>& fields,
|
||||
std::vector<std::string>& types,
|
||||
std::vector<int>& sizes
|
||||
);
|
||||
void readAscii(std::istream&, std::size_t offset, Eigen::MatrixXd& data);
|
||||
void readBinary(bool swapByteOrder,
|
||||
std::istream&,
|
||||
std::size_t offset,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data);
|
||||
void readBinary(
|
||||
bool swapByteOrder,
|
||||
std::istream&,
|
||||
std::size_t offset,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data
|
||||
);
|
||||
};
|
||||
|
||||
class PointsExport PcdReader: public Reader
|
||||
@@ -119,17 +123,21 @@ public:
|
||||
void read(const std::string& filename) override;
|
||||
|
||||
private:
|
||||
std::size_t readHeader(std::istream&,
|
||||
std::string& format,
|
||||
std::vector<std::string>& fields,
|
||||
std::vector<std::string>& types,
|
||||
std::vector<int>& sizes);
|
||||
std::size_t readHeader(
|
||||
std::istream&,
|
||||
std::string& format,
|
||||
std::vector<std::string>& fields,
|
||||
std::vector<std::string>& types,
|
||||
std::vector<int>& sizes
|
||||
);
|
||||
void readAscii(std::istream&, Eigen::MatrixXd& data);
|
||||
void readBinary(bool transpose,
|
||||
std::istream&,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data);
|
||||
void readBinary(
|
||||
bool transpose,
|
||||
std::istream&,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data
|
||||
);
|
||||
};
|
||||
|
||||
class PointsExport E57Reader: public Reader
|
||||
|
||||
@@ -58,10 +58,7 @@ PointsGrid::PointsGrid()
|
||||
, _fMinZ(0.0F)
|
||||
{}
|
||||
|
||||
PointsGrid::PointsGrid(const PointKernel& rclM,
|
||||
unsigned long ulX,
|
||||
unsigned long ulY,
|
||||
unsigned long ulZ)
|
||||
PointsGrid::PointsGrid(const PointKernel& rclM, unsigned long ulX, unsigned long ulY, unsigned long ulZ)
|
||||
: _pclPoints(&rclM)
|
||||
, _ulCtElements(0)
|
||||
, _ulCtGridsX(0)
|
||||
@@ -110,9 +107,11 @@ PointsGrid::PointsGrid(const PointKernel& rclM, double fGridLen)
|
||||
for (const auto& pnt : *_pclPoints) {
|
||||
clBBPts.Add(pnt);
|
||||
}
|
||||
PointsGrid::Rebuild(std::max<unsigned long>((unsigned long)(clBBPts.LengthX() / fGridLen), 1),
|
||||
std::max<unsigned long>((unsigned long)(clBBPts.LengthY() / fGridLen), 1),
|
||||
std::max<unsigned long>((unsigned long)(clBBPts.LengthZ() / fGridLen), 1));
|
||||
PointsGrid::Rebuild(
|
||||
std::max<unsigned long>((unsigned long)(clBBPts.LengthX() / fGridLen), 1),
|
||||
std::max<unsigned long>((unsigned long)(clBBPts.LengthY() / fGridLen), 1),
|
||||
std::max<unsigned long>((unsigned long)(clBBPts.LengthZ() / fGridLen), 1)
|
||||
);
|
||||
}
|
||||
|
||||
void PointsGrid::Attach(const PointKernel& rclM)
|
||||
@@ -213,9 +212,11 @@ void PointsGrid::InitGrid()
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB,
|
||||
std::vector<unsigned long>& raulElements,
|
||||
bool bDelDoubles) const
|
||||
unsigned long PointsGrid::InSide(
|
||||
const Base::BoundBox3d& rclBB,
|
||||
std::vector<unsigned long>& raulElements,
|
||||
bool bDelDoubles
|
||||
) const
|
||||
{
|
||||
unsigned long ulMinX {};
|
||||
unsigned long ulMinY {};
|
||||
@@ -233,9 +234,8 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB,
|
||||
for (auto i = ulMinX; i <= ulMaxX; i++) {
|
||||
for (auto j = ulMinY; j <= ulMaxY; j++) {
|
||||
for (auto k = ulMinZ; k <= ulMaxZ; k++) {
|
||||
raulElements.insert(raulElements.end(),
|
||||
_aulGrid[i][j][k].begin(),
|
||||
_aulGrid[i][j][k].end());
|
||||
raulElements
|
||||
.insert(raulElements.end(), _aulGrid[i][j][k].begin(), _aulGrid[i][j][k].end());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,18 +243,19 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB,
|
||||
if (bDelDoubles) {
|
||||
// remove duplicate mentions
|
||||
std::sort(raulElements.begin(), raulElements.end());
|
||||
raulElements.erase(std::unique(raulElements.begin(), raulElements.end()),
|
||||
raulElements.end());
|
||||
raulElements.erase(std::unique(raulElements.begin(), raulElements.end()), raulElements.end());
|
||||
}
|
||||
|
||||
return raulElements.size();
|
||||
}
|
||||
|
||||
unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB,
|
||||
std::vector<unsigned long>& raulElements,
|
||||
const Base::Vector3d& rclOrg,
|
||||
double fMaxDist,
|
||||
bool bDelDoubles) const
|
||||
unsigned long PointsGrid::InSide(
|
||||
const Base::BoundBox3d& rclBB,
|
||||
std::vector<unsigned long>& raulElements,
|
||||
const Base::Vector3d& rclOrg,
|
||||
double fMaxDist,
|
||||
bool bDelDoubles
|
||||
) const
|
||||
{
|
||||
unsigned long ulMinX {}, ulMinY {}, ulMinZ {};
|
||||
unsigned long ulMaxX {}, ulMaxY {}, ulMaxZ {};
|
||||
@@ -271,9 +272,11 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB,
|
||||
for (auto j = ulMinY; j <= ulMaxY; j++) {
|
||||
for (auto k = ulMinZ; k <= ulMaxZ; k++) {
|
||||
if (Base::DistanceP2(GetBoundBox(i, j, k).GetCenter(), rclOrg) < fMinDistP2) {
|
||||
raulElements.insert(raulElements.end(),
|
||||
_aulGrid[i][j][k].begin(),
|
||||
_aulGrid[i][j][k].end());
|
||||
raulElements.insert(
|
||||
raulElements.end(),
|
||||
_aulGrid[i][j][k].begin(),
|
||||
_aulGrid[i][j][k].end()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,15 +285,13 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB,
|
||||
if (bDelDoubles) {
|
||||
// remove duplicate mentions
|
||||
std::sort(raulElements.begin(), raulElements.end());
|
||||
raulElements.erase(std::unique(raulElements.begin(), raulElements.end()),
|
||||
raulElements.end());
|
||||
raulElements.erase(std::unique(raulElements.begin(), raulElements.end()), raulElements.end());
|
||||
}
|
||||
|
||||
return raulElements.size();
|
||||
}
|
||||
|
||||
unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB,
|
||||
std::set<unsigned long>& raulElements) const
|
||||
unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB, std::set<unsigned long>& raulElements) const
|
||||
{
|
||||
unsigned long ulMinX {}, ulMinY {}, ulMinZ {};
|
||||
unsigned long ulMaxX {}, ulMaxY {}, ulMaxZ {};
|
||||
@@ -312,33 +313,41 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB,
|
||||
return raulElements.size();
|
||||
}
|
||||
|
||||
void PointsGrid::Position(const Base::Vector3d& rclPoint,
|
||||
unsigned long& rulX,
|
||||
unsigned long& rulY,
|
||||
unsigned long& rulZ) const
|
||||
void PointsGrid::Position(
|
||||
const Base::Vector3d& rclPoint,
|
||||
unsigned long& rulX,
|
||||
unsigned long& rulY,
|
||||
unsigned long& rulZ
|
||||
) const
|
||||
{
|
||||
if (rclPoint.x <= _fMinX) {
|
||||
rulX = 0;
|
||||
}
|
||||
else {
|
||||
rulX = std::min<unsigned long>((unsigned long)((rclPoint.x - _fMinX) / _fGridLenX),
|
||||
_ulCtGridsX - 1);
|
||||
rulX = std::min<unsigned long>(
|
||||
(unsigned long)((rclPoint.x - _fMinX) / _fGridLenX),
|
||||
_ulCtGridsX - 1
|
||||
);
|
||||
}
|
||||
|
||||
if (rclPoint.y <= _fMinY) {
|
||||
rulY = 0;
|
||||
}
|
||||
else {
|
||||
rulY = std::min<unsigned long>((unsigned long)((rclPoint.y - _fMinY) / _fGridLenY),
|
||||
_ulCtGridsY - 1);
|
||||
rulY = std::min<unsigned long>(
|
||||
(unsigned long)((rclPoint.y - _fMinY) / _fGridLenY),
|
||||
_ulCtGridsY - 1
|
||||
);
|
||||
}
|
||||
|
||||
if (rclPoint.z <= _fMinZ) {
|
||||
rulZ = 0;
|
||||
}
|
||||
else {
|
||||
rulZ = std::min<unsigned long>((unsigned long)((rclPoint.z - _fMinZ) / _fGridLenZ),
|
||||
_ulCtGridsZ - 1);
|
||||
rulZ = std::min<unsigned long>(
|
||||
(unsigned long)((rclPoint.z - _fMinZ) / _fGridLenZ),
|
||||
_ulCtGridsZ - 1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,13 +363,11 @@ void PointsGrid::CalculateGridLength(unsigned long ulCtGrid, unsigned long ulMax
|
||||
double fVolElem {};
|
||||
|
||||
if (_ulCtElements > (ulMaxGrids * ulCtGrid)) {
|
||||
fVolElem =
|
||||
(clBBPtsEnlarged.LengthX() * clBBPtsEnlarged.LengthY() * clBBPtsEnlarged.LengthZ())
|
||||
fVolElem = (clBBPtsEnlarged.LengthX() * clBBPtsEnlarged.LengthY() * clBBPtsEnlarged.LengthZ())
|
||||
/ float(ulMaxGrids * ulCtGrid);
|
||||
}
|
||||
else {
|
||||
fVolElem =
|
||||
(clBBPtsEnlarged.LengthX() * clBBPtsEnlarged.LengthY() * clBBPtsEnlarged.LengthZ())
|
||||
fVolElem = (clBBPtsEnlarged.LengthX() * clBBPtsEnlarged.LengthY() * clBBPtsEnlarged.LengthZ())
|
||||
/ float(_ulCtElements);
|
||||
}
|
||||
|
||||
@@ -368,12 +375,9 @@ void PointsGrid::CalculateGridLength(unsigned long ulCtGrid, unsigned long ulMax
|
||||
double fGridLen = float(pow((float)fVol, 1.0F / 3.0F));
|
||||
|
||||
if (fGridLen > 0) {
|
||||
_ulCtGridsX =
|
||||
std::max<unsigned long>((unsigned long)(clBBPtsEnlarged.LengthX() / fGridLen), 1);
|
||||
_ulCtGridsY =
|
||||
std::max<unsigned long>((unsigned long)(clBBPtsEnlarged.LengthY() / fGridLen), 1);
|
||||
_ulCtGridsZ =
|
||||
std::max<unsigned long>((unsigned long)(clBBPtsEnlarged.LengthZ() / fGridLen), 1);
|
||||
_ulCtGridsX = std::max<unsigned long>((unsigned long)(clBBPtsEnlarged.LengthX() / fGridLen), 1);
|
||||
_ulCtGridsY = std::max<unsigned long>((unsigned long)(clBBPtsEnlarged.LengthY() / fGridLen), 1);
|
||||
_ulCtGridsZ = std::max<unsigned long>((unsigned long)(clBBPtsEnlarged.LengthZ() / fGridLen), 1);
|
||||
}
|
||||
else {
|
||||
// Degenerated grid
|
||||
@@ -528,8 +532,7 @@ void PointsGrid::CalculateGridLength(int iCtGridPerAxis)
|
||||
}
|
||||
}
|
||||
|
||||
void PointsGrid::SearchNearestFromPoint(const Base::Vector3d& rclPt,
|
||||
std::set<unsigned long>& raclInd) const
|
||||
void PointsGrid::SearchNearestFromPoint(const Base::Vector3d& rclPt, std::set<unsigned long>& raclInd) const
|
||||
{
|
||||
raclInd.clear();
|
||||
Base::BoundBox3d clBB = GetBoundBox();
|
||||
@@ -627,11 +630,13 @@ void PointsGrid::SearchNearestFromPoint(const Base::Vector3d& rclPt,
|
||||
}
|
||||
}
|
||||
|
||||
void PointsGrid::GetHull(unsigned long ulX,
|
||||
unsigned long ulY,
|
||||
unsigned long ulZ,
|
||||
unsigned long ulDistance,
|
||||
std::set<unsigned long>& raclInd) const
|
||||
void PointsGrid::GetHull(
|
||||
unsigned long ulX,
|
||||
unsigned long ulY,
|
||||
unsigned long ulZ,
|
||||
unsigned long ulDistance,
|
||||
std::set<unsigned long>& raclInd
|
||||
) const
|
||||
{
|
||||
int nX1 = std::max<int>(0, int(ulX) - int(ulDistance));
|
||||
int nY1 = std::max<int>(0, int(ulY) - int(ulDistance));
|
||||
@@ -678,10 +683,12 @@ void PointsGrid::GetHull(unsigned long ulX,
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long PointsGrid::GetElements(unsigned long ulX,
|
||||
unsigned long ulY,
|
||||
unsigned long ulZ,
|
||||
std::set<unsigned long>& raclInd) const
|
||||
unsigned long PointsGrid::GetElements(
|
||||
unsigned long ulX,
|
||||
unsigned long ulY,
|
||||
unsigned long ulZ,
|
||||
std::set<unsigned long>& raclInd
|
||||
) const
|
||||
{
|
||||
const std::set<unsigned long>& rclSet = _aulGrid[ulX][ulY][ulZ];
|
||||
if (!rclSet.empty()) {
|
||||
@@ -760,18 +767,22 @@ void PointsGrid::RebuildGrid()
|
||||
}
|
||||
}
|
||||
|
||||
void PointsGrid::Pos(const Base::Vector3d& rclPoint,
|
||||
unsigned long& rulX,
|
||||
unsigned long& rulY,
|
||||
unsigned long& rulZ) const
|
||||
void PointsGrid::Pos(
|
||||
const Base::Vector3d& rclPoint,
|
||||
unsigned long& rulX,
|
||||
unsigned long& rulY,
|
||||
unsigned long& rulZ
|
||||
) const
|
||||
{
|
||||
rulX = (unsigned long)((rclPoint.x - _fMinX) / _fGridLenX);
|
||||
rulY = (unsigned long)((rclPoint.y - _fMinY) / _fGridLenY);
|
||||
rulZ = (unsigned long)((rclPoint.z - _fMinZ) / _fGridLenZ);
|
||||
}
|
||||
|
||||
unsigned long PointsGrid::FindElements(const Base::Vector3d& rclPoint,
|
||||
std::set<unsigned long>& aulElements) const
|
||||
unsigned long PointsGrid::FindElements(
|
||||
const Base::Vector3d& rclPoint,
|
||||
std::set<unsigned long>& aulElements
|
||||
) const
|
||||
{
|
||||
unsigned long ulX {}, ulY {}, ulZ {};
|
||||
Pos(rclPoint, ulX, ulY, ulZ);
|
||||
@@ -792,19 +803,23 @@ PointsGridIterator::PointsGridIterator(const PointsGrid& rclG)
|
||||
, _clDir(0.0F, 0.0F, 0.0F)
|
||||
{}
|
||||
|
||||
bool PointsGridIterator::InitOnRay(const Base::Vector3d& rclPt,
|
||||
const Base::Vector3d& rclDir,
|
||||
float fMaxSearchArea,
|
||||
std::vector<unsigned long>& raulElements)
|
||||
bool PointsGridIterator::InitOnRay(
|
||||
const Base::Vector3d& rclPt,
|
||||
const Base::Vector3d& rclDir,
|
||||
float fMaxSearchArea,
|
||||
std::vector<unsigned long>& raulElements
|
||||
)
|
||||
{
|
||||
bool ret = InitOnRay(rclPt, rclDir, raulElements);
|
||||
_fMaxSearchArea = fMaxSearchArea;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool PointsGridIterator::InitOnRay(const Base::Vector3d& rclPt,
|
||||
const Base::Vector3d& rclDir,
|
||||
std::vector<unsigned long>& raulElements)
|
||||
bool PointsGridIterator::InitOnRay(
|
||||
const Base::Vector3d& rclPt,
|
||||
const Base::Vector3d& rclDir,
|
||||
std::vector<unsigned long>& raulElements
|
||||
)
|
||||
{
|
||||
// needed in NextOnRay() to avoid an infinite loop
|
||||
_cSearchPositions.clear();
|
||||
@@ -820,17 +835,21 @@ bool PointsGridIterator::InitOnRay(const Base::Vector3d& rclPt,
|
||||
// point lies within global BB
|
||||
if (_rclGrid.GetBoundBox().IsInBox(rclPt)) { // determine the voxel by the starting point
|
||||
_rclGrid.Position(rclPt, _ulX, _ulY, _ulZ);
|
||||
raulElements.insert(raulElements.end(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].end());
|
||||
raulElements.insert(
|
||||
raulElements.end(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].end()
|
||||
);
|
||||
_bValidRay = true;
|
||||
}
|
||||
else { // StartPoint outside
|
||||
Base::Vector3d cP0, cP1;
|
||||
if (_rclGrid.GetBoundBox().IntersectWithLine(rclPt,
|
||||
rclDir,
|
||||
cP0,
|
||||
cP1)) { // determine the next point
|
||||
if (_rclGrid.GetBoundBox().IntersectWithLine(
|
||||
rclPt,
|
||||
rclDir,
|
||||
cP0,
|
||||
cP1
|
||||
)) { // determine the next point
|
||||
if ((cP0 - rclPt).Length() < (cP1 - rclPt).Length()) {
|
||||
_rclGrid.Position(cP0, _ulX, _ulY, _ulZ);
|
||||
}
|
||||
@@ -838,9 +857,11 @@ bool PointsGridIterator::InitOnRay(const Base::Vector3d& rclPt,
|
||||
_rclGrid.Position(cP1, _ulX, _ulY, _ulZ);
|
||||
}
|
||||
|
||||
raulElements.insert(raulElements.end(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].end());
|
||||
raulElements.insert(
|
||||
raulElements.end(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].end()
|
||||
);
|
||||
_bValidRay = true;
|
||||
}
|
||||
}
|
||||
@@ -859,8 +880,8 @@ bool PointsGridIterator::NextOnRay(std::vector<unsigned long>& raulElements)
|
||||
Base::Vector3d clIntersectPoint;
|
||||
|
||||
// Look for the next adjacent BB on the search beam
|
||||
Base::BoundBox3d::SIDE tSide =
|
||||
_rclGrid.GetBoundBox(_ulX, _ulY, _ulZ).GetSideFromRay(_clPt, _clDir, clIntersectPoint);
|
||||
Base::BoundBox3d::SIDE tSide
|
||||
= _rclGrid.GetBoundBox(_ulX, _ulY, _ulZ).GetSideFromRay(_clPt, _clDir, clIntersectPoint);
|
||||
|
||||
// Search area
|
||||
//
|
||||
@@ -896,17 +917,18 @@ bool PointsGridIterator::NextOnRay(std::vector<unsigned long>& raulElements)
|
||||
|
||||
GridElement pos(_ulX, _ulY, _ulZ);
|
||||
if (_cSearchPositions.find(pos) != _cSearchPositions.end()) {
|
||||
_bValidRay =
|
||||
false; // grid element already visited => result from GetSideFromRay invalid
|
||||
_bValidRay = false; // grid element already visited => result from GetSideFromRay invalid
|
||||
}
|
||||
}
|
||||
|
||||
if (_bValidRay && _rclGrid.CheckPos(_ulX, _ulY, _ulZ)) {
|
||||
GridElement pos(_ulX, _ulY, _ulZ);
|
||||
_cSearchPositions.insert(pos);
|
||||
raulElements.insert(raulElements.end(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].end());
|
||||
raulElements.insert(
|
||||
raulElements.end(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].end()
|
||||
);
|
||||
}
|
||||
else {
|
||||
_bValidRay = false; // ray exited
|
||||
|
||||
@@ -80,8 +80,10 @@ public:
|
||||
* grid gets rebuilt automatically. */
|
||||
virtual void Attach(const PointKernel& rclM);
|
||||
/** Rebuilds the grid structure. */
|
||||
virtual void Rebuild(unsigned long ulPerGrid = POINTS_CT_GRID,
|
||||
unsigned long ulMaxGrid = POINTS_MAX_GRIDS);
|
||||
virtual void Rebuild(
|
||||
unsigned long ulPerGrid = POINTS_CT_GRID,
|
||||
unsigned long ulMaxGrid = POINTS_MAX_GRIDS
|
||||
);
|
||||
/** Rebuilds the grid structure. */
|
||||
virtual void Rebuild(int iCtGridPerAxis = POINTS_CT_GRID_PER_AXIS);
|
||||
/** Rebuilds the grid structure. */
|
||||
@@ -90,18 +92,24 @@ public:
|
||||
/** @name Search */
|
||||
//@{
|
||||
/** Searches for elements lying in the intersection area of the grid and the bounding box. */
|
||||
virtual unsigned long InSide(const Base::BoundBox3d& rclBB,
|
||||
std::vector<unsigned long>& raulElements,
|
||||
bool bDelDoubles = true) const;
|
||||
virtual unsigned long InSide(
|
||||
const Base::BoundBox3d& rclBB,
|
||||
std::vector<unsigned long>& raulElements,
|
||||
bool bDelDoubles = true
|
||||
) const;
|
||||
/** Searches for elements lying in the intersection area of the grid and the bounding box. */
|
||||
virtual unsigned long InSide(const Base::BoundBox3d& rclBB,
|
||||
std::set<unsigned long>& raulElementss) const;
|
||||
virtual unsigned long InSide(
|
||||
const Base::BoundBox3d& rclBB,
|
||||
std::set<unsigned long>& raulElementss
|
||||
) const;
|
||||
/** Searches for elements lying in the intersection area of the grid and the bounding box. */
|
||||
virtual unsigned long InSide(const Base::BoundBox3d& rclBB,
|
||||
std::vector<unsigned long>& raulElements,
|
||||
const Base::Vector3d& rclOrg,
|
||||
double fMaxDist,
|
||||
bool bDelDoubles = true) const;
|
||||
virtual unsigned long InSide(
|
||||
const Base::BoundBox3d& rclBB,
|
||||
std::vector<unsigned long>& raulElements,
|
||||
const Base::Vector3d& rclOrg,
|
||||
double fMaxDist,
|
||||
bool bDelDoubles = true
|
||||
) const;
|
||||
/** Searches for the nearest grids that contain elements from a point, the result are grid
|
||||
* indices. */
|
||||
void SearchNearestFromPoint(const Base::Vector3d& rclPt, std::set<unsigned long>& rclInd) const;
|
||||
@@ -125,8 +133,7 @@ public:
|
||||
/** @name Boundings */
|
||||
//@{
|
||||
/** Returns the bounding box of a given grid element. */
|
||||
inline Base::BoundBox3d
|
||||
GetBoundBox(unsigned long ulX, unsigned long ulY, unsigned long ulZ) const;
|
||||
inline Base::BoundBox3d GetBoundBox(unsigned long ulX, unsigned long ulY, unsigned long ulZ) const;
|
||||
/** Returns the bounding box of the whole. */
|
||||
inline Base::BoundBox3d GetBoundBox() const;
|
||||
//@}
|
||||
@@ -136,8 +143,7 @@ public:
|
||||
return _aulGrid[ulX][ulY][ulZ].size();
|
||||
}
|
||||
/** Finds all points that lie in the same grid as the point \a rclPoint. */
|
||||
unsigned long FindElements(const Base::Vector3d& rclPoint,
|
||||
std::set<unsigned long>& aulElements) const;
|
||||
unsigned long FindElements(const Base::Vector3d& rclPoint, std::set<unsigned long>& aulElements) const;
|
||||
/** Validates the grid structure and rebuilds it if needed. */
|
||||
virtual void Validate(const PointKernel& rclM);
|
||||
/** Validates the grid structure and rebuilds it if needed. */
|
||||
@@ -146,15 +152,19 @@ public:
|
||||
virtual bool Verify() const;
|
||||
/** Returns the indices of the grid this point lies in. If the point is outside the grid then
|
||||
* the indices of the nearest grid element are taken.*/
|
||||
virtual void Position(const Base::Vector3d& rclPoint,
|
||||
unsigned long& rulX,
|
||||
unsigned long& rulY,
|
||||
unsigned long& rulZ) const;
|
||||
virtual void Position(
|
||||
const Base::Vector3d& rclPoint,
|
||||
unsigned long& rulX,
|
||||
unsigned long& rulY,
|
||||
unsigned long& rulZ
|
||||
) const;
|
||||
/** Returns the indices of the elements in the given grid. */
|
||||
unsigned long GetElements(unsigned long ulX,
|
||||
unsigned long ulY,
|
||||
unsigned long ulZ,
|
||||
std::set<unsigned long>& raclInd) const;
|
||||
unsigned long GetElements(
|
||||
unsigned long ulX,
|
||||
unsigned long ulY,
|
||||
unsigned long ulZ,
|
||||
std::set<unsigned long>& raclInd
|
||||
) const;
|
||||
|
||||
protected:
|
||||
/** Checks if this is a valid grid position. */
|
||||
@@ -176,15 +186,17 @@ protected:
|
||||
}
|
||||
/** Get the indices of all elements lying in the grids around a given grid with distance \a
|
||||
* ulDistance. */
|
||||
void GetHull(unsigned long ulX,
|
||||
unsigned long ulY,
|
||||
unsigned long ulZ,
|
||||
unsigned long ulDistance,
|
||||
std::set<unsigned long>& raclInd) const;
|
||||
void GetHull(
|
||||
unsigned long ulX,
|
||||
unsigned long ulY,
|
||||
unsigned long ulZ,
|
||||
unsigned long ulDistance,
|
||||
std::set<unsigned long>& raclInd
|
||||
) const;
|
||||
|
||||
private:
|
||||
std::vector<std::vector<std::vector<std::set<unsigned long>>>>
|
||||
_aulGrid; /**< Grid data structure. */
|
||||
std::vector<std::vector<std::vector<std::set<unsigned long>>>> _aulGrid; /**< Grid data
|
||||
structure. */
|
||||
const PointKernel* _pclPoints; /**< The point kernel. */
|
||||
unsigned long _ulCtElements; /**< Number of grid elements for validation issues. */
|
||||
unsigned long _ulCtGridsX; /**< Number of grid elements in z. */
|
||||
@@ -207,10 +219,12 @@ protected:
|
||||
* ulPtIndex the corresponding index in the point kernel. */
|
||||
void AddPoint(const Base::Vector3d& rclPt, unsigned long ulPtIndex, float fEpsilon = 0.0F);
|
||||
/** Returns the grid numbers to the given point \a rclPoint. */
|
||||
void Pos(const Base::Vector3d& rclPoint,
|
||||
unsigned long& rulX,
|
||||
unsigned long& rulY,
|
||||
unsigned long& rulZ) const;
|
||||
void Pos(
|
||||
const Base::Vector3d& rclPoint,
|
||||
unsigned long& rulX,
|
||||
unsigned long& rulY,
|
||||
unsigned long& rulZ
|
||||
) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -230,9 +244,11 @@ public:
|
||||
/** Returns indices of the elements in the current grid. */
|
||||
void GetElements(std::vector<unsigned long>& raulElements) const
|
||||
{
|
||||
raulElements.insert(raulElements.end(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].end());
|
||||
raulElements.insert(
|
||||
raulElements.end(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(),
|
||||
_rclGrid._aulGrid[_ulX][_ulY][_ulZ].end()
|
||||
);
|
||||
}
|
||||
/** @name Iteration */
|
||||
//@{
|
||||
@@ -268,14 +284,18 @@ public:
|
||||
/** @name Tests with rays */
|
||||
//@{
|
||||
/** Searches for facets around the ray. */
|
||||
bool InitOnRay(const Base::Vector3d& rclPt,
|
||||
const Base::Vector3d& rclDir,
|
||||
std::vector<unsigned long>& raulElements);
|
||||
bool InitOnRay(
|
||||
const Base::Vector3d& rclPt,
|
||||
const Base::Vector3d& rclDir,
|
||||
std::vector<unsigned long>& raulElements
|
||||
);
|
||||
/** Searches for facets around the ray. */
|
||||
bool InitOnRay(const Base::Vector3d& rclPt,
|
||||
const Base::Vector3d& rclDir,
|
||||
float fMaxSearchArea,
|
||||
std::vector<unsigned long>& raulElements);
|
||||
bool InitOnRay(
|
||||
const Base::Vector3d& rclPt,
|
||||
const Base::Vector3d& rclDir,
|
||||
float fMaxSearchArea,
|
||||
std::vector<unsigned long>& raulElements
|
||||
);
|
||||
/** Searches for facets around the ray. */
|
||||
bool NextOnRay(std::vector<unsigned long>& raulElements);
|
||||
//@}
|
||||
@@ -328,8 +348,7 @@ private:
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
inline Base::BoundBox3d
|
||||
PointsGrid::GetBoundBox(unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
|
||||
inline Base::BoundBox3d PointsGrid::GetBoundBox(unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
|
||||
{
|
||||
double fX = _fMinX + (double(ulX) * _fGridLenX);
|
||||
double fY = _fMinY + (double(ulY) * _fGridLenY);
|
||||
@@ -340,12 +359,14 @@ PointsGrid::GetBoundBox(unsigned long ulX, unsigned long ulY, unsigned long ulZ)
|
||||
|
||||
inline Base::BoundBox3d PointsGrid::GetBoundBox() const
|
||||
{
|
||||
return Base::BoundBox3d(_fMinX,
|
||||
_fMinY,
|
||||
_fMinZ,
|
||||
_fMinX + (_fGridLenX * double(_ulCtGridsX)),
|
||||
_fMinY + (_fGridLenY * double(_ulCtGridsY)),
|
||||
_fMinZ + (_fGridLenZ * double(_ulCtGridsZ)));
|
||||
return Base::BoundBox3d(
|
||||
_fMinX,
|
||||
_fMinY,
|
||||
_fMinZ,
|
||||
_fMinX + (_fGridLenX * double(_ulCtGridsX)),
|
||||
_fMinY + (_fGridLenY * double(_ulCtGridsY)),
|
||||
_fMinZ + (_fGridLenZ * double(_ulCtGridsZ))
|
||||
);
|
||||
}
|
||||
|
||||
inline bool PointsGrid::CheckPos(unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
|
||||
|
||||
@@ -179,10 +179,12 @@ PyObject* PointsPy::addPoints(PyObject* args)
|
||||
}
|
||||
}
|
||||
catch (const Py::Exception&) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"either expect\n"
|
||||
"-- [Vector,...] \n"
|
||||
"-- [(x,y,z),...]");
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError,
|
||||
"either expect\n"
|
||||
"-- [Vector,...] \n"
|
||||
"-- [(x,y,z),...]"
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "Properties.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <ppl.h>
|
||||
# include <ppl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -384,11 +384,9 @@ void PropertyNormalList::transformGeometry(const Base::Matrix4D& mat)
|
||||
|
||||
// Rotate the normal vectors
|
||||
#ifdef _MSC_VER
|
||||
Concurrency::parallel_for_each(_lValueList.begin(),
|
||||
_lValueList.end(),
|
||||
[rot](Base::Vector3f& value) {
|
||||
value = rot * value;
|
||||
});
|
||||
Concurrency::parallel_for_each(_lValueList.begin(), _lValueList.end(), [rot](Base::Vector3f& value) {
|
||||
value = rot * value;
|
||||
});
|
||||
#else
|
||||
QtConcurrent::blockingMap(_lValueList, [rot](Base::Vector3f& value) {
|
||||
rot.multVec(value, value);
|
||||
@@ -415,8 +413,7 @@ void PropertyNormalList::removeIndices(const std::vector<unsigned long>& uIndice
|
||||
remainValue.reserve(rValueList.size() - uSortedInds.size());
|
||||
|
||||
std::vector<unsigned long>::iterator pos = uSortedInds.begin();
|
||||
for (std::vector<Base::Vector3f>::const_iterator it = rValueList.begin();
|
||||
it != rValueList.end();
|
||||
for (std::vector<Base::Vector3f>::const_iterator it = rValueList.begin(); it != rValueList.end();
|
||||
++it) {
|
||||
unsigned long index = it - rValueList.begin();
|
||||
if (pos == uSortedInds.end()) {
|
||||
@@ -545,8 +542,7 @@ void PropertyCurvatureList::removeIndices(const std::vector<unsigned long>& uInd
|
||||
remainValue.reserve(_lValueList.size() - uSortedInds.size());
|
||||
|
||||
std::vector<unsigned long>::iterator pos = uSortedInds.begin();
|
||||
for (std::vector<CurvatureInfo>::const_iterator it = _lValueList.begin();
|
||||
it != _lValueList.end();
|
||||
for (std::vector<CurvatureInfo>::const_iterator it = _lValueList.begin(); it != _lValueList.end();
|
||||
++it) {
|
||||
unsigned long index = it - _lValueList.begin();
|
||||
if (pos == uSortedInds.end()) {
|
||||
|
||||
@@ -31,9 +31,11 @@ namespace Points
|
||||
{
|
||||
|
||||
template<typename PropertyT>
|
||||
bool copyProperty(App::DocumentObject* target,
|
||||
std::vector<App::DocumentObject*> source,
|
||||
const char* propertyName)
|
||||
bool copyProperty(
|
||||
App::DocumentObject* target,
|
||||
std::vector<App::DocumentObject*> source,
|
||||
const char* propertyName
|
||||
)
|
||||
{
|
||||
// check for properties
|
||||
if (std::all_of(std::begin(source), std::end(source), [=](auto obj) {
|
||||
@@ -41,7 +43,8 @@ bool copyProperty(App::DocumentObject* target,
|
||||
})) {
|
||||
|
||||
auto target_prop = freecad_cast<PropertyT*>(
|
||||
target->addDynamicProperty(PropertyT::getClassTypeId().getName(), propertyName));
|
||||
target->addDynamicProperty(PropertyT::getClassTypeId().getName(), propertyName)
|
||||
);
|
||||
if (target_prop) {
|
||||
auto values = target_prop->getValues();
|
||||
for (auto it : source) {
|
||||
|
||||
@@ -95,8 +95,10 @@ PyMOD_INIT_FUNC(PointsGui)
|
||||
PointsGui::ViewProviderPython ::init();
|
||||
PointsGui::Workbench ::init();
|
||||
// clang-format on
|
||||
Gui::ViewProviderBuilder::add(Points::PropertyPointKernel::getClassTypeId(),
|
||||
PointsGui::ViewProviderPoints::getClassTypeId());
|
||||
Gui::ViewProviderBuilder::add(
|
||||
Points::PropertyPointKernel::getClassTypeId(),
|
||||
PointsGui::ViewProviderPoints::getClassTypeId()
|
||||
);
|
||||
|
||||
// add resources and reloads the translators
|
||||
loadPointsResource();
|
||||
|
||||
@@ -82,7 +82,8 @@ void CmdPointsImport::activated(int iMsg)
|
||||
QString(),
|
||||
QString(),
|
||||
QStringLiteral("%1 (*.asc *.pcd *.ply *.e57);;%2 (*.*)")
|
||||
.arg(QObject::tr("Point formats"), QObject::tr("All Files")));
|
||||
.arg(QObject::tr("Point formats"), QObject::tr("All Files"))
|
||||
);
|
||||
if (fn.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -92,10 +93,7 @@ void CmdPointsImport::activated(int iMsg)
|
||||
App::Document* doc = getActiveDocument();
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Import points"));
|
||||
addModule(Command::App, "Points");
|
||||
doCommand(Command::Doc,
|
||||
"Points.insert(\"%s\", \"%s\")",
|
||||
fn.toUtf8().data(),
|
||||
doc->getName());
|
||||
doCommand(Command::Doc, "Points.insert(\"%s\", \"%s\")", fn.toUtf8().data(), doc->getName());
|
||||
commitCommand();
|
||||
|
||||
updateActive();
|
||||
@@ -114,9 +112,12 @@ void CmdPointsImport::activated(int iMsg)
|
||||
QMessageBox msgBox(Gui::getMainWindow());
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
msgBox.setWindowTitle(QObject::tr("Points not at Origin"));
|
||||
msgBox.setText(QObject::tr(
|
||||
"The bounding box of the imported points does not contain the origin. "
|
||||
"Translate it to the origin?"));
|
||||
msgBox.setText(
|
||||
QObject::tr(
|
||||
"The bounding box of the imported points does not contain the origin. "
|
||||
"Translate it to the origin?"
|
||||
)
|
||||
);
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||
auto ret = msgBox.exec();
|
||||
@@ -160,25 +161,29 @@ void CmdPointsExport::activated(int iMsg)
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
addModule(Command::App, "Points");
|
||||
std::vector<App::DocumentObject*> points =
|
||||
getSelection().getObjectsOfType(Points::Feature::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> points = getSelection().getObjectsOfType(
|
||||
Points::Feature::getClassTypeId()
|
||||
);
|
||||
for (auto point : points) {
|
||||
QString fn = Gui::FileDialog::getSaveFileName(
|
||||
Gui::getMainWindow(),
|
||||
QString(),
|
||||
QString(),
|
||||
QStringLiteral("%1 (*.asc *.pcd *.ply);;%2 (*.*)")
|
||||
.arg(QObject::tr("Point formats"), QObject::tr("All Files")));
|
||||
.arg(QObject::tr("Point formats"), QObject::tr("All Files"))
|
||||
);
|
||||
if (fn.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!fn.isEmpty()) {
|
||||
fn = Base::Tools::escapeEncodeFilename(fn);
|
||||
doCommand(Command::Doc,
|
||||
"Points.export([App.ActiveDocument.%s], \"%s\")",
|
||||
point->getNameInDocument(),
|
||||
fn.toUtf8().data());
|
||||
doCommand(
|
||||
Command::Doc,
|
||||
"Points.export([App.ActiveDocument.%s], \"%s\")",
|
||||
point->getNameInDocument(),
|
||||
fn.toUtf8().data()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,19 +215,21 @@ void CmdPointsConvert::activated(int iMsg)
|
||||
int decimals = Base::UnitsApi::getDecimals();
|
||||
double tolerance_from_decimals = pow(10., -decimals);
|
||||
|
||||
double minimal_tolerance =
|
||||
tolerance_from_decimals < STD_OCC_TOLERANCE ? STD_OCC_TOLERANCE : tolerance_from_decimals;
|
||||
double minimal_tolerance = tolerance_from_decimals < STD_OCC_TOLERANCE ? STD_OCC_TOLERANCE
|
||||
: tolerance_from_decimals;
|
||||
|
||||
bool ok;
|
||||
double tol = QInputDialog::getDouble(Gui::getMainWindow(),
|
||||
QObject::tr("Distance"),
|
||||
QObject::tr("Enter maximum distance:"),
|
||||
0.1,
|
||||
minimal_tolerance,
|
||||
10.0,
|
||||
decimals,
|
||||
&ok,
|
||||
Qt::MSWindowsFixedSizeDialogHint);
|
||||
double tol = QInputDialog::getDouble(
|
||||
Gui::getMainWindow(),
|
||||
QObject::tr("Distance"),
|
||||
QObject::tr("Enter maximum distance:"),
|
||||
0.1,
|
||||
minimal_tolerance,
|
||||
10.0,
|
||||
decimals,
|
||||
&ok,
|
||||
Qt::MSWindowsFixedSizeDialogHint
|
||||
);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
@@ -247,8 +254,7 @@ void CmdPointsConvert::activated(int iMsg)
|
||||
}
|
||||
|
||||
Py::Module commands(module, true);
|
||||
commands.callMemberFunction("make_points_from_geometry",
|
||||
Py::TupleN(list, Py::Float(tol)));
|
||||
commands.callMemberFunction("make_points_from_geometry", Py::TupleN(list, Py::Float(tol)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -294,10 +300,10 @@ void CmdPointsPolyCut::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
std::vector<App::DocumentObject*> docObj =
|
||||
Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
|
||||
for (std::vector<App::DocumentObject*>::iterator it = docObj.begin(); it != docObj.end();
|
||||
++it) {
|
||||
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(
|
||||
Points::Feature::getClassTypeId()
|
||||
);
|
||||
for (std::vector<App::DocumentObject*>::iterator it = docObj.begin(); it != docObj.end(); ++it) {
|
||||
if (it == docObj.begin()) {
|
||||
Gui::Document* doc = getActiveGuiDocument();
|
||||
Gui::MDIView* view = doc->getActiveView();
|
||||
@@ -305,8 +311,10 @@ void CmdPointsPolyCut::activated(int iMsg)
|
||||
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
|
||||
viewer->setEditing(true);
|
||||
viewer->startSelection(Gui::View3DInventorViewer::Lasso);
|
||||
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
|
||||
PointsGui::ViewProviderPoints::clipPointsCallback);
|
||||
viewer->addEventCallback(
|
||||
SoMouseButtonEvent::getClassTypeId(),
|
||||
PointsGui::ViewProviderPoints::clipPointsCallback
|
||||
);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
@@ -347,8 +355,9 @@ void CmdPointsMerge::activated(int iMsg)
|
||||
Points::Feature* pts = doc->addObject<Points::Feature>("Merged Points");
|
||||
Points::PointKernel* kernel = pts->Points.startEditing();
|
||||
|
||||
std::vector<App::DocumentObject*> docObj =
|
||||
Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(
|
||||
Points::Feature::getClassTypeId()
|
||||
);
|
||||
for (auto it : docObj) {
|
||||
const Points::PointKernel& k = static_cast<Points::Feature*>(it)->Points.getValue();
|
||||
std::size_t numPts = kernel->size();
|
||||
@@ -373,7 +382,8 @@ void CmdPointsMerge::activated(int iMsg)
|
||||
}
|
||||
|
||||
if (auto vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(pts))) {
|
||||
Gui::Application::Instance->getViewProvider(pts)
|
||||
)) {
|
||||
vp->DisplayMode.setValue(displayMode.c_str());
|
||||
}
|
||||
|
||||
@@ -407,8 +417,9 @@ void CmdPointsStructure::activated(int iMsg)
|
||||
App::Document* doc = App::GetApplication().getActiveDocument();
|
||||
doc->openTransaction("Structure point cloud");
|
||||
|
||||
std::vector<App::DocumentObject*> docObj =
|
||||
Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(
|
||||
Points::Feature::getClassTypeId()
|
||||
);
|
||||
for (auto it : docObj) {
|
||||
std::string name = it->Label.getValue();
|
||||
name += " (Structured)";
|
||||
@@ -458,8 +469,7 @@ void CmdPointsStructure::activated(int iMsg)
|
||||
// Pre-fill the vector with <nan, nan, nan> points and afterwards replace them
|
||||
// with valid point coordinates
|
||||
double nan = std::numeric_limits<double>::quiet_NaN();
|
||||
std::vector<Base::Vector3d> sortedPoints(width_l * height_l,
|
||||
Base::Vector3d(nan, nan, nan));
|
||||
std::vector<Base::Vector3d> sortedPoints(width_l * height_l, Base::Vector3d(nan, nan, nan));
|
||||
|
||||
for (std::size_t i = 0; i < k.size(); ++i) {
|
||||
Base::Vector3d pnt = k.getPoint(i);
|
||||
|
||||
@@ -42,9 +42,11 @@ class DlgPointsReadImp: public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgPointsReadImp(const char* FileName,
|
||||
QWidget* parent = nullptr,
|
||||
Qt::WindowFlags fl = Qt::WindowFlags());
|
||||
explicit DlgPointsReadImp(
|
||||
const char* FileName,
|
||||
QWidget* parent = nullptr,
|
||||
Qt::WindowFlags fl = Qt::WindowFlags()
|
||||
);
|
||||
~DlgPointsReadImp() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -102,8 +102,8 @@ void ViewProviderPoints::onChanged(const App::Property* prop)
|
||||
pcPointStyle->pointSize = PointSize.getValue();
|
||||
}
|
||||
else if (prop == &SelectionStyle) {
|
||||
pcHighlight->style =
|
||||
SelectionStyle.getValue() ? Gui::SoFCSelection::BOX : Gui::SoFCSelection::EMISSIVE;
|
||||
pcHighlight->style = SelectionStyle.getValue() ? Gui::SoFCSelection::BOX
|
||||
: Gui::SoFCSelection::EMISSIVE;
|
||||
}
|
||||
else {
|
||||
ViewProviderGeometryObject::onChanged(prop);
|
||||
@@ -172,7 +172,8 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName)
|
||||
"ViewProviderPoints::setDisplayMode",
|
||||
"The number of points (%d) doesn't match with the number of colors (%d).",
|
||||
numPoints,
|
||||
colors->getSize());
|
||||
colors->getSize()
|
||||
);
|
||||
#endif
|
||||
// fallback
|
||||
setDisplayMaskMode("Point");
|
||||
@@ -191,15 +192,17 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName)
|
||||
for (const auto& it : Map) {
|
||||
Base::Type type = it.second->getTypeId();
|
||||
if (type == Points::PropertyGreyValueList::getClassTypeId()) {
|
||||
Points::PropertyGreyValueList* greyValues =
|
||||
static_cast<Points::PropertyGreyValueList*>(it.second);
|
||||
Points::PropertyGreyValueList* greyValues
|
||||
= static_cast<Points::PropertyGreyValueList*>(it.second);
|
||||
if (numPoints != greyValues->getSize()) {
|
||||
#ifdef FC_DEBUG
|
||||
SoDebugError::postWarning("ViewProviderPoints::setDisplayMode",
|
||||
"The number of points (%d) doesn't match with the "
|
||||
"number of grey values (%d).",
|
||||
numPoints,
|
||||
greyValues->getSize());
|
||||
SoDebugError::postWarning(
|
||||
"ViewProviderPoints::setDisplayMode",
|
||||
"The number of points (%d) doesn't match with the "
|
||||
"number of grey values (%d).",
|
||||
numPoints,
|
||||
greyValues->getSize()
|
||||
);
|
||||
#endif
|
||||
// Intensity mode is not possible then set the default () mode instead.
|
||||
setDisplayMaskMode("Point");
|
||||
@@ -218,15 +221,17 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName)
|
||||
for (const auto& it : Map) {
|
||||
Base::Type type = it.second->getTypeId();
|
||||
if (type == Points::PropertyNormalList::getClassTypeId()) {
|
||||
Points::PropertyNormalList* normals =
|
||||
static_cast<Points::PropertyNormalList*>(it.second);
|
||||
Points::PropertyNormalList* normals = static_cast<Points::PropertyNormalList*>(
|
||||
it.second
|
||||
);
|
||||
if (numPoints != normals->getSize()) {
|
||||
#ifdef FC_DEBUG
|
||||
SoDebugError::postWarning(
|
||||
"ViewProviderPoints::setDisplayMode",
|
||||
"The number of points (%d) doesn't match with the number of normals (%d).",
|
||||
numPoints,
|
||||
normals->getSize());
|
||||
normals->getSize()
|
||||
);
|
||||
#endif
|
||||
// fallback
|
||||
setDisplayMaskMode("Point");
|
||||
@@ -265,8 +270,7 @@ std::vector<std::string> ViewProviderPoints::getDisplayModes() const
|
||||
std::map<std::string, App::Property*> Map;
|
||||
pcObject->getPropertyMap(Map);
|
||||
|
||||
for (std::map<std::string, App::Property*>::iterator it = Map.begin(); it != Map.end();
|
||||
++it) {
|
||||
for (std::map<std::string, App::Property*>::iterator it = Map.begin(); it != Map.end(); ++it) {
|
||||
Base::Type type = it->second->getTypeId();
|
||||
if (type == Points::PropertyNormalList::getClassTypeId()) {
|
||||
StrList.push_back("Shaded");
|
||||
@@ -348,8 +352,9 @@ void ViewProviderPoints::clipPointsCallback(void*, SoEventCallback* n)
|
||||
clPoly.push_back(clPoly.front());
|
||||
}
|
||||
|
||||
std::vector<Gui::ViewProvider*> views =
|
||||
view->getViewProvidersOfType(ViewProviderPoints::getClassTypeId());
|
||||
std::vector<Gui::ViewProvider*> views = view->getViewProvidersOfType(
|
||||
ViewProviderPoints::getClassTypeId()
|
||||
);
|
||||
for (auto it : views) {
|
||||
ViewProviderPoints* that = static_cast<ViewProviderPoints*>(it);
|
||||
if (that->getEditingMode() > -1) {
|
||||
@@ -443,8 +448,7 @@ void ViewProviderScattered::updateData(const App::Property* prop)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked,
|
||||
Gui::View3DInventorViewer& Viewer)
|
||||
void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer& Viewer)
|
||||
{
|
||||
// create the polygon from the picked points
|
||||
Base::Polygon2d cPoly;
|
||||
@@ -464,8 +468,7 @@ void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked,
|
||||
removeIndices.reserve(points.size());
|
||||
|
||||
unsigned long index = 0;
|
||||
for (Points::PointKernel::const_iterator jt = points.begin(); jt != points.end();
|
||||
++jt, ++index) {
|
||||
for (Points::PointKernel::const_iterator jt = points.begin(); jt != points.end(); ++jt, ++index) {
|
||||
SbVec3f pt(jt->x, jt->y, jt->z);
|
||||
|
||||
// project from 3d to 2d
|
||||
@@ -481,7 +484,8 @@ void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked,
|
||||
|
||||
// Remove the points from the cloud and open a transaction object for the undo/redo stuff
|
||||
Gui::Application::Instance->activeDocument()->openCommand(
|
||||
QT_TRANSLATE_NOOP("Command", "Cut points"));
|
||||
QT_TRANSLATE_NOOP("Command", "Cut points")
|
||||
);
|
||||
|
||||
// sets the points outside the polygon to update the Inventor node
|
||||
fea->Points.removeIndices(removeIndices);
|
||||
@@ -499,8 +503,8 @@ void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked,
|
||||
}
|
||||
else if (type == App::PropertyColorList::getClassTypeId()) {
|
||||
// static_cast<App::PropertyColorList*>(it->second)->removeIndices(removeIndices);
|
||||
const std::vector<Base::Color>& colors =
|
||||
static_cast<App::PropertyColorList*>(it.second)->getValues();
|
||||
const std::vector<Base::Color>& colors
|
||||
= static_cast<App::PropertyColorList*>(it.second)->getValues();
|
||||
|
||||
if (removeIndices.size() > colors.size()) {
|
||||
break;
|
||||
@@ -606,8 +610,7 @@ void ViewProviderStructured::updateData(const App::Property* prop)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked,
|
||||
Gui::View3DInventorViewer& Viewer)
|
||||
void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer& Viewer)
|
||||
{
|
||||
// create the polygon from the picked points
|
||||
Base::Polygon2d cPoly;
|
||||
@@ -649,7 +652,8 @@ void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked,
|
||||
if (invalidatePoints) {
|
||||
// Remove the points from the cloud and open a transaction object for the undo/redo stuff
|
||||
Gui::Application::Instance->activeDocument()->openCommand(
|
||||
QT_TRANSLATE_NOOP("Command", "Cut points"));
|
||||
QT_TRANSLATE_NOOP("Command", "Cut points")
|
||||
);
|
||||
|
||||
// sets the points outside the polygon to update the Inventor node
|
||||
fea->Points.setValue(newKernel);
|
||||
@@ -674,8 +678,7 @@ template class PointsGuiExport ViewProviderFeaturePythonT<PointsGui::ViewProvide
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
void ViewProviderPointsBuilder::buildNodes(const App::Property* prop,
|
||||
std::vector<SoNode*>& nodes) const
|
||||
void ViewProviderPointsBuilder::buildNodes(const App::Property* prop, std::vector<SoNode*>& nodes) const
|
||||
{
|
||||
SoCoordinate3* pcPointsCoord = nullptr;
|
||||
SoPointSet* pcPoints = nullptr;
|
||||
@@ -700,12 +703,15 @@ void ViewProviderPointsBuilder::buildNodes(const App::Property* prop,
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPointsBuilder::createPoints(const App::Property* prop,
|
||||
SoCoordinate3* coords,
|
||||
SoPointSet* points) const
|
||||
void ViewProviderPointsBuilder::createPoints(
|
||||
const App::Property* prop,
|
||||
SoCoordinate3* coords,
|
||||
SoPointSet* points
|
||||
) const
|
||||
{
|
||||
const Points::PropertyPointKernel* prop_points =
|
||||
static_cast<const Points::PropertyPointKernel*>(prop);
|
||||
const Points::PropertyPointKernel* prop_points = static_cast<const Points::PropertyPointKernel*>(
|
||||
prop
|
||||
);
|
||||
const Points::PointKernel& cPts = prop_points->getValue();
|
||||
|
||||
coords->point.setNum(cPts.size());
|
||||
@@ -724,12 +730,15 @@ void ViewProviderPointsBuilder::createPoints(const App::Property* prop,
|
||||
coords->point.finishEditing();
|
||||
}
|
||||
|
||||
void ViewProviderPointsBuilder::createPoints(const App::Property* prop,
|
||||
SoCoordinate3* coords,
|
||||
SoIndexedPointSet* points) const
|
||||
void ViewProviderPointsBuilder::createPoints(
|
||||
const App::Property* prop,
|
||||
SoCoordinate3* coords,
|
||||
SoIndexedPointSet* points
|
||||
) const
|
||||
{
|
||||
const Points::PropertyPointKernel* prop_points =
|
||||
static_cast<const Points::PropertyPointKernel*>(prop);
|
||||
const Points::PropertyPointKernel* prop_points = static_cast<const Points::PropertyPointKernel*>(
|
||||
prop
|
||||
);
|
||||
const Points::PointKernel& cPts = prop_points->getValue();
|
||||
|
||||
coords->point.setNum(cPts.size());
|
||||
@@ -745,8 +754,7 @@ void ViewProviderPointsBuilder::createPoints(const App::Property* prop,
|
||||
++it, idx++) {
|
||||
vec[idx].setValue(it->x, it->y, it->z);
|
||||
// valid point?
|
||||
if (!(boost::math::isnan(it->x) || boost::math::isnan(it->y)
|
||||
|| boost::math::isnan(it->z))) {
|
||||
if (!(boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z))) {
|
||||
indices.push_back(idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,25 +25,25 @@
|
||||
#include <FCGlobal.h>
|
||||
|
||||
#ifndef POINTS_GLOBAL_H
|
||||
#define POINTS_GLOBAL_H
|
||||
# define POINTS_GLOBAL_H
|
||||
|
||||
|
||||
// Points
|
||||
#ifndef PointsExport
|
||||
#ifdef Points_EXPORTS
|
||||
#define PointsExport FREECAD_DECL_EXPORT
|
||||
#else
|
||||
#define PointsExport FREECAD_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
# ifndef PointsExport
|
||||
# ifdef Points_EXPORTS
|
||||
# define PointsExport FREECAD_DECL_EXPORT
|
||||
# else
|
||||
# define PointsExport FREECAD_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
|
||||
// PointsGui
|
||||
#ifndef PointsGuiExport
|
||||
#ifdef PointsGui_EXPORTS
|
||||
#define PointsGuiExport FREECAD_DECL_EXPORT
|
||||
#else
|
||||
#define PointsGuiExport FREECAD_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
# ifndef PointsGuiExport
|
||||
# ifdef PointsGui_EXPORTS
|
||||
# define PointsGuiExport FREECAD_DECL_EXPORT
|
||||
# else
|
||||
# define PointsGuiExport FREECAD_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif // POINTS_GLOBAL_H
|
||||
|
||||
Reference in New Issue
Block a user