Ejemplo n.º 1
0
    static int[][] Prim(int n, int root, List <int[]>[] map)
    {
        var u = new bool[n];
        var q = PQ <int[]> .Create(e => e[2]);

        u[root] = true;
        q.PushRange(map[root].ToArray());
        var mes = new List <int[]>();

        // 実際の頂点数に注意。
        while (q.Count > 0 && mes.Count < n - 1)
        {
            var e = q.Pop();
            if (u[e[1]])
            {
                continue;
            }
            u[e[1]] = true;
            mes.Add(e);
            foreach (var ne in map[e[1]])
            {
                if (ne[1] != e[0])
                {
                    q.Push(ne);
                }
            }
        }
        return(mes.ToArray());
    }
Ejemplo n.º 2
0
    int[] DijkstraFrom(int from)
    {
        var d = new int[V];

        for (var i = 0; i < V; i++)
        {
            d[i] = Inf;
        }
        var queue = new PQ();

        d[from] = 0;
        queue.Enqueue(new P(from, 0));
        while (queue.Count > 0)
        {
            var p = queue.Dequeue();
            int u = p.First, tmp = d[u] + (dead.Contains(u) ? 1 : 0);
            if (d[u] < p.Second)
            {
                continue;
            }
            var k = es[u].Count;
            for (var i = 0; i < k; i++)
            {
                int v = es[u][i];
                if (d[v] > tmp)
                {
                    queue.Enqueue(new P(v, d[v] = tmp));
                }
            }
        }
        return(d);
    }
        public static double TryGetHeight(PQS pqs, Vector3d reference)
        {
            float dot         = -2;
            PQ    closestQuad = null;

            foreach (PQ quad in pqs.quads)
            {
                float testdot = (float)Vector3d.Dot(quad.positionPlanet.normalized, reference);
                if (testdot > dot)
                {
                    dot         = testdot;
                    closestQuad = quad;
                }
            }

            Vector3d[] triangle = TryGetHeight(closestQuad, reference.normalized);

            double dist1 = Vector3d.Distance(reference, triangle[0]);
            double dist2 = Vector3d.Distance(reference, triangle[1]);
            double dist3 = Vector3d.Distance(reference, triangle[2]);
            double mag   = (dist1 + dist2 + dist3);
            double mag1  = dist1 / mag;
            double mag2  = dist2 / mag;
            double mag3  = dist3 / mag;

            return((mag1 * triangle[0].magnitude) + (mag2 * triangle[1].magnitude) + (mag3 * triangle[2].magnitude));
        }
        private static Vector3d[] TryGetHeight(PQ quad, Vector3d reference)
        {
            float dot         = -2;
            PQ    closestQuad = null;

            Vector3d[] verts = null;
            if (quad.subNodes != null && quad.subNodes.Length > 0)
            {
                //OverlayMgr.Log("subquad: " + quad.subNodes.Length);
                foreach (PQ sub in quad.subNodes)
                {
                    if (sub != null && sub.positionPlanet != null)
                    {
                        float testdot = (float)Vector3d.Dot(sub.positionPlanet.normalized, reference);
                        if (testdot > dot)
                        {
                            dot         = testdot;
                            closestQuad = sub;
                        }
                    }
                }
                //OverlayMgr.Log("subQuad dot: " + dot);
                if (closestQuad != null)
                {
                    //OverlayMgr.Log("subQuad pos: " + closestQuad.positionPlanet);
                    verts = TryGetHeight(closestQuad, reference);
                    return(verts);
                }
                verts = GetClosestVerts(quad, reference);
                return(verts);
            }
            return(verts);
        }
Ejemplo n.º 5
0
    static void Main()
    {
        var r = new List <int>();
        var h = Read();
        var n = h[0];

        var qs = new int[n].Select(_ => PQ <int> .Create(desc: true)).ToArray();

        for (int i = 0; i < h[1]; i++)
        {
            var q = Read();
            if (q[0] == 0)
            {
                qs[q[1]].Push(q[2]);
            }
            else if (q[0] == 1)
            {
                if (qs[q[1]].Any())
                {
                    r.Add(qs[q[1]].First);
                }
            }
            else
            {
                if (qs[q[1]].Any())
                {
                    qs[q[1]].Pop();
                }
            }
        }
        Console.WriteLine(string.Join("\n", r));
    }
Ejemplo n.º 6
0
        public void IVL_PQSerializationTest03()
        {
            PQ low = new PQ(1, "s");

            low.CodingRationale = new SET <CodingRationale>(
                CodingRationale.Required
                );

            PQ high = new PQ(10, "s");

            high.CodingRationale = new SET <CodingRationale>(
                CodingRationale.Required
                );

            IVL <PQ> ivl = new IVL <PQ>(
                low, high
                );

            ivl.ValidTimeLow  = new TS(new DateTime(2008, 01, 01), DatePrecision.Day);
            ivl.ValidTimeHigh = new TS(new DateTime(2008, 01, 31), DatePrecision.Day);
            ivl.UpdateMode    = UpdateMode.Add;
            ivl.Width         = null;
            ivl.LowClosed     = true;
            ivl.HighClosed    = true;
            ivl.NullFlavor    = null;
            ivl.OriginalText  = "Test";

            Assert.IsTrue(ivl.Validate());
            var expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" lowClosed=""true"" highClosed=""true"" validTimeLow=""20080101"" validTimeHigh=""20080131"" updateMode=""A"" ><originalText language=""en-US"" value=""Test"" /><low value=""1"" unit=""s"" codingRationale=""Required""/><high value=""10"" unit=""s"" codingRationale=""Required""/></test>";
            var actualXml   = R2SerializationHelper.SerializeAsString(ivl);

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Ejemplo n.º 7
0
 public override void OnQuadDestroy(PQ quad)
 {
     foreach (EVAFootprint footprint in quad.GetComponentsInChildren <EVAFootprint>(true))
     {
         Destroy(footprint.gameObject);
     }
 }
Ejemplo n.º 8
0
 public PatientMeasurableObservations()
 {
     this.id   = new IIImpl();
     this.code = new CDImpl();
     this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl));
     this.value = new PQImpl();
 }
Ejemplo n.º 9
0
    static object Solve()
    {
        var(n, k) = Read2();
        var s = Console.ReadLine();

        var r = new List <char>();

        var q = PQ <int> .Create(i => s[i] * 100000L + i);

        q.PushRange(Enumerable.Range(0, n - k).ToArray());

        var t = -1;

        for (int i = n - k; i < n; i++)
        {
            q.Push(i);
            while (q.First < t)
            {
                q.Pop();
            }

            t = q.Pop();
            r.Add(s[t]);
        }

        return(string.Join("", r));
    }
Ejemplo n.º 10
0
        public void IVL_ContainsTest05()
        {
            // Create an instance of IVL
            IVL <PQ> acceptableRange = new IVL <PQ>(
                new PQ(0, "L"),
                new PQ(10, "L")
                )
            {
                LowClosed  = true,
                HighClosed = true
            };

            // Since we need to convert PQ units, add a unit converter
            PQ.UnitConverters.Add(new SimpleSiUnitConverter());
            PQ test = new PQ(10, "m");

            try
            {
                // Determine if the value is in range (true)
                bool isInRange = acceptableRange.Contains(test);
                acceptableRange.NullFlavor = NullFlavor.NoInformation;
                Assert.IsFalse(isInRange);
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.ToString().Contains("Units must match to compare PQ"));
            }
        }
Ejemplo n.º 11
0
    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        var line = Console.ReadLine().Split(' ');

        Pq = new PQ();
        I[] kk = new I[N];
        I[] gg = new I[N];

        for (int i = 0; i < N; i++)
        {
            int a = int.Parse(line[i]);
            if (i % 2 == 1)
            {
                kk[i] = new I(a, i);
                gg[i] = new I(int.MaxValue, -1);
            }
            else
            {
                gg[i] = new I(a, i);
                kk[i] = new I(int.MaxValue, -1);
            }
        }
        G = new SegTree(gg);
        K = new SegTree(kk);
        Pq.Push(new S(0, N, G.Q(0, N)));
    }
Ejemplo n.º 12
0
    public static long[] Dijkstra(int n, Func <int, int[][]> nexts, int sv, int ev = -1)
    {
        var costs = Array.ConvertAll(new bool[n], _ => long.MaxValue);
        var q     = PQ <int> .CreateWithKey(v => costs[v]);

        costs[sv] = 0;
        q.Push(sv);

        while (q.Count > 0)
        {
            var(c, v) = q.Pop();
            if (v == ev)
            {
                break;
            }
            if (costs[v] < c)
            {
                continue;
            }

            foreach (var e in nexts(v))
            {
                var(nv, nc) = (e[1], c + e[2]);
                if (costs[nv] <= nc)
                {
                    continue;
                }
                costs[nv] = nc;
                q.Push(nv);
            }
        }
        return(costs);
    }
