Revision: 44633
http://brlcad.svn.sourceforge.net/brlcad/?rev=44633&view=rev
Author: r_weiss
Date: 2011-05-19 15:45:40 +0000 (Thu, 19 May 2011)
Log Message:
-----------
Updated nmg boolean functions using the classlist array. Changed the classlist
type from 'size_t' to 'short'.
Modified Paths:
--------------
brlcad/trunk/include/raytrace.h
brlcad/trunk/src/librt/primitives/nmg/nmg_bool.c
brlcad/trunk/src/librt/primitives/nmg/nmg_class.c
brlcad/trunk/src/librt/primitives/nmg/nmg_eval.c
brlcad/trunk/src/librt/primitives/nmg/nmg_plot.c
Modified: brlcad/trunk/include/raytrace.h
===================================================================
--- brlcad/trunk/include/raytrace.h 2011-05-18 22:13:15 UTC (rev 44632)
+++ brlcad/trunk/include/raytrace.h 2011-05-19 15:45:40 UTC (rev 44633)
@@ -5245,7 +5245,7 @@
/* graphical display of classifier results */
RT_EXPORT BU_EXTERN(void nmg_show_broken_classifier_stuff,
(unsigned long *p,
- size_t *classlist[4],
+ short **classlist,
int all_new,
int fancy,
const char *a_string));
@@ -5354,7 +5354,7 @@
RT_EXPORT BU_EXTERN(void nmg_class_shells,
(struct shell *sA,
struct shell *sB,
- size_t *classlist[4],
+ short **classlist,
const struct bn_tol *tol));
/* from nmg_fcut.c */
@@ -5414,7 +5414,7 @@
(struct shell *sA,
struct shell *sB,
int op,
- size_t *classlist[8],
+ short **classlist,
const struct bn_tol *tol));
/* The following functions cannot be publicly declared because struct
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_bool.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_bool.c 2011-05-18 22:13:15 UTC
(rev 44632)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_bool.c 2011-05-19 15:45:40 UTC
(rev 44633)
@@ -119,7 +119,7 @@
* edge.
*/
void
-nmg_show_each_loop(struct shell *s, size_t **classlist, int new, int fancy,
const char *str)
+nmg_show_each_loop(struct shell *s, short **classlist, int new, int fancy,
const char *str)
/* non-zero means flush previous vlist */
@@ -343,7 +343,7 @@
*/
static void
-nmg_classify_shared_edges_verts(struct shell *sA, struct shell *sB, size_t
**classlist)
+nmg_classify_shared_edges_verts(struct shell *sA, struct shell *sB, short
**classlist)
{
struct bu_ptbl verts;
struct bu_ptbl edges;
@@ -551,9 +551,8 @@
static struct shell * nmg_bool(struct shell *sA, struct shell *sB, const int
oper, const struct bn_tol *tol)
{
int i;
- size_t nelem;
- size_t *classlist[8];
- size_t *classlist_base;
+ long nelem;
+ short *classlist[8];
FILE *fd, *fp;
struct model *m;
struct nmgregion *rA;
@@ -662,25 +661,16 @@
nmg_m_reindex(m, 0);
- /*
- * Allocate storage for classlist[].
- * Get all 8 lists at once, and just build pointers for the rest.
- * XXX In some cases, number of items may grow
- * XXX (e.g. added vu's, loops) as things are demoted, etc.
- * XXX Try to accomodate here by reserving some extra table space.
- *
- * XXX The classlist really only needs to be an unsigned char,
- * XXX not a long*.
+ /* Allocate storage for classlist[].
+ * Allocate each of the 8 class lists one at a time. This will
+ * assist with debugging to determine if each array read/write
+ * is within its allocated space. The datatype needs to accommodate
+ * values -1 thru 7 therefore a signed datatype is necessary.
*/
- /* It needs to be determined how much extra space is needed.
- * Maybe space can be increased as necessary.
- */
- nelem = (m->maxindex)*10+1; /* includes extra space */
- classlist_base = (size_t *)bu_calloc(8 * nelem + 1,
- sizeof(size_t), "nmg_bool classlist_base");
+ nelem = m->maxindex;
for (i = 0; i < 8; i++) {
- classlist[i] = classlist_base + 8 + (i * nelem);
+ classlist[i] = (short *)bu_calloc(nelem, sizeof(short), "nmg_bool
classlist_base");
}
nmg_classify_shared_edges_verts(sA, sB, classlist);
@@ -803,8 +793,7 @@
nmg_class_nothing_broken = 1;
if (rt_g.NMG_debug & (DEBUG_GRAPHCL|DEBUG_PL_LOOP)) {
- nmg_show_broken_classifier_stuff((unsigned long *)sA, &classlist[0],
- nmg_class_nothing_broken, 1,
"unclassed sA");
+ nmg_show_broken_classifier_stuff((unsigned long *)sA, &classlist[0],
nmg_class_nothing_broken, 1, "unclassed sA");
nmg_show_broken_classifier_stuff((unsigned long *)sB, &classlist[4], 1,
1, "unclassed sB");
}
@@ -815,12 +804,12 @@
* A -vs- B live in classlist[0..3], B -vs- A live in classlist[4..7].
*/
nmg_class_shells(sA, sB, &classlist[0], tol);
- memcpy((size_t *)classlist[4+NMG_CLASS_AonBshared],
- (size_t *)classlist[0+NMG_CLASS_AonBshared],
- nelem*sizeof(size_t *));
- memcpy((size_t *)classlist[4+NMG_CLASS_AonBanti],
- (size_t *)classlist[0+NMG_CLASS_AonBanti],
- nelem*sizeof(size_t *));
+ memcpy((short *)classlist[4+NMG_CLASS_AonBshared],
+ (short *)classlist[0+NMG_CLASS_AonBshared],
+ nelem*sizeof(short *));
+ memcpy((short *)classlist[4+NMG_CLASS_AonBanti],
+ (short *)classlist[0+NMG_CLASS_AonBanti],
+ nelem*sizeof(short *));
nmg_class_shells(sB, sA, &classlist[4], tol);
if (rt_g.NMG_debug & (DEBUG_GRAPHCL|DEBUG_PL_LOOP)) {
@@ -923,7 +912,9 @@
}
}
- bu_free((size_t *)classlist_base, "nmg_bool classlist_base");
+ for (i = 0; i < 8; i++) {
+ bu_free((short *)classlist[i], "nmg_bool classlist");
+ }
if (rt_g.NMG_debug & DEBUG_BOOL) {
bu_log("Returning from NMG_BOOL\n");
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_class.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_class.c 2011-05-18 22:13:15 UTC
(rev 44632)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_class.c 2011-05-19 15:45:40 UTC
(rev 44633)
@@ -80,13 +80,13 @@
const point_t pt, const struct loopuse *lu,
const struct bn_tol *tol));
static int class_vu_vs_s BU_ARGS((struct vertexuse *vu, struct shell *sB,
- size_t *classlist[4], const struct bn_tol
*tol));
+ short **classlist, const struct bn_tol *tol));
static int class_eu_vs_s BU_ARGS((struct edgeuse *eu, struct shell *s,
- size_t *classlist[4], const struct bn_tol
*tol));
+ short **classlist, const struct bn_tol *tol));
static int class_lu_vs_s BU_ARGS((struct loopuse *lu, struct shell *s,
- size_t *classlist[4], const struct bn_tol
*tol));
+ short **classlist, const struct bn_tol *tol));
static void class_fu_vs_s BU_ARGS((struct faceuse *fu, struct shell *s,
- size_t *classlist[4], const struct bn_tol
*tol));
+ short **classlist, const struct bn_tol
*tol));
/**
* N M G _ C L A S S _ S T A T U S
@@ -744,7 +744,7 @@
* Classify a loopuse/vertexuse from shell A WRT shell B.
*/
static int
-class_vu_vs_s(struct vertexuse *vu, struct shell *sB, size_t **classlist,
const struct bn_tol *tol)
+class_vu_vs_s(struct vertexuse *vu, struct shell *sB, short **classlist, const
struct bn_tol *tol)
{
struct vertexuse *vup;
pointp_t pt;
@@ -864,7 +864,7 @@
* C L A S S _ E U _ V S _ S
*/
static int
-class_eu_vs_s(struct edgeuse *eu, struct shell *s, size_t **classlist, const
struct bn_tol *tol)
+class_eu_vs_s(struct edgeuse *eu, struct shell *s, short **classlist, const
struct bn_tol *tol)
{
int euv_cl, matev_cl;
int status = 0;
@@ -1209,7 +1209,7 @@
* "newclass" should only be AonBshared or AonBanti.
*/
void
-nmg_reclassify_lu_eu(struct loopuse *lu, size_t **classlist, int newclass)
+nmg_reclassify_lu_eu(struct loopuse *lu, short **classlist, int newclass)
{
struct vertexuse *vu;
struct edgeuse *eu;
@@ -1454,7 +1454,7 @@
* class_fu_vs_s
*/
static int
-class_lu_vs_s(struct loopuse *lu, struct shell *s, size_t **classlist, const
struct bn_tol *tol)
+class_lu_vs_s(struct loopuse *lu, struct shell *s, short **classlist, const
struct bn_tol *tol)
{
int class;
unsigned int in, outside, on;
@@ -1838,7 +1838,7 @@
* nmg_class_shells()
*/
static void
-class_fu_vs_s(struct faceuse *fu, struct shell *s, size_t **classlist, const
struct bn_tol *tol)
+class_fu_vs_s(struct faceuse *fu, struct shell *s, short **classlist, const
struct bn_tol *tol)
{
struct loopuse *lu;
plane_t n;
@@ -1872,7 +1872,7 @@
* nmg_bool.c
*/
void
-nmg_class_shells(struct shell *sA, struct shell *sB, size_t **classlist, const
struct bn_tol *tol)
+nmg_class_shells(struct shell *sA, struct shell *sB, short **classlist, const
struct bn_tol *tol)
{
struct faceuse *fu;
struct loopuse *lu;
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_eval.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_eval.c 2011-05-18 22:13:15 UTC
(rev 44632)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_eval.c 2011-05-19 15:45:40 UTC
(rev 44633)
@@ -43,7 +43,7 @@
struct shell *bs_dest;
struct shell *bs_src;
int bs_isA; /* true if A, else doing B */
- size_t **bs_classtab;
+ short **bs_classtab;
const int *bs_actions;
const struct bn_tol *bs_tol;
};
@@ -193,7 +193,7 @@
*
*/
void
-nmg_evaluate_boolean(struct shell *sA, struct shell *sB, int op, size_t
**classlist, const struct bn_tol *tol)
+nmg_evaluate_boolean(struct shell *sA, struct shell *sB, int op, short
**classlist, const struct bn_tol *tol)
{
int const *actions;
struct nmg_bool_state bool_state;
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_plot.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_plot.c 2011-05-18 22:13:15 UTC
(rev 44632)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_plot.c 2011-05-19 15:45:40 UTC
(rev 44633)
@@ -1515,7 +1515,7 @@
************************************************************************/
int nmg_class_nothing_broken=1;
-static size_t **global_classlist;
+static short **global_classlist;
static long *broken_tab;
static int broken_tab_len;
static int broken_color;
@@ -1528,7 +1528,7 @@
{ 255, 255, 125 } /* no classification list (cyan) */
};
#define PICK_BROKEN_COLOR(p) { \
- if (global_classlist == (size_t **)NULL) { \
+ if (global_classlist == (short **)NULL) { \
broken_color = 5; \
} else if (NMG_INDEX_TEST(global_classlist[NMG_CLASS_AinB], (p))) \
broken_color = NMG_CLASS_AinB; \
@@ -1808,7 +1808,7 @@
* that this is a graphical display of classifier operation.
*/
void
-nmg_show_broken_classifier_stuff(unsigned long *p, size_t **classlist, int
all_new, int fancy, const char *a_string)
+nmg_show_broken_classifier_stuff(unsigned long *p, short **classlist, int
all_new, int fancy, const char *a_string)
{
static struct bn_vlblock *vbp = (struct bn_vlblock *)NULL;
struct model *m;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits