Revision: 33263
http://brlcad.svn.sourceforge.net/brlcad/?rev=33263view=rev
Author: bob1961
Date: 2008-12-01 16:50:25 + (Mon, 01 Dec 2008)
Log Message:
---
Added labels.c and scale.c for drawing primitive labels and a view scale.
Modified Paths:
--
brlcad/trunk/src/libdm/Makefile.am
Added Paths:
---
brlcad/trunk/src/libdm/labels.c
brlcad/trunk/src/libdm/scale.c
Modified: brlcad/trunk/src/libdm/Makefile.am
===
--- brlcad/trunk/src/libdm/Makefile.am 2008-12-01 16:43:24 UTC (rev 33262)
+++ brlcad/trunk/src/libdm/Makefile.am 2008-12-01 16:50:25 UTC (rev 33263)
@@ -45,9 +45,11 @@
focus.c \
grid.c \
knob.c \
+ labels.c \
options.c \
query.c \
rect.c \
+ scale.c \
tcl.c \
vers.c
Added: brlcad/trunk/src/libdm/labels.c
===
--- brlcad/trunk/src/libdm/labels.c (rev 0)
+++ brlcad/trunk/src/libdm/labels.c 2008-12-01 16:50:25 UTC (rev 33263)
@@ -0,0 +1,696 @@
+/* L A B E L S . C
+ * BRL-CAD
+ *
+ * Copyright (c) 1998-2008 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 labels.c
+ *
+ * Functions -
+ * dm_draw_labels Draw primitive labels.
+ *
+ */
+
+#include common.h
+#include bio.h
+
+#include stdio.h
+#include math.h
+
+#include vmath.h
+#include bu.h
+#include bn.h
+#include db.h
+#include mater.h
+#include nmg.h
+#include rtgeom.h
+#include nurb.h
+#include solid.h
+#include dm.h
+
+/*
+ * Put labels on the vertices of the currently edited solid.
+ * XXX This really should use import/export interface!!! Or be part of it.
+ *
+ * This code was lifted from mged/edsol.c.
+ * XXX This should probably live in librt.
+ */
+void
+dm_label_primitive(struct rt_wdb *wdbp,
+ int *num_lines,
+ point_t *lines,
+ struct rt_point_labels pl[],
+ int max_pl,
+ const mat_t xform,
+ struct rt_db_internal*ip)
+{
+register int i;
+point_twork;
+point_tpos_view;
+intnpl = 0;
+
+
+#definePOINT_LABEL( _pt, _char ) { \
+ VMOVE( pl[npl].pt, _pt ); \
+ pl[npl].str[0] = _char; \
+ pl[npl++].str[1] = '\0'; }
+
+#definePOINT_LABEL_STR( _pt, _str ){ \
+ VMOVE( pl[npl].pt, _pt ); \
+ bu_strlcpy( pl[npl++].str, _str, sizeof(pl[0].str) ); }
+
+
+RT_CK_DB_INTERNAL(ip);
+
+if (ip-idb_major_type != DB5_MAJORTYPE_BRLCAD)
+ /* silently ignore */
+ return;
+
+switch (ip-idb_minor_type) {
+ case DB5_MINORTYPE_BRLCAD_TOR: {
+ struct rt_tor_internal *tor =
+ (struct rt_tor_internal *)ip-idb_ptr;
+ fastf_t r3, r4;
+ vect_t adir;
+
+ RT_TOR_CK_MAGIC(tor);
+
+ bn_vec_ortho(adir, tor-h);
+
+ MAT4X3PNT(pos_view, xform, tor-v);
+ POINT_LABEL(pos_view, 'V');
+
+ r3 = tor-r_a - tor-r_h;
+ VJOIN1(work, tor-v, r3, adir);
+ MAT4X3PNT(pos_view, xform, work);
+ POINT_LABEL(pos_view, 'I');
+
+ r4 = tor-r_a + tor-r_h;
+ VJOIN1(work, tor-v, r4, adir);
+ MAT4X3PNT(pos_view, xform, work);
+ POINT_LABEL(pos_view, 'O');
+
+ VJOIN1(work, tor-v, tor-r_a, adir);
+ VADD2(work, work, tor-h);
+ MAT4X3PNT(pos_view, xform, work);
+ POINT_LABEL(pos_view, 'H');
+ }
+
+ break;
+ case DB5_MINORTYPE_BRLCAD_TGC: {
+ struct rt_tgc_internal *tgc =
+ (struct rt_tgc_internal *)ip-idb_ptr;
+
+ RT_TGC_CK_MAGIC(tgc);
+ MAT4X3PNT(pos_view, xform, tgc-v);
+ POINT_LABEL(pos_view, 'V');
+
+ VADD2(work, tgc-v, tgc-a);
+ MAT4X3PNT(pos_view, xform, work);
+ POINT_LABEL(pos_view, 'A');
+
+ VADD2(work, tgc-v, tgc-b);
+ MAT4X3PNT(pos_view, xform, work);
+ POINT_LABEL(pos_view, 'B');
+
+