/// <summary> /// Histogram descriptor for calculating the cube root of a tetrahedron given by four random vertices. /// </summary> /// <param name="mesh">The mesh of which the descriptor value is calculated.</param> /// <returns>The histogram descriptor with the calculated histogram.</returns> public static HistDescriptor CubeRootTetrahedron(IMesh mesh) { double binSize = 0.075; int[] binValues = new int[Settings.BinsPerHistogram]; Parallel.For(0, Settings.ValuesPerHistogram, i => { Random random = RandomUtil.ThreadSafeRandom; Vector3[] randomVertices = GetRandomVertices(mesh, random, 4); double volume = Math.Pow(Functions.GetTetVolume(randomVertices), (1d / 3d)); int bin = Math.Min((int)(volume / binSize), binValues.Length - 1); Interlocked.Increment(ref binValues[bin]); }); return(HistDescriptor.FromIntHistogram("CubeRootTetrahedron", binSize, binValues)); }
/// <summary> /// Histogram descriptor for calculating the angle between three random vertices. /// </summary> /// <param name="mesh">The mesh of which the descriptor value is calculated.</param> /// <returns>The histogram descriptor with the calculated histogram.</returns> public static HistDescriptor AngleVertices(IMesh mesh) { double binSize = 18; int[] binValues = new int[Settings.BinsPerHistogram]; Parallel.For(0, Settings.ValuesPerHistogram, i => { Random random = RandomUtil.ThreadSafeRandom; Vector3[] randomVertices = GetRandomVertices(mesh, random, 3); double angle = Functions.GetAngleVertices(randomVertices); int bin = Math.Min((int)(angle / binSize), binValues.Length - 1); Interlocked.Increment(ref binValues[bin]); }); return(HistDescriptor.FromIntHistogram("AngleVertices", binSize, binValues)); }
/// <summary> /// Histogram descriptor for calculating the distance between two random vertices. /// </summary> /// <param name="mesh">The mesh of which the descriptor value is calculated.</param> /// <returns>The histogram descriptor with the calculated histogram.</returns> public static HistDescriptor DistanceVertices(IMesh mesh) { double binSize = 0.25; int[] binValues = new int[Settings.BinsPerHistogram]; Parallel.For(0, Settings.ValuesPerHistogram, i => { Random random = RandomUtil.ThreadSafeRandom; Vector3[] randomVertices = GetRandomVertices(mesh, random, 2); float distance = Vector3.Distance(randomVertices[0], randomVertices[1]); int bin = Math.Min((int)(distance / binSize), binValues.Length - 1); Interlocked.Increment(ref binValues[bin]); }); return(HistDescriptor.FromIntHistogram("DistanceVertices", binSize, binValues)); }
private static IDescriptor DeserialiseDescriptor(string name, string serialised) { //Check whether value is an ElemDescriptor or HistDescriptor if (ElemDescriptor.TryParse(name, serialised, out ElemDescriptor edesc)) { return(edesc); } else if (HistDescriptor.TryParse(name, serialised, out HistDescriptor hdesc)) { return(hdesc); } else { throw new NotImplementedException( string.Format( Settings.Culture, Resources.EX_Not_Supported, serialised ) ); } }