Revision: 76455
http://sourceforge.net/p/brlcad/code/76455
Author: starseeker
Date: 2020-07-23 22:15:12 +0000 (Thu, 23 Jul 2020)
Log Message:
-----------
Cherrypick r75053 - avoid mixing open and C++ for Windows
Modified Paths:
--------------
brlcad/branches/RELEASE/src/libged/CMakeLists.txt
brlcad/branches/RELEASE/src/libged/facetize.cpp
brlcad/branches/RELEASE/src/libged/ged_private.h
Added Paths:
-----------
brlcad/branches/RELEASE/src/libged/facetize_log.c
Property Changed:
----------------
brlcad/branches/RELEASE/
Index: brlcad/branches/RELEASE
===================================================================
--- brlcad/branches/RELEASE 2020-07-23 22:01:22 UTC (rev 76454)
+++ brlcad/branches/RELEASE 2020-07-23 22:15:12 UTC (rev 76455)
Property changes on: brlcad/branches/RELEASE
___________________________________________________________________
Modified: svn:mergeinfo
## -6,4 +6,4 ##
/brlcad/branches/opencl:65867-66137
/brlcad/branches/osg:62110-62113
/brlcad/branches/prep-cache:68236-68933
-/brlcad/trunk:36844-37285,37571-38764,38777-38845,41559-43155,43159-43908,44241-44324,44326-44385,44710-45373,45377,45379-47342,47370-68122,68125-74976,74981,74991,75000,75056,75063-75064,75077-75078,75084,75325,75375,75377-75378,75387,75470-75472,75477,75492,75495,75549,75565-75566,75656-75661,75672,75675,75678,75811
\ No newline at end of property
+/brlcad/trunk:36844-37285,37571-38764,38777-38845,41559-43155,43159-43908,44241-44324,44326-44385,44710-45373,45377,45379-47342,47370-68122,68125-74976,74981,74991,75000,75053,75056,75063-75064,75077-75078,75084,75325,75375,75377-75378,75387,75470-75472,75477,75492,75495,75549,75565-75566,75656-75661,75672,75675,75678,75811
\ No newline at end of property
Modified: brlcad/branches/RELEASE/src/libged/CMakeLists.txt
===================================================================
--- brlcad/branches/RELEASE/src/libged/CMakeLists.txt 2020-07-23 22:01:22 UTC
(rev 76454)
+++ brlcad/branches/RELEASE/src/libged/CMakeLists.txt 2020-07-23 22:15:12 UTC
(rev 76455)
@@ -147,6 +147,7 @@
eye.c
eye_pos.c
facedef.c
+ facetize_log.c
facetize.cpp
fb2pix.c
fbclear.c
Modified: brlcad/branches/RELEASE/src/libged/facetize.cpp
===================================================================
--- brlcad/branches/RELEASE/src/libged/facetize.cpp 2020-07-23 22:01:22 UTC
(rev 76454)
+++ brlcad/branches/RELEASE/src/libged/facetize.cpp 2020-07-23 22:15:12 UTC
(rev 76455)
@@ -150,55 +150,6 @@
return ret;
}
-struct _ged_facetize_opts {
-
- int quiet;
- int verbosity;
- int regions;
- int resume;
- int retry;
- int in_place;
- fastf_t feature_size;
- fastf_t feature_scale;
- fastf_t d_feature_size;
- int max_time;
- struct bg_tess_tol *tol;
- struct bu_vls *faceted_suffix;
-
- /* NMG specific options */
- int triangulate;
- int make_nmg;
- int nmgbool;
- int screened_poisson;
- int continuation;
- int method_flags;
- int nmg_use_tnurbs;
-
- /* Poisson specific options */
- int max_pnts;
- struct bg_3d_spsr_opts s_opts;
-
- /* Brep specific options */
- double nonovlp_threshold;
-
- /* internal */
- struct bu_attribute_value_set *c_map;
- struct bu_attribute_value_set *s_map;
- struct bu_hook_list *saved_bomb_hooks;
- struct bu_hook_list *saved_log_hooks;
- struct bu_vls *nmg_log;
- struct bu_vls *nmg_log_header;
- int nmg_log_print_header;
- int stderr_stashed;
- int serr;
- int fnull;
-
- struct bu_vls *froot;
- struct bu_vls *nmg_comb;
- struct bu_vls *continuation_comb;
- struct bu_vls *spsr_comb;
-};
-
struct _ged_facetize_opts * _ged_facetize_opts_create()
{
struct bg_3d_spsr_opts s_opts = BG_3D_SPSR_OPTS_DEFAULT;
@@ -358,87 +309,7 @@
}
}
-
-static int
-_ged_facetize_bomb_hook(void *cdata, void *str)
-{
- struct _ged_facetize_opts *o = (struct _ged_facetize_opts *)cdata;
- if (o->nmg_log_print_header) {
- bu_vls_printf(o->nmg_log, "%s\n", bu_vls_addr(o->nmg_log_header));
- o->nmg_log_print_header = 0;
- }
- bu_vls_printf(o->nmg_log, "%s\n", (const char *)str);
- return 0;
-}
-
-static int
-_ged_facetize_nmg_logging_hook(void *data, void *str)
-{
- struct _ged_facetize_opts *o = (struct _ged_facetize_opts *)data;
- if (o->nmg_log_print_header) {
- bu_vls_printf(o->nmg_log, "%s\n", bu_vls_addr(o->nmg_log_header));
- o->nmg_log_print_header = 0;
- }
- bu_vls_printf(o->nmg_log, "%s\n", (const char *)str);
- return 0;
-}
-
static void
-_ged_facetize_log_nmg(struct _ged_facetize_opts *o)
-{
- if (fileno(stderr) < 0)
- return;
-
- /* Seriously, bu_bomb, we don't want you blathering
- * to stderr... shut down stderr temporarily, assuming
- * we can find /dev/null or something similar */
- o->fnull = open("/dev/null", O_WRONLY);
- if (o->fnull == -1) {
- /* https://gcc.gnu.org/ml/gcc-patches/2005-05/msg01793.html */
- o->fnull = open("nul", O_WRONLY);
- }
- if (o->fnull != -1) {
- o->serr = fileno(stderr);
- o->stderr_stashed = dup(o->serr);
- dup2(o->fnull, o->serr);
- close(o->fnull);
- }
-
- /* Set bu_log logging to capture in nmg_log, rather than the
- * application defaults */
- bu_log_hook_delete_all();
- bu_log_add_hook(_ged_facetize_nmg_logging_hook, (void *)o);
-
- /* Also engage the nmg bomb hooks */
- bu_bomb_delete_all_hooks();
- bu_bomb_add_hook(_ged_facetize_bomb_hook, (void *)o);
-}
-
-
-static void
-_ged_facetize_log_default(struct _ged_facetize_opts *o)
-{
- if (fileno(stderr) < 0)
- return;
-
- /* Put stderr back */
- if (o->fnull != -1) {
- fflush(stderr);
- dup2(o->stderr_stashed, o->serr);
- close(o->stderr_stashed);
- o->fnull = -1;
- }
-
- /* Restore bu_bomb hooks to the application defaults */
- bu_bomb_delete_all_hooks();
- bu_bomb_restore_hooks(o->saved_bomb_hooks);
-
- /* Restore bu_log hooks to the application defaults */
- bu_log_hook_delete_all();
- bu_log_hook_restore_all(o->saved_log_hooks);
-}
-
-static void
_ged_facetize_mkname(struct ged *gedp, struct _ged_facetize_opts *opts, const
char *n, int type)
{
struct bu_vls incr_template = BU_VLS_INIT_ZERO;
@@ -3102,12 +2973,12 @@
}
-/*
- * Local Variables:
- * tab-width: 8
- * mode: C
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
+
+// Local Variables:
+// tab-width: 8
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// c-file-style: "stroustrup"
+// End:
+// ex: shiftwidth=4 tabstop=8
Copied: brlcad/branches/RELEASE/src/libged/facetize_log.c (from rev 75053,
brlcad/trunk/src/libged/facetize_log.c)
===================================================================
--- brlcad/branches/RELEASE/src/libged/facetize_log.c
(rev 0)
+++ brlcad/branches/RELEASE/src/libged/facetize_log.c 2020-07-23 22:15:12 UTC
(rev 76455)
@@ -0,0 +1,121 @@
+/* F A C E T I Z E _ L O G . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2008-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 libged/facetize_log.c
+ *
+ * logging mechanisms for the facetize command.
+ *
+ */
+
+#include "common.h"
+
+#include <string.h>
+
+#include "bu/hook.h"
+#include "bu/vls.h"
+#include "./ged_private.h"
+
+static int
+_ged_facetize_bomb_hook(void *cdata, void *str)
+{
+ struct _ged_facetize_opts *o = (struct _ged_facetize_opts *)cdata;
+ if (o->nmg_log_print_header) {
+ bu_vls_printf(o->nmg_log, "%s\n", bu_vls_addr(o->nmg_log_header));
+ o->nmg_log_print_header = 0;
+ }
+ bu_vls_printf(o->nmg_log, "%s\n", (const char *)str);
+ return 0;
+}
+
+static int
+_ged_facetize_nmg_logging_hook(void *data, void *str)
+{
+ struct _ged_facetize_opts *o = (struct _ged_facetize_opts *)data;
+ if (o->nmg_log_print_header) {
+ bu_vls_printf(o->nmg_log, "%s\n", bu_vls_addr(o->nmg_log_header));
+ o->nmg_log_print_header = 0;
+ }
+ bu_vls_printf(o->nmg_log, "%s\n", (const char *)str);
+ return 0;
+}
+
+void
+_ged_facetize_log_nmg(struct _ged_facetize_opts *o)
+{
+ if (fileno(stderr) < 0)
+ return;
+
+ /* Seriously, bu_bomb, we don't want you blathering
+ * to stderr... shut down stderr temporarily, assuming
+ * we can find /dev/null or something similar */
+ o->fnull = open("/dev/null", O_WRONLY);
+ if (o->fnull == -1) {
+ /* https://gcc.gnu.org/ml/gcc-patches/2005-05/msg01793.html */
+ o->fnull = open("nul", O_WRONLY);
+ }
+ if (o->fnull != -1) {
+ o->serr = fileno(stderr);
+ o->stderr_stashed = dup(o->serr);
+ dup2(o->fnull, o->serr);
+ close(o->fnull);
+ }
+
+ /* Set bu_log logging to capture in nmg_log, rather than the
+ * application defaults */
+ bu_log_hook_delete_all();
+ bu_log_add_hook(_ged_facetize_nmg_logging_hook, (void *)o);
+
+ /* Also engage the nmg bomb hooks */
+ bu_bomb_delete_all_hooks();
+ bu_bomb_add_hook(_ged_facetize_bomb_hook, (void *)o);
+}
+
+
+void
+_ged_facetize_log_default(struct _ged_facetize_opts *o)
+{
+ if (fileno(stderr) < 0)
+ return;
+
+ /* Put stderr back */
+ if (o->fnull != -1) {
+ fflush(stderr);
+ dup2(o->stderr_stashed, o->serr);
+ close(o->stderr_stashed);
+ o->fnull = -1;
+ }
+
+ /* Restore bu_bomb hooks to the application defaults */
+ bu_bomb_delete_all_hooks();
+ bu_bomb_restore_hooks(o->saved_bomb_hooks);
+
+ /* Restore bu_log hooks to the application defaults */
+ bu_log_hook_delete_all();
+ bu_log_hook_restore_all(o->saved_log_hooks);
+}
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Modified: brlcad/branches/RELEASE/src/libged/ged_private.h
===================================================================
--- brlcad/branches/RELEASE/src/libged/ged_private.h 2020-07-23 22:01:22 UTC
(rev 76454)
+++ brlcad/branches/RELEASE/src/libged/ged_private.h 2020-07-23 22:15:12 UTC
(rev 76455)
@@ -30,7 +30,10 @@
#include <time.h>
+#include "bu/avs.h"
#include "bu/opt.h"
+#include "bg/spsr.h"
+#include "bg/trimesh.h"
#include "rt/db4.h"
#include "raytrace.h"
#include "rt/geom.h"
@@ -612,6 +615,63 @@
extern void
_ged_delete_io_handler(void *interp, void *chan, struct bu_process *p, int fd,
void *data, io_handler_callback_t callback);
+
+
+/* Ideally all of this could be in facetize.cpp, but the open() calls
+ * used by the logging routines are problematic in C++ with Visual C++. */
+struct _ged_facetize_opts {
+ int quiet;
+ int verbosity;
+ int regions;
+ int resume;
+ int retry;
+ int in_place;
+ fastf_t feature_size;
+ fastf_t feature_scale;
+ fastf_t d_feature_size;
+ int max_time;
+ struct bg_tess_tol *tol;
+ struct bu_vls *faceted_suffix;
+
+ /* NMG specific options */
+ int triangulate;
+ int make_nmg;
+ int nmgbool;
+ int screened_poisson;
+ int continuation;
+ int method_flags;
+ int nmg_use_tnurbs;
+
+ /* Poisson specific options */
+ int max_pnts;
+ struct bg_3d_spsr_opts s_opts;
+
+ /* Brep specific options */
+ double nonovlp_threshold;
+
+ /* internal */
+ struct bu_attribute_value_set *c_map;
+ struct bu_attribute_value_set *s_map;
+ struct bu_hook_list *saved_bomb_hooks;
+ struct bu_hook_list *saved_log_hooks;
+ struct bu_vls *nmg_log;
+ struct bu_vls *nmg_log_header;
+ int nmg_log_print_header;
+ int stderr_stashed;
+ int serr;
+ int fnull;
+
+ struct bu_vls *froot;
+ struct bu_vls *nmg_comb;
+ struct bu_vls *continuation_comb;
+ struct bu_vls *spsr_comb;
+};
+
+void
+_ged_facetize_log_nmg(struct _ged_facetize_opts *o);
+void
+_ged_facetize_log_default(struct _ged_facetize_opts *o);
+
__END_DECLS
#endif /* LIBGED_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