diff --git a/src/libged/CMakeLists.txt b/src/libged/CMakeLists.txt index ae5042e7fc..56e49066f4 100644 --- a/src/libged/CMakeLists.txt +++ b/src/libged/CMakeLists.txt @@ -169,6 +169,7 @@ set(LIBGED_SOURCES nmg_simplify.c nmg_kill_v.c nmg_kill_f.c + nmg_move_v.c ocenter.c open.c orient.c diff --git a/src/libged/nmg.c b/src/libged/nmg.c index 426fc56b22..b7d5e35454 100644 --- a/src/libged/nmg.c +++ b/src/libged/nmg.c @@ -39,6 +39,7 @@ extern int ged_nmg_mm(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_kill_v(struct ged *gedp, int argc, const char *argv[]); extern int ged_nmg_kill_f(struct ged *gedp, int argc, const char *argv[]); +extern int ged_nmg_move_v(struct ged *gedp, int argc, const char *argv[]); int ged_nmg(struct ged *gedp, int argc, const char *argv[]) @@ -69,6 +70,10 @@ ged_nmg(struct ged *gedp, int argc, const char *argv[]) "index). When specifying the face to be removed, user generally " "will display face indices in object via the MGED command " "labelface.\n"); + bu_vls_printf(gedp->ged_result_str, "\tmove V - moves an existing " + "vertex specified by the coordinates x_initial y_initial " + "z_initial to the position with coordinates x_final y_final " + "z_final.\n"); return GED_HELP; } @@ -95,6 +100,12 @@ ged_nmg(struct ged *gedp, int argc, const char *argv[]) ged_nmg_kill_f(gedp, argc, argv); } } + else if( BU_STR_EQUAL( "move", subcmd ) ) { + const char* opt = argv[2]; + if ( BU_STR_EQUAL( "V", opt ) ) { + ged_nmg_move_v(gedp, argc, argv); + } + } else { bu_vls_printf(gedp->ged_result_str, "%s is not a subcommand.", subcmd ); return GED_ERROR; diff --git a/src/libged/nmg_move_v.c b/src/libged/nmg_move_v.c new file mode 100644 index 0000000000..0f4963db47 --- /dev/null +++ b/src/libged/nmg_move_v.c @@ -0,0 +1,151 @@ +/* N M G _ M O V E _ 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_move_v.c + * + * The move V subcommand for nmg top-level command. + * + */ + +#include "common.h" + +#include + +#include "bu/cmd.h" +#include "rt/geom.h" + +#include "./ged_private.h" + +#if 0 +void remove_face(const struct model* m, long int fid) +{ + struct nmgregion *r; + struct shell *s; + struct faceuse *fu; + struct face *f; + + NMG_CK_MODEL(m); + + 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 ( fid == f->index ) { + /* this kills both facesuses using the face, + * and the face itself. + */ + nmg_kfu(fu); + } + } + } + } +} +#endif + +int +ged_nmg_move_v(struct ged* UNUSED(gedp), int UNUSED(argc), const char* UNUSED(argv[])) +{ +#if 0 + struct rt_db_internal internal; + struct directory *dp; + struct model* m; + const char* name; + long int fid; + + static const char *usage = "kill F id"; + + 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 < 4) { + 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; + } + + /* get face index from command line */ + fid = (long int)atoi(argv[3]); + + m = (struct model *)internal.idb_ptr; + NMG_CK_MODEL(m); + + remove_face(m, fid); + + 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); +#endif + return GED_OK; +} + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */