00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "common.h"
00041
00042
00043
00044 #include <stdio.h>
00045 #include "machine.h"
00046 #include "vmath.h"
00047 #include "nmg.h"
00048 #include "raytrace.h"
00049 #include "nurb.h"
00050
00051
00052
00053
00054
00055
00056
00057 struct face_g_snurb *
00058 rt_nurb_s_refine(const struct face_g_snurb *srf, int dir, struct knot_vector *kv, struct resource *res)
00059
00060
00061
00062
00063
00064 {
00065 register struct face_g_snurb * nurb_srf;
00066 struct oslo_mat *oslo;
00067 int i;
00068
00069 NMG_CK_SNURB(srf);
00070
00071 if (dir == RT_NURB_SPLIT_ROW) {
00072 GET_SNURB(nurb_srf);
00073 nurb_srf->order[0] = srf->order[0];
00074 nurb_srf->order[1] = srf->order[1];
00075
00076 rt_nurb_kvcopy(&nurb_srf->u, kv, res);
00077 rt_nurb_kvcopy(&nurb_srf->v, &srf->v, res);
00078
00079 nurb_srf->s_size[0] = srf->s_size[0];
00080 nurb_srf->s_size[1] = kv->k_size - srf->order[0];
00081 nurb_srf->pt_type = srf->pt_type;
00082 nurb_srf->ctl_points = (fastf_t *)
00083 bu_malloc( sizeof (fastf_t) *
00084 nurb_srf->s_size[0] *
00085 nurb_srf->s_size[1] *
00086 RT_NURB_EXTRACT_COORDS( nurb_srf->pt_type),
00087 "rt_nurb_s_refine: row mesh control points");
00088
00089 oslo = (struct oslo_mat *)
00090 rt_nurb_calc_oslo (srf -> order[RT_NURB_SPLIT_ROW], &srf->u, kv, res);
00091
00092 for( i = 0; i < nurb_srf->s_size[0]; i++)
00093 {
00094 fastf_t * old_mesh_ptr;
00095 fastf_t * new_mesh_ptr;
00096
00097 old_mesh_ptr = &srf->ctl_points[
00098 i * srf->s_size[1] *
00099 RT_NURB_EXTRACT_COORDS( srf->pt_type)];
00100 new_mesh_ptr = &nurb_srf->ctl_points[
00101 i * nurb_srf->s_size[1] *
00102 RT_NURB_EXTRACT_COORDS( nurb_srf->pt_type)];
00103 rt_nurb_map_oslo( oslo, old_mesh_ptr, new_mesh_ptr,
00104 RT_NURB_EXTRACT_COORDS( srf->pt_type ),
00105 RT_NURB_EXTRACT_COORDS( nurb_srf->pt_type ),
00106 0, kv->k_size - nurb_srf->order[0],
00107 nurb_srf->pt_type);
00108 }
00109
00110 rt_nurb_free_oslo(oslo, res);
00111
00112 } else {
00113 GET_SNURB(nurb_srf);
00114 nurb_srf->order[0] = srf->order[0];
00115 nurb_srf->order[1] = srf->order[1];
00116
00117 rt_nurb_kvcopy(&nurb_srf->u, &srf->u, res);
00118 rt_nurb_kvcopy(&nurb_srf->v, kv, res);
00119
00120 nurb_srf->s_size[0] = kv->k_size - srf->order[1];
00121 nurb_srf->s_size[1] = srf->s_size[1];
00122
00123 nurb_srf->pt_type = srf->pt_type;
00124 nurb_srf->ctl_points = (fastf_t *)
00125 bu_malloc( sizeof (fastf_t) *
00126 nurb_srf->s_size[0] *
00127 nurb_srf->s_size[1] *
00128 RT_NURB_EXTRACT_COORDS( nurb_srf->pt_type),
00129 "rt_nurb_s_refine: row mesh control points");
00130
00131 oslo = (struct oslo_mat *)
00132 rt_nurb_calc_oslo (srf->order[RT_NURB_SPLIT_COL], &srf->v, kv, res);
00133
00134 for( i = 0; i < nurb_srf->s_size[1]; i++)
00135 {
00136 fastf_t * old_mesh_ptr;
00137 fastf_t * new_mesh_ptr;
00138
00139 old_mesh_ptr = &srf->ctl_points[
00140 i * RT_NURB_EXTRACT_COORDS( srf->pt_type)];
00141 new_mesh_ptr = &nurb_srf->ctl_points[
00142 i * RT_NURB_EXTRACT_COORDS( nurb_srf->pt_type)];
00143 rt_nurb_map_oslo( oslo, old_mesh_ptr, new_mesh_ptr,
00144 srf->s_size[1] *
00145 RT_NURB_EXTRACT_COORDS( srf->pt_type ),
00146 nurb_srf->s_size[1] *
00147 RT_NURB_EXTRACT_COORDS( nurb_srf->pt_type ),
00148 0, kv->k_size - nurb_srf->order[1],
00149 nurb_srf->pt_type);
00150 }
00151 rt_nurb_free_oslo( oslo, res );
00152 }
00153 return nurb_srf;
00154 }
00155
00156 struct edge_g_cnurb *
00157 rt_nurb_c_refine(const struct edge_g_cnurb *crv, struct knot_vector *kv)
00158 {
00159 struct oslo_mat * oslo;
00160 struct edge_g_cnurb * new_crv;
00161 int i, coords;
00162
00163 NMG_CK_CNURB(crv);
00164
00165 coords = RT_NURB_EXTRACT_COORDS( crv->pt_type);
00166
00167 new_crv = ( struct edge_g_cnurb *) rt_nurb_new_cnurb(
00168 crv->order, kv->k_size, kv->k_size - crv->order,
00169 crv->pt_type);
00170
00171 oslo = (struct oslo_mat *) rt_nurb_calc_oslo(
00172 crv->order, &crv->k, kv, (struct resource *)NULL);
00173
00174 rt_nurb_map_oslo( oslo, crv->ctl_points,
00175 new_crv->ctl_points,
00176 coords, coords, 0,
00177 kv->k_size - new_crv->order,
00178 new_crv->pt_type);
00179
00180 new_crv->k.k_size = kv->k_size;
00181
00182 for( i = 0; i < kv->k_size; i++)
00183 new_crv->k.knots[i] = kv->knots[i];
00184
00185 rt_nurb_free_oslo( oslo, (struct resource *)NULL );
00186
00187 return new_crv;
00188 }
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198