Пример #1
0
        public Int32Collection GetFilteredRows(DataTable i_Table, Int32Collection i_InnerRows)
        {
            i_InnerRows = this.Filter.GetFilteredRows(i_Table, i_InnerRows);

            Int32Collection i_FilterRows = new Int32Collection();

            foreach (int row in i_InnerRows)
            {
                if (row < 0 || row >= i_Table.Rows.Count)
                {
                    continue;
                }

                DataRow dataRow = i_Table.Rows[row];

                foreach (SectionFilter m_Section in this.SectionFilters)
                {
                    if (m_Section.Filter.CheckResultWithBracket(dataRow))       //Modified at 2009-2-16 16:38:31@Scott
                    {
                        if (m_Section.Filter.PlayAfter && i_Table.Rows.Count > row + 1)
                        {
                            i_FilterRows.Add(row + 1);
                        }
                        else
                        {
                            i_FilterRows.Add(row);
                        }
                    }
                }
            }

            return(i_FilterRows);
        }
        /// <summary>
        /// Converts <paramref name="obj"/> to a <see cref="MeshGeometry3D"/>
        /// </summary>
        /// <param name="obj">The <see cref="OBJFile"/> to convert to a <see cref="MeshGeometry3D"/></param>
        /// <returns>A <see cref="MeshGeometry3D"/> converted from <paramref name="obj"/></returns>
        /// <remarks>Normals do not get converted</remarks>
        public static MeshGeometry3D ConvertOBJ(OBJFile obj)
        {
            MeshGeometry3D mesh = new MeshGeometry3D();

            Int32Collection indices = new Int32Collection();

            foreach (OBJFace face in obj.Faces)
            {
                indices.Add((int)face.VertexIndices[0]);
                indices.Add((int)face.VertexIndices[1]);
                indices.Add((int)face.VertexIndices[2]);
            }

            Point3DCollection vertices = new Point3DCollection();

            foreach (Vector3 vertex in obj.Vertices)
            {
                vertices.Add(new Point3D(vertex.X, vertex.Y, vertex.Z));
            }

            PointCollection uvs = new PointCollection();

            foreach (Vector2 uv in obj.UVs)
            {
                uvs.Add(new Point(uv.X, uv.Y));
            }

            mesh.TextureCoordinates = uvs;
            mesh.TriangleIndices    = indices;
            mesh.Positions          = vertices;

            return(mesh);
        }
Пример #3
0
//		public bool CheckOldResult(DataRow row)	//old check result method
//		{
//			try
//			{
//				//12-17-2007@Scott
//				BoolStack stack = new BoolStack();
//
//				this.InnerList.Reverse();
//
//				foreach(DBCondition condition in this)
//				{
//					bool bResult = condition.CheckResult(row);
//
//					BoolResult br = new BoolResult(bResult,condition.Bracket,condition.FollowedOperand);
//
//					stack.Push(br);
//				}
//				BoolResult result = stack.GetResult();
//
//				this.InnerList.Reverse();
//
//				return result.Result;
//			}
//			catch(Exception ex)
//			{
//				System.Diagnostics.Debug.WriteLine("Check filter result error. Message:"+ex.Message);
//
//				return false;
//			}
//		}

        //06-04-2008@Scott
        public Int32Collection GetFilteredRows(System.Data.DataTable table, Webb.Collections.Int32Collection baseRows)
        {
            if (this.InnerList.Count == 0 && !this.PlayAfter)
            {
                return(baseRows);
            }

            Int32Collection filteredRows = new Int32Collection();

            foreach (int row in baseRows)
            {
                if (table.Rows.Count <= row)
                {
                    continue;
                }

                //if(this.CheckResult(table.Rows[row],0,this.Count - 1))	//Modified at 2009-2-13 13:40:23@Scott
                if (this.CheckResultWithBracket(table.Rows[row]))                       //Modified at 2009-2-16 16:38:31@Scott
                {
                    if (this.PlayAfter && table.Rows.Count > row + 1)
                    {
                        filteredRows.Add(row + 1);
                    }
                    else
                    {
                        filteredRows.Add(row);
                    }
                }
            }

            return(filteredRows);
        }
Пример #4
0
    static int Main()
    {
        Int32Collection src  = new Int32Collection();
        Int32Collection dest = new Int32Collection();

        src.Add(5);
        src.Add(7);
        dest.Add(4);

        ReplaceContentsWith <Int32Collection> (src, dest);

        if (dest.Count != 2)
        {
            return(1);
        }
        if (dest[0] != 5)
        {
            return(2);
        }
        if (dest[1] != 7)
        {
            return(3);
        }

        return(0);
    }
        /// <summary>
        /// Initializes a 3D mesh to deform every frame
        /// </summary>
        private void InitializeMesh()
        {
            var vertices = this.currentFaceModel.CalculateVerticesForAlignment(this.currentFaceAlignment);

            var triangleIndices = this.currentFaceModel.TriangleIndices;

            var indices = new Int32Collection(triangleIndices.Count);

            for (int i = 0; i < triangleIndices.Count; i += 3)
            {
                uint index01 = triangleIndices[i];
                uint index02 = triangleIndices[i + 1];
                uint index03 = triangleIndices[i + 2];

                indices.Add((int)index03);
                indices.Add((int)index02);
                indices.Add((int)index01);
            }

            this.theGeometry.TriangleIndices    = indices;
            this.theGeometry.Normals            = null;
            this.theGeometry.Positions          = new Point3DCollection();
            this.theGeometry.TextureCoordinates = new PointCollection();

            foreach (var vert in vertices)
            {
                this.theGeometry.Positions.Add(new Point3D(vert.X, vert.Y, -vert.Z));
                this.theGeometry.TextureCoordinates.Add(new Point());
            }
        }
Пример #6
0
        private GeometryModel3D Triangle(double x, double y, double s)
        {
            //define the geometry as a set of points and order the points are connected up
            Point3DCollection corners = new Point3DCollection();

            corners.Add(new Point3D(x, y, 0));
            corners.Add(new Point3D(x, y + s, 0));
            corners.Add(new Point3D(x + s, y + s, 0));
            Int32Collection Triangles = new Int32Collection();

            Triangles.Add(0);
            Triangles.Add(1);
            Triangles.Add(2);

            //After the geometry is defined
            MeshGeometry3D tmesh = new MeshGeometry3D();

            tmesh.Positions       = corners;
            tmesh.TriangleIndices = Triangles;

            //Defines the normal vector
            tmesh.Normals.Add(new Vector3D(0, 0, -1));

            //Puts the geometry together with some material properties
            GeometryModel3D msheet = new GeometryModel3D();

            msheet.Geometry = tmesh;
            return(msheet);
        }
