Пример #1
0
        public override void UpdateGeometry()
        {
            GeometryList.Clear();
            GeometryList.Add(Name + "Up", new Geometry2D(Name, "StandardMenu", PX * ScreenWidth, PY * ScreenHeight, SX * ScreenWidth, SY * ScreenHeight, TX, TY, TSX, TSY, Z));
            GeometryList.Add(Name + "Down", new Geometry2D(Name, "StandardMenu", PX * ScreenWidth, PY * ScreenHeight, SX * ScreenWidth, SY * ScreenHeight, TX, TY, TSX, TSY, Z));

            float Buffer    = SX * 0.1f;
            float LetterGap = 0.75f;

            LetterGap = Text.Length > 1 ? LetterGap : 1;
            float DX = (SX - Buffer) / Text.Length;
            float OY = (SY - DX) / 2.0f;

            float DY = DX;

            DY = DY > SY / 4.0f ? DY : SY / 4.0f;

            for (int i = 0; i < Text.Length; i++)
            {
                int Index = Text[i] - 1;

                string Bit = Text[i].ToString();

                /*
                 * if ( Int32.TryParse(Bit, out int n))
                 * {
                 *  Index = 64 + Int32.Parse(Bit);
                 * }
                 */

                GeometryList.Add(Name + i, new Geometry2D(Name + i, "StandardText", (PX + Buffer / 2) * ScreenWidth + (DX * LetterGap * i * ScreenWidth), (PY + OY) * ScreenHeight, DX * (2.0f - LetterGap) * ScreenWidth, DY * ScreenHeight, 0.0625f * (Index % 16), 0.0625f * (Index / 16), 0.0625f, 0.0625f, Z + 0.1f));
            }
            NeedsNodeUpdate = true;
        }
Пример #2
0
        public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace)
        {
            if ((this.layerIndex < 1) || (this.layerIndex >= historyWorkspace.Document.Layers.Count))
            {
                object[] objArray1 = new object[] { "layerIndex must be greater than or equal to 1, and a valid layer index. layerIndex=", this.layerIndex, ", allowableRange=[0,", historyWorkspace.Document.Layers.Count, ")" };
                throw new ArgumentException(string.Concat(objArray1));
            }
            int          layerIndex = this.layerIndex - 1;
            RectInt32    rect       = historyWorkspace.Document.Bounds();
            GeometryList list       = new GeometryList();

            list.AddRect(rect);
            RectInt32[]          changedRegion = list.EnumerateInteriorScans().ToArrayEx <RectInt32>();
            BitmapHistoryMemento memento       = new BitmapHistoryMemento(null, null, historyWorkspace, layerIndex, changedRegion);
            BitmapLayer          layer         = (BitmapLayer)historyWorkspace.Document.Layers[this.layerIndex];
            BitmapLayer          layer2        = (BitmapLayer)historyWorkspace.Document.Layers[layerIndex];
            RenderArgs           args          = new RenderArgs(layer2.Surface);

            base.EnterCriticalRegion();
            foreach (RectInt32 num4 in changedRegion)
            {
                layer.Render(args, num4.ToGdipRectangle());
            }
            layer2.Invalidate();
            args.Dispose();
            args = null;
            list = null;
            HistoryMemento memento2 = new DeleteLayerFunction(this.layerIndex).Execute(historyWorkspace);

            return(new CompoundHistoryMemento(StaticName, StaticImage, new HistoryMemento[] { memento, memento2 }));
        }
