BRL-CAD
oslo_map.c
Go to the documentation of this file.
1 /* O S L O _ M A P . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1990-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 nurb */
21 /** @{ */
22 /** @file librt/oslo_map.c
23  *
24  * Map the oslo matrix with the old curve resulting in a new one.
25  *
26  */
27 
28 #include "common.h"
29 
30 #include "bio.h"
31 
32 #include "vmath.h"
33 #include "raytrace.h"
34 #include "nurb.h"
35 
36 /* This routine takes a oslo refinement matrix as described in the
37  * paper "Making the Oslo Algorithm More Efficient" and maps it to the
38  * old control points resulting in new control points. (this
39  * procedure should probably never called by a user program but should
40  * remain internal to the library. Bounds are given to facilitate
41  * easier splitting of the surface.
42  */
43 
44 void
45 rt_nurb_map_oslo(struct oslo_mat *oslo, fastf_t *old_pts, fastf_t *new_pts, int o_stride, int n_stride, int lower, int upper, int pt_type)
46 /* Oslo matrix */
47 /* Old control points */
48 /* New control points */
49 /* inc to next point of old mesh*/
50 /* inc to next point of new mesh*/
51 /* Upper and lower bounds for curve generation */
52 
53 {
54  register fastf_t *c_ptr; /* new curve pointer */
55  register fastf_t *o_pts;
56  register struct oslo_mat *o_ptr; /* oslo matrix pointer */
57  register int k;
58  int j, /* j loop */
59  i; /* oslo loop */
60  int coords;
61 
62  coords = RT_NURB_EXTRACT_COORDS(pt_type);
63 
64  c_ptr = new_pts;
65 
66  if (lower != 0)
67  for (i = 0, o_ptr = oslo; i < lower; i++, o_ptr =
68  o_ptr->next)
69  ;
70  else
71  o_ptr = oslo;
72 
73  for (j = lower; j < upper; j++, o_ptr = o_ptr->next) {
74  fastf_t o_scale;
75  o_pts = &old_pts[(o_ptr->offset * o_stride)];
76 
77  o_scale = o_ptr->o_vec[0];
78 
79  for (k = 0; k < coords; k++)
80  c_ptr[k] = o_pts[k] * o_scale;
81 
82  for (i = 1; i <= o_ptr->osize; i++) {
83  o_scale = o_ptr->o_vec[i];
84  o_pts += o_stride;
85  for (k = 0; k < coords; k++)
86  c_ptr[k] += o_scale * o_pts[k];
87  }
88  c_ptr += n_stride;
89  }
90 }
91 
92 
93 /** @} */
94 /*
95  * Local Variables:
96  * mode: C
97  * tab-width: 8
98  * indent-tabs-mode: t
99  * c-file-style: "stroustrup"
100  * End:
101  * ex: shiftwidth=4 tabstop=8
102  */
void rt_nurb_map_oslo(struct oslo_mat *oslo, fastf_t *old_pts, fastf_t *new_pts, int o_stride, int n_stride, int lower, int upper, int pt_type)
Definition: oslo_map.c:45
Header file for the BRL-CAD common definitions.
double fastf_t
Definition: defines.h:300