24 static_assert(std::is_base_of<GenericIndexedCloudPersist, T>::value,
25 "T must be a descendant of GenericIndexedCloudPersist");
38 inline unsigned size()
const override {
39 return static_cast<unsigned>(
m_points.size());
46 if (!currentOutScalarFieldArray) {
52 for (
unsigned i = 0; i < n; ++i) {
53 action(
m_points[i], (*currentOutScalarFieldArray)[i]);
80 if (!currentInScalarField) {
98 assert(currentInScalarField);
112 if (!currentInScalarFieldArray) {
116 std::size_t sfValuesCount = currentInScalarFieldArray->size();
117 return (sfValuesCount != 0 && sfValuesCount >=
m_points.size());
147 return point(
static_cast<unsigned>(index));
154 inline void getPoint(
unsigned index,
double P[3])
const override {
155 P[0] =
static_cast<double>(
point(index)->
x);
156 P[1] =
static_cast<double>(
point(index)->
y);
157 P[2] =
static_cast<double>(
point(index)->
z);
176 std::size_t oldCount =
m_points.size();
181 }
catch (
const std::bad_alloc&) {
190 for (std::size_t j = 0; j < i; ++j) {
217 }
catch (
const std::bad_alloc&) {
227 return (
m_points.capacity() >= newCapacity);
248 if (P.
x != P.
x || P.
y != P.
y || P.
z != P.
z) {
260 if (index <
size()) {
262 if (P.
x != P.
x || P.
y != P.
y || P.
z != P.
z) {
273 if (index <
size()) {
274 bool is_nan = (std::isnan(
point(0)) || std::isnan(
point(1)) ||
275 std::isnan(
point(2)));
276 bool is_infinite = (std::isinf(
point(0)) || std::isinf(
point(1)) ||
277 std::isinf(
point(2)));
280 if (!is_nan && !is_infinite) {
329 for (
size_t i = 0; i <
points.size(); ++i) {
355 return (index >= 0 && index <
static_cast<int>(
m_scalarFields.size())
366 return (index >= 0 && index <
static_cast<int>(
m_scalarFields.size())
377 for (std::size_t i = 0; i < sfCount; ++i) {
380 return static_cast<int>(i);
466 }
catch (
const std::bad_alloc&)
501 if (index < 0 || index >= sfCount)
return;
511 int lastIndex = sfCount - 1;
512 if (index < lastIndex)
541 return static_cast<unsigned>(
m_points.capacity());
546 virtual void swapPoints(
unsigned firstIndex,
unsigned secondIndex) {
547 if (firstIndex == secondIndex || firstIndex >=
m_points.size() ||
565 assert(index <
size());
575 assert(index <
size());
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
virtual void release()
Decrease counter and deletes object when 0.
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
static std::vector< Eigen::Matrix< double, 3, 1 > > fromArrayContainer(const std::vector< Vector3Tpl< PointCoordinateType >> &container)
const Vector3Tpl< T > & maxCorner() const
Returns max corner (const)
void setValidity(bool state)
Sets bonding box validity.
void clear()
Resets the bounding box.
const Vector3Tpl< T > & minCorner() const
Returns min corner (const)
bool isValid() const
Returns whether bounding box is valid or not.
void add(const Vector3Tpl< T > &P)
'Enlarges' the bounding box with a point
std::function< void(const CCVector3 &, ScalarType &)> genericPointAction
Generic function applied to a point (used by foreach)
void setEigenPoints(const std::vector< Eigen::Vector3d > &points)
void addPoint(double x, double y, double z)
std::vector< ScalarField * > m_scalarFields
Associated scalar fields.
std::vector< CCVector3 > m_points
3D Points database
void addEigenPoint(const Eigen::Vector3d &point)
ScalarField * getCurrentOutScalarField() const
Returns the scalar field currently associated to the cloud output.
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
const CCVector3 * getNextPoint() override
void reset()
Clears the cloud database.
virtual void swapPoints(unsigned firstIndex, unsigned secondIndex)
Swaps two points (and their associated scalar values!)
void forEach(GenericCloud::genericPointAction action) override
virtual void deleteScalarField(int index)
Deletes a specific scalar field.
virtual void invalidateBoundingBox()
Invalidates bounding box.
int getCurrentInScalarFieldIndex()
Returns current INPUT scalar field index (or -1 if none)
void setCurrentOutScalarField(int index)
Sets the OUTPUT scalar field.
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
unsigned getNumberOfScalarFields() const
Returns the number of associated (and active) scalar fields.
std::vector< CCVector3 > & getPoints()
CCVector3 * getPointPtr(size_t index)
void setPointScalarValue(unsigned pointIndex, ScalarType value) override
CCVector3 * point(unsigned index)
Returns non const access to a given point.
void addPoint(double xyz[3])
virtual bool reserve(unsigned newCapacity)
Reserves memory for the point database.
void addPoints(const std::vector< Eigen::Vector3d > &points)
virtual int addScalarField(const char *uniqueName)
Creates a new scalar field and registers it.
BoundingBox m_bbox
Bounding-box.
bool isScalarFieldEnabled() const override
void setCurrentScalarField(int index)
Sets both the INPUT & OUTPUT scalar field.
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
const CCVector3 * getPointPersistentPtr(unsigned index) override
int getCurrentOutScalarFieldIndex()
Returns current OUTPUT scalar field index (or -1 if none)
void getBoundingBox(CCVector3 &bbMin, CCVector3 &bbMax) override
unsigned size() const override
bool renameScalarField(int index, const char *newName)
Renames a specific scalar field.
virtual void deleteAllScalarFields()
Deletes all scalar fields associated to this cloud.
const char * getScalarFieldName(int index) const
Returns the name of a specific scalar field.
const std::vector< CCVector3 > & getPoints() const
ScalarType getPointScalarValue(unsigned pointIndex) const override
void setEigenPoint(size_t index, const Eigen::Vector3d &point)
void getPoint(unsigned index, CCVector3 &P) const override
void getPoint(unsigned index, double P[3]) const override
int m_currentInScalarFieldIndex
Index of current scalar field used for input.
std::vector< Eigen::Vector3d > getEigenPoints() const
virtual bool resize(unsigned newCount)
Resizes the point database.
void setCurrentInScalarField(int index)
Sets the INPUT scalar field.
const CCVector3 * point(unsigned index) const
Returns const access to a given point.
PointCloudTpl()
Default constructor.
unsigned capacity() const
Returns cloud capacity (i.e. reserved size)
Eigen::Vector3d getEigenPoint(size_t index) const
void setPoint(size_t index, const CCVector3 &P)
int m_currentOutScalarFieldIndex
Index of current scalar field used for output.
void placeIteratorAtBeginning() override
unsigned m_currentPointIndex
'Iterator' on the points db
const CCVector3 * getPoint(unsigned index) const override
const CCVector3 * getPointPersistentPtr(unsigned index) const
void addPoints(const std::vector< CCVector3 > &points)
bool enableScalarField() override
ScalarField * getCurrentInScalarField() const
Returns the scalar field currently associated to the cloud input.
virtual ~PointCloudTpl()
Default destructor.
A simple scalar field (to be associated to a point cloud)
void setName(const char *name)
Sets scalar field name.
bool resizeSafe(std::size_t count, bool initNewElements=false, ScalarType valueForNewElements=0)
Resizes memory (no exception thrown)
Generic file read and write utility for python interface.
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.