Rework/simplify ft_labels callback logic

Rather than setting up bv_scene_obj outputs, focus the method on
returning label info.  This should allow both MGED and qged to use the
same source for labels.
This commit is contained in:
Clifford Yapp committed 2024-12-20 11:54:46 -05:00
1 parent 5f80972733
commit 3d12a3452a
20 files changed
+445 -813

No files matched your search

+4 -3
View File
@@ -44,6 +44,7 @@
#include "rt/db_internal.h"
#include "rt/db_instance.h"
#include "rt/hit.h"
#include "rt/misc.h"
#include "rt/resource.h"
#include "rt/rt_instance.h"
#include "rt/seg.h"
@@ -269,9 +270,9 @@ struct rt_functab {
int (*ft_prep_serialize)(struct soltab *stp, const struct rt_db_internal *ip, struct bu_external *external, size_t *version);
#define RTFUNCTAB_FUNC_PREP_SERIALIZE_CAST(_func) ((int (*)(struct soltab *, const struct rt_db_internal *, struct bu_external *, size_t *))((void (*)(void))_func))
/** generate struct bv_scene_obj labels for the primitive */
void (*ft_labels)(struct bv_scene_obj *ps, const struct rt_db_internal *ip);
#define RTFUNCTAB_FUNC_LABELS_CAST(_func) ((void (*)(struct bv_scene_obj *, const struct rt_db_internal *))((void (*)(void))_func))
/** generate labels for the primitive. Returns the number of labels populated in pl */
int (*ft_labels)(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *tol);
#define RTFUNCTAB_FUNC_LABELS_CAST(_func) ((int (*)(struct rt_point_labels *, int, const mat_t, const struct rt_db_internal *, const struct bn_tol *))((void (*)(void))_func))
/** perturb geometry parameters of primitive. NOTE: the oip primitive
* returned is NOT guaranteed to be the same type as that of ip - for example,
+42 -52
View File
@@ -2626,75 +2626,65 @@ rt_arb_find_e_nearest_pt2(int *edge,
return 0;
}
void
rt_arb_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_arb_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *utol)
{
int i;
if (!pl || pl_max < 8)
return 0;
if (!ps || !ip)
return;
struct rt_arb_internal *arb = (struct rt_arb_internal *)ip->idb_ptr;
const struct bn_tol ltol = BN_TOL_INIT_TOL;
const struct bn_tol *tol = (utol) ? utol : &ltol;
struct rt_arb_internal *arb= (struct rt_arb_internal *)ip->idb_ptr;
RT_ARB_CK_MAGIC(arb);
int es_type = rt_arb_std_type(ip, tol);
const struct bn_tol arb_tol = BN_TOL_INIT_TOL;
int arbType = rt_arb_std_type(ip, &arb_tol);
point_t pos_view;
int npl = 0;
// Set up the containers
struct bv_label *l[8];
for (i = 0; i < arbType; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
l[i] = la;
}
// Do the specific data assignments for each label
switch (arbType) {
switch (es_type)
{
case ARB8:
for (i=0; i<8; i++) {
bu_vls_sprintf(&l[i]->label, "%d", i+1);
VMOVE(l[i]->p, arb->pt[i]);
for (int i=0; i<8; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
break;
return 8;
case ARB7:
for (i=0; i<7; i++) {
bu_vls_sprintf(&l[i]->label, "%d", i+1);
VMOVE(l[i]->p, arb->pt[i]);
for (int i=0; i<7; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
break;
return 7;
case ARB6:
for (i=0; i<5; i++) {
bu_vls_sprintf(&l[i]->label, "%d", i+1);
VMOVE(l[i]->p, arb->pt[i]);
for (int i=0; i<5; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
bu_vls_sprintf(&l[5]->label, "6");
VMOVE(l[5]->p, arb->pt[6]);
break;
MAT4X3PNT(pos_view, xform, arb->pt[6]);
POINT_LABEL(pos_view, '6');
return 6;
case ARB5:
for (i=0; i<5; i++) {
bu_vls_sprintf(&l[i]->label, "%d", i+1);
VMOVE(l[i]->p, arb->pt[i]);
for (int i=0; i<5; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
break;
return 5;
case ARB4:
for (i=0; i<3; i++) {
bu_vls_sprintf(&l[i]->label, "%d", i+1);
VMOVE(l[i]->p, arb->pt[i]);
for (int i=0; i<3; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
bu_vls_sprintf(&l[3]->label, "4");
VMOVE(l[3]->p, arb->pt[4]);
break;
MAT4X3PNT(pos_view, xform, arb->pt[4]);
POINT_LABEL(pos_view, '4');
return 4;
default:
return 0;
}
}
int
+15 -24
View File
@@ -968,40 +968,31 @@ rt_ars_params(struct pc_pc_set *UNUSED(ps), const struct rt_db_internal *ip)
return 0; /* OK */
}
void
rt_ars_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_ars_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
/*XXX Needs work - doesn't really represent the ARS data well... */
int lcnt = 1;
if (!pl || pl_max < lcnt)
return 0;
struct rt_ars_internal *ars = (struct rt_ars_internal *)ip->idb_ptr;
RT_ARS_CK_MAGIC(ars);
// Set up the containers
struct bv_label *l[2];
int lcnt = 1;
for (int i = 0; i < lcnt; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
point_t pos_view;
int npl = 0;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
l[i] = la;
}
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, ars->curves[0]);
MAT4X3PNT(pos_view, xform, ars->curves[0]);
POINT_LABEL(pos_view, 'V');
return lcnt;
}
/** @} */
/*
* Local Variables:
-56
View File
@@ -1439,62 +1439,6 @@ rt_nurb_params(struct pc_pc_set *, const struct rt_db_internal *)
return 0; /* OK */
}
extern "C" void
rt_nurb_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
{
if (!ps || !ip)
return;
struct rt_nurb_internal *nurb = (struct rt_nurb_internal *)ip->idb_ptr;
RT_NURB_CK_MAGIC(nurb);
// Set up the containers
struct bv_label *l[5];
for (int i = 0; i < 5; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
l[i] = la;
}
// Do the specific data assignments for each label
/*XXX Needs work */
struct face_g_snurb *surf;
fastf_t *fp;
surf = nurb->srfs[0];
NMG_CK_SNURB(surf);
fp = &RT_NURB_GET_CONTROL_POINT(surf, 0, 0);
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, fp);
fp = &RT_NURB_GET_CONTROL_POINT(surf, 0, 0);
bu_vls_sprintf(&l[1]->label, " 0, 0");
VMOVE(l[1]->p, fp);
fp = &RT_NURB_GET_CONTROL_POINT(surf, 0, surf->s_size[1]-1);
bu_vls_sprintf(&l[2]->label, "u, 0");
VMOVE(l[2]->p, fp);
fp = &RT_NURB_GET_CONTROL_POINT(surf, surf->s_size[0]-1, 0);
bu_vls_sprintf(&l[3]->label, "0, v");
VMOVE(l[3]->p, fp);
fp = &RT_NURB_GET_CONTROL_POINT(surf, surf->s_size[0]-1, surf->s_size[1]-1);
bu_vls_sprintf(&l[4]->label, "u, v");
VMOVE(l[4]->p, fp);
}
#ifdef __cplusplus
}
#endif
+17 -26
View File
@@ -1144,43 +1144,34 @@ rt_cline_to_pipe(struct rt_pipe_internal *pipep, const struct rt_db_internal *ip
return 0;
}
void
rt_cline_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_cline_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 2;
if (!pl || pl_max < lcnt)
return 0;
struct rt_cline_internal *cline = (struct rt_cline_internal *)ip->idb_ptr;
RT_CLINE_CK_MAGIC(cline);
// Set up the containers
struct bv_label *l[2];
for (int i = 0; i < 2; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
point_t work1, pos_view;
int npl = 0;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
l[i] = la;
}
MAT4X3PNT(pos_view, xform, cline->v);
POINT_LABEL(pos_view, 'V');
// Do the specific data assignments for each label
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, cline->v);
bu_vls_sprintf(&l[0]->label, "H");
VADD2(l[1]->p, cline->v, cline->h);
VADD2(work1, cline->v, cline->h);
MAT4X3PNT(pos_view, xform, work1);
POINT_LABEL(pos_view, 'H');
return lcnt;
}
/** @} */
/*
* Local Variables:
+31 -35
View File
@@ -2077,60 +2077,56 @@ rt_ehy_centroid(point_t *cent, const struct rt_db_internal *ip)
VJOIN1(*cent, apex, dist_C, unit_vec);
}
void
rt_ehy_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_ehy_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 5;
if (!pl || pl_max < lcnt)
return 0;
struct rt_ehy_internal *ehy = (struct rt_ehy_internal *)ip->idb_ptr;
RT_EHY_CK_MAGIC(ehy);
// Set up the containers
struct bv_label *l[5];
for (int i = 0; i < 5; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
point_t work, pos_view;
int npl = 0;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
l[i] = la;
}
vect_t A, B;
// Do the specific data assignments for each label
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, ehy->ehy_V);
MAT4X3PNT(pos_view, xform, ehy->ehy_V);
POINT_LABEL(pos_view, 'V');
bu_vls_sprintf(&l[1]->label, "H");
VADD2(l[1]->p, ehy->ehy_V, ehy->ehy_H);
VADD2(work, ehy->ehy_V, ehy->ehy_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
bu_vls_sprintf(&l[2]->label, "A");
vect_t A;
VSCALE(A, ehy->ehy_Au, ehy->ehy_r1);
VADD2(l[2]->p, ehy->ehy_V, A);
VADD2(work, ehy->ehy_V, A);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
bu_vls_sprintf(&l[3]->label, "B");
vect_t B;
VCROSS(B, ehy->ehy_Au, ehy->ehy_H);
VUNITIZE(B);
VSCALE(B, B, ehy->ehy_r2);
VADD2(l[3]->p, ehy->ehy_V, B);
VADD2(work, ehy->ehy_V, B);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
bu_vls_sprintf(&l[4]->label, "c");
VMOVE(l[4]->p, ehy->ehy_H);
VUNITIZE(l[4]->p);
VSCALE(l[4]->p, l[4]->p, MAGNITUDE(ehy->ehy_H) + ehy->ehy_c);
VADD2(l[4]->p, ehy->ehy_V, l[4]->p);
VMOVE(work, ehy->ehy_H);
VUNITIZE(work);
VSCALE(work, work,
MAGNITUDE(ehy->ehy_H) + ehy->ehy_c);
VADD2(work, ehy->ehy_V, work);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'c');
return lcnt;
}
/** @} */
/*
* Local Variables:
+23 -28
View File
@@ -1967,47 +1967,42 @@ rt_ell_surf_area(fastf_t *area, const struct rt_db_internal *ip)
}
}
void
rt_ell_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_ell_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 4;
if (!pl || pl_max < lcnt)
return 0;
struct rt_ell_internal *ell = (struct rt_ell_internal *)ip->idb_ptr;
RT_ELL_CK_MAGIC(ell);
// Set up the containers
struct bv_label *l[4];
for (int i = 0; i < 4; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
point_t work, pos_view;
int npl = 0;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
l[i] = la;
}
MAT4X3PNT(pos_view, xform, ell->v);
POINT_LABEL(pos_view, 'V');
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, ell->v);
VADD2(work, ell->v, ell->a);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
bu_vls_sprintf(&l[1]->label, "A");
VADD2(l[1]->p, ell->v, ell->a);
VADD2(work, ell->v, ell->b);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
bu_vls_sprintf(&l[2]->label, "B");
VADD2(l[2]->p, ell->v, ell->b);
bu_vls_sprintf(&l[3]->label, "C");
VADD2(l[3]->p, ell->v, ell->c);
VADD2(work, ell->v, ell->c);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'C');
return lcnt;
}
/** @} */
/*
* Local Variables:
+24 -29
View File
@@ -2020,51 +2020,46 @@ epa_is_valid(struct rt_epa_internal *epa)
return 1;
}
void
rt_epa_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_epa_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 4;
if (!pl || pl_max < lcnt)
return 0;
struct rt_epa_internal *epa = (struct rt_epa_internal *)ip->idb_ptr;
RT_EPA_CK_MAGIC(epa);
// Set up the containers
struct bv_label *l[4];
for (int i = 0; i < 4; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
point_t work, pos_view;
int npl = 0;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
l[i] = la;
}
vect_t A, B;
MAT4X3PNT(pos_view, xform, epa->epa_V);
POINT_LABEL(pos_view, 'V');
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, epa->epa_V);
VADD2(work, epa->epa_V, epa->epa_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
bu_vls_sprintf(&l[1]->label, "H");
VADD2(l[1]->p, epa->epa_V, epa->epa_H);
bu_vls_sprintf(&l[2]->label, "A");
vect_t A;
VSCALE(A, epa->epa_Au, epa->epa_r1);
VADD2(l[2]->p, epa->epa_V, A);
VADD2(work, epa->epa_V, A);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
bu_vls_sprintf(&l[3]->label, "B");
vect_t B;
VCROSS(B, epa->epa_Au, epa->epa_H);
VUNITIZE(B);
VSCALE(B, B, epa->epa_r2);
VADD2(l[3]->p, epa->epa_V, B);
VADD2(work, epa->epa_V, B);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
return lcnt;
}
+24 -29
View File
@@ -1676,39 +1676,30 @@ eto_is_valid(struct rt_eto_internal *eto)
return 1;
}
void
rt_eto_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_eto_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 4;
if (!pl || pl_max < lcnt)
return 0;
struct rt_eto_internal *eto = (struct rt_eto_internal *)ip->idb_ptr;
RT_ETO_CK_MAGIC(eto);
// Set up the containers
struct bv_label *l[4];
for (int i = 0; i < 4; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
point_t work, pos_view;
int npl = 0;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
l[i] = la;
}
// Do the specific data assignments for each label
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, eto->eto_V);
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
fastf_t ch, cv, dh, dv, cmag, phi;
vect_t Au, Nu;
MAT4X3PNT(pos_view, xform, eto->eto_V);
POINT_LABEL(pos_view, 'V');
VMOVE(Nu, eto->eto_N);
VUNITIZE(Nu);
bn_vec_ortho(Au, Nu);
@@ -1723,15 +1714,19 @@ rt_eto_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
dv = -eto->eto_rd * sin(phi);
dh = eto->eto_rd * cos(phi);
bu_vls_sprintf(&l[1]->label, "C");
VJOIN2(l[1]->p, eto->eto_V, eto->eto_r+ch, Au, cv, Nu);
VJOIN2(work, eto->eto_V, eto->eto_r+ch, Au, cv, Nu);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'C');
bu_vls_sprintf(&l[2]->label, "D");
VJOIN2(l[2]->p, eto->eto_V, eto->eto_r+dh, Au, dv, Nu);
VJOIN2(work, eto->eto_V, eto->eto_r+dh, Au, dv, Nu);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'D');
bu_vls_sprintf(&l[3]->label, "r");
VJOIN1(l[3]->p, eto->eto_V, eto->eto_r, Au);
VJOIN1(work, eto->eto_V, eto->eto_r, Au);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'r');
return lcnt;
}
/** @} */
+27 -30
View File
@@ -1434,48 +1434,45 @@ rt_hyp_volume(fastf_t *volume, const struct rt_db_internal *ip)
}
}
void
rt_hyp_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_hyp_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 4;
if (!pl || pl_max < lcnt)
return 0;
struct rt_hyp_internal *hyp = (struct rt_hyp_internal *)ip->idb_ptr;
RT_HYP_CK_MAGIC(hyp);
// Set up the containers
struct bv_label *l[4];
for (int i = 0; i < 4; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
point_t work, pos_view;
int npl = 0;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
l[i] = la;
}
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, hyp->hyp_Vi);
bu_vls_sprintf(&l[1]->label, "H");
VADD2(l[1]->p, hyp->hyp_Vi, hyp->hyp_Hi);
bu_vls_sprintf(&l[2]->label, "A");
VADD2(l[2]->p, hyp->hyp_Vi, hyp->hyp_A);
bu_vls_sprintf(&l[3]->label, "B");
vect_t vB;
MAT4X3PNT(pos_view, xform, hyp->hyp_Vi);
POINT_LABEL(pos_view, 'V');
VADD2(work, hyp->hyp_Vi, hyp->hyp_Hi);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VADD2(work, hyp->hyp_Vi, hyp->hyp_A);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
VCROSS(vB, hyp->hyp_A, hyp->hyp_Hi);
VUNITIZE(vB);
VSCALE(vB, vB, hyp->hyp_b);
VADD2(l[3]->p, hyp->hyp_Vi, vB);
VADD2(work, hyp->hyp_Vi, vB);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
return lcnt;
}
/*
+29 -32
View File
@@ -1878,50 +1878,47 @@ rt_part_centroid(point_t *cent, const struct rt_db_internal *ip)
VADD3(*cent, fcent, hhcent, cvcent);
}
void
rt_part_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_part_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 4;
if (!pl || pl_max < lcnt)
return 0;
struct rt_part_internal *part = (struct rt_part_internal *)ip->idb_ptr;
RT_PART_CK_MAGIC(part);
// Set up the containers
struct bv_label *l[4];
for (int i = 0; i < 4; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
point_t work, pos_view;
int npl = 0;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
l[i] = la;
}
// Do the specific data assignments for each label
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, part->part_V);
bu_vls_sprintf(&l[1]->label, "H");
VADD2(l[1]->p, part->part_V, part->part_H);
bu_vls_sprintf(&l[2]->label, "v");
vect_t Ru, ortho;
MAT4X3PNT(pos_view, xform, part->part_V);
POINT_LABEL(pos_view, 'V');
VADD2(work, part->part_V, part->part_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VMOVE(Ru, part->part_H);
VUNITIZE(Ru);
bn_vec_ortho(ortho, Ru);
VSCALE(l[2]->p, ortho, part->part_vrad);
VADD2(l[2]->p, part->part_V, l[2]->p);
VSCALE(work, ortho, part->part_vrad);
VADD2(work, part->part_V, work);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'v');
bu_vls_sprintf(&l[3]->label, "h");
VSCALE(l[3]->p, ortho, part->part_hrad);
VADD3(l[3]->p, part->part_V, part->part_H, l[3]->p);
VSCALE(work, ortho, part->part_hrad);
VADD3(work, part->part_V, part->part_H, work);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'h');
return lcnt;
}
/*
+34 -37
View File
@@ -1953,58 +1953,55 @@ rt_rhc_centroid(point_t *cent, const struct rt_db_internal *ip)
}
}
void
rt_rhc_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_rhc_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 5;
if (!pl || pl_max < lcnt)
return 0;
struct rt_rhc_internal *rhc = (struct rt_rhc_internal *)ip->idb_ptr;
RT_RHC_CK_MAGIC(rhc);
// Set up the containers
struct bv_label *l[5];
for (int i = 0; i < 5; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
point_t work, pos_view;
int npl = 0;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
l[i] = la;
}
// Do the specific data assignments for each label
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, rhc->rhc_V);
bu_vls_sprintf(&l[1]->label, "B");
VADD2(l[1]->p, rhc->rhc_V, rhc->rhc_B);
bu_vls_sprintf(&l[2]->label, "H");
VADD2(l[2]->p, rhc->rhc_V, rhc->rhc_H);
bu_vls_sprintf(&l[3]->label, "r");
vect_t Ru;
MAT4X3PNT(pos_view, xform, rhc->rhc_V);
POINT_LABEL(pos_view, 'V');
VADD2(work, rhc->rhc_V, rhc->rhc_B);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
VADD2(work, rhc->rhc_V, rhc->rhc_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VCROSS(Ru, rhc->rhc_B, rhc->rhc_H);
VUNITIZE(Ru);
VSCALE(Ru, Ru, rhc->rhc_r);
VADD2(l[3]->p, rhc->rhc_V, Ru);
VADD2(work, rhc->rhc_V, Ru);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'r');
bu_vls_sprintf(&l[4]->label, "c");
VMOVE(l[4]->p, rhc->rhc_B);
VUNITIZE(l[4]->p);
VSCALE(l[4]->p, l[4]->p, MAGNITUDE(rhc->rhc_B) + rhc->rhc_c);
VADD2(l[4]->p, l[4]->p, rhc->rhc_V);
VMOVE(work, rhc->rhc_B);
VUNITIZE(work);
VSCALE(work, work,
MAGNITUDE(rhc->rhc_B) + rhc->rhc_c);
VADD2(work, work, rhc->rhc_V);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'c');
return lcnt;
}
/*
* Local Variables:
* mode: C
+29 -34
View File
@@ -1731,50 +1731,45 @@ rpc_is_valid(struct rt_rpc_internal *rpc)
return 1;
}
void
rt_rpc_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_rpc_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 4;
if (!pl || pl_max < lcnt)
return 0;
struct rt_rpc_internal *rpc = (struct rt_rpc_internal *)ip->idb_ptr;
RT_RPC_CK_MAGIC(rpc);
// Set up the containers
struct bv_label *l[4];
for (int i = 0; i < 4; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
l[i] = la;
}
// Do the specific data assignments for each label
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, rpc->rpc_V);
bu_vls_sprintf(&l[1]->label, "B");
VADD2(l[1]->p, rpc->rpc_V, rpc->rpc_B);
bu_vls_sprintf(&l[2]->label, "H");
VADD2(l[2]->p, rpc->rpc_V, rpc->rpc_H);
bu_vls_sprintf(&l[3]->label, "r");
vect_t Ru;
point_t work, pos_view;
int npl = 0;
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
MAT4X3PNT(pos_view, xform, rpc->rpc_V);
POINT_LABEL(pos_view, 'V');
VADD2(work, rpc->rpc_V, rpc->rpc_B);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
VADD2(work, rpc->rpc_V, rpc->rpc_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VCROSS(Ru, rpc->rpc_B, rpc->rpc_H);
VUNITIZE(Ru);
VSCALE(Ru, Ru, rpc->rpc_r);
VADD2(l[3]->p, rpc->rpc_V, Ru);
}
VADD2(work, rpc->rpc_V, Ru);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'r');
return lcnt;
}
/*
* Local Variables:
-33
View File
@@ -428,39 +428,6 @@ rt_sph_params(struct pc_pc_set *UNUSED(ps), const struct rt_db_internal *ip)
return 0; /* OK */
}
void
rt_sph_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
{
if (!ps || !ip)
return;
struct rt_ell_internal *ell = (struct rt_ell_internal *)ip->idb_ptr;
RT_ELL_CK_MAGIC(ell);
// Set up the containers
struct bv_label *l[4];
for (int i = 0; i < 4; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
l[i] = la;
}
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, ell->v);
bu_vls_sprintf(&l[1]->label, "R");
VADD2(l[1]->p, ell->v, ell->a);
}
/* ELL versions are used for many of the callbacks */
+36
View File
@@ -1293,6 +1293,42 @@ rt_superell_surf_area(fastf_t *area, const struct rt_db_internal *ip)
}
}
int
rt_superell_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
int lcnt = 4;
if (!pl || pl_max < lcnt)
return 0;
struct rt_superell_internal *superell = (struct rt_superell_internal *)ip->idb_ptr;
RT_SUPERELL_CK_MAGIC(superell);
point_t work, pos_view;
int npl = 0;
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
MAT4X3PNT(pos_view, xform, superell->v);
POINT_LABEL(pos_view, 'V');
VADD2(work, superell->v, superell->a);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
VADD2(work, superell->v, superell->b);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
VADD2(work, superell->v, superell->c);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'C');
return lcnt;
}
/*
* Local Variables:
+5 -5
View File
@@ -80,7 +80,7 @@ extern "C" {
extern struct rt_selection *rt_##name##_evaluate_selection(const struct rt_db_internal *ip, int op, const struct rt_selection *a, const struct rt_selection *b); \
extern int rt_##name##_process_selection(struct rt_db_internal *ip, struct db_i *, const struct rt_selection *selection, const struct rt_selection_operation *op); \
extern int rt_##name##_prep_serialize(struct soltab *stp, const struct rt_db_internal *ip, struct bu_external *external, size_t *version); \
extern void rt_##name##_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip); \
extern int rt_##name##_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *utol); \
extern int rt_##name##_perturb(struct rt_db_internal **oip, const struct rt_db_internal *ip, int planar_only, fastf_t factor)
RT_DECLARE_INTERFACE(tor);
@@ -640,7 +640,7 @@ const struct rt_functab OBJ[] = {
NULL, /* evaluate_selection */
NULL, /* process_selection */
NULL, /* serialize */
RTFUNCTAB_FUNC_LABELS_CAST(rt_nurb_labels), /* label */
NULL, /* label */
NULL /* perturb */
},
@@ -688,7 +688,7 @@ const struct rt_functab OBJ[] = {
NULL, /* evaluate_selection */
NULL, /* process_selection */
NULL, /* serialize */
RTFUNCTAB_FUNC_LABELS_CAST(rt_sph_labels), /* label */
RTFUNCTAB_FUNC_LABELS_CAST(rt_ell_labels), /* label */
NULL /* perturb */
},
@@ -1168,7 +1168,7 @@ const struct rt_functab OBJ[] = {
NULL, /* evaluate_selection */
NULL, /* process_selection */
NULL, /* serialize */
RTFUNCTAB_FUNC_LABELS_CAST(rt_ehy_labels), /* label */
RTFUNCTAB_FUNC_LABELS_CAST(rt_epa_labels), /* label */
NULL /* perturb */
},
@@ -1937,7 +1937,7 @@ const struct rt_functab OBJ[] = {
NULL, /* evaluate_selection */
NULL, /* process_selection */
NULL, /* serialize */
NULL, /* label */
RTFUNCTAB_FUNC_LABELS_CAST(rt_superell_labels), /* label */
NULL /* perturb */
},
+28 -32
View File
@@ -3419,47 +3419,43 @@ rt_tgc_centroid(point_t *cent, const struct rt_db_internal *ip)
}
}
void
rt_tgc_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_tgc_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 5;
if (!pl || pl_max < lcnt)
return 0;
point_t work, pos_view;
int npl = 0;
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
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');
// Set up the containers
struct bv_label *l[5];
for (int i = 0; i < 5; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
VADD2(work, tgc->v, tgc->a);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
VADD2(work, tgc->v, tgc->b);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
l[i] = la;
}
VADD3(work, tgc->v, tgc->h, tgc->c);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'C');
// Do the specific data assignments for each label
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, tgc->v);
VADD3(work, tgc->v, tgc->h, tgc->d);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'D');
bu_vls_sprintf(&l[1]->label, "A");
VADD2(l[1]->p, tgc->v, tgc->a);
bu_vls_sprintf(&l[2]->label, "B");
VADD2(l[2]->p, tgc->v, tgc->b);
bu_vls_sprintf(&l[3]->label, "C");
VADD3(l[3]->p, tgc->v, tgc->h, tgc->c);
bu_vls_sprintf(&l[4]->label, "D");
VADD3(l[4]->p, tgc->v, tgc->h, tgc->d);
return lcnt;
}
int
+29 -34
View File
@@ -1812,54 +1812,49 @@ rt_tor_centroid(point_t *cent, const struct rt_db_internal *ip)
VMOVE(*cent,tip->v);
}
void
rt_tor_labels(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
int
rt_tor_labels(struct rt_point_labels *pl, int pl_max, const mat_t xform, const struct rt_db_internal *ip, const struct bn_tol *UNUSED(tol))
{
if (!ps || !ip)
return;
int lcnt = 4;
if (!pl || pl_max < 4)
return 0;
struct rt_tor_internal *tor = (struct rt_tor_internal *)ip->idb_ptr;
RT_TOR_CK_MAGIC(tor);
// Set up the containers
struct bv_label *l[4];
for (int i = 0; i < 4; i++) {
struct bv_scene_obj *s = bv_obj_get_child(ps);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
l[i] = la;
}
// Do the specific data assignments for each label
point_t work, pos_view;
fastf_t r3, r4;
vect_t adir;
int npl = 0;
#define POINT_LABEL(_pt, _char) { \
VMOVE(pl[npl].pt, _pt); \
pl[npl].str[0] = _char; \
pl[npl++].str[1] = '\0'; }
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');
bu_vls_sprintf(&l[0]->label, "V");
VMOVE(l[0]->p, tor->v);
VJOIN1(work, tor->v, tor->r_a, adir);
VADD2(work, work, tor->h);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
bu_vls_sprintf(&l[1]->label, "I");
VJOIN1(l[1]->p, tor->v, r3, adir);
bu_vls_sprintf(&l[2]->label, "O");
VJOIN1(l[2]->p, tor->v, r4, adir);
bu_vls_sprintf(&l[3]->label, "H");
VJOIN1(l[3]->p, tor->v, tor->r_a, adir);
VADD2(l[3]->p, l[3]->p, tor->h);
return lcnt;
}
/*
* Local Variables:
* mode: C
+26 -292
View File
@@ -6479,14 +6479,13 @@ f_param(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])
void
label_edited_solid(
struct mged_state *s,
int *num_lines,
point_t *lines,
int *num_lines, // NOTE - used only for BOTs
point_t *lines, // NOTE - used only for BOTs
struct rt_point_labels pl[],
int UNUSED(max_pl),
int max_pl,
const mat_t xform,
struct rt_db_internal *ip)
{
int i;
point_t work;
point_t pos_view;
int npl = 0;
@@ -6509,43 +6508,7 @@ label_edited_solid(
struct rt_arb_internal *arb=
(struct rt_arb_internal *)s->edit_state.es_int.idb_ptr;
RT_ARB_CK_MAGIC(arb);
switch (es_type)
{
case ARB8:
for (i=0; i<8; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
break;
case ARB7:
for (i=0; i<7; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
break;
case ARB6:
for (i=0; i<5; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
MAT4X3PNT(pos_view, xform, arb->pt[6]);
POINT_LABEL(pos_view, '6');
break;
case ARB5:
for (i=0; i<5; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
break;
case ARB4:
for (i=0; i<3; i++) {
MAT4X3PNT(pos_view, xform, arb->pt[i]);
POINT_LABEL(pos_view, i+'1');
}
MAT4X3PNT(pos_view, xform, arb->pt[4]);
POINT_LABEL(pos_view, '4');
break;
}
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
case ID_TGC:
@@ -6553,24 +6516,7 @@ label_edited_solid(
struct rt_tgc_internal *tgc =
(struct rt_tgc_internal *)s->edit_state.es_int.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');
VADD3(work, tgc->v, tgc->h, tgc->c);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'C');
VADD3(work, tgc->v, tgc->h, tgc->d);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'D');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6579,21 +6525,7 @@ label_edited_solid(
struct rt_ell_internal *ell =
(struct rt_ell_internal *)s->edit_state.es_int.idb_ptr;
RT_ELL_CK_MAGIC(ell);
MAT4X3PNT(pos_view, xform, ell->v);
POINT_LABEL(pos_view, 'V');
VADD2(work, ell->v, ell->a);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
VADD2(work, ell->v, ell->b);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
VADD2(work, ell->v, ell->c);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'C');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6602,51 +6534,17 @@ label_edited_solid(
struct rt_superell_internal *superell =
(struct rt_superell_internal *)s->edit_state.es_int.idb_ptr;
RT_SUPERELL_CK_MAGIC(superell);
MAT4X3PNT(pos_view, xform, superell->v);
POINT_LABEL(pos_view, 'V');
VADD2(work, superell->v, superell->a);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
VADD2(work, superell->v, superell->b);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
VADD2(work, superell->v, superell->c);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'C');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
case ID_TOR:
{
struct rt_tor_internal *tor =
(struct rt_tor_internal *)s->edit_state.es_int.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');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6654,26 +6552,8 @@ label_edited_solid(
{
struct rt_rpc_internal *rpc =
(struct rt_rpc_internal *)s->edit_state.es_int.idb_ptr;
vect_t Ru;
RT_RPC_CK_MAGIC(rpc);
MAT4X3PNT(pos_view, xform, rpc->rpc_V);
POINT_LABEL(pos_view, 'V');
VADD2(work, rpc->rpc_V, rpc->rpc_B);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
VADD2(work, rpc->rpc_V, rpc->rpc_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VCROSS(Ru, rpc->rpc_B, rpc->rpc_H);
VUNITIZE(Ru);
VSCALE(Ru, Ru, rpc->rpc_r);
VADD2(work, rpc->rpc_V, Ru);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'r');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6681,28 +6561,8 @@ label_edited_solid(
{
struct rt_part_internal *part =
(struct rt_part_internal *)s->edit_state.es_int.idb_ptr;
vect_t Ru, ortho;
RT_PART_CK_MAGIC(part);
MAT4X3PNT(pos_view, xform, part->part_V);
POINT_LABEL(pos_view, 'V');
VADD2(work, part->part_V, part->part_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VMOVE(Ru, part->part_H);
VUNITIZE(Ru);
bn_vec_ortho(ortho, Ru);
VSCALE(work, ortho, part->part_vrad);
VADD2(work, part->part_V, work);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'v');
VSCALE(work, ortho, part->part_hrad);
VADD3(work, part->part_V, part->part_H, work);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'h');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6710,34 +6570,8 @@ label_edited_solid(
{
struct rt_rhc_internal *rhc =
(struct rt_rhc_internal *)s->edit_state.es_int.idb_ptr;
vect_t Ru;
RT_RHC_CK_MAGIC(rhc);
MAT4X3PNT(pos_view, xform, rhc->rhc_V);
POINT_LABEL(pos_view, 'V');
VADD2(work, rhc->rhc_V, rhc->rhc_B);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
VADD2(work, rhc->rhc_V, rhc->rhc_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VCROSS(Ru, rhc->rhc_B, rhc->rhc_H);
VUNITIZE(Ru);
VSCALE(Ru, Ru, rhc->rhc_r);
VADD2(work, rhc->rhc_V, Ru);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'r');
VMOVE(work, rhc->rhc_B);
VUNITIZE(work);
VSCALE(work, work,
MAGNITUDE(rhc->rhc_B) + rhc->rhc_c);
VADD2(work, work, rhc->rhc_V);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'c');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6745,27 +6579,8 @@ label_edited_solid(
{
struct rt_epa_internal *epa =
(struct rt_epa_internal *)s->edit_state.es_int.idb_ptr;
vect_t A, B;
RT_EPA_CK_MAGIC(epa);
MAT4X3PNT(pos_view, xform, epa->epa_V);
POINT_LABEL(pos_view, 'V');
VADD2(work, epa->epa_V, epa->epa_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VSCALE(A, epa->epa_Au, epa->epa_r1);
VADD2(work, epa->epa_V, A);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
VCROSS(B, epa->epa_Au, epa->epa_H);
VUNITIZE(B);
VSCALE(B, B, epa->epa_r2);
VADD2(work, epa->epa_V, B);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6773,35 +6588,8 @@ label_edited_solid(
{
struct rt_ehy_internal *ehy =
(struct rt_ehy_internal *)s->edit_state.es_int.idb_ptr;
vect_t A, B;
RT_EHY_CK_MAGIC(ehy);
MAT4X3PNT(pos_view, xform, ehy->ehy_V);
POINT_LABEL(pos_view, 'V');
VADD2(work, ehy->ehy_V, ehy->ehy_H);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VSCALE(A, ehy->ehy_Au, ehy->ehy_r1);
VADD2(work, ehy->ehy_V, A);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
VCROSS(B, ehy->ehy_Au, ehy->ehy_H);
VUNITIZE(B);
VSCALE(B, B, ehy->ehy_r2);
VADD2(work, ehy->ehy_V, B);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
VMOVE(work, ehy->ehy_H);
VUNITIZE(work);
VSCALE(work, work,
MAGNITUDE(ehy->ehy_H) + ehy->ehy_c);
VADD2(work, ehy->ehy_V, work);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'c');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6809,27 +6597,8 @@ label_edited_solid(
{
struct rt_hyp_internal *hyp =
(struct rt_hyp_internal *)s->edit_state.es_int.idb_ptr;
vect_t vB;
RT_HYP_CK_MAGIC(hyp);
MAT4X3PNT(pos_view, xform, hyp->hyp_Vi);
POINT_LABEL(pos_view, 'V');
VADD2(work, hyp->hyp_Vi, hyp->hyp_Hi);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'H');
VADD2(work, hyp->hyp_Vi, hyp->hyp_A);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'A');
VCROSS(vB, hyp->hyp_A, hyp->hyp_Hi);
VUNITIZE(vB);
VSCALE(vB, vB, hyp->hyp_b);
VADD2(work, hyp->hyp_Vi, vB);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'B');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6837,39 +6606,8 @@ label_edited_solid(
{
struct rt_eto_internal *eto =
(struct rt_eto_internal *)s->edit_state.es_int.idb_ptr;
fastf_t ch, cv, dh, dv, cmag, phi;
vect_t Au, Nu;
RT_ETO_CK_MAGIC(eto);
MAT4X3PNT(pos_view, xform, eto->eto_V);
POINT_LABEL(pos_view, 'V');
VMOVE(Nu, eto->eto_N);
VUNITIZE(Nu);
bn_vec_ortho(Au, Nu);
VUNITIZE(Au);
cmag = MAGNITUDE(eto->eto_C);
/* get horizontal and vertical components of C and Rd */
cv = VDOT(eto->eto_C, Nu);
ch = sqrt(cmag*cmag - cv*cv);
/* angle between C and Nu */
phi = acos(cv / cmag);
dv = -eto->eto_rd * sin(phi);
dh = eto->eto_rd * cos(phi);
VJOIN2(work, eto->eto_V, eto->eto_r+ch, Au, cv, Nu);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'C');
VJOIN2(work, eto->eto_V, eto->eto_r+dh, Au, dv, Nu);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'D');
VJOIN1(work, eto->eto_V, eto->eto_r, Au);
MAT4X3PNT(pos_view, xform, work);
POINT_LABEL(pos_view, 'r');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
@@ -6879,9 +6617,9 @@ label_edited_solid(
(struct rt_ars_internal *)s->edit_state.es_int.idb_ptr;
RT_ARS_CK_MAGIC(ars);
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
MAT4X3PNT(pos_view, xform, ars->curves[0]);
// Conditional additional labeling
if (es_ars_crv >= 0 && es_ars_col >= 0) {
point_t ars_pt;
@@ -6890,17 +6628,17 @@ label_edited_solid(
POINT_LABEL_STR(ars_pt, "pt");
}
}
POINT_LABEL(pos_view, 'V');
break;
case ID_BSPLINE:
{
struct rt_nurb_internal *sip =
(struct rt_nurb_internal *) s->edit_state.es_int.idb_ptr;
RT_NURB_CK_MAGIC(sip);
// Conditional labeling
struct face_g_snurb *surf;
fastf_t *fp;
RT_NURB_CK_MAGIC(sip);
surf = sip->srfs[spl_surfno];
NMG_CK_SNURB(surf);
fp = &RT_NURB_GET_CONTROL_POINT(surf, spl_ui, spl_vi);
@@ -6919,6 +6657,7 @@ label_edited_solid(
fp = &RT_NURB_GET_CONTROL_POINT(surf, surf->s_size[0]-1, surf->s_size[1]-1);
MAT4X3PNT(pos_view, xform, fp);
POINT_LABEL_STR(pos_view, " u,v");
}
break;
case ID_NMG:
@@ -6930,6 +6669,7 @@ label_edited_solid(
NMG_CK_MODEL(m);
#endif
// Conditional labeling
if (es_eu) {
point_t cent;
NMG_CK_EDGEUSE(es_eu);
@@ -6951,6 +6691,7 @@ label_edited_solid(
RT_PIPE_CK_MAGIC(pipeip);
#endif
// Conditional labeling
if (es_pipe_pnt) {
BU_CKMAG(es_pipe_pnt, WDB_PIPESEG_MAGIC, "wdb_pipe_pnt");
@@ -6963,16 +6704,8 @@ label_edited_solid(
{
struct rt_cline_internal *cli =
(struct rt_cline_internal *)s->edit_state.es_int.idb_ptr;
point_t work1;
RT_CLINE_CK_MAGIC(cli);
MAT4X3PNT(pos_view, xform, cli->v);
POINT_LABEL(pos_view, 'V');
VADD2(work1, cli->v, cli->h);
MAT4X3PNT(pos_view, xform, work1);
POINT_LABEL(pos_view, 'H');
OBJ[ip->idb_type].ft_labels(pl, max_pl, xform, &s->edit_state.es_int, &s->tol.tol);
}
break;
case ID_BOT:
@@ -6982,6 +6715,7 @@ label_edited_solid(
RT_BOT_CK_MAGIC(bot);
// Conditional labeling
if (bot_verts[2] > -1 &&
bot_verts[1] > -1 &&
bot_verts[0] > -1)
+22 -2
View File
@@ -207,9 +207,29 @@ QEll::update_obj_wireframe()
bu_opt_color(NULL, 1, (const char **)&av[0], (void *)&cval);
bu_color_to_rgb_chars(&cval, p->s_color);
// When editing, we show the labels
// When editing, we show the labels (if any)
struct rt_point_labels pl[8+1];
int lcnt = 0;
mat_t idn_mat;
MAT_IDN(idn_mat);
if (intern.idb_meth->ft_labels)
intern.idb_meth->ft_labels(p, &intern);
lcnt = intern.idb_meth->ft_labels(pl, 8, idn_mat, &intern, tol);
for (int i = 0; i < lcnt; i++) {
struct bv_scene_obj *s = bv_obj_get_child(p);
struct bv_label *la;
BU_GET(la, struct bv_label);
s->s_i_data = (void *)la;
BU_LIST_INIT(&(s->s_vlist));
VSET(s->s_color, 255, 255, 0);
s->s_type_flags |= BV_DBOBJ_BASED;
s->s_type_flags |= BV_LABELS;
BU_VLS_INIT(&la->label);
bu_vls_sprintf(&la->label, "%s", pl[i].str);
VMOVE(la->p, pl[i].pt);
}
p->s_flag = UP;
// TODO - we should be able to set UP or DOWN on the various labels