BRL-CAD
nurb_plot.c
Go to the documentation of this file.
1 /* N U R B _ P L O T . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1986-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 primitives/bspline/nurb_plot.c
23  *
24  * Utilities for spline debugging.
25  *
26  */
27 /** @} */
28 
29 #include "common.h"
30 
31 #include <sys/types.h>
32 #include "bio.h"
33 
34 #include "vmath.h"
35 #include "raytrace.h"
36 #include "nurb.h"
37 #include "plot3.h"
38 
39 
40 void
41 rt_nurb_plot_snurb(FILE *fp, const struct face_g_snurb *srf)
42 {
43  int i, j;
44  const fastf_t * m_ptr = srf->ctl_points;
45  int evp = RT_NURB_EXTRACT_COORDS(srf->pt_type);
46  int rat = RT_NURB_IS_PT_RATIONAL(srf->pt_type);
47  point_t pt;
48 
49  NMG_CK_SNURB(srf);
50 
51  for (i = 0; i < srf->s_size[0]; i++) {
52  for (j = 0; j < srf->s_size[1]; j++) {
53  if (rat) {
54  pt[0] = m_ptr[0]/ m_ptr[3];
55  pt[1] = m_ptr[1]/ m_ptr[3];
56  pt[2] = m_ptr[2]/ m_ptr[3];
57  } else {
58  pt[0] = m_ptr[0];
59  pt[1] = m_ptr[1];
60  pt[2] = m_ptr[2];
61 
62  }
63 
64  if (j == 0) {
65  pdv_3move(fp, pt);
66  } else
67  pdv_3cont(fp, pt);
68 
69  m_ptr += evp;
70  }
71  }
72 
73  for (j = 0; j < srf->s_size[1]; j++) {
74  int stride;
75  stride = srf->s_size[1] * evp;
76  m_ptr = &srf->ctl_points[j * evp];
77  for (i = 0; i < srf->s_size[0]; i++) {
78  if (rat) {
79  pt[0] = m_ptr[0]/ m_ptr[3];
80  pt[1] = m_ptr[1]/ m_ptr[3];
81  pt[2] = m_ptr[2]/ m_ptr[3];
82  } else {
83  pt[0] = m_ptr[0];
84  pt[1] = m_ptr[1];
85  pt[2] = m_ptr[2];
86 
87  }
88 
89 
90  if (i == 0)
91  pdv_3move(fp, pt);
92  else
93  pdv_3cont(fp, pt);
94 
95  m_ptr += stride;
96  }
97  }
98 }
99 
100 
101 void
102 rt_nurb_plot_cnurb(FILE *fp, const struct edge_g_cnurb *crv)
103 {
104  register int i, k;
105  const fastf_t * m_ptr = crv->ctl_points;
106  int evp = RT_NURB_EXTRACT_COORDS(crv->pt_type);
107  int rat = RT_NURB_IS_PT_RATIONAL(crv->pt_type);
108  point_t ptr;
109 
110  for (i = 0; i < crv->c_size; i++) {
111  if (rat) {
112  for (k = 0; k < evp; k++)
113  ptr[k] = m_ptr[k] / m_ptr[evp-1];
114 
115  } else {
116  for (k = 0; k < evp; k++)
117  ptr[k] = m_ptr[k];
118 
119  }
120  if (i == 0)
121  pdv_3move(fp, ptr);
122  else
123  pdv_3cont(fp, ptr);
124  m_ptr += evp;
125  }
126 }
127 
128 
129 /**
130  * Old routines included for backwards compat. Don't use in new code.
131  */
132 void rt_nurb_setfile(int n)
133 {
134  pl_color(stdout, n * 25 % 255, n * 50 % 255, n * 75 %255);
135 }
136 
137 
138 void
140 {
141 }
142 
143 
144 void rt_nurb_s_plot(const struct face_g_snurb *srf)
145 {
146  rt_nurb_plot_snurb(stdout, srf);
147 }
148 
149 
150 /*
151  * Local Variables:
152  * mode: C
153  * tab-width: 8
154  * indent-tabs-mode: t
155  * c-file-style: "stroustrup"
156  * End:
157  * ex: shiftwidth=4 tabstop=8
158  */
void pdv_3move(register FILE *plotfp, const fastf_t *pt)
Definition: plot3.c:618
Header file for the BRL-CAD common definitions.
void rt_nurb_closefile(void)
Definition: nurb_plot.c:139
void rt_nurb_plot_snurb(FILE *fp, const struct face_g_snurb *srf)
Definition: nurb_plot.c:41
void pdv_3cont(register FILE *plotfp, const fastf_t *pt)
Definition: plot3.c:630
void rt_nurb_s_plot(const struct face_g_snurb *srf)
Definition: nurb_plot.c:144
void pl_color(register FILE *plotfp, int r, int g, int b)
Definition: plot3.c:325
void rt_nurb_plot_cnurb(FILE *fp, const struct edge_g_cnurb *crv)
Definition: nurb_plot.c:102
double fastf_t
Definition: defines.h:300
void rt_nurb_setfile(int n)
Definition: nurb_plot.c:132