33 for (
unsigned n = 0; n < mesh->
size(); ++n) {
63 for (
unsigned n = 0; n < mesh->
size(); ++n) {
76 double signedVol = (-
static_cast<double>(C.
x * B.
y * A.
z) +
77 static_cast<double>(B.
x * C.
y * A.
z) +
78 static_cast<double>(C.
x * A.
y * B.
z) -
79 static_cast<double>(A.
x * C.
y * B.
z) -
80 static_cast<double>(B.
x * A.
y * C.
z) +
81 static_cast<double>(A.
x * B.
y * C.
z)) /
93 return ((
static_cast<unsigned long long>(i2) << 32) |
94 static_cast<unsigned long long>(i1));
100 i1 =
static_cast<unsigned>(key & 0x00000000FFFFFFFF);
101 i2 =
static_cast<unsigned>((key >> 32) & 0x00000000FFFFFFFF);
108 if (!mesh)
return false;
113 for (
unsigned n = 0; n < mesh->
size(); ++n) {
117 for (
unsigned j = 0; j < 3; ++j) {
118 unsigned i1 = tri->
i[j];
119 unsigned i2 = tri->
i[(j + 1) % 3];
125 }
catch (
const std::bad_alloc&) {
137 if (!mesh)
return false;
144 stats.
edgesCount =
static_cast<unsigned>(edgeCounters.size());
145 for (std::map<unsigned long long, unsigned>::const_iterator edgeIt =
146 edgeCounters.begin();
147 edgeIt != edgeCounters.end(); ++edgeIt) {
148 assert(edgeIt->second != 0);
149 if (edgeIt->second == 1)
151 else if (edgeIt->second == 2)
164 if (!mesh || !flags || flags->
currentSize() == 0)
return false;
176 stats->
edgesCount =
static_cast<unsigned>(edgeCounters.size());
179 for (std::map<unsigned long long, unsigned>::const_iterator edgeIt =
180 edgeCounters.begin();
181 edgeIt != edgeCounters.end(); ++edgeIt) {
186 if (edgeIt->second == 1) {
190 }
else if (edgeIt->second == 2) {
194 }
else if (edgeIt->second > 2) {
213 unsigned numberOfPoints,
215 std::vector<unsigned>* triIndices ) {
216 if (!mesh)
return nullptr;
223 double samplingDensity = numberOfPoints / Stotal;
232 double samplingDensity,
234 std::vector<unsigned>* triIndices ) {
235 if (!mesh)
return nullptr;
240 unsigned theoreticNumberOfPoints =
241 static_cast<unsigned>(
ceil(Stotal * samplingDensity));
244 progressCb, triIndices);
249 double samplingDensity,
250 unsigned theoreticNumberOfPoints,
252 std::vector<unsigned>* triIndices ) {
253 if (theoreticNumberOfPoints < 1)
return nullptr;
256 unsigned triCount = (mesh ? mesh->
size() : 0);
257 if (triCount == 0)
return nullptr;
260 if (!sampledCloud->
reserve(theoreticNumberOfPoints))
269 triIndices->
reserve(theoreticNumberOfPoints);
270 }
catch (
const std::bad_alloc&) {
282 snprintf(buffer, 64,
"Triangles: %u\nPoints: %u", triCount,
283 theoreticNumberOfPoints);
290 unsigned addedPoints = 0;
291 std::random_device rd;
292 std::mt19937 gen(rd());
293 std::uniform_real_distribution<double>
dist(0, 1);
297 for (
unsigned n = 0; n < triCount; ++n) {
311 double S = N.
normd() / 2;
314 double fPointsToAdd = S * samplingDensity;
315 unsigned pointsToAdd =
static_cast<unsigned>(fPointsToAdd);
318 double fracPart = fPointsToAdd -
static_cast<double>(pointsToAdd);
321 if (
dist(gen) <= fracPart) pointsToAdd += 1;
325 if (addedPoints + pointsToAdd >= theoreticNumberOfPoints) {
326 theoreticNumberOfPoints += pointsToAdd;
328 if (!sampledCloud->
reserve(theoreticNumberOfPoints)) {
330 sampledCloud =
nullptr;
338 triIndices->capacity() <
339 theoreticNumberOfPoints)
342 triIndices->reserve(theoreticNumberOfPoints);
343 }
catch (
const std::bad_alloc&) {
345 sampledCloud =
nullptr;
354 for (
unsigned i = 0; i < pointsToAdd; ++i) {
359 double x =
dist(gen);
360 double y =
dist(gen);
372 if (triIndices) triIndices->push_back(n);
377 if (progressCb && !normProgress.
oneStep())
break;
386 if (triIndices) triIndices->resize(addedPoints);
388 if (triIndices) triIndices->resize(0);
constexpr ScalarType NAN_VALUE
NaN as a ScalarType value.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
double normd() const
Returns vector norm (forces double precision output)
Type norm() const
Returns vector norm.
Vector3Tpl cross(const Vector3Tpl &v) const
Cross product.
A generic mesh with index-based vertex access.
virtual VerticesIndexes * getNextTriangleVertIndexes()=0
virtual unsigned size() const =0
Returns the number of triangles.
virtual void getBoundingBox(CCVector3 &bbMin, CCVector3 &bbMax)=0
Returns the mesh bounding-box.
virtual GenericTriangle * _getNextTriangle()=0
Returns the next triangle (relatively to the global iterator position)
virtual void placeIteratorAtBeginning()=0
Places the mesh iterator at the beginning.
virtual void setInfo(const char *infoStr)=0
Notifies some information about the ongoing process.
virtual void setMethodTitle(const char *methodTitle)=0
Notifies the algorithm title.
virtual bool textCanBeEdited() const
Returns whether the dialog title and info can be updated or not.
virtual void update(float percent)=0
Notifies the algorithm progress.
A generic triangle interface.
virtual const CCVector3 * _getA() const =0
Returns the first vertex (A)
virtual const CCVector3 * _getC() const =0
Returns the third vertex (C)
virtual const CCVector3 * _getB() const =0
Returns the second vertex (B)
bool oneStep()
Increments total progress value of a single unit.
virtual bool reserve(unsigned newCapacity)
Reserves memory for the point database.
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
bool resize(unsigned newCount) override
Resizes the point database.
A simple scalar field (to be associated to a point cloud)
void fill(ScalarType fillValue=0)
Fills the array with a particular value.
virtual void computeMinAndMax()
Determines the min and max values.
void setValue(std::size_t index, ScalarType value)
unsigned currentSize() const
__host__ __device__ int2 abs(int2 v)
static double dist(double x1, double y1, double x2, double y2)
::ccPointCloud PointCloud
MiniVec< float, N > ceil(const MiniVec< float, N > &a)
Generic file read and write utility for python interface.
bool LessThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Triangle described by the indexes of its 3 vertices.