[GRASS-SVN] r33536 - grass/trunk/lib/vector/diglib

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 25 07:41:09 EDT 2008


Author: martinl
Date: 2008-09-25 07:41:09 -0400 (Thu, 25 Sep 2008)
New Revision: 33536

Modified:
   grass/trunk/lib/vector/diglib/plus_line.c
Log:
vlib: Vect_restore_line() added (initial step towards vector digitizer undo) - update r33533
(merge from devbr6, r35535)


Modified: grass/trunk/lib/vector/diglib/plus_line.c
===================================================================
--- grass/trunk/lib/vector/diglib/plus_line.c	2008-09-25 11:40:11 UTC (rev 33535)
+++ grass/trunk/lib/vector/diglib/plus_line.c	2008-09-25 11:41:09 UTC (rev 33536)
@@ -17,34 +17,13 @@
 #include <stdlib.h>
 #include <grass/Vect.h>
 
-/*!
- * \brief Add new line to Plus_head structure.
- *
- * \param[in,out] plus pointer to Plus_head structure
- * \param[in] type feature type
- * \param[in] Points line geometry
- * \param[in] offset line offset
- *
- * \return -1 on error      
- * \return line id
- */
-int
-dig_add_line(struct Plus_head *plus, int type, struct line_pnts *Points,
-	     long offset)
+static int add_line(struct Plus_head *plus, int lineid, int type, struct line_pnts *Points,
+		    long offset)
 {
-    int lineid, node, lp;
+    int node, lp;
     P_LINE *line;
     BOUND_BOX box;
 
-    /* First look if we have space in array of pointers to lines
-     *  and reallocate if necessary */
-    if (plus->n_lines >= plus->alloc_lines) {	/* array is full */
-	if (dig_alloc_lines(plus, 1000) == -1)
-	    return -1;
-    }
-
-    /* allocate line structure */
-    lineid = plus->n_lines + 1;
     plus->Line[lineid] = dig_alloc_line();
     line = plus->Line[lineid];
 
@@ -98,6 +77,45 @@
     line->S = 0;
     line->E = 0;
     line->W = 0;
+
+    dig_line_box(Points, &box);
+    dig_line_set_box(plus, lineid, &box);
+    dig_spidx_add_line(plus, lineid, &box);
+    if (plus->do_uplist)
+	dig_line_add_updated(plus, lineid);
+
+    return (lineid);
+}
+
+/*!
+ * \brief Add new line to Plus_head structure.
+ *
+ * \param[in,out] plus pointer to Plus_head structure
+ * \param[in] type feature type
+ * \param[in] Points line geometry
+ * \param[in] offset line offset
+ *
+ * \return -1 on error      
+ * \return line id
+ */
+int
+dig_add_line(struct Plus_head *plus, int type, struct line_pnts *Points,
+	     long offset)
+{
+    int ret;
+    
+    /* First look if we have space in array of pointers to lines
+     *  and reallocate if necessary */
+    if (plus->n_lines >= plus->alloc_lines) {	/* array is full */
+	if (dig_alloc_lines(plus, 1000) == -1)
+	    return -1;
+    }
+
+    ret = add_line(plus, plus->n_lines + 1, type, Points, offset);
+
+    if (ret == -1)
+	return ret;
+
     plus->n_lines++;
 
     switch (type) {
@@ -121,13 +139,30 @@
 	break;
     }
 
-    dig_line_box(Points, &box);
-    dig_line_set_box(plus, lineid, &box);
-    dig_spidx_add_line(plus, lineid, &box);
-    if (plus->do_uplist)
-	dig_line_add_updated(plus, lineid);
+    return ret;
+}
 
-    return (lineid);
+/*!
+ * \brief Restore line in Plus_head structure.
+ *
+ * \param[in,out] plus pointer to Plus_head structure
+ * \param[in] type feature type
+ * \param[in] Points line geometry
+ * \param[in] offset line offset
+ *
+ * \return -1 on error      
+ * \return line id
+ */
+int
+dig_restore_line(struct Plus_head *plus, int lineid,
+		 int type, struct line_pnts *Points,
+		 long offset)
+{
+    if (lineid < 1 || lineid > plus->n_lines) {
+	return -1;
+    }
+
+    return add_line(plus, lineid, type, Points, offset);    
 }
 
 /*!



More information about the grass-commit mailing list