BRL-CAD
arb_edit.h
Go to the documentation of this file.
1/* A R B _ E D I T . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2014-2023 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 rt_arb */
21/** @{ */
22/** @file rt/arb_edit.h
23 *
24 * @brief
25 * Editing operations for arb primitives.
26 *
27 */
28
29#ifndef RT_ARB_EDIT_H
30#define RT_ARB_EDIT_H
31
32#include "common.h"
33#include "bn.h"
34#include "rt/defines.h"
35#include "rt/db4.h"
36#include "rt/geom.h"
37
38__BEGIN_DECLS
39
40/**
41 * face definitions for each arb type
42 *
43 * row 1: ARB4
44 * row 2: ARB5
45 * row 3: ARB6
46 * row 4: ARB7
47 * row 5: ARB8
48 *
49 * To use this array, define it as follows:
50 *
51 * const int arb_faces[5][24] = rt_arb_faces;
52 *
53 */
54#define rt_arb_faces { \
55 {0,1,2,3, 0,1,4,5, 1,2,4,5, 0,2,4,5, -1,-1,-1,-1, -1,-1,-1,-1}, \
56 {0,1,2,3, 4,0,1,5, 4,1,2,5, 4,2,3,5, 4,3,0,5, -1,-1,-1,-1}, \
57 {0,1,2,3, 1,2,6,4, 0,4,6,3, 4,1,0,5, 6,2,3,7, -1,-1,-1,-1}, \
58 {0,1,2,3, 4,5,6,7, 0,3,4,7, 1,2,6,5, 0,1,5,4, 3,2,6,4}, \
59 {0,1,2,3, 4,5,6,7, 0,4,7,3, 1,2,6,5, 0,1,5,4, 3,2,6,7}, \
60}
61
62/* The following arb editing arrays generally contain the following:
63 *
64 * location comments
65 *-------------------------------------------------------------------
66 * 0,1 edge end points
67 * 2,3 bounding planes 1 and 2
68 * 4, 5,6,7 plane 1 to recalculate, using next 3 points
69 * 8, 9,10,11 plane 2 to recalculate, using next 3 points
70 * 12, 13,14,15 plane 3 to recalculate, using next 3 points
71 * 16,17 points (vertices) to recalculate
72 *
73 * Each line is repeated for each edge (or point) to move.
74 * See g_arb.c for more details.
75 */
76
77/**
78 * edit array for arb8's
79 *
80 * row 1: edge 12
81 * row 2: edge 23
82 * row 3: edge 34
83 * row 4: edge 14
84 * row 5: edge 15
85 * row 6: edge 26
86 * row 7: edge 56
87 * row 8: edge 67
88 * row 9: edge 78
89 * row 10: edge 58
90 * row 11: edge 37
91 * row 12: edge 48
92 *
93 * To use this array, define it as follows:
94 *
95 * const short earb8[12][18] = earb8_edit_array;
96 */
97#define earb8_edit_array { \
98 {0,1, 2,3, 0,0,1,2, 4,0,1,4, -1,0,0,0, 3,5}, \
99 {1,2, 4,5, 0,0,1,2, 3,1,2,5, -1,0,0,0, 3,6}, \
100 {2,3, 3,2, 0,0,2,3, 5,2,3,6, -1,0,0,0, 1,7}, \
101 {0,3, 4,5, 0,0,1,3, 2,0,3,4, -1,0,0,0, 2,7}, \
102 {0,4, 0,1, 2,0,4,3, 4,0,1,4, -1,0,0,0, 7,5}, \
103 {1,5, 0,1, 4,0,1,5, 3,1,2,5, -1,0,0,0, 4,6}, \
104 {4,5, 2,3, 4,0,5,4, 1,4,5,6, -1,0,0,0, 1,7}, \
105 {5,6, 4,5, 3,1,5,6, 1,4,5,6, -1,0,0,0, 2,7}, \
106 {6,7, 3,2, 5,2,7,6, 1,4,6,7, -1,0,0,0, 3,4}, \
107 {4,7, 4,5, 2,0,7,4, 1,4,5,7, -1,0,0,0, 3,6}, \
108 {2,6, 0,1, 3,1,2,6, 5,2,3,6, -1,0,0,0, 5,7}, \
109 {3,7, 0,1, 2,0,3,7, 5,2,3,7, -1,0,0,0, 4,6}, \
110}
111
112/**
113 * edge/vertex mapping for arb8's
114 *
115 * row 1: edge 12
116 * row 2: edge 23
117 * row 3: edge 34
118 * row 4: edge 14
119 * row 5: edge 15
120 * row 6: edge 26
121 * row 7: edge 56
122 * row 8: edge 67
123 * row 9: edge 78
124 * row 10: edge 58
125 * row 11: edge 37
126 * row 12: edge 48
127 *
128 * To use this mapping , define it as follows:
129 * const short arb8_evm[12][2] = arb8_edge_vertex_mapping;
130 */
131#define arb8_edge_vertex_mapping { \
132 {0,1}, \
133 {1,2}, \
134 {2,3}, \
135 {0,3}, \
136 {0,4}, \
137 {1,5}, \
138 {4,5}, \
139 {5,6}, \
140 {6,7}, \
141 {4,7}, \
142 {2,6}, \
143 {3,7}, \
144}
145
146/**
147 * edit array for arb7's
148
149 * row 1: edge 12
150 * row 2: edge 23
151 * row 3: edge 34
152 * row 4: edge 41
153 * row 5: edge 15
154 * row 6: edge 26
155 * row 7: edge 56
156 * row 8: edge 67
157 * row 9: edge 37
158 * row 10: edge 57
159 * row 11: edge 45
160 * row 12: point 5
161 *
162 * To use this array, define it as follows:
163 *
164 * const short earb7[12][18] = earb7_edit_array;
165 */
166#define earb7_edit_array { \
167 {0,1, 2,3, 0,0,1,2, 4,0,1,4, -1,0,0,0, 3,5}, \
168 {1,2, 4,5, 0,0,1,2, 3,1,2,5, -1,0,0,0, 3,6}, \
169 {2,3, 3,2, 0,0,2,3, 5,2,3,6, -1,0,0,0, 1,4}, \
170 {0,3, 4,5, 0,0,1,3, 2,0,3,4, -1,0,0,0, 2,-1}, \
171 {0,4, 0,5, 4,0,5,4, 2,0,3,4, 1,4,5,6, 1,-1}, \
172 {1,5, 0,1, 4,0,1,5, 3,1,2,5, -1,0,0,0, 4,6}, \
173 {4,5, 5,3, 2,0,3,4, 4,0,5,4, 1,4,5,6, 1,-1}, \
174 {5,6, 4,5, 3,1,6,5, 1,4,5,6, -1,0,0,0, 2, -1}, \
175 {2,6, 0,1, 5,2,3,6, 3,1,2,6, -1,0,0,0, 4,5}, \
176 {4,6, 4,3, 2,0,3,4, 5,3,4,6, 1,4,5,6, 2,-1}, \
177 {3,4, 0,1, 4,0,1,4, 2,0,3,4, 5,2,3,4, 5,6}, \
178 {-1,-1, -1,-1, 5,2,3,4, 4,0,1,4, 8,2,1,-1, 6,5}, \
179}
180
181/**
182 * edge/vertex mapping for arb7's
183 *
184 * row 1: edge 12
185 * row 2: edge 23
186 * row 3: edge 34
187 * row 4: edge 41
188 * row 5: edge 15
189 * row 6: edge 26
190 * row 7: edge 56
191 * row 8: edge 67
192 * row 9: edge 37
193 * row 10: edge 57
194 * row 11: edge 45
195 * row 12: point 5
196 *
197 * To use this mapping , define it as follows:
198 * const short arb7_evm[12][2] = arb7_edge_vertex_mapping;
199 */
200#define arb7_edge_vertex_mapping { \
201 {0,1}, \
202 {1,2}, \
203 {2,3}, \
204 {0,3}, \
205 {0,4}, \
206 {1,5}, \
207 {4,5}, \
208 {5,6}, \
209 {2,6}, \
210 {4,6}, \
211 {3,4}, \
212 {4,4}, \
213}
214
215/**
216 * edit array for arb6's
217 *
218 * row 1: edge 12
219 * row 2: edge 23
220 * row 3: edge 34
221 * row 4: edge 14
222 * row 5: edge 15
223 * row 6: edge 25
224 * row 7: edge 36
225 * row 8: edge 46
226 * row 9: point 5
227 * row 10: point 6
228 *
229 * To use this array, define it as follows:
230 *
231 * const short earb6[10][18] = earb6_edit_array;
232 */
233#define earb6_edit_array { \
234 {0,1, 2,1, 3,0,1,4, 0,0,1,2, -1,0,0,0, 3,-1}, \
235 {1,2, 3,4, 1,1,2,5, 0,0,1,2, -1,0,0,0, 3,4}, \
236 {2,3, 1,2, 4,2,3,5, 0,0,2,3, -1,0,0,0, 1,-1}, \
237 {0,3, 3,4, 2,0,3,5, 0,0,1,3, -1,0,0,0, 4,2}, \
238 {0,4, 0,1, 3,0,1,4, 2,0,3,4, -1,0,0,0, 6,-1}, \
239 {1,4, 0,2, 3,0,1,4, 1,1,2,4, -1,0,0,0, 6,-1}, \
240 {2,6, 0,2, 4,6,2,3, 1,1,2,6, -1,0,0,0, 4,-1}, \
241 {3,6, 0,1, 4,6,2,3, 2,0,3,6, -1,0,0,0, 4,-1}, \
242 {-1,-1, -1,-1, 2,0,3,4, 1,1,2,4, 3,0,1,4, 6,-1}, \
243 {-1,-1, -1,-1, 2,0,3,6, 1,1,2,6, 4,2,3,6, 4,-1}, \
244}
245
246/**
247 * edge/vertex mapping for arb6's
248 *
249 * row 1: edge 12
250 * row 2: edge 23
251 * row 3: edge 34
252 * row 4: edge 14
253 * row 5: edge 15
254 * row 6: edge 25
255 * row 7: edge 36
256 * row 8: edge 46
257 * row 9: point 5
258 * row 10: point 6
259 *
260 * To use this mapping , define it as follows:
261 *
262 * const short arb6_evm[10][2] = arb6_edge_vertex_mapping;
263 */
264#define arb6_edge_vertex_mapping { \
265 {0,1}, \
266 {1,2}, \
267 {2,3}, \
268 {0,3}, \
269 {0,4}, \
270 {1,4}, \
271 {2,5}, \
272 {3,5}, \
273 {4,4}, \
274 {7,7}, \
275}
276
277/**
278 * edit array for arb5's
279 *
280 * row 1: edge 12
281 * row 2: edge 23
282 * row 3: edge 34
283 * row 4: edge 14
284 * row 5: edge 15
285 * row 6: edge 25
286 * row 7: edge 35
287 * row 8: edge 45
288 * row 9: point 5
289 *
290 * To use this array, define it as follows:
291 *
292 * const short earb5[9][18] = earb5_edit_array;
293 */
294#define earb5_edit_array { \
295 {0,1, 4,2, 0,0,1,2, 1,0,1,4, -1,0,0,0, 3,-1}, \
296 {1,2, 1,3, 0,0,1,2, 2,1,2,4, -1,0,0,0, 3,-1}, \
297 {2,3, 2,4, 0,0,2,3, 3,2,3,4, -1,0,0,0, 1,-1}, \
298 {0,3, 1,3, 0,0,1,3, 4,0,3,4, -1,0,0,0, 2,-1}, \
299 {0,4, 0,2, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
300 {1,4, 0,3, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
301 {2,4, 0,4, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
302 {3,4, 0,1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
303 {-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
304}
305
306/**
307 * edge/vertex mapping for arb5's
308 *
309 * row 1: edge 12
310 * row 2: edge 23
311 * row 3: edge 34
312 * row 4: edge 14
313 * row 5: edge 15
314 * row 6: edge 25
315 * row 7: edge 35
316 * row 8: edge 45
317 * row 9: point 5
318 *
319 * To use this mapping , define it as follows:
320 *
321 * const short arb5_evm[9][2] = arb5_edge_vertex_mapping;
322 */
323#define arb5_edge_vertex_mapping { \
324 {0,1}, \
325 {1,2}, \
326 {2,3}, \
327 {0,3}, \
328 {0,4}, \
329 {1,4}, \
330 {2,4}, \
331 {3,4}, \
332 {4,4}, \
333}
334
335/**
336 * edit array for arb4's
337 *
338 * row 1: point 1
339 * row 2: point 2
340 * row 3: point 3
341 * row 4: dummy
342 * row 5: point 4
343 *
344 * To use this array, define it as follows:
345 *
346 * const short earb4[5][18] = earb4_edit_array;
347 */
348#define earb4_edit_array { \
349 {-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
350 {-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
351 {-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
352 {-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
353 {-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, \
354}
355
356/**
357 * edge/vertex mapping for arb4's
358 *
359 * row 1: point 1
360 * row 2: point 2
361 * row 3: point 3
362 * row 4: dummy
363 * row 5: point 4
364 *
365 * To use this mapping , define it as follows:
366 *
367 * const short arb4_evm[5][2] = arb4_edge_vertex_mapping;
368 */
369#define arb4_edge_vertex_mapping { \
370 {0,0}, \
371 {1,1}, \
372 {2,2}, \
373 {3,3}, \
374 {4,4}, \
375}
376
377/**
378 * EXT4TO6(): extrudes face pt1 pt2 pt3 of an ARB4 "distance"
379 * to produce ARB6
380 */
381RT_EXPORT extern void
382ext4to6(int pt1, int pt2, int pt3, struct rt_arb_internal *arb, fastf_t peqn[7][4]);
383
384
385/* MV_EDGE: Moves an arb edge (end1, end2) with bounding planes bp1
386 * and bp2 through point "thru". The edge has (non-unit) slope "dir".
387 * Note that the fact that the normals here point in rather than out
388 * makes no difference for computing the correct intercepts. After
389 * the intercepts are found, they should be checked against the other
390 * faces to make sure that they are always "inside".
391 */
392RT_EXPORT extern int
394 const vect_t thru,
395 const int bp1, const int bp2,
396 const int end1, const int end2,
397 const vect_t dir,
398 const struct bn_tol *tol,
399 fastf_t peqn[7][4]);
400
401/* Extrude an arb face */
402RT_EXPORT extern int
404 int face, fastf_t dist,
405 const struct bn_tol *tol,
406 fastf_t peqn[7][4]);
407
408
409/* Permute the vertex labels of an ARB
410 *
411 * Minimum and maximum tuple lengths
412 * ------------------------------------------------
413 * Solid # vertices needed # vertices
414 * type to disambiguate in THE face
415 * ------------------------------------------------
416 * ARB4 3 3
417 * ARB5 2 4
418 * ARB6 2 4
419 * ARB7 1 4
420 * ARB8 3 4
421 * ------------------------------------------------
422 */
423RT_EXPORT extern int
424arb_permute(struct rt_arb_internal *arb, const char *encoded_permutation, const struct bn_tol *tol);
425
426
427/* Mirror an arb face about the x, y or z axis */
428RT_EXPORT extern int
429arb_mirror_face_axis(struct rt_arb_internal *arb, fastf_t peqn[7][4], const int face, const char *axis, const struct bn_tol *tol);
430
431/* An ARB edge is moved by finding the direction of the line
432 * containing the edge and the 2 "bounding" planes. The new edge is
433 * found by intersecting the new line location with the bounding
434 * planes. The two "new" planes thus defined are calculated and the
435 * affected points are calculated by intersecting planes. This keeps
436 * ALL faces planar.
437 */
438RT_EXPORT extern int
439arb_edit(struct rt_arb_internal *arb, fastf_t peqn[7][4], int edge, int newedge, vect_t pos_model, const struct bn_tol *tol);
440
441
442__END_DECLS
443
444#endif /* RT_ARB_EDIT_H */
445
446/** @} */
447/*
448 * Local Variables:
449 * tab-width: 8
450 * mode: C
451 * indent-tabs-mode: t
452 * c-file-style: "stroustrup"
453 * End:
454 * ex: shiftwidth=4 tabstop=8
455 */
Header file for the BRL-CAD Numerical Computation Library, LIBBN.
Header file for the BRL-CAD common definitions.
GED Database Format v4.
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)
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)
void ext4to6(int pt1, int pt2, int pt3, struct rt_arb_internal *arb, fastf_t peqn[7][4])
int arb_extrude(struct rt_arb_internal *arb, int face, fastf_t dist, const struct bn_tol *tol, fastf_t peqn[7][4])
int arb_permute(struct rt_arb_internal *arb, const char *encoded_permutation, 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])
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition: vmath.h:345
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
Definition: tol.h:72
NMG topological edge.
Definition: topology.h:144
NMG topological face.
Definition: topology.h:210