Exemple #1
0
        public void MaximumRelAtt(RelationSymbol parameterSym1, string exAttribute, RelationSymbol returnSym)
        {
            Console.WriteLine("Maximum'ing...");

            var index = parameterSym1.Index.Value;

            QLPart partForTypeExtraction = null; //first present attribute provides type info
            var    tuples = parameterSym1.Tuples.ToArray();

            foreach (var tuple in tuples)
            {
                var part = tuple[index].GetPropertyValue(exAttribute);
                if (part != null)
                {
                    partForTypeExtraction = part;
                    break;
                }
            }

            if (partForTypeExtraction == null)
            {
                return;
            }

            IEnumerable <QLEntity[]> tuplesOut = null;

            if (partForTypeExtraction.QLNumber != null)
            {
                var max = tuples.Max(t => t[index].GetPropertyValue(exAttribute).QLNumber.Value);
                tuplesOut = tuples.Where(t => t[index].GetPropertyValue(exAttribute).QLNumber.Value == max);
            }

            returnSym.SetTuples(tuplesOut);
        }
Exemple #2
0
        private void CartesianProduct(RelationSymbol returnSymbol, SetSymbol parameterSymbolA, SetSymbol parameterSymbolB,
                                      Func <TriangleMesh, TriangleMesh, bool> operation)
        {
            foreach (var ifcEntityA in parameterSymbolA.Entites)
            {
                var meshA = GetMesh(ifcEntityA);
                if (meshA == null)
                {
                    continue;
                }

                foreach (var ifcEntityB in parameterSymbolB.Entites)
                {
                    var meshB = GetMesh(ifcEntityB);
                    if (meshB == null)
                    {
                        continue;
                    }

                    if (operation(meshA, meshB))
                    {
                        returnSymbol.AddTuple(new[] { ifcEntityA, ifcEntityB });
                    }
                }
            }
        }
Exemple #3
0
        //only symbols and simple types in operators, no nodes
        //symbolTable, parameterSym1, ..., returnSym

        public void ProjectRelAttRelation(RelationSymbol parameterSym1, int[] attributeIndices, RelationSymbol returnSym)
        {
            Console.WriteLine("Projector'ing...");

            var result = ProjectLocal(parameterSym1.Tuples, attributeIndices);

            returnSym.SetTuples(result);
        }
Exemple #4
0
        public void ProjectRelAttSet(RelationSymbol parameterSym1, SetSymbol returnSym)
        {
            Console.WriteLine("Projector'ing...");

            var result = ProjectLocal(parameterSym1.Tuples, new [] { parameterSym1.Index.Value }).Select(t => t[0]).Distinct();

            returnSym.EntityDic = result.ToDictionary(e => e.Id);;
        }
Exemple #5
0
        public void Touch(RelationSymbol returnSymbol, SetSymbol parameterSymbolA, SetSymbol parameterSymbolB)
        {
            var sw = new Stopwatch();

            sw.Start("Touch");
            CartesianProduct(returnSymbol, parameterSymbolA, parameterSymbolB, touchOperator.Touch);
            sw.Stop();
        }
Exemple #6
0
        public void TypeFilterRelation(RelationSymbol parameterSym1, Tuple <int, string>[] indexAndTypeNames, RelationSymbol returnSym)
        {
            Console.WriteLine("TypeFilter'ing...");

            var tuples    = parameterSym1.Tuples;
            var tuplesOut = GetTuples(tuples, indexAndTypeNames);

            returnSym.SetTuples(tuplesOut);
        }
Exemple #7
0
        //only symbols and simple types in operators, no nodes
        //symbolTable, parameterSym1, ..., returnSym
        public void AttributeFilterRelAtt(RelationSymbol parameterSym1, PredicateNode[] predicateNodes, RelationSymbol returnSym)
        {
            Console.WriteLine("AttributeFilter'ing...");
            //var index = parameterSym1.Index.Value; todo remove index prop
            var attributes    = parameterSym1.Attributes;
            var indexAndPreps = predicateNodes.Select(p =>
                                                      new Tuple <int, PredicateNode>((p.FirstNode as AttributeAccessNode).RelAttNode.AttIndex, p));

            var result = parameterSym1.Tuples.Where(t => indexAndPreps.All(
                                                        indexAndPrep => AttributeSetTestLocal(t[indexAndPrep.Item1], indexAndPrep.Item2)));

            returnSym.SetTuples(result);
        }