Пример #7
0
        protected override void CalculateGeometry()
        {
            int numberOfSeparators = 4 * _NumberOfSegments + 4;

            _Points          = new Point3DCollection(_NumberOfSegments + 1);
            _TriangleIndices = new Int32Collection((numberOfSeparators + 1) * 3);

            _Points.Add(new Point3D(0, 0, 0));
            for (int divider = 0; divider < numberOfSeparators; divider++)
            {
                double alpha = Math.PI / 2 / (_NumberOfSegments + 1) * divider;
                _Points.Add(new Point3D(_Radius * Math.Cos(alpha), 0, -1 * Math.Sin(alpha)));

                _TriangleIndices.Add(0);
                _TriangleIndices.Add(divider + 1);
                if (divider == numberOfSeparators - 1)
                {
                    _TriangleIndices.Add(1);
                }
                else
                {
                    _TriangleIndices.Add(divider + 2);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Find all edges in the mesh (each edge is only inclued once)
        /// </summary>
        /// <param name="mesh">a mesh</param>
        /// <returns>edge indices (minium index first)</returns>
        public static Int32Collection FindEdges(MeshGeometry3D mesh)
        {
            var edges = new Int32Collection();
            var dict  = new HashSet <ulong>();

            for (int i = 0; i < mesh.TriangleIndices.Count / 3; i++)
            {
                int i0 = i * 3;
                for (int j = 0; j < 3; j++)
                {
                    int   index0   = mesh.TriangleIndices[i0 + j];
                    int   index1   = mesh.TriangleIndices[i0 + (j + 1) % 3];
                    int   minIndex = Math.Min(index0, index1);
                    int   maxIndex = Math.Max(index1, index0);
                    ulong key      = CreateKey((UInt32)minIndex, (UInt32)maxIndex);
                    if (!dict.Contains(key))
                    {
                        edges.Add(minIndex);
                        edges.Add(maxIndex);
                        dict.Add(key);
                    }
                }
            }
            return(edges);
        }
Пример #9
0
        private GeometryModel3D Triangle(double x, double y, double s)
        {
            Point3DCollection corners = new Point3DCollection();

            corners.Add(new Point3D(x, y, 0));
            corners.Add(new Point3D(x, y + s, 0));
            corners.Add(new Point3D(x + s, y + s, 0));
            corners.Add(new Point3D(x + y + s, x + y + s, 0));

            Int32Collection Triangles = new Int32Collection();

            Triangles.Add(0);
            Triangles.Add(1);
            Triangles.Add(2);
            Triangles.Add(3);

            MeshGeometry3D tmesh = new MeshGeometry3D();

            tmesh.Positions       = corners;
            tmesh.TriangleIndices = Triangles;
            tmesh.Normals.Add(new Vector3D(0, 0, -1));

            GeometryModel3D msheet = new GeometryModel3D();

            msheet.Geometry = tmesh;
            msheet.Material = new DiffuseMaterial(new SolidColorBrush(Colors.Red));
            return(msheet);
        }
Пример #10
0
        private static GeometryModel3D GetCmpModel(MeshGroup meshGroup, int meshIndex)
        {
            VMeshData.MeshHeader mesh      = meshGroup.Mesh.Meshes[meshIndex];
            Point3DCollection    positions = new Point3DCollection();
            Int32Collection      indices   = new Int32Collection();
            Vector3DCollection   normals   = new Vector3DCollection();

            // PointCollection texture = new PointCollection();
            int vertexCount = meshGroup.MeshReference.VertexStart + mesh.EndVertex + 1;

            if (meshGroup.Mesh.Vertices.Length < vertexCount)
            {
                return(null);
            }

            for (int i = meshGroup.MeshReference.VertexStart + mesh.StartVertex; i < vertexCount; ++i)
            {
                positions.Add(meshGroup.Mesh.Vertices[i].Position);
                normals.Add(meshGroup.Mesh.Vertices[i].Normal);

                // texture.Add(new Point
                // {
                // X = vMesh.Vertices[i].S,
                // Y = vMesh.Vertices[i].T
                // });
            }

            int triangleCount = (mesh.TriangleStart + mesh.NumRefVertices) / 3;

            if (meshGroup.Mesh.Triangles.Length < triangleCount)
            {
                return(null);
            }

            for (int i = mesh.TriangleStart / 3; i < triangleCount; ++i)
            {
                indices.Add(meshGroup.Mesh.Triangles[i].Vertex1);
                indices.Add(meshGroup.Mesh.Triangles[i].Vertex2);
                indices.Add(meshGroup.Mesh.Triangles[i].Vertex3);
            }

            GeometryModel3D gm = new GeometryModel3D
            {
                Geometry = new MeshGeometry3D
                {
                    Positions       = positions,
                    TriangleIndices = indices,
                    Normals         = normals,

                    // TextureCoordinates = texture
                },
                Material  = SharedMaterials.CmpModel,
                Transform = new MatrixTransform3D(meshGroup.Transform * ConversionMatrix)
            };

            gm.Freeze();
            return(gm);
        }
Пример #11
0
        public static MeshGeometry3D Simplify(MeshGeometry3D mesh, double eps)
        {
            // Find common positions
            var dict = new Dictionary <int, int>(); // map position index to first occurence of same position

            for (int i = 0; i < mesh.Positions.Count; i++)
            {
                for (int j = i + 1; j < mesh.Positions.Count; j++)
                {
                    if (dict.ContainsKey(j))
                    {
                        continue;
                    }

                    double l2 = (mesh.Positions[i] - mesh.Positions[j]).LengthSquared;
                    if (l2 < eps)
                    {
                        dict.Add(j, i);
                    }
                }
            }

            var p  = new Point3DCollection();
            var ti = new Int32Collection();

            // create new positions array
            var newIndex = new Dictionary <int, int>(); // map old index to new index

            for (int i = 0; i < mesh.Positions.Count; i++)
            {
                if (!dict.ContainsKey(i))
                {
                    newIndex.Add(i, p.Count);
                    p.Add(mesh.Positions[i]);
                }
            }

            // Update triangle indices
            for (int i = 0; i < mesh.TriangleIndices.Count; i++)
            {
                int index = mesh.TriangleIndices[i];
                int j;
                if (dict.TryGetValue(index, out j))
                {
                    ti.Add(newIndex[j]);
                }
                else
                {
                    ti.Add(newIndex[index]);
                }
            }

            var result = new MeshGeometry3D();

            result.Positions       = p;
            result.TriangleIndices = ti;
            return(result);
        }
Пример #12
0
        public static MeshGeometry3D CreateCylinder(double radius, double height, int steps)
        {
            var geometry  = new MeshGeometry3D();
            var positions = new Point3DCollection();
            var indicies  = new Int32Collection();
            var normals   = new Vector3DCollection();

            // center
            positions.Add(new Point3D(0, height, 0));
            normals.Add(new Vector3D(0, 1, 0));

            var delta = 360.0 / steps;

            for (int i = 0; i < steps; ++i)
            {
                var rad = Helper.DegreesToRadians * (i * delta);
                var v1  = new Point3D(Math.Sin(rad) * radius, 0, Math.Cos(rad) * radius);
                var v2  = new Point3D(Math.Sin(rad) * radius, height, Math.Cos(rad) * radius);
                var n   = new Vector3D(Math.Sin(rad), 0, Math.Cos(rad));
                positions.Add(v1);
                normals.Add(n);
                positions.Add(v2);
                normals.Add(n);
            }

            // top disc

            for (int i = 0; i < steps; ++i)
            {
                indicies.Add(0);
                int j = i;
                int k = j + 1;
                j %= steps;
                k %= steps;
                indicies.Add((j + 1) * 2);
                indicies.Add((k + 1) * 2);
            }

            // border quads

            for (int i = 0; i < steps; ++i)
            {
                int j = i;
                int k = j + 1;
                j %= steps;
                k %= steps;
                indicies.Add(((j + 1) * 2) - 1);
                indicies.Add(((k + 1) * 2) + 0);
                indicies.Add(((j + 1) * 2) + 0);

                indicies.Add(((k + 1) * 2) - 1);
                indicies.Add(((k + 1) * 2) + 0);
                indicies.Add(((j + 1) * 2) - 1);
            }

            geometry.TriangleIndices = indicies;
            geometry.Positions       = positions;
            geometry.Normals         = normals;
            return(geometry);
        }
Пример #13
0
        /// <summary>
        /// Creates a new mesh where no vertices are shared.
        /// </summary>
        /// <param name="input">
        /// The input mesh.
        /// </param>
        /// <returns>
        /// A new mesh.
        /// </returns>
        public static MeshGeometry3D NoSharedVertices(MeshGeometry3D input)
        {
            var p  = new Point3DCollection();
            var ti = new Int32Collection();
            Vector3DCollection n = null;

            if (input.Normals != null)
            {
                n = new Vector3DCollection();
            }

            PointCollection tc = null;

            if (input.TextureCoordinates != null)
            {
                tc = new PointCollection();
            }

            for (int i = 0; i < input.TriangleIndices.Count; i += 3)
            {
                int i0     = i;
                int i1     = i + 1;
                int i2     = i + 2;
                int index0 = input.TriangleIndices[i0];
                int index1 = input.TriangleIndices[i1];
                int index2 = input.TriangleIndices[i2];
                var p0     = input.Positions[index0];
                var p1     = input.Positions[index1];
                var p2     = input.Positions[index2];
                p.Add(p0);
                p.Add(p1);
                p.Add(p2);
                ti.Add(i0);
                ti.Add(i1);
                ti.Add(i2);
                if (n != null)
                {
                    n.Add(input.Normals[index0]);
                    n.Add(input.Normals[index1]);
                    n.Add(input.Normals[index2]);
                }

                if (tc != null)
                {
                    tc.Add(input.TextureCoordinates[index0]);
                    tc.Add(input.TextureCoordinates[index1]);
                    tc.Add(input.TextureCoordinates[index2]);
                }
            }

            return(new MeshGeometry3D {
                Positions = p, TriangleIndices = ti, Normals = n, TextureCoordinates = tc
            });
        }
Пример #14
0
        public void TruncateRowIdIntoPlayId(DataTable dt, GroupInfo groupInfo)
        {
            if (groupInfo == null || groupInfo.GroupResults == null)
            {
                return;
            }

            foreach (GroupResult groupResult in groupInfo.GroupResults)
            {
                Int32Collection realRowIndicators = new Int32Collection();

                foreach (int recorderIndex in groupResult.RowIndicators)
                {
                    try
                    {
                        int realrowIndicator = Convert.ToInt32(dt.Rows[recorderIndex][0]);

                        realRowIndicators.Add(realrowIndicator);
                    }
                    catch
                    {
                        realRowIndicators.Add(recorderIndex);
                    }
                }

                groupResult.RowIndicators = realRowIndicators;

                foreach (GroupSummary groupSummary in groupResult.Summaries)
                {
                    Int32Collection summaryRows = new Int32Collection();

                    foreach (int recorderIndex in groupResult.RowIndicators)
                    {
                        try
                        {
                            int realrowIndicator = Convert.ToInt32(dt.Rows[recorderIndex][0]);

                            summaryRows.Add(realrowIndicator);
                        }
                        catch
                        {
                            summaryRows.Add(recorderIndex);
                        }
                    }
                    groupSummary.SetRowIndicators(summaryRows);
                }

                foreach (GroupInfo subGroupInfo in groupResult.SubGroupInfos)
                {
                    TruncateRowIdIntoPlayId(dt, subGroupInfo);
                }
            }
        }
Пример #15
0
        public Int32Collection GenerateIndices()
        {
            Int32Collection indices = new Int32Collection();

            for (int i = 0; i < Faces.Count; i++)
            {
                indices.Add(Faces[i].IndexList[0]);
                indices.Add(Faces[i].IndexList[1]);
                indices.Add(Faces[i].IndexList[2]);
            }
            return(indices);
        }
Пример #16
0
        protected override Int32Collection MakeTriangles()
        {
            var finalTriangles = new Int32Collection();

            foreach (var triangle in Triangles[NSubdivisions])
            {
                finalTriangles.Add(triangle.V1);
                finalTriangles.Add(triangle.V2);
                finalTriangles.Add(triangle.V3);
            }

            return(finalTriangles);
        }
        // Token: 0x06002283 RID: 8835 RVA: 0x000AB760 File Offset: 0x000A9960
        private static Int32Collection DeserializeFrom(BinaryReader reader)
        {
            XamlInt32CollectionSerializer.IntegerCollectionType integerCollectionType = (XamlInt32CollectionSerializer.IntegerCollectionType)reader.ReadByte();
            int num = reader.ReadInt32();

            if (num < 0)
            {
                throw new ArgumentException(SR.Get("IntegerCollectionLengthLessThanZero"));
            }
            Int32Collection int32Collection = new Int32Collection(num);

            if (integerCollectionType == XamlInt32CollectionSerializer.IntegerCollectionType.Consecutive)
            {
                int num2 = reader.ReadInt32();
                for (int i = 0; i < num; i++)
                {
                    int32Collection.Add(num2 + i);
                }
            }
            else
            {
                switch (integerCollectionType)
                {
                case XamlInt32CollectionSerializer.IntegerCollectionType.Byte:
                    for (int j = 0; j < num; j++)
                    {
                        int32Collection.Add((int)reader.ReadByte());
                    }
                    break;

                case XamlInt32CollectionSerializer.IntegerCollectionType.UShort:
                    for (int k = 0; k < num; k++)
                    {
                        int32Collection.Add((int)reader.ReadUInt16());
                    }
                    break;

                case XamlInt32CollectionSerializer.IntegerCollectionType.Integer:
                    for (int l = 0; l < num; l++)
                    {
                        int value = reader.ReadInt32();
                        int32Collection.Add(value);
                    }
                    break;

                default:
                    throw new ArgumentException(SR.Get("UnknownIndexType"));
                }
            }
            return(int32Collection);
        }
Пример #18
0
        public static Int32Collection CombineIndexCollection(Int32Collection initialIndices, List <int> addingIndices, int offset)
        {
            var ret = new Int32Collection(initialIndices.Count + addingIndices.Count);

            foreach (var origIndex in initialIndices)
            {
                ret.Add(origIndex);
            }
            foreach (var origIndex in addingIndices)
            {
                ret.Add(origIndex + offset);
            }
            return(ret);
        }
Пример #19
0
        private Int32Collection ReadFaceList()
        {
            int size  = reader.ReadUInt16();
            var faces = new Int32Collection(size * 3);

            for (int i = 0; i < size; i++)
            {
                faces.Add(reader.ReadUInt16());
                faces.Add(reader.ReadUInt16());
                faces.Add(reader.ReadUInt16());
                float flags = reader.ReadUInt16();
            }
            return(faces);
        }
Пример #20
0
        public SubDMeshHandler.MeshGenerationResult GenerateSubDMesh()
        {
            if (this.list_4 == null)
            {
                throw new InvalidOperationException("Can not start SubDMesh handler: no triangles defined.");
            }
            if (this.list_4.Count < 1)
            {
                return(new SubDMeshHandler.MeshGenerationResult());
            }
            Database workingDatabase = HostApplicationServices.WorkingDatabase;
            Editor   arg_3C_0        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            SubDMeshHandler.MeshGenerationResult result;
            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                this.BuildDataStructure(true);
                Point3dCollection point3dCollection = new Point3dCollection();
                for (int i = 0; i < this.list_0.Count; i++)
                {
                    point3dCollection.Add(new Point3d(this.list_0[i].X, this.list_0[i].Y, this.list_0[i].Z));
                }
                Int32Collection int32Collection = new Int32Collection(3 * this.list_4.Count);
                for (int j = 0; j < this.list_4.Count; j++)
                {
                    int32Collection.Add(3);
                    int32Collection.Add(this.list_1[j]);
                    int32Collection.Add(this.list_2[j]);
                    int32Collection.Add(this.list_3[j]);
                }
                SubDMesh subDMesh = new SubDMesh();
                subDMesh.SetDatabaseDefaults();
                subDMesh.SetSubDMesh(point3dCollection, int32Collection, 0);
                subDMesh.SetPropertiesFrom(this.list_4[0].AcDbFace);
                BlockTable       blockTable       = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                blockTableRecord.AppendEntity(subDMesh);
                transaction.AddNewlyCreatedDBObject(subDMesh, true);
                transaction.Commit();
                result = new SubDMeshHandler.MeshGenerationResult
                {
                    objectId_0 = subDMesh.ObjectId,
                    int_0      = this.list_0.Count,
                    int_1      = this.list_4.Count,
                    string_0   = DBManager.GetLayerName(subDMesh.LayerId)
                };
            }
            return(result);
        }
Пример #21
0
        private void GenerateBox(Point3D center, Point3DCollection positions, Int32Collection triangleIndices)
        {
            const int BOX_POINTS_COUNT = 8;

            Contract.Requires(positions != null);
            Contract.Requires(triangleIndices != null);
            Contract.Ensures(positions.Count - Contract.OldValue(positions.Count) == BOX_POINTS_COUNT);
            Contract.Ensures(triangleIndices.Count - Contract.OldValue(triangleIndices.Count) == BOX_TRIANGLE_INDICES.Length);

            double x0 = center.X;
            double y0 = center.Y;
            double z0 = center.Z;

            var baseIndex = positions.Count;

            positions.Add(new Point3D(x0 - PointSize / 2, y0 - PointSize / 2, z0 - PointSize / 2));
            positions.Add(new Point3D(x0 + PointSize / 2, y0 - PointSize / 2, z0 - PointSize / 2));
            positions.Add(new Point3D(x0 - PointSize / 2, y0 + PointSize / 2, z0 - PointSize / 2));
            positions.Add(new Point3D(x0 + PointSize / 2, y0 + PointSize / 2, z0 - PointSize / 2));

            positions.Add(new Point3D(x0 - PointSize / 2, y0 - PointSize / 2, z0 + PointSize / 2));
            positions.Add(new Point3D(x0 + PointSize / 2, y0 - PointSize / 2, z0 + PointSize / 2));
            positions.Add(new Point3D(x0 - PointSize / 2, y0 + PointSize / 2, z0 + PointSize / 2));
            positions.Add(new Point3D(x0 + PointSize / 2, y0 + PointSize / 2, z0 + PointSize / 2));

            for (int i = 0; i < BOX_TRIANGLE_INDICES.Length; ++i)
            {
                triangleIndices.Add(baseIndex + BOX_TRIANGLE_INDICES[i]);
            }
        }
Пример #22
0
    private ModelVisual3D MakeCube()
    {
        Point3D p0, p1, p2, p3, p4, p5, p6, p7;

        int[]             surfaceConnections = { 2, 7, 6, 3, 7, 2,
                                                 0,             5, 4, 1, 5, 0, 2, 4, 6, 0, 4, 2, 5, 3, 1,
                                                 7,             3, 5, 0, 3, 1, 2, 3, 0, 7, 5, 6, 6, 5, 4 };
        MeshGeometry3D[]  meshGeometry3D  = new MeshGeometry3D[6];
        Point3DCollection pointCollection = new Point3DCollection();

        GeometryModel3D[] geometryModel = new GeometryModel3D[6];
        Model3DGroup      model3DGroup  = new Model3DGroup();
        Int32Collection   triangeles;

        //get cube vertex
        p0 = new Point3D(0, 0, 0);
        p1 = new Point3D(0, 0, Depth);
        p2 = new Point3D(0, Height, 0);
        p3 = new Point3D(0, Height, Depth);
        p4 = new Point3D(Width, 0, 0);
        p5 = new Point3D(Width, 0, Depth);
        p6 = new Point3D(Width, Height, 0);
        p7 = new Point3D(Width, Height, Depth);

        pointCollection.Add(p0);
        pointCollection.Add(p1);
        pointCollection.Add(p2);
        pointCollection.Add(p3);
        pointCollection.Add(p4);
        pointCollection.Add(p5);
        pointCollection.Add(p6);
        pointCollection.Add(p7);
        //Each cube side has it's own geometry
        for (int i = 0; i < 6; i++)
        {
            meshGeometry3D[i]           = new MeshGeometry3D();
            meshGeometry3D[i].Positions = pointCollection;
            geometryModel[i]            = new GeometryModel3D();
            triangeles = new Int32Collection();
            for (int j = 0; j < 6; j++)
            {
                triangeles.Add(surfaceConnections[i * 6 + j]);
            }
            meshGeometry3D[i].TriangleIndices = triangeles;
            geometryModel[i].Geometry         = meshGeometry3D[i];
            model3DGroup.Children.Add(geometryModel[i]);
        }
        Cube3D.Content           = model3DGroup;
        Transform                = new Transform3DGroup();
        this.ScaleTransform      = new ScaleTransform3D(1, 1, 1);
        this.RotateTransform     = new RotateTransform3D();
        RotateTransform.Rotation = new AxisAngleRotation3D()
        {
            Axis  = new Vector3D(1, 1, 1),
            Angle = 0
        };
        this.TranslateTransform = new TranslateTransform3D(0, 0, 0);
        Cube3D.Transform        = Transform;
        return(Cube3D);
    }
        public void GetProductSearchPage()
        {
            Assert.IsNotNull(TestData.Category2CS);
            //
            Int32Collection l = new Int32Collection();
            for(int i = 0; i < TestData.Category2CS.Count; i++ )
            {
            CategoryType c = TestData.Category2CS[i];
            if( c.ProductSearchPageAvailableSpecified && c.ProductSearchPageAvailable
            && c.CharacteristicsSets != null && c.CharacteristicsSets.Count > 0
            )
            {
            l.Add(c.CharacteristicsSets[0].AttributeSetID);
            break;
            }
            }
            //
            GetProductSearchPageCall api = new GetProductSearchPageCall(this.apiContext);
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
               DetailLevelCodeType.ReturnAll
            };
            api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            api.AttributeSetIDList = l;
            // Make API call.
            ProductSearchPageTypeCollection searchPages = api.GetProductSearchPage();
            Assert.IsNotNull(searchPages);
            Assert.IsTrue(searchPages.Count > 0);
            TestData.ProductSearchPages = searchPages;
        }
Пример #24
0
        protected override void Triangulate(DependencyPropertyChangedEventArgs args,
                                            Point3DCollection vertices,
                                            Vector3DCollection normals,
                                            Int32Collection indices,
                                            PointCollection textures)
        {
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            MeshGeometry3D mesh = MeshGenerator.Geometry;

            foreach (Point3D vertex in mesh.Positions)
            {
                vertices.Add(vertex);
            }

            foreach (Vector3D normal in mesh.Normals)
            {
                normals.Add(normal);
            }

            foreach (int index in mesh.TriangleIndices)
            {
                indices.Add(index);
            }

            foreach (Point texture in mesh.TextureCoordinates)
            {
                textures.Add(texture);
            }
        }
Пример #25
0
 public void GetProductFinder()
 {
     Assert.IsNotNull(TestData.Category2CS);
     GetProductFinderCall api = new GetProductFinderCall(this.apiContext);
     api.DetailLevelList = new DetailLevelCodeTypeCollection();
     api.DetailLevelList.Add(DetailLevelCodeType.ReturnAll) ;
     //
     Int32Collection l = new Int32Collection();
     for(int i = 0; i < TestData.Category2CS.Count; i++ )
     {
     CategoryType c = TestData.Category2CS[i];
     if( c.ProductFinderIDs != null && c.ProductFinderIDs.Count > 0 )
     {
     for(int n = 0; n < c.ProductFinderIDs.Count; n++ )
     l.Add(c.ProductFinderIDs[n].ProductFinderID);
     break;
     }
     }
     //
     //int[] ids = new int[l.Count()];
     //for(int i = 0; i < l.Count(); i++)
     //ids[i] = ((Integer)l.get(i)).intValue();
     api.ProductFinderIDList = l;
     // Make API call.
     String pfData = api.GetProductFinder();
 }
Пример #26
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public MeshGeometry3D GetMesh()
        {
            var pos  = new Point3DCollection(vertices.Select(x => new Point3D(x.p.X, x.p.Y, x.p.Z)));
            var tris = new Int32Collection(triangles.Count * 3);

            foreach (var tri in triangles)
            {
                tris.Add(tri.v[0]);
                tris.Add(tri.v[1]);
                tris.Add(tri.v[2]);
            }
            return(new MeshGeometry3D()
            {
                Positions = pos, TriangleIndices = tris
            });
        }
Пример #27
0
        /// <summary>
        /// Get xml that contains multiple CSs. Only set AttributeSet.CSId
        /// and AttributeSet.ProductId (optional).
        /// </summary>
        /// <param name="asList">List of <c>AttributeSet</c> objects for which
        /// you want to get CSXml.</param>
        /// <returns>The CS xml for specified CSs.</returns>
        public XmlDocument GetMultipleCSXml(IAttributeSetCollection asList)
        {
            bool            validVersion = validateCurrentVersion();
            Int32Collection csIds        = new Int32Collection();

            if (asList != null)
            {
                foreach (AttributeSet ast in asList)
                {
                    if (ast == null)
                    {
                        continue;
                    }
                    csIds.Add(ast.attributeSetID);
                }
            }
            ATTR_XML_FILE_NAME_PREFIX = createXmlFilePrefix(csIds.ToArray());
            DownloadXml();
            if (!validateCurrentVersion())
            {
                init();
            }

            XmlDocument xml = ExtractMultiCSFromXml(mXml, csIds, true);

            return(xml);
        }
Пример #28
0
        /// <summary>
        /// Converts the specified SKN File to a <see cref="MeshGeometry3D"/>
        /// </summary>
        /// <param name="skn">The SKN File which should get converted</param>
        /// <returns>The list of converted SKN Submeshes in a Tuple(SubmeshName, MeshGeometry3D)</returns>
        public static IEnumerable <Tuple <string, MeshGeometry3D> > ConvertSKN(SKNFile skn)
        {
            foreach (SKNSubmesh Submesh in skn.Submeshes)
            {
                MeshGeometry3D mesh = new MeshGeometry3D();

                Int32Collection indices = new Int32Collection();
                for (int i = 0; i < Submesh.IndexCount; i++)
                {
                    indices.Add(skn.Indices[i + (int)Submesh.StartIndex] - (int)Submesh.StartIndex);
                }

                Point3DCollection  vertices = new Point3DCollection();
                Vector3DCollection normals  = new Vector3DCollection();
                PointCollection    uv       = new PointCollection();
                for (int i = 0; i < Submesh.VertexCount; i++)
                {
                    SKNVertex vertex = skn.Vertices[i + (int)Submesh.StartVertex];
                    vertices.Add(new Point3D(vertex.Position.X, vertex.Position.Y, vertex.Position.Z));
                    normals.Add(new Vector3D(vertex.Normal.X, vertex.Normal.Y, vertex.Normal.Z));
                    uv.Add(new Point(vertex.UV.X, vertex.UV.Y));
                }

                mesh.TextureCoordinates = uv;
                mesh.Positions          = vertices;
                mesh.Normals            = normals;
                mesh.TriangleIndices    = indices;

                yield return(new Tuple <string, MeshGeometry3D>(Submesh.Name, mesh));
            }
        }
Пример #29
0
        /// <summary>
        /// there is no appororiate category whose ProductFinderBuySide is false.
        /// </summary>
        ///[Test]
        public void GetProductFinderFull()
        {
            Assert.IsNotNull(TestData.Category2CS);
            GetProductFinderCall api = new GetProductFinderCall(this.apiContext);
            api.DetailLevelList = new DetailLevelCodeTypeCollection();
            api.DetailLevelList.Add(DetailLevelCodeType.ReturnAll) ;
            CategoryType category = TestData.Category2CS2;
            Assert.IsNotNull(category.ProductFinderIDs);
            Assert.Greater(category.ProductFinderIDs.Count,0);
            Assert.IsTrue(category.ProductFinderIDs[0].ProductFinderBuySideSpecified==false);

            //get all product finder id
            Int32Collection productFinderIDs = new Int32Collection();
            for(int i=0; i<category.ProductFinderIDs.Count;i++)
            {
                productFinderIDs.Add(category.ProductFinderIDs[i].ProductFinderID);
            }

            //it must contain value.
            Assert.Greater(productFinderIDs.Count,0);
            api.ProductFinderIDList = productFinderIDs;

            //execute call.
            api.Execute();

            //check whether the call is success.
            Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning,"the call is failure!");
            //the product finder data must return value.
            Assert.Greater(api.ApiResponse.ProductFinderData.Length,0);
        }
 public void GetProductSearchPageFull()
 {
     Assert.IsNotNull(TestData.Category2CS2);
     //here comes out hard code.
     //the category should be children books category.
     Assert.IsTrue((string.Compare(TestData.Category2CS2.CategoryID,childrenBookCategory,true)==0));
     Int32Collection attributeSets = new Int32Collection();
     CategoryType category = TestData.Category2CS2;
     Assert.Greater(category.CharacteristicsSets.Count,0);
     for(int i=0; i< category.CharacteristicsSets.Count;i++)
     {
         attributeSets.Add(category.CharacteristicsSets[i].AttributeSetID);
     }
     Assert.Greater(attributeSets.Count,0);
     GetProductSearchPageCall api = new GetProductSearchPageCall(this.apiContext);
     DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
     DetailLevelCodeType.ReturnAll
     };
     api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
     api.AttributeSetIDList = attributeSets;
     api.Execute();
     //check whether the call is success.
     Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning,"the call is failure!");
     Assert.IsNotNull(api.ApiResponse.ProductSearchPage);
     Assert.Greater(api.ApiResponse.ProductSearchPage.Count,0);
     //the children category's SearchCharacteristicsSet property has value.
     Assert.IsNotNull(api.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet);
     Assert.Greater(api.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics.Count,0);
     //cache the children's mapping data.
     TestData.ProductSearchPages2 = api.ApiResponse.ProductSearchPage;
 }
Пример #31
0
        //05-09-2008@Scott
//		private void CalculateAllTotal(System.Data.DataTable i_Table,int i_FilteredRowsCount, Webb.Collections.Int32Collection i_Rows)
//		{
//			this.TotalSummaries.Clear();
//
//			this.GetTotalSummaries(this.TotalSummaries);
//
//			foreach(GroupSummary summary in this.TotalSummaries)
//			{
//				summary.CalculateResult(i_Table,i_FilteredRowsCount,i_Rows.Count/*08-27-2008@Scott*/,i_Rows);
//			}
//		}

        //05-09-2008@Scott
        private Int32Collection GetAllTotalIndicators()
        {
            Int32Collection totalIndicators = new Int32Collection();

            if (this.RootGroupInfo.GroupResults == null)
            {
                return(totalIndicators);
            }

            foreach (GroupResult result in this.RootGroupInfo.GroupResults)
            {
                if (result.RowIndicators == null)
                {
                    continue;
                }

                foreach (int row in result.RowIndicators)
                {
                    if (totalIndicators.Contains(row))
                    {
                        continue;
                    }

                    totalIndicators.Add(row);
                }
            }

            return(totalIndicators);
        }
 public static void Add(this Int32Collection c, params int[] values)
 {
     foreach (var i in values)
     {
         c.Add(i);
     }
 }
