コード例 #1
0
ファイル: Wavetable.cs プロジェクト: jacalifa/Sinepost
		public Wavetable(Recurse amplitude, uint iterations = 64u, uint size = defaultSize){
			
			this.size = size;
			waveform = new float[this.size];
			
			double index = 0d, a;
			float peak = float.Epsilon;
			
			for(int i = 0; i < this.size; i++){
				
				a = 1d;
				index = i / (this.size - 1f);
				
				for(uint j = 0u; j < iterations; j++)
					waveform[i] += (float)(amplitude(ref a) * Math.Sin(2d * Math.PI * (j + 1) * index));
				
				if(Mathf.Abs(waveform[i]) > peak)
					peak = Mathf.Abs(waveform[i]);
				
			}
			
			for(int i = 0; i < this.size; i++)
				waveform[i] /= peak;
			
		}
コード例 #2
0
 public void Add(string filename, Recurse recurse)
 {
     Debug("SVN: Add(" + filename + ", " + recurse + ")");
     BeforeWriteOperation("add");
     try
     {
         _client.Add(filename, ConvertDepth(recurse));
     }
     catch (SvnException ex)
     {
         throw new SvnClientException(ex);
     }
     finally
     {
         AfterOperation();
     }
 }
コード例 #3
0
 private static SvnDepth ConvertDepth(Recurse recurse)
 {
     return recurse == Recurse.Full ? SvnDepth.Infinity : SvnDepth.Empty;
 }
コード例 #4
0
 public void Revert(string[] files, Recurse recurse)
 {
     Debug("SVN: Revert(" + string.Join(",", files) + ", " + recurse + ")");
     BeforeWriteOperation("revert");
     try
     {
         _client.Revert(
             files,
             new SvnRevertArgs
             {
                 Depth = ConvertDepth(recurse)
             });
     }
     catch (SvnException ex)
     {
         throw new SvnClientException(ex);
     }
     finally
     {
         AfterOperation();
     }
 }
コード例 #5
0
		static SvnDepth ConvertDepth(Recurse recurse)
		{
			if (recurse == Recurse.Full)
				return SvnDepth.Infinity;
			else
				return SvnDepth.Empty;
		}
コード例 #6
0
ファイル: GetChildItemCommand.cs プロジェクト: soulhakr/Pash
        protected override void ProcessRecord()
        {
            if (Path == null)
            {
                Path = new String[] { String.Empty }
            }
            ;

            if (Include != null)
            {
                if (Exclude != null)
                {
                    foreach (String _path in Path)
                    {
                        IncludeExclude(
                            InvokeProvider.ChildItem.GetNames(_path, ReturnContainers.ReturnMatchingContainers, Recurse.ToBool()),
                            InvokeProvider.ChildItem.Get(_path, Recurse.ToBool()),
                            Include,
                            Exclude);
                    }
                    return;
                }
            }

            if (Name.ToBool())
            {
                foreach (String _path in Path)
                {
                    foreach (String _name in
                             InvokeProvider.ChildItem.GetNames(_path, ReturnContainers.ReturnMatchingContainers, Recurse.ToBool()))
                    {
                        WriteObject(_name);
                    }
                }
            }

            else
            {
                foreach (String _path in Path)
                {
                    foreach (PSObject _item in
                             InvokeProvider.ChildItem.Get(_path, Recurse.ToBool()))
                    {
                        WriteObject(_item);
                    }
                }
            }
        }
コード例 #7
0
ファイル: Wavetable.cs プロジェクト: jacalifa/Sinepost
		public Wavetable(Recurse partial, Recurse amplitude, Recurse phase, Recurse offset, uint iterations = 64u, uint size = defaultSize){
			
			this.size = size;
			waveform = new float[this.size];
			
			double index = 0d, h, a, p, o;
			float peak = float.MinValue;
			
			for(int i = 0; i < this.size; i++){
				
				h = 1d;
				a = 1d;
				p = 0d;
				o = 0d;
				index = i / (this.size - 1d);
				
				for(uint j = 0; j < iterations; j++)
					waveform[i] += (float)(amplitude(ref a) * Math.Sin(2d * Math.PI * partial(ref h) * index + phase(ref p)) + offset(ref o));
				
				if(Mathf.Abs(waveform[i]) > peak)
					peak = Mathf.Abs(waveform[i]);
				
			}
			
			for(int i = 0; i < this.size; i++)
				waveform[i] /= peak;
			
		}
