Beispiel #1
0
 /// <summary>
 /// Toggles if the selected segment is visible in 3D or not.
 /// </summary>
 /// <param name="b">new toggle value</param>
 private void Toggle3D(bool b)
 {
     if (_dontSendToggleEvent)
     {
         return;
     }
     Display3Ds = SegmentCache.SetIndex(Display3Ds, _selectedSegment, b);
     OnSelectionChanged3D.Invoke(Display3Ds);
 }
Beispiel #2
0
        // Use this for initialization
        private void Start()
        {
            _workIndicator = FindObjectOfType <GlobalWorkIndicator>();
            MainMenu.ClearDropdown();

            var folders = new List <string>(Directory.GetDirectories(Application.streamingAssetsPath));

            var names = new List <string>();

            for (var index = 0; index < folders.Count; index++)
            {
                var fold = folders[index];
                names.Add(fold.Split('\\')[1]);
            }

            MainMenu.AddDropdownOptions(names);

            _stack = gameObject.AddComponent <ImageStack>();
            _stack.OnTextureUpdate.AddListener(Slice2DView.TextureUpdated);

            _segmentCache = gameObject.AddComponent <SegmentCache>();
            _segmentCache.TextureReady.AddListener(Slice2DView.SegmentTextureUpdated);
            _segmentCache.SegmentChanged.AddListener(SegmentChanged);

            Slice2DView.SegmentCache = _segmentCache;

            WindowSettingsPanel.OnSettingsChangedEvent.AddListener(_stack.OnWindowSettingsChanged);
            WindowSettingsPanel.gameObject.SetActive(false);

            //Volume.SetActive(false);
            VolumeRenderingParent.SetActive(false);
            RotationObjectParent.SetActive(false);

            Slice2DView.gameObject.SetActive(false);

            SegmentConfiguration.transform.gameObject.SetActive(false);
            SegmentConfiguration.OnSelectionChanged2D.AddListener(SelectionChanged2D);
            SegmentConfiguration.OnSelectionChanged3D.AddListener(SelectionChanged3D);
            SegmentConfiguration.OnHideBaseChanged.AddListener(HideBaseChanged);

            Slice2DView.OnPointSelected.AddListener(SegmentConfiguration.UpdateRegionSeed);

            MainMenu.DisableButtons();
        }
Beispiel #3
0
        /// <summary>
        /// Initializes the configuration window for the given cache.
        /// </summary>
        /// <param name="cache">SegmentCache containing the segments</param>
        /// <param name="minIntensity">Minimum possible intensity in data</param>
        /// <param name="maxIntensity">Maximum possible intensity in data</param>
        public void Initialize(SegmentCache cache, int minIntensity, int maxIntensity)
        {
            _segmentCache = cache;

            _segmentCache.SegmentChanged.AddListener(delegate
            {
                ValidateCurrentParameters();
            });

            _selectedColor.color          = cache.GetSegment(_selectedSegment).SegmentColor;
            _minRange.MinimumValue        = minIntensity;
            _maxRange.MinimumValue        = minIntensity;
            _minRange.MaximumValue        = maxIntensity;
            _maxRange.MaximumValue        = maxIntensity;
            _thresholdRegion.MinimumValue = 0;
            _thresholdRegion.MaximumValue = (maxIntensity - minIntensity) / 2f;

            _segmentationStrategyChoice.value = 0;

            for (var i = 0; i < SegmentCache.MaxSegmentCount; i++)
            {
                _selectedType[i]         = SegmentationType.Range;
                _rangeParameters[i]      = new RangeSegmentation.RangeParameter(minIntensity, maxIntensity, 2);
                _regionGrowParameters[i] = new RegionGrowSegmentation.RegionGrowParameter(-1, -1, -1, (int)(_thresholdRegion.MaximumValue / 4));
            }

            var options = new List <string>(Enum.GetNames(typeof(SegmentationType)));

            options.Remove(Enum.GetName(typeof(SegmentationType), SegmentationType.Unknown));
            _segmentationStrategyChoice.ClearOptions();
            _segmentationStrategyChoice.AddOptions(options);

            _thresholdRegion.CurrentInt = (int)(_thresholdRegion.MaximumValue / 4);

            UpdateRegionSeed(-1, -1, -1);
            ValidateCurrentParameters();
            _dontSendToggleEvent = true;

            Display2Ds = 0xFFFFFFFF;
            Display3Ds = 0xFFFFFFFF;

            UpdateToggles();
            _dontSendToggleEvent = false;
        }
    void Start()
    {
        // Front[0] = Resources.Load("Back_0") as Texture2DArray;
        // Debug.Log(sw.ElapsedMilliseconds.ToString());
        // Front[1] = Resources.Load("Back_1") as Texture2DArray;
        // Debug.Log(sw.ElapsedMilliseconds.ToString());
        // Front[2] = Resources.Load("Back_2") as Texture2DArray;

        cache = new SegmentCache(16);

        cameraPosOffset          = cameraTransform.position;
        cameraTransform.position = new Vector3(InitialPosition.x, 0f, InitialPosition.y);

        ViewPlainCenter.rotation = Quaternion.Euler(0, cameraTransform.rotation.eulerAngles.y, 0);

        // [0,X] : front, [1,X] : right, [2,X] : left, [3,X] : back
        imageDepth = new float[4, 3] {
            { 662f, 660f, 657f },
            { 640f, 645f, 646f },
            { 624f, 633f, 639f },
            { 653f, 663f, 660f }
        };


        //프로퍼티 이름으로 부터 ID를 추출 합니다.
        //프로퍼티 이름은 해당 쉐이더를 클릭하여 나오는 오른쪽 Inspector창에서 확인해야 합니다.
        Distance_property          = Shader.PropertyToID("Vector1_A1C90C0E");
        HorizontalPositon_property = Shader.PropertyToID("Vector1_DF5BD731");
        Texture_property           = Shader.PropertyToID("Texture2DArray_F092712C");
        Texture_property_L         = Shader.PropertyToID("Texture2DArray_5C3CC0FC");
        Texture_property_R         = Shader.PropertyToID("Texture2DArray_4CAF86FE");
        PositionDelta_property     = Shader.PropertyToID("Vector1_14AEA0F9");

        //front_plain.SetTexture(Texture_property, Front[1]);
        //front_plain.SetTexture(Texture_property_L, Front[0]);
        //front_plain.SetTexture(Texture_property_R, Front[2]);
    }
Beispiel #5
0
        /// <summary>
        /// Creates a Segment with the current selection.
        /// </summary>
        private void CreateSelection()
        {
            _create.interactable = false;
            switch (_selectedType[_selectedSegment])
            {
            case SegmentationType.Range:
                _segmentCache.CreateSegment(SegmentCache.GetSelector(_selectedSegment), _rangeSegmentation,
                                            _rangeParameters[_selectedSegment], false);

#if PRINT_USAGE
                _numberRangeCreations++;
                Debug.Log(Time.time +
                          $" : Started Creating Range Segment number {_numberRangeCreations} (min {_rangeParameters[_selectedSegment].Lower:N0}, max {_rangeParameters[_selectedSegment].Upper:N0})");
#endif

                break;

            case SegmentationType.RegionGrow:
                _segmentCache.CreateSegment(SegmentCache.GetSelector(_selectedSegment), _regionGrowSegmentation,
                                            _regionGrowParameters[_selectedSegment]);

#if PRINT_USAGE
                _numberRegionCreations++;
                Debug.Log(Time.time +
                          $" : Started Creating Region Grow Segment number {_numberRegionCreations} (seedX {_regionGrowParameters[_selectedSegment].X:N0}," +
                          $" seedY {_regionGrowParameters[_selectedSegment].Y:N0}," +
                          $" seedZ {_regionGrowParameters[_selectedSegment].X:N0}," +
                          $" threshold {_regionGrowParameters[_selectedSegment].Threshold:N0})");
#endif

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #6
0
 public Blackburrow(int index, SegmentCache cache, Facet facet) : base(index, cache, facet)
 {
 }
Beispiel #7
0
 public Oakvael(int index, SegmentCache cache, Facet facet) : base(index, cache, facet)
 {
 }
Beispiel #8
0
 public Kesmai(int index, SegmentCache cache, Facet facet) : base(index, cache, facet)
 {
 }
Beispiel #9
0
 public Tortuga(int index, SegmentCache cache, Facet facet) : base(index, cache, facet)
 {
 }
Beispiel #10
0
 public RazalasPeak(int index, SegmentCache cache, Facet facet) : base(index, cache, facet)
 {
 }
Beispiel #11
0
 /// <summary>
 /// Updates the 2D and 3D toggle for the current selection.
 /// </summary>
 private void UpdateToggles()
 {
     _display2D.isOn = SegmentCache.ContainsIndex(Display2Ds, _selectedSegment);
     _display3D.isOn = SegmentCache.ContainsIndex(Display3Ds, _selectedSegment);
 }
Beispiel #12
0
        ////////////////////////////////////////////////////////////////////////////////
        //////////////////// I/O METHODS ///////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Read/Write bytes
        /// </summary>
        /// <param name="op">DEFS.OP_READ or DEFS.OP_WRITE</param>
        /// <param name="address"></param>
        /// <param name="data"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        protected void io_protected(int op, long address, ref byte[] data, long length)
        {
            if (length <= 0)
            {
                throw new VSException(DEFS.E0028_INVALID_LENGTH_ERROR_CODE, "- " + length.ToString());
            }

            long r_length  = length;            // Remaining length
            long s_address = 0;                 // Shifted address

            VSAllocation obj      = this;
            bool         eo_chunk = false;

            if (address < this.Length)
            {
                s_address = 0;             // Address is in the current chunk
            }
            else
            { // Search cache
                obj = null;
                for (int i = (SCache.Count - 1); i >= 0; i--)
                {
                    if ((address >= SCache[i].VIRTUAL_ADDRESS) & (address < (SCache[i].VIRTUAL_ADDRESS + SCache[i].LENGTH)))
                    {
                        s_address = SCache[i].VIRTUAL_ADDRESS;
                        obj       = new VSAllocation(vm, SCache[i].DESCRIPTOR_ADDRESS);
                        break;
                    }
                }
                if (obj == null)
                { // NOT found in cache
                    if ((this.Chunk == 0) | (this.NEXT == 0))
                    {
                        eo_chunk = true;
                    }
                    else
                    {
                        obj       = this.NextChunk;
                        s_address = this.Length;
                        while (!eo_chunk)
                        {
                            if (address < (s_address + obj.Length))
                            { // Address is in chunk, add to cache
                                if (SCache.Count == cache_size)
                                {
                                    SCache.RemoveAt(0);
                                }
                                SegmentCache ac = new SegmentCache();
                                ac.VIRTUAL_ADDRESS    = s_address;
                                ac.LENGTH             = obj.Length;
                                ac.DESCRIPTOR_ADDRESS = obj.DescriptorAddress;
                                SCache.Add(ac);
                                break;
                            }
                            else
                            { //start address not in this chunk
                                if ((obj.Chunk > 0) & (obj.NEXT > 0))
                                {
                                    s_address += obj.Length;
                                    obj        = obj.NextChunk;
                                }
                                else
                                {
                                    eo_chunk = true;
                                }
                            }
                        }
                    }
                }
            }

            if (obj != null)
            {
                long l_address = address - s_address;           // Local address in chunk
                long r_address = 0;                             // Relative address in the input array
                while ((obj != null) & (r_length > 0) & !eo_chunk)
                {
                    long l_length = (r_length > (obj.Length - l_address)) ? (obj.Length - l_address) : r_length;
                    vm.Io(obj.Address + l_address, ref data, l_length, op, r_address);
                    l_address  = 0;
                    r_length  -= l_length;
                    r_address += l_length;
                    obj        = obj.NextChunk;
                }
            }
            if ((r_length > 0) | (length <= 0) | (address < 0))
            {
                throw new VSException(DEFS.E0019_INVALID_OP_ADDRESS_ERROR_CODE, "- address " + address.ToString() + "; lenght " + length.ToString());
            }
        }
Beispiel #13
0
 public Leng(int index, SegmentCache cache, Facet facet) : base(index, cache, facet)
 {
 }
Beispiel #14
0
 public AxeGlacier(int index, SegmentCache cache, Facet facet) : base(index, cache, facet)
 {
 }
Beispiel #15
0
 public Underkingdom(int index, SegmentCache cache, Facet facet) : base(index, cache, facet)
 {
 }
Beispiel #16
0
 public Bloodlands(int index, SegmentCache cache, Facet facet) : base(index, cache, facet)
 {
 }