Ejemplo n.º 13
0
        public override void OnQuadDestroy(PQ quad)
        {
            List <Material> materials = new List <Material> (quad.meshRenderer.sharedMaterials);

            materials.Remove(materials.Find(mat => mat.shader.name == "Scatterer/AtmosphericLocalScatter"));             //probably slow
            quad.meshRenderer.sharedMaterials = materials.ToArray();
        }
Ejemplo n.º 14
0
 public override void OnQuadCreate(PQ quad)
 {
     if (quad.sphereRoot == this.sphere)
     {
         AddMaterial(quad.meshRenderer);
     }
 }
Ejemplo n.º 15
0
    static void Main()
    {
        var qc = int.Parse(Console.ReadLine());
        var qs = Array.ConvertAll(new bool[qc], _ => Read());

        var pq = PQ <long> .Create();

        var d = 0L;

        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput())
        {
            AutoFlush = false
        });
        foreach (var q in qs)
        {
            if (q[0] == 1)
            {
                pq.Push(q[1] - d);
            }
            else if (q[0] == 2)
            {
                d += q[1];
            }
            else
            {
                Console.WriteLine(pq.Pop() + d);
            }
        }
        Console.Out.Flush();
    }
Ejemplo n.º 16
0
 public PatientMeasurableObservations()
 {
     this.id   = new IIImpl();
     this.code = new CDImpl();
     this.confidentialityCode = new CVImpl();
     this.value = new PQImpl();
 }
Ejemplo n.º 17
0
 public SubsequentSupplyRequest()
 {
     this.effectiveTime   = new IVLImpl <TS, Interval <PlatformDate> >();
     this.repeatNumber    = new INTImpl();
     this.quantity        = new PQImpl();
     this.expectedUseTime = new IVLImpl <TS, Interval <PlatformDate> >();
 }
Ejemplo n.º 18
0
 public SupplyEvent()
 {
     this.code            = new CVImpl();
     this.effectiveTime   = new IVLImpl <TS, Interval <PlatformDate> >();
     this.quantity        = new PQImpl();
     this.expectedUseTime = new IVLImpl <TS, Interval <PlatformDate> >();
 }
Ejemplo n.º 19
0
    List <int> Calc()
    {
        var N = G()[0];
        var a = G();
        var r = new int[N];

        for (var i = 0; i < N; i++)
        {
            r[--a[i]] = i;
        }
        var        par = new[] { new RMQ(a, 0), new RMQ(a, 1) };
        var        q   = new PQ();
        var        d   = new Dictionary <int, P>();
        Action <P> add = p => { if (p.r - p.l > 1)
                                {
                                    var z = par[p.l & 1].Min(p); d[z] = p; q.Enqueue(z);
                                }
        };

        add(new P(0, N));
        var L = new List <int>();

        while (q.N > 0)
        {
            int x = q.Dequeue(), i = r[x];
            var p = d[x];
            int f = p.l & 1, y = par[1 - f].Min(i + 1, p.r), j = r[y];
            L.Add(x + 1);
            L.Add(y + 1);
            add(new P(p.l, i));
            add(new P(i + 1, j));
            add(new P(j + 1, p.r));
        }
        return(L);
    }
