private void KillOrDeath(Collider other) { ObjectSize size = GetComponentInParent <ObjectSize>(); //エネミーのサイズ if (other.CompareTag("Splinter")) { audioSource.PlayOneShot(deadClip); GetComponentInParent <EnemyDead>().Dead(); return; } if (size == null) //鏡に影響を受けない敵なら無条件でプレイヤーが死ぬ { other.GetComponent <AliveFlag>().Dead(); return; } if (IsSmall(size)) //エネミーが小さいときはエネミーが死ぬ { audioSource.PlayOneShot(deadClip); GetComponentInParent <EnemyDead>().Dead(); return; } other.GetComponent <AliveFlag>().Dead(); //小さくなかったのでプレイヤーが死ぬ }
public void UpdateWalkableNode(ObjectSize size, Node origin) { List <Node> neighbours = GetNeighbours(origin); origin.walkable = true; updatedNodes.Add(origin); foreach (Node neighbour in neighbours) { if (NodeIsFree(neighbour)) { continue; } if (neighbour.objectOnNode.GetComponent <HomeObject>().size == size && !neighbour.walkable) { neighbour.walkable = true; updatedNodes.Add(neighbour); UpdateWalkableNode(size, neighbour); } else { continue; } } return; }
/// <summary> /// Creates a new ImageDetection from a given image, set of points and values. It also populates it with <see cref="ObjectPhotometry"/>, <see cref="ObjectPoints"/>, /// and <see cref="ObjectSize"/> properties. /// </summary> /// <param name="Image">Image on which the object was detected.</param> /// <param name="Points">The set of points on the image where it has been detected.</param> /// <param name="Values">The set of pixel intensitities.</param> /// <returns>A new instance of ImageDetection with the specified extension properties.</returns> public static ImageDetection CreateDetection(Image Image, IEnumerable <PixelPoint> Points, IEnumerable <double> Values) { IWCSProjection Transform = Image.Transform; PixelPoint[] PixPoints = Points.ToArray(); double[] PixValues = Values.ToArray(); EquatorialPoint[] EquatorialPoints = Transform.GetEquatorialPoints(PixPoints); double Xmean = 0, Ymean = 0; double XXP = 0, XYP = 0, YYP = 0; double XXB = 0, XYB = 0, YYB = 0; double Flux = 0; double XBmean = 0, YBmean = 0; for (int i = 0; i < PixPoints.Length; i++) { PixelPoint pt = PixPoints[i]; double Val = PixValues[i]; Xmean += pt.X; Ymean += pt.Y; XBmean += Val * pt.X; YBmean += Val * pt.Y; XXB += pt.X * pt.X * Val; XYB += pt.X * pt.Y * Val; YYB += pt.Y * pt.Y * Val; XXP += pt.X * pt.X; XYP += pt.X * pt.Y; YYP += pt.Y * pt.Y; Flux += Val; } Xmean /= PixPoints.Length; Ymean /= PixPoints.Length; XBmean /= Flux; YBmean /= Flux; XXB /= Flux; XYB /= Flux; YYB /= Flux; XXP /= PixPoints.Length; XYP /= PixPoints.Length; YYP /= PixPoints.Length; XXB -= XBmean * XBmean; XYB -= XBmean * YBmean; YYB -= YBmean * YBmean; XXP -= Xmean * Xmean; XYP -= Xmean * Ymean; YYP -= Ymean * Ymean; PixelPoint BarycenterPP = new PixelPoint() { X = XBmean, Y = YBmean }; EquatorialPoint BarycenterEP = Transform.GetEquatorialPoint(BarycenterPP); Position Pos = new Position(BarycenterEP, BarycenterPP); SourceEllipse BarycentricEllipse = new SourceEllipse(XXB, XYB, YYB); SourceEllipse PixelEllipse = new SourceEllipse(XXP, XYP, YYP); ObjectSize Shape = new ObjectSize() { BarycentricEllipse = BarycentricEllipse, PixelEllipse = PixelEllipse }; ImageDetection Detection = new ImageDetection(Pos, Image.GetProperty <ObservationTime>(), Image); Detection.AppendProperty(Shape); Detection.AppendProperty(new ObjectPhotometry() { Flux = Flux }); Detection.AppendProperty(new ObjectPoints() { PixelPoints = PixPoints, PixelValues = PixValues, EquatorialPoints = EquatorialPoints }); return(Detection); }
public void CellIndexAndObjectSizeAdditionTest2() { var a = new CellPosition("A1"); var b = new ObjectSize(2, 2); var c = a.Add(b); c.RowIndex.Should().Be(3); c.ColumnIndex.Should().Be(3); }
public void ObjectSizeSubtractionTest() { var a = new ObjectSize(1, 22); var b = new ObjectSize(1, 11); var c = a.Subtract(b); c.Width.Should().Be(0); c.Height.Should().Be(11); }
public void ObjectSizeAdditionTest() { var a = new ObjectSize(23, 22); var b = new ObjectSize(12, 15); var c = a.Add(b); c.Width.Should().Be(35); c.Height.Should().Be(37); }
/// <summary> /// 映し元を反映 /// </summary> private void ReflectToOrigin() { ObjectSize objSize = originObj.GetComponent <ObjectSize>(); if (objSize) { objSize.SetSize(size); objSize.SetReflectSize(sizeRate); } }
/// <summary> /// どのObjを反映するか /// </summary> /// <param name="originObj">映し元</param> /// <param name="size">拡大・縮小のサイズ</param> public void ReflectFrom(GameObject originObj, Vector3 size, SizeEnum sizeEnum) { gameObject.layer = 8; this.originObj = originObj; this.size = sizeEnum; reflectSize = originObj.transform.localScale; //映し元のサイズ指定 ObjectSize objSize = originObj.GetComponent <ObjectSize>(); if (objSize) { reflectSize = objSize.DefaultSize(); } reflectSize.Scale(size); //拡大縮小したサイズ sizeRate = size; InitMeshRenderer(); }
public TileType(int id, string name, TileRole role, char character, Color foreColor, Color backColor, ObjectSize size, ObjectHeight height, bool isPassable, bool isDestructible = false, int durability = 0) { Id = id; Name = name; Character = character; ForeColor = foreColor; BackColor = backColor; Role = role; Size = size; Height = height; IsPassable = isPassable; IsDestructible = isDestructible; Durability = durability; }
/// <summary> /// 小さいか /// </summary> /// <param name="size">エネミーのサイズ</param> /// <returns></returns> private bool IsSmall(ObjectSize size) { SizeEnum eSize = size.GetSize(); if (eSize == SizeEnum.Small_XY) { return(true); } //全体的に小さいか if (eSize == SizeEnum.Small_X) { return(true); } //横に縮んでいるか if (eSize == SizeEnum.Small_Y) { return(true); } //縦に縮んでいるか return(false); //縮んでいない。 }
private float GetForceMultiplier(ObjectSize size) { switch (size) { case ObjectSize.Small: return(2); case ObjectSize.Medium: return(1); case ObjectSize.Big: return(0.5f); case ObjectSize.Huge: throw new InvalidOperationException("It is impossible to throw Huge objects."); default: throw new ArgumentOutOfRangeException($"Unknown object size: {size}"); } }
void OnCollisionEnter2D(Collision2D hit) { EnemyAI prey = hit.gameObject.GetComponent <EnemyAI> (); ObjectSize enemy_size = gameObject.GetComponent <ObjectSize> (); //angle = Vector3.Angle (prey.transform.position, gameObject.transform.position); if (prey.GetComponent <ObjectSize>().size < enemy_size.size) { Debug.Log("Hit"); StartCoroutine(eat()); Destroy(prey.m_target); Destroy(hit.gameObject); gameObject.transform.localScale = gameObject.transform.localScale * m_growFactor; enemy_size.setSize(enemy_size.size * m_growFactor); } else { Destroy(gameObject); } }
public void StringCacheEnforcesSizeLimit() { // Test correct normal behavior with large limit StringCache cache = new StringCache(2000000, 10); cache.Add(key2, value2); Assert.AreEqual(value2, cache.Get(key2)); // Edge case: cache size limit is exactly the calculated size of the cached item (requires knowledge of the implementation details of the cache). // In this case, we are using a reference type for key and value, which means 3 references will be counted. // We also have one reference for the CacheItem used to wrap around the Value, and 8 bytes for the DateTime used to calculate its age. int overhead = (ObjectSize.ReferenceSize * 4) + 8; int requiredSize = overhead + (int)ObjectSize.SizeOf(key2) + (int)ObjectSize.SizeOf(value2); cache = new StringCache(requiredSize, 10); cache.Add(key2, value2); Assert.AreEqual(value2, cache.Get(key2)); // Edge case: cache size limit one byte smaller than required cache = new StringCache(requiredSize - 1, 10); cache.Add(key2, value2); Assert.IsNull(cache.Get(key2)); // Value should fail to load from the cache, because it should have been removed for being over the limit. cache.Add(key0, value0); // Adding a shorter value should work Assert.AreEqual(value0, cache.Get(key0)); cache.Add(key0, value0); // Adding the same key again with the same value should change nothing Assert.AreEqual(value0, cache.Get(key0)); cache.Add(key0, value1); // Adding the same key again with a DIFFERENT but equal length value should work Assert.AreEqual(value1, cache.Get(key0)); cache.Add(key2, value2); // Adding the oversized value again should cause the cache to be empty. Assert.IsNull(cache.Get(key0)); // Value should fail to load from the cache, because it should have been removed for being over the limit. Assert.IsNull(cache.Get(key2)); // Value should fail to load from the cache, because it should have been removed for being over the limit. }
// void OnCollisionEnter2D(Collision2D hit) { EnemyAI prey = hit.gameObject.GetComponent <EnemyAI>(); ObjectSize player_size = this.GetComponent <ObjectSize>(); angle = Vector3.Angle(prey.transform.position, gameObject.transform.position); if (prey.GetComponent <ObjectSize>().size < player_size.size) { //rigidbody.AddTorque(Vector3.up * 10); StartCoroutine(eat()); //Debug.Log ("Hit"); Destroy(prey.m_target); Destroy(hit.gameObject); gameObject.transform.localScale = gameObject.transform.localScale * m_growFactor; player_size.setSize(player_size.size * m_growFactor); } else { gameObject.transform.localScale = gameObject.transform.localScale / m_growFactor; player_size.setSize(player_size.size / m_growFactor); } }
/// <summary> /// 像の情報などをリリース /// </summary> public void Release() { DestroyReflects(); //像を消す for (int i = 0; i < originObj.Count; ++i) { if (!originObj[i]) { continue; } ObjectSize objSize = originObj[i].GetComponent <ObjectSize>(); if (objSize) { objSize.SetSize(SizeEnum.Normal); } ChangeObjectSize cos = originObj[i].GetComponent <ChangeObjectSize>(); if (cos) { cos.ReleaseMirror(); } } originObj.Clear(); //リストクリア }
internal static extern pxcmStatus PXCMTrackerUtils_Start3DMapCreation(IntPtr util, ObjectSize objSize);
private void MultiOperation(ObjectSize objectSize, int p) { Console.Clear(); Console.WriteLine(@"Adding {0} items to cache with apporx. {1} kb. Please ensure you have defined more then 1 server node!!", p, objectSize.ToString()); List<string> keys = new List<string>(); string keyPrefix = string.Format("ThreadID-{0}-MultiGet:", System.Threading.Thread.CurrentThread.ManagedThreadId); Dictionary<string, byte[]> multiDataToAdd = new Dictionary<string, byte[]>(); for (int i = 0; i < p; i++) { if(i%10 == 0) Console.Write(". "); multiDataToAdd.Add(keyPrefix + i.ToString(), COM.Formatters.Serialization.BinarySerialize( new TestSizeObject(objectSize) ) ); keys.Add(keyPrefix + i.ToString()); } Console.WriteLine(); System.Diagnostics.Stopwatch sp = new System.Diagnostics.Stopwatch(); sp.Start(); Common.Util.CacheMultiAdd(multiDataToAdd); sp.Stop(); Console.WriteLine(@"Multi Add: {0} ms", sp.ElapsedMilliseconds); sp.Start(); IDictionary<string, byte[]> data = Common.Util.CacheMultiGet(keys); sp.Stop(); Console.WriteLine(@"Multi Get: {0} ms - received items: {1}", sp.ElapsedMilliseconds, data != null ? data.Count.ToString() : "0"); #region Commented //if (data != null) //{ // Console.WriteLine("Total amount of received items: {0}", data.Count); // foreach (KeyValuePair<string, byte[]> item in data) // { // Console.WriteLine("Item with key {0} was available", item.Key); // } //} //else //{ // Console.WriteLine("no data received !!!"); //} #endregion sp.Start(); Common.Util.CacheMultiDelete(keys); sp.Stop(); Console.WriteLine(@"Multi Del: {0} ms", sp.ElapsedMilliseconds); Console.WriteLine(); Console.WriteLine(@"Operation Done"); Console.WriteLine(@"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); Console.WriteLine(); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.Clear(); }
private void CalculateRequestTest(ObjectSize size, int loops, double addSeconds) { Console.WriteLine(@"ClearCache!"); Common.Util.CacheClear(); string result1 = string.Empty; string result2 = string.Empty; string result3 = string.Empty; Console.WriteLine(@"Step 1: The clients loads {0} objects with an appox. size of {1} kb", loops, size.ToString()); List<TestSizeObject> testObjectList = new List<TestSizeObject>(); for (int i = 0; i < loops; ++i) { if (i % 10 == 0) Console.Write(". "); testObjectList.Add(new TestSizeObject(size)); } Console.WriteLine(); Console.WriteLine(@"Client is done to load the data"); Console.WriteLine("Step 2: Adding all items into cache"); DateTime start = DateTime.Now; foreach (TestSizeObject o in testObjectList) { Common.Util.CacheAdd(o.Id, o, DateTime.Now.AddSeconds(addSeconds)); } TimeSpan span = DateTime.Now.Subtract(start); Console.WriteLine(); Console.WriteLine(Common.Util.CacheGetStats()); Console.WriteLine(); result1 = string.Format(@"taken time: {0}h {1}m {2}s {3}mi", span.Hours, span.Minutes, span.Seconds, span.Milliseconds); Console.WriteLine(result1); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.WriteLine(@"Step 3: Retrieve each item from cache"); List<string> keyList = Common.Util.CacheGetAllKeys(); int success = 0; int failed = 0; TestSizeObject o2 = null ; start = DateTime.Now; foreach (string key in keyList) { o2 = Common.Util.CacheGet<TestSizeObject>(key); if (o2 != null) ++success; else ++failed; o2 = null; } span = DateTime.Now.Subtract(start); Console.WriteLine(); Console.WriteLine(Common.Util.CacheGetStats()); Console.WriteLine(); result2 = string.Format(@"taken time: {0}h {1}m {2}s {3}mi / success {4} - failed {5}", span.Hours, span.Minutes, span.Seconds, span.Milliseconds, success, failed); Console.WriteLine(result2); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.WriteLine(); Console.WriteLine(@"Step 4: Remove each item by key... NOT ALL AT ONCE!"); start = DateTime.Now; foreach (string key in keyList) { Common.Util.CacheRemove(key); } span = DateTime.Now.Subtract(start); Console.WriteLine(); Console.WriteLine(Common.Util.CacheGetStats()); Console.WriteLine(); result3 = string.Format(@"taken time: {0}h {1}m {2}s {3}mi", span.Hours, span.Minutes, span.Seconds, span.Milliseconds); Console.WriteLine(result3); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.Clear(); Console.WriteLine(); Console.WriteLine("Using {0} roundtrips with an amount of approx.: {1}", loops, size.ToString()); Console.WriteLine("- - - - - - - - - - - - - - - - - - - - - - - - - - -"); // Console.WriteLine(@"Overview {0}:", lastSelectMenuOption); Console.WriteLine(@"Result 1:" + result1); Console.WriteLine(@"Result 2:" + result2); Console.WriteLine(@"Result 3:" + result3); Console.WriteLine(); Console.WriteLine(Common.Util.CacheGetStats()); Console.WriteLine(@"Free Memory"); for (int i = 0; i < testObjectList.Count; ++i) { testObjectList[i] = null; } testObjectList = null; Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.Clear(); GC.Collect(); }
private void CompareObjectWithAndWithoutList(ObjectSize size, int loops) { Console.Clear(); Console.WriteLine(@"Clear Cache"); Console.WriteLine(); Common.Util.CacheClear(); string result1 = string.Empty; string result2 = string.Empty; string result3 = string.Empty; Console.WriteLine(@"Step 1: The clients loads {0} objects with an appox. size of {1} kb", loops, size.ToString()); List<string> without = new List<string>(); List<string> with = new List<string>(); List<TestSizeObject> testObjectList = new List<TestSizeObject>(); List<TestSizeObjectWithList> testObjectListWithList = new List<TestSizeObjectWithList>(); for (int i = 0; i < loops; ++i) { testObjectList.Add(new TestSizeObject(size)); testObjectListWithList.Add(new TestSizeObjectWithList(size)); } Console.WriteLine(@"Client is done to load the data"); Console.WriteLine("Object Comparsion: \nwithout: {0, 7} bytes \nwith: {1, 10} bytes", COM.Formatters.Serialization.BinarySerialize(testObjectList[0]).Length, COM.Formatters.Serialization.BinarySerialize(testObjectListWithList[0]).Length ); Console.WriteLine("Step 2a: Adding all items into cache (without list)"); DateTime start = DateTime.Now; foreach (TestSizeObject o in testObjectList) { Common.Util.CacheAdd(o.Id, o); without.Add(o.Id); } TimeSpan span = DateTime.Now.Subtract(start); Console.WriteLine(); result1 = string.Format(@"without list taken time: {0}h {1}m {2}s {3}mi", span.Hours, span.Minutes, span.Seconds, span.Milliseconds); Console.WriteLine("Step 2b: Adding all items into cache (with list)"); start = DateTime.Now; foreach (TestSizeObjectWithList o in testObjectListWithList) { Common.Util.CacheAdd(o.Id, o); with.Add(o.Id); } span = DateTime.Now.Subtract(start); Console.WriteLine(); Console.WriteLine(Common.Util.CacheGetStats()); Console.WriteLine(); Console.WriteLine(result1); result1 = string.Format(@"with taken time: {0}h {1}m {2}s {3}mi", span.Hours, span.Minutes, span.Seconds, span.Milliseconds); Console.WriteLine(result1); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.WriteLine(@"Step 3a: Retrieve each item from cache (without list)"); int success = 0; int failed = 0; TestSizeObject o2 = null; start = DateTime.Now; foreach (string key in without) { o2 = Common.Util.CacheGet<TestSizeObject>(key); if (o2 != null) ++success; else ++failed; o2 = null; } span = DateTime.Now.Subtract(start); result2 = string.Format(@"taken time: {0}h {1}m {2}s {3}mi / success {4} - failed {5}", span.Hours, span.Minutes, span.Seconds, span.Milliseconds, success, failed); Console.WriteLine(result2); Console.WriteLine(@"Step 3b: Retrieve each item from cache (with list)"); success = 0; failed = 0; TestSizeObjectWithList o3 = null; start = DateTime.Now; foreach (string key in with) { o3 = Common.Util.CacheGet<TestSizeObjectWithList>(key); if (o3 != null) ++success; else ++failed; o3 = null; } span = DateTime.Now.Subtract(start); Console.WriteLine(); Console.WriteLine(Common.Util.CacheGetStats()); Console.WriteLine(); result2 = string.Format(@"taken time: {0}h {1}m {2}s {3}mi / success {4} - failed {5}", span.Hours, span.Minutes, span.Seconds, span.Milliseconds, success, failed); Console.WriteLine(result2); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.WriteLine(); Console.WriteLine(@"Step 4a: Remove each item by key without list... NOT ALL AT ONCE!"); start = DateTime.Now; foreach (string key in with) { Common.Util.CacheRemove(key); } span = DateTime.Now.Subtract(start); Console.WriteLine(); Console.WriteLine(); result3 = string.Format(@"taken time: {0}h {1}m {2}s {3}mi", span.Hours, span.Minutes, span.Seconds, span.Milliseconds); Console.WriteLine(); Console.WriteLine(@"Step 4b: Remove each item by key with list... NOT ALL AT ONCE!"); start = DateTime.Now; foreach (string key in without) { Common.Util.CacheRemove(key); } span = DateTime.Now.Subtract(start); Console.WriteLine(); Console.WriteLine(Common.Util.CacheGetStats()); Console.WriteLine(); Console.WriteLine(result3); result3 = string.Format(@"taken time: {0}h {1}m {2}s {3}mi", span.Hours, span.Minutes, span.Seconds, span.Milliseconds); Console.WriteLine(result3); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(@"Operation Done"); Console.WriteLine(@"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); Console.WriteLine(); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.Clear(); }
private void AddObjectsWithOffset(ObjectSize size, int p) { Console.Clear(); Console.WriteLine(@"Consider to set for this test the server app.config value of: ServiceCacheCleanupThreadJob - 30000 or even less"); Console.WriteLine(); Console.WriteLine(@"Clear Cache"); Console.WriteLine(); Common.Util.CacheClear(); Console.WriteLine(@"Adding one object without any expiry date (takes per default DateTime.MaxValue)"); Common.Util.CacheAdd(@"StaticObject", new TestSizeObject(size)); for (int i = 0; i < 10; ++i) { DateTime dt = DateTime.Now.AddMinutes(p); Common.Util.CacheAdd(i.ToString(), new TestSizeObject(size), dt); Console.Clear(); Console.WriteLine(@"Added object with an expiry datetime: {0:u}", dt); Console.WriteLine(@"Wait 20 seconds."); Console.WriteLine(Common.Util.CacheGetStats()); System.Threading.Thread.Sleep(20000); } Console.WriteLine(@"Watch log files or Server Console, the Objects get deleted within the expiry date."); for (int i = 0; i < 5; ++i) { Console.WriteLine(@"Wait 20 seconds."); Console.WriteLine(Common.Util.CacheGetStats()); System.Threading.Thread.Sleep(20000); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine(@"Operation Done"); Console.WriteLine(@"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); Console.WriteLine(); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.Clear(); }
static ImageDetection Transform(ObsEntry Entry, FitsImage AssociatedImage) { EquatorialPoint eqp = new EquatorialPoint() { RA = Entry.RA / 180 * Math.PI, Dec = Entry.Dec / 180 * Math.PI }; PixelPoint pp = new PixelPoint() { X = Entry.X, Y = Entry.Y }; Position p = new Position(eqp, pp); ImageDetection det = new ImageDetection(p, AssociatedImage.GetProperty <ObservationTime>(), AssociatedImage); bool Ellipse = false; ObjectSize sz = new ObjectSize(); if (Entry.A.HasValue && Entry.B.HasValue) { sz.PixelEllipse = new SourceEllipse() { SemiaxisMajor = Entry.A.Value, SemiaxisMinor = Entry.B.Value }; Ellipse = true; } else if (Entry.FWHM.HasValue && Entry.Ellipticity.HasValue) { sz.PixelEllipse = new SourceEllipse() { SemiaxisMajor = Entry.FWHM.Value / Math.Sqrt(1 - Entry.Ellipticity.Value), SemiaxisMinor = Entry.FWHM.Value * Math.Sqrt(1 - Entry.Ellipticity.Value), }; Ellipse = true; } if (Ellipse) { if (Entry.EllipseTheta.HasValue) { sz.PixelEllipse.SemiaxisMajorAngle = Entry.EllipseTheta.Value / 180 * Math.PI; } det.AppendProperty(sz); } PairingProperties pprop = new PairingProperties() { IsDotDetection = Ellipse && (sz.PixelEllipse.SemiaxisMajor < 2 * sz.PixelEllipse.SemiaxisMinor), IsPaired = false, PearsonR = 0, StarPolluted = false, Algorithm = DetectionAlgorithm.SourceExtractor }; det.AppendProperty(pprop); if (Entry.Flux.HasValue) { ObjectPhotometry oph = new ObjectPhotometry() { Flux = Entry.Flux.Value, Magnitude = Entry.Mag.Value }; det.AppendProperty(oph); } return(det); }
public void TestObjectSizeExhaustive() { // Strings // strings have an overhead of 4 bytes for the m_stringLength field and 2 bytes for the m_firstChar field. Assert.AreEqual(14, ObjectSize.SizeOf("test")); Assert.AreEqual(16, ObjectSize.SizeOf("tests")); // Primitive Types Assert.AreEqual(1, ObjectSize.SizeOf(false)); Assert.AreEqual(1, ObjectSize.SizeOf(true)); Assert.AreEqual(1, ObjectSize.SizeOf(byte.MaxValue)); Assert.AreEqual(1, ObjectSize.SizeOf(sbyte.MaxValue)); Assert.AreEqual(2, ObjectSize.SizeOf(ushort.MaxValue)); Assert.AreEqual(2, ObjectSize.SizeOf(short.MaxValue)); Assert.AreEqual(4, ObjectSize.SizeOf(uint.MaxValue)); Assert.AreEqual(4, ObjectSize.SizeOf(int.MaxValue)); Assert.AreEqual(8, ObjectSize.SizeOf(ulong.MaxValue)); Assert.AreEqual(8, ObjectSize.SizeOf(long.MaxValue)); Assert.AreEqual(2, ObjectSize.SizeOf(char.MaxValue)); Assert.AreEqual(4, ObjectSize.SizeOf(float.MaxValue)); Assert.AreEqual(8, ObjectSize.SizeOf(double.MaxValue)); Assert.AreEqual(16, ObjectSize.SizeOf(decimal.MaxValue)); Assert.AreEqual(8, ObjectSize.SizeOf(DateTime.MinValue)); Assert.AreEqual(ObjectSize.ReferenceSize, ObjectSize.SizeOf(UIntPtr.Zero)); Assert.AreEqual(ObjectSize.ReferenceSize, ObjectSize.SizeOf(IntPtr.Zero)); // Arrays of primitive types Assert.AreEqual(30, ObjectSize.SizeOf(new bool[30])); Assert.AreEqual(30, ObjectSize.SizeOf(new byte[30])); Assert.AreEqual(60, ObjectSize.SizeOf(new char[30])); Assert.AreEqual(60, ObjectSize.SizeOf(new short[30])); Assert.AreEqual(120, ObjectSize.SizeOf(new int[30])); Assert.AreEqual(240, ObjectSize.SizeOf(new long[30])); Assert.AreEqual(480, ObjectSize.SizeOf(new decimal[30])); Assert.AreEqual(0, ObjectSize.SizeOf(new decimal[0])); // Array of string string[] strArr = new string[] { "test", "tests" }; int strArrExpectedSize = 30 + (ObjectSize.ReferenceSize * 2); Assert.AreEqual(strArrExpectedSize, ObjectSize.SizeOf(strArr)); // Array of objects object[] objArr = new object[] { /* 14 */ "test", /* 1 */ byte.MinValue, /* 1 */ false, /* 8 */ long.MinValue }; int objArrExpectedSize = 14 + 1 + 1 + 8 + (ObjectSize.ReferenceSize * 4); Assert.AreEqual(objArrExpectedSize, ObjectSize.SizeOf(objArr)); // Generic Lists int list_overhead = 0; list_overhead += ObjectSize.ReferenceSize; // Reference to internal array list_overhead += 4; // (int) size list_overhead += 4; // (int) _version list_overhead += ObjectSize.ReferenceSize; // Reference to internal syncroot object (which will be null) List <byte> list_byte = new List <byte>(3); Assert.AreEqual(list_overhead + 3, ObjectSize.SizeOf(list_byte)); List <string> list_string = new List <string>(strArr); Assert.AreEqual(list_overhead + strArrExpectedSize, ObjectSize.SizeOf(list_string)); List <object> list_object = new List <object>(objArr); Assert.AreEqual(list_overhead + objArrExpectedSize, ObjectSize.SizeOf(list_object)); List <object> list_object_nulls = new List <object>(3); Assert.AreEqual(list_overhead + (ObjectSize.ReferenceSize * 3), ObjectSize.SizeOf(list_object_nulls)); // Complex objects object dyn = new { f1 = "tests", f2 = false, f3 = new { f1 = (int)234190, f2 = float.MinValue } }; // Expected: ((ref size) + 16 + 1 + (ref size) + 4 + 4) = 24 + (ref size) + (ref size) Assert.AreEqual(25 + (ObjectSize.ReferenceSize * 2), ObjectSize.SizeOf(dyn)); // Expected: ((ref size) + 16 + 1 + (ref size) + 4 + 4 + 4 + 4 + 4) = 36 + (ref size) + (ref size) Assert.AreEqual(37 + (ObjectSize.ReferenceSize * 2), ObjectSize.SizeOf(new InternalClass1())); }
/** * Interactive version of map creation, similar to the toolbox functionality. Depth is automatically * used if supported in the current camera profile. Map creation is stopped either explicitly with \c Cancel3DMapCreation * or by pausing the tracking module using pSenseManager->PauseTracker(TRUE). * * The map file may be saved at any time with \c Save3DMap. * * \param objSize: Relative size of the object to create a map for, an accurate value helps improve the initialization time. * * \sa Cancel3DMapCreation * \sa Save3DMap * \sa QueryNumberFeaturePoints * \sa QueryFeaturePoints */ public pxcmStatus Start3DMapCreation(ObjectSize objSize) { return(PXCMTrackerUtils_Start3DMapCreation(instance, objSize)); }
/** * Interactive version of map creation, similar to the toolbox functionality. Depth is automatically * used if supported in the current camera profile. Map creation is stopped either explicitly with \c Cancel3DMapCreation * or by pausing the tracking module using pSenseManager->PauseTracker(TRUE). * * The map file may be saved at any time with \c Save3DMap. * * \param objSize: Relative size of the object to create a map for, an accurate value helps improve the initialization time. * * \sa Cancel3DMapCreation * \sa Save3DMap * \sa QueryNumberFeaturePoints * \sa QueryFeaturePoints */ public pxcmStatus Start3DMapCreation(ObjectSize objSize) { return PXCMTrackerUtils_Start3DMapCreation(instance, objSize); }