예제 #1
0
        public static BitmapImage[] getBitmaps(SeismicBitmapInfo[] infos)
        {
            BitmapImage[] bitmaps = new BitmapImage[infos.Length];
            int i = 0;
            foreach (SeismicBitmapInfo sbi in infos)
            {
                bitmaps[i] = infos[i].bitmapImage;
                i++;
            }

            return bitmaps;
        }
예제 #2
0
        public void insertSeismicInfoIntoListTest()
        {
            List<SeismicBitmapInfo> List = new List<SeismicBitmapInfo>();
            SeismicBitmapInfo sbi = new SeismicBitmapInfo();
            SeismicBitmapInfo sbi1 = new SeismicBitmapInfo();
            SeismicBitmapInfo sbi2 = new SeismicBitmapInfo();
            SeismicBitmapInfo sbi3 = new SeismicBitmapInfo();

            sbi.line = new LineSegment(new SeismicUtilities.Point(1, 1), new SeismicUtilities.Point(5, 5));
            sbi1.line = new LineSegment(new SeismicUtilities.Point(1,0), new SeismicUtilities.Point(5,4));
            sbi2.line = new LineSegment(new SeismicUtilities.Point(1, 3), new SeismicUtilities.Point(5, 7));
            sbi3.line = new LineSegment(new SeismicUtilities.Point(1, 2), new SeismicUtilities.Point(5, 6));

            FileUtilities_Accessor.insertSeismicInfoIntoList(List, sbi);
            FileUtilities_Accessor.insertSeismicInfoIntoList(List, sbi1);
            FileUtilities_Accessor.insertSeismicInfoIntoList(List, sbi2);
            FileUtilities_Accessor.insertSeismicInfoIntoList(List, sbi3);

            Assert.IsTrue(List.Count == 4);
            SeismicBitmapInfo[] testarray = List.ToArray();

            Assert.AreEqual(sbi1, testarray[0]);
            Assert.AreEqual(sbi, testarray[1]);
            Assert.AreEqual(sbi3, testarray[2]);
            Assert.AreEqual(sbi2, testarray[3]);
        }
예제 #3
0
        private void initializeBitmapWithInfo(SeismicBitmapInfo[] bitmapInfos)
        {
            if (bitmapInfos.Length < 2)
            {
                //One line? REDO!

                return;
            }

            LineSegment firstLine = bitmapInfos.First().line;
            LineSegment lastLine = bitmapInfos.Last().line;
            this.offsetPoint = firstLine.lowerBound;
            //The shortest line will dictate the width of the rectangle created from a list of nearly parallel lines
            this.regionWidth = FileUtilities.getMinLineLengthFromInfo(bitmapInfos);

            //Region height is the perpendicular distance from the offset point, to the last lines lowest bound
            //Creates a perpendicular line at the first lines lwoer bound
            Line perpendicularLine = new Line(new Point(firstLine.lowerBound.x, firstLine.lowerBound.y), new Point(firstLine.upperBound.x, firstLine.upperBound.y));
            bool infiniteIntersections = false;

            if (firstLine.isInfiniteSlope)
            {
                perpendicularLine.slope = 0;
                perpendicularLine.isZeroSlope = true;
                perpendicularLine.yintercept = firstLine.lowerBound.y;
            }
            else if (firstLine.isZeroSlope)
            {
                perpendicularLine.slope = 0;
                perpendicularLine.isInfiniteSlope = true;
                perpendicularLine.xintercept = firstLine.lowerBound.x;
            }
            else
            {
                perpendicularLine = new Line(-1 / firstLine.slope, 1 / firstLine.slope * firstLine.lowerBound.x + firstLine.lowerBound.y);
            }

            Point intersectionPoint = perpendicularLine.intersectsLine(lastLine, ref infiniteIntersections);

            if (infiniteIntersections)
            {
                //Shouldnt be possible becasue the lines should be nearly parallel!

                return;
            }

            this.regionHeight = intersectionPoint.distanceTo(firstLine.lowerBound);

            //Find the bitmaps rotation relative to positive x axis
            //this.rotation = Math.Atan((bitmapInfos.First().two.y - bitmapInfos.First().one.y) / (bitmapInfos.First().two.x - bitmapInfos.First().one.x));
            this.rotation = Math.Atan((firstLine.upperBound.y - firstLine.lowerBound.y) / (firstLine.upperBound.x - firstLine.lowerBound.x));
            int i = 0;
            //if (bitmapInfos.First().one.x < bitmapInfos.First().two.x)
            //    this.offsetPoint = bitmapInfos.First().one;
            //else if (bitmapInfos.First().one.x > bitmapInfos.First().two.x)
            //    this.offsetPoint = bitmapInfos.First().two;
            //else
            //{
            //    if (bitmapInfos.First().one.y < bitmapInfos.First().two.y)
            //        this.offsetPoint = bitmapInfos.First().one;
            //    else if (bitmapInfos.First().one.y > bitmapInfos.First().two.y)
            //        this.offsetPoint = bitmapInfos.First().two;
            //    else
            //    {
            //        //The points are equal
            //        this.offsetPoint = bitmapInfos.First().one;
            //    }
            //}

            //this.regionWidth = bitmapInfos.First().one.distanceTo(bitmapInfos.First().two);
            //this.regionHeight = bitmapInfos.Last().one.distanceTo(bitmapInfos.First().one);
            //this.rotation = Math.Atan((bitmapInfos.First().two.y - bitmapInfos.First().one.y) / (bitmapInfos.First().two.x - bitmapInfos.First().one.x));
        }
