Ejemplo n.º 1
0
        /// <summary>
        ///     Generates a <see cref="PocoAudioRing" /> which fills all audio gaps between videos with the specified audio
        ///     <paramref name="ids" />.
        /// </summary>
        /// <param name="ring">The ring from which the audio should be generated.</param>
        /// <param name="ids">The audio ids</param>
        public static PocoAudioRing CreateGapFillingAudioRing(this IRing <IFrameRingEntry> ring, IEnumerable <Guid> ids)
        {
            var audioIds      = ids as List <Guid> ?? ids.ToList();
            var frameAnalyses = new Dictionary <IFrameRingEntry, FrameAnalysis>();
            var audioRing     = new PocoAudioRing
            {
                RingBufferSize = 1,
                RingPeriod     = ring.RingPeriod,
                RingStartTime  = ring.RingStartTime
            };


            var foo          = ring.RingItems as IFrameRingEntry[] ?? ring.RingItems.ToArray();
            var audioStarted = (foo[foo.Length - 1].RingEntryFrame?.Analyse().Videos.Count ?? 0) == 0;

            foreach (var entry in ring.RingItems)
            {
                FrameAnalysis analysis;

                if (!frameAnalyses.TryGetValue(entry, out analysis))
                {
                    analysis = entry.RingEntryFrame?.Analyse();
                    frameAnalyses.Add(entry, analysis);
                }
                if ((analysis?.Videos.Count ?? 0) != 0)
                {
                    // Video will start
                    if (!audioStarted)
                    {
                        continue;
                    }
                    audioRing.PocoRingItems.Add(new PocoAudioRingEntry {
                        AudioGuidList = null, RingEntryStartTime = entry.RingEntryStartTime
                    });
                    audioStarted = false;
                }
                else
                {
                    // Video will stop
                    if (audioStarted)
                    {
                        continue;
                    }

                    audioRing.PocoRingItems.Add(new PocoAudioRingEntry
                    {
                        RingEntryStartTime = entry.RingEntryStartTime,
                        AudioGuidList      = audioIds,
                    });
                    audioStarted = true;
                }
            }

            return(audioRing);
        }
Ejemplo n.º 2
0
        public static IGeometry GetExample5()
        {
            const int    XRange            = 16;
            const int    YRange            = 16;
            const int    InteriorRingCount = 25;
            const double HoleRange         = 0.5;

            //RingGroup: Square Lying In XY Plane With Single Exterior Ring And Multiple Interior Rings

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;

            //Exterior Ring

            IPointCollection exteriorRingPointCollection = new RingClass();

            exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0.5 * (XRange + 2), -0.5 * (YRange + 2), 0), ref _missing, ref _missing);
            exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-0.5 * (XRange + 2), -0.5 * (YRange + 2), 0), ref _missing, ref _missing);
            exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-0.5 * (XRange + 2), 0.5 * (YRange + 2), 0), ref _missing, ref _missing);
            exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0.5 * (XRange + 2), 0.5 * (YRange + 2), 0), ref _missing, ref _missing);

            IRing exteriorRing = exteriorRingPointCollection as IRing;

            exteriorRing.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Rings

            Random random = new Random();

            for (int i = 0; i < InteriorRingCount; i++)
            {
                double interiorRingOriginX = XRange * (random.NextDouble() - 0.5);
                double interiorRingOriginY = YRange * (random.NextDouble() - 0.5);

                IPointCollection interiorRingPointCollection = new RingClass();
                interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX - 0.5 * HoleRange, interiorRingOriginY - 0.5 * HoleRange, 0), ref _missing, ref _missing);
                interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX + 0.5 * HoleRange, interiorRingOriginY - 0.5 * HoleRange, 0), ref _missing, ref _missing);
                interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX + 0.5 * HoleRange, interiorRingOriginY + 0.5 * HoleRange, 0), ref _missing, ref _missing);
                interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX - 0.5 * HoleRange, interiorRingOriginY + 0.5 * HoleRange, 0), ref _missing, ref _missing);

                IRing interiorRing = interiorRingPointCollection as IRing;
                interiorRing.Close();

                multiPatchGeometryCollection.AddGeometry(interiorRing as IGeometry, ref _missing, ref _missing);

                multiPatch.PutRingType(interiorRing, esriMultiPatchRingType.esriMultiPatchInnerRing);
            }

            return(multiPatchGeometryCollection as IGeometry);
        }
Ejemplo n.º 3
0
        protected override object ShapeParameterValue(OgcSpatialFeatureclass fClass, gView.Framework.Geometry.IGeometry shape, int srid, out bool AsSqlParameter)
        {
            if (shape is IPolygon)
            {
                #region Check Polygon Rings
                IPolygon p = new Polygon();
                for (int i = 0; i < ((IPolygon)shape).RingCount; i++)
                {
                    IRing ring = ((IPolygon)shape)[i];
                    if (ring != null && ring.Area > 0D)
                    {
                        p.AddRing(ring);
                    }
                }

                if (p.RingCount == 0)
                {
                    AsSqlParameter = true;
                    return(null);
                }
                shape = p;
                #endregion
            }
            else if (shape is IPolyline)
            {
                #region Check Polyline Paths
                IPolyline l = new Polyline();
                for (int i = 0; i < ((IPolyline)shape).PathCount; i++)
                {
                    IPath path = ((IPolyline)shape)[i];
                    if (path != null && path.Length > 0D)
                    {
                        l.AddPath(path);
                    }
                }

                if (l.PathCount == 0)
                {
                    AsSqlParameter = true;
                    return(null);
                }
                shape = l;
                #endregion
            }

            AsSqlParameter = false;

            //return gView.Framework.OGC.OGC.GeometryToWKB(shape, gView.Framework.OGC.OGC.WkbByteOrder.Ndr);
            string geometryString =
                (shape is IPolygon) ?
                "geometry::STGeomFromText('" + gView.Framework.OGC.WKT.ToWKT(shape) + "'," + srid + ").MakeValid()" :
                "geometry::STGeomFromText('" + gView.Framework.OGC.WKT.ToWKT(shape) + "'," + srid + ")";
            return(geometryString);
            //return "geometry::STGeomFromText('" + geometryString + "',0)";
        }
Ejemplo n.º 4
0
        private static ICurvePolygon FlattenCurvePolygon(ICurvePolygon curvePolygon, FgfGeometryFactory factory)
        {
            IRing          extRing  = FlattenRing(curvePolygon.ExteriorRing, factory);
            RingCollection intRings = new RingCollection();

            for (int i = 0; i < curvePolygon.InteriorRingCount; i++)
            {
                intRings.Add(FlattenRing(curvePolygon.get_InteriorRing(i), factory));
            }
            return(factory.CreateCurvePolygon(extRing, intRings));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Multiplies the specified element power times.
        /// </summary>
        /// <param name="ring">The ring.</param>
        /// <param name="element">The element.</param>
        /// <param name="power">The power.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        /// <returns>The result.</returns>
        public static T Pow <T>(this IRing <T> ring, T element, uint power)
        {
            var result = ring.One;

            for (var i = 0; i < power; i++)
            {
                result = ring.Multiplication(element, result);
            }

            return(result);
        }
        public void TestCompare_IAtomContainer_Null()
        {
            IChemObjectBuilder builder = ChemObjectBuilder.Instance;
            IRing cycloPentane         = builder.NewRing(5, "C");

            // Instantiate the comparator
            IComparer <IAtomContainer> comparator = new AtomContainerComparator <IAtomContainer>();

            // Assert.assert correct comparison
            Assert.AreEqual(-1, comparator.Compare(cycloPentane, null), "cycloPentane <-> null");
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Instancia um novo objecto do tipo <see cref="ADeterminant{ElementsType}"/>.
 /// </summary>
 /// <param name="ring">O anel responsável pelas operações sobre os coeficientes.</param>
 /// <exception cref="ArgumentNullException">Se o anel for nulo.</exception>
 public ADeterminant(IRing <ElementsType> ring)
 {
     if (ring == null)
     {
         throw new ArgumentNullException("ring");
     }
     else
     {
         this.ring = ring;
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Checks if <paramref name="atom1"/> and <paramref name="atom2"/> share membership in the same ring or ring system.
 /// Membership in the same ring is checked if the RingSet contains the SSSR of a molecule; membership in
 /// the same ring or same ring system is checked if the RingSet contains all rings of a molecule.
 /// </summary>
 /// <remarks>
 /// <note type="important">
 /// This method only returns meaningful results if <paramref name="atom1"/> and
 /// <paramref name="atom2"/> are members of the same molecule for which the ring set was calculated!
 /// </note>
 /// </remarks>
 /// <param name="ringSet">The collection of rings</param>
 /// <param name="atom1">The first atom</param>
 /// <param name="atom2">The second atom</param>
 /// <returns><see langword="true"/> if <paramref name="atom1"/> and <paramref name="atom2"/> share membership of at least one ring or ring system, false otherwise</returns>
 public static bool IsSameRing(IRingSet ringSet, IAtom atom1, IAtom atom2)
 {
     foreach (var atomContainer in ringSet)
     {
         IRing ring = (IRing)atomContainer;
         if (ring.Contains(atom1) && ring.Contains(atom2))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 9
0
        //public IPolygon GetPolygonGeomery(IPointCollection ipc)
        //{

        //    IGeometryCollection polygon = new PolygonClass();
        //    IPolyline polyline = ipc as IPolyline;
        //    ILine repolyline = new LineClass();
        //    repolyline.PutCoords(polyline.FromPoint, polyline.ToPoint);
        //    ISegment segment = repolyline as ISegment;
        //    ISegmentCollection psc = new RingClass();
        //    psc.AddSegment(segment);
        //    IRing pring = psc as IRing;
        //    pring.Close();
        //    polygon.AddGeometry(pring);
        //    IPolygon finalpolygon = polygon as IPolygon;
        //    return finalpolygon;

        //}
        public IPolygon GetPolygonGeomery(IPointCollection ipc)
        {
            IPolyline polyline = null;

            polyline = ipc as IPolyline;
            IRing pring = polyline as IRing;

            pring.Close();
            IPolygon polygon = pring as IPolygon;

            return(polygon);
        }
Ejemplo n.º 10
0
        public override void TestToString()
        {
            IChemObject obj         = NewChemObject();
            IRing       r           = obj.Builder.NewRing(5, "C");
            string      description = r.ToString();

            for (int i = 0; i < description.Length; i++)
            {
                Assert.IsTrue(description[i] != '\n');
                Assert.IsTrue(description[i] != '\r');
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Instancia um novo objecto do tipo <see cref="AuxAksModArithmRing{CoeffType}"/>.
 /// </summary>
 /// <param name="powerModule">O módulo segundo o qual são realizadas as simplificações de potência.</param>
 /// <param name="variableName">O nome da variável.</param>
 /// <param name="ring">O anel responsável pelas operações sobre os coeficientes.</param>
 /// <exception cref="ArgumentException">Se o módulo potência for inferior a um.</exception>
 public AuxAksModArithmRing(int powerModule, string variableName, IRing <CoeffType> ring)
     : base(variableName, ring)
 {
     if (powerModule < 1)
     {
         throw new ArgumentException("The power module can't be less than one.");
     }
     else
     {
         this.powerModule = powerModule;
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Verifica se o número complexo actual corresponde à unidade.
 /// </summary>
 /// <param name="ring">O anel responsável pelas operações sobre os coeficientes.</param>
 /// <returns>Verdadeiro caso o número complexo seja unitário e falso caso contrário.</returns>
 /// <exception cref="ArgumentNullException">Se o anel for nulo.</exception>
 public bool IsOne(IRing <ObjectType> ring)
 {
     if (ring == null)
     {
         throw new ArgumentNullException("ring");
     }
     else
     {
         return(ring.IsMultiplicativeUnity(this.realPart) &&
                ring.IsAdditiveUnity(this.imaginaryPart));
     }
 }
Ejemplo n.º 13
0
        private static bool IsAromaticRing(IRing ring)
        {
            for (int i = 0; i < ring.Atoms.Count; i++)
            {
                if (!ring.Atoms[i].IsAromatic)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 14
0
        private IRenderingElement GenerateRingRingElement(IBond bond, IRing ring, RendererModel model)
        {
            var c = ToPoint(GeometryUtil.Get2DCenter(ring));

            var minmax = GeometryUtil.GetMinMax(ring);
            var width  = minmax[2] - minmax[0];
            var height = minmax[3] - minmax[1];
            var radius = Math.Min(width, height) * model.GetRingProportion();
            var color  = GetColorForBond(bond, model);

            return(new OvalElement(c, radius, false, color));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Calculated the center for the first ring so that it can
        /// layed out. Only then, all other rings can be assigned
        /// coordinates relative to it.
        /// </summary>
        /// <param name="ring">The ring for which the center is to be calculated</param>
        /// <returns>A Vector2 pointing to the new ring center</returns>
        public virtual Vector2 GetRingCenterOfFirstRing(IRing ring, Vector2 bondVector, double bondLength)
        {
            int    size   = ring.Atoms.Count;
            double radius = bondLength / (2 * Math.Sin((Math.PI) / size));
            double newRingPerpendicular = Math.Sqrt(Math.Pow(radius, 2) - Math.Pow(bondLength / 2, 2));
            /* get the angle between the x axis and the bond vector */
            double rotangle = GeometryUtil.GetAngle(bondVector.X, bondVector.Y);

            // Add 90 Degrees to this angle, this is supposed to be the new ringcenter vector
            rotangle += Math.PI / 2;
            return(new Vector2((Math.Cos(rotangle) * newRingPerpendicular), (Math.Sin(rotangle) * newRingPerpendicular)));
        }
Ejemplo n.º 16
0
        private static void SevenMemberedRingPossibilities(IAtomContainer m, IRing r, IList <IList <IList <string> > > MasterList)
        {
            // for now only consider case where have 3 double bonds

            var ringatoms = new IAtom[7];

            ringatoms[0] = r.Atoms[0];

            var num = new int[7];

            for (int j = 0; j <= 6; j++)
            {
                num[j] = m.Atoms.IndexOf(r.Atoms[j]);
            }

            var al1 = new List <string>();
            var al2 = new List <string>();
            var al3 = new List <string>();
            var al4 = new List <string>();
            var al5 = new List <string>();

            al1.Add(num[0] + "-" + num[1]);
            al1.Add(num[2] + "-" + num[3]);
            al1.Add(num[4] + "-" + num[5]);

            al2.Add(num[0] + "-" + num[1]);
            al2.Add(num[2] + "-" + num[3]);
            al2.Add(num[5] + "-" + num[6]);

            al3.Add(num[1] + "-" + num[2]);
            al3.Add(num[3] + "-" + num[4]);
            al3.Add(num[5] + "-" + num[6]);

            al4.Add(num[1] + "-" + num[2]);
            al4.Add(num[3] + "-" + num[4]);
            al4.Add(num[6] + "-" + num[0]);

            al5.Add(num[2] + "-" + num[3]);
            al5.Add(num[4] + "-" + num[5]);
            al5.Add(num[6] + "-" + num[0]);

            var mal = new List <IList <string> >
            {
                al1,
                al2,
                al3,
                al4,
                al5
            };

            MasterList.Add(mal);
        }
Ejemplo n.º 17
0
        private void 生成地形挖洞ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            myListNode selectNode = this.listView1.SelectedItems[0] as myListNode;

            if (selectNode != null)
            {
                IRenderPolygon rgeo    = selectNode.obj as IRenderPolygon;
                IPolygon       polygon = rgeo.GetFdeGeometry() as IPolygon;

                // 生成带洞polygon,可注释掉
                IEnvelope env    = rgeo.Envelope;
                IRing     ring   = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryRing, gviVertexAttribute.gviVertexAttributeZ) as IRing;
                IPoint    center = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                center.Position   = env.Center;
                center.SpatialCRS = crs as ISpatialCRS;
                ring.AppendPoint(center);
                center.Y = env.Center.Y - 50;
                ring.AppendPoint(center);
                center.X = env.Center.X + 50;
                ring.AppendPoint(center);
                center.Y = env.Center.Y;
                ring.AppendPoint(center);
                polygon.AddInteriorRing(ring);
                // To here

                ISurfaceSymbol sfbottom = new SurfaceSymbol();
                sfbottom.Color = System.Drawing.Color.Red;
                IRenderPolygon rgeoNew = this.axRenderControl1.ObjectManager.CreateRenderPolygon(polygon, sfbottom, rootId);

                TerrainHoleSettingForm form = new TerrainHoleSettingForm();
                if (form.ShowDialog() == DialogResult.OK)
                {
                    order = form.Order;

                    ITerrainHole hole = this.axRenderControl1.ObjectManager.CreateTerrainHole(polygon, rootId);
                    if (hole != null)
                    {
                        hole.DrawOrder = order;

                        // 添加节点到界面控件上
                        myListNode item = new myListNode(string.Format("TerrainHole_{0}", hole.Guid), TreeNodeType.NT_TerrainHole, hole);
                        item.Checked = true;
                        listView1.Items.Add(item);

                        // 添加节点到界面控件上
                        item         = new myListNode(string.Format("RenderPolygon_{0}", hole.Guid), TreeNodeType.NT_RenderGeomtry, rgeoNew);
                        item.Checked = true;
                        listView1.Items.Add(item);
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public bool CheckFeature(IFeature pFeature, ref object pErrFeatureInf)
        {
            IFieldEdit        edit             = this._layer.FeatureClass.Fields.get_Field(this._layer.FeatureClass.Fields.FindField(this._layer.FeatureClass.ShapeFieldName)) as IFieldEdit;
            ISpatialReference spatialReference = edit.GeometryDef.SpatialReference;
            bool                flag           = true;
            List <double[]>     list           = (List <double[]>)pErrFeatureInf;
            IGeometryCollection shape          = pFeature.Shape as IGeometryCollection;

            for (int i = 0; i < shape.GeometryCount; i++)
            {
                esriNonSimpleReasonEnum enum2     = esriNonSimpleReasonEnum.esriNonSimpleOK;
                IPointCollection        newPoints = shape.get_Geometry(i) as IPointCollection;
                PolylineClass           o         = new PolylineClass();
                o.AddPointCollection(newPoints);
                o.SpatialReference = spatialReference;
                ITopologicalOperator3 ioperator = o as ITopologicalOperator3;
                ioperator.IsKnownSimple_2 = false;
                if (!ioperator.get_IsSimpleEx(out enum2))
                {
                    IRing ring = newPoints as IRing;
                    int   num2 = 0;
                    if (ring.IsClosed)
                    {
                        num2 = 1;
                    }
                    flag = false;
                    List <string> list2 = new List <string>();
                    List <string> list3 = new List <string>();
                    for (int j = num2; j < newPoints.PointCount; j++)
                    {
                        IPoint point = newPoints.get_Point(j);
                        string item  = point.X.ToString() + "," + point.Y.ToString();
                        if (list2.Contains(item))
                        {
                            if (!list3.Contains(item))
                            {
                                double[] numArray = new double[] { point.X, point.Y };
                                list.Add(numArray);
                                list3.Add(item);
                            }
                        }
                        else
                        {
                            list2.Add(item);
                        }
                    }
                }
                Marshal.ReleaseComObject(o);
                o = null;
            }
            return(flag);
        }
Ejemplo n.º 19
0
        private List <IRing> method_7(IRing iring_0, IPolygon ipolygon_0)
        {
            List <IRing>  list     = new List <IRing>();
            IPolygon4     polygon  = ipolygon_0 as IPolygon4;
            IEnumGeometry geometry = polygon.get_InteriorRingBag(iring_0) as IEnumGeometry;

            geometry.Reset();
            for (IRing ring = geometry.Next() as IRing; ring != null; ring = geometry.Next() as IRing)
            {
                list.Add(ring);
            }
            return(list);
        }
Ejemplo n.º 20
0
        private List <IRing> method_6(IPolygon ipolygon_0)
        {
            IPolygon4     polygon         = ipolygon_0 as IPolygon4;
            List <IRing>  list            = new List <IRing>();
            IEnumGeometry exteriorRingBag = polygon.ExteriorRingBag as IEnumGeometry;

            exteriorRingBag.Reset();
            for (IRing ring = exteriorRingBag.Next() as IRing; ring != null; ring = exteriorRingBag.Next() as IRing)
            {
                list.Add(ring);
            }
            return(list);
        }
Ejemplo n.º 21
0
        public void CanCreateNonSimpleRing()
        {
            IPath path =
                GeometryFactory.CreatePath(GeometryFactory.CreatePoint(100, 100));

            IRing ring = GeometryFactory.CreateRing(path);

            Assert.AreEqual(1, ((IPointCollection)ring).PointCount);

            ring = GeometryFactory.CreateRing(new PathClass());

            Assert.IsTrue(ring.IsEmpty);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 获取多边形指定外环所包含的内环
        /// </summary>
        /// <param name="polygon">多边形</param>
        /// <param name="exteriorRing">外部环,此外部环必须是指定多边形的</param>
        /// <returns></returns>
        public static List <IRing> GetInteriorRings(this IPolygon4 polygon, IRing exteriorRing)
        {
            List <IRing>        rings = new List <IRing>();
            IGeometryBag        interiorRingGeometryBag        = polygon.get_InteriorRingBag(exteriorRing);
            IGeometryCollection interiorRingGeometryCollection = (IGeometryCollection)interiorRingGeometryBag;

            for (int k = 0; k < interiorRingGeometryCollection.GeometryCount; k++)
            {
                IGeometry interiorRingGeometry = interiorRingGeometryCollection.get_Geometry(k);
                rings.Add(interiorRingGeometry as IRing);
            }
            return(rings);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Generate rendering Element(s) for the current bond, including ring
        /// elements if this bond is part of a ring.
        /// </summary>
        /// <param name="currentBond">the bond to use when generating elements</param>
        /// <param name="model">the renderer model</param>
        /// <returns>one or more rendering elements</returns>
        public virtual IRenderingElement Generate(IBond currentBond, RendererModel model)
        {
            IRing ring = RingSetManipulator.GetHeaviestRing(ringSet, currentBond);

            if (ring != null)
            {
                return(GenerateRingElements(currentBond, ring, model));
            }
            else
            {
                return(GenerateBond(currentBond, model));
            }
        }
Ejemplo n.º 24
0
        public static string KnotHash(string input, IRing <int> ring)
        {
            var bytes = input.ToBytes().ToList();

            bytes.AddRange(new List <byte> {
                17, 31, 73, 47, 23
            });

            var list = Part0(ring, bytes.ToInt32(), 64);

            var response = DenseHash(list);

            return(response.ToHex());
        }
Ejemplo n.º 25
0
        public void TestCompare_RingSize()
        {
            // Create some IAtomContainers
            IChemObjectBuilder builder = ChemObjectBuilder.Instance;
            IRing cycloPentane         = builder.NewRing(5, "C");
            IRing cycloHexane          = builder.NewRing(6, "C");

            // Instantiate the comparator
            IComparer <IAtomContainer> comparator = new AtomContainerComparator <IAtomContainer>();

            Assert.AreEqual(-1, comparator.Compare(cycloPentane, cycloHexane), "cycloPentane <-> cycloHexane");
            Assert.AreEqual(0, comparator.Compare(cycloPentane, cycloPentane), "cycloPentane <-> cycloPentane");
            Assert.AreEqual(1, comparator.Compare(cycloHexane, cycloPentane), "cycloHexane <-> cycloPentane");
        }
        public void Addition_LeftMultiplicationFunctionRightAdditionFunction_PointsAreEqual <T> (
            T value1,
            T value2,
            T expectedResult,
            IRing <T> ring)
        {
            Func <T, T, T> func1 = ring.Addition;
            Func <T, T, T> func2 = ring.Multiplication;

            var calc = ring.Addition(func1, func2);

            Assert.NotNull(calc);
            Assert.AreEqual(expectedResult, calc(value1, value2));
        }
 /// <summary>
 /// Instancia um novo objecto do tipo <see cref="UnivarPolDeterminantResultantAlg{CoeffType}"/>.
 /// </summary>
 /// <param name="ring">O anel responsável pelas operações sobre os coeficientes.</param>
 /// <exception cref="ArgumentNullException">Se o anel for nulo.</exception>
 public UnivarPolDeterminantResultantAlg(IRing <CoeffType> ring)
 {
     if (ring == null)
     {
         throw new ArgumentNullException("ring");
     }
     else
     {
         this.ring           = ring;
         this.determinantAlg = new FastDivisionFreeCharPolynomCalculator <CoeffType>(
             "x",
             this.ring);
     }
 }
Ejemplo n.º 28
0
        public static IList <int> DenseHash(IRing <int> ring)
        {
            var result = new List <int>();

            for (var i = 0; i < ring.Count; i += 16)
            {
                var range = ring.Skip(i).Take(16).ToList();
                var val   = range.Aggregate(0, (current, x) => current ^ x);

                result.Add(val);
            }

            return(result);
        }
Ejemplo n.º 29
0
        private static IList <GeometryPart> GetMultipatchExteriorRingParts(
            [NotNull] IMultiPatch2 multipatch)
        {
            var geometryCollection = (IGeometryCollection)multipatch;

            var partsByExteriorRing = new Dictionary <IRing, GeometryPart>();

            for (var i = 0; i < geometryCollection.GeometryCount; i++)
            {
                var ring = geometryCollection.Geometry[i] as IRing;

                if (ring == null)
                {
                    continue;
                }

                // for multipatches we cannot use IsExterior property - it's just not correct
                var  isBeginningRing = false;
                bool isExterior      = multipatch.GetRingType(ring, ref isBeginningRing) !=
                                       esriMultiPatchRingType.esriMultiPatchInnerRing;

                if (isExterior)
                {
                    var newExteriorPart = new GeometryPart(ring)
                    {
                        LabelText = Convert.ToString(i)
                    };

                    partsByExteriorRing.Add(ring, newExteriorPart);
                }
                else
                {
                    IRing exteriorRing = multipatch.FindBeginningRing(ring);

                    Assert.NotNull(exteriorRing, "No exterior ring found for inner ring");

                    GeometryPart part;
                    if (!partsByExteriorRing.TryGetValue(exteriorRing, out part))
                    {
                        part = new GeometryPart(exteriorRing);
                        partsByExteriorRing.Add(exteriorRing, part);
                    }

                    part.AddInnerRingGeometry(ring);
                }
            }

            return(partsByExteriorRing.Values.ToList());
        }
Ejemplo n.º 30
0
        public static IRing CreateRing(Linestring closedLinestring, IRing ringTemplate)
        {
            int pointCount = closedLinestring.SegmentCount + 1;

            WKSPointZ[] wksPointZs =
                GetWksPoints(closedLinestring.GetPoints(), pointCount);

            IRing ring = GeometryFactory.Clone(ringTemplate);

            ring.SetEmpty();

            GeometryUtils.AddWKSPointZs((IPointCollection4)ring, wksPointZs, pointCount);

            return(ring);
        }
Ejemplo n.º 31
0
 private static IRing FlattenRing(IRing ring, FgfGeometryFactory factory)
 {
     CurveSegmentCollection curves = new CurveSegmentCollection();
     foreach (ICurveSegmentAbstract curve in ring.CurveSegments)
     {
         curves.Add(FlattenCurveSegment(curve, factory));
     }
     return factory.CreateRing(curves);
 }
Ejemplo n.º 32
0
 /// <summary>  Perform a walk in the given RingSet, starting at a given Ring and
 /// recursivly searching for other Rings connected to this ring. By doing
 /// this it finds all rings in the RingSet connected to the start ring,
 /// putting them in newRs, and removing them from rs.
 /// 
 /// </summary>
 /// <param name="rs">    The RingSet to be searched
 /// </param>
 /// <param name="ring">  The ring to start with
 /// </param>
 /// <param name="newRs"> The RingSet containing all Rings connected to ring
 /// </param>
 /// <returns>        newRs The RingSet containing all Rings connected to ring
 /// </returns>
 private static IRingSet walkRingSystem(IRingSet rs, IRing ring, IRingSet newRs)
 {
     IRing tempRing;
     System.Collections.IList tempRings = rs.getConnectedRings(ring);
     if (debug)
     {
         System.Console.Out.WriteLine("walkRingSystem -> tempRings.size(): " + tempRings.Count);
     }
     rs.removeAtomContainer(ring);
     System.Collections.IEnumerator iter = tempRings.GetEnumerator();
     //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
     while (iter.MoveNext())
     {
         //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
         tempRing = (IRing)iter.Current;
         if (!newRs.contains(tempRing))
         {
             newRs.addAtomContainer(tempRing);
             newRs.add(walkRingSystem(rs, tempRing, newRs));
         }
     }
     return newRs;
 }
        /// <summary>  Tests the <code>ring</code> in the <code>molecule</code> for aromaticity. Uses the 
        /// H&uuml;ckle rule (4n + 2) pie electrons. sp<sup>2</sup> hybridized C contibute 1 electron non 
        /// sp<sup>2</sup> hybridized heteroatoms contribute 2 electrons (N and O should never be sp in 
        /// or anything else in a ring and d electron elements get to complicated) 
        /// sp<sup>2</sup> hybridized heteroatoms contribute 1 electron hybridization is worked out by
        /// counting the number of bonds with order 2. Therefore sp<sup>2</sup> hybridization is assumed 
        /// if there is one bond of order 2. Otherwise sp<sup>3</sup> hybridization is assumed.
        /// 
        /// </summary>
        /// <param name="ring">     the ring to test
        /// </param>
        /// <param name="atomContainer"> the AtomContainer the ring is in
        /// </param>
        /// <returns>           true if the ring is aromatic false otherwise.
        /// </returns>
        protected internal static bool isAromatic(IRing ring, IAtomContainer atomContainer)
        {

            IAtom[] ringAtoms = ring.Atoms;
            int eCount = 0;
            IBond[] conectedBonds;
            int numDoubleBond = 0;
            bool allConnectedBondsSingle;

            for (int i = 0; i < ringAtoms.Length; i++)
            {
                IAtom atom = ringAtoms[i];
                numDoubleBond = 0;
                allConnectedBondsSingle = true;
                conectedBonds = atomContainer.getConnectedBonds(atom);
                for (int j = 0; j < conectedBonds.Length; j++)
                {
                    IBond bond = conectedBonds[j];
                    if (bond.Order == 2 && ring.contains(bond))
                    {
                        numDoubleBond++;
                    }
                    // Count the Electron if bond order = 1.5
                    else if (bond.Order == 1.5 && ring.contains(bond))
                    {
                        numDoubleBond = 1;
                    }

                    if (bond.Order != 1)
                    {
                        allConnectedBondsSingle = false;
                    }
                }
                if (numDoubleBond == 1)
                {
                    //C or heteroatoms both contibute 1 electron in sp2 hybridized form
                    eCount++;
                }
                else if (!atom.Symbol.Equals("C"))
                {
                    //Heteroatom probably in sp3 hybrid therefore 2 electrons contributed.
                    eCount = eCount + 2;
                }
                else if (atom.getFlag(CDKConstants.ISAROMATIC))
                {
                    eCount++;
                }
                else if (allConnectedBondsSingle && atom.Symbol.Equals("C") && atom.getFormalCharge() == 1.0)
                {
                    // This is for tropylium and kinds. 
                    // Dependence on hybridisation would be better:
                    // empty p-orbital is needed
                    continue;
                }
                else
                {
                    return false;
                }
            }
            if (eCount - 2 != 0 && (eCount - 2) % 4 == 0)
            {
                return true;
            }
            return false;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// ������Ļ��ֽ���߶μ���
        /// </summary>
        /// <param name="pRing">����Ļ�����IRing</param>
        /// <param name="strFeatureCode">�ߵ�Ҫ�ش���</param>
        /// <param name="strRepresentation">ͼ�α��ֱ���</param>
        /// <param name="nEntityID">��ʵ������</param>
        /// <returns>VCT�߶ζ��󼯺�</returns>
        private List<LineNodeEx> GetLineNodeExsByRing(IRing pRing, string strFeatureCode, string strRepresentation, int nEntityID)
        {
            try
            {
                List<LineNodeEx> arrLineNodeEx = new List<LineNodeEx>();

                ///��ȡÿ�����е��߶μ���
                IPointCollection pIPointCollection = pRing as IPointCollection;

                for (int i = 0; i < pIPointCollection.PointCount; i++)
                {
                    if (i > 0)
                    {
                        LineNodeEx pLineNodeEx = new LineNodeEx();//����VCT�߶ζ���
                        pLineNodeEx.SegmentNodes = new SegmentNodes();//�����߶ζ�Ӧ�ĵ㼯��
                        pLineNodeEx.FeatureCode = strFeatureCode;//����Ҫ�ش���
                        pLineNodeEx.Representation = strRepresentation;
                        pLineNodeEx.PolygonID = nEntityID;///������ı�ʶ��

                        BrokenLineNode pBrokenLinNode = new BrokenLineNode();//��������
                        pBrokenLinNode.PointInfoNodes = new PointInfoNodes();

                        IPoint pIPoint1 = pIPointCollection.get_Point(i - 1);
                        IPoint pIPoint2 = pIPointCollection.get_Point(i);
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pIPoint1.X, pIPoint1.Y));
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pIPoint2.X, pIPoint2.Y));
                        pLineNodeEx.SegmentNodes.Add(pBrokenLinNode);

                        arrLineNodeEx.Add(pLineNodeEx);
                    }
                }

                return arrLineNodeEx;
                /*
                ///��������еĸ����߶�
                for (int i = 0; i < pExRingSegmentCollection.SegmentCount; i++)
                {
                    ISegment pSegment = pExRingSegmentCollection.get_Segment(i);

                    LineNodeEx pLineNodeEx = new LineNodeEx();//����VCT�߶ζ���
                    pLineNodeEx.SegmentNodes = new SegmentNodes();//�����߶ζ�Ӧ�ĵ㼯��
                    //pLineNodeEx.IsReverse = bReverse;//���÷���
                    pLineNodeEx.FeatureCode = strFeatureCode;//����Ҫ�ش���
                    pLineNodeEx.Representation = strRepresentation;
                    pLineNodeEx.PolygonID = nEntityID;///������ı�ʶ��

                    BrokenLineNode pBrokenLinNode = new BrokenLineNode();//��������
                    pBrokenLinNode.PointInfoNodes = new PointInfoNodes();

                    ILine pLine = pSegment as ILine;
                    if (pLine != null)
                    {
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pLine.FromPoint.X, pLine.FromPoint.Y));
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pLine.ToPoint.X, pLine.ToPoint.Y));
                    }

                    //////����Ƿ���
                    ////if (bReverse)
                    ////{
                    ////    PointInfoNodes tempPointInfoNodes = new PointInfoNodes();
                    ////    foreach (PointInfoNode item in pBrokenLinNode.PointInfoNodes)
                    ////    {
                    ////        tempPointInfoNodes.Add(item);
                    ////    }
                    ////    pBrokenLinNode.PointInfoNodes = tempPointInfoNodes;
                    ////}
                    pLineNodeEx.SegmentNodes.Add(pBrokenLinNode);
                    pListLine.Add(pLineNodeEx);
                }

                return pListLine;*/
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
Ejemplo n.º 35
0
 private void getBondsInRing(IAtomContainer mol, IRing ring, int[] bonds)
 {
     for (int i = 0; i < ring.getBondCount(); i++)
     {
         int m = mol.getBondNumber(ring.getBondAt(i));
         bonds[m] = 1;
     }
 }