Skip to content
Snippets Groups Projects
Fact.cs 39.2 KiB
Newer Older
  • Learn to ignore specific revisions
  •         SOMDoc tp = new OMS(MMTConstants.Wall);
            SOMDoc df = new OMA(
                    new OMS(MMTConstants.CreateWall),
    
                    Pids.Select(pid => new OMS(pid)).ToArray()
    
            return new MMTGeneralFact(Label, tp, df);
    
        protected override bool EquivalentWrapped(QuadFact f1, QuadFact f2)
    
            if (f1.Points.Length != f2.Points.Length)
    
            int i = 0;
            for (; i < f2.Points.Length; i++) // 1st incedence
                if (f2.Points[i].Equivalent(f1.Points[0]))
                    break;
    
            if (i == f2.Points.Length) // no match
                return false;
    
            for (int j = 1; j < f2.Points.Length; j++) // cyclic match
                if (!f2.Points[(i + j) % f2.Points.Length].Equivalent(f1.Points[j]))
                    return false;
    
        public override bool HasDependentFacts => true;
    
        protected override string[] GetDependentFactIds()
            => Pids;
    
        protected override void RecalculateTransform() { }
    
        protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer)
    
            => new QuadFact(Pids.Select(pid => old_to_new[pid]).ToArray(), organizer);
    
    #pragma warning disable // Testing...
    
    
    ki7077's avatar
    ki7077 committed
    /// use this if you need to test certain implementations of facts.
    
    ki7077's avatar
    ki7077 committed
    /// just for testing purposes  
    
    /// </summary>
    public class TestFact : FactWrappedCRTP<TestFact>
    {
        /// <summary> \copydoc Fact.Fact </summary>
        public TestFact() : base()
        {
    
        /// Standard Constructor:
        /// Initiates members and creates MMT %Fact Server-Side
    
        /// </summary>
        /// <param name="pid1">sets <see cref="Pid1"/></param>
        /// <param name="pid2">sets <see cref="Pid2"/></param>
        /// <param name="radius">sets <see cref="radius"/></param>
        /// <param name="normal">sets <see cref="normal"/></param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
    
    MaZiFAU's avatar
    MaZiFAU committed
        public TestFact(FactRecorder organizer) : base(organizer)
    
    MaZiFAU's avatar
    MaZiFAU committed
            SendToMMT();
    
    MaZiFAU's avatar
    MaZiFAU committed
        protected override void RecalculateTransform() { }
    
    MaZiFAU's avatar
    MaZiFAU committed
    
    
        /// <summary>
        /// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
        /// </summary>
        /// <param name="Pid1">sets <see cref="Pid1"/></param>
        /// <param name="Pid2">sets <see cref="Pid2"/></param>
        /// <param name="radius">sets <see cref="radius"/></param>
        /// <param name="normal">sets <see cref="normal"/></param>
        /// <param name="backendURI">MMT URI</param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
    
    MaZiFAU's avatar
    MaZiFAU committed
        public TestFact(string backendURI, FactRecorder organizer) : base(organizer)
    
            this.ServerDefinition = ServerDefinition;
    
            _ = this.Label;
        }
    
        /// <summary>
        /// parses the Circlefact response of the MMT-Server
        /// </summary>
    
        /// \copydoc Fact.parseFact(ScrollFact) 
    
        public new static IEnumerator parseFact(List<Fact> ret, MMTFact fact)
    
        {
            string uri = fact.@ref.uri;
            Debug.Log("TestFact Uri:" + uri);
    
            ret.Add(new TestFact(uri, StageStatic.stage.factState));
            yield break;
    
        }
    
        /// \copydoc Fact.generateLabel
    
    MaZiFAU's avatar
    MaZiFAU committed
        protected override string generateLabel()
    
    
        /// \copydoc Fact.hasDependentFacts
    
        public override bool HasDependentFacts => false;
    
    
        /// \copydoc Fact.getDependentFactIds
    
        protected override string[] GetDependentFactIds()
    
    
        /// \copydoc Fact.GetHashCode
    
    MaZiFAU's avatar
    MaZiFAU committed
        public override int GetHashCode()
    
            => base.GetHashCode();// this.Pid1.GetHashCode() ^ this.Pid2.GetHashCode();
    
    
        /// \copydoc Fact.Equivalent(Fact, Fact)
        protected override bool EquivalentWrapped(TestFact f1, TestFact f2)
        {
    
    MaZiFAU's avatar
    MaZiFAU committed
            return DependentFactsEquivalent(f1, f2);
    
    MaZiFAU's avatar
    MaZiFAU committed
        protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer)
    
    MaZiFAU's avatar
    MaZiFAU committed
            => new TestFact(organizer);
    
        public override MMTFact MakeMMTDeclaration()
    
        {
            throw new NotImplementedException();
        }
    
    }
    
    #pragma warning restore // Testing over