BRL-CAD
arb_edit.c
Go to the documentation of this file.
1 /* A R B _ E D I T . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1985-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 arb_edit */
21 /** @{ */
22 /** @file primitives/arb8/arb_edit.c
23  *
24  * Editing operations on arb primitives.
25  *
26  */
27 
28 #include "common.h"
29 
30 #include <stdlib.h>
31 #include <ctype.h>
32 #include <string.h>
33 
34 #include "rt/arb_edit.h"
35 #include "raytrace.h"
36 
37 
38 void
39 ext4to6(int pt1, int pt2, int pt3, struct rt_arb_internal *arb, fastf_t peqn[7][4])
40 {
41  point_t pts[8];
42  int i;
43 
44  VMOVE(pts[0], arb->pt[pt1]);
45  VMOVE(pts[1], arb->pt[pt2]);
46  VMOVE(pts[4], arb->pt[pt3]);
47  VMOVE(pts[5], arb->pt[pt3]);
48 
49  /* extrude "distance" to get remaining points */
50  VADD2(pts[2], pts[1], &peqn[6][0]);
51  VADD2(pts[3], pts[0], &peqn[6][0]);
52  VADD2(pts[6], pts[4], &peqn[6][0]);
53  VMOVE(pts[7], pts[6]);
54 
55  /* copy to the original record */
56  for (i=0; i<8; i++)
57  VMOVE(arb->pt[i], pts[i]);
58 }
59 
60 int
61 mv_edge(struct rt_arb_internal *arb,
62  const vect_t thru,
63  const int bp1, const int bp2,
64  const int end1, const int end2,
65  const vect_t dir,
66  const struct bn_tol *tol,
67  fastf_t peqn[7][4])
68 {
69  fastf_t t1, t2;
70 
71  if (bn_isect_line3_plane(&t1, thru, dir, peqn[bp1], tol) < 0 ||
72  bn_isect_line3_plane(&t2, thru, dir, peqn[bp2], tol) < 0) {
73  return 1;
74  }
75 
76  VJOIN1(arb->pt[end1], thru, t1, dir);
77  VJOIN1(arb->pt[end2], thru, t2, dir);
78 
79  return 0;
80 }
81 
82 int
83 arb_extrude(struct rt_arb_internal *arb,
84  int face, fastf_t dist,
85  const struct bn_tol *tol,
86  fastf_t peqn[7][4])
87 {
88  int type, prod, i, j;
89  int uvec[8], svec[11];
90  int pt[4];
91  struct bu_vls error_msg = BU_VLS_INIT_ZERO;
92  struct rt_arb_internal larb; /* local copy of arb for new way */
93  RT_ARB_CK_MAGIC(arb);
94 
95  if (rt_arb_get_cgtype(&type, arb, tol, uvec, svec) == 0) type = 0;
96  if (type != 8 && type != 6 && type != 4) {return 1;}
97 
98  memcpy((char *)&larb, (char *)arb, sizeof(struct rt_arb_internal));
99 
100  if ((type == ARB6 || type == ARB4) && face < 1000) {
101  /* 3 point face */
102  pt[0] = face / 100;
103  i = face - (pt[0]*100);
104  pt[1] = i / 10;
105  pt[2] = i - (pt[1]*10);
106  pt[3] = 1;
107  } else {
108  pt[0] = face / 1000;
109  i = face - (pt[0]*1000);
110  pt[1] = i / 100;
111  i = i - (pt[1]*100);
112  pt[2] = i / 10;
113  pt[3] = i - (pt[2]*10);
114  }
115 
116  /* user can input face in any order - will use product of
117  * face points to distinguish faces:
118  * product face
119  * 24 1234 for ARB8
120  * 1680 5678 for ARB8
121  * 252 2367 for ARB8
122  * 160 1548 for ARB8
123  * 672 4378 for ARB8
124  * 60 1256 for ARB8
125  * 10 125 for ARB6
126  * 72 346 for ARB6
127  * --- special case to make ARB6 from ARB4
128  * --- provides easy way to build ARB6's
129  * 6 123 for ARB4
130  * 8 124 for ARB4
131  * 12 134 for ARB4
132  * 24 234 for ARB4
133  */
134  prod = 1;
135  for (i = 0; i <= 3; i++) {
136  prod *= pt[i];
137  if (type == ARB6 && pt[i] == 6)
138  pt[i]++;
139  if (type == ARB4 && pt[i] == 4)
140  pt[i]++;
141  pt[i]--;
142  if (pt[i] > 7) {
143  return 1;
144  }
145  }
146 
147  /* find plane containing this face */
148  if (bn_mk_plane_3pts(peqn[6], larb.pt[pt[0]], larb.pt[pt[1]],
149  larb.pt[pt[2]], tol)) {
150  return 1;
151  }
152 
153  /* get normal vector of length == dist */
154  for (i = 0; i < 3; i++)
155  peqn[6][i] *= dist;
156 
157  /* protrude the selected face */
158  switch (prod) {
159 
160  case 24: /* protrude face 1234 */
161  if (type == ARB6) {
162  return 1;
163  }
164  if (type == ARB4)
165  goto a4toa6; /* extrude face 234 of ARB4 to make ARB6 */
166 
167  for (i = 0; i < 4; i++) {
168  j = i + 4;
169  VADD2(larb.pt[j], larb.pt[i], peqn[6]);
170  }
171  break;
172 
173  case 6: /* extrude ARB4 face 123 to make ARB6 */
174  case 8: /* extrude ARB4 face 124 to make ARB6 */
175  case 12: /* extrude ARB4 face 134 to Make ARB6 */
176  a4toa6:
177  ext4to6(pt[0], pt[1], pt[2], &larb, peqn);
178  type = ARB6;
179  /* TODO - solid edit menu was called here in MGED - why? */
180  break;
181 
182  case 1680: /* protrude face 5678 */
183  for (i = 0; i < 4; i++) {
184  j = i + 4;
185  VADD2(larb.pt[i], larb.pt[j], peqn[6]);
186  }
187  break;
188 
189  case 60: /* protrude face 1256 */
190  case 10: /* extrude face 125 of ARB6 */
191  VADD2(larb.pt[3], larb.pt[0], peqn[6]);
192  VADD2(larb.pt[2], larb.pt[1], peqn[6]);
193  VADD2(larb.pt[7], larb.pt[4], peqn[6]);
194  VADD2(larb.pt[6], larb.pt[5], peqn[6]);
195  break;
196 
197  case 672: /* protrude face 4378 */
198  case 72: /* extrude face 346 of ARB6 */
199  VADD2(larb.pt[0], larb.pt[3], peqn[6]);
200  VADD2(larb.pt[1], larb.pt[2], peqn[6]);
201  VADD2(larb.pt[5], larb.pt[6], peqn[6]);
202  VADD2(larb.pt[4], larb.pt[7], peqn[6]);
203  break;
204 
205  case 252: /* protrude face 2367 */
206  VADD2(larb.pt[0], larb.pt[1], peqn[6]);
207  VADD2(larb.pt[3], larb.pt[2], peqn[6]);
208  VADD2(larb.pt[4], larb.pt[5], peqn[6]);
209  VADD2(larb.pt[7], larb.pt[6], peqn[6]);
210  break;
211 
212  case 160: /* protrude face 1548 */
213  VADD2(larb.pt[1], larb.pt[0], peqn[6]);
214  VADD2(larb.pt[5], larb.pt[4], peqn[6]);
215  VADD2(larb.pt[2], larb.pt[3], peqn[6]);
216  VADD2(larb.pt[6], larb.pt[7], peqn[6]);
217  break;
218 
219  case 120:
220  case 180:
221  return 1;
222 
223  default:
224  return 1;
225  }
226 
227  /* redo the plane equations */
228  if (rt_arb_calc_planes(&error_msg, &larb, type, peqn, tol)) {
229  bu_vls_free(&error_msg);
230  return 1;
231  }
232  bu_vls_free(&error_msg);
233 
234  /* copy local copy back to original */
235  memcpy((char *)arb, (char *)&larb, sizeof(struct rt_arb_internal));
236 
237  return 0;
238 }
239 
240 
241 int
242 arb_permute(struct rt_arb_internal *arb, const char *encoded_permutation, const struct bn_tol *tol)
243 {
244  struct rt_arb_internal larb; /* local copy of solid */
245  struct rt_arb_internal tarb; /* temporary copy of solid */
246  static size_t min_tuple_size[9] = {0, 0, 0, 0, 3, 2, 2, 1, 3};
247  int vertex, i, k;
248  size_t arglen;
249  size_t face_size; /* # vertices in THE face */
250  int uvec[8], svec[11];
251  int type;
252  char **p;
253 
254  /*
255  * The Permutations
256  *
257  * Each permutation is encoded as an 8-character string,
258  * where the ith character specifies which of the current vertices
259  * (1 through n for an ARBn) should assume the role of vertex i.
260  * Wherever the internal representation of the ARB as an ARB8
261  * stores a redundant copy of a vertex, the string contains a '*'.
262  */
263  static char *perm4[4][7] = {
264  {"123*4***", "124*3***", "132*4***", "134*2***", "142*3***",
265  "143*2***", 0},
266  {"213*4***", "214*3***", "231*4***", "234*1***", "241*3***",
267  "243*1***", 0},
268  {"312*4***", "314*2***", "321*4***", "324*1***", "341*2***",
269  "342*1***", 0},
270  {"412*3***", "413*2***", "421*3***", "423*1***", "431*2***",
271  "432*1***", 0}
272  };
273  static char *perm5[5][3] = {
274  {"12345***", "14325***", 0},
275  {"21435***", "23415***", 0},
276  {"32145***", "34125***", 0},
277  {"41235***", "43215***", 0},
278  {0, 0, 0}
279  };
280  static char *perm6[6][3] = {
281  {"12345*6*", "15642*3*", 0},
282  {"21435*6*", "25631*4*", 0},
283  {"34126*5*", "36524*1*", 0},
284  {"43216*5*", "46513*2*", 0},
285  {"51462*3*", "52361*4*", 0},
286  {"63254*1*", "64153*2*", 0}
287  };
288  static char *perm7[7][2] = {
289  {"1234567*", 0},
290  {0, 0},
291  {0, 0},
292  {"4321576*", 0},
293  {0, 0},
294  {"6237514*", 0},
295  {"7326541*", 0}
296  };
297  static char *perm8[8][7] = {
298  {"12345678", "12654378", "14325876", "14852376",
299  "15624873", "15842673", 0},
300  {"21436587", "21563487", "23416785", "23761485",
301  "26513784", "26731584", 0},
302  {"32147658", "32674158", "34127856", "34872156",
303  "37624851", "37842651", 0},
304  {"41238567", "41583267", "43218765", "43781265",
305  "48513762", "48731562", 0},
306  {"51268437", "51486237", "56218734", "56781234",
307  "58416732", "58761432", 0},
308  {"62157348", "62375148", "65127843", "65872143",
309  "67325841", "67852341", 0},
310  {"73268415", "73486215", "76238514", "76583214",
311  "78436512", "78563412", 0},
312  {"84157326", "84375126", "85147623", "85674123",
313  "87345621", "87654321", 0}
314  };
315  static int vert_loc[] = {
316  /* -----------------------------
317  * Array locations in which
318  * the vertices are stored
319  * -----------------------------
320  * 1 2 3 4 5 6 7 8
321  * -----------------------------
322  * ARB4 */ 0, 1, 2, 4, -1, -1, -1, -1,
323  /* ARB5 */ 0, 1, 2, 3, 4, -1, -1, -1,
324  /* ARB6 */ 0, 1, 2, 3, 4, 6, -1, -1,
325  /* ARB7 */ 0, 1, 2, 3, 4, 5, 6, -1,
326  /* ARB8 */ 0, 1, 2, 3, 4, 5, 6, 7
327  };
328 #define ARB_VERT_LOC(n, v) vert_loc[((n) - 4) * 8 + (v) - 1]
329 
330  RT_ARB_CK_MAGIC(arb);
331 
332 
333  /* make a local copy of the solid */
334  memcpy((char *)&larb, (char *)arb, sizeof(struct rt_arb_internal));
335 
336  /*
337  * Find the encoded form of the specified permutation, if it
338  * exists.
339  */
340  arglen = strlen(encoded_permutation);
341  if (rt_arb_get_cgtype(&type, arb, tol, uvec, svec) == 0) type = 0;
342  if (type < 4 || type > 8) {return 1;}
343  if (arglen < min_tuple_size[type]) {return 1;}
344  face_size = (type == 4) ? 3 : 4;
345  if (arglen > face_size) {return 1;}
346  vertex = encoded_permutation[0] - '1';
347  if ((vertex < 0) || (vertex >= type)) {return 1;}
348  p = (type == 4) ? perm4[vertex] :
349  (type == 5) ? perm5[vertex] :
350  (type == 6) ? perm6[vertex] :
351  (type == 7) ? perm7[vertex] : perm8[vertex];
352  for (;; ++p) {
353  if (*p == 0) {
354  return 1;
355  }
356  if (bu_strncmp(*p, encoded_permutation, arglen) == 0)
357  break;
358  }
359 
360  /*
361  * Collect the vertices in the specified order
362  */
363  for (i = 0; i < 8; ++i) {
364  char buf[2];
365 
366  if ((*p)[i] == '*') {
367  VSETALL(tarb.pt[i], 0);
368  } else {
369  sprintf(buf, "%c", (*p)[i]);
370  k = atoi(buf);
371  VMOVE(tarb.pt[i], larb.pt[ARB_VERT_LOC(type, k)]);
372  }
373  }
374 
375  /*
376  * Reinstall the permuted vertices back into the temporary buffer,
377  * copying redundant vertices as necessary
378  *
379  * -------+-------------------------
380  * Solid | Redundant storage
381  * Type | of some of the vertices
382  * -------+-------------------------
383  * ARB4 | 3=0, 5=6=7=4
384  * ARB5 | 5=6=7=4
385  * ARB6 | 5=4, 7=6
386  * ARB7 | 7=4
387  * ARB8 |
388  * -------+-------------------------
389  */
390  for (i = 0; i < 8; i++) {
391  VMOVE(larb.pt[i], tarb.pt[i]);
392  }
393  switch (type) {
394  case ARB4:
395  VMOVE(larb.pt[3], larb.pt[0]);
396  /* break intentionally left out */
397  case ARB5:
398  VMOVE(larb.pt[5], larb.pt[4]);
399  VMOVE(larb.pt[6], larb.pt[4]);
400  VMOVE(larb.pt[7], larb.pt[4]);
401  break;
402  case ARB6:
403  VMOVE(larb.pt[5], larb.pt[4]);
404  VMOVE(larb.pt[7], larb.pt[6]);
405  break;
406  case ARB7:
407  VMOVE(larb.pt[7], larb.pt[4]);
408  break;
409  case ARB8:
410  break;
411  default:
412  {
413  return 1;
414  }
415  }
416 
417  /* copy back to original arb */
418  memcpy((char *)arb, (char *)&larb, sizeof(struct rt_arb_internal));
419 
420  return 0;
421 }
422 
423 int
424 arb_mirror_face_axis(struct rt_arb_internal *arb, fastf_t peqn[7][4], const int face, const char *axis, const struct bn_tol *tol)
425 {
426  int i, j, k;
427  int type;
428  int uvec[8], svec[11];
429  static int pt[4];
430  static int prod;
431  static vect_t work;
432  struct rt_arb_internal larb; /* local copy of solid */
433 
434  /* check which axis */
435  k = -1;
436  if (BU_STR_EQUAL(axis, "x"))
437  k = 0;
438  if (BU_STR_EQUAL(axis, "y"))
439  k = 1;
440  if (BU_STR_EQUAL(axis, "z"))
441  k = 2;
442  if (k < 0) {
443  return 1;
444  }
445 
446  work[0] = work[1] = work[2] = 1.0;
447  work[k] = -1.0;
448 
449  /* make local copy of arb */
450  memcpy((char *)&larb, (char *)arb, sizeof(struct rt_arb_internal));
451 
452  if (rt_arb_get_cgtype(&type, arb, tol, uvec, svec) == 0) type = 0;
453 
454  if (type != ARB8 && type != ARB6) {return 1;}
455 
456  if (face > 9999 || (face < 1000 && type != ARB6)) {return 1;}
457 
458  if (type == ARB6 && face < 1000) {
459  /* 3 point face */
460  pt[0] = face / 100;
461  i = face - (pt[0]*100);
462  pt[1] = i / 10;
463  pt[2] = i - (pt[1]*10);
464  pt[3] = 1;
465  } else {
466  pt[0] = face / 1000;
467  i = face - (pt[0]*1000);
468  pt[1] = i / 100;
469  i = i - (pt[1]*100);
470  pt[2] = i / 10;
471  pt[3] = i - (pt[2]*10);
472  }
473 
474  /* user can input face in any order - will use product of
475  * face points to distinguish faces:
476  * product face
477  * 24 1234 for ARB8
478  * 1680 5678 for ARB8
479  * 252 2367 for ARB8
480  * 160 1548 for ARB8
481  * 672 4378 for ARB8
482  * 60 1256 for ARB8
483  * 10 125 for ARB6
484  * 72 346 for ARB6
485  */
486  prod = 1;
487  for (i = 0; i <= 3; i++) {
488  prod *= pt[i];
489  pt[i]--;
490  if (pt[i] > 7) {
491  return 1;
492  }
493  }
494 
495  /* mirror the selected face */
496  switch (prod) {
497 
498  case 24: /* mirror face 1234 */
499  if (type == ARB6) {
500  return 1;
501  }
502  for (i = 0; i < 4; i++) {
503  j = i + 4;
504  VELMUL(larb.pt[j], larb.pt[i], work);
505  }
506  break;
507 
508  case 1680: /* mirror face 5678 */
509  for (i = 0; i < 4; i++) {
510  j = i + 4;
511  VELMUL(larb.pt[i], larb.pt[j], work);
512  }
513  break;
514 
515  case 60: /* mirror face 1256 */
516  case 10: /* mirror face 125 of ARB6 */
517  VELMUL(larb.pt[3], larb.pt[0], work);
518  VELMUL(larb.pt[2], larb.pt[1], work);
519  VELMUL(larb.pt[7], larb.pt[4], work);
520  VELMUL(larb.pt[6], larb.pt[5], work);
521  break;
522 
523  case 672: /* mirror face 4378 */
524  case 72: /* mirror face 346 of ARB6 */
525  VELMUL(larb.pt[0], larb.pt[3], work);
526  VELMUL(larb.pt[1], larb.pt[2], work);
527  VELMUL(larb.pt[5], larb.pt[6], work);
528  VELMUL(larb.pt[4], larb.pt[7], work);
529  break;
530 
531  case 252: /* mirror face 2367 */
532  VELMUL(larb.pt[0], larb.pt[1], work);
533  VELMUL(larb.pt[3], larb.pt[2], work);
534  VELMUL(larb.pt[4], larb.pt[5], work);
535  VELMUL(larb.pt[7], larb.pt[6], work);
536  break;
537 
538  case 160: /* mirror face 1548 */
539  VELMUL(larb.pt[1], larb.pt[0], work);
540  VELMUL(larb.pt[5], larb.pt[4], work);
541  VELMUL(larb.pt[2], larb.pt[3], work);
542  VELMUL(larb.pt[6], larb.pt[7], work);
543  break;
544 
545  case 120:
546  case 180:
547  return 1;
548  default:
549  return 1;
550  }
551 
552  /* redo the plane equations */
553  {
554  struct bu_vls error_msg = BU_VLS_INIT_ZERO;
555  if (rt_arb_calc_planes(&error_msg, &larb, type, peqn, tol)) {
556  return 1;
557  }
558  bu_vls_free(&error_msg);
559  }
560 
561  /* copy to original */
562  memcpy((char *)arb, (char *)&larb, sizeof(struct rt_arb_internal));
563 
564  return 0;
565 }
566 
567 int
568 arb_edit(struct rt_arb_internal *arb, fastf_t peqn[7][4], int edge, int newedge, vect_t pos_model, const struct bn_tol *tol)
569 {
570  int type;
571  int pflag = 0;
572  int uvec[8], svec[11];
573  static int pt1, pt2, bp1, bp2, newp, p1, p2, p3;
574  const short *edptr; /* pointer to arb edit array */
575  const short *final; /* location of points to redo */
576  static int i;
577  const int *iptr;
578  const short earb8[12][18] = earb8_edit_array;
579  const short earb7[12][18] = earb7_edit_array;
580  const short earb6[10][18] = earb6_edit_array;
581  const short earb5[9][18] = earb5_edit_array;
582  const short earb4[5][18] = earb4_edit_array;
583 
584  RT_ARB_CK_MAGIC(arb);
585 
586  if (rt_arb_get_cgtype(&type, arb, tol, uvec, svec) == 0) return 1;
587 
588  /* set the pointer */
589  switch (type) {
590  case ARB4:
591  edptr = &earb4[edge][0];
592  final = &earb4[edge][16];
593  pflag = 1;
594  break;
595  case ARB5:
596  edptr = &earb5[edge][0];
597  final = &earb5[edge][16];
598  if (edge == 8)
599  pflag = 1;
600  break;
601  case ARB6:
602  edptr = &earb6[edge][0];
603  final = &earb6[edge][16];
604  if (edge > 7)
605  pflag = 1;
606  break;
607  case ARB7:
608  edptr = &earb7[edge][0];
609  final = &earb7[edge][16];
610  if (edge == 11)
611  pflag = 1;
612  break;
613  case ARB8:
614  edptr = &earb8[edge][0];
615  final = &earb8[edge][16];
616  break;
617  default:
618  return 1;
619  }
620 
621 
622  /* do the arb editing */
623 
624  if (pflag) {
625  /* moving a point - not an edge */
626  VMOVE(arb->pt[edge], pos_model);
627  edptr += 4;
628  } else {
629  vect_t edge_dir;
630 
631  /* moving an edge */
632  pt1 = *edptr++;
633  pt2 = *edptr++;
634  /* direction of this edge */
635  if (newedge) {
636  /* edge direction comes from edgedir() in pos_model */
637  VMOVE(edge_dir, pos_model);
638  VMOVE(pos_model, arb->pt[pt1]);
639  newedge = 0;
640  } else {
641  /* must calculate edge direction */
642  VSUB2(edge_dir, arb->pt[pt2], arb->pt[pt1]);
643  }
644  if (ZERO(MAGNITUDE(edge_dir)))
645  goto err;
646  /* bounding planes bp1, bp2 */
647  bp1 = *edptr++;
648  bp2 = *edptr++;
649 
650  /* move the edge */
651  if (mv_edge(arb, pos_model, bp1, bp2, pt1, pt2, edge_dir, tol, peqn)){
652  goto err;
653  }
654  }
655 
656  /* editing is done - insure planar faces */
657  /* redo plane eqns that changed */
658  newp = *edptr++; /* plane to redo */
659 
660  if (newp == 9) {
661  struct bu_vls error_msg = BU_VLS_INIT_ZERO;
662  int arb_calc_ret = 0;
663  arb_calc_ret = rt_arb_calc_planes(&error_msg, arb, type, peqn, tol);
664  bu_vls_free(&error_msg);
665  if (arb_calc_ret) goto err;
666  }
667 
668  if (newp >= 0 && newp < 6) {
669  for (i=0; i<3; i++) {
670  /* redo this plane (newp), use points p1, p2, p3 */
671  p1 = *edptr++;
672  p2 = *edptr++;
673  p3 = *edptr++;
674  if (bn_mk_plane_3pts(peqn[newp], arb->pt[p1], arb->pt[p2],
675  arb->pt[p3], tol))
676  goto err;
677 
678  /* next plane */
679  if ((newp = *edptr++) == -1 || newp == 8)
680  break;
681  }
682  }
683  if (newp == 8) {
684  /* special...redo next planes using pts defined in faces */
685  const int local_arb_faces[5][24] = rt_arb_faces;
686  for (i=0; i<3; i++) {
687  if ((newp = *edptr++) == -1)
688  break;
689  iptr = &local_arb_faces[type-4][4*newp];
690  p1 = *iptr++;
691  p2 = *iptr++;
692  p3 = *iptr++;
693  if (bn_mk_plane_3pts(peqn[newp], arb->pt[p1], arb->pt[p2],
694  arb->pt[p3], tol))
695  goto err;
696  }
697  }
698 
699  /* the changed planes are all redone push necessary points back
700  * into the planes.
701  */
702  edptr = final; /* point to the correct location */
703  for (i=0; i<2; i++) {
704  if ((p1 = *edptr++) == -1)
705  break;
706  /* intersect proper planes to define vertex p1 */
707  if (rt_arb_3face_intersect(arb->pt[p1], (const plane_t *)peqn, type, p1*3))
708  goto err;
709  }
710 
711  /* Special case for ARB7: move point 5 .... must recalculate plane
712  * 2 = 456
713  */
714  if (type == ARB7 && pflag) {
715  if (bn_mk_plane_3pts(peqn[2], arb->pt[4], arb->pt[5], arb->pt[6], tol))
716  goto err;
717  }
718 
719  /* carry along any like points */
720  switch (type) {
721  case ARB8:
722  break;
723 
724  case ARB7:
725  VMOVE(arb->pt[7], arb->pt[4]);
726  break;
727 
728  case ARB6:
729  VMOVE(arb->pt[5], arb->pt[4]);
730  VMOVE(arb->pt[7], arb->pt[6]);
731  break;
732 
733  case ARB5:
734  for (i=5; i<8; i++)
735  VMOVE(arb->pt[i], arb->pt[4]);
736  break;
737 
738  case ARB4:
739  VMOVE(arb->pt[3], arb->pt[0]);
740  for (i=5; i<8; i++)
741  VMOVE(arb->pt[i], arb->pt[4]);
742  break;
743  }
744 
745  return 0; /* OK */
746 
747  err:
748  return 1; /* BAD */
749 
750 }
751 
752 /** @} */
753 
754 /*
755  * Local Variables:
756  * mode: C
757  * tab-width: 8
758  * indent-tabs-mode: t
759  * c-file-style: "stroustrup"
760  * End:
761  * ex: shiftwidth=4 tabstop=8
762  */
int rt_arb_calc_planes(struct bu_vls *error_msg_ret, struct rt_arb_internal *arb, int type, plane_t planes[6], const struct bn_tol *tol)
Definition: arb8.c:1871
int bn_isect_line3_plane(fastf_t *dist, const point_t pt, const vect_t dir, const plane_t plane, const struct bn_tol *tol)
int mv_edge(struct rt_arb_internal *arb, const vect_t thru, const int bp1, const int bp2, const int end1, const int end2, const vect_t dir, const struct bn_tol *tol, fastf_t peqn[7][4])
Definition: arb_edit.c:61
#define earb7_edit_array
Definition: arb_edit.h:177
#define VSETALL(a, s)
Definition: color.c:54
Header file for the BRL-CAD common definitions.
#define earb4_edit_array
Definition: arb_edit.h:359
#define rt_arb_faces
Definition: arb_edit.h:65
#define earb5_edit_array
Definition: arb_edit.h:305
void bu_vls_free(struct bu_vls *vp)
Definition: vls.c:248
int bu_strncmp(const char *string1, const char *string2, size_t n)
Definition: str.c:191
int arb_extrude(struct rt_arb_internal *arb, int face, fastf_t dist, const struct bn_tol *tol, fastf_t peqn[7][4])
Definition: arb_edit.c:83
int rt_arb_3face_intersect(point_t point, const plane_t planes[6], int type, int loc)
Editing operations for arb primitives.
#define earb6_edit_array
Definition: arb_edit.h:244
Support for uniform tolerances.
Definition: tol.h:71
int arb_permute(struct rt_arb_internal *arb, const char *encoded_permutation, const struct bn_tol *tol)
Definition: arb_edit.c:242
#define ARB_VERT_LOC(n, v)
#define ZERO(val)
Definition: units.c:38
#define earb8_edit_array
Definition: arb_edit.h:108
axis
Definition: color.c:48
void ext4to6(int pt1, int pt2, int pt3, struct rt_arb_internal *arb, fastf_t peqn[7][4])
Definition: arb_edit.c:39
#define BU_VLS_INIT_ZERO
Definition: vls.h:84
int arb_mirror_face_axis(struct rt_arb_internal *arb, fastf_t peqn[7][4], const int face, const char *axis, const struct bn_tol *tol)
Definition: arb_edit.c:424
Definition: vls.h:56
int rt_arb_get_cgtype(int *cgtype, struct rt_arb_internal *arb, const struct bn_tol *tol, register int *uvec, register int *svec)
Definition: arb8.c:203
double fastf_t
Definition: defines.h:300
int bn_mk_plane_3pts(plane_t plane, const point_t a, const point_t b, const point_t c, const struct bn_tol *tol)
int arb_edit(struct rt_arb_internal *arb, fastf_t peqn[7][4], int edge, int newedge, vect_t pos_model, const struct bn_tol *tol)
Definition: arb_edit.c:568
#define BU_STR_EQUAL(s1, s2)
Definition: str.h:126