Cleanup: Various clang-tidy warnings in intern
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
#ifndef __DUALCON_H__
|
||||
#define __DUALCON_H__
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -17,28 +17,28 @@
|
||||
*/
|
||||
|
||||
// 3d point with integer coordinates
|
||||
typedef struct {
|
||||
struct Point3i {
|
||||
int x, y, z;
|
||||
} Point3i;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct BoundingBox {
|
||||
Point3i begin;
|
||||
Point3i end;
|
||||
} BoundingBox;
|
||||
};
|
||||
|
||||
// triangle that points to three vertices
|
||||
typedef struct {
|
||||
struct Triangle {
|
||||
float vt[3][3];
|
||||
} Triangle;
|
||||
};
|
||||
|
||||
// 3d point with float coordinates
|
||||
typedef struct {
|
||||
struct Point3f {
|
||||
float x, y, z;
|
||||
} Point3f;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct BoundingBoxf {
|
||||
Point3f begin;
|
||||
Point3f end;
|
||||
} BoundingBoxf;
|
||||
};
|
||||
|
||||
#endif /* __GEOCOMMON_H__ */
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
#ifndef __MEMORYALLOCATOR_H__
|
||||
#define __MEMORYALLOCATOR_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#define HEAP_BASE 16
|
||||
#define UCHAR unsigned char
|
||||
@@ -22,7 +24,7 @@
|
||||
*/
|
||||
class VirtualMemoryAllocator {
|
||||
public:
|
||||
virtual ~VirtualMemoryAllocator() {}
|
||||
virtual ~VirtualMemoryAllocator() = default;
|
||||
|
||||
virtual void *allocate() = 0;
|
||||
virtual void deallocate(void *obj) = 0;
|
||||
@@ -120,7 +122,7 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
void destroy()
|
||||
void destroy() override
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < datablocknum; i++) {
|
||||
@@ -136,7 +138,7 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
|
||||
/**
|
||||
* Allocation method
|
||||
*/
|
||||
void *allocate()
|
||||
void *allocate() override
|
||||
{
|
||||
if (available == 0) {
|
||||
allocateDataBlock();
|
||||
@@ -150,7 +152,7 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
|
||||
/**
|
||||
* De-allocation method
|
||||
*/
|
||||
void deallocate(void *obj)
|
||||
void deallocate(void *obj) override
|
||||
{
|
||||
if (available == stacksize) {
|
||||
allocateStackBlock();
|
||||
@@ -165,7 +167,7 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
|
||||
/**
|
||||
* Print information
|
||||
*/
|
||||
void printInfo()
|
||||
void printInfo() override
|
||||
{
|
||||
printf("Bytes: %d Used: %d Allocated: %d Maxfree: %d\n",
|
||||
getBytes(),
|
||||
@@ -177,17 +179,17 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
|
||||
/**
|
||||
* Query methods
|
||||
*/
|
||||
int getAllocated()
|
||||
int getAllocated() override
|
||||
{
|
||||
return HEAP_UNIT * datablocknum - available;
|
||||
};
|
||||
|
||||
int getAll()
|
||||
int getAll() override
|
||||
{
|
||||
return HEAP_UNIT * datablocknum;
|
||||
};
|
||||
|
||||
int getBytes()
|
||||
int getBytes() override
|
||||
{
|
||||
return N;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
class ModelReader {
|
||||
public:
|
||||
/// Constructor
|
||||
ModelReader(){};
|
||||
ModelReader() = default;
|
||||
|
||||
/// Get next triangle
|
||||
virtual Triangle *getNextTriangle() = 0;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "Projections.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
const int vertmap[8][3] = {
|
||||
{0, 0, 0},
|
||||
@@ -180,12 +180,8 @@ CubeTriangleIsect::CubeTriangleIsect(int64_t cube[2][3],
|
||||
for (i = 1; i < 8; i++) {
|
||||
int64_t proj = (vertmap[i][0] * cube_proj.edges[0] + vertmap[i][1] * cube_proj.edges[1] +
|
||||
vertmap[i][2] * cube_proj.edges[2]);
|
||||
if (proj > max) {
|
||||
max = proj;
|
||||
}
|
||||
if (proj < min) {
|
||||
min = proj;
|
||||
}
|
||||
max = std::max(proj, max);
|
||||
min = std::min(proj, min);
|
||||
}
|
||||
cube_proj.min = min;
|
||||
cube_proj.max = max;
|
||||
@@ -201,13 +197,8 @@ CubeTriangleIsect::CubeTriangleIsect(int64_t cube[2][3],
|
||||
inherit->tri_proj[axis][0] = vts[0];
|
||||
inherit->tri_proj[axis][1] = vts[0];
|
||||
for (i = 1; i < 3; i++) {
|
||||
if (vts[i] < inherit->tri_proj[axis][0]) {
|
||||
inherit->tri_proj[axis][0] = vts[i];
|
||||
}
|
||||
|
||||
if (vts[i] > inherit->tri_proj[axis][1]) {
|
||||
inherit->tri_proj[axis][1] = vts[i];
|
||||
}
|
||||
inherit->tri_proj[axis][0] = std::min(vts[i], inherit->tri_proj[axis][0]);
|
||||
inherit->tri_proj[axis][1] = std::max(vts[i], inherit->tri_proj[axis][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,7 +262,7 @@ unsigned char CubeTriangleIsect::getBoxMask()
|
||||
/**
|
||||
* Shifting a cube to a new origin
|
||||
*/
|
||||
void CubeTriangleIsect::shift(int off[3])
|
||||
void CubeTriangleIsect::shift(const int off[3])
|
||||
{
|
||||
for (int i = 0; i < NUM_AXES; i++) {
|
||||
cubeProj[i].origin += (off[0] * cubeProj[i].edges[0] + off[1] * cubeProj[i].edges[1] +
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
#ifndef __PROJECTIONS_H__
|
||||
#define __PROJECTIONS_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#define CONTAINS_INDEX
|
||||
#define GRID_DIMENSION 20
|
||||
@@ -16,7 +17,7 @@
|
||||
# define LONG __int64
|
||||
# define int64_t __int64
|
||||
#else
|
||||
# include <stdint.h>
|
||||
# include <cstdint>
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -76,8 +77,7 @@ class CubeTriangleIsect {
|
||||
/// Projections of the cube vertices
|
||||
CubeProjection cubeProj[NUM_AXES];
|
||||
|
||||
public:
|
||||
CubeTriangleIsect() {}
|
||||
CubeTriangleIsect() = default;
|
||||
|
||||
/**
|
||||
* Construction from a cube (axes aligned) and triangle
|
||||
@@ -95,7 +95,7 @@ class CubeTriangleIsect {
|
||||
/**
|
||||
* Shifting a cube to a new origin
|
||||
*/
|
||||
void shift(int off[3]);
|
||||
void shift(const int off[3]);
|
||||
|
||||
/**
|
||||
* Method to test intersection of the triangle and the cube
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef __QUEUE_H__
|
||||
#define __QUEUE_H__
|
||||
|
||||
#include "MemoryAllocator.h"
|
||||
|
||||
struct gridQueueEle {
|
||||
int x, y, z;
|
||||
UCHAR dir;
|
||||
@@ -19,8 +21,8 @@ class GridQueue {
|
||||
public:
|
||||
GridQueue()
|
||||
{
|
||||
head = NULL;
|
||||
tail = NULL;
|
||||
head = nullptr;
|
||||
tail = nullptr;
|
||||
numEles = 0;
|
||||
}
|
||||
|
||||
@@ -34,15 +36,15 @@ class GridQueue {
|
||||
return numEles;
|
||||
}
|
||||
|
||||
void pushQueue(int st[3], int dir)
|
||||
void pushQueue(const int st[3], int dir)
|
||||
{
|
||||
gridQueueEle *ele = new gridQueueEle;
|
||||
ele->x = st[0];
|
||||
ele->y = st[1];
|
||||
ele->z = st[2];
|
||||
ele->dir = (UCHAR)dir;
|
||||
ele->next = NULL;
|
||||
if (head == NULL) {
|
||||
ele->next = nullptr;
|
||||
if (head == nullptr) {
|
||||
head = ele;
|
||||
}
|
||||
else {
|
||||
@@ -54,7 +56,7 @@ class GridQueue {
|
||||
|
||||
int popQueue(int st[3], int &dir)
|
||||
{
|
||||
if (head == NULL) {
|
||||
if (head == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -67,8 +69,8 @@ class GridQueue {
|
||||
head = head->next;
|
||||
delete temp;
|
||||
|
||||
if (head == NULL) {
|
||||
tail = NULL;
|
||||
if (head == nullptr) {
|
||||
tail = nullptr;
|
||||
}
|
||||
numEles--;
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef __CUBES_H__
|
||||
#define __CUBES_H__
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "marching_cubes_table.h"
|
||||
|
||||
/* simple wrapper for auto-generated marching cubes data */
|
||||
|
||||
@@ -5,14 +5,11 @@
|
||||
#include "ModelReader.h"
|
||||
#include "dualcon.h"
|
||||
#include "octree.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include <cstdio>
|
||||
#include <float.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define isnan(n) _isnan(n)
|
||||
#endif
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
|
||||
static void veccopy(float dst[3], const float src[3])
|
||||
{
|
||||
@@ -42,7 +39,7 @@ class DualConInputReader : public ModelReader {
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset()
|
||||
void reset() override
|
||||
{
|
||||
curtri = 0;
|
||||
maxsize = 0;
|
||||
@@ -54,9 +51,7 @@ class DualConInputReader : public ModelReader {
|
||||
/* initialize maxsize */
|
||||
for (int i = 0; i < 3; i++) {
|
||||
float d = max[i] - min[i];
|
||||
if (d > maxsize) {
|
||||
maxsize = d;
|
||||
}
|
||||
maxsize = std::max(d, maxsize);
|
||||
}
|
||||
|
||||
/* redo the bounds */
|
||||
@@ -71,10 +66,10 @@ class DualConInputReader : public ModelReader {
|
||||
maxsize *= 1 / scale;
|
||||
}
|
||||
|
||||
Triangle *getNextTriangle()
|
||||
Triangle *getNextTriangle() override
|
||||
{
|
||||
if (curtri == input_mesh->tottri) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Triangle *t = new Triangle();
|
||||
@@ -89,7 +84,7 @@ class DualConInputReader : public ModelReader {
|
||||
/* remove triangle if it contains invalid coords */
|
||||
for (int i = 0; i < 3; i++) {
|
||||
const float *co = t->vt[i];
|
||||
if (isnan(co[0]) || isnan(co[1]) || isnan(co[2])) {
|
||||
if (std::isnan(co[0]) || std::isnan(co[1]) || std::isnan(co[2])) {
|
||||
delete t;
|
||||
return getNextTriangle();
|
||||
}
|
||||
@@ -98,7 +93,7 @@ class DualConInputReader : public ModelReader {
|
||||
return t;
|
||||
}
|
||||
|
||||
int getNextTriangle(int t[3])
|
||||
int getNextTriangle(int t[3]) override
|
||||
{
|
||||
if (curtri == input_mesh->tottri) {
|
||||
return 0;
|
||||
@@ -114,31 +109,31 @@ class DualConInputReader : public ModelReader {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int getNumTriangles()
|
||||
int getNumTriangles() override
|
||||
{
|
||||
return tottri;
|
||||
}
|
||||
|
||||
int getNumVertices()
|
||||
int getNumVertices() override
|
||||
{
|
||||
return input_mesh->totco;
|
||||
}
|
||||
|
||||
float getBoundingBox(float origin[3])
|
||||
float getBoundingBox(float origin[3]) override
|
||||
{
|
||||
veccopy(origin, min);
|
||||
return maxsize;
|
||||
}
|
||||
|
||||
/* output */
|
||||
void getNextVertex(float /*v*/[3])
|
||||
void getNextVertex(float /*v*/[3]) override
|
||||
{
|
||||
/* not used */
|
||||
}
|
||||
|
||||
/* stubs */
|
||||
void printInfo() {}
|
||||
int getMemory()
|
||||
void printInfo() override {}
|
||||
int getMemory() override
|
||||
{
|
||||
return sizeof(DualConInputReader);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#ifndef __MANIFOLD_TABLE_H__
|
||||
#define __MANIFOLD_TABLE_H__
|
||||
|
||||
typedef struct {
|
||||
struct ManifoldIndices {
|
||||
int comps;
|
||||
int pairs[12][2];
|
||||
} ManifoldIndices;
|
||||
};
|
||||
|
||||
extern const ManifoldIndices manifold_table[256];
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "octree.h"
|
||||
#include "Queue.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <limits>
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
|
||||
/**
|
||||
* Implementations of Octree member functions.
|
||||
@@ -266,7 +266,7 @@ void Octree::addAllTriangles()
|
||||
|
||||
srand(0);
|
||||
|
||||
while ((trian = reader->getNextTriangle()) != NULL) {
|
||||
while ((trian = reader->getNextTriangle()) != nullptr) {
|
||||
// Drop triangles
|
||||
{
|
||||
addTriangle(trian, count);
|
||||
@@ -473,10 +473,10 @@ void Octree::trace()
|
||||
totRingLengths = 0;
|
||||
maxRingLength = 0;
|
||||
|
||||
PathList *chdpath = NULL;
|
||||
PathList *chdpath = nullptr;
|
||||
root = trace(root, st, dimen, maxDepth, chdpath);
|
||||
|
||||
if (chdpath != NULL) {
|
||||
if (chdpath != nullptr) {
|
||||
dc_printf("there are incomplete rings.\n");
|
||||
printPaths(chdpath);
|
||||
}
|
||||
@@ -500,8 +500,8 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *&paths
|
||||
nst[i][j] = st[j] + len * vertmap[i][j];
|
||||
}
|
||||
|
||||
if (chd[i] == NULL || newnode->internal.is_child_leaf(i)) {
|
||||
chdpaths[i] = NULL;
|
||||
if (chd[i] == nullptr || newnode->internal.is_child_leaf(i)) {
|
||||
chdpaths[i] = nullptr;
|
||||
}
|
||||
else {
|
||||
trace(chd[i], nst[i], len, depth - 1, chdpaths[i]);
|
||||
@@ -526,7 +526,7 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *&paths
|
||||
nstf[j] = nst[c[j]];
|
||||
}
|
||||
|
||||
conn[i] = NULL;
|
||||
conn[i] = nullptr;
|
||||
|
||||
findPaths((Node **)nf, lf, df, nstf, depth - 1, cellProcFaceMask[i][2], conn[i]);
|
||||
|
||||
@@ -538,7 +538,7 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *&paths
|
||||
}
|
||||
|
||||
// Connect paths
|
||||
PathList *rings = NULL;
|
||||
PathList *rings = nullptr;
|
||||
combinePaths(chdpaths[0], chdpaths[1], conn[8], rings);
|
||||
combinePaths(chdpaths[2], chdpaths[3], conn[9], rings);
|
||||
combinePaths(chdpaths[4], chdpaths[5], conn[10], rings);
|
||||
@@ -546,13 +546,13 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *&paths
|
||||
|
||||
combinePaths(chdpaths[0], chdpaths[2], conn[4], rings);
|
||||
combinePaths(chdpaths[4], chdpaths[6], conn[5], rings);
|
||||
combinePaths(chdpaths[0], NULL, conn[6], rings);
|
||||
combinePaths(chdpaths[4], NULL, conn[7], rings);
|
||||
combinePaths(chdpaths[0], nullptr, conn[6], rings);
|
||||
combinePaths(chdpaths[4], nullptr, conn[7], rings);
|
||||
|
||||
combinePaths(chdpaths[0], chdpaths[4], conn[0], rings);
|
||||
combinePaths(chdpaths[0], NULL, conn[1], rings);
|
||||
combinePaths(chdpaths[0], NULL, conn[2], rings);
|
||||
combinePaths(chdpaths[0], NULL, conn[3], rings);
|
||||
combinePaths(chdpaths[0], nullptr, conn[1], rings);
|
||||
combinePaths(chdpaths[0], nullptr, conn[2], rings);
|
||||
combinePaths(chdpaths[0], nullptr, conn[3], rings);
|
||||
|
||||
// By now, only chdpaths[0] and rings have contents
|
||||
|
||||
@@ -565,9 +565,7 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *&paths
|
||||
while (trings) {
|
||||
numRings++;
|
||||
totRingLengths += trings->length;
|
||||
if (trings->length > maxRingLength) {
|
||||
maxRingLength = trings->length;
|
||||
}
|
||||
maxRingLength = std::max(trings->length, maxRingLength);
|
||||
trings = trings->next;
|
||||
}
|
||||
|
||||
@@ -580,8 +578,13 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *&paths
|
||||
return newnode;
|
||||
}
|
||||
|
||||
void Octree::findPaths(
|
||||
Node *node[2], int leaf[2], int depth[2], int *st[2], int maxdep, int dir, PathList *&paths)
|
||||
void Octree::findPaths(Node *node[2],
|
||||
const int leaf[2],
|
||||
const int depth[2],
|
||||
int *st[2],
|
||||
int maxdep,
|
||||
int dir,
|
||||
PathList *&paths)
|
||||
{
|
||||
if (!(node[0] && node[1])) {
|
||||
return;
|
||||
@@ -651,7 +654,7 @@ void Octree::findPaths(
|
||||
ele2->pos[2] = st[1][2];
|
||||
|
||||
ele1->next = ele2;
|
||||
ele2->next = NULL;
|
||||
ele2->next = nullptr;
|
||||
|
||||
PathList *lst = new PathList;
|
||||
lst->head = ele1;
|
||||
@@ -668,7 +671,7 @@ void Octree::findPaths(
|
||||
void Octree::combinePaths(PathList *&list1, PathList *list2, PathList *paths, PathList *&rings)
|
||||
{
|
||||
// Make new list of paths
|
||||
PathList *nlist = NULL;
|
||||
PathList *nlist = nullptr;
|
||||
|
||||
// Search for each connectors in paths
|
||||
PathList *tpaths = paths;
|
||||
@@ -677,13 +680,15 @@ void Octree::combinePaths(PathList *&list1, PathList *list2, PathList *paths, Pa
|
||||
PathList *singlist = tpaths;
|
||||
PathList *templist;
|
||||
tpaths = tpaths->next;
|
||||
singlist->next = NULL;
|
||||
singlist->next = nullptr;
|
||||
|
||||
// Look for hookup in list1
|
||||
tlist = list1;
|
||||
pre = NULL;
|
||||
pre = nullptr;
|
||||
while (tlist) {
|
||||
if ((templist = combineSinglePath(list1, pre, tlist, singlist, NULL, singlist)) != NULL) {
|
||||
if ((templist = combineSinglePath(list1, pre, tlist, singlist, nullptr, singlist)) !=
|
||||
nullptr)
|
||||
{
|
||||
singlist = templist;
|
||||
continue;
|
||||
}
|
||||
@@ -693,9 +698,11 @@ void Octree::combinePaths(PathList *&list1, PathList *list2, PathList *paths, Pa
|
||||
|
||||
// Look for hookup in list2
|
||||
tlist = list2;
|
||||
pre = NULL;
|
||||
pre = nullptr;
|
||||
while (tlist) {
|
||||
if ((templist = combineSinglePath(list2, pre, tlist, singlist, NULL, singlist)) != NULL) {
|
||||
if ((templist = combineSinglePath(list2, pre, tlist, singlist, nullptr, singlist)) !=
|
||||
nullptr)
|
||||
{
|
||||
singlist = templist;
|
||||
continue;
|
||||
}
|
||||
@@ -705,9 +712,11 @@ void Octree::combinePaths(PathList *&list1, PathList *list2, PathList *paths, Pa
|
||||
|
||||
// Look for hookup in nlist
|
||||
tlist = nlist;
|
||||
pre = NULL;
|
||||
pre = nullptr;
|
||||
while (tlist) {
|
||||
if ((templist = combineSinglePath(nlist, pre, tlist, singlist, NULL, singlist)) != NULL) {
|
||||
if ((templist = combineSinglePath(nlist, pre, tlist, singlist, nullptr, singlist)) !=
|
||||
nullptr)
|
||||
{
|
||||
singlist = templist;
|
||||
continue;
|
||||
}
|
||||
@@ -734,8 +743,8 @@ void Octree::combinePaths(PathList *&list1, PathList *list2, PathList *paths, Pa
|
||||
|
||||
// Append list2 and nlist to the end of list1
|
||||
tlist = list1;
|
||||
if (tlist != NULL) {
|
||||
while (tlist->next != NULL) {
|
||||
if (tlist != nullptr) {
|
||||
while (tlist->next != nullptr) {
|
||||
tlist = tlist->next;
|
||||
}
|
||||
tlist->next = list2;
|
||||
@@ -745,8 +754,8 @@ void Octree::combinePaths(PathList *&list1, PathList *list2, PathList *paths, Pa
|
||||
list1 = list2;
|
||||
}
|
||||
|
||||
if (tlist != NULL) {
|
||||
while (tlist->next != NULL) {
|
||||
if (tlist != nullptr) {
|
||||
while (tlist->next != nullptr) {
|
||||
tlist = tlist->next;
|
||||
}
|
||||
tlist->next = nlist;
|
||||
@@ -770,8 +779,8 @@ PathList *Octree::combineSinglePath(PathList *&head1,
|
||||
// Reverse list1
|
||||
PathElement *prev = list1->head;
|
||||
PathElement *next = prev->next;
|
||||
prev->next = NULL;
|
||||
while (next != NULL) {
|
||||
prev->next = nullptr;
|
||||
while (next != nullptr) {
|
||||
PathElement *tnext = next->next;
|
||||
next->next = prev;
|
||||
|
||||
@@ -786,8 +795,8 @@ PathList *Octree::combineSinglePath(PathList *&head1,
|
||||
// Reverse list2
|
||||
PathElement *prev = list2->head;
|
||||
PathElement *next = prev->next;
|
||||
prev->next = NULL;
|
||||
while (next != NULL) {
|
||||
prev->next = nullptr;
|
||||
while (next != nullptr) {
|
||||
PathElement *tnext = next->next;
|
||||
next->next = prev;
|
||||
|
||||
@@ -811,14 +820,14 @@ PathList *Octree::combineSinglePath(PathList *&head1,
|
||||
nlist->length = list1->length + list2->length - 1;
|
||||
nlist->head = list2->head;
|
||||
nlist->tail = list1->tail;
|
||||
nlist->next = NULL;
|
||||
nlist->next = nullptr;
|
||||
|
||||
deletePath(head1, pre1, list1);
|
||||
deletePath(head2, pre2, list2);
|
||||
|
||||
return nlist;
|
||||
}
|
||||
else if (isEqual(list1->tail, list2->head)) {
|
||||
if (isEqual(list1->tail, list2->head)) {
|
||||
// Easy case
|
||||
PathElement *temp = list2->head->next;
|
||||
delete list2->head;
|
||||
@@ -828,7 +837,7 @@ PathList *Octree::combineSinglePath(PathList *&head1,
|
||||
nlist->length = list1->length + list2->length - 1;
|
||||
nlist->head = list1->head;
|
||||
nlist->tail = list2->tail;
|
||||
nlist->next = NULL;
|
||||
nlist->next = nullptr;
|
||||
|
||||
deletePath(head1, pre1, list1);
|
||||
deletePath(head2, pre2, list2);
|
||||
@@ -836,7 +845,7 @@ PathList *Octree::combineSinglePath(PathList *&head1,
|
||||
return nlist;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Octree::deletePath(PathList *&head, PathList *pre, PathList *&curr)
|
||||
@@ -845,7 +854,7 @@ void Octree::deletePath(PathList *&head, PathList *pre, PathList *&curr)
|
||||
curr = temp->next;
|
||||
delete temp;
|
||||
|
||||
if (pre == NULL) {
|
||||
if (pre == nullptr) {
|
||||
head = curr;
|
||||
}
|
||||
else {
|
||||
@@ -855,7 +864,7 @@ void Octree::deletePath(PathList *&head, PathList *pre, PathList *&curr)
|
||||
|
||||
void Octree::printElement(PathElement *ele)
|
||||
{
|
||||
if (ele != NULL) {
|
||||
if (ele != nullptr) {
|
||||
dc_printf("(%d %d %d)", ele->pos[0], ele->pos[1], ele->pos[2]);
|
||||
}
|
||||
}
|
||||
@@ -906,7 +915,7 @@ void Octree::printPath(PathElement *path)
|
||||
void Octree::printPaths(PathList *path)
|
||||
{
|
||||
PathList *iter = path;
|
||||
while (iter != NULL) {
|
||||
while (iter != nullptr) {
|
||||
dc_printf("Path %d:\n", i);
|
||||
printPath(iter);
|
||||
iter = iter->next;
|
||||
@@ -924,7 +933,7 @@ Node *Octree::patch(Node *newnode, int st[3], int len, PathList *rings)
|
||||
PathList* tlist = rings;
|
||||
PathList* ttlist;
|
||||
PathElement* telem, * ttelem;
|
||||
while(tlist!= NULL) {
|
||||
while(tlist!= nullptr) {
|
||||
// printPath(tlist);
|
||||
numRings ++;
|
||||
totRingLengths += tlist->length;
|
||||
@@ -963,7 +972,7 @@ Node *Octree::patch(Node *newnode, int st[3], int len, PathList *rings)
|
||||
len >>= 1;
|
||||
int count = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (zlists[i] != NULL) {
|
||||
if (zlists[i] != nullptr) {
|
||||
int nori[3] = {
|
||||
st[0] + len * vertmap[i][0], st[1] + len * vertmap[i][1], st[2] + len * vertmap[i][2]};
|
||||
patch(newnode->internal.get_child(count), nori, len, zlists[i]);
|
||||
@@ -992,10 +1001,10 @@ Node *Octree::patchSplit(Node *newnode,
|
||||
printPaths(rings);
|
||||
#endif
|
||||
|
||||
nrings1 = NULL;
|
||||
nrings2 = NULL;
|
||||
nrings1 = nullptr;
|
||||
nrings2 = nullptr;
|
||||
PathList *tmp;
|
||||
while (rings != NULL) {
|
||||
while (rings != nullptr) {
|
||||
// Process this ring
|
||||
newnode = patchSplitSingle(newnode, st, len, rings->head, dir, nrings1, nrings2);
|
||||
|
||||
@@ -1029,19 +1038,18 @@ Node *Octree::patchSplitSingle(Node *newnode,
|
||||
printPath(head);
|
||||
#endif
|
||||
|
||||
if (head == NULL) {
|
||||
if (head == nullptr) {
|
||||
#ifdef IN_DEBUG_MODE
|
||||
dc_printf("Return from PATCHSPLITSINGLE with head==NULL.\n");
|
||||
dc_printf("Return from PATCHSPLITSINGLE with head==nullptr.\n");
|
||||
#endif
|
||||
return newnode;
|
||||
}
|
||||
else {
|
||||
// printPath(head);
|
||||
}
|
||||
|
||||
// printPath(head);
|
||||
|
||||
// Walk along the ring to find pair of intersections
|
||||
PathElement *pre1 = NULL;
|
||||
PathElement *pre2 = NULL;
|
||||
PathElement *pre1 = nullptr;
|
||||
PathElement *pre2 = nullptr;
|
||||
int side = findPair(head, st[dir] + len / 2, dir, pre1, pre2);
|
||||
|
||||
#if 0
|
||||
@@ -1084,7 +1092,7 @@ Node *Octree::patchSplitSingle(Node *newnode,
|
||||
if (isEqual(pre1, pre1->next)) {
|
||||
if (pre1 == pre1->next) {
|
||||
delete pre1;
|
||||
pre1 = NULL;
|
||||
pre1 = nullptr;
|
||||
}
|
||||
else {
|
||||
PathElement *temp = pre1->next;
|
||||
@@ -1095,7 +1103,7 @@ Node *Octree::patchSplitSingle(Node *newnode,
|
||||
if (isEqual(pre2, pre2->next)) {
|
||||
if (pre2 == pre2->next) {
|
||||
delete pre2;
|
||||
pre2 = NULL;
|
||||
pre2 = nullptr;
|
||||
}
|
||||
else {
|
||||
PathElement *temp = pre2->next;
|
||||
@@ -1183,10 +1191,10 @@ Node *Octree::connectFace(
|
||||
|
||||
PathElement *curEleN = f1;
|
||||
PathElement *curEleP = f2->next;
|
||||
Node *nodeN = NULL, *nodeP = NULL;
|
||||
Node *nodeN = nullptr, *nodeP = nullptr;
|
||||
LeafNode *curN = locateLeaf(&newnode->internal, len, f1->pos);
|
||||
LeafNode *curP = locateLeaf(&newnode->internal, len, f2->next->pos);
|
||||
if (curN == NULL || curP == NULL) {
|
||||
if (curN == nullptr || curP == nullptr) {
|
||||
exit(0);
|
||||
}
|
||||
int stN[3], stP[3];
|
||||
@@ -1412,7 +1420,7 @@ LeafNode *Octree::patchAdjacent(InternalNode *node,
|
||||
}
|
||||
|
||||
Node *Octree::locateCell(InternalNode *node,
|
||||
int st[3],
|
||||
const int st[3],
|
||||
int len,
|
||||
int ori[3],
|
||||
int dir,
|
||||
@@ -1498,7 +1506,7 @@ Node *Octree::locateCell(InternalNode *node,
|
||||
void Octree::checkElement(PathElement * /*ele*/)
|
||||
{
|
||||
#if 0
|
||||
if (ele != NULL && locateLeafCheck(ele->pos) != ele->node) {
|
||||
if (ele != nullptr && locateLeafCheck(ele->pos) != ele->node) {
|
||||
dc_printf("Screwed! at pos: %d %d %d\n",
|
||||
ele->pos[0] >> minshift,
|
||||
ele->pos[1] >> minshift,
|
||||
@@ -1522,7 +1530,7 @@ void Octree::checkPath(PathElement *path)
|
||||
void Octree::testFacePoint(PathElement *e1, PathElement *e2)
|
||||
{
|
||||
int i;
|
||||
PathElement *e = NULL;
|
||||
PathElement *e = nullptr;
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (e1->pos[i] != e2->pos[i]) {
|
||||
if (e1->pos[i] < e2->pos[i]) {
|
||||
@@ -1708,7 +1716,7 @@ int Octree::isEqual(PathElement *e1, PathElement *e2)
|
||||
|
||||
void Octree::compressRing(PathElement *&ring)
|
||||
{
|
||||
if (ring == NULL) {
|
||||
if (ring == nullptr) {
|
||||
return;
|
||||
}
|
||||
#ifdef IN_DEBUG_MODE
|
||||
@@ -1728,20 +1736,18 @@ void Octree::compressRing(PathElement *&ring)
|
||||
// The ring has shrinked to a point
|
||||
delete pre;
|
||||
delete cur;
|
||||
anchor = NULL;
|
||||
anchor = nullptr;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
prepre->next = cur->next;
|
||||
delete pre;
|
||||
delete cur;
|
||||
pre = prepre->next;
|
||||
cur = pre->next;
|
||||
anchor = prepre;
|
||||
}
|
||||
prepre->next = cur->next;
|
||||
delete pre;
|
||||
delete cur;
|
||||
pre = prepre->next;
|
||||
cur = pre->next;
|
||||
anchor = prepre;
|
||||
}
|
||||
|
||||
if (anchor == NULL) {
|
||||
if (anchor == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1787,7 +1793,7 @@ void Octree::buildSigns()
|
||||
|
||||
void Octree::buildSigns(unsigned char table[], Node *node, int isLeaf, int sg, int rvalue[8])
|
||||
{
|
||||
if (node == NULL) {
|
||||
if (node == nullptr) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
rvalue[i] = sg;
|
||||
}
|
||||
@@ -1864,7 +1870,7 @@ void Octree::clearProcessBits(Node *node, int height)
|
||||
}
|
||||
}
|
||||
|
||||
int Octree::floodFill(LeafNode *leaf, int st[3], int len, int /*height*/, int threshold)
|
||||
int Octree::floodFill(LeafNode *leaf, const int st[3], int len, int /*height*/, int threshold)
|
||||
{
|
||||
int i, j;
|
||||
int maxtotal = 0;
|
||||
@@ -1980,9 +1986,7 @@ int Octree::floodFill(LeafNode *leaf, int st[3], int len, int /*height*/, int th
|
||||
|
||||
if (threshold == 0) {
|
||||
// Measuring stage
|
||||
if (total > maxtotal) {
|
||||
maxtotal = total;
|
||||
}
|
||||
maxtotal = std::max(total, maxtotal);
|
||||
dc_printf(".\n");
|
||||
delete queue;
|
||||
continue;
|
||||
@@ -2112,9 +2116,7 @@ int Octree::floodFill(Node *node, int st[3], int len, int height, int threshold)
|
||||
nst[2] = st[2] + vertmap[i][2] * len;
|
||||
|
||||
int d = floodFill(node->internal.get_child(count), nst, len, height - 1, threshold);
|
||||
if (d > maxtotal) {
|
||||
maxtotal = d;
|
||||
}
|
||||
maxtotal = std::max(d, maxtotal);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -2442,13 +2444,11 @@ void Octree::processEdgeWrite(Node *node[4], int /*depth*/[4], int /*maxdep*/, i
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Octree::edgeProcContour(Node *node[4], int leaf[4], int depth[4], int maxdep, int dir)
|
||||
void Octree::edgeProcContour(Node *node[4], const int leaf[4], int depth[4], int maxdep, int dir)
|
||||
{
|
||||
if (!(node[0] && node[1] && node[2] && node[3])) {
|
||||
return;
|
||||
@@ -2463,7 +2463,7 @@ void Octree::edgeProcContour(Node *node[4], int leaf[4], int depth[4], int maxde
|
||||
for (i = 0; i < 8; i++) {
|
||||
chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ?
|
||||
node[j]->internal.get_child(node[j]->internal.get_child_count(i)) :
|
||||
NULL;
|
||||
nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2495,7 +2495,8 @@ void Octree::edgeProcContour(Node *node[4], int leaf[4], int depth[4], int maxde
|
||||
}
|
||||
}
|
||||
|
||||
void Octree::faceProcContour(Node *node[2], int leaf[2], int depth[2], int maxdep, int dir)
|
||||
void Octree::faceProcContour(
|
||||
Node *node[2], const int leaf[2], const int depth[2], int maxdep, int dir)
|
||||
{
|
||||
if (!(node[0] && node[1])) {
|
||||
return;
|
||||
@@ -2509,7 +2510,7 @@ void Octree::faceProcContour(Node *node[2], int leaf[2], int depth[2], int maxde
|
||||
for (i = 0; i < 8; i++) {
|
||||
chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ?
|
||||
node[j]->internal.get_child(node[j]->internal.get_child_count(i)) :
|
||||
NULL;
|
||||
nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2567,7 +2568,7 @@ void Octree::faceProcContour(Node *node[2], int leaf[2], int depth[2], int maxde
|
||||
|
||||
void Octree::cellProcContour(Node *node, int leaf, int depth)
|
||||
{
|
||||
if (node == NULL) {
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2579,7 +2580,7 @@ void Octree::cellProcContour(Node *node, int leaf, int depth)
|
||||
for (i = 0; i < 8; i++) {
|
||||
chd[i] = ((!leaf) && node->internal.has_child(i)) ?
|
||||
node->internal.get_child(node->internal.get_child_count(i)) :
|
||||
NULL;
|
||||
nullptr;
|
||||
}
|
||||
|
||||
// 8 Cell calls
|
||||
@@ -2623,7 +2624,7 @@ void Octree::cellProcContour(Node *node, int leaf, int depth)
|
||||
}
|
||||
}
|
||||
|
||||
void Octree::processEdgeParity(LeafNode *node[4], int /*depth*/[4], int /*maxdep*/, int dir)
|
||||
void Octree::processEdgeParity(LeafNode *node[4], const int /*depth*/[4], int /*maxdep*/, int dir)
|
||||
{
|
||||
int con = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@@ -2644,7 +2645,8 @@ void Octree::processEdgeParity(LeafNode *node[4], int /*depth*/[4], int /*maxdep
|
||||
}
|
||||
}
|
||||
|
||||
void Octree::edgeProcParity(Node *node[4], int leaf[4], int depth[4], int maxdep, int dir)
|
||||
void Octree::edgeProcParity(
|
||||
Node *node[4], const int leaf[4], const int depth[4], int maxdep, int dir)
|
||||
{
|
||||
if (!(node[0] && node[1] && node[2] && node[3])) {
|
||||
return;
|
||||
@@ -2659,7 +2661,7 @@ void Octree::edgeProcParity(Node *node[4], int leaf[4], int depth[4], int maxdep
|
||||
for (i = 0; i < 8; i++) {
|
||||
chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ?
|
||||
node[j]->internal.get_child(node[j]->internal.get_child_count(i)) :
|
||||
NULL;
|
||||
nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2693,7 +2695,8 @@ void Octree::edgeProcParity(Node *node[4], int leaf[4], int depth[4], int maxdep
|
||||
}
|
||||
}
|
||||
|
||||
void Octree::faceProcParity(Node *node[2], int leaf[2], int depth[2], int maxdep, int dir)
|
||||
void Octree::faceProcParity(
|
||||
Node *node[2], const int leaf[2], const int depth[2], int maxdep, int dir)
|
||||
{
|
||||
if (!(node[0] && node[1])) {
|
||||
return;
|
||||
@@ -2707,7 +2710,7 @@ void Octree::faceProcParity(Node *node[2], int leaf[2], int depth[2], int maxdep
|
||||
for (i = 0; i < 8; i++) {
|
||||
chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ?
|
||||
node[j]->internal.get_child(node[j]->internal.get_child_count(i)) :
|
||||
NULL;
|
||||
nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2765,7 +2768,7 @@ void Octree::faceProcParity(Node *node[2], int leaf[2], int depth[2], int maxdep
|
||||
|
||||
void Octree::cellProcParity(Node *node, int leaf, int depth)
|
||||
{
|
||||
if (node == NULL) {
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2777,7 +2780,7 @@ void Octree::cellProcParity(Node *node, int leaf, int depth)
|
||||
for (i = 0; i < 8; i++) {
|
||||
chd[i] = ((!leaf) && node->internal.has_child(i)) ?
|
||||
node->internal.get_child(node->internal.get_child_count(i)) :
|
||||
NULL;
|
||||
nullptr;
|
||||
}
|
||||
|
||||
// 8 Cell calls
|
||||
|
||||
@@ -9,14 +9,12 @@
|
||||
#include "MemoryAllocator.h"
|
||||
#include "ModelReader.h"
|
||||
#include "Projections.h"
|
||||
#include "Queue.h"
|
||||
#include "cubes.h"
|
||||
#include "dualcon.h"
|
||||
#include "manifold_table.h"
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* Main class and structures for scan-convertion, sign-generation,
|
||||
@@ -107,7 +105,7 @@ struct InternalNode {
|
||||
count++;
|
||||
}
|
||||
else {
|
||||
children[i] = NULL;
|
||||
children[i] = nullptr;
|
||||
leaf[i] = 0;
|
||||
}
|
||||
}
|
||||
@@ -255,7 +253,6 @@ class Octree {
|
||||
|
||||
DualConMode mode;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construtor
|
||||
*/
|
||||
@@ -264,10 +261,10 @@ class Octree {
|
||||
DualConAddVert add_vert_func,
|
||||
DualConAddQuad add_quad_func,
|
||||
DualConFlags flags,
|
||||
DualConMode mode,
|
||||
DualConMode dualcon_mode,
|
||||
int depth,
|
||||
float threshold,
|
||||
float hermite_num);
|
||||
float sharpness);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@@ -308,10 +305,10 @@ class Octree {
|
||||
void resetMinimalEdges();
|
||||
|
||||
void cellProcParity(Node *node, int leaf, int depth);
|
||||
void faceProcParity(Node *node[2], int leaf[2], int depth[2], int maxdep, int dir);
|
||||
void edgeProcParity(Node *node[4], int leaf[4], int depth[4], int maxdep, int dir);
|
||||
void faceProcParity(Node *node[2], const int leaf[2], const int depth[2], int maxdep, int dir);
|
||||
void edgeProcParity(Node *node[4], const int leaf[4], const int depth[4], int maxdep, int dir);
|
||||
|
||||
void processEdgeParity(LeafNode *node[4], int depths[4], int maxdep, int dir);
|
||||
void processEdgeParity(LeafNode *node[4], const int depths[4], int maxdep, int dir);
|
||||
|
||||
/**
|
||||
* Add triangles to the tree
|
||||
@@ -341,8 +338,13 @@ class Octree {
|
||||
/**
|
||||
* Look for path on the face and add to paths
|
||||
*/
|
||||
void findPaths(
|
||||
Node *node[2], int leaf[2], int depth[2], int *st[2], int maxdep, int dir, PathList *&paths);
|
||||
void findPaths(Node *node[2],
|
||||
const int leaf[2],
|
||||
const int depth[2],
|
||||
int *st[2],
|
||||
int maxdep,
|
||||
int dir,
|
||||
PathList *&paths);
|
||||
/**
|
||||
* Combine two list1 and list2 into list1 using connecting paths list3,
|
||||
* while closed paths are appended to rings
|
||||
@@ -378,7 +380,7 @@ class Octree {
|
||||
PathList *&nrings2);
|
||||
Node *connectFace(Node *node, int st[3], int len, int dir, PathElement *f1, PathElement *f2);
|
||||
Node *locateCell(InternalNode *node,
|
||||
int st[3],
|
||||
const int st[3],
|
||||
int len,
|
||||
int ori[3],
|
||||
int dir,
|
||||
@@ -428,7 +430,7 @@ class Octree {
|
||||
/************************************************************************/
|
||||
void floodFill();
|
||||
void clearProcessBits(Node *node, int height);
|
||||
int floodFill(LeafNode *leaf, int st[3], int len, int height, int threshold);
|
||||
int floodFill(LeafNode *leaf, const int st[3], int len, int height, int threshold);
|
||||
int floodFill(Node *node, int st[3], int len, int height, int threshold);
|
||||
|
||||
/**
|
||||
@@ -444,8 +446,8 @@ class Octree {
|
||||
* op: 0 for counting, 1 for writing OBJ, 2 for writing OFF, 3 for writing PLY
|
||||
*/
|
||||
void cellProcContour(Node *node, int leaf, int depth);
|
||||
void faceProcContour(Node *node[2], int leaf[2], int depth[2], int maxdep, int dir);
|
||||
void edgeProcContour(Node *node[4], int leaf[4], int depth[4], int maxdep, int dir);
|
||||
void faceProcContour(Node *node[2], const int leaf[2], const int depth[2], int maxdep, int dir);
|
||||
void edgeProcContour(Node *node[4], const int leaf[4], int depth[4], int maxdep, int dir);
|
||||
void processEdgeWrite(Node *node[4], int depths[4], int maxdep, int dir);
|
||||
|
||||
/* output callbacks/data */
|
||||
@@ -454,7 +456,6 @@ class Octree {
|
||||
DualConAddQuad add_quad;
|
||||
void *output_mesh;
|
||||
|
||||
private:
|
||||
/************ Operators for all nodes ************/
|
||||
|
||||
/** Lookup table */
|
||||
@@ -491,16 +492,11 @@ class Octree {
|
||||
if (height == 0) {
|
||||
return getSign(&node->leaf, index);
|
||||
}
|
||||
else {
|
||||
if (node->internal.has_child(index)) {
|
||||
return getSign(
|
||||
node->internal.get_child(node->internal.get_child_count(index)), height - 1, index);
|
||||
}
|
||||
else {
|
||||
return getSign(
|
||||
node->internal.get_child(0), height - 1, 7 - node->internal.get_child_index(0));
|
||||
}
|
||||
if (node->internal.has_child(index)) {
|
||||
return getSign(
|
||||
node->internal.get_child(node->internal.get_child_count(index)), height - 1, index);
|
||||
}
|
||||
return getSign(node->internal.get_child(0), height - 1, 7 - node->internal.get_child_index(0));
|
||||
}
|
||||
|
||||
/************ Operators for leaf nodes ************/
|
||||
@@ -508,7 +504,7 @@ class Octree {
|
||||
void printInfo(int st[3])
|
||||
{
|
||||
printf("INFO AT: %d %d %d\n", st[0] >> minshift, st[1] >> minshift, st[2] >> minshift);
|
||||
LeafNode *leaf = (LeafNode *)locateLeafCheck(st);
|
||||
LeafNode *leaf = locateLeafCheck(st);
|
||||
if (leaf) {
|
||||
printInfo(leaf);
|
||||
}
|
||||
@@ -563,7 +559,7 @@ class Octree {
|
||||
return leaf->signs;
|
||||
}
|
||||
|
||||
void setInProcessAll(int st[3], int dir)
|
||||
void setInProcessAll(const int st[3], int dir)
|
||||
{
|
||||
int nst[3], eind;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@@ -579,7 +575,7 @@ class Octree {
|
||||
}
|
||||
}
|
||||
|
||||
void flipParityAll(int st[3], int dir)
|
||||
void flipParityAll(const int st[3], int dir)
|
||||
{
|
||||
int nst[3], eind;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@@ -615,7 +611,7 @@ class Octree {
|
||||
}
|
||||
|
||||
/** Generate signs at the corners from the edge parity */
|
||||
void generateSigns(LeafNode *leaf, unsigned char table[], int start)
|
||||
void generateSigns(LeafNode *leaf, const unsigned char table[], int start)
|
||||
{
|
||||
leaf->signs = table[leaf->edge_parity];
|
||||
|
||||
@@ -721,7 +717,7 @@ class Octree {
|
||||
}
|
||||
}
|
||||
|
||||
removeLeaf(num - 1, (LeafNode *)leaf);
|
||||
removeLeaf(num - 1, leaf);
|
||||
leaf = nleaf;
|
||||
}
|
||||
}
|
||||
@@ -776,9 +772,7 @@ class Octree {
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Retrieve number of edges intersected */
|
||||
@@ -819,7 +813,7 @@ class Octree {
|
||||
}
|
||||
|
||||
/** Set multiple edge intersections */
|
||||
void setEdgeOffsets(LeafNode *leaf, float pt[3], int len)
|
||||
void setEdgeOffsets(LeafNode *leaf, const float pt[3], int len)
|
||||
{
|
||||
float *pts = leaf->edge_intersections;
|
||||
for (int i = 0; i < len; i++) {
|
||||
@@ -917,7 +911,7 @@ class Octree {
|
||||
|
||||
/** Retrieve complete edge intersection */
|
||||
void getEdgeIntersectionByIndex(
|
||||
const LeafNode *leaf, int index, int st[3], int len, float pt[3], float nm[3]) const
|
||||
const LeafNode *leaf, int index, const int st[3], int len, float pt[3], float nm[3]) const
|
||||
{
|
||||
int count = getEdgeCount(leaf, index);
|
||||
const float *pts = leaf->edge_intersections;
|
||||
@@ -1041,7 +1035,7 @@ class Octree {
|
||||
// int nstt[3] = {0, 0, 0};
|
||||
// nstt[i] += 1;
|
||||
const LeafNode *node = locateLeafCheck(nst);
|
||||
if (node == NULL) {
|
||||
if (node == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1076,7 +1070,7 @@ class Octree {
|
||||
// int nstt[3] = {1, 1, 1};
|
||||
// nstt[i] -= 1;
|
||||
const LeafNode *node = locateLeafCheck(nst);
|
||||
if (node == NULL) {
|
||||
if (node == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1117,7 +1111,7 @@ class Octree {
|
||||
// int nstt[3] = {0, 0, 0};
|
||||
// nstt[i] += 1;
|
||||
LeafNode *node = locateLeafCheck(nst);
|
||||
if (node == NULL) {
|
||||
if (node == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1146,7 +1140,7 @@ class Octree {
|
||||
// int nstt[3] = {1, 1, 1};
|
||||
// nstt[i] -= 1;
|
||||
LeafNode *node = locateLeafCheck(nst);
|
||||
if (node == NULL) {
|
||||
if (node == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1179,9 +1173,9 @@ class Octree {
|
||||
* Locate a leaf
|
||||
* WARNING: assuming this leaf already exists!
|
||||
*/
|
||||
LeafNode *locateLeaf(int st[3])
|
||||
LeafNode *locateLeaf(const int st[3])
|
||||
{
|
||||
Node *node = (Node *)root;
|
||||
Node *node = root;
|
||||
for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) {
|
||||
int index = (((st[0] >> i) & 1) << 2) | (((st[1] >> i) & 1) << 1) | (((st[2] >> i) & 1));
|
||||
node = node->internal.get_child(node->internal.get_child_count(index));
|
||||
@@ -1190,7 +1184,7 @@ class Octree {
|
||||
return &node->leaf;
|
||||
}
|
||||
|
||||
const LeafNode *locateLeaf(int st[3]) const
|
||||
const LeafNode *locateLeaf(const int st[3]) const
|
||||
{
|
||||
const Node *node = root;
|
||||
for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) {
|
||||
@@ -1201,7 +1195,7 @@ class Octree {
|
||||
return &node->leaf;
|
||||
}
|
||||
|
||||
LeafNode *locateLeaf(InternalNode *parent, int len, int st[3])
|
||||
LeafNode *locateLeaf(InternalNode *parent, int len, const int st[3])
|
||||
{
|
||||
Node *node = (Node *)parent;
|
||||
int index;
|
||||
@@ -1213,13 +1207,13 @@ class Octree {
|
||||
return &node->leaf;
|
||||
}
|
||||
|
||||
LeafNode *locateLeafCheck(int st[3])
|
||||
LeafNode *locateLeafCheck(const int st[3])
|
||||
{
|
||||
Node *node = (Node *)root;
|
||||
Node *node = root;
|
||||
for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) {
|
||||
int index = (((st[0] >> i) & 1) << 2) | (((st[1] >> i) & 1) << 1) | (((st[2] >> i) & 1));
|
||||
if (!node->internal.has_child(index)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
node = node->internal.get_child(node->internal.get_child_count(index));
|
||||
}
|
||||
@@ -1227,13 +1221,13 @@ class Octree {
|
||||
return &node->leaf;
|
||||
}
|
||||
|
||||
const LeafNode *locateLeafCheck(int st[3]) const
|
||||
const LeafNode *locateLeafCheck(const int st[3]) const
|
||||
{
|
||||
const Node *node = root;
|
||||
for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) {
|
||||
int index = (((st[0] >> i) & 1) << 2) | (((st[1] >> i) & 1) << 1) | (((st[2] >> i) & 1));
|
||||
if (!node->internal.has_child(index)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
node = node->internal.get_child(node->internal.get_child_count(index));
|
||||
}
|
||||
@@ -1241,10 +1235,10 @@ class Octree {
|
||||
return &node->leaf;
|
||||
}
|
||||
|
||||
InternalNode *locateParent(int len, int st[3], int &count)
|
||||
InternalNode *locateParent(int len, const int st[3], int &count)
|
||||
{
|
||||
InternalNode *node = (InternalNode *)root;
|
||||
InternalNode *pre = NULL;
|
||||
InternalNode *pre = nullptr;
|
||||
int index = 0;
|
||||
for (int i = dimen / 2; i >= len; i >>= 1) {
|
||||
index = (((st[0] & i) ? 4 : 0) | ((st[1] & i) ? 2 : 0) | ((st[2] & i) ? 1 : 0));
|
||||
@@ -1256,10 +1250,10 @@ class Octree {
|
||||
return pre;
|
||||
}
|
||||
|
||||
InternalNode *locateParent(InternalNode *parent, int len, int st[3], int &count)
|
||||
InternalNode *locateParent(InternalNode *parent, int len, const int st[3], int &count)
|
||||
{
|
||||
InternalNode *node = parent;
|
||||
InternalNode *pre = NULL;
|
||||
InternalNode *pre = nullptr;
|
||||
int index = 0;
|
||||
for (int i = len / 2; i >= mindimen; i >>= 1) {
|
||||
index = (((st[0] & i) ? 4 : 0) | ((st[1] & i) ? 2 : 0) | ((st[2] & i) ? 1 : 0));
|
||||
|
||||
Reference in New Issue
Block a user