/* * Get the total number of points in the base sequence class */ static size_t get_real_point_count(const stp_curve_t *curve) { if (curve->piecewise) return stp_sequence_get_size(curve->seq) / 2; else return stp_sequence_get_size(curve->seq); }
/* * Recompute the delta values for interpolation. * When we actually do support spline curves, this routine will * compute the second derivatives for that purpose, too. */ static void compute_intervals(stp_curve_t *curve) { if (curve->interval) { stp_free(curve->interval); curve->interval = NULL; } if (stp_sequence_get_size(curve->seq) > 0) { switch (curve->curve_type) { case STP_CURVE_TYPE_SPLINE: compute_spline_deltas(curve); break; case STP_CURVE_TYPE_LINEAR: compute_linear_deltas(curve); break; } } curve->recompute_interval = 0; }
stp_array_t * stp_array_create_from_xmltree(stp_mxml_node_t *array) /* The array node */ { const char *stmp; /* Temporary string */ stp_mxml_node_t *child; /* Child sequence node */ int x_size, y_size; size_t count; stp_sequence_t *seq = NULL; stp_array_t *ret = NULL; stmp = stp_mxmlElementGetAttr(array, "x-size"); if (stmp) { x_size = (int) strtoul(stmp, NULL, 0); } else { stp_erprintf("stp_array_create_from_xmltree: \"x-size\" missing\n"); goto error; } /* Get y-size */ stmp = stp_mxmlElementGetAttr(array, "y-size"); if (stmp) { y_size = (int) strtoul(stmp, NULL, 0); } else { stp_erprintf("stp_array_create_from_xmltree: \"y-size\" missing\n"); goto error; } /* Get the sequence data */ child = stp_mxmlFindElement(array, array, "sequence", NULL, NULL, STP_MXML_DESCEND); if (child) seq = stp_sequence_create_from_xmltree(child); if (seq == NULL) goto error; ret = stp_array_create(x_size, y_size); if (ret->data) stp_sequence_destroy(ret->data); ret->data = seq; count = stp_sequence_get_size(seq); if (count != (x_size * y_size)) { stp_erprintf("stp_array_create_from_xmltree: size mismatch between array and sequence\n"); goto error; } return ret; error: stp_erprintf("stp_array_create_from_xmltree: error during array read\n"); if (ret) stp_array_destroy(ret); return NULL; }