Example #1
0
        public EditableRoundingRect(IUnityContainer container)
            : base(container)
        {
            double size             = App.DeviceInfo.ImageSize.Width / 100;
            Size   controlPointSize = new Size(size, size);

            ControlPointList.Add(new LeftControlPoint()
            {
                X = X, Y = Y, Size = controlPointSize
            });
            ControlPointList.Add(new TopControlPoint()
            {
                X = X, Y = Y, Size = controlPointSize
            });
            ControlPointList.Add(new RightControlPoint()
            {
                X = X, Y = Y, Size = controlPointSize
            });
            ControlPointList.Add(new BottomControlPoint()
            {
                X = X, Y = Y, Size = controlPointSize
            });
            ControlPointList.Add(new RadiusControlPoint()
            {
                X = X, Y = Y, Size = controlPointSize
            });
        }
Example #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ControlPointList.Cast <Vector4>().GetHashCode(v => v.GetHashCode());
         hashCode = (hashCode * 397) ^ KnotsU.GetHashCode(v => v.GetHashCode());
         hashCode = (hashCode * 397) ^ KnotsV.GetHashCode(v => v.GetHashCode());
         hashCode = (hashCode * 397) ^ OrderU;
         hashCode = (hashCode * 397) ^ OrderV;
         return(hashCode);
     }
 }
Example #3
0
        /// <summary>
        /// Returns an untrimmed solidworks surface.
        /// </summary>
        /// <param name="swBSplineSurfaceParams"></param>
        /// <returns></returns>
        public ISurface ToSurface()
        {
            var vOrder = BitConverter.GetBytes(OrderV);
            var uOrder = BitConverter.GetBytes(OrderU);

            var swControlPointList = ControlPointList
                                     .EnumerateColumnWise()
                                     .SelectMany(v => new[] { v.X / v.W, v.Y / v.W, v.Z / v.W, v.W }.Take(SurfaceDimension))
                                     .ToArray();

            var uLength = ControlPointList.GetLength(0);
            var vLength = ControlPointList.GetLength(1);

            var numUCtrPts = BitConverter.GetBytes(uLength);
            var numVCtrPts = BitConverter.GetBytes(vLength);

            var uPeriodicity = BitConverter.GetBytes(UIsPeriodic ? 1 : 0);
            var vPeriodicity = BitConverter.GetBytes(VIsPeriodic ? 1 : 0);

            var dimControlPoints = BitConverter.GetBytes(SurfaceDimension);
            var unusedParameter  = BitConverter.GetBytes(0);

            var props = new[]
            {
                BitConverter.ToDouble(uOrder.Concat(vOrder).ToArray(), 0),
                BitConverter.ToDouble(numVCtrPts.Concat(numUCtrPts).ToArray(), 0),
                BitConverter.ToDouble(uPeriodicity.Concat(vPeriodicity).ToArray(), 0),
                BitConverter.ToDouble(dimControlPoints.Concat(unusedParameter).ToArray(), 0)
            };

            var bsplineSurface = (Surface)SwAddinBase.Active.Modeler
                                 .CreateBsplineSurface
                                     (props
                                     , KnotsU
                                     , KnotsV
                                     , swControlPointList
                                     );

            Debug.Assert(bsplineSurface != null);

#if DEBUG
            var p = bsplineSurface.Parameterization2();
            Debug.Assert(Math.Abs(p.UMax - KnotsU.Last()) < 1e-9);
            Debug.Assert(Math.Abs(p.UMin - KnotsU.First()) < 1e-9);
            Debug.Assert(Math.Abs(p.VMax - KnotsV.Last()) < 1e-9);
            Debug.Assert(Math.Abs(p.VMin - KnotsV.First()) < 1e-9);
#endif

            return(bsplineSurface);
        }
    public override bool Calculate()
    {
        IModule3D value = Inputs[0].GetValue <IModule3D>();

        if (value == null)
        {
            return(false);
        }
        ControlPointList value2 = Inputs[1].GetValue <ControlPointList>();

        if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Curve && (value2 == null || value2.points.Count == 0))
        {
            return(false);
        }
        FloatList value3 = Inputs[2].GetValue <FloatList>();

        if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Terrace && (value3 == null || value3.points.Count == 0))
        {
            return(false);
        }
        IModule3D module3D = target.CreateModule(value);

        if (module3D == null)
        {
            return(false);
        }
        if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Curve)
        {
            Curve curve = module3D as Curve;
            curve.ClearControlPoints();
            List <ControlPoint> controls = value2.GetControls();
            foreach (ControlPoint item in controls)
            {
                curve.AddControlPoint(item);
            }
        }
        else if (target.modifyType == ProcGen.Noise.Modifier.ModifyType.Terrace)
        {
            Terrace terrace = module3D as Terrace;
            terrace.ClearControlPoints();
            foreach (float point in value3.points)
            {
                float input = point;
                terrace.AddControlPoint(input);
            }
        }
        Outputs[0].SetValue(module3D);
        return(true);
    }
Example #5
0
        public bool Equals(BSplineSurface other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            return(ControlPointList.Cast <Vector4>().SequenceEqual(other.ControlPointList.Cast <Vector4>()) &&
                   KnotsU.SequenceEqual(other.KnotsU) &&
                   KnotsV.SequenceEqual(other.KnotsV)

                   && OrderU == other.OrderU &&
                   OrderV == other.OrderV);
        }
Example #6
0
        private void CreateDspObjects()
        {
            Debug.Console(2, "Creating DSP Objects");

            var props = JsonConvert.DeserializeObject <TesiraDspPropertiesConfig>(_dc.Properties.ToString());

            if (props == null)
            {
                return;
            }

            Debug.Console(2, this, "Props Exists");
            Debug.Console(2, this, "Here's the props string\n {0}", _dc.Properties.ToString());

            Faders.Clear();
            Presets.Clear();
            Dialers.Clear();
            States.Clear();
            Switchers.Clear();
            ControlPointList.Clear();
            Meters.Clear();
            RoomCombiners.Clear();

            if (props.FaderControlBlocks != null)
            {
                Debug.Console(2, this, "levelControlBlocks is not null - There are {0} of them", props.FaderControlBlocks.Count());
                foreach (var block in props.FaderControlBlocks)
                {
                    var key = block.Key;
                    Debug.Console(2, this, "LevelControlBlock Key - {0}", key);
                    var value = block.Value;

                    Faders.Add(key, new TesiraDspFaderControl(key, value, this));
                    Debug.Console(2, this, "Added LevelControlPoint {0} LevelTag: {1} MuteTag: {2}", key, value.LevelInstanceTag, value.MuteInstanceTag);
                    if (block.Value.Enabled)
                    {
                        //Add ControlPoint to the list for the watchdog
                        ControlPointList.Add(Faders[key]);
                    }
                }
            }

            if (props.SwitcherControlBlocks != null)
            {
                Debug.Console(2, this, "switcherControlBlocks is not null - There are {0} of them", props.FaderControlBlocks.Count());
                foreach (var block in props.SwitcherControlBlocks)
                {
                    var key = block.Key;
                    Debug.Console(2, this, "SwitcherControlBlock Key - {0}", key);
                    var value = block.Value;

                    Switchers.Add(key, new TesiraDspSwitcher(key, value, this));
                    Debug.Console(2, this, "Added TesiraSwitcher {0} InstanceTag {1}", key, value.SwitcherInstanceTag);

                    if (block.Value.Enabled)
                    {
                        //Add ControlPoint to the list for the watchdog

                        ControlPointList.Add(Switchers[key]);
                    }
                }
            }

            if (props.DialerControlBlocks != null)
            {
                Debug.Console(2, this, "DialerControlBlocks is not null - There are {0} of them", props.DialerControlBlocks.Count());
                foreach (var block in props.DialerControlBlocks)
                {
                    var key = block.Key;
                    Debug.Console(2, this, "LevelControlBlock Key - {0}", key);
                    var value = block.Value;
                    Dialers.Add(key, new TesiraDspDialer(key, value, this));
                    Debug.Console(2, this, "Added DspDialer {0} ControlStatusTag: {1} DialerTag: {2}", key, value.ControlStatusInstanceTag, value.DialerInstanceTag);

                    if (block.Value.Enabled)
                    {
                        ControlPointList.Add(Dialers[key]);
                    }
                }
            }

            if (props.StateControlBlocks != null)
            {
                Debug.Console(2, this, "stateControlBlocks is not null - There are {0} of them", props.StateControlBlocks.Count());
                foreach (var block in props.StateControlBlocks)
                {
                    var key   = block.Key;
                    var value = block.Value;
                    States.Add(key, new TesiraDspStateControl(key, value, this));
                    Debug.Console(2, this, "Added DspState {0} InstanceTag: {1}", key, value.StateInstanceTag);

                    if (block.Value.Enabled)
                    {
                        ControlPointList.Add(States[key]);
                    }
                }
            }

            if (props.Presets != null)
            {
                foreach (var preset in props.Presets)
                {
                    var value = preset.Value;
                    var key   = preset.Key;
                    Presets.Add(key, value);
                    Debug.Console(2, this, "Added Preset {0} {1}", value.Label, value.PresetName);
                }
            }

            if (props.MeterControlBlocks != null)
            {
                foreach (var meter in props.MeterControlBlocks)
                {
                    var key   = meter.Key;
                    var value = meter.Value;
                    Meters.Add(key, new TesiraDspMeter(key, value, this));
                    Debug.Console(2, this, "Adding Meter {0} InstanceTag: {1}", key, value.MeterInstanceTag);

                    if (value.Enabled)
                    {
                        ControlPointList.Add(Meters[key]);
                    }
                }
            }

            if (props.CrosspointStateControlBlocks != null)
            {
                foreach (var mixer in props.CrosspointStateControlBlocks)
                {
                    var key   = mixer.Key;
                    var value = mixer.Value;
                    CrosspointStates.Add(key, new TesiraDspCrosspointState(key, value, this));
                    Debug.Console(2, this, "Adding Mixer {0} InstanceTag: {1}", key, value.MatrixInstanceTag);

                    if (value.Enabled)
                    {
                        ControlPointList.Add(CrosspointStates[key]);
                    }
                }
            }
            if (props.RoomCombinerControlBlocks == null)
            {
                return;
            }
            foreach (var roomCombiner in props.RoomCombinerControlBlocks)
            {
                var key   = roomCombiner.Key;
                var value = roomCombiner.Value;
                RoomCombiners.Add(key, new TesiraDspRoomCombiner(key, value, this));
                Debug.Console(2, this, "Adding Mixer {0} InstanceTag: {1}", key, value.RoomCombinerInstanceTag);

                if (value.Enabled)
                {
                    ControlPointList.Add(RoomCombiners[key]);
                }
            }

            //Keep me at the end of this method!
            DeviceManager.AddDevice(new TesiraDspDeviceInfo(String.Format("{0}--DeviceInfo", Key), String.Format("{0}--DeviceInfo", Name, Presets), this, Presets));
        }