Example #1
0
        private SolutionAgg HandleUnion(SolutionAgg first, SolutionAgg second)
        {
            // Can we combine the currentSol with this existent solution?
            IndexList unionIndices = IndexList.UnionIndices(first.atomIndices, second.atomIndices);

            // Disjoint union not possible.
            if (unionIndices == null)
            {
                return(null);
            }

            //
            // Can combine; create a new solution / equation with addition.
            //
            SolutionAgg newSum = new SolutionAgg();

            newSum.atomIndices = unionIndices;
            newSum.solType     = first.solType == SolutionAgg.SolutionType.COMPUTABLE &&
                                 second.solType == SolutionAgg.SolutionType.COMPUTABLE ? SolutionAgg.SolutionType.COMPUTABLE : SolutionAgg.SolutionType.INCOMPUTABLE;
            newSum.solArea = newSum.solType == SolutionAgg.SolutionType.COMPUTABLE ? first.solArea + second.solArea : -1;
            newSum.solEq   = new ComplexRegionEquation(MakeRegion(unionIndices.orderedIndices),
                                                       new ComplexRegionEquation.Binary(first.solEq.target, OperationT.ADDITION, second.solEq.target));
            return(newSum);
        }