Пример #33
0
        private void Display()
        {
            viewport.Children.Remove(modViz);

            var CVPoints = new Point3DCollection();

            foreach (var chV in convexHullVertices)
            {
                CVPoints.Add(chV.Center);
                viewport.Children.Add(chV.AsHullVertex());
            }

            var faceTris = new Int32Collection();

            foreach (var f in faces)
            {
                // The vertices are stored in clockwise order.
                faceTris.Add(convexHullVertices.IndexOf(f.Vertices[0]));
                faceTris.Add(convexHullVertices.IndexOf(f.Vertices[1]));
                faceTris.Add(convexHullVertices.IndexOf(f.Vertices[2]));
            }
            var mg3d = new MeshGeometry3D
            {
                Positions       = CVPoints,
                TriangleIndices = faceTris
            };

            var material = new MaterialGroup
            {
                Children = new MaterialCollection
                {
                    new DiffuseMaterial(Brushes.Red),
                    new SpecularMaterial(Brushes.Beige, 2.0)
                }
            };

            var geoMod = new GeometryModel3D
            {
                Geometry = mg3d,
                Material = material
            };

            modViz = new ModelVisual3D {
                Content = geoMod
            };
            viewport.Children.Add(modViz);
        }
Пример #34
0
        /// <summary>
        /// If the model exists as a list of triangles only, it has to be converted to positions and indices
        /// before we can smoothen it using Paul Bourke's logic (see included pdf). This function does a straight
        /// conversion for the same. There is scope to improve it's performance, but I am expecting the models to
        /// be more in the indices format so expecting this function to be used less.
        /// </summary>
        /// <param name="triangles"></param>
        /// <returns></returns>
        public static MeshGeometry3D CreateMeshGeometry3DFromTriangles(List <Triangle> triangles)
        {
            if (triangles == null || triangles.Count <= 0)
            {
                throw new ArgumentException("CreateMeshGeometry3DFromTriangles: No triangles supplied.");
            }

            var positions = new Point3DCollection();
            var triangleIndexCollection = new Int32Collection();

            var zeroesToRoundTo = GetZeroesToRoundTo(triangles[0]);

            foreach (var triangle in triangles)
            {
                var triangleIndex = new int[3];

                var existingVertices = new List <Point3D> {
                    triangle.V1, triangle.V2, triangle.V3
                };
                for (var ctr = 0; ctr < existingVertices.Count; ctr++)
                {
                    var p0 = existingVertices[ctr];
                    //the same positions could not be recognized as unique due to minute fractional differences, so rounding off positions.
                    //If this is not done, the algorithm to find all neighboring point fails.
                    var p = new Point3D(Math.Round(p0.X, zeroesToRoundTo), Math.Round(p0.Y, zeroesToRoundTo), Math.Round(p0.Z, zeroesToRoundTo));

                    var existingIndex = positions.IndexOf(p);
                    if (existingIndex >= 0)
                    {
                        triangleIndex[ctr] = existingIndex;
                    }
                    else
                    {
                        positions.Add(p);
                        triangleIndex[ctr] = positions.Count - 1;
                    }
                }

                triangleIndexCollection.Add(triangleIndex[0]);
                triangleIndexCollection.Add(triangleIndex[1]);
                triangleIndexCollection.Add(triangleIndex[2]);
            }

            return(new MeshGeometry3D {
                Positions = positions, TriangleIndices = triangleIndexCollection
            });
        }
 public void GetSiteWideAttributeSetsForCategories()
 {
     init();
     Int32Collection catIds = new Int32Collection();
     catIds.Add(378);
     IAttributeSetCollection siteWideAttrSets = master.GetSiteWideAttributeSetsForCategories(catIds);
     releaseResource();
     Assert.IsNotNull(siteWideAttrSets);
     Assert.AreEqual(1, siteWideAttrSets.Count);
 }
 public void GetItemSpecificAttributeSetsForCategories()
 {
     this.apiContext=ApiContextLoader.LoadApiContext("");
     init();
     Int32Collection catIds = new Int32Collection();
     catIds.Add(CATEGORYID);
     IAttributeSetCollection itemAttrSets = master.GetItemSpecificAttributeSetsForCategories(catIds);
     releaseResource();
     Assert.IsNotNull(itemAttrSets);
     Assert.AreEqual(1, itemAttrSets.Count);
 }
 public void GetReturnPolicyAttributeSet()
 {
     init();
     Int32Collection catIds = new Int32Collection();
     catIds.Add(CATEGORYID);
     IAttributeSetCollection siteWideAttrSets = master.GetSiteWideAttributeSetsForCategories(catIds);
     releaseResource();
     Assert.IsNotNull(siteWideAttrSets);
     Assert.AreEqual(1, siteWideAttrSets.Count);
     AttributeSet retPolicySet = master.GetReturnPolicyAttributeSet(siteWideAttrSets);
     Assert.IsNotNull(retPolicySet);
 }