예제 #4
0
 public static int findHeightFromBitmaps(SeismicBitmapInfo[] bitmaps)
 {
     //Determine how many different images you want. this combined with the rule for setting each y value in the bitmap will determine how to populate the bitmap3D
     return 50;
 }
예제 #5
0
        public static SeismicBitmapInfo[] getBitmapsInfoFromDirectory()
        {
            var applicationDirectory = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "Resources\\";

            //will return a list of seismic data
            string[] jpgFiles = Directory.GetFiles(applicationDirectory, imageJPGExtension);
            string[] dataFiles = Directory.GetFiles(applicationDirectory, dataExtension);

            if (dataFiles.Length != 1 || jpgFiles.Length == 0)
                return null;

            StreamReader dataReader = new StreamReader(dataFiles[0]);
            int lineCount = 0;
            while (dataReader.ReadLine() != null)
                lineCount++;

            dataReader.BaseStream.Position = 0;
            dataReader.DiscardBufferedData();

            if (lineCount % 3 != 0)
                return null;//The number of lines must be a multiple of 3, because 1 piece of "data" requires 3 lines, line name, 2 lat/long points

            int numberOfSeismicImages = lineCount / 3;

            if (numberOfSeismicImages != jpgFiles.Length)
                return null;

            List<SeismicBitmapInfo> bitmapInfoCollection = new List<SeismicBitmapInfo>();
            string[] dataStrings = new string[3];
            SeismicBitmapInfo newinfo;
            for (int i = 0; i < numberOfSeismicImages; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    dataStrings[j] = dataReader.ReadLine();
                }

                string lineFileName = getLineFileFromString(applicationDirectory, dataStrings[0]);
                if (!jpgFiles.Contains(lineFileName))
                    continue;//You only create and populate info for lines that both exist in the data file, and have corresponding image file

                newinfo = new SeismicBitmapInfo();
                newinfo.line = new LineSegment(getLatLongPointFromString(dataStrings[1]), getLatLongPointFromString(dataStrings[2]));
                newinfo.bitmapName = lineFileName;
                newinfo.bitmapImage = new BitmapImage(new Uri(lineFileName, UriKind.Relative));
                newinfo.lineNumber = getLineNumberFromString(dataStrings[0]);
                //bitmapInfoCollection.Add(newinfo);
                insertSeismicInfoIntoList(bitmapInfoCollection, newinfo);
            }

            //bitmapInfoCollection.Reverse();

            return bitmapInfoCollection.ToArray();
        }
예제 #6
0
        private static void insertSeismicInfoIntoList(List<SeismicBitmapInfo> List, SeismicBitmapInfo sbi)
        {
            //Checks the line numbers and inserts it into a sorted list
            if (List == null)
                List = new List<SeismicBitmapInfo>();

            if (List.Count == 0)
            {
                List.Insert(0, sbi);
                return;
            }

            for (int i = 0; i < List.Count; i++)
            {
                if (sbi.line.lowerBound.y < List.ElementAt(i).line.lowerBound.y || (sbi.line.lowerBound.y == List.ElementAt(i).line.lowerBound.y && sbi.line.lowerBound.x < List.ElementAt(i).line.lowerBound.x))
                {
                    List.Insert(i, sbi);
                    return;
                }

                //if (sbi.lineNumber > List.ElementAt(i).lineNumber)
                //{
                //    List.Insert(i, sbi);
                //    return;
                //}
            }

            List.Add(sbi);
        }
예제 #7
0
        public static double getMinLineLengthFromInfo(SeismicBitmapInfo[] bitmapInfo)
        {
            if (bitmapInfo == null || bitmapInfo.Length == 0)
                return 0;

            double minLength = bitmapInfo[0].line.lowerBound.distanceTo(bitmapInfo[0].line.upperBound);

            foreach (SeismicBitmapInfo info in bitmapInfo)
            {

                if (info.line.lowerBound.distanceTo(info.line.upperBound) < minLength)
                    minLength = info.line.lowerBound.distanceTo(info.line.upperBound);
            }

            return minLength;
        }
예제 #8
0
        public static System.Windows.Size getMinBitmapImageSizeFromInfo(SeismicBitmapInfo[] bitmapInfo)
        {
            if (bitmapInfo == null || bitmapInfo.Length == 0)
                return new System.Windows.Size(0, 0);

            int minWidth = bitmapInfo[0].bitmapImage.PixelWidth, minHeight = bitmapInfo[0].bitmapImage.PixelHeight;

            foreach (SeismicBitmapInfo info in bitmapInfo)
            {
                if (info.bitmapImage.PixelWidth < minWidth)
                    minWidth = info.bitmapImage.PixelWidth;

                if (info.bitmapImage.PixelHeight < minHeight)
                    minHeight = info.bitmapImage.PixelHeight;
            }

            return new System.Windows.Size(minWidth, minHeight);
        }