public void getLatLongPointFromStringTest() { string s = "25,25"; SeismicUtilities.Point expected = new SeismicUtilities.Point(25, 25); SeismicUtilities.Point actual = FileUtilities_Accessor.getLatLongPointFromString(s); Assert.AreEqual(expected.x, actual.x); Assert.AreEqual(expected.y, actual.y); s = "0,15"; expected = new SeismicUtilities.Point(0, 15); actual = FileUtilities_Accessor.getLatLongPointFromString(s); Assert.AreEqual(expected.x, actual.x); Assert.AreEqual(expected.y, actual.y); }
public void GetCrossSectionForBuiltinLines() { SeismicUtilities.Point anchorPoint = myClient.GetSeismicAreaAnchorPoint(); double Rotation = myClient.GetSeismicRotation(); double areaHeight = myClient.GetSeismicAreaHeight(); double areaWidth = myClient.GetSeismicAreaWidth(); //System.Diagnostics.Debug.WriteLine(myAnchorPoint.x + " " + myAnchorPoint.y); //System.Diagnostics.Debug.WriteLine(Rotation); //System.Diagnostics.Debug.WriteLine(areaHeight); //System.Diagnostics.Debug.WriteLine(areaWidth); SeismicUtilities.Point bottomLeft = new SeismicUtilities.Point(anchorPoint.x, anchorPoint.y); SeismicUtilities.Point topLeft = new SeismicUtilities.Point(anchorPoint.x, anchorPoint.y + areaHeight); SeismicUtilities.Point bottomRight = new SeismicUtilities.Point(anchorPoint.x + areaWidth, anchorPoint.y); SeismicUtilities.Point topRight = new SeismicUtilities.Point(anchorPoint.x + areaWidth, anchorPoint.y + areaHeight); topLeft = topLeft.rotatePointAboutPoint(Rotation, bottomLeft); bottomRight = bottomRight.rotatePointAboutPoint(Rotation, bottomLeft); topRight = topRight.rotatePointAboutPoint(Rotation, bottomLeft); System.Diagnostics.Debug.WriteLine(bottomLeft.x + " " + bottomLeft.y); System.Diagnostics.Debug.WriteLine(topLeft.x + " " + topLeft.y); System.Diagnostics.Debug.WriteLine(topRight.x + " " + topRight.y); System.Diagnostics.Debug.WriteLine(bottomRight.x + " " + bottomRight.y); SeismicUtilities.Bitmap2D bitmap = myClient.GetSeismicCrossSection( bottomLeft.x, bottomLeft.y, topRight.x, topRight.y); if (bitmap != null) { BitmapSource bitmapsource = BitmapSource.Create( (int)bitmap.getBitmap2dWidth(), (int)bitmap.getBitmap2dHeight(), 96.0, 96.0, PixelFormats.Bgr32, null, bitmap.getImageData(), (int)(bitmap.getBitmap2dWidth() * PixelFormats.Bgr32.BitsPerPixel / 8)); MyImage.Source = bitmapsource; //System.Diagnostics.Debug.WriteLine(bitmapsource.PixelHeight + " " + bitmapsource.PixelWidth); } else System.Diagnostics.Debug.WriteLine("no bitmap2d"); }
void imageLeft_MouseDown(object sender, MouseButtonEventArgs e) { if (!mouseonedown) { recreateGrid(); imagepointone = new SeismicUtilities.Point(e.GetPosition(imageLeft).X, arraySpaceImageHeight - e.GetPosition(imageLeft).Y); screenpointone = new SeismicUtilities.Point(e.GetPosition(this).X, arraySpaceImageHeight - e.GetPosition(this).Y); mouseonedown = true; Line.Visibility = Visibility.Hidden; } else { imagepointtwo = new SeismicUtilities.Point(e.GetPosition(imageLeft).X, arraySpaceImageHeight - e.GetPosition(imageLeft).Y); screenpointtwo = new SeismicUtilities.Point(e.GetPosition(this).X, arraySpaceImageHeight - e.GetPosition(this).Y); mouseonedown = false; //Draw line Line.X1 = screenpointone.x; Line.X2 = screenpointtwo.x; Line.Y1 = arraySpaceImageHeight - screenpointone.y; Line.Y2 = arraySpaceImageHeight - screenpointtwo.y; crossSectionBitmap2D = SeismicServiceClient.GetSeismicCrossSection(imagepointone.x, imagepointone.y, imagepointtwo.x, imagepointtwo.y); ///crossSectionBitmap2D = SCSG.generate2DCrossSection(imagepointone, imagepointtwo);//bitmap3D.generateBitmap2DCrossSection(coordinates); if (crossSectionBitmap2D != null) { //DisplayiLneOnPixelGrid(SCSG.getCoordList()); DisplayLineOnPixelGrid(SeismicServiceClient.GetSeismicCoordinatesList(), numxregions, numyregions); redrawRightImage(); Line.Visibility = Visibility.Visible; } //imageLeft.Visibility = Visibility.Hidden; } }
public void createPixelGrid(byte[] rawData, int sizex, int sizey, SeismicUtilities.Point offsetpoint, int pixelPaddingX, int pixelPaddingY, double rotation) { long memoryoffset = 0; //Turn all pixels white while (memoryoffset < sizex * sizey * pixelFormat.BitsPerPixel / 8) { //deal with one pixel at a time rawData[memoryoffset++] = (byte)255; rawData[memoryoffset++] = (byte)255; rawData[memoryoffset++] = (byte)255; rawData[memoryoffset++] = (byte)255; } //Draw horizontal border lines int x = 0, y = 0; for (int i = 0; i < sizex; i++) { x = i; y = 0; memoryoffset = (y * sizex + x) * pixelFormat.BitsPerPixel / 8; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)255; y = sizey - 1; memoryoffset = (y * sizex + x) * pixelFormat.BitsPerPixel / 8; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)255; } //Draw vertical border lines for (int i = 0; i < sizey; i++) { x = 0; y = i; memoryoffset = (y * sizex + x) * pixelFormat.BitsPerPixel / 8; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)255; x = sizex - 1; memoryoffset = (y * sizex + x) * pixelFormat.BitsPerPixel / 8; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)0; rawData[memoryoffset++] = (byte)255; } SeismicUtilities.Point bottomLeft = offsetpoint; SeismicUtilities.Point bottomRight = new SeismicUtilities.Point(offsetpoint.x + arraySpaceImageWidth - 2 * imagePixelPaddingX, offsetpoint.y); SeismicUtilities.Point topLeft = new SeismicUtilities.Point(offsetpoint.x, offsetpoint.y + arraySpaceImageHeight - 2 * imagePixelPaddingY); SeismicUtilities.Point topRight = new SeismicUtilities.Point(offsetpoint.x + arraySpaceImageWidth - 2 * imagePixelPaddingX, offsetpoint.y + arraySpaceImageHeight - 2 * imagePixelPaddingY); SeismicUtilities.Point rotatedTopLeft = topLeft.rotatePointAboutPoint(rotation, offsetpoint); SeismicUtilities.Point rotatedTopRight = topRight.rotatePointAboutPoint(rotation, offsetpoint); SeismicUtilities.Point rotatedBottomRight = bottomRight.rotatePointAboutPoint(rotation, offsetpoint); //Left rectangle line SeismicUtilities.LineSegment line = new SeismicUtilities.LineSegment(new SeismicUtilities.Point(rotatedTopLeft.x, arraySpaceImageHeight - rotatedTopLeft.y), new SeismicUtilities.Point(offsetpoint.x, arraySpaceImageHeight - offsetpoint.y)); List<SeismicUtilities.Point> points = ArraySpaceUtilities.getArrayIndiciesMarkedByLine(line, sizex, sizey); drawPoints(points, sizex, sizey, rawData); //Bottom rect line line = new SeismicUtilities.LineSegment(new SeismicUtilities.Point(offsetpoint.x, arraySpaceImageHeight - offsetpoint.y), new SeismicUtilities.Point(rotatedBottomRight.x, arraySpaceImageHeight - rotatedBottomRight.y)); points = ArraySpaceUtilities.getArrayIndiciesMarkedByLine(line, sizex, sizey); drawPoints(points, sizex, sizey, rawData); //Right rect line line = new SeismicUtilities.LineSegment(new SeismicUtilities.Point(rotatedBottomRight.x, arraySpaceImageHeight - rotatedBottomRight.y), new SeismicUtilities.Point(rotatedTopRight.x, arraySpaceImageHeight - rotatedTopRight.y)); points = ArraySpaceUtilities.getArrayIndiciesMarkedByLine(line, sizex, sizey); drawPoints(points, sizex, sizey, rawData); //top rect line line = new SeismicUtilities.LineSegment(new SeismicUtilities.Point(rotatedTopRight.x, arraySpaceImageHeight - rotatedTopRight.y), new SeismicUtilities.Point(rotatedTopLeft.x, arraySpaceImageHeight - rotatedTopLeft.y)); points = ArraySpaceUtilities.getArrayIndiciesMarkedByLine(line, sizex, sizey); drawPoints(points, sizex, sizey, rawData); ////Draw horizontal array space lines //for (int i = 0; i < sizex - 2 * pixelPaddingX; i++) // { // x = i; // y = pixelPaddingY; // memoryoffset = (y * sizex + x + pixelPaddingX) * pixelFormat.BitsPerPixel / 8; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)255; // y = sizey - 1 - pixelPaddingY; // memoryoffset = (y * sizex + x + pixelPaddingX) * pixelFormat.BitsPerPixel / 8; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)255; // } //Draw vertical array space lines //for (int i = 0; i < sizey - 2 * pixelPaddingY; i++) //{ // x = pixelPaddingX; // y = i + pixelPaddingY; // memoryoffset = (y * sizex + x) * pixelFormat.BitsPerPixel / 8; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)255; // x = sizex - 1 - pixelPaddingX; // memoryoffset = (y * sizex + x) * pixelFormat.BitsPerPixel / 8; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)255; //} #region //for (int i = 1; i < numxregions; i++) //{ // for (int j = 0; j < sizey; j++) // { // x = i * sizex / numxregions; // y = j; // memoryoffset = (y * sizex + x) * pixelFormat.BitsPerPixel / 8; // //if (i == 1) // //{ // // rawData[memoryoffset++] = (byte)0; // // rawData[memoryoffset++] = (byte)255; // // rawData[memoryoffset++] = (byte)0; // // rawData[memoryoffset++] = (byte)255; // //} // //else // //{ // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)255; // //} // } //} //for (int i = 1; i < numyregions; i++) //{ // for (int j = 0; j < sizex; j++) // { // x = j; // y = i * sizey / numyregions; // memoryoffset = (y * sizex + x )* pixelFormat.BitsPerPixel / 8; // //if (i == 1) // //{ // // rawData[memoryoffset++] = (byte)0; // // rawData[memoryoffset++] = (byte)255; // // rawData[memoryoffset++] = (byte)0; // // rawData[memoryoffset++] = (byte)255; // //} // //else // //{ // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)0; // rawData[memoryoffset++] = (byte)255; // //} // } //} #endregion }
public void getPreliminaryDataFromService() { numxregions = SeismicServiceClient.GetNumberOfColumnsInBitmap3D(); numyregions = SeismicServiceClient.GetNumberOfRowsInBitmap3D(); arraySpaceImageHeight = (int)SeismicServiceClient.GetSeismicAreaHeight(); arraySpaceImageWidth = (int)SeismicServiceClient.GetSeismicAreaWidth(); offsetPoint = SeismicServiceClient.GetSeismicAreaAnchorPoint(); imagePixelPaddingX = (int)offsetPoint.x; imagePixelPaddingY = (int)offsetPoint.y; //pixelFormat = SeismicServiceClient.GetBitmapPixelFormat(); rotation = SeismicServiceClient.GetSeismicRotation(); }