Revision: 76690
http://sourceforge.net/p/brlcad/code/76690
Author: starseeker
Date: 2020-08-07 22:47:46 +0000 (Fri, 07 Aug 2020)
Log Message:
-----------
More work on bg_vlist functions
Modified Paths:
--------------
brlcad/branches/bioh/include/bg/vlist.h
brlcad/branches/bioh/src/libbg/vlist.cpp
Modified: brlcad/branches/bioh/include/bg/vlist.h
===================================================================
--- brlcad/branches/bioh/include/bg/vlist.h 2020-08-07 20:03:58 UTC (rev
76689)
+++ brlcad/branches/bioh/include/bg/vlist.h 2020-08-07 22:47:46 UTC (rev
76690)
@@ -119,16 +119,16 @@
* size is set via command, it applies to the points/segments defined after
that
* command is introduced. */
-BG_EXPORT extern size_t
+BG_EXPORT extern size_t
bg_vlist_npts(struct bg_vlist *v);
BG_EXPORT extern size_t
bg_vlist_ncmds(struct bg_vlist *v);
-BG_EXPORT extern long
+BG_EXPORT extern int
bg_vlist_append(struct bg_vlist *v, bg_vlist_cmd_t cmd, point_t *p);
-BG_EXPORT extern long
+BG_EXPORT extern int
bg_vlist_insert(struct bg_vlist *v, size_t i, bg_vlist_cmd_t cmd, point_t *p);
BG_EXPORT extern bg_vlist_cmd_t
Modified: brlcad/branches/bioh/src/libbg/vlist.cpp
===================================================================
--- brlcad/branches/bioh/src/libbg/vlist.cpp 2020-08-07 20:03:58 UTC (rev
76689)
+++ brlcad/branches/bioh/src/libbg/vlist.cpp 2020-08-07 22:47:46 UTC (rev
76690)
@@ -86,6 +86,16 @@
void
bg_vlist_destroy(struct bg_vlist *v)
{
+ if (v->i->q) {
+ // If we're using a queue, all of the objects
+ // in this vlist will be available for reuse
+ for (size_t i = 0; i < v->i->v.size(); i++) {
+ vobj &nv = v->i->q->i->objs[v->i->v[i]];
+ VSET(nv.p, 0, 0, 0);
+ nv.cmd = BG_VLIST_NULL;
+ v->i->q->i->free_objs.push(v->i->v[i]);
+ }
+ }
delete[] v->i;
BU_PUT(v, struct bg_vlist);
}
@@ -132,6 +142,64 @@
return cnt;
}
+int
+bg_vlist_append(struct bg_vlist *v, bg_vlist_cmd_t cmd, point_t *p)
+{
+ if (!v) {
+ return -1;
+ }
+ if (v->i->q) {
+ size_t nobj = v->i->q->i->free_objs.front();
+ v->i->q->i->free_objs.pop();
+ vobj &nv = v->i->q->i->objs[nobj];
+ nv.cmd = cmd;
+ if (p) {
+ VMOVE(nv.p, *p);
+ }
+ v->i->v.push_back(nobj);
+ } else {
+ vobj nv;
+ nv.cmd = cmd;
+ if (p) {
+ VMOVE(nv.p, *p);
+ }
+ v->i->vlocal.push_back(nv);
+ v->i->v.push_back(v->i->vlocal.size() - 1);
+ }
+
+ return 0;
+}
+
+int
+bg_vlist_insert(struct bg_vlist *v, size_t i, bg_vlist_cmd_t cmd, point_t *p)
+{
+ if (!v) {
+ return -1;
+ }
+ if (v->i->q) {
+ size_t nobj = v->i->q->i->free_objs.front();
+ v->i->q->i->free_objs.pop();
+ vobj &nv = v->i->q->i->objs[nobj];
+ nv.cmd = cmd;
+ if (p) {
+ VMOVE(nv.p, *p);
+ }
+ std::vector<size_t>::iterator v_it = v->i->v.begin()+i;
+ v->i->v.insert(v_it, nobj);
+ } else {
+ vobj nv;
+ nv.cmd = cmd;
+ if (p) {
+ VMOVE(nv.p, *p);
+ }
+ v->i->vlocal.push_back(nv);
+ std::vector<size_t>::iterator v_it = v->i->v.begin()+i;
+ v->i->v.insert(v_it, v->i->vlocal.size() - 1);
+ }
+
+ return 0;
+}
+
bg_vlist_cmd_t
bg_vlist_get(point_t *op, struct bg_vlist *v, size_t i)
{
@@ -147,6 +215,27 @@
return cv.cmd;
}
+
+int
+bg_vlist_set(struct bg_vlist *v, size_t i, point_t *p, bg_vlist_cmd_t cmd)
+{
+ if (i > v->i->v.size() - 1) {
+ return -1;
+ }
+
+ // Actual node info is either in the queue or the local vector
+ vobj &cv = (v->i->q) ? v->i->q->i->objs[v->i->v[i]] :
v->i->vlocal[v->i->v[i]];
+ if (p) {
+ VMOVE(cv.p, *p);
+ }
+ if (cmd != BG_VLIST_NULL) {
+ cv.cmd = cmd;
+ }
+
+ return 0;
+}
+
+
size_t
bg_vlist_find(struct bg_vlist *v, size_t start_ind, bg_vlist_cmd_t cmd,
point_t *p)
{
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