Exemple #8
0
        public void AddRelSymbol(RelationNode relationNode)
        {
            if (symbols.ContainsKey(relationNode.RelationName))
            {
                throw new QueryException($"Symbol {relationNode.RelationName} already present.");
            }

            Symbol symbol = new RelationSymbol(relationNode);

            if (!symbols.ContainsKey(relationNode.RelationName))
            {
                symbols.Add(relationNode.RelationName, symbol);
            }
        }
Exemple #9
0
        public void ReferenceRelAtt(RelationSymbol parameterSym1, string[] references, RelationSymbol returnSym)
        {
            var index = parameterSym1.Index.Value;

            if (references.Length == 1)
            {
                var firstTuples = ResolveReferenceTuplesIn(parameterSym1.Tuples, index, false, references[0]);
                returnSym.SetTuples(firstTuples);
            }
            else if (references.Length == 2)
            {
                var firstTuples = ResolveReferenceTuplesIn(parameterSym1.Tuples, index, false, references[0]);
                returnSym.SetTuples(ResolveReferenceTuplesIn(firstTuples, index + 1, true, references[1]));
            }
            else
            {
                throw new QueryException("The operation Dereferencer-relation has the wrong number of parameters");
            }
        }
Exemple #10
0
        public void ReferenceSet(SetSymbol parameterSym1, string[] references, RelationSymbol returnSym)
        {
            Console.WriteLine("Dereferencer'ing...");

            if (references.Length == 1)
            {
                var firstPairs = ResolveReferenceSetIn(parameterSym1.Entites, references[0]);
                returnSym.SetTuples(firstPairs);
            }
            else if (references.Length == 2)
            {
                //pair original first arg
                var firstPairs = ResolveReferenceSetIn(parameterSym1.Entites, references[0]);

                //pair original second arg
                var secondPairs = ResolveReferenceTuplesIn(firstPairs, 1, true, references[1]);
                returnSym.SetTuples(secondPairs);
            }
            else
            {
                throw new QueryException("The operation Dereferencer-Set has the wrong number of parameters");
            }
        }
Exemple #11
0
        //only symbols and simple types in operators, no nodes
        //symbolTable, parameterSym1, ..., returnSym

        public void TimeResolverRel(RelationSymbol parameterSym1, RelationSymbol returnSym)
        {
            Console.WriteLine("TimeResolver'ing...");

            var index  = parameterSym1.Index.Value;
            var tuples = deassociater.GetTuplesRelAtt(parameterSym1.Tuples, index, new [] { "ReferencedBy" }).ToArray();

            var lastIndex = returnSym.Attributes.Count - 2;

            tuples = dereferenceOperator.ResolveReferenceTuplesIn(tuples, lastIndex, false, "TaskTime").ToArray();

            var typeList = new List <Tuple <int, string> >()
            {
                new Tuple <int, string>(index, "IfcProduct"),
                new Tuple <int, string>(lastIndex, "IfcTask"),
                new Tuple <int, string>(lastIndex + 1, "IfcTaskTime"),
            };

            //type filtering ifcTask (plus products?)
            var tuplesTyped = typeFilter.GetTuples(tuples, typeList.ToArray());

            returnSym.SetTuples(tuplesTyped);
        }
Exemple #12
0
 public void Overlap(RelationSymbol returnSymbol, SetSymbol parameterSymbolA, SetSymbol parameterSymbolB)
 {
     CartesianProduct(returnSymbol, parameterSymbolA, parameterSymbolB, overlapOperator.Overlap);
 }
Exemple #13
0
 public void DeassociaterSet(SetSymbol parameterSym1, string[] exAtts, RelationSymbol returnSym)
 {
     Console.WriteLine("Deassociater'ing...");
     returnSym.SetTuples(GetTuplesSet(parameterSym1.Entites, exAtts));
 }
Exemple #14
0
 public void DeassociaterRelAtt(RelationSymbol parameterSym1, string[] exAtts, RelationSymbol returnSym)
 {
     Console.WriteLine("Deassociater'ing...");
     returnSym.SetTuples(GetTuplesRelAtt(parameterSym1.Tuples, parameterSym1.Index.Value, exAtts));
 }
Exemple #15
0
        public void Execute(string operatorName, RelationSymbol returnSymbol, SetSymbol parameterSymbol1, SetSymbol parameterSymbol2)
        {
            Console.WriteLine(operatorName + "'ing...");
            switch (operatorName)
            {
            case "Overlaps":
                Overlap(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "OL":
                Overlap(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "Touches":
                Touch(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "TO":
                Touch(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "AboveRelaxed":
                AboveReleaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "AR":
                AboveReleaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "AboveStrict":
                AboveStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "AS":
                AboveStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "BelowRelaxed":
                BelowReleaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "BR":
                BelowReleaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "BelowStrict":
                BelowStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "BS":
                BelowStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "WestRelaxed":
                WestRelaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "WestStrict":
                WestStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "WS":
                WestStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "EastRelaxed":
                EastRelaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "ER":
                EastRelaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "EastStrict":
                EastStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "ES":
                EastStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "NorthRelaxed":
                NorthRelaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "NR":
                NorthRelaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "NorthStrict":
                NorthStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "NS":
                NorthStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "SouthRelaxed":
                SouthRelaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "SR":
                SouthRelaxed(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "SouthStrict":
                SouthStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;

            case "SS":
                SouthStrict(returnSymbol, parameterSymbol1, parameterSymbol2);
                break;
            }
        }
        public void PropertyFilterSet(SetSymbol parameterSym1, string parameter2, string parameter3, RelationSymbol returnSym)
        {
            Console.WriteLine("PropertyFilterOperator'ing...");


            var pair      = dereferenceOperator.ResolveReferenceTuplesIn(parameterSym1.Tuples, 0, false, "IsDefinedBy");
            var triple    = dereferenceOperator.ResolveReferenceTuplesIn(pair, 1, false, "RelatingPropertyDefinition");
            var quadruple = dereferenceOperator.ResolveReferenceTuplesIn(triple, 2, false, "HasProperties");

            var pairEntiyProp = projectorOperator.ProjectLocal(quadruple, new [] { 0, 3 });

            //var predicateData1 =  new AttributeFilterOperator.PredicateData() //todo
            //    {
            //        PropName = "name",
            //        Compare = "=",
            //        StringValue = parameter2
            //};

            //var pairAttributePresent = pairEntiyProp.Where(p => attributeFilterOperator.AttributeSetTestLocal(p[1], predicateData1)).ToArray();
            //var predicateData2 = new AttributeFilterOperator.PredicateData()
            //{
            //    PropName = "nominalValue",
            //    Compare = "=",
            //    StringValue = parameter3
            //};

            //var result =  pairAttributePresent.Where(p => attributeFilterOperator.AttributeSetTestLocal(p[1], predicateData2)).ToArray();

            //returnSym.SetTuples(result);
        }
Exemple #17
0
 public void Distance(RelationSymbol returnSymbol, SetSymbol parameterSymbolA, SetSymbol parameterSymbolB)
 {
     CartesianProduct(returnSymbol, parameterSymbolA, parameterSymbolB, directionalOperators.AboveOfRelaxed);
 }
Exemple #18
0
 public void SouthStrict(RelationSymbol returnSymbol, SetSymbol parameterSymbolA, SetSymbol parameterSymbolB)
 {
     CartesianProduct(returnSymbol, parameterSymbolA, parameterSymbolB, directionalOperators.SouthOfStrict);
 }
Exemple #19
0
 public void NorthRelaxed(RelationSymbol returnSymbol, SetSymbol parameterSymbolA, SetSymbol parameterSymbolB)
 {
     CartesianProduct(returnSymbol, parameterSymbolA, parameterSymbolB, directionalOperators.NorthOfRelaxed);
 }