Revision: 76326
http://sourceforge.net/p/brlcad/code/76326
Author: starseeker
Date: 2020-07-14 16:34:25 +0000 (Tue, 14 Jul 2020)
Log Message:
-----------
Now able to write out a v4 asc file with gcv for moss
Modified Paths:
--------------
brlcad/trunk/src/libgcv/gcv.c
brlcad/trunk/src/libgcv/plugins/asc/asc.cpp
brlcad/trunk/src/libgcv/plugins/asc/asc_v4.cpp
Modified: brlcad/trunk/src/libgcv/gcv.c
===================================================================
--- brlcad/trunk/src/libgcv/gcv.c 2020-07-14 15:59:51 UTC (rev 76325)
+++ brlcad/trunk/src/libgcv/gcv.c 2020-07-14 16:34:25 UTC (rev 76326)
@@ -65,13 +65,19 @@
return 0;
}
- if (db_dump(context->dbip->dbi_wdbp, in_dbip)) {
- bu_log("db_dump() failed (from '%s' to context->dbip)\n", source_path);
+ if (db_version(in_dbip) > 4) {
+ if (db_dump(context->dbip->dbi_wdbp, in_dbip)) {
+ bu_log("db_dump() failed (from '%s' to context->dbip)\n",
source_path);
+ db_close(in_dbip);
+ return 0;
+ }
+
db_close(in_dbip);
- return 0;
+ } else {
+ // For v4 .g files, use the original rather than an inmem (which is v5)
+ db_close(context->dbip);
+ context->dbip = in_dbip;
}
-
- db_close(in_dbip);
return 1;
}
Modified: brlcad/trunk/src/libgcv/plugins/asc/asc.cpp
===================================================================
--- brlcad/trunk/src/libgcv/plugins/asc/asc.cpp 2020-07-14 15:59:51 UTC (rev
76325)
+++ brlcad/trunk/src/libgcv/plugins/asc/asc.cpp 2020-07-14 16:34:25 UTC (rev
76326)
@@ -32,11 +32,13 @@
#include <sstream>
#include <string>
+#include "rt/db_io.h"
#include "gcv/api.h"
#include "gcv/util.h"
extern void asc_read_v4(struct gcv_context *c, const struct gcv_opts *o,
std::ifstream &fs);
extern void asc_read_v5(struct gcv_context *c, const struct gcv_opts *o,
std::ifstream &fs);
+extern void asc_write_v4(struct gcv_context *c, const struct gcv_opts *o,
const char *dest_path);
extern void asc_write_v5(struct gcv_context *c, const struct gcv_opts *o,
const char *dest_path);
static int
@@ -117,9 +119,11 @@
const void *UNUSED(odata), const char *dest_path)
{
if (!c || !o || !dest_path) return 0;
- bu_log("asc write\n");
- // TODO - check for version option
- asc_write_v5(c, o, dest_path);
+ if (db_version(c->dbip) < 5) {
+ asc_write_v4(c, o, dest_path);
+ } else {
+ asc_write_v5(c, o, dest_path);
+ }
return 1;
}
Modified: brlcad/trunk/src/libgcv/plugins/asc/asc_v4.cpp
===================================================================
--- brlcad/trunk/src/libgcv/plugins/asc/asc_v4.cpp 2020-07-14 15:59:51 UTC
(rev 76325)
+++ brlcad/trunk/src/libgcv/plugins/asc/asc_v4.cpp 2020-07-14 16:34:25 UTC
(rev 76326)
@@ -1630,7 +1630,7 @@
ascv4_wdestroy(struct ascv4_wstate *s)
{
if (s->ofp) {
- fclose(s->ifp);
+ fclose(s->ofp);
}
BU_PUT(s, struct ascv4_wstate);
}
@@ -2559,7 +2559,7 @@
// Need to downgrade the db first, or update this logic to
// work with in-mem data rather than the disk file...
- if (db_version(c->dbip) < 5) {
+ if (db_version(c->dbip) > 4) {
bu_log("Attempting to write v4 asc output with a v5 database -
unsupported\n");
return 0;
}
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