Пример #38
0
 public static Int32Collection ConvertTriangleStripToTriangleList(Int32Collection indices)
 {
     Int32Collection newIndices = new Int32Collection();
     for (int i = 2; i < indices.Count; ++i)
     {
         if (i % 2 == 0)
         {
             newIndices.Add(indices[i - 2]);
             newIndices.Add(indices[i - 1]);
             newIndices.Add(indices[i - 0]);
         }
         else
         {
             newIndices.Add(indices[i - 1]);
             newIndices.Add(indices[i - 2]);
             newIndices.Add(indices[i - 0]);
         }
     }
     return newIndices;
 }
Пример #39
0
        /// <summary>
        /// Reads a int array from the stream.
        /// </summary>
        public Int32Collection ReadInt32Array(string fieldName)
        {
            int length = ReadArrayLength();

            if (length == -1)
            {
                return null;
            }

            Int32Collection values = new Int32Collection(length);

            for (int ii = 0; ii < length; ii++)
            {
                values.Add(ReadInt32(null));
            }

            return values;
        }
Пример #40
0
        private void SyncJoinedAttrSets()
        {
            Int32Collection ids = new Int32Collection();
            int catId = Int32.Parse(this.CategoryID);
            ids.Add(catId);

            IAttributeSetCollection itemSpecAttrSets = this.attrMaster.GetItemSpecificAttributeSetsForCategories(ids);
            IAttributeSetCollection siteWideAttrSets = this.attrMaster.GetSiteWideAttributeSetsForCategories(ids);
            IAttributeSetCollection joinedAttrSets = this.attrMaster.JoinItemSpecificAndSiteWideAttributeSets(itemSpecAttrSets, siteWideAttrSets);

            this.joinedAttrSets = joinedAttrSets;
        }
		/// <summary>
		/// Extract CS xml by CSId from combined CS Xml document.
		/// </summary>
		/// <param name="allCSXml">The CS Xml document that contains multiple CS Xml.</param>
		/// <param name="csId">Id of the CS that you want to get Xml for. Set to null to return
		/// xml for all CS.</param>
		/// <param name="copyOverrides">Copy Overrides node or not..</param>
		/// <returns>The new generated Xml document that contains the specified CS Xml.</returns>
		public static XmlDocument ExtractCSFromXml(XmlDocument allCSXml, int csId, bool copyOverrides)
		{
			Int32Collection csIds = null;
			if( csId != 0 )
			{
				csIds = new Int32Collection();
				csIds.Add(csId);
			}
			return ExtractMultiCSFromXml(allCSXml, csIds, copyOverrides);
		}
		/// <summary>
		/// Get xml that contains multiple CSs. Only set AttributeSet.CSId
		/// and AttributeSet.ProductId (optional).
		/// </summary>
		/// <param name="asList">List of <c>AttributeSet</c> objects for which
		/// you want to get CSXml.</param>
		/// <returns>The CS xml for specified CSs.</returns>
		public XmlDocument GetMultipleCSXml(IAttributeSetCollection asList)
		{
			bool validVersion = validateCurrentVersion();
			Int32Collection csIds = new Int32Collection();
			if(asList != null) 
			{
				foreach(AttributeSet ast in asList) 
				{
					if(ast == null) 
					{
						continue;
					}
					csIds.Add(ast.attributeSetID);
				}
			}
			ATTR_XML_FILE_NAME_PREFIX = createXmlFilePrefix(csIds.ToArray());
			DownloadXml();
			if(!validateCurrentVersion()) 
			{
				init();
			}

			XmlDocument xml = ExtractMultiCSFromXml(mXml, csIds, true);
			
			return xml;
		}
		/// <summary>
		/// Get CharacteristicSet(CS) xml. This implementation does not support
		/// catalog, i.e., csInfo.ProductId will be ignored.
		/// </summary>
		/// <param name="csInfo">Identification information about the CS for which 
		/// you want to get CSXml. You only need to set CS.CSId and, optionally, you can
		/// set CS.ProductId if you want to get the CSXml that is associated with
		/// specific product information.
		/// Set CS.CSId to 0 to get entire CharacteristicSet xml for all CSs.</param>
		/// <returns>The xml text of the CS.</returns>
		public string GetCSXmlText(AttributeSet csInfo)
		{
			if(csInfo == null) 
			{
				return null;
			}
			Int32Collection csIds = new Int32Collection();
			csIds.Add(csInfo.attributeSetID);

			ATTR_XML_FILE_NAME_PREFIX = createXmlFilePrefix(csIds.ToArray());

			if(!validateCurrentVersion()) 
			{
				init();
			}

			XmlDocument xml = ExtractCSFromXml(this.mXml, csInfo.attributeSetID, true);
			return xml.InnerXml;
		}
Пример #44
0
        private static Int32Collection DeserializeFrom( BinaryReader reader )
        {
            Int32Collection theCollection; 
            IntegerCollectionType type; 

            type = (IntegerCollectionType) reader.ReadByte(); 

            int count = reader.ReadInt32(); 


            if ( count < 0 ) 
            {
                throw new ArgumentException(SR.Get(SRID.IntegerCollectionLengthLessThanZero)); 
            }                
                    
            theCollection = new Int32Collection( count ); 
                                
            if ( type == IntegerCollectionType.Consecutive ) 
            {
                // Get the first integer 
                int first = reader.ReadInt32(); 

                for( int i = 0; i < count; i ++)
                {
                    theCollection.Add( first + i ); 
                }
            }
            else
            {
                switch( type ) 
                {
                    case IntegerCollectionType.Byte : 
                    {
                        for ( int i = 0; i < count; i++ ) 
                        {                        
                            theCollection.Add( (int) reader.ReadByte()); 
                        }
                    }
                    break; 
                        
                    case IntegerCollectionType.UShort : 
                    {
                        for ( int i = 0; i < count; i++ ) 
                        {                    
                            theCollection.Add( (int) reader.ReadUInt16()); 
                        }
                    }
                    break; 
                        
                    case IntegerCollectionType.Integer : 
                    {                    
                        for ( int i = 0; i < count; i++ ) 
                        {                    
                            int value = reader.ReadInt32(); 

                            theCollection.Add( value);
                        }                            
                    }                            
                    break; 
                    
                    default:
                        throw new ArgumentException(SR.Get(SRID.UnknownIndexType)); 
                        
                }
            }

            return theCollection; 
        }
 public void RenderHtml()
 {
     init();
     Int32Collection catIds = new Int32Collection();
     catIds.Add(CATEGORYID);
     IAttributeSetCollection siteWideAttrSets = master.GetSiteWideAttributeSetsForCategories(catIds);
     AttributeSet retPolicySet = master.GetReturnPolicyAttributeSet(siteWideAttrSets);
     IAttributeSetCollection retPolicySetCollection = new AttributeSetCollection();
     retPolicySetCollection.Add(retPolicySet);
     string tableText = master.RenderHtml(retPolicySetCollection, null);
     DOMDocument30 xmlDoc = master.getXmlToRenderDoc();
     //TextWriter writer = new StreamWriter("C:\\SDK\\48514.xml");
     string xmlString = xmlDoc.xml;
     Console.WriteLine(xmlString);
     releaseResource();
 }
Пример #46
0
        private void DisplayAttributes(NameValueCollection request, IErrorSetCollection errList)
        {
            AttributesMaster attrMaster = (AttributesMaster)Session[Global.ATTRIBUTES_MASTER];

            AddHtmlHeaders();

            string tableText=string.Empty;

            // For the first time we have only categoryId and categoryId2 but we don't
            // have any attributes request data so we have to use RenderHtmlForCategories to generate the html text.
            string strCatId = request[CategoryList.CAT_ID];
            if( strCatId != null && strCatId.Length != 0 )
            {
                Int32Collection ids = new Int32Collection();
                int catId = Int32.Parse(strCatId);
                ids.Add(catId);

                Session["CategoryId"] = catId;
                Session["Category2Id"] = 0;

                strCatId = request[CategoryList.CAT_ID2];
                if( strCatId != null && strCatId.Length != 0 )
                {
                    catId = Int32.Parse(strCatId);
                    ids.Add(catId);

                    Session["Category2Id"] = catId;
             				}
                IAttributeSetCollection itemSpecAttrSets = attrMaster.GetItemSpecificAttributeSetsForCategories(ids);
                IAttributeSetCollection siteWideAttrSets = attrMaster.GetSiteWideAttributeSetsForCategories(ids);
                Session[Global.ITEM_SITE_WIDE_ATTR_SETS] = siteWideAttrSets;
                IAttributeSetCollection joinedAttrSets = attrMaster.JoinItemSpecificAndSiteWideAttributeSets(itemSpecAttrSets, siteWideAttrSets);
                Session[Global.JOINED_ATTR_SETS] = joinedAttrSets;
                if(joinedAttrSets!=null)
                {
                    tableText = attrMaster.RenderHtml(joinedAttrSets, errList);
                }
            }
            else
            {
                tableText = attrMaster.RenderHtmlForPostback(AttributesHelper.ConvertFromNameValues(request), errList);
            }

            IAttributeSetCollection attrSets = Session[Global.JOINED_ATTR_SETS] as IAttributeSetCollection;
            if (attrSets != null && attrSets.Count > 0)
            {
                hasAttributes = true;
            }
            else
            {
                hasAttributes = false;
            }

            Response.Write(tableText);

            AddCustomItemSpecificsHtml();

            AddHtmlTails();
        }
        /// <summary>
        /// Reads a int array from the stream.
        /// </summary>
        public Int32Collection ReadInt32Array(string fieldName)
        {
            var values = new Int32Collection();

            List<object> token = null;

            if (!ReadArrayField(fieldName, out token))
            {
                return values;
            }

            for (int ii = 0; ii < token.Count; ii++)
            {
                try
                {
                    m_stack.Push(token[ii]);
                    values.Add(ReadInt32(null));
                }
                finally
                {
                    m_stack.Pop();
                }
            }

            return values;
        }
Пример #48
0
 /// <summary>
 /// Converts comma-separated list of integer status codes into the appropriate Int32Collection ready to set into the filter.
 /// </summary>
 /// <param name="configString"></param>
 /// <returns></returns>
 public static Int32Collection ParseTriggerHttpStatusCodes(string configString)
 {
     if (configString == null || configString.Length == 0)
         return null;
     Int32Collection outCollection = new Int32Collection();
     string[] tokens = configString.Split(SEPS);
     for (int i = 0; i < tokens.Length; i++)
     {
         outCollection.Add(Int32.Parse(tokens[i]));
     }
     return outCollection;
 }
