Beispiel #1
0
        internal static int LoadTupleVector(HTupleVector outVector, IntPtr vectorHandle)
        {
            int dimension;

            EngineAPI.HCkE(EngineAPI.GetTupleVectorDimension(vectorHandle, out dimension));
            int length;

            EngineAPI.HCkE(EngineAPI.GetTupleVectorLength(vectorHandle, out length));
            if (dimension == 1)
            {
                for (int index = length - 1; index >= 0; --index)
                {
                    IntPtr element_handle;
                    EngineAPI.HCkE(EngineAPI.GetTupleVectorTuple(vectorHandle, index, out element_handle));
                    outVector[index].T = HalconAPI.LoadTuple(element_handle);
                }
            }
            else
            {
                for (int index = length - 1; index >= 0; --index)
                {
                    IntPtr element_handle;
                    EngineAPI.HCkE(EngineAPI.GetTupleVectorVector(vectorHandle, index, out element_handle));
                    EngineAPI.HCkE(EngineAPI.LoadTupleVector(outVector[index], element_handle));
                    EngineAPI.HCkE(EngineAPI.DestroyTupleVector(element_handle));
                }
            }
            return(2);
        }
Beispiel #2
0
        internal static int StoreTupleVector(HTupleVector inVector, IntPtr vectorHandle)
        {
            int dimension = inVector.Dimension;
            int length    = inVector.Length;

            if (dimension == 1)
            {
                for (int index = length - 1; index >= 0; --index)
                {
                    IntPtr tuple;
                    EngineAPI.HCkE(HalconAPI.CreateTuple(out tuple));
                    HalconAPI.StoreTuple(tuple, inVector[index].T);
                    EngineAPI.HCkE(EngineAPI.SetTupleVectorTuple(vectorHandle, index, tuple));
                    EngineAPI.HCkE(HalconAPI.DestroyTuple(tuple));
                }
            }
            else
            {
                for (int index = length - 1; index >= 0; --index)
                {
                    IntPtr vectorHandle1;
                    EngineAPI.HCkE(EngineAPI.CreateTupleVector(inVector[index], out vectorHandle1));
                    EngineAPI.HCkE(EngineAPI.SetTupleVectorVector(vectorHandle, index, vectorHandle1));
                    EngineAPI.HCkE(EngineAPI.DestroyTupleVector(vectorHandle1));
                }
            }
            GC.KeepAlive((object)inVector);
            return(2);
        }
Beispiel #3
0
        /// <summary>Sets input control parameter for procedure call</summary>
        public void SetInputCtrlParamVector(string name, HTupleVector vector)
        {
            IntPtr vectorHandle;

            HDevProcedureCall.HCkE(EngineAPI.CreateTupleVector(vector, out vectorHandle));
            HDevProcedureCall.HCkE(EngineAPI.SetInputCtrlParamVector(this.call, name, vectorHandle));
            GC.KeepAlive((object)this);
            HDevProcedureCall.HCkE(EngineAPI.DestroyTupleVector(vectorHandle));
        }
Beispiel #4
0
 /// <summary>Create copy of tuple vector</summary>
 public HTupleVector(HTupleVector vector)
     : base((HVector)vector)
 {
     if (this.mDimension > 0)
     {
         return;
     }
     this.mTuple = vector.mTuple.Clone();
 }
Beispiel #5
0
        /// <summary>Sets the value of a global control variable</summary>
        public void SetGlobalCtrlVarVector(string name, HTupleVector vector)
        {
            IntPtr vectorHandle;

            HDevEngine.HCkE(EngineAPI.CreateTupleVector(vector, out vectorHandle));
            HDevEngine.HCkE(EngineAPI.SetGlobalCtrlVarVector(this.engine, name, vectorHandle));
            GC.KeepAlive((object)this);
            HDevEngine.HCkE(EngineAPI.DestroyTupleVector(vectorHandle));
        }
Beispiel #6
0
        internal static int CreateTupleVector(HTupleVector inVector, out IntPtr vectorHandle)
        {
            IntPtr vector_handle;

            EngineAPI.HCkE(EngineAPI.CreateTupleVector(inVector.Dimension, out vector_handle));
            EngineAPI.HCkE(EngineAPI.StoreTupleVector(inVector, vector_handle));
            GC.KeepAlive((object)inVector);
            vectorHandle = vector_handle;
            return(2);
        }
Beispiel #7
0
        internal static HTupleVector GetAndDestroyTupleVector(IntPtr vectorHandle)
        {
            int dimension;

            EngineAPI.HCkE(EngineAPI.GetTupleVectorDimension(vectorHandle, out dimension));
            HTupleVector outVector = new HTupleVector(dimension);

            EngineAPI.HCkE(EngineAPI.LoadTupleVector(outVector, vectorHandle));
            EngineAPI.HCkE(EngineAPI.DestroyTupleVector(vectorHandle));
            return(outVector);
        }
Beispiel #8
0
 /// <summary>
 ///   Create 1-dimensional vector by splitting input tuple into
 ///   blocks of fixed size (except possibly for the last block).
 ///   This corresponds to convert_tuple_to_vector_1d in HDevelop.
 /// </summary>
 public HTupleVector(HTuple tuple, int blockSize)
     : base(1)
 {
     if (blockSize <= 0)
     {
         throw new HVectorAccessException("Invalid block size in vector constructor");
     }
     for (int index = 0; (double)index < Math.Ceiling((double)tuple.Length / (double)blockSize); ++index)
     {
         int num1 = index * blockSize;
         int num2 = Math.Min((index + 1) * blockSize, tuple.Length) - 1;
         this[index] = new HTupleVector(tuple.TupleSelectRange((HTuple)num1, (HTuple)num2));
     }
 }
Beispiel #9
0
 /// <summary>Insert vector at specified index</summary>
 public HTupleVector Insert(int index, HTupleVector vector)
 {
     this.InsertImpl(index, (HVector)vector, true);
     return(this);
 }
Beispiel #10
0
 /// <summary>Append vector to this vector</summary>
 public HTupleVector Append(HTupleVector vector)
 {
     return((HTupleVector)this.ConcatImpl((HVector)vector, true, true));
 }
Beispiel #11
0
 /// <summary>Concatenate two vectors, creating new vector</summary>
 public HTupleVector Concat(HTupleVector vector)
 {
     return((HTupleVector)this.ConcatImpl((HVector)vector, false, true));
 }
Beispiel #12
0
 /// <summary>
 ///   Returns true if vector has same dimension, lengths, and elements
 /// </summary>
 public bool VectorEqual(HTupleVector vector)
 {
     return(this.EqualsImpl((HVector)vector));
 }