Ejemplo n.º 20
0
 public LengthofWoundEntryRelationshipObservation()
 {
     this.negationInd        = new BLImpl();
     this.typeId             = new IIImpl();
     this.templateId         = new LISTImpl <II, Identifier>(typeof(IIImpl));
     this.id                 = new LISTImpl <II, Identifier>(typeof(IIImpl));
     this.derivationExpr     = new STImpl();
     this.text               = new EDImpl <EncapsulatedData>();
     this.statusCode         = new CS_R2Impl <Code>();
     this.effectiveTime      = new IVL_TSImpl();
     this.priorityCode       = new CE_R2Impl <Code>();
     this.repeatNumber       = new IVLImpl <INT, Interval <int?> >();
     this.languageCode       = new CS_R2Impl <Code>();
     this.value              = new PQImpl();
     this.interpretationCode = new LISTImpl <CE_R2 <Code>, CodedTypeR2 <Code> >(typeof(CE_R2Impl <Code>));
     this.methodCode         = new LISTImpl <CE_R2 <Code>, CodedTypeR2 <Code> >(typeof(CE_R2Impl <Code>));
     this.targetSiteCode     = new LISTImpl <CD_R2 <Code>, CodedTypeR2 <Code> >(typeof(CD_R2Impl <Code>));
     this.specimen           = new List <Ca.Infoway.Messagebuilder.Model.Ccda_r1_1.Merged.Specimen>();
     this.performer          = new List <Ca.Infoway.Messagebuilder.Model.Ccda_r1_1.Merged.Performer2_1>();
     this.author             = new List <Ca.Infoway.Messagebuilder.Model.Ccda_r1_1.Merged.Author_1>();
     this.informant          = new List <Ca.Infoway.Messagebuilder.Model.Ccda_r1_1.Merged.Informant12>();
     this.participant        = new List <Ca.Infoway.Messagebuilder.Model.Ccda_r1_1.Merged.Participant2_2>();
     this.entryRelationship  = new List <Ca.Infoway.Messagebuilder.Model.Ccda_r1_1.Merged.EntryRelationship_2>();
     this.reference          = new List <Ca.Infoway.Messagebuilder.Model.Ccda_r1_1.Basemodel.Reference>();
     this.precondition       = new List <Ca.Infoway.Messagebuilder.Model.Ccda_r1_1.Basemodel.Precondition>();
     this.referenceRange     = new List <Ca.Infoway.Messagebuilder.Model.Ccda_r1_1.Merged.ReferenceRange>();
 }
Ejemplo n.º 21
0
    static object Solve()
    {
        var n = int.Parse(Console.ReadLine());
        var a = ReadL();

        var q = PQ <long> .Create();

        var c = 0;

        foreach (var v in a)
        {
            var x = v;
            while ((x & 1) == 0)
            {
                x >>= 1;
                c++;
            }
            q.Push(x);
        }

        while (c-- > 0)
        {
            var x = q.Pop();
            q.Push(x * 3);
        }

        return(q.First);
    }
Ejemplo n.º 22
0
    static object Solve()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Read();

        var r1 = a.ToArray();
        var r2 = a.ToArray();

        var q1 = new Queue <int>();
        var q2 = PQ <int> .Create(true);

        var t = 0;

        for (int i = 0; i < n; i++)
        {
            if (t == a[i])
            {
                r1[i] = q1.Dequeue();
                r2[i] = q2.Pop();
            }
            else
            {
                for (t++; t < a[i]; t++)
                {
                    q1.Enqueue(t);
                    q2.Push(t);
                }
            }
        }

        return(string.Join(" ", r1) + "\n" + string.Join(" ", r2));
    }
Ejemplo n.º 23
0
 public DrugContains()
 {
     this.negationInd             = new BLImpl();
     this.quantity                = new PQImpl();
     this.ingredientSubstanceCode = new CVImpl();
     this.ingredientSubstanceName = new STImpl();
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Função principal de busca
        /// </summary>
        /// <returns></returns>
        private int[] FindSolution()
        {
            Node           inicio = new Node(null, initState, 0, null);
            PQ             open   = new PQ();
            List <Caminho> closed = new List <Caminho>();


            int     euristicaInicio = Euristica(inicio);
            Caminho n = new Caminho(inicio, euristicaInicio, 0);

            open.Add(n);
            closed.Add(n);
            while (!open.EstaVazio())
            {
                foreach (Caminho m in GetSucessors(n.N, euristicaInicio))
                {
                    if (!closed.Contains(m))
                    {
                        open.Add(m);
                    }
                }
                n = open.Pop();
                closed.Add(n);
                if (TargetFound(n.N))
                {
                    break;
                }
            }

            return(BuildAnswer(n.N));;
        }
        //remove extra material at end of quad's life to prevent issues
        public override void OnQuadDestroy(PQ quad)
        {
            var mats    = quad.meshRenderer.sharedMaterials;
            var newMats = new Material[] { mats [0] };

            quad.meshRenderer.sharedMaterials = newMats;
        }
Ejemplo n.º 26
0
 public SupplyRequest()
 {
     this.statusCode      = new CSImpl();
     this.quantity        = new PQImpl();
     this.repeatNumber    = new INTImpl();
     this.expectedUseTime = new IVLImpl <TS, Interval <PlatformDate> >();
 }
Ejemplo n.º 27
0
    static object Solve()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Read();

        var counts = a.GroupBy(x => x).Select(g => g.Count()).ToArray();
        var q      = PQ <int> .Create(true);

        q.PushRange(counts);

        while (q.Count >= 2)
        {
            var c1 = q.Pop() - 1;
            var c2 = q.Pop() - 1;

            if (c1 > 0)
            {
                q.Push(c1);
            }
            if (c2 > 0)
            {
                q.Push(c2);
            }
        }

        if (q.Count == 0)
        {
            return(0);
        }
        return(q.Pop());
    }
