예제 #1
0
        private void ButtonGo_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            DialogResult dr = sfd.ShowDialog();
            if (dr == DialogResult.OK)
            {
                DMSImage source;
                if (TextBoxSource.Text == String.Empty)
                    source = new DMSImage(new TestPattern(new Size(6000, 3000), Color.FromArgb(114, 115, 181), Color.FromArgb(229, 229, 229), TestPatternType.EquirectCheckerBoardPlane, 30, 5));
                else if (TextBoxSource.Text == "quasi")
                    source = null;
                else
                    source = new DMSImage(TextBoxSource.Text);

                Net net = checkTriangular.Checked ? new TriangularNet(TextBoxNet.Text) : new Net(TextBoxNet.Text);
                DMSImage dest;

                if (RadioStereographic.Checked)
                    dest = new DMSImage(new NetMap(new Size(3000, 1500), source, Color.Gray, net, NetMap.XfrmMode.Stereographic));
                else if (radioLagrange.Checked)
                    dest = new DMSImage(new NetMap(new Size(3600, 3600), source, Color.Gray, net, NetMap.XfrmMode.Lagrange));
                else if (TextBoxSource.Text == "quasi")
                    dest = new DMSImage(new NetMap(new Size(1500, 1500), source, Color.White, net, NetMap.XfrmMode.Quasiconformal));
                else //default
                    dest = new DMSImage(new NetMap(new Size(3000, 3000), source, Color.White, net));

                dest.Save(sfd.FileName);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            //check arguments
            if (args.Count() < 2)
            {
                System.Console.WriteLine("Usage: EQtoSTL <pano_in> <stl_out>");
                return;
            }

            //load image
            DMSImage pano = new DMSImage(args[0]);

            /**
             * Build and write out the file
             */
            Surface Final = new PanoSurface(WHITE_RADIUS, BLACK_RADIUS, pano, 350000);
            Final.AddSurface(new Sphere(SHELL_RADIUS, 6, SHELL_RADIUS > WHITE_RADIUS)); //shell
            SurfaceTools.PunchHole( ref Final, Point3D.ZAxis.ScaledTo(WHITE_RADIUS), Point3D.ZAxis, 3.0, 1.5);

            StreamWriter sw = new StreamWriter(args[1]);
            sw.WriteLine("solid eqtostl");

            Final.Output(sw, 1.0);

            sw.WriteLine("endsolid");
            sw.Close();
        }
예제 #3
0
        //constructors;
        public Filler(DMSImage Source)
            : base(new Size(Source.Width, Source.Height), Source, Color.Gray)
        {
            m_pixelindex = new Dictionary<int, int>();
            m_pixels = new List<PixelInfo>();
            m_resolution = START_RESOLUTION;
            m_rand = new Random();
            double delta = 0;
            int iter = 0;

            while (m_pixels.Count < MIN_PIXELS || delta > DELTA_THRESHOLD && iter < MAX_ITERS)
            {
                if (iter == MAX_ITERS || delta < DELTA_THRESHOLD)
                {
                    iter = 0;
                    m_resolution >>= 1;
                    if (m_resolution == 0) break;
                    Console.Write("\n" + m_resolution);

                    //bring on new pixels if necessary
                    for (int u = 0; u < Source.Width; u += m_resolution)
                    {
                        for (int v = 0; v < Source.Height; v += m_resolution)
                        {
                            if (GetPixelHelper(u, v) == null)
                            {
                                PixelInfo newpixel = new PixelInfo(u, v, new Point3D());
                                newpixel.SetNeighbors(m_Source, m_resolution);
                                SetAvgColour(newpixel);

                                m_pixels.Add(newpixel);
                                m_pixelindex.Add(v * Source.Width + u, m_pixels.Count() - 1);
                            }
                        }
                    }
                }
                else
                {
                    iter++;
                }

                Console.Write('.');

                //do the averaging!
                delta = 0.0;
                if (m_pixels.Count() == 0) continue;
                for (int i = 0; i < 10000; i++)
                {
                    int idx = m_rand.Next(m_pixelindex.Count());
                    idx = m_pixelindex.Keys.ToArray()[idx];
                    int u = idx % Source.Width;
                    int v = idx / Source.Width;
                    int pixelidx = m_pixelindex[idx];

                    delta += SetAvgColour(m_pixels[pixelidx]);
                }
            }
            Console.WriteLine();
        }
예제 #4
0
 public Form1()
 {
     InitializeComponent();
     SetTarget( RectangleF.Empty );
     m_saveimg = null;
     m_savegm = null;
     m_outputfilename = String.Empty;
 }
예제 #5
0
 public ConformShapes(Net net)
 {
     m_net = net;
     m_type = ConformShapeType.FixFrame;
     m_mask = null;
     m_bFirstPass = true;
     m_Ratio = 1.0;
 }
예제 #6
0
 public Globedrawer( int size, DMSImage source, Color Background, Skeleton skeleton, bool bOrthographic = true )
     : base(new Size(bOrthographic?size:2*size, size), source, Background)
 {
     m_bOrthographic = bOrthographic;
     m_Skeleton = skeleton;
     m_radius = size/2;
     m_center = new Point2D(m_radius, m_radius);
 }
예제 #7
0
 //standard constructor
 public Globemaker( Size size, DMSImage source, Color Background, Skeleton skeleton )
     : base(size, source, Background)
 {
     m_Skeleton = skeleton;
     m_Target = new RectangleF( (float)(m_Skeleton.GetMinPt().X - Math.PI),
                                (float)(m_Skeleton.GetMinPt().Y - Math.PI),
                                (float)(m_Skeleton.GetMaxPt().X - m_Skeleton.GetMinPt().X + DMS.TAU),
                                (float)(m_Skeleton.GetMaxPt().Y - m_Skeleton.GetMinPt().Y + DMS.TAU) );
 }
예제 #8
0
 public Droste(DMSImage Source, Point2D SrcCenter, double SrcInnerRad, double SrcOuterRad,
                Size DstSize, Point2D DstCenter, double DstTwistFactor,
                Color Blank)
     : base(DstSize, Source, Blank)
 {
     m_srcCenter = SrcCenter;
     m_dstCenter = DstCenter;
     m_outerRadius = Math.Max(SrcOuterRad, SrcInnerRad);
     m_innerRadius = Math.Min(SrcOuterRad, SrcInnerRad);
     m_Tightness = m_outerRadius / m_innerRadius;
     m_TwistFactor = DstTwistFactor;
 }
예제 #9
0
 //constructors;
 public OctahedronUnit(Size size, DMSImage Source, Point3D center, Point3D topRight)
     : base(size, Source)
 {
     O = center.Normalized;
     F = Point3D.Cross(center, topRight).Normalized;
     A = Point3D.Cross(F, O);
     H = -A;
     C = -F;
     B = (O + A + C).ScaledTo(2.0 / Math.Sqrt(3.0));
     E = (O + C + H).ScaledTo(2.0 / Math.Sqrt(3.0));
     G = (O + F + H).ScaledTo(2.0 / Math.Sqrt(3.0));
     D = (O + F + A).ScaledTo(2.0 / Math.Sqrt(3.0));
 }
