Blob Blame History Raw
diff -urp mathgl-2.1.2/src/pixel.cpp mathgl-2.1.2-stlerror/src/pixel.cpp
--- mathgl-2.1.2/src/pixel.cpp	2013-01-28 18:34:04.000000000 +0700
+++ mathgl-2.1.2-stlerror/src/pixel.cpp	2013-04-22 16:45:58.894481072 +0700
@@ -839,7 +839,6 @@ void mglCanvas::mark_draw(long k, char t
 #if MGL_HAVE_PTHREAD
 	pthread_mutex_lock(&mutexPnt);
 #endif
-	size_t pos = Pnt.size(), qos=pos;
 	if(type=='.' || ss==0)
 	{
 		if(d)	d->PenWidth = ss?ss:sqrt(font_factor/400);
@@ -847,6 +846,9 @@ void mglCanvas::mark_draw(long k, char t
 	}
 	else
 	{
+		if(type=='C')	pnt_draw(k,d);
+		std::vector<mglPnt> pnt = Pnt;	Pnt.clear();
+		long qos = 0;
 		if(d)
 		{
 			d->PDef = 0xffff;	d->PenWidth*=fabs(50*size);
@@ -857,10 +859,10 @@ void mglCanvas::mark_draw(long k, char t
 		{
 		case 'P':
 			p.x = q.x-ss;	p.y = q.y-ss;	Pnt.push_back(p);
-			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(pos,pos+1,d);
-			p.x = q.x+ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(pos+1,pos+2,d);
-			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(pos+2,pos+3,d);
-			line_draw(pos+3,pos,d);	qos+=4;
+			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(0,1,d);
+			p.x = q.x+ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(1,2,d);
+			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(2,3,d);
+			line_draw(3,0,d);	qos+=4;
 		case '+':
 			p.x = q.x-ss;	p.y = q.y;		Pnt.push_back(p);
 			p.x = q.x+ss;	p.y = q.y;		Pnt.push_back(p);	line_draw(qos,qos+1,d);
@@ -869,10 +871,10 @@ void mglCanvas::mark_draw(long k, char t
 			break;
 		case 'X':
 			p.x = q.x-ss;	p.y = q.y-ss;	Pnt.push_back(p);
-			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(pos,pos+1,d);
-			p.x = q.x+ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(pos+1,pos+2,d);
-			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(pos+2,pos+3,d);
-			line_draw(pos+3,pos,d);	qos+=4;
+			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(0,1,d);
+			p.x = q.x+ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(1,2,d);
+			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(2,3,d);
+			line_draw(3,0,d);	qos+=4;
 		case 'x':
 			p.x = q.x-ss;	p.y = q.y-ss;	Pnt.push_back(p);
 			p.x = q.x+ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
@@ -884,7 +886,7 @@ void mglCanvas::mark_draw(long k, char t
 			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);
 			p.x= q.x+ss;	p.y= q.y+ss;	Pnt.push_back(p);
 			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);
-			quad_draw(pos,pos+1,pos+3,pos+2,d);	qos+=4;
+			quad_draw(0,1,3,2,d);	qos+=4;
 		case 's':
 			p.x = q.x-ss;	p.y = q.y-ss;	Pnt.push_back(p);
 			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
@@ -896,7 +898,7 @@ void mglCanvas::mark_draw(long k, char t
 			p.x = q.x+ss;	p.y = q.y;		Pnt.push_back(p);
 			p.x= q.x;	p.y= q.y+ss;		Pnt.push_back(p);
 			p.x = q.x-ss;	p.y = q.y;		Pnt.push_back(p);
-			quad_draw(pos,pos+1,pos+3,pos+2,d);	qos+=4;
+			quad_draw(0,1,3,2,d);	qos+=4;
 		case 'd':
 			p.x = q.x;	p.y = q.y-ss;		Pnt.push_back(p);
 			p.x = q.x+ss;	p.y = q.y;		Pnt.push_back(p);	line_draw(qos,qos+1,d);
@@ -905,23 +907,23 @@ void mglCanvas::mark_draw(long k, char t
 			line_draw(qos+3,qos,d);	break;
 		case 'Y':
 			p.x = q.x;	p.y = q.y;			Pnt.push_back(p);
-			p.x = q.x;	p.y = q.y-ss;		Pnt.push_back(p);	line_draw(pos,pos+1,d);
-			p.x = q.x-0.8*ss;	p.y = q.y+0.6*ss;	Pnt.push_back(p);	line_draw(pos,pos+2,d);
-			p.x = q.x+0.8*ss;	p.y = q.y+0.6*ss;	Pnt.push_back(p);	line_draw(pos,pos+3,d);
+			p.x = q.x;	p.y = q.y-ss;		Pnt.push_back(p);	line_draw(0,1,d);
+			p.x = q.x-0.8*ss;	p.y = q.y+0.6*ss;	Pnt.push_back(p);	line_draw(0,2,d);
+			p.x = q.x+0.8*ss;	p.y = q.y+0.6*ss;	Pnt.push_back(p);	line_draw(0,3,d);
 			break;
 		case '*':
 			p.x = q.x-ss;		p.y = q.y;	Pnt.push_back(p);
-			p.x = q.x+ss;		p.y = q.y;	Pnt.push_back(p);	line_draw(pos,pos+1,d);
+			p.x = q.x+ss;		p.y = q.y;	Pnt.push_back(p);	line_draw(0,1,d);
 			p.x = q.x-0.6*ss;	p.y = q.y-0.8*ss;	Pnt.push_back(p);
-			p.x = q.x+0.6*ss;	p.y = q.y+0.8*ss;	Pnt.push_back(p);	line_draw(pos+2,pos+3,d);
+			p.x = q.x+0.6*ss;	p.y = q.y+0.8*ss;	Pnt.push_back(p);	line_draw(2,3,d);
 			p.x = q.x-0.6*ss;	p.y = q.y+0.8*ss;	Pnt.push_back(p);
-			p.x = q.x+0.6*ss;	p.y = q.y-0.8*ss;	Pnt.push_back(p);	line_draw(pos+4,pos+5,d);
+			p.x = q.x+0.6*ss;	p.y = q.y-0.8*ss;	Pnt.push_back(p);	line_draw(4,5,d);
 			break;
 		case 'T':
 			p.x = q.x-ss;	p.y = q.y-ss/2;	Pnt.push_back(p);
 			p.x = q.x+ss;	p.y = q.y-ss/2;	Pnt.push_back(p);
 			p.x= q.x;		p.y= q.y+ss;	Pnt.push_back(p);
-			trig_draw(pos,pos+1,pos+2,false,d);	qos+=3;
+			trig_draw(0,1,2,false,d);	qos+=3;
 		case '^':
 			p.x = q.x-ss;	p.y = q.y-ss/2;	Pnt.push_back(p);
 			p.x = q.x+ss;	p.y = q.y-ss/2;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
@@ -931,7 +933,7 @@ void mglCanvas::mark_draw(long k, char t
 			p.x = q.x-ss;	p.y = q.y+ss/2;	Pnt.push_back(p);
 			p.x = q.x+ss;	p.y = q.y+ss/2;	Pnt.push_back(p);
 			p.x= q.x;		p.y= q.y-ss;	Pnt.push_back(p);
-			trig_draw(pos,pos+1,pos+2,false,d);	qos+=3;
+			trig_draw(0,1,2,false,d);	qos+=3;
 		case 'v':
 			p.x = q.x-ss;	p.y = q.y+ss/2;	Pnt.push_back(p);
 			p.x = q.x+ss;	p.y = q.y+ss/2;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
@@ -941,7 +943,7 @@ void mglCanvas::mark_draw(long k, char t
 			p.x = q.x+ss/2;	p.y = q.y+ss;	Pnt.push_back(p);
 			p.x = q.x+ss/2;	p.y = q.y-ss;	Pnt.push_back(p);
 			p.x= q.x-ss;	p.y= q.y;		Pnt.push_back(p);
-			trig_draw(pos,pos+1,pos+2,false,d);	qos+=3;
+			trig_draw(0,1,2,false,d);	qos+=3;
 		case '<':
 			p.x = q.x+ss/2;	p.y = q.y+ss;	Pnt.push_back(p);
 			p.x = q.x+ss/2;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
@@ -951,7 +953,7 @@ void mglCanvas::mark_draw(long k, char t
 			p.x = q.x-ss/2;	p.y = q.y+ss;	Pnt.push_back(p);
 			p.x = q.x-ss/2;	p.y = q.y-ss;	Pnt.push_back(p);
 			p.x= q.x+ss;	p.y= q.y;		Pnt.push_back(p);
-			trig_draw(pos,pos+1,pos+2,false,d);	qos+=3;
+			trig_draw(0,1,2,false,d);	qos+=3;
 		case '>':
 			p.x = q.x-ss/2;	p.y = q.y+ss;	Pnt.push_back(p);
 			p.x = q.x-ss/2;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
@@ -968,19 +970,18 @@ void mglCanvas::mark_draw(long k, char t
 			for(i=0;i<=20;i++)
 			{
 				p.x = q.x+ss*cos(i*M_PI/10);	p.y = q.y+ss*sin(i*M_PI/10);	Pnt.push_back(p);
-				if(i>0)	line_draw(pos+i-1,pos+i,d);
+				if(i>0)	line_draw(i-1,i,d);
 			}
 			break;
 		case 'C':
-			pnt_draw(k,d);
 			for(i=0;i<=20;i++)
 			{
 				p.x = q.x+ss*cos(i*M_PI/10);	p.y = q.y+ss*sin(i*M_PI/10);	Pnt.push_back(p);
-				if(i>0)	line_draw(pos+i-1,pos+i,d);
+				if(i>0)	line_draw(i-1,i,d);
 			}
 			break;
 		}
-		Pnt.erase(Pnt.begin()+pos,Pnt.end());
+		Pnt = pnt;
 	}
 #if MGL_HAVE_PTHREAD
 	pthread_mutex_unlock(&mutexPnt);
@@ -1045,7 +1046,8 @@ void mglCanvas::glyph_draw(const mglPrim
 void mglCanvas::glyph_fill(const mglPnt &pp, mreal f, const mglGlyph &g, mglDrawReg *d)
 {
 	if(!g.trig || g.nt<=0)	return;
-	long ik,ii,pos=Pnt.size();
+	std::vector<mglPnt> pnt = Pnt;	Pnt.clear();
+	long ik,ii,jj=0;
 	mglPnt p=pp;	p.u=p.v=NAN;
 	mglPoint p1,p2,p3;
 	for(ik=0;ik<g.nt;ik++)
@@ -1056,15 +1058,16 @@ void mglCanvas::glyph_fill(const mglPnt
 		p.x = p1.x;	p.y = p1.y;	p.z = p1.z;	Pnt.push_back(p);
 		p.x = p2.x;	p.y = p2.y;	p.z = p2.z;	Pnt.push_back(p);
 		p.x = p3.x;	p.y = p3.y;	p.z = p3.z;	Pnt.push_back(p);
-		ii = Pnt.size()-3;	trig_draw(ii,ii+1,ii+2,false,d);
+		trig_draw(jj,jj+1,jj+2,false,d);	jj+=3;
 	}
-	Pnt.erase(Pnt.begin()+pos,Pnt.end());
+	Pnt = pnt;
 }
 //-----------------------------------------------------------------------------
 void mglCanvas::glyph_wire(const mglPnt &pp, mreal f, const mglGlyph &g, mglDrawReg *d)
 {
 	if(!g.line || g.nl<=0)	return;
-	long ik,ii,il=0,pos=Pnt.size();
+	long ik,ii,il=0,jj=0;
+	std::vector<mglPnt> pnt = Pnt;	Pnt.clear();
 	mglPnt p=pp;	p.u=p.v=NAN;
 	if(d)	{	d->PDef = 0xffff;	d->PenWidth=0.75;	}
 	mglPoint p1,p2;
@@ -1086,9 +1089,9 @@ void mglCanvas::glyph_wire(const mglPnt
 		PostScale(p1);	PostScale(p2);
 		p.x = p1.x;	p.y = p1.y;	p.z = p1.z;	Pnt.push_back(p);
 		p.x = p2.x;	p.y = p2.y;	p.z = p2.z;	Pnt.push_back(p);
-		ii = Pnt.size()-2;	line_draw(ii,ii+1,d);
+		line_draw(jj,jj+1,d);	jj+=2;
 	}
-	Pnt.erase(Pnt.begin()+pos,Pnt.end());
+	Pnt = pnt;
 }
 //-----------------------------------------------------------------------------
 void mglCanvas::glyph_line(const mglPnt &pp, mreal f, bool solid, mglDrawReg *d)
@@ -1096,7 +1099,7 @@ void mglCanvas::glyph_line(const mglPnt
 	mglPnt p=pp;	p.u=p.v=NAN;
 	if(d)	{	d->PDef = 0xffff;	d->PenWidth=1;	}
 	mglPoint p1,p2,p3,p4;
-	long pos=Pnt.size();
+	std::vector<mglPnt> pnt = Pnt;	Pnt.clear();
 
 	mreal dy = 0.004;
 	p1 = mglPoint(pp.u,pp.v-dy,0);	PostScale(p1);
@@ -1109,13 +1112,13 @@ void mglCanvas::glyph_line(const mglPnt
 	p.x = p3.x;	p.y = p3.y;	p.z = p3.z;	Pnt.push_back(p);
 	p.x = p4.x;	p.y = p4.y;	p.z = p4.z;	Pnt.push_back(p);
 
-	if(solid)	quad_draw(pos,pos+1,pos+3,pos+2,d);
+	if(solid)	quad_draw(0,1,3,2,d);
 	else
 	{
-		line_draw(pos,pos+1,d);	line_draw(pos+2,pos+1,d);
-		line_draw(pos,pos+3,d);	line_draw(pos+2,pos+3,d);
+		line_draw(0,1,d);	line_draw(2,1,d);
+		line_draw(0,3,d);	line_draw(2,3,d);
 	}
-	Pnt.erase(Pnt.begin()+pos,Pnt.end());
+	Pnt = pnt;
 }
 //-----------------------------------------------------------------------------
 long mglCanvas::setPp(mglPnt &q, const mglPoint &p)