BRL-CAD
cline.c
Go to the documentation of this file.
1 /* C L I N E . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2000-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @addtogroup primitives */
21 /** @{ */
22 /** @file primitives/cline/cline.c
23  *
24  * Intersect a ray with a FASTGEN4 CLINE element.
25  *
26  */
27 
28 #include "common.h"
29 
30 #include <stdlib.h>
31 #include <stddef.h>
32 #include <math.h>
33 #include "bio.h"
34 
35 #include "tcl.h"
36 #include "bu/cv.h"
37 #include "vmath.h"
38 #include "db.h"
39 #include "nmg.h"
40 #include "rtgeom.h"
41 #include "raytrace.h"
42 #include "wdb.h"
43 
44 
45 /* ray tracing form of solid, including precomputed terms */
47  point_t V;
48  vect_t height;
51  vect_t h; /* unitized height */
52 };
53 
54 
55 #define RT_CLINE_O(m) bu_offsetof(struct rt_cline_internal, m)
56 
57 const struct bu_structparse rt_cline_parse[] = {
58  { "%f", 3, "V", RT_CLINE_O(v), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
59  { "%f", 3, "H", RT_CLINE_O(h), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
60  { "%f", 1, "r", RT_CLINE_O(radius), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
61  { "%f", 1, "t", RT_CLINE_O(thickness), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
62  { {'\0', '\0', '\0', '\0'}, 0, (char *)NULL, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
63 };
64 
65 /**
66  * Calculate bounding RPP for cline
67  */
68 int
69 rt_cline_bbox(struct rt_db_internal *ip, point_t *min, point_t *max, const struct bn_tol *UNUSED(tol)) {
70  struct rt_cline_internal *cline_ip;
71  vect_t rad, work;
72  point_t top;
73  fastf_t max_tr;
74 
76  cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
77  RT_CLINE_CK_MAGIC(cline_ip);
78 
79  if (rt_cline_radius > 0.0)
80  max_tr = rt_cline_radius;
81  else
82  max_tr = 0.0;
83 
84  VSETALL((*min), INFINITY);
85  VSETALL((*max), -INFINITY);
86 
87  VSETALL(rad, cline_ip->radius + max_tr);
88  VADD2(work, cline_ip->v, rad);
89  VMINMAX((*min), (*max), work);
90  VSUB2(work, cline_ip->v, rad);
91  VMINMAX((*min), (*max), work);
92  VADD2(top, cline_ip->v, cline_ip->h);
93  VADD2(work, top, rad);
94  VMINMAX((*min), (*max), work);
95  VSUB2(work, top, rad);
96  VMINMAX((*min), (*max), work);
97  return 0;
98 }
99 
100 /**
101  * Given a pointer to a GED database record, determine if this is a
102  * valid cline solid, and if so, precompute various terms of the
103  * formula.
104  *
105  * Returns -
106  * 0 cline is OK
107  * !0 Error in description
108  *
109  * Implicit return -
110  * A struct cline_specific is created, and its address is stored
111  * in stp->st_specific for use by rt_cline_shot().
112  */
113 int
114 rt_cline_prep(struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
115 {
116  struct rt_cline_internal *cline_ip;
117  register struct cline_specific *cline;
118  fastf_t tmp;
119  fastf_t max_tr;
120 
121  RT_CK_DB_INTERNAL(ip);
122  cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
123  RT_CLINE_CK_MAGIC(cline_ip);
124  if (rtip) RT_CK_RTI(rtip);
125 
126  BU_GET(cline, struct cline_specific);
127  cline->thickness = cline_ip->thickness;
128  cline->radius = cline_ip->radius;
129  VMOVE(cline->V, cline_ip->v);
130  VMOVE(cline->height, cline_ip->h);
131  VMOVE(cline->h, cline_ip->h);
132  VUNITIZE(cline->h);
133  stp->st_specific = (void *)cline;
134 
135  if (rt_cline_radius > 0.0)
136  max_tr = rt_cline_radius;
137  else
138  max_tr = 0.0;
139  tmp = MAGNITUDE(cline_ip->h) * 0.5;
140  stp->st_aradius = sqrt(tmp*tmp + cline_ip->radius*cline_ip->radius);
141  stp->st_bradius = stp->st_aradius + max_tr;
142 
143  if (rt_cline_bbox(ip, &(stp->st_min), &(stp->st_max), &rtip->rti_tol)) return 1;
144 
145  return 0;
146 }
147 
148 
149 void
150 rt_cline_print(register const struct soltab *stp)
151 {
152  register const struct cline_specific *cline =
153  (struct cline_specific *)stp->st_specific;
154 
155  VPRINT("V", cline->V);
156  VPRINT("Height", cline->height);
157  VPRINT("Unit Height", cline->h);
158  bu_log("Radius: %g\n", cline->radius);
159  if (cline->thickness > 0.0)
160  bu_log("Plate Mode Thickness: %g\n", cline->thickness);
161  else
162  bu_log("Volume mode\n");
163 }
164 
165 
166 /**
167  * Intersect a ray with a cline mode solid. If an intersection
168  * occurs, at least one struct seg will be acquired and filled in.
169  *
170  * Returns -
171  * 0 MISS
172  * >0 HIT
173  */
174 int
175 rt_cline_shot(struct soltab *stp, register struct xray *rp, struct application *ap, struct seg *seghead)
176 {
177  register struct cline_specific *cline =
178  (struct cline_specific *)stp->st_specific;
179  struct seg ref_seghead;
180  register struct seg *segp;
181  fastf_t reff;
182  fastf_t dist[3];
183  fastf_t cosa, sina;
184  fastf_t half_los;
185  point_t pt1, pt2;
186  vect_t diff;
187  fastf_t tmp;
188  fastf_t distmin, distmax;
189  fastf_t add_radius;
190 
191  if (ap) RT_CK_APPLICATION(ap);
192 
193  BU_LIST_INIT(&ref_seghead.l);
194 
195  /* This is a CLINE FASTGEN element */
196  if (rt_cline_radius > 0.0) {
197  add_radius = rt_cline_radius;
198  reff = cline->radius + add_radius;
199  } else {
200  add_radius = 0.0;
201  reff = cline->radius;
202  }
203 
204  cosa = VDOT(rp->r_dir, cline->h);
205 
206  if (cosa > 0.0)
207  tmp = cosa - 1.0;
208  else
209  tmp = cosa + 1.0;
210 
211  (void)bn_distsq_line3_line3(dist, cline->V, cline->height,
212  rp->r_pt, rp->r_dir, pt1, pt2);
213 
214  if (NEAR_ZERO(tmp, RT_DOT_TOL)) {
215  /* ray is parallel to CLINE */
216 #if 1
217  /* FASTGEN developers claim they report hits on volume mode
218  * when ray is parallel to CLINE axis, but their code drops
219  * this case from consideration before their intersection code
220  * is even called (see SUBROUTINE BULK)
221  */
222  return 0;
223 #else
224 
225  if (cline->thickness > 0.0)
226  return 0; /* No end-on hits for plate mode cline */
227 
228  if (dist[2] > reff*reff)
229  return 0; /* missed */
230 
231  VJOIN2(diff, cline->V, 1.0, cline->height, -1.0, rp->r_pt);
232  dist[0] = VDOT(diff, rp->r_dir);
233  if (dist[1] < dist[0]) {
234  dist[2] = dist[0];
235  dist[0] = dist[1];
236  dist[1] = dist[2];
237  }
238 
239  /* volume mode */
240 
241  RT_GET_SEG(segp, ap->a_resource);
242  segp->seg_stp = stp;
243  segp->seg_in.hit_dist = dist[0];
244  segp->seg_in.hit_surfno = 1;
245  if (cosa > 0.0) {
246  VREVERSE(segp->seg_in.hit_normal, cline->h);
247  } else {
248  VMOVE(segp->seg_in.hit_normal, cline->h);
249  }
250 
251  segp->seg_out.hit_dist = dist[1];
252  segp->seg_out.hit_surfno = -1;
253  if (cosa < 0.0) {
254  VREVERSE(segp->seg_out.hit_normal, cline->h);
255  } else {
256  VMOVE(segp->seg_out.hit_normal, cline->h);
257  }
258  BU_LIST_INSERT(&(seghead->l), &(segp->l));
259  return 1;
260 #endif
261  }
262 
263  if (dist[2] > reff*reff)
264  return 0; /* missed */
265 
266 
267  /* Exactly ==0 and ==1 are hits, not misses */
268  if (dist[0] < 0.0 || dist[0] > 1.0)
269  return 0; /* missed */
270 
271  sina = sqrt(1.0 - cosa*cosa);
272  tmp = sqrt(dist[2]) - add_radius;
273  if (dist[2] > add_radius * add_radius)
274  half_los = sqrt(cline->radius*cline->radius - tmp*tmp) / sina;
275  else
276  half_los = cline->radius / sina;
277 
278  VSUB2(diff, cline->V, rp->r_pt);
279  distmin = VDOT(rp->r_dir, diff);
280  VADD2(diff, cline->V, cline->height);
281  VSUB2(diff, diff, rp->r_pt);
282  distmax = VDOT(rp->r_dir, diff);
283 
284  if (distmin > distmax) {
285  tmp = distmin;
286  distmin = distmax;
287  distmax = tmp;
288  }
289 
290  distmin -= cline->radius;
291  distmax += cline->radius;
292 
293  if (cline->thickness <= 0.0) {
294  /* volume mode */
295 
296  RT_GET_SEG(segp, ap->a_resource);
297  segp->seg_stp = stp;
298  segp->seg_in.hit_surfno = 2;
299  segp->seg_in.hit_dist = dist[1] - half_los;
300  if (segp->seg_in.hit_dist < distmin)
301  segp->seg_in.hit_dist = distmin;
302  VMOVE(segp->seg_in.hit_vpriv, cline->h);
303 
304  segp->seg_out.hit_surfno = -2;
305  segp->seg_out.hit_dist = dist[1] + half_los;
306  if (segp->seg_out.hit_dist > distmax)
307  segp->seg_out.hit_dist = distmax;
308  VMOVE(segp->seg_out.hit_vpriv, cline->h);
309  BU_LIST_INSERT(&(seghead->l), &(segp->l));
310 
311  return 1;
312  } else {
313  /* plate mode */
314 
315  RT_GET_SEG(segp, ap->a_resource);
316  segp->seg_stp = stp;
317  segp->seg_in.hit_surfno = 2;
318  segp->seg_in.hit_dist = dist[1] - half_los;
319  if (segp->seg_in.hit_dist < distmin)
320  segp->seg_in.hit_dist = distmin;
321  VMOVE(segp->seg_in.hit_vpriv, cline->h);
322 
323  segp->seg_out.hit_surfno = -2;
324  segp->seg_out.hit_dist = segp->seg_in.hit_dist + cline->thickness;
325  VMOVE(segp->seg_out.hit_vpriv, cline->h);
326  BU_LIST_INSERT(&(seghead->l), &(segp->l));
327 
328  RT_GET_SEG(segp, ap->a_resource);
329  segp->seg_stp = stp;
330  segp->seg_in.hit_surfno = 2;
331  segp->seg_in.hit_dist = dist[1] + half_los;
332  if (segp->seg_in.hit_dist > distmax)
333  segp->seg_in.hit_dist = distmax;
334  segp->seg_in.hit_dist -= cline->thickness;
335  VMOVE(segp->seg_in.hit_vpriv, cline->h);
336 
337  segp->seg_out.hit_surfno = -2;
338  segp->seg_out.hit_dist = segp->seg_in.hit_dist + cline->thickness;
339  VMOVE(segp->seg_out.hit_vpriv, cline->h);
340  BU_LIST_INSERT(&(seghead->l), &(segp->l));
341 
342  return 2;
343  }
344 }
345 
346 
347 /**
348  * Given ONE ray distance, return the normal and entry/exit point.
349  */
350 void
351 rt_cline_norm(struct hit *hitp, struct soltab *stp, struct xray *rp)
352 {
353  vect_t tmp;
354  fastf_t dot;
355 
356  if (hitp) RT_CK_HIT(hitp);
357 
358  if (hitp->hit_surfno == 1 || hitp->hit_surfno == -1)
359  return;
360 
361  /* only need to do some calculations for surfno 2 or -2 */
362 
363  /* this is wrong, but agrees with FASTGEN */
364  VCROSS(tmp, rp->r_dir, hitp->hit_vpriv);
365  VCROSS(hitp->hit_normal, tmp, hitp->hit_vpriv);
366  VUNITIZE(hitp->hit_normal);
367  dot = VDOT(hitp->hit_normal, rp->r_dir);
368  if (dot < 0.0 && hitp->hit_surfno < 0) {
369  VREVERSE(hitp->hit_normal, hitp->hit_normal);
370  } else if (dot > 0.0 && hitp->hit_surfno > 0) {
371  VREVERSE(hitp->hit_normal, hitp->hit_normal);
372  }
373 
374  if (MAGNITUDE(hitp->hit_normal) < 0.9) {
375  bu_log("BAD normal for solid %s for ray -p %g %g %g -d %g %g %g\n",
376  stp->st_name, V3ARGS(rp->r_pt), V3ARGS(rp->r_dir));
377  bu_bomb("BAD normal\n");
378  }
379  VJOIN1(hitp->hit_point, rp->r_pt, hitp->hit_dist, rp->r_dir);
380 }
381 
382 
383 /**
384  * Return the curvature of the cline.
385  */
386 void
387 rt_cline_curve(struct curvature *cvp, struct hit *hitp, struct soltab *stp)
388 {
389  if (stp) RT_CK_SOLTAB(stp);
390  if (hitp) RT_CK_HIT(hitp);
391 
392  /* for now, don't do curvature */
393  cvp->crv_c1 = cvp->crv_c2 = 0;
394 
395  /* any tangent direction */
396  bn_vec_ortho(cvp->crv_pdir, hitp->hit_normal);
397 }
398 
399 
400 /**
401  * For a hit on the surface of an cline, return the (u, v) coordinates
402  * of the hit point, 0 <= u, v <= 1.
403  */
404 void
405 rt_cline_uv(struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
406 {
407  if (ap) RT_CK_APPLICATION(ap);
408  if (stp) RT_CK_SOLTAB(stp);
409  if (hitp) RT_CK_HIT(hitp);
410 
411  uvp->uv_u = 0.0;
412  uvp->uv_v = 0.0;
413  uvp->uv_du = 0.0;
414  uvp->uv_dv = 0.0;
415 }
416 
417 
418 void
419 rt_cline_free(register struct soltab *stp)
420 {
421  register struct cline_specific *cline =
422  (struct cline_specific *)stp->st_specific;
423 
424  if (stp) RT_CK_SOLTAB(stp);
425 
426  BU_PUT(cline, struct cline_specific);
427 }
428 
429 
430 int
431 rt_cline_class(const struct soltab *stp, const fastf_t *min, const fastf_t *max, const struct bn_tol *tol)
432 {
433  if (stp) RT_CK_SOLTAB(stp);
434  if (!min) return 0;
435  if (!max) return 0;
436  if (tol) BN_CK_TOL(tol);
437 
438  return 0;
439 }
440 
441 
442 int
443 rt_cline_plot(struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *UNUSED(ttol), const struct bn_tol *UNUSED(tol), const struct rt_view_info *UNUSED(info))
444 {
445  struct rt_cline_internal *cline_ip;
446  fastf_t top[16*3];
447  fastf_t bottom[16*3];
448  point_t top_pt;
449  vect_t unit_a, unit_b;
450  vect_t a, b;
451  fastf_t inner_radius;
452  int i;
453 
454  BU_CK_LIST_HEAD(vhead);
455  RT_CK_DB_INTERNAL(ip);
456  cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
457  RT_CLINE_CK_MAGIC(cline_ip);
458 
459  VADD2(top_pt, cline_ip->v, cline_ip->h);
460  bn_vec_ortho(unit_a, cline_ip->h);
461  VCROSS(unit_b, unit_a, cline_ip->h);
462  VUNITIZE(unit_b);
463  VSCALE(a, unit_a, cline_ip->radius);
464  VSCALE(b, unit_b, cline_ip->radius);
465 
466  rt_ell_16pts(bottom, cline_ip->v, a, b);
467  rt_ell_16pts(top, top_pt, a, b);
468 
469  /* Draw the top */
470  RT_ADD_VLIST(vhead, &top[15*ELEMENTS_PER_VECT], BN_VLIST_LINE_MOVE);
471  for (i = 0; i < 16; i++) {
472  RT_ADD_VLIST(vhead, &top[i*ELEMENTS_PER_VECT], BN_VLIST_LINE_DRAW);
473  }
474 
475  /* Draw the bottom */
476  RT_ADD_VLIST(vhead, &bottom[15*ELEMENTS_PER_VECT], BN_VLIST_LINE_MOVE);
477  for (i = 0; i < 16; i++) {
478  RT_ADD_VLIST(vhead, &bottom[i*ELEMENTS_PER_VECT], BN_VLIST_LINE_DRAW);
479  }
480 
481  /* Draw connections */
482  for (i = 0; i < 16; i += 4) {
483  RT_ADD_VLIST(vhead, &top[i*ELEMENTS_PER_VECT], BN_VLIST_LINE_MOVE);
484  RT_ADD_VLIST(vhead, &bottom[i*ELEMENTS_PER_VECT], BN_VLIST_LINE_DRAW);
485  }
486 
487  if (cline_ip->thickness > 0.0 && cline_ip->thickness < cline_ip->radius) {
488  /* draw inner cylinder */
489 
490  inner_radius = cline_ip->radius - cline_ip->thickness;
491 
492  VSCALE(a, unit_a, inner_radius);
493  VSCALE(b, unit_b, inner_radius);
494 
495  rt_ell_16pts(bottom, cline_ip->v, a, b);
496  rt_ell_16pts(top, top_pt, a, b);
497 
498  /* Draw the top */
499  RT_ADD_VLIST(vhead, &top[15*ELEMENTS_PER_VECT], BN_VLIST_LINE_MOVE);
500  for (i = 0; i < 16; i++) {
501  RT_ADD_VLIST(vhead, &top[i*ELEMENTS_PER_VECT], BN_VLIST_LINE_DRAW);
502  }
503 
504  /* Draw the bottom */
505  RT_ADD_VLIST(vhead, &bottom[15*ELEMENTS_PER_VECT], BN_VLIST_LINE_MOVE);
506  for (i = 0; i < 16; i++) {
507  RT_ADD_VLIST(vhead, &bottom[i*ELEMENTS_PER_VECT], BN_VLIST_LINE_DRAW);
508  }
509 
510  /* Draw connections */
511  for (i = 0; i < 16; i += 4) {
512  RT_ADD_VLIST(vhead, &top[i*ELEMENTS_PER_VECT], BN_VLIST_LINE_MOVE);
513  RT_ADD_VLIST(vhead, &bottom[i*ELEMENTS_PER_VECT], BN_VLIST_LINE_DRAW);
514  }
515 
516  }
517 
518  return 0;
519 }
520 
521 
522 struct cline_vert {
523  point_t pt;
524  struct vertex *v;
525 };
526 
527 
528 /**
529  * Returns -
530  * -1 failure
531  * 0 OK. *r points to nmgregion that holds this tessellation.
532  */
533 int
534 rt_cline_tess(struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
535 {
536  struct shell *s;
537  struct rt_cline_internal *cline_ip;
538  fastf_t ang_tol, abs_tol, norm_tol, rel_tol;
539  int nsegs, seg_no, i;
540  struct cline_vert *base_outer, *base_inner, *top_outer, *top_inner;
541  struct cline_vert base_center, top_center;
542  vect_t v1, v2;
543  point_t top;
544  struct bu_ptbl faces;
545 
546  RT_CK_DB_INTERNAL(ip);
547  cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
548  RT_CLINE_CK_MAGIC(cline_ip);
549 
550  *r = nmg_mrsv(m);
551  s = BU_LIST_FIRST(shell, &(*r)->s_hd);
552 
553  ang_tol = M_PI_2;
554  abs_tol = M_PI_2;
555  rel_tol = M_PI_2;
556  norm_tol = M_PI_2;
557 
558  if (ttol->abs <= 0.0 && ttol->rel <= 0.0 && ttol->norm <= 0.0) {
559  /* no tolerances specified, use 10% relative tolerance */
560  ang_tol = 2.0 * acos(0.9);
561  } else {
562  if (ttol->abs > 0.0 && ttol->abs < cline_ip->radius)
563  abs_tol = 2.0 * acos(1.0 - ttol->abs / cline_ip->radius);
564  if (ttol->rel > 0.0 && ttol->rel < 1.0)
565  rel_tol = 2.0 * acos(1.0 - ttol->rel);
566  if (ttol->norm > 0.0)
567  norm_tol = 2.0 * ttol->norm;
568  }
569 
570  if (abs_tol < ang_tol)
571  ang_tol = abs_tol;
572  if (rel_tol < ang_tol)
573  ang_tol = rel_tol;
574  if (norm_tol < ang_tol)
575  ang_tol = norm_tol;
576 
577  /* get number of segments per quadrant */
578  nsegs = (int)(M_PI_2 / ang_tol + 0.9999);
579  if (nsegs < 2)
580  nsegs = 2;
581 
582  ang_tol = M_PI_2 / nsegs;
583 
584  /* and for complete circle */
585  nsegs *= 4;
586 
587  /* allocate memory for arrays of vertices */
588  base_outer = (struct cline_vert *)bu_calloc(nsegs, sizeof(struct cline_vert), "base outer vertices");
589  top_outer = (struct cline_vert *)bu_calloc(nsegs, sizeof(struct cline_vert), "top outer vertices");
590 
591  if (cline_ip->thickness > 0.0 && cline_ip->thickness < cline_ip->radius) {
592  base_inner = (struct cline_vert *)bu_calloc(nsegs, sizeof(struct cline_vert), "base inner vertices");
593  top_inner = (struct cline_vert *)bu_calloc(nsegs, sizeof(struct cline_vert), "top inner vertices");
594  } else {
595  base_inner = NULL;
596  top_inner = NULL;
597  }
598 
599  /* calculate geometry for each vertex */
600  bn_vec_ortho(v1, cline_ip->h);
601  VCROSS(v2, cline_ip->h, v1);
602  VUNITIZE(v2);
603  VADD2(top, cline_ip->v, cline_ip->h);
604  for (seg_no = 0; seg_no < nsegs; seg_no++) {
605  fastf_t a, b, c, d, angle;
606 
607  angle = ang_tol * seg_no;
608 
609  a = cos(angle);
610  b = sin(angle);
611 
612  if (cline_ip->thickness > 0.0 && cline_ip->thickness < cline_ip->radius) {
613  c = a * (cline_ip->radius - cline_ip->thickness);
614  d = b * (cline_ip->radius - cline_ip->thickness);
615  } else {
616  c = d = 0;
617  }
618 
619  a *= cline_ip->radius;
620  b *= cline_ip->radius;
621 
622  VJOIN2(base_outer[seg_no].pt, cline_ip->v, a, v1, b, v2);
623  VADD2(top_outer[seg_no].pt, base_outer[seg_no].pt, cline_ip->h);
624 
625  if (cline_ip->thickness > 0.0 && cline_ip->thickness < cline_ip->radius) {
626  VJOIN2(base_inner[seg_no].pt, cline_ip->v, c, v1, d, v2);
627  VADD2(top_inner[seg_no].pt, base_inner[seg_no].pt, cline_ip->h);
628  }
629  }
630 
631  bu_ptbl_init(&faces, 64, "faces");
632  /* build outer faces */
633  for (seg_no = 0; seg_no < nsegs; seg_no++) {
634  int next_seg;
635  struct vertex **verts[3];
636  struct faceuse *fu;
637 
638  next_seg = seg_no + 1;
639  if (next_seg == nsegs)
640  next_seg = 0;
641 
642  verts[2] = &top_outer[seg_no].v;
643  verts[1] = &top_outer[next_seg].v;
644  verts[0] = &base_outer[seg_no].v;
645 
646  fu = nmg_cmface(s, verts, 3);
647  bu_ptbl_ins(&faces, (long *)fu);
648 
649  verts[2] = &base_outer[seg_no].v;
650  verts[1] = &top_outer[next_seg].v;
651  verts[0] = &base_outer[next_seg].v;
652 
653  fu = nmg_cmface(s, verts, 3);
654  bu_ptbl_ins(&faces, (long *)fu);
655  }
656 
657  /* build inner faces */
658  if (cline_ip->thickness > 0.0 && cline_ip->thickness < cline_ip->radius) {
659  for (seg_no = 0; seg_no < nsegs; seg_no++) {
660  int next_seg;
661  struct vertex **verts[3];
662  struct faceuse *fu;
663 
664  next_seg = seg_no + 1;
665  if (next_seg == nsegs)
666  next_seg = 0;
667 
668  verts[0] = &top_inner[seg_no].v;
669  verts[1] = &top_inner[next_seg].v;
670  verts[2] = &base_inner[seg_no].v;
671 
672  fu = nmg_cmface(s, verts, 3);
673  bu_ptbl_ins(&faces, (long *)fu);
674 
675  verts[0] = &base_inner[seg_no].v;
676  verts[1] = &top_inner[next_seg].v;
677  verts[2] = &base_inner[next_seg].v;
678 
679  fu = nmg_cmface(s, verts, 3);
680  bu_ptbl_ins(&faces, (long *)fu);
681  }
682  }
683 
684  /* build top faces */
685  top_center.v = (struct vertex *)NULL;
686  VMOVE(top_center.pt, top);
687  for (seg_no = 0; seg_no < nsegs; seg_no++) {
688  int next_seg;
689  struct vertex **verts[3];
690  struct faceuse *fu;
691 
692  next_seg = seg_no + 1;
693  if (next_seg == nsegs)
694  next_seg = 0;
695 
696  if (cline_ip->thickness > 0.0 && cline_ip->thickness < cline_ip->radius) {
697  verts[2] = &top_outer[seg_no].v;
698  verts[1] = &top_inner[seg_no].v;
699  verts[0] = &top_inner[next_seg].v;
700  fu = nmg_cmface(s, verts, 3);
701  bu_ptbl_ins(&faces, (long *)fu);
702 
703  verts[2] = &top_inner[next_seg].v;
704  verts[1] = &top_outer[next_seg].v;
705  verts[0] = &top_outer[seg_no].v;
706  fu = nmg_cmface(s, verts, 3);
707  bu_ptbl_ins(&faces, (long *)fu);
708  } else {
709  verts[2] = &top_outer[seg_no].v;
710  verts[1] = &top_center.v;
711  verts[0] = &top_outer[next_seg].v;
712  fu = nmg_cmface(s, verts, 3);
713  bu_ptbl_ins(&faces, (long *)fu);
714  }
715  }
716 
717  /* build base faces */
718  base_center.v = (struct vertex *)NULL;
719  VMOVE(base_center.pt, cline_ip->v);
720  for (seg_no = 0; seg_no < nsegs; seg_no++) {
721  int next_seg;
722  struct vertex **verts[3];
723  struct faceuse *fu;
724 
725  next_seg = seg_no + 1;
726  if (next_seg == nsegs)
727  next_seg = 0;
728 
729  if (cline_ip->thickness > 0.0 && cline_ip->thickness < cline_ip->radius) {
730  verts[0] = &base_outer[seg_no].v;
731  verts[1] = &base_inner[seg_no].v;
732  verts[2] = &base_inner[next_seg].v;
733  fu = nmg_cmface(s, verts, 3);
734  bu_ptbl_ins(&faces, (long *)fu);
735 
736  verts[0] = &base_inner[next_seg].v;
737  verts[1] = &base_outer[next_seg].v;
738  verts[2] = &base_outer[seg_no].v;
739  fu = nmg_cmface(s, verts, 3);
740  bu_ptbl_ins(&faces, (long *)fu);
741  } else {
742  verts[0] = &base_outer[seg_no].v;
743  verts[1] = &base_center.v;
744  verts[2] = &base_outer[next_seg].v;
745  fu = nmg_cmface(s, verts, 3);
746  bu_ptbl_ins(&faces, (long *)fu);
747  }
748  }
749 
750  /* assign vertex geometry */
751  if (top_center.v)
752  nmg_vertex_gv(top_center.v, top_center.pt);
753  if (base_center.v)
754  nmg_vertex_gv(base_center.v, base_center.pt);
755 
756  for (seg_no = 0; seg_no < nsegs; seg_no++) {
757  nmg_vertex_gv(top_outer[seg_no].v, top_outer[seg_no].pt);
758  nmg_vertex_gv(base_outer[seg_no].v, base_outer[seg_no].pt);
759  }
760 
761  if (cline_ip->thickness > 0.0 && cline_ip->thickness < cline_ip->radius) {
762  for (seg_no = 0; seg_no < nsegs; seg_no++) {
763  nmg_vertex_gv(top_inner[seg_no].v, top_inner[seg_no].pt);
764  nmg_vertex_gv(base_inner[seg_no].v, base_inner[seg_no].pt);
765  }
766  }
767 
768  bu_free((char *)base_outer, "base outer vertices");
769  bu_free((char *)top_outer, "top outer vertices");
770  if (cline_ip->thickness > 0.0 && cline_ip->thickness < cline_ip->radius) {
771  bu_free((char *)base_inner, "base inner vertices");
772  bu_free((char *)top_inner, "top inner vertices");
773  }
774 
775  /* Associate face plane equations */
776  for (i = 0; i < BU_PTBL_END(&faces); i++) {
777  struct faceuse *fu;
778 
779  fu = (struct faceuse *)BU_PTBL_GET(&faces, i);
780  NMG_CK_FACEUSE(fu);
781 
782  if (nmg_calc_face_g(fu)) {
783  bu_log("rt_tess_cline: failed to calculate plane equation\n");
784  nmg_pr_fu_briefly(fu, "");
785  return -1;
786  }
787  }
788 
789  nmg_region_a(*r, tol);
790  bu_ptbl_free(&faces);
791 
792  return 0;
793 }
794 
795 
796 /**
797  * Import an cline from the database format to the internal format.
798  * Apply modeling transformations as well.
799  */
800 int
801 rt_cline_import4(struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
802 {
803  struct rt_cline_internal *cline_ip;
804  union record *rp;
805 
806  /* must be double for import and export */
807  double work[ELEMENTS_PER_POINT];
808  double scan;
809 
810  BU_CK_EXTERNAL(ep);
811  rp = (union record *)ep->ext_buf;
812  /* Check record type */
813 
814  if (rp->u_id != DBID_CLINE) {
815  bu_log("rt_cline_import4: defective record\n");
816  return -1;
817  }
818 
819  if (dbip) RT_CK_DBI(dbip);
820 
821  RT_CK_DB_INTERNAL(ip);
822  ip->idb_major_type = DB5_MAJORTYPE_BRLCAD;
823  ip->idb_type = ID_CLINE;
824  ip->idb_meth = &OBJ[ID_CLINE];
825  BU_ALLOC(ip->idb_ptr, struct rt_cline_internal);
826 
827  cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
828  cline_ip->magic = RT_CLINE_INTERNAL_MAGIC;
829  if (mat == NULL) mat = bn_mat_identity;
830 
831  bu_cv_ntohd((unsigned char *)&scan, rp->cli.cli_thick, 1);
832  cline_ip->thickness = scan / mat[15];
833  bu_cv_ntohd((unsigned char *)&scan, rp->cli.cli_radius, 1);
834  cline_ip->radius = scan / mat[15];
835  bu_cv_ntohd((unsigned char *)&work, rp->cli.cli_V, ELEMENTS_PER_POINT);
836  MAT4X3PNT(cline_ip->v, mat, work);
837  bu_cv_ntohd((unsigned char *)&work, rp->cli.cli_h, ELEMENTS_PER_POINT);
838  MAT4X3VEC(cline_ip->h, mat, work);
839 
840  return 0; /* OK */
841 }
842 
843 
844 /**
845  * The name is added by the caller, in the usual place.
846  */
847 int
848 rt_cline_export4(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
849 {
850  struct rt_cline_internal *cline_ip;
851  union record *rec;
852 
853  /* must be double for import and export */
854  double tmp;
855  double work[ELEMENTS_PER_VECT];
856 
857  RT_CK_DB_INTERNAL(ip);
858  if (ip->idb_type != ID_CLINE) return -1;
859  cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
860  RT_CLINE_CK_MAGIC(cline_ip);
861 
862  BU_CK_EXTERNAL(ep);
863  ep->ext_nbytes = sizeof(union record);
864  ep->ext_buf = (uint8_t *)bu_calloc(1, ep->ext_nbytes, "cline external");
865  rec = (union record *)ep->ext_buf;
866 
867  if (dbip) RT_CK_DBI(dbip);
868 
869  rec->s.s_id = ID_SOLID;
870  rec->cli.cli_id = DBID_CLINE; /* GED primitive type from db.h */
871 
872  tmp = cline_ip->thickness * local2mm;
873  bu_cv_htond(rec->cli.cli_thick, (unsigned char *)(&tmp), 1);
874  tmp = cline_ip->radius * local2mm;
875  bu_cv_htond(rec->cli.cli_radius, (unsigned char *)(&tmp), 1);
876  VSCALE(work, cline_ip->v, local2mm);
877  bu_cv_htond(rec->cli.cli_V, (unsigned char *)work, ELEMENTS_PER_VECT);
878  VSCALE(work, cline_ip->h, local2mm);
879  bu_cv_htond(rec->cli.cli_h, (unsigned char *)work, ELEMENTS_PER_VECT);
880 
881  return 0;
882 }
883 
884 
885 /**
886  * Import an cline from the database format to the internal format.
887  * Apply modeling transformations as well.
888  */
889 int
890 rt_cline_import5(struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
891 {
892  struct rt_cline_internal *cline_ip;
893 
894  /* must be double for import and export */
895  double vec[8];
896 
897  if (dbip) RT_CK_DBI(dbip);
898 
899  BU_CK_EXTERNAL(ep);
901 
902  RT_CK_DB_INTERNAL(ip);
903  ip->idb_major_type = DB5_MAJORTYPE_BRLCAD;
904  ip->idb_type = ID_CLINE;
905  ip->idb_meth = &OBJ[ID_CLINE];
906  BU_ALLOC(ip->idb_ptr, struct rt_cline_internal);
907 
908  cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
909  cline_ip->magic = RT_CLINE_INTERNAL_MAGIC;
910 
911  /* Convert from database (network) to internal (host) format */
912  bu_cv_ntohd((unsigned char *)vec, ep->ext_buf, 8);
913 
914  if (mat == NULL) mat = bn_mat_identity;
915  cline_ip->thickness = vec[0] / mat[15];
916  cline_ip->radius = vec[1] / mat[15];
917  MAT4X3PNT(cline_ip->v, mat, &vec[2]);
918  MAT4X3VEC(cline_ip->h, mat, &vec[5]);
919 
920  return 0; /* OK */
921 }
922 
923 
924 /**
925  * The name is added by the caller, in the usual place.
926  */
927 int
928 rt_cline_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
929 {
930  struct rt_cline_internal *cline_ip;
931 
932  /* must be double for import and export */
933  double vec[8];
934 
935  if (dbip) RT_CK_DBI(dbip);
936 
937  RT_CK_DB_INTERNAL(ip);
938  if (ip->idb_type != ID_CLINE) return -1;
939  cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
940  RT_CLINE_CK_MAGIC(cline_ip);
941 
942  BU_CK_EXTERNAL(ep);
944  ep->ext_buf = (uint8_t *)bu_malloc(ep->ext_nbytes, "cline external");
945 
946  vec[0] = cline_ip->thickness * local2mm;
947  vec[1] = cline_ip->radius * local2mm;
948  VSCALE(&vec[2], cline_ip->v, local2mm);
949  VSCALE(&vec[5], cline_ip->h, local2mm);
950 
951  /* Convert from internal (host) to database (network) format */
952  bu_cv_htond(ep->ext_buf, (unsigned char *)vec, 8);
953 
954  return 0;
955 }
956 
957 
958 /**
959  * Make human-readable formatted presentation of this solid. First
960  * line describes type of solid. Additional lines are indented one
961  * tab, and give parameter values.
962  */
963 int
964 rt_cline_describe(struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local)
965 {
966  register struct rt_cline_internal *cline_ip =
967  (struct rt_cline_internal *)ip->idb_ptr;
968  char buf[256];
969  point_t local_v;
970  vect_t local_h;
971 
972  RT_CLINE_CK_MAGIC(cline_ip);
973  bu_vls_strcat(str, "cline solid (CLINE)\n");
974 
975  if (!verbose)
976  return 0;
977 
978  VSCALE(local_v, cline_ip->v, mm2local);
979  VSCALE(local_h, cline_ip->h, mm2local);
980 
981  if (cline_ip->thickness > 0.0) {
982  sprintf(buf, "\tV (%g %g %g)\n\tH (%g %g %g)\n\tradius %g\n\tplate mode thickness %g",
983  V3INTCLAMPARGS(local_v), V3INTCLAMPARGS(local_h), INTCLAMP(cline_ip->radius*mm2local), INTCLAMP(cline_ip->thickness*mm2local));
984  } else {
985  sprintf(buf, "\tV (%g %g %g)\n\tH (%g %g %g)\n\tradius %g\n\tVolume mode\n",
986  V3INTCLAMPARGS(local_v), V3INTCLAMPARGS(local_h), INTCLAMP(cline_ip->radius*mm2local));
987  }
988  bu_vls_strcat(str, buf);
989 
990  return 0;
991 }
992 
993 
994 /**
995  * Free the storage associated with the rt_db_internal version of this
996  * solid.
997  */
998 void
1000 {
1001  register struct rt_cline_internal *cline_ip;
1002 
1003  RT_CK_DB_INTERNAL(ip);
1004 
1005  cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
1006  RT_CLINE_CK_MAGIC(cline_ip);
1007  cline_ip->magic = 0; /* sanity */
1008 
1009  bu_free((char *)cline_ip, "cline ifree");
1010  ip->idb_ptr = ((void *)0); /* sanity */
1011 }
1012 
1013 
1014 int
1015 rt_cline_get(struct bu_vls *logstr, const struct rt_db_internal *intern, const char *attr)
1016 {
1017  register struct rt_cline_internal *cli =
1018  (struct rt_cline_internal *)intern->idb_ptr;
1019 
1020  RT_CLINE_CK_MAGIC(cli);
1021 
1022  if (attr == (char *)NULL) {
1023  bu_vls_strcpy(logstr, "cline");
1024  bu_vls_printf(logstr, " V {%.25G %.25G %.25G}", V3ARGS(cli->v));
1025  bu_vls_printf(logstr, " H {%.25G %.25G %.25G}", V3ARGS(cli->h));
1026  bu_vls_printf(logstr, " R %.25G T %.25G", cli->radius, cli->thickness);
1027  } else if (*attr == 'V')
1028  bu_vls_printf(logstr, "%.25G %.25G %.25G", V3ARGS(cli->v));
1029  else if (*attr == 'H')
1030  bu_vls_printf(logstr, "%.25G %.25G %.25G", V3ARGS(cli->h));
1031  else if (*attr == 'R')
1032  bu_vls_printf(logstr, "%.25G", cli->radius);
1033  else if (*attr == 'T')
1034  bu_vls_printf(logstr, "%.25G", cli->thickness);
1035  else {
1036  bu_vls_strcat(logstr, "ERROR: unrecognized attribute, must be V, H, R, or T!!!");
1037  return BRLCAD_ERROR;
1038  }
1039 
1040  return BRLCAD_OK;
1041 }
1042 
1043 
1044 int
1045 rt_cline_adjust(struct bu_vls *logstr, struct rt_db_internal *intern, int argc, const char **argv)
1046 {
1047  struct rt_cline_internal *cli =
1048  (struct rt_cline_internal *)intern->idb_ptr;
1049  fastf_t *newval;
1050 
1051  RT_CK_DB_INTERNAL(intern);
1052  RT_CLINE_CK_MAGIC(cli);
1053 
1054  while (argc >= 2) {
1055  int array_len=3;
1056 
1057  if (*argv[0] == 'V') {
1058  newval = cli->v;
1059  if (tcl_list_to_fastf_array(brlcad_interp, argv[1], &newval, &array_len) !=
1060  array_len) {
1061  bu_vls_printf(logstr, "ERROR: Incorrect number of coordinates for vector\n");
1062  return BRLCAD_ERROR;
1063  }
1064  } else if (*argv[0] == 'H') {
1065  newval = cli->h;
1066  if (tcl_list_to_fastf_array(brlcad_interp, argv[1], &newval, &array_len) !=
1067  array_len) {
1068  bu_vls_printf(logstr, "ERROR: Incorrect number of coordinates for point\n");
1069  return BRLCAD_ERROR;
1070  }
1071  } else if (*argv[0] == 'R')
1072  cli->radius = atof(argv[1]);
1073  else if (*argv[0] == 'T')
1074  cli->thickness = atof(argv[1]);
1075 
1076  argc -= 2;
1077  argv += 2;
1078  }
1079 
1080  return BRLCAD_OK;
1081 }
1082 
1083 
1084 int
1085 rt_cline_form(struct bu_vls *logstr, const struct rt_functab *ftp)
1086 {
1087  RT_CK_FUNCTAB(ftp);
1088 
1089  bu_vls_printf(logstr,
1090  "V {%%f %%f %%f} H {%%f %%f %%f} R %%f T %%f");
1091 
1092  return BRLCAD_OK;
1093 
1094 }
1095 
1096 
1097 int
1098 rt_cline_params(struct pc_pc_set *UNUSED(ps), const struct rt_db_internal *ip)
1099 {
1100  if (ip) RT_CK_DB_INTERNAL(ip);
1101 
1102  return 0; /* OK */
1103 }
1104 
1105 int
1106 rt_cline_to_pipe(struct rt_pipe_internal *pipep, const struct rt_db_internal *ip)
1107 {
1108  struct rt_cline_internal *cip;
1109  struct wdb_pipept *point, *point2;
1110 
1111  if (!ip)
1112  return -1;
1113 
1114  RT_CK_DB_INTERNAL(ip);
1115  cip = (struct rt_cline_internal *)ip->idb_ptr;
1116  RT_CLINE_CK_MAGIC(cip);
1117 
1118  if (!pipep)
1119  return -1;
1120 
1121  pipep->pipe_magic = RT_PIPE_INTERNAL_MAGIC;
1122  pipep->pipe_count = 1;
1123 
1124  BU_LIST_INIT(&pipep->pipe_segs_head);
1125  BU_ALLOC(point, struct wdb_pipept);
1126  point->pp_bendradius = 0.0;
1127  VMOVE(point->pp_coord, cip->v);
1128  point->l.magic = WDB_PIPESEG_MAGIC;
1129  point->pp_od = cip->radius * 2;
1130  point->pp_id = (cip->radius - cip->thickness) * 2;
1131  BU_LIST_APPEND(&pipep->pipe_segs_head, &point->l);
1132 
1133  BU_ALLOC(point2, struct wdb_pipept);
1134  point2->pp_bendradius = 0.0;
1135  VADD2(point2->pp_coord, cip->v, cip->h);
1136  point2->l.magic = WDB_PIPESEG_MAGIC;
1137  point2->pp_od = cip->radius * 2;
1138  point2->pp_id = (cip->radius - cip->thickness) * 2;
1139  BU_LIST_APPEND(&pipep->pipe_segs_head, &point2->l);
1140 
1141  return 0;
1142 }
1143 
1144 
1145 /** @} */
1146 /*
1147  * Local Variables:
1148  * mode: C
1149  * tab-width: 8
1150  * indent-tabs-mode: t
1151  * c-file-style: "stroustrup"
1152  * End:
1153  * ex: shiftwidth=4 tabstop=8
1154  */
Definition: raytrace.h:800
#define RT_CK_FUNCTAB(_p)
Definition: raytrace.h:2242
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
#define BU_LIST_INSERT(old, new)
Definition: list.h:183
point_t V
Definition: cline.c:47
#define RT_CLINE_O(m)
Definition: cline.c:55
vect_t height
Definition: cline.c:48
#define SIZEOF_NETWORK_DOUBLE
Definition: cv.h:48
int rt_cline_plot(struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol, const struct rt_view_info *info)
Definition: cline.c:443
Definition: list.h:118
int rt_cline_get(struct bu_vls *logstr, const struct rt_db_internal *intern, const char *attr)
Definition: cline.c:1015
int rt_cline_adjust(struct bu_vls *logstr, struct rt_db_internal *intern, int argc, const char **argv)
Definition: cline.c:1045
#define RT_DOT_TOL
Definition: raytrace.h:170
void rt_cline_print(register const struct soltab *stp)
Definition: cline.c:150
#define RT_CK_APPLICATION(_p)
Definition: raytrace.h:1675
#define RT_CK_RTI(_p)
Definition: raytrace.h:1833
fastf_t radius
Definition: cline.c:49
vect_t crv_pdir
Principle direction.
Definition: raytrace.h:307
const mat_t bn_mat_identity
Matrix and vector functionality.
Definition: mat.c:46
fastf_t uv_u
Range 0..1.
Definition: raytrace.h:341
if lu s
Definition: nmg_mod.c:3860
void bu_ptbl_init(struct bu_ptbl *b, size_t len, const char *str)
Definition: ptbl.c:32
void bu_vls_strcat(struct bu_vls *vp, const char *s)
Definition: vls.c:368
int rt_cline_bbox(struct rt_db_internal *ip, point_t *min, point_t *max, const struct bn_tol *tol)
Definition: cline.c:69
#define VSETALL(a, s)
Definition: color.c:54
Definition: raytrace.h:215
Definition: pc.h:108
Definition: raytrace.h:368
fastf_t thickness
Definition: cline.c:50
#define BU_ASSERT_LONG(_lhs, _relation, _rhs)
Definition: defines.h:240
Definition: raytrace.h:248
void nmg_vertex_gv(struct vertex *v, const fastf_t *pt)
Definition: nmg_mk.c:1668
int rt_cline_class(const struct soltab *stp, const fastf_t *min, const fastf_t *max, const struct bn_tol *tol)
Definition: cline.c:431
fastf_t st_aradius
Radius of APPROXIMATING sphere.
Definition: raytrace.h:433
Header file for the BRL-CAD common definitions.
#define ID_CLINE
FASTGEN4 CLINE solid.
Definition: raytrace.h:487
#define BU_LIST_APPEND(old, new)
Definition: list.h:197
int bu_ptbl_ins(struct bu_ptbl *b, long *p)
struct resource * a_resource
dynamic memory resources
Definition: raytrace.h:1591
void bu_cv_htond(unsigned char *out, const unsigned char *in, size_t count)
int rt_cline_import5(struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
Definition: cline.c:890
int nmg_calc_face_g(struct faceuse *fu)
Definition: nmg_misc.c:1786
struct bu_list l
Definition: raytrace.h:369
void * bu_malloc(size_t siz, const char *str)
Definition: malloc.c:314
Definition: ptbl.h:62
double rel
rel dist tol
Definition: raytrace.h:181
fastf_t rt_cline_radius
Definition: globals.c:78
if(share_geom)
Definition: nmg_mod.c:3829
int idb_major_type
Definition: raytrace.h:192
vect_t hit_vpriv
PRIVATE vector for xxx_*()
Definition: raytrace.h:253
#define RT_ADD_VLIST(hd, pnt, draw)
Definition: raytrace.h:1865
void rt_cline_ifree(struct rt_db_internal *ip)
Definition: cline.c:999
#define RT_CK_DB_INTERNAL(_p)
Definition: raytrace.h:207
#define BU_ALLOC(_ptr, _type)
Definition: malloc.h:223
void * bu_calloc(size_t nelem, size_t elsize, const char *str)
Definition: malloc.c:321
int rt_cline_import4(struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
Definition: cline.c:801
fastf_t st_bradius
Radius of BOUNDING sphere.
Definition: raytrace.h:434
fastf_t crv_c2
curvature in other direction
Definition: raytrace.h:309
#define RT_CK_HIT(_p)
Definition: raytrace.h:259
#define BU_PTBL_GET(ptbl, i)
Definition: ptbl.h:108
#define RT_CLINE_INTERNAL_MAGIC
Definition: magic.h:87
#define BN_VLIST_LINE_MOVE
Definition: vlist.h:82
const struct rt_functab * idb_meth
for ft_ifree(), etc.
Definition: raytrace.h:194
int rt_cline_export4(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
Definition: cline.c:848
fastf_t uv_dv
delta in v
Definition: raytrace.h:344
#define V3ARGS(a)
Definition: color.c:56
#define NEAR_ZERO(val, epsilon)
Definition: color.c:55
#define BRLCAD_OK
Definition: defines.h:71
uint8_t * ext_buf
Definition: parse.h:216
static void top()
#define BU_GET(_ptr, _type)
Definition: malloc.h:201
void rt_cline_free(register struct soltab *stp)
Definition: cline.c:419
point_t hit_point
DEPRECATED: Intersection point, use VJOIN1 hit_dist.
Definition: raytrace.h:251
point_t st_max
max X, Y, Z of bounding RPP
Definition: raytrace.h:438
int rt_cline_params(struct pc_pc_set *ps, const struct rt_db_internal *ip)
Definition: cline.c:1098
#define BN_VLIST_LINE_DRAW
Definition: vlist.h:83
point_t pt
Definition: cline.c:523
int rt_cline_describe(struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local)
Definition: cline.c:964
Coord * point
Definition: chull3d.cpp:52
#define UNUSED(parameter)
Definition: common.h:239
#define BU_PUT(_ptr, _type)
Definition: malloc.h:215
Support for uniform tolerances.
Definition: tol.h:71
#define BN_CK_TOL(_p)
Definition: tol.h:82
int rt_cline_to_pipe(struct rt_pipe_internal *pipep, const struct rt_db_internal *ip)
Definition: cline.c:1106
struct nmgregion * nmg_mrsv(struct model *m)
Definition: nmg_mk.c:306
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153
vect_t r_dir
Direction of ray (UNIT Length)
Definition: raytrace.h:219
void bu_ptbl_free(struct bu_ptbl *b)
Definition: ptbl.c:226
struct bn_tol rti_tol
Math tolerances for this model.
Definition: raytrace.h:1765
int bn_distsq_line3_line3(fastf_t dist[3], point_t P, vect_t d, point_t Q, vect_t e, point_t pt1, point_t pt2)
Plane/line/point calculations.
void rt_cline_uv(struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
Definition: cline.c:405
#define RT_CK_DBI(_p)
Definition: raytrace.h:829
#define RT_GET_SEG(p, res)
Definition: raytrace.h:379
void rt_cline_norm(struct hit *hitp, struct soltab *stp, struct xray *rp)
Definition: cline.c:351
#define BU_LIST_INIT(_hp)
Definition: list.h:148
void * idb_ptr
Definition: raytrace.h:195
point_t r_pt
Point at which ray starts.
Definition: raytrace.h:218
point_t st_min
min X, Y, Z of bounding RPP
Definition: raytrace.h:437
void bu_cv_ntohd(unsigned char *out, const unsigned char *in, size_t count)
const struct rt_functab OBJ[]
Definition: table.c:159
#define BU_PTBL_END(ptbl)
Definition: ptbl.h:106
#define WDB_PIPESEG_MAGIC
Definition: magic.h:214
vect_t h
Definition: cline.c:51
void bn_vec_ortho(vect_t out, const vect_t in)
double abs
absolute dist tol
Definition: raytrace.h:180
#define RT_CK_SOLTAB(_p)
Definition: raytrace.h:453
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
void * st_specific
-> ID-specific (private) struct
Definition: raytrace.h:435
fastf_t uv_du
delta in u
Definition: raytrace.h:343
int tcl_list_to_fastf_array(Tcl_Interp *interp, const char *char_list, fastf_t **array, int *array_len)
Definition: tcl.c:829
const struct bu_structparse rt_cline_parse[]
Definition: cline.c:57
fastf_t crv_c1
curvature in principle dir
Definition: raytrace.h:308
int rt_cline_shot(struct soltab *stp, register struct xray *rp, struct application *ap, struct seg *seghead)
Definition: cline.c:175
void bu_vls_strcpy(struct bu_vls *vp, const char *s)
Definition: vls.c:310
double norm
normal tol
Definition: raytrace.h:182
int hit_surfno
solid-specific surface indicator
Definition: raytrace.h:255
void bu_free(void *ptr, const char *str)
Definition: malloc.c:328
struct vertex * v
Definition: cline.c:524
vect_t hit_normal
DEPRECATED: Surface Normal at hit_point, use RT_HIT_NORMAL.
Definition: raytrace.h:252
#define BU_CK_LIST_HEAD(_p)
Definition: list.h:142
#define BU_CK_EXTERNAL(_p)
Definition: parse.h:224
void nmg_pr_fu_briefly(const struct faceuse *fu, char *h)
Definition: nmg_pr.c:359
void rt_cline_curve(struct curvature *cvp, struct hit *hitp, struct soltab *stp)
Definition: cline.c:387
struct faceuse * nmg_cmface(struct shell *s, struct vertex ***verts, int n)
Definition: nmg_mod.c:979
int rt_cline_prep(struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
Definition: cline.c:114
void rt_ell_16pts(fastf_t *ov, fastf_t *V, fastf_t *A, fastf_t *B)
Definition: ell.c:606
size_t ext_nbytes
Definition: parse.h:210
fastf_t hit_dist
dist from r_pt to hit_point
Definition: raytrace.h:250
HIDDEN void verbose(struct human_data_t *dude)
Definition: human.c:2008
Definition: vls.h:56
#define BRLCAD_ERROR
Definition: defines.h:72
void bu_bomb(const char *str) _BU_ATTR_NORETURN
Definition: bomb.c:91
double fastf_t
Definition: defines.h:300
#define VPRINT(a, b)
Definition: raytrace.h:1881
int rt_cline_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
Definition: cline.c:928
int rt_cline_tess(struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
Definition: cline.c:534
Tcl_Interp * brlcad_interp
Definition: tcl.c:41
#define BU_LIST_FIRST(structure, hp)
Definition: list.h:312
fastf_t uv_v
Range 0..1.
Definition: raytrace.h:342
#define RT_PIPE_INTERNAL_MAGIC
Definition: magic.h:104
int rt_cline_form(struct bu_vls *logstr, const struct rt_functab *ftp)
Definition: cline.c:1085
void nmg_region_a(struct nmgregion *r, const struct bn_tol *tol)
Definition: nmg_mk.c:2557