[SCM] Packaging for mathgl branch, experimental, updated. debian/2.rc1-1-6-g7261097
Dimitrios Eftaxiopoulos
eftaxi12 at otenet.gr
Tue Oct 4 00:20:39 UTC 2011
The following commit has been merged in the experimental branch:
commit 7261097e5d3bf220dc7b103f0c7fd55bc2ecc8ee
Author: Dimitrios Eftaxiopoulos <eftaxi12 at otenet.gr>
Date: Tue Oct 4 03:19:57 2011 +0300
Fix symbols failure for i386
diff --git a/debian/control b/debian/control
index 01b84e1..eeca0b9 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@ Priority: optional
Maintainer: Debian Science Maintainers <debian-science-maintainers at lists.alioth.debian.org>
Uploaders: Dimitrios Eftaxiopoulos <eftaxi12 at otenet.gr>, D Haley <mycae at yahoo.com>
DM-Upload-Allowed: yes
-Build-Depends: debhelper (>= 7.2.3~), libltdl-dev, libgsl0-dev, freeglut3-dev,
+Build-Depends: debhelper (>= 7.2.3~), libltdl-dev, libgsl0-dev, freeglut3-dev, zlib1g-dev,
libgl1-mesa-dev | libgl-dev, libpng-dev, libhdf5-serial-dev | libhdf5-dev,
libjpeg-dev, libtiff-dev, libfltk1.3-dev | libfltk-dev, libqt4-dev, libwxgtk2.8-dev, swig,
texinfo, texi2html, texlive, texlive-generic-recommended, octave3.2-headers,
diff --git a/debian/libmgl-wnd6.symbols b/debian/libmgl-wnd6.symbols
index 1aeacdd..aafd61d 100644
--- a/debian/libmgl-wnd6.symbols
+++ b/debian/libmgl-wnd6.symbols
@@ -142,8 +142,10 @@ libmgl-wnd.so.6 libmgl-wnd6 #MINVER#
_ZTV11mglCanvasQT at Base 2~rc1
_ZTV7QMathGL at Base 2~rc1
_ZTV9Fl_MathGL at Base 2~rc1
- _ZThn16_N7QMathGLD0Ev at Base 2~rc1
- _ZThn16_N7QMathGLD1Ev at Base 2~rc1
+ (arch=!i386)_ZThn16_N7QMathGLD0Ev at Base 2~rc1
+ (arch=!i386)_ZThn16_N7QMathGLD1Ev at Base 2~rc1
+ (arch=i386)_ZThn8_N7QMathGLD0Ev at Base 2~rc1
+ (arch=i386)_ZThn8_N7QMathGLD1Ev at Base 2~rc1
menuitems at Base 2~rc1
mgl_create_graph_fltk at Base 2~rc1
mgl_create_graph_fltk_ at Base 2~rc1
diff --git a/debian/libmgl6.symbols b/debian/libmgl6.symbols
index 623d7bd..bffbbbb 100644
--- a/debian/libmgl6.symbols
+++ b/debian/libmgl6.symbols
@@ -334,7 +334,8 @@ libmgl.so.6 libmgl6 #MINVER#
_Z14mgl_draw_graphP7mglBasePv at Base 2~rc1
_Z14mgl_qo2d_hprepPv at Base 2~rc1
_Z14mgl_surf3_plotP7mglBasellPlS1_S1_S1_S1_St6vectorI8mglPointSaIS3_EEb at Base 2~rc1
- _Z14mgl_write_bps_PmPKcS1_ii at Base 2~rc1
+ (arch=!i386)_Z14mgl_write_bps_PmPKcS1_ii at Base 2~rc1
+ (arch=i386)_Z14mgl_write_bps_PjPKcS1_ii at Base 2~rc1
_Z14mglc_addlegendPwlP6mglArgPiPKc at Base 2~rc1
_Z14mglc_arrowsizePwlP6mglArgPiPKc at Base 2~rc1
_Z14mglc_integratePwlP6mglArgPiPKc at Base 2~rc1
@@ -377,7 +378,8 @@ libmgl.so.6 libmgl6 #MINVER#
_Z16mgls_perspectiveP8mglGraphlP6mglArgPiPKc at Base 2~rc1
_Z16mgls_triangulateP8mglGraphlP6mglArgPiPKc at Base 2~rc1
_Z17mgl_create_schemePKcRl at Base 2~rc1
- _Z17mgl_set_font_def_PmPci at Base 2~rc1
+ (arch=!i386)_Z17mgl_set_font_def_PmPci at Base 2~rc1
+ (arch=i386)_Z17mgl_set_font_def_PjPci at Base 2~rc1
_Z18mgl_data_read_hdf4P7mglDataPKcS2_ at Base 2~rc1
_Z3adddd at Base 2~rc1
_Z3argdd at Base 2~rc1
@@ -929,10 +931,12 @@ libmgl.so.6 libmgl6 #MINVER#
_ZNSs19_M_replace_dispatchIN9__gnu_cxx17__normal_iteratorIPwSbIwSt11char_traitsIwESaIwEEEEEERSsNS1_IPcSsEESA_T_SB_St12__false_type at Base 2~rc1
_ZNSt6vectorI10mglSegmentSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_ at Base 2~rc1
_ZNSt6vectorI10mglTextureSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_ at Base 2~rc1
- _ZNSt6vectorI10mglTextureSaIS0_EE7reserveEm at Base 2~rc1
+ (arch=!i386)_ZNSt6vectorI10mglTextureSaIS0_EE7reserveEm at Base 2~rc1
+ (arch=i386)_ZNSt6vectorI10mglTextureSaIS0_EE7reserveEj at Base 2~rc1
_ZNSt6vectorI6mglPntSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_ at Base 2~rc1
_ZNSt6vectorI6mglPntSaIS0_EE5eraseEN9__gnu_cxx17__normal_iteratorIPS0_S2_EES6_ at Base 2~rc1
- _ZNSt6vectorI6mglPntSaIS0_EE7reserveEm at Base 2~rc1
+ (arch=!i386)_ZNSt6vectorI6mglPntSaIS0_EE7reserveEm at Base 2~rc1
+ (arch=i386)_ZNSt6vectorI6mglPntSaIS0_EE7reserveEj at Base 2~rc1
_ZNSt6vectorI6mglPntSaIS0_EE9push_backERKS0_ at Base 2~rc1
_ZNSt6vectorI7mglPrimSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_ at Base 2~rc1
_ZNSt6vectorI7mglPrimSaIS0_EED1Ev at Base 2~rc1
@@ -945,16 +949,20 @@ libmgl.so.6 libmgl6 #MINVER#
_ZNSt6vectorI8mglGroupSaIS0_EED1Ev at Base 2~rc1
_ZNSt6vectorI8mglGroupSaIS0_EED2Ev at Base 2~rc1
_ZNSt6vectorI8mglPointSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_ at Base 2~rc1
- _ZNSt6vectorI8mglPointSaIS0_EE7reserveEm at Base 2~rc1
+ (arch=!i386)_ZNSt6vectorI8mglPointSaIS0_EE7reserveEm at Base 2~rc1
+ (arch=i386)_ZNSt6vectorI8mglPointSaIS0_EE7reserveEj at Base 2~rc1
_ZNSt6vectorI8mglPointSaIS0_EEaSERKS2_ at Base 2~rc1
_ZNSt6vectorI9mglMatrixSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_ at Base 2~rc1
_ZNSt6vectorIlSaIlEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPlS1_EERKl at Base 2~rc1
_ZNSt6vectorIlSaIlEEaSERKS1_ at Base 2~rc1
_ZSt10__pop_heapIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEEEvT_S8_S8_ at Base 2~rc1
- _ZSt11__push_heapIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEElS2_EvT_T0_S9_T1_ at Base 2~rc1
- _ZSt13__adjust_heapIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEElS2_EvT_T0_S9_T1_ at Base 2~rc1
+ (optional)_ZSt11__push_heapIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEElS2_EvT_T0_S9_T1_ at Base 2~rc1
+ (optional)_ZSt11__push_heapIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEEiS2_EvT_T0_S9_T1_ at Base 2~rc1
+ (optional)_ZSt13__adjust_heapIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEElS2_EvT_T0_S9_T1_ at Base 2~rc1
+ (optional)_ZSt13__adjust_heapIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEEiS2_EvT_T0_S9_T1_ at Base 2~rc1
_ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEEEvT_S8_ at Base 2~rc1
- _ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEElEvT_S8_T0_ at Base 2~rc1
+ (optional)_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEElEvT_S8_T0_ at Base 2~rc1
+ (optional)_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEEiEvT_S8_T0_ at Base 2~rc1
_ZSt19__move_median_firstIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEEEvT_S8_S8_ at Base 2~rc1
_ZSt25__unguarded_linear_insertIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEEEvT_ at Base 2~rc1
_ZSt9make_heapIN9__gnu_cxx17__normal_iteratorIP7mglPrimSt6vectorIS2_SaIS2_EEEEEvT_S8_ at Base 2~rc1
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..8930613
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+src-data_png_cpp.patch
diff --git a/debian/patches/src-data_png_cpp.patch b/debian/patches/src-data_png_cpp.patch
new file mode 100644
index 0000000..d5d2a30
--- /dev/null
+++ b/debian/patches/src-data_png_cpp.patch
@@ -0,0 +1,358 @@
+Include zlib.h header in file src/data_png.cpp
+--- a/src/data_png.cpp
++++ b/src/data_png.cpp
+@@ -1,178 +1,179 @@
+-/***************************************************************************
+- * data_png.cpp is part of Math Graphic Library
+- * Copyright (C) 2007 Alexey Balakin <balakin at appl.sci-nnov.ru> *
+- * *
+- * This program is free software; you can redistribute it and/or modify *
+- * it under the terms of the GNU Library General Public License as *
+- * published by the Free Software Foundation; either version 3 of the *
+- * License, or (at your option) any later version. *
+- * *
+- * This program is distributed in the hope that it will be useful, *
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+- * GNU General Public License for more details. *
+- * *
+- * You should have received a copy of the GNU Library General Public *
+- * License along with this program; if not, write to the *
+- * Free Software Foundation, Inc., *
+- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+- ***************************************************************************/
+-#include <stdlib.h>
+-#ifndef NO_PNG
+-#include <png.h>
+-#endif
+-#include "mgl/data.h"
+-//-----------------------------------------------------------------------------
+-long mgl_col_dif(unsigned char *c1,unsigned char *c2,bool sum)
+-{
+- long res,d1=abs(long(c1[0])-long(c2[0])),
+- d2=abs(long(c1[1])-long(c2[1])),d3=abs(long(c1[2])-long(c2[2]));
+- if(sum) res = d1+d2+d3;
+- else res = mgl_max(d1,mgl_max(d2,d3));
+- return res;
+-}
+-//-----------------------------------------------------------------------------
+-unsigned char *mgl_create_scheme(const char *scheme,long &num)
+-{
+- unsigned char *c=0,*cc=new unsigned char[3*strlen(scheme)+3];
+- long nc=1,np=0;
+- register long i,j;
+- mglColor col;
+- for(i=0;i<long(strlen(scheme));i++)
+- {
+- col = mglColor(scheme[i]);
+- if(col.Valid())
+- { cc[3*np]=col.r; cc[3*np+1]=col.g; cc[3*np+2]=col.b; np++; }
+- }
+- if(np<2) { delete []cc; return 0; }
+- for(i=0;i<np-1;i++) nc+=mgl_col_dif(cc+3*i,cc+3*i+3,false);
+- c = new unsigned char[3*nc+3];
+- long dd,pos=0;
+- for(i=0;i<np-1;i++)
+- {
+- dd=mgl_col_dif(cc+3*i,cc+3*i+3,false);
+- for(j=0;j<dd;j++)
+- {
+- c[3*(pos+j)] = cc[3*i]+(cc[3*i+3]-cc[3*i])*j/dd;
+- c[3*(pos+j)+1] = cc[3*i+1]+(cc[3*i+4]-cc[3*i+1])*j/dd;
+- c[3*(pos+j)+2] = cc[3*i+2]+(cc[3*i+5]-cc[3*i+2])*j/dd;
+- }
+- pos += dd;
+- }
+- memcpy(c+3*nc-3,cc+3*np-3,3*sizeof(unsigned char));
+- delete []cc;
+- num=nc;
+- return c;
+-}
+-//-----------------------------------------------------------------------------
++/***************************************************************************
++ * data_png.cpp is part of Math Graphic Library
++ * Copyright (C) 2007 Alexey Balakin <balakin at appl.sci-nnov.ru> *
++ * *
++ * This program is free software; you can redistribute it and/or modify *
++ * it under the terms of the GNU Library General Public License as *
++ * published by the Free Software Foundation; either version 3 of the *
++ * License, or (at your option) any later version. *
++ * *
++ * This program is distributed in the hope that it will be useful, *
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
++ * GNU General Public License for more details. *
++ * *
++ * You should have received a copy of the GNU Library General Public *
++ * License along with this program; if not, write to the *
++ * Free Software Foundation, Inc., *
++ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
++ ***************************************************************************/
++#include <stdlib.h>
++#ifndef NO_PNG
++#include <png.h>
++#endif
++#include "mgl/data.h"
++#include <zlib.h>
++//-----------------------------------------------------------------------------
++long mgl_col_dif(unsigned char *c1,unsigned char *c2,bool sum)
++{
++ long res,d1=abs(long(c1[0])-long(c2[0])),
++ d2=abs(long(c1[1])-long(c2[1])),d3=abs(long(c1[2])-long(c2[2]));
++ if(sum) res = d1+d2+d3;
++ else res = mgl_max(d1,mgl_max(d2,d3));
++ return res;
++}
++//-----------------------------------------------------------------------------
++unsigned char *mgl_create_scheme(const char *scheme,long &num)
++{
++ unsigned char *c=0,*cc=new unsigned char[3*strlen(scheme)+3];
++ long nc=1,np=0;
++ register long i,j;
++ mglColor col;
++ for(i=0;i<long(strlen(scheme));i++)
++ {
++ col = mglColor(scheme[i]);
++ if(col.Valid())
++ { cc[3*np]=col.r; cc[3*np+1]=col.g; cc[3*np+2]=col.b; np++; }
++ }
++ if(np<2) { delete []cc; return 0; }
++ for(i=0;i<np-1;i++) nc+=mgl_col_dif(cc+3*i,cc+3*i+3,false);
++ c = new unsigned char[3*nc+3];
++ long dd,pos=0;
++ for(i=0;i<np-1;i++)
++ {
++ dd=mgl_col_dif(cc+3*i,cc+3*i+3,false);
++ for(j=0;j<dd;j++)
++ {
++ c[3*(pos+j)] = cc[3*i]+(cc[3*i+3]-cc[3*i])*j/dd;
++ c[3*(pos+j)+1] = cc[3*i+1]+(cc[3*i+4]-cc[3*i+1])*j/dd;
++ c[3*(pos+j)+2] = cc[3*i+2]+(cc[3*i+5]-cc[3*i+2])*j/dd;
++ }
++ pos += dd;
++ }
++ memcpy(c+3*nc-3,cc+3*np-3,3*sizeof(unsigned char));
++ delete []cc;
++ num=nc;
++ return c;
++}
++//-----------------------------------------------------------------------------
+ void mgl_data_import(HMDT d, const char *fname, const char *scheme,float v1,float v2)
+-{
+- if(v1>=v2) return;
+- long num=0;
+-#ifndef NO_PNG
+- FILE *fp = fopen(fname, "rb");
+- if (!fp) return;
+- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+- if (!png_ptr) { fclose(fp); return; }
+- png_infop info_ptr = png_create_info_struct(png_ptr);
+- if (!info_ptr)
+- { png_destroy_read_struct(&png_ptr,0,0); fclose(fp); return; }
+- png_infop end_info = png_create_info_struct(png_ptr);
+- if (!end_info)
+- { png_destroy_read_struct(&png_ptr,&info_ptr,0); fclose(fp); return; }
+-
+- png_init_io(png_ptr, fp);
+- png_read_png(png_ptr, info_ptr,
+- PNG_TRANSFORM_STRIP_ALPHA|PNG_TRANSFORM_PACKING|
+- PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_EXPAND,0);
+- unsigned char **rows = png_get_rows(png_ptr, info_ptr);
+- unsigned char *c = mgl_create_scheme(scheme,num);
+- if(num>1)
+- {
+- long w=png_get_image_width(png_ptr, info_ptr);
+- long h=png_get_image_height(png_ptr, info_ptr);
+- d->Create(w,h,1);
+- register long i,j,k;
+- long pos=0,val,mval=256;
+- for(i=0;i<d->ny;i++) for(j=0;j<d->nx;j++)
+- {
+- for(mval=256,k=0;k<num;k++)
+- {
+- val = mgl_col_dif(c+3*k,rows[d->ny-i-1]+3*j,true);
+- if(val==0) { pos=k; break; }
+- if(val<mval) { pos=k; mval=val; }
+- }
+- d->a[j+d->nx*i] = v1 + pos*(v2-v1)/num;
+- }
+- }
+- delete []c;
+- png_destroy_read_struct(&png_ptr, &info_ptr,&end_info);
+- fclose(fp);
+-#endif
+-}
+-//-----------------------------------------------------------------------------
++{
++ if(v1>=v2) return;
++ long num=0;
++#ifndef NO_PNG
++ FILE *fp = fopen(fname, "rb");
++ if (!fp) return;
++ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
++ if (!png_ptr) { fclose(fp); return; }
++ png_infop info_ptr = png_create_info_struct(png_ptr);
++ if (!info_ptr)
++ { png_destroy_read_struct(&png_ptr,0,0); fclose(fp); return; }
++ png_infop end_info = png_create_info_struct(png_ptr);
++ if (!end_info)
++ { png_destroy_read_struct(&png_ptr,&info_ptr,0); fclose(fp); return; }
++
++ png_init_io(png_ptr, fp);
++ png_read_png(png_ptr, info_ptr,
++ PNG_TRANSFORM_STRIP_ALPHA|PNG_TRANSFORM_PACKING|
++ PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_EXPAND,0);
++ unsigned char **rows = png_get_rows(png_ptr, info_ptr);
++ unsigned char *c = mgl_create_scheme(scheme,num);
++ if(num>1)
++ {
++ long w=png_get_image_width(png_ptr, info_ptr);
++ long h=png_get_image_height(png_ptr, info_ptr);
++ d->Create(w,h,1);
++ register long i,j,k;
++ long pos=0,val,mval=256;
++ for(i=0;i<d->ny;i++) for(j=0;j<d->nx;j++)
++ {
++ for(mval=256,k=0;k<num;k++)
++ {
++ val = mgl_col_dif(c+3*k,rows[d->ny-i-1]+3*j,true);
++ if(val==0) { pos=k; break; }
++ if(val<mval) { pos=k; mval=val; }
++ }
++ d->a[j+d->nx*i] = v1 + pos*(v2-v1)/num;
++ }
++ }
++ delete []c;
++ png_destroy_read_struct(&png_ptr, &info_ptr,&end_info);
++ fclose(fp);
++#endif
++}
++//-----------------------------------------------------------------------------
+ void mgl_data_export(HCDT dd, const char *fname, const char *scheme,float v1,float v2,long ns)
+-{
+- register long i,j,k;
+- long nx=dd->GetNx(), ny=dd->GetNy(), nz=dd->GetNz();
+- mreal vv;
+- if(v1>v2) return;
+- if(ns<0 || ns>=nz) ns=0;
+- if(v1==v2)
+- {
+- v1 = 1e20; v2=-1e20;
+- for(i=0;i<nx*ny*nz;i++)
+- { vv = dd->vthr(i); if(vv<v1) v1=vv; if(vv>v2) v2=vv; }
+- }
+- if(v1==v2) return;
+-#ifndef NO_PNG
+- long num=0;
+- unsigned char *c = mgl_create_scheme(scheme,num);
+- if(num<2) { delete []c; return; }
+-
+- unsigned char **p = (unsigned char **)malloc(ny*sizeof(unsigned char *));
+- unsigned char *d = (unsigned char *)malloc(3*nx*ny*sizeof(unsigned char));
+- for(i=0;i<ny;i++) p[i] = d+3*nx*(ny-1-i);
+- for(i=0;i<ny;i++) for(j=0;j<nx;j++)
+- {
+- k = long(num*(dd->v(j,i,ns)-v1)/(v2-v1));
+- if(k<0) k=0; if(k>=num) k=num-1;
+- memcpy(d+3*(j+i*nx),c+3*k,3*sizeof(unsigned char));
+- }
+- delete []c;
+-
+- FILE *fp = fopen(fname, "wb");
+- if (!fp) return;
+- png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+- if (!png_ptr) { fclose(fp); return; }
+- png_infop info_ptr = png_create_info_struct(png_ptr);
+- if (!info_ptr)
+- { png_destroy_write_struct(&png_ptr,0); fclose(fp); return; }
+- png_init_io(png_ptr, fp);
+- png_set_filter(png_ptr, 0, PNG_ALL_FILTERS);
+- png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
+- png_set_IHDR(png_ptr, info_ptr, nx, ny, 8, PNG_COLOR_TYPE_RGB,
+- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+- png_set_rows(png_ptr, info_ptr, p);
+- png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, 0);
+- png_write_end(png_ptr, info_ptr);
+- png_destroy_write_struct(&png_ptr, &info_ptr);
+- fclose(fp); free(p); free(d);
+-#endif
+-}
+-//-----------------------------------------------------------------------------
+-void mgl_data_export_(uintptr_t *d, const char *fname, const char *scheme,float *v1,float *v2,int *ns,int l,int n)
+-{
+- char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;
+- char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;
+- mgl_data_export(_DT_,s,f,*v1,*v2,*ns);
+- delete []s; delete []f;
+-}
++{
++ register long i,j,k;
++ long nx=dd->GetNx(), ny=dd->GetNy(), nz=dd->GetNz();
++ mreal vv;
++ if(v1>v2) return;
++ if(ns<0 || ns>=nz) ns=0;
++ if(v1==v2)
++ {
++ v1 = 1e20; v2=-1e20;
++ for(i=0;i<nx*ny*nz;i++)
++ { vv = dd->vthr(i); if(vv<v1) v1=vv; if(vv>v2) v2=vv; }
++ }
++ if(v1==v2) return;
++#ifndef NO_PNG
++ long num=0;
++ unsigned char *c = mgl_create_scheme(scheme,num);
++ if(num<2) { delete []c; return; }
++
++ unsigned char **p = (unsigned char **)malloc(ny*sizeof(unsigned char *));
++ unsigned char *d = (unsigned char *)malloc(3*nx*ny*sizeof(unsigned char));
++ for(i=0;i<ny;i++) p[i] = d+3*nx*(ny-1-i);
++ for(i=0;i<ny;i++) for(j=0;j<nx;j++)
++ {
++ k = long(num*(dd->v(j,i,ns)-v1)/(v2-v1));
++ if(k<0) k=0; if(k>=num) k=num-1;
++ memcpy(d+3*(j+i*nx),c+3*k,3*sizeof(unsigned char));
++ }
++ delete []c;
++
++ FILE *fp = fopen(fname, "wb");
++ if (!fp) return;
++ png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
++ if (!png_ptr) { fclose(fp); return; }
++ png_infop info_ptr = png_create_info_struct(png_ptr);
++ if (!info_ptr)
++ { png_destroy_write_struct(&png_ptr,0); fclose(fp); return; }
++ png_init_io(png_ptr, fp);
++ png_set_filter(png_ptr, 0, PNG_ALL_FILTERS);
++ png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
++ png_set_IHDR(png_ptr, info_ptr, nx, ny, 8, PNG_COLOR_TYPE_RGB,
++ PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
++ png_set_rows(png_ptr, info_ptr, p);
++ png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, 0);
++ png_write_end(png_ptr, info_ptr);
++ png_destroy_write_struct(&png_ptr, &info_ptr);
++ fclose(fp); free(p); free(d);
++#endif
++}
++//-----------------------------------------------------------------------------
++void mgl_data_export_(uintptr_t *d, const char *fname, const char *scheme,float *v1,float *v2,int *ns,int l,int n)
++{
++ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;
++ char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;
++ mgl_data_export(_DT_,s,f,*v1,*v2,*ns);
++ delete []s; delete []f;
++}
+ void mgl_data_import_(uintptr_t *d, const char *fname, const char *scheme,float *v1,float *v2,int l,int n)
+-{
+- char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;
+- char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;
+- mgl_data_import(_DT_,s,f,*v1,*v2);
+- delete []s; delete []f;
+-}
+-//-----------------------------------------------------------------------------
++{
++ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;
++ char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;
++ mgl_data_import(_DT_,s,f,*v1,*v2);
++ delete []s; delete []f;
++}
++//-----------------------------------------------------------------------------
diff --git a/src/data_png.cpp b/src/data_png.cpp
index b1479e3..f70e85f 100644
--- a/src/data_png.cpp
+++ b/src/data_png.cpp
@@ -1,178 +1,179 @@
-/***************************************************************************
- * data_png.cpp is part of Math Graphic Library
- * Copyright (C) 2007 Alexey Balakin <balakin at appl.sci-nnov.ru> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU Library General Public License as *
- * published by the Free Software Foundation; either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#include <stdlib.h>
-#ifndef NO_PNG
-#include <png.h>
-#endif
-#include "mgl/data.h"
-//-----------------------------------------------------------------------------
-long mgl_col_dif(unsigned char *c1,unsigned char *c2,bool sum)
-{
- long res,d1=abs(long(c1[0])-long(c2[0])),
- d2=abs(long(c1[1])-long(c2[1])),d3=abs(long(c1[2])-long(c2[2]));
- if(sum) res = d1+d2+d3;
- else res = mgl_max(d1,mgl_max(d2,d3));
- return res;
-}
-//-----------------------------------------------------------------------------
-unsigned char *mgl_create_scheme(const char *scheme,long &num)
-{
- unsigned char *c=0,*cc=new unsigned char[3*strlen(scheme)+3];
- long nc=1,np=0;
- register long i,j;
- mglColor col;
- for(i=0;i<long(strlen(scheme));i++)
- {
- col = mglColor(scheme[i]);
- if(col.Valid())
- { cc[3*np]=col.r; cc[3*np+1]=col.g; cc[3*np+2]=col.b; np++; }
- }
- if(np<2) { delete []cc; return 0; }
- for(i=0;i<np-1;i++) nc+=mgl_col_dif(cc+3*i,cc+3*i+3,false);
- c = new unsigned char[3*nc+3];
- long dd,pos=0;
- for(i=0;i<np-1;i++)
- {
- dd=mgl_col_dif(cc+3*i,cc+3*i+3,false);
- for(j=0;j<dd;j++)
- {
- c[3*(pos+j)] = cc[3*i]+(cc[3*i+3]-cc[3*i])*j/dd;
- c[3*(pos+j)+1] = cc[3*i+1]+(cc[3*i+4]-cc[3*i+1])*j/dd;
- c[3*(pos+j)+2] = cc[3*i+2]+(cc[3*i+5]-cc[3*i+2])*j/dd;
- }
- pos += dd;
- }
- memcpy(c+3*nc-3,cc+3*np-3,3*sizeof(unsigned char));
- delete []cc;
- num=nc;
- return c;
-}
-//-----------------------------------------------------------------------------
+/***************************************************************************
+ * data_png.cpp is part of Math Graphic Library
+ * Copyright (C) 2007 Alexey Balakin <balakin at appl.sci-nnov.ru> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include <stdlib.h>
+#ifndef NO_PNG
+#include <png.h>
+#endif
+#include "mgl/data.h"
+#include <zlib.h>
+//-----------------------------------------------------------------------------
+long mgl_col_dif(unsigned char *c1,unsigned char *c2,bool sum)
+{
+ long res,d1=abs(long(c1[0])-long(c2[0])),
+ d2=abs(long(c1[1])-long(c2[1])),d3=abs(long(c1[2])-long(c2[2]));
+ if(sum) res = d1+d2+d3;
+ else res = mgl_max(d1,mgl_max(d2,d3));
+ return res;
+}
+//-----------------------------------------------------------------------------
+unsigned char *mgl_create_scheme(const char *scheme,long &num)
+{
+ unsigned char *c=0,*cc=new unsigned char[3*strlen(scheme)+3];
+ long nc=1,np=0;
+ register long i,j;
+ mglColor col;
+ for(i=0;i<long(strlen(scheme));i++)
+ {
+ col = mglColor(scheme[i]);
+ if(col.Valid())
+ { cc[3*np]=col.r; cc[3*np+1]=col.g; cc[3*np+2]=col.b; np++; }
+ }
+ if(np<2) { delete []cc; return 0; }
+ for(i=0;i<np-1;i++) nc+=mgl_col_dif(cc+3*i,cc+3*i+3,false);
+ c = new unsigned char[3*nc+3];
+ long dd,pos=0;
+ for(i=0;i<np-1;i++)
+ {
+ dd=mgl_col_dif(cc+3*i,cc+3*i+3,false);
+ for(j=0;j<dd;j++)
+ {
+ c[3*(pos+j)] = cc[3*i]+(cc[3*i+3]-cc[3*i])*j/dd;
+ c[3*(pos+j)+1] = cc[3*i+1]+(cc[3*i+4]-cc[3*i+1])*j/dd;
+ c[3*(pos+j)+2] = cc[3*i+2]+(cc[3*i+5]-cc[3*i+2])*j/dd;
+ }
+ pos += dd;
+ }
+ memcpy(c+3*nc-3,cc+3*np-3,3*sizeof(unsigned char));
+ delete []cc;
+ num=nc;
+ return c;
+}
+//-----------------------------------------------------------------------------
void mgl_data_import(HMDT d, const char *fname, const char *scheme,float v1,float v2)
-{
- if(v1>=v2) return;
- long num=0;
-#ifndef NO_PNG
- FILE *fp = fopen(fname, "rb");
- if (!fp) return;
- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
- if (!png_ptr) { fclose(fp); return; }
- png_infop info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr)
- { png_destroy_read_struct(&png_ptr,0,0); fclose(fp); return; }
- png_infop end_info = png_create_info_struct(png_ptr);
- if (!end_info)
- { png_destroy_read_struct(&png_ptr,&info_ptr,0); fclose(fp); return; }
-
- png_init_io(png_ptr, fp);
- png_read_png(png_ptr, info_ptr,
- PNG_TRANSFORM_STRIP_ALPHA|PNG_TRANSFORM_PACKING|
- PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_EXPAND,0);
- unsigned char **rows = png_get_rows(png_ptr, info_ptr);
- unsigned char *c = mgl_create_scheme(scheme,num);
- if(num>1)
- {
- long w=png_get_image_width(png_ptr, info_ptr);
- long h=png_get_image_height(png_ptr, info_ptr);
- d->Create(w,h,1);
- register long i,j,k;
- long pos=0,val,mval=256;
- for(i=0;i<d->ny;i++) for(j=0;j<d->nx;j++)
- {
- for(mval=256,k=0;k<num;k++)
- {
- val = mgl_col_dif(c+3*k,rows[d->ny-i-1]+3*j,true);
- if(val==0) { pos=k; break; }
- if(val<mval) { pos=k; mval=val; }
- }
- d->a[j+d->nx*i] = v1 + pos*(v2-v1)/num;
- }
- }
- delete []c;
- png_destroy_read_struct(&png_ptr, &info_ptr,&end_info);
- fclose(fp);
-#endif
-}
-//-----------------------------------------------------------------------------
+{
+ if(v1>=v2) return;
+ long num=0;
+#ifndef NO_PNG
+ FILE *fp = fopen(fname, "rb");
+ if (!fp) return;
+ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+ if (!png_ptr) { fclose(fp); return; }
+ png_infop info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr)
+ { png_destroy_read_struct(&png_ptr,0,0); fclose(fp); return; }
+ png_infop end_info = png_create_info_struct(png_ptr);
+ if (!end_info)
+ { png_destroy_read_struct(&png_ptr,&info_ptr,0); fclose(fp); return; }
+
+ png_init_io(png_ptr, fp);
+ png_read_png(png_ptr, info_ptr,
+ PNG_TRANSFORM_STRIP_ALPHA|PNG_TRANSFORM_PACKING|
+ PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_EXPAND,0);
+ unsigned char **rows = png_get_rows(png_ptr, info_ptr);
+ unsigned char *c = mgl_create_scheme(scheme,num);
+ if(num>1)
+ {
+ long w=png_get_image_width(png_ptr, info_ptr);
+ long h=png_get_image_height(png_ptr, info_ptr);
+ d->Create(w,h,1);
+ register long i,j,k;
+ long pos=0,val,mval=256;
+ for(i=0;i<d->ny;i++) for(j=0;j<d->nx;j++)
+ {
+ for(mval=256,k=0;k<num;k++)
+ {
+ val = mgl_col_dif(c+3*k,rows[d->ny-i-1]+3*j,true);
+ if(val==0) { pos=k; break; }
+ if(val<mval) { pos=k; mval=val; }
+ }
+ d->a[j+d->nx*i] = v1 + pos*(v2-v1)/num;
+ }
+ }
+ delete []c;
+ png_destroy_read_struct(&png_ptr, &info_ptr,&end_info);
+ fclose(fp);
+#endif
+}
+//-----------------------------------------------------------------------------
void mgl_data_export(HCDT dd, const char *fname, const char *scheme,float v1,float v2,long ns)
-{
- register long i,j,k;
- long nx=dd->GetNx(), ny=dd->GetNy(), nz=dd->GetNz();
- mreal vv;
- if(v1>v2) return;
- if(ns<0 || ns>=nz) ns=0;
- if(v1==v2)
- {
- v1 = 1e20; v2=-1e20;
- for(i=0;i<nx*ny*nz;i++)
- { vv = dd->vthr(i); if(vv<v1) v1=vv; if(vv>v2) v2=vv; }
- }
- if(v1==v2) return;
-#ifndef NO_PNG
- long num=0;
- unsigned char *c = mgl_create_scheme(scheme,num);
- if(num<2) { delete []c; return; }
-
- unsigned char **p = (unsigned char **)malloc(ny*sizeof(unsigned char *));
- unsigned char *d = (unsigned char *)malloc(3*nx*ny*sizeof(unsigned char));
- for(i=0;i<ny;i++) p[i] = d+3*nx*(ny-1-i);
- for(i=0;i<ny;i++) for(j=0;j<nx;j++)
- {
- k = long(num*(dd->v(j,i,ns)-v1)/(v2-v1));
- if(k<0) k=0; if(k>=num) k=num-1;
- memcpy(d+3*(j+i*nx),c+3*k,3*sizeof(unsigned char));
- }
- delete []c;
-
- FILE *fp = fopen(fname, "wb");
- if (!fp) return;
- png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
- if (!png_ptr) { fclose(fp); return; }
- png_infop info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr)
- { png_destroy_write_struct(&png_ptr,0); fclose(fp); return; }
- png_init_io(png_ptr, fp);
- png_set_filter(png_ptr, 0, PNG_ALL_FILTERS);
- png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
- png_set_IHDR(png_ptr, info_ptr, nx, ny, 8, PNG_COLOR_TYPE_RGB,
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
- png_set_rows(png_ptr, info_ptr, p);
- png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, 0);
- png_write_end(png_ptr, info_ptr);
- png_destroy_write_struct(&png_ptr, &info_ptr);
- fclose(fp); free(p); free(d);
-#endif
-}
-//-----------------------------------------------------------------------------
-void mgl_data_export_(uintptr_t *d, const char *fname, const char *scheme,float *v1,float *v2,int *ns,int l,int n)
-{
- char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;
- char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;
- mgl_data_export(_DT_,s,f,*v1,*v2,*ns);
- delete []s; delete []f;
-}
+{
+ register long i,j,k;
+ long nx=dd->GetNx(), ny=dd->GetNy(), nz=dd->GetNz();
+ mreal vv;
+ if(v1>v2) return;
+ if(ns<0 || ns>=nz) ns=0;
+ if(v1==v2)
+ {
+ v1 = 1e20; v2=-1e20;
+ for(i=0;i<nx*ny*nz;i++)
+ { vv = dd->vthr(i); if(vv<v1) v1=vv; if(vv>v2) v2=vv; }
+ }
+ if(v1==v2) return;
+#ifndef NO_PNG
+ long num=0;
+ unsigned char *c = mgl_create_scheme(scheme,num);
+ if(num<2) { delete []c; return; }
+
+ unsigned char **p = (unsigned char **)malloc(ny*sizeof(unsigned char *));
+ unsigned char *d = (unsigned char *)malloc(3*nx*ny*sizeof(unsigned char));
+ for(i=0;i<ny;i++) p[i] = d+3*nx*(ny-1-i);
+ for(i=0;i<ny;i++) for(j=0;j<nx;j++)
+ {
+ k = long(num*(dd->v(j,i,ns)-v1)/(v2-v1));
+ if(k<0) k=0; if(k>=num) k=num-1;
+ memcpy(d+3*(j+i*nx),c+3*k,3*sizeof(unsigned char));
+ }
+ delete []c;
+
+ FILE *fp = fopen(fname, "wb");
+ if (!fp) return;
+ png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+ if (!png_ptr) { fclose(fp); return; }
+ png_infop info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr)
+ { png_destroy_write_struct(&png_ptr,0); fclose(fp); return; }
+ png_init_io(png_ptr, fp);
+ png_set_filter(png_ptr, 0, PNG_ALL_FILTERS);
+ png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
+ png_set_IHDR(png_ptr, info_ptr, nx, ny, 8, PNG_COLOR_TYPE_RGB,
+ PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+ png_set_rows(png_ptr, info_ptr, p);
+ png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, 0);
+ png_write_end(png_ptr, info_ptr);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+ fclose(fp); free(p); free(d);
+#endif
+}
+//-----------------------------------------------------------------------------
+void mgl_data_export_(uintptr_t *d, const char *fname, const char *scheme,float *v1,float *v2,int *ns,int l,int n)
+{
+ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;
+ char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;
+ mgl_data_export(_DT_,s,f,*v1,*v2,*ns);
+ delete []s; delete []f;
+}
void mgl_data_import_(uintptr_t *d, const char *fname, const char *scheme,float *v1,float *v2,int l,int n)
-{
- char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;
- char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;
- mgl_data_import(_DT_,s,f,*v1,*v2);
- delete []s; delete []f;
-}
-//-----------------------------------------------------------------------------
+{
+ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;
+ char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;
+ mgl_data_import(_DT_,s,f,*v1,*v2);
+ delete []s; delete []f;
+}
+//-----------------------------------------------------------------------------
--
Packaging for mathgl
More information about the debian-science-commits
mailing list