public HTupleMixed(object[] o, bool copy) { for (int index = 0; index < o.Length; ++index) { int objectType = HTupleImplementation.GetObjectType(o[index]); if (objectType == 15 || (objectType & 32768) > 0) { throw new HTupleAccessException("Encountered invalid data types when creating HTuple"); } } this.SetArray((Array)o, copy); }
public static void StoreTuple(IntPtr tupleHandle, HTuple tuple) { HTupleType type = tuple.Type == HTupleType.LONG ? HTupleType.INTEGER : tuple.Type; HalconAPI.HCkH(HalconAPI.CreateElementsOfType(tupleHandle, tuple.Length, type)); switch (tuple.Type) { case HTupleType.INTEGER: HalconAPI.HCkH(HalconAPI.SetIArr(tupleHandle, tuple.IArr)); break; case HTupleType.DOUBLE: HalconAPI.HCkH(HalconAPI.SetDArr(tupleHandle, tuple.DArr)); break; case HTupleType.STRING: string[] sarr = tuple.SArr; for (int index = 0; index < tuple.Length; ++index) { HalconAPI.HCkH(HalconAPI.SetS(tupleHandle, index, sarr[index])); } break; case HTupleType.MIXED: object[] oarr = tuple.data.OArr; for (int index = 0; index < tuple.Length; ++index) { switch (HTupleImplementation.GetObjectType(oarr[index])) { case 1: HalconAPI.HCkH(HalconAPI.SetI(tupleHandle, index, (int)oarr[index])); break; case 2: HalconAPI.HCkH(HalconAPI.SetD(tupleHandle, index, (double)oarr[index])); break; case 4: HalconAPI.HCkH(HalconAPI.SetS(tupleHandle, index, (string)oarr[index])); break; case 129: HalconAPI.HCkH(HalconAPI.SetL(tupleHandle, index, (long)oarr[index])); break; } } break; case HTupleType.LONG: HalconAPI.HCkH(HalconAPI.SetLArr(tupleHandle, tuple.LArr)); break; } }
public HTupleType GetElementType(int[] indices) { if (indices == null || indices.Length == 0) { return(HTupleType.EMPTY); } HTupleType objectType = (HTupleType)HTupleImplementation.GetObjectType(this.o[indices[0]]); for (int index = 1; index < indices.Length; ++index) { if ((HTupleType)HTupleImplementation.GetObjectType(this.o[indices[index]]) != objectType) { return(HTupleType.MIXED); } } return(objectType); }
protected override void StoreData(IntPtr proc, IntPtr tuple) { for (int index = 0; index < this.iLength; ++index) { switch (HTupleImplementation.GetObjectType(this.o[index])) { case 1: HalconAPI.HCkP(proc, HalconAPI.SetI(tuple, index, (int)this.o[index])); break; case 2: HalconAPI.HCkP(proc, HalconAPI.SetD(tuple, index, (double)this.o[index])); break; case 4: HalconAPI.HCkP(proc, HalconAPI.SetS(tuple, index, (string)this.o[index])); break; case 129: HalconAPI.HCkP(proc, HalconAPI.SetL(tuple, index, (long)this.o[index])); break; } } }
public HTupleType GetElementType(int index) { return((HTupleType)HTupleImplementation.GetObjectType(this.o[index])); }