예제 #10
0
        public void fastSave(String filename)
        {
            Rectangle image_rect = new Rectangle(0, 0, m_rainbow.Width, m_rainbow.Height);
            DMSImage output = new DMSImage(image_rect.Size);

            BitmapData output_data = output.Bitmap.LockBits(image_rect, ImageLockMode.WriteOnly, DMSImage.pixel_format);
            BitmapData rainbow_data = m_rainbow.Bitmap.LockBits(image_rect, ImageLockMode.ReadOnly, DMSImage.pixel_format);
            BitmapData source_data = m_Source.Bitmap.LockBits(new Rectangle(0, 0, m_Source.Bitmap.Width, m_Source.Bitmap.Height), ImageLockMode.ReadOnly, DMSImage.pixel_format);

            unsafe
            {
                byte* map = (byte*)rainbow_data.Scan0;
                byte* dest = (byte*)output_data.Scan0;
                for (int i = 0; i < m_rainbow.Height * m_rainbow.Width; i++)
                {
                    byte b = *map++;
                    byte g = *map++;
                    byte r = *map++;
                    map++;

                    if (r == 0x80 && g == 0x80 && b == 0x80)
                    {
                        *dest++ = 0x80;
                        *dest++ = 0x80;
                        *dest++ = 0x80;
                        *dest++ = 0xFF;
                    }
                    else
                    {
                        int x;
                        int y;
                        XYFromRGB(r, g, b, out x, out y);

                        byte* output_color = (byte*)source_data.Scan0 +
                                                    y * source_data.Stride +
                                                    x * 4;
                        *dest++ = *output_color++;
                        *dest++ = *output_color++;
                        *dest++ = *output_color++;
                        *dest++ = *output_color++;
                    }
                }
            }

            output.Bitmap.UnlockBits(output_data);
            m_rainbow.Bitmap.UnlockBits(rainbow_data);
            m_Source.Bitmap.UnlockBits(source_data);

            output.Save(filename);
        }
예제 #11
0
        private void bg_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (m_outputfilename == String.Empty)  return;

            if (m_savegm != null)
            {
                m_saveimg = null;
                if (m_outputfilename == String.Empty)
                    return;
                m_saveimg = new DMSImage(m_savegm);
                m_saveimg.Save(m_outputfilename);
            }
            else if( m_saverr != null)
            {
            m_saverr.fastSave(m_outputfilename);
            }
        }
예제 #12
0
        public Stippler(int nPoints, String SourceFileName)
        {
            try { m_Source = new DMSImage(SourceFileName); }
            catch { m_Source = null; }

            //add the cities
            for (int i = 0; i < nPoints; i++) AddCity();

            m_NeighborList = new List<int> [nPoints];
            for (int i = 0; i < nPoints; i++)
                m_NeighborList[i] = new List<int>();

            // upper bound calculated by dividing 4pi sr by num cities and getting the radius of a spherical cap with that area
            m_YangSearchRadius = Math.Acos(1.0 - 2.0 / m_Cities.Count());

            //based on amount of blank space, and number of cities, st. 60 cities yields a 0.025 jitter radius
            m_JitterRadius = 0.193649167 / Math.Sqrt((double)m_Cities.Count() / (m_totalareacount - m_emptyareacount) * m_totalareacount);
            m_JitterRadius /= m_SumGreyValues / m_Cities.Count();
        }
예제 #13
0
        public Stippler(String CSVFilename, String SourceFileName )
        {
            try { m_Source = new DMSImage(SourceFileName); }
            catch { m_Source = null; }

            StreamReader sr = new StreamReader(CSVFilename);
            while (!sr.EndOfStream)
            {
                String linein = sr.ReadLine();
                string[] split = linein.Split(new Char[] { ',' });
                m_Cities.Add(new Point3D(double.Parse(split[0]), double.Parse(split[1]), double.Parse(split[2])));
            }

            m_NeighborList = new List<int>[m_Cities.Count];
            for (int i = 0; i < m_Cities.Count; i++)
                m_NeighborList[i] = new List<int>();

            // upper bound calculated by dividing 4pi sr by num cities and getting the radius of a spherical cap with that area
            m_YangSearchRadius = Math.Acos(1.0 - 2.0 / m_Cities.Count());
        }
예제 #14
0
        double m_y; //distance travelled along the stripe per turn

        #endregion Fields

        #region Constructors

        //constructors;
        public SpiralText(DMSImage Source, int lines)
            : base(new Size(4000, 2000),
                    Source, 
                    Color.Gray)
        {
            //some preliminaries
            m_maxStretched = 90.0;
            m_maxUnstretched = unstretch(m_maxStretched);
            m_stretchFactor = m_maxStretched / m_maxUnstretched;

            //deal with the lines
            m_linesInSource = lines;
            m_textStripeSize = new SizeF( (float)m_Source.Width * (float)m_linesInSource,
                                          (float)m_Source.Height / (float)m_linesInSource );
            m_stretchedSize = new SizeF((float)m_Source.Width * (float)m_linesInSource * (float)m_stretchFactor,
                                        (float)m_Source.Height / (float)m_linesInSource);
            m_alpha = alphaFromAspectRatio(m_stretchedSize.Width / m_stretchedSize.Height);
            m_x = DMS.TAU * Math.Tan(m_alpha);
            m_y = DMS.TAU / Math.Cos(m_alpha);
            m_n = DMS.HALFTAU / m_x - 1.0;
        }
예제 #15
0
        static void Main(string[] args)
        {
            //Usage
            if( args.Count() != 3 && args.Count() != 2 )
            {
                Console.WriteLine( "Usage globedrawer <SkeletonName.skl> <OutputImg> [SourceImg]\n\n" );
                return;
            }

            //Read in Skeleton
            Skeleton skel = new Skeleton( args[0] );

            //Read in Source image
            DMSImage source = null;
            if( args.Count() == 3 )
                source = new DMSImage(args[2]);

            bool bDrawAsSphere = false;
            Globedrawer drawer = new Globedrawer(1500, source, Color.Gray, skel, bDrawAsSphere);

            DMSImage output = new DMSImage(drawer);
            output.Save(args[1]);
        }
예제 #16
0
        //constructors;
        public Palette(DMSImage SourcePixels, DMSImage Target)
            : base(new Size(Target.Width, Target.Height))
        {
            Random rnd = new Random();
            int u, v, i;

            //set up histogram tables.
            m_sourceTable = new double[256];
            m_targetTable = new double[256];
            for (i = 0; i < 256; i++)
            {
                m_sourceTable[i] = 0;
                m_targetTable[i] = 0;
            }

            m_totalSourcePixels = 0.0;
            for (u = 0; u < SourcePixels.Width; u++)
            {
                for (v = 0; v < SourcePixels.Height; v++)
                {
                    Color pixel = SourcePixels.GetPixel(u, v);

                    m_sourceTable[pixel.R] += (double)pixel.A / 255.0;
                    m_totalSourcePixels += (double)pixel.A / 255.0;
                }
            }

            for( u = 0; u < Target.Width; u++ )
            {
                for (v = 0; v < Target.Height; v++)
                {
                    m_targetTable[Target.GetPixel(u, v).R]++;
                }
            }

            //scale source pixels to equal total number of target pixels.
            double factor = (double)Target.Height * Target.Width / m_totalSourcePixels;
            for ( i = 0; i < 256; i++)
                m_sourceTable[i] *= factor;

            //set targetTable such that targetTable[i-1] .. targetTable[i] is the range of pixel indices of value i;
            for (i = 1; i < 256; i++)
                m_targetTable[i] += m_targetTable[i - 1];

            //okay now set each pixel
            for (u = 0; u < Target.Width; u++)
            {
                for (v = 0; v < Target.Height; v++)
                {
                    int pixelValue = Target.GetPixel(u, v).R;
            #if false
                    //find out how far we are into the histogram.
                    double index = (pixelValue == 0) ? 0 : m_targetTable[pixelValue - 1];
                    index += rnd.NextDouble() * (m_targetTable[pixelValue] - index);  //this randomization effects a dithering
            #else
                    m_targetTable[pixelValue]--;
                    if (m_targetTable[pixelValue] < 0) m_targetTable[pixelValue] = 0;
                    double index = m_targetTable[pixelValue];
            #endif

                    //now which value in source has this pixel?
                    double sum=0;
                    for( i=0; i<256; i++ )
                    {
                        if( sum + m_sourceTable[i] >= index )
                            break;
                        sum += m_sourceTable[i];
                    }

                    SetPixel(u,v,Color.FromArgb(i,i,i));
                }
            }
        }
