Revision: 76836
          http://sourceforge.net/p/brlcad/code/76836
Author:   starseeker
Date:     2020-08-18 20:57:50 +0000 (Tue, 18 Aug 2020)
Log Message:
-----------
Pull in inside/outside pnts logic from trunk for refactoring

Modified Paths:
--------------
    brlcad/branches/analyze_cmd/include/analyze/pnts.h
    brlcad/branches/analyze_cmd/src/libanalyze/CMakeLists.txt
    brlcad/branches/analyze_cmd/src/libanalyze/polygonizer.c
    brlcad/branches/analyze_cmd/src/libged/pnts/pnts.cpp
    brlcad/branches/analyze_cmd/src/libged/pnts_util.c
    brlcad/branches/analyze_cmd/src/libged/pnts_util.h

Added Paths:
-----------
    brlcad/branches/analyze_cmd/src/libanalyze/pnt_inside.c

Modified: brlcad/branches/analyze_cmd/include/analyze/pnts.h
===================================================================
--- brlcad/branches/analyze_cmd/include/analyze/pnts.h  2020-08-18 20:50:54 UTC 
(rev 76835)
+++ brlcad/branches/analyze_cmd/include/analyze/pnts.h  2020-08-18 20:57:50 UTC 
(rev 76836)
@@ -65,6 +65,13 @@
 ANALYZE_EXPORT int analyze_obj_to_pnts(struct rt_pnts_internal *rpnts, double 
*avg_thickness, struct db_i *dbip,
                                       const char *obj, struct bn_tol *tol, int 
flags, int max_pnts, int max_time, int verbosity);
 
+
+/**
+ * Given an application structure and a test point, use ray sampling to 
determine
+ * if the point is inside (on or within) or outside the volume described.
+ */
+ANALYZE_EXPORT int analyze_pnt_in_vol(point_t *p, struct application *ap, int 
on_is_in);
+
 __END_DECLS
 
 #endif /* ANALYZE_PNTS_H */

Modified: brlcad/branches/analyze_cmd/src/libanalyze/CMakeLists.txt
===================================================================
--- brlcad/branches/analyze_cmd/src/libanalyze/CMakeLists.txt   2020-08-18 
20:50:54 UTC (rev 76835)
+++ brlcad/branches/analyze_cmd/src/libanalyze/CMakeLists.txt   2020-08-18 
20:57:50 UTC (rev 76836)
@@ -45,6 +45,7 @@
   nirt/diff.cpp
   obj_to_pnts.cpp
   overlaps.c
+  pnt_inside.c
   polygonizer.c
   raydiff.c
   #find_subtracted_shapes.cpp

Added: brlcad/branches/analyze_cmd/src/libanalyze/pnt_inside.c
===================================================================
--- brlcad/branches/analyze_cmd/src/libanalyze/pnt_inside.c                     
        (rev 0)
+++ brlcad/branches/analyze_cmd/src/libanalyze/pnt_inside.c     2020-08-18 
20:57:50 UTC (rev 76836)
@@ -0,0 +1,159 @@
+/*                    P N T _ I N S I D E . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2020 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file pnt_inside.c
+ *
+ * Brief description
+ *
+ */
+
+#include "common.h"
+
+#include "raytrace.h"
+#include "analyze.h"
+
+static void
+_tgc_hack_fix(struct partition *part, struct soltab *stp) {
+    /* hack fix for bad tgc surfaces - avoids a logging crash, which is 
probably something else altogether... */
+    if (bu_strncmp("rec", stp->st_meth->ft_label, 3) == 0 || bu_strncmp("tgc", 
stp->st_meth->ft_label, 3) == 0) {
+
+       /* correct invalid surface number */
+       if (part->pt_inhit->hit_surfno < 1 || part->pt_inhit->hit_surfno > 3) {
+           part->pt_inhit->hit_surfno = 2;
+       }
+       if (part->pt_outhit->hit_surfno < 1 || part->pt_outhit->hit_surfno > 3) 
{
+           part->pt_outhit->hit_surfno = 2;
+       }
+    }
+}
+
+
+static int
+in_out_hit(struct application *ap, struct partition *partH, struct seg 
*UNUSED(segs))
+{
+    struct partition *part = partH->pt_forw;
+    struct soltab *stp = part->pt_inseg->seg_stp;
+
+    int *ret = (int *)(ap->a_uptr);
+
+    RT_CK_APPLICATION(ap);
+
+    _tgc_hack_fix(part, stp);
+
+    if (part->pt_inhit->hit_dist < 0) {
+       (*ret) = -1;
+    }
+
+    if (NEAR_ZERO(part->pt_inhit->hit_dist, VUNITIZE_TOL)) {
+       (*ret) = 1;
+    }
+
+    return 0;
+}
+
+static int
+in_out_miss(struct application *UNUSED(ap))
+{
+    return 0;
+}
+
+int
+analyze_pnt_in_vol(point_t *p, struct application *ap, int on_is_in)
+{
+    int i;
+    int fret = 1;
+    int dir_results[6] = {0, 0, 0, 0, 0, 0};
+    int (*a_hit)(struct application *, struct partition *, struct seg *);
+    int (*a_miss)(struct application *);
+    void *uptr_stash;
+
+    vect_t mx, my, mz, px, py, pz;
+    VSET(mx, -1,  0,  0);
+    VSET(my,  0, -1,  0);
+    VSET(mz,  0,  0, -1);
+    VSET(px,  1,  0,  0);
+    VSET(py,  0,  1,  0);
+    VSET(pz,  0,  0,  1);
+
+    /* reuse existing application, just cache pre-existing hit routines and
+     * substitute our own */
+    a_hit = ap->a_hit;
+    a_miss = ap->a_miss;
+    uptr_stash = ap->a_uptr;
+
+    ap->a_hit = in_out_hit;
+    ap->a_miss = in_out_miss;
+
+    VMOVE(ap->a_ray.r_pt, *p);
+
+    /* Check the six directions to see if any of them indicate we are inside */
+
+    /* -x */
+    ap->a_uptr = &(dir_results[0]);
+    VMOVE(ap->a_ray.r_dir, mx);
+    (void)rt_shootray(ap);
+    /* -y */
+    ap->a_uptr = &(dir_results[1]);
+    VMOVE(ap->a_ray.r_dir, my);
+    (void)rt_shootray(ap);
+    /* -z */
+    ap->a_uptr = &(dir_results[2]);
+    VMOVE(ap->a_ray.r_dir, mz);
+    (void)rt_shootray(ap);
+    /* x */
+    ap->a_uptr = &(dir_results[3]);
+    VMOVE(ap->a_ray.r_dir, px);
+    (void)rt_shootray(ap);
+    /* y */
+    ap->a_uptr = &(dir_results[4]);
+    VMOVE(ap->a_ray.r_dir, py);
+    (void)rt_shootray(ap);
+    /* z */
+    ap->a_uptr = &(dir_results[5]);
+    VMOVE(ap->a_ray.r_dir, pz);
+    (void)rt_shootray(ap);
+
+    for (i = 0; i < 6; i++) {
+       if (on_is_in) {
+           if (dir_results[i] != 0)
+               fret = -1;
+       } else {
+           if (dir_results[i] < 0)
+               fret = -1;
+       }
+    }
+
+    /* restore application */
+    ap->a_hit = a_hit;
+    ap->a_miss = a_miss;
+    ap->a_uptr = uptr_stash;
+
+    return fret;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
+


Property changes on: brlcad/branches/analyze_cmd/src/libanalyze/pnt_inside.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: brlcad/branches/analyze_cmd/src/libanalyze/polygonizer.c
===================================================================
--- brlcad/branches/analyze_cmd/src/libanalyze/polygonizer.c    2020-08-18 
20:50:54 UTC (rev 76835)
+++ brlcad/branches/analyze_cmd/src/libanalyze/polygonizer.c    2020-08-18 
20:57:50 UTC (rev 76836)
@@ -399,7 +399,7 @@
 }
 
 
-HIDDEN void
+static void
 _polygonizer_tgc_hack_fix(struct partition *part, struct soltab *stp) {
     /* hack fix for bad tgc surfaces - avoids a logging crash, which is 
probably something else altogether... */
     if (bu_strncmp("rec", stp->st_meth->ft_label, 3) == 0 || bu_strncmp("tgc", 
stp->st_meth->ft_label, 3) == 0) {
@@ -414,7 +414,7 @@
     }
 }
 
-HIDDEN int
+static int
 first_hit(struct application *ap, struct partition *PartHeadp, struct seg 
*UNUSED(segs))
 {
     struct partition *part = PartHeadp->pt_forw;
@@ -627,99 +627,11 @@
     bu_free(m, "mesh");
 }
 
-
-HIDDEN int
-in_out_hit(struct application *ap, struct partition *partH, struct seg 
*UNUSED(segs))
-{
-    struct partition *part = partH->pt_forw;
-    struct soltab *stp = part->pt_inseg->seg_stp;
-
-    int *ret = (int *)(ap->a_uptr);
-
-    RT_CK_APPLICATION(ap);
-
-    _polygonizer_tgc_hack_fix(part, stp);
-
-    if (part->pt_inhit->hit_dist < 0) {
-       (*ret) = -1;
-    }
-
-    return 0;
-}
-
-int
-in_out_miss(struct application *UNUSED(ap))
-{
-    return 0;
-}
-
-int
+static int
 pnt_in_out(point_t *p, void *d)
 {
-    int i;
-    int fret = 1;
-    int dir_results[6] = {0, 0, 0, 0, 0, 0};
     struct application *ap = (struct application *)d;
-    int (*a_hit)(struct application *, struct partition *, struct seg *);
-    int (*a_miss)(struct application *);
-    void *uptr_stash;
-
-    vect_t mx, my, mz, px, py, pz;
-    VSET(mx, -1,  0,  0);
-    VSET(my,  0, -1,  0);
-    VSET(mz,  0,  0, -1);
-    VSET(px,  1,  0,  0);
-    VSET(py,  0,  1,  0);
-    VSET(pz,  0,  0,  1);
-
-    /* reuse existing application, just cache pre-existing hit routines and
-     * substitute our own */
-    a_hit = ap->a_hit;
-    a_miss = ap->a_miss;
-    uptr_stash = ap->a_uptr;
-
-    ap->a_hit = in_out_hit;
-    ap->a_miss = in_out_miss;
-
-    VMOVE(ap->a_ray.r_pt, *p);
-
-    /* Check the six directions to see if any of them indicate we are inside */
-
-    /* -x */
-    ap->a_uptr = &(dir_results[0]);
-    VMOVE(ap->a_ray.r_dir, mx);
-    (void)rt_shootray(ap);
-    /* -y */
-    ap->a_uptr = &(dir_results[1]);
-    VMOVE(ap->a_ray.r_dir, my);
-    (void)rt_shootray(ap);
-    /* -z */
-    ap->a_uptr = &(dir_results[2]);
-    VMOVE(ap->a_ray.r_dir, mz);
-    (void)rt_shootray(ap);
-    /* x */
-    ap->a_uptr = &(dir_results[3]);
-    VMOVE(ap->a_ray.r_dir, px);
-    (void)rt_shootray(ap);
-    /* y */
-    ap->a_uptr = &(dir_results[4]);
-    VMOVE(ap->a_ray.r_dir, py);
-    (void)rt_shootray(ap);
-    /* z */
-    ap->a_uptr = &(dir_results[5]);
-    VMOVE(ap->a_ray.r_dir, pz);
-    (void)rt_shootray(ap);
-
-    for (i = 0; i < 6; i++) {
-       if (dir_results[i] < 0) fret = -1;
-    }
-
-    /* restore application */
-    ap->a_hit = a_hit;
-    ap->a_miss = a_miss;
-    ap->a_uptr = uptr_stash;
-
-    return fret;
+    return analyze_pnt_in_vol(p, ap, 0);
 }
 
 /**** An Implicit Surface Polygonizer ****/

Modified: brlcad/branches/analyze_cmd/src/libged/pnts/pnts.cpp
===================================================================
--- brlcad/branches/analyze_cmd/src/libged/pnts/pnts.cpp        2020-08-18 
20:50:54 UTC (rev 76835)
+++ brlcad/branches/analyze_cmd/src/libged/pnts/pnts.cpp        2020-08-18 
20:57:50 UTC (rev 76836)
@@ -48,6 +48,234 @@
 #include "../pnts_util.h"
 }
 
+static int
+_pnts_inside_obj(struct ged *gedp, int argc, const char **argv)
+{
+    int ret = GED_OK;
+    unsigned long pntcnt = 0;
+    struct directory *dp = RT_DIR_NULL;
+    int print_help = 0;
+    int report_outside = 0;
+    int opt_ret = 0;
+    const char *usage = "Usage: pnts inside [options] <test_pnts_obj> 
<test_vol_obj> <output_pnts_obj>\n\n";
+    struct bu_opt_desc d[3];
+    BU_OPT(d[0], "h", "help",      "",  NULL, &print_help,     "Print help and 
exit");
+    BU_OPT(d[1], "R", "reverse",   "",  NULL, &report_outside, "Report points 
outside volume.");
+    BU_OPT_NULL(d[2]);
+
+    if (!gedp)
+               return GED_ERROR;
+
+    argc-=(argc>0); argv+=(argc>0); /* skip command name argv[0] */
+
+    /* must be wanting help */
+    if (argc < 1) {
+       _ged_cmd_help(gedp, usage, d);
+       return GED_OK;
+    }
+
+    /* parse standard options */
+    opt_ret = bu_opt_parse(NULL, argc, argv, d);
+
+    if (print_help) {
+       _ged_cmd_help(gedp, usage, d);
+       return GED_OK;
+    }
+
+    /* adjust argc to match the leftovers of the options parsing */
+    argc = opt_ret;
+
+    if (argc != 3) {
+       _ged_cmd_help(gedp, usage, d);
+       return GED_ERROR;
+    }
+
+    const char *test_pnts_obj = argv[0];
+    const char *vol_obj = argv[1];
+    const char *output_pnts_obj = argv[2];
+    struct pnt *pstd, *pstdl = NULL;
+    struct pnt_color *pc, *pcl = NULL;
+    struct pnt_scale *ps, *psl = NULL;
+    struct pnt_normal *pn, *pnl = NULL;
+    struct pnt_color_scale *pcs, *pcsl = NULL;
+    struct pnt_color_normal *pcn, *pcnl = NULL;
+    struct pnt_scale_normal *psn, *psnl = NULL;
+    struct pnt_color_scale_normal *pcsn, *pcsnl = NULL;
+    void *npnt = NULL;
+    int iostat = 0;
+    struct rt_db_internal internal;
+    struct rt_pnts_internal *opnts = NULL;
+
+    /* Sanity */
+    GED_CHECK_EXISTS(gedp, output_pnts_obj, LOOKUP_QUIET, GED_ERROR);
+
+    /* get objs */
+    struct directory *test_pnts_dp = RT_DIR_NULL;
+    GED_DB_LOOKUP(gedp, test_pnts_dp, test_pnts_obj, LOOKUP_NOISY, GED_ERROR & 
GED_QUIET);
+    struct directory *test_vol_dp = RT_DIR_NULL;
+    GED_DB_LOOKUP(gedp, test_vol_dp, vol_obj, LOOKUP_NOISY, GED_ERROR & 
GED_QUIET);
+
+    /* For the test points, we need to introspect the object's data */
+    struct rt_db_internal tpnts_intern;
+    GED_DB_GET_INTERNAL(gedp, &tpnts_intern, test_pnts_dp, bn_mat_identity, 
&rt_uniresource, GED_ERROR);
+    if (tpnts_intern.idb_major_type != DB5_MAJORTYPE_BRLCAD || 
tpnts_intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_PNTS) {
+       bu_vls_printf(gedp->ged_result_str, "pnts inside: %s is not a pnts 
object!", test_pnts_obj);
+       rt_db_free_internal(&tpnts_intern);
+       return GED_ERROR;
+    }
+    struct rt_pnts_internal *pnts = (struct rt_pnts_internal 
*)tpnts_intern.idb_ptr;
+    RT_PNTS_CK_MAGIC(pnts);
+
+
+    /* For the vol object, we need to raytrace it */
+    struct application *ap;
+    struct resource *resp;
+    struct rt_i *rtip;
+    size_t ncpus;
+    BU_GET(ap, struct application);
+    RT_APPLICATION_INIT(ap);
+    BU_GET(resp, struct resource);
+    rtip = rt_new_rti(gedp->ged_wdbp->dbip);
+    rt_init_resource(resp, 0, rtip);
+    ap->a_rt_i = rtip;
+    ap->a_resource = resp;
+    ap->a_onehit = 1;
+    ap->a_hit = NULL;
+    ap->a_miss = NULL;
+    ap->a_overlap = NULL;
+    ap->a_logoverlap = rt_silent_logoverlap;
+    if ((rt_gettree(rtip, vol_obj) < 0)) {
+       ret = GED_ERROR;
+       goto pnts_internal_memfree;
+    }
+    ncpus = bu_avail_cpus();
+    rt_prep_parallel(rtip, ncpus);
+
+    /* For the output, make a new pnts object */
+    RT_DB_INTERNAL_INIT(&internal);
+    internal.idb_major_type = DB5_MAJORTYPE_BRLCAD;
+    internal.idb_type = ID_PNTS;
+    internal.idb_meth = &OBJ[ID_PNTS];
+    BU_ALLOC(internal.idb_ptr, struct rt_pnts_internal);
+    opnts = (struct rt_pnts_internal *) internal.idb_ptr;
+    opnts->magic = RT_PNTS_INTERNAL_MAGIC;
+    opnts->scale = pnts->scale;
+    opnts->type = pnts->type;
+    opnts->point = _ged_pnts_new_pnt(pnts->type);
+    _ged_pnts_init_head_pnt(opnts);
+
+    switch(pnts->type) {
+       case RT_PNT_TYPE_PNT:
+           pstdl = (struct pnt *)pnts->point;
+           for (BU_LIST_FOR(pstd, pnt, &(pstdl->l))) {
+               iostat = analyze_pnt_in_vol(&(pstd->v), ap, 1);
+               if ((!report_outside && iostat == -1) || (report_outside && 
iostat != -1)) {
+                   npnt = _ged_pnts_dup((void *)pstd, RT_PNT_TYPE_PNT);
+                   _ged_pnts_add(opnts, npnt);
+                   pntcnt++;
+               }
+           }
+           break;
+       case RT_PNT_TYPE_COL:
+           pcl = (struct pnt_color *)pnts->point;
+           for (BU_LIST_FOR(pc, pnt_color, &(pcl->l))) {
+               iostat = analyze_pnt_in_vol(&(pc->v), ap, 1);
+               if ((!report_outside && iostat == -1) || (report_outside && 
iostat != -1)) {
+                   npnt = _ged_pnts_dup((void *)pc, RT_PNT_TYPE_COL);
+                   _ged_pnts_add(opnts, npnt);
+                   pntcnt++;
+               }
+           }
+           break;
+       case RT_PNT_TYPE_SCA:
+           psl = (struct pnt_scale *)pnts->point;
+           for (BU_LIST_FOR(ps, pnt_scale, &(psl->l))) {
+               iostat = analyze_pnt_in_vol(&(ps->v), ap, 1);
+               if ((!report_outside && iostat == -1) || (report_outside && 
iostat != -1)) {
+                   npnt = _ged_pnts_dup((void *)ps, RT_PNT_TYPE_SCA);
+                   _ged_pnts_add(opnts, npnt);
+                   pntcnt++;
+               }
+           }
+           break;
+       case RT_PNT_TYPE_NRM:
+           pnl = (struct pnt_normal *)pnts->point;
+           for (BU_LIST_FOR(pn, pnt_normal, &(pnl->l))) {
+               iostat = analyze_pnt_in_vol(&(pn->v), ap, 1);
+               if ((!report_outside && iostat == -1) || (report_outside && 
iostat != -1)) {
+                   npnt = _ged_pnts_dup((void *)pn, RT_PNT_TYPE_NRM);
+                   _ged_pnts_add(opnts, npnt);
+                   pntcnt++;
+               }
+           }
+           break;
+       case RT_PNT_TYPE_COL_SCA:
+           pcsl = (struct pnt_color_scale *)pnts->point;
+           for (BU_LIST_FOR(pcs, pnt_color_scale, &(pcsl->l))) {
+               iostat = analyze_pnt_in_vol(&(pcs->v), ap, 1);
+               if ((!report_outside && iostat == -1) || (report_outside && 
iostat != -1)) {
+                   npnt = _ged_pnts_dup((void *)pcs, RT_PNT_TYPE_COL_SCA);
+                   _ged_pnts_add(opnts, npnt);
+                   pntcnt++;
+               }
+           }
+           break;
+       case RT_PNT_TYPE_COL_NRM:
+           pcnl = (struct pnt_color_normal *)pnts->point;
+           for (BU_LIST_FOR(pcn, pnt_color_normal, &(pcnl->l))) {
+               iostat = analyze_pnt_in_vol(&(pcn->v), ap, 1);
+               if ((!report_outside && iostat == -1) || (report_outside && 
iostat != -1)) {
+                   npnt = _ged_pnts_dup((void *)pcn, RT_PNT_TYPE_COL_NRM);
+                   _ged_pnts_add(opnts, npnt);
+                   pntcnt++;
+               }
+           }
+           break;
+       case RT_PNT_TYPE_SCA_NRM:
+           psnl = (struct pnt_scale_normal *)pnts->point;
+           for (BU_LIST_FOR(psn, pnt_scale_normal, &(psnl->l))) {
+               iostat = analyze_pnt_in_vol(&(psn->v), ap, 1);
+               if ((!report_outside && iostat == -1) || (report_outside && 
iostat != -1)) {
+                   npnt = _ged_pnts_dup((void *)psn, RT_PNT_TYPE_SCA_NRM);
+                   _ged_pnts_add(opnts, npnt);
+                   pntcnt++;
+               }
+           }
+           break;
+       case RT_PNT_TYPE_COL_SCA_NRM:
+           pcsnl = (struct pnt_color_scale_normal *)pnts->point;
+           for (BU_LIST_FOR(pcsn, pnt_color_scale_normal, &(pcsnl->l))) {
+               iostat = analyze_pnt_in_vol(&(pcsn->v), ap, 1);
+               if (iostat == 1 || (report_outside && iostat != 1)) {
+                   npnt = _ged_pnts_dup((void *)pcsn, RT_PNT_TYPE_COL_SCA_NRM);
+                   _ged_pnts_add(opnts, npnt);
+                   pntcnt++;
+               }
+           }
+           break;
+       default:
+           bu_vls_printf(gedp->ged_result_str, "Unknown point type in object, 
aborting\n");
+           ret = GED_ERROR;
+           goto pnts_internal_memfree;
+    };
+
+    opnts->count = pntcnt;
+    GED_DB_DIRADD(gedp, dp, output_pnts_obj, RT_DIR_PHONY_ADDR, 0, 
RT_DIR_SOLID, (void *)&internal.idb_type, GED_ERROR);
+    GED_DB_PUT_INTERNAL(gedp, dp, &internal, &rt_uniresource, GED_ERROR);
+
+    bu_vls_printf(gedp->ged_result_str, "Generated pnts object %s with %ld 
matching points", output_pnts_obj, pntcnt);
+
+pnts_internal_memfree:
+    rt_db_free_internal(&tpnts_intern);
+    rt_clean_resource(rtip, resp);
+    rt_free_rti(rtip);
+    BU_PUT(resp, struct resource);
+    BU_PUT(ap, struct appliation);
+
+    return ret;
+}
+
+
 HIDDEN void
 _pnt_to_tri(point_t *p, vect_t *n, struct rt_bot_internal *bot_ip, fastf_t 
scale, unsigned long pntcnt)
 {
@@ -1163,7 +1391,7 @@
     int opt_ret = 0;
     int opt_argc = argc;
     struct bu_opt_desc d[2];
-    const char * const pnt_subcommands[] = {"gen", "read", "tri", "wn", 
"write", NULL};
+    const char * const pnt_subcommands[] = {"gen", "inside", "read", "tri", 
"wn", "write", NULL};
     const char * const *subcmd;
 
     BU_OPT(d[0], "h", "help",      "", NULL, &print_help,        "Print help 
and exit");
@@ -1221,6 +1449,9 @@
     }
 
     len = strlen(argv[0]);
+
+    if (bu_strncmp(argv[0], "inside", len) == 0) return _pnts_inside_obj(gedp, 
argc, argv);
+
     if (bu_strncmp(argv[0], "tri", len) == 0) return _pnts_to_bot(gedp, argc, 
argv);
 
     if (bu_strncmp(argv[0], "gen", len) == 0) return _obj_to_pnts(gedp, argc, 
argv);

Modified: brlcad/branches/analyze_cmd/src/libged/pnts_util.c
===================================================================
--- brlcad/branches/analyze_cmd/src/libged/pnts_util.c  2020-08-18 20:50:54 UTC 
(rev 76835)
+++ brlcad/branches/analyze_cmd/src/libged/pnts_util.c  2020-08-18 20:57:50 UTC 
(rev 76836)
@@ -392,6 +392,91 @@
     }
 }
 
+void *
+_ged_pnts_dup(void *point, rt_pnt_type type)
+{
+    void *npnt = NULL;
+    struct pnt *pstd, *pstdnew = NULL;
+    struct pnt_color *pc, *pcnew = NULL;
+    struct pnt_scale *ps, *psnew = NULL;
+    struct pnt_normal *pn, *pnnew = NULL;
+    struct pnt_color_scale *pcs, *pcsnew = NULL;
+    struct pnt_color_normal *pcn, *pcnnew = NULL;
+    struct pnt_scale_normal *psn, *psnnew = NULL;
+    struct pnt_color_scale_normal *pcsn, *pcsnnew = NULL;
+
+    switch (type) {
+       case RT_PNT_TYPE_PNT:
+           pstd = (struct pnt *)point;
+           npnt = _ged_pnts_new_pnt(type);
+           pstdnew = (struct pnt *)npnt;
+           VMOVE(pstdnew->v, pstd->v);
+           break;
+       case RT_PNT_TYPE_COL:
+           pc = (struct pnt_color *)point;
+           npnt = _ged_pnts_new_pnt(type);
+           pcnew = (struct pnt_color *)npnt;
+           VMOVE(pcnew->v, pc->v);
+           pcnew->c.buc_rgb[0] = pc->c.buc_rgb[0];
+           pcnew->c.buc_rgb[1] = pc->c.buc_rgb[1];
+           pcnew->c.buc_rgb[2] = pc->c.buc_rgb[2];
+           break;
+       case RT_PNT_TYPE_SCA:
+           ps = (struct pnt_scale *)point;
+           npnt = _ged_pnts_new_pnt(type);
+           psnew = (struct pnt_scale *)npnt;
+           VMOVE(psnew->v, ps->v);
+           psnew->s = ps->s;
+           break;
+       case RT_PNT_TYPE_NRM:
+           pn = (struct pnt_normal *)point;
+           npnt = _ged_pnts_new_pnt(type);
+           pnnew = (struct pnt_normal *)npnt;
+           VMOVE(pnnew->v, pn->v);
+           VMOVE(pnnew->n, pn->n);
+           break;
+       case RT_PNT_TYPE_COL_SCA:
+           pcs = (struct pnt_color_scale *)point;
+           npnt = _ged_pnts_new_pnt(type);
+           pcsnew = (struct pnt_color_scale *)npnt;
+           VMOVE(pcsnew->v, pcs->v);
+           pcsnew->c.buc_rgb[0] = pcs->c.buc_rgb[0];
+           pcsnew->c.buc_rgb[1] = pcs->c.buc_rgb[1];
+           pcsnew->c.buc_rgb[2] = pcs->c.buc_rgb[2];
+           pcsnew->s = pcs->s;
+           break;
+       case RT_PNT_TYPE_COL_NRM:
+           pcn = (struct pnt_color_normal *)point;
+           npnt = _ged_pnts_new_pnt(type);
+           pcnnew = (struct pnt_color_normal *)npnt;
+           VMOVE(pcnnew->v, pcn->v);
+           VMOVE(pcnnew->n, pcn->n);
+           break;
+       case RT_PNT_TYPE_SCA_NRM:
+           psn = (struct pnt_scale_normal *)point;
+           npnt = _ged_pnts_new_pnt(type);
+           psnnew = (struct pnt_scale_normal *)npnt;
+           VMOVE(psnnew->v, psn->v);
+           psnnew->s = psn->s;
+           VMOVE(psnnew->n, psn->n);
+           break;
+       case RT_PNT_TYPE_COL_SCA_NRM:
+           pcsn = (struct pnt_color_scale_normal *)point;
+           npnt = _ged_pnts_new_pnt(type);
+           pcsnnew = (struct pnt_color_scale_normal *)npnt;
+           VMOVE(pcsnnew->v, pcsn->v);
+           pcsnnew->c.buc_rgb[0] = pcsn->c.buc_rgb[0];
+           pcsnnew->c.buc_rgb[1] = pcsn->c.buc_rgb[1];
+           pcsnnew->c.buc_rgb[2] = pcsn->c.buc_rgb[2];
+           pcsnnew->s = pcsn->s;
+           VMOVE(pcsnnew->n, pcsn->n);
+           break;
+       default:
+           break;
+    }
+    return npnt;
+}
+
 /*
  * Local Variables:
  * tab-width: 8

Modified: brlcad/branches/analyze_cmd/src/libged/pnts_util.h
===================================================================
--- brlcad/branches/analyze_cmd/src/libged/pnts_util.h  2020-08-18 20:50:54 UTC 
(rev 76835)
+++ brlcad/branches/analyze_cmd/src/libged/pnts_util.h  2020-08-18 20:57:50 UTC 
(rev 76836)
@@ -60,6 +60,8 @@
 
 GED_EXPORT extern void _ged_pnts_add(struct rt_pnts_internal *pnts, void 
*point);
 
+GED_EXPORT extern void * _ged_pnts_dup(void *point, rt_pnt_type t);
+
 __END_DECLS
 
 #endif //LIBGED_PNT_GED_PRIVATE_H

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to