Пример #1
0
        public static bool AddNewHits(ISpread<Blob> hits, ISpread<Blob> currentBlobs)
        {
            var isAdded = false;

            foreach (var hit in hits.Where(hit => hit.IsNew))
            {
                currentBlobs.Add(hit);
                isAdded = true;
            }

            return isAdded;
        }
        private void UpdateOutputPins()
        {
            FVariableName.SliceCount = FVariableType.SliceCount = FStride.SliceCount = 0;

            for (int i = 0; i < FAttributeName.SliceCount; i++)
            {
                string     varDefinition = FAttributeName[i];
                Definition def           = new Definition(varDefinition);
                FVariableName.Add(def.Name);
                FVariableType.Add(def.Type);
                FStride.Add(def.Size * 4);
            }

            FVariableName.Flush();
            FVariableType.Flush();
            FStride.Flush();
        }
        private void UpdateOutputPins()
        {
            FOrder.SliceCount         = FBufferSemantic.SliceCount = FElementCountBuf.SliceCount = FValueRange.SliceCount =
                FStrideBuf.SliceCount = FModeBuf.SliceCount = FResetCounterBuf.SliceCount = 0;

            if (FParticleSystemName.SliceCount != 0)
            {
                var particleSystemData = ParticleSystemRegistry.Instance.GetByParticleSystemName(FParticleSystemName[0]);
                if (particleSystemData != null)
                {
                    // gett all buffer settings
                    var pbsl = particleSystemData.BufferSettings
                               .SelectMany(kvp => kvp.Value).ToArray();

                    // now find the buffer settings specified by enum
                    for (int i = 0; i < pbsl.Count(); i++)
                    {
                        ParticleSystemBufferSettings pbs = pbsl[i];
                        for (int j = 0; j < FBufferName.SliceCount; j++)
                        {
                            if (pbs.bufferSemantic == FBufferName[j])
                            {
                                // we found the specified buffer settings
                                FOrder.Add(i);
                                FBufferSemantic.Add(pbs.bufferSemantic);
                                FElementCountBuf.Add(pbs.elementCount);
                                FValueRange.Add(pbs.valueRange);
                                FStrideBuf.Add(pbs.stride);
                                FModeBuf.Add(pbs.bufferMode);
                                FResetCounterBuf.Add(pbs.resetCounter);

                                break;
                            }
                        }
                    }
                }

                FOrder.Flush();
                FBufferSemantic.Flush();
                FElementCountBuf.Flush();
                FValueRange.Flush();
                FStrideBuf.Flush();
                FModeBuf.Flush();
                FResetCounterBuf.Flush();
            }
        }
Пример #4
0
 /// <summary>
 /// Inserts an item to the <see cref="ISpread{T}"/> at the specified index.
 /// </summary>
 /// <param name="spread">The <see cref="ISpread{T}"/> to insert the item into.</param>
 /// <param name="index">The zero-based index at which item should be inserted.</param>
 /// <param name="item">The object to insert into the <see cref="ISpread{T}"/>.</param>
 /// <remarks>
 /// If index equals the number of items in the <see cref="ISpread{T}"/>, then item is appended to the spread.
 /// </remarks>
 public static void Insert <T>(this ISpread <T> spread, int index, T item)
 {
     if (index == spread.SliceCount)
     {
         spread.Add(item);
     }
     else
     {
         index = VMath.Zmod(index, spread.SliceCount);
         spread.SliceCount++;
         for (int j = spread.SliceCount - 1; j >= index; j--)
         {
             spread[j] = spread[j - 1];
         }
         spread[index] = item;
     }
 }
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            FOutSlides.SliceCount = 0;

            var indexList = new List <int>(FInIndex);

            foreach (var slide in FInSlides)
            {
                if (slide != null)
                {
                    if (indexList.Contains(slide.Index))
                    {
                        FOutSlides.Add(slide);
                    }
                }
            }
        }
Пример #6
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            FPinOutput.SliceCount = 0;
            if (FPinInput.SliceCount > 0 && FPinInput[0] != null)
            {
                for (int i = 0; i < FPinInput.SliceCount; i++)
                {
                    bool matches = false;
                    for (int j = 0; j < FPinInAddress.SliceCount; j++)
                    {
                        switch (FPinInFilter[0])
                        {
                        case Filter.Matches:
                            matches |= FPinInput[i].Address == FPinInAddress[j];
                            break;

                        case Filter.Contains:
                            matches |= FPinInput[i].Address.Contains(FPinInAddress[j]);
                            break;

                        case Filter.Starts:
                            matches |= FPinInput[i].Address.StartsWith(FPinInAddress[j]);
                            break;

                        case Filter.Ends:
                            matches |= FPinInput[i].Address.EndsWith(FPinInAddress[j]);
                            break;

                        case Filter.All:
                            matches = true;
                            break;
                        }
                    }
                    if (matches)
                    {
                        FPinOutput.Add <OSCPacket>(FPinInput[i]);
                    }
                }
            }

            if (FPinOutput.SliceCount == 0)
            {
                FPinOutput.SliceCount = 1;
                FPinOutput[0]         = null;
            }
        }
Пример #7
0
 public void Evaluate(int spreadMax)
 {
     FOutput.SliceCount      = 0;
     FFormerIndex.SliceCount = 0;
     FFilterIndex.SliceCount = 0;
     for (int i = 0; i < FInput.SliceCount; i++)
     {
         for (int f = 0; f < FName.SliceCount; f++)
         {
             if (FInput[i] != null && FInput[i].Name == FName[f])
             {
                 FOutput.Add(FInput[i]);
                 FFormerIndex.Add(i);
                 FFilterIndex.Add(f);
             }
         }
     }
 }
Пример #8
0
        private void UpdateOutputs()
        {
            StatesOut.SliceCount = 0;
            foreach (State state in stateList) // Loop through List with foreach.
            {
                StatesOut.Add(state.Name);
            }


            TransitionTimeSettingOut.SliceCount = 0;
            TransitionsOut.SliceCount           = 0;
            foreach (Transition transition in transitionList) // Loop through List with foreach.
            {
                TransitionsOut.Add(transition.Name);
                TransitionTimeSettingOut.Add(transition.Frames);
            }
            TransitionsOut.Add("∅");
        }
Пример #9
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            FOutID.SliceCount                = 0;
            FOutLastSeen.SliceCount          = 0;
            FOutTimeSinceLastSeen.SliceCount = 0;
            FOutBus.SliceCount               = 0;

            foreach (var motor in FInput)
            {
                if (motor != null)
                {
                    FOutID.Add(motor.ID);
                    FOutLastSeen.Add(motor.LastSeen.ToString());
                    FOutTimeSinceLastSeen.Add((DateTime.Now - motor.LastSeen).TotalSeconds);
                    FOutBus.Add(motor.Bus);
                }
            }
        }
Пример #10
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FApply[0])
            {
                FGeometry.SliceCount = 0;

                for (int i = 0; i < FVertices.SliceCount; i++)
                {
                    if (FVertices[i].SliceCount > 2)
                    {
                        PathGeometry myPathGeometry = new PathGeometry();

                        myPathGeometry.FillRule = FFillRuleEnum[i];
                        PathFigureCollection myPathFigureCollection = new PathFigureCollection();
                        myPathGeometry.Figures = myPathFigureCollection;

                        PathFigure myPathFigure = new PathFigure();
                        myPathFigureCollection.Add(myPathFigure);

                        PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
                        myPathFigure.Segments = myPathSegmentCollection;

                        myPathFigure.StartPoint = new Point(FVertices[i][0].x, FVertices[i][0].y);

                        for (int j = 1; j < FVertices[i].SliceCount; j++)
                        {
                            LineSegment myLineSegment = new LineSegment();
                            myLineSegment.Point = new Point(FVertices[i][j].x, FVertices[i][j].y);
                            myPathSegmentCollection.Add(myLineSegment);
                        }

                        myPathFigure.IsClosed = FClosed[i];

                        if (FClosed[i])
                        {
                            LineSegment myLineSegment = new LineSegment();
                            myLineSegment.Point = new Point(FVertices[i][0].x, FVertices[i][0].y);
                            myPathSegmentCollection.Add(myLineSegment);
                        }
                        FGeometry.Add(myPathGeometry);
                    }
                }
            }
        }