예제 #17
0
 public Icosahedral(DMSImage source)
     : base(source)
 {
 }
예제 #18
0
 public Tetrahedral(DMSImage source)
     : base(source)
 {
 }
예제 #19
0
 public Octohedral(DMSImage source)
     : base(source)
 {
 }
예제 #20
0
 public Kaleidoscopic(DMSImage source)
     : base(new Size(3000, 1500), source)
 {
     m_hasSource = true;
 }
예제 #21
0
 //standard constructor
 public RainbowRenderer( Size size, DMSImage source, Color background, DMSImage rainbow )
     : base(size, source, background)
 {
     m_rainbow = rainbow;
 }
예제 #22
0
        public void SetNeighbors(DMSImage Source, int resolution)
        {
            if (resolution >= m_savedResolution)
                return;
            m_savedResolution = resolution;

            if (_V != 0 && (Up == 0 || Up > resolution))
            {
                for (Up = 1; Up < resolution; Up++)
                {
                    if (_V - Up < 0)
                    {
                        Up = 0;
                        break;
                    }
                    if (Source.GetPixel(_U, _V - Up).A != 0)
                        break;
                }
            }

            if (_V != Source.Height - 1 && (Down == 0 || Down > resolution))
            {
                for (Down = 1; Down < resolution; Down++)
                {
                    if (_V + Down >= Source.Height)
                    {
                        Down = 0;
                        break;
                    }
                    if (Source.GetPixel(_U, _V + Down).A != 0)
                        break;
                }
            }

            if (_U != 0 && (Left == 0 || Left > resolution))
            {
                for (Left = 1; Left < resolution; Left++)
                {
                    if (_U - Left < 0)
                    {
                        Left = 0;
                        break;
                    }
                    if (Source.GetPixel(_U - Left, _V).A != 0)
                        break;
                }
            }

            if (_U != Source.Width - 1 && (Right == 0 || Right > resolution))
            {
                for (Right = 1; Right < resolution; Right++)
                {
                    if (_U + Right >= Source.Width)
                    {
                        Right = 0;
                        break;
                    }
                    if (Source.GetPixel(_U + Right, _V).A != 0)
                        break;
                }
            }
        }
예제 #23
0
 public RainbowRenderer(DMSImage source, Color background, DMSImage rainbow)
     : base(new Size(rainbow.Width, rainbow.Height), source, background)
 {
     m_rainbow = rainbow;
 }
예제 #24
0
 public Bookball( Size size, DMSImage source, Color Background )
     : base(new Size(size.Width,size.Width*3/4), source, Background)
 {
     nRectWidth = size.Width / 10;
     nRectHeight = nRectWidth * 5 / 4;
 }
예제 #25
0
 public StretchRadius(DMSImage source, double NewSymmetry)
     : base(new Size(source.Width, source.Height), source, Color.Gray)
 {
     m_Symmetry = NewSymmetry;
 }
 //constructors;
 public Stereographic2Equirectangular(DMSImage Source, int height)
     : base(new Size(height*2, height), Source)
 {
 }
예제 #27
0
 public NetMap(System.Drawing.Size size, DMSImage source, Color Background, Net net, XfrmMode mode)
     : this(size, source, Background, net)
 {
     m_Xfrm = mode;
 }
예제 #28
0
 public ConformShapes(Net net, ConformShapeType type, String filename)
     : this(net, type)
 {
     m_mask = new DMSImage(filename);
 }
예제 #29
0
 public ConformShapes(Net net, ConformShapeType type, String filename, double ratio)
     : this(net, type)
 {
     m_mask = new DMSImage(filename);
     m_Ratio = ratio;
 }
예제 #30
0
 //private static Rotation tweak = new Rotation();
 public NetMap( System.Drawing.Size size, DMSImage source, Color Background, Net net )
     : base(size, source, Background)
 {
     m_Net = net;
 }