Dmitrij S. Kryzhevich b35340c
diff -urp mathgl-2.1.2/include/mgl2/canvas.h mathgl-2.1.2-stlerror/include/mgl2/canvas.h
Dmitrij S. Kryzhevich b35340c
--- mathgl-2.1.2/include/mgl2/canvas.h	2013-01-28 18:33:59.000000000 +0700
Dmitrij S. Kryzhevich b35340c
+++ mathgl-2.1.2-stlerror/include/mgl2/canvas.h	2013-04-23 09:33:14.801413395 +0700
Dmitrij S. Kryzhevich b35340c
@@ -373,15 +373,15 @@ protected:
Dmitrij S. Kryzhevich b35340c
 	mreal text_plot(long p,const wchar_t *text,const char *fnt,mreal size=-1,mreal sh=0,mreal  col=-('k'), bool rot=true);
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 	void add_prim(mglPrim &a);	///< add primitive to list
Dmitrij S. Kryzhevich b35340c
-	void mark_draw(long p, char type, mreal size, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
-	void arrow_draw(long p1, long p2, char st, mreal size, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
-	virtual void line_draw(long p1, long p2, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
-	virtual void trig_draw(long p1, long p2, long p3, bool anorm, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
-	virtual void quad_draw(long p1, long p2, long p3, long p4, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
-	virtual void pnt_draw(long p, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    void mark_draw(const mglPnt &p, char type, mreal size, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    void arrow_draw(const mglPnt &p1, const mglPnt &p2, char st, mreal size, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    virtual void line_draw(const mglPnt &p1, const mglPnt &p2, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    virtual void trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    virtual void quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    virtual void pnt_draw(const mglPnt &p, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
 	void arrow_draw(long n1, long n2, char st, float ll);
Dmitrij S. Kryzhevich b35340c
-	void arrow_plot_3d(long p1, long p2, char st, float ll);
Dmitrij S. Kryzhevich b35340c
-	void glyph_draw(const mglPrim *P, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    void arrow_plot_3d(long n1, long n2, char st, float ll);
Dmitrij S. Kryzhevich b35340c
+    void glyph_draw(const mglPrim &P, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
 	bool IsSame(const mglPrim &pr,mreal wp,mglColor cp,int st);
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 	// restore normalized coordinates from screen ones
Dmitrij S. Kryzhevich b35340c
@@ -425,7 +425,7 @@ private:
Dmitrij S. Kryzhevich b35340c
 	/// Combine colors in 2 plane.
Dmitrij S. Kryzhevich b35340c
 	void combine(unsigned char *c1, const unsigned char *c2);
Dmitrij S. Kryzhevich b35340c
 	/// Fast drawing of line between 2 points
Dmitrij S. Kryzhevich b35340c
-	void fast_draw(long p1, long p2, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    void fast_draw(const mglPnt &p1, const mglPnt &p2, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 	/// Additionally scale points p for positioning in image
Dmitrij S. Kryzhevich b35340c
 	void PostScale(mglPoint &p) const;
Dmitrij S. Kryzhevich b35340c
diff -urp mathgl-2.1.2/include/mgl2/opengl.h mathgl-2.1.2-stlerror/include/mgl2/opengl.h
Dmitrij S. Kryzhevich b35340c
--- mathgl-2.1.2/include/mgl2/opengl.h	2013-01-28 18:33:59.000000000 +0700
Dmitrij S. Kryzhevich b35340c
+++ mathgl-2.1.2-stlerror/include/mgl2/opengl.h	2013-04-23 09:34:13.701604344 +0700
Dmitrij S. Kryzhevich b35340c
@@ -45,10 +45,15 @@ public:
Dmitrij S. Kryzhevich b35340c
 	void Clf(mglColor Back=WC);
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 protected:
Dmitrij S. Kryzhevich b35340c
-	void line_draw(long p1, long p2, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
-	void trig_draw(long p1, long p2, long p3, bool anorm, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
-	void quad_draw(long p1, long p2, long p3, long p4, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
-	void pnt_draw(long p, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    // provide fastest variant for usual points (not glyphs or marks)
Dmitrij S. Kryzhevich b35340c
+    void line_draw(long n1, long n2);
Dmitrij S. Kryzhevich b35340c
+    void trig_draw(long n1, long n2, long n3);
Dmitrij S. Kryzhevich b35340c
+    void quad_draw(long n1, long n2, long n3, long n4);
Dmitrij S. Kryzhevich b35340c
+    // variant for glyphs or marks
Dmitrij S. Kryzhevich b35340c
+    void line_draw(const mglPnt &p1, const mglPnt &p2, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    void trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    void quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
+    void pnt_draw(const mglPnt &p, mglDrawReg *d);
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 	unsigned char **GetRGBLines(long &w, long &h, unsigned char *&f, bool solid=true);
Dmitrij S. Kryzhevich b35340c
 	void LightScale();
Dmitrij S. Kryzhevich b35340c
diff -urp mathgl-2.1.2/src/canvas.cpp mathgl-2.1.2-stlerror/src/canvas.cpp
Dmitrij S. Kryzhevich b35340c
--- mathgl-2.1.2/src/canvas.cpp	2013-01-28 18:34:04.000000000 +0700
Dmitrij S. Kryzhevich b35340c
+++ mathgl-2.1.2-stlerror/src/canvas.cpp	2013-04-23 09:57:19.486537407 +0700
Dmitrij S. Kryzhevich b35340c
@@ -301,7 +301,7 @@ mreal mglCanvas::GetOrgZ(char dir) const
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
 //	Put primitives
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-#define MGL_MARK_PLOT	if(Quality&4)	mark_draw(p,type,size,&d);else	\
Dmitrij S. Kryzhevich b35340c
+#define MGL_MARK_PLOT   if(Quality&4)   mark_draw(Pnt[p],type,size,&d);else \
Dmitrij S. Kryzhevich b35340c
 						{	mglPrim a;	a.w = pw;	a.s = size;	\
Dmitrij S. Kryzhevich b35340c
 							a.n1 = p;	a.n4 = type;	add_prim(a);	}
Dmitrij S. Kryzhevich b35340c
 void mglCanvas::mark_plot(long p, char type, mreal size)
Dmitrij S. Kryzhevich b35340c
@@ -322,13 +322,14 @@ void mglCanvas::mark_plot(long p, char t
Dmitrij S. Kryzhevich b35340c
 	else	{	MGL_MARK_PLOT	}
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-#define MGL_LINE_PLOT	if(Quality&4)	line_draw(p1,p2,&dd);else	\
Dmitrij S. Kryzhevich b35340c
+#define MGL_LINE_PLOT   if(Quality&4)   line_draw(Pnt[p1],Pnt[p2],&dd);else \
Dmitrij S. Kryzhevich b35340c
 						{	mglPrim a(1);	a.n3=PDef;	a.s = pPos;	\
Dmitrij S. Kryzhevich b35340c
 							a.n1 = p1;	a.n2 = p2;	a.w = pw;	add_prim(a);	}
Dmitrij S. Kryzhevich b35340c
 void mglCanvas::line_plot(long p1, long p2)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
 	if(PDef==0)	return;
Dmitrij S. Kryzhevich b35340c
 	if(p1<0 || p2<0 || mgl_isnan(Pnt[p1].x) || mgl_isnan(Pnt[p2].x))	return;
Dmitrij S. Kryzhevich b35340c
+    if(p1>p2)   {   long kk=p1; p1=p2;  p2=kk;  }   // rearrange start/end for proper dashing
Dmitrij S. Kryzhevich b35340c
 	long pp1=p1,pp2=p2;
Dmitrij S. Kryzhevich b35340c
 	mreal pw = fabs(PenWidth)*sqrt(font_factor/400), d;
Dmitrij S. Kryzhevich b35340c
 	d = hypot(Pnt[p1].x-Pnt[p2].x, Pnt[p1].y-Pnt[p2].y);
Dmitrij S. Kryzhevich b35340c
@@ -344,7 +345,7 @@ void mglCanvas::line_plot(long p1, long
Dmitrij S. Kryzhevich b35340c
 	pPos = fmod(pPos+d/pw/1.5, 16);
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-#define MGL_TRIG_PLOT	if(Quality&4)	trig_draw(p1,p2,p3,true,&d);else	\
Dmitrij S. Kryzhevich b35340c
+#define MGL_TRIG_PLOT   if(Quality&4)   trig_draw(Pnt[p1],Pnt[p2],Pnt[p3],true,&d);else \
Dmitrij S. Kryzhevich b35340c
 						{	mglPrim a(2);	a.n1 = p1;	a.n2 = p2;	\
Dmitrij S. Kryzhevich b35340c
 							a.n3 = p3;	add_prim(a);}
Dmitrij S. Kryzhevich b35340c
 void mglCanvas::trig_plot(long p1, long p2, long p3)
Dmitrij S. Kryzhevich b35340c
@@ -358,7 +359,7 @@ void mglCanvas::trig_plot(long p1, long
Dmitrij S. Kryzhevich b35340c
 	else	{	MGL_TRIG_PLOT	}
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-#define MGL_QUAD_PLOT	if(Quality&4)	quad_draw(p1,p2,p3,p4,&d);else	\
Dmitrij S. Kryzhevich b35340c
+#define MGL_QUAD_PLOT   if(Quality&4)   quad_draw(Pnt[p1],Pnt[p2],Pnt[p3],Pnt[p4],&d);else  \
Dmitrij S. Kryzhevich b35340c
 						{	mglPrim a(3);	a.n1 = p1;	a.n2 = p2;	\
Dmitrij S. Kryzhevich b35340c
 							a.n3 = p3;	a.n4 = p4;	add_prim(a);	}
Dmitrij S. Kryzhevich b35340c
 void mglCanvas::quad_plot(long p1, long p2, long p3, long p4)
Dmitrij S. Kryzhevich b35340c
@@ -480,7 +481,7 @@ void mglCanvas::Glyph(mreal x, mreal y,
Dmitrij S. Kryzhevich b35340c
 	d.PDef = s;		d.pPos = a.s;
Dmitrij S. Kryzhevich b35340c
 	d.ObjId=ObjId;	d.PenWidth=a.w;
Dmitrij S. Kryzhevich b35340c
 	
Dmitrij S. Kryzhevich b35340c
-	if(Quality&4)	glyph_draw(&a,&d);
Dmitrij S. Kryzhevich b35340c
+	if(Quality&4)   glyph_draw(a,&d);
Dmitrij S. Kryzhevich b35340c
 	else	add_prim(a);
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
@@ -708,6 +709,7 @@ void mglCanvas::AddLight(int n, mglPoint
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
 void mglCanvas::arrow_plot(long n1, long n2, char st)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
+    if(n1<0 || n2<0 || !strchr("AVKSDTIO",st))  return;
Dmitrij S. Kryzhevich b35340c
 	float ll = PenWidth*ArrowSize*0.35*font_factor;
Dmitrij S. Kryzhevich b35340c
 	if((Quality&3)==3)
Dmitrij S. Kryzhevich b35340c
 		arrow_plot_3d(n1, n2, st, ll);
Dmitrij S. Kryzhevich b35340c
diff -urp mathgl-2.1.2/src/opengl.cpp mathgl-2.1.2-stlerror/src/opengl.cpp
Dmitrij S. Kryzhevich b35340c
--- mathgl-2.1.2/src/opengl.cpp	2013-01-28 18:34:04.000000000 +0700
Dmitrij S. Kryzhevich b35340c
+++ mathgl-2.1.2-stlerror/src/opengl.cpp	2013-04-23 11:09:18.381161728 +0700
Dmitrij S. Kryzhevich b35340c
@@ -41,11 +41,11 @@ void mglCanvasGL::Finish(bool fast)
Dmitrij S. Kryzhevich b35340c
 			p=Prm[i];	PDef=p.n3;	pPos=p.s;	PenWidth=p.w;
Dmitrij S. Kryzhevich b35340c
 			switch(p.type)
Dmitrij S. Kryzhevich b35340c
 			{
Dmitrij S. Kryzhevich b35340c
-			case 0:	mark_draw(p.n1,p.n4,p.s,0);	break;
Dmitrij S. Kryzhevich b35340c
-			case 1:	line_draw(p.n1,p.n2,0);		break;
Dmitrij S. Kryzhevich b35340c
-			case 2:	trig_draw(p.n1,p.n2,p.n3,true,0);	break;
Dmitrij S. Kryzhevich b35340c
-			case 3:	quad_draw(p.n1,p.n2,p.n3,p.n4,0);	break;
Dmitrij S. Kryzhevich b35340c
-			case 4:	glyph_draw(&p,0);	break;
Dmitrij S. Kryzhevich b35340c
+            case 0: mark_draw(Pnt[p.n1],p.n4,p.s,0);    break;
Dmitrij S. Kryzhevich b35340c
+            case 1: line_draw(p.n1,p.n2);   break;
Dmitrij S. Kryzhevich b35340c
+            case 2: trig_draw(p.n1,p.n2,p.n3);  break;
Dmitrij S. Kryzhevich b35340c
+            case 3: quad_draw(p.n1,p.n2,p.n3,p.n4); break;
Dmitrij S. Kryzhevich b35340c
+            case 4: glyph_draw(p,0);    break;
Dmitrij S. Kryzhevich b35340c
 			}
Dmitrij S. Kryzhevich b35340c
 		}
Dmitrij S. Kryzhevich b35340c
 		PDef=pdef;	pPos=ss;	PenWidth=ww;
Dmitrij S. Kryzhevich b35340c
@@ -231,26 +231,24 @@ unsigned char **mglCanvasGL::GetRGBLines
Dmitrij S. Kryzhevich b35340c
 	return p;
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-void mglCanvasGL::trig_draw(long k1, long k2, long k3, bool, mglDrawReg *)
Dmitrij S. Kryzhevich b35340c
+void mglCanvasGL::quad_draw(long k1, long k2, long k3, long k4)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	if(k1<0 || k2<0 || k3<0)	return;
Dmitrij S. Kryzhevich b35340c
-	glBegin(GL_TRIANGLES);
Dmitrij S. Kryzhevich b35340c
-	glArrayElement(k1);	glArrayElement(k2);	glArrayElement(k3);
Dmitrij S. Kryzhevich b35340c
+    glBegin(GL_QUADS);
Dmitrij S. Kryzhevich b35340c
+    glArrayElement(k1); glArrayElement(k2);
Dmitrij S. Kryzhevich b35340c
+    glArrayElement(k4); glArrayElement(k3);
Dmitrij S. Kryzhevich b35340c
 	glEnd();
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-void mglCanvasGL::quad_draw(long k1, long k2, long k3, long k4, mglDrawReg *)
Dmitrij S. Kryzhevich b35340c
+void mglCanvasGL::trig_draw(long k1, long k2, long k3)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	if(k1<0 || k2<0 || k3<0 || k4<0)	return;
Dmitrij S. Kryzhevich b35340c
-	glBegin(GL_QUADS);
Dmitrij S. Kryzhevich b35340c
-	glArrayElement(k1);	glArrayElement(k2);
Dmitrij S. Kryzhevich b35340c
-	glArrayElement(k4);	glArrayElement(k3);
Dmitrij S. Kryzhevich b35340c
+    glBegin(GL_TRIANGLES);
Dmitrij S. Kryzhevich b35340c
+    glArrayElement(k1); glArrayElement(k2); glArrayElement(k3);
Dmitrij S. Kryzhevich b35340c
 	glEnd();
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-void mglCanvasGL::line_draw(long k1, long k2, mglDrawReg *)
Dmitrij S. Kryzhevich b35340c
+void mglCanvasGL::line_draw(long k1, long k2)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	if(k1<0 || k2<0 || PDef==0)	return;
Dmitrij S. Kryzhevich b35340c
+	if(PDef==0) return;
Dmitrij S. Kryzhevich b35340c
 /*	unsigned pdef = PDef*0x10001;
Dmitrij S. Kryzhevich b35340c
 	pdef = pdef << (int(100*pPos+0.5)%16);
Dmitrij S. Kryzhevich b35340c
 	set_pen(pdef&0xffff,PenWidth);*/
Dmitrij S. Kryzhevich b35340c
@@ -260,12 +258,39 @@ void mglCanvasGL::line_draw(long k1, lon
Dmitrij S. Kryzhevich b35340c
 	glEnd();
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-void mglCanvasGL::pnt_draw(long k1, mglDrawReg *)
Dmitrij S. Kryzhevich b35340c
+void mglCanvasGL::quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, mglDrawReg *)
Dmitrij S. Kryzhevich b35340c
+{
Dmitrij S. Kryzhevich b35340c
+    glBegin(GL_QUADS);
Dmitrij S. Kryzhevich b35340c
+    glNormal3f(p1.u,p1.v,p1.w); glColor4f(p1.r,p1.g,p1.b,p1.a); glVertex3f(p1.x,p1.y,p1.z);
Dmitrij S. Kryzhevich b35340c
+    glNormal3f(p2.u,p2.v,p2.w); glColor4f(p2.r,p2.g,p2.b,p2.a); glVertex3f(p2.x,p2.y,p2.z);
Dmitrij S. Kryzhevich b35340c
+    glNormal3f(p3.u,p3.v,p3.w); glColor4f(p3.r,p3.g,p3.b,p3.a); glVertex3f(p3.x,p3.y,p3.z);
Dmitrij S. Kryzhevich b35340c
+    glNormal3f(p4.u,p4.v,p4.w); glColor4f(p4.r,p4.g,p4.b,p4.a); glVertex3f(p4.x,p4.y,p4.z);
Dmitrij S. Kryzhevich b35340c
+    glEnd();
Dmitrij S. Kryzhevich b35340c
+}
Dmitrij S. Kryzhevich b35340c
+//-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
+void mglCanvasGL::trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool, mglDrawReg *)
Dmitrij S. Kryzhevich b35340c
+{
Dmitrij S. Kryzhevich b35340c
+    glBegin(GL_TRIANGLES);
Dmitrij S. Kryzhevich b35340c
+    glNormal3f(p1.u,p1.v,p1.w); glColor4f(p1.r,p1.g,p1.b,p1.a); glVertex3f(p1.x,p1.y,p1.z);
Dmitrij S. Kryzhevich b35340c
+    glNormal3f(p2.u,p2.v,p2.w); glColor4f(p2.r,p2.g,p2.b,p2.a); glVertex3f(p2.x,p2.y,p2.z);
Dmitrij S. Kryzhevich b35340c
+    glNormal3f(p3.u,p3.v,p3.w); glColor4f(p3.r,p3.g,p3.b,p3.a); glVertex3f(p3.x,p3.y,p3.z);
Dmitrij S. Kryzhevich b35340c
+    glEnd();
Dmitrij S. Kryzhevich b35340c
+}
Dmitrij S. Kryzhevich b35340c
+//-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
+void mglCanvasGL::line_draw(const mglPnt &p1, const mglPnt &p2, mglDrawReg *)
Dmitrij S. Kryzhevich b35340c
+{
Dmitrij S. Kryzhevich b35340c
+    if(PDef==0) return;
Dmitrij S. Kryzhevich b35340c
+    set_pen(PDef,PenWidth);
Dmitrij S. Kryzhevich b35340c
+    glBegin(GL_LINES);
Dmitrij S. Kryzhevich b35340c
+    glColor4f(p1.r,p1.g,p1.b,p1.a); glVertex3f(p1.x,p1.y,p1.z);
Dmitrij S. Kryzhevich b35340c
+    glColor4f(p2.r,p2.g,p2.b,p2.a); glVertex3f(p2.x,p2.y,p2.z);
Dmitrij S. Kryzhevich b35340c
+    glEnd();
Dmitrij S. Kryzhevich b35340c
+}
Dmitrij S. Kryzhevich b35340c
+//-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
+void mglCanvasGL::pnt_draw(const mglPnt &p1, mglDrawReg *)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	if(k1<0)	return;
Dmitrij S. Kryzhevich b35340c
 	glBegin(GL_POINTS);
Dmitrij S. Kryzhevich b35340c
-	glArrayElement(k1);
Dmitrij S. Kryzhevich b35340c
+	glColor4f(p1.r,p1.g,p1.b,p1.a); glVertex3f(p1.x,p1.y,p1.z);
Dmitrij S. Kryzhevich b35340c
 	glEnd();
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-
Dmitrij S. Kryzhevich fefea00
diff -urp mathgl-2.1.2/src/pixel.cpp mathgl-2.1.2-stlerror/src/pixel.cpp
Dmitrij S. Kryzhevich fefea00
--- mathgl-2.1.2/src/pixel.cpp	2013-01-28 18:34:04.000000000 +0700
Dmitrij S. Kryzhevich b35340c
+++ mathgl-2.1.2-stlerror/src/pixel.cpp	2013-04-23 10:34:47.308501443 +0700
Dmitrij S. Kryzhevich b35340c
@@ -304,11 +304,11 @@ void mglCanvas::pxl_primdr(size_t id, si
Dmitrij S. Kryzhevich b35340c
 		d.ObjId = p.id;	d.PenWidth=p.w;
Dmitrij S. Kryzhevich b35340c
 		switch(p.type)
Dmitrij S. Kryzhevich b35340c
 		{
Dmitrij S. Kryzhevich b35340c
-		case 0:	mark_draw(p.n1,p.n4,p.s,&d);	break;
Dmitrij S. Kryzhevich b35340c
-		case 1:	line_draw(p.n1,p.n2,&d);		break;
Dmitrij S. Kryzhevich b35340c
-		case 2:	trig_draw(p.n1,p.n2,p.n3,true,&d);	break;
Dmitrij S. Kryzhevich b35340c
-		case 3:	quad_draw(p.n1,p.n2,p.n3,p.n4,&d);	break;
Dmitrij S. Kryzhevich b35340c
-		case 4:	glyph_draw(&p,&d);	break;
Dmitrij S. Kryzhevich b35340c
+        case 0: mark_draw(Pnt[p.n1],p.n4,p.s,&d);   break;
Dmitrij S. Kryzhevich b35340c
+        case 1: line_draw(Pnt[p.n1],Pnt[p.n2],&d);      break;
Dmitrij S. Kryzhevich b35340c
+        case 2: trig_draw(Pnt[p.n1],Pnt[p.n2],Pnt[p.n3],true,&d);   break;
Dmitrij S. Kryzhevich b35340c
+        case 3: quad_draw(Pnt[p.n1],Pnt[p.n2],Pnt[p.n3],Pnt[p.n4],&d);  break;
Dmitrij S. Kryzhevich b35340c
+        case 4: glyph_draw(p,&d);   break;
Dmitrij S. Kryzhevich b35340c
 		}
Dmitrij S. Kryzhevich b35340c
 	}
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
@@ -586,17 +586,16 @@ unsigned char **mglCanvas::GetRGBLines(l
Dmitrij S. Kryzhevich b35340c
 /* Bilinear interpolation r(u,v) = r0 + (r1-r0)*u + (r2-r0)*v + (r3+r0-r1-r2)*u*v
Dmitrij S. Kryzhevich b35340c
 	is used (where r is one of {x,y,z,R,G,B,A}. Variables u,v are determined
Dmitrij S. Kryzhevich b35340c
 	for each point (x,y) and selected one pair which 0
Dmitrij S. Kryzhevich b35340c
-void mglCanvas::quad_draw(long k1, long k2, long k3, long k4, mglDrawReg *d)
Dmitrij S. Kryzhevich b35340c
+void mglCanvas::quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, mglDrawReg *d)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
 	if(!(Quality&3))
Dmitrij S. Kryzhevich b35340c
 	{
Dmitrij S. Kryzhevich b35340c
-		fast_draw(k1,k2,d);	fast_draw(k1,k3,d);
Dmitrij S. Kryzhevich b35340c
-		fast_draw(k4,k2,d);	fast_draw(k4,k3,d);	return;
Dmitrij S. Kryzhevich b35340c
+        fast_draw(p1,p2,d); fast_draw(p1,p3,d);
Dmitrij S. Kryzhevich b35340c
+        fast_draw(p4,p2,d); fast_draw(p4,p3,d); return;
Dmitrij S. Kryzhevich b35340c
 	}
Dmitrij S. Kryzhevich b35340c
 	unsigned char r[4];
Dmitrij S. Kryzhevich b35340c
 	long y1,x1,y2,x2;
Dmitrij S. Kryzhevich b35340c
 	float dd,dsx,dsy;
Dmitrij S. Kryzhevich b35340c
-	const mglPnt &p1=Pnt[k1], &p2=Pnt[k2], &p3=Pnt[k3], &p4=Pnt[k4];
Dmitrij S. Kryzhevich b35340c
 	mglPnt d1=p2-p1, d2=p3-p1, d3=p4+p1-p2-p3, p;
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 	x1 = long(fmin(fmin(p1.x,p2.x),fmin(p3.x,p4.x)));	// bounding box
Dmitrij S. Kryzhevich b35340c
@@ -612,7 +611,7 @@ void mglCanvas::quad_draw(long k1, long
Dmitrij S. Kryzhevich b35340c
 	dsy = 4*(d2.y*d3.x - d2.x*d3.y)*d1.x;
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 	if((d1.x==0 && d1.y==0) || (d2.x==0 && d2.y==0) || !(Quality&2))
Dmitrij S. Kryzhevich b35340c
-	{	trig_draw(k1,k2,k4,true,d);	trig_draw(k1,k3,k4,true,d);	return;	}
Dmitrij S. Kryzhevich b35340c
+	{   trig_draw(p1,p2,p4,true,d); trig_draw(p1,p3,p4,true,d); return; }
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 	mglPoint n1 = mglPoint(p2.x-p1.x,p2.y-p1.y,p2.z-p1.z)^mglPoint(p3.x-p1.x,p3.y-p1.y,p3.z-p1.z);
Dmitrij S. Kryzhevich b35340c
 	mglPoint n2 = mglPoint(p2.x-p4.x,p2.y-p4.y,p2.z-p4.z)^mglPoint(p3.x-p4.x,p3.y-p4.y,p3.z-p4.z);
Dmitrij S. Kryzhevich b35340c
@@ -657,17 +656,16 @@ void mglCanvas::quad_draw(long k1, long
Dmitrij S. Kryzhevich b35340c
 /* Linear interpolation r(u,v) = r0 + (r1-r0)*u + (r2-r0)*v is used, where r is
Dmitrij S. Kryzhevich b35340c
 	one of {x,y,z,R,G,B,A}. Variables u,v are determined for each point (x,y).
Dmitrij S. Kryzhevich b35340c
 	Point plotted is u>0 and v>0 and u+v<1.*/
Dmitrij S. Kryzhevich b35340c
-void mglCanvas::trig_draw(long k1, long k2, long k3, bool anorm, mglDrawReg *d)
Dmitrij S. Kryzhevich b35340c
+void mglCanvas::trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, mglDrawReg *d)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
 	if(!(Quality&3))
Dmitrij S. Kryzhevich b35340c
 	{
Dmitrij S. Kryzhevich b35340c
-		fast_draw(k1,k2,d);	fast_draw(k1,k3,d);
Dmitrij S. Kryzhevich b35340c
-		fast_draw(k2,k3,d);	return;
Dmitrij S. Kryzhevich b35340c
+        fast_draw(p1,p2,d); fast_draw(p1,p3,d);
Dmitrij S. Kryzhevich b35340c
+        fast_draw(p2,p3,d); return;
Dmitrij S. Kryzhevich b35340c
 	}
Dmitrij S. Kryzhevich b35340c
 	unsigned char r[4];
Dmitrij S. Kryzhevich b35340c
 	long y1,x1,y2,x2;
Dmitrij S. Kryzhevich b35340c
 	float dxu,dxv,dyu,dyv;
Dmitrij S. Kryzhevich b35340c
-	const mglPnt &p1=Pnt[k1], &p2=Pnt[k2], &p3=Pnt[k3];
Dmitrij S. Kryzhevich b35340c
 	mglPnt d1=p2-p1, d2=p3-p1, p;
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 	dxu = d2.x*d1.y - d1.x*d2.y;
Dmitrij S. Kryzhevich b35340c
@@ -704,10 +702,9 @@ void mglCanvas::trig_draw(long k1, long
Dmitrij S. Kryzhevich b35340c
 	}
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-void mglCanvas::line_draw(long k1, long k2, mglDrawReg *dr)
Dmitrij S. Kryzhevich b35340c
+void mglCanvas::line_draw(const mglPnt &p1, const mglPnt &p2, mglDrawReg *dr)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	if(k1>k2)	{	long kk=k1;	k1=k2;	k2=kk;	}	// rearrange start/end for proper dashing
Dmitrij S. Kryzhevich b35340c
-	if(!(Quality&3))	{	fast_draw(k1,k2,dr);	return;	}
Dmitrij S. Kryzhevich b35340c
+	if(!(Quality&3))    {   fast_draw(p1,p2,dr);    return; }
Dmitrij S. Kryzhevich b35340c
 	unsigned char r[4];
Dmitrij S. Kryzhevich b35340c
 	long y1,x1,y2,x2;
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
@@ -715,7 +712,6 @@ void mglCanvas::line_draw(long k1, long
Dmitrij S. Kryzhevich b35340c
 	float dz = Width>2 ? 1 : 1e-5*Width;		// provide additional height to be well visible on the surfaces
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
 	if(dr->ObjId==HighId)	{	pw *= 2;	dpw=2;	}
Dmitrij S. Kryzhevich b35340c
-	const mglPnt &p1=Pnt[k1], &p2=Pnt[k2];
Dmitrij S. Kryzhevich b35340c
 	mglPnt d=p2-p1, p;
Dmitrij S. Kryzhevich b35340c
 	bool hor = fabs(d.x)>fabs(d.y);
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
@@ -777,9 +773,8 @@ void mglCanvas::line_draw(long k1, long
Dmitrij S. Kryzhevich b35340c
 	set(aa,MGL_ENABLE_ALPHA);
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-void mglCanvas::fast_draw(long k1, long k2, mglDrawReg *dr)
Dmitrij S. Kryzhevich b35340c
+void mglCanvas::fast_draw(const mglPnt &p1, const mglPnt &p2, mglDrawReg *dr)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	const mglPnt &p1=Pnt[k1], &p2=Pnt[k2];
Dmitrij S. Kryzhevich b35340c
 	mglPnt d=p2-p1;
Dmitrij S. Kryzhevich b35340c
 	unsigned char r[4];	col2int(p1,r,dr->ObjId);
Dmitrij S. Kryzhevich b35340c
 	long y1,x1,y2,x2;
Dmitrij S. Kryzhevich b35340c
@@ -807,12 +802,11 @@ void mglCanvas::fast_draw(long k1, long
Dmitrij S. Kryzhevich b35340c
 	}
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-void mglCanvas::pnt_draw(long k, mglDrawReg *dr)
Dmitrij S. Kryzhevich b35340c
+void mglCanvas::pnt_draw(const mglPnt &p, mglDrawReg *dr)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
 	register long i,j,s,x,y;
Dmitrij S. Kryzhevich b35340c
 	register float v,pw=3*dr->PenWidth,dpw=3;
Dmitrij S. Kryzhevich b35340c
 	if(dr->ObjId==HighId)	{	pw *= 2;	dpw=2;	}
Dmitrij S. Kryzhevich b35340c
-	const mglPnt &p=Pnt[k];
Dmitrij S. Kryzhevich b35340c
 	unsigned char cs[4], cc;
Dmitrij S. Kryzhevich b35340c
 	col2int(p,cs,dr->ObjId);	cc = cs[3];
Dmitrij S. Kryzhevich b35340c
 	if(cc==0)	return;
Dmitrij S. Kryzhevich b35340c
@@ -829,21 +823,17 @@ void mglCanvas::pnt_draw(long k, mglDraw
Dmitrij S. Kryzhevich b35340c
 	}
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-void mglCanvas::mark_draw(long k, char type, mreal size, mglDrawReg *d)
Dmitrij S. Kryzhevich b35340c
+void mglCanvas::mark_draw(const mglPnt &q, char type, mreal size, mglDrawReg *d)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	const mglPnt &q=Pnt[k];
Dmitrij S. Kryzhevich b35340c
 	unsigned char cs[4];	col2int(q,cs,d->ObjId);	cs[3] = size>0 ? 255 : 255*q.t;
Dmitrij S. Kryzhevich b35340c
-	mglPnt p=q;
Dmitrij S. Kryzhevich b35340c
+	mglPnt p0=q,p1=q,p2=q,p3=q;
Dmitrij S. Kryzhevich b35340c
 	mreal ss=fabs(size);
Dmitrij S. Kryzhevich b35340c
 	register long i,j;
Dmitrij S. Kryzhevich b35340c
-#if MGL_HAVE_PTHREAD
Dmitrij S. Kryzhevich b35340c
-	pthread_mutex_lock(&mutexPnt);
Dmitrij S. Kryzhevich b35340c
-#endif
Dmitrij S. Kryzhevich fefea00
-	size_t pos = Pnt.size(), qos=pos;
Dmitrij S. Kryzhevich b35340c
+
Dmitrij S. Kryzhevich fefea00
 	if(type=='.' || ss==0)
Dmitrij S. Kryzhevich fefea00
 	{
Dmitrij S. Kryzhevich fefea00
 		if(d)	d->PenWidth = ss?ss:sqrt(font_factor/400);
Dmitrij S. Kryzhevich b35340c
-		pnt_draw(k,d);
Dmitrij S. Kryzhevich b35340c
+		pnt_draw(q,d);
Dmitrij S. Kryzhevich fefea00
 	}
Dmitrij S. Kryzhevich fefea00
 	else
Dmitrij S. Kryzhevich fefea00
 	{
Dmitrij S. Kryzhevich b35340c
@@ -856,107 +846,100 @@ void mglCanvas::mark_draw(long k, char t
Dmitrij S. Kryzhevich b35340c
 		switch(type)
Dmitrij S. Kryzhevich fefea00
 		{
Dmitrij S. Kryzhevich fefea00
 		case 'P':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(pos,pos+1,d);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x+ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(pos+1,pos+2,d);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(pos+2,pos+3,d);
Dmitrij S. Kryzhevich fefea00
-			line_draw(pos+3,pos,d);	qos+=4;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y-ss;  p1.x = q.x+ss;  p1.y = q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            p2.x = q.x+ss;  p2.y = q.y+ss;  p3.x = q.x-ss;  p3.y = q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            line_draw(p0,p1,d); line_draw(p1,p2,d);
Dmitrij S. Kryzhevich b35340c
+            line_draw(p2,p3,d); line_draw(p3,p0,d);
Dmitrij S. Kryzhevich fefea00
 		case '+':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y;		Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y;		Pnt.push_back(p);	line_draw(qos,qos+1,d);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x;	p.y = q.y-ss;		Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x;	p.y = q.y+ss;		Pnt.push_back(p);	line_draw(qos+2,qos+3,d);
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y; p1.x = q.x+ss;  p1.y = q.y; line_draw(p0,p1,d);
Dmitrij S. Kryzhevich b35340c
+            p2.x = q.x; p2.y = q.y-ss;  p3.x = q.x; p3.y = q.y+ss;  line_draw(p2,p3,d);
Dmitrij S. Kryzhevich fefea00
 			break;
Dmitrij S. Kryzhevich fefea00
 		case 'X':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(pos,pos+1,d);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x+ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(pos+1,pos+2,d);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(pos+2,pos+3,d);
Dmitrij S. Kryzhevich fefea00
-			line_draw(pos+3,pos,d);	qos+=4;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y-ss;  p1.x = q.x+ss;  p1.y = q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            p2.x = q.x+ss;  p2.y = q.y+ss;  p3.x = q.x-ss;  p3.y = q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            line_draw(p0,p1,d); line_draw(p1,p2,d);
Dmitrij S. Kryzhevich b35340c
+            line_draw(p2,p3,d); line_draw(p3,p0,d);
Dmitrij S. Kryzhevich fefea00
 		case 'x':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(qos+2,qos+3,d);
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y-ss;  p1.x = q.x+ss;  p1.y = q.y+ss;  line_draw(p0,p1,d);
Dmitrij S. Kryzhevich b35340c
+            p2.x = q.x+ss;  p2.y = q.y-ss;  p3.x = q.x-ss;  p3.y = q.y+ss;  line_draw(p2,p3,d);
Dmitrij S. Kryzhevich b35340c
 			break;
Dmitrij S. Kryzhevich b35340c
 		case 'S':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x+ss;	p.y= q.y+ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			quad_draw(pos,pos+1,pos+3,pos+2,d);	qos+=4;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y-ss;  p1.x = q.x-ss;  p1.y = q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x+ss;   p2.y= q.y+ss;   p3.x = q.x+ss;  p3.y = q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            quad_draw(p0,p1,p3,p2,d);
Dmitrij S. Kryzhevich fefea00
 		case 's':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(qos+1,qos+2,d);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y+ss;	Pnt.push_back(p);	line_draw(qos+2,qos+3,d);
Dmitrij S. Kryzhevich b35340c
-			line_draw(qos+3,qos,d);	break;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y-ss;  p1.x = q.x+ss;  p1.y = q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            p2.x = q.x+ss;  p2.y = q.y+ss;  p3.x = q.x-ss;  p3.y = q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            line_draw(p0,p1,d); line_draw(p1,p2,d);
Dmitrij S. Kryzhevich b35340c
+            line_draw(p2,p3,d); line_draw(p3,p0,d);
Dmitrij S. Kryzhevich b35340c
+            break;
Dmitrij S. Kryzhevich b35340c
 		case 'D':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x;	p.y = q.y-ss;		Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y;		Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x;	p.y= q.y+ss;		Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y;		Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			quad_draw(pos,pos+1,pos+3,pos+2,d);	qos+=4;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x; p0.y = q.y-ss;  p1.x = q.x+ss;  p1.y = q.y;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x;  p2.y= q.y+ss;   p3.x = q.x-ss;  p3.y = q.y;
Dmitrij S. Kryzhevich b35340c
+            quad_draw(p0,p1,p3,p2,d);
Dmitrij S. Kryzhevich fefea00
 		case 'd':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x;	p.y = q.y-ss;		Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y;		Pnt.push_back(p);	line_draw(qos,qos+1,d);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x;	p.y = q.y+ss;		Pnt.push_back(p);	line_draw(qos+1,qos+2,d);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y;		Pnt.push_back(p);	line_draw(qos+2,qos+3,d);
Dmitrij S. Kryzhevich b35340c
-			line_draw(qos+3,qos,d);	break;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x; p0.y = q.y-ss;  p1.x = q.x+ss;  p1.y = q.y;
Dmitrij S. Kryzhevich b35340c
+            p2.x = q.x; p2.y = q.y+ss;  p3.x = q.x-ss;  p3.y = q.y;
Dmitrij S. Kryzhevich b35340c
+            line_draw(p0,p1,d); line_draw(p1,p2,d);
Dmitrij S. Kryzhevich b35340c
+            line_draw(p2,p3,d); line_draw(p3,p0,d);
Dmitrij S. Kryzhevich b35340c
+            break;
Dmitrij S. Kryzhevich fefea00
 		case 'Y':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x;	p.y = q.y;			Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x;	p.y = q.y-ss;		Pnt.push_back(p);	line_draw(pos,pos+1,d);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x-0.8*ss;	p.y = q.y+0.6*ss;	Pnt.push_back(p);	line_draw(pos,pos+2,d);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x+0.8*ss;	p.y = q.y+0.6*ss;	Pnt.push_back(p);	line_draw(pos,pos+3,d);
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x; p1.y = q.y-ss;  line_draw(q,p1,d);
Dmitrij S. Kryzhevich b35340c
+            p2.x = q.x-0.8*ss;  p2.y = q.y+0.6*ss;  line_draw(q,p2,d);
Dmitrij S. Kryzhevich b35340c
+            p3.x = q.x+0.8*ss;  p3.y = q.y+0.6*ss;  line_draw(q,p3,d);
Dmitrij S. Kryzhevich fefea00
 			break;
Dmitrij S. Kryzhevich fefea00
 		case '*':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;		p.y = q.y;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			p.x = q.x+ss;		p.y = q.y;	Pnt.push_back(p);	line_draw(pos,pos+1,d);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-0.6*ss;	p.y = q.y-0.8*ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			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);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-0.6*ss;	p.y = q.y+0.8*ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			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);
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;      p0.y = q.y;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x+ss;      p1.y = q.y; line_draw(p0,p1,d);
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-0.6*ss;  p0.y = q.y-0.8*ss;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x+0.6*ss;  p1.y = q.y+0.8*ss;  line_draw(p0,p1,d);
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-0.6*ss;  p0.y = q.y+0.8*ss;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x+0.6*ss;  p1.y = q.y-0.8*ss;  line_draw(p0,p1,d);
Dmitrij S. Kryzhevich fefea00
 			break;
Dmitrij S. Kryzhevich fefea00
 		case 'T':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y-ss/2;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y-ss/2;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x;		p.y= q.y+ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			trig_draw(pos,pos+1,pos+2,false,d);	qos+=3;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y-ss/2;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x+ss;  p1.y = q.y-ss/2;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x;      p2.y= q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            trig_draw(p0,p1,p2,false,d);
Dmitrij S. Kryzhevich fefea00
 		case '^':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y-ss/2;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y-ss/2;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x;		p.y= q.y+ss;	Pnt.push_back(p);	line_draw(qos+1,qos+2,d);
Dmitrij S. Kryzhevich b35340c
-			line_draw(qos+2,qos,d);		break;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y-ss/2;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x+ss;  p1.y = q.y-ss/2;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x;      p2.y= q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            line_draw(p0,p1,d); line_draw(p1,p2,d);
Dmitrij S. Kryzhevich b35340c
+            line_draw(p2,p0,d); break;
Dmitrij S. Kryzhevich b35340c
 		case 'V':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y+ss/2;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y+ss/2;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x;		p.y= q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			trig_draw(pos,pos+1,pos+2,false,d);	qos+=3;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y+ss/2;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x+ss;  p1.y = q.y+ss/2;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x;      p2.y= q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            trig_draw(p0,p1,p2,false,d);
Dmitrij S. Kryzhevich fefea00
 		case 'v':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss;	p.y = q.y+ss/2;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss;	p.y = q.y+ss/2;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x;		p.y= q.y-ss;	Pnt.push_back(p);	line_draw(qos+1,qos+2,d);
Dmitrij S. Kryzhevich b35340c
-			line_draw(qos+2,qos,d);		break;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss;  p0.y = q.y+ss/2;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x+ss;  p1.y = q.y+ss/2;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x;      p2.y= q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            line_draw(p0,p1,d); line_draw(p1,p2,d);
Dmitrij S. Kryzhevich b35340c
+            line_draw(p2,p0,d); break;
Dmitrij S. Kryzhevich b35340c
 		case 'L':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss/2;	p.y = q.y+ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss/2;	p.y = q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x-ss;	p.y= q.y;		Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			trig_draw(pos,pos+1,pos+2,false,d);	qos+=3;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x+ss/2;    p0.y = q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x+ss/2;    p1.y = q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x-ss;       p2.y= q.y;
Dmitrij S. Kryzhevich b35340c
+            trig_draw(p0,p1,p2,false,d);
Dmitrij S. Kryzhevich fefea00
 		case '<':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss/2;	p.y = q.y+ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x+ss/2;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x-ss;	p.y= q.y;		Pnt.push_back(p);	line_draw(qos+1,qos+2,d);
Dmitrij S. Kryzhevich b35340c
-			line_draw(qos+2,qos,d);		break;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x+ss/2;    p0.y = q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x+ss/2;    p1.y = q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x-ss;       p2.y= q.y;
Dmitrij S. Kryzhevich b35340c
+            line_draw(p0,p1,d); line_draw(p1,p2,d);
Dmitrij S. Kryzhevich b35340c
+            line_draw(p2,p0,d); break;
Dmitrij S. Kryzhevich b35340c
 		case 'R':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss/2;	p.y = q.y+ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss/2;	p.y = q.y-ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x+ss;	p.y= q.y;		Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-			trig_draw(pos,pos+1,pos+2,false,d);	qos+=3;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss/2;    p0.y = q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x-ss/2;    p1.y = q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x+ss;       p2.y= q.y;
Dmitrij S. Kryzhevich b35340c
+            trig_draw(p0,p1,p2,false,d);
Dmitrij S. Kryzhevich fefea00
 		case '>':
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss/2;	p.y = q.y+ss;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-			p.x = q.x-ss/2;	p.y = q.y-ss;	Pnt.push_back(p);	line_draw(qos,qos+1,d);
Dmitrij S. Kryzhevich b35340c
-			p.x= q.x+ss;	p.y= q.y;		Pnt.push_back(p);	line_draw(qos+1,qos+2,d);
Dmitrij S. Kryzhevich b35340c
-			line_draw(qos+2,qos,d);		break;
Dmitrij S. Kryzhevich b35340c
+            p0.x = q.x-ss/2;    p0.y = q.y+ss;
Dmitrij S. Kryzhevich b35340c
+            p1.x = q.x-ss/2;    p1.y = q.y-ss;
Dmitrij S. Kryzhevich b35340c
+            p2.x= q.x+ss;       p2.y= q.y;
Dmitrij S. Kryzhevich b35340c
+            line_draw(p0,p1,d); line_draw(p1,p2,d);
Dmitrij S. Kryzhevich b35340c
+            line_draw(p2,p0,d); break;
Dmitrij S. Kryzhevich b35340c
 		case 'O':
Dmitrij S. Kryzhevich b35340c
 			for(j=long(-ss);j<=long(ss);j++)	for(i=long(-ss);i<=long(ss);i++)
Dmitrij S. Kryzhevich b35340c
 			{
Dmitrij S. Kryzhevich b35340c
@@ -967,24 +950,20 @@ void mglCanvas::mark_draw(long k, char t
Dmitrij S. Kryzhevich b35340c
 		case 'o':
Dmitrij S. Kryzhevich fefea00
 			for(i=0;i<=20;i++)
Dmitrij S. Kryzhevich fefea00
 			{
Dmitrij S. Kryzhevich b35340c
-				p.x = q.x+ss*cos(i*M_PI/10);	p.y = q.y+ss*sin(i*M_PI/10);	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-				if(i>0)	line_draw(pos+i-1,pos+i,d);
Dmitrij S. Kryzhevich b35340c
+                p0 = p1;    p1.x = q.x+ss*cos(i*M_PI/10);   p1.y = q.y+ss*sin(i*M_PI/10);
Dmitrij S. Kryzhevich b35340c
+                if(i>0) line_draw(p0,p1,d);
Dmitrij S. Kryzhevich fefea00
 			}
Dmitrij S. Kryzhevich fefea00
 			break;
Dmitrij S. Kryzhevich fefea00
 		case 'C':
Dmitrij S. Kryzhevich fefea00
-			pnt_draw(k,d);
Dmitrij S. Kryzhevich b35340c
+			pnt_draw(q,d);
Dmitrij S. Kryzhevich fefea00
 			for(i=0;i<=20;i++)
Dmitrij S. Kryzhevich fefea00
 			{
Dmitrij S. Kryzhevich b35340c
-				p.x = q.x+ss*cos(i*M_PI/10);	p.y = q.y+ss*sin(i*M_PI/10);	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-				if(i>0)	line_draw(pos+i-1,pos+i,d);
Dmitrij S. Kryzhevich b35340c
+                p0 = p1;    p1.x = q.x+ss*cos(i*M_PI/10);   p1.y = q.y+ss*sin(i*M_PI/10);
Dmitrij S. Kryzhevich b35340c
+                if(i>0) line_draw(p0,p1,d);
Dmitrij S. Kryzhevich fefea00
 			}
Dmitrij S. Kryzhevich fefea00
 			break;
Dmitrij S. Kryzhevich fefea00
 		}
Dmitrij S. Kryzhevich fefea00
-		Pnt.erase(Pnt.begin()+pos,Pnt.end());
Dmitrij S. Kryzhevich fefea00
 	}
Dmitrij S. Kryzhevich b35340c
-#if MGL_HAVE_PTHREAD
Dmitrij S. Kryzhevich b35340c
-	pthread_mutex_unlock(&mutexPnt);
Dmitrij S. Kryzhevich b35340c
-#endif
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
 // scale direction for new view/zoom
Dmitrij S. Kryzhevich b35340c
@@ -1009,31 +988,31 @@ float mglCanvas::GetGlyphPhi(const mglPn
Dmitrij S. Kryzhevich b35340c
 	return phi;
Dmitrij S. Kryzhevich b35340c
 }
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
-void mglCanvas::glyph_draw(const mglPrim *P, mglDrawReg *d)
Dmitrij S. Kryzhevich b35340c
+void mglCanvas::glyph_draw(const mglPrim &P, mglDrawReg *d)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	float phi = GetGlyphPhi(Pnt[P->n2],P->w);
Dmitrij S. Kryzhevich b35340c
+	float phi = GetGlyphPhi(Pnt[P.n2],P.w);
Dmitrij S. Kryzhevich b35340c
 	if(mgl_isnan(phi))	return;
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
-	mglPnt p=Pnt[P->n1];
Dmitrij S. Kryzhevich b35340c
-	mreal pf=sqrt((Bp.b[0]*Bp.b[0]+Bp.b[1]*Bp.b[1]+Bp.b[3]*Bp.b[3]+Bp.b[4]*Bp.b[4])/2), f = P->p*pf;
Dmitrij S. Kryzhevich b35340c
+    mglPnt p=Pnt[P.n1];
Dmitrij S. Kryzhevich b35340c
+    mreal pf=sqrt((Bp.b[0]*Bp.b[0]+Bp.b[1]*Bp.b[1]+Bp.b[3]*Bp.b[3]+Bp.b[4]*Bp.b[4])/2), f = P.p*pf;
Dmitrij S. Kryzhevich fefea00
 #if MGL_HAVE_PTHREAD
Dmitrij S. Kryzhevich b35340c
 	pthread_mutex_lock(&mutexPnt);
Dmitrij S. Kryzhevich b35340c
 #endif
Dmitrij S. Kryzhevich b35340c
 	Push();		B.clear();
Dmitrij S. Kryzhevich b35340c
-	B.b[0] = B.b[4] = B.b[8] = P->s;
Dmitrij S. Kryzhevich b35340c
+	B.b[0] = B.b[4] = B.b[8] = P.s;
Dmitrij S. Kryzhevich b35340c
 	RotateN(phi,0,0,1);
Dmitrij S. Kryzhevich b35340c
 	B.x=p.x;	B.y=p.y;	B.z=p.z;	B.pf = 1;
Dmitrij S. Kryzhevich b35340c
 	p.u *= pf;	p.v *= pf;
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
-	const mglGlyph &g = Glf[P->n4];
Dmitrij S. Kryzhevich b35340c
-	if(P->n3&8)
Dmitrij S. Kryzhevich b35340c
+    const mglGlyph &g = Glf[P.n4];
Dmitrij S. Kryzhevich b35340c
+    if(P.n3&8)
Dmitrij S. Kryzhevich b35340c
 	{
Dmitrij S. Kryzhevich b35340c
-		if(!(P->n3&4))	glyph_line(p,f,true, d);
Dmitrij S. Kryzhevich b35340c
+		if(!(P.n3&4))   glyph_line(p,f,true, d);
Dmitrij S. Kryzhevich b35340c
 		glyph_line(p,f,false, d);
Dmitrij S. Kryzhevich b35340c
 	}
Dmitrij S. Kryzhevich b35340c
 	else
Dmitrij S. Kryzhevich b35340c
 	{
Dmitrij S. Kryzhevich b35340c
-		if(!(P->n3&4))	glyph_fill(p,f,g, d);
Dmitrij S. Kryzhevich b35340c
+		if(!(P.n3&4))   glyph_fill(p,f,g, d);
Dmitrij S. Kryzhevich b35340c
 		glyph_wire(p,f,g, d);
Dmitrij S. Kryzhevich b35340c
 	}
Dmitrij S. Kryzhevich b35340c
 	Pop();
Dmitrij S. Kryzhevich b35340c
@@ -1045,27 +1024,27 @@ void mglCanvas::glyph_draw(const mglPrim
Dmitrij S. Kryzhevich fefea00
 void mglCanvas::glyph_fill(const mglPnt &pp, mreal f, const mglGlyph &g, mglDrawReg *d)
Dmitrij S. Kryzhevich fefea00
 {
Dmitrij S. Kryzhevich fefea00
 	if(!g.trig || g.nt<=0)	return;
Dmitrij S. Kryzhevich fefea00
-	long ik,ii,pos=Pnt.size();
Dmitrij S. Kryzhevich b35340c
-	mglPnt p=pp;	p.u=p.v=NAN;
Dmitrij S. Kryzhevich b35340c
-	mglPoint p1,p2,p3;
Dmitrij S. Kryzhevich b35340c
+    long ik,ii;
Dmitrij S. Kryzhevich b35340c
+    mglPnt q0=pp, q1=pp, q2=pp;
Dmitrij S. Kryzhevich b35340c
+    q0.u=q0.v=q1.u=q1.v=q2.u=q2.v=NAN;
Dmitrij S. Kryzhevich b35340c
+    mglPoint p1,p2,p3;
Dmitrij S. Kryzhevich fefea00
 	for(ik=0;ik
Dmitrij S. Kryzhevich b35340c
 	{
Dmitrij S. Kryzhevich b35340c
 		ii = 6*ik;	p1 = mglPoint(f*g.trig[ii]+pp.u,f*g.trig[ii+1]+pp.v,0);	PostScale(p1);
Dmitrij S. Kryzhevich b35340c
 		ii+=2;		p2 = mglPoint(f*g.trig[ii]+pp.u,f*g.trig[ii+1]+pp.v,0);	PostScale(p2);
Dmitrij S. Kryzhevich b35340c
 		ii+=2;		p3 = mglPoint(f*g.trig[ii]+pp.u,f*g.trig[ii+1]+pp.v,0);	PostScale(p3);
Dmitrij S. Kryzhevich b35340c
-		p.x = p1.x;	p.y = p1.y;	p.z = p1.z;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-		p.x = p2.x;	p.y = p2.y;	p.z = p2.z;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-		p.x = p3.x;	p.y = p3.y;	p.z = p3.z;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-		ii = Pnt.size()-3;	trig_draw(ii,ii+1,ii+2,false,d);
Dmitrij S. Kryzhevich b35340c
+        q0.x = p1.x;    q0.y = p1.y;    q0.z = p1.z;
Dmitrij S. Kryzhevich b35340c
+        q1.x = p2.x;    q1.y = p2.y;    q1.z = p2.z;
Dmitrij S. Kryzhevich b35340c
+        q2.x = p3.x;    q2.y = p3.y;    q2.z = p3.z;
Dmitrij S. Kryzhevich b35340c
+        trig_draw(q0,q1,q2,false,d);
Dmitrij S. Kryzhevich fefea00
 	}
Dmitrij S. Kryzhevich fefea00
-	Pnt.erase(Pnt.begin()+pos,Pnt.end());
Dmitrij S. Kryzhevich fefea00
 }
Dmitrij S. Kryzhevich fefea00
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich fefea00
 void mglCanvas::glyph_wire(const mglPnt &pp, mreal f, const mglGlyph &g, mglDrawReg *d)
Dmitrij S. Kryzhevich fefea00
 {
Dmitrij S. Kryzhevich fefea00
 	if(!g.line || g.nl<=0)	return;
Dmitrij S. Kryzhevich fefea00
-	long ik,ii,il=0,pos=Pnt.size();
Dmitrij S. Kryzhevich b35340c
-	mglPnt p=pp;	p.u=p.v=NAN;
Dmitrij S. Kryzhevich b35340c
+    long ik,ii,il=0;
Dmitrij S. Kryzhevich b35340c
+    mglPnt q0=pp, q1=pp;    q0.u=q0.v=q1.u=q1.v=NAN;
Dmitrij S. Kryzhevich fefea00
 	if(d)	{	d->PDef = 0xffff;	d->PenWidth=0.75;	}
Dmitrij S. Kryzhevich fefea00
 	mglPoint p1,p2;
Dmitrij S. Kryzhevich b35340c
 	for(ik=0;ik
Dmitrij S. Kryzhevich b35340c
@@ -1084,19 +1063,18 @@ void mglCanvas::glyph_wire(const mglPnt
Dmitrij S. Kryzhevich b35340c
 			p2 = mglPoint(f*g.line[ii]+pp.u,f*g.line[ii+1]+pp.v,0);
Dmitrij S. Kryzhevich b35340c
 		}
Dmitrij S. Kryzhevich fefea00
 		PostScale(p1);	PostScale(p2);
Dmitrij S. Kryzhevich b35340c
-		p.x = p1.x;	p.y = p1.y;	p.z = p1.z;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-		p.x = p2.x;	p.y = p2.y;	p.z = p2.z;	Pnt.push_back(p);
Dmitrij S. Kryzhevich fefea00
-		ii = Pnt.size()-2;	line_draw(ii,ii+1,d);
Dmitrij S. Kryzhevich b35340c
+        q0.x = p1.x;    q0.y = p1.y;    q0.z = p1.z;
Dmitrij S. Kryzhevich b35340c
+        q1.x = p2.x;    q1.y = p2.y;    q1.z = p2.z;
Dmitrij S. Kryzhevich b35340c
+        line_draw(q0,q1,d);
Dmitrij S. Kryzhevich fefea00
 	}
Dmitrij S. Kryzhevich fefea00
-	Pnt.erase(Pnt.begin()+pos,Pnt.end());
Dmitrij S. Kryzhevich fefea00
 }
Dmitrij S. Kryzhevich fefea00
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich fefea00
 void mglCanvas::glyph_line(const mglPnt &pp, mreal f, bool solid, mglDrawReg *d)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	mglPnt p=pp;	p.u=p.v=NAN;
Dmitrij S. Kryzhevich b35340c
+    mglPnt q0=pp,q1=pp,q2=pp,q3=pp;
Dmitrij S. Kryzhevich b35340c
+    q0.u=q0.v=q1.u=q1.v=q2.u=q2.v=q3.u=q3.v=NAN;
Dmitrij S. Kryzhevich fefea00
 	if(d)	{	d->PDef = 0xffff;	d->PenWidth=1;	}
Dmitrij S. Kryzhevich fefea00
 	mglPoint p1,p2,p3,p4;
Dmitrij S. Kryzhevich fefea00
-	long pos=Pnt.size();
Dmitrij S. Kryzhevich fefea00
 
Dmitrij S. Kryzhevich fefea00
 	mreal dy = 0.004;
Dmitrij S. Kryzhevich fefea00
 	p1 = mglPoint(pp.u,pp.v-dy,0);	PostScale(p1);
Dmitrij S. Kryzhevich b35340c
@@ -1104,18 +1082,17 @@ void mglCanvas::glyph_line(const mglPnt
Dmitrij S. Kryzhevich b35340c
 	p3 = mglPoint(fabs(f)+pp.u,pp.v+dy,0);	PostScale(p3);
Dmitrij S. Kryzhevich b35340c
 	p4 = mglPoint(fabs(f)+pp.u,pp.v-dy,0);	PostScale(p4);
Dmitrij S. Kryzhevich b35340c
 
Dmitrij S. Kryzhevich b35340c
-	p.x = p1.x;	p.y = p1.y;	p.z = p1.z;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-	p.x = p2.x;	p.y = p2.y;	p.z = p2.z;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-	p.x = p3.x;	p.y = p3.y;	p.z = p3.z;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
-	p.x = p4.x;	p.y = p4.y;	p.z = p4.z;	Pnt.push_back(p);
Dmitrij S. Kryzhevich b35340c
+    q0.x = p1.x;    q0.y = p1.y;    q0.z = p1.z;
Dmitrij S. Kryzhevich b35340c
+    q1.x = p2.x;    q1.y = p2.y;    q1.z = p2.z;
Dmitrij S. Kryzhevich b35340c
+    q2.x = p3.x;    q2.y = p3.y;    q2.z = p3.z;
Dmitrij S. Kryzhevich b35340c
+    q3.x = p4.x;    q3.y = p4.y;    q3.z = p4.z;
Dmitrij S. Kryzhevich fefea00
 
Dmitrij S. Kryzhevich fefea00
-	if(solid)	quad_draw(pos,pos+1,pos+3,pos+2,d);
Dmitrij S. Kryzhevich b35340c
+	if(solid)   quad_draw(q0,q1,q3,q2,d);
Dmitrij S. Kryzhevich fefea00
 	else
Dmitrij S. Kryzhevich fefea00
 	{
Dmitrij S. Kryzhevich fefea00
-		line_draw(pos,pos+1,d);	line_draw(pos+2,pos+1,d);
Dmitrij S. Kryzhevich fefea00
-		line_draw(pos,pos+3,d);	line_draw(pos+2,pos+3,d);
Dmitrij S. Kryzhevich b35340c
+        line_draw(q0,q1,d); line_draw(q2,q1,d);
Dmitrij S. Kryzhevich b35340c
+        line_draw(q0,q3,d); line_draw(q2,q3,d);
Dmitrij S. Kryzhevich fefea00
 	}
Dmitrij S. Kryzhevich fefea00
-	Pnt.erase(Pnt.begin()+pos,Pnt.end());
Dmitrij S. Kryzhevich fefea00
 }
Dmitrij S. Kryzhevich fefea00
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich fefea00
 long mglCanvas::setPp(mglPnt &q, const mglPoint &p)
Dmitrij S. Kryzhevich b35340c
@@ -1127,7 +1104,6 @@ long mglCanvas::setPp(mglPnt &q, const m
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
 void mglCanvas::arrow_draw(long n1, long n2, char st, float ll)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	if(n1<0 || n2<0 || !strchr("AVKSDTIO",st))	return;
Dmitrij S. Kryzhevich b35340c
 	const mglPnt &p1=Pnt[n1], &p2=Pnt[n2];
Dmitrij S. Kryzhevich b35340c
 	mglPnt q=p1; 	//q.u=q.v=q.w=0;
Dmitrij S. Kryzhevich b35340c
 	
Dmitrij S. Kryzhevich b35340c
@@ -1178,7 +1154,6 @@ void mglCanvas::arrow_draw(long n1, long
Dmitrij S. Kryzhevich b35340c
 //-----------------------------------------------------------------------------
Dmitrij S. Kryzhevich b35340c
 void mglCanvas::arrow_plot_3d(long n1, long n2, char st, float ll)
Dmitrij S. Kryzhevich b35340c
 {
Dmitrij S. Kryzhevich b35340c
-	if(n1<0 || n2<0 || !strchr("AVKSDTIO",st))	return;
Dmitrij S. Kryzhevich b35340c
 	const mglPnt &p1=Pnt[n1], &p2=Pnt[n2];
Dmitrij S. Kryzhevich b35340c
 	mglPnt q=p1; 	//q.u=q.v=q.w=0;
Dmitrij S. Kryzhevich b35340c