private static Element GetConnectedSegments(Element nodes, Element segments, Element currentIndex, bool reversed)
        {
            Element currentSegmentCheck = new V_ArrayElement();

            Element isValid;

            if (!reversed)
            {
                isValid = Element.Part <V_Or>(
                    new V_Compare(Attribute(currentSegmentCheck), Operators.NotEqual, new V_Number(1)),
                    new V_Compare(Node1(currentSegmentCheck), Operators.Equal, currentIndex)
                    );
            }
            else
            {
                isValid = Element.Part <V_Or>(
                    new V_Compare(Attribute(currentSegmentCheck), Operators.NotEqual, new V_Number(1)),
                    new V_Compare(Node2(currentSegmentCheck), Operators.Equal, currentIndex)
                    );
            }

            return(Element.Part <V_FilteredArray>(
                       segments,
                       Element.Part <V_And>(
                           Element.Part <V_ArrayContains>(
                               BothNodes(currentSegmentCheck),
                               currentIndex
                               ),
                           isValid
                           )
                       ));
        }
Beispiel #2
0
        private Element GetConnectedSegments(Element currentIndex)
        {
            Element currentSegmentCheck = new V_ArrayElement();

            Element useAttribute;

            if (!reverseAttributes)
            {
                useAttribute = Element.TernaryConditional(
                    new V_Compare(Node1(currentSegmentCheck), Operators.Equal, currentIndex),
                    Node2Attribute(currentSegmentCheck),
                    Node1Attribute(currentSegmentCheck)
                    );
            }
            else
            {
                useAttribute = Element.TernaryConditional(
                    new V_Compare(Node1(currentSegmentCheck), Operators.Equal, currentIndex),
                    Node1Attribute(currentSegmentCheck),
                    Node2Attribute(currentSegmentCheck)
                    );
            }

            Element isValid;

            if (useAttributes)
            {
                isValid = Element.Part <V_ArrayContains>(
                    Element.Part <V_Append>(attributes, new V_Number(0)),
                    useAttribute
                    );
            }
            else
            {
                isValid = new V_Compare(useAttribute, Operators.Equal, new V_Number(0));
            }

            return(Element.Part <V_FilteredArray>(
                       Segments,
                       Element.Part <V_And>(
                           // Make sure one of the segments nodes is the current node.
                           Element.Part <V_ArrayContains>(
                               BothNodes(currentSegmentCheck),
                               currentIndex
                               ),
                           isValid
                           )
                       ));
        }