Example #1
0
        public static BoundingBox ToBoundingBox(this DB.BoundingBoxXYZ value, out Transform transform)
        {
            var rhino = RawDecoder.AsBoundingBox(value, out transform);

            UnitConverter.Scale(ref rhino, UnitConverter.ToRhinoUnits);
            UnitConverter.Scale(ref transform, UnitConverter.ToRhinoUnits);
            return(rhino);
        }
Example #2
0
        public static Box ToBox(this DB.BoundingBoxXYZ value)
        {
            var rhino = RawDecoder.AsBoundingBox(value, out var transform);

            UnitConverter.Scale(ref rhino, UnitConverter.ToRhinoUnits);
            UnitConverter.Scale(ref transform, UnitConverter.ToRhinoUnits);

            return(new Box
                   (
                       new Plane
                       (
                           origin:    new Point3d(transform.M03, transform.M13, transform.M23),
                           xDirection: new Vector3d(transform.M00, transform.M10, transform.M20),
                           yDirection: new Vector3d(transform.M01, transform.M11, transform.M21)
                       ),
                       xSize: new Interval(rhino.Min.X, rhino.Max.X),
                       ySize: new Interval(rhino.Min.Y, rhino.Max.Y),
                       zSize: new Interval(rhino.Min.Z, rhino.Max.Z)
                   ));
        }
Example #3
0
 public static BoundingBox ToRhino(this DB.BoundingBoxXYZ bbox) => RawDecoder.ToRhino(bbox);
Example #4
0
 public static Transform ToTransform(this DB.Transform value)
 {
     var rhino = RawDecoder.AsTransform(value); UnitConverter.Scale(ref rhino, UnitConverter.ToRhinoUnits); return(rhino);
 }
Example #5
0
 public static Point3d ToPoint3d(this DB.XYZ value)
 {
     var rhino = RawDecoder.AsPoint3d(value); UnitConverter.Scale(ref rhino, UnitConverter.ToRhinoUnits); return(rhino);
 }
Example #6
0
 public static PolylineCurve ToPolylineCurve(this DB.PolyLine value)
 {
     var rhino = RawDecoder.ToRhino(value); UnitConverter.Scale(rhino, UnitConverter.ToRhinoUnits); return(rhino);
 }
Example #7
0
 public static Point ToPoint(this DB.Point value)
 {
     var rhino = RawDecoder.ToRhino(value); UnitConverter.Scale(rhino, UnitConverter.ToRhinoUnits); return(rhino);
 }
Example #8
0
 public static RevSurface ToRhino(this DB.RevolvedSurface surface, DB.BoundingBoxUV bboxUV) => RawDecoder.ToRhino(surface, bboxUV);
Example #9
0
 public static NurbsCurve ToRhino(this DB.HermiteSpline hermite) => RawDecoder.ToRhino(hermite);
Example #10
0
 public static NurbsCurve ToRhino(this DB.Ellipse ellipse) => RawDecoder.ToRhino(ellipse);
Example #11
0
 public static ArcCurve ToRhino(this DB.Arc arc) => RawDecoder.ToRhino(arc);
Example #12
0
 public static LineCurve ToRhino(this DB.Line line) => RawDecoder.ToRhino(line);
Example #13
0
 public static Plane ToRhino(this DB.Plane plane) => RawDecoder.ToRhino(plane);
Example #14
0
 public static Point ToRhino(this DB.Point point) => RawDecoder.ToRhino(point);
Example #15
0
 public static Transform ToRhino(this DB.Transform transform) => RawDecoder.ToRhino(transform);
Example #16
0
 public static RevSurface ToRhino(this DB.CylindricalSurface surface, DB.BoundingBoxUV bboxUV) => RawDecoder.ToRhino(surface, bboxUV);
Example #17
0
 public static RevSurface ToRhinoSurface(this DB.RevolvedFace face, double relativeTolerance) => RawDecoder.ToRhinoSurface(face, relativeTolerance);
Example #18
0
 public static NurbsCurve ToRhino(this DB.NurbSpline nurb) => RawDecoder.ToRhino(nurb);
Example #19
0
        private void OpenFile(StorageFile file)
        {
            //Add a loading screen
            progressDisplay.Visibility = Visibility.Visible;
            histoLoadingBar.Visibility = Visibility.Visible;
            emptyImage();
            Task t = Task.Run(async() =>
            {
                try
                {
                    Stream stream         = (await file.OpenReadAsync()).AsStreamForRead();
                    RawParser parser      = new RawParser(ref stream);
                    RawDecoder decoder    = parser.decoder;
                    decoder.failOnUnknown = false;
                    decoder.checkSupport(metadata);


                    thumbnail = decoder.decodeThumb();
                    if (thumbnail != null)
                    {
                        //read the thumbnail
                        Task.Run(() =>
                        {
                            if (thumbnail.type == ThumbnailType.JPEG)
                            {
                                displayImage(JpegHelper.getJpegInArrayAsync(thumbnail.data));
                            }
                            else if (thumbnail.type == ThumbnailType.RAW)
                            {
                                //this is a raw image in an array
                                JpegHelper.getThumbnailAsSoftwareBitmap(thumbnail);
                            }
                        });
                    }

                    raw = decoder.decodeRaw();
                    decoder.decodeMetaData(metadata);
                    raw.fileName = file.DisplayName;
                    //read the exifs
                    displayExif();
                    //scale the value
                    //raw.scaleValues();

                    //correctWB
                    //raw.CorrectWB();

                    //demos
                    if (raw.cfa != null && raw.cpp == 1)
                    {
                        Demosaic.demos(ref raw, demosAlgorithm.NearNeighbour);
                    }
                    createPreview();
                    updatePreview();

                    //activate the editing control
                    enableEditingControl(true);
                    //dispose
                    file   = null;
                    parser = null;
                }
                catch (FormatException e)
                {
                    var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                    var str    = loader.GetString("ExceptionText");
                    ExceptionDisplay.display(str);
                }

                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    //Hide the loading screen
                    progressDisplay.Visibility = Visibility.Collapsed;
                });
            });
        }
Example #20
0
 public static NurbsCurve ToRhino(this DB.CylindricalHelix helix) => RawDecoder.ToRhino(helix);
Example #21
0
 public static Curve ToCurve(this DB.Curve value)
 {
     var rhino = RawDecoder.ToRhino(value); UnitConverter.Scale(rhino, UnitConverter.ToRhinoUnits); return(rhino);
 }
Example #22
0
 public static Curve ToRhino(this DB.Curve curve) => RawDecoder.ToRhino(curve);
Example #23
0
 public static Brep ToBrep(this DB.Solid value)
 {
     var rhino = RawDecoder.ToRhino(value); UnitConverter.Scale(rhino, UnitConverter.ToRhinoUnits); return(rhino);
 }
Example #24
0
 public static PolylineCurve ToRhino(this DB.PolyLine polyline) => RawDecoder.ToRhino(polyline);
Example #25
0
 public static Plane ToPlane(this DB.Plane value)
 {
     var rhino = RawDecoder.AsPlane(value); UnitConverter.Scale(ref rhino, UnitConverter.ToRhinoUnits); return(rhino);
 }
Example #26
0
 public static PlaneSurface ToRhinoSurface(this DB.PlanarFace face, double relativeTolerance) => RawDecoder.ToRhinoSurface(face, relativeTolerance);
Example #27
0
 public static PlaneSurface ToRhino(this DB.Plane surface, DB.BoundingBoxUV bboxUV) => RawDecoder.ToRhino(surface, bboxUV);
Example #28
0
 public static RevSurface ToRhinoSurface(this DB.CylindricalFace face, double relativeTolerance) => RawDecoder.ToRhinoSurface(face, relativeTolerance);
Example #29
0
        private void OpenFile(StorageFile file)
        {
            //Add a loading screen
            if (rawImage != null)
            {
                EmptyImage();
            }
            Load.Show();
            ImageSelected = true;
            isBindingEnabled = false;

            Task.Run(async () =>
            {
                try
                {
                    var watchTotal = Stopwatch.StartNew();
                    using (Stream stream = (await file.OpenReadAsync()).AsStreamForRead())
                    {
                        var watchdecode = Stopwatch.StartNew();
                        RawDecoder decoder = RawParser.GetDecoder(stream, file);
                        try
                        {
                            thumbnail = decoder.DecodeThumb();
                            Task.Run(() =>
                            {
                                var result = thumbnail?.GetBitmap();
                                DisplayImage(result, true);
                            });
                        }
                        //since thumbnail are optionnal, we ignore all errors           
                        catch (Exception ex) { }

                        decoder.DecodeRaw();
                        decoder.DecodeMetadata();
                        rawImage = decoder.rawImage;

                        watchdecode.Stop();
                        Debug.WriteLine("Decoding done in " + watchdecode.ElapsedMilliseconds + " ms");

                        var watchLook = Stopwatch.StartNew();
                        rawImage.ApplyTableLookUp();
                        watchLook.Stop();
                        Debug.WriteLine("Lookup done in " + watchLook.ElapsedMilliseconds + " ms");

                        var watchScale = Stopwatch.StartNew();
                        ImageHelper.ScaleValues(rawImage);
                        watchScale.Stop();
                        Debug.WriteLine("Scale done in " + watchScale.ElapsedMilliseconds + " ms");
                    }

                    rawImage.metadata.SetFileMetatdata(file);

                    if (rawImage.isCFA)
                    {
                        var watchDemos = Stopwatch.StartNew();
                        //get the algo from the settings
                        DemosaicAlgorithm algo;
                        try
                        {
                            algo = SettingStorage.DemosAlgo;
                        }
                        catch (Exception)
                        {
                            algo = DemosaicAlgorithm.FastAdams;
                        }
                        Demosaic.Demos(rawImage, algo);

                        watchDemos.Stop();
                        Debug.WriteLine("Demos done in " + watchDemos.ElapsedMilliseconds + " ms");
                    }

                    if (rawImage.convertionM != null)
                    {
                        var watchConvert = Stopwatch.StartNew();
                        rawImage.ConvertRGB();
                        watchConvert.Stop();
                        Debug.WriteLine("ConvertRGB done in " + watchConvert.ElapsedMilliseconds + " ms");
                    }

                    var watchPreview = Stopwatch.StartNew();
                    ImageHelper.CreatePreview(SettingStorage.PreviewFactor, ImageDisplay.ViewportHeight, ImageDisplay.ViewportWidth, rawImage);
                    watchPreview.Stop();
                    Debug.WriteLine("Preview done in " + watchPreview.ElapsedMilliseconds + " ms");

                    watchTotal.Stop();
                    rawImage.metadata.ParsingTime = watchTotal.ElapsedMilliseconds;
                    GC.Collect();
                    //check if enough memory
                    if (MemoryManager.AppMemoryUsageLimit - MemoryManager.AppMemoryUsage < ((ulong)rawImage.fullSize.green.Length * 6) || MemoryManager.AppMemoryUsageLevel == AppMemoryUsageLevel.High)
                    {
                        TextDisplay.DisplayWarning("The image is bigger than what your device support, this application may fail when saving. Only " + ((MemoryManager.AppMemoryUsageLimit - MemoryManager.AppMemoryUsage) / (1024 * 1024)) + "Mb left of memory for this app to use");
                    }
#if !DEBUG
                    //send an event with file extension, camera model and make
                    logger.Log("SuccessOpening " + rawImage?.metadata?.FileExtension.ToLower() + " " + rawImage?.metadata?.Make + " " + rawImage?.metadata?.Model);
#endif
                    DefaultValue.Rotation = rawImage.metadata.OriginalRotation;
                    DefaultValue.ReverseGamma = rawImage.IsGammaCorrected;
                    DefaultValue.RMul = rawImage?.metadata.WbCoeffs?.Red ?? 1;
                    DefaultValue.GMul = rawImage?.metadata.WbCoeffs?.Green ?? 1;
                    DefaultValue.BMul = rawImage?.metadata.WbCoeffs?.Blue ?? 1;
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        var exif = rawImage.ParseExif();
                        //Group the data
                        var groups = from x in exif group x by x.Group into grp orderby grp.Key select grp;
                        //Set the grouped data to CollectionViewSource
                        ExifSource.Source = groups;
                        ResetControls();
                        UpdatePreview(true);
                        ControlVisibilty.Value = true;
                        SetImageSizeText();
                    });
                    if (rawImage.errors.Count > 0)
                    {
                        var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                        TextDisplay.DisplayWarning(loader.GetString("ErrorOnLoadWarning"));
#if !DEBUG
                        //send an event with file extension and camera model and make if any                   
                        logger.Log("ErrorOnOpen " + file?.FileType.ToLower() + " " + rawImage?.metadata?.Make + " " + rawImage?.metadata?.Model + "" + rawImage.errors.Count);
#endif
                    }
                    isBindingEnabled = true;
                    thumbnail = null;
                }
                catch (Exception ex)
                {
#if !DEBUG
                    //send an event with file extension and camera model and make if any                   
                    logger.Log("FailOpening " + file?.FileType.ToLower() + " " + rawImage?.metadata?.Make + " " + rawImage?.metadata?.Model);
#endif

                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        EmptyImage();
                    });
                    ImageSelected = false;
                    var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                    TextDisplay.DisplayError(loader.GetString("ExceptionText"));
                }

                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    // Blur(false);
                    Load.Hide();
                });
                ImageSelected = false;
            });
        }
Example #30
0
 public static IEnumerable <Point3d> ToRhino(this IEnumerable <DB.XYZ> points) => points.Select(x => RawDecoder.ToRhino(x));