Пример #11
0
 public void Evaluate(int SpreadMax)
 {
     if (!FInputs.IsChanged)
     {
         return;
     }
     FOutSelector.SliceCount = 0;
     for (int i = 0; i < FInputs.Count(); i++)
     {
         for (int j = 0; j < FInputs[i].IOObject.SliceCount; j++)
         {
             Selector selectorIn = FInputs[i].IOObject[j];
             if (selectorIn != null)
             {
                 FOutSelector.Add(selectorIn);
             }
         }
     }
 }
Пример #12
0
        //fill the pins recursive with data
        private void FillRecursive(SvgElement elem, int level)
        {
            FElementsOut.Add(elem);
            FElementTypeOut.Add(elem.GetType().Name.Replace("Svg", ""));
            FElementLevelOut.Add(level);
            FElementIDOut.Add(elem.ID);
            var className = "";

            if (elem.CustomAttributes.ContainsKey("class"))
            {
                className = elem.CustomAttributes["class"];
            }
            FElementClassOut.Add(className);

            foreach (var child in elem.Children)
            {
                FillRecursive(child, level + 1);
            }
        }
        private unsafe void DepthFrameReady(object sender, DepthFrameArrivedEventArgs e)
        {
            if (e.FrameReference != null)
            {
                using (var frame = e.FrameReference.AcquireFrame())
                {
                    if (frame != null)
                    {
                        using (var buffer = frame.LockImageBuffer())
                        {
                            short *data = (short *)buffer.UnderlyingBuffer;
                            FOutValue.SliceCount = 0;
                            FRayTable.SliceCount = 0;

                            int pixelX = 10;
                            int pixelY = 10;

                            foreach (var item in FInPixelPos)
                            {
                                pixelX = (int)item.X;
                                pixelY = (int)item.Y;

                                pixelX = pixelX < 0 ? 0 : pixelX;
                                pixelY = pixelY < 0 ? 0 : pixelY;

                                pixelX = pixelX > 511 ? 511 : pixelX;
                                pixelY = pixelY > 423 ? 423 : pixelY;

                                double pixel = data[pixelY * 512 + pixelX];
                                FOutValue.Add(pixel);

                                if (dataRayTable != null)
                                {
                                    PointF mypoint = dataRayTable[pixelY * 512 + pixelX];

                                    FRayTable.Add(new Vector2(mypoint.X, mypoint.Y));
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #14
0
        public void Evaluate(int SpreadMax)
        {
            if (MessageEnumerator == null)
            {
                return;
            }

            if (!FReset.IsAnyInvalid() && FReset[0])
            {
                MessageEnumerator.Reset();
            }

            if (FRead.IsAnyInvalid() || !FRead[0])
            {
                return;
            }

            FEndOfStream[0] = false;


            FOutput.SliceCount = 0;
            var maxCount = FCount[0];

            for (int i = 0; i < maxCount; i++)
            {
                try
                {
                    MessageEnumerator.MoveNext();
                    var message = MessageEnumerator.Current.ToObject <Message>();
                    FOutput.Add(message);
                }
                catch (Exception e)
                {
                    MessageEnumerator.Reset();
                    FEndOfStream[0] = true;

                    FLogger.Log(LogType.Debug, e.ToString());
                }
            }
            FOutput.Flush();

            FError[0] = "";
        }
Пример #15
0
#pragma warning restore
        #endregion fields & pins

        public void Evaluate(int SpreadMax)
        {
            FOutput.SliceCount = FInput.SliceCount;
            FFormer.SliceCount = 0;
            if (FInput.IsChanged)
            {
                for (int i = 0; i < FInput.SliceCount; i++)
                {
                    FOutput[i].SliceCount = 0;
                    for (int j = 0; j < FSelect[i]; j++)
                    {
                        FOutput[i].AddRange(FInput[i]);
                        FFormer.Add(i);
                    }
                }
                FOutput.Flush();
                FFormer.Flush();
            }
        }
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (!(FSelect.IsChanged || FGeometryIn.IsChanged))
            {
                return;
            }

            FGeometryOut.SliceCount = 0;
            for (int i = 0; i < SpreadMax; i++)
            {
                try {
                    if (FSelect[i])
                    {
                        FGeometryOut.Add(FGeometryIn[i]);
                    }
                } catch (Exception e) {
                }
            }
        }
Пример #17
0
        //called when data for any output pin is requested
        public void Evaluate(int spreadMax)
        {
            FOutFlags.SliceCount      = 0;
            FOutIdentifier.SliceCount = 0;
            FOutLength.SliceCount     = 0;
            FOutData.SliceCount       = 0;

            for (int i = 0; i < spreadMax; i++)
            {
                var message = FInput[i];
                if (message != null)
                {
                    FOutFlags.Add((int)message.Flags);
                    FOutIdentifier.Add((int)message.Identifier);
                    FOutLength.Add(message.Length);
                    FOutData.Add(new MemoryStream(message.Data));
                }
            }
        }
Пример #18
0
 protected override void UseGesture(GestureNotification gesture, bool isFilterMatch, int index)
 {
     if (isFilterMatch)
     {
         double distance = (double)(gesture.Arguments & Const.ULL_ARGUMENTS_BIT_MASK);
         if (index < 0)
         {
             DistanceOut.Add(distance / (double)gesture.ClientArea.Height * 2);
         }
         else
         {
             DistanceOut[index] = distance / (double)gesture.ClientArea.Height * 2;
         }
     }
     else if (index >= 0)
     {
         DistanceOut.RemoveAt(index);
     }
 }
Пример #19
0
        public void Evaluate(int spreadMax)
        {
            int sMax = SpreadUtils.SpreadMax(FInput, FSelect);

            FOutput.SliceCount      = 0;
            FFormerSlice.SliceCount = 0;

            for (int i = 0; i < sMax; i++)
            {
                for (int s = 0; s < FSelect[i]; s++)
                {
                    if (s == 0)
                    {
                        FOutput.SliceCount++;
                    }
                    FOutput[FOutput.SliceCount - 1] = FInput[i];
                    FFormerSlice.Add(i);
                }
            }
        }
Пример #20
0
        //called when data for any output pin is requested

        public void Evaluate(int SpreadMax)
        {
            FValid.SliceCount = FInput.SliceCount;
            if (FInput.IsChanged)
            {
                FJOutput.SliceCount = 0;
                for (int i = 0; i < FInput.SliceCount; i++)
                {
                    if (JToken.Parse(FInput[i]) != null)
                    {
                        FJOutput.Add(JToken.Parse(FInput[i]));
                        FValid[i] = true;
                    }
                    else
                    {
                        FValid[i] = false;
                    }
                }
            }
        }
Пример #21
0
        public void Evaluate(int SpreadMax)
        {
            if (!FInputs.IsChanged)
            {
                return;
            }

            int index = FSwitch[0];

            FOutSelector.SliceCount = 0;

            for (int i = 0; i < FInputs[index].IOObject.SliceCount; i++)
            {
                Selector selectorIn = FInputs[index].IOObject[i];
                if (selectorIn != null)
                {
                    FOutSelector.Add(selectorIn);
                }
            }
        }
        //called when data for any output pin is requested
        public void Evaluate(int spreadMax)
        {
            FOutput.SliceCount = 0;

            for (int i = 0; i < spreadMax; i++)
            {
                //get the input stream
                var inputStream = FInput[i];
                var value       = inputStream.ReadByte();
                while (value != -1)
                {
                    if (value == 0xFF)
                    {
                        try {
                            var message = this.DecodeBuffer();
                            if (message != null)
                            {
                                FOutput.Add(message);
                            }
                        }
                        catch {
                            this.FErrors++;
                        }
                        finally {
                            this.FIncomingBuffer.Clear();
                        }
                    }
                    else
                    {
                        if (value != 0x0A)
                        {
                            this.FIncomingBuffer.Add((char)value);
                        }
                    }
                    value = inputStream.ReadByte();
                }
            }
            FOutBufferLength[0] = FIncomingBuffer.Count;
            FOutErrors[0]       = this.FErrors;
            //this will force the changed flag of the output pin to be set
        }
Пример #23
0
        protected override void UseGesture(GestureNotification gesture, bool isFilterMatch, int index)
        {
            if (isFilterMatch)
            {
                double rotate = (double)(gesture.Arguments & Const.ULL_ARGUMENTS_BIT_MASK);
                rotate = rotate / 65535.0 * 2 - 1;

                if (index < 0)
                {
                    RotateOut.Add(rotate);
                }
                else
                {
                    RotateOut[index] = rotate;
                }
            }
            else if (index >= 0)
            {
                RotateOut.RemoveAt(index);
            }
        }
Пример #24
0
#pragma warning restore
        #endregion fields & pins

        public void Evaluate(int SpreadMax)
        {
            FOutput.SliceCount = 0;
            FFormer.SliceCount = 0;
            if (FInput.IsChanged)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    Time output = FInput[i];

                    for (int j = 0; j < FSelect[i]; j++)
                    {
                        FOutput.Add(output);
                        FFormer.Add(i % FInput.SliceCount);
                    }
                }

                FOutput.Flush();
                FFormer.Flush();
            }
        }
Пример #25
0
#pragma warning restore
        #endregion fields & pins

        public void Evaluate(int SpreadMax)
        {
            FOutput.SliceCount = 0;
            FFormer.SliceCount = 0;

            if ((FInput.SliceCount > 0) && (FInput[0] != null))
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    T output = FInput[i];

                    for (int j = 0; j < FSelect[i]; j++)
                    {
                        FOutput.Add(output);
                        FFormer.Add(i % FInput.SliceCount);
                    }
                }
            }
            FOutput.Flush();
            FFormer.Flush();
        }
Пример #26
0
        private void LoadList()
        {
            try
            {
                FPinOutDevices.SliceCount = 0;

                foreach (var camera in Context.Cameras)
                {
                    if (camera.IsSessionOpen)
                    {
                        FPinOutDevices.Add(camera);
                    }
                }

                FPinOutStatus[0] = "OK";
            }
            catch (Exception e)
            {
                FPinOutStatus[0] = "ERROR : " + e.Message;
            }
        }
Пример #27
0
        private void Refresh()
        {
            try
            {
                var cameras = FContext.Framework.GetCameraCollection();

                FPinOutDevices.SliceCount = 0;

                foreach (var camera in cameras)
                {
                    FPinOutDevices.Add(camera);
                }

                FPinOutStatus[0] = "OK";
            }

            catch (Exception e)
            {
                FPinOutStatus[0] = "ERROR : " + e.Message;
            }
        }
Пример #28
0
        //called when data for any output pin is requested
        public void Evaluate(int spreadMax)
        {
            FOutFlags.SliceCount        = 0;
            FOutID.SliceCount           = 0;
            FOutOperation.SliceCount    = 0;
            FOutRegisterType.SliceCount = 0;
            FOutValue.SliceCount        = 0;

            for (int i = 0; i < spreadMax; i++)
            {
                var message = FInput[i];
                if (message != null)
                {
                    if (message.Length == 7)
                    {
                        var operation = message.Data[0];
                        if (operation < 100)
                        {
                            int registerIndex = 0;
                            registerIndex += (int)message.Data[2] << 8;
                            registerIndex += (int)message.Data[1];

                            int registerValue = 0;
                            registerValue += (int)message.Data[3];
                            registerValue += (int)message.Data[4] << 8;
                            registerValue += (int)message.Data[5] << 16;
                            registerValue += (int)message.Data[6] << 24;

                            var ID = message.Identifier >> 19;

                            FOutFlags.Add((int)message.Flags);
                            FOutID.Add((int)ID);
                            FOutOperation.Add((int)operation);
                            FOutRegisterType.Add(registerIndex);
                            FOutValue.Add(registerValue);
                        }
                    }
                }
            }
        }
Пример #29
0
        public override void Evaluate(int SpreadMax, CVRSystem system)
        {
            FSystem = system;

            if (OpenVRManager.RenderPoses == null)
            {
                return;
            }

            //poses
            var poseCount   = (int)OpenVR.k_unMaxTrackedDeviceCount;
            var renderPoses = OpenVRManager.RenderPoses;
            var gamePoses   = OpenVRManager.GamePoses;

            FRenderPosesOut.SliceCount     = poseCount;
            FGamePosesOut.SliceCount       = poseCount;
            FDeviceClassOut.SliceCount     = poseCount;
            FLighthousePosesOut.SliceCount = 0;
            FControllerPosesOut.SliceCount = 0;

            for (int i = 0; i < poseCount; i++)
            {
                FRenderPosesOut[i] = renderPoses[i].mDeviceToAbsoluteTracking.ToMatrix();
                FGamePosesOut[i]   = gamePoses[i].mDeviceToAbsoluteTracking.ToMatrix();
                var deviceClass = system.GetTrackedDeviceClass((uint)i);
                FDeviceClassOut[i] = deviceClass.ToString();

                if (deviceClass == ETrackedDeviceClass.TrackingReference)
                {
                    FLighthousePosesOut.Add(FGamePosesOut[i]);
                }

                if (deviceClass == ETrackedDeviceClass.Controller)
                {
                    FControllerPosesOut.Add(FGamePosesOut[i]);
                }
            }

            FHMDPoseOut[0] = FRenderPosesOut[0];
        }
Пример #30
0
        //called when data for any output pin is requested
        public virtual void Evaluate(int SpreadMax)
        {
            int sMax = Math.Max(FInput.SliceCount, FSelect.SliceCount);

            FOutput.SliceCount      = 0;
            FFormerSlice.SliceCount = 0;

            for (int i = 0; i < sMax; i++)
            {
                for (int s = 0; s < FSelect[i]; s++)
                {
                    if (s == 0)
                    {
                        FOutput.SliceCount++;
                        FOutput[FOutput.SliceCount - 1].SliceCount = 0;
                    }
                    FOutput[FOutput.SliceCount - 1].AddRange(FInput[i]);

                    FFormerSlice.Add(i);
                }
            }
        }
Пример #31
0
 public void Evaluate(int SpreadMax)
 {
     Output.ResizeAndDispose(Input.SliceCount, (int i) => new RingStream(BufferSizes[i]));
     FSpreadMax.SliceCount = Output.SliceCount;
     Debug.SliceCount      = 0;
     for (int i = 0; i < Output.SliceCount; i++)
     {
         var buff = Output[i] as RingStream;
         if (BufferSizes.IsChanged)
         {
             buff.BufferSize = BufferSizes[i];
         }
         if (Input.IsChanged)
         {
             var inStream = Input[i];
             buff.CopyFrom(inStream);
         }
         Output[i]     = buff;
         FSpreadMax[i] = Output[i].GetHashCode();
         Debug.Add(buff.ToString());
     }
 }
Пример #32
0
		public void GetSkeletons(ISpread<Skeleton> spread)
		{
			spread.SliceCount = 0;
			foreach(var s in FSkeletons)
				spread.Add(s);
		}