Thread: [brlcad-commits] SF.net SVN: brlcad:[58217] brlcad/trunk/src/libged (Page 9)
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <tbr...@us...> - 2013-10-18 17:07:32
|
Revision: 58217 http://sourceforge.net/p/brlcad/code/58217 Author: tbrowder2 Date: 2013-10-18 17:07:27 +0000 (Fri, 18 Oct 2013) Log Message: ----------- correct print format erros and use C89 print formats; some ws and style changes Modified Paths: -------------- brlcad/trunk/src/libged/bot_fuse.c brlcad/trunk/src/libged/brep.c brlcad/trunk/src/libged/wdb_obj.c Modified: brlcad/trunk/src/libged/bot_fuse.c =================================================================== --- brlcad/trunk/src/libged/bot_fuse.c 2013-10-18 17:06:57 UTC (rev 58216) +++ brlcad/trunk/src/libged/bot_fuse.c 2013-10-18 17:07:27 UTC (rev 58217) @@ -102,7 +102,7 @@ BN_ADD_VLIST(vbp->free_vlist_hd, vhead, pt2, BN_VLIST_LINE_DRAW); } else if (out_type == 2) { if (!plotfp) { - bu_vls_sprintf(&plot_file_name, "%s.%zu.pl", name, magic_p); + bu_vls_sprintf(&plot_file_name, "%s.%p.pl", name, (void *)magic_p); if ((plotfp = fopen(bu_vls_addr(&plot_file_name), "wb")) == (FILE *)NULL) { bu_vls_free(&plot_file_name); bu_log("Error, unable to create plot file (%s), open edge test failed.\n", Modified: brlcad/trunk/src/libged/brep.c =================================================================== --- brlcad/trunk/src/libged/brep.c 2013-10-18 17:06:57 UTC (rev 58216) +++ brlcad/trunk/src/libged/brep.c 2013-10-18 17:07:27 UTC (rev 58217) @@ -249,7 +249,7 @@ bu_vls_init(&bname_suffix); bu_vls_sprintf(&bname_suffix, "%s%s", solid_name, bu_vls_addr(&suffix)); if (db_lookup(gedp->ged_wdbp->dbip, bu_vls_addr(&bname_suffix), LOOKUP_QUIET) != RT_DIR_NULL) { - bu_vls_printf(gedp->ged_result_str, "%s already exists.", bname_suffix); + bu_vls_printf(gedp->ged_result_str, "%s already exists.", bu_vls_addr(&bname_suffix)); bu_vls_free(&bname); bu_vls_free(&suffix); bu_vls_free(&bname_suffix); Modified: brlcad/trunk/src/libged/wdb_obj.c =================================================================== --- brlcad/trunk/src/libged/wdb_obj.c 2013-10-18 17:06:57 UTC (rev 58216) +++ brlcad/trunk/src/libged/wdb_obj.c 2013-10-18 17:07:27 UTC (rev 58217) @@ -2892,7 +2892,7 @@ return TCL_ERROR; } - bu_vls_printf(&vls, "%p", wdbp->dbip); + bu_vls_printf(&vls, "%p", (void *)wdbp->dbip); Tcl_AppendResult(wdbp->wdb_interp, bu_vls_addr(&vls), (char *)NULL); bu_vls_free(&vls); return TCL_OK; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2013-11-07 20:46:12
|
Revision: 58485 http://sourceforge.net/p/brlcad/code/58485 Author: starseeker Date: 2013-11-07 20:46:08 +0000 (Thu, 07 Nov 2013) Log Message: ----------- Add the osg libged file as well. Modified Paths: -------------- brlcad/trunk/src/libged/CMakeLists.txt Added Paths: ----------- brlcad/trunk/src/libged/osg.cpp Modified: brlcad/trunk/src/libged/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libged/CMakeLists.txt 2013-11-07 20:39:03 UTC (rev 58484) +++ brlcad/trunk/src/libged/CMakeLists.txt 2013-11-07 20:46:08 UTC (rev 58485) @@ -346,6 +346,7 @@ simulate/simulate.h simulate/simutils.h wdb_qray.h + osg.cpp ) CMAKEFILES(${ged_ignore_files}) Added: brlcad/trunk/src/libged/osg.cpp =================================================================== --- brlcad/trunk/src/libged/osg.cpp (rev 0) +++ brlcad/trunk/src/libged/osg.cpp 2013-11-07 20:46:08 UTC (rev 58485) @@ -0,0 +1,320 @@ +/* O S G . C P P + * BRL-CAD + * + * Copyright (c) 2011 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. + */ +/** @addtogroup libged */ +/** @{ */ +/** @file libged/osg.cpp + * + * An interface to OSG. + * + */ +/** @} */ + +#include "common.h" + +#include "ged.h" +#include "solid.h" +#include <assert.h> + +#include <osg/Geode> +#include <osg/Geometry> +#include <osg/RenderInfo> +#include <osgViewer/Viewer> +#include <osgUtil/Optimizer> +#include <osgDB/ReadFile> +#include <osgDB/WriteFile> + + +__BEGIN_DECLS +void ged_osgLoadScene(struct bu_list *hdlp, void *osgData); +__END_DECLS + + +struct osg_stuff { + osg::ref_ptr<osgViewer::Viewer> viewer; + double left, right, bottom, top, near, far; + int prev_pflag; +}; + +HIDDEN void +_osgLoadHiddenSolid(osg::Geode *geode, struct solid *sp) +{ + register struct bn_vlist *vp = (struct bn_vlist *)&sp->s_vlist; + osg::Vec3dArray* vertices; +} + + +HIDDEN void +_osgLoadSolid(osg::Geode *geode, osg::Geometry *geom, osg::Vec3dArray *vertices, osg::Vec3dArray *normals, struct solid *sp) +{ + struct bn_vlist *tvp; + int first; +#if 0 + int mflag = 1; + static float black[4] = {0.0, 0.0, 0.0, 0.0}; +#endif + register struct bn_vlist *vp = (struct bn_vlist *)&sp->s_vlist; + int begin; + int nverts; + + bu_log("ged_osgLoadSolid: enter\n"); + +#if 0 + if (line_style != sp->s_soldash) { + line_style = sp->s_soldash; + DM_SET_LINE_ATTR(dmp, dmp->dm_lineWidth, line_style); + } + + if (sp->s_iflag == UP) + DM_SET_FGCOLOR(dmp, 255, 255, 255, 0, sp->s_transparency); + else + DM_SET_FGCOLOR(dmp, + (unsigned char)sp->s_color[0], + (unsigned char)sp->s_color[1], + (unsigned char)sp->s_color[2], 0, sp->s_transparency); + + if (sp->s_hiddenLine) { + DM_DRAW_VLIST_HIDDEN_LINE(dmp, (struct bn_vlist *)&sp->s_vlist); + } else { + DM_DRAW_VLIST(dmp, (struct bn_vlist *)&sp->s_vlist); + } +#endif + + + /* Viewing region is from -1.0 to +1.0 */ + begin = 0; + nverts = 0; + first = 1; + for (BU_LIST_FOR(tvp, bn_vlist, &vp->l)) { + int i; + int nused = tvp->nused; + int *cmd = tvp->cmd; + point_t *pt = tvp->pt; + for (i = 0; i < nused; i++, cmd++, pt++) { + switch (*cmd) { + case BN_VLIST_LINE_MOVE: +#if 0 + /* Move, start line */ + if (first == 0) + glEnd(); + first = 0; + + if (dmp->dm_light && mflag) { + mflag = 0; + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, wireColor); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, black); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, black); + + if (dmp->dm_transparency) + glDisable(GL_BLEND); + } + + glBegin(GL_LINE_STRIP); + glVertex3dv(*pt); +#else + /* Move, start line */ + if (first == 0) { + geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,begin,nverts)); + //geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,vertices->size())); + + bu_log("Add linestrip: begin - %d, nverts - %d\n", begin, nverts); + + // add the points geometry to the geode. + //geode->addDrawable(geom); + } else + first = 0; + + vertices->push_back(osg::Vec3d((*pt)[X], (*pt)[Y], (*pt)[Z])); + normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f)); + begin += nverts; + nverts = 1; + //bu_log("ged_osgLoadSolid: loaded point - (%lf %lf %lf)\n", (*pt)[X], (*pt)[Y], (*pt)[Z]); +#endif + break; + case BN_VLIST_POLY_START: +#if 0 + /* Start poly marker & normal */ + if (first == 0) + glEnd(); + first = 0; + + if (dmp->dm_light && mflag) { + mflag = 0; + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambientColor); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularColor); + glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseColor); + + switch (dmp->dm_light) { + case 1: + break; + case 2: + glMaterialfv(GL_BACK, GL_DIFFUSE, diffuseColor); + break; + case 3: + glMaterialfv(GL_BACK, GL_DIFFUSE, backDiffuseColorDark); + break; + default: + glMaterialfv(GL_BACK, GL_DIFFUSE, backDiffuseColorLight); + break; + } + + if (dmp->dm_transparency) + glEnable(GL_BLEND); + } + + glBegin(GL_POLYGON); + /* Set surface normal (vl_pnt points outward) */ + glNormal3dv(*pt); +#endif + normals->push_back(osg::Vec3d((*pt)[X], (*pt)[Y], (*pt)[Z])); + begin += nverts; + nverts = 0; + + break; + case BN_VLIST_LINE_DRAW: + case BN_VLIST_POLY_MOVE: + case BN_VLIST_POLY_DRAW: + vertices->push_back(osg::Vec3d((*pt)[X], (*pt)[Y], (*pt)[Z])); + ++nverts; + + //bu_log("ged_osgLoadSolid: loaded point - (%lf %lf %lf)\n", (*pt)[X], (*pt)[Y], (*pt)[Z]); + break; + case BN_VLIST_POLY_END: +#if 0 + /* Draw, End Polygon */ + glVertex3dv(*pt); + glEnd(); +#endif + //vertices->push_back(osg::Vec3d((*pt)[X], (*pt)[Y], (*pt)[Z])); + //++nverts; + geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,begin,nverts)); + first = 1; + + bu_log("Add polygon: begin - %d, nverts - %d\n", begin, nverts); + + break; + case BN_VLIST_POLY_VERTNORM: +#if 0 + /* Set per-vertex normal. Given before vert. */ + glNormal3dv(*pt); +#endif + break; + } + } + } + + if (first == 0) { + geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,begin,nverts)); + //geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,vertices->size())); + + bu_log("Add linestrip: begin - %d, nverts - %d\n", begin, nverts); + + // add the points geometry to the geode. + //geode->addDrawable(geom); + } + + bu_log("ged_osgLoadSolid: leave\n"); +} + + +void +ged_osgLoadScene(struct bu_list *hdlp, void *osgData) +{ + register struct ged_display_list *gdlp; + register struct ged_display_list *next_gdlp; + struct solid *sp; + struct osg_stuff *osp = (struct osg_stuff *)osgData; +#if 0 + int line_style = -1; +#endif + + //bu_log("ged_osgLoadScene: do nothing!\n"); + //return; + +#if 0 + bu_log("ged_osgLoadScene: part A\n"); + osp->viewer->setSceneData(osgDB::readNodeFile("/home/bparker/brlcad/bin/a10_skin.osg")); +#else + bu_log("ged_osgLoadScene: part B\n"); + osg::Group* root = new osg::Group(); + + // create the Geode (Geometry Node) to contain all our osg::Geometry objects. + osg::Geode* geode = new osg::Geode(); + + bu_log("before: max frame rate - %lf\n", osp->viewer->getRunMaxFrameRate()); +#if 1 + bu_log("ged_osgLoadScene: enter\n"); + gdlp = BU_LIST_NEXT(ged_display_list, hdlp); + while (BU_LIST_NOT_HEAD(gdlp, hdlp)) { + next_gdlp = BU_LIST_PNEXT(ged_display_list, gdlp); + + FOR_ALL_SOLIDS(sp, &gdlp->gdl_headSolid) { + if (sp->s_hiddenLine) { + _osgLoadHiddenSolid(geode, sp); + } else { + osg::Geometry* geom = new osg::Geometry(); + osg::Vec3dArray* vertices = new osg::Vec3dArray; + osg::Vec3dArray* normals = new osg::Vec3dArray; + _osgLoadSolid(geode, geom, vertices, normals, sp); + geom->setVertexArray(vertices); + geom->setNormalArray(normals); + geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET); + //osg::RenderInfo ri(osp->viewer->getCamera()->getGraphicsContext()->getState(), osp->viewer->getCamera()->getView()); + //geom->compileGLObjects(ri); + geom->setUseDisplayList(true); + geode->addDrawable(geom); + } + } + + gdlp = next_gdlp; + } +#endif + +#if 1 + //osp->viewer->setSceneData(osgDB::readNodeFile("/home/bparker/brlcad/bin/a10_skin.osg")); + root->addChild(geode); + osp->viewer->setSceneData(root); +#else + // Made no difference + //osgUtil::Optimizer optimizer; + //optimizer.optimize(geode); + + osp->viewer->setSceneData(geode); +#endif + bu_log("after: max frame rate - %lf\n", osp->viewer->getRunMaxFrameRate()); + +// if (!osgDB::writeNodeFile(*geode, "a10_skin.osg")) +// bu_log("ged_osgLoadScene: failed to write geode to a10.osg\n"); + + bu_log("ged_osgLoadScene: loaded geode\n"); +#endif +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: brlcad/trunk/src/libged/osg.cpp ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pet...@us...> - 2013-12-21 20:02:11
|
Revision: 59111 http://sourceforge.net/p/brlcad/code/59111 Author: peter-sa Date: 2013-12-21 20:02:08 +0000 (Sat, 21 Dec 2013) Log Message: ----------- Replace calls to qsort() with calls to bu_sort() (GCI Task : http://www.google-melange.com/gci/task/view/google/gci2013/5138768247914496) Modified Paths: -------------- brlcad/trunk/src/libged/attr.c brlcad/trunk/src/libged/comb.c Modified: brlcad/trunk/src/libged/attr.c =================================================================== --- brlcad/trunk/src/libged/attr.c 2013-12-21 19:11:14 UTC (rev 59110) +++ brlcad/trunk/src/libged/attr.c 2013-12-21 20:02:08 UTC (rev 59111) @@ -42,10 +42,10 @@ /* - * avs attribute comparison function, e.g. for qsort + * avs attribute comparison function, e.g. for bu_sort */ HIDDEN int -attr_cmp(const void *p1, const void *p2) +attr_cmp(const void *p1, const void *p2, void *UNUSED(arg)) { return bu_strcmp(((struct bu_attribute_value_pair *)p1)->name, ((struct bu_attribute_value_pair *)p2)->name); @@ -53,7 +53,7 @@ HIDDEN int -attr_cmp_nocase(const void *p1, const void *p2) +attr_cmp_nocase(const void *p1, const void *p2, void *UNUSED(arg)) { return bu_strcasecmp(((struct bu_attribute_value_pair *)p1)->name, ((struct bu_attribute_value_pair *)p2)->name); @@ -61,7 +61,7 @@ HIDDEN int -attr_cmp_value(const void *p1, const void *p2) +attr_cmp_value(const void *p1, const void *p2, void *UNUSED(arg)) { return bu_strcmp(((struct bu_attribute_value_pair *)p1)->value, ((struct bu_attribute_value_pair *)p2)->value); @@ -69,7 +69,7 @@ HIDDEN int -attr_cmp_value_nocase(const void *p1, const void *p2) +attr_cmp_value_nocase(const void *p1, const void *p2, void *UNUSED(arg)) { return bu_strcasecmp(((struct bu_attribute_value_pair *)p1)->value, ((struct bu_attribute_value_pair *)p2)->value); @@ -230,7 +230,7 @@ } /* default: sort attribute-value set array by attribute name (case sensitive) */ - qsort(&avs.avp[0], avs.count, sizeof(struct bu_attribute_value_pair), attr_cmp); + bu_sort(&avs.avp[0], avs.count, sizeof(struct bu_attribute_value_pair), attr_cmp, NULL); if (scmd == ATTR_SORT) { /* pretty print */ @@ -243,11 +243,11 @@ } else { /* argv[3] is the sort type: 'case', 'nocase', 'value', 'value-nocase' */ if (BU_STR_EQUIV(argv[3], NOCASE)) { - qsort(&avs.avp[0], avs.count, sizeof(struct bu_attribute_value_pair), attr_cmp_nocase); + bu_sort(&avs.avp[0], avs.count, sizeof(struct bu_attribute_value_pair), attr_cmp_nocase, NULL); } else if (BU_STR_EQUIV(argv[3], VALUE)) { - qsort(&avs.avp[0], avs.count, sizeof(struct bu_attribute_value_pair), attr_cmp_value); + bu_sort(&avs.avp[0], avs.count, sizeof(struct bu_attribute_value_pair), attr_cmp_value, NULL); } else if (BU_STR_EQUIV(argv[3], VALUE_NOCASE)) { - qsort(&avs.avp[0], avs.count, sizeof(struct bu_attribute_value_pair), attr_cmp_value_nocase); + bu_sort(&avs.avp[0], avs.count, sizeof(struct bu_attribute_value_pair), attr_cmp_value_nocase, NULL); } else if (BU_STR_EQUIV(argv[3], CASE)) { ; /* don't need to do anything since this is the existing (default) sort */ } Modified: brlcad/trunk/src/libged/comb.c =================================================================== --- brlcad/trunk/src/libged/comb.c 2013-12-21 19:11:14 UTC (rev 59110) +++ brlcad/trunk/src/libged/comb.c 2013-12-21 20:02:08 UTC (rev 59111) @@ -202,9 +202,9 @@ return GED_OK; } -/* QSort functions for solids */ +/* bu_sort functions for solids */ HIDDEN int -name_compare(const void *d1, const void *d2) +name_compare(const void *d1, const void *d2, void *UNUSED(arg)) { struct directory *dp1 = *(struct directory **)d1; struct directory *dp2 = *(struct directory **)d2; @@ -220,7 +220,7 @@ * * Run the first search, and quit if any non-union ops are present. * If all clear, search for the solid and comb lists. Clear the old - * tree and union in all the solids - solids are sorted via qsort. + * tree and union in all the solids - solids are sorted via bu_sort. * If we have combs, run the not-in-this-comb-tree search and check * which (if any) of the combs under the current comb are not used * elsewhere. For those that are not, remove them. @@ -284,7 +284,7 @@ /* Sort the solids and union them into a new tree for dp */ if (BU_PTBL_LEN(solids)) { - qsort((genptr_t)BU_PTBL_BASEADDR(solids), BU_PTBL_LEN(solids), sizeof(struct directory *), name_compare); + bu_sort((void *)BU_PTBL_BASEADDR(solids), BU_PTBL_LEN(solids), sizeof(struct directory *), name_compare, NULL); for (BU_PTBL_FOR(dp_curr, (struct directory **), solids)) { /* add "child" comb to the newly cleared parent */ if (_ged_combadd(gedp, (*dp_curr), dp->d_namep, 0, WMOP_UNION, 0, 0) == RT_DIR_NULL) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pet...@us...> - 2013-12-30 23:11:48
|
Revision: 59236 http://sourceforge.net/p/brlcad/code/59236 Author: peter-sa Date: 2013-12-30 23:11:43 +0000 (Mon, 30 Dec 2013) Log Message: ----------- Remove duplicate code in src/libged/track.c and src/libged/wdb_track.c, from GCI task http://www.google-melange.com/gci/task/view/google/gci2013/5274134879666176 Modified Paths: -------------- brlcad/trunk/src/libged/ged_private.h brlcad/trunk/src/libged/track.c brlcad/trunk/src/libged/wdb_track.c Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2013-12-30 23:10:43 UTC (rev 59235) +++ brlcad/trunk/src/libged/ged_private.h 2013-12-30 23:11:43 UTC (rev 59236) @@ -471,6 +471,8 @@ extern int _ged_results_clear(struct ged *gedp); +/* defined in track.c */ +extern int _ged_track(struct bu_vls *log_str, struct rt_wdb *wdbp, const char *argv[]); __END_DECLS Modified: brlcad/trunk/src/libged/track.c =================================================================== --- brlcad/trunk/src/libged/track.c 2013-12-30 23:10:43 UTC (rev 59235) +++ brlcad/trunk/src/libged/track.c 2013-12-30 23:11:43 UTC (rev 59236) @@ -74,11 +74,11 @@ static int track_mk_comb(); -/* ==== I T O A () +/* ==== I T O A () * convert integer to ascii wd format */ static void -itoa(struct ged *gedp, +itoa(struct bu_vls *log_str, int n, char s[], int w) { @@ -93,7 +93,7 @@ */ for (j = i; j < w; j++) s[j] = ' '; if (i > w) - bu_vls_printf(gedp->ged_result_str, "itoa: field length too small\n"); + bu_vls_printf(log_str, "itoa: field length too small\n"); s[w] = '\0'; /* reverse the array */ @@ -106,22 +106,21 @@ static void -crname(struct ged *gedp, +crname(struct bu_vls *log_str, char name[], int pos, int maxlen) { char temp[4]; - itoa(gedp, pos, temp, 1); + itoa(log_str, pos, temp, 1); bu_strlcat(name, temp, maxlen); - - return; } static void -crregion(struct ged *gedp, +crregion(struct bu_vls *log_str, + struct rt_wdb *wdbp, char region[], char op[], int members[], @@ -132,18 +131,21 @@ int i; struct bu_list head; + if (wdbp->dbip == DBI_NULL) + return; + BU_LIST_INIT(&head); for (i = 0; i < number; i++) { solidname[grpname_len + extraTypeChars] = '\0'; - crname(gedp, solidname, members[i], maxlen); - if (db_lookup(gedp->ged_wdbp->dbip, solidname, LOOKUP_QUIET) == RT_DIR_NULL) { - bu_vls_printf(gedp->ged_result_str, "region: %s will skip member: %s\n", region, solidname); + crname(log_str, solidname, members[i], maxlen); + if (db_lookup(wdbp->dbip, solidname, LOOKUP_QUIET) == RT_DIR_NULL) { + bu_vls_printf(log_str, "region: %s will skip member: %s\n", region, solidname); continue; } track_mk_addmember(solidname, &head, NULL, op[i]); } - (void)track_mk_comb(gedp->ged_wdbp, region, &head, + (void)track_mk_comb(wdbp, region, &head, 1, NULL, NULL, NULL, 500+Trackpos+i, 0, mat_default, los_default, 0, 1, 1); @@ -152,11 +154,13 @@ /* * - * Adds track given "wheel" info + * Adds track given "wheel" info. This only needs a logging VLS and a + * database, so it can be used as a replacement for wdb_track_cmd when + * no struct ged is available. * */ int -ged_track(struct ged *gedp, int argc, const char *argv[]) +_ged_track(struct bu_vls *log_str, struct rt_wdb *wdbp, const char *argv[]) { fastf_t fw[3], lw[3], iw[3], dw[3], tr[3]; char *solname = NULL; @@ -170,26 +174,7 @@ int edit_result = GED_OK; struct bu_list head; int len; - static const char *usage = "basename rX1 rX2 rZ rR dX dZ dR iX iZ iR minX minY th"; - GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); - GED_CHECK_READ_ONLY(gedp, GED_ERROR); - GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); - - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); - - /* must be wanting help */ - if (argc == 1) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_HELP; - } - - if (argc != 15) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_ERROR; - } - BU_LIST_INIT(&head); oper[0] = oper[2] = WMOP_INTERSECT; @@ -206,105 +191,105 @@ /* first road wheel X */ ++arg; - fw[0] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + fw[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; /* last road wheel X */ ++arg; - lw[0] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + lw[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; if (fw[0] <= lw[0]) { - bu_vls_printf(gedp->ged_result_str, "First wheel after last wheel - STOP\n"); + bu_vls_printf(log_str, "First wheel after last wheel - STOP\n"); edit_result = GED_ERROR; goto end; } /* road wheel Z */ ++arg; - fw[1] = lw[1] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + fw[1] = lw[1] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; /* roadwheel radius */ ++arg; - fw[2] = lw[2] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + fw[2] = lw[2] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; if (fw[2] <= 0) { - bu_vls_printf(gedp->ged_result_str, "Radius <= 0 - STOP\n"); + bu_vls_printf(log_str, "Radius <= 0 - STOP\n"); edit_result = GED_ERROR; goto end; } /* drive sprocket X */ ++arg; - dw[0] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + dw[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; if (dw[0] >= lw[0]) { - bu_vls_printf(gedp->ged_result_str, "DRIVE wheel not in the rear - STOP \n"); + bu_vls_printf(log_str, "DRIVE wheel not in the rear - STOP \n"); edit_result = GED_ERROR; goto end; } /* drive sprocket Z */ ++arg; - dw[1] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + dw[1] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; /* drive sprocket radius */ ++arg; - dw[2] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + dw[2] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; if (dw[2] <= 0) { - bu_vls_printf(gedp->ged_result_str, "Radius <= 0 - STOP\n"); + bu_vls_printf(log_str, "Radius <= 0 - STOP\n"); edit_result = GED_ERROR; goto end; } /* idler wheel X */ ++arg; - iw[0] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + iw[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; if (iw[0] <= fw[0]) { - bu_vls_printf(gedp->ged_result_str, "IDLER wheel not in the front - STOP \n"); + bu_vls_printf(log_str, "IDLER wheel not in the front - STOP \n"); edit_result = GED_ERROR; goto end; } /* idler wheel Z */ ++arg; - iw[1] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + iw[1] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; /* idler wheel radius */ ++arg; - iw[2] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + iw[2] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; if (iw[2] <= 0) { - bu_vls_printf(gedp->ged_result_str, "Radius <= 0 - STOP\n"); + bu_vls_printf(log_str, "Radius <= 0 - STOP\n"); edit_result = GED_ERROR; goto end; } /* track MIN Y */ ++arg; - tr[2] = tr[0] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + tr[2] = tr[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; /* track MAX Y */ ++arg; - tr[1] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + tr[1] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; if (EQUAL(tr[0], tr[1])) { - bu_vls_printf(gedp->ged_result_str, "MIN == MAX ... STOP\n"); + bu_vls_printf(log_str, "MIN == MAX ... STOP\n"); edit_result = GED_ERROR; goto end; } if (tr[0] > tr[1]) { - bu_vls_printf(gedp->ged_result_str, "MIN > MAX .... will switch\n"); + bu_vls_printf(log_str, "MIN > MAX .... will switch\n"); tr[1] = tr[0]; tr[0] = tr[2]; } /* track thickness */ ++arg; - tr[2] = atof(argv[arg]) * gedp->ged_wdbp->dbip->dbi_local2base; + tr[2] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; if (tr[2] <= 0) { - bu_vls_printf(gedp->ged_result_str, "Track thickness <= 0 - STOP\n"); + bu_vls_printf(log_str, "Track thickness <= 0 - STOP\n"); edit_result = GED_ERROR; goto end; } @@ -343,12 +328,12 @@ */ for (i = 0; i < 10; i++) { - crname(gedp, solname, i, len); - crname(gedp, regname, i, len); - if ((db_lookup(gedp->ged_wdbp->dbip, solname, LOOKUP_QUIET) != RT_DIR_NULL) || - (db_lookup(gedp->ged_wdbp->dbip, regname, LOOKUP_QUIET) != RT_DIR_NULL)) { + crname(log_str, solname, i, len); + crname(log_str, regname, i, len); + if ((db_lookup(wdbp->dbip, solname, LOOKUP_QUIET) != RT_DIR_NULL) || + (db_lookup(wdbp->dbip, regname, LOOKUP_QUIET) != RT_DIR_NULL)) { /* name already exists */ - bu_vls_printf(gedp->ged_result_str, "Track: naming error -- STOP\n"); + bu_vls_printf(log_str, "Track: naming error -- STOP\n"); edit_result = GED_ERROR; goto end; } @@ -363,13 +348,13 @@ /* add the solids */ /* solid 0 */ - slope(gedp, fw, iw, tr); + slope(log_str, fw, iw, tr); VMOVE(temp2, &sol.s_values[0]); - crname(gedp, solname, 0, len); + crname(log_str, solname, 0, len); bu_strlcpy(sol.s_name, solname, len); sol.s_type = ID_ARB8; - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; @@ -380,9 +365,9 @@ sol.s_values[i] = 0.0; sol.s_type = ID_TGC; trcurve(iw, tr); - crname(gedp, solname, 1, len); + crname(log_str, solname, 1, len); bu_strlcpy(sol.s_name, solname, len); - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; /* idler dummy rcc */ @@ -391,9 +376,9 @@ VMOVE(&sol.s_values[12], &sol.s_values[6]); VMOVE(&sol.s_values[15], &sol.s_values[9]); /* solid 2 */ - crname(gedp, solname, 2, len); + crname(log_str, solname, 2, len); bu_strlcpy(sol.s_name, solname, len); - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; @@ -401,11 +386,11 @@ /* find idler track dummy arb8 */ for (i = 0; i < 24; i++) sol.s_values[i] = 0.0; - crname(gedp, solname, 3, len); + crname(log_str, solname, 3, len); bu_strlcpy(sol.s_name, solname, len); sol.s_type = ID_ARB8; crdummy(iw, tr, 1); - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; @@ -413,11 +398,11 @@ /* track slope to drive */ for (i = 0; i < 24; i++) sol.s_values[i] = 0.0; - slope(gedp, lw, dw, tr); + slope(log_str, lw, dw, tr); VMOVE(temp1, &sol.s_values[0]); - crname(gedp, solname, 4, len); + crname(log_str, solname, 4, len); bu_strlcpy(sol.s_name, solname, len); - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; @@ -427,9 +412,9 @@ sol.s_values[i] = 0.0; sol.s_type = ID_TGC; trcurve(dw, tr); - crname(gedp, solname, 5, len); + crname(log_str, solname, 5, len); bu_strlcpy(sol.s_name, solname, len); - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; @@ -439,9 +424,9 @@ sol.s_values[11] = dw[2]; VMOVE(&sol.s_values[12], &sol.s_values[6]); VMOVE(&sol.s_values[15], &sol.s_values[9]); - crname(gedp, solname, 6, len); + crname(log_str, solname, 6, len); bu_strlcpy(sol.s_name, solname, len); - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; @@ -449,11 +434,11 @@ /* drive dummy arb8 */ for (i = 0; i < 24; i++) sol.s_values[i] = 0.0; - crname(gedp, solname, 7, len); + crname(log_str, solname, 7, len); bu_strlcpy(sol.s_name, solname, len); sol.s_type = ID_ARB8; crdummy(dw, tr, 2); - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; @@ -461,9 +446,9 @@ /* track bottom */ temp1[1] = temp2[1] = tr[0]; bottom(temp1, temp2, tr); - crname(gedp, solname, 8, len); + crname(log_str, solname, 8, len); bu_strlcpy(sol.s_name, solname, len); - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; @@ -475,9 +460,9 @@ temp2[0] = iw[0]; temp2[2] = iw[1] + iw[2]; top(temp1, temp2, tr); - crname(gedp, solname, 9, len); + crname(log_str, solname, 9, len); bu_strlcpy(sol.s_name, solname, len); - if (wrobj(gedp, solname, RT_DIR_SOLID)) + if (wrobj(log_str, wdbp, solname, RT_DIR_SOLID)) return GED_ERROR; solname[grpname_len + extraTypeChars] = '\0'; @@ -492,53 +477,53 @@ /* region 1 */ memb[0] = 0; memb[1] = 3; - crname(gedp, regname, 0, len); - crregion(gedp, regname, oper, memb, 2, solname, len); + crname(log_str, regname, 0, len); + crregion(log_str, wdbp, regname, oper, memb, 2, solname, len); solname[grpname_len + extraTypeChars] = '\0'; regname[grpname_len + extraTypeChars] = '\0'; /* region 1 */ - crname(gedp, regname, 1, len); + crname(log_str, regname, 1, len); memb[0] = 1; memb[1] = 2; memb[2] = 3; - crregion(gedp, regname, oper, memb, 3, solname, len); + crregion(log_str, wdbp, regname, oper, memb, 3, solname, len); solname[grpname_len + extraTypeChars] = '\0'; regname[grpname_len + extraTypeChars] = '\0'; /* region 4 */ - crname(gedp, regname, 4, len); + crname(log_str, regname, 4, len); memb[0] = 4; memb[1] = 7; - crregion(gedp, regname, oper, memb, 2, solname, len); + crregion(log_str, wdbp, regname, oper, memb, 2, solname, len); solname[grpname_len + extraTypeChars] = '\0'; regname[grpname_len + extraTypeChars] = '\0'; /* region 5 */ - crname(gedp, regname, 5, len); + crname(log_str, regname, 5, len); memb[0] = 5; memb[1] = 6; memb[2] = 7; - crregion(gedp, regname, oper, memb, 3, solname, len); + crregion(log_str, wdbp, regname, oper, memb, 3, solname, len); solname[grpname_len + extraTypeChars] = '\0'; regname[grpname_len + extraTypeChars] = '\0'; /* region 8 */ - crname(gedp, regname, 8, len); + crname(log_str, regname, 8, len); memb[0] = 8; memb[1] = 0; memb[2] = 4; oper[2] = WMOP_SUBTRACT; - crregion(gedp, regname, oper, memb, 3, solname, len); + crregion(log_str, wdbp, regname, oper, memb, 3, solname, len); solname[grpname_len + extraTypeChars] = '\0'; regname[grpname_len + extraTypeChars] = '\0'; /* region 9 */ - crname(gedp, regname, 9, len); + crname(log_str, regname, 9, len); memb[0] = 9; memb[1] = 3; memb[2] = 7; - crregion(gedp, regname, oper, memb, 3, solname, len); + crregion(log_str, wdbp, regname, oper, memb, 3, solname, len); solname[grpname_len + extraTypeChars] = '\0'; regname[grpname_len + extraTypeChars] = '\0'; @@ -547,20 +532,20 @@ if (i == 2 || i == 3 || i == 6 || i == 7) continue; regname[grpname_len + extraTypeChars] = '\0'; - crname(gedp, regname, i, len); - if (db_lookup(gedp->ged_wdbp->dbip, regname, LOOKUP_QUIET) == RT_DIR_NULL) { - bu_vls_printf(gedp->ged_result_str, "group: %s will skip member: %s\n", grpname, regname); + crname(log_str, regname, i, len); + if (db_lookup(wdbp->dbip, regname, LOOKUP_QUIET) == RT_DIR_NULL) { + bu_vls_printf(log_str, "group: %s will skip member: %s\n", grpname, regname); continue; } track_mk_addmember(regname, &head, NULL, WMOP_UNION); } /* Add them all at once */ - if (track_mk_comb(gedp->ged_wdbp, grpname, &head, + if (track_mk_comb(wdbp, grpname, &head, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 1, 1) < 0) { - bu_vls_printf(gedp->ged_result_str, "An error has occurred while adding '%s' to the database.\n", grpname); + bu_vls_printf(log_str, "An error has occurred while adding '%s' to the database.\n", grpname); } Trackpos += 10; @@ -585,25 +570,57 @@ } +/* + * + * Adds track given "wheel" info. + * + */ +int +ged_track(struct ged *gedp, int argc, const char *argv[]) +{ + GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); + GED_CHECK_READ_ONLY(gedp, GED_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); + static const char *usage = "basename rX1 rX2 rZ rR dX dZ dR iX iZ iR minX minY th"; + + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); + + /* must be wanting help */ + if (argc == 1) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_HELP; + } + + if (argc != 15) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; + } + + return _ged_track(gedp->ged_result_str, gedp->ged_wdbp, argv); +} + static int -wrobj(struct ged *gedp, - char name[], - int flags) { +wrobj(struct bu_vls *log_str, + struct rt_wdb *wdbp, + const char name[], + int flags) +{ struct directory *tdp; struct rt_db_internal intern; int i; - if (gedp->ged_wdbp->dbip == DBI_NULL) - return 0; + if (wdbp->dbip == DBI_NULL) + return GED_OK; - if (db_lookup(gedp->ged_wdbp->dbip, name, LOOKUP_QUIET) != RT_DIR_NULL) { - bu_vls_printf(gedp->ged_result_str, "track naming error: %s already exists\n", name); - return GED_ERROR; + if (db_lookup(wdbp->dbip, name, LOOKUP_QUIET) != RT_DIR_NULL) { + bu_vls_printf(log_str, "track naming error: %s already exists\n", name); + return -1; } if (flags != RT_DIR_SOLID) { - bu_vls_printf(gedp->ged_result_str, "wrobj can only write solids, aborting\n"); - return GED_ERROR; + bu_vls_printf(log_str, "wrobj can only write solids, aborting\n"); + return -1; } RT_DB_INTERNAL_INIT(&intern); @@ -646,30 +663,27 @@ } break; default: - bu_vls_printf(gedp->ged_result_str, "Unrecognized solid type in 'wrobj', aborting\n"); + bu_vls_printf(log_str, "Unrecognized solid type in 'wrobj', aborting\n"); return GED_ERROR; } - tdp = db_diradd(gedp->ged_wdbp->dbip, name, RT_DIR_PHONY_ADDR, 0, flags, (genptr_t)&intern.idb_type); - if (tdp == RT_DIR_NULL) { + if ((tdp = db_diradd(wdbp->dbip, name, RT_DIR_PHONY_ADDR, 0, flags, (genptr_t)&intern.idb_type)) == RT_DIR_NULL) { rt_db_free_internal(&intern); - bu_vls_printf(gedp->ged_result_str, "Cannot add '%s' to directory, aborting\n", name); + bu_vls_printf(log_str, "Cannot add '%s' to directory, aborting\n", name); return GED_ERROR; } - if (rt_db_put_internal(tdp, gedp->ged_wdbp->dbip, &intern, &rt_uniresource) < 0) { + if (rt_db_put_internal(tdp, wdbp->dbip, &intern, &rt_uniresource) < 0) { rt_db_free_internal(&intern); - bu_vls_printf(gedp->ged_result_str, "wrobj(gedp, %s): write error\n", name); - bu_vls_printf(gedp->ged_result_str, "The in-memory table of contents may not match the status of the on-disk\ndatabase. The on-disk database should still be intact. For safety, \nyou should exit now, and resolve the I/O problem, before continuing.\n"); - + bu_vls_printf(log_str, "write error\n"); + bu_vls_printf(log_str, "The in-memory table of contents may not match the status of the on-disk\ndatabase. The on-disk database should still be intact. For safety, \nyou should exit now, and resolve the I/O problem, before continuing.\n"); return GED_ERROR; } - return 0; + return GED_OK; } - static void -tancir(struct ged *gedp, +tancir(struct bu_vls *log_str, fastf_t cir1[], fastf_t cir2[]) { static fastf_t mag; @@ -684,7 +698,7 @@ if (mag > 1.0e-20 || mag < -1.0e-20) { f = 1.0/mag; } else { - bu_vls_printf(gedp->ged_result_str, "tancir(): 0-length vector!\n"); + bu_vls_printf(log_str, "tancir(): 0-length vector!\n"); return; } VSCALE(work, work, f); @@ -707,7 +721,7 @@ static void -slope(struct ged *gedp, +slope(struct bu_vls *log_str, fastf_t wh1[], fastf_t wh2[], fastf_t t[]) { @@ -726,7 +740,7 @@ wh2[i] = temp; } } - tancir(gedp, wh1, wh2); + tancir(log_str, wh1, wh2); if (switchs) { for (i = 0; i < 3; i++) { temp = wh1[i]; @@ -769,9 +783,9 @@ work[1] = t[1] - t[0]; VMOVE(&sol.s_values[12], work); for (i = 3; i <= 9; i += 3) { - j = i + 12; - VADD2(&sol.s_values[j], &sol.s_values[i], work); - } + j = i + 12; + VADD2(&sol.s_values[j], &sol.s_values[i], work); + } return; } Modified: brlcad/trunk/src/libged/wdb_track.c =================================================================== --- brlcad/trunk/src/libged/wdb_track.c 2013-12-30 23:10:43 UTC (rev 59235) +++ brlcad/trunk/src/libged/wdb_track.c 2013-12-30 23:11:43 UTC (rev 59236) @@ -47,1169 +47,39 @@ #include "raytrace.h" #include "wdb.h" -/*XXX The following WDB_ defines need to go inside of a header file */ -#define WDB_TCL_CHECK_READ_ONLY \ - if (wdbp->dbip->dbi_read_only) { \ - bu_log("Sorry, this database is READ-ONLY\n"); \ - return TCL_ERROR; \ - } -#define WDB_TCL_ERROR_RECOVERY_SUGGESTION \ - bu_log("\ -The in-memory table of contents may not match the status of the on-disk\n\ -database. The on-disk database should still be intact. For safety, \n\ -you should exit now, and resolve the I/O problem, before continuing.\n") +#include "./ged_private.h" - -static int Trackpos = 0; -static int mat_default = 1; -static int los_default = 50; -static int item_default = 500; -static fastf_t plano[4], plant[4]; -static int grpname_len; -static int extraTypeChars = 3; -static int extraChars = 4; - -static struct track_solid { - int s_type; - char *s_name; - fastf_t s_values[24]; -} sol; - - -static int -wrobj(struct rt_wdb *wdbp, - const char name[], - int flags) -{ - struct directory *tdp; - struct rt_db_internal intern; - int i; - - if (wdbp->dbip == DBI_NULL) - return 0; - - if (db_lookup(wdbp->dbip, name, LOOKUP_QUIET) != RT_DIR_NULL) { - bu_log("track naming error: %s already exists\n", name); - return -1; - } - - if (flags != RT_DIR_SOLID) { - bu_log("wrobj can only write solids, aborting\n"); - return -1; - } - - RT_DB_INTERNAL_INIT(&intern); - switch (sol.s_type) { - case ID_ARB8: { - struct rt_arb_internal *arb; - - BU_ALLOC(arb, struct rt_arb_internal); - - arb->magic = RT_ARB_INTERNAL_MAGIC; - - VMOVE(arb->pt[0], &sol.s_values[0]); - for (i = 1; i < 8; i++) - VADD2(arb->pt[i], &sol.s_values[i*3], arb->pt[0]); - - intern.idb_ptr = (genptr_t)arb; - intern.idb_major_type = DB5_MAJORTYPE_BRLCAD; - intern.idb_type = ID_ARB8; - intern.idb_meth = &OBJ[ID_ARB8]; - } - break; - case ID_TGC: { - struct rt_tgc_internal *tgc; - - BU_ALLOC(tgc, struct rt_tgc_internal); - - tgc->magic = RT_TGC_INTERNAL_MAGIC; - - VMOVE(tgc->v, &sol.s_values[0]); - VMOVE(tgc->h, &sol.s_values[3]); - VMOVE(tgc->a, &sol.s_values[6]); - VMOVE(tgc->b, &sol.s_values[9]); - VMOVE(tgc->c, &sol.s_values[12]); - VMOVE(tgc->d, &sol.s_values[15]); - - intern.idb_ptr = (genptr_t)tgc; - intern.idb_major_type = DB5_MAJORTYPE_BRLCAD; - intern.idb_type = ID_TGC; - intern.idb_meth = &OBJ[ID_TGC]; - } - break; - default: - bu_log("Unrecognized solid type in 'wrobj', aborting\n"); - return -1; - } - - if ((tdp = db_diradd(wdbp->dbip, name, RT_DIR_PHONY_ADDR, 0, flags, (genptr_t)&intern.idb_type)) == RT_DIR_NULL) { - rt_db_free_internal(&intern); - bu_log("Cannot add '%s' to directory, aborting\n", name); - return -1; - } - - if (rt_db_put_internal(tdp, wdbp->dbip, &intern, &rt_uniresource) < 0) { - rt_db_free_internal(&intern); - bu_log("write error\n"); - WDB_TCL_ERROR_RECOVERY_SUGGESTION; - return -1; - } - return 0; -} - - -static void -tancir(fastf_t cir1[], - fastf_t cir2[]) { - static fastf_t mag; - vect_t work; - fastf_t f; - static fastf_t temp, tempp, ang, angc; - - work[0] = cir2[0] - cir1[0]; - work[2] = cir2[1] - cir1[1]; - work[1] = 0.0; - mag = MAGNITUDE(work); - if (mag > 1.0e-20 || mag < -1.0e-20) { - f = 1.0/mag; - } else { - bu_log("tancir(): 0-length vector!\n"); - return; - } - VSCALE(work, work, f); - temp = acos(work[0]); - if (work[2] < 0.0) - temp = 6.28318512717958646 - temp; - tempp = acos((cir1[2] - cir2[2]) * f); - ang = temp + tempp; - angc = temp - tempp; - if ((cir1[1] + cir1[2] * sin(ang)) > - (cir1[1] + cir1[2] * sin(angc))) - ang = angc; - plano[0] = cir1[0] + cir1[2] * cos(ang); - plano[1] = cir1[1] + cir1[2] * sin(ang); - plant[0] = cir2[0] + cir2[2] * cos(ang); - plant[1] = cir2[1] + cir2[2] * sin(ang); - - return; -} - - -static void -slope(fastf_t wh1[], - fastf_t wh2[], - fastf_t t[]) { - int i, j, switchs; - fastf_t temp; - fastf_t mag; - fastf_t z, r, b; - vect_t del, work; - - switchs = 0; - if (wh1[2] < wh2[2]) { - switchs++; - for (i = 0; i < 3; i++) { - temp = wh1[i]; - wh1[i] = wh2[i]; - wh2[i] = temp; - } - } - tancir(wh1, wh2); - if (switchs) { - for (i = 0; i < 3; i++) { - temp = wh1[i]; - wh1[i] = wh2[i]; - wh2[i] = temp; - } - } - if (plano[1] <= plant[1]) { - for (i = 0; i < 2; i++) { - temp = plano[i]; - plano[i] = plant[i]; - plant[i] = temp; - } - } - del[1] = 0.0; - del[0] = plano[0] - plant[0]; - del[2] = plano[1] - plant[1]; - mag = MAGNITUDE(del); - work[0] = -1.0 * t[2] * del[2] / mag; - if (del[0] < 0.0) - work[0] *= -1.0; - work[1] = 0.0; - work[2] = t[2] * fabs(del[0]) / mag; - b = (plano[1] - work[2]) - (del[2]/del[0]*(plano[0] - work[0])); - z = wh1[1]; - r = wh1[2]; - if (wh1[1] >= wh2[1]) { - z = wh2[1]; - r = wh2[2]; - } - sol.s_values[2] = z - r - t[2]; - sol.s_values[1] = t[0]; - sol.s_values[0] = (sol.s_values[2] - b) / (del[2] / del[0]); - sol.s_values[3] = plano[0] + (del[0]/mag) - work[0] - sol.s_values[0]; - sol.s_values[4] = 0.0; - sol.s_values[5] = plano[1] + (del[2]/mag) - work[2] - sol.s_values[2]; - VADD2(&sol.s_values[6], &sol.s_values[3], work); - VMOVE(&sol.s_values[9], work); - work[0] = work[2] = 0.0; - work[1] = t[1] - t[0]; - VMOVE(&sol.s_values[12], work); - for (i = 3; i <= 9; i += 3) { - j = i + 12; - VADD2(&sol.s_values[j], &sol.s_values[i], work); - } - - return; -} - - -static void -crdummy(fastf_t w[3], fastf_t t[3], int flag) -{ - fastf_t temp; - vect_t vec; - int i, j; - - vec[1] = 0.0; - if (plano[1] <= plant[1]) { - for (i = 0; i < 2; i++) { - temp = plano[i]; - plano[i] = plant[i]; - plant[i] = temp; - } - } - - vec[0] = w[2] + t[2] + 1.0; - vec[2] = ((plano[1] - w[1]) * vec[0]) / (plano[0] - w[0]); - if (flag > 1) - vec[0] *= -1.0; - if (vec[2] >= 0.0) - vec[2] *= -1.0; - sol.s_values[0] = w[0]; - sol.s_values[1] = t[0] -1.0; - sol.s_values[2] = w[1]; - VMOVE(&sol.s_values[3], vec); - vec[2] = w[2] + t[2] + 1.0; - VMOVE(&sol.s_values[6], vec); - vec[0] = 0.0; - VMOVE(&sol.s_values[9], vec); - vec[2] = 0.0; - vec[1] = t[1] - t[0] + 2.0; - VMOVE(&sol.s_values[12], vec); - for (i = 3; i <= 9; i += 3) { - j = i + 12; - VADD2(&sol.s_values[j], &sol.s_values[i], vec); - } - - return; - -} - - -static void -trcurve(fastf_t wh[], fastf_t t[]) -{ - sol.s_values[0] = wh[0]; - sol.s_values[1] = t[0]; - sol.s_values[2] = wh[1]; - sol.s_values[4] = t[1] - t[0]; - sol.s_values[6] = wh[2] + t[2]; - sol.s_values[11] = wh[2] + t[2]; - VMOVE(&sol.s_values[12], &sol.s_values[6]); - VMOVE(&sol.s_values[15], &sol.s_values[9]); -} - - -static void -bottom(vect_t vec1, vect_t vec2, fastf_t t[]) -{ - vect_t tvec; - int i, j; - - VMOVE(&sol.s_values[0], vec1); - tvec[0] = vec2[0] - vec1[0]; - tvec[1] = tvec[2] = 0.0; - VMOVE(&sol.s_values[3], tvec); - tvec[0] = tvec[1] = 0.0; - tvec[2] = t[2]; - VADD2(&sol.s_values[6], &sol.s_values[3], tvec); - VMOVE(&sol.s_values[9], tvec); - tvec[0] = tvec[2] = 0.0; - tvec[1] = t[1] - t[0]; - VMOVE(&sol.s_values[12], tvec); - - for (i = 3; i <= 9; i += 3) { - j = i + 12; - VADD2(&sol.s_values[j], &sol.s_values[i], tvec); - } -} - - -static void -top(vect_t vec1, vect_t vec2, fastf_t t[]) -{ - fastf_t tooch, mag; - vect_t del, tvec; - int i, j; - - tooch = t[2] * .25; - del[0] = vec2[0] - vec1[0]; - del[1] = 0.0; - del[2] = vec2[2] - vec1[2]; - mag = MAGNITUDE(del); - VSCALE(tvec, del, tooch/mag); - VSUB2(&sol.s_values[0], vec1, tvec); - VADD2(del, del, tvec); - VADD2(&sol.s_values[3], del, tvec); - tvec[0] = tvec[2] = 0.0; - tvec[1] = t[1] - t[0]; - VCROSS(del, tvec, &sol.s_values[3]); - mag = MAGNITUDE(del); - if (del[2] < 0) - mag *= -1.0; - VSCALE(&sol.s_values[9], del, t[2]/mag); - VADD2(&sol.s_values[6], &sol.s_values[3], &sol.s_values[9]); - VMOVE(&sol.s_values[12], tvec); - - for (i = 3; i <= 9; i += 3) { - j = i + 12; - VADD2(&sol.s_values[j], &sol.s_values[i], tvec); - } -} - - -/* ==== I T O A () - * convert integer to ascii wd format - */ -static void -itoa(int n, - char s[], - int w) { - int c, i, j, sign; - - if ((sign = n) < 0) n = -n; - i = 0; - do s[i++] = n % 10 + '0'; while ((n /= 10) > 0); - if (sign < 0) s[i++] = '-'; - - /* blank fill array - */ - for (j = i; j < w; j++) s[j] = ' '; - if (i > w) - bu_log("itoa: field length too small\n"); - s[w] = '\0'; - /* reverse the array - */ - for (i = 0, j = w - 1; i < j; i++, j--) { - c = s[i]; - s[i] = s[j]; - s[j] = c; - } -} - - -static void -crname(char name[], - int pos, - int maxlen) -{ - char temp[4]; - - itoa(pos, temp, 1); - bu_strlcat(name, temp, maxlen); - - return; -} - - -/* - * M K _ T R E E _ G I F T - * - * Add some nodes to a new or existing combination's tree, - * with GIFT precedence and semantics. - * - * NON-PARALLEL due to rt_uniresource - * - * Returns - - * -1 ERROR - * 0 OK - */ -static int -track_mk_tree_gift(struct rt_comb_internal *comb, struct bu_list *member_hd) -{ - struct wmember *wp; - union tree *tp; - struct rt_tree_array *tree_list; - size_t node_count; - size_t actual_count; - int new_nodes; - - if ((new_nodes = bu_list_len(member_hd)) <= 0) - return 0; /* OK, nothing to do */ - - if (comb->tree && db_ck_v4gift_tree(comb->tree) < 0) { - db_non_union_push(comb->tree, &rt_uniresource); - if (db_ck_v4gift_tree(comb->tree) < 0) { - bu_log("track_mk_tree_gift() Cannot flatten tree for editing\n"); - return -1; - } - } - - /* make space for an extra leaf */ - node_count = db_tree_nleaves(comb->tree); - tree_list = (struct rt_tree_array *)bu_calloc(node_count + (size_t)new_nodes, - sizeof(struct rt_tree_array), "tree list"); - - /* flatten tree */ - if (comb->tree) { - /* Release storage for non-leaf nodes, steal leaves */ - actual_count = (struct rt_tree_array *)db_flatten_tree(tree_list, comb->tree, OP_UNION, 1, &rt_uniresource) - tree_list; - BU_ASSERT_SIZE_T(actual_count, ==, node_count); - comb->tree = TREE_NULL; - } else { - actual_count = 0; - } - - /* Add new members to the array */ - for (BU_LIST_FOR(wp, wmember, member_hd)) { - WDB_CK_WMEMBER(wp); - - switch (wp->wm_op) { - case WMOP_INTERSECT: - tree_list[node_count].tl_op = OP_INTERSECT; - break; - case WMOP_SUBTRACT: - tree_list[node_count].tl_op = OP_SUBTRACT; - break; - default: - bu_log("track_mk_tree_gift() unrecognized relation %c (assuming UNION)\n", wp->wm_op); - /* Fall through */ - case WMOP_UNION: - tree_list[node_count].tl_op = OP_UNION; - break; - } - - /* make new leaf node, and insert at end of array */ - BU_ALLOC(tp, union tree); - RT_TREE_INIT(tp); - tree_list[node_count++].tl_tree = tp; - tp->tr_l.tl_op = OP_DB_LEAF; - tp->tr_l.tl_name = bu_strdup(wp->wm_name); - if (!bn_mat_is_identity(wp->wm_mat)) { - tp->tr_l.tl_mat = bn_mat_dup(wp->wm_mat); - } else { - tp->tr_l.tl_mat = (matp_t)NULL; - } - } - BU_ASSERT_SIZE_T(node_count, ==, actual_count + (size_t)new_nodes); - - /* rebuild the tree with GIFT semantics */ - comb->tree = (union tree *)db_mkgift_tree(tree_list, node_count, &rt_uniresource); - - bu_free((char *)tree_list, "track_mk_tree_gift: tree_list"); - - return 0; /* OK */ -} - - -/* - * M K _ F R E E M E M B E R S - */ -static void -track_mk_freemembers(struct bu_list *headp) -{ - struct wmember *wp; - - while (BU_LIST_WHILE(wp, wmember, headp)) { - WDB_CK_WMEMBER(wp); - BU_LIST_DEQUEUE(&wp->l); - bu_free((char *)wp->wm_name, "wm_name"); - bu_free((char *)wp, "wmember"); - } -} - - -/* - * M K _ T R E E _ P U R E - * - * Given a list of wmember structures, build a tree that performs - * the boolean operations in the given sequence. - * No GIFT semantics or precedence is provided. - * For that, use mk_tree_gift(). - */ -static void -track_mk_tree_pure(struct rt_comb_internal *comb, struct bu_list *member_hd) -{ - struct wmember *wp; - - for (BU_LIST_FOR(wp, wmember, member_hd)) { - union tree *leafp, *nodep; - - WDB_CK_WMEMBER(wp); - - BU_ALLOC(leafp, union tree); - RT_TREE_INIT(leafp); - leafp->tr_l.tl_op = OP_DB_LEAF; - leafp->tr_l.tl_name = bu_strdup(wp->wm_name); - if (!bn_mat_is_identity(wp->wm_mat)) { - leafp->tr_l.tl_mat = bn_mat_dup(wp->wm_mat); - } - - if (!comb->tree) { - comb->tree = leafp; - continue; - } - /* Build a left-heavy tree */ - BU_ALLOC(nodep, union tree); - RT_TREE_INIT(nodep); - switch (wp->wm_op) { - case WMOP_UNION: - nodep->tr_b.tb_op = OP_UNION; - break; - case WMOP_INTERSECT: - nodep->tr_b.tb_op = OP_INTERSECT; - break; - case WMOP_SUBTRACT: - nodep->tr_b.tb_op = OP_SUBTRACT; - break; - default: - bu_bomb("track_mk_tree_pure() bad wm_op"); - } - nodep->tr_b.tb_left = comb->tree; - nodep->tr_b.tb_right = leafp; - comb->tree = nodep; - } -} - - -/* - * M K _ C O M B - * - * Make a combination, where the - * members are described by a linked list of wmember structs. - * - * The linked list is freed when it has been output. - * - * Has many operating modes. - * - * Returns - - * -1 ERROR - * 0 OK - */ -static int -track_mk_comb( - struct rt_wdb *wdbp, - const char *combname, - struct bu_list *headp, /* Made by mk_addmember() */ - int region_kind, /* 1 => region. 'P' and 'V' for FASTGEN */ - const char *shadername, /* shader name, or NULL */ - const char *shaderargs, /* shader args, or NULL */ - const unsigned char *rgb, /* NULL => no color */ - int id, /* region_id */ - int air, /* aircode */ - int material, /* GIFTmater */ - int los, - int inherit, - int append_ok, /* 0 = obj must not exit */ - int gift_semantics) /* 0 = pure, 1 = gift */ -{ - struct rt_db_internal intern; - struct rt_comb_internal *comb; - int fresh_combination; - - RT_CK_WDB(wdbp); - - RT_DB_INTERNAL_INIT(&intern); - - if (append_ok && - wdb_import(wdbp, &intern, combname, (matp_t)NULL) >= 0) { - /* We retrieved an existing object, append to it */ - comb = (struct rt_comb_internal *)intern.idb_ptr; - RT_CK_COMB(comb); - - fresh_combination = 0; - } else { - /* Create a fresh new object for export */ - BU_ALLOC(comb, struct rt_comb_internal); - RT_COMB_INTERNAL_INIT(comb); - - intern.idb_major_type = DB5_MAJORTYPE_BRLCAD; - intern.idb_type = ID_COMBINATION; - intern.idb_ptr = (genptr_t)comb; - intern.idb_meth = &OBJ[ID_COMBINATION]; - - fresh_combination = 1; - } - - if (gift_semantics) - track_mk_tree_gift(comb, headp); - else - track_mk_tree_pure(comb, headp); - - /* Release the wmember list dynamic storage */ - track_mk_freemembers(headp); - - /* Don't change these things when appending to existing combination */ - if (fresh_combination) { - if (region_kind) { - comb->region_flag = 1; - switch (region_kind) { - case 'P': - comb->is_fastgen = REGION_FASTGEN_PLATE; - break; - case 'V': - comb->is_fastgen = REGION_FASTGEN_VOLUME; - break; - case 'R': - case 1: - /* Regular non-FASTGEN Region */ - break; - default: - bu_log("mk_comb(%s) unknown region_kind=%d (%c), assuming normal non-FASTGEN\n", - combname, region_kind, region_kind); - } - } - if (shadername) bu_vls_strcat(&comb->shader, shadername); - if (shaderargs) { - bu_vls_strcat(&comb->shader, " "); - bu_vls_strcat(&comb->shader, shaderargs); - /* Convert to Tcl form if necessary. Use heuristics */ - if (strchr(shaderargs, '=') != NULL && strchr(shaderargs, '{') == NULL) { - struct bu_vls old = BU_VLS_INIT_ZERO; - bu_vls_vlscatzap(&old, &comb->shader); - if (bu_shader_to_list(bu_vls_addr(&old), &comb->shader)) - bu_log("Unable to convert shader string '%s %s'\n", shadername, shaderargs); - bu_vls_free(&old); - } - } - - if (rgb) { - comb->rgb_valid = 1; - comb->rgb[0] = rgb[0]; - comb->rgb[1] = rgb[1]; - comb->rgb[2] = rgb[2]; - } - - comb->region_id = id; - comb->aircode = air; - comb->GIFTmater = material; - comb->los = los; - - comb->inherit = inherit; - } - - /* The internal representation will be freed */ - return wdb_put_internal(wdbp, combname, &intern, 1.0); -} - - -/* - * M K _ A D D M E M B E R - * - * Obtain dynamic storage for a new wmember structure, fill in the - * name, default the operation and matrix, and add to doubly linked - * list. In typical use, a one-line call is sufficient. To change - * the defaults, catch the pointer that is returned, and adjust the - * structure to taste. - * - * The caller is responsible for initializing the header structures - * forward and backward links. - */ -static struct wmember * -track_mk_addmember( - const char *name, - struct bu_list *headp, - mat_t mat, - int op) -{ - struct wmember *wp; - - BU_ALLOC(wp, struct wmember); - wp->l.magic = WMEMBER_MAGIC; - wp->wm_name = bu_strdup(name); - switch (op) { - case WMOP_UNION: - case WMOP_INTERSECT: - case WMOP_SUBTRACT: - wp->wm_op = op; - break; - default: - bu_log("mk_addmember() op=x%x is bad\n", op); - return WMEMBER_NULL; - } - - /* if the user gave a matrix, use it. otherwise use identity matrix*/ - if (mat) { - MAT_COPY(wp->wm_mat, mat); - } else { - MAT_IDN(wp->wm_mat); - } - - /* Append to end of doubly linked list */ - BU_LIST_INSERT(headp, &wp->l); - return wp; -} - - -static void -crregion(struct rt_wdb *wdbp, - char region[], - char op[], - int members[], - int number, - char solidname[], - int maxlen) -{ - int i; - struct bu_list head; - - if (wdbp->dbip == DBI_NULL) - return; - - BU_LIST_INIT(&head); - - for (i = 0; i < number; i++) { - solidname[grpname_len + extraTypeChars] = '\0'; - crname(solidname, members[i], maxlen); - if (db_lookup(wdbp->dbip, solidname, LOOKUP_QUIET) == RT_DIR_NULL) { - bu_log("region: %s will skip member: %s\n", region, solidname); - continue; - } - track_mk_addmember(solidname, &head, NULL, op[i]); - } - (void)track_mk_comb(wdbp, region, &head, - 1, NULL, NULL, NULL, - 500+Trackpos+i, 0, mat_default, los_default, - 0, 1, 1); -} - - -/* - * - * Adds track given "wheel" info - * - */ int wdb_track_cmd(void *data, int argc, const char *argv[]) { + struct bu_vls log_str = BU_VLS_INIT_ZERO; struct rt_wdb *wdbp = (struct rt_wdb *)data; - fastf_t fw[3], lw[3], iw[3], dw[3], tr[3]; - char *solname = NULL; - char *regname = NULL; - char *grpname = NULL; - char oper[3]; - int i, memb[4]; - vect_t temp1, temp2; - int item, mat, los; - int arg; - int edit_result = TCL_OK; - struct bu_list head; - int len; + int retval; - BU_LIST_INIT(&head); - if (argc != 15) { bu_log("ERROR: expecting 15 arguments\n"); return TCL_ERROR; } - oper[0] = oper[2] = WMOP_INTERSECT; - oper[1] = WMOP_SUBTRACT; + retval = _ged_track(&log_str, wdbp, argv); - /* base name */ - arg = 1; - grpname = bu_strdup(argv[arg]); - grpname_len = (int)strlen(grpname); - len = grpname_len + 1 + extraChars; - solname = bu_malloc(len, "solid name"); - regname = bu_malloc(len, "region name"); - sol.s_name = bu_malloc(len, "sol.s_name"); - - /* first road wheel X */ - ++arg; - fw[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - /* last road wheel X */ - ++arg; - lw[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - if (fw[0] <= lw[0]) { - bu_log("First wheel after last wheel - STOP\n"); - edit_result = TCL_ERROR; - goto end; + if (bu_vls_strlen(&log_str) > 0) { + bu_log("%s", bu_vls_addr(&log_str)); } - /* road wheel Z */ - ++arg; - fw[1] = lw[1] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - /* roadwheel radius */ - ++arg; - fw[2] = lw[2] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - if (fw[2] <= 0) { - bu_log("Radius <= 0 - STOP\n"); - edit_result = TCL_ERROR; - goto end; + switch(retval) { + case GED_OK: + return TCL_OK; + case GED_ERROR: + return TCL_ERROR; } - /* drive sprocket X */ - ++arg; - dw[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - if (dw[0] >= lw[0]) { - bu_log("DRIVE wheel not in the rear - STOP \n"); - edit_result = TCL_ERROR; - goto end; - } - - /* drive sprocket Z */ - ++arg; - dw[1] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - /* drive sprocket radius */ - ++arg; - dw[2] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - if (dw[2] <= 0) { - bu_log("Radius <= 0 - STOP\n"); - edit_result = TCL_ERROR; - goto end; - } - - /* idler wheel X */ - ++arg; - iw[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - if (iw[0] <= fw[0]) { - bu_log("IDLER wheel not in the front - STOP \n"); - edit_result = TCL_ERROR; - goto end; - } - - /* idler wheel Z */ - ++arg; - iw[1] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - /* idler wheel radius */ - ++arg; - iw[2] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - if (iw[2] <= 0) { - bu_log("Radius <= 0 - STOP\n"); - edit_result = TCL_ERROR; - goto end; - } - - /* track MIN Y */ - ++arg; - tr[2] = tr[0] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - /* track MAX Y */ - ++arg; - tr[1] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - if (EQUAL(tr[0], tr[1])) { - bu_log("MIN == MAX ... STOP\n"); - edit_result = TCL_ERROR; - goto end; - } - if (tr[0] > tr[1]) { - bu_log("MIN > MAX .... will switch\n"); - tr[1] = tr[0]; - tr[0] = tr[2]; - } - - /* track thickness */ - ++arg; - tr[2] = atof(argv[arg]) * wdbp->dbip->dbi_local2base; - - if (tr[2] <= 0) { - bu_log("Track thickness <= 0 - STOP\n"); - edit_result = TCL_ERROR; - goto end; - } - - for (i = 0; i < grpname_len; ++i) { - solname[i] = grpname[i]; - regname[i] = grpname[i]; - } - - solname[i] = regname[i] = '.'; - ++i; - solname[i] = 's'; - regname[i] = 'r'; - ++i; - solname[i] = regname[i] = '.'; - ++i; - solname[i] = regname[i] = '\0'; -/* - bu_log("\nX of first road wheel %10.4f\n", fw[0]); - bu_log("X of last road wheel %10.4f\n", lw[0]); - bu_log("Z of road wheels %10.4f\n", fw[1]); - bu_log("radius of road wheels %10.4f\n", fw[2]); - bu_log("\nX of drive wheel %10.4f\n", dw[0]); - bu_log("Z of drive wheel %10.4f\n", dw[1]); - bu_log("radius of drive wheel %10.4f\n", dw[2]); - bu_log("\nX of idler wheel %10.4f\n", iw[0]); - bu_log("Z of idler wheel %10.4f\n", iw[1]); - bu_log("radius of idler wheel %10.4f\n", iw[2]); - bu_log("\nY MIN of track %10.4f\n", tr[0]); - bu_log("Y MAX of track %10.4f\n", tr[1]); - bu_log("thickness of track %10.4f\n", tr[2]); -*/ - -/* Check for names to use: - * grpname.s.0->9 and grpname.r.0->9 - */ - - for (i = 0; i < 10; i++) { - crname(solname, i, len); - crname(regname, i, len); - if ((db_lookup(wdbp->dbip, solname, LOOKUP_QUIET) != RT_DIR_NULL) || - (db_lookup(wdbp->dbip, regname, LOOKUP_QUIET) != RT_DIR_NULL)) { - /* name already exists */ - bu_log("Track: naming error -- STOP\n"); - edit_result = TCL_ERROR; - goto end; - } - - solname[grpname_len + extraTypeChars] = '\0'; - regname[grpname_len + extraTypeChars] = '\0'; - } - - /* find the front track slope to the idler */ - for (i = 0; i < 24; i++) - sol.s_values[i] = 0.0; - - /* add the solids */ - /* solid 0 */ - slope(fw, iw, tr); - VMOVE(temp2, &sol.s_values[0]); - crname(solname, 0, len); - bu_strlcpy(sol.s_name, solname, len); - - sol.s_type = ID_ARB8; - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - - solname[grpname_len + extraTypeChars] = '\0'; - - /* solid 1 */ - /* find track around idler */ - for (i = 0; i < 24; i++) - sol.s_values[i] = 0.0; - sol.s_type = ID_TGC; - trcurve(iw, tr); - crname(solname, 1, len); - bu_strlcpy(sol.s_name, solname, len); - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - solname[grpname_len + extraTypeChars] = '\0'; - /* idler dummy rcc */ - sol.s_values[6] = iw[2]; - sol.s_values[11] = iw[2]; - VMOVE(&sol.s_values[12], &sol.s_values[6]); - VMOVE(&sol.s_values[15], &sol.s_values[9]); - /* solid 2 */ - crname(solname, 2, len); - bu_strlcpy(sol.s_name, solname, len); - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - solname[grpname_len + extraTypeChars] = '\0'; - - /* solid 3 */ - /* find idler track dummy arb8 */ - for (i = 0; i < 24; i++) - sol.s_values[i] = 0.0; - crname(solname, 3, len); - bu_strlcpy(sol.s_name, solname, len); - sol.s_type = ID_ARB8; - crdummy(iw, tr, 1); - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - solname[grpname_len + extraTypeChars] = '\0'; - - /* solid 4 */ - /* track slope to drive */ - for (i = 0; i < 24; i++) - sol.s_values[i] = 0.0; - slope(lw, dw, tr); - VMOVE(temp1, &sol.s_values[0]); - crname(solname, 4, len); - bu_strlcpy(sol.s_name, solname, len); - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - solname[grpname_len + extraTypeChars] = '\0'; - - /* solid 5 */ - /* track around drive */ - for (i = 0; i < 24; i++) - sol.s_values[i] = 0.0; - sol.s_type = ID_TGC; - trcurve(dw, tr); - crname(solname, 5, len); - bu_strlcpy(sol.s_name, solname, len); - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - solname[grpname_len + extraTypeChars] = '\0'; - - /* solid 6 */ - /* drive dummy rcc */ - sol.s_values[6] = dw[2]; - sol.s_values[11] = dw[2]; - VMOVE(&sol.s_values[12], &sol.s_values[6]); - VMOVE(&sol.s_values[15], &sol.s_values[9]); - crname(solname, 6, len); - bu_strlcpy(sol.s_name, solname, len); - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - solname[grpname_len + extraTypeChars] = '\0'; - - /* solid 7 */ - /* drive dummy arb8 */ - for (i = 0; i < 24; i++) - sol.s_values[i] = 0.0; - crname(solname, 7, len); - bu_strlcpy(sol.s_name, solname, len); - sol.s_type = ID_ARB8; - crdummy(dw, tr, 2); - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - solname[grpname_len + extraTypeChars] = '\0'; - - /* solid 8 */ - /* track bottom */ - temp1[1] = temp2[1] = tr[0]; - bottom(temp1, temp2, tr); - crname(solname, 8, len); - bu_strlcpy(sol.s_name, solname, len); - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - solname[grpname_len + extraTypeChars] = '\0'; - - /* solid 9 */ - /* track top */ - temp1[0] = dw[0]; - temp1[1] = temp2[1] = tr[0]; - temp1[2] = dw[1] + dw[2]; - temp2[0] = iw[0]; - temp2[2] = iw[1] + iw[2]; - top(temp1, temp2, tr); - crname(solname, 9, len); - bu_strlcpy(sol.s_name, solname, len); - if (wrobj(wdbp, solname, RT_DIR_SOLID)) - return TCL_ERROR; - solname[grpname_len + extraTypeChars] = '\0'; - - /* add the regions */ - /* region 0 */ - item = item_default; - mat = mat_default; - los = los_default; - item_default = 500; - mat_default = 1; - los_default = 50; - /* region 1 */ - memb[0] = 0; - memb[1] = 3; - crname(regname, 0, len); - crregion(wdbp, regname, oper, memb, 2, solname, len); - solname[grpname_len + extraTypeChars] = '\0'; - regname[grpname_len + extraTypeChars] = '\0'; - - /* region 1 */ - crname(regname, 1, len); - memb[0] = 1; - memb[1] = 2; - memb[2] = 3; - crregion(wdbp, regname, oper, memb, 3, solname, len); - solname[grpname_len + extraTypeChars] = '\0'; - regname[grpname_len + extraTypeChars] = '\0'; - - /* region 4 */ - crname(regname, 4, len); - memb[0] = 4; - memb[1] = 7; - crregion(wdbp, regname, oper, memb, 2, solname, len); - solname[grpname_len + extraTypeChars] = '\0'; - regname[grpname_len + extraTypeChars] = '\0'; - - /* region 5 */ - crname(regname, 5, len); - memb[0] = 5; - memb[1] = 6; - memb[2] = 7; - crregion(wdbp, regname, oper, memb, 3, solname, len); - solname[grpname_len + extraTypeChars] = '\0'; - regname[grpname_len + extraTypeChars] = '\0'; - - /* region 8 */ - crname(regname, 8, len); - memb[0] = 8; - memb[1] = 0; - memb[2] = 4; - oper[2] = WMOP_SUBTRACT; - crregion(wdbp, regname, oper, memb, 3, solname, len); - solname[grpname_len + extraTypeChars] = '\0'; - regname[grpname_len + extraTypeChars] = '\0'; - - /* region 9 */ - crname(regname, 9, len); - memb[0] = 9; - memb[1] = 3; - memb[2] = 7; - crregion(wdbp, regname, oper, memb, 3, solname, len); - solname[grpname_len + extraTypeChars] = '\0'; - regname[grpname_len + extraTypeChars] = '\0'; - - /* group all the track regions */ - for (i = 0; i < 10; i++) { - if (i == 2 || i == 3 || i == 6 || i == 7) - continue; - regname[grpname_len + extraTypeChars] = '\0'; - crname(regname, i, len); - if (db_lookup(wdbp->dbip, regname, LOOKUP_QUIET) == RT_DIR_NULL) { - bu_log("group: %s will skip member: %s\n", grpname, regname); - continue; - } - track_mk_addmember(regname, &head, NULL, WMOP_UNION); - } - - /* Add them all at once */ - if (track_mk_comb(wdbp, grpname, &head, - 0, NULL, NULL, NULL, - 0, 0, 0, 0, - 0, 1, 1) < 0) { - bu_log("An error has occurred while adding '%s' to the database.\n", grpname); - } - - Trackpos += 10; - item_default = item; - mat_default = mat; - los_default = los; - - bu_free((genptr_t)solname, "solid name"); - bu_free((genptr_t)regname, "region name"); - bu_free((genptr_t)grpname, "group name"); - bu_free((genptr_t)sol.s_name, "sol.s_name"); - - return edit_result; - -end: - bu_free((genptr_t)solname, "solid name"); - bu_free((genptr_t)regname, "region name"); - bu_free((genptr_t)grpname, "group name"); - bu_free((genptr_t)sol.s_name, "sol.s_name"); - - return edit_result; + /* This should never happen */ + return TCL_ERROR; } - /* * Local Variables: * mode: C This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pet...@us...> - 2014-01-02 07:06:58
|
Revision: 59251 http://sourceforge.net/p/brlcad/code/59251 Author: peter-sa Date: 2014-01-02 07:06:54 +0000 (Thu, 02 Jan 2014) Log Message: ----------- Remove duplicate code in src/libged/wdb_bigE.c and src/libged/bigE.c, from GCI task http://www.google-melange.com/gci/task/view/google/gci2013/4967846266273792 Modified Paths: -------------- brlcad/trunk/src/libged/CMakeLists.txt brlcad/trunk/src/libged/dg_obj.c Removed Paths: ------------- brlcad/trunk/src/libged/wdb_bigE.c Modified: brlcad/trunk/src/libged/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libged/CMakeLists.txt 2014-01-02 06:45:47 UTC (rev 59250) +++ brlcad/trunk/src/libged/CMakeLists.txt 2014-01-02 07:06:54 UTC (rev 59251) @@ -287,7 +287,6 @@ vrot.c vutil.c wcodes.c - wdb_bigE.c wdb_comb_std.c wdb_importFg4Section.c wdb_nirt.c Modified: brlcad/trunk/src/libged/dg_obj.c =================================================================== --- brlcad/trunk/src/libged/dg_obj.c 2014-01-02 06:45:47 UTC (rev 59250) +++ brlcad/trunk/src/libged/dg_obj.c 2014-01-02 07:06:54 UTC (rev 59251) @@ -714,8 +714,22 @@ const char **argv) { struct dg_obj *dgop = (struct dg_obj *)clientData; + struct ged ged; + int ret; - return dgo_E_cmd(dgop, argc-1, argv+1); + GED_INIT(&ged, dgop->dgo_wdbp); + + ret = ged_E(&ged, argc-1, argv+1); + + ged_free(&ged); + + if (ret == GED_OK) { + return TCL_OK; + } else { + return TCL_ERROR; + } + + return TCL_OK; } Deleted: brlcad/trunk/src/libged/wdb_bigE.c =================================================================== --- brlcad/trunk/src/libged/wdb_bigE.c 2014-01-02 06:45:47 UTC (rev 59250) +++ brlcad/trunk/src/libged/wdb_bigE.c 2014-01-02 07:06:54 UTC (rev 59251) @@ -1,2176 +0,0 @@ -/* B I G E . C - * BRL-CAD - * - * Copyright (c) 1997-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. - */ -/** @addtogroup libged */ -/** @{ */ -/** @file libged/bigE.c - * - * This module implements the 'E' command. - * - */ -/** @} */ - -#include "common.h" - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <time.h> -#include "bio.h" - -#include "bu.h" -#include "vmath.h" -#include "nmg.h" -#include "rtgeom.h" -#include "solid.h" -#include "dg.h" -#include "ged.h" - -/* #define debug 1 */ - - -struct dg_client_data { - struct dg_obj *dgop; - Tcl_Interp *interp; - int wireframe_color_override; - int wireframe_color[3]; - struct application *ap; - struct bu_ptbl leaf_list; - struct rt_i *rtip; - time_t start_time; - time_t etime; - long nvectors; - int do_polysolids; - int num_halfs; -}; - - -extern void dgo_drawH_part2(int, struct bu_list *, const struct db_full_path *, struct db_tree_state *, struct solid *, struct dg_client_data *); -union E_tree *wdb_build_etree(union tree *tp, struct dg_client_data *dgcdp); - -/* segment types (stored in the "seg_stp" field of the (struct seg) */ -#define ON_SURF (struct soltab *)0x1 -#define IN_SOL (struct soltab *)0x2 -#define ON_INT (struct soltab *)0x3 - -#define NOT_SEG_OVERLAP(_a, _b) ((_a->seg_out.hit_dist <= _b->seg_in.hit_dist) || (_b->seg_out.hit_dist <= _a->seg_in.hit_dist)) - -/* RT_FREE_SEG_LIST assumed list head is a "struct seg" */ -#define MY_FREE_SEG_LIST(_segheadp, _res) { \ - struct seg *_a; \ - while (BU_LIST_WHILE(_a, seg, (_segheadp))) { \ - BU_LIST_DEQUEUE(&(_a->l)); \ - RT_FREE_SEG(_a, _res); \ - } } - -/* stolen from g_half.c */ -struct half_specific { - plane_t half_eqn; /* Plane equation, outward normal */ - vect_t half_Xbase; /* "X" basis direction */ - vect_t half_Ybase; /* "Y" basis direction */ -}; -#define HALF_NULL ((struct half_specific *)0) - -/* structures for building a tree corresponding to the region to be drawn - * uses the same "op" values as "union tree" - */ -union E_tree -{ - uint32_t magic; - - struct E_node { - /* the operator nodes */ - uint32_t magic; - int op; - union E_tree *left; - union E_tree *right; - } n; - - struct E_leaf { - /* the leaf nodes */ - uint32_t magic; - int op; - struct model *m; /* NMG version of this leaf solid */ - struct bu_list seghead; /* head of list of segments for this leaf solid */ - struct bu_ptbl edge_list; /* list of edges from above NMG */ - struct soltab *stp; /* the usual soltab pointer */ - unsigned char do_not_free_model; /* A flag indicating that the NMG model pointer is a reference to the - * NMG model in the soltab structure */ - } l; -}; - - -#define E_TREE_MAGIC 0x45545245 -#define CK_ETREE(_p) BU_CKMAG(_p, E_TREE_MAGIC, "struct E_tree") - -HIDDEN union E_tree * -wdb_add_solid(const struct directory *dp, - matp_t mat, - struct dg_client_data *dgcdp) -{ - union E_tree *eptr; - struct nmgregion *r; - struct rt_db_internal intern; - int id; - int solid_is_plate_mode_bot=0; - - BU_ALLOC(eptr, union E_tree); - eptr->magic = E_TREE_MAGIC; - - id = rt_db_get_internal(&intern, dp, dgcdp->dgop->dgo_wdbp->dbip, mat, &rt_uniresource); - if (id < 0) { - Tcl_AppendResult(dgcdp->interp, "Failed to get internal form of ", - dp->d_namep, "\n", (char *)NULL); - eptr->l.m = (struct model *)NULL; - return eptr; - } - if (id == ID_COMBINATION) { - /* do explicit expansion of referenced combinations */ - - struct rt_comb_internal *comb; - - bu_free((char *)eptr, "eptr"); - - comb = (struct rt_comb_internal *)intern.idb_ptr; - RT_CK_COMB(comb); - - eptr = wdb_build_etree(comb->tree, dgcdp); - rt_db_free_internal(&intern); - return eptr; - } - if (id == ID_HALF) { - eptr->l.m = NULL; - dgcdp->num_halfs++; - } else if (id == ID_NMG) { - /* steal the nmg model */ - eptr->l.m = (struct model *)intern.idb_ptr; - eptr->l.do_not_free_model = 1; - } else { - /* create the NMG version of this solid */ - eptr->l.m = nmg_mm(); - if (!OBJ[id].ft_tessellate && OBJ[id].ft_tessellate(&r, eptr->l.m, &intern, - &dgcdp->dgop->dgo_wdbp->wdb_ttol, &dgcdp->dgop->dgo_wdbp->wdb_tol) < 0) { - nmg_km(eptr->l.m); - eptr->l.m = NULL; - } - } - - /* get the soltab stuff */ - BU_ALLOC(eptr->l.stp, struct soltab); - eptr->l.stp->l.magic = RT_SOLTAB_MAGIC; - eptr->l.stp->l2.magic = RT_SOLTAB2_MAGIC; - eptr->l.stp->st_dp = dp; - eptr->l.stp->st_matp = mat; - - { - struct rt_bot_internal *bot; - struct rt_db_internal intern2; - - if (dgcdp->do_polysolids) { - struct shell *s=(struct shell *)NULL; - - /* create and prep a BoT version of this solid */ - if (eptr->l.m) { - r = BU_LIST_FIRST(nmgregion, &eptr->l.m->r_hd); - s = BU_LIST_FIRST(shell, &r->s_hd); - } - - if (solid_is_plate_mode_bot - || !eptr->l.m - || (bot=nmg_bot(s, &dgcdp->dgop->dgo_wdbp->wdb_tol)) == (struct rt_bot_internal *)NULL) - { - eptr->l.stp->st_id = id; - eptr->l.stp->st_meth = &OBJ[id]; - if (!OBJ[id].ft_prep || OBJ[id].ft_prep(eptr->l.stp, &intern, dgcdp->rtip) < 0) - Tcl_AppendResult(dgcdp->interp, "Prep failure for solid '", dp->d_namep, - "'\n", (char *)NULL); - } else { - RT_DB_INTERNAL_INIT(&intern2); - intern2.idb_major_type = DB5_MAJORTYPE_BRLCAD; - intern2.idb_type = ID_BOT; - intern2.idb_meth = &OBJ[ID_BOT]; - intern2.idb_ptr = (genptr_t)bot; - eptr->l.stp->st_id = ID_BOT; - eptr->l.stp->st_meth = &OBJ[ID_BOT]; - if (!OBJ[ID_BOT].ft_prep || OBJ[ID_BOT].ft_prep(eptr->l.stp, &intern2, dgcdp->rtip) < 0) { - Tcl_AppendResult(dgcdp->interp, "Prep failure for solid '", dp->d_namep, - "'\n", (char *)NULL); - } - - rt_db_free_internal(&intern2); - } - } else { - /* prep this solid */ - - eptr->l.stp->st_id = id; - eptr->l.stp->st_meth = &OBJ[id]; - if (!OBJ[id].ft_prep || OBJ[id].ft_prep(eptr->l.stp, &intern, dgcdp->rtip) < 0) - Tcl_AppendResult(dgcdp->interp, "Prep failure for solid '", dp->d_namep, - "'\n", (char *)NULL); - } - } - - if (id != ID_NMG) - rt_db_free_internal(&intern); - - /* add this leaf to the leaf list */ - bu_ptbl_ins(&dgcdp->leaf_list, (long *)eptr); - - return eptr; -} - - -/* build an E_tree corresponding to the region tree (tp) */ -union E_tree * -wdb_build_etree(union tree *tp, - struct dg_client_data *dgcdp) -{ - union E_tree *eptr = NULL; - struct soltab *stp; - struct directory *dp; - - RT_CK_TREE(tp); - - switch (tp->tr_op) { - case OP_UNION: - case OP_SUBTRACT: - case OP_INTERSECT: - BU_ALLOC(eptr, union E_tree); - eptr->magic = E_TREE_MAGIC; - eptr->n.op = tp->tr_op; - eptr->n.left = wdb_build_etree(tp->tr_b.tb_left, dgcdp); - eptr->n.right = wdb_build_etree(tp->tr_b.tb_right, dgcdp); - break; - case OP_SOLID: - stp = tp->tr_a.tu_stp; - eptr = wdb_add_solid(stp->st_dp, stp->st_matp, dgcdp); - eptr->l.op = tp->tr_op; - BU_LIST_INIT(&eptr->l.seghead); - break; - case OP_DB_LEAF: - if ((dp=db_lookup(dgcdp->dgop->dgo_wdbp->dbip, tp->tr_l.tl_name, LOOKUP_NOISY)) == RT_DIR_NULL) { - break; - } - eptr = wdb_add_solid(dp, tp->tr_l.tl_mat, dgcdp); - eptr->l.op = tp->tr_op; - BU_LIST_INIT(&eptr->l.seghead); - break; - case OP_NOP: - /* add a NULL solid */ - BU_ALLOC(eptr, union E_tree); - eptr->magic = E_TREE_MAGIC; - eptr->l.m = (struct model *)NULL; - break; - default: - bu_bomb("wdb_build_etree() Unknown tr_op\n"); - } - return eptr; -} - - -/* a handy routine (for debugging) that prints asegment list */ -void -wdb_show_seg(struct bu_list *seg, char *str) -{ - struct seg *ptr; - - if (!seg) - bu_log("%s - NULL seg list\n", str); - else { - if (BU_LIST_IS_EMPTY(seg)) - bu_log("%s - empty\n", str); - else { - bu_log("%s:\n", str); - for (BU_LIST_FOR(ptr, seg, seg)) { - if (ptr->seg_stp == ON_SURF) - bu_log("\t %g to %g (ON_SURF)\n", ptr->seg_in.hit_dist, ptr->seg_out.hit_dist); - else if (ptr->seg_stp == ON_INT) - bu_log("\t %g to %g (ON_INT)\n", ptr->seg_in.hit_dist, ptr->seg_out.hit_dist); - else if (ptr->seg_stp == IN_SOL) - bu_log("\t %g to %g (IN)\n", ptr->seg_in.hit_dist, ptr->seg_out.hit_dist); - else - bu_log("\t %g to %g (?)\n", ptr->seg_in.hit_dist, ptr->seg_out.hit_dist); - bu_log("\t\t(%g %g %g) <-> (%g %g %g)\n", V3ARGS(ptr->seg_in.hit_point), - V3ARGS(ptr->seg_out.hit_point)); - } - } - } -} - - -/* given a segment list, eliminate any overlaps in the segments */ -HIDDEN void -wdb_eliminate_overlaps(struct bu_list *seghead, - struct dg_client_data *dgcdp) -{ - struct seg *a, *b, *nextb; - - a = BU_LIST_FIRST(seg, seghead); - while (BU_LIST_NOT_HEAD(&a->l, seghead)) { - b = BU_LIST_PNEXT(seg, &a->l); - if (BU_LIST_IS_HEAD(&b->l, seghead)) - break; - - while (BU_LIST_NOT_HEAD(&b->l, seghead)) { - nextb = BU_LIST_PNEXT(seg, &b->l); - if (NOT_SEG_OVERLAP(a, b)) - break; - - if (b->seg_in.hit_dist < a->seg_out.hit_dist) { - if (b->seg_out.hit_dist > a->seg_out.hit_dist) - a->seg_out.hit_dist = b->seg_out.hit_dist; - - BU_LIST_DEQUEUE(&b->l); - RT_FREE_SEG(b, dgcdp->ap->a_resource); - b = nextb; - continue; - } - - b = nextb; - } - - a = BU_LIST_PNEXT(seg, &a->l); - } -} - - -/* perform the intersection of two segments - * the result is assigned the provided type - */ -HIDDEN void -wdb_do_intersect(struct seg *A, - struct seg *B, - struct bu_list *seghead, - struct soltab *type, - struct dg_client_data *dgcdp) -{ - struct seg *tmp=(struct seg *)NULL; - - if (NOT_SEG_OVERLAP(A, B)) - return; - - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - if (A->seg_in.hit_dist <= B->seg_in.hit_dist) { - if (B->seg_out.hit_dist <= A->seg_out.hit_dist) { - *tmp = *B; - tmp->seg_stp = type; - } else { - tmp->seg_in.hit_dist = B->seg_in.hit_dist; - tmp->seg_out.hit_dist = A->seg_out.hit_dist; - tmp->seg_stp = type; - } - } else { - if (B->seg_out.hit_dist >= A->seg_out.hit_dist) { - *tmp = *A; - tmp->seg_stp = type; - } else { - tmp->seg_in.hit_dist = A->seg_in.hit_dist; - tmp->seg_out.hit_dist = B->seg_out.hit_dist; - tmp->seg_stp = type; - } - } - if (tmp) - BU_LIST_INSERT(seghead, &tmp->l); - return; -} - - -/* perform the subtraction of one segment from another - * the result is assigned the type from segment A - */ -HIDDEN void -wdb_do_subtract(struct seg *A, - struct seg *B, - struct bu_list *seghead, - struct dg_client_data *dgcdp) -{ - struct seg *tmp=(struct seg *)NULL; - - - if (NOT_SEG_OVERLAP(A, B)) { - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - *tmp = *A; - BU_LIST_INSERT(seghead, &tmp->l); - return; - } - - if (B->seg_in.hit_dist<= A->seg_in.hit_dist) { - if (B->seg_out.hit_dist < A->seg_out.hit_dist) { - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - *tmp = *A; - tmp->seg_in.hit_dist = B->seg_out.hit_dist; - BU_LIST_INSERT(seghead, &tmp->l); - return; - } else - return; - } else { - if (B->seg_out.hit_dist >= A->seg_out.hit_dist) { - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - *tmp = *A; - tmp->seg_out.hit_dist = B->seg_in.hit_dist; - BU_LIST_INSERT(seghead, &tmp->l); - return; - } else { - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - tmp->seg_in.hit_dist = A->seg_in.hit_dist; - tmp->seg_out.hit_dist = B->seg_in.hit_dist; - tmp->seg_stp = A->seg_stp; - BU_LIST_INSERT(seghead, &tmp->l); - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - tmp->seg_in.hit_dist = B->seg_out.hit_dist; - tmp->seg_out.hit_dist = A->seg_out.hit_dist; - tmp->seg_stp = A->seg_stp; - BU_LIST_INSERT(seghead, &tmp->l); - return; - } - } -} - - -HIDDEN void -wdb_promote_ints(struct bu_list *head, - struct dg_client_data *dgcdp) -{ - struct seg *a, *b, *tmp; - -#ifdef debug - bu_log("In wdb_promote_ints():\n"); - wdb_show_seg(head, "SEGS"); - for (BU_LIST_FOR(a, seg, head)) { - b = BU_LIST_PNEXT(seg, &a->l); - if (BU_LIST_IS_HEAD(&b->l, head)) - break; - - if (b->seg_in.hit_dist < a->seg_in.hit_dist) - bu_log("\tsegments out of order:\n"); - } -#endif - - a = BU_LIST_FIRST(seg, head); - while (BU_LIST_NOT_HEAD(&a->l, head)) { - b = BU_LIST_PNEXT(seg, &a->l); - while (BU_LIST_NOT_HEAD(&b->l, head)) { - if (a->seg_stp == ON_INT && b->seg_stp == ON_SURF) { - if (NOT_SEG_OVERLAP(a, b)) { - b = BU_LIST_PNEXT(seg, &b->l); - continue; - } - - if (EQUAL(a->seg_in.hit_dist, b->seg_in.hit_dist) - && EQUAL(a->seg_out.hit_dist, b->seg_out.hit_dist)) - { - a->seg_stp = ON_SURF; - tmp = b; - b = BU_LIST_PNEXT(seg, &b->l); - BU_LIST_DEQUEUE(&tmp->l); - RT_FREE_SEG(tmp, dgcdp->ap->a_resource); - continue; - } - - if (EQUAL(a->seg_out.hit_dist, b->seg_out.hit_dist)) - a->seg_out.hit_dist = b->seg_in.hit_dist; - else if (a->seg_out.hit_dist < b->seg_out.hit_dist) { - if (b->seg_in.hit_dist > a->seg_in.hit_dist) - a->seg_out.hit_dist = b->seg_in.hit_dist; - else { - tmp = a; - a = BU_LIST_PLAST(seg, &a->l); - BU_LIST_DEQUEUE(&tmp->l); - RT_FREE_SEG(tmp, dgcdp->ap->a_resource); - break; - } - } else if (EQUAL(a->seg_in.hit_dist, b->seg_in.hit_dist)) { - fastf_t tmp_dist; - - tmp_dist = a->seg_out.hit_dist; - a->seg_out.hit_dist = b->seg_out.hit_dist; - b->seg_in.hit_dist = a->seg_out.hit_dist; - b->seg_out.hit_dist = tmp_dist; - a->seg_stp = ON_SURF; - b->seg_stp = ON_INT; - } else { - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - *tmp = *a; - tmp->seg_in.hit_dist = b->seg_out.hit_dist; - a->seg_out.hit_dist = b->seg_in.hit_dist; - BU_LIST_APPEND(&b->l, &tmp->l); - } - } else if (b->seg_stp == ON_INT && a->seg_stp == ON_SURF) { - if (NOT_SEG_OVERLAP(b, a)) { - b = BU_LIST_PNEXT(seg, &b->l); - continue; - } - - if (EQUAL(b->seg_in.hit_dist, a->seg_in.hit_dist) - && EQUAL(b->seg_out.hit_dist, a->seg_out.hit_dist)) - { - b->seg_stp = ON_SURF; - tmp = a; - a = BU_LIST_PLAST(seg, &a->l); - BU_LIST_DEQUEUE(&tmp->l); - RT_FREE_SEG(tmp, dgcdp->ap->a_resource); - break; - } - - if (EQUAL(b->seg_out.hit_dist, a->seg_out.hit_dist)) { - tmp = b; - b = BU_LIST_PNEXT(seg, &b->l); - BU_LIST_DEQUEUE(&tmp->l); - RT_FREE_SEG(tmp, dgcdp->ap->a_resource); - } else if (b->seg_out.hit_dist < a->seg_out.hit_dist) { - if (a->seg_in.hit_dist > b->seg_in.hit_dist) - b->seg_out.hit_dist = a->seg_in.hit_dist; - else { - tmp = b; - b = BU_LIST_PNEXT(seg, &b->l); - BU_LIST_DEQUEUE(&tmp->l); - RT_FREE_SEG(tmp, dgcdp->ap->a_resource); - continue; - } - } else if (EQUAL(b->seg_in.hit_dist, a->seg_in.hit_dist)) - b->seg_in.hit_dist = a->seg_out.hit_dist; - else { - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - *tmp = *b; - tmp->seg_in.hit_dist = a->seg_out.hit_dist; - b->seg_out.hit_dist = a->seg_in.hit_dist; - BU_LIST_APPEND(&a->l, &tmp->l); - } - } - - if ((a->seg_stp != ON_INT) || (b->seg_stp != ON_INT)) { - b = BU_LIST_PNEXT(seg, &b->l); - continue; - } - - if (NOT_SEG_OVERLAP(a, b)) { - b = BU_LIST_PNEXT(seg, &b->l); - continue; - } - -#ifdef debug - bu_log("\tfound overlapping ON_INT segs:\n"); -#endif - - if (EQUAL(a->seg_in.hit_dist, b->seg_in.hit_dist) - && EQUAL(a->seg_out.hit_dist, b->seg_out.hit_dist)) - { -#ifdef debug - bu_log("Promoting A, eliminating B\n"); -#endif - - a->seg_stp = ON_SURF; - BU_LIST_DEQUEUE(&b->l); - RT_FREE_SEG(b, dgcdp->ap->a_resource); - break; - } - - if (EQUAL(a->seg_out.hit_dist, b->seg_out.hit_dist)) { - b->seg_stp = ON_SURF; - a->seg_out.hit_dist = b->seg_in.hit_dist; - -#ifdef debug - bu_log("Promoting B, reducing A:\n"); -#endif - } else if (a->seg_out.hit_dist < b->seg_out.hit_dist) { - if (b->seg_in.hit_dist > a->seg_in.hit_dist) { - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - tmp->seg_stp = ON_SURF; - tmp->seg_in.hit_dist = b->seg_in.hit_dist; - tmp->seg_out.hit_dist = a->seg_out.hit_dist; - b->seg_in.hit_dist = a->seg_out.hit_dist; - a->seg_out.hit_dist = tmp->seg_in.hit_dist; - BU_LIST_INSERT(&b->l, &tmp->l); - -#ifdef debug - bu_log("--==__ overlap\n"); -#endif - } else { - b->seg_in.hit_dist = a->seg_out.hit_dist; - a->seg_stp = ON_SURF; - -#ifdef debug - bu_log("A within B\n"); -#endif - } - } else { - if (EQUAL(a->seg_in.hit_dist, b->seg_in.hit_dist)) { - fastf_t tmp_dist; - - tmp_dist = a->seg_out.hit_dist; - a->seg_out.hit_dist = b->seg_out.hit_dist; - a->seg_stp = ON_SURF; - b->seg_in.hit_dist = a->seg_out.hit_dist; - b->seg_out.hit_dist = tmp_dist; - } else { - RT_GET_SEG(tmp, dgcdp->ap->a_resource) - *tmp = *a; - tmp->seg_in.hit_dist = b->seg_out.hit_dist; - a->seg_out.hit_dist = b->seg_in.hit_dist; - b->seg_stp = ON_SURF; - BU_LIST_APPEND(&b->l, &tmp->l) - -#ifdef debug - bu_log("B within A:\n"); -#endif - } - } - b = BU_LIST_PNEXT(seg, &b->l); - } - a = BU_LIST_PNEXT(seg, &a->l); - } - -#ifdef debug - bu_log("Results of wdb_promote_ints()\n"); - wdb_show_seg(head, "SEGS"); -#endif -} - - -/* Evaluate an operation on the operands (segment lists) */ -HIDDEN struct bu_list * -wdb_eval_op(struct bu_list *A, - int op, - struct bu_list *B, - struct dg_client_data *dgcdp) -{ - struct seg *sega, *segb, *tmp, *next; - struct bu_list ret, ons, ins; - int inserted; - - BU_LIST_INIT(&ret); - -#ifdef debug - bu_log("In wdb_eval_op:\n"); - wdb_show_seg(A, "\tA:"); - wdb_show_seg(B, "\tB:"); -#endif - - switch (op) { - case OP_SUBTRACT: - -#ifdef debug - bu_log("\t\tSUBTACT\n"); -#endif - - if (BU_LIST_IS_EMPTY(A)) { - MY_FREE_SEG_LIST(B, dgcdp->ap->a_resource); - bu_free((char *)B, "bu_list"); - -#ifdef debug - wdb_show_seg(A, "Returning"); -#endif - - return A; - } else if (BU_LIST_IS_EMPTY(B)) { - bu_free((char *)B, "bu_list"); - -#ifdef debug - wdb_show_seg(A, "Returning"); -#endif - - return A; - } - - /* A - B: - * keep segments: - * ON_A - IN_B - * ON_A - ON_B - * ON_B + IN_A - * IN_A - IN_B - */ - for (BU_LIST_FOR(sega, seg, A)) { - for (BU_LIST_FOR(segb, seg, B)) { - if (sega->seg_stp == ON_INT && segb->seg_stp == ON_INT) - wdb_do_intersect(sega, segb, &ret, ON_SURF, dgcdp); - else if (sega->seg_stp == ON_SURF || sega->seg_stp == ON_INT) { - wdb_do_subtract(sega, segb, &ret, dgcdp); - } else if (segb->seg_stp == ON_SURF || segb->seg_stp == ON_INT) - wdb_do_intersect(segb, sega, &ret, segb->seg_stp, dgcdp); - } - } - MY_FREE_SEG_LIST(B, dgcdp->ap->a_resource); - bu_free((char *)B, "bu_list"); - MY_FREE_SEG_LIST(A, dgcdp->ap->a_resource); - BU_LIST_INSERT_LIST(A, &ret) - -#ifdef debug - wdb_show_seg(A, "Returning"); -#endif - - return A; - case OP_INTERSECT: - -#ifdef debug - bu_log("\t\tINTERSECT\n"); -#endif - - if (BU_LIST_IS_EMPTY(A) || BU_LIST_IS_EMPTY(B)) { - MY_FREE_SEG_LIST(A, dgcdp->ap->a_resource); - MY_FREE_SEG_LIST(B, dgcdp->ap->a_resource); - bu_free((char *)B, "bu_list"); - -#ifdef debug - wdb_show_seg(A, "Returning"); -#endif - - return A; - } - /* A + B - * This is merely the intersection of segments from A with those from B - * The two different calls to "wdb_do_intersect" get the types (IN, ON) right - */ - for (BU_LIST_FOR(sega, seg, A)) { - for (BU_LIST_FOR(segb, seg, B)) { - if (sega->seg_stp == ON_INT && segb->seg_stp == ON_INT) - wdb_do_intersect(sega, segb, &ret, ON_SURF, dgcdp); - else if (sega->seg_stp == ON_SURF || sega->seg_stp == ON_INT) - wdb_do_intersect(sega, segb, &ret, sega->seg_stp, dgcdp); - else - wdb_do_intersect(segb, sega, &ret, segb->seg_stp, dgcdp); - } - } - MY_FREE_SEG_LIST(B, dgcdp->ap->a_resource); - bu_free((char *)B, "bu_list"); - MY_FREE_SEG_LIST(A, dgcdp->ap->a_resource); - BU_LIST_INSERT_LIST(A, &ret) - -#ifdef debug - wdb_show_seg(A, "Returning"); -#endif - - return A; - case OP_UNION: - -#ifdef debug - bu_log("\t\tUNION\n"); -#endif - - if (BU_LIST_IS_EMPTY(A)) { - bu_free((char *)A, "bu_list"); - -#ifdef debug - wdb_show_seg(B, "Returning B (A is empty)"); -#endif - - return B; - } - if (BU_LIST_IS_EMPTY(B)) { - bu_free((char *)B, "bu_list"); - -#ifdef debug - wdb_show_seg(A, "Returning A (B is empty)"); -#endif - - return A; - } - /* A u B: - * keep segments: - * ON_A - IN_B (ON) - * IN_B + ON_A (IN) - * ON_B - IN_A (ON) - * IN_A + ON_B (IN) - * all remaining unique ON or IN segments - */ - - /* create two new lists, one with all the ON segments, - * the other with all the IN segments - */ - BU_LIST_INIT(&ons); - BU_LIST_INIT(&ins); - - /* Put the A operand segments on the lists */ - while (BU_LIST_WHILE(sega, seg, A)) { - BU_LIST_DEQUEUE(&sega->l); - - if (sega->seg_stp == ON_SURF || sega->seg_stp == ON_INT) { - BU_LIST_INSERT(&ons, &sega->l); - } else { - BU_LIST_INSERT(&ins, &sega->l); - } - } - - /* insert the B operand segments in the lists (maintaining order from smaller starting - * hit distance to larger - */ - while (BU_LIST_WHILE(segb, seg, B)) { - BU_LIST_DEQUEUE(&segb->l); - - if (segb->seg_stp == IN_SOL) { - inserted = 0; - for (BU_LIST_FOR(tmp, seg, &ins)) { - if (tmp->seg_in.hit_dist >= segb->seg_in.hit_dist) { - inserted = 1; - BU_LIST_INSERT(&tmp->l, &segb->l); - break; - } - } - if (!inserted) { - BU_LIST_INSERT(&ins, &segb->l); - } - } else { - inserted = 0; - for (BU_LIST_FOR(tmp, seg, &ons)) { - if (tmp->seg_in.hit_dist >= segb->seg_in.hit_dist) { - inserted = 1; - BU_LIST_INSERT(&tmp->l, &segb->l); - break; - } - } - if (!inserted) { - BU_LIST_INSERT(&ons, &segb->l); - } - } - } - - /* promote intersecting ON_INT's to ON_SURF */ - wdb_promote_ints(&ons, dgcdp); - - /* make sure the segments are unique */ - wdb_eliminate_overlaps(&ins, dgcdp); - wdb_eliminate_overlaps(&ons, dgcdp); - -#ifdef debug - wdb_show_seg(&ons, "ONS"); - wdb_show_seg(&ins, "INS"); -#endif - - /* subtract INS from ONS */ -#ifdef debug - bu_log("doing subtraction:\n"); -#endif - sega = BU_LIST_FIRST(seg, &ons); - while (BU_LIST_NOT_HEAD(&sega->l, &ons)) { - next = BU_LIST_PNEXT(seg, &sega->l); - -#ifdef debug - bu_log("A is %g to %g:\n", sega->seg_in.hit_dist, sega->seg_out.hit_dist); -#endif - - for (BU_LIST_FOR(segb, seg, &ins)) { -#ifdef debug - bu_log("\tcomparing to B %g to %g\n", segb->seg_in.hit_dist, segb->seg_out.hit_dist); -#endif - - if (NOT_SEG_OVERLAP(sega, segb)) { -#ifdef debug - bu_log("\t\tNo overlap!!\n"); -#endif - - continue; - } - - if (segb->seg_in.hit_dist <= sega->seg_in.hit_dist - && segb->seg_out.hit_dist >= sega->seg_out.hit_dist) - { -#ifdef debug - bu_log("\t\teliminating A\n"); -#endif - - /* eliminate sega */ - BU_LIST_DEQUEUE(&sega->l) - RT_FREE_SEG(sega, dgcdp->ap->a_resource) - sega = next; - break; - } - - if (segb->seg_in.hit_dist > sega->seg_in.hit_dist - && segb->seg_out.hit_dist < sega->seg_out.hit_dist) - { - /* split sega */ - RT_GET_SEG(tmp, dgcdp->ap->a_resource); - *tmp = *sega; - tmp->seg_in.hit_dist = segb->seg_out.hit_dist; - sega->seg_out.hit_dist = segb->seg_in.hit_dist; - BU_LIST_APPEND(&sega->l, &tmp->l); - next = tmp; - -#ifdef debug - bu_log("\t\tsplit A into: %g to %g and %g to %g\n", sega->seg_in.hit_dist, sega->seg_out.hit_dist, tmp->seg_in.hit_dist, tmp->seg_out.hit_dist); -#endif - } else { - /* subtract edges */ - if (segb->seg_in.hit_dist > sega->seg_in.hit_dist) - sega->seg_out.hit_dist = segb->seg_in.hit_dist; - if (segb->seg_out.hit_dist < sega->seg_out.hit_dist) - sega->seg_in.hit_dist = segb->seg_out.hit_dist; - -#ifdef debug - bu_log("\t\tsubtracted A down to %g to %g\n", sega->seg_in.hit_dist, sega->seg_out.hit_dist); -#endif - } - } - sega = next; - } - - /* put the resulting ONS list on the result list */ - BU_LIST_INSERT_LIST(&ret, &ons); - - /* add INS to the return list (maintain order) */ - while (BU_LIST_WHILE(sega, seg, &ins)) { - BU_LIST_DEQUEUE(&sega->l); - - inserted = 0; - for (BU_LIST_FOR(segb, seg, &ret)) { - if (sega->seg_in.hit_dist < segb->seg_in.hit_dist) { - BU_LIST_INSERT(&segb->l, &sega->l); - inserted = 1; - break; - } - } - - if (!inserted) { - BU_LIST_INSERT(&ret, &sega->l); - } - } - - MY_FREE_SEG_LIST(B, dgcdp->ap->a_resource); - bu_free((char *)B, "bu_list"); - MY_FREE_SEG_LIST(A, dgcdp->ap->a_resource); - BU_LIST_INSERT_LIST(A, &ret); - -#ifdef debug - wdb_show_seg(A, "Returning"); -#endif - - return A; - } - - /* should never get here */ - MY_FREE_SEG_LIST(A, dgcdp->ap->a_resource); - MY_FREE_SEG_LIST(B, dgcdp->ap->a_resource); - bu_free((char *)B, "bu_list"); - -#ifdef debug - wdb_show_seg(A, "Returning (default)"); -#endif - - return A; - -} - - -/* evaluate an E-tree */ -HIDDEN struct bu_list * -wdb_eval_etree(union E_tree *eptr, - struct dg_client_data *dgcdp) - -{ - struct bu_list *A, *B; - - CK_ETREE(eptr); - -#ifdef debug - bu_log("In wdb_eval_etree:\n"); -#endif - - switch (eptr->l.op) { - case OP_DB_LEAF: - case OP_SOLID: - BU_ALLOC(A, struct bu_list); - BU_LIST_INIT(A); - BU_LIST_INSERT_LIST(A, &eptr->l.seghead); - -#ifdef debug - wdb_show_seg(A, "LEAF:"); -#endif - - return A; - case OP_SUBTRACT: - case OP_INTERSECT: - case OP_UNION: -#ifdef debug - bu_log("Evaluating subtrees\n"); -#endif - - A = wdb_eval_etree(eptr->n.left, dgcdp); - B = wdb_eval_etree(eptr->n.right, dgcdp); - return wdb_eval_op(A, eptr->n.op, B, dgcdp); - } - - /* should never get here */ - return (struct bu_list *)NULL; /* for the compilers */ -} - - -HIDDEN void -wdb_inverse_dir(vect_t dir, vect_t inv_dir) -{ - /* Compute the inverse of the direction cosines */ - if (!ZERO(dir[X])) { - inv_dir[X]=1.0/dir[X]; - } else { - inv_dir[X] = INFINITY; - dir[X] = 0.0; - } - if (!ZERO(dir[Y])) { - inv_dir[Y]=1.0/dir[Y]; - } else { - inv_dir[Y] = INFINITY; - dir[Y] = 0.0; - } - if (!ZERO(dir[Z])) { - inv_dir[Z]=1.0/dir[Z]; - } else { - inv_dir[Z] = INFINITY; - dir[Z] = 0.0; - } -} - - -HIDDEN struct soltab * -wdb_classify_seg(struct seg *seg, struct soltab *shoot, struct xray *rp, struct dg_client_data *dgcdp) -{ - fastf_t mid_dist; - struct xray new_rp; - struct ray_data rd; - struct soltab *ret = IN_SOL; - - memset(&rd, 0, sizeof(struct ray_data)); - - BU_ALLOC(rd.seghead, struct seg); - BU_LIST_INIT(&rd.seghead->l); - - mid_dist = (seg->seg_in.hit_dist + seg->seg_out.hit_dist) / 2.0; - VJOIN1(new_rp.r_pt, rp->r_pt, mid_dist, rp->r_dir); -#ifdef debug - bu_log("Classifying segment with mid_pt (%g %g %g) with respect to %s\n", V3ARGS(new_rp.r_pt), shoot->st_dp->d_namep); -#endif - - bn_vec_ortho(new_rp.r_dir, rp->r_dir); - wdb_inverse_dir(new_rp.r_dir, rd.rd_invdir); - - /* set up "ray_data" structure for nmg raytrace */ - rd.rp = &new_rp; - rd.tol = &dgcdp->dgop->dgo_wdbp->wdb_tol; - rd.ap = dgcdp->ap; - rd.magic = NMG_RAY_DATA_MAGIC; - rd.classifying_ray = 0; - rd.hitmiss = (struct hitmiss **)NULL; - rd.stp = shoot; - - if (OBJ[shoot->st_id].ft_shot && OBJ[shoot->st_id].ft_shot(shoot, &new_rp, dgcdp->ap, rd.seghead)) { - struct seg *segp; - - while (BU_LIST_WHILE(segp, seg, &rd.seghead->l)) { - BU_LIST_DEQUEUE(&segp->l); -#ifdef debug - bu_log("dist = %g and %g\n", segp->seg_in.hit_dist, - segp->seg_out.hit_dist); -#endif - if (ret != ON_SURF) { - if (NEAR_ZERO(segp->seg_in.hit_dist, rd.tol->dist)) { - ret = ON_SURF; - } - if (NEAR_ZERO(segp->seg_out.hit_dist, rd.tol->dist)) { - ret = ON_SURF; - } - } - RT_FREE_SEG(segp, dgcdp->ap->a_resource); - } - } - - if (ret != ON_SURF) { - vect_t new_dir; - - VCROSS(new_dir, new_rp.r_dir, rp->r_dir); - VMOVE(new_rp.r_dir, new_dir); - wdb_inverse_dir(new_rp.r_dir, rd.rd_invdir); - if (OBJ[shoot->st_id].ft_shot && OBJ[shoot->st_id].ft_shot(shoot, &new_rp, dgcdp->ap, rd.seghead)) { - struct seg *segp; - - while (BU_LIST_WHILE(segp, seg, &rd.seghead->l)) { - BU_LIST_DEQUEUE(&segp->l); -#ifdef debug - bu_log("dist = %g and %g\n", segp->seg_in.hit_dist, - segp->seg_out.hit_dist); -#endif - if (ret != ON_SURF) { - if (NEAR_ZERO(segp->seg_in.hit_dist, rd.tol->dist)) { - ret = ON_SURF; - } - if (NEAR_ZERO(segp->seg_out.hit_dist, rd.tol->dist)) { - ret = ON_SURF; - } - } - RT_FREE_SEG(segp, dgcdp->ap->a_resource); - } - } - } -#ifdef debug - bu_log("\t x%x\n", ret); -#endif - return ret; -} - - -/* Shoot rays (corresponding to possible edges in the result) - * at the solids, put the results in the E-tree leaves as type IN_SOL. - * Call wdb_eval_etree() and plot the results - */ -HIDDEN void -wdb_shoot_and_plot(point_t start_pt, - vect_t dir, - struct bu_list *vhead, - fastf_t edge_len, - int skip_leaf1, - int skip_leaf2, - union E_tree *eptr, - struct soltab *type, - struct dg_client_data *dgcdp) -{ - struct xray rp; - struct ray_data rd; - int shoot_leaf; - struct bu_list *final_segs; - - if (bu_debug&BU_DEBUG_MEM_CHECK && bu_mem_barriercheck()) - bu_log("Error at start of wdb_shoot_and_plot()\n"); - - CK_ETREE(eptr); - - memset(&rd, 0, sizeof(struct ray_data)); - - BU_ALLOC(rd.seghead, struct seg); - BU_LIST_INIT(&rd.seghead->l); - - VMOVE(rp.r_pt, start_pt); - VMOVE(rp.r_dir, dir); - /* Compute the inverse of the direction cosines */ - if (!ZERO(rp.r_dir[X])) { - rd.rd_invdir[X]=1.0/rp.r_dir[X]; - } else { - rd.rd_invdir[X] = INFINITY; - rp.r_dir[X] = 0.0; - } - if (!ZERO(rp.r_dir[Y])) { - rd.rd_invdir[Y]=1.0/rp.r_dir[Y]; - } else { - rd.rd_invdir[Y] = INFINITY; - rp.r_dir[Y] = 0.0; - } - if (!ZERO(rp.r_dir[Z])) { - rd.rd_invdir[Z]=1.0/rp.r_dir[Z]; - } else { - rd.rd_invdir[Z] = INFINITY; - rp.r_dir[Z] = 0.0; - } - - /* set up "ray_data" structure for nmg raytrace */ - rd.rp = &rp; - rd.tol = &dgcdp->dgop->dgo_wdbp->wdb_tol; - rd.ap = dgcdp->ap; - rd.magic = NMG_RAY_DATA_MAGIC; - rd.classifying_ray = 0; - rd.hitmiss = (struct hitmiss **)NULL; - - /* shoot this ray at every leaf solid except the one this edge came from - * (or the two that this intersection line came from - */ - for (shoot_leaf=0; shoot_leaf < BU_PTBL_END(&dgcdp->leaf_list); shoot_leaf++) { - union E_tree *shoot; - int dont_shoot=0; - - shoot = (union E_tree *)BU_PTBL_GET(&dgcdp->leaf_list, shoot_leaf); - - if (BU_LIST_NON_EMPTY(&shoot->l.seghead)) { - MY_FREE_SEG_LIST(&shoot->l.seghead, dgcdp->ap->a_resource); - } - BU_LIST_INIT(&shoot->l.seghead); - - /* don't shoot rays at the leaves that were the source of this possible edge */ - if (shoot_leaf == skip_leaf1 || shoot_leaf == skip_leaf2) - dont_shoot = 1; - else { - /* don't shoot at duplicate solids either */ - union E_tree *leaf; - - if (skip_leaf1 >= 0) { - leaf = (union E_tree *)BU_PTBL_GET(&dgcdp->leaf_list, skip_leaf1); - if (leaf->l.stp->st_dp == shoot->l.stp->st_dp) { - if (!leaf->l.stp->st_matp && !shoot->l.stp->st_matp) - dont_shoot = 1; - else if (!leaf->l.stp->st_matp && - bn_mat_is_equal(shoot->l.stp->st_matp, - bn_mat_identity, - &dgcdp->dgop->dgo_wdbp->wdb_tol)) - dont_shoot = 1; - else if (!shoot->l.stp->st_matp && - bn_mat_is_equal(leaf->l.stp->st_matp, - bn_mat_identity, - &dgcdp->dgop->dgo_wdbp->wdb_tol)) - dont_shoot = 1; - else if (leaf->l.stp->st_matp && - shoot->l.stp->st_matp && - bn_mat_is_equal(leaf->l.stp->st_matp, - shoot->l.stp->st_matp, - &dgcdp->dgop->dgo_wdbp->wdb_tol)) - dont_shoot = 1; - } - } - if (!dont_shoot && skip_leaf2 >= 0) { - leaf = (union E_tree *)BU_PTBL_GET(&dgcdp->leaf_list, skip_leaf2); - if (leaf->l.stp->st_dp == shoot->l.stp->st_dp) { - if (!leaf->l.stp->st_matp && !shoot->l.stp->st_matp) - dont_shoot = 1; - else if (!leaf->l.stp->st_matp && - bn_mat_is_equal(shoot->l.stp->st_matp, - bn_mat_identity, - &dgcdp->dgop->dgo_wdbp->wdb_tol)) - dont_shoot = 1; - else if (!shoot->l.stp->st_matp && - bn_mat_is_equal(leaf->l.stp->st_matp, - bn_mat_identity, - &dgcdp->dgop->dgo_wdbp->wdb_tol)) - dont_shoot = 1; - else if (leaf->l.stp->st_matp && - shoot->l.stp->st_matp && - bn_mat_is_equal(leaf->l.stp->st_matp, - shoot->l.stp->st_matp, - &dgcdp->dgop->dgo_wdbp->wdb_tol)) - dont_shoot = 1; - } - } - } - - if (dont_shoot) { - struct seg *seg; - - /* put entire edge in seg list and mark it as ON the surface */ - RT_GET_SEG(seg, dgcdp->ap->a_resource); - seg->l.magic = RT_SEG_MAGIC; - seg->seg_in.hit_dist = 0.0; - seg->seg_out.hit_dist = edge_len; - seg->seg_stp = type; - BU_LIST_INSERT(&shoot->l.seghead, &seg->l); - continue; - } - - /* initialize the lists of things that have been hit/missed */ - rd.rd_m = shoot->l.m; - BU_LIST_INIT(&rd.rd_hit); - BU_LIST_INIT(&rd.rd_miss); - - rd.stp = shoot->l.stp; - - /* actually shoot the ray, assign segments to the leaf, and mark them as IN_SOL */ - if (rt_in_rpp(&rp, rd.rd_invdir, shoot->l.stp->st_min, shoot->l.stp->st_max)) { - if (OBJ[shoot->l.stp->st_id].ft_shot && OBJ[shoot->l.stp->st_id].ft_shot(shoot->l.stp, &rp, dgcdp->ap, rd.seghead)) { - struct seg *seg; - - /* put the segments in the lead solid structure */ - while (BU_LIST_WHILE(seg, seg, &rd.seghead->l)) { - BU_LIST_DEQUEUE(&seg->l); - /* clip segments to the edge being considered */ - if (seg->seg_in.hit_dist >= edge_len || seg->seg_out.hit_dist <= 0) { - RT_FREE_SEG(seg, dgcdp->ap->a_resource); - } else { - if (seg->seg_in.hit_dist < 0.0) - seg->seg_in.hit_dist = 0.0; - if (seg->seg_out.hit_dist > edge_len) - seg->seg_out.hit_dist = edge_len; - seg->seg_stp = wdb_classify_seg(seg, shoot->l.stp, &rp, dgcdp); - BU_LIST_INSERT(&shoot->l.seghead, &seg->l); - } - } - } - } - } - - /* Evaluate the Boolean tree to get the "final" segments - * which are to be plotted. - */ -#ifdef debug - bu_log("EVALUATING ETREE:\n"); - bu_log("ray start (%g %g %g), dir=(%g %g %g)\n", V3ARGS(start_pt), V3ARGS(dir)); -#endif - - final_segs = wdb_eval_etree(eptr, dgcdp); - -#ifdef debug - wdb_show_seg(final_segs, "DRAWING"); -#endif - - if (final_segs) { - struct seg *seg; - - /* add the segments to the VLIST */ - for (BU_LIST_FOR(seg, seg, final_segs)) { - point_t pt; - - /* only plot the resulting segments that are ON the SURFace */ - if (seg->seg_stp != ON_SURF) - continue; - - dgcdp->nvectors++; - VJOIN1(pt, rp.r_pt, seg->seg_in.hit_dist, rp.r_dir); - -#ifdef debug - bu_log("\t\tDRAW (%g %g %g)", V3ARGS(pt)); -#endif - - RT_ADD_VLIST(vhead, pt, BN_VLIST_LINE_MOVE); - VJOIN1(pt, rp.r_pt, seg->seg_out.hit_dist, rp.r_dir); - -#ifdef debug - bu_log("<->(%g %g %g)\n", V3ARGS(pt)); -#endif - - RT_ADD_VLIST(vhead, pt, BN_VLIST_LINE_DRAW); - } - - } - - if (final_segs) - MY_FREE_SEG_LIST(final_segs, dgcdp->ap->a_resource); - bu_free((char *)final_segs, "bu_list"); - - if (bu_debug&BU_DEBUG_MEM_CHECK && bu_mem_barriercheck()) - bu_log("Error at end of wdb_shoot_and_plot()\n"); - -} - - -#define HITS_BLOCK 20 - -HIDDEN void -wdb_Eplot(union E_tree *eptr, - struct bu_list *vhead, - struct dg_client_data *dgcdp) -{ - point_t start_pt; - int leaf_no; - union E_tree *leaf_ptr; - int hit_count1=0, hit_count2=0; - point_t *hits1=NULL, *hits2=NULL; - int hits_avail1=0, hits_avail2=0; - int i; - struct bu_list *result; - struct bn_tol *tol; - - tol = &dgcdp->dgop->dgo_wdbp->wdb_tol; - - CK_ETREE(eptr); - - /* create an edge list for each leaf solid */ - for (leaf_no=0; leaf_no < BU_PTBL_END(&dgcdp->leaf_list); leaf_no++) { - leaf_ptr = (union E_tree *)BU_PTBL_GET(&dgcdp->leaf_list, leaf_no); - CK_ETREE(leaf_ptr); - if (leaf_ptr->l.op != OP_DB_LEAF && leaf_ptr->l.op != OP_SOLID) { - Tcl_AppendResult(dgcdp->interp, "wdb_Eplot: Bad leaf node!!!\n", (char *)NULL); - return; - } - - if (leaf_ptr->l.m) - nmg_edge_tabulate(&leaf_ptr->l.edge_list, &leaf_ptr->l.m->magic); - else - bu_ptbl_init(&leaf_ptr->l.edge_list, 1, "edge_list"); - } - - /* now plot appropriate parts of each solid */ - - /* loop through every leaf solid */ - for (leaf_no=0; leaf_no < BU_PTBL_END(&dgcdp->leaf_list); leaf_no++) { - int edge_no; - - leaf_ptr = (union E_tree *)BU_PTBL_GET(&dgcdp->leaf_list, leaf_no); - - if (!leaf_ptr->l.m) - continue; - - /* do each edge of the current leaf solid */ - for (edge_no=0; edge_no < BU_PTBL_END(&leaf_ptr->l.edge_list); edge_no++) { - struct edge *e; - struct vertex_g *vg; - struct vertex_g *vg2; - vect_t dir; - fastf_t edge_len; - fastf_t inv_len; - - e = (struct edge *)BU_PTBL_GET(&leaf_ptr->l.edge_list, edge_no); - NMG_CK_EDGE(e); - vg = e->eu_p->vu_p->v_p->vg_p; - NMG_CK_VERTEX_G(vg); - - vg2 = e->eu_p->eumate_p->vu_p->v_p->vg_p; - NMG_CK_VERTEX_G(vg2); - - /* set up a ray from vg towards vg2 */ - VSUB2(dir, vg2->coord, vg->coord); - edge_len = MAGNITUDE(dir); - if (edge_len < tol->dist) - continue; - inv_len = 1.0/edge_len; - VSCALE(dir, dir, inv_len); - wdb_shoot_and_plot(vg->coord, dir, vhead, edge_len, leaf_no, -1, eptr, ON_SURF, dgcdp); - - } - } - - hits1 = (point_t *)bu_calloc(HITS_BLOCK, sizeof(point_t), "hits"); - hits_avail1 = HITS_BLOCK; - hits2 = (point_t *)bu_calloc(HITS_BLOCK, sizeof(point_t), "hits"); - hits_avail2 = HITS_BLOCK; - - /* Now draw solid intersection lines */ - for (leaf_no=0; leaf_no < BU_PTBL_END(&dgcdp->leaf_list); leaf_no++) { - int leaf2; - - leaf_ptr = (union E_tree *)BU_PTBL_GET(&dgcdp->leaf_list, leaf_no); - if (!leaf_ptr->l.m) - continue; - - for (leaf2=leaf_no+1; leaf2 < BU_PTBL_END(&dgcdp->leaf_list); leaf2++) { - union E_tree *leaf2_ptr; - struct nmgregion *r1, *r2; - struct shell *s1, *s2; - struct faceuse *fu1, *fu2; - struct face *f1, *f2; - plane_t pl1, pl2; - struct loopuse *lu1, *lu2; - struct edgeuse *eu1, *eu2; - struct vertex_g *vg1a, *vg1b, *vg2a, *vg2b; - struct bu_list *A, *B; - - leaf2_ptr = (union E_tree *)BU_PTBL_GET(&dgcdp->leaf_list, leaf2); - if (!leaf2_ptr->l.m) - continue; - - /* find intersection lines between these two NMG's */ - - r1 = BU_LIST_FIRST(nmgregion, &leaf_ptr->l.m->r_hd); - s1 = BU_LIST_FIRST(shell, &r1->s_hd); - r2 = BU_LIST_FIRST(nmgregion, &leaf2_ptr->l.m->r_hd); - s2 = BU_LIST_FIRST(shell, &r2->s_hd); - - for (BU_LIST_FOR(fu1, faceuse, &s1->fu_hd)) { - if (fu1->orientation != OT_SAME) - continue; - - f1 = fu1->f_p; - NMG_GET_FU_PLANE(pl1, fu1); - - for (BU_LIST_FOR(fu2, faceuse, &s2->fu_hd)) { - fastf_t dist; - vect_t dir; - vect_t diff; - fastf_t *dists1, *dists2; - fastf_t min_dist, max_dist; - int min_hit, max_hit; - int done; - struct seg *aseg; - - if (fu2->orientation != OT_SAME) - continue; - - f2 = fu2->f_p; - - if (!V3RPP_OVERLAP_TOL(f2->min_pt, f2->max_pt, f1->min_pt, f1->max_pt, tol->dist)) - continue; - - NMG_GET_FU_PLANE(pl2, fu2); - - if (bn_coplanar(pl1, pl2, tol)) { - continue; - } - - hit_count1=0; - hit_count2=0; - for (BU_LIST_FOR(lu1, loopuse, &fu1->lu_hd)) { - if (BU_LIST_FIRST_MAGIC(&lu1->down_hd) != NMG_EDGEUSE_MAGIC) - continue; - - for (BU_LIST_FOR(eu1, edgeuse, &lu1->down_hd)) { - vg1a = eu1->vu_p->v_p->vg_p; - vg1b = eu1->eumate_p->vu_p->v_p->vg_p; - VSUB2(dir, vg1b->coord, vg1a->coord); - - /* find intersection of this edge with fu2 */ - - if (bn_isect_line3_plane(&dist, vg1a->coord, - dir, pl2, - tol) < 1) - continue; - - if (dist < -tol->dist || dist > 1.0 + tol->dist) - continue; - - if (hit_count1 >= hits_avail1) { - hits_avail1 += HITS_BLOCK; - hits1 = (point_t *)bu_realloc(hits1, - hits_avail1 * sizeof(point_t), "hits1"); - } - VJOIN1(hits1[hit_count1], vg1a->coord, dist, dir); - hit_count1++; - } - } - for (BU_LIST_FOR(lu2, loopuse, &fu2->lu_hd)) { - if (BU_LIST_FIRST_MAGIC(&lu2->down_hd) != NMG_EDGEUSE_MAGIC) - continue; - - for (BU_LIST_FOR(eu2, edgeuse, &lu2->down_hd)) { - vg2a = eu2->vu_p->v_p->vg_p; - vg2b = eu2->eumate_p->vu_p->v_p->vg_p; - VSUB2(dir, vg2b->coord, vg2a->coord); - - /* find intersection of this edge with fu1 */ - - if (bn_isect_line3_plane(&dist, vg2a->coord, - dir, pl1, - tol) < 1) - continue; - - if (dist < -tol->dist || dist > 1.0 + tol->dist) - continue; - - if (hit_count2 >= hits_avail2) { - hits_avail2 += HITS_BLOCK; - hits2 = (point_t *)bu_realloc(hits2, - hits_avail2 * sizeof(point_t), "hits2"); - } - VJOIN1(hits2[hit_count2], vg2a->coord, dist, dir); - hit_count2++; - } - } - - if (hit_count1 < 2 || hit_count2 < 2) { - /* nothing to plot */ - continue; - } - - /* sort the hits on face 1 */ - dists1 = (fastf_t *)bu_calloc(hit_count1, - sizeof(fastf_t), "dists1"); - dists2 = (fastf_t *)bu_calloc(hit_count2, - sizeof(fastf_t), "dists2"); - VMOVE(start_pt, hits1[0]); - dists1[0] = 0.0; - min_dist = 0.0; - min_hit = 0; - VSUB2(dir, hits1[1], hits1[0]); - dists1[1] = MAGNITUDE(dir); - VUNITIZE(dir); - max_dist = dists1[1]; - max_hit = 1; - for (i = 2; i < hit_count1; i++) { - VSUB2(diff, hits1[i], start_pt); - dists1[i] = MAGNITUDE(diff); - if (VDOT(dir, diff) < 0.0) - dists1[i] = -dists1[i]; - if (dists1[i] > max_dist) { - max_dist = dists1[i]; - max_hit = i; - } - if (dists1[i] < min_dist) { - min_dist = dists1[i]; - min_hit = i; - } - } - - /* recalculate dir */ - VSUB2(dir, hits1[max_hit], hits1[min_hit]); - VUNITIZE(dir); - - done = 0; - while (!done) { - done = 1; - for (i = 1; i < hit_count1; i++) { - if (dists1[i-1] > dists1[i]) { - fastf_t tmp; - point_t tmp_pt; - - done = 0; - tmp = dists1[i]; - VMOVE(tmp_pt, hits1[i]); - dists1[i] = dists1[i-1]; - VMOVE(hits1[i], hits1[i-1]); - dists1[i-1] = tmp; - VMOVE(hits1[i-1], tmp_pt); - } - } - } - - /* sort the hits on face 2 */ - min_dist = MAX_FASTF; - min_hit = -1; - max_dist = -min_dist; - max_hit = -1; - for (i = 0; i < hit_count2; i++) { - VSUB2(diff, hits2[i], start_pt); - dists2[i] = MAGNITUDE(diff); - if (VDOT(dir, diff) < 0.0) - dists2[i] = -dists2[i]; - if (dists2[i] > max_dist) { - max_dist = dists2[i]; - max_hit = i; - } - if (dists2[i] < min_dist) { - min_dist = dists2[i]; - min_hit = i; - } - } - - done = 0; - while (!done) { - done = 1; - for (i = 1; i < hit_count2; i++) { - if (dists2[i-1] > dists2[i]) { - fastf_t tmp; - point_t tmp_pt; - - done = 0; - tmp = dists2[i]; - VMOVE(tmp_pt, hits2[i]); - dists2[i] = dists2[i-1]; - VMOVE(hits2[i], hits2[i-1]); - dists2[i-1] = tmp; - VMOVE(hits2[i-1], tmp_pt); - } - } - } - - /* build a segment list for each solid */ - BU_ALLOC(A, struct bu_list); - BU_ALLOC(B, struct bu_list); - - BU_LIST_INIT(A); - BU_LIST_INIT(B); - - for (i = 1; i < hit_count1; i += 2) { - if (NEAR_EQUAL(dists1[i], dists1[i-1], tol->dist)) { - continue; - } - RT_GET_SEG(aseg, dgcdp->ap->a_resource); - aseg->l.magic = RT_SEG_MAGIC; - aseg->seg_stp = ON_INT; - VMOVE(aseg->seg_in.hit_point, hits1[i-1]); - aseg->seg_in.hit_dist = dists1[i-1]; - VMOVE(aseg->seg_out.hit_point, hits1[i]); - aseg->seg_out.hit_dist = dists1[i]; - - BU_LIST_APPEND(A, &aseg->l); - } - - for (i = 1; i < hit_count2; i += 2) { - if (NEAR_EQUAL(dists2[i], dists2[i-1], tol->dist)) { - continue; - } - RT_GET_SEG(aseg, dgcdp->ap->a_resource); - aseg->l.magic = RT_SEG_MAGIC; - aseg->seg_stp = ON_INT; - VMOVE(aseg->seg_in.hit_point, hits2[i-1]); - aseg->seg_in.hit_dist = dists2[i-1]; - VMOVE(aseg->seg_out.hit_point, hits2[i]); - aseg->seg_out.hit_dist = dists2[i]; - - BU_LIST_APPEND(B, &aseg->l); - } - - result = wdb_eval_op(A, OP_INTERSECT, B, dgcdp); - - for (BU_LIST_FOR(aseg, seg, result)) { - point_t ray_start; - - VJOIN1(ray_start, start_pt, aseg->seg_in.hit_dist, dir); - wdb_shoot_and_plot(ray_start, dir, vhead, - aseg->seg_out.hit_dist - aseg->seg_in.hit_dist, - leaf_no, leaf2, eptr, ON_INT, dgcdp); - } - MY_FREE_SEG_LIST(result, dgcdp->ap->a_resource); - - bu_free((char *)dists1, "dists1"); - bu_free((char *)dists2, "dists2"); - } - } - } - } - - bu_free((char *)hits1, "hits1"); - bu_free((char *)hits2, "hits2"); -} - - -HIDDEN void -wdb_free_etree(union E_tree *eptr, - struct dg_client_data *dgcdp) -{ - CK_ETREE(eptr); - - switch (eptr->l.op) { - case OP_UNION: - case OP_SUBTRACT: - case OP_INTERSECT: - wdb_free_etree(eptr->n.left, dgcdp); - wdb_free_etree(eptr->n.right, dgcdp); - bu_free((char *)eptr, "node pointer"); - break; - case OP_DB_LEAF: - case OP_SOLID: - if (eptr->l.m && !eptr->l.do_not_free_model) { - nmg_km(eptr->l.m); - eptr->l.m = (struct model *)NULL; - } - if (BU_LIST_NON_EMPTY(&eptr->l.seghead)) { - MY_FREE_SEG_LIST(&eptr->l.seghead, dgcdp->ap->a_resource); - } - if (BU_LIST_NON_EMPTY(&eptr->l.edge_list.l)) { - bu_ptbl_free(&eptr->l.edge_list); - } - if (eptr->l.stp) { - if (eptr->l.stp->st_specific && OBJ[eptr->l.stp->st_id].ft_free) - OBJ[eptr->l.stp->st_id].ft_free(eptr->l.stp); - bu_free((char *)eptr->l.stp, "struct soltab"); - } - - bu_free((char *)eptr, "leaf pointer"); - break; - } -} - - -/* convert all "half" solids to polysolids */ -HIDDEN void -wdb_fix_halfs(struct dg_client_data *dgcdp) -{ - point_t max, min; - int i, count=0; - struct bn_tol *tol; - - tol = &dgcdp->dgop->dgo_wdbp->wdb_tol; - - VSETALL(max, -INFINITY); - VSETALL(min, INFINITY); - - for (i = 0; i < BU_PTBL_END(&dgcdp->leaf_list); i++) { - union E_tree *tp; - - tp = (union E_tree *)BU_PTBL_GET(&dgcdp->leaf_list, i); - - if (tp->l.stp->st_id == ID_HALF) - continue; - - VMINMAX(min, max, tp->l.stp->st_min); - VMINMAX(min, max, tp->l.stp->st_max); - count++; - } - - if (!count) { - Tcl_AppendResult(dgcdp->interp, "A 'half' solid is the only solid in a region (ignored)\n", (char *)NULL); - return; - } - - for (i = 0; i < BU_PTBL_END(&dgcdp->leaf_list); i++) { - union E_tree *tp; - struct vertex *v[8]; - struct vertex **vp[4]; - struct nmgregion *r; - struct shell *s; - struct rt_pg_internal *pg; - struct faceuse *fu; - plane_t haf_pl; - struct half_specific *hp; - int j; - - tp = (union E_tree *)BU_PTBL_GET(&dgcdp->leaf_list, i); - - if (tp->l.stp->st_id != ID_HALF) - continue; - - hp = (struct half_specific *)tp->l.stp->st_specific; - - HMOVE(haf_pl, hp->half_eqn); - - if (DIST_PT_PLANE(max, haf_pl) >= -tol->dist && - DIST_PT_PLANE(min, haf_pl) >= -tol->dist) - continue; - - /* make an NMG the size of our model bounding box */ - tp->l.m = nmg_mm(); - r = nmg_mrsv(tp->l.m); - s = BU_LIST_FIRST(shell, &r->s_hd); - - for (j = 0; j < 8; j++) - v[j] = (struct vertex *)NULL; - - vp[0] = &v[0]; - vp[1] = &v[1]; - vp[2] = &v[2]; - vp[3] = &v[3]; - fu = nmg_cmface(s, vp, 4); - nmg_vertex_g(v[0], max[X], min[Y], min[Z]); - nmg_vertex_g(v[1], max[X], max[Y], min[Z]); - nmg_vertex_g(v[2], max[X], max[Y], max[Z]); - nmg_vertex_g(v[3], max[X], min[Y], max[Z]); - nmg_calc_face_g(fu); - - vp[0] = &v[4]; - vp[1] = &v[5]; - vp[2] = &v[6]; - vp[3] = &v[7]; - fu = nmg_cmface(s, vp, 4); - nmg_vertex_g(v[4], min[X], min[Y], min[Z]); - nmg_vertex_g(v[5], min[X], min[Y], max[Z]); - nmg_vertex_g(v[6], min[X], max[Y], max[Z]); - nmg_vertex_g(v[7], min[X], max[Y], min[Z]); - nmg_calc_face_g(fu); - - vp[0] = &v[0]; - vp[1] = &v[3]; - vp[2] = &v[5]; - vp[3] = &v[4]; - fu = nmg_cmface(s, vp, 4); - nmg_calc_face_g(fu); - - vp[0] = &v[1]; - vp[1] = &v[7]; - vp[2] = &v[6]; - vp[3] = &v[2]; - fu = nmg_cmface(s, vp, 4); - nmg_calc_face_g(fu); - - vp[0] = &v[3]; - vp[1] = &v[2]; - vp[2] = &v[6]; - vp[3] = &v[5]; - fu = nmg_cmface(s, vp, 4); - nmg_calc_face_g(fu); - - vp[0] = &v[1]; - vp[1] = &v[0]; - vp[2] = &v[4]; - vp[3] = &v[7]; - fu = nmg_cmface(s, vp, 4); - nmg_calc_face_g(fu); - - nmg_region_a(r, tol); - - for (BU_LIST_FOR(fu, faceuse, &s->fu_hd)) { - struct edgeuse *eu, *new_eu; - struct loopuse *lu, *new_lu; - plane_t pl; - struct vertexuse *vcut[2]; - point_t pt[2]; - struct edgeuse *eu_split[2]; - - if (fu->orientation != OT_SAME) - continue; - - NMG_GET_FU_PLANE(pl, fu); - - if (bn_coplanar(pl, haf_pl, tol) > 0) - continue; - - lu = BU_LIST_FIRST(loopuse, &fu->lu_hd); - - count = 0; - for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) { - vect_t dir; - struct vertex_g *v1g, *v2g; - fastf_t dist; - - v1g = eu->vu_p->v_p->vg_p; - v2g = eu->eumate_p->vu_p->v_p->vg_p; - - VSUB2(dir, v2g->coord, v1g->coord); - - if (bn_isect_line3_plane(&dist, v1g->coord, dir, haf_pl, tol) < 1) - continue; - - if (dist < 0.0 || dist >=1.0) - continue; - - VJOIN1(pt[count], v1g->coord, dist, dir); - eu_split[count] = eu; - - count++; - if (count == 2) - break; - } - - if (count != 2) - continue; - - new_eu = nmg_eusplit((struct vertex *)NULL, eu_split[0], 1); - vcut[0] = new_eu->vu_p; - nmg_vertex_gv(vcut[0]->v_p, pt[0]); - - new_eu = nmg_eusplit((struct vertex *)NULL, eu_split[1], 1); - vcut[1] = new_eu->vu_p; - nmg_vertex_gv(vcut[1]->v_p, pt[1]); - - new_lu = nmg_cut_loop(vcut[0], vcut[1]); - nmg_lu_reorient(lu); - nmg_lu_reorient(new_lu); - - for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) { - if (eu->vu_p->v_p == vcut[0]->v_p || eu->vu_p->v_p == vcut[1]->v_p) - continue; - - if (DIST_PT_PLANE(eu->vu_p->v_p->vg_p->coord, haf_pl) > tol->dist) { - nmg_klu(lu); - break; - } else { - nmg_klu(new_lu); - break; - } - } - } - - /* kill any faces outside the half */ - fu = BU_LIST_FIRST(faceuse, &s->fu_hd); - if (fu->orientation != OT_SAME) - fu = BU_LIST_PNEXT(faceuse, &fu->l); - while (BU_LIST_NOT_HEAD(&fu->l, &s->fu_hd)) { - struct faceuse *next_fu; - struct loopuse *lu; - int killfu=0; - - next_fu = BU_LIST_PNEXT(faceuse, &fu->l); - if (fu->fumate_p == next_fu) - next_fu = BU_LIST_PNEXT(faceuse, &next_fu->l); - - if (fu->orientation != OT_SAME) { - fu = next_fu; - continue; - } - - lu = BU_LIST_FIRST(loopuse, &fu->lu_hd); - while (BU_LIST_NOT_HEAD(&lu->l, &fu->lu_hd)) { - struct loopuse *next_lu; - struct edgeuse *eu; - int killit; - - next_lu = BU_LIST_PNEXT(loopuse, &lu->l); - - killit = 0; - for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) { - struct vertex_g *vg; - - vg = eu->vu_p->v_p->vg_p; - - if (DIST_PT_PLANE(vg->coord, haf_pl) > tol->dist) { - killit = 1; - break; - } - } - - if (killit) { - if (nmg_klu(lu)) { - killfu = 1; - break; - } - } - lu = next_lu; - } - - if (killfu) - nmg_kfu(fu); - - fu = next_fu; - } - - nmg_rebound(tp->l.m, tol); - nmg_model_fuse(tp->l.m, tol); - nmg_close_shell(s, tol); - nmg_rebound(tp->l.m, tol); - - BU_ALLOC(pg, struct rt_pg_internal); - - if (!nmg_to_poly(tp->l.m, pg, tol)) { - bu_free((char *)pg, "rt_pg_internal"); - Tcl_AppendResult(dgcdp->interp, "Prep failure for solid '", tp->l.stp->st_dp->d_namep, - "'\n", (char *)NULL); - } else { - struct rt_db_internal intern2; - - RT_DB_INTERNAL_INIT(&intern2); - intern2.idb_major_type = DB5_MAJORTYPE_BRLCAD; - intern2.idb_type = ID_POLY; - intern2.idb_meth = &OBJ[ID_POLY]; - intern2.idb_ptr = (genptr_t)pg; - if (OBJ[tp->l.stp->st_id].ft_free) - OBJ[tp->l.stp->st_id].ft_free(tp->l.stp); - tp->l.stp->st_specific = NULL; - tp->l.stp->st_id = ID_POLY; - VSETALL(tp->l.stp->st_max, -INFINITY); - VSETALL(tp->l.stp->st_min, INFINITY); - if (!OBJ[ID_POLY].ft_prep || OBJ[ID_POLY].ft_prep(tp->l.stp, &intern2, dgcdp->rtip) < 0) { - Tcl_AppendResult(dgcdp->interp, "Prep failure for polysolid version of solid '", tp->l.stp->st_dp->d_namep, - "'\n", (char *)NULL); - } - - rt_db_free_internal(&intern2); - } - } -} - - -int -dgo_E_cmd(struct dg_obj *dgop, - int argc, - const char **argv) -{ - int c; - char perf_message[128]; - struct dg_client_data *dgcdp; - - if (argc < 2) { - struct bu_vls vls = BU_VLS_INIT_ZERO; - - bu_vls_printf(&vls, "help E"); - Tcl_Eval(dgop->interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; - } - - if (bu_debug&BU_DEBUG_MEM_CHECK && bu_mem_barriercheck()) - bu_log("Error at start of 'E'\n"); - - BU_ALLOC(dgcdp, struct dg_client_data); - dgcdp->dgop = dgop; - dgcdp->interp = dgop->interp; - dgcdp->do_polysolids = 0; - dgcdp->wireframe_color_override = 0; - - /* Parse options. */ - bu_optind = 1; /* re-init bu_getopt() */ - while ((c=bu_getopt(argc, (char * const *)argv, "sC:")) != -1) { - switch (c) { - case 'C': { - int r, g, b; - char *cp = bu_optarg; - - r = atoi(cp); - while ((*cp >= '0' && *cp <= '9')) cp++; - while (*cp && (*cp < '0' || *cp > '9')) cp++; - g = atoi(cp); - while ((*cp >= '0' && *cp <= '9')) cp++; - while (*cp && (*cp < '0' || *cp > '9')) cp++; - b = atoi(cp); - - if (r < 0 || r > 255) r = 255; - if (g < 0 || g > 255) g = 255; - if (b < 0 || b > 255) b = 255; - - dgcdp->wireframe_color_override = 1; - dgcdp->wireframe_color[0] = r; - dgcdp->wireframe_color[1] = g; - dgcdp->wireframe_color[2] = b; - } - break; - case 's': - dgcdp->do_polysolids = 1; - break; - default: { - struct bu_vls vls = BU_VLS_INIT_ZERO; - - bu_vls_printf(&vls, "help %s", argv[0]); - Tcl_Eval(dgop->interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - - return TCL_ERROR; - } - } - } - argc -= bu_optind; - argv += bu_optind; - - dgo_eraseobjpath(dgop, argc, argv, LOOKUP_QUIET, 0); - - BU_ALLOC(dgcdp->ap, struct application); - RT_APPLICATION_INIT(dgcdp->ap); - dgcdp->ap->a_resource = &rt_uniresource; - rt_uniresource.re_magic = RESOURCE_MAGIC; - if (!BU_LIST_IS_INITIALIZED(&rt_uniresource.re_nmgfree)) - BU_LIST_INIT(&rt_uniresource.re_nmgfree); - - bu_ptbl_init(&dgcdp->leaf_list, 8, "leaf_list"); - - dgcdp->rtip = rt_new_rti(dgop->dgo_wdbp->dbip); - dgcdp->rtip->rti_tol = dgop->dgo_wdbp->wdb_tol; /* struct copy */ - dgcdp->rtip->useair = 1; - dgcdp->ap->a_rt_i = dgcdp->rtip; - - dgcdp->nvectors = 0; - (void)time(&dgcdp->start_time); - - if (rt_gettrees(dgcdp->rtip, argc, (const char **)argv, 1)) { - bu_ptbl_free(&dgcdp->leaf_list); - - /* do not do an rt_free_rti() (closes the database!!!!) */ - rt_clean(dgcdp->rtip); - - bu_free((char *)dgcdp->rtip, "rt_i structure for 'E'"); - bu_free(dgcdp, "dgcdp"); - - bu_log("Failed to get objects\n"); - return TCL_ERROR; - } - { - struct region *rp; - union E_tree *eptr; - struct bu_list vhead; - struct db_tree_state ts; - struct db_full_path path; - - BU_LIST_INIT(&vhead); - - for (BU_LIST_FOR(rp, region, &(dgcdp->rtip->HeadRegion))) { - dgcdp->num_halfs = 0; - eptr = wdb_build_etree(rp->reg_treetop, dgcdp); - - if (dgcdp->num_halfs) - wdb_fix_halfs(dgcdp); - - wdb_Eplot(eptr, &vhead, dgcdp); - wdb_free_etree(eptr, dgcdp); - bu_ptbl_reset(&dgcdp->leaf_list); - ts.ts_mater = rp->reg_mater; - db_string_to_path(&path, dgop->dgo_wdbp->dbip, rp->reg_name); - dgo_drawH_part2(0, &vhead, &path, &ts, SOLID_NULL, dgcdp); - db_free_full_path(&path); - } - /* do not do an rt_free_rti() (closes the database!!!!) */ - rt_clean(dgcdp->rtip); - - bu_free((char *)dgcdp->rtip, "rt_i structure for 'E'"); - } - - dgo_color_soltab(&dgop->dgo_headSolid); - (void)time(&dgcdp->etime); - - /* free leaf_list */ - bu_ptbl_free(&dgcdp->leaf_list); - - sprintf(perf_message, "E: %ld vectors in %ld sec\n", dgcdp->nvectors, (long)(dgcdp->etime - dgcdp->start_time)); - Tcl_AppendResult(dgop->interp, perf_message, (char *)NULL); - - return TCL_OK; -} - - -/* - * Local Variables: - * mode: C - * tab-width: 8 - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2014-01-09 15:54:02
|
Revision: 59333 http://sourceforge.net/p/brlcad/code/59333 Author: starseeker Date: 2014-01-09 15:53:58 +0000 (Thu, 09 Jan 2014) Log Message: ----------- More avoiding of 'new' keyword collisions with C++ Modified Paths: -------------- brlcad/trunk/src/libged/joint.c brlcad/trunk/src/libged/move_all.c brlcad/trunk/src/libged/select.c Modified: brlcad/trunk/src/libged/joint.c =================================================================== --- brlcad/trunk/src/libged/joint.c 2014-01-09 15:49:57 UTC (rev 59332) +++ brlcad/trunk/src/libged/joint.c 2014-01-09 15:53:58 UTC (rev 59333) @@ -2306,7 +2306,7 @@ struct joint *jp; int freedom; double old; - double new; + double snew; }; #define SOLVE_STACK_MAGIC 0x76766767 struct bu_list solve_head = { @@ -2607,7 +2607,7 @@ ssp->freedom = bestfreedom; ssp->old = (bestfreedom<3) ? bestjoint->rots[bestfreedom].current : bestjoint->dirs[bestfreedom-3].current; - ssp->new = bestvalue; + ssp->snew = bestvalue; BU_LIST_PUSH(&solve_head, ssp); } if (bestfreedom < 3) { @@ -2631,7 +2631,7 @@ if (joint_debug & DEBUG_J_SYSTEM) { bu_vls_printf(gedp->ged_result_str, "reject_move: rejecting %s(%d, %g)->%g\n", ssp->jp->name, - ssp->freedom, ssp->new, ssp->old); + ssp->freedom, ssp->snew, ssp->old); } if (ssp->freedom<3) { ssp->jp->rots[ssp->freedom].current = ssp->old; Modified: brlcad/trunk/src/libged/move_all.c =================================================================== --- brlcad/trunk/src/libged/move_all.c 2014-01-09 15:49:57 UTC (rev 59332) +++ brlcad/trunk/src/libged/move_all.c 2014-01-09 15:53:58 UTC (rev 59333) @@ -35,7 +35,7 @@ #include "./ged_private.h" HIDDEN int -move_all_func(struct ged *gedp, int nflag, const char *old, const char *new) +move_all_func(struct ged *gedp, int nflag, const char *old_name, const char *new_name) { int i; struct ged_display_list *gdlp; @@ -45,11 +45,11 @@ struct bu_ptbl stack; /* rename the record itself */ - if ((dp = db_lookup(gedp->ged_wdbp->dbip, old, LOOKUP_NOISY)) == RT_DIR_NULL) + if ((dp = db_lookup(gedp->ged_wdbp->dbip, old_name, LOOKUP_NOISY)) == RT_DIR_NULL) return GED_ERROR; - if (db_lookup(gedp->ged_wdbp->dbip, new, LOOKUP_QUIET) != RT_DIR_NULL) { - bu_vls_printf(gedp->ged_result_str, "%s: already exists", new); + if (db_lookup(gedp->ged_wdbp->dbip, new_name, LOOKUP_QUIET) != RT_DIR_NULL) { + bu_vls_printf(gedp->ged_result_str, "%s: already exists", new_name); return GED_ERROR; } @@ -79,13 +79,13 @@ extrude = (struct rt_extrude_internal *)intern.idb_ptr; RT_EXTRUDE_CK_MAGIC(extrude); - if (BU_STR_EQUAL(extrude->sketch_name, old)) { + if (BU_STR_EQUAL(extrude->sketch_name, old_name)) { if (nflag) { bu_vls_printf(gedp->ged_result_str, "%s ", dirp->d_namep); rt_db_free_internal(&intern); } else { bu_free(extrude->sketch_name, "sketch name"); - extrude->sketch_name = bu_strdup(new); + extrude->sketch_name = bu_strdup(new_name); if (rt_db_put_internal(dirp, gedp->ged_wdbp->dbip, &intern, &rt_uniresource) < 0) { bu_log("oops\n"); @@ -100,8 +100,8 @@ if (!nflag) { /* Change object name in the directory. */ - if (db_rename(gedp->ged_wdbp->dbip, dp, new) < 0) { - bu_vls_printf(gedp->ged_result_str, "error in rename to %s, aborting", new); + if (db_rename(gedp->ged_wdbp->dbip, dp, new_name) < 0) { + bu_vls_printf(gedp->ged_result_str, "error in rename to %s, aborting", new_name); return GED_ERROR; } @@ -140,7 +140,7 @@ comb_leaf = comb_leaf->tr_b.tb_left; } - if (BU_STR_EQUAL(comb_leaf->tr_l.tl_name, old)) { + if (BU_STR_EQUAL(comb_leaf->tr_l.tl_name, old_name)) { bu_vls_printf(gedp->ged_result_str, "%s ", dp->d_namep); } @@ -157,7 +157,7 @@ } rt_db_free_internal(&intern); } else { - int comb_mvall_status = db_comb_mvall(dp, gedp->ged_wdbp->dbip, old, new, &stack); + int comb_mvall_status = db_comb_mvall(dp, gedp->ged_wdbp->dbip, old_name, new_name, &stack); if (!comb_mvall_status) continue; if (comb_mvall_status == 2) { bu_ptbl_free(&stack); @@ -180,14 +180,14 @@ char *tok = strtok(dupstr, "/"); while (tok) { - if (BU_STR_EQUAL(tok, old)) { + if (BU_STR_EQUAL(tok, old_name)) { found = 1; if (first) { first = 0; - bu_vls_printf(&new_path, "%s", new); + bu_vls_printf(&new_path, "%s", new_name); } else - bu_vls_printf(&new_path, "/%s", new); + bu_vls_printf(&new_path, "/%s", new_name); } else { if (first) { first = 0; Modified: brlcad/trunk/src/libged/select.c =================================================================== --- brlcad/trunk/src/libged/select.c 2014-01-09 15:49:57 UTC (rev 59332) +++ brlcad/trunk/src/libged/select.c 2014-01-09 15:53:58 UTC (rev 59333) @@ -507,11 +507,11 @@ struct rt_object_selections * ged_get_object_selections(struct ged *gedp, const char *object_name) { - int new; + int int_new; struct bu_hash_entry *entry; entry = bu_hash_tbl_add(gedp->ged_selections, (unsigned char *)object_name, - strlen(object_name), &new); + strlen(object_name), &int_new); return (struct rt_object_selections *)bu_get_hash_value(entry); } @@ -521,11 +521,11 @@ { struct rt_object_selections *obj_selections; struct bu_hash_entry *entry; - int new; + int int_new; obj_selections = ged_get_object_selections(gedp, object_name); entry = bu_hash_tbl_add(obj_selections->sets, - (const unsigned char *)selection_name, strlen(selection_name), &new); + (const unsigned char *)selection_name, strlen(selection_name), &int_new); return (struct rt_selection_set *)bu_get_hash_value(entry); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <r_...@us...> - 2014-02-07 22:24:27
|
Revision: 59757 http://sourceforge.net/p/brlcad/code/59757 Author: r_weiss Date: 2014-02-07 22:24:24 +0000 (Fri, 07 Feb 2014) Log Message: ----------- Quiet windows build warnings. Modified Paths: -------------- brlcad/trunk/src/libged/dg_obj.c brlcad/trunk/src/libged/editit.c brlcad/trunk/src/libged/rt.c brlcad/trunk/src/libged/rtcheck.c Modified: brlcad/trunk/src/libged/dg_obj.c =================================================================== --- brlcad/trunk/src/libged/dg_obj.c 2014-02-07 22:23:24 UTC (rev 59756) +++ brlcad/trunk/src/libged/dg_obj.c 2014-02-07 22:24:24 UTC (rev 59757) @@ -1743,7 +1743,7 @@ dgo_run_rt(struct dg_obj *dgop, struct view_obj *vop) { - size_t i; + ssize_t i; FILE *fp_in; #ifndef _WIN32 int pipe_in[2]; @@ -2362,11 +2362,10 @@ const char **argv) { const char **vp; - size_t i; + ssize_t i; size_t args; +#ifndef _WIN32 int ret; - -#ifndef _WIN32 int pid; int i_pipe[2]; /* object reads results for building vectors */ int o_pipe[2]; /* object writes view parameters */ Modified: brlcad/trunk/src/libged/editit.c =================================================================== --- brlcad/trunk/src/libged/editit.c 2014-02-07 22:23:24 UTC (rev 59756) +++ brlcad/trunk/src/libged/editit.c 2014-02-07 22:24:24 UTC (rev 59757) @@ -185,8 +185,6 @@ { - char *editor_basename; - #if defined(_WIN32) && !defined(__CYGWIN__) char buffer[RT_MAXLINE + 1] = {0}; STARTUPINFO si = {0}; @@ -204,7 +202,7 @@ WaitForSingleObject(pi.hProcess, INFINITE); return 1; #else - + char *editor_basename; editor_basename = (char *)bu_calloc(strlen(editor), sizeof(char), "_ged_editit editor_basename"); bu_basename(editor_basename, editor); if (BU_STR_EQUAL(editor_basename, "TextEdit")) { Modified: brlcad/trunk/src/libged/rt.c =================================================================== --- brlcad/trunk/src/libged/rt.c 2014-02-07 22:23:24 UTC (rev 59756) +++ brlcad/trunk/src/libged/rt.c 2014-02-07 22:24:24 UTC (rev 59757) @@ -297,7 +297,7 @@ line[count] = '\0'; /* handle (i.e., probably log to stderr) the resulting line */ - if (drcdp->gedp->ged_output_handler != (void (*)())0) + if (drcdp->gedp->ged_output_handler != (void (*)(struct ged *, char *))0) drcdp->gedp->ged_output_handler(drcdp->gedp, line); else bu_vls_printf(drcdp->gedp->ged_result_str, "%s", line); Modified: brlcad/trunk/src/libged/rtcheck.c =================================================================== --- brlcad/trunk/src/libged/rtcheck.c 2014-02-07 22:23:24 UTC (rev 59756) +++ brlcad/trunk/src/libged/rtcheck.c 2014-02-07 22:24:24 UTC (rev 59757) @@ -257,7 +257,7 @@ } line[count] = '\0'; - if (rtcop->gedp->ged_output_handler != (void (*)())0) + if (rtcop->gedp->ged_output_handler != (void (*)(struct ged *, char *))0) rtcop->gedp->ged_output_handler(rtcop->gedp, line); else bu_vls_printf(rtcop->gedp->ged_result_str, "%s", line); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2014-03-05 05:07:12
|
Revision: 60057 http://sourceforge.net/p/brlcad/code/60057 Author: starseeker Date: 2014-03-05 05:07:07 +0000 (Wed, 05 Mar 2014) Log Message: ----------- remove bu.h inclusions from libged files. Similar to librt - getting a lot from headers currently, but will boil down as they are broken up. Modified Paths: -------------- brlcad/trunk/src/libged/adc.c brlcad/trunk/src/libged/analyze.c brlcad/trunk/src/libged/bigE.c brlcad/trunk/src/libged/bot_dump.c brlcad/trunk/src/libged/brep.c brlcad/trunk/src/libged/coil.c brlcad/trunk/src/libged/columns.c brlcad/trunk/src/libged/comb_std.c brlcad/trunk/src/libged/constraint/constraint.c brlcad/trunk/src/libged/dg_obj.c brlcad/trunk/src/libged/draw.c brlcad/trunk/src/libged/facedef.c brlcad/trunk/src/libged/fb2pix.c brlcad/trunk/src/libged/ged.c brlcad/trunk/src/libged/ged_util.c brlcad/trunk/src/libged/gqa.c brlcad/trunk/src/libged/grid.c brlcad/trunk/src/libged/human.c brlcad/trunk/src/libged/inside.c brlcad/trunk/src/libged/joint.c brlcad/trunk/src/libged/nirt.c brlcad/trunk/src/libged/pix2fb.c brlcad/trunk/src/libged/png.c brlcad/trunk/src/libged/ps.c brlcad/trunk/src/libged/pull.c brlcad/trunk/src/libged/push.c brlcad/trunk/src/libged/qray.c brlcad/trunk/src/libged/rect.c brlcad/trunk/src/libged/screengrab.c brlcad/trunk/src/libged/simulate/simulate.c brlcad/trunk/src/libged/solids_on_ray.c brlcad/trunk/src/libged/tire.c brlcad/trunk/src/libged/track.c brlcad/trunk/src/libged/view_obj.c brlcad/trunk/src/libged/wdb_comb_std.c brlcad/trunk/src/libged/wdb_nirt.c brlcad/trunk/src/libged/wdb_obj.c brlcad/trunk/src/libged/wdb_qray.c brlcad/trunk/src/libged/wdb_track.c brlcad/trunk/src/libged/zoom/zoom.c Modified: brlcad/trunk/src/libged/adc.c =================================================================== --- brlcad/trunk/src/libged/adc.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/adc.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -29,7 +29,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "ged.h" Modified: brlcad/trunk/src/libged/analyze.c =================================================================== --- brlcad/trunk/src/libged/analyze.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/analyze.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -31,7 +31,7 @@ #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "bn.h" #include "raytrace.h" Modified: brlcad/trunk/src/libged/bigE.c =================================================================== --- brlcad/trunk/src/libged/bigE.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/bigE.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -33,7 +33,8 @@ #include <time.h> #include "bio.h" -#include "bu.h" +#include "bu/debug.h" +#include "bu/getopt.h" #include "vmath.h" #include "nmg.h" #include "rtgeom.h" Modified: brlcad/trunk/src/libged/bot_dump.c =================================================================== --- brlcad/trunk/src/libged/bot_dump.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/bot_dump.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -33,10 +33,13 @@ #include "bio.h" #include "bin.h" +#include "bu/cv.h" +#include "bu/getopt.h" +#include "bu/units.h" #include "vmath.h" #include "nmg.h" #include "rtgeom.h" -#include "bu.h" + #include "raytrace.h" #include "wdb.h" Modified: brlcad/trunk/src/libged/brep.c =================================================================== --- brlcad/trunk/src/libged/brep.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/brep.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -29,7 +29,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "raytrace.h" #include "rtgeom.h" #include "wdb.h" Modified: brlcad/trunk/src/libged/coil.c =================================================================== --- brlcad/trunk/src/libged/coil.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/coil.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -29,7 +29,8 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#include "bu.h" + +#include "bu/getopt.h" #include "vmath.h" #include "bn.h" #include "raytrace.h" Modified: brlcad/trunk/src/libged/columns.c =================================================================== --- brlcad/trunk/src/libged/columns.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/columns.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -32,7 +32,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "raytrace.h" #include "db.h" Modified: brlcad/trunk/src/libged/comb_std.c =================================================================== --- brlcad/trunk/src/libged/comb_std.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/comb_std.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -31,7 +31,8 @@ #include "bio.h" #include "tcl.h" -#include "bu.h" + +#include "bu/getopt.h" #include "vmath.h" #include "rtgeom.h" #include "ged.h" Modified: brlcad/trunk/src/libged/constraint/constraint.c =================================================================== --- brlcad/trunk/src/libged/constraint/constraint.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/constraint/constraint.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -20,7 +20,7 @@ #include "common.h" -#include "bu.h" + #include "bu/cmd.h" #include "ged.h" Modified: brlcad/trunk/src/libged/dg_obj.c =================================================================== --- brlcad/trunk/src/libged/dg_obj.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/dg_obj.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -44,7 +44,7 @@ #include "bio.h" #include "tcl.h" -#include "bu.h" + #include "bn.h" #include "bu/cmd.h" #include "vmath.h" Modified: brlcad/trunk/src/libged/draw.c =================================================================== --- brlcad/trunk/src/libged/draw.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/draw.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -28,8 +28,10 @@ #include <stdlib.h> #include <string.h> -#include "bu.h" + #include "bio.h" +#include "bu/getopt.h" +#include "bu/parallel.h" #include "mater.h" #include "solid.h" Modified: brlcad/trunk/src/libged/facedef.c =================================================================== --- brlcad/trunk/src/libged/facedef.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/facedef.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -29,7 +29,7 @@ #include <signal.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "rtgeom.h" #include "raytrace.h" Modified: brlcad/trunk/src/libged/fb2pix.c =================================================================== --- brlcad/trunk/src/libged/fb2pix.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/fb2pix.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -37,7 +37,8 @@ # include <unistd.h> #endif -#include "bu.h" + +#include "bu/getopt.h" #include "fb.h" #include "fbserv_obj.h" Modified: brlcad/trunk/src/libged/ged.c =================================================================== --- brlcad/trunk/src/libged/ged.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/ged.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -40,7 +40,8 @@ #include <math.h> #include "bio.h" -#include "bu.h" + +#include "bu/sort.h" #include "vmath.h" #include "bn.h" #include "rtgeom.h" Modified: brlcad/trunk/src/libged/ged_util.c =================================================================== --- brlcad/trunk/src/libged/ged_util.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/ged_util.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -34,7 +34,7 @@ #include <math.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "bn.h" #include "rtgeom.h" Modified: brlcad/trunk/src/libged/gqa.c =================================================================== --- brlcad/trunk/src/libged/gqa.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/gqa.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -42,7 +42,9 @@ #include <limits.h> /* home of INT_MAX a/k/a MAXINT */ #include "bio.h" -#include "bu.h" + +#include "bu/parallel.h" +#include "bu/getopt.h" #include "vmath.h" #include "raytrace.h" #include "plot3.h" Modified: brlcad/trunk/src/libged/grid.c =================================================================== --- brlcad/trunk/src/libged/grid.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/grid.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -29,7 +29,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "./ged_private.h" Modified: brlcad/trunk/src/libged/human.c =================================================================== --- brlcad/trunk/src/libged/human.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/human.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -82,7 +82,8 @@ #include <string.h> #include <math.h> #include <time.h> -#include "bu.h" + +#include "bu/getopt.h" #include "vmath.h" #include "bn.h" #include "raytrace.h" Modified: brlcad/trunk/src/libged/inside.c =================================================================== --- brlcad/trunk/src/libged/inside.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/inside.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -31,7 +31,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "bn.h" #include "nmg.h" Modified: brlcad/trunk/src/libged/joint.c =================================================================== --- brlcad/trunk/src/libged/joint.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/joint.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -38,7 +38,8 @@ #include <string.h> #include <math.h> -#include "bu.h" + +#include "bu/getopt.h" #include "dg.h" #include "solid.h" #include "raytrace.h" Modified: brlcad/trunk/src/libged/nirt.c =================================================================== --- brlcad/trunk/src/libged/nirt.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/nirt.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -47,7 +47,7 @@ #include "bio.h" #include "tcl.h" -#include "bu.h" + #include "bn.h" #include "bu/cmd.h" #include "vmath.h" Modified: brlcad/trunk/src/libged/pix2fb.c =================================================================== --- brlcad/trunk/src/libged/pix2fb.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/pix2fb.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -38,7 +38,8 @@ #endif #include "bio.h" -#include "bu.h" + +#include "bu/getopt.h" #include "fb.h" #include "fbserv_obj.h" Modified: brlcad/trunk/src/libged/png.c =================================================================== --- brlcad/trunk/src/libged/png.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/png.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -32,7 +32,8 @@ #include <png.h> #include "bio.h" -#include "bu.h" + +#include "bu/getopt.h" #include "vmath.h" #include "bn.h" #include "solid.h" Modified: brlcad/trunk/src/libged/ps.c =================================================================== --- brlcad/trunk/src/libged/ps.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/ps.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -30,7 +30,8 @@ #include <string.h> #include "bio.h" -#include "bu.h" + +#include "bu/getopt.h" #include "vmath.h" #include "bn.h" #include "solid.h" Modified: brlcad/trunk/src/libged/pull.c =================================================================== --- brlcad/trunk/src/libged/pull.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/pull.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -30,7 +30,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "bn.h" #include "bu/cmd.h" Modified: brlcad/trunk/src/libged/push.c =================================================================== --- brlcad/trunk/src/libged/push.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/push.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -29,7 +29,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "bu/cmd.h" #include "./ged_private.h" Modified: brlcad/trunk/src/libged/qray.c =================================================================== --- brlcad/trunk/src/libged/qray.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/qray.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -30,7 +30,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "dg.h" #include "ged.h" Modified: brlcad/trunk/src/libged/rect.c =================================================================== --- brlcad/trunk/src/libged/rect.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/rect.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -29,7 +29,7 @@ #include <math.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "fb.h" Modified: brlcad/trunk/src/libged/screengrab.c =================================================================== --- brlcad/trunk/src/libged/screengrab.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/screengrab.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -29,7 +29,7 @@ #include <ctype.h> #include <string.h> -#include "bu.h" + #include "icv.h" #include "./ged_private.h" Modified: brlcad/trunk/src/libged/simulate/simulate.c =================================================================== --- brlcad/trunk/src/libged/simulate/simulate.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/simulate/simulate.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -38,7 +38,7 @@ /* Public Headers */ #include "vmath.h" #include "db.h" -#include "bu.h" + #include "raytrace.h" /* Private Headers */ Modified: brlcad/trunk/src/libged/solids_on_ray.c =================================================================== --- brlcad/trunk/src/libged/solids_on_ray.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/solids_on_ray.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -29,7 +29,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "bn.h" #include "bu/cmd.h" #include "solid.h" Modified: brlcad/trunk/src/libged/tire.c =================================================================== --- brlcad/trunk/src/libged/tire.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/tire.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -30,7 +30,9 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#include "bu.h" + +#include "bu/getopt.h" +#include "bu/units.h" #include "vmath.h" #include "bn.h" #include "raytrace.h" Modified: brlcad/trunk/src/libged/track.c =================================================================== --- brlcad/trunk/src/libged/track.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/track.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -40,7 +40,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "bn.h" #include "rtgeom.h" Modified: brlcad/trunk/src/libged/view_obj.c =================================================================== --- brlcad/trunk/src/libged/view_obj.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/view_obj.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -35,7 +35,7 @@ #include "tcl.h" -#include "bu.h" + #include "bn.h" #include "bu/cmd.h" #include "vmath.h" Modified: brlcad/trunk/src/libged/wdb_comb_std.c =================================================================== --- brlcad/trunk/src/libged/wdb_comb_std.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/wdb_comb_std.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -32,7 +32,8 @@ #include "bio.h" #include "tcl.h" -#include "bu.h" + +#include "bu/getopt.h" #include "vmath.h" #include "rtgeom.h" #include "ged.h" Modified: brlcad/trunk/src/libged/wdb_nirt.c =================================================================== --- brlcad/trunk/src/libged/wdb_nirt.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/wdb_nirt.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -47,7 +47,7 @@ #include "bio.h" #include "tcl.h" -#include "bu.h" + #include "bn.h" #include "bu/cmd.h" #include "vmath.h" Modified: brlcad/trunk/src/libged/wdb_obj.c =================================================================== --- brlcad/trunk/src/libged/wdb_obj.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/wdb_obj.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -41,7 +41,7 @@ #include "tcl.h" -#include "bu.h" + #include "bn.h" #include "bu/cmd.h" #include "vmath.h" Modified: brlcad/trunk/src/libged/wdb_qray.c =================================================================== --- brlcad/trunk/src/libged/wdb_qray.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/wdb_qray.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -30,7 +30,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "dg.h" #include "ged.h" Modified: brlcad/trunk/src/libged/wdb_track.c =================================================================== --- brlcad/trunk/src/libged/wdb_track.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/wdb_track.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -40,7 +40,7 @@ #include <string.h> #include "bio.h" -#include "bu.h" + #include "vmath.h" #include "bn.h" #include "rtgeom.h" Modified: brlcad/trunk/src/libged/zoom/zoom.c =================================================================== --- brlcad/trunk/src/libged/zoom/zoom.c 2014-03-05 04:58:15 UTC (rev 60056) +++ brlcad/trunk/src/libged/zoom/zoom.c 2014-03-05 05:07:07 UTC (rev 60057) @@ -22,7 +22,7 @@ #include "bio.h" -#include "bu.h" + #include "ged.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2014-04-04 19:33:00
|
Revision: 60384 http://sourceforge.net/p/brlcad/code/60384 Author: starseeker Date: 2014-04-04 19:32:57 +0000 (Fri, 04 Apr 2014) Log Message: ----------- apparently the other 'append' functions weren't used anywhere. Modified Paths: -------------- brlcad/trunk/src/libged/ged_private.h brlcad/trunk/src/libged/ged_util.c Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2014-04-04 15:31:56 UTC (rev 60383) +++ brlcad/trunk/src/libged/ged_private.h 2014-04-04 19:32:57 UTC (rev 60384) @@ -463,15 +463,7 @@ int (*func)()); /* defined in ged_util.c */ -extern int _ged_results_append_str(struct ged *gedp, - char *result_string); - -extern int _ged_results_append_vls(struct ged *gedp, - struct bu_vls *result_vls); - -extern int _ged_results_clear(struct ged *gedp); - -/* For this version, deliberately not adding a separate +/* Deliberately not adding a separate * vls function for API simplicity - just us bu_vls_addr * and call this function */ extern int _ged_results_add(struct ged_results *results, char *result_string); Modified: brlcad/trunk/src/libged/ged_util.c =================================================================== --- brlcad/trunk/src/libged/ged_util.c 2014-04-04 15:31:56 UTC (rev 60383) +++ brlcad/trunk/src/libged/ged_util.c 2014-04-04 19:32:57 UTC (rev 60384) @@ -28,45 +28,17 @@ #include "common.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> #include "bio.h" - -#include "vmath.h" -#include "bn.h" -#include "rtgeom.h" -#include "raytrace.h" -#include "plot3.h" - +#include "ged.h" #include "./ged_private.h" int -_ged_results_append_str(struct ged *gedp, char *result_string) +_ged_results_add(struct ged_results *UNUSED(results), char *UNUSED(result_string)) { - bu_vls_printf(gedp->ged_result_str, "%s", result_string); return GED_OK; } - -int -_ged_results_append_vls(struct ged *gedp, struct bu_vls *result_vls) -{ - bu_vls_printf(gedp->ged_result_str, "%s", bu_vls_addr(result_vls)); - return GED_OK; -} - - -int -_ged_results_clear(struct ged *gedp) -{ - bu_vls_trunc(gedp->ged_result_str, 0); - return GED_OK; -} - - /* * Local Variables: * mode: C This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2014-05-14 15:50:16
|
Revision: 60621 http://sourceforge.net/p/brlcad/code/60621 Author: brlcad Date: 2014-05-14 15:50:12 +0000 (Wed, 14 May 2014) Log Message: ----------- an aircode attribute will only get written out if it's non-zero, so don't mislead the user. did not update the wdb interface since they need to go away. Modified Paths: -------------- brlcad/trunk/src/libged/comb.c brlcad/trunk/src/libged/comb_std.c Modified: brlcad/trunk/src/libged/comb.c =================================================================== --- brlcad/trunk/src/libged/comb.c 2014-05-14 15:44:09 UTC (rev 60620) +++ brlcad/trunk/src/libged/comb.c 2014-05-14 15:50:12 UTC (rev 60621) @@ -769,9 +769,10 @@ comb->aircode = air; comb->los = gedp->ged_wdbp->wdb_los_default; comb->GIFTmater = gedp->ged_wdbp->wdb_mat_default; - bu_vls_printf(gedp->ged_result_str, - "Creating region with attrs: region_id=%d, air=%d, los=%d, material_id=%d\n", - ident, air, + bu_vls_printf(gedp->ged_result_str, "Creating region with attrs: region_id=%d, ", ident); + if (air) + bu_vls_printf(gedp->ged_result_str, "air=%d, ", air); + bu_vls_printf(gedp->ged_result_str, "los=%d, material_id=%d\n", gedp->ged_wdbp->wdb_los_default, gedp->ged_wdbp->wdb_mat_default); } else { Modified: brlcad/trunk/src/libged/comb_std.c =================================================================== --- brlcad/trunk/src/libged/comb_std.c 2014-05-14 15:44:09 UTC (rev 60620) +++ brlcad/trunk/src/libged/comb_std.c 2014-05-14 15:50:12 UTC (rev 60621) @@ -634,10 +634,14 @@ comb->aircode = gedp->ged_wdbp->wdb_air_default; comb->los = gedp->ged_wdbp->wdb_los_default; comb->GIFTmater = gedp->ged_wdbp->wdb_mat_default; - bu_vls_printf(gedp->ged_result_str, - "Creating region with attrs: region_id=%ld, air=%ld, los=%ld, material_id=%ld\n", - comb->region_id, comb->aircode, comb->los, comb->GIFTmater); + bu_vls_printf(gedp->ged_result_str, "Creating region with attrs: region_id=%d, ", comb->region_id); + if (comb->aircode) + bu_vls_printf(gedp->ged_result_str, "air=%d, ", comb->aircode); + bu_vls_printf(gedp->ged_result_str, "los=%d, material_id=%d\n", + comb->los, + comb->GIFTmater); + flags |= RT_DIR_REGION; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2014-07-14 15:24:32
|
Revision: 61691 http://sourceforge.net/p/brlcad/code/61691 Author: brlcad Date: 2014-07-14 15:24:24 +0000 (Mon, 14 Jul 2014) Log Message: ----------- ws indent style cleanup Modified Paths: -------------- brlcad/trunk/src/libged/joint.c brlcad/trunk/src/libged/joint.h Modified: brlcad/trunk/src/libged/joint.c =================================================================== --- brlcad/trunk/src/libged/joint.c 2014-07-14 15:19:36 UTC (rev 61690) +++ brlcad/trunk/src/libged/joint.c 2014-07-14 15:24:24 UTC (rev 61691) @@ -56,7 +56,7 @@ #define DEBUG_J_PARSE 0x00000040 #define DEBUG_J_LEX 0x00000080 #define JOINT_DEBUG_FORMAT \ -"\020\10LEX\7PARSE\6SYSTEM\5EVAL\4SOLVE\3MOVE\2LOAD\1MESH" + "\020\10LEX\7PARSE\6SYSTEM\5EVAL\4SOLVE\3MOVE\2LOAD\1MESH" void joint_move(struct ged *gedp, struct joint *jp); @@ -119,9 +119,9 @@ */ static int joint_cmd(struct ged *gedp, - int argc, - const char *argv[], - struct funtab functions[]) + int argc, + const char *argv[], + struct funtab functions[]) { struct funtab *ftp; @@ -129,7 +129,7 @@ return GED_OK; /* No command entered, that's fine */ /* initialize result */ - bu_vls_trunc(gedp->ged_result_str,0); + bu_vls_trunc(gedp->ged_result_str, 0); for (ftp = &functions[1]; ftp->ft_name; ftp++) { if (!BU_STR_EQUAL(ftp->ft_name, argv[0])) @@ -159,10 +159,11 @@ return GED_ERROR; } + int f_Jdebug(struct ged *gedp, - int argc, - const char *argv[]) + int argc, + const char *argv[]) { /* initialize result */ bu_vls_trunc(gedp->ged_result_str, 0); @@ -179,6 +180,7 @@ return GED_OK; } + int ged_joint(struct ged *gedp, int argc, const char *argv[]) { @@ -187,8 +189,8 @@ GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); /* Skip the command name */ argc--; @@ -202,6 +204,7 @@ return GED_ERROR; } + /** * Common code for help commands */ @@ -213,8 +216,8 @@ bad = 0; - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); /* Help command(s) */ for (i=1; i<argc; i++) { @@ -222,11 +225,11 @@ if (!BU_STR_EQUAL(ftp->ft_name, argv[i])) continue; - bu_vls_printf(gedp->ged_result_str, "Usage: %s%s %s\n\t( %s )\n", functions->ft_name, ftp->ft_name, ftp->ft_parms, ftp->ft_comment); - break; + bu_vls_printf(gedp->ged_result_str, "Usage: %s%s %s\n\t(%s)\n", functions->ft_name, ftp->ft_name, ftp->ft_parms, ftp->ft_comment); + break; } if (!ftp->ft_name) { - bu_vls_printf(gedp->ged_result_str, "%s%s : no such command, type '%s?' for help\n", functions->ft_name, argv[i], functions->ft_name); + bu_vls_printf(gedp->ged_result_str, "%s%s : no such command, type '%s?' for help\n", functions->ft_name, argv[i], functions->ft_name); bad = 1; } } @@ -234,6 +237,7 @@ return bad ? GED_ERROR : GED_OK; } + /** * Print a help message, two lines for each command. Or, help with * the indicated commands. @@ -243,19 +247,20 @@ { struct funtab *ftp; - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); if (argc <= 1) { bu_vls_printf(gedp->ged_result_str, "The following commands are available:\n"); for (ftp = functions+1; ftp->ft_name; ftp++) { - bu_vls_printf(gedp->ged_result_str, "%s%s %s\n\t (%s)\n", functions->ft_name, ftp->ft_name, ftp->ft_parms, ftp->ft_comment); + bu_vls_printf(gedp->ged_result_str, "%s%s %s\n\t (%s)\n", functions->ft_name, ftp->ft_name, ftp->ft_parms, ftp->ft_comment); } return GED_OK; } return helpcomm(gedp, argc, argv, functions); } + int f_help2(struct ged *gedp, int argc, const char *argv[], struct funtab *functions) { @@ -270,12 +275,13 @@ vls_col_item(gedp->ged_result_str, ftp->ft_name); } vls_col_eol(gedp->ged_result_str); - bu_vls_printf(gedp->ged_result_str,"\n"); + bu_vls_printf(gedp->ged_result_str, "\n"); return GED_OK; } return helpcomm(gedp, argc, argv, functions); } + static int f_Jhelp2(struct ged *gedp, int argc, const char *argv[]) { @@ -289,6 +295,7 @@ return GED_ERROR; } + static int f_Jhelp(struct ged *gedp, int argc, const char *argv[]) { @@ -302,11 +309,13 @@ return GED_ERROR; } + struct bu_list joint_head = { BU_LIST_HEAD_MAGIC, &joint_head, &joint_head }; + struct bu_list hold_head = { BU_LIST_HEAD_MAGIC, &hold_head, &hold_head @@ -324,6 +333,7 @@ return (struct joint *) 0; } + static void free_arc(struct arc *ap) { @@ -343,6 +353,7 @@ ap->type=ARC_UNSET; } + static void free_joint(struct joint *jp) { @@ -352,6 +363,7 @@ BU_PUT(jp, struct joint); } + static void free_hold(struct hold *hp) { @@ -380,12 +392,14 @@ BU_PUT(hp, struct hold); } + static void hold_clear_flags(struct hold *hp) { hp->effector.flag = hp->objective.flag = 0; } + int f_Junload(struct ged *gedp, int argc, const char *argv[]) { @@ -431,6 +445,7 @@ return GED_OK; } + #define KEY_JOINT 1 #define KEY_CON 2 #define KEY_ARC 3 @@ -525,7 +540,7 @@ {SYM_EQ, "="}, {SYM_ARC, "/"}, {SYM_END, ";"}, - {SYM_COMMA, ","}, + {SYM_COMMA, ", "}, {SYM_MINUS, "-"}, {SYM_PLUS, "+"}, {0, 0}}; @@ -564,6 +579,7 @@ bu_free(text, "error pointer"); } + int get_token(struct ged *gedp, union bu_lex_token *token, FILE *fip, struct bu_vls *str, struct bu_lex_key *keys, struct bu_lex_key *syms) { @@ -610,6 +626,7 @@ return used; } + static int gobble_token(struct ged *gedp, int type_wanted, int value_wanted, FILE *fip, struct bu_vls *str) { @@ -654,6 +671,7 @@ return 0; } + static void skip_group(struct ged *gedp, FILE *fip, struct bu_vls *str) { @@ -686,6 +704,7 @@ } + static int parse_units(struct ged *gedp, FILE *fip, struct bu_vls *str) { @@ -797,6 +816,7 @@ return 1; } + static int parse_list(struct ged *gedp, struct arc *ap, FILE *fip, struct bu_vls *str) { @@ -835,7 +855,7 @@ } ap->arc[ap->arc_last] = token.t_id.value; if (get_token(gedp, &token, fip, str, (struct bu_lex_key *)NULL, animsyms) == EOF) { - parse_error(gedp, str, "parse_path: Unexpected EOF while getting ',' or ';'"); + parse_error(gedp, str, "parse_path: Unexpected EOF while getting ', ' or ';'"); free_arc(ap); return 0; } @@ -858,6 +878,7 @@ return 1; } + static int parse_ARC(struct ged *gedp, struct arc *ap, FILE *fip, struct bu_vls *str) { @@ -920,6 +941,7 @@ return 0; } + static int parse_double(struct ged *gedp, double *dbl, FILE *fip, struct bu_vls *str) { @@ -960,6 +982,7 @@ return 1; } + static int parse_assign(struct ged *gedp, double *dbl, FILE *fip, struct bu_vls *str) { @@ -978,6 +1001,7 @@ return 1; } + static int parse_vect(struct ged *gedp, fastf_t *vect, FILE *fip, struct bu_vls *str) { @@ -1005,6 +1029,7 @@ return 1; } + static int parse_trans(struct ged *gedp, struct joint *jp, int idx, FILE *fip, struct bu_vls *str) { @@ -1169,6 +1194,7 @@ return 0; } + static int parse_rots(struct ged *gedp, struct joint *jp, int idx, FILE *fip, struct bu_vls *str) { @@ -1331,6 +1357,7 @@ return 0; } + static int parse_joint(struct ged *gedp, FILE *fip, struct bu_vls *str) { @@ -1493,6 +1520,7 @@ /* NOTREACHED */ } + static int parse_jset(struct ged *gedp, struct hold *hp, FILE *fip, struct bu_vls *str) { @@ -1587,6 +1615,7 @@ } } + static int parse_solid(struct ged *gedp, struct hold_point *pp, FILE *fip, struct bu_vls *str) { @@ -1655,6 +1684,7 @@ } } + static int parse_point(struct ged *gedp, struct hold_point *pp, FILE *fip, struct bu_vls *str) { @@ -1701,6 +1731,7 @@ return 1; } + static int parse_hold(struct ged *gedp, FILE *fip, struct bu_vls *str) { @@ -1866,6 +1897,7 @@ /* NOTREACHED */ } + static struct bu_list path_head; int f_Jload(struct ged *gedp, int argc, const char *argv[]) @@ -2106,6 +2138,7 @@ return GED_OK; } + int f_Jaccept(struct ged *gedp, int argc, const char *argv[]) { @@ -2145,6 +2178,7 @@ return GED_OK; } + int f_Jreject(struct ged *gedp, int argc, const char *argv[]) { @@ -2186,6 +2220,7 @@ return GED_OK; } + static int hold_point_location(struct ged *gedp, fastf_t *loc, struct hold_point *hp) { @@ -2211,17 +2246,17 @@ MAT4X3PNT(loc, mat, hp->point); return 1; } - /* TODO - * there is a bug where f_jhold/f_jsolve is passing a hold struct - * with NULL fields when using MGED's "joint holds" or "joint solve" - * command. In particular, hp->path.fp_names can end up NULL, - * this prints an error message instead of crashing MGED. - */ - if (!hp->path.fp_names) { - bu_vls_printf(gedp->ged_result_str, "hold_point_location(): null pointer! '%s' not found!\n", - "hp->path.fp_names"); - return 0; - } + /* TODO + * there is a bug where f_jhold/f_jsolve is passing a hold struct + * with NULL fields when using MGED's "joint holds" or "joint solve" + * command. In particular, hp->path.fp_names can end up NULL, + * this prints an error message instead of crashing MGED. + */ + if (!hp->path.fp_names) { + bu_vls_printf(gedp->ged_result_str, "hold_point_location(): null pointer! '%s' not found!\n", + "hp->path.fp_names"); + return 0; + } if (rt_db_get_internal(&intern, hp->path.fp_names[hp->path.fp_maxlen-1], gedp->ged_wdbp->dbip, NULL, &rt_uniresource) < 0) return 0; @@ -2244,7 +2279,7 @@ jp = joint_lookup(hp->arc.arc[hp->arc.arc_last]); if (!jp) { bu_vls_printf(gedp->ged_result_str, "hold_eval: Lost joint! %s not found!\n", - hp->arc.arc[hp->arc.arc_last]); + hp->arc.arc[hp->arc.arc_last]); return 0; } VMOVE(hp->point, jp->location); @@ -2256,6 +2291,7 @@ return 1; /* For the picky compilers */ } + double hold_eval(struct ged *gedp, struct hold *hp) { @@ -2272,14 +2308,14 @@ if (!hold_point_location(gedp, e_loc, &hp->effector)) { if (joint_debug & DEBUG_J_EVAL) { bu_vls_printf(gedp->ged_result_str, "hold_eval: unable to find location of effector for %s.\n", - hp->name); + hp->name); } return 0.0; } if (!hold_point_location(gedp, o_loc, &hp->objective)) { if (joint_debug & DEBUG_J_EVAL) { bu_vls_printf(gedp->ged_result_str, "hold_eval: unable to find location of objective for %s.\n", - hp->name); + hp->name); } return 0.0; } @@ -2304,6 +2340,7 @@ &solve_head }; + void joint_clear(void) { @@ -2315,6 +2352,7 @@ } } + int part_solve(struct ged *gedp, struct hold *hp, double limits, double tol) { @@ -2358,17 +2396,17 @@ } for (i=0;i<hp->effector.path.fp_len; i++) { if (!BU_STR_EQUAL(jp->path.arc[0], - hp->effector.path.fp_names[i]->d_namep)==0) break; + hp->effector.path.fp_names[i]->d_namep)==0) break; } if (i+jp->path.arc_last >= hp->effector.path.fp_len) continue; for (j=1; j <= (size_t)jp->path.arc_last;j++) { if (!BU_STR_EQUAL(jp->path.arc[j], - hp->effector.path.fp_names[i+j]->d_namep) + hp->effector.path.fp_names[i+j]->d_namep) != 0) break; } if (j>(size_t)jp->path.arc_last) { if (joint_debug & DEBUG_J_SOLVE) { - bu_vls_printf(gedp->ged_result_str, "part_solve: found %s\n",jp->name); + bu_vls_printf(gedp->ged_result_str, "part_solve: found %s\n", jp->name); } BU_GET(jh, struct jointH); jh->l.magic = MAGIC_JOINT_HANDLE; @@ -2431,10 +2469,10 @@ #define R 0.61803399 #define C (1.0-R) /* - * find the min in the range ax-bx-cx where ax is - * bx-limits-0.001 or lower and cx = bx+limits+0.001 - * or upper. - */ + * find the min in the range ax-bx-cx where ax is + * bx-limits-0.001 or lower and cx = bx+limits+0.001 + * or upper. + */ ax=bx-limits-EPSI; if (ax < jp->rots[i].lower) ax=jp->rots[i].lower; cx=bx+limits+EPSI; @@ -2608,6 +2646,7 @@ return 1; } + void reject_move(struct ged *gedp) { @@ -2631,6 +2670,7 @@ BU_PUT(ssp, struct solve_stack); } + /* Constraint system solver. * * The basic idea is that we are called with some priority level. @@ -2711,7 +2751,7 @@ hp = (struct hold*)hp->l.forw; } } - Middle: +Middle: /* * now we find the constraint(s) we will be working with. */ @@ -2770,19 +2810,19 @@ i = (2<<6) - 1; /* Six degrees of freedom */ if (test_hold) { /* make sure we've got test_hold */ - for (BU_LIST_FOR(jh, jointH, &test_hold->j_head)) { - if (ssp->jp != jh->p) { + for (BU_LIST_FOR(jh, jointH, &test_hold->j_head)) { + if (ssp->jp != jh->p) { + i &= jh->flag; + continue; + } + jh->flag |= (1 << ssp->freedom); i &= jh->flag; - continue; } - jh->flag |= (1 << ssp->freedom); - i &= jh->flag; + if (i == ((2<<6)-1)) { + /* All joints, all freedoms */ + test_hold->flag |= HOLD_FLAG_TRIED; + } } - if (i == ((2<<6)-1)) { - /* All joints, all freedoms */ - test_hold->flag |= HOLD_FLAG_TRIED; - } - } reject_move(gedp); goto Middle; } @@ -2819,18 +2859,18 @@ } i = (2 << 6) - 1; if (test_hold) { /* again, make sure we've got test_hold */ - for (BU_LIST_FOR(jh, jointH, &test_hold->j_head)) { - if (ssp->jp != jh->p) { + for (BU_LIST_FOR(jh, jointH, &test_hold->j_head)) { + if (ssp->jp != jh->p) { + i &= jh->flag; + continue; + } + jh->flag |= (1 << ssp->freedom); i &= jh->flag; - continue; } - jh->flag |= (1 << ssp->freedom); - i &= jh->flag; + if (i == ((2<<6) - 1)) { + test_hold->flag |= HOLD_FLAG_TRIED; + } } - if (i == ((2<<6) - 1)) { - test_hold->flag |= HOLD_FLAG_TRIED; - } - } reject_move(gedp); if (joint_debug & DEBUG_J_SYSTEM) { bu_vls_printf(gedp->ged_result_str, "system_solve: returning -1\n"); @@ -2850,12 +2890,13 @@ return 1; } if (joint_debug & DEBUG_J_SYSTEM) { - bu_vls_trunc(gedp->ged_result_str, 0); - bu_vls_printf(gedp->ged_result_str, "0\n"); } + bu_vls_trunc(gedp->ged_result_str, 0); + bu_vls_printf(gedp->ged_result_str, "0\n"); } return 0; } + int f_Jsolve(struct ged *gedp, int argc, char *argv[]) { @@ -3043,6 +3084,7 @@ return GED_OK; } + static char * hold_point_to_string(struct ged *gedp, struct hold_point *hp) { @@ -3090,6 +3132,7 @@ } } + int f_Jhold(struct ged *gedp, int argc, const char *argv[]) { @@ -3110,6 +3153,7 @@ return GED_OK; } + int f_Jlist(struct ged *gedp, int UNUSED(argc), const char *UNUSED(argv[])) { @@ -3126,6 +3170,7 @@ return GED_OK; } + void joint_move(struct ged *gedp, struct joint *jp) { @@ -3200,9 +3245,9 @@ tmp*2*RAD2DEG, q1[X], q1[Y], q1[Z]); } {double srot = sin(tmp); - q1[X] *= srot; - q1[Y] *= srot; - q1[Z] *= srot; + q1[X] *= srot; + q1[Y] *= srot; + q1[Z] *= srot; } q1[W] = cos(tmp); @@ -3249,6 +3294,7 @@ } } + int f_Jmove(struct ged *gedp, int argc, const char *argv[]) { @@ -3388,7 +3434,7 @@ } if (best > 0) { if (joint_debug & DEBUG_J_MESH) { - bu_vls_printf(gedp->ged_result_str, "joint mesh: returning joint '%s'\n",bestjp->name); + bu_vls_printf(gedp->ged_result_str, "joint mesh: returning joint '%s'\n", bestjp->name); } return bestjp; } @@ -3399,6 +3445,7 @@ return (struct joint *) 0; } + HIDDEN union tree * mesh_leaf(struct db_tree_state *UNUSED(tsp), const struct db_full_path *pathp, struct rt_db_internal *ip, void *UNUSED(client_data)) { @@ -3502,6 +3549,7 @@ NULL /* ts_resp */ }; + /* * The cvt_vlblock_to_solids() function is not converted it, a bu_bomb() function call * it is used temporarily to return from the function. The name variable is commented @@ -3517,7 +3565,7 @@ f_Jmesh(struct ged *gedp, int UNUSED(argc), const char *UNUSED(argv[])) { /* name used for the cvt_vlblock_to_solids call - const char *name; */ + const char *name; */ struct bn_vlblock*vbp; struct bu_list *vhead; struct artic_joints *jp; @@ -3529,11 +3577,11 @@ if (gedp->ged_wdbp->dbip == DBI_NULL) return GED_OK; /* - if (argc <= 2) { - name = "_ANIM_"; - } else { - name = argv[2]; - }*/ + if (argc <= 2) { + name = "_ANIM_"; + } else { + name = argv[2]; + }*/ topc = ged_build_tops(gedp, topv, topv+2000); { @@ -3588,7 +3636,7 @@ } bu_bomb("cvt_vlblock_to_solids not converted yet\n"); - /* cvt_vlblock_to_solids(gedp,vbp, name, 0); */ + /* cvt_vlblock_to_solids(gedp, vbp, name, 0); */ rt_vlblock_free(vbp); while (BU_LIST_WHILE(jp, artic_joints, &artic_head)) { @@ -3602,6 +3650,7 @@ return GED_OK; } + /* * Local Variables: * mode: C Modified: brlcad/trunk/src/libged/joint.h =================================================================== --- brlcad/trunk/src/libged/joint.h 2014-07-14 15:19:36 UTC (rev 61690) +++ brlcad/trunk/src/libged/joint.h 2014-07-14 15:24:24 UTC (rev 61691) @@ -90,6 +90,7 @@ int org_last; }; + #define ARC_UNSET 0x0 #define ARC_PATH 0x1 #define ARC_ARC 0x2 @@ -195,6 +196,7 @@ int tcl_converted; }; + void vls_col_item(struct bu_vls *str, const char *cp); void vls_col_eol(struct bu_vls *str); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2014-07-14 17:32:04
|
Revision: 61707 http://sourceforge.net/p/brlcad/code/61707 Author: brlcad Date: 2014-07-14 17:32:00 +0000 (Mon, 14 Jul 2014) Log Message: ----------- most of the code using this passes a static string. the name field should be const. Modified Paths: -------------- brlcad/trunk/src/libged/draw.c brlcad/trunk/src/libged/ged_private.h Modified: brlcad/trunk/src/libged/draw.c =================================================================== --- brlcad/trunk/src/libged/draw.c 2014-07-14 17:31:25 UTC (rev 61706) +++ brlcad/trunk/src/libged/draw.c 2014-07-14 17:32:00 UTC (rev 61707) @@ -1082,11 +1082,11 @@ void -_ged_cvt_vlblock_to_solids(struct ged *gedp, struct bn_vlblock *vbp, char *name, int copy) +_ged_cvt_vlblock_to_solids(struct ged *gedp, struct bn_vlblock *vbp, const char *name, int copy) { size_t i; - char shortname[32]; - char namebuf[64]; + char shortname[32] = {0}; + char namebuf[64] = {0}; bu_strlcpy(shortname, name, sizeof(shortname)); Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2014-07-14 17:31:25 UTC (rev 61706) +++ brlcad/trunk/src/libged/ged_private.h 2014-07-14 17:32:00 UTC (rev 61707) @@ -152,7 +152,7 @@ /* defined in draw.c */ extern void _ged_cvt_vlblock_to_solids(struct ged *gedp, struct bn_vlblock *vbp, - char *name, + const char *name, int copy); extern int _ged_invent_solid(struct ged *gedp, char *name, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2014-07-16 14:10:07
|
Revision: 61773 http://sourceforge.net/p/brlcad/code/61773 Author: brlcad Date: 2014-07-16 14:09:59 +0000 (Wed, 16 Jul 2014) Log Message: ----------- ws indent Modified Paths: -------------- brlcad/trunk/src/libged/analyze.c brlcad/trunk/src/libged/coil.c brlcad/trunk/src/libged/comb.c brlcad/trunk/src/libged/ged_private.h brlcad/trunk/src/libged/joint.c brlcad/trunk/src/libged/ls.c brlcad/trunk/src/libged/open.c brlcad/trunk/src/libged/pull.c brlcad/trunk/src/libged/tire.c brlcad/trunk/src/libged/wdb_obj.c Modified: brlcad/trunk/src/libged/analyze.c =================================================================== --- brlcad/trunk/src/libged/analyze.c 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/analyze.c 2014-07-16 14:09:59 UTC (rev 61773) @@ -638,7 +638,7 @@ } if (OBJ[ip->idb_minor_type].ft_centroid) { - OBJ[ip->idb_minor_type].ft_centroid(¢roid, ip); + OBJ[ip->idb_minor_type].ft_centroid(¢roid, ip); bu_vls_printf(gedp->ged_result_str, "\n Centroid: (%g, %g, %g)\n", centroid[X] * gedp->ged_wdbp->dbip->dbi_base2local, centroid[Y] * gedp->ged_wdbp->dbip->dbi_base2local, @@ -916,7 +916,7 @@ /* allocate array of pt structs, max number of verts per faces = (# of faces) - 1 */ faces[i].pts = (point_t *)bu_calloc(aip->neqn - 1, sizeof(point_t), "analyze_arbn: pts"); tmp_pts[i] = faces[i].pts; - HMOVE(eqs[i], faces[i].plane_eqn); + HMOVE(eqs[i], faces[i].plane_eqn); } /* allocate table rows, 1 row per plane eqn */ table.rows = (row_t *)bu_calloc(aip->neqn, sizeof(row_t), "analyze_arbn: rows"); Modified: brlcad/trunk/src/libged/coil.c =================================================================== --- brlcad/trunk/src/libged/coil.c 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/coil.c 2014-07-16 14:09:59 UTC (rev 61773) @@ -391,7 +391,7 @@ break; default: usage(gedp); - return GED_ERROR; + return GED_ERROR; } } if (argc == 1) { Modified: brlcad/trunk/src/libged/comb.c =================================================================== --- brlcad/trunk/src/libged/comb.c 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/comb.c 2014-07-16 14:09:59 UTC (rev 61773) @@ -429,7 +429,7 @@ bu_ptbl_init(&stack, 64, "comb mvall working stack"); (void)db_search(&combs_in_tree, DB_SEARCH_RETURN_UNIQ_DP, combs_in_tree_plan, 1, &dp, gedp->ged_wdbp->dbip); - bu_ptbl_ins(&combs_in_tree, (long *)dp); + bu_ptbl_ins(&combs_in_tree, (long *)dp); for (BU_PTBL_FOR(dp_curr, (struct directory **), ®ions_to_wrap)) { if ((*dp_curr) != dp) { struct directory **dp_comb_from_tree; @@ -510,13 +510,13 @@ bu_optind = 1; /* Grab any arguments off of the argv list */ while ((c = bu_getopt(argc, (char **)argv, "crwflS")) != -1) { - switch (c) { - case 'c' : - set_comb = 1; - break; - case 'r' : - set_region = 1; - break; + switch (c) { + case 'c' : + set_comb = 1; + break; + case 'r' : + set_region = 1; + break; case 'w' : wrap_comb = 1; standard_comb_build = 0; @@ -529,12 +529,12 @@ lift_region_comb = 1; standard_comb_build = 0; break; - case 'S' : + case 'S' : alter_existing = 0; break; default : - break; - } + break; + } } argc -= bu_optind - 1; @@ -565,10 +565,10 @@ bu_vls_printf(gedp->ged_result_str, "ERROR: %s is not a combination", comb_name); return GED_ERROR; } - if (!alter_existing) { + if (!alter_existing) { bu_vls_printf(gedp->ged_result_str, "ERROR: %s already exists.", comb_name); return GED_ERROR; - } + } } /* If we aren't performing one of the option operations, Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/ged_private.h 2014-07-16 14:09:59 UTC (rev 61773) @@ -467,7 +467,7 @@ * the real definition of the struct goes here. The public * header has only the notion of a ged_results structure.*/ struct ged_results { - struct bu_ptbl *results_tbl; + struct bu_ptbl *results_tbl; }; /* defined in ged_util.c */ Modified: brlcad/trunk/src/libged/joint.c =================================================================== --- brlcad/trunk/src/libged/joint.c 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/joint.c 2014-07-16 14:09:59 UTC (rev 61773) @@ -3108,7 +3108,8 @@ ssp = (struct solve_stack *) solve_head.forw; i = (2<<6) - 1; /* Six degrees of freedom */ - if (test_hold) { /* make sure we've got test_hold */ + if (test_hold) { + /* make sure we've got test_hold */ for (BU_LIST_FOR(jh, jointH, &test_hold->j_head)) { if (ssp->jp != jh->p) { i &= jh->flag; @@ -3161,7 +3162,8 @@ reject_move(gedp); } i = (2 << 6) - 1; - if (test_hold) { /* again, make sure we've got test_hold */ + if (test_hold) { + /* again, make sure we've got test_hold */ for (BU_LIST_FOR(jh, jointH, &test_hold->j_head)) { if (ssp->jp != jh->p) { i &= jh->flag; Modified: brlcad/trunk/src/libged/ls.c =================================================================== --- brlcad/trunk/src/libged/ls.c 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/ls.c 2014-07-16 14:09:59 UTC (rev 61773) @@ -491,7 +491,7 @@ vls_line_dpp(gedp, dirp0, (int)(dirp - dirp0), aflag, cflag, rflag, sflag); else { _ged_vls_col_pr4v(gedp->ged_result_str, dirp0, (int)(dirp - dirp0), 0); - _ged_results_add(gedp->ged_results, bu_vls_addr(gedp->ged_result_str)); + _ged_results_add(gedp->ged_results, bu_vls_addr(gedp->ged_result_str)); } bu_free((void *)dirp0, "_ged_getspace dp[]"); Modified: brlcad/trunk/src/libged/open.c =================================================================== --- brlcad/trunk/src/libged/open.c 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/open.c 2014-07-16 14:09:59 UTC (rev 61773) @@ -56,7 +56,7 @@ char *av[2]; struct db_i *old_dbip = gedp->ged_wdbp->dbip; struct mater *old_materp = rt_material_head(); - struct mater *new_materp; + struct mater *new_materp; rt_new_material_head(MATER_NULL); @@ -71,7 +71,7 @@ new_materp = rt_material_head(); gedp->ged_wdbp->dbip = old_dbip; - rt_new_material_head(old_materp); + rt_new_material_head(old_materp); av[0] = "zap"; av[1] = (char *)0; Modified: brlcad/trunk/src/libged/pull.c =================================================================== --- brlcad/trunk/src/libged/pull.c 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/pull.c 2014-07-16 14:09:59 UTC (rev 61773) @@ -37,7 +37,6 @@ #include "./ged_private.h" - void pull_comb(struct db_i *dbip, struct directory *dp, @@ -178,14 +177,14 @@ if (mat == NULL) { mat = (matp_t)bu_malloc(sizeof(mat_t), "cur_mat"); - MAT_IDN(mat); + MAT_IDN(mat); } if (!(dp->d_flags & RT_DIR_SOLID)) - return; + return; if (rt_db_get_internal(&intern, dp, dbip, mat, &rt_uniresource) < 0) { - bu_vls_printf((struct bu_vls *)mp, "Database read error, aborting\n"); - return; + bu_vls_printf((struct bu_vls *)mp, "Database read error, aborting\n"); + return; } MAT_IDN(mat); Modified: brlcad/trunk/src/libged/tire.c =================================================================== --- brlcad/trunk/src/libged/tire.c 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/tire.c 2014-07-16 14:09:59 UTC (rev 61773) @@ -1863,8 +1863,8 @@ bu_opterr = 1; while ((c=bu_getopt(argc, (char * const *)argv, options)) != -1) { - if (bu_optopt == '?') - c='h'; + if (bu_optopt == '?') + c='h'; switch (c) { case 'a' : *gen_name = 1; @@ -1930,7 +1930,7 @@ show_help(gedp, argv[0]); if (c=='h') return GED_HELP; - return GED_ERROR; + return GED_ERROR; } } @@ -2021,7 +2021,7 @@ if (gen_name == 1) { if (bu_vls_strlen(&name) == 0) bu_vls_printf(&name,"tire-%d-%dR%d", (int)isoarray[0], (int)isoarray[1], (int)isoarray[2]); - else + else bu_vls_printf(&name, "-%d-%dR%d", (int)isoarray[0], (int)isoarray[1], (int)isoarray[2]); } Modified: brlcad/trunk/src/libged/wdb_obj.c =================================================================== --- brlcad/trunk/src/libged/wdb_obj.c 2014-07-16 14:06:21 UTC (rev 61772) +++ brlcad/trunk/src/libged/wdb_obj.c 2014-07-16 14:09:59 UTC (rev 61773) @@ -6674,8 +6674,8 @@ */ int wdb_pull_tcl(void *clientData, - int argc, - const char *argv[]) + int argc, + const char *argv[]) { struct rt_wdb *wdbp = (struct rt_wdb *)clientData; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2014-09-18 19:59:49
|
Revision: 62842 http://sourceforge.net/p/brlcad/code/62842 Author: brlcad Date: 2014-09-18 19:59:43 +0000 (Thu, 18 Sep 2014) Log Message: ----------- more consistent op handling propagation for red and combmem. Modified Paths: -------------- brlcad/trunk/src/libged/combmem.c brlcad/trunk/src/libged/red.c Modified: brlcad/trunk/src/libged/combmem.c =================================================================== --- brlcad/trunk/src/libged/combmem.c 2014-09-18 19:57:59 UTC (rev 62841) +++ brlcad/trunk/src/libged/combmem.c 2014-09-18 19:59:43 UTC (rev 62842) @@ -435,21 +435,21 @@ } -#define COMBMEM_SET_PART_II(_gedp, _argv, _i, _rt_tree_array, _tree_index, _mat) { \ - db_op_t combmem_set_part_ii_op = db_str2op((_argv)[(_i)]); \ +#define COMBMEM_SET_PART_II(_gedp, _opstr, _rt_tree_array_index, _mat) { \ + db_op_t combmem_set_part_ii_op = db_str2op((_opstr)); \ \ /* Add it to the combination */ \ switch (combmem_set_part_ii_op) { \ case DB_OP_INTERSECT: \ - (_rt_tree_array)[(_tree_index)].tl_op = OP_INTERSECT; \ + (_rt_tree_array_index).tl_op = OP_INTERSECT; \ break; \ case DB_OP_SUBTRACT: \ - (_rt_tree_array)[(_tree_index)].tl_op = OP_SUBTRACT; \ + (_rt_tree_array_index).tl_op = OP_SUBTRACT; \ break; \ default: \ - bu_vls_printf((_gedp)->ged_result_str, "combmem_set: unrecognized relation %c (assuming UNION)\n", (_argv)[(_i)][0]); \ + bu_vls_printf((_gedp)->ged_result_str, "combmem_set: unrecognized relation %c (assuming UNION)\n", (_opstr)[0]); \ case DB_OP_UNION: \ - (_rt_tree_array)[(_tree_index)].tl_op = OP_UNION; \ + (_rt_tree_array_index).tl_op = OP_UNION; \ break; \ } \ \ @@ -457,8 +457,8 @@ } -#define COMBMEM_SET_PART_III(_tp, _tree, _rt_tree_array, _tree_index, _name) \ - (_rt_tree_array)[(_tree_index)].tl_tree = (_tp); \ +#define COMBMEM_SET_PART_III(_tp, _tree, _rt_tree_array_index, _name) \ + (_rt_tree_array_index).tl_tree = (_tp); \ (_tp)->tr_l.tl_op = OP_DB_LEAF; \ (_tp)->tr_l.tl_name = bu_strdup(_name); \ (_tp)->tr_l.tl_mat = (matp_t)bu_calloc(1, sizeof(mat_t), "combmem_set: mat"); @@ -559,7 +559,7 @@ vect_t aetvec = VINIT_ZERO; vect_t tvec = VINIT_ZERO; - COMBMEM_SET_PART_II(gedp, argv, i, rt_tree_array, tree_index, mat); + COMBMEM_SET_PART_II(gedp, argv[i], rt_tree_array[tree_index], mat); if (sscanf(argv[i+2], "%lf", &az) == 1 && sscanf(argv[i+3], "%lf", &el) == 1 && @@ -595,7 +595,7 @@ BU_ALLOC(tp, union tree); RT_TREE_INIT(tp); - COMBMEM_SET_PART_III(tp, tree, rt_tree_array, tree_index, argv[i+1]); + COMBMEM_SET_PART_III(tp, tree, rt_tree_array[tree_index], argv[i+1]); if (etype == ETYPES_REL && tree_index < old_node_count @@ -656,7 +656,7 @@ double kx, ky, kz; point_t key_pt = VINIT_ZERO; - COMBMEM_SET_PART_II(gedp, argv, i, rt_tree_array, tree_index, mat); + COMBMEM_SET_PART_II(gedp, argv[i], rt_tree_array[tree_index], mat); if (sscanf(argv[i+2], "%lf", &az) == 1 && sscanf(argv[i+3], "%lf", &el) == 1 && @@ -683,7 +683,7 @@ BU_ALLOC(tp, union tree); RT_TREE_INIT(tp); - COMBMEM_SET_PART_III(tp, tree, rt_tree_array, tree_index, argv[i+1]); + COMBMEM_SET_PART_III(tp, tree, rt_tree_array[tree_index], argv[i+1]); if (tree_index < old_node_count && old_rt_tree_array[tree_index].tl_tree->tr_l.tl_mat @@ -743,7 +743,7 @@ vect_t dir; point_t pt; - COMBMEM_SET_PART_II(gedp, argv, i, rt_tree_array, tree_index, mat); + COMBMEM_SET_PART_II(gedp, argv[i], rt_tree_array[tree_index], mat); if (sscanf(argv[i+2], "%lf", &px) == 1 && sscanf(argv[i+3], "%lf", &py) == 1 && @@ -763,7 +763,7 @@ BU_ALLOC(tp, union tree); RT_TREE_INIT(tp); - COMBMEM_SET_PART_III(tp, tree, rt_tree_array, tree_index, argv[i+1]); + COMBMEM_SET_PART_III(tp, tree, rt_tree_array[tree_index], argv[i+1]); if (tree_index < old_node_count && old_rt_tree_array[tree_index].tl_tree->tr_l.tl_mat && BU_STR_EQUAL(old_rt_tree_array[tree_index].tl_tree->tr_l.tl_name, tp->tr_l.tl_name)) { @@ -819,7 +819,7 @@ double tx, ty, tz; vect_t tvec = VINIT_ZERO; - COMBMEM_SET_PART_II(gedp, argv, i, rt_tree_array, tree_index, mat); + COMBMEM_SET_PART_II(gedp, argv[i], rt_tree_array[tree_index], mat); if (sscanf(argv[i+2], "%lf", &tx) == 1 && sscanf(argv[i+3], "%lf", &ty) == 1 && @@ -832,7 +832,7 @@ BU_ALLOC(tp, union tree); RT_TREE_INIT(tp); - COMBMEM_SET_PART_III(tp, tree, rt_tree_array, tree_index, argv[i+1]); + COMBMEM_SET_PART_III(tp, tree, rt_tree_array[tree_index], argv[i+1]); if (tree_index < old_node_count && old_rt_tree_array[tree_index].tl_tree->tr_l.tl_mat && BU_STR_EQUAL(old_rt_tree_array[tree_index].tl_tree->tr_l.tl_name, tp->tr_l.tl_name)) { @@ -887,7 +887,7 @@ HSETALL(svec, 0); - COMBMEM_SET_PART_II(gedp, argv, i, rt_tree_array, tree_index, mat); + COMBMEM_SET_PART_II(gedp, argv[i], rt_tree_array[tree_index], mat); if (sscanf(argv[i+2], "%lf", &sa) == 1 && sscanf(argv[i+3], "%lf", &sx) == 1 && @@ -908,7 +908,7 @@ BU_ALLOC(tp, union tree); RT_TREE_INIT(tp); - COMBMEM_SET_PART_III(tp, tree, rt_tree_array, tree_index, argv[i+1]); + COMBMEM_SET_PART_III(tp, tree, rt_tree_array[tree_index], argv[i+1]); if (tree_index < old_node_count && old_rt_tree_array[tree_index].tl_tree->tr_l.tl_mat Modified: brlcad/trunk/src/libged/red.c =================================================================== --- brlcad/trunk/src/libged/red.c 2014-09-18 19:57:59 UTC (rev 62841) +++ brlcad/trunk/src/libged/red.c 2014-09-18 19:59:43 UTC (rev 62842) @@ -404,6 +404,8 @@ rt_tree_array = (struct rt_tree_array *)bu_calloc(node_count, sizeof(struct rt_tree_array), "tree list"); /* As long as we have operators ahead of us in the tree, we have comb entries to handle */ while (ret == 0) { + db_op_t op; + ret = regexec(&combtree_op_regex, currptr, combtree_op_regex.re_nsub , result_locations, 0); bu_vls_sprintf(&curr_op_vls, "%s", bu_vls_addr(&next_op_vls)); if (ret == 0) { @@ -460,21 +462,22 @@ if (bu_vls_addr(&curr_op_vls)[0] != '-') nonsubs++; + op = db_str2op(bu_vls_addr(&curr_op_vls)); + /* Add it to the combination */ - switch (bu_vls_addr(&curr_op_vls)[0]) { + switch (op) { case DB_OP_INTERSECT: rt_tree_array[tree_index].tl_op = OP_INTERSECT; break; case DB_OP_SUBTRACT: rt_tree_array[tree_index].tl_op = OP_SUBTRACT; break; + default: + bu_vls_printf(gedp->ged_result_str, "build_comb: unrecognized relation %c (assume UNION)\n", bu_vls_addr(&curr_op_vls)[0]); + /* fall through */ case DB_OP_UNION: rt_tree_array[tree_index].tl_op = OP_UNION; break; - default: - bu_vls_printf(gedp->ged_result_str, - "build_comb: unrecognized relation (assume UNION)\n"); - rt_tree_array[tree_index].tl_op = OP_UNION; } BU_ALLOC(tp, union tree); RT_TREE_INIT(tp); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <n_...@us...> - 2014-12-09 22:02:12
|
Revision: 63647 http://sourceforge.net/p/brlcad/code/63647 Author: n_reed Date: 2014-12-09 22:02:09 +0000 (Tue, 09 Dec 2014) Log Message: ----------- make selection of the draw shading mode more readable Modified Paths: -------------- brlcad/trunk/src/libged/draw.c brlcad/trunk/src/libged/ged_private.h Modified: brlcad/trunk/src/libged/draw.c =================================================================== --- brlcad/trunk/src/libged/draw.c 2014-12-09 21:45:48 UTC (rev 63646) +++ brlcad/trunk/src/libged/draw.c 2014-12-09 22:02:09 UTC (rev 63647) @@ -72,10 +72,6 @@ RT_GET_TREE(curtree, tsp->ts_resp); curtree->tr_op = OP_NOP; - /* - * Use gedp->ged_gdp->gd_shaded_mode if set and not being overridden. Otherwise use dgcdp->shaded_mode_override. - */ - switch (dgcdp->dmode) { case _GED_SHADED_MODE_BOTS: if (ip->idb_major_type == DB5_MAJORTYPE_BRLCAD && @@ -110,7 +106,7 @@ /* turn shaded mode off for this non-bot/non-poly object */ dgcdp->gedp->ged_gdp->gd_shaded_mode = 0; - dgcdp->shaded_mode_override = -1; + dgcdp->shaded_mode_override = _GED_SHADED_MODE_UNSET; dgcdp->dmode = _GED_WIREFRAME; _ged_drawtrees(dgcdp->gedp, ac, av, 1, (struct _ged_client_data *)client_data); @@ -156,7 +152,7 @@ /* turn shaded mode off for this pipe object */ dgcdp->gedp->ged_gdp->gd_shaded_mode = 0; - dgcdp->shaded_mode_override = -1; + dgcdp->shaded_mode_override = _GED_SHADED_MODE_UNSET; dgcdp->dmode = _GED_WIREFRAME; _ged_drawtrees(dgcdp->gedp, ac, av, 1, (struct _ged_client_data *)client_data); @@ -563,6 +559,7 @@ dgcdp.draw_edge_uses = 0; dgcdp.wireframe_color_override = 0; dgcdp.fastpath_count = 0; + dgcdp.shaded_mode_override = _GED_SHADED_MODE_UNSET; /* default color - red */ dgcdp.wireframe_color[0] = 255; @@ -572,10 +569,6 @@ /* default transparency - opaque */ dgcdp.transparency = 1.0; - /* -1 indicates flag not set */ - dgcdp.shaded_mode_override = -1; - - /* freesolid */ dgcdp.freesolid = gedp->freesolid; @@ -649,11 +642,25 @@ dgcdp.shaded_mode_override = _GED_SHADED_MODE_ALL; break; case 'm': - /* clamp it to [-infinity, 2] */ dgcdp.shaded_mode_override = atoi(bu_optarg); - if (2 < dgcdp.shaded_mode_override) - dgcdp.shaded_mode_override = 2; + switch (dgcdp.shaded_mode_override) { + case 0: + dgcdp.shaded_mode_override = _GED_WIREFRAME; + break; + case 1: + dgcdp.shaded_mode_override = _GED_SHADED_MODE_BOTS; + break; + case 2: + dgcdp.shaded_mode_override = _GED_SHADED_MODE_ALL; + break; + default: + if (dgcdp.shaded_mode_override < 0) { + dgcdp.shaded_mode_override = _GED_SHADED_MODE_UNSET; + } else { + dgcdp.shaded_mode_override = _GED_SHADED_MODE_ALL; + } + } break; case 'x': dgcdp.transparency = atof(bu_optarg); @@ -686,13 +693,12 @@ switch (kind) { case 1: - if (gedp->ged_gdp->gd_shaded_mode && dgcdp.shaded_mode_override < 0) { - dgcdp.dmode = gedp->ged_gdp->gd_shaded_mode; - } else if (0 <= dgcdp.shaded_mode_override) + dgcdp.dmode = _GED_WIREFRAME; + if (dgcdp.shaded_mode_override != _GED_SHADED_MODE_UNSET) { dgcdp.dmode = dgcdp.shaded_mode_override; - else - dgcdp.dmode = _GED_WIREFRAME; - + } else if (gedp->ged_gdp->gd_shaded_mode) { + dgcdp.dmode = gedp->ged_gdp->gd_shaded_mode; + } break; case 2: case 3: @@ -725,7 +731,9 @@ * If shaded_mode is _GED_SHADED_MODE_ALL, everything except pipe solids * are drawn as shaded polygons. */ - if (_GED_SHADED_MODE_BOTS <= dgcdp.dmode && dgcdp.dmode <= _GED_SHADED_MODE_ALL) { + if (dgcdp.dmode == _GED_SHADED_MODE_BOTS || + dgcdp.dmode == _GED_SHADED_MODE_ALL) + { for (i = 0; i < argc; ++i) { if (drawtrees_depth == 1) dgcdp.gdlp = dl_addToDisplay(gedp->ged_gdp->gd_headDisplay, gedp->ged_wdbp->dbip, argv[i]); Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2014-12-09 21:45:48 UTC (rev 63646) +++ brlcad/trunk/src/libged/ged_private.h 2014-12-09 22:02:09 UTC (rev 63647) @@ -54,11 +54,12 @@ #define _GED_LISTEVAL 2 #define _GED_EVAL_ONLY 3 -#define _GED_WIREFRAME 0 -#define _GED_SHADED_MODE_BOTS 1 -#define _GED_SHADED_MODE_ALL 2 -#define _GED_BOOL_EVAL 3 -#define _GED_HIDDEN_LINE 4 +#define _GED_SHADED_MODE_UNSET -1 +#define _GED_WIREFRAME 0 +#define _GED_SHADED_MODE_BOTS 1 +#define _GED_SHADED_MODE_ALL 2 +#define _GED_BOOL_EVAL 3 +#define _GED_HIDDEN_LINE 4 #define _GED_TREE_AFLAG 0x01 #define _GED_TREE_CFLAG 0x02 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <n_...@us...> - 2014-12-09 22:36:18
|
Revision: 63649 http://sourceforge.net/p/brlcad/code/63649 Author: n_reed Date: 2014-12-09 22:36:09 +0000 (Tue, 09 Dec 2014) Log Message: ----------- Name the draw 'kind' constants for readability. Neither private function with a kind parameter is called with kind == 2 (Big-E), so remove checks for it. Modified Paths: -------------- brlcad/trunk/src/libged/draw.c brlcad/trunk/src/libged/ged_private.h Modified: brlcad/trunk/src/libged/draw.c =================================================================== --- brlcad/trunk/src/libged/draw.c 2014-12-09 22:06:57 UTC (rev 63648) +++ brlcad/trunk/src/libged/draw.c 2014-12-09 22:36:09 UTC (rev 63649) @@ -109,7 +109,8 @@ dgcdp->shaded_mode_override = _GED_SHADED_MODE_UNSET; dgcdp->dmode = _GED_WIREFRAME; - _ged_drawtrees(dgcdp->gedp, ac, av, 1, (struct _ged_client_data *)client_data); + _ged_drawtrees(dgcdp->gedp, ac, av, _GED_DRAW_WIREFRAME, + (struct _ged_client_data *)client_data); /* restore shaded mode states */ dgcdp->gedp->ged_gdp->gd_shaded_mode = save_shaded_mode; @@ -143,7 +144,9 @@ (void)rt_pg_plot_poly(&vhead, ip, tsp->ts_ttol, tsp->ts_tol); _ged_drawH_part2(0, &vhead, pathp, tsp, dgcdp); } else - _ged_drawtrees(dgcdp->gedp, ac, av, 3, (struct _ged_client_data *)client_data); + _ged_drawtrees(dgcdp->gedp, ac, av, + _GED_DRAW_NMG_POLY, + (struct _ged_client_data *)client_data); } else { /* save shaded mode states */ int save_shaded_mode = dgcdp->gedp->ged_gdp->gd_shaded_mode; @@ -155,7 +158,8 @@ dgcdp->shaded_mode_override = _GED_SHADED_MODE_UNSET; dgcdp->dmode = _GED_WIREFRAME; - _ged_drawtrees(dgcdp->gedp, ac, av, 1, (struct _ged_client_data *)client_data); + _ged_drawtrees(dgcdp->gedp, ac, av, _GED_DRAW_WIREFRAME, + (struct _ged_client_data *)client_data); /* restore shaded mode states */ dgcdp->gedp->ged_gdp->gd_shaded_mode = save_shaded_mode; @@ -502,11 +506,6 @@ * Add a set of tree hierarchies to the active set. * Note that argv[0] should be ignored, it has the command name in it. * - * Kind = - * 1 regular wireframes - * 2 big-E - * 3 NMG polygons - * * Returns - * 0 Ordinarily * -1 On major error @@ -692,7 +691,7 @@ argv += bu_optind; switch (kind) { - case 1: + case _GED_DRAW_WIREFRAME: dgcdp.dmode = _GED_WIREFRAME; if (dgcdp.shaded_mode_override != _GED_SHADED_MODE_UNSET) { dgcdp.dmode = dgcdp.shaded_mode_override; @@ -700,8 +699,7 @@ dgcdp.dmode = gedp->ged_gdp->gd_shaded_mode; } break; - case 2: - case 3: + case _GED_DRAW_NMG_POLY: dgcdp.dmode = _GED_BOOL_EVAL; break; } @@ -719,7 +717,7 @@ bu_vls_printf(gedp->ged_result_str, "ERROR, bad kind\n"); --drawtrees_depth; return -1; - case 1: /* Wireframes */ + case _GED_DRAW_WIREFRAME: /* * If asking for wireframe and in shaded_mode and no shaded mode override, * or asking for wireframe and shaded mode is being overridden with a value @@ -825,13 +823,8 @@ bu_free(paths_to_draw, "draw paths"); } break; - case 2: /* Big-E */ - bu_vls_printf(gedp->ged_result_str, "drawtrees: can't do big-E here\n"); - --drawtrees_depth; - return -1; - case 3: + case _GED_DRAW_NMG_POLY: { - /* NMG */ nmg_model = nmg_mm(); gedp->ged_wdbp->wdb_initial_tree_state.ts_m = &nmg_model; if (dgcdp.draw_edge_uses) { @@ -1130,14 +1123,14 @@ int ged_draw(struct ged *gedp, int argc, const char *argv[]) { - return ged_draw_guts(gedp, argc, argv, 1); + return ged_draw_guts(gedp, argc, argv, _GED_DRAW_WIREFRAME); } int ged_ev(struct ged *gedp, int argc, const char *argv[]) { - return ged_draw_guts(gedp, argc, argv, 3); + return ged_draw_guts(gedp, argc, argv, _GED_DRAW_NMG_POLY); } int Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2014-12-09 22:06:57 UTC (rev 63648) +++ brlcad/trunk/src/libged/ged_private.h 2014-12-09 22:36:09 UTC (rev 63649) @@ -61,6 +61,9 @@ #define _GED_BOOL_EVAL 3 #define _GED_HIDDEN_LINE 4 +#define _GED_DRAW_WIREFRAME 1 +#define _GED_DRAW_NMG_POLY 3 + #define _GED_TREE_AFLAG 0x01 #define _GED_TREE_CFLAG 0x02 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <n_...@us...> - 2014-12-10 21:07:56
|
Revision: 63665 http://sourceforge.net/p/brlcad/code/63665 Author: n_reed Date: 2014-12-10 21:07:53 +0000 (Wed, 10 Dec 2014) Log Message: ----------- Add an evaluated shaded draw mode (draw -m3 ...) that draws the poly plots of the draw paths after temporary conversion to evaluated breps. Modified Paths: -------------- brlcad/trunk/src/libged/draw.c brlcad/trunk/src/libged/ged_private.h Modified: brlcad/trunk/src/libged/draw.c =================================================================== --- brlcad/trunk/src/libged/draw.c 2014-12-10 20:37:08 UTC (rev 63664) +++ brlcad/trunk/src/libged/draw.c 2014-12-10 21:07:53 UTC (rev 63665) @@ -171,7 +171,95 @@ } } +static int +get_path_and_state( + struct db_tree_state *tsp, + struct db_full_path *pathp, + const char *path_name, + struct ged *gedp) +{ + *tsp = gedp->ged_wdbp->wdb_initial_tree_state; + tsp->ts_dbip = gedp->ged_wdbp->dbip; + tsp->ts_resp = &rt_uniresource; + return db_follow_path_for_state(tsp, pathp, path_name, LOOKUP_QUIET); +} + +static int +plot_shaded_eval( + struct ged *gedp, + const char *path_name, + struct _ged_client_data *dgcdp) +{ + int ret; + const char *av[3]; + const char *tmp_basename = "tmp_shaded_eval_obj"; + char *brep_name; + + /* make a name for the temp brep */ + av[0] = "make_name"; + av[1] = tmp_basename; + + ged_make_name(gedp, 2, (const char **)av); + + brep_name = bu_vls_strdup(gedp->ged_result_str); + bu_vls_trunc(gedp->ged_result_str, 0); + + /* create temp evaluated brep from named object */ + av[0] = "brep"; + av[1] = path_name; + av[2] = brep_name; + ret = ged_brep(gedp, 3, av); + + if (ret == GED_OK) { + int brep_made = 0; + struct db_tree_state ts; + struct rt_db_internal brep_intern; + struct db_full_path input_path, brep_path; + + RT_DB_INTERNAL_INIT(&brep_intern); + db_full_path_init(&input_path); + db_full_path_init(&brep_path); + + /* get brep internal */ + ret = get_path_and_state(&ts, &brep_path, brep_name, gedp); + if (ret == GED_OK) { + struct directory *dp = DB_FULL_PATH_CUR_DIR(&brep_path); + + if (dp->d_flags & RT_DIR_COMB) { + ret = rt_db_get_internal(&brep_intern, dp, ts.ts_dbip, NULL, + ts.ts_resp); + } else { + ret = rt_db_get_internal(&brep_intern, dp, ts.ts_dbip, ts.ts_mat, + ts.ts_resp); + } + if (ret >= 0) { + brep_made = 1; + } + db_free_full_path(&brep_path); + } + + /* plot brep, but use the path and state of the input object */ + if (brep_made) { + ret = get_path_and_state(&ts, &input_path, path_name, gedp); + if (ret == GED_OK) { + plot_shaded(&ts, &input_path, &brep_intern, dgcdp); + + rt_db_free_internal(&brep_intern); + db_free_full_path(&input_path); + } + } + + /* kill temp brep */ + av[0] = "kill"; + av[1] = brep_name; + ged_kill(gedp, 2, av); + } + bu_free((char *)brep_name, "vls_strdup"); + + return ret; +} + static union tree * wireframe_region_end(struct db_tree_state *tsp, const struct db_full_path *pathp, union tree *curtree, void *UNUSED(client_data)) { @@ -501,7 +589,7 @@ struct _ged_client_data dgcdp; int i; int ac = 1; - char *av[2]; + char *av[3]; RT_CHECK_DBI(gedp->ged_wdbp->dbip); @@ -632,6 +720,9 @@ case 2: dgcdp.shaded_mode_override = _GED_SHADED_MODE_ALL; break; + case 3: + dgcdp.shaded_mode_override = _GED_SHADED_MODE_EVAL; + break; default: if (dgcdp.shaded_mode_override < 0) { dgcdp.shaded_mode_override = _GED_SHADED_MODE_UNSET; @@ -709,8 +800,11 @@ * are drawn as shaded polygons. */ if (dgcdp.dmode == _GED_SHADED_MODE_BOTS || - dgcdp.dmode == _GED_SHADED_MODE_ALL) + dgcdp.dmode == _GED_SHADED_MODE_ALL || + dgcdp.dmode == _GED_SHADED_MODE_EVAL) { + struct _ged_client_data dgcdp_save; + for (i = 0; i < argc; ++i) { if (drawtrees_depth == 1) dgcdp.gdlp = dl_addToDisplay(gedp->ged_gdp->gd_headDisplay, gedp->ged_wdbp->dbip, argv[i]); @@ -718,6 +812,19 @@ if (dgcdp.gdlp == GED_DISPLAY_LIST_NULL) continue; + dgcdp_save = dgcdp; + + if (dgcdp.dmode == _GED_SHADED_MODE_EVAL) { + ret = plot_shaded_eval(gedp, argv[i], &dgcdp); + if (ret == GED_OK) { + continue; + } + /* if evaluated shading failed, fall back to "all" mode */ + dgcdp.gedp->ged_gdp->gd_shaded_mode = 0; + dgcdp.shaded_mode_override = _GED_SHADED_MODE_ALL; + dgcdp.dmode = _GED_SHADED_MODE_ALL; + } + av[0] = (char *)argv[i]; ret = db_walk_tree(gedp->ged_wdbp->dbip, ac, @@ -728,6 +835,8 @@ draw_check_region_end, draw_check_leaf, (void *)&dgcdp); + + dgcdp = dgcdp_save; } } else { struct display_list **paths_to_draw; Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2014-12-10 20:37:08 UTC (rev 63664) +++ brlcad/trunk/src/libged/ged_private.h 2014-12-10 21:07:53 UTC (rev 63665) @@ -60,6 +60,7 @@ #define _GED_SHADED_MODE_ALL 2 #define _GED_BOOL_EVAL 3 #define _GED_HIDDEN_LINE 4 +#define _GED_SHADED_MODE_EVAL 5 #define _GED_DRAW_WIREFRAME 1 #define _GED_DRAW_NMG_POLY 3 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ej...@us...> - 2014-12-23 17:49:38
|
Revision: 63828 http://sourceforge.net/p/brlcad/code/63828 Author: ejno Date: 2014-12-23 17:49:27 +0000 (Tue, 23 Dec 2014) Log Message: ----------- enable ray shots Modified Paths: -------------- brlcad/trunk/src/libged/CMakeLists.txt brlcad/trunk/src/libged/simulate/collision.cpp brlcad/trunk/src/libged/simulate/physics_world.cpp brlcad/trunk/src/libged/simulate/simulate.cpp Added Paths: ----------- brlcad/trunk/src/libged/simulate/rt_instance.cpp brlcad/trunk/src/libged/simulate/rt_instance.hpp Modified: brlcad/trunk/src/libged/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libged/CMakeLists.txt 2014-12-23 17:28:06 UTC (rev 63827) +++ brlcad/trunk/src/libged/CMakeLists.txt 2014-12-23 17:49:27 UTC (rev 63828) @@ -251,6 +251,7 @@ shells.c showmats.c simulate/collision.cpp + simulate/rt_instance.cpp simulate/physics_world.cpp simulate/simulate.cpp simulate/simrt.c @@ -336,6 +337,7 @@ joint.h qray.h simulate/collision.hpp + simulate/rt_instance.hpp simulate/physics_world.hpp simulate/simrt.h osg.cpp Modified: brlcad/trunk/src/libged/simulate/collision.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/collision.cpp 2014-12-23 17:28:06 UTC (rev 63827) +++ brlcad/trunk/src/libged/simulate/collision.cpp 2014-12-23 17:49:27 UTC (rev 63828) @@ -30,6 +30,7 @@ #include "common.h" #include "collision.hpp" +#include "rt_instance.hpp" #include "raytrace.h" @@ -120,7 +121,7 @@ application app; { RT_APPLICATION_INIT(&app); - app.a_rt_i = NULL; // TODO + app.a_rt_i = rt_instance_data::rt_instance; app.a_multioverlap = on_multioverlap; } Modified: brlcad/trunk/src/libged/simulate/physics_world.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/physics_world.cpp 2014-12-23 17:28:06 UTC (rev 63827) +++ brlcad/trunk/src/libged/simulate/physics_world.cpp 2014-12-23 17:49:27 UTC (rev 63828) @@ -132,7 +132,7 @@ btScalar bt_matrix[16]; m_rigid_body.getCenterOfMassTransform().getOpenGLMatrix(bt_matrix); - VSCALE(&bt_matrix[12], &bt_matrix[12], 1e3); // scale millimeters to meters + VSCALE(&bt_matrix[12], &bt_matrix[12], 1e3); // scale meters to millimeters MAT_TRANSPOSE(m_matrix, bt_matrix); } Added: brlcad/trunk/src/libged/simulate/rt_instance.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/rt_instance.cpp (rev 0) +++ brlcad/trunk/src/libged/simulate/rt_instance.cpp 2014-12-23 17:49:27 UTC (rev 63828) @@ -0,0 +1,14 @@ +#include "common.h" + + +#include "rt_instance.hpp" + + +namespace rt_instance_data +{ + + +rt_i *rt_instance; + + +} Property changes on: brlcad/trunk/src/libged/simulate/rt_instance.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: brlcad/trunk/src/libged/simulate/rt_instance.hpp =================================================================== --- brlcad/trunk/src/libged/simulate/rt_instance.hpp (rev 0) +++ brlcad/trunk/src/libged/simulate/rt_instance.hpp 2014-12-23 17:49:27 UTC (rev 63828) @@ -0,0 +1,14 @@ +// FIXME this file will go away after testing + + +#include "raytrace.h" + + +namespace rt_instance_data +{ + + +extern rt_i *rt_instance; + + +} Property changes on: brlcad/trunk/src/libged/simulate/rt_instance.hpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: brlcad/trunk/src/libged/simulate/simulate.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/simulate.cpp 2014-12-23 17:28:06 UTC (rev 63827) +++ brlcad/trunk/src/libged/simulate/simulate.cpp 2014-12-23 17:49:27 UTC (rev 63828) @@ -31,6 +31,7 @@ #include "physics_world.hpp" +#include "rt_instance.hpp" #include <map> @@ -228,6 +229,7 @@ simulate::PhysicsWorld world; world_add_tree(world, *rt_instance.ptr, *vtree, *gedp->ged_wdbp->dbip); rt_prep(rt_instance.ptr); + rt_instance_data::rt_instance = rt_instance.ptr; world.step(1); } catch (const std::logic_error &e) { bu_vls_sprintf(gedp->ged_result_str, "%s: %s", argv[0], e.what()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ej...@us...> - 2015-01-09 17:14:49
|
Revision: 63908 http://sourceforge.net/p/brlcad/code/63908 Author: ejno Date: 2015-01-09 17:14:45 +0000 (Fri, 09 Jan 2015) Log Message: ----------- update the database for librt when necessary Modified Paths: -------------- brlcad/trunk/src/libged/CMakeLists.txt brlcad/trunk/src/libged/simulate/collision.cpp brlcad/trunk/src/libged/simulate/physics_world.cpp brlcad/trunk/src/libged/simulate/physics_world.hpp brlcad/trunk/src/libged/simulate/rt_instance.cpp brlcad/trunk/src/libged/simulate/rt_instance.hpp brlcad/trunk/src/libged/simulate/simulate.cpp Modified: brlcad/trunk/src/libged/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libged/CMakeLists.txt 2015-01-09 17:00:47 UTC (rev 63907) +++ brlcad/trunk/src/libged/CMakeLists.txt 2015-01-09 17:14:45 UTC (rev 63908) @@ -251,10 +251,11 @@ shells.c showmats.c simulate/collision.cpp + simulate/physics_world.cpp simulate/rt_instance.cpp - simulate/physics_world.cpp + simulate/simrt.c simulate/simulate.cpp - simulate/simrt.c + simulate/world_object.cpp size.c slew.c solids_on_ray.c @@ -337,9 +338,10 @@ joint.h qray.h simulate/collision.hpp + simulate/physics_world.hpp simulate/rt_instance.hpp - simulate/physics_world.hpp simulate/simrt.h + simulate/world_object.hpp osg.cpp ) CMAKEFILES(${ged_ignore_files}) Modified: brlcad/trunk/src/libged/simulate/collision.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/collision.cpp 2015-01-09 17:00:47 UTC (rev 63907) +++ brlcad/trunk/src/libged/simulate/collision.cpp 2015-01-09 17:14:45 UTC (rev 63908) @@ -30,11 +30,9 @@ #include "common.h" #include "collision.hpp" -#include "rt_instance.hpp" +#include "world_object.hpp" -#include "raytrace.h" - namespace { @@ -134,8 +132,10 @@ // shoot the rays application app; { + const simulate::MatrixMotionState &rb_a_motion_state = + *static_cast<const simulate::MatrixMotionState *>(rb_a.getMotionState()); RT_APPLICATION_INIT(&app); - app.a_rt_i = rt_instance_data::rt_instance; + app.a_rt_i = &rb_a_motion_state.get_rt_instance(); app.a_multioverlap = on_multioverlap; app.a_logoverlap = rt_silent_logoverlap; app.a_uptr = &result; Modified: brlcad/trunk/src/libged/simulate/physics_world.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/physics_world.cpp 2015-01-09 17:00:47 UTC (rev 63907) +++ brlcad/trunk/src/libged/simulate/physics_world.cpp 2015-01-09 17:14:45 UTC (rev 63908) @@ -35,99 +35,26 @@ #include <limits> -namespace -{ - - -HIDDEN btRigidBody::btRigidBodyConstructionInfo -build_construction_info(btMotionState &motion_state, - btCollisionShape &collision_shape, btScalar mass) -{ - btVector3 inertia; - collision_shape.calculateLocalInertia(mass, inertia); - return btRigidBody::btRigidBodyConstructionInfo(mass, &motion_state, - &collision_shape, inertia); -} - - -} - - namespace simulate { -class WorldObject -{ -public: - WorldObject(std::auto_ptr<btMotionState> motion_state, btScalar mass, - const btVector3 &bounding_box_dimensions, const btVector3 &linear_velocity, - const btVector3 &angular_velocity); - - void add_to_world(btDiscreteDynamicsWorld &world); - - -private: - WorldObject(const WorldObject &source); - WorldObject &operator=(const WorldObject &source); - - bool m_in_world; - std::auto_ptr<btMotionState> m_motion_state; - RtCollisionShape m_collision_shape; - btRigidBody m_rigid_body; -}; - - -WorldObject::WorldObject(std::auto_ptr<btMotionState> motion_state, - btScalar mass, const btVector3 &bounding_box_dimensions, - const btVector3 &linear_velocity, const btVector3 &angular_velocity) : - m_in_world(false), - m_motion_state(motion_state), - m_collision_shape(bounding_box_dimensions / 2.0), - m_rigid_body(build_construction_info(*m_motion_state.get(), m_collision_shape, - mass)) -{ - m_rigid_body.setLinearVelocity(linear_velocity); - m_rigid_body.setAngularVelocity(angular_velocity); -} - - -void -WorldObject::add_to_world(btDiscreteDynamicsWorld &world) -{ - if (m_in_world) - throw std::runtime_error("already in world"); - else { - m_in_world = true; - world.addRigidBody(&m_rigid_body); - } -} - - PhysicsWorld::PhysicsWorld() : m_broadphase(), m_collision_config(), m_collision_dispatcher(&m_collision_config), m_constraint_solver(), m_world(&m_collision_dispatcher, &m_broadphase, &m_constraint_solver, - &m_collision_config), - m_objects() + &m_collision_config) { m_collision_dispatcher.registerCollisionCreateFunc( RtCollisionShape::RT_SHAPE_TYPE, RtCollisionShape::RT_SHAPE_TYPE, new RtCollisionAlgorithm::CreateFunc); + m_world.setGravity(btVector3(0.0, 0.0, -9.8)); } -PhysicsWorld::~PhysicsWorld() -{ - for (std::vector<WorldObject *>::iterator it = m_objects.begin(); - it != m_objects.end(); ++it) - delete *it; -} - - void PhysicsWorld::step(btScalar seconds) { @@ -136,13 +63,9 @@ void -PhysicsWorld::add_object(std::auto_ptr<btMotionState> motion_state, - btScalar mass, const btVector3 &bounding_box_dimensions, - const btVector3 &linear_velocity, const btVector3 &angular_velocity) +PhysicsWorld::add_rigid_body(btRigidBody &rigid_body) { - m_objects.push_back(new WorldObject(motion_state, mass, bounding_box_dimensions, - linear_velocity, angular_velocity)); - m_objects.back()->add_to_world(m_world); + m_world.addRigidBody(&rigid_body); } Modified: brlcad/trunk/src/libged/simulate/physics_world.hpp =================================================================== --- brlcad/trunk/src/libged/simulate/physics_world.hpp 2015-01-09 17:00:47 UTC (rev 63907) +++ brlcad/trunk/src/libged/simulate/physics_world.hpp 2015-01-09 17:14:45 UTC (rev 63908) @@ -28,9 +28,6 @@ #define PHYSICS_WORLD_H -#include <memory> -#include <vector> - #include <btBulletDynamicsCommon.h> #include "vmath.h" @@ -44,12 +41,9 @@ { public: PhysicsWorld(); - ~PhysicsWorld(); void step(btScalar seconds); - void add_object(std::auto_ptr<btMotionState> motion_state, btScalar mass, - const btVector3 &bounding_box_dimensions, const btVector3 &linear_velocity, - const btVector3 &angular_velocity); + void add_rigid_body(btRigidBody &rigid_body); private: @@ -61,8 +55,6 @@ btCollisionDispatcher m_collision_dispatcher; btSequentialImpulseConstraintSolver m_constraint_solver; btDiscreteDynamicsWorld m_world; - - std::vector<class WorldObject *> m_objects; }; Modified: brlcad/trunk/src/libged/simulate/rt_instance.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/rt_instance.cpp 2015-01-09 17:00:47 UTC (rev 63907) +++ brlcad/trunk/src/libged/simulate/rt_instance.cpp 2015-01-09 17:14:45 UTC (rev 63908) @@ -1,14 +1,148 @@ +/* R T _ I N S T A N C E . C P P + * BRL-CAD + * + * Copyright (c) 2015 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 rt_instance.cpp + * + * Brief description + * + */ + + +#ifdef HAVE_BULLET + + #include "common.h" - #include "rt_instance.hpp" +#include <stdexcept> -namespace rt_instance_data + +namespace { -rt_i *rt_instance; +HIDDEN rt_db_internal +duplicate_comb_internal(const rt_db_internal &source) +{ + if (source.idb_minor_type != ID_COMBINATION) + throw std::invalid_argument("source is not a combination"); + rt_db_internal dest = source; + BU_GET(dest.idb_ptr, rt_comb_internal); + BU_AVS_INIT(&dest.idb_avs); + bu_avs_merge(&dest.idb_avs, &source.idb_avs); + { + const rt_comb_internal &source_comb = *static_cast<const rt_comb_internal *> + (source.idb_ptr); + rt_comb_internal &dest_comb = *static_cast<rt_comb_internal *>(dest.idb_ptr); + + dest_comb = source_comb; + BU_VLS_INIT(&dest_comb.shader); + BU_VLS_INIT(&dest_comb.material); + bu_vls_vlscat(&dest_comb.shader, &source_comb.shader); + bu_vls_vlscat(&dest_comb.material, &source_comb.material); + dest_comb.tree = db_dup_subtree(source_comb.tree, &rt_uniresource); + } + + return dest; } + + +} + + +namespace simulate +{ + + +TreeUpdater::TreeUpdater(db_i &db_instance, directory &vdirectory, + const rt_db_internal &comb_internal) : + m_db_instance(db_instance), + m_directory(vdirectory), + m_comb_internal(comb_internal), + m_is_modified(false), + m_rt_instance(NULL) +{} + + +TreeUpdater::~TreeUpdater() +{ + if (m_rt_instance) + rt_free_rti(m_rt_instance); +} + + +void TreeUpdater::mark_modified() +{ + m_is_modified = true; +} + + +rt_i & +TreeUpdater::get_rt_instance() const +{ + if (!m_is_modified && m_rt_instance) + return *m_rt_instance; + + m_is_modified = false; + + if (m_rt_instance) { + rt_free_rti(m_rt_instance); + m_rt_instance = NULL; + } + + rt_db_internal write_internal = duplicate_comb_internal(m_comb_internal); + + if (rt_db_put_internal(&m_directory, &m_db_instance, &write_internal, + &rt_uniresource) < 0) + throw std::runtime_error("rt_db_put_internal() failed"); + + m_rt_instance = rt_new_rti(&m_db_instance); + + if (!m_rt_instance) + throw std::runtime_error("rt_new_rti() failed"); + + if (rt_gettree(m_rt_instance, m_directory.d_namep) < 0) { + rt_free_rti(m_rt_instance); + m_rt_instance = NULL; + throw std::runtime_error("rt_gettree() failed"); + } + + rt_prep(m_rt_instance); + + return *m_rt_instance; +} + + +} + + +#endif + + +// 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/trunk/src/libged/simulate/rt_instance.hpp =================================================================== --- brlcad/trunk/src/libged/simulate/rt_instance.hpp 2015-01-09 17:00:47 UTC (rev 63907) +++ brlcad/trunk/src/libged/simulate/rt_instance.hpp 2015-01-09 17:14:45 UTC (rev 63908) @@ -1,14 +1,75 @@ -// FIXME this file will go away after testing +/* R T _ I N S T A N C E . H P P + * BRL-CAD + * + * Copyright (c) 2015 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 rt_instance.hpp + * + * Brief description + * + */ +#ifndef RT_INSTANCE_H +#define RT_INSTANCE_H + + #include "raytrace.h" -namespace rt_instance_data +namespace simulate { -extern rt_i *rt_instance; +class TreeUpdater +{ +public: + TreeUpdater(db_i &db_instance, directory &vdirectory, + const rt_db_internal &comb_internal); + ~TreeUpdater(); + void mark_modified(); + rt_i &get_rt_instance() const; + +private: + TreeUpdater(const TreeUpdater &source); + TreeUpdater &operator=(const TreeUpdater &source); + + db_i &m_db_instance; + directory &m_directory; + const rt_db_internal &m_comb_internal; + + mutable bool m_is_modified; + mutable rt_i *m_rt_instance; +}; + + } + + +#endif + + +// 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/trunk/src/libged/simulate/simulate.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/simulate.cpp 2015-01-09 17:00:47 UTC (rev 63907) +++ brlcad/trunk/src/libged/simulate/simulate.cpp 2015-01-09 17:14:45 UTC (rev 63908) @@ -30,16 +30,14 @@ #ifdef HAVE_BULLET -#include "physics_world.hpp" +#include "world_object.hpp" #include "rt_instance.hpp" - #include <cmath> #include <map> #include <sstream> #include <stdexcept> - #include "ged.h" @@ -47,64 +45,6 @@ { -class MatrixMotionState : public btMotionState -{ -public: - MatrixMotionState(mat_t matrix); - - virtual void getWorldTransform(btTransform &dest) const; - virtual void setWorldTransform(const btTransform &transform); - - -private: - MatrixMotionState(const MatrixMotionState &source); - MatrixMotionState &operator=(const MatrixMotionState &source); - - const matp_t m_matrix; -}; - - -MatrixMotionState::MatrixMotionState(mat_t matrix) : - m_matrix(matrix) -{} - - -void -MatrixMotionState::getWorldTransform(btTransform &dest) const -{ - /* - // rotation - // matrix decomposition - - // translation - btVector3 translation(0.0, 0.0, 0.0); - MAT_DELTAS_GET(translation, m_matrix); - dest.setOrigin(translation); - */ - - btScalar bt_matrix[16]; - MAT_TRANSPOSE(bt_matrix, m_matrix); - dest.setFromOpenGLMatrix(bt_matrix); -} - - -void -MatrixMotionState::setWorldTransform(const btTransform &transform) -{ - /* - // rotation - // matrix decomposition - - // translation - MAT_DELTAS_VEC(m_matrix, transform.getOrigin()); - */ - - btScalar bt_matrix[16]; - transform.getOpenGLMatrix(bt_matrix); - MAT_TRANSPOSE(m_matrix, bt_matrix); -} - - template <typename T, void (*Destructor)(T *)> struct AutoDestroyer { AutoDestroyer(T *vptr) : ptr(vptr) {} @@ -142,12 +82,12 @@ HIDDEN std::map<std::string, std::string> -get_attributes(const db_i &dbi, const std::string &name) +get_attributes(const db_i &db_instance, const std::string &name) { const char * const prefix = "simulate::"; const std::size_t prefix_len = strlen(prefix); - directory *dir = db_lookup(&dbi, name.c_str(), false); + directory *dir = db_lookup(&db_instance, name.c_str(), false); if (!dir) throw std::invalid_argument("failed to lookup '" + name + "'"); @@ -155,7 +95,7 @@ bu_attribute_value_set obj_avs; bu_avs_init_empty(&obj_avs); - if (db5_get_attributes(&dbi, &obj_avs, dir) < 0) + if (db5_get_attributes(&db_instance, &obj_avs, dir) < 0) throw std::runtime_error("db5_get_attributes() failed"); AutoDestroyer<bu_attribute_value_set, bu_avs_free> obj_avs_autodestroy( @@ -172,16 +112,17 @@ HIDDEN void -get_bounding_box_dimensions(db_i &dbi, const std::string &name, vect_t &dest) +get_bounding_box_dimensions(db_i &db_instance, const std::string &name, + vect_t &dest) { - directory *dir = db_lookup(&dbi, name.c_str(), false); + directory *dir = db_lookup(&db_instance, name.c_str(), false); if (!dir) throw std::invalid_argument("failed to lookup '" + name + "'"); point_t bb_min, bb_max; - if (rt_bound_internal(&dbi, dir, bb_min, bb_max)) + if (rt_bound_internal(&db_instance, dir, bb_min, bb_max)) throw std::runtime_error("failed to get bounding box"); VSUB2(dest, bb_max, bb_min); @@ -189,16 +130,16 @@ HIDDEN fastf_t -get_volume(const db_i &dbi, const std::string &name) +get_volume(const db_i &db_instance, const std::string &name) { - directory *dir = db_lookup(&dbi, name.c_str(), false); + directory *dir = db_lookup(&db_instance, name.c_str(), false); if (!dir) throw std::invalid_argument("failed to lookup '" + name + "'"); rt_db_internal internal; - if (rt_db_get_internal(&internal, dir, &dbi, bn_mat_identity, + if (rt_db_get_internal(&internal, dir, &db_instance, bn_mat_identity, &rt_uniresource) < 0) throw std::runtime_error("rt_db_get_internal() failed"); @@ -230,65 +171,71 @@ } -HIDDEN void -world_add_tree(simulate::PhysicsWorld &world, tree &vtree, db_i &dbi) +HIDDEN simulate::WorldObject * +build_world_object(db_i &db_instance, const std::string &name, matp_t &matrix, + simulate::TreeUpdater &tree_updater) { - switch (vtree.tr_op) { - case OP_DB_LEAF: { - if (!vtree.tr_l.tl_mat) { - vtree.tr_l.tl_mat = static_cast<fastf_t *>(bu_malloc(sizeof(mat_t), "tl_mat")); - MAT_IDN(vtree.tr_l.tl_mat); - } + if (!matrix) { + matrix = static_cast<fastf_t *>(bu_malloc(sizeof(mat_t), "tl_mat")); + MAT_IDN(matrix); + } - const fastf_t density = 1.0; - fastf_t mass = density * get_volume(dbi, vtree.tr_l.tl_name); - vect_t linear_velocity = {0, 0, 0}, angular_velocity = {0, 0, 0}; + const fastf_t density = 1.0; + fastf_t mass = density * get_volume(db_instance, name); + vect_t linear_velocity = {0, 0, 0}, angular_velocity = {0, 0, 0}; - std::map<std::string, std::string> attributes = get_attributes(dbi, - vtree.tr_l.tl_name); + std::map<std::string, std::string> attributes = get_attributes(db_instance, + name); - for (std::map<std::string, std::string>::const_iterator it = attributes.begin(); - it != attributes.end(); ++it) { - if (it->first == "mass") { - mass = lexical_cast<fastf_t>(it->second, "invalid attribute 'mass'"); + for (std::map<std::string, std::string>::const_iterator it = attributes.begin(); + it != attributes.end(); ++it) { + if (it->first == "mass") { + mass = lexical_cast<fastf_t>(it->second, "invalid attribute 'mass'"); - if (mass < 0.0) throw std::invalid_argument("invalid attribute 'mass'"); + if (mass < 0.0) throw std::invalid_argument("invalid attribute 'mass'"); - } else if (it->first == "linear_velocity") { - deserialize_vector(linear_velocity, it->second); - } else if (it->first == "angular_velocity") { - deserialize_vector(angular_velocity, it->second); - } else - throw std::invalid_argument("invalid attribute '" + it->first + "' on object '" - + vtree.tr_l.tl_name + "'"); - } + } else if (it->first == "linear_velocity") { + deserialize_vector(linear_velocity, it->second); + } else if (it->first == "angular_velocity") { + deserialize_vector(angular_velocity, it->second); + } else + throw std::invalid_argument("invalid attribute '" + it->first + "' on object '" + + name + "'"); + } - { - vect_t bounding_box_dimensions; - get_bounding_box_dimensions(dbi, vtree.tr_l.tl_name, bounding_box_dimensions); + vect_t bounding_box_dimensions; + get_bounding_box_dimensions(db_instance, name, bounding_box_dimensions); - btVector3 bt_bounding_box_dimensions, bt_linear_velocity, bt_angular_velocity; - VMOVE(bt_bounding_box_dimensions, bounding_box_dimensions); - VMOVE(bt_linear_velocity, linear_velocity); - VMOVE(bt_angular_velocity, angular_velocity); + btVector3 bt_bounding_box_dimensions, bt_linear_velocity, bt_angular_velocity; + VMOVE(bt_bounding_box_dimensions, bounding_box_dimensions); + VMOVE(bt_linear_velocity, linear_velocity); + VMOVE(bt_angular_velocity, angular_velocity); - // apply matrix scaling - bt_bounding_box_dimensions[X] *= 1.0 / vtree.tr_l.tl_mat[MSX]; - bt_bounding_box_dimensions[Y] *= 1.0 / vtree.tr_l.tl_mat[MSY]; - bt_bounding_box_dimensions[Z] *= 1.0 / vtree.tr_l.tl_mat[MSZ]; - bt_bounding_box_dimensions *= 1.0 / vtree.tr_l.tl_mat[MSA]; + // apply matrix scaling + bt_bounding_box_dimensions[X] *= 1.0 / matrix[MSX]; + bt_bounding_box_dimensions[Y] *= 1.0 / matrix[MSY]; + bt_bounding_box_dimensions[Z] *= 1.0 / matrix[MSZ]; + bt_bounding_box_dimensions *= 1.0 / matrix[MSA]; - world.add_object( - std::auto_ptr<btMotionState>(new MatrixMotionState(vtree.tr_l.tl_mat)), - mass, bt_bounding_box_dimensions, bt_linear_velocity, bt_angular_velocity); - } + return new simulate::WorldObject(matrix, tree_updater, mass, + bt_bounding_box_dimensions, bt_linear_velocity, bt_angular_velocity); +} + +HIDDEN void +get_tree_objects(db_i &db_instance, tree &vtree, + simulate::TreeUpdater &tree_updater, + std::vector<simulate::WorldObject *> &objects) +{ + switch (vtree.tr_op) { + case OP_DB_LEAF: + objects.push_back(build_world_object(db_instance, vtree.tr_l.tl_name, + vtree.tr_l.tl_mat, tree_updater)); break; - } case OP_UNION: - world_add_tree(world, *vtree.tr_b.tb_left, dbi); - world_add_tree(world, *vtree.tr_b.tb_right, dbi); + get_tree_objects(db_instance, *vtree.tr_b.tb_left, tree_updater, objects); + get_tree_objects(db_instance, *vtree.tr_b.tb_right, tree_updater, objects); break; default: @@ -298,37 +245,47 @@ HIDDEN void -do_simulate(db_i &dbi, directory &scene_directory, fastf_t seconds) +do_simulate(db_i &db_instance, directory &scene_directory, fastf_t seconds) { rt_db_internal internal; - if (rt_db_get_internal(&internal, &scene_directory, &dbi, bn_mat_identity, - &rt_uniresource) < 0) + if (rt_db_get_internal(&internal, &scene_directory, &db_instance, + bn_mat_identity, &rt_uniresource) < 0) throw std::runtime_error("rt_db_get_internal() failed"); AutoDestroyer<rt_db_internal, rt_db_free_internal> internal_autodestroy( &internal); { - AutoDestroyer<rt_i, rt_free_rti> rt_instance(rt_new_rti(&dbi)); + simulate::PhysicsWorld world; + tree * const vtree = static_cast<rt_comb_internal *>(internal.idb_ptr)->tree; - if (!rt_instance.ptr) throw std::runtime_error("rt_new_rti() failed"); + simulate::TreeUpdater tree_updater(db_instance, scene_directory, internal); + std::vector<simulate::WorldObject *> objects; - if (rt_gettree(rt_instance.ptr, scene_directory.d_namep) < 0) - throw std::runtime_error("rt_gettree() failed"); + try { + if (vtree) get_tree_objects(db_instance, *vtree, tree_updater, objects); - rt_prep(rt_instance.ptr); - rt_instance_data::rt_instance = rt_instance.ptr; + for (std::vector<simulate::WorldObject *>::iterator it = objects.begin(); + it != objects.end(); ++it) + (*it)->add_to_world(world); - simulate::PhysicsWorld world; - tree * const vtree = static_cast<rt_comb_internal *>(internal.idb_ptr)->tree; + world.step(seconds); + } catch (...) { + for (std::vector<simulate::WorldObject *>::iterator it = objects.begin(); + it != objects.end(); ++it) + delete *it; - if (vtree) world_add_tree(world, *vtree, dbi); + throw; + } - world.step(seconds); + for (std::vector<simulate::WorldObject *>::iterator it = objects.begin(); + it != objects.end(); ++it) + delete *it; } - if (rt_db_put_internal(&scene_directory, &dbi, &internal, &rt_uniresource) < 0) + if (rt_db_put_internal(&scene_directory, &db_instance, &internal, + &rt_uniresource) < 0) throw std::runtime_error("rt_db_put_internal() failed"); } @@ -361,12 +318,7 @@ if (seconds < 0.0) throw std::runtime_error("invalid value for 'seconds'"); - // We must reinitialize a simulate::PhysicsWorld after every ray trace. - // This is because rt_db_put_internal() is required for librt to - // receive the transforms. - // TODO: preserve velocity; reinitialize after every ray trace - for (int i = 0; i < std::ceil(10.0 * seconds); ++i) - do_simulate(*gedp->ged_wdbp->dbip, *dir, 0.1); + do_simulate(*gedp->ged_wdbp->dbip, *dir, seconds); } catch (const std::logic_error &e) { bu_vls_sprintf(gedp->ged_result_str, "%s: %s", argv[0], e.what()); return GED_ERROR; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ej...@us...> - 2015-01-09 18:51:03
|
Revision: 63916 http://sourceforge.net/p/brlcad/code/63916 Author: ejno Date: 2015-01-09 18:50:54 +0000 (Fri, 09 Jan 2015) Log Message: ----------- remove simrt Modified Paths: -------------- brlcad/trunk/src/libged/CMakeLists.txt Removed Paths: ------------- brlcad/trunk/src/libged/simulate/simrt.c brlcad/trunk/src/libged/simulate/simrt.h Modified: brlcad/trunk/src/libged/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libged/CMakeLists.txt 2015-01-09 18:42:47 UTC (rev 63915) +++ brlcad/trunk/src/libged/CMakeLists.txt 2015-01-09 18:50:54 UTC (rev 63916) @@ -253,7 +253,6 @@ simulate/collision.cpp simulate/physics_world.cpp simulate/rt_instance.cpp - simulate/simrt.c simulate/simulate.cpp simulate/world_object.cpp size.c @@ -340,7 +339,6 @@ simulate/collision.hpp simulate/physics_world.hpp simulate/rt_instance.hpp - simulate/simrt.h simulate/world_object.hpp osg.cpp ) Deleted: brlcad/trunk/src/libged/simulate/simrt.c =================================================================== --- brlcad/trunk/src/libged/simulate/simrt.c 2015-01-09 18:42:47 UTC (rev 63915) +++ brlcad/trunk/src/libged/simulate/simrt.c 2015-01-09 18:50:54 UTC (rev 63916) @@ -1,505 +0,0 @@ -/* S I M R T . C - * BRL-CAD - * - * Copyright (c) 2011-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. - */ -/* - * Implements the raytrace based manifold generator. - * - * Used for returning the manifold points to physics. - * - */ - -#include "common.h" - -#ifdef HAVE_BULLET - -/* Private Header */ -#include "simrt.h" - - -/* - * Maximum number of overlaps to record per ray shot. - * Stored in the global overlap_list. - */ -#define MAX_OVERLAPS 4 - -/* - * Maximum normals allowed to be detected by ray shots - */ -#define MAX_NORMALS 10 - - -/* - * This structure is a single node of an array - * of overlap regions: similar to the one in nirt/usrfmt.h - */ -struct overlap { - int index; - struct application *ap; - struct partition *pp; - struct region *reg1; - struct region *reg2; - fastf_t in_dist; - fastf_t out_dist; - point_t in_point; - point_t out_point; - vect_t in_normal, out_normal; - struct soltab *insol, *outsol; - struct curvature incur, outcur; -}; - - -/** - * This structure contains the results of analyzing an overlap volume(among 2 - * regions), through shooting rays - */ -struct rayshot_results { - - /* Was an overlap detected ? in that case no point in using air gap - * It may happen that an object is not sufficiently close to the object it - * intends to strike, i.e. the gap between them is not <= TOL, so the air gap - * info can't be used to create contact pairs. In the next iteration the object - * moves so far that it has overlapped(i.e. penetrated) the target, - * so air gap still can't be used, thus the below flag detects any overlap and - * enables the logic for creating contact pairs using overlap info. - * - * Also rt_result.overlap_found is set to FALSE, before even a single - * ray is shot and its value is valid across all the different ray shots, - * so if an overlap has been detected in a ray, all subsequent air gap processing is - * skipped. - */ - int overlap_found; - - /* The vector sum of the normals over the surface in the overlap region for A & B*/ - vect_t resultant_normal_A; - vect_t resultant_normal_B; -}; - - -int num_overlaps = 0; -struct overlap overlap_list[MAX_OVERLAPS]; -struct rayshot_results rt_result; - - -HIDDEN int -check_tree_funcleaf( - struct db_i *dbip, - struct rt_comb_internal *comb, - union tree *comb_tree, - int (*leaf_func)(), - void *user_ptr1) -{ - int rv = 0; - - RT_CK_DBI(dbip); - - if (!comb_tree) - return 0; - - RT_CK_TREE(comb_tree); - - switch (comb_tree->tr_op) { - case OP_DB_LEAF: - rv = (*leaf_func)(dbip, comb, comb_tree, user_ptr1); - break; - - case OP_UNION: - case OP_INTERSECT: - case OP_SUBTRACT: - case OP_XOR: - rv = check_tree_funcleaf(dbip, comb, comb_tree->tr_b.tb_left, leaf_func, - user_ptr1); - - if (!rv) - rv = check_tree_funcleaf(dbip, comb, comb_tree->tr_b.tb_right, leaf_func, - user_ptr1); - - break; - - default: - bu_log("check_tree_funcleaf: bad op %d\n", comb_tree->tr_op); - bu_bomb("check_tree_funcleaf: bad op\n"); - break; - } - - return rv; -} - - -HIDDEN int -find_solid(struct db_i *dbip, - struct rt_comb_internal *comb, - union tree *comb_leaf, - void *object) -{ - char *obj_name; - - if (dbip) RT_CK_DBI(dbip); - - if (comb) RT_CK_COMB(comb); - - RT_CK_TREE(comb_leaf); - - obj_name = (char *)object; - - if (BU_STR_EQUAL(comb_leaf->tr_l.tl_name, obj_name)) - return 1; - else - return 0; -} - - -/** - * Gets the exact overlap volume between 2 AABBs - */ -static int -get_overlap(struct rigid_body *rbA, struct rigid_body *rbB, vect_t overlap_min, - vect_t overlap_max) -{ - VMOVE(overlap_max, rbA->btbb_max); - VMIN(overlap_max, rbB->btbb_max); - - VMOVE(overlap_min, rbA->btbb_min); - VMAX(overlap_min, rbB->btbb_min); - return GED_OK; -} - - -static void -if_multioverlap(struct application *ap, struct partition *pp1, - struct bu_ptbl *pptbl, - struct partition *pp2) -{ - int i = 0; - struct region *reg1, *reg2; - - reg1 = (struct region *)BU_PTBL_GET(pptbl, 0); - reg2 = (struct region *)BU_PTBL_GET(pptbl, 1); - - if (num_overlaps < MAX_OVERLAPS) { - i = num_overlaps; - overlap_list[i].ap = ap; - overlap_list[i].pp = pp1; - overlap_list[i].reg1 = reg1; - overlap_list[i].reg2 = reg2; - overlap_list[i].in_dist = pp1->pt_inhit->hit_dist; - overlap_list[i].out_dist = pp1->pt_outhit->hit_dist; - VJOIN1(overlap_list[i].in_point, ap->a_ray.r_pt, pp1->pt_inhit->hit_dist, - ap->a_ray.r_dir); - VJOIN1(overlap_list[i].out_point, ap->a_ray.r_pt, pp1->pt_outhit->hit_dist, - ap->a_ray.r_dir); - - - /* Entry solid */ - overlap_list[i].insol = pp1->pt_inseg->seg_stp; - - /* Exit solid */ - overlap_list[i].outsol = pp1->pt_outseg->seg_stp; - - overlap_list[i].index = i; - num_overlaps++; - } - - (void)rt_defoverlap(ap, pp1, reg1, reg2, pp2); -} - - -/** - * Traverse the hit list and overlap list, drawing the ray segments - * for normal rays - */ -static int -traverse_normalray_lists( - struct sim_manifold *mf, - struct simulation_params *sim_params, - vect_t overlap_min, - vect_t overlap_max) -{ - int i, j, rv; - - struct bu_vls reg_vls = BU_VLS_INIT_ZERO; - fastf_t depth; - struct rt_comb_internal *comb = (struct rt_comb_internal *)NULL; - - - /* Draw all the overlap regions : lines are added for overlap segments - * to help visual debugging - */ - for (i = 0; i < num_overlaps; i++) { - - /* Check of both points are within the overlap RPP */ - if (!V3PT_IN_RPP(overlap_list[i].in_point, overlap_min, overlap_max) || - !V3PT_IN_RPP(overlap_list[i].out_point, overlap_min, overlap_max)) - continue; - - - /* Must check if insol belongs to rbA and outsol to rbB IN THIS ORDER, else results may - * be incorrect if geometry of either has overlap defects within. - */ - - /* Check if the in solid belongs to rbA */ - comb = (struct rt_comb_internal *)mf->rbA->intern.idb_ptr; - rv = check_tree_funcleaf(sim_params->gedp->ged_wdbp->dbip, - comb, - comb->tree, - find_solid, - (void *)(overlap_list[i].insol->st_name)); - - if (!rv) - continue; - - /* Check if the out solid belongs to rbB */ - comb = (struct rt_comb_internal *)mf->rbB->intern.idb_ptr; - rv = check_tree_funcleaf(sim_params->gedp->ged_wdbp->dbip, - comb, - comb->tree, - find_solid, - (void *)(overlap_list[i].outsol->st_name)); - - if (!rv) - continue; - - /* Overlap confirmed, set overlap_found here, because only here it's known - * that at least one of detected overlaps was between A & B */ - rt_result.overlap_found = 1; - - depth = DIST_PT_PT(overlap_list[i].in_point, overlap_list[i].out_point); - - bu_log("traverse_normalray_lists: Contact point %d for B:%s at (%f, %f, %f) , depth %f \ - n=(%f, %f, %f), at solid %s", mf->num_contacts + 1, - mf->rbB->rb_namep, - V3ARGS(overlap_list[i].out_point), - -depth, - V3ARGS(rt_result.resultant_normal_B), - overlap_list[i].insol->st_name); - - - /* Add the points to the contacts list of the 1st manifold, without maximizing area here - * Bullet should handle contact point minimization and area maximization - */ - if (mf->num_contacts == MAX_CONTACTS_PER_MANIFOLD) { - continue; - } - - j = mf->num_contacts; - VMOVE(mf->contacts[j].ptB, overlap_list[i].out_point); - VMOVE(mf->contacts[j].normalWorldOnB, rt_result.resultant_normal_B); - mf->contacts[j].depth = -depth; - mf->num_contacts++; - - bu_log("traverse_normalray_lists : Penetration depth set to %f\n", - mf->contacts[j].depth); - - - } /* end-for overlap */ - - - bu_vls_free(®_vls); - - return GED_OK; -} - - -/* - * Shoots a circular bunch of rays from B towards A along resultant_normal_B - * - */ -static int -shoot_normal_rays(struct sim_manifold *current_manifold, - struct simulation_params *sim_params, - vect_t overlap_min, - vect_t overlap_max) -{ - vect_t diff, up_vec, ref_axis; - point_t overlap_center; - fastf_t d, r; - struct xrays *xrayp; - struct xrays *entry; - struct xray center_ray; - - /* Setup center ray */ - center_ray.index = 0; - VMOVE(center_ray.r_dir, rt_result.resultant_normal_B); - - /* The radius of the circular bunch of rays to shoot to get depth and points on B is - * the half of the diagonal of the overlap RPP , so that no matter how the normal is - * oriented, rays are shot to cover the entire volume - */ - VSUB2(diff, overlap_max, overlap_min); - d = MAGNITUDE(diff); - r = d / 2; - - /* Get overlap volume position in 3D space */ - VCOMB2(overlap_center, 1, overlap_min, 0.5, overlap_max); - - /* Step back from the overlap_center, along the normal by r - * to ensure rays start from outside overlap region - */ - VSCALE(diff, rt_result.resultant_normal_B, -r); - VADD2(center_ray.r_pt, overlap_center, diff); - - /* Generate the up vector, try cross with x-axis */ - VSET(ref_axis, 1, 0, 0); - VCROSS(up_vec, rt_result.resultant_normal_B, ref_axis); - - /* Parallel to x-axis ? then try y-axis */ - if (VZERO(up_vec)) { - VSET(ref_axis, 0, 1, 0); - VCROSS(up_vec, rt_result.resultant_normal_B, ref_axis); - } - - /* Initialize the BU_LIST in preparation for rt_gen_circular_grid() */ - BU_ALLOC(xrayp, struct xrays); - BU_LIST_INIT(&(xrayp->l)); - VMOVE(xrayp->ray.r_pt, center_ray.r_pt); - VMOVE(xrayp->ray.r_dir, center_ray.r_dir); - xrayp->ray.index = 0; - xrayp->ray.magic = RT_RAY_MAGIC; - - rt_gen_circular_grid(xrayp, ¢er_ray, r, up_vec, 0.1); - - /* Lets check the rays */ - while (BU_LIST_WHILE(entry, xrays, &(xrayp->l))) { - VUNITIZE(entry->ray.r_dir); - { - struct application ap; - - /* initialization of the application structure */ - RT_APPLICATION_INIT(&ap); - ap.a_multioverlap = if_multioverlap; - ap.a_logoverlap = rt_silent_logoverlap; - ap.a_rt_i = sim_params->rtip; /* rt_i pointer */ - - /* Set the ray start point and direction rt_shootray() uses these - * two to determine what ray to fire. - * It's worth nothing that librt assumes units of millimeters. - * All geometry is stored as millimeters regardless of the units - * set during editing. There are libbu routines for performing - * unit conversions if desired. - */ - VMOVE(ap.a_ray.r_pt, entry->ray.r_pt); - VMOVE(ap.a_ray.r_dir, entry->ray.r_dir); - - (void)rt_shootray(&ap); - } - - - traverse_normalray_lists(current_manifold, sim_params, - overlap_min, overlap_max); - - num_overlaps = 0; /* clean up the list */ - - BU_LIST_DEQUEUE(&(entry->l)); - bu_free(entry, "free xrays entry"); - } - - - bu_free(xrayp, "free xrays list head"); - - return GED_OK; -} - - -/** - * Creates the contact pairs from the raytracing results. - * This is the core logic of the simulation and the manifold points - * have to satisfy certain constraints (max area within overlap region etc.) - * to have a successful simulation. The normals and penetration depth is also - * generated here for each point in the contact pairs. There can be upto 4 - * contact pairs. - */ - - -static int -create_contact_pairs( - struct sim_manifold *mf, - struct simulation_params *sim_params, - vect_t overlap_min, - vect_t overlap_max) -{ - /* Calculate the normal of the contact points as the resultant of -A & B velocity - * NOTE: Currently the sum of normals along overlapping surface , approach is not used - */ - vect_t v; - VMOVE(v, mf->rbA->linear_velocity); - VUNITIZE(v); - VREVERSE(rt_result.resultant_normal_B, v); - - VMOVE(v, mf->rbB->linear_velocity); - VUNITIZE(v); - VADD2(rt_result.resultant_normal_B, rt_result.resultant_normal_B, v); - VUNITIZE(rt_result.resultant_normal_B); - - mf->num_contacts = 0; - - bu_log("create_contact_pairs : Final normal from B to A : (%f, %f, %f)\n", - V3ARGS(rt_result.resultant_normal_B)); - - /* Begin making contacts */ - - /* Shoot rays along the normal to get points on B and the depth along this direction */ - shoot_normal_rays(mf, sim_params, overlap_min, overlap_max); - - return GED_OK; -} - - -int -generate_manifolds(struct simulation_params *sim_params, - struct rigid_body *rbA, - struct rigid_body *rbB) -{ - /* The manifold between rbA & rbB will be stored in B */ - struct sim_manifold *rt_mf; - - vect_t overlap_min, overlap_max; - - rt_mf = &(rbB->rt_manifold); - - /* Setup the manifold participant pointers */ - rt_mf->rbA = rbA; - rt_mf->rbB = rbB; - - /* Get the overlap region */ - get_overlap(rbA, rbB, overlap_min, overlap_max); - - /* Initialize the rayshot results structure, has to be done for each manifold */ - VSETALL(rt_result.resultant_normal_A, SMALL_FASTF); - VSETALL(rt_result.resultant_normal_B, SMALL_FASTF); - rt_result.overlap_found = 0; - - - /* Create the contact pairs and normals : Currently just 1 manifold is allowed per pair of objects*/ - create_contact_pairs(rt_mf, sim_params, overlap_min, overlap_max); - - return GED_OK; -} - - -#endif - -/* - * 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 - */ Deleted: brlcad/trunk/src/libged/simulate/simrt.h =================================================================== --- brlcad/trunk/src/libged/simulate/simrt.h 2015-01-09 18:42:47 UTC (rev 63915) +++ brlcad/trunk/src/libged/simulate/simrt.h 2015-01-09 18:50:54 UTC (rev 63916) @@ -1,174 +0,0 @@ -/* S I M R T . H - * BRL-CAD - * - * Copyright (c) 2011-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. - */ -/* - * The header for the raytrace based manifold generator - * for the simulate command. - * - * - */ - -#ifndef LIBGED_SIMULATE_SIMRT_H -#define LIBGED_SIMULATE_SIMRT_H - -#if defined __cplusplus - -/* If the functions in this header have C linkage, this - * will specify linkage for all C++ language compilers */ -extern "C" { -#endif - - /*#include "common.h"*/ - - /* System Headers */ -#include <stdlib.h> -#include <ctype.h> -#include <math.h> -#include <string.h> - - /* Public Headers */ -#include "vmath.h" -#include "db.h" -#include "bu.h" - - /* Private Headers */ -#include "../ged_private.h" - - - /* Contains the simulation parameters, such as number of rigid bodies, - * the head node of the linked list containing the bodies and - * time/steps for which the simulation will be run. - */ - struct simulation_params { - int duration; /**< @brief contains either the number of steps or the time */ - int num_bodies; /**< @brief number of rigid bodies participating in the sim */ - struct bu_vls - *result_str; /**< @brief handle to the libged object to access geometry info */ - char *sim_comb_name; /**< @brief name of the group which contains all sim regions*/ - char *ground_plane_name; /**< @brief name of the ground plane region */ - struct rigid_body *head_node; /**< @brief link to first rigid body node */ - - struct rt_i - *rtip; /**< @brief the raytrace instance used by rt to find contact points */ - struct ged - *gedp; /**< @brief pass the gfx context to allow lines to be drawn by rt */ - - /* Debugging */ - int iter; - }; - - - struct sim_contact { - vect_t ptA; - vect_t ptB; - vect_t normalWorldOnB; - fastf_t depth; - }; - - -#define MAX_CONTACTS_PER_MANIFOLD 100 - struct sim_manifold { - struct rigid_body *rbA, *rbB; - int num_contacts; - struct sim_contact contacts[MAX_CONTACTS_PER_MANIFOLD]; - }; - - - /* Contains information about a single rigid body constructed from a - * BRL-CAD region. This structure is the node of a linked list - * containing the geometry to be added to the sim. - * - * TODO: Only the bb is currently present, but physical properties - * like elasticity, custom forces will be added later. - */ -#define MAX_MANIFOLDS 4 - struct rigid_body { - int index; - char *rb_namep; /**< @brief pointer to name string */ - point_t bb_min; /**< @brief body min bb bounds, only calculated 1st time */ - point_t bb_max; /**< @brief body max bb bounds, only calculated 1st time */ - point_t bb_center; /**< @brief bb center */ - point_t bb_dims; /**< @brief bb dimensions */ - point_t btbb_min; /**< @brief Bullet body min bb bounds, updated after each iter. */ - point_t btbb_max; /**< @brief Bullet body max bb bounds, updated after each iter. */ - point_t btbb_center; /**< @brief Bullet bb center */ - point_t btbb_dims; /**< @brief Bullet bb dimensions */ - mat_t m; /**< @brief transformation matrix from Bullet */ - mat_t m_prev; /**< @brief previous transformation matrix from Bullet */ - int state; /**< @brief rigid body state from Bullet */ - struct directory - *dp; /**< @brief directory pointer to the related region */ - struct rt_db_internal - intern; /**< @brief internal format of the related region */ - struct rigid_body *next; /**< @brief link to next body */ - - /* Can be set by libged or Bullet(checked and inserted into sim) */ - vect_t linear_velocity; /**< @brief linear velocity components */ - vect_t angular_velocity; /**< @brief angular velocity components */ - - /* Manifold generated by Bullet, where this body is B, only body B has manifold info */ - int num_bt_manifolds; /**< @brief number of manifolds for this body */ - struct sim_manifold - bt_manifold[MAX_MANIFOLDS]; /**< @brief the manifolds for this body */ - - /* Manifold generated by RT, where this body is B, ONLY 1 needed as its injected into the physics - * pipeline immediately after creation thus allowing the next one to replace it - */ - struct sim_manifold - rt_manifold; /**< @brief only 1 manifold struct needed as the manifold is used - immediately after being generated in the nearphase callback*/ - - /* Debugging */ - int iter; - }; - - - /** - * Shoots rays within the AABB overlap regions only, to allow more rays to be shot - * in a grid of finer granularity and to increase performance. The bodies to be targeted - * are got from the list of manifolds returned by Bullet which carries out AABB - * intersection checks. These manifolds are stored in the corresponding rigid_body - * structures of each body participating in the simulation. The manifolds are then used - * to generate manifolds based on raytracing and stored in a separate list for the body B - * of that particular manifold. The list is freed in the next iteration in this function - * as well, to prevent memory leaks, before a new set manifolds are created. - */ - - int - generate_manifolds(struct simulation_params *sim_params, - struct rigid_body *rbA, - struct rigid_body *rbB); - -#if defined __cplusplus -} /* matches the linkage specification at the beginning. */ -#endif - - -#endif /* LIBGED_SIMULATE_SIMRT_H */ - -/* - * 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 - */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2015-03-13 16:17:51
|
Revision: 64392 http://sourceforge.net/p/brlcad/code/64392 Author: starseeker Date: 2015-03-13 16:17:49 +0000 (Fri, 13 Mar 2015) Log Message: ----------- Enable the csg logic as a 'brep objname csg' subcommand. Modified Paths: -------------- brlcad/trunk/src/libged/CMakeLists.txt brlcad/trunk/src/libged/brep.c brlcad/trunk/src/libged/ged_private.h brlcad/trunk/src/libged/shape_recognition.cpp Modified: brlcad/trunk/src/libged/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libged/CMakeLists.txt 2015-03-13 15:50:46 UTC (rev 64391) +++ brlcad/trunk/src/libged/CMakeLists.txt 2015-03-13 16:17:49 UTC (rev 64392) @@ -249,6 +249,7 @@ shaded_mode.c shader.c shells.c + shape_recognition.cpp showmats.c simulate/collision.cpp simulate/physics_world.cpp @@ -337,7 +338,6 @@ ged_private.h joint.h qray.h - shape_recognition.cpp simulate/collision.hpp simulate/physics_world.hpp simulate/rt_instance.hpp Modified: brlcad/trunk/src/libged/brep.c =================================================================== --- brlcad/trunk/src/libged/brep.c 2015-03-13 15:50:46 UTC (rev 64391) +++ brlcad/trunk/src/libged/brep.c 2015-03-13 16:17:49 UTC (rev 64392) @@ -299,6 +299,7 @@ if (BU_STR_EQUAL(argv[2], "csg")) { /* Call csg conversion routine */ + return _ged_brep_to_csg(gedp, argv[1]); } /* make sure arg isn't --no-evaluate */ Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2015-03-13 15:50:46 UTC (rev 64391) +++ brlcad/trunk/src/libged/ged_private.h 2015-03-13 16:17:49 UTC (rev 64392) @@ -524,6 +524,8 @@ */ extern int _ged_results_add(struct ged_results *results, const char *result_string); +extern int _ged_brep_to_csg(struct ged *gedp, const char *obj_name); + __END_DECLS #endif /* LIBGED_GED_PRIVATE_H */ Modified: brlcad/trunk/src/libged/shape_recognition.cpp =================================================================== --- brlcad/trunk/src/libged/shape_recognition.cpp 2015-03-13 15:50:46 UTC (rev 64391) +++ brlcad/trunk/src/libged/shape_recognition.cpp 2015-03-13 16:17:49 UTC (rev 64392) @@ -10,11 +10,8 @@ #include <algorithm> #include "vmath.h" -#include "raytrace.h" #include "wdb.h" -#include "plot3.h" -#include "opennurbs.h" -#include "brep.h" +#include "ged.h" #include "../libbrep/shape_recognition.h" #define ptout(p) p.x << " " << p.y << " " << p.z @@ -407,42 +404,27 @@ return 0; } -int -main(int argc, char *argv[]) +extern "C" int +_ged_brep_to_csg(struct ged *gedp, const char *dp_name) { - struct db_i *dbip; - struct rt_wdb *wdbp; - struct directory *dp; struct rt_db_internal intern; struct rt_brep_internal *brep_ip = NULL; - if (argc != 3) { - bu_exit(1, "Usage: %s file.g object", argv[0]); - } + struct rt_wdb *wdbp = gedp->ged_wdbp; - dbip = db_open(argv[1], DB_OPEN_READWRITE); - if (dbip == DBI_NULL) { - bu_exit(1, "ERROR: Unable to read from %s\n", argv[1]); - } - - wdbp = wdb_dbopen(dbip, RT_WDB_TYPE_DB_DISK); - - if (db_dirbuild(dbip) < 0) - bu_exit(1, "ERROR: Unable to read from %s\n", argv[1]); - - dp = db_lookup(dbip, argv[2], LOOKUP_QUIET); + struct directory *dp = db_lookup(wdbp->dbip, dp_name, LOOKUP_QUIET); if (dp == RT_DIR_NULL) { - bu_exit(1, "ERROR: Unable to look up object %s\n", argv[2]); + return GED_ERROR; } RT_DB_INTERNAL_INIT(&intern) - if (rt_db_get_internal(&intern, dp, dbip, NULL, &rt_uniresource) < 0) { - bu_exit(1, "ERROR: Unable to get internal representation of %s\n", argv[2]); + if (rt_db_get_internal(&intern, dp, wdbp->dbip, NULL, &rt_uniresource) < 0) { + return GED_ERROR; } if (intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BREP) { - bu_exit(1, "ERROR: object %s does not appear to be of type BRep\n", argv[2]); + return GED_ERROR; } else { brep_ip = (struct rt_brep_internal *)intern.idb_ptr; } @@ -451,17 +433,14 @@ ON_Brep *brep = brep_ip->brep; struct wmember pcomb; struct bu_vls comb_name = BU_VLS_INIT_ZERO; - bu_vls_sprintf(&comb_name, "%s_csg.c", dp->d_namep); + bu_vls_sprintf(&comb_name, "%s_csg", dp->d_namep); BU_LIST_INIT(&pcomb.l); struct bu_ptbl *subbreps = find_subbreps(brep); struct bu_ptbl *subbreps_tree = find_top_level_hierarchy(subbreps); for (unsigned int i = 0; i < BU_PTBL_LEN(subbreps); i++){ struct subbrep_object_data *obj = (struct subbrep_object_data *)BU_PTBL_GET(subbreps, i); - //print_subbrep_object(obj, ""); (void)make_shapes(obj, wdbp, NULL, 0); - //subbrep_object_free(obj); - //BU_PUT(obj, struct subbrep_object_data); } struct wmember *ccomb = NULL; @@ -511,9 +490,7 @@ // TODO - probably should be region mk_lcomb(wdbp, bu_vls_addr(&comb_name), &pcomb, 0, NULL, NULL, NULL, 0); - db_close(dbip); - - return 0; + return GED_OK; } // Local Variables: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2015-03-19 20:11:28
|
Revision: 64457 http://sourceforge.net/p/brlcad/code/64457 Author: starseeker Date: 2015-03-19 20:11:21 +0000 (Thu, 19 Mar 2015) Log Message: ----------- More getting set for comb handling. Modified Paths: -------------- brlcad/trunk/src/libged/brep.c brlcad/trunk/src/libged/shape_recognition.cpp Modified: brlcad/trunk/src/libged/brep.c =================================================================== --- brlcad/trunk/src/libged/brep.c 2015-03-19 20:01:25 UTC (rev 64456) +++ brlcad/trunk/src/libged/brep.c 2015-03-19 20:11:21 UTC (rev 64457) @@ -305,20 +305,15 @@ if (BU_STR_EQUAL(argv[2], "csg")) { /* Call csg conversion routine */ - - if (intern.idb_type == ID_COMBINATION) { - struct bu_vls bname_csg; - bu_vls_init(&bname_csg); - bu_vls_sprintf(&bname_csg, "csg_%s", solid_name); - if (db_lookup(gedp->ged_wdbp->dbip, bu_vls_addr(&bname_csg), LOOKUP_QUIET) != RT_DIR_NULL) { - bu_vls_printf(gedp->ged_result_str, "%s already exists.", bu_vls_addr(&bname_csg)); - bu_vls_free(&bname_csg); - return GED_OK; - } - bu_log("TODO - csg brep tree conversion\n"); + struct bu_vls bname_csg; + bu_vls_init(&bname_csg); + bu_vls_sprintf(&bname_csg, "csg_%s", solid_name); + if (db_lookup(gedp->ged_wdbp->dbip, bu_vls_addr(&bname_csg), LOOKUP_QUIET) != RT_DIR_NULL) { + bu_vls_printf(gedp->ged_result_str, "%s already exists.", bu_vls_addr(&bname_csg)); bu_vls_free(&bname_csg); return GED_OK; } + bu_vls_free(&bname_csg); return _ged_brep_to_csg(gedp, argv[1]); } Modified: brlcad/trunk/src/libged/shape_recognition.cpp =================================================================== --- brlcad/trunk/src/libged/shape_recognition.cpp 2015-03-19 20:01:25 UTC (rev 64456) +++ brlcad/trunk/src/libged/shape_recognition.cpp 2015-03-19 20:11:21 UTC (rev 64457) @@ -355,6 +355,7 @@ } if (intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BREP) { + bu_vls_printf(gedp->ged_result_str, "%s is not a B-Rep - aborting\n", dp->d_namep); return 1; } else { brep_ip = (struct rt_brep_internal *)intern.idb_ptr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2015-04-22 13:36:39
|
Revision: 64692 http://sourceforge.net/p/brlcad/code/64692 Author: starseeker Date: 2015-04-22 13:36:31 +0000 (Wed, 22 Apr 2015) Log Message: ----------- gdiff ged command will need an option for raytrace based testing. Modified Paths: -------------- brlcad/trunk/src/libged/CMakeLists.txt brlcad/trunk/src/libged/gdiff.c Modified: brlcad/trunk/src/libged/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libged/CMakeLists.txt 2015-04-22 13:24:49 UTC (rev 64691) +++ brlcad/trunk/src/libged/CMakeLists.txt 2015-04-22 13:36:31 UTC (rev 64692) @@ -115,6 +115,7 @@ get_solid_kp.c get_type.c glob.c + gdiff.c gqa.c grid.c grid2model_lu.c Modified: brlcad/trunk/src/libged/gdiff.c =================================================================== --- brlcad/trunk/src/libged/gdiff.c 2015-04-22 13:24:49 UTC (rev 64691) +++ brlcad/trunk/src/libged/gdiff.c 2015-04-22 13:36:31 UTC (rev 64692) @@ -61,7 +61,7 @@ bu_opterr = 1; /* parse args */ - while ((c=bu_getopt(argc, (char * const *)argv, "O:N:vh?")) != -1) { + while ((c=bu_getopt(argc, (char * const *)argv, "O:N:vhr?")) != -1) { if (bu_optopt == '?') c='h'; switch (c) { @@ -78,6 +78,9 @@ case 'v' : bu_log("Reporting mode is verbose"); break; + case 'r' : + bu_log("Raytrace based evaluation of differences between objects."); + break; default: bu_vls_printf(gedp->ged_result_str, "Usage: %s", gdiff_usage()); return GED_ERROR; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2015-07-15 15:58:23
|
Revision: 65644 http://sourceforge.net/p/brlcad/code/65644 Author: starseeker Date: 2015-07-15 15:58:20 +0000 (Wed, 15 Jul 2015) Log Message: ----------- Add a way to proceed with and without verification - should probably make this a user settable value (maybe both the multiplier and an absolute tolerance?) Modified Paths: -------------- brlcad/trunk/src/libged/brep.c brlcad/trunk/src/libged/ged_private.h brlcad/trunk/src/libged/shape_recognition.cpp Modified: brlcad/trunk/src/libged/brep.c =================================================================== --- brlcad/trunk/src/libged/brep.c 2015-07-15 15:35:50 UTC (rev 65643) +++ brlcad/trunk/src/libged/brep.c 2015-07-15 15:58:20 UTC (rev 65644) @@ -314,9 +314,23 @@ return GED_OK; } bu_vls_free(&bname_csg); - return _ged_brep_to_csg(gedp, argv[1]); + return _ged_brep_to_csg(gedp, argv[1], 0); } + if (BU_STR_EQUAL(argv[2], "csgv")) { + /* Call csg conversion routine */ + struct bu_vls bname_csg; + bu_vls_init(&bname_csg); + bu_vls_sprintf(&bname_csg, "csg_%s", solid_name); + if (db_lookup(gedp->ged_wdbp->dbip, bu_vls_addr(&bname_csg), LOOKUP_QUIET) != RT_DIR_NULL) { + bu_vls_printf(gedp->ged_result_str, "%s already exists.", bu_vls_addr(&bname_csg)); + bu_vls_free(&bname_csg); + return GED_OK; + } + bu_vls_free(&bname_csg); + return _ged_brep_to_csg(gedp, argv[1], 1); + } + /* make sure arg isn't --no-evaluate */ if (argc > 2 && argv[2][1] != '-') { op = db_str2op(argv[2]); Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2015-07-15 15:35:50 UTC (rev 65643) +++ brlcad/trunk/src/libged/ged_private.h 2015-07-15 15:58:20 UTC (rev 65644) @@ -524,7 +524,7 @@ */ extern int _ged_results_add(struct ged_results *results, const char *result_string); -extern int _ged_brep_to_csg(struct ged *gedp, const char *obj_name); +extern int _ged_brep_to_csg(struct ged *gedp, const char *obj_name, int verify); __END_DECLS Modified: brlcad/trunk/src/libged/shape_recognition.cpp =================================================================== --- brlcad/trunk/src/libged/shape_recognition.cpp 2015-07-15 15:35:50 UTC (rev 65643) +++ brlcad/trunk/src/libged/shape_recognition.cpp 2015-07-15 15:58:20 UTC (rev 65644) @@ -403,7 +403,7 @@ * 2 not a valid brep */ int -brep_to_csg(struct ged *gedp, struct directory *dp) +brep_to_csg(struct ged *gedp, struct directory *dp, int verify) { struct rt_db_internal intern; struct rt_brep_internal *brep_ip = NULL; @@ -522,11 +522,12 @@ // Verify that the resulting csg tree and the original B-Rep pass a difference test. - { + if (verify) { ON_BoundingBox bbox; struct bn_tol tol = {BN_TOL_MAGIC, BN_TOL_DIST, BN_TOL_DIST * BN_TOL_DIST, 1.0e-6, 1.0 - 1.0e-6 }; brep->GetBoundingBox(bbox); tol.dist = (bbox.Diagonal().Length() / 1000.0); + bu_log("Analyzing %s csg conversion, tol %f...\n", dp->d_namep, tol.dist); if (analyze_raydiff(NULL, gedp->ged_wdbp->dbip, dp->d_namep, bu_vls_addr(&comb_name), &tol, 1)) { /* TODO - kill tree if debugging flag isn't passed - not valid */ bu_log("Warning - %s did not pass diff test at tol %f!\n", bu_vls_addr(&comb_name), tol.dist); @@ -536,10 +537,10 @@ return 0; } -int comb_to_csg(struct ged *gedp, struct directory *dp); +int comb_to_csg(struct ged *gedp, struct directory *dp, int verify); int -brep_csg_conversion_tree(struct ged *gedp, const union tree *oldtree, union tree *newtree) +brep_csg_conversion_tree(struct ged *gedp, const union tree *oldtree, union tree *newtree, int verify) { int ret = 0; *newtree = *oldtree; @@ -552,7 +553,7 @@ //bu_log("convert right\n"); newtree->tr_b.tb_right = new tree; RT_TREE_INIT(newtree->tr_b.tb_right); - ret = brep_csg_conversion_tree(gedp, oldtree->tr_b.tb_right, newtree->tr_b.tb_right); + ret = brep_csg_conversion_tree(gedp, oldtree->tr_b.tb_right, newtree->tr_b.tb_right, verify); #if 0 if (ret) { delete newtree->tr_b.tb_right; @@ -567,7 +568,7 @@ //bu_log("convert left\n"); BU_ALLOC(newtree->tr_b.tb_left, union tree); RT_TREE_INIT(newtree->tr_b.tb_left); - ret = brep_csg_conversion_tree(gedp, oldtree->tr_b.tb_left, newtree->tr_b.tb_left); + ret = brep_csg_conversion_tree(gedp, oldtree->tr_b.tb_left, newtree->tr_b.tb_left, verify); #if 0 if (ret) { delete newtree->tr_b.tb_left; @@ -587,7 +588,7 @@ if (dir != RT_DIR_NULL) { if (dir->d_flags & RT_DIR_COMB) { - ret = comb_to_csg(gedp, dir); + ret = comb_to_csg(gedp, dir, verify); if (ret) { bu_vls_free(&tmpname); break; @@ -598,7 +599,7 @@ } // It's a primitive. If it's a b-rep object, convert it. Otherwise, // just duplicate it. Might need better error codes from brep_to_csg for this... - int brep_c = brep_to_csg(gedp, dir); + int brep_c = brep_to_csg(gedp, dir, verify); int need_break = 0; switch (brep_c) { case 0: @@ -634,7 +635,7 @@ } int -comb_to_csg(struct ged *gedp, struct directory *dp) +comb_to_csg(struct ged *gedp, struct directory *dp, int verify) { struct rt_db_internal intern; struct rt_comb_internal *comb_internal = NULL; @@ -668,23 +669,23 @@ union tree *newtree = new_internal->tree; - (void)brep_csg_conversion_tree(gedp, oldtree, newtree); + (void)brep_csg_conversion_tree(gedp, oldtree, newtree, verify); (void)wdb_export(wdbp, bu_vls_addr(&comb_name), (void *)new_internal, ID_COMBINATION, 1); return 0; } extern "C" int -_ged_brep_to_csg(struct ged *gedp, const char *dp_name) +_ged_brep_to_csg(struct ged *gedp, const char *dp_name, int verify) { struct rt_wdb *wdbp = gedp->ged_wdbp; struct directory *dp = db_lookup(wdbp->dbip, dp_name, LOOKUP_QUIET); if (dp == RT_DIR_NULL) return GED_ERROR; if (dp->d_flags & RT_DIR_COMB) { - return comb_to_csg(gedp, dp) ? GED_ERROR : GED_OK; + return comb_to_csg(gedp, dp, verify) ? GED_ERROR : GED_OK; } else { - return brep_to_csg(gedp, dp) ? GED_ERROR : GED_OK; + return brep_to_csg(gedp, dp, verify) ? GED_ERROR : GED_OK; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2015-08-02 20:10:10
|
Revision: 65797 http://sourceforge.net/p/brlcad/code/65797 Author: starseeker Date: 2015-08-02 20:10:07 +0000 (Sun, 02 Aug 2015) Log Message: ----------- Apply patch #395 from Brad Hollister - add kill V subcommand Modified Paths: -------------- brlcad/trunk/src/libged/CMakeLists.txt brlcad/trunk/src/libged/nmg.c brlcad/trunk/src/libged/nmg_cmface.c Added Paths: ----------- brlcad/trunk/src/libged/nmg_kill_v.c Removed Paths: ------------- brlcad/trunk/src/libged/nmg_cface.c brlcad/trunk/src/libged/nmg_eins.c brlcad/trunk/src/libged/nmg_esplit.c brlcad/trunk/src/libged/nmg_eusplit.c brlcad/trunk/src/libged/nmg_keu.c brlcad/trunk/src/libged/nmg_kfu.c brlcad/trunk/src/libged/nmg_klu.c brlcad/trunk/src/libged/nmg_km.c brlcad/trunk/src/libged/nmg_kr.c brlcad/trunk/src/libged/nmg_ks.c brlcad/trunk/src/libged/nmg_kvu.c brlcad/trunk/src/libged/nmg_me.c brlcad/trunk/src/libged/nmg_meonvu.c brlcad/trunk/src/libged/nmg_mf.c brlcad/trunk/src/libged/nmg_ml.c brlcad/trunk/src/libged/nmg_mlv.c brlcad/trunk/src/libged/nmg_mmr.c brlcad/trunk/src/libged/nmg_mrsv.c brlcad/trunk/src/libged/nmg_msv.c brlcad/trunk/src/libged/nmg_mvu.c brlcad/trunk/src/libged/nmg_mvvu.c Modified: brlcad/trunk/src/libged/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libged/CMakeLists.txt 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/CMakeLists.txt 2015-08-02 20:10:07 UTC (rev 65797) @@ -162,31 +162,11 @@ nirt.c nmg.c nmg_mm.c - nmg_me.c - nmg_eins.c - nmg_esplit.c - nmg_eusplit.c - nmg_meonvu.c - nmg_mf.c - nmg_ml.c - nmg_mlv.c - nmg_mmr.c - nmg_mrsv.c - nmg_msv.c - nmg_mvu.c - nmg_mvvu.c - nmg_cface.c nmg_cmface.c - nmg_keu.c - nmg_kfu.c - nmg_klu.c - nmg_km.c - nmg_kr.c - nmg_ks.c - nmg_kvu.c nmg_collapse.c nmg_fix_normals.c nmg_simplify.c + nmg_kill_v.c ocenter.c open.c orient.c @@ -375,3 +355,4 @@ # indent-tabs-mode: t # End: # ex: shiftwidth=2 tabstop=8 + Modified: brlcad/trunk/src/libged/nmg.c =================================================================== --- brlcad/trunk/src/libged/nmg.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -36,168 +36,54 @@ #include "./ged_private.h" extern int ged_nmg_mm(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_mmr(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_msv(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_mrsv(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_mvvu(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_mvu(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_me(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_meonvu(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_eusplit(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_esplit(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_eins(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_ml(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_mlv(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_mf(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_cface(struct ged *gedp, int argc, const char *argv[]); extern int ged_nmg_cmface(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_keu(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_kfu(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_klu(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_km(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_kr(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_ks(struct ged *gedp, int argc, const char *argv[]); -extern int ged_nmg_kvu(struct ged *gedp, int argc, const char *argv[]); +extern int ged_nmg_kill_v(struct ged *gedp, int argc, const char *argv[]); int ged_nmg(struct ged *gedp, int argc, const char *argv[]) { - static const char *usage = "nmg [command|suffix] "; - const char *subcmd = argv[1]; + static const char *usage = "nmg object subcommand [V|F|R|S] [suffix]"; + const char *subcmd = argv[2]; GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); /* must be wanting help */ - if (argc < 2) { + if (argc < 3) { bu_vls_printf(gedp->ged_result_str, "Usage: %s\n\t%s\n", argv[0], usage); bu_vls_printf(gedp->ged_result_str, "commands:\n"); bu_vls_printf(gedp->ged_result_str, "\tmm - creates a new " "NMG model structure and fills the appropriate fields. The result " "is an empty model.\n"); - bu_vls_printf(gedp->ged_result_str, "\tmmr - creates a new " - "model and creates a region within the model.\n"); - bu_vls_printf(gedp->ged_result_str, "\tmsv - creates a new " - "shell consisting of a single vertex in the parameter region. A " - "new vertex is created for the shell.\n"); - bu_vls_printf(gedp->ged_result_str, "\tmrsv - creates a new " - "region within the existing model, and creates a shell of a single " - "vertex within the region.\n"); - bu_vls_printf(gedp->ged_result_str, "\tmvvu - exists so that " - "shells, loops and edges can be created on a new vertex.\n"); - bu_vls_printf(gedp->ged_result_str, "\tmvu - allocates a new " - "vertexuse for an existing vertex.\n"); - bu_vls_printf(gedp->ged_result_str, "\tme - creates a new " - "wire edge in the shell specified.\n"); - bu_vls_printf(gedp->ged_result_str, "\tmeonvu - is used to create " - "an edge on a vertex in a loop or shell. The resultant edge has " - "the same vertex at each endpoint.\n"); - bu_vls_printf(gedp->ged_result_str, "\teusplit - splits an " - "existing edgeuse pair of a wire or dangling face-edge by " - "inserting a new vertex.\n"); - bu_vls_printf(gedp->ged_result_str, "\tesplit - causes a new " - "vertex to be inserted along an existing edge.\n"); - bu_vls_printf(gedp->ged_result_str, "\teins - inserts a new, " - "zero length edge between the edge associated with the parameter " - "edgeuse and the edge associated with the edgeuse previous to the " - "parameter edgeuse.\n"); - bu_vls_printf(gedp->ged_result_str, "\tml - takes the largest " - "possible number of contiguous wire edges which form a circuit " - "from the parameter shell and uses them to create a wire loop in " - "the shell.\n"); - bu_vls_printf(gedp->ged_result_str, "\tmlv - creates a new " - "vertex-loop. The loop will be a child of the structure indicated " - "by the magic number pointer parameter, and will have the " - "specified orientation. If the vertex is NULL, a new vertex is " - "created for the loop.\n"); - bu_vls_printf(gedp->ged_result_str, "\tmlf - generates a new " - "face from the parameter wire loop and its mate.\n"); + bu_vls_printf(gedp->ged_result_str, "\tcmface - creates a " + "manifold face in the first encountered shell of the NMG " + "object. Vertices are listed as the suffix and define the " + "winding-order of the face.\n"); + bu_vls_printf(gedp->ged_result_str, "\tkill V - removes the " + "vertexuse and vertex geometry of the selected vertex (via its " + "coordinates) and higher-order topology containing the vertex. " + "When specifying vertex to be removed, user generally will display " + "vertex coordinates in object via the MGED command labelvert.\n"); return GED_HELP; } - if (argc < 2) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_ERROR; + if (argc < 3) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; } /* advance CLI arguments for subcommands */ --argc; ++argv; - /* NMG CONSTRUCTION ROUTINES */ if( BU_STR_EQUAL( "mm", subcmd ) ) { ged_nmg_mm(gedp, argc, argv); } - else if( BU_STR_EQUAL( "mmr", subcmd ) ) { - ged_nmg_mmr(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "msv", subcmd ) ) { - ged_nmg_msv(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "mrsv", subcmd ) ) { - ged_nmg_mrsv(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "mvvu", subcmd ) ) { - ged_nmg_mvvu(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "mvu", subcmd ) ) { - ged_nmg_mvu(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "me", subcmd ) ) { - ged_nmg_me(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "meonvu", subcmd ) ) { - ged_nmg_meonvu(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "eusplit", subcmd ) ) { - ged_nmg_eusplit(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "esplit", subcmd ) ) { - ged_nmg_esplit(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "eins", subcmd ) ) { - ged_nmg_eins(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "ml", subcmd ) ) { - ged_nmg_ml(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "mlv", subcmd ) ) { - ged_nmg_mlv(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "mf", subcmd ) ) { - ged_nmg_mf(gedp, argc, argv); - } - - /* NMG CONSTRUCTION CONVENIENCE ROUTINES */ - else if( BU_STR_EQUAL( "cface", subcmd ) ) { - ged_nmg_cface(gedp, argc, argv); - } else if( BU_STR_EQUAL( "cmface", subcmd ) ) { ged_nmg_cmface(gedp, argc, argv); } - - /* NMG DESTRUCTION ROUTINES */ - else if( BU_STR_EQUAL( "keu", subcmd ) ) { - ged_nmg_keu(gedp, argc, argv); + else if( BU_STR_EQUAL( "kill", subcmd ) ) { + ged_nmg_kill_v(gedp, argc, argv); } - else if( BU_STR_EQUAL( "kfu", subcmd ) ) { - ged_nmg_kfu(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "klu", subcmd ) ) { - ged_nmg_klu(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "km", subcmd ) ) { - ged_nmg_km(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "kr", subcmd ) ) { - ged_nmg_kr(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "ks", subcmd ) ) { - ged_nmg_ks(gedp, argc, argv); - } - else if( BU_STR_EQUAL( "kvu", subcmd ) ) { - ged_nmg_kvu(gedp, argc, argv); - } - else { bu_vls_printf(gedp->ged_result_str, "%s is not a subcommand.", subcmd ); return GED_ERROR; Deleted: brlcad/trunk/src/libged/nmg_cface.c =================================================================== --- brlcad/trunk/src/libged/nmg_cface.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_cface.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,50 +0,0 @@ -/* N M G _ C F A C E . C - * BRL-CAD - * - * Copyright (c) 2015 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/nmg_cface.c - * - * The cface command. - * - */ - -#include "common.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_cface(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Modified: brlcad/trunk/src/libged/nmg_cmface.c =================================================================== --- brlcad/trunk/src/libged/nmg_cmface.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_cmface.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -54,7 +54,7 @@ struct vertex ***face_verts; int idx, num_verts; - static const char *usage = "nmg_name x0 y0 z0 ... xn yn zn"; + static const char *usage = "nmg_name cmface x0 y0 z0 ... xn yn zn"; GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); GED_CHECK_READ_ONLY(gedp, GED_ERROR); @@ -69,7 +69,7 @@ } /* attempt to resolve and verify */ - name = argv[1]; + name = argv[0]; if ( (dp=db_lookup(gedp->ged_wdbp->dbip, name, LOOKUP_QUIET)) == RT_DIR_NULL ) { Deleted: brlcad/trunk/src/libged/nmg_eins.c =================================================================== --- brlcad/trunk/src/libged/nmg_eins.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_eins.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,48 +0,0 @@ -/* N M G _ E I N S . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_eins.c - * - * The nmg_eins command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int ged_nmg_eins(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_esplit.c =================================================================== --- brlcad/trunk/src/libged/nmg_esplit.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_esplit.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,48 +0,0 @@ -/* N M G _ E S P L I T . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_esplit.c - * - * The nmg_esplit command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int ged_nmg_esplit(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_eusplit.c =================================================================== --- brlcad/trunk/src/libged/nmg_eusplit.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_eusplit.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,48 +0,0 @@ -/* N M G _ E U S P L I T . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_eusplit.c - * - * The nmg_eusplit command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int ged_nmg_eusplit(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_keu.c =================================================================== --- brlcad/trunk/src/libged/nmg_keu.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_keu.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,50 +0,0 @@ -/* N M G _ K E U . C - * BRL-CAD - * - * Copyright (c) 2015 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/nmg_keu.c - * - * The keu command. - * - */ - -#include "common.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_keu(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_kfu.c =================================================================== --- brlcad/trunk/src/libged/nmg_kfu.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_kfu.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,50 +0,0 @@ -/* N M G _ K F U . C - * BRL-CAD - * - * Copyright (c) 2015 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/nmg_kfu.c - * - * The kfu command. - * - */ - -#include "common.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_kfu(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Added: brlcad/trunk/src/libged/nmg_kill_v.c =================================================================== --- brlcad/trunk/src/libged/nmg_kill_v.c (rev 0) +++ brlcad/trunk/src/libged/nmg_kill_v.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -0,0 +1,329 @@ +/* N M G _ K I L L _ V. C + * BRL-CAD + * + * Copyright (c) 2015 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/nmg_kill_v.c + * + * The kill V subcommand for nmg top-level command. + * + */ + +#include "common.h" + +#include <string.h> + +#include "bu/cmd.h" +#include "rt/geom.h" + +#include "./ged_private.h" + +void remove_vertex(const struct model* m, point_t rv) +{ + struct nmgregion *r; + struct shell *s; + struct faceuse *fu; + struct face *f; + struct loopuse *lu; + struct loop *l; + struct edgeuse *eu; + struct edge *e; + struct vertexuse *vu; + struct vertex *v; + + NMG_CK_MODEL(m); + + /* Traverse NMG model and remove instances of vertexuses. + * In addition to vertex being removed, associated faceuses, loopuses + * and edgeuses need to be removed that contained the deleted vertexuse. + */ + + for (BU_LIST_FOR(r, nmgregion, &m->r_hd)) { + NMG_CK_REGION(r); + + if (r->ra_p) { + NMG_CK_REGION_A(r->ra_p); + } + + for (BU_LIST_FOR(s, shell, &r->s_hd)) { + NMG_CK_SHELL(s); + + if (s->sa_p) { + NMG_CK_SHELL_A(s->sa_p); + } + + /* Faces in shell */ + for (BU_LIST_FOR(fu, faceuse, &s->fu_hd)) { + NMG_CK_FACEUSE(fu); + f = fu->f_p; + NMG_CK_FACE(f); + + if (f->g.magic_p) switch (*f->g.magic_p) { + case NMG_FACE_G_PLANE_MAGIC: + break; + case NMG_FACE_G_SNURB_MAGIC: + break; + } + + /* Loops in face */ + for (BU_LIST_FOR(lu, loopuse, &fu->lu_hd)) { + NMG_CK_LOOPUSE(lu); + l = lu->l_p; + NMG_CK_LOOP(l); + + if (l->lg_p) { + NMG_CK_LOOP_G(l->lg_p); + } + + if (BU_LIST_FIRST_MAGIC(&lu->down_hd) == NMG_VERTEXUSE_MAGIC) { + /* Loop of Lone vertex */ + vu = BU_LIST_FIRST(vertexuse, &lu->down_hd); + + /* check and remove vertexuse */ + NMG_CK_VERTEXUSE(vu); + v = vu->v_p; + NMG_CK_VERTEX(v); + + if (v->vg_p) { + NMG_CK_VERTEX_G(v->vg_p); + + if ( VNEAR_EQUAL(v->vg_p->coord, rv, BN_TOL_DIST) ) { + nmg_kvu(vu); + nmg_klu(lu); + } + } + + continue; + } + + for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) { + NMG_CK_EDGEUSE(eu); + e = eu->e_p; + NMG_CK_EDGE(e); + + if (eu->g.magic_p) { + switch (*eu->g.magic_p) { + case NMG_EDGE_G_LSEG_MAGIC: + break; + case NMG_EDGE_G_CNURB_MAGIC: + break; + } + } + + vu = eu->vu_p; + + /* check and remove vertexuse */ + NMG_CK_VERTEXUSE(vu); + v = vu->v_p; + NMG_CK_VERTEX(v); + + if (v->vg_p) { + NMG_CK_VERTEX_G(v->vg_p); + + if ( VNEAR_EQUAL(v->vg_p->coord, + rv, BN_TOL_DIST) ) { + nmg_kvu(vu); + nmg_keu(eu); + nmg_klu(lu); + } + } + } + } + } + + /* Wire loops in shell */ + for (BU_LIST_FOR(lu, loopuse, &s->lu_hd)) { + NMG_CK_LOOPUSE(lu); + l = lu->l_p; + NMG_CK_LOOP(l); + + if (l->lg_p) { + NMG_CK_LOOP_G(l->lg_p); + } + + if (BU_LIST_FIRST_MAGIC(&lu->down_hd) == NMG_VERTEXUSE_MAGIC) { + /* Wire loop of Lone vertex */ + vu = BU_LIST_FIRST(vertexuse, &lu->down_hd); + /* check and remove vertexuse */ + NMG_CK_VERTEXUSE(vu); + v = vu->v_p; + NMG_CK_VERTEX(v); + if (v->vg_p) { + NMG_CK_VERTEX_G(v->vg_p); + if ( VNEAR_EQUAL(v->vg_p->coord, rv, BN_TOL_DIST) ) { + nmg_kvu(vu); + nmg_klu(lu); + } + } + continue; + } + + for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) { + NMG_CK_EDGEUSE(eu); + e = eu->e_p; + NMG_CK_EDGE(e); + + if (eu->g.magic_p) switch (*eu->g.magic_p) { + case NMG_EDGE_G_LSEG_MAGIC: + break; + case NMG_EDGE_G_CNURB_MAGIC: + break; + } + vu = eu->vu_p; + + /* check and remove vertexuse */ + NMG_CK_VERTEXUSE(vu); + v = vu->v_p; + NMG_CK_VERTEX(v); + + if (v->vg_p) { + NMG_CK_VERTEX_G(v->vg_p); + if ( VNEAR_EQUAL(v->vg_p->coord, rv, BN_TOL_DIST) ) { + nmg_kvu(vu); + nmg_keu(eu); + nmg_klu(lu); + } + } + } + } + + /* Wire edges in shell */ + for (BU_LIST_FOR(eu, edgeuse, &s->eu_hd)) { + NMG_CK_EDGEUSE(eu); + e = eu->e_p; + NMG_CK_EDGE(e); + + if (eu->g.magic_p) { + switch (*eu->g.magic_p) { + case NMG_EDGE_G_LSEG_MAGIC: + break; + case NMG_EDGE_G_CNURB_MAGIC: + break; + } + } + + vu = eu->vu_p; + + /* check and remove vertexuse */ + NMG_CK_VERTEXUSE(vu); + v = vu->v_p; + NMG_CK_VERTEX(v); + + if (v->vg_p) { + NMG_CK_VERTEX_G(v->vg_p); + + if ( VNEAR_EQUAL(v->vg_p->coord, rv, BN_TOL_DIST) ) { + nmg_kvu(vu); + nmg_keu(eu); + } + } + } + + /* Lone vertex in shell */ + vu = s->vu_p; + + if (vu) { + /* check and remove vertexuse */ + NMG_CK_VERTEXUSE(vu); + v = vu->v_p; + NMG_CK_VERTEX(v); + + if (v->vg_p) { + NMG_CK_VERTEX_G(v->vg_p); + + if ( VNEAR_EQUAL(v->vg_p->coord, rv, BN_TOL_DIST) ) { + nmg_kvu(vu); + } + } + } + } + } +} + +int +ged_nmg_kill_v(struct ged* gedp, int argc, const char* argv[]) +{ + struct rt_db_internal internal; + struct directory *dp; + struct model* m; + const char* name; + point_t vt; + + static const char *usage = "kill V x y z"; + + GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); + GED_CHECK_DRAWABLE(gedp, GED_ERROR); + GED_CHECK_READ_ONLY(gedp, GED_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); + + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); + + /* must be wanting help */ + if (argc < 6) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_HELP; + } + + /* attempt to resolve and verify */ + name = argv[0]; + + if ( (dp=db_lookup(gedp->ged_wdbp->dbip, name, LOOKUP_QUIET)) + == RT_DIR_NULL ) { + bu_vls_printf(gedp->ged_result_str, "%s does not exist\n", name); + return GED_ERROR; + } + + if (rt_db_get_internal(&internal, dp, gedp->ged_wdbp->dbip, + bn_mat_identity, &rt_uniresource) < 0) { + bu_vls_printf(gedp->ged_result_str, "rt_db_get_internal() error\n"); + return GED_ERROR; + } + + if (internal.idb_type != ID_NMG) { + bu_vls_printf(gedp->ged_result_str, "%s is not an NMG solid\n", name); + rt_db_free_internal(&internal); + return GED_ERROR; + } + + vt[0] = atof(argv[3]); vt[1] = atof(argv[4]); vt[2] = atof(argv[5]); + + m = (struct model *)internal.idb_ptr; + NMG_CK_MODEL(m); + + remove_vertex(m, vt); + + if ( wdb_put_internal(gedp->ged_wdbp, name, &internal, 1.0) < 0 ) { + bu_vls_printf(gedp->ged_result_str, "wdb_put_internal(%s)", argv[1]); + rt_db_free_internal(&internal); + return GED_ERROR; + } + + rt_db_free_internal(&internal); + + return GED_OK; +} + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: brlcad/trunk/src/libged/nmg_kill_v.c ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Deleted: brlcad/trunk/src/libged/nmg_klu.c =================================================================== --- brlcad/trunk/src/libged/nmg_klu.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_klu.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,50 +0,0 @@ -/* N M G _ K L U . C - * BRL-CAD - * - * Copyright (c) 2015 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/nmg_klu.c - * - * The klu command. - * - */ - -#include "common.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_klu(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_km.c =================================================================== --- brlcad/trunk/src/libged/nmg_km.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_km.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,50 +0,0 @@ -/* N M G _ K M . C - * BRL-CAD - * - * Copyright (c) 2015 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/nmg_km.c - * - * The km command. - * - */ - -#include "common.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_km(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_kr.c =================================================================== --- brlcad/trunk/src/libged/nmg_kr.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_kr.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,50 +0,0 @@ -/* N M G _ K R . C - * BRL-CAD - * - * Copyright (c) 2015 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/nmg_kr.c - * - * The kr command. - * - */ - -#include "common.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_kr(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_ks.c =================================================================== --- brlcad/trunk/src/libged/nmg_ks.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_ks.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,50 +0,0 @@ -/* N M G _ K S . C - * BRL-CAD - * - * Copyright (c) 2015 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/nmg_ks.c - * - * The ks command. - * - */ - -#include "common.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_ks(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_kvu.c =================================================================== --- brlcad/trunk/src/libged/nmg_kvu.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_kvu.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,50 +0,0 @@ -/* N M G _ K V U . C - * BRL-CAD - * - * Copyright (c) 2015 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/nmg_kvu.c - * - * The kvu command. - * - */ - -#include "common.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_kvu(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_me.c =================================================================== --- brlcad/trunk/src/libged/nmg_me.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_me.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,51 +0,0 @@ -/* N M G _ M E . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_me.c - * - * The nmg_me command. - * - */ - -#include "common.h" -#include "nmg.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_me(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_meonvu.c =================================================================== --- brlcad/trunk/src/libged/nmg_meonvu.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_meonvu.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,49 +0,0 @@ -/* N M G _ M E O N V U . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_meonvu.c - * - * The nmg_meonvu command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_meonvu(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_mf.c =================================================================== --- brlcad/trunk/src/libged/nmg_mf.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_mf.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,49 +0,0 @@ -/* N M G _ M F . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_mf.c - * - * The nmg_mf command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_mf(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_ml.c =================================================================== --- brlcad/trunk/src/libged/nmg_ml.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_ml.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,49 +0,0 @@ -/* N M G _ M L . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_ml.c - * - * The nmg_ml command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_ml(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_OK; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_mlv.c =================================================================== --- brlcad/trunk/src/libged/nmg_mlv.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_mlv.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,49 +0,0 @@ -/* N M G _ M L V . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_mlv.c - * - * The nmg_mlv command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_mlv(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_mmr.c =================================================================== --- brlcad/trunk/src/libged/nmg_mmr.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_mmr.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,50 +0,0 @@ -/* N M G _ M M R. C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_mmr.c - * - * The nmg_mmr command. - * - */ - -#include "common.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_mmr(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_mrsv.c =================================================================== --- brlcad/trunk/src/libged/nmg_mrsv.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_mrsv.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,49 +0,0 @@ -/* N M G _ M R S V . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_mrsv.c - * - * The nmg_mrsv command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_mrsv(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_msv.c =================================================================== --- brlcad/trunk/src/libged/nmg_msv.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_msv.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,49 +0,0 @@ -/* N M G _ M S V . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_msv.c - * - * The nmg_msv command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_msv(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_mvu.c =================================================================== --- brlcad/trunk/src/libged/nmg_mvu.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_mvu.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,51 +0,0 @@ -/* N M G _ M V U . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_mvu.c - * - * The nmg_mvu command. - * - */ - -#include "common.h" -#include "nmg.h" - -#include <signal.h> -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_mvu(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Deleted: brlcad/trunk/src/libged/nmg_mvvu.c =================================================================== --- brlcad/trunk/src/libged/nmg_mvvu.c 2015-08-02 20:00:07 UTC (rev 65796) +++ brlcad/trunk/src/libged/nmg_mvvu.c 2015-08-02 20:10:07 UTC (rev 65797) @@ -1,49 +0,0 @@ -/* N M G _ M V V U . C - * BRL-CAD - * - * Copyright (c) 2008-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 libged/nmg_mvvu.c - * - * The nmg_mvvu command. - * - */ - -#include "common.h" - -#include <string.h> - -#include "bu/cmd.h" -#include "rt/geom.h" - -#include "./ged_private.h" - -int -ged_nmg_mvvu(struct ged *UNUSED(gedp), int UNUSED(argc), const char *UNUSED(argv[])) -{ - return GED_ERROR; -} - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |