Revision: 33611 http://brlcad.svn.sourceforge.net/brlcad/?rev=33611&view=rev Author: bob1961 Date: 2009-01-27 18:24:49 +0000 (Tue, 27 Jan 2009)
Log Message: ----------- Added the following functions to libged: ged_grid2model_lu, ged_grid2view_lu, ged_model2grid_lu, ged_model2view_lu, ged_view2grid_lu, ged_view2model_lu and ged_view2model_vec. Modified Paths: -------------- brlcad/trunk/include/ged.h brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj brlcad/trunk/src/libged/Makefile.am brlcad/trunk/src/mged/setup.c Added Paths: ----------- brlcad/trunk/src/libged/grid2model_lu.c brlcad/trunk/src/libged/grid2view_lu.c brlcad/trunk/src/libged/model2grid_lu.c brlcad/trunk/src/libged/model2view_lu.c brlcad/trunk/src/libged/view2grid_lu.c brlcad/trunk/src/libged/view2model_lu.c brlcad/trunk/src/libged/view2model_vec.c Modified: brlcad/trunk/include/ged.h =================================================================== --- brlcad/trunk/include/ged.h 2009-01-27 04:50:38 UTC (rev 33610) +++ brlcad/trunk/include/ged.h 2009-01-27 18:24:49 UTC (rev 33611) @@ -1683,6 +1683,22 @@ GED_EXPORT BU_EXTERN(int ged_grid, (struct ged *gedp, int argc, const char *argv[])); /** + * Convert grid coordinates to model coordinates. + * + * Usage: + * grid2model_lu u v + */ +GED_EXPORT BU_EXTERN(int ged_grid2model_lu, (struct ged *gedp, int argc, const char *argv[])); + +/** + * Convert grid coordinates to view coordinates. + * + * Usage: + * grid2view_lu u v + */ +GED_EXPORT BU_EXTERN(int ged_grid2view_lu, (struct ged *gedp, int argc, const char *argv[])); + +/** * Create or append objects to a group * * Usage: @@ -1916,6 +1932,14 @@ GED_EXPORT BU_EXTERN(int ged_mirror, (struct ged *gedp, int argc, const char *argv[])); /** + * Convert model coordinates to grid coordinates. + * + * Usage: + * model2grid_lu u v + */ +GED_EXPORT BU_EXTERN(int ged_model2grid_lu, (struct ged *gedp, int argc, const char *argv[])); + +/** * Get the model to view matrix * * Usage: @@ -1924,6 +1948,14 @@ GED_EXPORT BU_EXTERN(int ged_model2view, (struct ged *gedp, int argc, const char *argv[])); /** + * Convert model coordinates to view coordinates. + * + * Usage: + * model2view_lu u v + */ +GED_EXPORT BU_EXTERN(int ged_model2view_lu, (struct ged *gedp, int argc, const char *argv[])); + +/** * Move an arb's edge through point * * Usage: @@ -2621,6 +2653,14 @@ GED_EXPORT BU_EXTERN(int ged_view, (struct ged *gedp, int argc, const char *argv[])); /** + * Convert view coordinates to grid coordinates. + * + * Usage: + * view2grid_lu u v + */ +GED_EXPORT BU_EXTERN(int ged_view2grid_lu, (struct ged *gedp, int argc, const char *argv[])); + +/** * Get the view2model matrix. * * Usage: @@ -2629,6 +2669,22 @@ GED_EXPORT BU_EXTERN(int ged_view2model, (struct ged *gedp, int argc, const char *argv[])); /** + * Convert view coordinates to model coordinates. + * + * Usage: + * view2model_lu u v + */ +GED_EXPORT BU_EXTERN(int ged_view2model_lu, (struct ged *gedp, int argc, const char *argv[])); + +/** + * Convert a view vector to a model vector. + * + * Usage: + * view2model_vec u v + */ +GED_EXPORT BU_EXTERN(int ged_view2model_vec, (struct ged *gedp, int argc, const char *argv[])); + +/** * Rotate the view. Note - x, y and z are rotations in view coordinates. * * Usage: Modified: brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj =================================================================== --- brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj 2009-01-27 04:50:38 UTC (rev 33610) +++ brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj 2009-01-27 18:24:49 UTC (rev 33611) @@ -530,6 +530,14 @@ > </File> <File + RelativePath="..\..\..\src\libged\grid2model_lu.c" + > + </File> + <File + RelativePath="..\..\..\src\libged\grid2view_lu.c" + > + </File> + <File RelativePath="..\..\..\src\libged\group.c" > </File> @@ -646,10 +654,18 @@ > </File> <File + RelativePath="..\..\..\src\libged\model2grid_lu.c" + > + </File> + <File RelativePath="..\..\..\src\libged\model2view.c" > </File> <File + RelativePath="..\..\..\src\libged\model2view_lu.c" + > + </File> + <File RelativePath="..\..\..\src\libged\move.c" > </File> @@ -994,10 +1010,22 @@ > </File> <File + RelativePath="..\..\..\src\libged\view2grid_lu.c" + > + </File> + <File RelativePath="..\..\..\src\libged\view2model.c" > </File> <File + RelativePath="..\..\..\src\libged\view2model_lu.c" + > + </File> + <File + RelativePath="..\..\..\src\libged\view2model_vec.c" + > + </File> + <File RelativePath="..\..\..\src\libged\view_obj.c" > </File> Modified: brlcad/trunk/src/libged/Makefile.am =================================================================== --- brlcad/trunk/src/libged/Makefile.am 2009-01-27 04:50:38 UTC (rev 33610) +++ brlcad/trunk/src/libged/Makefile.am 2009-01-27 18:24:49 UTC (rev 33611) @@ -79,6 +79,8 @@ globals.c \ gqa.c \ grid.c \ + grid2model_lu.c \ + grid2view_lu.c \ group.c \ hide.c \ how.c \ @@ -108,7 +110,9 @@ match.c \ mater.c \ mirror.c \ + model2grid_lu.c \ model2view.c \ + model2view_lu.c \ move.c \ move_all.c \ move_arb_edge.c \ @@ -195,7 +199,10 @@ vdraw.c \ version.c \ view.c \ + view2grid_lu.c \ view2model.c \ + view2model_lu.c \ + view2model_vec.c \ view_obj.c \ viewdir.c \ vrot.c \ Added: brlcad/trunk/src/libged/grid2model_lu.c =================================================================== --- brlcad/trunk/src/libged/grid2model_lu.c (rev 0) +++ brlcad/trunk/src/libged/grid2model_lu.c 2009-01-27 18:24:49 UTC (rev 33611) @@ -0,0 +1,86 @@ +/* G R I D 2 M O D E L _ L U . C + * BRL-CAD + * + * Copyright (c) 2008-2009 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 grid2model_lu.c + * + * The grid2model_lu command. + * + */ + +#include "common.h" +#include "bio.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged_private.h" + + +int +ged_grid2model_lu(struct ged *gedp, int argc, const char *argv[]) +{ + fastf_t f; + point_t view_pt; + point_t model_pt; + point_t mo_view_pt; /* model origin in view space */ + point_t diff; + static const char *usage = "u v"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_VIEW(gedp, BRLCAD_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + + if (argc != 3) + goto bad; + + if (sscanf(argv[1], "%lf", &diff[X]) != 1 || + sscanf(argv[2], "%lf", &diff[Y]) != 1) + goto bad; + diff[Z] = 0.0; + + f = 1.0 / (gedp->ged_gvp->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local); + VSCALE(diff, diff, f); + VSETALL(model_pt, 0.0); + MAT4X3PNT(mo_view_pt, gedp->ged_gvp->gv_model2view, model_pt); + VADD2(view_pt, mo_view_pt, diff); + MAT4X3PNT(model_pt, gedp->ged_gvp->gv_view2model, view_pt); + VSCALE(model_pt, model_pt, gedp->ged_wdbp->dbip->dbi_base2local); + bn_encode_vect(&gedp->ged_result_str, model_pt); + + return BRLCAD_OK; + +bad: + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; +} + + +/* + * 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/grid2model_lu.c ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: brlcad/trunk/src/libged/grid2view_lu.c =================================================================== --- brlcad/trunk/src/libged/grid2view_lu.c (rev 0) +++ brlcad/trunk/src/libged/grid2view_lu.c 2009-01-27 18:24:49 UTC (rev 33611) @@ -0,0 +1,84 @@ +/* G R I D 2 V I E W _ L U . C + * BRL-CAD + * + * Copyright (c) 2008-2009 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 grid2view_lu.c + * + * The grid2view_lu command. + * + */ + +#include "common.h" +#include "bio.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged_private.h" + + +int +ged_grid2view_lu(struct ged *gedp, int argc, const char *argv[]) +{ + fastf_t f; + point_t view_pt; + point_t model_pt; + point_t mo_view_pt; /* model origin in view space */ + point_t diff; + static const char *usage = "u v"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_VIEW(gedp, BRLCAD_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + + if (argc != 3) + goto bad; + + if (sscanf(argv[1], "%lf", &diff[X]) != 1 || + sscanf(argv[2], "%lf", &diff[Y]) != 1) + goto bad; + diff[Z] = 0.0; + + VSETALL(model_pt, 0.0); + MAT4X3PNT(mo_view_pt, gedp->ged_gvp->gv_model2view, model_pt); + f = gedp->ged_gvp->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local; + VSCALE(mo_view_pt, mo_view_pt, f); + VADD2(view_pt, mo_view_pt, diff); + bn_encode_vect(&gedp->ged_result_str, view_pt); + + return BRLCAD_OK; + +bad: + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; +} + + +/* + * 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/grid2view_lu.c ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: brlcad/trunk/src/libged/model2grid_lu.c =================================================================== --- brlcad/trunk/src/libged/model2grid_lu.c (rev 0) +++ brlcad/trunk/src/libged/model2grid_lu.c 2009-01-27 18:24:49 UTC (rev 33611) @@ -0,0 +1,87 @@ +/* M O D E L 2 G R I D _ L U . C + * BRL-CAD + * + * Copyright (c) 2008-2009 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 model2grid_lu.c + * + * The model2grid_lu command. + * + */ + +#include "common.h" +#include "bio.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged_private.h" + + +int +ged_model2grid_lu(struct ged *gedp, int argc, const char *argv[]) +{ + fastf_t f; + point_t view_pt; + point_t model_pt; + point_t mo_view_pt; /* model origin in view space */ + point_t diff; + static const char *usage = "x y z"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_VIEW(gedp, BRLCAD_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + + if (argc != 4) + goto bad; + + VSETALL(model_pt, 0.0); + MAT4X3PNT(mo_view_pt, gedp->ged_gvp->gv_model2view, model_pt); + + if (sscanf(argv[1], "%lf", &model_pt[X]) != 1 || + sscanf(argv[2], "%lf", &model_pt[Y]) != 1 || + sscanf(argv[3], "%lf", &model_pt[Z]) != 1) + goto bad; + + VSCALE(model_pt, model_pt, gedp->ged_wdbp->dbip->dbi_local2base); + MAT4X3PNT(view_pt, gedp->ged_gvp->gv_model2view, model_pt); + VSUB2(diff, view_pt, mo_view_pt); + f = gedp->ged_gvp->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local; + VSCALE(diff, diff, f); + bu_vls_printf(&gedp->ged_result_str, "%.15e %.15e", diff[X], diff[Y]); + + return BRLCAD_OK; + +bad: + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; +} + + +/* + * 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/model2grid_lu.c ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: brlcad/trunk/src/libged/model2view_lu.c =================================================================== --- brlcad/trunk/src/libged/model2view_lu.c (rev 0) +++ brlcad/trunk/src/libged/model2view_lu.c 2009-01-27 18:24:49 UTC (rev 33611) @@ -0,0 +1,81 @@ +/* M O D E L 2 V I E W _ L U . C + * BRL-CAD + * + * Copyright (c) 2008-2009 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 model2view_lu.c + * + * The model2view_lu command. + * + */ + +#include "common.h" +#include "bio.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged_private.h" + + +int +ged_model2view_lu(struct ged *gedp, int argc, const char *argv[]) +{ + fastf_t f; + point_t view_pt; + point_t model_pt; + static const char *usage = "x y z"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_VIEW(gedp, BRLCAD_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + + if (argc != 4) + goto bad; + + if (sscanf(argv[1], "%lf", &model_pt[X]) != 1 || + sscanf(argv[2], "%lf", &model_pt[Y]) != 1 || + sscanf(argv[3], "%lf", &model_pt[Z]) != 1) + goto bad; + + VSCALE(model_pt, model_pt, gedp->ged_wdbp->dbip->dbi_local2base); + MAT4X3PNT(view_pt, gedp->ged_gvp->gv_model2view, model_pt); + f = gedp->ged_gvp->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local; + VSCALE(view_pt, view_pt, f); + bn_encode_vect(&gedp->ged_result_str, view_pt); + + return BRLCAD_OK; + +bad: + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; +} + + +/* + * 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/model2view_lu.c ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: brlcad/trunk/src/libged/view2grid_lu.c =================================================================== --- brlcad/trunk/src/libged/view2grid_lu.c (rev 0) +++ brlcad/trunk/src/libged/view2grid_lu.c 2009-01-27 18:24:49 UTC (rev 33611) @@ -0,0 +1,86 @@ +/* V I E W 2 G R I D _ L U . C + * BRL-CAD + * + * Copyright (c) 2008-2009 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 view2grid_lu.c + * + * The view2grid_lu command. + * + */ + +#include "common.h" +#include "bio.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged_private.h" + + +int +ged_view2grid_lu(struct ged *gedp, int argc, const char *argv[]) +{ + fastf_t f; + point_t view_pt; + point_t model_pt; + point_t mo_view_pt; /* model origin in view space */ + point_t diff; + static const char *usage = "x y z"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_VIEW(gedp, BRLCAD_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + + if (argc != 4) + goto bad; + + if (sscanf(argv[1], "%lf", &view_pt[X]) != 1 || + sscanf(argv[2], "%lf", &view_pt[Y]) != 1 || + sscanf(argv[3], "%lf", &view_pt[Z]) != 1) + goto bad; + + + VSETALL(model_pt, 0.0); + MAT4X3PNT(mo_view_pt, gedp->ged_gvp->gv_model2view, model_pt); + f = gedp->ged_gvp->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local; + VSCALE(mo_view_pt, mo_view_pt, f); + VSUB2(diff, view_pt, mo_view_pt); + + bu_vls_printf(&gedp->ged_result_str, "%.15e %.15e", diff[X], diff[Y]); + + return BRLCAD_OK; + +bad: + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; +} + + +/* + * 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/view2grid_lu.c ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: brlcad/trunk/src/libged/view2model_lu.c =================================================================== --- brlcad/trunk/src/libged/view2model_lu.c (rev 0) +++ brlcad/trunk/src/libged/view2model_lu.c 2009-01-27 18:24:49 UTC (rev 33611) @@ -0,0 +1,82 @@ +/* V I E W 2 M O D E L _ L U . C + * BRL-CAD + * + * Copyright (c) 2008-2009 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 view2model_lu.c + * + * The view2model_lu command. + * + */ + +#include "common.h" +#include "bio.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged_private.h" + + +int +ged_view2model_lu(struct ged *gedp, int argc, const char *argv[]) +{ + fastf_t sf; + point_t view_pt; + point_t model_pt; + static const char *usage = "x y z"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_VIEW(gedp, BRLCAD_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + + if (argc != 4) + goto bad; + + if (sscanf(argv[1], "%lf", &view_pt[X]) != 1 || + sscanf(argv[2], "%lf", &view_pt[Y]) != 1 || + sscanf(argv[3], "%lf", &view_pt[Z]) != 1) + goto bad; + + sf = 1.0 / (gedp->ged_gvp->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local); + VSCALE(view_pt, view_pt, sf); + MAT4X3PNT(model_pt, gedp->ged_gvp->gv_view2model, view_pt); + VSCALE(model_pt, model_pt, gedp->ged_wdbp->dbip->dbi_base2local); + + bn_encode_vect(&gedp->ged_result_str, model_pt); + + return BRLCAD_OK; + +bad: + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; +} + + +/* + * 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/view2model_lu.c ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: brlcad/trunk/src/libged/view2model_vec.c =================================================================== --- brlcad/trunk/src/libged/view2model_vec.c (rev 0) +++ brlcad/trunk/src/libged/view2model_vec.c 2009-01-27 18:24:49 UTC (rev 33611) @@ -0,0 +1,80 @@ +/* V I E W 2 M O D E L _ V E C . C + * BRL-CAD + * + * Copyright (c) 2008-2009 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 view2model_vec.c + * + * The view2model_vec command. + * + */ + +#include "common.h" +#include "bio.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged_private.h" + + +int +ged_view2model_vec(struct ged *gedp, int argc, const char *argv[]) +{ + point_t model_vec; + point_t view_vec; + mat_t inv_Viewrot; + static const char *usage = "x y z"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_VIEW(gedp, BRLCAD_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + + if (argc != 4) + goto bad; + + if (sscanf(argv[1], "%lf", &view_vec[X]) != 1 || + sscanf(argv[2], "%lf", &view_vec[Y]) != 1 || + sscanf(argv[3], "%lf", &view_vec[Z]) != 1) + goto bad; + + bn_mat_inv(inv_Viewrot, gedp->ged_gvp->gv_rotation); + MAT4X3PNT(model_vec, inv_Viewrot, view_vec); + + bn_encode_vect(&gedp->ged_result_str, model_vec); + + return BRLCAD_OK; + +bad: + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; +} + + +/* + * 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/view2model_vec.c ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: brlcad/trunk/src/mged/setup.c =================================================================== --- brlcad/trunk/src/mged/setup.c 2009-01-27 04:50:38 UTC (rev 33610) +++ brlcad/trunk/src/mged/setup.c 2009-01-27 18:24:49 UTC (rev 33611) @@ -152,8 +152,8 @@ {"get_sed_menus", f_get_sedit_menus, GED_FUNC_PTR_NULL}, {"get_solid_keypoint", f_get_solid_keypoint, GED_FUNC_PTR_NULL}, {"gqa", cmd_ged_plain_wrapper, ged_gqa}, - {"grid2model_lu", f_grid2model_lu, GED_FUNC_PTR_NULL}, - {"grid2view_lu", f_grid2view_lu, GED_FUNC_PTR_NULL}, + {"grid2model_lu", cmd_ged_plain_wrapper, ged_grid2model_lu}, + {"grid2view_lu", cmd_ged_plain_wrapper, ged_grid2view_lu}, #ifdef HIDELINE {"H", f_hideline, GED_FUNC_PTR_NULL}, #endif @@ -201,9 +201,9 @@ {"mirror", cmd_ged_edit_wrapper, ged_mirror}, {"mmenu_get", cmd_mmenu_get, GED_FUNC_PTR_NULL}, {"mmenu_set", cmd_nop, GED_FUNC_PTR_NULL}, - {"model2grid_lu", f_model2grid_lu, GED_FUNC_PTR_NULL}, + {"model2grid_lu", cmd_ged_plain_wrapper, ged_model2grid_lu}, {"model2view", cmd_ged_plain_wrapper, ged_model2view}, - {"model2view_lu", f_model2view_lu, GED_FUNC_PTR_NULL}, + {"model2view_lu", cmd_ged_plain_wrapper, ged_model2view_lu}, {"mrot", cmd_mrot, GED_FUNC_PTR_NULL}, {"mv", cmd_ged_plain_wrapper, ged_move}, {"mvall", cmd_ged_plain_wrapper, ged_move_all}, @@ -338,10 +338,10 @@ {"viewget", cmd_viewget, GED_FUNC_PTR_NULL}, {"viewset", cmd_viewset, GED_FUNC_PTR_NULL}, #endif - {"view2grid_lu", f_view2grid_lu, GED_FUNC_PTR_NULL}, + {"view2grid_lu", cmd_ged_plain_wrapper, ged_view2grid_lu}, {"view2model", cmd_ged_plain_wrapper, ged_view2model}, - {"view2model_lu", f_view2model_lu, GED_FUNC_PTR_NULL}, - {"view2model_vec", f_view2model_vec, GED_FUNC_PTR_NULL}, + {"view2model_lu", cmd_ged_plain_wrapper, ged_view2model_lu}, + {"view2model_vec", cmd_ged_plain_wrapper, ged_view2model_vec}, {"viewdir", cmd_ged_plain_wrapper, ged_viewdir}, {"viewsize", cmd_size, GED_FUNC_PTR_NULL}, /* alias "size" for saveview scripts */ {"vnirt", f_vnirt, GED_FUNC_PTR_NULL}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits