Exemplo n.º 1
0
        private void SetOrientationInfo(PlaneOrientation orientation)
        {
            if (null != orientation)
            {
                comboBoxTop.SelectedItem   = orientation.Top;
                comboBoxRight.SelectedItem = orientation.Right;

                if (orientation.Condition == null ||
                    orientation.Condition.GetType( ) != typeof(TagValueOrientationCondition))
                {
                    TagConditionTextBox.Text = string.Empty;
                }
                else
                {
                    TagValueOrientationCondition condition;


                    condition = ( TagValueOrientationCondition )orientation.Condition;

                    TagConditionTextBox.Text = GetTag(condition.Tag);
                }

                BuildDataSet( );
            }
            else
            {
                TagConditionTextBox.Text  = string.Empty;
                dicomPropertyGrid.DataSet = null;
            }
        }
Exemplo n.º 2
0
 private void RemoveEntityFrom2DLocations(List <IntVector2D> locations, PlaneOrientation planeOrientation, WorldEntity2D e)
 {
     for (int i = 0; i < locations.Count; i++)
     {
         Remove2DEntityFrom(locations[i], planeOrientation, e);
     }
 }
Exemplo n.º 3
0
    private bool CanExistOn(List <IntVector2D> relativeLocations, IntVector2D on, PlaneOrientation orientation)
    {
        int i;

        switch (orientation)
        {
        case PlaneOrientation.XY:
            for (i = 0; i < relativeLocations.Count; i++)
            {
                if (!PassableAtXY(relativeLocations[i] + on))
                {
                    return(false);
                }
            }
            break;

        case PlaneOrientation.ZY:
            for (i = 0; i < relativeLocations.Count; i++)
            {
                if (!PassableAtZY(relativeLocations[i] + on))
                {
                    return(false);
                }
            }
            break;
        }
        return(true);
    }
Exemplo n.º 4
0
        private void BuildDataSet( )
        {
            if (comboBoxConfigs.SelectedIndex < 0)
            {
                return;
            }

            PlaneOrientation             po = comboBoxConfigs.SelectedItem as PlaneOrientation;
            TagValueOrientationCondition condition;

            _Dataset.Reset( );

            if (null == po.Condition || po.Condition.GetType( ) != typeof(TagValueOrientationCondition))
            {
                dicomPropertyGrid.DataSet = _Dataset;

                return;
            }

            condition = ( TagValueOrientationCondition )po.Condition;

            if (condition.Tag != -1)
            {
                _PreviousCode = condition.Tag;

                _Dataset.InsertElementAndSetValue(condition.Tag, condition.TagValue);
            }

            dicomPropertyGrid.DataSet = _Dataset;
        }
Exemplo n.º 5
0
    List <IntVector2D> PlanPathToLocForAvatar(IntVector2D goalPos, Char2D avatar, bool sendThereIfPossible)
    {
        List <IntVector2D> list        = null;
        PlaneOrientation   orientation = avatar.Orientation;

        if (WorldManager.g.IsInBounds2D(goalPos, orientation))
        {
            IntVector2D lastLoc = avatar.Location;
            list = WorldManager.g.PlanPath(avatar, lastLoc, goalPos);
            if (list != null)
            {
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    IntVector2D nextLoc = list[i];
                    Vector3     a       = WorldManager.g.WorldPosFromIntVec(lastLoc, orientation);
                    Vector3     b       = WorldManager.g.WorldPosFromIntVec(nextLoc, orientation);
                    Debug.DrawLine(a, b, Color.red);
                    lastLoc = nextLoc;
                }
                if (sendThereIfPossible)
                {
                    avatar.DesiredPath = list;
                }
            }
            else
            {
                // Debug.Log("NO VALID PATH FOR "+orientation.ToString()+"!");
            }
        }
        return(list);
    }
Exemplo n.º 6
0
    public bool IsInBounds2D(int a, int y, PlaneOrientation orientation)
    {
        if (y >= _yDim || y < 0)
        {
            return(false);
        }
        switch (orientation)
        {
        case PlaneOrientation.XY:
            if (a >= _xDim || a < 0)
            {
                return(false);
            }
            break;

        case PlaneOrientation.ZY:
            if (a >= _zDim || a < 0)
            {
                return(false);
            }
            break;

        default:
            break;
        }
        return(true);
    }
Exemplo n.º 7
0
    // Adapted From http://stackoverflow.com/questions/10983110/a-star-a-and-generic-find-method
    public List <IntVector2D> PlanPath(Char2D entity, IntVector2D start, IntVector2D destination)
    {
        PlaneOrientation   orientation       = entity.Orientation;
        List <IntVector2D> relativeLocations = entity.AbsoluteLocations(new IntVector2D(0, 0));
        var closed = new HashSet <IntVector2D>();
        var queue  = new PriorityQueue <Path <IntVector2D>, float>();

        queue.Enqueue(new Path <IntVector2D>(start), 0f);
        while (!queue.IsEmpty)
        {
            var path = queue.Dequeue();
            if (closed.Contains(path.LastStep))
            {
                continue;
            }
            if (path.LastStep == destination)
            {
                return(path.AsList);
            }
            IntVector2D leafNode = path.LastStep;
            closed.Add(leafNode);
            List <IntVector2D> neighbors = ConnectedNodesForRelativeLocations(relativeLocations, leafNode, orientation);
            for (int i = 0; i < neighbors.Count; i++)
            {
                IntVector2D n        = neighbors[i];
                float       stepCost = CostBetween(path.LastStep, n);
                var         newPath  = path.AddStep(n, stepCost);
                queue.Enqueue(newPath, newPath.TotalCost + HeuristicCostEstimate(n, destination));
            }
        }
        return(null);
    }
Exemplo n.º 8
0
 private void AddEntityTo2DLocations(List <IntVector2D> locations, PlaneOrientation planeOrientation, WorldEntity2D e)
 {
     for (int i = 0; i < locations.Count; i++)
     {
         Add2DEntityTo(locations[i], planeOrientation, e);
     }
 }
Exemplo n.º 9
0
        private void comboBoxTop_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxConfigs.SelectedIndex < 0 || comboBoxTop.SelectedIndex < 0)
                {
                    return;
                }

                OrientationAxis  orientation = (OrientationAxis)comboBoxTop.SelectedItem;
                PlaneOrientation po          = comboBoxConfigs.SelectedItem as PlaneOrientation;

                labelBottom.Text = GetOppositeOrientation(orientation).ToString( );

                po.Top = orientation;

                CheckRight(orientation);

                _OldTopOrientation = orientation;
            }
            catch (Exception exception)
            {
                Messager.ShowError(this, exception);
            }
        }
Exemplo n.º 10
0
 public AcePlane(string _id, string _playerId, string _name, string ctrl, Vector2 initialPos, PlaneOrientation initialOrient)
 {
     PlaneId     = _id;
     PlayerId    = _playerId;
     Name        = _name;
     CtrlType    = ctrl;
     Position    = initialPos;
     Orientation = initialOrient;
 }
Exemplo n.º 11
0
    public HashSet <WorldEntity2D> Contents2DAt(IntVector2D v, PlaneOrientation planeOrientation)
    {
        var map      = Map2DForOrientation(planeOrientation);
        var contents = map[v[0], v[1]];

        if (contents == null)
        {
            contents        = new HashSet <WorldEntity2D>();
            map[v[0], v[1]] = contents;
        }
        return(contents);
    }
Exemplo n.º 12
0
    private HashSet <WorldEntity2D>[,] Map2DForOrientation(PlaneOrientation planeOrientation)
    {
        switch (planeOrientation)
        {
        case PlaneOrientation.XY:
            return(_xyWorldEntities);

        case PlaneOrientation.ZY:
            return(_zyWorldEntities);
        }
        return(null); // Compiler isn't smart enough to know this will never happen
    }
Exemplo n.º 13
0
    private void Remove2DEntityFrom(IntVector2D v, PlaneOrientation planeOrientation, WorldEntity2D t)
    {
        HashSet <WorldEntity2D>[,] mapToModify = Map2DForOrientation(planeOrientation);
        var contents = mapToModify[v[0], v[1]];

        if (contents == null)
        {
            contents = new HashSet <WorldEntity2D>();
            mapToModify[v[0], v[1]] = contents;
        }
        contents.Remove(t);
    }
Exemplo n.º 14
0
        public void SetBit(uint bit)
        {
            if (bit == (uint)ColliderShapeType.CONVEX_SHAPE || bit == (uint)ColliderShapeType.BOUND_RECT_SHAPE || bit == (uint)ColliderShapeType.MESH_SHAPE)
            {
                _shapeType = (ColliderShapeType)bit;
            }
            else if (bit == (uint)PlaneOrientation.HORIZONTAL || bit == (uint)PlaneOrientation.VERTICAL || bit == (uint)PlaneOrientation.OBLIQUE || bit == (uint)PlaneOrientation.FRAGMENT)
            {
                _orientation = (PlaneOrientation)bit;
            }

            PropBits = (uint)_shapeType | (uint)_orientation;
        }
    public static string GetPlaneOrientationString(PlaneOrientation orientation)
    {
        switch (orientation)
        {
        case PlaneOrientation.PlaneXY: return("XY");

        case PlaneOrientation.PlaneYZ: return("YZ");

        case PlaneOrientation.PlaneZX: return("ZX");

        default: return(orientation.ToString());
        }
    }
Exemplo n.º 16
0
    bool PassableAt2D(int a, int y, PlaneOrientation orientation)
    {
        switch (orientation)
        {
        case PlaneOrientation.XY:
            return(PassableAtXY(a, y));

        case PlaneOrientation.ZY:
            return(PassableAtZY(a, y));

        default:
            return(false);
        }
    }
Exemplo n.º 17
0
        public void AcePlane_Deserialize()
        {
            const string     planeId     = "xPlaneId";
            const string     playerId    = "yPeerId";
            const string     name        = "zName";
            const string     ctrl        = "ai";
            Vector2          pos         = new Vector2(4, 3);
            PlaneOrientation orientation = PlaneOrientation.kConcealed;
            string           json        = $"[\"{planeId}\",\"{playerId}\",\"{name}\",\"{ctrl}\",{pos.x},{pos.y},{(int)orientation}]";

            AcePlane pl = AcePlane.FromApianJson(json);

            Assert.That(pl.PlaneId, Is.EqualTo(planeId));
            Assert.That(pl.Position, Is.EqualTo(pos));
        }
Exemplo n.º 18
0
        public void AcePlane_Serialize()
        {
            const string     planeId     = "xPlaneId";
            const string     playerId    = "yPeerId";
            const string     name        = "zName";
            const string     ctrl        = "ai";
            Vector2          pos         = new Vector2(4, 3);
            PlaneOrientation orientation = PlaneOrientation.kConcealed;

            string expected = $"[\"{planeId}\",\"{playerId}\",\"{name}\",\"{ctrl}\",{pos.x},{pos.y},{(int)orientation}]";

            AcePlane pl     = new AcePlane(planeId, playerId, name, ctrl, pos, orientation);
            string   result = pl.ApianSerialized();

            Assert.That(result, Is.EqualTo(expected));
        }
Exemplo n.º 19
0
    public Vector3 WorldPosFromIntVec(IntVector2D vec, PlaneOrientation orientation)
    {
        float   tileSize = WorldManager.g.TileSize;
        Vector2 vector2  = vec.ToVector2();

        if (orientation == PlaneOrientation.XY)
        {
            vector2.x *= -1f;
            vector2.x -= 1f;
        }
        if (orientation == PlaneOrientation.XY)
        {
            return(ProjectionMath.ThreeDimCoordsOnPlane(vector2 * tileSize + Vector2.one * tileSize / 2f, _planeXY));
        }
        else
        {
            return(ProjectionMath.ThreeDimCoordsOnPlane(vector2 * tileSize + Vector2.one * tileSize / 2f, _planeZY));
        }
    }
Exemplo n.º 20
0
        public void AcePlane_Ctor()
        {
            const string     planeId     = "aPlaneId";
            const string     playerId    = "aPeerId";
            const string     name        = "aName";
            const string     ctrl        = "ai";
            Vector2          pos         = new Vector2(3, 7);
            PlaneOrientation orientation = PlaneOrientation.kUp;

            AcePlane pl = new AcePlane(planeId, playerId, name, ctrl, pos, orientation);

            Assert.That(pl, Is.Not.Null);
            Assert.That(pl.PlaneId, Is.EqualTo(planeId));
            Assert.That(pl.PlayerId, Is.EqualTo(playerId));
            Assert.That(pl.Name, Is.EqualTo(name));
            Assert.That(pl.CtrlType, Is.EqualTo(ctrl));
            Assert.That(pl.Position, Is.EqualTo(pos));
            Assert.That(pl.Orientation, Is.EqualTo(orientation));
        }
Exemplo n.º 21
0
    public IntVector2D CoerceToBounds2D(IntVector2D vec, PlaneOrientation orientation)
    {
        IntVector2D res = vec;

        res.y = Mathf.Min(Mathf.Max(0, res.y), _yDim - 1);
        switch (orientation)
        {
        case PlaneOrientation.XY:
            res.x = Mathf.Min(Mathf.Max(0, res.x), _xDim - 1);
            break;

        case PlaneOrientation.ZY:
            res[0] = Mathf.Min(Mathf.Max(0, res[0]), _zDim - 1);
            break;

        default:
            break;
        }
        return(res);
    }
Exemplo n.º 22
0
        private void dicomPropertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            try
            {
                if (comboBoxConfigs.SelectedIndex < 0)
                {
                    return;
                }

                PlaneOrientation po = comboBoxConfigs.SelectedItem as PlaneOrientation;

                if (po.Condition == null || po.Condition.GetType( ) != typeof(TagValueOrientationCondition))
                {
                    return;
                }


                (( TagValueOrientationCondition )po.Condition).TagValue = e.ChangedItem.Value;
            }
            catch (Exception exception)
            {
                Messager.ShowError(this, exception);
            }
        }
Exemplo n.º 23
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                ConfigurationEditorDialog dlg;


                if (comboBoxPlane.SelectedIndex < 0)
                {
                    return;
                }

                dlg = new ConfigurationEditorDialog(false);

                dlg.ApplyCondition = true;

                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    Plane                        plane;
                    PlaneOrientation             orientation;
                    TagValueOrientationCondition condition;

                    plane       = ( Plane )comboBoxPlane.SelectedItem;
                    orientation = new PlaneOrientation();

                    if (dlg.ApplyCondition)
                    {
                        condition = new TagValueOrientationCondition(GetTag(dlg.DicomTag), dlg.TagValue);
                    }
                    else
                    {
                        condition = null;
                    }

                    orientation.Name      = dlg.ConfigurationName;
                    orientation.Condition = condition;

                    switch (plane)
                    {
                    case Plane.Axial:
                    {
                        _Configuration.Axial.Add(orientation);
                    }
                    break;

                    case Plane.Coronal:
                    {
                        orientation.Top   = OrientationAxis.Superior;
                        orientation.Right = OrientationAxis.Right;

                        _Configuration.Coronal.Add(orientation);
                    }
                    break;

                    case Plane.Sagittal:
                    {
                        orientation.Top   = OrientationAxis.Superior;
                        orientation.Right = OrientationAxis.Anterior;

                        _Configuration.Sagittal.Add(orientation);
                    }
                    break;
                    }

                    comboBoxConfigs.Items.Add(orientation);
                    comboBoxConfigs.SelectedItem = orientation;

                    SetOrientationInfo(orientation);

                    UpdateOrientConfigUI( );
                }
            }
            catch (Exception exception)
            {
                Messager.ShowError(this, exception);
            }
        }
Exemplo n.º 24
0
    private List <IntVector2D> ConnectedNodesForRelativeLocations(List <IntVector2D> relativeLocations, IntVector2D node, PlaneOrientation orientation)
    {
        var         connected = new List <IntVector2D>();
        IntVector2D below     = node + new IntVector2D(0, -1);

        if (IsInBounds2D(below.x, below.y, orientation) &&
            CanExistOn(relativeLocations, below, orientation))
        {
            connected.Add(below);
            return(connected); // Enforce falling if possible
        }

        // Move left and right
        for (int i = -1; i <= 1; i += 2)
        {
            int         horizPos = node[0] + i;
            IntVector2D dest     = new IntVector2D(horizPos, node.y);
            if (IsInBounds2D(horizPos, node.y, orientation) &&
                CanExistOn(relativeLocations, dest, orientation))
            {
                connected.Add(dest);
            }
            else   // Move step up
            {
                int vertPos = node[1] + 1;
                dest = new IntVector2D(horizPos, vertPos);
                if (IsInBounds2D(horizPos, node.y, orientation) &&
                    CanExistOn(relativeLocations, dest, orientation))
                {
                    connected.Add(dest);
                }
            }
        }

        return(connected);
    }
Exemplo n.º 25
0
 public bool IsInBounds2D(IntVector2D vec, PlaneOrientation orientation)
 {
     return(IsInBounds2D(vec[0], vec.y, orientation));
 }
    CursorPositioningController GetControllerForPositioningMethod(CursorPositioningMethod cursorPositioningMethod, PlaneOrientation plane)
    {
        switch (cursorPositioningMethod)
        {
        case CursorPositioningMethod.Meta2Interaction:
            return(inputDevices.GetComponentInChildren <Meta2CursorBehaviour>(true));

        case CursorPositioningMethod.LeapMotionController:
            return(inputDevices.GetComponentInChildren <LeapMotionControllerCursorBehaviour>(true));

        case CursorPositioningMethod.VIVE:
            return(inputDevices.GetComponentInChildren <ViveControllerPositionBehaviour>(true));

        case CursorPositioningMethod.Mouse:
        default:
        {
            Mouse2DInputBehaviour mouseController = inputDevices.GetComponentInChildren <Mouse2DInputBehaviour>(true);
            mouseController.plane = plane;
            return(mouseController);
        }
        }
    }
Exemplo n.º 27
0
 bool PassableAt2D(IntVector2D v, PlaneOrientation orientation)
 {
     return(PassableAt2D(v[0], v[1], orientation));
 }