Ejemplo n.º 28
0
    static (long[] d, int[] from) Dijkstra(int n, int sv, int[][] es, bool directed = false)
    {
        // 使われない頂点が存在してもかまいません (1-indexed でも可)。
        var map = ToMap2(n, es, directed);

        var d    = Enumerable.Repeat(long.MaxValue, n + 1).ToArray();
        var from = Enumerable.Repeat(-1, n + 1).ToArray();
        var q    = PQ <int> .CreateWithKey(v => d[v]);

        d[sv] = 0;
        q.Push(sv);

        while (q.Count > 0)
        {
            var(v, qd) = q.Pop();
            if (d[v] < qd)
            {
                continue;
            }
            foreach (var e in map[v])
            {
                if (d[e.To] <= d[v] + e.Weight)
                {
                    continue;
                }
                d[e.To]    = d[v] + e.Weight;
                from[e.To] = v;
                q.Push(e.To);
            }
        }
        return(d, from);
    }
Ejemplo n.º 29
0
        public override void OnQuadCreate(PQ quad)
        {
            List <Material> materials = new List <Material> (quad.meshRenderer.sharedMaterials);

            materials.Add(atmosphereMaterial);
            quad.meshRenderer.sharedMaterials = materials.ToArray();
        }
Ejemplo n.º 30
0
 public override void OnQuadDestroy(PQ quad)
 {
     foreach (var footprint in quad.GetComponentsInChildren <KerbalEVAFootprintSpawner.KerbalEVAFootprint>(true))
     {
         Destroy(footprint.gameObject);
     }
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Corutine to rebuild parts of a PQS sphere
 /// </summary>
 public static IEnumerator RebuildSphere(PQ[] quads, PQS pqs)
 {
     for (Int32 i = 0; i < quads.Length; i++)
     {
         PQ quad = quads[i];
         quad.isBuilt = false;
         quad.isBuilt = pqs.BuildQuad(quad);
         pqs.GetType().GetMethod("UpdateEdgeNormals", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(pqs, new[] { quad });
         yield return null;
     }
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Returns true if <paramref name="from"/> can be converted
        /// to the <paramref name="unitTo"/>
        /// </summary>
        /// <exception cref="T:System.ArgumentNullException">If any of the arguments are Null or NullFlavored</exception>
        public bool CanConvert(PQ from, string unitTo)
        {
            if (from == null || from.IsNull)
                throw new ArgumentNullException("from");
            else if (unitTo == null)
                throw new ArgumentNullException("unitTo");

            bool isSiMeasure = !String.IsNullOrEmpty(GetSiUnit(unitTo).Value) && !String.IsNullOrEmpty(GetSiUnit(from.Unit).Value);

            if (isSiMeasure)
                isSiMeasure = GetSiUnit(unitTo).Value.Equals(GetSiUnit(from.Unit).Value);
            return isSiMeasure;
        }
            // Enabling
            public override void OnQuadPreBuild(PQ quad)
            {
                // Don't update, if the Injector is still running
                if (isLoaded)
                    return;

                // Enable the maps
                if (OnDemandStorage.EnableBody(sphere.name))
                {
                    isLoaded = true;
                    Debug.Log("[OD] Enabling Body " + base.sphere.name + ": " + isLoaded);
                }
            }
Ejemplo n.º 34
0
        private void btnRender_Click(object sender, EventArgs e)
        {
            //A double to store the amount in.
            decimal amount;

            //Ensure that a valid amount and unit type exist.
            if (cbxUnit.SelectedItem == null || !Decimal.TryParse(txtValue.Text, out amount))
                return;

            //Create the PQ.
            PQ pq = new PQ(amount, cbxUnit.SelectedItem.ToString());

            // Get the PQ in XML format using the FormatterHelper class.
            string pqXmlStr = FormatterHelper.FormatDataType(pq, "PQ");
            
            // Display the generated xml.
            txtXml.Text = pqXmlStr;
        }
Ejemplo n.º 35
0
    public static List<Vector4> Plan(Vector4 start, Vector4 target, Map m, int weight, bool canTimeTravel)
    {
        if (!canTimeTravel && target.w != start.w) {
            return new List<Vector4> ();
        }

        PQ pq = new PQ();
        HashSet<Vector4> visited = new HashSet<Vector4>();
        int target_x = m.getRowNumber(target.x);
        int target_y = m.getVerNumber(target.y);
        int target_z = m.getColNumber(target.z);
        int target_w = (int)target.w;
        int start_x = m.getRowNumber(start.x);
        int start_y = m.getVerNumber(start.y);
        int start_z = m.getColNumber(start.z);
        int start_w = (int)start.w;

        float eDist = Node.euclideanDistance(start_x, start_y, start_z, start_w, target_x, target_y, target_z, target_w);
        Node init = new Node(start_x, start_y, start_z, start_w, 0, eDist, new List<Vector4>());
        pq.insert(init);

        int[][,,] inf_map = m.getInfluenceMapCopy ();
        Map.subtractInfluenceMap(start, weight, inf_map);

        while (!pq.isEmpty())
        {
            Node n = pq.pop();
            visited.Add(new Vector4(n.x, n.y, n.z, n.w));
            if (n.x == target_x && n.y == target_y && n.z == target_z && n.w == target_w)
            {
                return n.path;
            }

            processNextActions(pq, visited, n, target_x, target_y, target_z, target_w, m, inf_map, canTimeTravel);
        }

        return new List<Vector4> ();
    }
Ejemplo n.º 36
0
        public void PQTranslationsTest03()
        {
            PQ kilometers = new PQ(1, "km");
            
            // add unit converter
            PQ.UnitConverters.Add(new SimpleSiUnitConverter());

            try
            {
                // convert
                PQ temperature = kilometers.Convert("K");
                Console.WriteLine(temperature);    // this results in 100,000 m being printed
                Assert.IsFalse(temperature.Validate());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                
                // Make sure we get a 'cannot convert' exception message.
                Assert.IsTrue(e.ToString().Contains("Cannot convert"));
            }
        }
Ejemplo n.º 37
0
        public void PQTranslationsTest02()
        {
            PQ kilometers = new PQ(1, "km");
            try
            {
                Console.WriteLine(kilometers.Convert("cm"));
                // this throws an exception
            }
            catch (Exception)
            {
                Console.WriteLine("No converter was found!");
            }
            
            // add unit converter
            PQ.UnitConverters.Add(new SimpleSiUnitConverter());

            // convert
            PQ centimeters = kilometers.Convert("cm");
            Console.WriteLine(centimeters);    // this results in 100,000 m being printed
            Assert.AreNotEqual(kilometers, centimeters);
        }
Ejemplo n.º 38
0
 public void PQNULLValuePOPNullflavorValidationTest()
 {
     PQ pq = new PQ();
     pq.Value = null;
     pq.NullFlavor = NullFlavor.NotAsked;
     Assert.IsTrue(pq.Validate());
 }
Ejemplo n.º 39
0
        public void R2PQTranslationParseTest()
        {
            PQ inti = new PQ(48, "hr")
            {
                Translation = new SET<PQR>(
                    new PQR(2, "d", "UCUM")
                )
            };
            string actualXml = R2SerializationHelper.SerializeAsString(inti);
            PQ int2 = R2SerializationHelper.ParseString<PQ>(actualXml);
            Assert.AreEqual(inti, int2);

        }
Ejemplo n.º 40
0
 public void PQValidationPOPNullflavorValueTest()
 {
     PQ pq = new PQ();
     pq.NullFlavor = NullFlavor.NotAsked;
     pq.Value = 1;
     Assert.IsFalse(pq.Validate());
 }
		public override void OnQuadBuilt (PQ quad)
		{
			if (quad.sphereRoot != sphere)
				return;

			var surfaceMaterial = quad.meshRenderer.sharedMaterial;

			//take a copy of the emissive material
			var emissiveMaterial = new Material(EmissiveMaterial);
			emissiveMaterial.renderQueue = surfaceMaterial.renderQueue + 10;

			quad.meshRenderer.sharedMaterials = new Material[]{ surfaceMaterial, emissiveMaterial };
		}
Ejemplo n.º 42
0
 public void R2PQPrecisionSerializationTest()
 {
     PQ inti = new PQ((decimal)1.30001, "hr") { Precision = 3 };
     string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" unit=""hr"" value=""1.300""/>";
     string actualXml = R2SerializationHelper.SerializeAsString(inti);
     R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
 }
Ejemplo n.º 43
0
        public void PQCastFromDoubleTest()
        {
            decimal d = (decimal)23.32;
            PQ pq = new PQ();
            pq.Value = d; 
            pq.Unit = "ft_i";
            Assert.AreEqual(d, pq.Value);
            

        }
Ejemplo n.º 44
0
 public void PQValidationNULLNullflavorPOPValueTest()
 {
     PQ pq = new PQ();
     pq.NullFlavor = null;
     pq.Value = 1;
     Assert.IsTrue(pq.Validate());
 }
Ejemplo n.º 45
0
 public void R2PQExpressionSerializationTest()
 {
     PQ inti = new PQ(0, "hr")
     {
         NullFlavor = NullFlavor.Derived,
         Expression = new ED(
             System.Text.Encoding.UTF8.GetBytes("i = (10 + 2) / 2 + 2)"),
             "application/mathml+xml"
         )
     };
     string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" unit=""hr"" nullFlavor=""DER""><expression mediaType=""application/mathml+xml""><data>aSA9ICgxMCArIDIpIC8gMiArIDIp</data></expression></test>";
     string actualXml = R2SerializationHelper.SerializeAsString(inti);
     R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
 }
Ejemplo n.º 46
0
 public void R2PQNullFlavorSerializationTest()
 {
     PQ inti = new PQ(48, "hr")
     {
         Translation = new SET<PQR>(
             new PQR(2, "d", "UCUM")
         ),
         NullFlavor = NullFlavor.Invalid
     };
     string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" nullFlavor=""INV""/>";
     string actualXml = R2SerializationHelper.SerializeAsString(inti);
     R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
 }
Ejemplo n.º 47
0
 public void R2PQPrecisionParseTest()
 {
     PQ inti = new PQ((decimal)1.300, "hr") { Precision = 3 };
     string actualXml = R2SerializationHelper.SerializeAsString(inti);
     PQ int2 = R2SerializationHelper.ParseString<PQ>(actualXml);
     Assert.AreEqual(inti, int2);
 }
Ejemplo n.º 48
0
        public void R2PQExpressionParseTest()
        {
            PQ inti = new PQ()
            {
                Unit = "hr",
                NullFlavor = NullFlavor.Derived,
                Expression = new ED(
                    System.Text.Encoding.UTF8.GetBytes("i = (10 + 2) / 2 + 2)"),
                    "application/mathml+xml"
                )
            };
            string actualXml = R2SerializationHelper.SerializeAsString(inti);
            PQ int2 = R2SerializationHelper.ParseString<PQ>(actualXml);
            Assert.AreEqual(inti, int2);

        }
Ejemplo n.º 49
0
        public void IVL_ContainsTest01()
        {
            // Create an instance of IVL
            IVL<PQ> acceptableRange = new IVL<PQ>(
                new PQ(0, "L"),
                new PQ(10, "L")
            )
            {
                LowClosed = true,
                HighClosed = true
            };

            // Since we need to convert PQ units, add a unit converter
            PQ.UnitConverters.Add(new SimpleSiUnitConverter());
            PQ test = new PQ(9, "L");

            // Determine if the value is in range (true)
            bool isInRange = acceptableRange.Contains(test);

            acceptableRange.NullFlavor = NullFlavor.NoInformation;
            Assert.IsTrue(isInRange);
        }
Ejemplo n.º 50
0
 public void EV_1088_PQToStringLocalizationTest()
 {
     // Setup
     var defaultCulture = EverestFrameworkContext.CurrentCulture;
     EverestFrameworkContext.CurrentCulture = new System.Globalization.CultureInfo("fr-FR", false);
     
     // Graph 
     PQ test = new PQ((decimal)1.20, "mm");
     test.Precision = 2;
     Assert.AreEqual("1,20 mm", test.ToString());
     // Teardown
     EverestFrameworkContext.CurrentCulture = defaultCulture;
 }
Ejemplo n.º 51
0
        public void IVL_ContainsTest05()
        {
            // Create an instance of IVL
            IVL<PQ> acceptableRange = new IVL<PQ>(
                new PQ(0, "L"),
                new PQ(10, "L")
            )
            {
                LowClosed = true,
                HighClosed = true
            };

            // Since we need to convert PQ units, add a unit converter
            PQ.UnitConverters.Add(new SimpleSiUnitConverter());
            PQ test = new PQ(10, "m");

            try
            {
                // Determine if the value is in range (true)
                bool isInRange = acceptableRange.Contains(test);
                acceptableRange.NullFlavor = NullFlavor.NoInformation;
                Assert.IsFalse(isInRange);
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.ToString().Contains("Units must match to compare PQ"));
            }
        }
Ejemplo n.º 52
0
		static bool PQisNotNull (PQ pq)
		{
			return pq;
		}
Ejemplo n.º 53
0
 public void PQTranslationTest()
 {
     PQ h = new PQ((decimal)2.5, "m");
     h.Translation = new SET<PQR>(new PQR((decimal)82.021E+2, "ft_i", "123.23.24.3"), PQR.Comparator);
 }
Ejemplo n.º 54
0
 /// <summary>
 /// Convert <paramref name="original"/> to a new instance
 /// of PQ with the unit <paramref name="unitTo"/>
 /// </summary>
 public PQ Convert(PQ original, string unitTo)
 {
     if (!String.IsNullOrEmpty(GetSiUnit(unitTo).Value))
     {
         KeyValuePair<String, String> newSiData = GetSiUnit(unitTo),
             oldSiData = GetSiUnit(original.Unit);
         double oldSiBase = SimpleSiUnitConverter.s_siPrefixes[oldSiData.Key],
             newSiBase = SimpleSiUnitConverter.s_siPrefixes[newSiData.Key];
         return new PQ((decimal)((double)original.Value * oldSiBase / newSiBase), unitTo);
     }
     return new PQ() { NullFlavor = NullFlavor.Unknown };
 }
Ejemplo n.º 55
0
 public void PQValidationNULLNullflavorValueTest()
 {
     PQ pq = new PQ();
     pq.NullFlavor = null;
     pq.Value = null;
     Assert.IsFalse(pq.Validate());
 }
Ejemplo n.º 56
0
        public void PQTranslationsTest01()
        {

            PQ kilometers = new PQ(1, "km");
            try
            {
                Console.WriteLine(kilometers.Convert("cm"));
                // this throws an exception
            }
            catch (Exception)
            {
                Console.WriteLine("No converter was found!");
            }

            PQ.UnitConverters.Add(new SimpleSiUnitConverter());
            Console.WriteLine(kilometers.Convert("cm"));    // this results in 100,000 cm being printed
            Assert.IsTrue(kilometers.Validate());
        }
		//remove extra material at end of quad's life to prevent issues
		public override void OnQuadDestroy (PQ quad)
		{
			var mats = quad.meshRenderer.sharedMaterials;
			var newMats = new Material[]{ mats [0] };
			quad.meshRenderer.sharedMaterials = newMats;
		}
 public override void OnQuadDestroy(PQ quad)
 {
     foreach(var footprint in quad.GetComponentsInChildren<KerbalEVAFootprintSpawner.KerbalEVAFootprint>(true))
     {
         Destroy (footprint.gameObject);
     }
 }
Ejemplo n.º 59
0
 public void R2PQTranslationSerializationTest()
 {
     PQ inti = new PQ(48, "hr")
     {
         Translation = new SET<PQR>(
             new PQR(2, "d", "UCUM")
         )
     };
     string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" unit=""hr"" value=""48""><translation value=""2"" code=""d"" codeSystem=""UCUM""/></test>";
     string actualXml = R2SerializationHelper.SerializeAsString(inti);
     R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
 }
Ejemplo n.º 60
0
        public void R2PQBasicSerializationTest()
        {
            PQ dist = new PQ((decimal)2.1, "m");
            dist.Translation = new SET<PQR>(
                new PQR((decimal)6.8897, "ft_i", "2.16.840.1.113883.6.8")
            );
            R2SerializationHelper.SerializeAsString(dist);

            PQ inti = new PQ((decimal)1.304, "hr"); 
            string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" unit=""hr"" value=""1.304""/>";
            string actualXml = R2SerializationHelper.SerializeAsString(inti);
            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }