Esempio n. 1
0
        public Thing AddSegmentToUKS(PointPlus P1, PointPlus P2, int theColor, PointPlus motion = null, bool addToModel = true)
        {
            ModuleUKS nmUKS = (ModuleUKSN)FindModuleByType(typeof(ModuleUKSN));

            if (nmUKS is ModuleUKS UKS)
            {
                Thing t1, t2;
                Thing t3 = null;
                t1 = UKS.AddThing("p" + pCount++, new Thing[] { UKS.Labeled("Point") }, P1);
                t2 = UKS.AddThing("p" + pCount++, new Thing[] { UKS.Labeled("Point") }, P2);
                if (addToModel)
                {
                    t1.AddParent(UKS.Labeled("ModelThing"));
                    t2.AddParent(UKS.Labeled("ModelThing"));
                }
                if (motion != null)
                {
                    t3 = UKS.AddThing("m" + mCount++, new Thing[] { UKS.Labeled("Motion") }, motion);
                }
                Thing color = UKS.Valued(theColor);
                if (color == null)
                {
                    color = UKS.AddThing("c" + cCount++, new Thing[] { UKS.Labeled("Color") }, theColor);
                }
                Thing newThing = null;
                if (motion != null)
                {
                    newThing = UKS.AddThing("s" + sCount++, new Thing[] { UKS.Labeled("Segment") }, null, new Thing[] { t1, t2, color, t3 });
                }
                else
                {
                    newThing = UKS.AddThing("s" + sCount++, new Thing[] { UKS.Labeled("Segment") }, null, new Thing[] { t1, t2, color });
                }
                return(newThing);
            }
            return(null);
        }