Пример #3
0
        protected virtual Geometry Transform(GeometryCollection geom, Geometry parent)
        {
            GeometryList transGeomList = new GeometryList();

            for (int i = 0; i < geom.NumGeometries; i++)
            {
                Geometry transformGeom = Transform(geom[i]);
                if (transformGeom == null)
                {
                    continue;
                }
                if (pruneEmptyGeometry && transformGeom.IsEmpty)
                {
                    continue;
                }

                transGeomList.Add(transformGeom);
            }

            if (preserveGeometryCollectionType)
            {
                return(geomFactory.CreateGeometryCollection(transGeomList.ToArray()));
            }

            return(geomFactory.BuildGeometry(transGeomList));
        }
 /// <summary>
 /// Validates the specified geometry or returns <c>null</c> for invalid geometries.
 /// </summary>
 /// <remarks>
 /// The algorithm fixes the issues produced by the application of <see cref="PrecisionModel"/>.
 /// </remarks>
 /// <param name="geometry">The geometry.</param>
 /// <returns>A valid geometry or <c>null</c>.</returns>
 public static IGeometry Validate(IGeometry geometry)
 {
     if (geometry is IPolygon)
     {
         return(Validate(geometry as IPolygon));
     }
     else if (geometry is IGeometryCollection <IGeometry> )
     {
         IGeometryFactory factory = geometry.Factory;
         var collection           = new GeometryList <IGeometry>(factory, null);
         foreach (IGeometry subGeometry in (IGeometryCollection <IGeometry>)geometry)
         {
             try
             {
                 collection.Add(Validate(subGeometry));
             }
             catch (ArgumentNullException) { }  // null value cannot be added to the collection
         }
         if (collection.Count == 0)
         {
             collection = null;
         }
         return(collection);
     }
     else
     {
         return(geometry.IsValid ? geometry : null);
     }
 }
Пример #5
0
        /// <summary>
        /// Perform the polygonization, if it has not already been carried out.
        /// </summary>
        public void Polygonize()
        {
            // check if already computed
            if (polyList != null)
            {
                return;
            }

//?            polyList = new ArrayList();

            m_arrDangles  = graph.DeleteDangles();
            m_arrCutEdges = graph.DeleteCutEdges();
            ArrayList edgeRingList = graph.EdgeRings;

            ArrayList validEdgeRingList = new ArrayList();

            m_arrInvalidRingLines = new GeometryList();
            FindValidRings(edgeRingList, validEdgeRingList, m_arrInvalidRingLines);

            FindShellsAndHoles(validEdgeRingList);
            AssignHolesToShells(holeList, shellList);

            polyList = new GeometryList();

            for (IEnumerator i = shellList.GetEnumerator(); i.MoveNext();)
            {
                EdgeRing er = (EdgeRing)i.Current;

                polyList.Add(er.Polygon);
            }
        }
Пример #6
0
 /// <summary>
 /// Create a polygonizer with the same <see cref="GeometryFactory"/> as
 /// the input geometries.
 /// </summary>
 public Polygonizer()
 {
     lineStringAdder       = new LineStringAdder(this);
     m_arrDangles          = new ArrayList();
     m_arrCutEdges         = new ArrayList();
     m_arrInvalidRingLines = new GeometryList();
 }
        public QuadtreeNestedRingTester(GeometryGraph graph)
        {
            rings    = new GeometryList();
            totalEnv = new Envelope();

            this.graph = graph;
        }
Пример #8
0
        /// <summary>
        /// Builds a geometry (<see cref="LineString"/> or <see cref="MultiLineString"/> )
        /// representing the sequence.
        ///
        /// </summary>
        /// <param name="sequences">a List of Lists of DirectedEdges with
        /// LineMergeEdges as their parent edges.
        /// </param>
        /// <returns> the sequenced geometry, or <code>null</code> if no sequence exists
        /// </returns>
        private Geometry BuildSequencedGeometry(IList sequences)
        {
            GeometryList lines = new GeometryList();

            for (IEnumerator i1 = sequences.GetEnumerator(); i1.MoveNext();)
            {
                IList seq = (IList)i1.Current;

                for (IEnumerator i2 = seq.GetEnumerator(); i2.MoveNext();)
                {
                    DirectedEdge  de   = (DirectedEdge)i2.Current;
                    LineMergeEdge e    = (LineMergeEdge)de.Edge;
                    LineString    line = e.Line;

                    LineString lineToAdd = line;
                    if (!de.EdgeDirection && !line.IsClosed)
                    {
                        lineToAdd = Reverse(line);
                    }

                    lines.Add(lineToAdd);
                }
            }

            if (lines.Count == 0)
            {
                return(factory.CreateMultiLineString(new LineString[0]));
            }

            return(factory.BuildGeometry(lines));
        }
Пример #9
0
        private Polygon EditPolygon(Polygon polygon, IGeometryEdit operation)
        {
            Polygon newPolygon = (Polygon)operation.Edit(polygon, m_objFactory);

            if (newPolygon.IsEmpty)
            {
                //RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
                return(newPolygon);
            }

            LinearRing shell = (LinearRing)Edit(newPolygon.ExteriorRing, operation);

            if (shell.IsEmpty)
            {
                //RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
                return(m_objFactory.CreatePolygon(null, null));
            }

            GeometryList holes = new GeometryList();

            for (int i = 0; i < newPolygon.NumInteriorRings; i++)
            {
                LinearRing hole = (LinearRing)Edit(newPolygon.InteriorRing(i), operation);

                if (hole.IsEmpty)
                {
                    continue;
                }

                holes.Add(hole);
            }

            return(m_objFactory.CreatePolygon(shell, holes.ToLinearRingArray()));
        }
Пример #10
0
        /// <summary>
        /// Creates a MultiLineString using the next token in the stream.
        /// </summary>
        /// <param name="tokenizer">
        /// Tokenizer over a stream of text in Well-known Text
        /// format. The next tokens must form a &lt;MultiLineString Text&gt;.
        /// </param>
        /// <returns>
        /// A MultiLineString specified by the next token in the stream.
        /// </returns>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        /// <exception cref="GeometryIOException">
        /// If an unexpected token was encountered.
        /// </exception>
        private MultiLineString ReadMultiLineString(StreamTokenizer tokenizer)
        {
            string nextToken = GetNextEmptyOrOpener(tokenizer);

            if (nextToken.Equals(WktEmpty))
            {
                return(m_objFactory.CreateMultiLineString(
                           new LineString[] {}));
            }

            GeometryList lineStrings = new GeometryList();
            LineString   lineString  = ReadLineString(tokenizer);

            lineStrings.Add(lineString);
            nextToken = GetNextCloserOrComma(tokenizer);
            while (nextToken.Equals(TokenComma))
            {
                lineString = ReadLineString(tokenizer);
                lineStrings.Add(lineString);
                nextToken = GetNextCloserOrComma(tokenizer);
            }

            return(m_objFactory.CreateMultiLineString(
                       lineStrings.ToLineStringArray()));
        }
Пример #11
0
        /// <summary>
        /// Creates a Polygon using the next token in the stream.
        /// </summary>
        /// <param name="tokenizer">
        /// Tokenizer over a stream of text in Well-known Text
        /// format. The next tokens must form a &lt;Polygon Text&gt;.
        /// </param>
        /// <returns>
        /// A Polygon specified by the next token in the stream.
        /// </returns>
        /// <exception cref="GeometryIOException">
        /// If the coordinates used to create the Polygon shell and holes do
        /// not form closed linestrings, or if an unexpected token was
        /// encountered.
        /// </exception>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        private Polygon ReadPolygon(StreamTokenizer tokenizer)
        {
            string nextToken = GetNextEmptyOrOpener(tokenizer);

            if (nextToken.Equals(WktEmpty))
            {
                LinearRing objRing = m_objFactory.CreateLinearRing(new Coordinate[] {});

                return(m_objFactory.CreatePolygon(objRing, new LinearRing[] {}));
            }

            GeometryList holes = new GeometryList();
            LinearRing   shell = ReadLinearRing(tokenizer);

            nextToken = GetNextCloserOrComma(tokenizer);

            while (nextToken.Equals(TokenComma))
            {
                LinearRing hole = ReadLinearRing(tokenizer);
                holes.Add(hole);
                nextToken = GetNextCloserOrComma(tokenizer);
            }

            return(m_objFactory.CreatePolygon(shell,
                                              holes.ToLinearRingArray()));
        }
Пример #12
0
        private static bool AreTheSameGeometry(GeometryList geometry1, PointDouble[] polygon2)
        {
            if (geometry1.PolygonCount != 1)
            {
                return(false);
            }
            if (geometry1.TotalPointCount != polygon2.Length)
            {
                return(false);
            }
            RectDouble num = polygon2.Bounds();

            if (geometry1.Bounds != num)
            {
                return(false);
            }
            IList <PointDouble[]> polygonList = geometry1.GetPolygonList();

            if (polygonList.Count != 1)
            {
                throw new InternalErrorException();
            }
            PointDouble[] numArray = polygonList[0];
            for (int i = 0; i < numArray.Length; i++)
            {
                if (numArray[i] != polygon2[i])
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #13
0
        public void SetMapSize()
        {
            Layer TopLayer = GetTopLayer();

            if (TopLayer != null)
            {
                for (int i = 0; i < GeometryList.Count(); i++)
                {
                    if (!(GeometryList.ElementAt(i).Key == (Name + "Selector")))
                    {
                        GeometryList.ElementAt(i).Value.TX = 1.0f / Scale * AX;
                        GeometryList.ElementAt(i).Value.TY = 1.0f / Scale * AY;

                        GeometryList.ElementAt(i).Value.TSX = 1.0f / Scale;
                        GeometryList.ElementAt(i).Value.TSY = 1.0f / Scale;

                        //GeometryList.ElementAt(i).Value.TX = (float)1.0 / TopLayer.TileSizeX / Scale * AX;
                    }
                    else
                    {
                    }

                    //GeometryList.ElementAt(i).Value.PX = 0;
                    //GeometryList.ElementAt(i).Value.PY = 0;
                    //GeometryList.ElementAt(i).Value.SX = SX * ScreenWidth * Scale;
                    //GeometryList.ElementAt(i).Value.SY = SY * ScreenHeight * Scale;

                    //GeometryList.ElementAt(i).Value.TX = AX * TX / Scale;
                    //GeometryList.ElementAt(i).Value.TY = AY * TY / Scale;
                }
            }
        }
Пример #14
0
        /// <summary>
        /// Creates a MultiPolygon using the next token in the stream.
        /// </summary>
        /// <param name="tokenizer">
        /// Tokenizer over a stream of text in Well-known Text
        /// format. The next tokens must form a &lt;MultiPolygon Text&gt;.
        /// </param>
        /// <returns>
        /// A MultiPolygon specified by the next token in the stream, or if
        /// the coordinates used to create the Polygon shells and holes do
        /// not form closed linestrings.
        /// </returns>
        /// <exception cref=IOException"">
        /// If an I/O error occurs.
        /// </exception>
        /// <exception cref="GeometryIOException">
        /// if an unexpected token was encountered.
        /// </exception>
        private MultiPolygon ReadMultiPolygon(StreamTokenizer tokenizer)
        {
            string nextToken = GetNextEmptyOrOpener(tokenizer);

            if (nextToken.Equals(WktEmpty))
            {
                return(m_objFactory.CreateMultiPolygon(new Polygon[] {}));
            }

            GeometryList polygons = new GeometryList();
            Polygon      polygon  = ReadPolygon(tokenizer);

            polygons.Add(polygon);
            nextToken = GetNextCloserOrComma(tokenizer);
            while (nextToken.Equals(TokenComma))
            {
                polygon = ReadPolygon(tokenizer);

                polygons.Add(polygon);
                nextToken = GetNextCloserOrComma(tokenizer);
            }

            return(m_objFactory.CreateMultiPolygon(
                       polygons.ToPolygonArray()));
        }
Пример #15
0
 public void ToggleLayer(string LayerName)
 {
     if (GeometryList.ContainsKey(LayerName))
     {
         GeometryList[LayerName].HasCull = !GeometryList[LayerName].HasCull;
     }
 }
Пример #16
0
        /// <summary>
        /// Replace the geometries in the scene with the ones contained in the given Assimp scene.
        /// </summary>
        /// <param name="scene"></param>
        public void ReplaceGeometries(Assimp.Scene scene)
        {
            var skinToBoneMatrices = ComputeSkinToBoneMatrices(scene);

            GeometryList.Clear();
            Atomics.Clear();

            for (var i = 0; i < scene.Meshes.Count; i++)
            {
                var assimpMesh = scene.Meshes[i];

                var rootNode = FindMeshRootNode(scene.RootNode, i) ?? scene.RootNode;
                TransformMeshVertices(assimpMesh, rootNode);

                var geometryNode = new RwGeometryNode(this, assimpMesh, scene.Materials[assimpMesh.MaterialIndex], FrameList, skinToBoneMatrices, out bool singleWeight);
                GeometryList.Add(geometryNode);

                var atomicNode = new RwAtomicNode(this, 0, i, 5);
                if (singleWeight)
                {
                    if (assimpMesh.Bones.Count != 0)
                    {
                        atomicNode.FrameIndex = FrameList.GetFrameIndexByName(assimpMesh.Bones[0].Name);
                    }
                    else if (rootNode != null)
                    {
                        atomicNode.FrameIndex = FrameList.GetFrameIndexByName(rootNode.Name);
                    }
                }

                Atomics.Add(atomicNode);
            }

            mStructNode = new RwClumpStructNode(this);
        }
Пример #17
0
        public override void UpdateGeometry()
        {
            GeometryList.Clear();
            GeometryList.Add(Name + "Background", new Geometry2D(Name + "StandardMenu", "StandardMenu", PX * ScreenWidth, PY * ScreenHeight, SX * ScreenWidth, SY * ScreenHeight, TX, TY, TSX, TSY, Z));

            if (Lines.Count > 0)
            {
                float LetterGap = 0.5f;
                float DY        = SY / MaxLineCount;
                float DX        = DY;

                for (int i = CurrentIndex; i < CurrentIndex + MaxLineCount && i < Lines.Count; i++)
                {
                    string Line = Lines[i];


                    float AllowedLength = SX / (DX * LetterGap);

                    for (int j = 0; j < AllowedLength && j < Line.Length; j++)
                    {
                        //get text texcoord
                        int Index = Line[j] - 1;
                        GeometryList.Add(Name + i + "-" + j, new Geometry2D(Name + i + "-" + j, "StandardText", (PX + DX * LetterGap * j) * ScreenWidth, (PY + DY * i) * ScreenHeight, DX * ScreenWidth, DY * ScreenHeight, 0.0625f * (Index % 16), 0.0625f * (Index / 16), 0.0625f, 0.0625f, Z + 0.1f));

                        //GeometryList.Add(Name + i, new Geometry2D(Name + i, "StandardText", (PX + DX * j + Buffer / 2) * ScreenWidth + (DX * i * ScreenWidth), (PY + OY) * ScreenHeight, DX * (2.0f - LetterGap) * ScreenWidth, DY * ScreenHeight, 0.0625f * (Index % 16), 0.0625f * (Index / 16), 0.0625f, 0.0625f, Z + 0.1f));
                    }
                }

                GeometryList.Add(Name + "HighLight", new Geometry2D(Name + "HighLight", "StandardMenu", PX * ScreenWidth, (PY + (SY / MaxLineCount * CurrentLocalIndex)) * ScreenHeight, SX * ScreenWidth, SY / MaxLineCount * ScreenHeight, 0.75f, 0, 0.1875f, 0.0625f, Z));
            }
            NeedsNodeUpdate = true;
        }
Пример #18
0
 public Geometry2D GetGeometry(string Name)
 {
     if (GeometryList.ContainsKey(Name))
     {
         return(GeometryList[Name]);
     }
     return(null);
 }
Пример #19
0
 public override void GenerateGeometry()
 {
     if (GeometryList.Count > 0)
     {
         GeometryList.Clear();
     }
     GeometryList.Add(Name, new Geometry2D(Name, TextureName, PX * ScreenWidth, PY * ScreenHeight, SX * ScreenWidth, SY * ScreenHeight, 0, 0, 1.0f, 1.0f, Z));
 }
Пример #20
0
 public override void GenerateGeometry()
 {
     if (GeometryList.Count > 0)
     {
         GeometryList.Clear();
     }
     UpdateGeometry();
 }
Пример #21
0
 public virtual void ToggleVisibility(bool IsVisible)
 {
     IsActive = IsVisible;
     for (int i = 0; i < GeometryList.Count; i++)
     {
         GeometryList.ElementAt(i).Value.HasCull = !IsVisible;
     }
 }
Пример #22
0
 public virtual void GenerateGeometry()
 {
     if (GeometryList.Count > 0)
     {
         GeometryList.Clear();
     }
     GeometryList.Add(Name, new Geometry2D(Name, TextureName, PX * ScreenWidth, PY * ScreenHeight, SX * ScreenWidth, SY * ScreenHeight, TX, TY, TSX, TSY, Z));
 }
Пример #23
0
 public void AddLayer(string LayerName, string LayerTexture)
 {
     //geometry
     if (GeometryList.ContainsKey(LayerName))
     {
         GeometryList.Remove(LayerName);
     }
     GeometryList.Add(LayerName, new Geometry2D(LayerName, LayerTexture, PX * ScreenWidth, PY * ScreenHeight, SX * ScreenWidth, SY * ScreenHeight, TX, TY, TSX, TSY, Z));
 }
Пример #24
0
        private static Surface CreateThumbnail(MaskedSurface maskedSurface)
        {
            int          thumbSideLength  = UIUtil.ScaleWidth(120);
            Surface      surfaceReadOnly  = maskedSurface.SurfaceReadOnly;
            GeometryList geometryMaskCopy = maskedSurface.GetGeometryMaskCopy();
            RectInt32    maskBounds       = maskedSurface.GeometryMaskBounds.Int32Bound;

            return(CreateThumbnail(surfaceReadOnly, geometryMaskCopy, maskBounds, thumbSideLength));
        }
Пример #25
0
        /// <summary>
        /// Adds a hole to the polygon formed by this ring.
        /// </summary>
        /// <param name="hole">the {@link LinearRing} forming the hole.
        /// </param>
        public void AddHole(LinearRing hole)
        {
            if (holes == null)
            {
                holes = new GeometryList();
            }

            holes.Add(hole);
        }
Пример #26
0
        public override void Init(string[] Data, int Width, int Height, Dictionary <string, Effect> Shaders)
        {
            base.Init(Data, Width, Height, Shaders);
            PickerTexture = Data[11];

            ScreenWidth  = Width;
            ScreenHeight = Height;

            GeometryList.Add(Name + "Selector", new Geometry2D(Name, "StandardMenu", PX * ScreenWidth, PY * ScreenHeight, 0, 0, TX, TY, TSX, TSY, Z + 0.25f));
        }
Пример #27
0
        public LineBuilder(OverlayOp op, GeometryFactory geometryFactory,
                           PointLocator ptLocator)
        {
            lineEdgesList  = new ArrayList();
            resultLineList = new GeometryList();

            this.op = op;
            this.geometryFactory = geometryFactory;
            this.ptLocator       = ptLocator;
        }
Пример #28
0
        private static BitVector2D PixelatedGeometryListToBitVector2D(GeometryList geometry, int width, int height, CancellationToken cancellationToken)
        {
            BitVector2D vectord = new BitVector2D(width, height);

            foreach (RectInt32 num in geometry.EnumerateInteriorScans())
            {
                cancellationToken.ThrowIfCancellationRequested();
                vectord.Set(num, true);
            }
            return(vectord);
        }
Пример #29
0
        public void AddLayer(string LayerName, string LayerTexture, int TileX, int TileY, float TileZ, int TileSizeX, int TileSizeY, int PixelScale)
        {
            //geometry
            if (GeometryList.ContainsKey(LayerName))
            {
                GeometryList.Remove(LayerName);
            }
            GeometryList.Add(LayerName, new Geometry2D(LayerName, LayerTexture, PX * ScreenWidth, PY * ScreenHeight, SX * ScreenWidth, SY * ScreenHeight, TX, TY, TSX, TSY, Z + TileZ));

            Layers.Add(new Layer(TileX, TileY, TileZ, TileSizeX, TileSizeY, LayerName, PixelScale));
            Layers = Layers.OrderBy(x => x.TileZ).ToList();
        }
Пример #30
0
 public void RemoveLayer(string LayerName)
 {
     for (int i = 0; i < Layers.Count; i++)
     {
         if (Layers[i].Name == LayerName)
         {
             Layers.RemoveAt(i);
             break;
         }
     }
     GeometryList.Remove(LayerName);
 }
Пример #31
0
        public override Value Evaluate(FSharpList<Value> args)
        {
            GeometryList geometry = new GeometryList();

            System.String file_name = ((Value.String)args[0]).Item;
            var input = (args[1] as Value.List).Item;

            foreach (Value v in input)
            {
                Geometry g = ((Value.Container)v).Item as Geometry;
                geometry.Add(g);
            }

            ASMExporter.export_geometry(file_name, geometry);

            return args[1];
        }