static PyObject * vs_get_points(PyGimpVectorsStroke *self, void *closure) { double *controlpoints; int i, num_points; gboolean closed; PyObject *ret, *ret_points; gimp_vectors_stroke_get_points(self->vectors_ID, self->stroke, &num_points, &controlpoints, &closed); ret = PyTuple_New(2); if (ret == NULL) return NULL; ret_points = PyList_New(num_points); if (ret_points == NULL) { Py_DECREF(ret); return NULL; } for (i = 0; i < num_points; i++) PyList_SetItem(ret_points, i, PyFloat_FromDouble(controlpoints[i])); PyTuple_SetItem(ret, 0, ret_points); PyTuple_SetItem(ret, 1, PyBool_FromLong(closed)); return ret; }
/* ------------------------------------------ * p_capture_4_vector_points * ------------------------------------------ * capture the first 4 points of the 1st stroke in the active path vectors * pointOrder POINT_ORDER_MODE_31_42 : order 0,1,2,3 compatible with the exactAligner script * POINT_ORDER_MODE_21_43 : order 0,2,1,3 */ static gint p_capture_4_vector_points(gint32 imageId, AlingCoords *alingCoords, gint32 pointOrder) { gint32 activeVectorsId; PixelCoords *coordPtr[4]; gint ii; gint countVaildPoints; if (pointOrder == POINT_ORDER_MODE_31_42) { coordPtr[0] = &alingCoords->startCoords; coordPtr[1] = &alingCoords->startCoords2; coordPtr[2] = &alingCoords->currCoords; coordPtr[3] = &alingCoords->currCoords2; } else { coordPtr[0] = &alingCoords->startCoords; coordPtr[2] = &alingCoords->startCoords2; coordPtr[1] = &alingCoords->currCoords; coordPtr[3] = &alingCoords->currCoords2; } countVaildPoints = 0; for(ii=0; ii < 4; ii++) { coordPtr[ii]->px = -1; coordPtr[ii]->py = -1; coordPtr[ii]->valid = FALSE; } activeVectorsId = gimp_image_get_active_vectors(imageId); if(activeVectorsId >= 0) { gint num_strokes; gint *strokes; strokes = gimp_vectors_get_strokes (activeVectorsId, &num_strokes); if(strokes) { if(num_strokes > 0) { gdouble *points; gint num_points; gboolean closed; GimpVectorsStrokeType type; points = NULL; type = gimp_vectors_stroke_get_points(activeVectorsId, strokes[0], &num_points, &points, &closed); if(gap_debug) { gint ii; for(ii=0; ii < MIN(24, num_points); ii++) { printf ("point[%d] = %.3f\n", ii, points[ii]); } } if (type == GIMP_VECTORS_STROKE_TYPE_BEZIER) { if(num_points >= 6) { coordPtr[0]->px = points[0]; coordPtr[0]->py = points[1]; coordPtr[0]->valid = TRUE; countVaildPoints++; } if(num_points >= 12) { coordPtr[1]->px = points[6]; coordPtr[1]->py = points[7]; coordPtr[1]->valid = TRUE; countVaildPoints++; } if(num_points >= 18) { coordPtr[2]->px = points[12]; coordPtr[2]->py = points[13]; coordPtr[2]->valid = TRUE; countVaildPoints++; } if(num_points >= 24) { coordPtr[3]->px = points[18]; coordPtr[3]->py = points[19]; coordPtr[3]->valid = TRUE; countVaildPoints++; } } if(points) { g_free(points); } } g_free(strokes); } } return(countVaildPoints); } /* end p_capture_4_vector_points */
/* ------------------------------------------ * p_capture_2_vector_points * ------------------------------------------ * capture the first 2 points of the 1st stroke in the active path vectors */ static void p_capture_2_vector_points(gint32 imageId, PixelCoords *coordPtr, PixelCoords *coordPtr2) { gint32 activeVectorsId; gint32 gx1; gint32 gy1; gint32 gx2; gint32 gy2; gx1 = -1; gy1 = -1; gx2 = -1; gy2 = -1; activeVectorsId = gimp_image_get_active_vectors(imageId); if(activeVectorsId >= 0) { gint num_strokes; gint *strokes; strokes = gimp_vectors_get_strokes (activeVectorsId, &num_strokes); if(strokes) { if(num_strokes > 0) { gdouble *points; gint num_points; gboolean closed; GimpVectorsStrokeType type; points = NULL; type = gimp_vectors_stroke_get_points(activeVectorsId, strokes[0], &num_points, &points, &closed); if(gap_debug) { gint ii; for(ii=0; ii < MIN(12, num_points); ii++) { printf ("point[%d] = %.3f\n", ii, points[ii]); } } if (type == GIMP_VECTORS_STROKE_TYPE_BEZIER) { if(num_points >= 6) { gx1 = points[0]; gy1 = points[1]; } if(num_points >= 12) { gx2 = points[6]; gy2 = points[7]; } } if(points) { g_free(points); } } g_free(strokes); } } coordPtr->valid = FALSE; coordPtr2->valid = FALSE; if((gx1 >= 0) && (gy1 >= 0)) { if(gap_debug) { printf("\nPathPoints: x1=%d; y1=%d x2=%d; y2=%d\n" , gx1 , gy1 , gx2 , gy2 ); } coordPtr->px = gx1; coordPtr->py = gy1; coordPtr->valid = TRUE; if((gx2 != gx1) || (gy2 != gy1)) { if ((gx2 >= 0) && (gy2 >= 0)) { coordPtr2->px = gx2; coordPtr2->py = gy2; coordPtr2->valid = TRUE; } } } } /* end p_capture_2_vector_points */