Exemple #1
0
        ///////////////////////////////////////////////////////////////////////
        // HELPERS
        //

        private bool setOutput(string output, Record recordOut)
        {
            // Output Field is last
            AlteryxRecordInfoNet.FieldBase fbOut = _recordInfoOut[(int)_recordInfoIn.NumFields()];
            fbOut.SetFromString(recordOut, output);

            _outputHelper.PushRecord(recordOut.GetRecord());

            return(true);
        }
Exemple #2
0
        private void pushRecord(
            Int32 xCoord, Int32 yCoord,
            Int32 rValue, Int32 gValue, Int32 bValue,
            Int32 alphaValue, RecordData recordDataIn)
        {
            Record recordOut = _recordInfoOut.CreateRecord();

            recordOut.Reset();

            _recordCopier.Copy(recordOut, recordDataIn);

            var outFieldCount        = _recordInfoOut.NumFields();
            int indexXCoordField     = (int)outFieldCount - 6;
            int indexYCoordField     = (int)outFieldCount - 5;
            int indexRValueField     = (int)outFieldCount - 4;
            int indexGValueField     = (int)outFieldCount - 3;
            int indexBValueField     = (int)outFieldCount - 2;
            int indexAlphaValueField = (int)outFieldCount - 1;

            // RValue Field
            FieldBase fieldBase = _recordInfoOut[indexXCoordField];

            fieldBase.SetFromInt32(recordOut, xCoord);
            // RValue Field
            fieldBase = _recordInfoOut[indexYCoordField];
            fieldBase.SetFromInt32(recordOut, yCoord);
            // RValue Field
            fieldBase = _recordInfoOut[indexRValueField];
            fieldBase.SetFromInt32(recordOut, rValue);
            // GValue Field
            fieldBase = _recordInfoOut[indexGValueField];
            fieldBase.SetFromInt32(recordOut, gValue);
            // RValue Field
            fieldBase = _recordInfoOut[indexBValueField];
            fieldBase.SetFromInt32(recordOut, bValue);
            // AlphaValue Field
            fieldBase = _recordInfoOut[indexAlphaValueField];
            fieldBase.SetFromInt32(recordOut, alphaValue);

            _outputHelper.PushRecord(recordOut.GetRecord());
        }
        private void pushRecord(string path, string value, RecordData recordDataIn)
        {
            Record recordOut = _recordInfoOut.CreateRecord();

            recordOut.Reset();

            _recordCopier.Copy(recordOut, recordDataIn);

            var outFieldCount   = _recordInfoOut.NumFields();
            int indexPathField  = (int)outFieldCount - 2;
            int indexValueField = (int)outFieldCount - 1;

            // Path Field
            FieldBase fieldBase = _recordInfoOut[indexPathField];

            fieldBase.SetFromString(recordOut, path);

            // Value Field
            fieldBase = _recordInfoOut[indexValueField];
            fieldBase.SetFromString(recordOut, value);

            _outputHelper.PushRecord(recordOut.GetRecord());
        }
 public void PushData(RecordData data)
 {
     _output.PushRecord(data);
 }
        public bool II_PushRecord(RecordData recordDataIn)
        {
            DebugMessage($"II_PushRecord() Entering; ToolID={_toolID}");

            // The same object is used in each call, so reset the result fields before using them.
            _retCode = "";
            _cmdLine = "";
            lock (_sbStdOutLock) { _sbStdOut.Clear(); }
            lock (_sbExceptionsLock) { _sbExceptions.Clear(); }



            // Check the paths to Executable and Script...
            string exePath = getFieldBaseStringData(_exePathField, recordDataIn);

            checkValidPath(exePath, _exePathField);

            // Do the magic
            shell(exePath, getArguments(recordDataIn));

            // Get the output
            string stdOut = "";

            lock (_sbStdOutLock)
            { stdOut = _sbStdOut.ToString(); }

            // Get the exceptions
            string exceptions = "";

            lock (_sbExceptionsLock)
            { exceptions = _sbExceptions.ToString(); }


            // Prepare the output
            AlteryxRecordInfoNet.Record recordOut = _recordInfoOut.CreateRecord();
            recordOut.Reset();

            // Transfer existing data
            _recordCopier.Copy(recordOut, recordDataIn);


            // Set Output Fields
            var numInputFields = (int)_recordInfoIn.NumFields();

            AlteryxRecordInfoNet.FieldBase fbStdOut = _recordInfoOut[numInputFields];
            fbStdOut.SetFromString(recordOut, stdOut);

            AlteryxRecordInfoNet.FieldBase fbRetCode = _recordInfoOut[numInputFields + 1];
            fbRetCode.SetFromString(recordOut, _retCode);

            AlteryxRecordInfoNet.FieldBase fbExceptions = _recordInfoOut[numInputFields + 2];
            fbExceptions.SetFromString(recordOut, exceptions);

            AlteryxRecordInfoNet.FieldBase fbDiagnostics = _recordInfoOut[numInputFields + 3];
            fbDiagnostics.SetFromString(recordOut, _cmdLine);


            // Output
            _outputHelper.PushRecord(recordOut.GetRecord());


            // Clear the accumulated strings for next record
            _retCode = "";
            _cmdLine = "";
            lock (_sbStdOutLock) { _sbStdOut.Clear(); }
            lock (_sbExceptionsLock) { _sbExceptions.Clear(); }

            DebugMessage($"II_PushRecord() Exiting; ToolID={_toolID}");
            return(true);
        }
