Revision: 71231 http://sourceforge.net/p/brlcad/code/71231 Author: starseeker Date: 2018-07-24 14:55:09 +0000 (Tue, 24 Jul 2018) Log Message: ----------- Back up the Screened Poisson mesh building code to r65516. The code appears to be in a compilable/runnable state in this revision, at least on Linux, which does not appear to be the case as of r66056 (what appears to be the last commit before work stalled.) Really need to refactor this into something easier for us to make use of...
Modified Paths: -------------- brlcad/trunk/CMakeLists.txt brlcad/trunk/include/rt/misc.h brlcad/trunk/src/librt/screened_poisson.cpp brlcad/trunk/src/other/PoissonRecon/CMakeLists.txt brlcad/trunk/src/other/PoissonRecon/LICENSE brlcad/trunk/src/other/PoissonRecon/Src/Allocator.h brlcad/trunk/src/other/PoissonRecon/Src/Array.h brlcad/trunk/src/other/PoissonRecon/Src/Array.inl brlcad/trunk/src/other/PoissonRecon/Src/BSplineData.h brlcad/trunk/src/other/PoissonRecon/Src/BSplineData.inl brlcad/trunk/src/other/PoissonRecon/Src/BinaryNode.h brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.cpp brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.h brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.inl brlcad/trunk/src/other/PoissonRecon/Src/Factor.cpp brlcad/trunk/src/other/PoissonRecon/Src/Factor.h brlcad/trunk/src/other/PoissonRecon/Src/FunctionData.h brlcad/trunk/src/other/PoissonRecon/Src/FunctionData.inl brlcad/trunk/src/other/PoissonRecon/Src/Geometry.cpp brlcad/trunk/src/other/PoissonRecon/Src/Geometry.h brlcad/trunk/src/other/PoissonRecon/Src/Geometry.inl brlcad/trunk/src/other/PoissonRecon/Src/Hash.h brlcad/trunk/src/other/PoissonRecon/Src/MAT.h brlcad/trunk/src/other/PoissonRecon/Src/MAT.inl brlcad/trunk/src/other/PoissonRecon/Src/MarchingCubes.cpp brlcad/trunk/src/other/PoissonRecon/Src/MarchingCubes.h brlcad/trunk/src/other/PoissonRecon/Src/MemoryUsage.h brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.IsoSurface.inl brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.SortedTreeNodes.inl brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.h brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.inl brlcad/trunk/src/other/PoissonRecon/Src/MyTime.h brlcad/trunk/src/other/PoissonRecon/Src/Octree.h brlcad/trunk/src/other/PoissonRecon/Src/Octree.inl brlcad/trunk/src/other/PoissonRecon/Src/PPolynomial.h brlcad/trunk/src/other/PoissonRecon/Src/PPolynomial.inl brlcad/trunk/src/other/PoissonRecon/Src/Ply.h brlcad/trunk/src/other/PoissonRecon/Src/PlyFile.cpp brlcad/trunk/src/other/PoissonRecon/Src/PointStream.h brlcad/trunk/src/other/PoissonRecon/Src/PointStream.inl brlcad/trunk/src/other/PoissonRecon/Src/PoissonRecon.cpp brlcad/trunk/src/other/PoissonRecon/Src/Polynomial.h brlcad/trunk/src/other/PoissonRecon/Src/Polynomial.inl brlcad/trunk/src/other/PoissonRecon/Src/SPR.cpp brlcad/trunk/src/other/PoissonRecon/Src/SPR.h brlcad/trunk/src/other/PoissonRecon/Src/SparseMatrix.h brlcad/trunk/src/other/PoissonRecon/Src/SparseMatrix.inl brlcad/trunk/src/other/PoissonRecon/Src/SurfaceTrimmer.cpp brlcad/trunk/src/other/PoissonRecon/Src/Vector.h brlcad/trunk/src/other/PoissonRecon/Src/Vector.inl brlcad/trunk/src/other/PoissonRecon.dist Removed Paths: ------------- brlcad/trunk/src/other/PoissonRecon/Src/PoissonRecon_new.cpp Modified: brlcad/trunk/CMakeLists.txt =================================================================== --- brlcad/trunk/CMakeLists.txt 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/CMakeLists.txt 2018-07-24 14:55:09 UTC (rev 71231) @@ -1362,7 +1362,7 @@ endif(BRLCAD_ENABLE_OPENCL) # Enable features requiring Screened Poisson Surface Reconstruction -option(BRLCAD_ENABLE_SPR "Enable features requiring Screened Poisson Surface Reconstruction" OFF) +option(BRLCAD_ENABLE_SPR "Enable features requiring Screened Poisson Surface Reconstruction" ON) mark_as_advanced(BRLCAD_ENABLE_SPR) # Enable experimental support for binary attributes Modified: brlcad/trunk/include/rt/misc.h =================================================================== --- brlcad/trunk/include/rt/misc.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/include/rt/misc.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -58,9 +58,8 @@ * change */ RT_EXPORT void rt_generate_mesh(int **faces, int *num_faces, point_t **points, int *num_pnts, - struct db_i *dbip, const char *obj, int fidelity); + struct db_i *dbip, const char *obj, fastf_t delta); - /** * reduce an object into some form of simpler representation */ Modified: brlcad/trunk/src/librt/screened_poisson.cpp =================================================================== --- brlcad/trunk/src/librt/screened_poisson.cpp 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/librt/screened_poisson.cpp 2018-07-24 14:55:09 UTC (rev 71231) @@ -1,7 +1,7 @@ /* S C R E E N E D _ P O I S S O N . C P P * BRL-CAD * - * Copyright (c) 2015-2018 United States Government as represented by + * Copyright (c) 2015 United States Government as represented by * the U.S. Army Research Laboratory. * * This library is free software; you can redistribute it and/or @@ -24,8 +24,6 @@ */ #include "common.h" -#ifdef ENABLE_SPR - #include "vmath.h" #include "raytrace.h" #include "../other/PoissonRecon/Src/SPR.h" @@ -34,35 +32,18 @@ struct rt_vert { point_t p; vect_t n; - char *solid_name; - long solid_surfno; int is_set; }; struct npoints { - struct rt_vert in; /* IN */ - struct rt_vert out; /* OUT */ + struct rt_vert in; + struct rt_vert out; }; -struct rt_ray_container { - point_t p; /* ray starting point */ - vect_t d; /* direction vector */ - int x, y; /* indexes into 2D array of the current view */ - - struct npoints *pts; /* list of points along this ray */ - int pnt_cnt; - int pnt_capacity; -}; - struct rt_point_container { - struct rt_ray_container *rays; /* list of rays for this cpu - * along the current view */ - int ray_cnt; - int ray_capacity; - - struct npoints *pts; /* overall point array for this cpu */ + struct npoints *pts; int pnt_cnt; - int pnt_capacity; + int capacity; }; struct rt_parallel_container { @@ -71,17 +52,8 @@ struct bu_vls *logs; struct rt_point_container *npts; int ray_dir; - - /* stuff needed for subdividing among cpus */ - fastf_t spacing[3]; - point_t model_min; - point_t model_max; - fastf_t model_span[3]; - fastf_t per_cpu_slab_width[3]; - - /* edge sampling flags */ - int do_subsample; - int sub_division; + int ncpus; + fastf_t delta; }; /* add all hit point info to info list */ @@ -88,40 +60,28 @@ HIDDEN int add_hit_pnts(struct application *app, struct partition *partH, struct seg *UNUSED(segs)) { - /* iterating over partitions, this will keep track of the current - * partition we're working on. */ + struct partition *pp; - - /* will serve as a pointer for the entry and exit hitpoints */ - struct hit *hitp; - - /* will serve as a pointer to the solid primitive we hit */ struct soltab *stp; - - /* ray container and current points for this segment */ - struct rt_ray_container *c = (struct rt_ray_container *)(app->a_uptr); + /*point_t hit_pnt; + vect_t hit_normal;*/ + struct rt_point_container *c = (struct rt_point_container *)(app->a_uptr); struct npoints *npt; + if (c->pnt_cnt > c->capacity-1) { + c->capacity *= 4; + c->pts = (struct npoints *)bu_realloc((char *)c->pts, c->capacity * sizeof(struct npoints), "enlarge results array"); + } + RT_CK_APPLICATION(app); + /*struct bu_vls *fp = (struct bu_vls *)(app->a_uptr);*/ - /* iterate over each partition until we get back to the head. - * each partition corresponds to a specific homogeneous region of - * material. */ + /* add all hit points */ for (pp = partH->pt_forw; pp != partH; pp = pp->pt_forw) { - /* need to see if enough space is allocate to hold the data */ - if (c->pnt_cnt > c->pnt_capacity-1) { - c->pnt_capacity *= 4; - c->pts = (struct npoints *)bu_realloc((char *)c->pts, c->pnt_capacity * sizeof(struct npoints), "enlarge results array"); - } - - /* pointer to the next set of in/out to save */ npt = &(c->pts[c->pnt_cnt]); - /* entry hit point, so we type less */ - hitp = pp->pt_inhit; - - /* primitive we encountered on entry */ + /* add "in" hit point info */ stp = pp->pt_inseg->seg_stp; /* hack fix for bad tgc surfaces */ @@ -136,40 +96,19 @@ } } - /* record IN hit point */ - VJOIN1(npt->in.p, app->a_ray.r_pt, hitp->hit_dist, app->a_ray.r_dir); - /* calculate IN normal vector */ - RT_HIT_NORMAL(npt->in.n, hitp, stp, &(app->a_ray), pp->pt_inflip); - - /* save IN solid and surface number */ - npt->in.solid_name = bu_strdup(stp->st_dp->d_namep); - npt->in.solid_surfno = hitp->hit_surfno; - - /* flag IN point as set */ + VJOIN1(npt->in.p, app->a_ray.r_pt, pp->pt_inhit->hit_dist, app->a_ray.r_dir); + RT_HIT_NORMAL(npt->in.n, pp->pt_inhit, stp, &(app->a_ray), pp->pt_inflip); npt->in.is_set = 1; - //bu_vls_printf(fp, "%f %f %f %f %f %f\n", hit_pnt[0], hit_pnt[1], hit_pnt[2], hit_normal[0], hit_normal[1], hit_normal[2]); - - /* exit point, so we type less */ - hitp = pp->pt_outhit; - - /* primitive we exited from */ - stp = pp->pt_outseg->seg_stp; - - /* record OUT hit point */ - VJOIN1(npt->out.p, app->a_ray.r_pt, hitp->hit_dist, app->a_ray.r_dir); - - /* calculate OUT normal vector */ - RT_HIT_NORMAL(npt->out.n, hitp, stp, &(app->a_ray), pp->pt_outflip); - - /* save OUT solid and surface number */ - npt->out.solid_name = bu_strdup(stp->st_dp->d_namep); - npt->out.solid_surfno = hitp->hit_surfno; - - /* flag OUT point as set */ - npt->out.is_set = 1; - + /* add "out" hit point info (unless half-space) */ + stp = pp->pt_inseg->seg_stp; + if (bu_strncmp("half", stp->st_meth->ft_label, 4) != 0) { + VJOIN1(npt->out.p, app->a_ray.r_pt, pp->pt_outhit->hit_dist, app->a_ray.r_dir); + RT_HIT_NORMAL(npt->out.n, pp->pt_outhit, stp, &(app->a_ray), pp->pt_outflip); + npt->out.is_set = 1; + //bu_vls_printf(fp, "%f %f %f %f %f %f\n", hit_pnt[0], hit_pnt[1], hit_pnt[2], hit_normal[0], hit_normal[1], hit_normal[2]); + } c->pnt_cnt++; } return 1; @@ -185,191 +124,16 @@ } void -copy_ray_points_to_list(struct rt_point_container *cont, - struct rt_ray_container *ray) -{ - int i; - - for (i = 0; i < ray->pnt_cnt; i++) { - /* increase space if necessary */ - if (cont->pnt_cnt > cont->pnt_capacity-1) { - cont->pnt_capacity *= 4; - cont->pts = (struct npoints *)bu_realloc((char *)cont->pts, cont->pnt_capacity * sizeof(struct npoints), "enlarge cpu npoints array"); - } - - /* copy from ray into overall results array */ - memcpy(&(cont->pts[cont->pnt_cnt]), &(ray->pts[i]), sizeof(struct npoints)); - cont->pnt_cnt++; - } -} - -/* checks to see if the results of 2 rays are different */ -/* 1 = different, 0 = same */ -int -ray_results_differ(struct rt_ray_container *prevRay, - struct rt_ray_container *currRay) -{ - /* if the list sizes differ that is a dead give-away */ - if (prevRay->pnt_cnt != currRay->pnt_cnt) - return 1; - - /* they are the same size, walk them */ - for (int i=0; i < prevRay->pnt_cnt; i++) { - struct npoints *prevPt = &(prevRay->pts[i]); - struct npoints *currPt = &(currRay->pts[i]); - - if ((prevPt->in.is_set != currPt->in.is_set) || - (prevPt->out.is_set != currPt->out.is_set)) - return 1; - - if ((prevPt->in.solid_surfno != currPt->in.solid_surfno) || - (prevPt->out.solid_surfno != currPt->out.solid_surfno)) - return 1; - - if (bu_strcmp(prevPt->in.solid_name, currPt->in.solid_name) || - bu_strcmp(prevPt->out.solid_name, currPt->out.solid_name)) - return 1; - } - - return 0; -} - -void -sub_sample(struct rt_parallel_container *state, - struct rt_ray_container *prevRay, - struct rt_ray_container *currRay, - struct rt_point_container *pcont, - const int depth, int cpu) -{ - struct application ap; - struct rt_ray_container middle_ray; - - if (depth >= state->sub_division) return; - - /* init raytracer */ - RT_APPLICATION_INIT(&ap); - ap.a_rt_i = state->rtip; - ap.a_hit = add_hit_pnts; - ap.a_miss = ignore_miss; - ap.a_onehit = 0; - ap.a_logoverlap = rt_silent_logoverlap; - ap.a_resource = &state->resp[cpu-1]; - - /* init ray */ - VADD2(middle_ray.p, currRay->p, prevRay->p); - VSCALE(middle_ray.p, middle_ray.p, 0.5); - VMOVE(middle_ray.d, currRay->d); - middle_ray.x = -1; /* note that this is a sub-sample ray */ - middle_ray.y = -1; - VMOVE(ap.a_ray.r_pt, middle_ray.p); - VMOVE(ap.a_ray.r_dir, middle_ray.d); - int total_pts = 1e3; /* allocate enough space to hold 1e3 segments along this ray - * (probably overkill) */ - middle_ray.pts = (struct npoints *)bu_calloc(total_pts, sizeof(struct npoints), "subray npoints array"); - middle_ray.pnt_cnt = 0; - middle_ray.pnt_capacity = total_pts; - ap.a_uptr = (void *) &middle_ray; - - rt_shootray(&ap); /* shoot the ray */ - - int diffLeft = ray_results_differ(prevRay, &middle_ray); - int diffRight = ray_results_differ(&middle_ray, currRay); - - /* NOTE: There should be a way to check and see if we do or don't need points for this ray - * In previous PointSampler code of GCT we wouldn't keep points that did not provide - * new value as to limit the # of points we were dealing with. Right now we go ahead and - * save them because it is not hurting us and is easier */ -#if 0 - if (diffLeft && diffRight) { - /* sample the the left and right of the middle ray */ - sub_sample(state, prevRay, &middle_ray, pcont, depth+1, cpu); - sub_sample(state, &middle_ray, currRay, pcont, depth+1, cpu); - copy_ray_points_to_list(pcont, &middle_ray); /* store these points right to the main list */ - } else if (diffLeft) { - sub_sample(state, prevRay, &middle_ray, pcont, depth+1, cpu); - /*XXX need to to match checking for unneeded points */ - copy_ray_points_to_list(pcont, &middle_ray); /* store these points right to the main list */ - } else if (diffRight) { - sub_sample(state, &middle_ray, currRay, pcont, depth+1, cpu); - /*XXX need to to match checking for unneeded points */ - copy_ray_points_to_list(pcont, &middle_ray); /* store these points right to the main list */ - } -#else - copy_ray_points_to_list(pcont, &middle_ray); /* store these points right to the main list */ - - if (diffLeft) { - /* if the previous ray differs from this "middle" ray then look between it and the middle */ - sub_sample(state, prevRay, &middle_ray, pcont, depth+1, cpu); - } - - if (diffRight) { - /* if the current ray differs from this "middle" ray then look between it and the middle */ - sub_sample(state, &middle_ray, currRay, pcont, depth+1, cpu); - } -#endif - - bu_free(middle_ray.pts, "subray npoints array"); -} - -void -check_subsample(int cpu, int j, - struct rt_parallel_container *state, - struct rt_ray_container *prevRay, - struct rt_ray_container *currRay, - struct rt_point_container *pcont) -{ - /* look to see if we crossed a physical boundary - * along the i_axis and should sub-sample */ - if (ray_results_differ(prevRay, currRay)) { - sub_sample(state, prevRay, currRay, pcont, 0, cpu); - } - - /* look to see if we crossed a physical boundary - * along the j_axis and should sub-sample */ - if (j == 0) return; - - /* look backwards for matching x,y-1 entry */ - for (int l = pcont->ray_cnt-1; l >= 0; l--) { - struct rt_ray_container *lower = &(pcont->rays[l]); - if (lower->x == currRay->x && lower->y == (currRay->y -1)) { - /* found it */ - if (ray_results_differ(lower, currRay)) { - sub_sample(state, lower, currRay, pcont, 0, cpu); - } - - /* sample diagonally */ - if (ray_results_differ(prevRay, lower)) { - sub_sample(state, prevRay, lower, pcont, 0, cpu); - } - - /* now go looking back for the x-1,y-1 entry - * so we can sample along the other diagonal */ - for (int d = pcont->ray_cnt-1; d >= 0; d--) { - struct rt_ray_container *diag = &(pcont->rays[d]); - if (diag->x == (currRay->x -1) && diag->y == (currRay->y -1)) { - /* found it */ - if (ray_results_differ(diag, currRay)) { - sub_sample(state, diag, currRay, pcont, 0, cpu); - } - - break; - } /* found x-1, y-1 */ - } - break; - } /* found x, y-1 */ - } -} - -void _rt_gen_worker(int cpu, void *ptr) { int i, j; struct application ap; struct rt_parallel_container *state = (struct rt_parallel_container *)ptr; - struct rt_point_container *pcont = (struct rt_point_container *)(&state->npts[cpu-1]); - struct rt_ray_container *prevRay; - struct rt_ray_container *currRay; + point_t min, max; + int ymin, ymax; int dir1, dir2, dir3; + fastf_t d[3]; + int n[3]; RT_APPLICATION_INIT(&ap); ap.a_rt_i = state->rtip; ap.a_hit = add_hit_pnts; @@ -376,98 +140,57 @@ ap.a_miss = ignore_miss; ap.a_onehit = 0; ap.a_logoverlap = rt_silent_logoverlap; - ap.a_resource = &state->resp[cpu-1]; + ap.a_resource = &state->resp[cpu]; + ap.a_uptr = (void *)(&state->npts[cpu]); - /* allocate enough space for this view to hold 1e4 number of rays - * (probably overkill) */ - int total_rays = 1e4; - pcont->rays = (struct rt_ray_container *)bu_calloc(total_rays, sizeof(struct rt_ray_container), "cpu ray container array"); - pcont->ray_cnt = 0; - pcont->ray_capacity = total_rays; + /* get min and max points of bounding box */ + VMOVE(min, state->rtip->mdl_min); + VMOVE(max, state->rtip->mdl_max); + /* Make sure we've got at least 10 steps in all 3 dimensions, + * regardless of delta */ + for (i = 0; i < 3; i++) { + n[i] = (max[i] - min[i])/state->delta; + if(n[i] < 10) n[i] = 10; + d[i] = (max[i] - min[i])/n[i]; + } + dir1 = state->ray_dir; - dir2 = (state->ray_dir+1)%3; /* axis we step between rays */ - dir3 = (state->ray_dir+2)%3; /* the slab axis */ + dir2 = (state->ray_dir+1)%3; + dir3 = (state->ray_dir+2)%3; - /* set ray direction */ - ap.a_ray.r_dir[dir1] = 1; + if (state->ncpus == 1) { + ymin = 0; + ymax = n[dir3]; + } else { + ymin = n[dir3]/state->ncpus * (cpu - 1) + 1; + ymax = n[dir3]/state->ncpus * (cpu); + if (cpu == 1) ymin = 0; + if (cpu == state->ncpus) ymax = n[dir3]; + } + + ap.a_ray.r_dir[dir1] = -1; ap.a_ray.r_dir[dir2] = 0; ap.a_ray.r_dir[dir3] = 0; + VMOVE(ap.a_ray.r_pt, min); + ap.a_ray.r_pt[dir1] = max[dir1] + 100; - ap.a_ray.r_pt[dir1] = state->model_min[dir1] -100; - double slabBottom = (cpu - 1) * state->per_cpu_slab_width[dir3]; - double slabTop = cpu * state->per_cpu_slab_width[dir3]; - - int slabStartLN = ceil(slabBottom / state->spacing[dir3]); - int slabEndLN = ceil(slabTop / state->spacing[dir3]); - - for (j = slabStartLN; j <= slabEndLN; j++) { - ap.a_ray.r_pt[dir3] = state->model_min[dir3] + (j * state->spacing[dir3]); - - prevRay = NULL; /* reset previous ray */ - - int iAxisSteps = ceil(state->model_span[dir2] / state->spacing[dir2]); - for (i = 0; i <= iAxisSteps; i++) { - ap.a_ray.r_pt[dir2] = state->model_min[dir2] + (i * state->spacing[dir2]); - - /* expand ray array if necessary */ - if (pcont->ray_cnt > pcont->ray_capacity-1) { - pcont->ray_capacity *= 4; - pcont->rays = (struct rt_ray_container *)bu_realloc((char *)pcont->rays, pcont->ray_capacity * sizeof(struct rt_ray_container), "enlarge ray array"); - } - - /* set current ray info */ - currRay = &(pcont->rays[pcont->ray_cnt]); - VMOVE(currRay->p, ap.a_ray.r_pt); - VMOVE(currRay->d, ap.a_ray.r_dir); - currRay->x = i; - currRay->y = j; - - /* allocate enough space to hold 1e3 segments along this ray - * (probably overkill) */ - int total_pts = 1e3; - currRay->pts = (struct npoints *)bu_calloc(total_pts, sizeof(struct npoints), "ray npoints array"); - currRay->pnt_cnt = 0; - currRay->pnt_capacity = total_pts; - ap.a_uptr = (void *)currRay; - - /* fire the ray */ + for (i = 0; i < n[dir2]; i++) { + ap.a_ray.r_pt[dir3] = min[dir3] + d[dir3] * ymin; + for (j = ymin; j < ymax; j++) { rt_shootray(&ap); - pcont->ray_cnt++; - - if (state->do_subsample && state->sub_division > 0) { - if (i > 0) { - check_subsample(cpu, j, state, currRay, prevRay, pcont); - } - } - - prevRay = currRay; + ap.a_ray.r_pt[dir3] += d[dir3]; } + ap.a_ray.r_pt[dir2] += d[dir2]; } - - /* done all the rays for this view ... need to copy all the results - * to the main storage array */ - for (i = 0; i < pcont->ray_cnt; i++) { - currRay = &(pcont->rays[i]); - copy_ray_points_to_list(pcont, currRay); - - /* we can free the current ray's points because they've been copied */ - /* NOTE: no need to free the 'solid_name' for each point because the memory - * address was copied to the main result array and will be freed later */ - bu_free(currRay->pts, "ray npoints array"); - } - - /* free memory for the rays of this view */ - bu_free(pcont->rays, "cpu ray container array"); - pcont->rays = NULL; - pcont->ray_cnt = 0; } HIDDEN int -_rt_generate_points(int **faces, int *num_faces, point_t **points, int *num_pnts, struct bu_ptbl *hit_pnts, struct db_i *dbip, const char *obj, int fidelity) +_rt_generate_points(int **faces, int *num_faces, point_t **points, int *num_pnts, struct bu_ptbl *hit_pnts, struct db_i *dbip, const char *obj, fastf_t delta) { int i, dir1, j; + point_t min, max; int ncpus = bu_avail_cpus(); struct rt_parallel_container *state; struct bu_vls vlsstr; @@ -478,89 +201,42 @@ BU_GET(state, struct rt_parallel_container); state->rtip = rt_new_rti(dbip); + state->delta = delta; - /* load geometry object */ if (rt_gettree(state->rtip, obj) < 0) return -1; rt_prep_parallel(state->rtip, 1); - /* initialize all the per-CPU resources that are going to be used */ - state->resp = (struct resource *)bu_calloc(ncpus, sizeof(struct resource), "resources"); - for (i = 0; i < ncpus; i++) { + state->resp = (struct resource *)bu_calloc(ncpus+1, sizeof(struct resource), "resources"); + for (i = 0; i < ncpus+1; i++) { rt_init_resource(&(state->resp[i]), i, state->rtip); } - /* allocate storage for each of the cpus */ - state->npts = (struct rt_point_container *)bu_calloc(ncpus, sizeof(struct rt_point_container), "cpu point container arrays"); - - /* get min and max points of bounding box */ - VMOVE(state->model_min, state->rtip->mdl_min); - VMOVE(state->model_max, state->rtip->mdl_max); - VSUB2(state->model_span, state->model_max, state->model_min); - - state->do_subsample = 1; /* flag to turn on sub-sampling */ - - /* set spacing based on element width & fidelity */ - /* sub_division = # of recursive jumps */ - switch (fidelity) { - case 0: - state->sub_division = 2; - for (i = 0; i < 3; i++) { - state->spacing[i] = state->model_span[i] / 10.0; /* 10 sections on each side */ - } - break; - - case 1: - state->sub_division = 4; - for (i = 0; i < 3; i++) { - state->spacing[i] = state->model_span[i] / 12.0; /* 12 sections on each side */ - } - break; - - case 2: - { - fastf_t width = INFINITY; - - state->sub_division = 6; - for (i = 0; i < 3; i++) { - if (state->model_span[i] < width) - width = state->model_span[i]; - } - for (i = 0; i < 3; i++) { - state->spacing[i] = width / 15.0; /* at least 15 sections based on the SMALLEST side */ - } - } - break; - - default: - bu_log("Unknown fidelity: %d\n", fidelity); - /*XXX should probably free memory */ - return 1; - break; - } - + state->npts = (struct rt_point_container *)bu_calloc(ncpus+1, sizeof(struct rt_point_container), "point container arrays"); + int n[3]; + VMOVE(min, state->rtip->mdl_min); + VMOVE(max, state->rtip->mdl_max); for (i = 0; i < 3; i++) { - state->per_cpu_slab_width[i] = state->model_span[i] / ncpus; + n[i] = (int)((max[i] - min[i])/state->delta) + 2; + if(n[i] < 12) n[i] = 12; } - - - /* allocate enough space for each cpu to hold 1e6 number of points - * (probably overkill) */ - int total_pts = 1e6; - for (i = 0; i < ncpus; i++) { - state->npts[i].pts = (struct npoints *)bu_calloc(total_pts, sizeof(struct npoints), "cpu npoints array"); + int total = 0; + for (i = 0; i < 3; i++) total += n[i]*n[(i+1)%3]; + if (total > 1e6) total = 1e6; + for (i = 0; i < ncpus+1; i++) { + state->npts[i].pts = (struct npoints *)bu_calloc(total, sizeof(struct npoints), "npoints arrays"); state->npts[i].pnt_cnt = 0; - state->npts[i].pnt_capacity = total_pts; + state->npts[i].capacity = total; } - /* perform raytracing from the 3 views */ for (dir1 = 0; dir1 < 3; dir1++) { state->ray_dir = dir1; + state->ncpus = ncpus; + state->delta = delta; bu_parallel(_rt_gen_worker, ncpus, (void *)state); } - /* count the number of points */ int out_cnt = 0; - for (i = 0; i < ncpus; i++) { + for (i = 0; i < ncpus+1; i++) { bu_log("%d, pnt_cnt: %d\n", i, state->npts[i].pnt_cnt); for (j = 0; j < state->npts[i].pnt_cnt; j++) { struct npoints *npt = &(state->npts[i].pts[j]); @@ -571,10 +247,9 @@ if (!out_cnt) return 1; - /* store points */ struct rt_vert **rt_verts = (struct rt_vert **)bu_calloc(out_cnt, sizeof(struct rt_vert *), "output array"); int curr_ind = 0; - for (i = 0; i < ncpus; i++) { + for (i = 0; i < ncpus+1; i++) { for (j = 0; j < state->npts[i].pnt_cnt; j++) { struct npoints *npt = &(state->npts[i].pts[j]); if (npt->in.is_set) { @@ -588,47 +263,29 @@ } } - /* perform SPR algorithm */ - (void)spr_surface_build(faces, num_faces, (double **)points, num_pnts, - (const struct cvertex **)rt_verts, out_cnt, fidelity); + struct spr_options opts = SPR_OPTIONS_DEFAULT_INIT; + (void)spr_surface_build(faces, num_faces, (double **)points, num_pnts, (const struct cvertex **)rt_verts, out_cnt, &opts); - /* free memory */ - bu_free(rt_verts, "output array"); - rt_verts = NULL; - for (i = 0; i < ncpus; i++) { - for (j = 0; j < state->npts[i].pnt_cnt; j++) { - struct npoints *npt = &(state->npts[i].pts[j]); - if (npt->in.is_set) bu_free(npt->in.solid_name, "solid name"); - if (npt->out.is_set) bu_free(npt->out.solid_name, "solid number"); - } - bu_free(state->npts[i].pts, "npoints arrays"); - } - bu_free(state->npts, "point container arrays"); - bu_free(state->resp, "resources"); - BU_PUT(state, struct rt_parallel_container); - state = NULL; - return 0; } extern "C" void rt_generate_mesh(int **faces, int *num_faces, point_t **points, int *num_pnts, - struct db_i *dbip, const char *obj, int fidelity) + struct db_i *dbip, const char *obj, fastf_t delta) { + fastf_t d = delta; struct bu_ptbl *hit_pnts; if (!faces || !num_faces || !points || !num_pnts) return; if (!dbip || !obj) return; BU_GET(hit_pnts, struct bu_ptbl); bu_ptbl_init(hit_pnts, 64, "hit pnts"); - if (_rt_generate_points(faces, num_faces, points, num_pnts, hit_pnts, dbip, obj, fidelity)) { + if (NEAR_ZERO(d, SMALL_FASTF)) d = 1; + if (_rt_generate_points(faces, num_faces, points, num_pnts, hit_pnts, dbip, obj, d)) { (*num_faces) = 0; (*num_pnts) = 0; return; } } - -#endif - // Local Variables: // tab-width: 8 // mode: C++ Modified: brlcad/trunk/src/other/PoissonRecon/CMakeLists.txt =================================================================== --- brlcad/trunk/src/other/PoissonRecon/CMakeLists.txt 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/CMakeLists.txt 2018-07-24 14:55:09 UTC (rev 71231) @@ -87,11 +87,6 @@ Src/Factor.cpp Src/Geometry.cpp Src/MarchingCubes.cpp ) -# add_executable(PoissonRecon -# Src/CmdLineParser.cpp Src/PlyFile.cpp Src/PoissonRecon.cpp -# Src/Factor.cpp Src/Geometry.cpp Src/MarchingCubes.cpp Src/SPR.cpp -# ) - add_executable(SurfaceTrimmer Src/CmdLineParser.cpp Src/PlyFile.cpp Src/SurfaceTrimmer.cpp Src/Factor.cpp Src/Geometry.cpp Src/MarchingCubes.cpp Modified: brlcad/trunk/src/other/PoissonRecon/LICENSE =================================================================== --- brlcad/trunk/src/other/PoissonRecon/LICENSE 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/LICENSE 2018-07-24 14:55:09 UTC (rev 71231) @@ -1,22 +1,25 @@ -The MIT License (MIT) +Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho +All rights reserved. -Copyright (c) 2015 mkazhdan +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the distribution. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +Neither the name of the Johns Hopkins University nor the names of its contributors +may be used to endorse or promote products derived from this software without specific +prior written permission. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. Modified: brlcad/trunk/src/other/PoissonRecon/Src/Allocator.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/Allocator.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/Allocator.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -124,7 +124,7 @@ } } - /** This method initiallizes the constructor and the blockSize variable specifies the + /** This method initializes the constructor and the blockSize variable specifies the * the number of objects that should be pre-allocated at a time. */ void set( int blockSize) { Modified: brlcad/trunk/src/other/PoissonRecon/Src/Array.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/Array.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/Array.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -43,7 +43,7 @@ #endif // _WIN64 // Code from http://stackoverflow.com -inline void* aligned_malloc( size_t size , size_t align ) +void* aligned_malloc( size_t size , size_t align ) { // Align enough for the data, the alignment padding, and room to store a pointer to the actual start of the memory void* mem = malloc( size + align + sizeof( void* ) ); @@ -55,7 +55,7 @@ ( ( void** ) amem )[-1] = mem; return amem; } -inline void aligned_free( void* mem ) { free( ( ( void** )mem )[-1] ); } +void aligned_free( void* mem ) { free( ( ( void** )mem )[-1] ); } #if ARRAY_DEBUG #pragma message ( "[WARNING] Array debugging is enabled" ) @@ -62,7 +62,6 @@ #include "Array.inl" #define Pointer( ... ) Array< __VA_ARGS__ > #define ConstPointer( ... ) ConstArray< __VA_ARGS__ > -#define NullPointer( ... ) Array< __VA_ARGS__ >() template< class C > void FreePointer( Array< C >& a ){ a.Free( ); } template< class C > void AlignedFreePointer( Array< C >& a ){ a.Free( ); } template< class C > void VFreePointer( Array< C >& a ){ a.Free( ); } @@ -73,7 +72,7 @@ template< class C > Array< C > AlignedAllocPointer( size_t size , size_t alignment , const char* name=NULL ){ return Array< C >::AlignedAlloc( size , alignment , false , name ); } template< class C > Array< C > ReAllocPointer( Array< C >& a , size_t size , const char* name=NULL ){ return Array< C >::ReAlloc ( a , size , false , name ); } -//template< class C > Array< C > NullPointer( void ){ return Array< C >( ); } +template< class C > Array< C > NullPointer( void ){ return Array< C >( ); } template< class C > C* PointerAddress( Array< C >& a ) { return a.pointer(); } template< class C > const C* PointerAddress( ConstArray< C >& a ) { return a.pointer(); } @@ -85,7 +84,6 @@ #else // !ARRAY_DEBUG #define Pointer( ... ) __VA_ARGS__* #define ConstPointer( ... ) const __VA_ARGS__* -#define NullPointer( ... ) NULL #define FreePointer( ... ) { if( __VA_ARGS__ ) free( __VA_ARGS__ ) , __VA_ARGS__ = NULL; } #define AlignedFreePointer( ... ) { if( __VA_ARGS__ ) aligned_free( __VA_ARGS__ ) , __VA_ARGS__ = NULL; } @@ -96,7 +94,7 @@ template< class C > C* AlignedAllocPointer( size_t size , size_t alignment , const char* name=NULL ){ return (C*)aligned_malloc( sizeof(C) * size , alignment ); } template< class C > C* ReAllocPointer( C* c , size_t size , const char* name=NULL ){ return (C*) realloc( c , sizeof(C) * size ); } -//template< class C > C* NullPointer( void ){ return NULL; } +template< class C > C* NullPointer( void ){ return NULL; } template< class C > C* PointerAddress( C* c ){ return c; } template< class C > const C* PointerAddress( const C* c ){ return c; } Modified: brlcad/trunk/src/other/PoissonRecon/Src/Array.inl =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/Array.inl 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/Array.inl 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -185,7 +185,7 @@ } else { - // [WARNING] Chaning szC and szD to size_t causes some really strange behavior. + // [WARNING] Changing szC and szD to size_t causes some really strange behavior. long long szC = sizeof( C ); long long szD = sizeof( D ); data = (C*)&a[0]; @@ -396,7 +396,7 @@ template< class D > inline ConstArray( const ConstArray< D >& a ) { - // [WARNING] Chaning szC and szD to size_t causes some really strange behavior. + // [WARNING] Changing szC and szD to size_t causes some really strange behavior. long long szC = sizeof( C ); long long szD = sizeof( D ); data = ( const C*)a.pointer( ); Modified: brlcad/trunk/src/other/PoissonRecon/Src/BSplineData.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/BSplineData.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/BSplineData.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -188,4 +188,4 @@ template< int Degree1 , int Degree2 > void SetBSplineElementIntegrals( double integrals[Degree1+1][Degree2+1] ); #include "BSplineData.inl" -#endif // BSPLINE_DATA_INCLUDED \ No newline at end of file +#endif // BSPLINE_DATA_INCLUDED Modified: brlcad/trunk/src/other/PoissonRecon/Src/BSplineData.inl =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/BSplineData.inl 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/BSplineData.inl 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -183,7 +183,7 @@ template< int Degree > void BSplineData< Degree >::set( int maxDepth , int boundaryType ) { - _boundaryType = boundaryType>0 ? 1 : ( boundaryType<0 ? -1 : 0 ); + _boundaryType = boundaryType; depth = maxDepth; // [Warning] This assumes that the functions spacing is dual @@ -378,17 +378,17 @@ template< class Real > BSplineData< Degree >::DotTables< Real >::DotTables( void ) { - vvDotTable = NullPointer( Real ); - dvDotTable = NullPointer( Real ); - ddDotTable = NullPointer( Real ); + vvDotTable = NullPointer< Real >(); + dvDotTable = NullPointer< Real >(); + ddDotTable = NullPointer< Real >(); } template< int Degree > template< class Real > BSplineData< Degree >::DotTables< Real >::~DotTables( void ) { - DeletePointer( vvDotTable ); - DeletePointer( dvDotTable ); - DeletePointer( ddDotTable ); + DeletePointer( vvDotTable ); + DeletePointer( dvDotTable ); + DeletePointer( ddDotTable ); } template< int Degree > template< class Real > @@ -533,15 +533,15 @@ template< class Real > BSplineData< Degree >::ValueTables< Real >::ValueTables( void ) { - valueTable = NullPointer( Real ); - dValueTable = NullPointer( Real ); + valueTable = NullPointer< Real >(); + dValueTable = NullPointer< Real >(); } template< int Degree > template< class Real > BSplineData< Degree >::ValueTables< Real >::~ValueTables( void ) { - DeletePointer( valueTable ); - DeletePointer( dValueTable ); + DeletePointer( valueTable ); + DeletePointer( dValueTable ); } template< int Degree > template< class Real > @@ -643,13 +643,13 @@ if( set ) _addRight( offset+2*res , boundary ); } template< int Degree > -inline void BSplineElements< Degree >::upSample( BSplineElements< Degree >& high ) const +void BSplineElements< Degree >::upSample( BSplineElements< Degree >& high ) const { fprintf( stderr , "[ERROR] B-spline up-sampling not supported for degree %d\n" , Degree ); exit( 0 ); } template<> -inline void BSplineElements< 1 >::upSample( BSplineElements< 1 >& high ) const +void BSplineElements< 1 >::upSample( BSplineElements< 1 >& high ) const { high.resize( size()*2 ); high.assign( high.size() , BSplineElementCoefficients<1>() ); @@ -668,7 +668,7 @@ high.denominator = denominator * 2; } template<> -inline void BSplineElements< 2 >::upSample( BSplineElements< 2 >& high ) const +void BSplineElements< 2 >::upSample( BSplineElements< 2 >& high ) const { // /----\ // / \ Modified: brlcad/trunk/src/other/PoissonRecon/Src/BinaryNode.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/BinaryNode.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/BinaryNode.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED Modified: brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.cpp =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.cpp 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.cpp 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED Modified: brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED Modified: brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.inl =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.inl 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/CmdLineParser.inl 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED Modified: brlcad/trunk/src/other/PoissonRecon/Src/Factor.cpp =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/Factor.cpp 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/Factor.cpp 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED Modified: brlcad/trunk/src/other/PoissonRecon/Src/Factor.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/Factor.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/Factor.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -47,4 +47,4 @@ int Solve(const double* eqns,const double* values,double* solutions, int dim); -#endif // FACTOR_INCLUDED \ No newline at end of file +#endif // FACTOR_INCLUDED Modified: brlcad/trunk/src/other/PoissonRecon/Src/FunctionData.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/FunctionData.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/FunctionData.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -81,7 +81,7 @@ * 2] L2-norm equals 1 * <useDotRatios> specifies if dot-products of derivatives * should be pre-divided by function integrals - * <reflectBoundary> spcifies if function space should be + * <reflectBoundary> specifies if function space should be * forced to be reflectively symmetric across the boundary ********************************************************/ #if BOUNDARY_CONDITIONS @@ -106,4 +106,4 @@ #include "FunctionData.inl" -#endif // FUNCTION_DATA_INCLUDED \ No newline at end of file +#endif // FUNCTION_DATA_INCLUDED Modified: brlcad/trunk/src/other/PoissonRecon/Src/FunctionData.inl =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/FunctionData.inl 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/FunctionData.inl 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -207,7 +207,7 @@ #if BOUNDARY_CONDITIONS if( flags & D_DOT_FLAG ) dDotTable[idx] = dDotProduct( c1 , w1 , c2 , w2 , boundary1 , boundary2 ); if( flags & D2_DOT_FLAG ) d2DotTable[idx] = d2DotProduct( c1 , w1 , c2 , w2 , boundary1 , boundary2 ); -#else // !BOUNDARY_CONDTIONS +#else // !BOUNDARY_CONDITIONS if( flags & D_DOT_FLAG ) dDotTable[idx] = dDotProduct(c1,w1,c2,w2); if( flags & D2_DOT_FLAG ) d2DotTable[idx] = d2DotProduct(c1,w1,c2,w2); #endif // BOUNDARY_CONDITIONS Modified: brlcad/trunk/src/other/PoissonRecon/Src/Geometry.cpp =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/Geometry.cpp 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/Geometry.cpp 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -119,4 +119,4 @@ _bufferIndex += size; } return true; -} \ No newline at end of file +} Modified: brlcad/trunk/src/other/PoissonRecon/Src/Geometry.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/Geometry.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/Geometry.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -31,7 +31,7 @@ #include <math.h> #include <vector> -#include <stdlib.h> +#include <cstdlib> #include "Hash.h" template<class Real> @@ -42,7 +42,6 @@ { Real coords[3]; Point3D( void ) { coords[0] = coords[1] = coords[2] = Real(0); } - Point3D( Real v ) { coords[0] = coords[1] = coords[2] = v; } template< class _Real > Point3D( _Real v0 , _Real v1 , _Real v2 ){ coords[0] = Real(v0) , coords[1] = Real(v1) , coords[2] = Real(v2); } template< class _Real > Point3D( const Point3D< _Real >& p ){ coords[0] = Real( p[0] ) , coords[1] = Real( p[1] ) , coords[2] = Real( p[2] ); } inline Real& operator[] ( int i ) { return coords[i]; } @@ -223,7 +222,7 @@ } return Area()/d; } - + }; class CoredPointIndex { @@ -304,6 +303,8 @@ virtual void resetIterator( void ) = 0; virtual int addOutOfCorePoint( const Vertex& p ) = 0; + virtual int addPolygon( const std::vector< CoredVertexIndex >& vertices ) = 0; + virtual int addPolygon( const std::vector< int >& vertices ) = 0; virtual int addOutOfCorePoint_s( const Vertex& p ) = 0; virtual int addPolygon_s( const std::vector< CoredVertexIndex >& vertices ) = 0; virtual int addPolygon_s( const std::vector< int >& vertices ) = 0; @@ -328,6 +329,8 @@ void resetIterator(void); int addOutOfCorePoint( const Vertex& p ); + int addPolygon( const std::vector< CoredVertexIndex >& vertices ); + int addPolygon( const std::vector< int >& vertices ); int addOutOfCorePoint_s( const Vertex& p ); int addPolygon_s( const std::vector< CoredVertexIndex >& vertices ); int addPolygon_s( const std::vector< int >& vertices ); @@ -364,6 +367,8 @@ void resetIterator( void ); int addOutOfCorePoint( const Vertex& p ); + int addPolygon( const std::vector< CoredVertexIndex >& vertices ); + int addPolygon( const std::vector< int >& vertices ); int addOutOfCorePoint_s( const Vertex& p ); int addPolygon_s( const std::vector< CoredVertexIndex >& vertices ); int addPolygon_s( const std::vector< int >& vertices ); Modified: brlcad/trunk/src/other/PoissonRecon/Src/Geometry.inl =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/Geometry.inl 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/Geometry.inl 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -436,6 +436,21 @@ return int(oocPoints.size())-1; } template< class Vertex > +int CoredVectorMeshData< Vertex >::addPolygon( const std::vector< CoredVertexIndex >& vertices ) +{ + std::vector< int > polygon( vertices.size() ); + for( int i=0 ; i<(int)vertices.size() ; i++ ) + if( vertices[i].inCore ) polygon[i] = vertices[i].idx; + else polygon[i] = -vertices[i].idx-1; + return addPolygon( polygon ); +} +template< class Vertex > +int CoredVectorMeshData< Vertex >::addPolygon( const std::vector< int >& vertices ) +{ + polygons.push_back( vertices ); + return (int)polygons.size()-1; +} +template< class Vertex > int CoredVectorMeshData< Vertex >::addOutOfCorePoint_s( const Vertex& p ) { size_t sz; @@ -461,7 +476,7 @@ int CoredVectorMeshData< Vertex >::addPolygon_s( const std::vector< CoredVertexIndex >& vertices ) { std::vector< int > polygon( vertices.size() ); - for( int i=0 ; i<(int)vertices.size() ; i++ ) + for( int i=0 ; i<(int)vertices.size() ; i++ ) if( vertices[i].inCore ) polygon[i] = vertices[i].idx; else polygon[i] = -vertices[i].idx-1; return addPolygon_s( polygon ); @@ -502,7 +517,7 @@ CoredFileMeshData< Vertex >::CoredFileMeshData( void ) { oocPoints = polygons = 0; - + oocPointFile = new BufferedReadWriteFile(); polygonFile = new BufferedReadWriteFile(); } @@ -526,6 +541,24 @@ return oocPoints-1; } template< class Vertex > +int CoredFileMeshData< Vertex >::addPolygon( const std::vector< int >& vertices ) +{ + int vSize = (int)vertices.size(); + polygonFile->write( &vSize , sizeof(int) ); + polygonFile->write( &vertices[0] , sizeof(int)*vSize ); + polygons++; + return polygons-1; +} +template< class Vertex > +int CoredFileMeshData< Vertex >::addPolygon( const std::vector< CoredVertexIndex >& vertices ) +{ + std::vector< int > polygon( vertices.size() ); + for( int i=0 ; i<(int)vertices.size() ; i++ ) + if( vertices[i].inCore ) polygon[i] = vertices[i].idx; + else polygon[i] = -vertices[i].idx-1; + return addPolygon( polygon ); +} +template< class Vertex > int CoredFileMeshData< Vertex >::addOutOfCorePoint_s( const Vertex& p ) { int sz; @@ -554,7 +587,7 @@ int CoredFileMeshData< Vertex >::addPolygon_s( const std::vector< CoredVertexIndex >& vertices ) { std::vector< int > polygon( vertices.size() ); - for( int i=0 ; i<(int)vertices.size() ; i++ ) + for( int i=0 ; i<(int)vertices.size() ; i++ ) if( vertices[i].inCore ) polygon[i] = vertices[i].idx; else polygon[i] = -vertices[i].idx-1; return addPolygon_s( polygon ); Modified: brlcad/trunk/src/other/PoissonRecon/Src/Hash.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/Hash.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/Hash.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -15,8 +15,8 @@ template<> struct hash<const long long> { size_t operator()(const long long __x) const { return __x; } }; - - + + template<> struct hash<unsigned long long> { size_t operator()(unsigned long long __x) const { return __x; } }; Modified: brlcad/trunk/src/other/PoissonRecon/Src/MAT.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/MAT.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/MAT.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED Modified: brlcad/trunk/src/other/PoissonRecon/Src/MAT.inl =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/MAT.inl 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/MAT.inl 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED Modified: brlcad/trunk/src/other/PoissonRecon/Src/MarchingCubes.cpp =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/MarchingCubes.cpp 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/MarchingCubes.cpp 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -309,7 +309,7 @@ { int c1 , c2; Square::EdgeCorners( edgeIndex , c1 , c2 ); - return !( + return !( ( ( mcIndex&(1<<MarchingSquares::cornerMap[c1]) ) && ( mcIndex&(1<<MarchingSquares::cornerMap[c2])) ) || (!( mcIndex&(1<<MarchingSquares::cornerMap[c1]) ) && !( mcIndex&(1<<MarchingSquares::cornerMap[c2])) ) @@ -325,7 +325,7 @@ const int MarchingSquares::edgeMask[1<<Square::CORNERS]= { 0, // 0 -> -> -> - 9, // 1 -> 0 -> (0,0) -> 0,3 -> 9 + 9, // 1 -> 0 -> (0,0) -> 0,3 -> 9 3, // 2 -> 1 -> (1,0) -> 0,1 -> 3 10, // 3 -> 0,1 -> (0,0) (1,0) -> 1,3 -> 10 12, // 4 -> 2 -> (0,1) -> 2,3 -> 12 @@ -333,13 +333,13 @@ 15, // 6 -> 1,2 -> (1,0) (0,1) -> 0,1,2,3 -> 15 6, // 7 -> 0,1,2 -> (0,0) (1,0) (0,1) -> 1,2 -> 6 6, // 8 -> 3 -> (1,1) -> 1,2 -> 6 - 15, // 9 -> 0,3 -> (0,0) (1,1) -> 0,1,2,3 -> 15 + 15, // 9 -> 0,3 -> (0,0) (1,1) -> 0,1,2,3 -> 15 5, // 10 -> 1,3 -> (1,0) (1,1) -> 0,2 -> 5 12, // 11 -> 0,1,3 -> (0,0) (1,0) (1,1) -> 2,3 -> 12 10, // 12 -> 2,3 -> (0,1) (1,1) -> 1,3 -> 10 3, // 13 -> 0,2,3 -> (0,0) (0,1) (1,1) -> 0,1 -> 3 9, // 14 -> 1,2,3 -> (1,0) (0,1) (1,1) -> 0,3 -> 9 - 0, // 15 -> 0,1,2,3 -> (0,0) (1,0) (0,1) (1,1) -> + 0, // 15 -> 0,1,2,3 -> (0,0) (1,0) (0,1) (1,1) -> }; #if NEW_ORDERING /* @@ -950,7 +950,7 @@ { int c1 , c2; Cube::EdgeCorners( edgeIndex , c1 , c2 ); - return !( + return !( ( ( mcIndex&(1<<MarchingCubes::cornerMap[c1]) ) && ( mcIndex&(1<<MarchingCubes::cornerMap[c2])) ) || (!( mcIndex&(1<<MarchingCubes::cornerMap[c1]) ) && !( mcIndex&(1<<MarchingCubes::cornerMap[c2])) ) Modified: brlcad/trunk/src/other/PoissonRecon/Src/MarchingCubes.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/MarchingCubes.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/MarchingCubes.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED Modified: brlcad/trunk/src/other/PoissonRecon/Src/MemoryUsage.h =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/MemoryUsage.h 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/MemoryUsage.h 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -47,7 +47,7 @@ MEMORYSTATUSEX Mem; SYSTEM_INFO Info; ZeroMemory( &Mem, sizeof(Mem)); - ZeroMemory( &Info, sizeof(Info)); + ZeroMemory( &Info, sizeof(Info)); Mem.dwLength = sizeof(Mem); ::GlobalMemoryStatusEx( &Mem ); ::GetSystemInfo( &Info ); @@ -63,18 +63,18 @@ size_t usage(void) const {return TotalVirtualAddressSpace-FreeVirtualAddressSpace;} static size_t Usage(void){ - MEMORY_BASIC_INFORMATION mbi; - size_t dwMemUsed = 0; - PVOID pvAddress = 0; + MEMORY_BASIC_INFORMATION mbi; + size_t dwMemUsed = 0; + PVOID pvAddress = 0; - memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION)); - while(VirtualQuery(pvAddress, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) == sizeof(MEMORY_BASIC_INFORMATION)){ + memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION)); + while(VirtualQuery(pvAddress, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) == sizeof(MEMORY_BASIC_INFORMATION)){ if(mbi.State == MEM_COMMIT && mbi.Type == MEM_PRIVATE){dwMemUsed += mbi.RegionSize;} - pvAddress = ((BYTE*)mbi.BaseAddress) + mbi.RegionSize; - } - return dwMemUsed; - } + pvAddress = ((BYTE*)mbi.BaseAddress) + mbi.RegionSize; + } + return dwMemUsed; + } }; #else // !WIN32 @@ -90,7 +90,7 @@ static size_t Usage(void) { FILE* f = fopen("/proc/self/stat","rb"); - + int d; long ld; unsigned long lu; @@ -97,7 +97,7 @@ unsigned long long llu; char s[1024]; char c; - + int pid; unsigned long vm; @@ -106,47 +106,47 @@ fclose(f); /* -pid %d -comm %s -state %c -ppid %d -pgrp %d -session %d +pid %d +comm %s +state %c +ppid %d +pgrp %d +session %d tty_nr %d -tpgid %d -flags %lu -minflt %lu -cminflt %lu -majflt %lu -cmajflt %lu -utime %lu -stime %lu -cutime %ld -cstime %ld -priority %ld -nice %ld -0 %ld -itrealvalue %ld -starttime %lu -vsize %lu -rss %ld -rlim %lu -startcode %lu -endcode %lu -startstack %lu -kstkesp %lu -kstkeip %lu -signal %lu -blocked %lu -sigignore %lu -sigcatch %lu -wchan %lu -nswap %lu -cnswap %lu -exit_signal %d -processor %d -rt_priority %lu (since kernel 2.5.19) -policy %lu (since kernel 2.5.19) +tpgid %d +flags %lu +minflt %lu +cminflt %lu +majflt %lu +cmajflt %lu +utime %lu +stime %lu +cutime %ld +cstime %ld +priority %ld +nice %ld +0 %ld +itrealvalue %ld +starttime %lu +vsize %lu +rss %ld +rlim %lu +startcode %lu +endcode %lu +startstack %lu +kstkesp %lu +kstkeip %lu +signal %lu +blocked %lu +sigignore %lu +sigcatch %lu +wchan %lu +nswap %lu +cnswap %lu +exit_signal %d +processor %d +rt_priority %lu (since kernel 2.5.19) +policy %lu (since kernel 2.5.19) */ return vm; } @@ -193,7 +193,7 @@ }; -#endif // !__APPLE__ +#endif // !__APPLE__ #endif // WIN32 Modified: brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.IsoSurface.inl =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.IsoSurface.inl 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.IsoSurface.inl 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED @@ -38,10 +38,10 @@ Octree< Real >::SliceValues< Vertex >::SliceValues( void ) { _oldCCount = _oldECount = _oldFCount = _oldNCount = 0; - cornerValues = NullPointer( Real ) ; cornerNormals = NullPointer( Point3D< Real > ) ; cornerSet = NullPointer( char ); - edgeKeys = NullPointer( long long ) ; edgeSet = NullPointer( char ); - faceEdges = NullPointer( FaceEdges ) ; faceSet = NullPointer( char ); - mcIndices = NullPointer( char ); + cornerValues = NullPointer< Real >() ; cornerNormals = NullPointer< Point3D< Real > >() ; cornerSet = NullPointer< char >(); + edgeKeys = NullPointer< long long >() ; edgeSet = NullPointer< char >(); + faceEdges = NullPointer< FaceEdges >() ; faceSet = NullPointer< char >(); + mcIndices = NullPointer< char >(); } template< class Real > template< class Vertex > @@ -90,7 +90,7 @@ faceEdges = AllocPointer< FaceEdges >( _oldFCount ); faceSet = AllocPointer< char >( _oldFCount ); } - + if( sliceData.cCount>0 ) memset( cornerSet , 0 , sizeof( char ) * sliceData.cCount ); if( sliceData.eCount>0 ) memset( edgeSet , 0 , sizeof( char ) * sliceData.eCount ); if( sliceData.fCount>0 ) memset( faceSet , 0 , sizeof( char ) * sliceData.fCount ); @@ -100,8 +100,8 @@ Octree< Real >::XSliceValues< Vertex >::XSliceValues( void ) { _oldECount = _oldFCount = 0; - edgeKeys = NullPointer( long long ) ; edgeSet = NullPointer( char ); - faceEdges = NullPointer( FaceEdges ) ; faceSet = NullPointer( char ); + edgeKeys = NullPointer< long long >() ; edgeSet = NullPointer< char >(); + faceEdges = NullPointer< FaceEdges >() ; faceSet = NullPointer< char >(); } template< class Real > template< class Vertex > @@ -137,7 +137,7 @@ template< class Real > template< class Vertex > -void Octree< Real >::GetMCIsoSurface( ConstPointer( Real ) kernelDensityWeights , const SparseNodeData< ProjectiveData< Point3D< Real > > >* colorData , ConstPointer( Real ) solution , Real isoValue , CoredMeshData< Vertex >& mesh , bool nonLinearFit , bool addBarycenter , bool polygonMesh ) +void Octree< Real >::GetMCIsoSurface( ConstPointer( Real ) kernelDensityWeights , ConstPointer( Real ) solution , Real isoValue , CoredMeshData< Vertex >& mesh , bool nonLinearFit , bool addBarycenter , bool polygonMesh ) { typename BSplineData< 2 >::template CornerEvaluator< 2 > evaluator; _fData.setCornerEvaluator( evaluator , 0 , 0 , _boundaryType==0 ); @@ -179,7 +179,7 @@ // Copy edges from finer if( d<maxDepth ) CopyFinerSliceIsoEdgeKeys( d , 0 , slabValues , threads ); SetSliceIsoCorners( solution , GetPointer( coarseSolution ) , isoValue , d , 0 , slabValues , evaluator , vStencils[d].stencil , vStencils[d].stencils , nStencils[d].stencil , nStencils[d].stencils , threads ); - SetSliceIsoVertices( kernelDensityWeights , colorData , isoValue , d , 0 , vertexOffset , mesh , slabValues , threads ); + SetSliceIsoVertices( kernelDensityWeights , isoValue , d , 0 , vertexOffset , mesh , slabValues , threads ); SetSliceIsoEdges( d , 0 , slabValues , threads ); } // Iterate over the slices at the finest level @@ -197,11 +197,11 @@ // Set the slice values/vertices SetSliceIsoCorners( solution , GetPointer( coarseSolution ) , isoValue , d , o , slabValues , evaluator , vStencils[d].stencil , vStencils[d].stencils , nStencils[d].stencil , nStencils[d].stencils , threads ); - SetSliceIsoVertices( kernelDensityWeights , colorData , isoValue , d , o , vertexOffset , mesh , slabValues , threads ); + SetSliceIsoVertices( kernelDensityWeights , isoValue , d , o , vertexOffset , mesh , slabValues , threads ); SetSliceIsoEdges( d , o , slabValues , threads ); // Set the cross-slice edges - SetXSliceIsoVertices( kernelDensityWeights , colorData , isoValue , d , o-1 , vertexOffset , mesh , slabValues , threads ); + SetXSliceIsoVertices( kernelDensityWeights , isoValue , d , o-1 , vertexOffset , mesh , slabValues , threads ); SetXSliceIsoEdges( d , o-1 , slabValues , threads ); // Add the triangles @@ -247,7 +247,7 @@ for( int d=maxDepth ; d>=_minDepth ; d-- ) { std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) ); - for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( d ); + for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( d ); #pragma omp parallel for num_threads( threads ) reduction( + : isoValue , weightSum ) for( int i=_sNodes.nodeCount[d] ; i<_sNodes.nodeCount[d+1] ; i++ ) { @@ -272,7 +272,7 @@ int mn = 2+o , mx = (1<<d)-2-o; bool isInterior = ( off[0]>=mn && off[0]<mx && off[1]>=mn && off[1]<mx && off[2]>=mn && off[2]<mx ); - value = getCenterValue( neighborKey , node , ( ConstPointer( Real ) )solution , ( ConstPointer( Real ) )GetPointer( metSolution ) , evaluator , vStencils[d].stencil , vStencils[d].stencils[c] , isInterior ); + value = getCenterValue( neighborKey , node , solution , GetPointer( metSolution ) , evaluator , vStencils[d].stencil , vStencils[d].stencils[c] , isInterior ); } centerValues[i] = value; Real w = centerWeights[ node->nodeData.nodeIndex ]; @@ -279,7 +279,8 @@ if( w!=0 ) isoValue += value * w , weightSum += w; } } - return isoValue / weightSum; + if( _boundaryType==-1 ) return isoValue/weightSum - Real(0.5); + else return isoValue/weightSum; } template< class Real > @@ -295,7 +296,7 @@ { typename Octree< Real >::template SliceValues< Vertex >& sValues = slabValues[depth].sliceValues( slice ); std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) ); - for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); + for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); #pragma omp parallel for num_threads( threads ) for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z+1] ; i++ ) { @@ -352,18 +353,18 @@ template< class Real > template< class Vertex > -void Octree< Real >::SetSliceIsoVertices( ConstPointer( Real ) kernelDensityWeight , const SparseNodeData< ProjectiveData< Point3D< Real > > >* colorData , Real isoValue , int depth , int slice , int& vOffset , CoredMeshData< Vertex >& mesh , std::vector< SlabValues< Vertex > >& slabValues , int threads ) +void Octree< Real >::SetSliceIsoVertices( ConstPointer( Real ) kernelDensityWeight , Real isoValue , int depth , int slice , int& vOffset , CoredMeshData< Vertex >& mesh , std::vector< SlabValues< Vertex > >& slabValues , int threads ) { - if( slice>0 ) SetSliceIsoVertices( kernelDensityWeight , colorData , isoValue , depth , slice , 1 , vOffset , mesh , slabValues , threads ); - if( slice<(1<<depth) ) SetSliceIsoVertices( kernelDensityWeight , colorData , isoValue , depth , slice , 0 , vOffset , mesh , slabValues , threads ); + if( slice>0 ) SetSliceIsoVertices( kernelDensityWeight , isoValue , depth , slice , 1 , vOffset , mesh , slabValues , threads ); + if( slice<(1<<depth) ) SetSliceIsoVertices( kernelDensityWeight , isoValue , depth , slice , 0 , vOffset , mesh , slabValues , threads ); } template< class Real > template< class Vertex > -void Octree< Real >::SetSliceIsoVertices( ConstPointer( Real ) kernelDensityWeight , const SparseNodeData< ProjectiveData< Point3D< Real > > >* colorData , Real isoValue , int depth , int slice , int z , int& vOffset , CoredMeshData< Vertex >& mesh , std::vector< SlabValues< Vertex > >& slabValues , int threads ) +void Octree< Real >::SetSliceIsoVertices( ConstPointer( Real ) kernelDensityWeight , Real isoValue , int depth , int slice , int z , int& vOffset , CoredMeshData< Vertex >& mesh , std::vector< SlabValues< Vertex > >& slabValues , int threads ) { typename Octree< Real >::template SliceValues< Vertex >& sValues = slabValues[depth].sliceValues( slice ); std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) ); - for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); + for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); #pragma omp parallel for num_threads( threads ) for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z+1] ; i++ ) { @@ -386,7 +387,7 @@ int o , y; Square::FactorEdgeIndex( e , o , y ); long long key = VertexData::EdgeIndex( leaf , Cube::EdgeIndex( o , y , z ) , _sNodes.maxDepth ); - GetIsoVertex( kernelDensityWeight , colorData , isoValue , neighborKey , leaf , e , z , sValues , vertex ); + GetIsoVertex( kernelDensityWeight , isoValue , neighborKey , leaf , e , z , sValues , vertex ); vertex.point = vertex.point * _scale + _center; bool stillOwner = false; std::pair< int , Vertex > hashed_vertex; @@ -420,12 +421,7 @@ TreeOctNode* node = leaf; int _depth = depth , _slice = slice; bool _isNeeded = isNeeded; -#if 1 - // Bug fix courtesy of asmaloney - while( _isNeeded && node->parent && Cube::IsFaceCorner( (int)(node-node->parent->children) , f[k] ) ) -#else while( _isNeeded = node->parent && Cube::IsFaceCorner( (int)(node-node->parent->children) , f[k] ) ) -#endif { node = node->parent , _depth-- , _slice >>= 1; typename Octree< Real >::template SliceValues< Vertex >& _sValues = slabValues[_depth].sliceValues( _slice ); @@ -448,7 +444,7 @@ } template< class Real > template< class Vertex > -void Octree< Real >::SetXSliceIsoVertices( ConstPointer( Real ) kernelDensityWeight , const SparseNodeData< ProjectiveData< Point3D< Real > > >* colorData , Real isoValue , int depth , int slab , int& vOffset , CoredMeshData< Vertex >& mesh , std::vector< SlabValues< Vertex > >& slabValues , int threads ) +void Octree< Real >::SetXSliceIsoVertices( ConstPointer( Real ) kernelDensityWeight , Real isoValue , int depth , int slab , int& vOffset , CoredMeshData< Vertex >& mesh , std::vector< SlabValues< Vertex > >& slabValues , int threads ) { typename Octree< Real >::template SliceValues< Vertex >& bValues = slabValues[depth].sliceValues ( slab ); typename Octree< Real >::template SliceValues< Vertex >& fValues = slabValues[depth].sliceValues ( slab+1 ); @@ -455,7 +451,7 @@ typename Octree< Real >::template XSliceValues< Vertex >& xValues = slabValues[depth].xSliceValues( slab ); std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) ); - for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); + for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); #pragma omp parallel for num_threads( threads ) for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slab] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slab+1] ; i++ ) { @@ -479,7 +475,7 @@ { Vertex vertex; long long key = VertexData::EdgeIndex( leaf , e , _sNodes.maxDepth ); - GetIsoVertex( kernelDensityWeight , colorData , isoValue , neighborKey , leaf , c , bValues , fValues , vertex ); + GetIsoVertex( kernelDensityWeight , isoValue , neighborKey , leaf , c , bValues , fValues , vertex ); vertex.point = vertex.point * _scale + _center; bool stillOwner = false; std::pair< int , Vertex > hashed_vertex; @@ -660,7 +656,7 @@ { typename Octree< Real >::template SliceValues< Vertex >& sValues = slabValues[depth].sliceValues( slice ); std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) ); - for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); + for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); #pragma omp parallel for num_threads( threads ) for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z+1] ; i++ ) { @@ -720,7 +716,7 @@ typename Octree< Real >::template XSliceValues< Vertex >& xValues = slabValues[depth].xSliceValues( slab ); std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) ); - for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); + for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); #pragma omp parallel for num_threads( threads ) for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slab] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slab+1] ; i++ ) { @@ -791,12 +787,12 @@ } template< class Real > template< class Vertex > -void Octree< Real >::SetIsoSurface( int depth , int offset , const SliceValues< Vertex >& bValues , const SliceValues< Vertex >& fValues , const XSliceValues< Vertex >& xValues , CoredMeshData< Vertex >& mesh , bool polygonMesh , bool addBarycenter , int& vOffset , int threads ) +int Octree< Real >::SetIsoSurface( int depth , int offset , const SliceValues< Vertex >& bValues , const SliceValues< Vertex >& fValues , const XSliceValues< Vertex >& xValues , CoredMeshData< Vertex >& mesh , bool polygonMesh , bool addBarycenter , int& vOffset , int threads ) { std::vector< std::pair< int , Vertex > > polygon; std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) ); std::vector< std::vector< IsoEdge > > edgess( std::max< int >( 1 , threads ) ); - for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); + for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth ); #pragma omp parallel for num_threads( threads ) for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][offset] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][offset+1] ; i++ ) { @@ -807,7 +803,7 @@ { edges.clear(); unsigned char mcIndex = ( bValues.mcIndices[ i - bValues.sliceData.nodeOffset ] ) | ( fValues.mcIndices[ i - fValues.sliceData.nodeOffset ]<<4 ); - // [WARNING] Just because the node looks empty doesn't mean it doesn't get eges from finer neighbors + // [WARNING] Just because the node looks empty doesn't mean it doesn't get edges from finer neighbors { // Gather the edges from the faces (with the correct orientation) for( int f=0 ; f<Cube::FACES ; f++ ) @@ -833,7 +829,7 @@ if( iter!=sValues.faceEdgeMap.end() ) { const std::vector< IsoEdge >& _edges = iter->second; - for( size_t j=0 ; j<_edges.size() ; j++ ) edges.push_back( IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) ); + for( int j=0 ; j<_edges.size() ; j++ ) edges.push_back( IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) ); } else fprintf( stderr , "[ERROR] Invalid faces: %d %d %d\n" , i , d , o ) , exit( 0 ); } @@ -853,7 +849,7 @@ if( iter!=xValues.faceEdgeMap.end() ) { const std::vector< IsoEdge >& _edges = iter->second; - for( size_t j=0 ; j<_edges.size() ; j++ ) edges.push_back( IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) ); + for( int j=0 ; j<_edges.size() ; j++ ) edges.push_back( IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) ); } else fprintf( stderr , "[ERROR] Invalid faces: %d %d %d\n" , i , d , o ) , exit( 0 ); } @@ -870,7 +866,7 @@ while( current!=start ) { int idx; - for( idx=0 ; idx<(int)edges.size() ; idx++ ) if( edges[idx][0]==current ) break; + for( idx=0 ; idx<edges.size() ; idx++ ) if( edges[idx][0]==current ) break; if( idx==edges.size() ) { typename hash_map< long long , long long >::const_iterator iter; @@ -889,10 +885,10 @@ loops.back().push_back( start ); } // Add the loops to the mesh - for( size_t j=0 ; j<loops.size() ; j++ ) + for( int j=0 ; j<loops.size() ; j++ ) { std::vector< std::pair< int , Vertex > > polygon( loops[j].size() ); - for( size_t k=0 ; k<loops[j].size() ; k++ ) + for( int k=0 ; k<loops[j].size() ; k++ ) { long long key = loops[j][k]; typename hash_map< long long , std::pair< int , Vertex > >::const_iterator iter; @@ -907,20 +903,11 @@ } } } -template< class Real > void SetColor( Point3D< Real >& color , unsigned char c[3] ){ for( int i=0 ; i<3 ; i++ ) c[i] = (unsigned char)std::max< int >( 0 , std::min< int >( 255 , (int)( color[i]+0.5 ) ) ); } - -template< class Real > void SetIsoVertex( PlyVertex< float >& vertex , Point3D< Real > color , Real value ){ ; } -template< class Real > void SetIsoVertex( PlyColorVertex< float >& vertex , Point3D< Real > color , Real value ){ SetColor( color , vertex.color ); } -template< class Real > void SetIsoVertex( PlyValueVertex< float >& vertex , Point3D< Real > color , Real value ){ vertex.value = float(value); } -template< class Real > void SetIsoVertex( PlyColorAndValueVertex< float >& vertex , Point3D< Real > color , Real value ){ SetColor( color , vertex.color ) , vertex.value = float(value); } -template< class Real > void SetIsoVertex( PlyVertex< double >& vertex , Point3D< Real > color , Real value ){ ; } -template< class Real > void SetIsoVertex( PlyColorVertex< double >& vertex , Point3D< Real > color , Real value ){ SetColor( color , vertex.color ); } -template< class Real > void SetIsoVertex( PlyValueVertex< double >& vertex , Point3D< Real > color , Real value ){ vertex.value = double(value); } -template< class Real > void SetIsoVertex( PlyColorAndValueVertex< double >& vertex , Point3D< Real > color , Real value ){ SetColor( color , vertex.color ) , vertex.value = double(value); } - +template< class Real > void SetIsoVertexValue( PlyVertex< float >& vertex , Real value ){ ; } +template< class Real > void SetIsoVertexValue( PlyValueVertex< float >& vertex , Real value ){ vertex.value = float(value); } template< class Real > template< class Vertex > -bool Octree< Real >::GetIsoVertex( ConstPointer( Real ) kernelDensityWeights , const SparseNodeData< ProjectiveData< Point3D< Real > > >* colorData , Real isoValue , typename TreeOctNode::ConstNeighborKey3& neighborKey3 , const TreeOctNode* node , int edgeIndex , int z , const SliceValues< Vertex >& sValues , Vertex& vertex ) +bool Octree< Real >::GetIsoVertex( ConstPointer( Real ) kernelDensityWeights , Real isoValue , typename TreeOctNode::ConstNeighborKey3& neighborKey3 , const TreeOctNode* node , int edgeIndex , int z , const SliceValues< Vertex >& sValues , Vertex& vertex ) { Point3D< Real > position; int c0 , c1; @@ -954,6 +941,11 @@ } double dx0 = n0[o] , dx1 = n1[o]; + { + double dAverage = ( dx0 + dx1 ) / 2.; + dx0 = dx0 * (1.-_normalSmooth) + dAverage * _normalSmooth; + dx1 = dx1 * (1.-_normalSmooth) + dAverage * _normalSmooth; + } // The scaling will turn the Hermite Spline into a quadratic double scl = (x1-x0) / ( (dx1+dx0 ) / 2 ); @@ -980,22 +972,19 @@ } position[o] = Real( center - width/2 + width*averageRoot ); vertex.point = position; - Point3D< Real > color; - Real depth(0); if( kernelDensityWeights ) { - Real weight; + Real depth , weight; const TreeOctNode* temp = node; while( temp->depth()>_splatDepth ) temp=temp->parent; - GetSampleDepthAndWeight( kernelDensityWeights , temp , position , neighborKey3 , depth , weight ); + GetSampleDepthAndWeight( kernelDensityWeights , temp , position , neighborKey3 , _samplesPerNode , depth , weight ); + SetIsoVertexValue( vertex , depth ); } - if( colorData ) color = Point3D< Real >( _Evaluate( *colorData , position , neighborKey3 ) ); - SetIsoVertex( vertex , color , depth ); return true; } template< class Real > template< class Vertex > -bool Octree< Real >::GetIsoVertex( ConstPointer( Real ) kernelDensityWeights , const SparseNodeData< ProjectiveData< Point3D< Real > > >* colorData , Real isoValue , typename TreeOctNode::ConstNeighborKey3& neighborKey3 , const TreeOctNode* node , int cornerIndex , const SliceValues< Vertex >& bValues , const SliceValues< Vertex >& fValues , Vertex& vertex ) +bool Octree< Real >::GetIsoVertex( ConstPointer( Real ) kernelDensityWeights , Real isoValue , typename TreeOctNode::ConstNeighborKey3& neighborKey3 , const TreeOctNode* node , int cornerIndex , const SliceValues< Vertex >& bValues , const SliceValues< Vertex >& fValues , Vertex& vertex ) { Point3D< Real > position; @@ -1019,6 +1008,11 @@ position[1] = c[1] - width/2 + width*y; double dx0 = n0[2] , dx1 = n1[2]; + { + double dAverage = ( dx0 + dx1 ) / 2.; + dx0 = dx0 * (1.-_normalSmooth) + dAverage * _normalSmooth; + dx1 = dx1 * (1.-_normalSmooth) + dAverage * _normalSmooth; + } // The scaling will turn the Hermite Spline into a quadratic double scl = (x1-x0) / ( (dx1+dx0 ) / 2 ); @@ -1045,17 +1039,14 @@ } position[2] = Real( center - width/2 + width*averageRoot ); vertex.point = position; - Point3D< Real > color; - Real depth(0); if( kernelDensityWeights ) { - Real weight; + Real depth , weight; const TreeOctNode* temp = node; while( temp->depth()>_splatDepth ) temp=temp->parent; - GetSampleDepthAndWeight( kernelDensityWeights , temp , position , neighborKey3 , depth , weight ); + GetSampleDepthAndWeight( kernelDensityWeights , temp , position , neighborKey3 , _samplesPerNode , depth , weight ); + SetIsoVertexValue( vertex , depth ); } - if( colorData ) color = Point3D< Real >( _Evaluate( *colorData , position , neighborKey3 ) ); - SetIsoVertex( vertex , color , depth ); return true; } @@ -1086,11 +1077,9 @@ if( isCoplanar ) { Vertex c; - typename Vertex::Wrapper _c; - _c *= 0; - for( int i=0 ; i<(int)polygon.size() ; i++ ) _c += typename Vertex::Wrapper( polygon[i].second ); - _c /= Real( polygon.size() ); - c = Vertex( _c ); + c *= 0; + for( int i=0 ; i<(int)polygon.size() ; i++ ) c += polygon[i].second; + c /= Real( polygon.size() ); int cIdx; #pragma omp critical (add_barycenter_point_access) { Modified: brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.SortedTreeNodes.inl =================================================================== --- brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.SortedTreeNodes.inl 2018-07-24 14:21:28 UTC (rev 71230) +++ brlcad/trunk/src/other/PoissonRecon/Src/MultiGridOctreeData.SortedTreeNodes.inl 2018-07-24 14:55:09 UTC (rev 71231) @@ -8,14 +8,14 @@ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the distribution. +in the documentation and/or other materials provided with the distribution. Neither the name of the Johns Hopkins University nor the names of its contributors may be used to endorse or promote products derived from this software without specific -prior written permission. +prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits