[brlcad-commits] SF.net SVN: brlcad:[61672] brlcad/branches/openscenegraph
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <sta...@us...> - 2014-07-11 19:24:57
|
Revision: 61672 http://sourceforge.net/p/brlcad/code/61672 Author: starseeker Date: 2014-07-11 19:24:42 +0000 (Fri, 11 Jul 2014) Log Message: ----------- Sync through trunk r61669 Revision Links: -------------- http://sourceforge.net/p/brlcad/code/61669 Modified Paths: -------------- brlcad/branches/openscenegraph/AUTHORS brlcad/branches/openscenegraph/NEWS brlcad/branches/openscenegraph/doc/docbook/system/man1/en/orle-fb.xml brlcad/branches/openscenegraph/doc/docbook/system/man1/en/orle-pix.xml brlcad/branches/openscenegraph/doc/docbook/system/man1/en/pix-ps.xml brlcad/branches/openscenegraph/doc/docbook/system/man1/en/pix-rle.xml brlcad/branches/openscenegraph/doc/docbook/system/man1/en/rle-fb.xml brlcad/branches/openscenegraph/doc/docbook/system/man1/en/tire.xml brlcad/branches/openscenegraph/doc/docbook/system/man1/en/wdb_example.xml brlcad/branches/openscenegraph/doc/docbook/system/mann/en/wire.xml brlcad/branches/openscenegraph/include/config_win.h.in brlcad/branches/openscenegraph/include/dm/dm-Null.h brlcad/branches/openscenegraph/include/dm.h brlcad/branches/openscenegraph/include/fb.h brlcad/branches/openscenegraph/sh/enumerate.sh brlcad/branches/openscenegraph/src/conv/3dm/3dm-g.cpp brlcad/branches/openscenegraph/src/conv/3dm/conv3dm-g.cpp brlcad/branches/openscenegraph/src/conv/3dm/conv3dm-g.hpp brlcad/branches/openscenegraph/src/conv/comgeom/mat.c brlcad/branches/openscenegraph/src/conv/g-shell-rect.c brlcad/branches/openscenegraph/src/conv/nmg/asc-nmg.c brlcad/branches/openscenegraph/src/conv/nmg/g-nmg.c brlcad/branches/openscenegraph/src/conv/step/BRLCADWrapper.cpp brlcad/branches/openscenegraph/src/conv/step/BRLCADWrapper.h brlcad/branches/openscenegraph/src/conv/step/STEPWrapper.cpp brlcad/branches/openscenegraph/src/libbrep/PullbackCurve.cpp brlcad/branches/openscenegraph/src/libbrep/opennurbs_ext.cpp brlcad/branches/openscenegraph/src/libdm/dm-Null.c brlcad/branches/openscenegraph/src/libdm/dm-plot.c brlcad/branches/openscenegraph/src/libdm/dm-ps.c brlcad/branches/openscenegraph/src/libdm/dm-qt.cpp brlcad/branches/openscenegraph/src/libdm/dm-txt.c brlcad/branches/openscenegraph/src/libfb/if_qt.cpp brlcad/branches/openscenegraph/src/librt/primitives/brep/brep.cpp brlcad/branches/openscenegraph/src/librt/primitives/brep/brep_debug.cpp brlcad/branches/openscenegraph/src/mged/dm-qt.c brlcad/branches/openscenegraph/src/rt/viewarea.c brlcad/branches/openscenegraph/src/util/pix-ps.c Added Paths: ----------- brlcad/branches/openscenegraph/src/conv/3dm/solidity.cpp brlcad/branches/openscenegraph/src/conv/3dm/solidity.h Property Changed: ---------------- brlcad/branches/openscenegraph/ brlcad/branches/openscenegraph/src/libged/polyclip.cpp Index: brlcad/branches/openscenegraph =================================================================== --- brlcad/branches/openscenegraph 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph 2014-07-11 19:24:42 UTC (rev 61672) Property changes on: brlcad/branches/openscenegraph ___________________________________________________________________ Modified: svn:mergeinfo ## -1,3 +1,3 ## /brlcad/branches/RELEASE:57448-57860 /brlcad/branches/cmake:43219 -/brlcad/trunk:60102-61430,61432-61609 +/brlcad/trunk:60102-61430,61432-61669 \ No newline at end of property Modified: brlcad/branches/openscenegraph/AUTHORS =================================================================== --- brlcad/branches/openscenegraph/AUTHORS 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/AUTHORS 2014-07-11 19:24:42 UTC (rev 61672) @@ -743,7 +743,11 @@ 2014 July ARL Student Hire +Roberts, Mitchell +2014 July +ARL Student Hire + SPECIAL THANKS -------------- Modified: brlcad/branches/openscenegraph/NEWS =================================================================== --- brlcad/branches/openscenegraph/NEWS 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/NEWS 2014-07-11 19:24:42 UTC (rev 61672) @@ -14,6 +14,7 @@ --- 2014-XX-XX Release 7.26.XX --- ---------------------------------------------------------------------- +* fixed pix-ps -S -W -N output size options being ignored - Carl Moore * fixed crash exporting mixed mode merged BoT meshes - Sean Morrison * fixed submodel primitive crash - Cliff Yapp, Sean Morrison * support non-.g file import in Archer's file open dialog - Cliff Yapp Modified: brlcad/branches/openscenegraph/doc/docbook/system/man1/en/orle-fb.xml =================================================================== --- brlcad/branches/openscenegraph/doc/docbook/system/man1/en/orle-fb.xml 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/doc/docbook/system/man1/en/orle-fb.xml 2014-07-11 19:24:42 UTC (rev 61672) @@ -61,8 +61,8 @@ <varlistentry> <term><option>-d</option></term> <listitem> -<para>Debug option, provides verbose description of file structure and -processes called, written on standard error.</para> +<para>Debug option; provides verbose description of file structure and +processes called; written on standard error.</para> </listitem> </varlistentry> <varlistentry> @@ -83,7 +83,7 @@ </listitem> </varlistentry> <varlistentry> - <term><option>-b</option><replaceable>x</replaceable></term> + <term><option>-b </option><replaceable>x</replaceable></term> <listitem> <para>If the image is not being decoded in overlay mode, the background is normally set to the value recorded in the RLE file. @@ -108,7 +108,7 @@ </listitem> </varlistentry> <varlistentry> - <term><option>-p</option><replaceable>x y</replaceable></term> + <term><option>-p </option><replaceable>x y</replaceable></term> <listitem> <para>Reposition the image. The original lower left corner is positioned at @@ -123,7 +123,7 @@ </listitem> </varlistentry> <varlistentry> - <term><option>-F framebuffer</option></term> + <term><option>-F framebuffer</option></term> <listitem> <para>indicates that the output should be sent to the indicated framebuffer. See @@ -142,12 +142,10 @@ <refsection xml:id="examples"><title>EXAMPLES</title> <blockquote remap="RS"> -<para> orle-fb truck.rle -<!-- .br --> - orle-fb -Ot text.rle -<!-- .br --> - orle-fb -bG <car.rle - </para></blockquote> <!-- remap='RE' --> +<para>orle-fb truck.rle</para> +<para>orle-fb -Ot text.rle</para> +<para>orle-fb -bG <car.rle</para> + </blockquote> <!-- remap='RE' --> </refsection> <refsection xml:id="see_also"><title>SEE ALSO</title> Modified: brlcad/branches/openscenegraph/doc/docbook/system/man1/en/orle-pix.xml =================================================================== --- brlcad/branches/openscenegraph/doc/docbook/system/man1/en/orle-pix.xml 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/doc/docbook/system/man1/en/orle-pix.xml 2014-07-11 19:24:42 UTC (rev 61672) @@ -25,7 +25,7 @@ <refsect1 xml:id='description'><title>DESCRIPTION</title> -<para><emphasis remap='I'>orle-fb</emphasis> +<para><emphasis remap='I'>orle-pix</emphasis> decodes an old University of Utah standard (Edition-2) Run-Length Encoded (RLE) format file (saved with @@ -47,8 +47,8 @@ <varlistentry> <term><option>-d</option></term> <listitem> -<para>Debug option, provides verbose description of file structure and -processes called, written on standard error.</para> +<para>Debug option; provides verbose description of file structure and +processes called; written on standard error.</para> </listitem> </varlistentry> <varlistentry> @@ -59,7 +59,7 @@ </listitem> </varlistentry> <varlistentry> - <term><option>-b</option><replaceable>x</replaceable></term> + <term><option>-b </option><replaceable>x</replaceable></term> <listitem> <para>The background of the image is normally set to the value recorded in the RLE file. Modified: brlcad/branches/openscenegraph/doc/docbook/system/man1/en/pix-ps.xml =================================================================== --- brlcad/branches/openscenegraph/doc/docbook/system/man1/en/pix-ps.xml 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/doc/docbook/system/man1/en/pix-ps.xml 2014-07-11 19:24:42 UTC (rev 61672) @@ -72,20 +72,20 @@ <refsect1 xml:id='examples'><title>EXAMPLES</title> <para>pix-ps -c image.pix > image.ps</para> -<para>Produces a 6.75 inch PostScript file from an 512x512 input image +<para>Produces a 6.75 inch PostScript file from a 512x512 input image and centers it on an 8.5 x 11 inch page.</para> <para>pix-ps -e -w 1024 -n 768 image.pix > image.ps</para> <para>Takes the file image.pix which has the dimensions of 1024 pixels wide -by 768 pixel high, and produces an Encapsulated Postscript version +by 768 pixels high, and produces an Encapsulated Postscript version of it.</para> -<para>pix-ps -L -c -W 5.2 < image.pix > image.ps</para> +<para>pix-ps -L -c -S 5.2 < image.pix > image.ps</para> -<para>Makes a PostScript file of the (assumed 512 square) image, with +<para>Makes a PostScript file of the (assumed 512x512) image, with the output image 5.2 inches square, in landscape mode, centered on an 8.5 x 11 inch page.</para> </refsect1> Modified: brlcad/branches/openscenegraph/doc/docbook/system/man1/en/pix-rle.xml =================================================================== --- brlcad/branches/openscenegraph/doc/docbook/system/man1/en/pix-rle.xml 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/doc/docbook/system/man1/en/pix-rle.xml 2014-07-11 19:24:42 UTC (rev 61672) @@ -34,14 +34,17 @@ Run-Length Encoded (RLE) format file format, and writes it to standard out. If <emphasis remap='I'>file.pix</emphasis> -is not specified, standard input is read.</para> +is not specified, standard input is read. +<option>-w</option> and <option>-n</option> options specify the output width and height respectively; these can be set to the same value by +use of the <option>-s</option> option. +</para> <variablelist remap='TP'> <varlistentry> - <term><option>-C</option><replaceable>r/g/b</replaceable></term> + <term><option>-C </option><replaceable>r/g/b</replaceable></term> <listitem> <para>This option permits the user to specify a background color -as slash separated decimal numbers in the range of 0 to 255, +as slash-separated decimal numbers in the range of 0 to 255, one each for the red, green, and blue channels.</para> </listitem> </varlistentry> Modified: brlcad/branches/openscenegraph/doc/docbook/system/man1/en/rle-fb.xml =================================================================== --- brlcad/branches/openscenegraph/doc/docbook/system/man1/en/rle-fb.xml 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/doc/docbook/system/man1/en/rle-fb.xml 2014-07-11 19:24:42 UTC (rev 61672) @@ -30,7 +30,7 @@ <refsection xml:id="description"><title>DESCRIPTION</title> -<para><emphasis remap="I">rle-fb</emphasis> +<para><command>rle-fb</command> decodes a University of Utah standard (Edition-3, or "Utah Raster Toolkit") Run-Length Encoded (RLE) format file @@ -74,25 +74,25 @@ <emphasis remap="I">repos(1)</emphasis>.</para> <variablelist remap="TP"> <varlistentry> - <term><option>-W </option><replaceable>scr_width</replaceable></term> + <term><option>-W </option><replaceable>scr_width</replaceable></term> <listitem> <para>specifies the desired width of the screen, in pixels.</para> </listitem> </varlistentry> <varlistentry> - <term><option>-N </option><replaceable>scr_height</replaceable></term> + <term><option>-N </option><replaceable>scr_height</replaceable></term> <listitem> <para>specifies the desired height of the screen, in scanlines.</para> </listitem> </varlistentry> <varlistentry> - <term><option>-S </option><replaceable>squarescrsize</replaceable></term> + <term><option>-S </option><replaceable>squarescrsize</replaceable></term> <listitem> <para>sets the screen width and height to the indicated value.</para> </listitem> </varlistentry> <varlistentry> - <term><option>-F </option><replaceable>framebuffer</replaceable></term> + <term><option>-F </option><replaceable>framebuffer</replaceable></term> <listitem> <para>This option specifies which framebuffer the image is to be displayed on. If not given, the environment variable @@ -108,7 +108,7 @@ <varlistentry> <term><option>-c</option></term> <listitem> -<para>The “crunch colormap” option. +<para>The crunch colormap option. If the RLE file contains a colormap, rather than loading that colormap into the framebuffer and allowing the framebuffer to apply the colormap to produce the final image, this option causes the colormap to be applied @@ -125,7 +125,7 @@ <varlistentry> <term><option>-d</option></term> <listitem> -<para>Debug option, provides a verbose description of the input file structure and +<para>Debug option; provides a verbose description of the input file structure and image decoding process, written on standard error.</para> </listitem> </varlistentry> @@ -135,38 +135,38 @@ <para>Restores the image data in <emphasis remap="I">overlay</emphasis> mode. Only areas of the original image which were not the background color are decoded. The rest of the image already in the frame buffer is undisturbed. -That this mode uses twice as many DMAs to the frame buffer as +Note that this mode uses twice as many DMAs to the frame buffer as the normal mode. This is because each scanline of the previous image must be read from the framebuffer, -the overlay portions of the new image written on top, +the overlay portions of the new image must be written on top, and the composite scanline must be written back to the framebuffer.</para> </listitem> </varlistentry> <varlistentry> - <term><option>-C </option><replaceable>r/g/b</replaceable></term> + <term><option>-C </option><replaceable>r/g/b</replaceable></term> <listitem> <para>If the image is not being decoded in overlay mode, the background is normally set to the value recorded in the RLE file. This option permits the user to specify an alternate background color -as a red/green/blue triple, separated by slashes (“/”). +as a red/green/blue triple, separated by slashes (/). The color intensity in each channel ranges from 0 (dark) to 255 (bright).</para> </listitem> </varlistentry> <varlistentry> - <term><option>-X </option><replaceable>scr_xoff</replaceable></term> + <term><option>-X </option><replaceable>scr_xoff</replaceable></term> <listitem> <para>Specify a screen X offset, which will offset the file onto the screen by the given amount. (i.e., -<option>-X </option><literal>10</literal> +<option>-X</option><literal>10</literal> would place (0,0) in the RLE image rectangle at screen coordinate (10,0). The offset may be negative or positive. The RLE image rectangle will be clipped to the screen, as required.</para> </listitem> </varlistentry> <varlistentry> - <term><option>-Y </option><replaceable>scr_yoff</replaceable></term> + <term><option>-Y </option><replaceable>scr_yoff</replaceable></term> <listitem> <para>Specify a screen Y offset, which will offset the file onto the screen by the given amount.</para> @@ -216,24 +216,22 @@ <refsection xml:id="examples"><title>EXAMPLES</title> <blockquote remap="RS"> -<para> rle-fb truck.rle -<!-- .br --> - rle-fb -O text.rle -<!-- .br --> - rle-fb -C 0/255/0 <car.rle - </para></blockquote> <!-- remap='RE' --> +<para>rle-fb truck.rle</para> +<para>rle-fb -O text.rle</para> +<para>rle-fb -C 0/255/0 <car.rle</para> + </blockquote> <!-- remap='RE' --> </refsection> <refsection xml:id="diagnostics"><title>DIAGNOSTICS</title> <variablelist remap="TP"> <varlistentry> - <term>“rle-fb: excess arguments ignored”.</term> + <term>rle-fb: excess arguments ignored.</term> <listitem> <para>More than one RLE file name was specified.</para> </listitem> </varlistentry> <varlistentry> - <term>“rle-fb: Error reading setup information”.</term> + <term>rle-fb: Error reading setup information.</term> <listitem> <para>The subroutine <function>rle_get_setup()</function> @@ -246,7 +244,7 @@ </listitem> </varlistentry> <varlistentry> - <term>“rle-fb: Warning: RLE image rectangle entirely off screen”</term> + <term>rle-fb: Warning: RLE image rectangle entirely off screen</term> <listitem> <para>The combined effects of the RLE image rectangle definition stored in the RLE file and any @@ -260,7 +258,7 @@ </listitem> </varlistentry> <varlistentry> - <term>“rle-fb: correcting for old style colormap”.</term> + <term>rle-fb: correcting for old style colormap.</term> <listitem> <para>The only change between the Edition-2 and Edition-3 RLE file formats that is not upwards compatible is the format of the colormap. @@ -270,7 +268,7 @@ format, any colormap which has the upper eight bits all zero in all colormap entries is assumed to be an Edition-2 colormap, and is adjusted for suitable display. -While this heuristic may be “tricked” with an Edition-3 colormap +While this heuristic may be tricked with an Edition-3 colormap with degenerate values, the picture would have been very dark, and the benefits of full upwards compatibility from Edition-2 format files were deemed worth this risk.</para> Modified: brlcad/branches/openscenegraph/doc/docbook/system/man1/en/tire.xml =================================================================== --- brlcad/branches/openscenegraph/doc/docbook/system/man1/en/tire.xml 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/doc/docbook/system/man1/en/tire.xml 2014-07-11 19:24:42 UTC (rev 61672) @@ -31,13 +31,14 @@ open database (when run from within MGED) or in <emphasis remap="I">tire.g</emphasis> when run from the command line. If no dimensions are supplied defaults are used. The default is to <emphasis remap="I">not</emphasis> model tread (due to performance - issues) but tread modeling is implemented and available as a user option with the + issues), but tread modeling is implemented and available as a user option with the + <option>-p</option> flag and the <option>-t</option> flag. </para> <para> <option>-a #</option> instructs <command>tire</command> to automatically add dimensional information to the toplevel object name used in the generated BRL-CAD - database tree. Works with the <option>-n</option> option or standalone. Output + database tree. Works with the <option>-n</option> option or as stand-alone. Output format uses '-' instead of '/' because the latter has significance in BRL-CAD object trees. </para> @@ -126,8 +127,8 @@ <para> allows the user to specify a name other than 'tire' for the root name of the toplevel database object. Works with the - <emphasis remap="B">\a</emphasis> - option or standalone. + <emphasis remap="B">-a</emphasis> + option or as stand-alone. </para> </listitem> </varlistentry> Modified: brlcad/branches/openscenegraph/doc/docbook/system/man1/en/wdb_example.xml =================================================================== --- brlcad/branches/openscenegraph/doc/docbook/system/man1/en/wdb_example.xml 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/doc/docbook/system/man1/en/wdb_example.xml 2014-07-11 19:24:42 UTC (rev 61672) @@ -24,9 +24,10 @@ <refsect1 xml:id="description"><title>DESCRIPTION</title> - <literallayout>The wdb_example program creates a BRL-CAD geometry database from C code. This database contains a sphere centered a 0,0,0, an rpp under it and a union of both objects. - Note that this is for writing a database and not modifying it. Currently, there is no API for modifying the database. Also note that the values in the database are stored in millimeters. - </literallayout> + <para>The wdb_example program creates a BRL-CAD geometry database from C code. This database contains a sphere centered at 0,0,0; an rpp under it; and a union of both objects. + </para> + <para>Note that this is for writing a database and not modifying it. Currently, there is no API for modifying the database. Also note that the values in the database are stored in millimeters. + </para> </refsect1> <refsect1 xml:id="examples"> Modified: brlcad/branches/openscenegraph/doc/docbook/system/mann/en/wire.xml =================================================================== --- brlcad/branches/openscenegraph/doc/docbook/system/mann/en/wire.xml 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/doc/docbook/system/mann/en/wire.xml 2014-07-11 19:24:42 UTC (rev 61672) @@ -30,7 +30,7 @@ ending points of the different segments of wires along with the radius at each of these points. Currently the program is limited to 10 segments. This number may be changed by changing the variable MAXSEG. MAXSEG may be no greater - than 100 with out changing other parts of the program. The wires are composed + than 100 without changing other parts of the program. The wires are composed of cones and spheres. This program is designed to be run interactively. </para> </refsection> @@ -75,7 +75,7 @@ </example> <para> - In this example a wire of three segments is made. These + In this example, a wire of three segments is made. These segments are joined together with spheres. All dimensions are in millimeters. </para> Modified: brlcad/branches/openscenegraph/include/config_win.h.in =================================================================== --- brlcad/branches/openscenegraph/include/config_win.h.in 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/include/config_win.h.in 2014-07-11 19:24:42 UTC (rev 61672) @@ -98,6 +98,12 @@ #define YY_NO_UNISTD_H 1 #define YYTOKENTYPE 1 +/* it we're compiling c++ sources, there's a possibility that we'll be + * including libc++ headers (e.g., iostream) where these underscore IO + * function hacks become counterproductive. + */ +#ifndef __cplusplus + /* * functions declared in io.h */ @@ -124,6 +130,8 @@ #define umask _umask #define write _write +#endif /* __cplusplus */ + /* * other functions declared elsewhere (many in stdio.h) */ Modified: brlcad/branches/openscenegraph/include/dm/dm-Null.h =================================================================== --- brlcad/branches/openscenegraph/include/dm/dm-Null.h 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/include/dm/dm-Null.h 2014-07-11 19:24:42 UTC (rev 61672) @@ -185,6 +185,10 @@ DM_EXPORT extern void null_processEvents(struct dm *dmp); + +DM_EXPORT extern int +null_openFb(struct dm *dmp, FBIO *ifp); + __END_DECLS #endif /* DM_NULL_H */ Modified: brlcad/branches/openscenegraph/include/dm.h =================================================================== --- brlcad/branches/openscenegraph/include/dm.h 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/include/dm.h 2014-07-11 19:24:42 UTC (rev 61672) @@ -248,6 +248,7 @@ int (*dm_getDisplayImage)(struct dm *dmp, unsigned char **image); void (*dm_reshape)(struct dm *dmp, int width, int height); int (*dm_makeCurrent)(struct dm *dmp); + int (*dm_openFb)(struct dm *dmp, FBIO *ifp); unsigned long dm_id; /**< @brief window id */ int dm_displaylist; /**< @brief !0 means device has displaylist */ int dm_stereo; /**< @brief stereo flag */ Modified: brlcad/branches/openscenegraph/include/fb.h =================================================================== --- brlcad/branches/openscenegraph/include/fb.h 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/include/fb.h 2014-07-11 19:24:42 UTC (rev 61672) @@ -190,6 +190,10 @@ FB_EXPORT extern int _wgl_open_existing(FBIO *ifp, Display *dpy, Window win, Colormap cmap, PIXELFORMATDESCRIPTOR *vip, HDC hdc, int width, int height, HGLRC glxc, int double_buffer, int soft_cmap); #endif +#ifdef IF_QT +FB_EXPORT extern int _qt_open_existing(FBIO *ifp); +#endif + /* * Copy one RGB pixel to another. */ Modified: brlcad/branches/openscenegraph/sh/enumerate.sh =================================================================== --- brlcad/branches/openscenegraph/sh/enumerate.sh 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/sh/enumerate.sh 2014-07-11 19:24:42 UTC (rev 61672) @@ -200,6 +200,24 @@ echo "-----------------------------------------" +echo "-- PUBLIC API TOTALS --" +echo "-----------------------------------------" + +libs=`find $BASE/include -not \( $those_pattern \) -exec grep '^[A-Z]*_EXPORT' {} \; | awk '{print $1}' | sort | uniq -c | sort -n | awk '{print $2}' | sed 's/_EXPORT//g'` +exports_lc_total=0 +for lib in $libs ; do + exports=`find $BASE/include -not \( $those_pattern \) -exec grep "^${lib}_EXPORT" {} /dev/null \;` + exports_lc="`echo \"$exports\" | wc -l`" + printf "%7d\t%s\n" "$exports_lc" "$lib API" + exports_lc_total="`expr $exports_lc_total + $exports_lc`" +done +echo "-----------------------------------------" +printf "%7d\t%s\n" "$exports_lc_total" "BRL-CAD API Total" + +printf "\n" + + +echo "-----------------------------------------" echo "-- LINE COUNT TOTALS --" echo "-----------------------------------------" # echo " w/ws+= means with whitespace lines" @@ -282,9 +300,9 @@ printf "%7d\t%s\n" "$srcs_lc_total" "BRL-CAD Sources w/ Spaces" printf "%7d\t%s\n" "$real_lc_total" "BRL-CAD Source Code Total" - echo "=========================================" +printf "\nDone.\n" # Local Variables: # mode: sh Modified: brlcad/branches/openscenegraph/src/conv/3dm/3dm-g.cpp =================================================================== --- brlcad/branches/openscenegraph/src/conv/3dm/3dm-g.cpp 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/src/conv/3dm/3dm-g.cpp 2014-07-11 19:24:42 UTC (rev 61672) @@ -1,4 +1,4 @@ -/* 3 D M - G . C P P +/* 3 D M - G . C P P * BRL-CAD * * Copyright (c) 2004-2014 United States Government as represented by @@ -24,24 +24,22 @@ * */ +#ifdef OBJ_BREP #include "common.h" -#include "stdio.h" /* for sscanf */ +#include <cstdio> /* for sscanf */ +#include <iostream> -#ifdef OBJ_BREP - #include "conv3dm-g.hpp" #include "bu/getopt.h" -#include <iostream> -static const char * const USAGE = "USAGE: 3dm-g [-v vmode] [-r] [-u] -o output_file.g input_file.3dm\n"; - - int main(int argc, char** argv) { + static const char * const usage = "Usage: 3dm-g [-v vmode] [-r] [-u] -o output_file.g input_file.3dm\n"; + bool verbose_mode = false; bool random_colors = false; bool use_uuidnames = false; @@ -70,7 +68,7 @@ use_uuidnames = true; break; default: - std::cerr << USAGE; + std::cerr << usage; return 1; } } @@ -79,7 +77,7 @@ argv += bu_optind; inputFileName = argv[0]; if (outputFileName == NULL) { - std::cerr << USAGE; + std::cerr << usage; return 1; } @@ -90,9 +88,11 @@ } -#else +#else //!OBJ_BREP +#include "common.h" + #include <iostream> @@ -106,19 +106,13 @@ } - - #endif //!OBJ_BREP - - - -/* - * Local Variables: - * tab-width: 8 - * mode: C++ - * c-basic-offset: 4 - * indent-tabs-mode: t - * 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 Modified: brlcad/branches/openscenegraph/src/conv/3dm/conv3dm-g.cpp =================================================================== --- brlcad/branches/openscenegraph/src/conv/3dm/conv3dm-g.cpp 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/src/conv/3dm/conv3dm-g.cpp 2014-07-11 19:24:42 UTC (rev 61672) @@ -1,14 +1,14 @@ -/* C O N V 3 D M - G . H +/* C O N V 3 D M - G . C P P * BRL-CAD * * Copyright (c) 2004-2014 United States Government as represented by * the U.S. Army Research Laboratory. * - * This program is free software; you can redistribute it and/or + * 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 program is distributed in the hope that it will be useful, but + * 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. @@ -19,55 +19,44 @@ */ /** @file conv3dm-g.cpp * - * Program to convert a Rhino model (in a .3dm file) to a BRL-CAD .g - * file. + * Library for conversion of Rhino models (in .3dm files) to BRL-CAD databases. * */ - - -#include "common.h" - - #ifdef OBJ_BREP -#include "conv3dm-g.hpp" +/* interface header */ +#include "conv3dm-g.hpp" // includes common.h +/* system headers */ +#include <cctype> // for isalnum() #include <limits> #include <sstream> #include <stdexcept> - +/* implementation headers */ #include "bu/getopt.h" #include "icv.h" #include "vmath.h" #include "wdb.h" - - namespace { - - -static const std::string ROOT_UUID = "00000000-0000-0000-0000-000000000000"; +static const ON_UUID &ROOT_UUID = ON_nil_uuid; static const std::string DEFAULT_NAME = "noname"; static const std::pair<std::string, std::string> DEFAULT_SHADER("plastic", ""); -/* UUID buffers must be >= 37 chars per openNURBS API */ -static const std::size_t UUID_LEN = 37; - static struct _InitOpenNURBS { _InitOpenNURBS() { ON::Begin(); } - ~_InitOpenNURBS() { ON::End(); @@ -75,18 +64,17 @@ } _init_opennurbs; - - static inline std::string UUIDstr(const ON_UUID &uuid) { + // UUID buffers must be >= 37 chars per openNURBS API + const std::size_t UUID_LEN = 37; + char buf[UUID_LEN]; return ON_UuidToString(uuid, buf); } - - static inline std::string w2string(const ON_wString &source) { @@ -97,12 +85,10 @@ } - - -// used for checking existence with ON_SimpleArray::At() +// used for checking ON_SimpleArray::At(), // when accessing ONX_Model objects referenced by index template <typename T> -inline T &ref(T *ptr) +static inline T &ref(T *ptr) { if (!ptr) throw std::out_of_range("invalid index"); @@ -111,10 +97,32 @@ } +template <typename T, typename R, R(*Destructor)(T*)> +struct AutoDestroyer { + AutoDestroyer() : ptr(NULL) {} + AutoDestroyer(T *vptr) : ptr(vptr) {} -// according to openNURBS documentation, -// their own ON_CreateUUID() only works on Windows + ~AutoDestroyer() + { + if (ptr) Destructor(ptr); + } + + + T *ptr; + + +private: + AutoDestroyer(const AutoDestroyer &); + AutoDestroyer &operator=(const AutoDestroyer &); +}; + + +// according to openNURBS documentation, their own ON_CreateUuid() +// only works on Windows, but the implementation shows it's also +// implemented for XCode builds. when it fails, we pretend to make a +// uuid. FIXME: this is a great candidate for a bu_uuid() function +// (but with real uuid behavior). static ON_UUID generate_uuid() { @@ -122,7 +130,6 @@ if (ON_CreateUuid(result)) return result; - // sufficient for our use here, but // officially UUIDv4 also requires certain bits to be set result.Data1 = static_cast<ON__UINT32>(drand48() * @@ -140,34 +147,22 @@ } - - -static bool +static inline bool is_toplevel(const ON_Layer &layer) { - const std::string layer_uuid = UUIDstr(layer.m_layer_id); - const std::string parent_uuid = UUIDstr(layer.m_parent_layer_id); - - return (parent_uuid == ROOT_UUID) && (layer_uuid != ROOT_UUID); + return (layer.m_parent_layer_id == ROOT_UUID) && (layer.m_layer_id != ROOT_UUID); } - - static std::string -basename(const std::string &path) +strbasename(const std::string &path) { - char *buf = new char[path.size() + 1]; - bu_basename(buf, path.c_str()); - std::string result = buf; - delete[] buf; - - return result; + std::vector<char> buf(path.size() + 1); + bu_basename(&buf[0], path.c_str()); + return &buf[0]; } - - static std::string unique_name(std::map<std::string, int> &count_map, const std::string &prefix, @@ -185,8 +180,6 @@ } - - static void xform2mat_t(const ON_Xform &source, mat_t dest) { @@ -197,8 +190,6 @@ } - - static std::string extract_bitmap(const std::string &dir_path, const std::string &filename, const ON_EmbeddedBitmap &bitmap) @@ -216,101 +207,65 @@ std::ofstream file(path.c_str(), std::ofstream::binary); file.exceptions(std::ofstream::failbit | std::ofstream::badbit); file.write(static_cast<const char *>(bitmap.m_buffer), - bitmap.m_sizeof_buffer); + static_cast<std::streamsize>(bitmap.m_sizeof_buffer)); file.close(); return path; } - - -void +static void load_pix(const std::string &path, int width, int height) { char buf[BUFSIZ]; // libicv currently requires BUFSIZ ICV_IMAGE_FORMAT format = icv_guess_file_format(path.c_str(), buf); - if (icv_image_t *image = icv_read(path.c_str(), format, width, height)) { + AutoDestroyer<icv_image_t, int, icv_destroy> image(icv_read(path.c_str(), format, width, height)); + if (image.ptr) { // TODO import the image data after adding support to libicv - icv_destroy(image); } else throw std::runtime_error("icv_read() failed"); } - - -// Removes all leading and trailing non alpha-numeric characters, -// then replaces all remaining non alpha-numeric characters with -// the '_' character. The allow string is an exception list where -// these characters are allowed, but not leading or trailing, in -// the name. static std::string -CleanName(ON_wString name) +clean_name(const std::string &input) { - ON_wString allow(".-_"); - ON_wString new_name; - bool was_cleaned = false; + if (input.empty()) + return DEFAULT_NAME; - bool found_first = false; - int idx_first = 0, idx_last = 0; + std::ostringstream ss; + int index = -1; + for (std::string::const_iterator it = input.begin(); + it != input.end(); ++it) { + ++index; + switch (*it) { + case '.': + case '-': + case '_': + ss.put(index > 0 ? *it : '_'); + break; - for (int j = 0; j < name.Length(); j++) { - wchar_t c = name.GetAt(j); - bool ok_char = false; - if (isalnum(c)) { - if (!found_first) { - idx_first = idx_last = j; - found_first = true; - } else { - idx_last = j; - } - ok_char = true; - } else { - for (int k = 0 ; k < allow.Length() ; k++) { - if (c == allow.GetAt(k)) { - ok_char = true; - break; - } - } + default: + if (std::isalnum(*it)) + ss.put(*it); + else + ss.put('_'); } - if (!ok_char) { - c = L'_'; - was_cleaned = true; - } - new_name += c; } - if (idx_first != 0 || name.Length() != ((idx_last - idx_first) + 1)) { - new_name = new_name.Mid(idx_first, (idx_last - idx_first) + 1); - was_cleaned = true; - } - if (was_cleaned) { - name.Destroy(); - name = new_name; - } - if (name) - return w2string(name); - else - return DEFAULT_NAME; + return ss.str(); } - - } - - namespace conv3dm { - - class RhinoConverter::Color { public: @@ -318,7 +273,7 @@ Color(); - Color(int red, int green, int blue); + Color(unsigned char red, unsigned char green, unsigned char blue); Color(const ON_Color &src); bool operator==(const Color &rhs) const; @@ -327,65 +282,62 @@ private: - void set_rgb(int red, int green, int blue); - unsigned char m_rgb[3]; }; - - struct RhinoConverter::ModelObject { std::string m_name; std::vector<std::string> m_children; - bool is_in_idef; + bool m_idef_member; ModelObject() : m_name(), m_children(), - is_in_idef(false) + m_idef_member(false) {} }; - - RhinoConverter::Color RhinoConverter::Color::random() { - int red = static_cast<int>(255 * drand48()); - int green = static_cast<int>(255 * drand48()); - int blue = static_cast<int>(255 * drand48()); + unsigned char red = static_cast<unsigned char>(255 * drand48()); + unsigned char green = static_cast<unsigned char>(255 * drand48()); + unsigned char blue = static_cast<unsigned char>(255 * drand48()); return Color(red, green, blue); } - - RhinoConverter::Color::Color() { - set_rgb(0, 0, 0); + m_rgb[0] = m_rgb[1] = m_rgb[2] = 0; } - - -RhinoConverter::Color::Color(int red, int green, int blue) +RhinoConverter::Color::Color(unsigned char red, unsigned char green, + unsigned char blue) { - set_rgb(red, green, blue); + m_rgb[0] = red; + m_rgb[1] = green; + m_rgb[2] = blue; } - RhinoConverter::Color::Color(const ON_Color &src) { - set_rgb(src.Red(), src.Green(), src.Blue()); + if (src.Red() < 0 || src.Red() > 255 + || src.Green() < 0 || src.Green() > 255 + || src.Blue() < 0 || src.Blue() > 255) + throw std::invalid_argument("invalid ON_Color"); + + m_rgb[0] = static_cast<unsigned char>(src.Red()); + m_rgb[1] = static_cast<unsigned char>(src.Green()); + m_rgb[2] = static_cast<unsigned char>(src.Blue()); } - - bool RhinoConverter::Color::operator==(const Color &rhs) const { @@ -395,8 +347,6 @@ } - - const unsigned char * RhinoConverter::Color::get_rgb() const { @@ -404,24 +354,6 @@ } - - -void -RhinoConverter::Color::set_rgb(int red, int green, int blue) -{ - if (red < 0 || red > 255 - || green < 0 || green > 255 - || blue < 0 || blue > 255) - throw std::invalid_argument("invalid color"); - - m_rgb[0] = static_cast<unsigned char>(red); - m_rgb[1] = static_cast<unsigned char>(green); - m_rgb[2] = static_cast<unsigned char>(blue); -} - - - - RhinoConverter::RhinoConverter(const std::string &output_path, bool verbose_mode) : m_verbose_mode(verbose_mode), @@ -446,16 +378,12 @@ } - - RhinoConverter::~RhinoConverter() { wdb_close(m_db); } - - void RhinoConverter::write_model(const std::string &path, bool use_uuidnames, bool random_colors) @@ -474,7 +402,7 @@ m_log->Print("Number of NURBS objects read: %d\n\n", m_model->m_object_table.Count()); - m_obj_map[ROOT_UUID].m_name = basename(path); + m_obj_map[UUIDstr(ROOT_UUID)].m_name = strbasename(path); map_uuid_names(); create_all_bitmaps(); @@ -488,8 +416,6 @@ } - - void RhinoConverter::clean_model() { @@ -514,26 +440,24 @@ } - - void RhinoConverter::map_uuid_names() { for (int i = 0; i < m_model->m_object_table.Count(); ++i) { - const ON_Object *object = m_model->m_object_table[i].m_object; - const ON_3dmObjectAttributes &myAttributes = + const ON_Object *geom = m_model->m_object_table[i].m_object; + const ON_3dmObjectAttributes &geom_attrs = m_model->m_object_table[i].m_attributes; - const std::string obj_uuid = UUIDstr(myAttributes.m_uuid); + const std::string geom_uuid = UUIDstr(geom_attrs.m_uuid); std::string suffix = ".s"; - if (object->ObjectType() == ON::instance_reference) + if (geom->ObjectType() == ON::instance_reference) suffix = ".c"; if (m_use_uuidnames) - m_obj_map[obj_uuid].m_name = obj_uuid + suffix; + m_obj_map[geom_uuid].m_name = geom_uuid + suffix; else - m_obj_map[obj_uuid].m_name = - unique_name(m_name_count_map, CleanName(myAttributes.m_name), suffix); + m_obj_map[geom_uuid].m_name = + unique_name(m_name_count_map, clean_name(w2string(geom_attrs.m_name)), suffix); } @@ -546,7 +470,7 @@ m_obj_map[idef_uuid].m_name = idef_uuid + ".c"; else m_obj_map[idef_uuid].m_name = - unique_name(m_name_count_map, CleanName(idef.Name()), ".c"); + unique_name(m_name_count_map, clean_name(w2string(idef.Name())), ".c"); } @@ -562,7 +486,7 @@ m_obj_map[layer_uuid].m_name = layer_uuid + suffix; else m_obj_map[layer_uuid].m_name = - unique_name(m_name_count_map, CleanName(layer.m_name), suffix); + unique_name(m_name_count_map, clean_name(w2string(layer.m_name)), suffix); } @@ -575,9 +499,9 @@ if (m_use_uuidnames) m_obj_map[bitmap_uuid].m_name = bitmap_uuid + ".pix"; else { - std::string bitmap_name = CleanName(bitmap->m_bitmap_name); + std::string bitmap_name = clean_name(w2string(bitmap->m_bitmap_name)); if (bitmap_name == DEFAULT_NAME) - bitmap_name = CleanName(bitmap->m_bitmap_filename); + bitmap_name = clean_name(strbasename(w2string(bitmap->m_bitmap_filename))); m_obj_map[bitmap_uuid].m_name = unique_name(m_name_count_map, bitmap_name, ".pix"); @@ -586,8 +510,6 @@ } - - void RhinoConverter::create_all_bitmaps() { @@ -604,13 +526,11 @@ } - - void RhinoConverter::create_bitmap(const ON_Bitmap *bmap) { if (const ON_EmbeddedBitmap *bitmap = ON_EmbeddedBitmap::Cast(bmap)) { - const std::string filename = basename(w2string(bitmap->m_bitmap_filename)); + const std::string filename = strbasename(w2string(bitmap->m_bitmap_filename)); const std::string path = extract_bitmap(m_output_dirname, filename, *bitmap); try { @@ -637,8 +557,6 @@ } - - void RhinoConverter::nest_all_layers() { @@ -652,8 +570,6 @@ } - - void RhinoConverter::create_all_layers() { @@ -675,8 +591,6 @@ } - - void RhinoConverter::create_layer(const ON_Layer &layer) { @@ -689,7 +603,7 @@ for (std::vector<std::string>::const_iterator it = layer_obj.m_children.begin(); it != layer_obj.m_children.end(); ++it) { const ModelObject &obj = m_obj_map.at(*it); - if (obj.is_in_idef) continue; + if (obj.m_idef_member) continue; mk_addmember(obj.m_name.c_str(), &members.l, NULL, WMOP_UNION); } @@ -708,14 +622,13 @@ color = Color(255, 0, 0); } + const bool do_inherit = false; mk_comb(m_db, layer_obj.m_name.c_str(), &members.l, is_region, shader.first.c_str(), shader.second.c_str(), color.get_rgb(), - 0, 0, 0, 0, false, false, false); + 0, 0, 0, 0, do_inherit, false, false); } - - void RhinoConverter::create_all_idefs() { @@ -732,8 +645,6 @@ } - - void RhinoConverter::create_idef(const ON_InstanceDefinition &idef) { @@ -745,7 +656,7 @@ ModelObject &member_obj = m_obj_map.at(member_uuid); mk_addmember(member_obj.m_name.c_str(), &members.l, NULL, WMOP_UNION); - member_obj.is_in_idef = true; + member_obj.m_idef_member = true; } const std::string &idef_name = @@ -754,8 +665,6 @@ } - - void RhinoConverter::create_iref(const ON_InstanceRef &iref, const ON_3dmObjectAttributes &iref_attrs) @@ -776,10 +685,11 @@ BU_LIST_INIT(&members.l); mk_addmember(member_name.c_str(), &members.l, matrix, WMOP_UNION); + const bool do_inherit = false; mk_comb(m_db, iref_name.c_str(), &members.l, false, shader.first.c_str(), shader.second.c_str(), get_color(iref_attrs).get_rgb(), - 0, 0, 0, 0, false, false, false); + 0, 0, 0, 0, do_inherit, false, false); const std::string parent_uuid = UUIDstr(ref(m_model->m_layer_table.At(iref_attrs.m_layer_index)).m_layer_id); @@ -787,8 +697,6 @@ } - - RhinoConverter::Color RhinoConverter::get_color(const ON_3dmObjectAttributes &obj_attrs) const { @@ -811,8 +719,7 @@ break; default: - m_log->Print("ERROR: unknown color source\n"); - return Color(255, 0, 0); + throw std::logic_error("unknown color source"); } @@ -824,8 +731,6 @@ } - - std::pair<std::string, std::string> RhinoConverter::get_shader(int index) const { @@ -850,8 +755,6 @@ } - - void RhinoConverter::create_geom_comb(const ON_3dmObjectAttributes &geom_attrs) { @@ -862,7 +765,7 @@ const std::string geom_uuid = UUIDstr(geom_attrs.m_uuid); const ModelObject &geom_obj = m_obj_map.at(geom_uuid); - if (geom_obj.is_in_idef || !is_toplevel(parent_layer)) { + if (geom_obj.m_idef_member || !is_toplevel(parent_layer)) { m_obj_map.at(parent_layer_uuid).m_children.push_back(geom_uuid); return; } @@ -884,18 +787,17 @@ BU_LIST_INIT(&members.l); mk_addmember(geom_obj.m_name.c_str(), &members.l, NULL, WMOP_UNION); + const bool do_inherit = false; mk_comb(m_db, comb_name.c_str(), &members.l, false, shader.first.c_str(), shader.second.c_str(), get_color(geom_attrs).get_rgb(), - 0, 0, 0, 0, false, false, false); + 0, 0, 0, 0, do_inherit, false, false); m_obj_map[comb_uuid].m_name = comb_name; m_obj_map.at(parent_layer_uuid).m_children.push_back(comb_uuid); } - - void RhinoConverter::create_brep(const ON_Brep &brep, const ON_3dmObjectAttributes &brep_attrs) @@ -911,8 +813,6 @@ } - - void RhinoConverter::create_mesh(ON_Mesh mesh, const ON_3dmObjectAttributes &mesh_attrs) @@ -924,41 +824,99 @@ m_log->Print("Creating Mesh '%s'\n", mesh_name.c_str()); mesh.ConvertQuadsToTriangles(); + mesh.CombineIdenticalVertices(); + mesh.Compact(); + mesh.UnitizeFaceNormals(); - const int num_vertices = mesh.m_V.Count(); - const int num_faces = mesh.m_F.Count(); + const std::size_t num_vertices = static_cast<std::size_t>(mesh.m_V.Count()); + const std::size_t num_faces = static_cast<std::size_t>(mesh.m_F.Count()); + unsigned char mode = mesh.IsSolid() ? RT_BOT_SOLID : RT_BOT_PLATE; + unsigned char orientation; + switch (mesh.SolidOrientation()) { + case 0: + orientation = RT_BOT_UNORIENTED; + break; + + case 1: + orientation = RT_BOT_CW; + break; + + case -1: + orientation = RT_BOT_CCW; + break; + + default: + throw std::logic_error("unknown orientation"); + } + if (num_vertices == 0 || num_faces == 0) { m_log->Print("-- Mesh has no content; skipping...\n"); return; } std::vector<fastf_t> vertices(num_vertices * 3); - for (int i = 0; i < num_vertices; ++i) { - const ON_3fPoint &point = mesh.m_V[i]; + for (std::size_t i = 0; i < num_vertices; ++i) { + const ON_3fPoint &point = mesh.m_V[static_cast<int>(i)]; vertices[i * 3] = point.x; vertices[i * 3 + 1] = point.y; vertices[i * 3 + 2] = point.z; } std::vector<int> faces(num_faces * 3); - for (int i = 0; i < num_faces; ++i) { - const ON_MeshFace &face = mesh.m_F[i]; + for (std::size_t i = 0; i < num_faces; ++i) { + const ON_MeshFace &face = mesh.m_F[static_cast<int>(i)]; faces[i * 3] = face.vi[0]; faces[i * 3 + 1] = face.vi[1]; faces[i * 3 + 2] = face.vi[2]; } - mk_bot(m_db, mesh_name.c_str(), 0, 0, 0, - num_vertices, num_faces, &vertices[0], &faces[0], - NULL, NULL); + std::vector<fastf_t> thicknesses; + + AutoDestroyer<bu_bitv, void, bu_bitv_free> mbitv; + + if (mode == RT_BOT_PLATE) { + thicknesses.assign(num_faces, 2); + mbitv.ptr = bu_bitv_new(num_faces); + } + + if (mesh.m_FN.Count() != mesh.m_F.Count()) { + int r = mk_bot(m_db, mesh_name.c_str(), mode, orientation, 0, + num_vertices, num_faces, &vertices[0], &faces[0], + thicknesses.empty() ? NULL : &thicknesses[0], + mbitv.ptr); + + if (r) throw std::runtime_error("mk_bot() failed"); + } else { + std::vector<fastf_t> normals(num_faces * 3); + for (std::size_t i = 0; i < num_faces; ++i) { + const ON_3fVector &vec = mesh.m_FN[static_cast<int>(i)]; + normals[i * 3] = vec.x; + normals[i * 3 + 1] = vec.y; + normals[i * 3 + 2] = vec.z; + } + + std::vector<int> face_normals(num_faces * 3); + for (std::size_t i = 0; i < num_faces; ++i) { + face_normals[i * 3] = i; + face_normals[i * 3 + 1] = i; + face_normals[i * 3 + 2] = i; + } + + int r = mk_bot_w_normals(m_db, mesh_name.c_str(), mode, orientation, + RT_BOT_HAS_SURFACE_NORMALS | RT_BOT_USE_NORMALS, + num_vertices, num_faces, &vertices[0], &faces[0], + thicknesses.empty() ? NULL : &thicknesses[0], + mbitv.ptr, num_faces, &normals[0], &face_normals[0]); + + if (r) throw std::runtime_error("mk_bot_w_normals() failed"); + } + create_geom_comb(mesh_attrs); } - - void RhinoConverter::create_all_geometry() { @@ -985,8 +943,6 @@ } - - void RhinoConverter::create_geometry(const ON_Geometry *geom, const ON_3dmObjectAttributes &geom_attrs) @@ -1007,7 +963,6 @@ create_mesh(*mesh, geom_attrs); - if (m_verbose_mode) mesh->Dump(*m_log); } else if (const ON_RevSurface *revsurf = ON_RevSurface::Cast(geom)) { m_log->Print("-- Skipping: Type: ON_RevSurface\n"); if (m_verbose_mode) revsurf->Dump(*m_log); @@ -1045,24 +1000,16 @@ } - - } - - #endif //OBJ_BREP - - - -/* - * Local Variables: - * tab-width: 8 - * mode: C++ - * c-basic-offset: 4 - * indent-tabs-mode: t - * 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 Modified: brlcad/branches/openscenegraph/src/conv/3dm/conv3dm-g.hpp =================================================================== --- brlcad/branches/openscenegraph/src/conv/3dm/conv3dm-g.hpp 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/src/conv/3dm/conv3dm-g.hpp 2014-07-11 19:24:42 UTC (rev 61672) @@ -1,14 +1,14 @@ -/* C O N V 3 D M - G . H +/* C O N V 3 D M - G . H P P * BRL-CAD * * Copyright (c) 2004-2014 United States Government as represented by * the U.S. Army Research Laboratory. * - * This program is free software; you can redistribute it and/or + * 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 program is distributed in the hope that it will be useful, but + * 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. @@ -17,10 +17,9 @@ * License along with this file; see the file named COPYING for more * information. */ -/** @file conv3dm-g.cpp +/** @file conv3dm-g.hpp * - * Program to convert a Rhino model (in a .3dm file) to a BRL-CAD .g - * file. + * Library for conversion of Rhino models (in .3dm files) to BRL-CAD databases. * */ @@ -28,6 +27,7 @@ #ifndef CONV3DM_G_H #define CONV3DM_G_H +#include "common.h" #include <map> #include <memory> @@ -120,15 +120,11 @@ #endif - - - -/* - * Local Variables: - * tab-width: 8 - * mode: C++ - * c-basic-offset: 4 - * indent-tabs-mode: t - * 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/openscenegraph/src/conv/3dm/solidity.cpp (from rev 61669, brlcad/trunk/src/conv/3dm/solidity.cpp) =================================================================== --- brlcad/branches/openscenegraph/src/conv/3dm/solidity.cpp (rev 0) +++ brlcad/branches/openscenegraph/src/conv/3dm/solidity.cpp 2014-07-11 19:24:42 UTC (rev 61672) @@ -0,0 +1,106 @@ +/* S O L I D I T Y . C P P + * BRL-CAD + * + * Copyright (c) 2014 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 solidity.cpp + * + * Library to determine whether a BoT is closed. + * + */ + + +#include "solidity.h" + + +#include <map> +#include <set> + + +namespace +{ + + +typedef std::pair<std::size_t, std::size_t> Edge; + + +static bool register_edge( + std::vector<std::set<Edge> > &vertex_edges, + std::map<Edge, int> &edge_incidence_map, + std::size_t va, std::size_t vb) +{ + const Edge edge(std::min(va, vb), std::max(va, vb)); + vertex_edges[va].insert(edge); + vertex_edges[vb].insert(edge); + + // test fails if any edge borders more than two faces + return ++edge_incidence_map[edge] <= 2; +} + + +} + + +int bot_is_closed(const rt_bot_internal *bot) +{ + std::map<Edge, int> edge_incidence_map; + std::vector<std::set<Edge> > vertex_edges(bot->num_vertices); + + // map edges to number of incident faces + // map vertices to edges + for (std::size_t fi = 0; fi < bot->num_faces; ++fi) { + const std::size_t v1 = bot->faces[fi * 3]; + const std::size_t v2 = bot->faces[fi * 3 + 1]; + const std::size_t v3 = bot->faces[fi * 3 + 2]; + + bool valid = register_edge(vertex_edges, edge_incidence_map, v1, v2) + && register_edge(vertex_edges, edge_incidence_map, v1, v3) + && register_edge(vertex_edges, edge_incidence_map, v2, v3); + + if (!valid) return false; + } + + // all edges must border exactly two faces + for (std::map<Edge, int>::const_iterator it = edge_incidence_map.begin(); + it != edge_incidence_map.end(); ++it) + if (it->second != 2) return false; + + for (std::vector<std::set<Edge> >::const_iterator + vertex_it = vertex_edges.begin(); + vertex_it != vertex_edges.end(); ++vertex_it) { + + // each vertex must be incident to at least two edges + if (vertex_it->size() < 2) return false; + + // check if the edges form a closed or open fan + for (std::set<Edge>::const_iterator it = vertex_it->begin(); + it != vertex_it->end(); ++it) { + // TODO + } + } + + return true; +} + +// 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/openscenegraph/src/conv/3dm/solidity.h (from rev 61669, brlcad/trunk/src/conv/3dm/solidity.h) =================================================================== --- brlcad/branches/openscenegraph/src/conv/3dm/solidity.h (rev 0) +++ brlcad/branches/openscenegraph/src/conv/3dm/solidity.h 2014-07-11 19:24:42 UTC (rev 61672) @@ -0,0 +1,50 @@ +/* S O L I D I T Y . H + * BRL-CAD + * + * Copyright (c) 2014 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 solidity.h + * + * Library to determine whether a BoT is closed. + * + */ + + +#include "common.h" + + +#include "raytrace.h" + + +#ifdef __cplusplus +#define EXTERN_C extern "C" +#else +#define EXTERN_C +#endif + + +EXTERN_C int bot_is_closed(const struct rt_bot_internal *bot); + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Modified: brlcad/branches/openscenegraph/src/conv/comgeom/mat.c =================================================================== --- brlcad/branches/openscenegraph/src/conv/comgeom/mat.c 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/src/conv/comgeom/mat.c 2014-07-11 19:24:42 UTC (rev 61672) @@ -292,8 +292,6 @@ } - - /* * Takes a pointer to [x, y, z, w], and converts it to * an ordinary vector [x/w, y/w, z/w]. Modified: brlcad/branches/openscenegraph/src/conv/g-shell-rect.c =================================================================== --- brlcad/branches/openscenegraph/src/conv/g-shell-rect.c 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/src/conv/g-shell-rect.c 2014-07-11 19:24:42 UTC (rev 61672) @@ -1779,8 +1779,8 @@ if (!output_file) bu_exit(1, "ERROR: Output file must be specified!\n"); if ((fd_out = wdb_fopen(output_file)) == NULL) { - perror(argv[0]); - bu_exit(1, "ERROR: Cannot open output file (%s)\n", output_file); + perror(argv[0]); + bu_exit(1, "ERROR: Cannot open output file (%s)\n", output_file); } mk_id(fd_out, "test g-sgp"); Modified: brlcad/branches/openscenegraph/src/conv/nmg/asc-nmg.c =================================================================== --- brlcad/branches/openscenegraph/src/conv/nmg/asc-nmg.c 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/src/conv/nmg/asc-nmg.c 2014-07-11 19:24:42 UTC (rev 61672) @@ -65,7 +65,7 @@ } if (isatty(fileno(stdin)) && isatty(fileno(stdout)) && argc == 1) { - usage(); + usage(); bu_log(" Program continues running:\n"); } Modified: brlcad/branches/openscenegraph/src/conv/nmg/g-nmg.c =================================================================== --- brlcad/branches/openscenegraph/src/conv/nmg/g-nmg.c 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/src/conv/nmg/g-nmg.c 2014-07-11 19:24:42 UTC (rev 61672) @@ -535,7 +535,7 @@ regions_tried, regions_converted, percent); if (suppliedname) - printf("Output file name: %s\n",out_file); + printf("Output file name: %s\n",out_file); else printf("Output file name (default): %s\n",out_file); Modified: brlcad/branches/openscenegraph/src/conv/step/BRLCADWrapper.cpp =================================================================== --- brlcad/branches/openscenegraph/src/conv/step/BRLCADWrapper.cpp 2014-07-11 19:23:58 UTC (rev 61671) +++ brlcad/branches/openscenegraph/src/conv/step/BRLCADWrapper.cpp 2014-07-11 19:24:42 UTC (rev 61672) @@ -108,11 +108,70 @@ return true; } + +/* This simple routine will replace diacritic characters(code >= 192) from the extended + * ASCII set with a specific mapping from the standard ASCII set. This code was copied + * and modified from a solution provided on stackoverflow.com at: + * (http://stackoverflow.com/questions/14094621/) + */ std::string +BRLCADWrapper::ReplaceAccented( std::string &str ) { + std::string retStr = ""; + const char *p = str.c_str(); + while ( (*p)!=0 ) { + const char* + // "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" + tr = "AAAAAAECEEEEIIIIDNOOOOOx0UUUUYPsaaaaaaeceeeeiiiiOnooooo/0uuuuypy"; + unsigned char ch = (*p); + if ( ch >=192 ) { + retStr += tr[ ch-192 ]; + } else { + retStr += *p; + } + ++p; + } + return retStr; +} + + +/* + * Simplifying names for better behavior under our Tcl based tools. This routine + * replaces spaces and non-alphanumeric characters with underscores. It also replaces + * ASCII extended characters representing diacritics (code >= 192) with specific + * mapped ASCII characters below ASCII code 128. + */ +std::string +BRLCADWrapper::CleanBRLCADName(std::string &inname) +{ + std::string retStr = ""; + std::string name = ReplaceAccented(inname); + char *cp; + + for (cp = (char *)name.c_str(); *cp != '\0'; ++cp) { + if (*cp == '\'') { + // remove non-printable + continue; + } + if (*cp == ' ') { + // replace spaces with underscores + retStr += '_'; + ... [truncated message content] |