Revision: 76160 http://sourceforge.net/p/brlcad/code/76160 Author: starseeker Date: 2020-06-19 14:21:53 +0000 (Fri, 19 Jun 2020) Log Message: ----------- Move view files to subdirectory
Modified Paths: -------------- brlcad/trunk/src/libged/CMakeLists.txt Added Paths: ----------- brlcad/trunk/src/libged/view/ brlcad/trunk/src/libged/view/aet.c brlcad/trunk/src/libged/view/center.cpp brlcad/trunk/src/libged/view/eye.c brlcad/trunk/src/libged/view/quat.c brlcad/trunk/src/libged/view/size.c brlcad/trunk/src/libged/view/view.c brlcad/trunk/src/libged/view/ypr.c Removed Paths: ------------- brlcad/trunk/src/libged/aet.c brlcad/trunk/src/libged/center.cpp brlcad/trunk/src/libged/eye.c brlcad/trunk/src/libged/quat.c brlcad/trunk/src/libged/size.c brlcad/trunk/src/libged/view.c brlcad/trunk/src/libged/ypr.c Modified: brlcad/trunk/src/libged/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libged/CMakeLists.txt 2020-06-19 13:18:56 UTC (rev 76159) +++ brlcad/trunk/src/libged/CMakeLists.txt 2020-06-19 14:21:53 UTC (rev 76160) @@ -49,7 +49,6 @@ adc.c adjust.c ae2dir.c - aet.c analyze.c annotate.c arb.c @@ -71,8 +70,8 @@ bot_dump.c bot_face_fuse.c bot_face_sort.c + bot_flip.c bot_fuse.c - bot_flip.c bot_merge.c bot_smooth.c bot_split.c @@ -89,7 +88,6 @@ brep/valid.cpp cat.c cc.c - center.cpp check/check.c check/check_adj_air.c check/check_centroid.c @@ -133,10 +131,10 @@ dup.c eac.c echo.c + edarb.c edbot.c edcodes.c edcomb.c - edarb.c edit.c edit_metaball.c editit.c @@ -146,11 +144,10 @@ erase.c exists.c expand.c - eye.c eye_pos.c facedef.c + facetize.cpp facetize_log.c - facetize.cpp fb2pix.c fbclear.c find.c @@ -157,6 +154,7 @@ form.c fracture.c gdiff.c + gdiff.c ged.c ged_util.c get.c @@ -167,7 +165,6 @@ get_solid_kp.c get_type.c glob.c - gdiff.c gqa.c grid.c grid2model_lu.c @@ -219,15 +216,15 @@ mrot.c nirt.c nmg.c - nmg_make_v.c - nmg_mm.c nmg_cmface.c nmg_collapse.c nmg_fix_normals.c - nmg_simplify.c + nmg_kill_f.c nmg_kill_v.c - nmg_kill_f.c + nmg_make_v.c + nmg_mm.c nmg_move_v.c + nmg_simplify.c ocenter.c open.c orient.c @@ -245,8 +242,8 @@ pmodel2view.c png.c png2fb.c + pnts.cpp pnts_util.c - pnts.cpp polyclip.cpp prcolor.c prefix.c @@ -263,7 +260,6 @@ put_comb.c putmat.c qray.c - quat.c qvrot.c rcodes.c rect.c @@ -322,7 +318,6 @@ simulate/rt_motion_state.cpp simulate/simulation.cpp simulate/utility.cpp - size.c slew.c solid_report.c solids_on_ray.c @@ -346,7 +341,13 @@ v2m_point.c vdraw.c version.c - view.c + view/view.c + view/aet.c + view/center.cpp + view/eye.c + view/quat.c + view/size.c + view/ypr.c view2grid_lu.c view2model.c view2model_lu.c @@ -363,7 +364,6 @@ who.c wmater.c xpush.c - ypr.c zap.c zoom/zoom.c ${LIBGED_CMD_SRCS} Deleted: brlcad/trunk/src/libged/aet.c =================================================================== --- brlcad/trunk/src/libged/aet.c 2020-06-19 13:18:56 UTC (rev 76159) +++ brlcad/trunk/src/libged/aet.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -1,132 +0,0 @@ -/* A E T . C - * BRL-CAD - * - * Copyright (c) 2008-2020 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @file libged/aet.c - * - * The ae command. - * - */ - -#include "common.h" - -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#include "./ged_private.h" - - -int -ged_aet(struct ged *gedp, int argc, const char *argv[]) -{ - vect_t aet; - int iflag = 0; - static const char *usage = "[[-i] az el [tw]]"; - - GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); - GED_CHECK_VIEW(gedp, GED_ERROR); - GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); - - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); - - /* get aet */ - if (argc == 1) { - bn_encode_vect(gedp->ged_result_str, gedp->ged_gvp->gv_aet, 1); - return GED_OK; - } - - /* Check for -i option */ - if (argv[1][0] == '-' && argv[1][1] == 'i') { - iflag = 1; /* treat arguments as incremental values */ - ++argv; - --argc; - } - - if (argc == 2) { - /* set aet */ - int n; - - if ((n = bn_decode_vect(aet, argv[1])) == 2) - aet[2] = 0; - else if (n != 3) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_ERROR; - } - - if (iflag) { - VADD2(gedp->ged_gvp->gv_aet, gedp->ged_gvp->gv_aet, aet); - } else { - VMOVE(gedp->ged_gvp->gv_aet, aet); - } - _ged_mat_aet(gedp->ged_gvp); - ged_view_update(gedp->ged_gvp); - - return GED_OK; - } - - if (argc == 3 || argc == 4) { - double scan[3]; - - if (sscanf(argv[1], "%lf", &scan[X]) != 1) { - bu_vls_printf(gedp->ged_result_str, "%s: bad azimuth - %s\n", argv[0], argv[1]); - return GED_ERROR; - } - - if (sscanf(argv[2], "%lf", &scan[Y]) != 1) { - bu_vls_printf(gedp->ged_result_str, "%s: bad elevation - %s\n", argv[0], argv[2]); - return GED_ERROR; - } - - if (argc == 4) { - if (sscanf(argv[3], "%lf", &scan[Z]) != 1) { - bu_vls_printf(gedp->ged_result_str, "%s: bad twist - %s\n", argv[0], argv[3]); - return GED_ERROR; - } - } else - scan[Z] = 0.0; - - /* convert from double to fastf_t */ - VMOVE(aet, scan); - - if (iflag) { - VADD2(gedp->ged_gvp->gv_aet, gedp->ged_gvp->gv_aet, aet); - } else { - VMOVE(gedp->ged_gvp->gv_aet, aet); - } - _ged_mat_aet(gedp->ged_gvp); - ged_view_update(gedp->ged_gvp); - - return GED_OK; - } - - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - 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/center.cpp =================================================================== --- brlcad/trunk/src/libged/center.cpp 2020-06-19 13:18:56 UTC (rev 76159) +++ brlcad/trunk/src/libged/center.cpp 2020-06-19 14:21:53 UTC (rev 76160) @@ -1,162 +0,0 @@ -/* C E N T E R . C - * BRL-CAD - * - * Copyright (c) 2008-2020 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @file libged/center.c - * - * The center command. - * - */ - -#include "common.h" - -#include <iomanip> -#include <limits> -#include <sstream> -#include <string> - -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#include "./ged_private.h" - - -int -ged_center(struct ged *gedp, int argc, const char *argv[]) -{ - point_t center; - static const char *usage = "[-v] | [x y z]"; - - GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); - GED_CHECK_VIEW(gedp, GED_ERROR); - GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); - - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); - - /* get view center */ - if (argc == 1) { - MAT_DELTAS_GET_NEG(center, gedp->ged_gvp->gv_center); - VSCALE(center, center, gedp->ged_wdbp->dbip->dbi_base2local); - bn_encode_vect(gedp->ged_result_str, center, 1); - - return GED_OK; - } - - if (argc == 2 && BU_STR_EQUAL(argv[1], "-v")) { - std::ostringstream ss; - MAT_DELTAS_GET_NEG(center, gedp->ged_gvp->gv_center); - VSCALE(center, center, gedp->ged_wdbp->dbip->dbi_base2local); - ss << std::fixed << std::setprecision(std::numeric_limits<fastf_t>::max_digits10) << center[X]; - ss << " "; - ss << std::fixed << std::setprecision(std::numeric_limits<fastf_t>::max_digits10) << center[Y]; - ss << " "; - ss << std::fixed << std::setprecision(std::numeric_limits<fastf_t>::max_digits10) << center[Z]; - bu_vls_printf(gedp->ged_result_str, "%s", ss.str().c_str()); - return GED_OK; - } - - if (argc != 2 && argc != 4) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_ERROR; - } - - /* set view center */ - if (argc == 2) { - int success = 1; - if (bn_decode_vect(center, argv[1]) != 3) { - success = 0; - } - if (!success) { - success = 1; - std::string vline(argv[1]); - size_t spos = vline.find_first_of(",:"); - std::string xstr = vline.substr(0, spos); - vline.erase(0, spos+1); - spos = vline.find_first_of(",:"); - std::string ystr = vline.substr(0, spos); - vline.erase(0, spos+1); - std::string zstr = vline; - struct bu_vls xvalstr = BU_VLS_INIT_ZERO; - struct bu_vls yvalstr = BU_VLS_INIT_ZERO; - struct bu_vls zvalstr = BU_VLS_INIT_ZERO; - bu_vls_sprintf(&xvalstr, "%s", xstr.c_str()); - bu_vls_sprintf(&yvalstr, "%s", ystr.c_str()); - bu_vls_sprintf(&zvalstr, "%s", zstr.c_str()); - bu_vls_trimspace(&xvalstr); - bu_vls_trimspace(&yvalstr); - bu_vls_trimspace(&zvalstr); - fastf_t xval, yval, zval; - const char *xstrptr = bu_vls_cstr(&xvalstr); - const char *ystrptr = bu_vls_cstr(&yvalstr); - const char *zstrptr = bu_vls_cstr(&zvalstr); - if (bu_opt_fastf_t(NULL, 1, (const char **)&xstrptr, (void *)&xval) < 0) { - success = 0; - } - if (bu_opt_fastf_t(NULL, 1, (const char **)&ystrptr, (void *)&yval) < 0) { - success = 0; - } - if (bu_opt_fastf_t(NULL, 1, (const char **)&zstrptr, (void *)&zval) < 0) { - success = 0; - } - VSET(center, xval, yval, zval); - } - if (!success) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_ERROR; - } - } else { - double scan[3]; - - if (sscanf(argv[1], "%lf", &scan[X]) != 1) { - bu_vls_printf(gedp->ged_result_str, "ged_center: bad X value - %s\n", argv[1]); - return GED_ERROR; - } - - if (sscanf(argv[2], "%lf", &scan[Y]) != 1) { - bu_vls_printf(gedp->ged_result_str, "ged_center: bad Y value - %s\n", argv[2]); - return GED_ERROR; - } - - if (sscanf(argv[3], "%lf", &scan[Z]) != 1) { - bu_vls_printf(gedp->ged_result_str, "ged_center: bad Z value - %s\n", argv[3]); - return GED_ERROR; - } - - /* convert from double to fastf_t */ - VMOVE(center, scan); - } - - VSCALE(center, center, gedp->ged_wdbp->dbip->dbi_local2base); - MAT_DELTAS_VEC_NEG(gedp->ged_gvp->gv_center, center); - ged_view_update(gedp->ged_gvp); - - 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/eye.c =================================================================== --- brlcad/trunk/src/libged/eye.c 2020-06-19 13:18:56 UTC (rev 76159) +++ brlcad/trunk/src/libged/eye.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -1,120 +0,0 @@ -/* E Y E . C - * BRL-CAD - * - * Copyright (c) 2008-2020 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @file libged/eye.c - * - * The eye command. - * - */ - -#include "common.h" - -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#include "./ged_private.h" - - -int -ged_eye(struct ged *gedp, int argc, const char *argv[]) -{ - point_t eye_model; - double scan[3]; - vect_t xlate; - vect_t new_cent; - static const char *usage = "x y z"; - - GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); - GED_CHECK_VIEW(gedp, GED_ERROR); - GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); - - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); - - /* get eye */ - if (argc == 1) { - point_t eye; - - /* calculate eye point */ - VSET(xlate, 0.0, 0.0, 1.0); - MAT4X3PNT(eye, gedp->ged_gvp->gv_view2model, xlate); - VSCALE(eye, eye, gedp->ged_wdbp->dbip->dbi_base2local); - - bn_encode_vect(gedp->ged_result_str, eye, 1); - return GED_OK; - } - - if (argc != 2 && argc != 4) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_ERROR; - } - - if (argc == 2) { - if (bn_decode_vect(eye_model, argv[1]) != 3) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_ERROR; - } - } else { - if (sscanf(argv[1], "%lf", &scan[X]) < 1) { - bu_vls_printf(gedp->ged_result_str, "ged_eye: bad X value %s\n", argv[1]); - return GED_ERROR; - } - - if (sscanf(argv[2], "%lf", &scan[Y]) < 1) { - bu_vls_printf(gedp->ged_result_str, "ged_eye: bad Y value %s\n", argv[2]); - return GED_ERROR; - } - - if (sscanf(argv[3], "%lf", &scan[Z]) < 1) { - bu_vls_printf(gedp->ged_result_str, "ged_eye: bad Z value %s\n", argv[3]); - return GED_ERROR; - } - - /* convert from double to fastf_t */ - VMOVE(eye_model, scan); - } - - VSCALE(eye_model, eye_model, gedp->ged_wdbp->dbip->dbi_local2base); - - /* First step: put eye at view center (view 0, 0, 0) */ - MAT_DELTAS_VEC_NEG(gedp->ged_gvp->gv_center, eye_model); - ged_view_update(gedp->ged_gvp); - - /* Second step: put eye at view 0, 0, 1. - * For eye to be at 0, 0, 1, the old 0, 0, -1 needs to become 0, 0, 0. - */ - VSET(xlate, 0.0, 0.0, -1.0); /* correction factor */ - MAT4X3PNT(new_cent, gedp->ged_gvp->gv_view2model, xlate); - MAT_DELTAS_VEC_NEG(gedp->ged_gvp->gv_center, new_cent); - ged_view_update(gedp->ged_gvp); - - 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/quat.c =================================================================== --- brlcad/trunk/src/libged/quat.c 2020-06-19 13:18:56 UTC (rev 76159) +++ brlcad/trunk/src/libged/quat.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -1,88 +0,0 @@ -/* Q U A T . C - * BRL-CAD - * - * Copyright (c) 2008-2020 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @file libged/quat.c - * - * The quat command. - * - */ - -#include "common.h" - -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#include "./ged_private.h" - - -int -ged_quat(struct ged *gedp, int argc, const char *argv[]) -{ - quat_t quat; - double scan[4]; - static const char *usage = "a b c d"; - - GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); - GED_CHECK_VIEW(gedp, GED_ERROR); - GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); - - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); - - /* return Viewrot as a quaternion */ - if (argc == 1) { - quat_mat2quat(quat, gedp->ged_gvp->gv_rotation); - bu_vls_printf(gedp->ged_result_str, "%.12g %.12g %.12g %.12g", V4ARGS(quat)); - return GED_OK; - } - - if (argc != 5) { - bu_vls_printf(gedp->ged_result_str, "Usage: view %s %s", argv[0], usage); - return GED_ERROR; - } - - /* Set the view orientation given a quaternion */ - if (sscanf(argv[1], "%lf", &scan[0]) != 1 - || sscanf(argv[2], "%lf", &scan[1]) != 1 - || sscanf(argv[3], "%lf", &scan[2]) != 1 - || sscanf(argv[4], "%lf", &scan[3]) != 1) - { - bu_vls_printf(gedp->ged_result_str, "view %s: bad value detected - %s %s %s %s", - argv[0], argv[1], argv[2], argv[3], argv[4]); - return GED_ERROR; - } - HMOVE(quat, scan); - - quat_quat2mat(gedp->ged_gvp->gv_rotation, quat); - ged_view_update(gedp->ged_gvp); - - 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/size.c =================================================================== --- brlcad/trunk/src/libged/size.c 2020-06-19 13:18:56 UTC (rev 76159) +++ brlcad/trunk/src/libged/size.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -1,89 +0,0 @@ -/* S I Z E . C - * BRL-CAD - * - * Copyright (c) 2008-2020 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @file libged/size.c - * - * The size command. - * - */ - -#include "common.h" - -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#include "./ged_private.h" - - -int -ged_size(struct ged *gedp, int argc, const char *argv[]) -{ - /* intentionally double for scan */ - double size; - static const char *usage = "[s]"; - - GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); - GED_CHECK_VIEW(gedp, GED_ERROR); - GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); - - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); - - /* get view size */ - if (argc == 1) { - bu_vls_printf(gedp->ged_result_str, "%g", - gedp->ged_gvp->gv_size * gedp->ged_wdbp->dbip->dbi_base2local); - return GED_OK; - } - - /* set view size */ - if (argc == 2) { - if (sscanf(argv[1], "%lf", &size) != 1 - || size <= 0 - || ZERO(size)) - { - bu_vls_printf(gedp->ged_result_str, "bad size - %s", argv[1]); - return GED_ERROR; - } - - gedp->ged_gvp->gv_size = gedp->ged_wdbp->dbip->dbi_local2base * size; - if (gedp->ged_gvp->gv_size < RT_MINVIEWSIZE) - gedp->ged_gvp->gv_size = RT_MINVIEWSIZE; - gedp->ged_gvp->gv_isize = 1.0 / gedp->ged_gvp->gv_size; - gedp->ged_gvp->gv_scale = 0.5 * gedp->ged_gvp->gv_size; - ged_view_update(gedp->ged_gvp); - - return GED_OK; - } - - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_ERROR; -} - - -/* - * Local Variables: - * tab-width: 8 - * mode: C - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Copied: brlcad/trunk/src/libged/view/aet.c (from rev 76159, brlcad/trunk/src/libged/aet.c) =================================================================== --- brlcad/trunk/src/libged/view/aet.c (rev 0) +++ brlcad/trunk/src/libged/view/aet.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -0,0 +1,132 @@ +/* A E T . C + * BRL-CAD + * + * Copyright (c) 2008-2020 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file libged/aet.c + * + * The ae command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "../ged_private.h" + + +int +ged_aet(struct ged *gedp, int argc, const char *argv[]) +{ + vect_t aet; + int iflag = 0; + static const char *usage = "[[-i] az el [tw]]"; + + GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); + GED_CHECK_VIEW(gedp, GED_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); + + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); + + /* get aet */ + if (argc == 1) { + bn_encode_vect(gedp->ged_result_str, gedp->ged_gvp->gv_aet, 1); + return GED_OK; + } + + /* Check for -i option */ + if (argv[1][0] == '-' && argv[1][1] == 'i') { + iflag = 1; /* treat arguments as incremental values */ + ++argv; + --argc; + } + + if (argc == 2) { + /* set aet */ + int n; + + if ((n = bn_decode_vect(aet, argv[1])) == 2) + aet[2] = 0; + else if (n != 3) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; + } + + if (iflag) { + VADD2(gedp->ged_gvp->gv_aet, gedp->ged_gvp->gv_aet, aet); + } else { + VMOVE(gedp->ged_gvp->gv_aet, aet); + } + _ged_mat_aet(gedp->ged_gvp); + ged_view_update(gedp->ged_gvp); + + return GED_OK; + } + + if (argc == 3 || argc == 4) { + double scan[3]; + + if (sscanf(argv[1], "%lf", &scan[X]) != 1) { + bu_vls_printf(gedp->ged_result_str, "%s: bad azimuth - %s\n", argv[0], argv[1]); + return GED_ERROR; + } + + if (sscanf(argv[2], "%lf", &scan[Y]) != 1) { + bu_vls_printf(gedp->ged_result_str, "%s: bad elevation - %s\n", argv[0], argv[2]); + return GED_ERROR; + } + + if (argc == 4) { + if (sscanf(argv[3], "%lf", &scan[Z]) != 1) { + bu_vls_printf(gedp->ged_result_str, "%s: bad twist - %s\n", argv[0], argv[3]); + return GED_ERROR; + } + } else + scan[Z] = 0.0; + + /* convert from double to fastf_t */ + VMOVE(aet, scan); + + if (iflag) { + VADD2(gedp->ged_gvp->gv_aet, gedp->ged_gvp->gv_aet, aet); + } else { + VMOVE(gedp->ged_gvp->gv_aet, aet); + } + _ged_mat_aet(gedp->ged_gvp); + ged_view_update(gedp->ged_gvp); + + return GED_OK; + } + + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Copied: brlcad/trunk/src/libged/view/center.cpp (from rev 76159, brlcad/trunk/src/libged/center.cpp) =================================================================== --- brlcad/trunk/src/libged/view/center.cpp (rev 0) +++ brlcad/trunk/src/libged/view/center.cpp 2020-06-19 14:21:53 UTC (rev 76160) @@ -0,0 +1,162 @@ +/* C E N T E R . C + * BRL-CAD + * + * Copyright (c) 2008-2020 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file libged/center.c + * + * The center command. + * + */ + +#include "common.h" + +#include <iomanip> +#include <limits> +#include <sstream> +#include <string> + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "../ged_private.h" + + +int +ged_center(struct ged *gedp, int argc, const char *argv[]) +{ + point_t center; + static const char *usage = "[-v] | [x y z]"; + + GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); + GED_CHECK_VIEW(gedp, GED_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); + + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); + + /* get view center */ + if (argc == 1) { + MAT_DELTAS_GET_NEG(center, gedp->ged_gvp->gv_center); + VSCALE(center, center, gedp->ged_wdbp->dbip->dbi_base2local); + bn_encode_vect(gedp->ged_result_str, center, 1); + + return GED_OK; + } + + if (argc == 2 && BU_STR_EQUAL(argv[1], "-v")) { + std::ostringstream ss; + MAT_DELTAS_GET_NEG(center, gedp->ged_gvp->gv_center); + VSCALE(center, center, gedp->ged_wdbp->dbip->dbi_base2local); + ss << std::fixed << std::setprecision(std::numeric_limits<fastf_t>::max_digits10) << center[X]; + ss << " "; + ss << std::fixed << std::setprecision(std::numeric_limits<fastf_t>::max_digits10) << center[Y]; + ss << " "; + ss << std::fixed << std::setprecision(std::numeric_limits<fastf_t>::max_digits10) << center[Z]; + bu_vls_printf(gedp->ged_result_str, "%s", ss.str().c_str()); + return GED_OK; + } + + if (argc != 2 && argc != 4) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; + } + + /* set view center */ + if (argc == 2) { + int success = 1; + if (bn_decode_vect(center, argv[1]) != 3) { + success = 0; + } + if (!success) { + success = 1; + std::string vline(argv[1]); + size_t spos = vline.find_first_of(",:"); + std::string xstr = vline.substr(0, spos); + vline.erase(0, spos+1); + spos = vline.find_first_of(",:"); + std::string ystr = vline.substr(0, spos); + vline.erase(0, spos+1); + std::string zstr = vline; + struct bu_vls xvalstr = BU_VLS_INIT_ZERO; + struct bu_vls yvalstr = BU_VLS_INIT_ZERO; + struct bu_vls zvalstr = BU_VLS_INIT_ZERO; + bu_vls_sprintf(&xvalstr, "%s", xstr.c_str()); + bu_vls_sprintf(&yvalstr, "%s", ystr.c_str()); + bu_vls_sprintf(&zvalstr, "%s", zstr.c_str()); + bu_vls_trimspace(&xvalstr); + bu_vls_trimspace(&yvalstr); + bu_vls_trimspace(&zvalstr); + fastf_t xval, yval, zval; + const char *xstrptr = bu_vls_cstr(&xvalstr); + const char *ystrptr = bu_vls_cstr(&yvalstr); + const char *zstrptr = bu_vls_cstr(&zvalstr); + if (bu_opt_fastf_t(NULL, 1, (const char **)&xstrptr, (void *)&xval) < 0) { + success = 0; + } + if (bu_opt_fastf_t(NULL, 1, (const char **)&ystrptr, (void *)&yval) < 0) { + success = 0; + } + if (bu_opt_fastf_t(NULL, 1, (const char **)&zstrptr, (void *)&zval) < 0) { + success = 0; + } + VSET(center, xval, yval, zval); + } + if (!success) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; + } + } else { + double scan[3]; + + if (sscanf(argv[1], "%lf", &scan[X]) != 1) { + bu_vls_printf(gedp->ged_result_str, "ged_center: bad X value - %s\n", argv[1]); + return GED_ERROR; + } + + if (sscanf(argv[2], "%lf", &scan[Y]) != 1) { + bu_vls_printf(gedp->ged_result_str, "ged_center: bad Y value - %s\n", argv[2]); + return GED_ERROR; + } + + if (sscanf(argv[3], "%lf", &scan[Z]) != 1) { + bu_vls_printf(gedp->ged_result_str, "ged_center: bad Z value - %s\n", argv[3]); + return GED_ERROR; + } + + /* convert from double to fastf_t */ + VMOVE(center, scan); + } + + VSCALE(center, center, gedp->ged_wdbp->dbip->dbi_local2base); + MAT_DELTAS_VEC_NEG(gedp->ged_gvp->gv_center, center); + ged_view_update(gedp->ged_gvp); + + return GED_OK; +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Copied: brlcad/trunk/src/libged/view/eye.c (from rev 76159, brlcad/trunk/src/libged/eye.c) =================================================================== --- brlcad/trunk/src/libged/view/eye.c (rev 0) +++ brlcad/trunk/src/libged/view/eye.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -0,0 +1,120 @@ +/* E Y E . C + * BRL-CAD + * + * Copyright (c) 2008-2020 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file libged/eye.c + * + * The eye command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "../ged_private.h" + + +int +ged_eye(struct ged *gedp, int argc, const char *argv[]) +{ + point_t eye_model; + double scan[3]; + vect_t xlate; + vect_t new_cent; + static const char *usage = "x y z"; + + GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); + GED_CHECK_VIEW(gedp, GED_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); + + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); + + /* get eye */ + if (argc == 1) { + point_t eye; + + /* calculate eye point */ + VSET(xlate, 0.0, 0.0, 1.0); + MAT4X3PNT(eye, gedp->ged_gvp->gv_view2model, xlate); + VSCALE(eye, eye, gedp->ged_wdbp->dbip->dbi_base2local); + + bn_encode_vect(gedp->ged_result_str, eye, 1); + return GED_OK; + } + + if (argc != 2 && argc != 4) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; + } + + if (argc == 2) { + if (bn_decode_vect(eye_model, argv[1]) != 3) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; + } + } else { + if (sscanf(argv[1], "%lf", &scan[X]) < 1) { + bu_vls_printf(gedp->ged_result_str, "ged_eye: bad X value %s\n", argv[1]); + return GED_ERROR; + } + + if (sscanf(argv[2], "%lf", &scan[Y]) < 1) { + bu_vls_printf(gedp->ged_result_str, "ged_eye: bad Y value %s\n", argv[2]); + return GED_ERROR; + } + + if (sscanf(argv[3], "%lf", &scan[Z]) < 1) { + bu_vls_printf(gedp->ged_result_str, "ged_eye: bad Z value %s\n", argv[3]); + return GED_ERROR; + } + + /* convert from double to fastf_t */ + VMOVE(eye_model, scan); + } + + VSCALE(eye_model, eye_model, gedp->ged_wdbp->dbip->dbi_local2base); + + /* First step: put eye at view center (view 0, 0, 0) */ + MAT_DELTAS_VEC_NEG(gedp->ged_gvp->gv_center, eye_model); + ged_view_update(gedp->ged_gvp); + + /* Second step: put eye at view 0, 0, 1. + * For eye to be at 0, 0, 1, the old 0, 0, -1 needs to become 0, 0, 0. + */ + VSET(xlate, 0.0, 0.0, -1.0); /* correction factor */ + MAT4X3PNT(new_cent, gedp->ged_gvp->gv_view2model, xlate); + MAT_DELTAS_VEC_NEG(gedp->ged_gvp->gv_center, new_cent); + ged_view_update(gedp->ged_gvp); + + return GED_OK; +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Copied: brlcad/trunk/src/libged/view/quat.c (from rev 76159, brlcad/trunk/src/libged/quat.c) =================================================================== --- brlcad/trunk/src/libged/view/quat.c (rev 0) +++ brlcad/trunk/src/libged/view/quat.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -0,0 +1,88 @@ +/* Q U A T . C + * BRL-CAD + * + * Copyright (c) 2008-2020 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file libged/quat.c + * + * The quat command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "../ged_private.h" + + +int +ged_quat(struct ged *gedp, int argc, const char *argv[]) +{ + quat_t quat; + double scan[4]; + static const char *usage = "a b c d"; + + GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); + GED_CHECK_VIEW(gedp, GED_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); + + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); + + /* return Viewrot as a quaternion */ + if (argc == 1) { + quat_mat2quat(quat, gedp->ged_gvp->gv_rotation); + bu_vls_printf(gedp->ged_result_str, "%.12g %.12g %.12g %.12g", V4ARGS(quat)); + return GED_OK; + } + + if (argc != 5) { + bu_vls_printf(gedp->ged_result_str, "Usage: view %s %s", argv[0], usage); + return GED_ERROR; + } + + /* Set the view orientation given a quaternion */ + if (sscanf(argv[1], "%lf", &scan[0]) != 1 + || sscanf(argv[2], "%lf", &scan[1]) != 1 + || sscanf(argv[3], "%lf", &scan[2]) != 1 + || sscanf(argv[4], "%lf", &scan[3]) != 1) + { + bu_vls_printf(gedp->ged_result_str, "view %s: bad value detected - %s %s %s %s", + argv[0], argv[1], argv[2], argv[3], argv[4]); + return GED_ERROR; + } + HMOVE(quat, scan); + + quat_quat2mat(gedp->ged_gvp->gv_rotation, quat); + ged_view_update(gedp->ged_gvp); + + return GED_OK; +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Copied: brlcad/trunk/src/libged/view/size.c (from rev 76159, brlcad/trunk/src/libged/size.c) =================================================================== --- brlcad/trunk/src/libged/view/size.c (rev 0) +++ brlcad/trunk/src/libged/view/size.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -0,0 +1,89 @@ +/* S I Z E . C + * BRL-CAD + * + * Copyright (c) 2008-2020 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file libged/size.c + * + * The size command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "../ged_private.h" + + +int +ged_size(struct ged *gedp, int argc, const char *argv[]) +{ + /* intentionally double for scan */ + double size; + static const char *usage = "[s]"; + + GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); + GED_CHECK_VIEW(gedp, GED_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); + + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); + + /* get view size */ + if (argc == 1) { + bu_vls_printf(gedp->ged_result_str, "%g", + gedp->ged_gvp->gv_size * gedp->ged_wdbp->dbip->dbi_base2local); + return GED_OK; + } + + /* set view size */ + if (argc == 2) { + if (sscanf(argv[1], "%lf", &size) != 1 + || size <= 0 + || ZERO(size)) + { + bu_vls_printf(gedp->ged_result_str, "bad size - %s", argv[1]); + return GED_ERROR; + } + + gedp->ged_gvp->gv_size = gedp->ged_wdbp->dbip->dbi_local2base * size; + if (gedp->ged_gvp->gv_size < RT_MINVIEWSIZE) + gedp->ged_gvp->gv_size = RT_MINVIEWSIZE; + gedp->ged_gvp->gv_isize = 1.0 / gedp->ged_gvp->gv_size; + gedp->ged_gvp->gv_scale = 0.5 * gedp->ged_gvp->gv_size; + ged_view_update(gedp->ged_gvp); + + return GED_OK; + } + + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Copied: brlcad/trunk/src/libged/view/view.c (from rev 76159, brlcad/trunk/src/libged/view.c) =================================================================== --- brlcad/trunk/src/libged/view/view.c (rev 0) +++ brlcad/trunk/src/libged/view/view.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -0,0 +1,95 @@ +/* V I E W . C + * BRL-CAD + * + * Copyright (c) 2008-2020 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file libged/view.c + * + * The view command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "../ged_private.h" + + +int +ged_view_func(struct ged *gedp, int argc, const char *argv[]) +{ + static const char *usage = "quat|ypr|aet|center|eye|size [args]"; + + GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); + GED_CHECK_VIEW(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_ERROR; + } + + if (6 < argc) { + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; + } + + if (BU_STR_EQUAL(argv[1], "quat")) { + return ged_quat(gedp, argc-1, argv+1); + } + + if (BU_STR_EQUAL(argv[1], "ypr")) { + return ged_ypr(gedp, argc-1, argv+1); + } + + if (BU_STR_EQUAL(argv[1], "aet")) { + return ged_aet(gedp, argc-1, argv+1); + } + + if (BU_STR_EQUAL(argv[1], "center")) { + return ged_center(gedp, argc-1, argv+1); + } + + if (BU_STR_EQUAL(argv[1], "eye")) { + return ged_eye(gedp, argc-1, argv+1); + } + + if (BU_STR_EQUAL(argv[1], "size")) { + return ged_size(gedp, argc-1, argv+1); + } + + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return GED_ERROR; +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Copied: brlcad/trunk/src/libged/view/ypr.c (from rev 76159, brlcad/trunk/src/libged/ypr.c) =================================================================== --- brlcad/trunk/src/libged/view/ypr.c (rev 0) +++ brlcad/trunk/src/libged/view/ypr.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -0,0 +1,102 @@ +/* Y P R . C + * BRL-CAD + * + * Copyright (c) 2008-2020 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file libged/ypr.c + * + * The ypr command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> +#include "../ged_private.h" + + +int +ged_ypr(struct ged *gedp, int argc, const char *argv[]) +{ + vect_t ypr; + mat_t mat; + double scan[3]; + static const char *usage = "yaw pitch roll"; + + GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); + GED_CHECK_VIEW(gedp, GED_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); + + /* initialize result */ + bu_vls_trunc(gedp->ged_result_str, 0); + + /* return Viewrot as yaw, pitch and roll */ + if (argc == 1) { + point_t pt = VINIT_ZERO; + + bn_mat_trn(mat, gedp->ged_gvp->gv_rotation); + anim_v_unpermute(mat); + + if (anim_mat2ypr(mat, pt) == 2) { + bu_vls_printf(gedp->ged_result_str, "view %s - matrix is not a rotation matrix", argv[0]); + return GED_ERROR; + } + + VSCALE(pt, pt, RAD2DEG); + bu_vls_printf(gedp->ged_result_str, "%.12g %.12g %.12g", V3ARGS(pt)); + + return GED_OK; + } + + if (argc != 4) { + bu_vls_printf(gedp->ged_result_str, "Usage: view %s %s", argv[0], usage); + return GED_ERROR; + } + + /* attempt to set Viewrot given yaw, pitch and roll */ + if (sscanf(argv[1], "%lf", &scan[0]) != 1 + || sscanf(argv[2], "%lf", &scan[1]) != 1 + || sscanf(argv[3], "%lf", &scan[2]) != 1) + { + + bu_vls_printf(gedp->ged_result_str, "view %s: bad value detected - %s %s %s", + argv[0], argv[1], argv[2], argv[3]); + return GED_ERROR; + } + /* convert double to fastf_t */ + VMOVE(ypr, scan); + + anim_dy_p_r2mat(mat, V3ARGS(ypr)); + anim_v_permute(mat); + bn_mat_trn(gedp->ged_gvp->gv_rotation, mat); + ged_view_update(gedp->ged_gvp); + + 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/view.c =================================================================== --- brlcad/trunk/src/libged/view.c 2020-06-19 13:18:56 UTC (rev 76159) +++ brlcad/trunk/src/libged/view.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -1,95 +0,0 @@ -/* V I E W . C - * BRL-CAD - * - * Copyright (c) 2008-2020 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @file libged/view.c - * - * The view command. - * - */ - -#include "common.h" - -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#include "./ged_private.h" - - -int -ged_view_func(struct ged *gedp, int argc, const char *argv[]) -{ - static const char *usage = "quat|ypr|aet|center|eye|size [args]"; - - GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); - GED_CHECK_VIEW(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_ERROR; - } - - if (6 < argc) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - return GED_ERROR; - } - - if (BU_STR_EQUAL(argv[1], "quat")) { - return ged_quat(gedp, argc-1, argv+1); - } - - if (BU_STR_EQUAL(argv[1], "ypr")) { - return ged_ypr(gedp, argc-1, argv+1); - } - - if (BU_STR_EQUAL(argv[1], "aet")) { - return ged_aet(gedp, argc-1, argv+1); - } - - if (BU_STR_EQUAL(argv[1], "center")) { - return ged_center(gedp, argc-1, argv+1); - } - - if (BU_STR_EQUAL(argv[1], "eye")) { - return ged_eye(gedp, argc-1, argv+1); - } - - if (BU_STR_EQUAL(argv[1], "size")) { - return ged_size(gedp, argc-1, argv+1); - } - - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); - 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/ypr.c =================================================================== --- brlcad/trunk/src/libged/ypr.c 2020-06-19 13:18:56 UTC (rev 76159) +++ brlcad/trunk/src/libged/ypr.c 2020-06-19 14:21:53 UTC (rev 76160) @@ -1,102 +0,0 @@ -/* Y P R . C - * BRL-CAD - * - * Copyright (c) 2008-2020 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @file libged/ypr.c - * - * The ypr command. - * - */ - -#include "common.h" - -#include <stdlib.h> -#include <ctype.h> -#include <string.h> -#include "./ged_private.h" - - -int -ged_ypr(struct ged *gedp, int argc, const char *argv[]) -{ - vect_t ypr; - mat_t mat; - double scan[3]; - static const char *usage = "yaw pitch roll"; - - GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); - GED_CHECK_VIEW(gedp, GED_ERROR); - GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); - - /* initialize result */ - bu_vls_trunc(gedp->ged_result_str, 0); - - /* return Viewrot as yaw, pitch and roll */ - if (argc == 1) { - point_t pt = VINIT_ZERO; - - bn_mat_trn(mat, gedp->ged_gvp->gv_rotation); - anim_v_unpermute(mat); - - if (anim_mat2ypr(mat, pt) == 2) { - bu_vls_printf(gedp->ged_result_str, "view %s - matrix is not a rotation matrix", argv[0]); - return GED_ERROR; - } - - VSCALE(pt, pt, RAD2DEG); - bu_vls_printf(gedp->ged_result_str, "%.12g %.12g %.12g", V3ARGS(pt)); - - return GED_OK; - } - - if (argc != 4) { - bu_vls_printf(gedp->ged_result_str, "Usage: view %s %s", argv[0], usage); - return GED_ERROR; - } - - /* attempt to set Viewrot given yaw, pitch and roll */ - if (sscanf(argv[1], "%lf", &scan[0]) != 1 - || sscanf(argv[2], "%lf", &scan[1]) != 1 - || sscanf(argv[3], "%lf", &scan[2]) != 1) - { - - bu_vls_printf(gedp->ged_result_str, "view %s: bad value detected - %s %s %s", - argv[0], argv[1], argv[2], argv[3]); - return GED_ERROR; - } - /* convert double to fastf_t */ - VMOVE(ypr, scan); - - anim_dy_p_r2mat(mat, V3ARGS(ypr)); - anim_v_permute(mat); - bn_mat_trn(gedp->ged_gvp->gv_rotation, mat); - ged_view_update(gedp->ged_gvp); - - return GED_OK; -} - - -/* - * 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. _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits