The R Project SVN R

Rev

Rev 21061 | Rev 24735 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21061 Rev 21594
Line 673... Line 673...
673
		     SEGP* segmentDB, int nlines, SEXP container)
673
		     SEGP* segmentDB, int nlines, SEXP container)
674
{
674
{
675
    double xend, yend;
675
    double xend, yend;
676
    int i, ii, j, jj, ns, ns2, dir, nc;
676
    int i, ii, j, jj, ns, ns2, dir, nc;
677
    SEGP seglist, seg, s, start, end;
677
    SEGP seglist, seg, s, start, end;
678
    SEXP ctr, level, xsxp, ysxp;
678
    SEXP ctr, level, xsxp, ysxp, names;
679
    /* Begin following contours. */
679
    /* Begin following contours. */
680
    /* 1. Grab a segment */
680
    /* 1. Grab a segment */
681
    /* 2. Follow its tail */
681
    /* 2. Follow its tail */
682
    /* 3. Follow its head */
682
    /* 3. Follow its head */
683
    /* 4. Save the contour */
683
    /* 4. Save the contour */
Line 751... Line 751...
751
		REAL(xsxp)[ns] = s->x1;
751
		REAL(xsxp)[ns] = s->x1;
752
		REAL(ysxp)[ns] = s->y1;
752
		REAL(ysxp)[ns] = s->y1;
753
		SET_VECTOR_ELT(ctr, CONTOUR_LIST_X, xsxp);
753
		SET_VECTOR_ELT(ctr, CONTOUR_LIST_X, xsxp);
754
		SET_VECTOR_ELT(ctr, CONTOUR_LIST_Y, ysxp);
754
		SET_VECTOR_ELT(ctr, CONTOUR_LIST_Y, ysxp);
755
		/* 
755
		/* 
-
 
756
		 * Set the names attribute for the contour
-
 
757
		 * So that users can extract components using 
-
 
758
		 * meaningful names
-
 
759
		 */
-
 
760
		PROTECT(names = allocVector(STRSXP, 3));
-
 
761
		SET_STRING_ELT(names, 0, mkChar("level"));
-
 
762
		SET_STRING_ELT(names, 1, mkChar("x"));
-
 
763
		SET_STRING_ELT(names, 2, mkChar("y"));
-
 
764
		setAttrib(ctr, R_NamesSymbol, names);
-
 
765
		/* 
756
		 * We're about to add another line to the list ...
766
		 * We're about to add another line to the list ...
757
		 */
767
		 */
758
		nlines += 1;
768
		nlines += 1;
759
		nc = LENGTH(VECTOR_ELT(container, 0));
769
		nc = LENGTH(VECTOR_ELT(container, 0));
760
		if (nlines == nc)
770
		if (nlines == nc)
761
		    /* Where does this get UNPROTECTed? */
771
		    /* Where does this get UNPROTECTed? */
762
		    SET_VECTOR_ELT(container, 0, 
772
		    SET_VECTOR_ELT(container, 0, 
763
				   growList(VECTOR_ELT(container, 0)));
773
				   growList(VECTOR_ELT(container, 0)));
764
		SET_VECTOR_ELT(VECTOR_ELT(container, 0), nlines - 1, ctr);
774
		SET_VECTOR_ELT(VECTOR_ELT(container, 0), nlines - 1, ctr);
765
		UNPROTECT(4);
775
		UNPROTECT(5);
766
	    }
776
	    }
767
	}
777
	}
768
    return nlines;
778
    return nlines;
769
}
779
}
770
 
780