Exemple #6
0
        public void II_Close()
        {
            DebugMessage($"II_Close() has been called; ToolID={_toolID}");

            // Get Concavity and ScaleFactor
            double concavity = 90;

            try { concavity = Convert.ToDouble(_sConcavity); }
            catch
            {
                WarningMessage($"Failed to convert concavity [{_sConcavity}] to double value;  Using 90 degrees;");
                concavity = 0;
            }

            /*
             * Int32 scaleFactor = 1;
             * try { scaleFactor = Convert.ToInt32(_sScaleFactor); }
             * catch
             * {
             *  WarningMessage($"Failed to convert scale factor [{_sScaleFactor}] to integer value;  Using 1;");
             *  scaleFactor = 1;
             * }
             *
             * if (scaleFactor < 1)
             * {
             *  WarningMessage($"Scale factor [{_sScaleFactor}] was unacceptable;  Positive non-zero integer required; Using 1;");
             *  scaleFactor = 1;
             * }
             */

            foreach (KeyValuePair <string, List <Tuple <Double, Double> > > kvp in _dicPoints)
            {
                DebugMessage($"Group [{kvp.Key}] has [{kvp.Value.Count}] points.  Would process at this point.");



                ////////////////////
                // HULL PROCESSING

                List <Node> dot_list = new List <Node>();
                int         id       = 0;
                foreach (Tuple <double, double> element in kvp.Value)
                {
                    ++id;
                    Node node = new Node(element.Item1, element.Item2, id);
                    dot_list.Add(node);
                }

                var hull = new Hull();
                hull.makeHull(dot_list, concavity);
                List <Node> way = hull.getWay();

                string diag = hull.dumpWay(way);

                // END HULL PROCESSING
                ////////////////////////

                int seq = 0;
                foreach (Node node in way)
                {
                    Record recordOut = _recordInfoOut.CreateRecord();
                    recordOut.Reset();

                    // Group
                    FieldBase fieldBase = _recordInfoOut[0];
                    fieldBase.SetFromString(recordOut, kvp.Key);

                    // Sequence Number Dummy
                    fieldBase = _recordInfoOut[1];
                    fieldBase.SetFromInt32(recordOut, seq);

                    // XCoord
                    fieldBase = _recordInfoOut[2];
                    fieldBase.SetFromDouble(recordOut, node.x);

                    // YCoord
                    fieldBase = _recordInfoOut[3];
                    fieldBase.SetFromDouble(recordOut, node.y);

                    // Write record
                    _outputHelper.PushRecord(recordOut.GetRecord());

                    ++seq;
                }
            }


            DebugMessage($"II_Close() is exiting; ToolID={_toolID}");
        }