Пример #49
0
        public void AddItemFull3()
        {
            bool isSucess,isProductSearchPageAvailable;
            bool existing=false,isbnExisting=false;
            string message;
            Int32Collection attributes=new Int32Collection();
            CategoryTypeCollection categories=null;
            CharacteristicsSetTypeCollection characteristics=null;

            ItemType item= ItemHelper.BuildItem();
            //check whether the category is catalog enabled.
            isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.ProductSearchPageAvailable,out isProductSearchPageAvailable,out message);
            Assert.IsTrue(isSucess,message);
            Assert.IsTrue(isProductSearchPageAvailable,message);
            isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.CatalogEnabled,out isProductSearchPageAvailable,out message);
            Assert.IsTrue(isSucess,message);
            Assert.IsTrue(isProductSearchPageAvailable,message);
            //modify item information approporiately.
            item.PrimaryCategory.CategoryID=PSPACATEGORYID.ToString();
            item.Description = "check whether the item can be added by GetProductSearchPage method way,This is a test item created by eBay SDK SanityTest.";

            //get characters information using GetCategory2CSCall
            GetCategory2CSCall csCall=new GetCategory2CSCall(this.apiContext);

            DetailLevelCodeTypeCollection levels=new DetailLevelCodeTypeCollection();
            DetailLevelCodeType level=new DetailLevelCodeType();
            level=DetailLevelCodeType.ReturnAll;
            levels.Add(level);
            csCall.DetailLevelList=levels;
            csCall.CategoryID=PSPACATEGORYID.ToString();
            csCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(csCall.AbstractResponse.Ack==AckCodeType.Success || csCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.IsNotNull(csCall.ApiResponse.MappedCategoryArray);
            Assert.Greater(csCall.ApiResponse.MappedCategoryArray.Count,0);
            categories=csCall.ApiResponse.MappedCategoryArray;

            foreach(CategoryType category in categories)
            {
                if(string.Compare(category.CategoryID,PSPACATEGORYID)==0)
                {
                    characteristics=category.CharacteristicsSets;
                    existing= true;
                    break;
                }
            }

            //confirm that the category was in the mapping category.
            Assert.IsTrue(existing,PSPACATEGORYID+" do not exist in the mapping category");
            Assert.IsNotNull(characteristics);
            Assert.Greater(characteristics.Count,0);

            foreach(CharacteristicsSetType characteristic in characteristics)
            {
                attributes.Add(characteristic.AttributeSetID);
            }

            //confirm that there is real attributeset in the mapping category.
            Assert.AreEqual(attributes.Count,1);//there is only one AttributeSetID in the category 279.

            GetProductSearchPageCall searchPageCall=new GetProductSearchPageCall(this.apiContext);
            searchPageCall.AttributeSetIDList=attributes;
            DetailLevelCodeTypeCollection levels2=new DetailLevelCodeTypeCollection();
            DetailLevelCodeType level2=new DetailLevelCodeType();
            level2=DetailLevelCodeType.ReturnAll;
            levels2.Add(level2);
            searchPageCall.DetailLevelList=levels2;
            searchPageCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchPageCall.ApiResponse.Ack==AckCodeType.Success || searchPageCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.AreEqual(searchPageCall.ApiResponse.ProductSearchPage.Count,1);//for the input attributeset id is only one.
            Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet);//for the input attributeset id is only one.
            Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics);
            Assert.Greater(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics.Count,0);

            //check the isbn-13 attribute id exists and its value has not been changed.
            CharacteristicTypeCollection chs = searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics;
            foreach(CharacteristicType charactersic in chs)
            {
                //check whether the isbn attribute can be used
                if(charactersic.AttributeID==ISBN13ATTRIBUTEID && (string.Compare(charactersic.Label.Name,"ISBN-13",true)==0))
                {
                    isbnExisting=true;
                    break;
                }
            }

            Assert.IsTrue(isbnExisting,"the isbn attribute id is not existing or has been changed!");
            //using GetProductSearchResults call to find products.
            ProductSearchType productSearch=new ProductSearchType();
            productSearch.AttributeSetID=attributes[0];
            SearchAttributesTypeCollection searchAttributes=new SearchAttributesTypeCollection();
            SearchAttributesType searchAttribute=new SearchAttributesType();
            searchAttribute.AttributeID=ISBN13ATTRIBUTEID;
            ValTypeCollection vals=new ValTypeCollection();
            ValType val=new ValType();
            val.ValueLiteral=ISBN;
            vals.Add(val);
            searchAttribute.ValueList=vals;
            searchAttributes.Add(searchAttribute);
            productSearch.SearchAttributes=searchAttributes;
            GetProductSearchResultsCall searchResultsCall=new GetProductSearchResultsCall(this.apiContext);
            searchResultsCall.ProductSearchList=new ProductSearchTypeCollection(new ProductSearchType[]{productSearch});
            searchResultsCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchResultsCall.ApiResponse.Ack==AckCodeType.Success || searchResultsCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult.Count,0);
            Assert.AreEqual(int.Parse(searchResultsCall.ApiResponse.ProductSearchResult[0].NumProducts),1);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet.Count,0);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies.Count,0);
            Assert.IsFalse(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].hasMoreChildren);
            Assert.IsNotNull(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID);

            string productID=searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID;
            ProductListingDetailsType plist=new ProductListingDetailsType();
            plist.ProductID=productID;
            plist.IncludePrefilledItemInformation=true;
            plist.IncludeStockPhotoURL=true;
            item.ProductListingDetails=plist;

            FeeTypeCollection fees;

            VerifyAddItemCall vi = new VerifyAddItemCall(apiContext);
            fees = vi.VerifyAddItem(item);
            Assert.IsNotNull(fees);

            AddItemCall addItemCall = new AddItemCall(apiContext);;
            fees = addItemCall.AddItem(item);
            //check whether the call is success.
            Assert.IsTrue(addItemCall.AbstractResponse.Ack==AckCodeType.Success || addItemCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.IsTrue(item.ItemID!=string.Empty);
            Assert.IsNotNull(fees);

            //caution check
            ItemType itemOut;
            isSucess=ItemHelper.GetItem(item,this.apiContext,out message, out itemOut);
            Assert.IsTrue(isSucess,message);
            Assert.IsNotNull(itemOut,"Item is null");
            Assert.Greater(itemOut.AttributeSetArray.Count,0);
            Assert.Greater(itemOut.AttributeSetArray[0].Attribute.Count,0);
            Assert.Greater(itemOut.AttributeSetArray[0].Attribute[0].Value.Count,0);
        }
		/// <summary>
		/// Get Site-Wide characteristics sets by category ID.
		/// </summary>
		/// <param name="catId">A specific category ID for which fetch Site-Wide CategoryCS data.</param>
		public int[] GetSiteWideCharSetsAttrIds(string catId) 
		{
			SiteWideCharacteristicsTypeCollection swAttrs = GetSiteWideCharacteristics(catId);
			Int32Collection attrSetIds = new Int32Collection();
			for(int i = 0; i < swAttrs.Count; i++) {
				SiteWideCharacteristicsType swCharSet = swAttrs.ToArray()[i];
				int attrSetId = swCharSet.CharacteristicsSet.AttributeSetID;
				attrSetIds.Add(attrSetId);
			}

			return attrSetIds.ToArray();
		}
Пример #51
0
        /// <summary>
        /// Reads a int array from the stream.
        /// </summary>
        public Int32Collection ReadInt32Array(string fieldName)
        {
            bool isNil = false;

            Int32Collection values = new Int32Collection();
                                    
            if (BeginField(fieldName, true, out isNil))
            {                                
                PushNamespace(Namespaces.OpcUaXsd);
                
                while (MoveToElement("Int32"))
                {
                    values.Add(ReadInt32("Int32"));
                }

                // check the length.
                if (m_context.MaxArrayLength > 0 && m_context.MaxArrayLength < values.Count)
                {
                    throw new ServiceResultException(StatusCodes.BadEncodingLimitsExceeded);
                }

                PopNamespace();

                EndField(fieldName);
                return values;
            }

            if (isNil)
            {
                return null;
            }

            return values;
        }
        public void GetProductSearchResultsFull()
        {
            bool isbnExisting=false;
            Int32Collection attributes=new Int32Collection();

            Assert.IsNotNull(TestData.ProductSearchPages2);
            Assert.Greater(TestData.ProductSearchPages2.Count,0);
            Assert.Greater(TestData.ProductSearchPages2[0].SearchCharacteristicsSet.Characteristics.Count,0);

            //check whether the call is success.
            Assert.AreEqual(string.Compare(TestData.Category2CS2.CategoryID,PSPACATEGORYID,true),0);
            CharacteristicsSetTypeCollection characteristics = TestData.Category2CS2.CharacteristicsSets;

            //confirm that the category was in the mapping category.
            Assert.IsNotNull(characteristics);
            Assert.Greater(characteristics.Count,0);

            foreach(CharacteristicsSetType characteristic in characteristics)
            {
                attributes.Add(characteristic.AttributeSetID);
            }

            //check the isbn-13 attribute id exists and its value has not been changed.
            CharacteristicTypeCollection chs = TestData.ProductSearchPages2[0].SearchCharacteristicsSet.Characteristics;
            foreach(CharacteristicType charactersic in chs)
            {
                //check whether the isbn attribute can be used
                if(charactersic.AttributeID==ISBN13ATTRIBUTEID && (string.Compare(charactersic.Label.Name,"ISBN-13",true)==0))
                {
                    isbnExisting=true;
                    break;
                }
            }

            Assert.IsTrue(isbnExisting,"the isbn attribute id is not existing or has been changed!");
            //using GetProductSearchResults call to find products.
            ProductSearchType productSearch=new ProductSearchType();
            productSearch.AttributeSetID=attributes[0];
            SearchAttributesTypeCollection searchAttributes=new SearchAttributesTypeCollection();
            SearchAttributesType searchAttribute=new SearchAttributesType();
            searchAttribute.AttributeID=ISBN13ATTRIBUTEID;
            ValTypeCollection vals=new ValTypeCollection();
            ValType val=new ValType();
            val.ValueLiteral=ISBN;
            vals.Add(val);
            searchAttribute.ValueList=vals;
            searchAttributes.Add(searchAttribute);
            productSearch.SearchAttributes=searchAttributes;
            GetProductSearchResultsCall searchResultsCall=new GetProductSearchResultsCall(this.apiContext);
            searchResultsCall.ProductSearchList=new ProductSearchTypeCollection(new ProductSearchType[]{productSearch});
            searchResultsCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchResultsCall.ApiResponse.Ack==AckCodeType.Success || searchResultsCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult.Count,0);
            Assert.AreEqual(int.Parse(searchResultsCall.ApiResponse.ProductSearchResult[0].NumProducts),1);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet.Count,0);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies.Count,0);
            Assert.IsFalse(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].hasMoreChildren);
            Assert.IsNotNull(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID);
            TestData.ProductSearchResults2 = searchResultsCall.ApiResponse.ProductSearchResult;
        }