コード例 #8
0
ファイル: ConsideringShould.cs プロジェクト: eOkadas/NFluent
 public Recurse()
 {
     this.me = this;
 }
コード例 #9
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (LiteralPath.Expression != null)
            {
                targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context));
            }

            if (Filter.Expression != null)
            {
                targetCommand.AddParameter("Filter", Filter.Get(context));
            }

            if (Include.Expression != null)
            {
                targetCommand.AddParameter("Include", Include.Get(context));
            }

            if (Exclude.Expression != null)
            {
                targetCommand.AddParameter("Exclude", Exclude.Get(context));
            }

            if (Recurse.Expression != null)
            {
                targetCommand.AddParameter("Recurse", Recurse.Get(context));
            }

            if (Depth.Expression != null)
            {
                targetCommand.AddParameter("Depth", Depth.Get(context));
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (Name.Expression != null)
            {
                targetCommand.AddParameter("Name", Name.Get(context));
            }

            if (Attributes.Expression != null)
            {
                targetCommand.AddParameter("Attributes", Attributes.Get(context));
            }

            if (Directory.Expression != null)
            {
                targetCommand.AddParameter("Directory", Directory.Get(context));
            }

            if (File.Expression != null)
            {
                targetCommand.AddParameter("File", File.Get(context));
            }

            if (Hidden.Expression != null)
            {
                targetCommand.AddParameter("Hidden", Hidden.Get(context));
            }

            if (ReadOnly.Expression != null)
            {
                targetCommand.AddParameter("ReadOnly", ReadOnly.Get(context));
            }

            if (System.Expression != null)
            {
                targetCommand.AddParameter("System", System.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
コード例 #10
0
        /// <summary>
        /// This is like the GenCell method, but super hacked up for the Catacombs image with Henry.
        /// </summary>
        internal static void GenCellCatacombs(Sphere[] simplex, bool ball)
        {
            // We don't want to include the first mirror (which reflects across cells).
            Sphere[] mirrors    = simplex.Skip(1).ToArray();
            Sphere[] allMirrors = simplex.ToArray();

            // Simplices will be the "cells" in Recurse.CalcCells.
            H3.Cell.Facet[] simplexFacets = simplex.Select(m => new H3.Cell.Facet(m)).ToArray();

            // Offset cell boundary ever so slightly, to avoid artifacts of adjacent cells.
            Sphere toReflectLater = simplexFacets[0].Sphere.Clone();

            //simplexFacets[0].Sphere = CoxeterImages.GeodesicOffset( simplexFacets[0].Sphere, ball ? -1e-6 : 1e-7, ball );

            H3.Cell startingCell = new H3.Cell(simplexFacets);
            startingCell = startingCell.Clone();                // So our mirrors don't get munged after we reflect around later.
            Vector3D cen = new Vector3D(0.05, 0.01, -0.05);     //	373, 438

            //Vector3D cen = new Vector3D( 0.05, 0.01, 100 );		//	637
            //cen.RotateXY( Math.PI / 2 );	// only if we also rotate simplex mirrors.  XXX - make a setting.
            startingCell.Center = cen;
            H3.Cell[] simplices = Recurse.CalcCells(mirrors, new H3.Cell[] { startingCell }, new Recurse.Settings()
            {
                Ball = ball
            });

            List <H3.Cell> simplicesFinal = new List <H3.Cell>();
            List <int[]>   reflectionSets = new List <int[]>();

            // 1 reflects in x-axis
            // 3, 1 rotates right
            // 1, 3 rotates left

            reflectionSets.Add(new int[] { 0, 3, 1, 3, 1, 0, 1, 3 });
            reflectionSets.Add(new int[] { 0, 3, 1, 2, 3, 1, 0, 3, 1, 2, 0, 3 });

            // 2
            reflectionSets.Add(new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 3, 1, 3, 1, 3, 1, 2, 3, 1, 3, 2, 3, 1 });
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0,		3, 1, 3, 1, 0,	3, 1, 3, 1, 3, 1, 2,	3, 1, 3, 2, 3, 1 } );

            // 3
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 3, 1, 3, 1, 0, 3, 1, 2 } );
            reflectionSets.Add(new int[] { 0, 3, 1, 3, 1, 3, 0, 3, 1, 3, 1, 0, 2 });
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 3, 1, 2 } );

            // 5
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 1, 2, 3, 1 } );

            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 0, 2, 3, 1 } );
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 0, 3, 1, 3, 1, 3, 1, 2, 3, 1, 3, 1, 0, 1, 3 } );	// baby
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 0, 3, 1, 3, 1, 3, 1, 2 } );	// maybe
            //reflectionSets.Add( new int[] { 0, 3, 1, 2, 3, 1, 0, 2, 1, 3 } );
            //reflectionSets.Add( new int[] { 0, 3, 1, 2, 3, 1, 0, 3, 1, 2 } );		// not great orientation
            // reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 2 } );	// big

            bool ceiling = true;

            if (ceiling)
            {
                simplicesFinal = simplices.ToList();
            }
            else
            {
                foreach (int[] set in reflectionSets)
                {
                    List <H3.Cell> copy = simplices.Select(s => s.Clone()).ToList();
                    foreach (int r in set)
                    {
                        foreach (H3.Cell cell in copy)
                        {
                            cell.Reflect(allMirrors[r]);
                        }
                    }
                    simplicesFinal.AddRange(copy);
                }
            }

            /*
             * // A second cell.
             * //toReflectLater = simplices[45].Facets[0].Sphere.Clone();
             * //toReflectLater = simplices.First( s => s.Depth == 2 ).Facets[0].Sphere.Clone();
             * foreach( H3.Cell cell in simplices )
             *      cell.Reflect( toReflectLater );
             *
             * // A third cell.
             * toReflectLater = simplices[40].Facets[0].Sphere.Clone();
             * //toReflectLater = simplices.First( s => s.Depth == 4 ).Facets[0].Sphere.Clone();
             * foreach( H3.Cell cell in simplices )
             *      cell.Reflect( toReflectLater );
             *
             * foreach( H3.Cell cell in simplices )
             *      cell.Depths = new int[4];
             * List<H3.Cell> simplicesFinal = Recurse.CalcCells2( mirrors, simplices ).ToList();
             * simplicesFinal = simplicesFinal.Where( s => s.Depths[0] % 3 == 1 && s.Depths[1] % 2 == 0 && s.Depths[2] % 2 == 1 ).ToList();
             */

            /*
             * List<H3.Cell> simplicesFinal = new List<H3.Cell>();
             * //for( int d = 0; d < 1; d+=2 )
             * int d = 0;
             * {
             *      //Sphere toReflect = simplices.First( s => s.Depth == d ).Facets[0].Sphere.Clone();
             *      //Sphere toReflect = simplices.Where( s => s.Depth == d ).Skip(1).Take(1).First().Facets[0].Sphere.Clone();
             *      List<H3.Cell> reflectionCells = simplices.Where( s => s.Depths[1] == d && s.Depths[0] % 2 == 0 ).Skip(0).Take(1).ToList();
             *      foreach( Sphere toReflect in reflectionCells.Select( c => c.Facets[0].Sphere.Clone() ) )
             *      {
             *              List<H3.Cell> thisCell = new List<H3.Cell>();
             *              foreach( H3.Cell cell in simplices )
             *              {
             *                      H3.Cell clone = cell.Clone();
             *                      clone.Reflect( toReflect );
             *                      thisCell.Add( clone );
             *              }
             *
             *              //Sphere toReflect2 = thisCell.First( s => s.Depth1 == d + 3 && s.Depth0 % 2 == 0 ).Facets[0].Sphere.Clone();
             *              //List<H3.Cell> reflectionCellsTemp = simplices.Where( s => Math.Abs( s.Depths[1] - d ) == 2 && s.Depths[0] % 2 == 0 ).ToList();
             *              List<H3.Cell> reflectionCellsTemp = simplices.Where( s => s.Depths[1] == 2 && s.Depths[1] == s.Depths[0] + s.Depths[2] ).ToList();
             *              List<H3.Cell> reflectionCells2 = reflectionCellsTemp;//.Where( ( x, i ) => i % 3 == 0 ).ToList(); // .Skip( 5 ).Take( 5 ).ToList();
             *              foreach( Sphere toReflect2 in reflectionCells2.Select( c => c.Facets[0].Sphere.Clone() ) )
             *              //Sphere toReflect2 = toReflectLater;
             *              {
             *                      foreach( H3.Cell cell in thisCell )
             *                      {
             *                              H3.Cell clone = cell.Clone();
             *                              clone.Reflect( toReflect2 );
             *                              simplicesFinal.Add( clone );
             *                      }
             *              }
             *      }
             * }*/

            int count = 0;

            foreach (H3.Cell cell in simplicesFinal)
            {
                count++;

                //if( count % 2 == 0 )
                //	continue;

                /*if( count < 1 )
                 *      continue;
                 * if( count > 30 )
                 *      return;
                 */
                //int[] include = new int[] { 0, 1, 2, 3 };
                int[] include = new int[] { 0 };
                PovRay.AppendSimplex(cell.Facets.Select(f => f.Sphere).ToArray(), cell.Center, include, "cell.pov");
            }
        }
コード例 #11
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (LiteralPath.Expression != null)
            {
                targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context));
            }

            if (Destination.Expression != null)
            {
                targetCommand.AddParameter("Destination", Destination.Get(context));
            }

            if (Container.Expression != null)
            {
                targetCommand.AddParameter("Container", Container.Get(context));
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (Filter.Expression != null)
            {
                targetCommand.AddParameter("Filter", Filter.Get(context));
            }

            if (Include.Expression != null)
            {
                targetCommand.AddParameter("Include", Include.Get(context));
            }

            if (Exclude.Expression != null)
            {
                targetCommand.AddParameter("Exclude", Exclude.Get(context));
            }

            if (Recurse.Expression != null)
            {
                targetCommand.AddParameter("Recurse", Recurse.Get(context));
            }

            if (PassThru.Expression != null)
            {
                targetCommand.AddParameter("PassThru", PassThru.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (FromSession.Expression != null)
            {
                targetCommand.AddParameter("FromSession", FromSession.Get(context));
            }

            if (ToSession.Expression != null)
            {
                targetCommand.AddParameter("ToSession", ToSession.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
コード例 #12
0
        public ConversionOptions GetConfiguration()
        {
            var options = new ConversionOptions();

            if (Path.HasValue())
            {
                options.Paths = Path.Values;
            }

            if (File.HasValue())
            {
                options.Files = File.Values;
            }

            if (List.HasValue())
            {
                options.ListFile = List.Value();
            }

            if (options.Paths.Count == 0 &&
                options.Files.Count == 0 &&
                String.IsNullOrEmpty(options.ListFile))
            {
                throw new ConfigurationException("Nothing to process, must specify one of --path, --file or --list");
            }

            if (IndentStyle.HasValue())
            {
                var style = IndentStyle.Value().ToLower();
                if (style == "tabs")
                {
                    options.Indentation = IndentationStyle.Tabs;
                }
                else if (style == "spaces")
                {
                    options.Indentation = IndentationStyle.Spaces;
                }
                else if (style == "leave")
                {
                    options.Indentation = IndentationStyle.Leave;
                }
                else
                {
                    throw new ConfigurationException($"'{style}' is an invalid indentation style");
                }
            }

            if (LineEndings.HasValue())
            {
                var lineEndingStyle = LineEndings.Value().ToLower();
                if (lineEndingStyle == "crlf")
                {
                    options.LineEndingStyle = LineEnding.CRLF;
                }
                else if (lineEndingStyle == "lf")
                {
                    options.LineEndingStyle = LineEnding.LF;
                }
                else
                {
                    throw new ConfigurationException("Line Endings must be crlf or lf");
                }
            }

            options.StripTrailingSpaces = StripTrailingSpaces.HasValue();

            // no point going any further if one of the change options isn't actually specified
            if (options.StripTrailingSpaces == false &&
                options.Indentation == IndentationStyle.Leave &&
                options.LineEndingStyle == LineEnding.Leave)
            {
                throw new ConfigurationException("Nothing to do, you must specify one of --strip-trailing-spaces, --line-endings or --indent");
            }

            if (TabWidth.HasValue())
            {
                if (!Int32.TryParse(TabWidth.Value(), out int tabWidth))
                {
                    throw new ConfigurationException("tabwidth must be a valid number");
                }
                options.TabWidth = tabWidth;
            }

            if (IncludeExtensions.HasValue())
            {
                options.IncludeExtensions = ParseFileExtensionsOption(IncludeExtensions.Values);
            }

            if (ExcludeExtensions.HasValue())
            {
                options.ExcludeExtensions = ParseFileExtensionsOption(ExcludeExtensions.Values);
            }

            if (ExcludeFolders.HasValue())
            {
                options.ExcludeFolders = ExcludeFolders.Values;
            }

            // the presence of recurse|dryrun means it's on, there is no value
            options.Recurse = Recurse.HasValue();
            options.DryRun  = DryRun.HasValue();
            options.Verbose = Verbose.HasValue();

            return(options);
        }