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;
 }
Пример #2
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 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;
        }
 protected BasicPrimitiveTessellator()
 {
     Positions = new Point3DCollection();
     Normals = new Vector3DCollection();
     Indices = new Int32Collection();
     TextureCoordinates = new Point2DCollection();
 }
Пример #5
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();
 }
Пример #6
0
        } // Read

        public static unsafe uint Read(this NativeReader reader, uint offset, out Int32Collection values)
        {
            values = new Int32Collection(reader, offset);
            uint count;
            offset = reader.DecodeUnsigned(offset, out count);
            offset = checked(offset + count * sizeof(Int32));
            return offset;
        } // Read
		/// <summary>
		/// This type is deprecated as the call is no longer available.
		/// </summary>
		/// 
		/// <param name="AttributeVersion">
		/// A version of the search page definitions for the site. Typically, an
		/// application passes the version value that was returned the last time the
		/// application executed this call. Filter that causes the call to return only
		/// the search pages for which the attribute meta-data has changed since the
		/// specified version. The latest version value is not necessarily greater
		/// than the previous value that was returned. Therefore, when comparing
		/// versions, only compare whether the value has changed.
		/// </param>
		///
		/// <param name="AttributeSetIDList">
		/// A characteristic set ID that is associated with a
		/// catalog-enabled category that supports product search pages.
		/// You can pass an array of these IDs in the request.
		/// Each characteristic set corresponds to a level in the
		/// eBay category hierarchy at which all items share common characteristics.
		/// Multiple categories can be mapped to the same characteristic set.
		/// Each ID is used as a filter to limit the response content to fewer
		/// characteristic sets. When IDs are specified, the call only returns
		/// search page data for the corresponding characteristic sets.
		/// When no IDs are specified, the call returns all the current
		/// search page data in the system.
		/// </param>
		///
		public ProductSearchPageTypeCollection GetProductSearchPage(string AttributeVersion, Int32Collection AttributeSetIDList)
		{
			this.AttributeVersion = AttributeVersion;
			this.AttributeSetIDList = AttributeSetIDList;

			Execute();
			return ApiResponse.ProductSearchPage;
		}
Пример #8
0
 public Mesh()
 {
     Positions = new Point3DCollection();
     Normals = new Vector3DCollection();
     TextureCoordinates = new Point3DCollection();
     Indices = new Int32Collection();
     Transform = new MatrixTransform(Matrix3D.Identity);
 }
 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);
 }
Пример #10
0
        public void CanConvertTriangleStripToTriangleList()
        {
            // Arrange.
            Int32Collection indices = new Int32Collection(new[] { 0, 3, 1, 4, 2, 5 });

            // Act.
            Int32Collection newIndices = MeshUtility.ConvertTriangleStripToTriangleList(indices);

            // Assert.
            CollectionAssert.AreEqual(new[] { 0, 3, 1, 1, 3, 4, 1, 4, 2, 2, 4, 5 }, newIndices);
        }
 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);
 }
Пример #13
0
 private static void AccumulateTriangleNormals(Int32Collection indices, Point3DCollection positions, Vector3D[] vertexNormals)
 {
     for (int i = 0; i < indices.Count; i += 3)
     {
         Point3D vector4 = positions[indices[i]];
         Point3D vector = positions[indices[i + 1]];
         Point3D vector3 = positions[indices[i + 2]];
         Vector3D vector2 = Vector3D.Normalize(Vector3D.Cross(vector3 - vector, vector - vector4));
         for (int j = 0; j < 3; j++)
             vertexNormals[indices[i + j]] += vector2;
     }
 }
Пример #14
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;
 }
		/// <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();
		}
Пример #16
0
        MeshGeometry3D MakeCube()
        {
            MeshGeometry3D    cube    = new MeshGeometry3D();
            Point3DCollection corners = new Point3DCollection();

            corners.Add(new Point3D(0.5, 0.5, 0.5));
            corners.Add(new Point3D(-0.5, 0.5, 0.5));
            corners.Add(new Point3D(-0.5, -0.5, 0.5));
            corners.Add(new Point3D(0.5, -0.5, 0.5));
            corners.Add(new Point3D(0.5, 0.5, -0.5));
            corners.Add(new Point3D(-0.5, 0.5, -0.5));
            corners.Add(new Point3D(-0.5, -0.5, -0.5));
            corners.Add(new Point3D(0.5, -0.5, -0.5));
            cube.Positions = corners;

            Int32[] indices =
            {
                //front
                0, 1, 2,
                0, 2, 3,
                //back
                4, 7, 6,
                4, 6, 5,
                //Right
                4, 0, 3,
                4, 3, 7,
                //Left
                1, 5, 6,
                1, 6, 2,
                //Top
                1, 0, 4,
                1, 4, 5,
                //Bottom
                2, 6, 7,
                2, 7, 3
            };

            indices2 = indices;

            Int32Collection Triangles =
                new Int32Collection();

            foreach (Int32 index in indices)
            {
                Triangles.Add(index);
            }
            cube.TriangleIndices = Triangles;

            for (int i = 0; i < cube.Positions.Count; i++)
            {
                // Text for Vertex
                //TextBlock text = new TextBlock();
                //text.Text = i.ToString();
                //text.HorizontalAlignment = HorizontalAlignment.Center;
                //text.Background = Brushes.White;

                //textBlocks.Add(text);

                // Circles for Vertex
                Ellipse circle = new Ellipse();
                circle.Stroke = System.Windows.Media.Brushes.Transparent;
                circle.Fill   = System.Windows.Media.Brushes.Transparent;
                circle.Width  = 5;
                circle.Height = 5;

                circles.Add(circle);
            }

            for (int i = 0; i < indices.Length; i++)
            {
                Line line = new Line();
                line.Stroke = System.Windows.Media.Brushes.White;
                line.HorizontalAlignment = HorizontalAlignment.Left;
                line.VerticalAlignment   = VerticalAlignment.Center;
                line.StrokeThickness     = 1;

                myLines.Add(line);
            }

            return(cube);
        }
Пример #17
0
		/// <summary>
		/// Returns collection of item specific AttributeSet objects for an array category Ids.
		/// Each element of the array contains a VCS Id, if it exists for a given category Id. 
		/// </summary>
		/// <param name="catIds">int[]</param>
		/// <returns>Collection of item specific AttributeSet objects</returns>
		public IAttributeSetCollection GetItemSpecificAttributeSetsForCategories(Int32Collection catIds) 
		{
			IAttributeSetCollection sets = new AttributeSetCollection();
			int i = 0;
			foreach(int catId in catIds) 
			{
				AttributeSet ast = new AttributeSet();
				int csId = mCategoryCSProvider.GetVCSId(catId);
				if (csId == 0) 
				{
					return null;
					//throw new SdkException("Unable to get CSID by category Id");
				}
				ast.attributeSetID = csId;
				ast.CategoryID = catId;
				ast.CategoryOrdinal = i++;

				sets.Add(ast);
			}

			return sets;
		}
Пример #18
0
        public HorizonGroupView(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            try
            {
                _RootGroupInfo = (Webb.Reports.ExControls.Data.GroupInfo)info.GetValue("_RootGroupInfo", typeof(Webb.Reports.ExControls.Data.GroupInfo));
            }
            catch
            {
            }
            try
            {
                _Fitler = (Webb.Data.DBFilter)info.GetValue("_Fitler", typeof(Webb.Data.DBFilter));
            }
            catch
            {
            }
            try
            {
                _ShowRowIndicators = info.GetBoolean("_ShowRowIndicators");
            }
            catch
            {
                _ShowRowIndicators = false;
            }
            try
            {
                _HaveHeader = info.GetBoolean("_HaveHeader");
            }
            catch
            {
                _HaveHeader = true;
            }
            try
            {
                _ColumnsWidth = (Webb.Collections.Int32Collection)info.GetValue("_ColumnsWidth", typeof(Webb.Collections.Int32Collection));
            }
            catch
            {
            }
            try
            {
                _RowsHight = (Webb.Collections.Int32Collection)info.GetValue("_RowsHight", typeof(Webb.Collections.Int32Collection));
            }
            catch
            {
            }
            try
            {
                _Total = info.GetBoolean("_Total");
            }
            catch
            {
                _Total = true;
            }
            try
            {
                _HorizonTopCount = info.GetInt32("_HorizonTopCount");
            }
            catch
            {
                _HorizonTopCount = 0;
            }
            try
            {
                _TotalOthers = info.GetBoolean("_TotalOthers");
            }
            catch
            {
                _TotalOthers = false;
            }
            try
            {
                _TotalOthersName = info.GetString("_TotalOthersName");
            }
            catch
            {
                _TotalOthersName = "Others";
            }
            try
            {
                _TotalStyle = (Webb.Reports.ExControls.BasicStyle)info.GetValue("_TotalStyle", typeof(Webb.Reports.ExControls.BasicStyle));
            }
            catch
            {
                _TotalStyle = new BasicStyle();
            }
            try
            {
                _HeaderRows = (Webb.Collections.Int32Collection)info.GetValue("_HeaderRows", typeof(Webb.Collections.Int32Collection));
            }
            catch
            {
                _HeaderRows = new Int32Collection();
            }
            try
            {
                TableHeaders = (Webb.Reports.ExControls.Data.HeadersData)info.GetValue("TableHeaders", typeof(Webb.Reports.ExControls.Data.HeadersData));
            }
            catch
            {
                TableHeaders = null;
            }
            try
            {
                _TotalPosition = (Webb.Data.TotalType)info.GetValue("_TotalPosition", typeof(Webb.Data.TotalType));
            }
            catch
            {
                if (_RootGroupInfo != null && _RootGroupInfo.AddTotal)
                {
                    _TotalPosition = TotalType.AllBefore;

                    _RootGroupInfo.AddTotal = false;
                }
                else
                {
                    _TotalPosition = TotalType.None;
                }
                if (RootGroupInfo != null)
                {
                    if (RootGroupInfo.SubGroupInfos.Count > 0 && RootGroupInfo.Summaries != null)
                    {
                        RootGroupInfo.SubGroupInfos[0].Summaries = RootGroupInfo.Summaries.CopyStructure();
                    }

                    RootGroupInfo.Summaries = new GroupSummaryCollection();

                    if (this.Total)
                    {
                        GroupSummary groupSummary = new GroupSummary();

                        groupSummary.ColorNeedChange = true;

                        groupSummary.Style.SetStyle(this.TotalStyle);

                        groupSummary.ShowZeros = true;

                        RootGroupInfo.Summaries.Add(groupSummary);
                    }
                }
            }
            try
            {
                _TotalOthersPosition = (Webb.Data.TotalType)info.GetValue("_TotalOthersPosition", typeof(Webb.Data.TotalType));
            }
            catch
            {
                if (this._TotalOthers)
                {
                    _TotalOthersPosition = TotalType.AllAfter;
                }
                else
                {
                    _TotalOthersPosition = TotalType.None;
                }
            }
            try
            {
                _SummaryForTotalGroup = (Webb.Reports.ExControls.Data.GroupSummary)info.GetValue("_SummaryForTotalGroup", typeof(Webb.Reports.ExControls.Data.GroupSummary));
            }
            catch
            {
                _SummaryForTotalGroup = new GroupSummary();
            }
            try
            {
                _SummaryForOthers = (Webb.Reports.ExControls.Data.GroupSummary)info.GetValue("_SummaryForOthers", typeof(Webb.Reports.ExControls.Data.GroupSummary));
            }
            catch
            {
                _SummaryForOthers = new GroupSummary();
            }
        }
        /// <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;
        }
		/// <summary>
		/// Extract CS xml by list of CSId from combined CS Xml document.
		/// </summary>
		/// <param name="allCSXml">The CS Xml document that contains multiple CS Xml.</param>
		/// <param name="csIds">List of CSIDs 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 ExtractMultiCSFromXml(XmlDocument allCSXml, Int32Collection csIds, bool copyOverrides)
		{
			XmlDocument retXml = null;
			if( csIds == null || csIds.Count == 0 )
				retXml = allCSXml;
			else
			{
				XmlNode verNode = allCSXml.SelectSingleNode(SELECT_VERSION);

				//
				retXml = new XmlDocument();
				XmlNode node = retXml.CreateXmlDeclaration("1.0", System.Text.Encoding.Unicode.BodyName, null);
				retXml.AppendChild(node);

				XmlNode eBayNode = XmlUtility.AddChild(retXml, retXml, "eBay");
				retXml.AppendChild(eBayNode);

				XmlNode asNode = XmlUtility.AddChild(retXml, eBayNode, "Attributes");
				XmlNode csNode = XmlUtility.AddChild(retXml, eBayNode, "Characteristics");

				if( verNode != null )
					eBayNode.AppendChild(retXml.ImportNode(verNode, true));

				XmlNode fromNode;

				foreach(int csId in csIds)
				{
					// Copy Attributes/AttributeSet
					fromNode = allCSXml.SelectSingleNode(String.Format(SELECT_AS, csId));
					if( fromNode == null ) 
                    {
                        string expMsg = "ExtractMultiCSFromXml: Unable to find source Attributes node the given CSId.\r\n";
                        expMsg += "There is error in the attributes meta-data, please check if the category is \r\n";
                        expMsg += "item specifics enabled(using GetCategoryFeatures) and use eBay item specifics related API instead.\r\n";
                        expMsg += "You may also contact eBay and report the error.";
						throw new SdkException(expMsg);
                    }
					asNode.AppendChild(retXml.ImportNode(fromNode, true));

					// Copy Characteristics/CharacteristicsSet
					fromNode = allCSXml.SelectSingleNode(String.Format(SELECT_CS, csId));
					if( fromNode == null )
						throw new SdkException("ExtractMultiCSFromXml: Unable to find source Characteristics node the given CSId.");
					csNode.AppendChild(retXml.ImportNode(fromNode, true));
				}

				// Copy eBay//API.XSL.Overrides
				if( copyOverrides )
				{
					fromNode = allCSXml.SelectSingleNode(SELECT_OVERRIDES);
					if( fromNode != null )
						eBayNode.AppendChild(retXml.ImportNode(fromNode, true));

					// Copy GlobalSettings
					fromNode = allCSXml.SelectSingleNode(SELECT_GLOBALSETTINGS);
					if( fromNode != null )
						eBayNode.AppendChild(retXml.ImportNode(fromNode, true));
				}
			}

			return retXml;
		}
        /// <summary>
        ///
        /// </summary>
        /// <param name="vertices"></param>
        /// <param name="normals"></param>
        /// <param name="indices"></param>
        /// <param name="textures"></param>
        protected void TriangleSubdivide(Point3DCollection vertices,
                                         Vector3DCollection normals,
                                         Int32Collection indices,
                                         PointCollection textures)
        {
            for (int i = 0; i < 3; i++)
            {
                verticesBase[2 - i] = vertices[vertices.Count - 1];
                normalsBase[2 - i]  = normals[vertices.Count - 1];
                texturesBase[2 - i] = textures[vertices.Count - 1];

                vertices.RemoveAt(vertices.Count - 1);
                normals.RemoveAt(normals.Count - 1);
                indices.RemoveAt(indices.Count - 1);
                textures.RemoveAt(textures.Count - 1);
            }

            int indexStart = vertices.Count;

            for (int slice = 0; slice <= Slices; slice++)
            {
                double weight = (double)slice / Slices;

                Point3D vertex1 = Point3DWeight(verticesBase[0], verticesBase[1], weight);
                Point3D vertex2 = Point3DWeight(verticesBase[0], verticesBase[2], weight);

                Vector3D normal1 = Vector3DWeight(normalsBase[0], normalsBase[1], weight);
                Vector3D normal2 = Vector3DWeight(normalsBase[0], normalsBase[2], weight);

                Point texture1 = PointWeight(texturesBase[0], texturesBase[1], weight);
                Point texture2 = PointWeight(texturesBase[0], texturesBase[2], weight);

                for (int i = 0; i <= slice; i++)
                {
                    weight = (double)i / slice;

                    if (Double.IsNaN(weight))
                    {
                        weight = 0;
                    }

                    vertices.Add(Point3DWeight(vertex1, vertex2, weight));
                    normals.Add(Vector3DWeight(normal1, normal2, weight));
                    textures.Add(PointWeight(texture1, texture2, weight));
                }
            }

            for (int slice = 0; slice < Slices; slice++)
            {
                int base1 = (slice + 1) * slice / 2;
                int base2 = base1 + slice + 1;

                for (int i = 0; i <= 2 * slice; i++)
                {
                    int half = i / 2;

                    if ((i & 1) == 0)         // even
                    {
                        indices.Add(indexStart + base1 + half);
                        indices.Add(indexStart + base2 + half);
                        indices.Add(indexStart + base2 + half + 1);
                    }
                    else                    // odd
                    {
                        indices.Add(indexStart + base1 + half);
                        indices.Add(indexStart + base2 + half + 1);
                        indices.Add(indexStart + base1 + half + 1);
                    }
                }
            }
        }
Пример #22
0
        public static Int32Collection[] GetConnectedMeshRegionsUsingSeadPoint(MeshGeometry3D mesh, int SeadIndex)
        {
            Int32Collection[]     ConnectedList = new Int32Collection[mesh.Positions.Count];
            Dictionary <int, int> TriIndices    = new Dictionary <int, int> {
            };

            for (int i = 0; i < mesh.TriangleIndices.Count; i++)
            {
                TriIndices.Add(i, mesh.TriangleIndices[i]);
            }

            var SortedGroups = from o in TriIndices group o by o.Value;

            //var SeadedIndex = from KeyValuePair<int, int> Connections in SortedGroups
            //    where Connections.Key .Equals(0)
            //    select Connections;


            foreach (var vGroup in SortedGroups)
            {
                foreach (var v in vGroup)
                {
                    int idx = v.Value;
                    if (ConnectedList[idx] == null)
                    {
                        ConnectedList[idx] = new Int32Collection();
                    }



                    int Face     = 3 * (v.Key / 3);
                    int Indices1 = Face;
                    int Indices2 = Face + 1;
                    int Indices3 = Face + 2;

                    bool alreadyInList = false;
                    if (ConnectedList[idx] != null && ConnectedList[idx].Count != 0)
                    {
                        int[] tri = new int[3];
                        tri[0] = Indices1;
                        tri[1] = Indices2;
                        tri[2] = Indices3;
                        for (int i = 0; i < ConnectedList[idx].Count; i++)
                        {
                            if (tri[0] == (ConnectedList[idx][i]) && tri[1] == (ConnectedList[idx][i + 1]) && tri[2] == (ConnectedList[idx][i + 2]))
                            {
                                alreadyInList = true;
                            }

                            i++;
                            i++;
                        }
                    }
                    if (alreadyInList == false)
                    {
                        ConnectedList[idx].Add(Face);
                        ConnectedList[idx].Add(Face + 1);
                        ConnectedList[idx].Add(Face + 2);
                    }
                }
            }
            TriIndices = null;
            return(ConnectedList);
        }
Пример #23
0
        public Transition3D()
            : base(new Viewport3D())
        {
            // camera to ue
            WrappedElement.Camera = new PerspectiveCamera();

            // the model visual 3D
            ModelVisual3D mv3D = new ModelVisual3D();

            mv3D.Content = new PointLight(Colors.White, new Point3D(0, 0, 0));

            WrappedElement.Children.Add(mv3D);

            MeshGeometry3D    plane     = new MeshGeometry3D();
            Point3DCollection positions = new Point3DCollection();

            positions.Add(new Point3D(-1, -1, 0));
            positions.Add(new Point3D(-1, 1, 0));
            positions.Add(new Point3D(1, 1, 0));
            positions.Add(new Point3D(1, -1, 0));
            positions.Freeze();
            plane.Positions = positions;

            PointCollection textureCoords = new PointCollection();

            textureCoords.Add(new Point(0, 1));
            textureCoords.Add(new Point(0, 0));
            textureCoords.Add(new Point(1, 0));
            textureCoords.Add(new Point(1, 1));
            textureCoords.Freeze();
            plane.TextureCoordinates = textureCoords;

            Int32Collection indices = new Int32Collection();

            indices.Add(0);
            indices.Add(3);
            indices.Add(1);
            indices.Add(1);
            indices.Add(3);
            indices.Add(2);
            indices.Freeze();
            plane.TriangleIndices = indices;

            Material planeMaterial = new DiffuseMaterial(Brushes.Blue);

            planeMaterial.SetValue(Viewport2DVisual3D.IsVisualHostMaterialProperty, true);

            m_visual3D          = new Viewport2DVisual3D();
            m_visual3D.Geometry = plane;
            m_visual3D.Material = planeMaterial;

            Transform3DGroup transform = new Transform3DGroup();

            m_rotation    = new AxisAngleRotation3D(new Vector3D(0, 1, 0), 35);
            m_scale       = new ScaleTransform3D(0, 0, 0);
            m_translation = new TranslateTransform3D(-2.5, 0, -10);

            transform.Children.Add(m_scale);
            transform.Children.Add(new RotateTransform3D(m_rotation));
            transform.Children.Add(m_translation);

            m_visual3D.Transform = transform;

            WrappedElement.Children.Add(m_visual3D);
        }
Пример #24
0
        public void Basic3DShapeExample()
        {
            // Declare scene objects.
            Viewport3D      myViewport3D    = new Viewport3D();
            Model3DGroup    myModel3DGroup  = new Model3DGroup();
            GeometryModel3D myGeometryModel = new GeometryModel3D();
            ModelVisual3D   myModelVisual3D = new ModelVisual3D();
            // Defines the camera used to view the 3D object. In order to view the 3D object,
            // the camera must be positioned and pointed such that the object is within view
            // of the camera.
            OrthographicCamera myPCamera = new OrthographicCamera();

            //PerspectiveCamera myPCamera = new PerspectiveCamera();

            // Specify where in the 3D scene the camera is.
            myPCamera.Position = new Point3D(0, 0, 2);

            // Specify the direction that the camera is pointing.
            myPCamera.LookDirection = new Vector3D(0, 0, -1);

            // Define camera's horizontal field of view in degrees.
            //myPCamera.FieldOfView = 60;

            // Asign the camera to the viewport
            myViewport3D.Camera = myPCamera;
            // Define the lights cast in the scene. Without light, the 3D object cannot
            // be seen. Note: to illuminate an object from additional directions, create
            // additional lights.
            DirectionalLight myDirectionalLight = new DirectionalLight();

            myDirectionalLight.Color     = Colors.White;
            myDirectionalLight.Direction = new Vector3D(-0.61, -0.5, -0.61);

            myModel3DGroup.Children.Add(myDirectionalLight);

            // The geometry specifes the shape of the 3D plane. In this sample, a flat sheet
            // is created.
            MeshGeometry3D myMeshGeometry3D = new MeshGeometry3D();

            // Create a collection of normal vectors for the MeshGeometry3D.
            Vector3DCollection myNormalCollection = new Vector3DCollection();

            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myMeshGeometry3D.Normals = myNormalCollection;

            // Create a collection of vertex positions for the MeshGeometry3D.
            Point3DCollection myPositionCollection = new Point3DCollection();

            myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
            myPositionCollection.Add(new Point3D(0.5, -0.5, 0.5));
            myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
            myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
            myPositionCollection.Add(new Point3D(-0.5, 0.5, 0.5));
            myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
            myMeshGeometry3D.Positions = myPositionCollection;

            // Create a collection of texture coordinates for the MeshGeometry3D.
            PointCollection myTextureCoordinatesCollection = new PointCollection();

            myTextureCoordinatesCollection.Add(new Point(0, 0));
            myTextureCoordinatesCollection.Add(new Point(1, 0));
            myTextureCoordinatesCollection.Add(new Point(1, 1));
            myTextureCoordinatesCollection.Add(new Point(1, 1));
            myTextureCoordinatesCollection.Add(new Point(0, 1));
            myTextureCoordinatesCollection.Add(new Point(0, 0));
            myMeshGeometry3D.TextureCoordinates = myTextureCoordinatesCollection;

            // Create a collection of triangle indices for the MeshGeometry3D.
            Int32Collection myTriangleIndicesCollection = new Int32Collection();

            myTriangleIndicesCollection.Add(0);
            myTriangleIndicesCollection.Add(1);
            myTriangleIndicesCollection.Add(2);
            myTriangleIndicesCollection.Add(3);
            myTriangleIndicesCollection.Add(4);
            myTriangleIndicesCollection.Add(5);
            myMeshGeometry3D.TriangleIndices = myTriangleIndicesCollection;

            // Apply the mesh to the geometry model.
            myGeometryModel.Geometry = myMeshGeometry3D;

            // The material specifies the material applied to the 3D object. In this sample a
            // linear gradient covers the surface of the 3D object.

            // Create a horizontal linear gradient with four stops.
            LinearGradientBrush myHorizontalGradient = new LinearGradientBrush();

            myHorizontalGradient.StartPoint = new Point(0, 0.5);
            myHorizontalGradient.EndPoint   = new Point(1, 0.5);
            myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
            myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Red, 0.25));
            myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Blue, 0.75));
            myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.LimeGreen, 1.0));

            // Define material and apply to the mesh geometries.
            DiffuseMaterial myMaterial = new DiffuseMaterial(myHorizontalGradient);

            myGeometryModel.Material = myMaterial;

            // Apply a transform to the object. In this sample, a rotation transform is applied,
            // rendering the 3D object rotated.
            RotateTransform3D   myRotateTransform3D   = new RotateTransform3D();
            AxisAngleRotation3D myAxisAngleRotation3d = new AxisAngleRotation3D();

            myAxisAngleRotation3d.Axis   = new Vector3D(0, 3, 0);
            myAxisAngleRotation3d.Angle  = 40;
            myRotateTransform3D.Rotation = myAxisAngleRotation3d;
            myGeometryModel.Transform    = myRotateTransform3D;

            // Add the geometry model to the model group.
            myModel3DGroup.Children.Add(myGeometryModel);

            // Add the group of models to the ModelVisual3d.
            myModelVisual3D.Content = myModel3DGroup;

            //
            myViewport3D.Children.Add(myModelVisual3D);

            // Apply the viewport to the page so it will be rendered.
            this.Content = myViewport3D;
        }
Пример #25
0
        /// <summary>
        /// Draw an arch
        /// </summary>
        /// <param name="matWindow">Brush for the arch.</param>
        /// <param name="matBorder">Brush for the arch borders.</param>
        /// <param name="p1">Bottom left corner point of the arch.</param>
        /// <param name="p2">Bottom right corner point of the arch.</param>
        /// <param name="borderWidth">Border width</param>
        private void DrawArch(Material matWindow, Material matBorder, Point3D p1, Point3D p2, double width, bool isFull = false)
        {
            // The geometry specifes the shape of the 3D plane.
            MeshGeometry3D winGeometryIn  = new MeshGeometry3D();
            MeshGeometry3D winGeometryOut = new MeshGeometry3D();

            // Create a collection of vertex positions for the MeshGeometry3D.
            Point3DCollection winPositionsIn  = new Point3DCollection();
            Point3DCollection winPositionsOut = new Point3DCollection();

            // Create a collection of triangle indices for the MeshGeometry3D.
            Int32Collection winTriangleIndicesIn  = new Int32Collection();
            Int32Collection winTriangleIndicesOut = new Int32Collection();

            // Calculate the coordinates of the left and right borders.
            double dx        = p2.X - p1.X;
            double dy        = p2.Y - p1.Y;
            double dz        = 0.0;
            double radiusIn  = 0.5 * Math.Sqrt(dx * dx + dy * dy + dz * dz);
            double radiusOut = radiusIn + width;
            double ratio     = radiusOut / radiusIn;
            int    num       = 18;
            double dAngle    = Math.Atan(1.0) * 4.0 / ((double)num);
            double angle     = 0.0;

            if (isFull)
            {
                num += num;
            }

            // Arch center
            double x0 = (p1.X + p2.X) * 0.5;
            double y0 = (p1.Y + p2.Y) * 0.5;
            double z0 = p2.Z;

            dz = radiusIn + radiusIn;
            winPositionsIn.Add(new Point3D(x0, y0, z0));

            for (int i = 0; i <= num; i++)
            {
                // sin(angle) and cos(angle)
                double ratioZ  = Math.Sin(angle);
                double ratioXY = Math.Cos(angle);

                // Coordinate of the inner perimeter
                double xIn = x0 + 0.5 * dx * ratioXY;
                double yIn = y0 + 0.5 * dy * ratioXY;
                double zIn = z0 + 0.5 * dz * ratioZ;

                // Coordinate of the outer perimeter
                double xOut = x0 + (xIn - x0) * ratio;
                double yOut = y0 + (yIn - y0) * ratio;
                double zOut = z0 + (zIn - z0) * ratio;

                Point3D pIn  = new Point3D(xIn, yIn, zIn);
                Point3D pOut = new Point3D(xOut, yOut, zOut);

                winPositionsIn.Add(pIn);
                winPositionsOut.Add(pIn);
                winPositionsOut.Add(pOut);

                if (i > 0)
                {
                    // Inner triangle
                    winTriangleIndicesIn.Add(0);
                    winTriangleIndicesIn.Add(i);
                    winTriangleIndicesIn.Add(i + 1);

                    // Two outer border triangles
                    int index1 = i + i - 2;
                    int index2 = i + i - 1;
                    int index3 = i + i;
                    int index4 = i + i + 1;

                    winTriangleIndicesOut.Add(index1);
                    winTriangleIndicesOut.Add(index2);
                    winTriangleIndicesOut.Add(index4);

                    winTriangleIndicesOut.Add(index1);
                    winTriangleIndicesOut.Add(index4);
                    winTriangleIndicesOut.Add(index3);
                }

                angle += dAngle;
            }

            // Draw the window (inner)
            winGeometryIn.Positions       = winPositionsIn;
            winGeometryIn.TriangleIndices = winTriangleIndicesIn;
            GeometryModel3D windowIn = new GeometryModel3D(winGeometryIn, matWindow);

            exteriorWalls.Children.Add(windowIn);

            // Draw the border (outer
            winGeometryOut.Positions       = winPositionsOut;
            winGeometryOut.TriangleIndices = winTriangleIndicesOut;
            GeometryModel3D windowOut = new GeometryModel3D(winGeometryOut, matBorder);

            exteriorWalls.Children.Add(windowOut);
        }
Пример #26
0
        public EmissiveMaterialExample()
        {
            // Declare scene objects.
            Viewport3D      myViewport3D    = new Viewport3D();
            Model3DGroup    myModel3DGroup  = new Model3DGroup();
            GeometryModel3D myGeometryModel = new GeometryModel3D();
            ModelVisual3D   myModelVisual3D = new ModelVisual3D();

            // Defines the camera used to view the 3D object. In order to view the 3D object,
            // the camera must be positioned and pointed such that the object is within view
            // of the camera.
            PerspectiveCamera myPCamera = new PerspectiveCamera();

            // Specify where in the 3D scene the camera is.
            myPCamera.Position = new Point3D(0, 0, 2);

            // Specify the direction that the camera is pointing.
            myPCamera.LookDirection = new Vector3D(0, 0, -1);

            // Define camera's horizontal field of view in degrees.
            myPCamera.FieldOfView = 60;

            // Asign the camera to the viewport
            myViewport3D.Camera = myPCamera;

            // Define the lights cast in the scene. Without light, the 3D object cannot
            // be seen. Note: to illuminate an object from additional directions, create
            // additional lights.
            DirectionalLight myDirectionalLight = new DirectionalLight();

            myDirectionalLight.Color     = Colors.White;
            myDirectionalLight.Direction = new Vector3D(-0.61, -0.5, -0.61);

            myModel3DGroup.Children.Add(myDirectionalLight);

            // The geometry specifes the shape of the 3D plane. In this sample, a flat sheet
            // is created.
            MeshGeometry3D myMeshGeometry3D = new MeshGeometry3D();

            // Create a collection of normal vectors for the MeshGeometry3D.
            Vector3DCollection myNormalCollection = new Vector3DCollection();

            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myMeshGeometry3D.Normals = myNormalCollection;

            // Create a collection of vertex positions for the MeshGeometry3D.
            Point3DCollection myPositionCollection = new Point3DCollection();

            myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
            myPositionCollection.Add(new Point3D(0.5, -0.5, 0.5));
            myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
            myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
            myPositionCollection.Add(new Point3D(-0.5, 0.5, 0.5));
            myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
            myMeshGeometry3D.Positions = myPositionCollection;

            // Create a collection of texture coordinates for the MeshGeometry3D.
            PointCollection myTextureCoordinatesCollection = new PointCollection();

            myTextureCoordinatesCollection.Add(new Point(0, 0));
            myTextureCoordinatesCollection.Add(new Point(1, 0));
            myTextureCoordinatesCollection.Add(new Point(1, 1));
            myTextureCoordinatesCollection.Add(new Point(1, 1));
            myTextureCoordinatesCollection.Add(new Point(0, 1));
            myTextureCoordinatesCollection.Add(new Point(0, 0));
            myMeshGeometry3D.TextureCoordinates = myTextureCoordinatesCollection;

            // Create a collection of triangle indices for the MeshGeometry3D.
            Int32Collection myTriangleIndicesCollection = new Int32Collection();

            myTriangleIndicesCollection.Add(0);
            myTriangleIndicesCollection.Add(1);
            myTriangleIndicesCollection.Add(2);
            myTriangleIndicesCollection.Add(3);
            myTriangleIndicesCollection.Add(4);
            myTriangleIndicesCollection.Add(5);
            myMeshGeometry3D.TriangleIndices = myTriangleIndicesCollection;

            // Apply the mesh to the geometry model.
            myGeometryModel.Geometry = myMeshGeometry3D;
            // <SnippetEmissiveMaterialCodeExampleInline1>
            // The material property of GeometryModel3D specifies the material applied to the 3D object.
            // In this sample the material applied to the 3D object is made up of two materials layered
            // on top of each other - a DiffuseMaterial (gradient brush) with an EmissiveMaterial
            // layered on top (blue SolidColorBrush). The EmmisiveMaterial alters the appearance of
            // the gradient toward blue.

            // Create a horizontal linear gradient with four stops.
            LinearGradientBrush myHorizontalGradient = new LinearGradientBrush();

            myHorizontalGradient.StartPoint = new Point(0, 0.5);
            myHorizontalGradient.EndPoint   = new Point(1, 0.5);
            myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
            myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Red, 0.25));
            myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Blue, 0.75));
            myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.LimeGreen, 1.0));

            // Define material that will use the gradient.
            DiffuseMaterial myDiffuseMaterial = new DiffuseMaterial(myHorizontalGradient);

            // Add this gradient to a MaterialGroup.
            MaterialGroup myMaterialGroup = new MaterialGroup();

            myMaterialGroup.Children.Add(myDiffuseMaterial);

            // Define an Emissive Material with a blue brush.
            Color c = new Color();

            c.ScA = 1;
            c.ScB = 255;
            c.ScR = 0;
            c.ScG = 0;
            EmissiveMaterial myEmissiveMaterial = new EmissiveMaterial(new SolidColorBrush(c));

            // Add the Emmisive Material to the Material Group.
            myMaterialGroup.Children.Add(myEmissiveMaterial);

            // Add the composite material to the 3D model.
            myGeometryModel.Material = myMaterialGroup;
            // </SnippetEmissiveMaterialCodeExampleInline1>
            // Apply a transform to the object. In this sample, a rotation transform is applied,
            // rendering the 3D object rotated.
            RotateTransform3D   myRotateTransform3D   = new RotateTransform3D();
            AxisAngleRotation3D myAxisAngleRotation3d = new AxisAngleRotation3D();

            myAxisAngleRotation3d.Axis   = new Vector3D(0, 3, 0);
            myAxisAngleRotation3d.Angle  = 40;
            myRotateTransform3D.Rotation = myAxisAngleRotation3d;
            myGeometryModel.Transform    = myRotateTransform3D;

            // Add the geometry model to the model group.
            myModel3DGroup.Children.Add(myGeometryModel);

            // Add the group of models to the ModelVisual3d.
            myModelVisual3D.Content = myModel3DGroup;
            myViewport3D.Children.Add(myModelVisual3D);

            // Apply the viewport to the page so it will be rendered.
            this.Content = myViewport3D;
        }
Пример #27
0
        /// <summary>
        /// Retrieves data that you use to construct valid "product finder" queries
        /// (queries against multiple attributes) against catalog products or (in some cases) listed items.
        /// The attributes describe search criteria (e.g., Manufacturer), as appropriate for the category.
        /// Use the results in combination with GetProductFinderXSL to render the Product Finder
        /// in a graphical user interface.
        /// 
        /// GetProductFinder does not conduct the actual product or listing search.
        /// It only returns data about what you can search on. Use the data as input to
        /// GetProductSearchResults to conduct the actual search for product information
        /// or as input to GetSearchResults to conduct the search for listed items.
        /// (Please note that this call may not return valid product finder IDs for some
        /// GetSearchResults use cases. See the Knowledge Base article referenced below for details.)
        /// 
        /// To retrieve single-attribute search criteria (querying against a single attribute, like UPC),
        /// use GetProductSearchPage instead (only applicable for catalog searches).
        /// 
        /// See the eBay Web Services Guide for an overview of Pre-filled Item Information and details about
        /// searching for catalog products and for information about searching for listed items.
        /// </summary>
        /// 
        /// <param name="AttributeVersion">
        /// A version of the product finder attribute definitions for the site.
        /// Typically, an application passes the version value that was returned the last
        /// time the application executed this call.
        /// Filter that causes the call to return only the Product Finders
        /// for which the attribute meta-data has changed since the specified version.
        /// The latest version value is not necessarily greater than the previous
        /// value that was returned. Therefore, when comparing versions, only
        /// compare whether the value has changed.
        /// </param>
        ///
        /// <param name="ProductFinderIDList">
        /// A number that uniquely identifies a product finder. 
        /// 
        /// For sell-side searches, you can determine the
        /// product finder IDs for a category by calling GetCategory2CS.
        /// 
        /// For buy-side searches, you can't use GetCategory2CS to reliably determine 
        /// the product finder IDs for an eBay category. 
        /// GetProductFinder may work for some attributes. Alternatively, you can 
        /// use the pfid parameter from the URL of the Product Finder search page 
        /// on the site you're interested in. 
        /// See the Knowledge Base article referenced below for more details.
        /// 
        /// Multiple categories can be mapped to the same product finder ID.
        /// You can pass zero or multiple IDs in the request. When IDs are specified, the call
        /// only returns product finder meta-data for the specified product finders.
        /// When no IDs are specified, the call returns all the current product finder
        /// meta-data available on the site.
        /// </param>
        ///
        public string GetProductFinder(string AttributeVersion, Int32Collection ProductFinderIDList)
        {
            this.AttributeVersion = AttributeVersion;
            this.ProductFinderIDList = ProductFinderIDList;

            Execute();
            return ApiResponse.AttributeSystemVersion;
        }
Пример #28
0
        public void AddTotalAndOthers(System.Data.DataTable i_Table, Int32Collection outerRows, Int32Collection innerRows)
        {
            if (this.RootGroupInfo == null)
            {
                return;
            }

            GroupResultCollection m_newResults = new GroupResultCollection();

            GroupResult m_TotalGroupResult = new GroupResult();

            m_TotalGroupResult.Summaries = new GroupSummaryCollection();

            GroupResult m_OtherGroupResult = new GroupResult();

            m_OtherGroupResult.Summaries = new GroupSummaryCollection();

            if (this.TotalPosition != TotalType.None)
            {
                #region Caclculate Result for Total

                m_TotalGroupResult.GroupValue = this.RootGroupInfo.TotalTitle;

                m_TotalGroupResult.RowIndicators = new Int32Collection();

                m_TotalGroupResult.ParentGroupInfo = this.RootGroupInfo;  //Add at 2009-2-19 14:23:47@Simon

                innerRows.CopyTo(m_TotalGroupResult.RowIndicators);

                if (this.RootGroupInfo.Summaries.Count > 0)
                {
                    GroupSummary summaryTotal = this.SummaryForTotalGroup.Copy();

                    m_TotalGroupResult.Summaries.Add(summaryTotal);

                    m_TotalGroupResult.CalculateSummaryResult(i_Table, innerRows, innerRows);
                }

                m_TotalGroupResult.SubGroupInfos = RootGroupInfo.SubGroupInfos.Copy();

                foreach (GroupInfo subGroupInfo in m_TotalGroupResult.SubGroupInfos)
                {
                    subGroupInfo.CalculateGroupResult(i_Table, outerRows, outerRows, innerRows, subGroupInfo);
                }
                #endregion
            }
            if (this.TotalPosition == TotalType.AllBefore)
            {
                m_newResults.Add(m_TotalGroupResult);
            }
            if (this.TotalOthersPosition == TotalType.AllBefore)
            {
                m_newResults.Add(m_OtherGroupResult);
            }

            Int32Collection m_OtherRowsTotal = new Int32Collection();

            for (int i = 0; i < this.RootGroupInfo.GroupResults.Count; i++)
            {
                if (i >= this.HorizonTopCount && HorizonTopCount > 0)
                {
                    m_OtherRowsTotal = m_OtherRowsTotal.Combine(this.RootGroupInfo.GroupResults[i].RowIndicators, m_OtherRowsTotal);
                }
                else
                {
                    m_newResults.Add(this.RootGroupInfo.GroupResults[i]);
                }
            }

            if (this.TotalOthersPosition != TotalType.None)
            {
                #region calculate Other results

                m_OtherGroupResult.GroupValue = this.TotalOthersName;

                m_OtherGroupResult.RowIndicators = new Int32Collection();

                m_OtherGroupResult.ParentGroupInfo = this.RootGroupInfo;  //Add at 2009-2-19 14:23:47@Simon

                m_OtherRowsTotal.CopyTo(m_OtherGroupResult.RowIndicators);

                if (this.RootGroupInfo.Summaries.Count > 0)
                {
                    GroupSummary summaryTotal = this.SummaryForOthers.Copy();

                    m_OtherGroupResult.Summaries.Add(summaryTotal);

                    m_OtherGroupResult.CalculateSummaryResult(i_Table, outerRows, m_OtherRowsTotal);
                }

                m_OtherGroupResult.SubGroupInfos = this.RootGroupInfo.SubGroupInfos.Copy();

                foreach (GroupInfo subGroupInfo in m_OtherGroupResult.SubGroupInfos)
                {
                    subGroupInfo.CalculateGroupResult(i_Table, m_OtherRowsTotal, outerRows, m_OtherRowsTotal, subGroupInfo);
                }
                #endregion
            }

            if (this.TotalOthersPosition == TotalType.AllAfter)
            {
                m_newResults.Add(m_OtherGroupResult);
            }
            if (this.TotalPosition == TotalType.AllAfter)
            {
                m_newResults.Add(m_TotalGroupResult);
            }

            this.RootGroupInfo.ResetGroupResults(m_newResults);
        }
Пример #29
0
        private static void AddFace(Point3DCollection positions, Int32Collection triangleIndices, Face face, Coords coords)
        {
            const int    triangleDensity = 10;
            const double delta           = 1d / triangleDensity;

            switch (face)
            {
            case Face.Front:
                AddFaceTriangles3(
                    positions, triangleIndices,
                    TranslatePoint(coords.X, coords.Y, -coords.Z),
                    TranslatePoint(coords.X + delta, coords.Y, -coords.Z),
                    TranslatePoint(coords.X + delta, coords.Y + delta, -coords.Z),
                    TranslatePoint(coords.X, coords.Y + delta, -coords.Z),
                    triangleDensity,
                    0, delta, 0,
                    delta, 0, 0);
                break;

            case Face.Back:
                AddFaceTriangles3(
                    positions, triangleIndices,
                    TranslatePoint(coords.X + delta, coords.Y, -coords.Z - 1),
                    TranslatePoint(coords.X, coords.Y, -coords.Z - 1),
                    TranslatePoint(coords.X, coords.Y + delta, -coords.Z - 1),
                    TranslatePoint(coords.X + delta, coords.Y + delta, -coords.Z - 1),
                    triangleDensity,
                    0, delta, 0,
                    delta, 0, 0);
                break;

            case Face.Left:
                AddFaceTriangles3(
                    positions, triangleIndices,
                    TranslatePoint(coords.X, coords.Y, -coords.Z - delta),
                    TranslatePoint(coords.X, coords.Y, -coords.Z),
                    TranslatePoint(coords.X, coords.Y + delta, -coords.Z),
                    TranslatePoint(coords.X, coords.Y + delta, -coords.Z - delta),
                    triangleDensity,
                    0, delta, 0,
                    0, 0, -delta);
                break;

            case Face.Right:
                AddFaceTriangles3(
                    positions, triangleIndices,
                    TranslatePoint(coords.X + 1, coords.Y, -coords.Z),
                    TranslatePoint(coords.X + 1, coords.Y, -coords.Z - delta),
                    TranslatePoint(coords.X + 1, coords.Y + delta, -coords.Z - delta),
                    TranslatePoint(coords.X + 1, coords.Y + delta, -coords.Z),
                    triangleDensity,
                    0, delta, 0,
                    0, 0, -delta);
                break;

            case Face.Top:
                AddFaceTriangles3(
                    positions, triangleIndices,
                    TranslatePoint(coords.X, coords.Y + 1, -coords.Z),
                    TranslatePoint(coords.X + delta, coords.Y + 1, -coords.Z),
                    TranslatePoint(coords.X + delta, coords.Y + 1, -coords.Z - delta),
                    TranslatePoint(coords.X, coords.Y + 1, -coords.Z - delta),
                    triangleDensity,
                    0, 0, -delta,
                    delta, 0, 0);
                break;

            case Face.Bottom:
                AddFaceTriangles3(
                    positions, triangleIndices,
                    TranslatePoint(coords.X + delta, coords.Y, -coords.Z - delta),
                    TranslatePoint(coords.X + delta, coords.Y, -coords.Z),
                    TranslatePoint(coords.X, coords.Y, -coords.Z),
                    TranslatePoint(coords.X, coords.Y, -coords.Z - delta),
                    triangleDensity,
                    delta, 0, 0,
                    0, 0, -delta);
                break;
            }
        }
Пример #30
0
        public static void BuildMeshData(Func <int, int, double> data, int width, int height,
                                         out Point3DCollection points, out PointCollection textureCoordinates, out Int32Collection triangleIndices,
                                         double textureWidth = 1, double textureHeight = 1)
        {
            int pointCount = width * height;

            points             = new Point3DCollection(pointCount);
            textureCoordinates = new PointCollection(pointCount);

            int triangleCount = 2 * (width - 1) * (height - 1);

            triangleIndices = new Int32Collection(3 * triangleCount);

            for (int iy = 0; iy < height; ++iy)
            {
                double yProportion = iy / (height - 1.0);
                double outY        = 0.5 - yProportion;
                double textureY    = textureHeight * yProportion;

                for (int ix = 0; ix < width; ++ix)
                {
                    double xProportion = ix / (width - 1.0);
                    double outX        = xProportion - 0.5;
                    double textureX    = textureWidth * xProportion;

                    points.Add(new Point3D(outX, outY, data(ix, iy)));
                    textureCoordinates.Add(new Point(textureX, textureY));

                    if (ix < (width - 1) && iy < (height - 1))
                    {
                        int topLeftIndex    = ix + iy * width;
                        int bottomLeftIndex = topLeftIndex + width;

                        triangleIndices.Add(bottomLeftIndex);
                        triangleIndices.Add(bottomLeftIndex + 1);
                        triangleIndices.Add(topLeftIndex);

                        triangleIndices.Add(bottomLeftIndex + 1);
                        triangleIndices.Add(topLeftIndex + 1);
                        triangleIndices.Add(topLeftIndex);
                    }
                }
            }

            Debug.WriteLine("In MeshHelper");
        }
		/// <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;
		}
Пример #32
0
        protected override void BeginTransition3D(
            TransitionPresenter transitionElement,
            ContentPresenter oldContent,
            ContentPresenter newContent,
            Viewport3D viewport)
        {
            Size size = transitionElement.RenderSize;

            Point   mouse2D = Mouse.GetPosition(transitionElement);
            Point3D mouse   = new Point3D(mouse2D.X, mouse2D.Y, 0.5 * size.Width);

            int xparticles = 10, yparticles = 10;

            if (size.Width > size.Height)
            {
                yparticles = (int)(xparticles * size.Height / size.Width);
            }
            else
            {
                xparticles = (int)(yparticles * size.Width / size.Height);
            }

            double   sx = 1.0 / xparticles, sy = 1.0 / yparticles;
            Vector3D u          = new Vector3D(size.Width * sx, 0, 0);
            Vector3D v          = new Vector3D(0, size.Height * sy, 0);
            Brush    cloneBrush = CreateBrush(oldContent);
            Material clone      = new DiffuseMaterial(cloneBrush);

            Vector3D[] velocities        = new Vector3D[xparticles * yparticles];
            Vector3D[] angularVelocities = new Vector3D[xparticles * yparticles];
            Point3D[]  centers           = new Point3D[xparticles * yparticles];

            Point3DCollection positions = new Point3DCollection(4 * xparticles * yparticles);
            PointCollection   textures  = new PointCollection(4 * xparticles * yparticles);
            Int32Collection   triangles = new Int32Collection(6 * xparticles * yparticles);
            int n = 0;

            for (int i = 0; i < xparticles; i++)
            {
                for (int j = 0; j < yparticles; j++)
                {
                    Point3D topleft = (Point3D)(i * u + j * v);
                    positions.Add(topleft);
                    positions.Add(topleft + u);
                    positions.Add(topleft + u + v);
                    positions.Add(topleft + v);

                    textures.Add(new Point(i * sx, j * sy));
                    textures.Add(new Point((i + 1) * sx, j * sy));
                    textures.Add(new Point((i + 1) * sx, (j + 1) * sy));
                    textures.Add(new Point(i * sx, (j + 1) * sy));

                    triangles.Add(n);
                    triangles.Add(n + 2);
                    triangles.Add(n + 1);

                    triangles.Add(n);
                    triangles.Add(n + 3);
                    triangles.Add(n + 2);

                    Vector3D f0 = positions[n] - mouse;
                    Vector3D f1 = positions[n + 1] - mouse;
                    Vector3D f2 = positions[n + 2] - mouse;
                    Vector3D f3 = positions[n + 3] - mouse;

                    f0 = f0 / f0.LengthSquared;
                    f1 = f1 / f1.LengthSquared;
                    f2 = f2 / f2.LengthSquared;
                    f3 = f3 / f3.LengthSquared;

                    velocities[n / 4] = 2 * size.Width * (f0 + f1 + f2 + f3);

                    Point3D center = centers[n / 4] = (Point3D)((i + 0.5) * u + (j + 0.5) * v);
                    angularVelocities[n / 4] = 200 * (Vector3D.CrossProduct(f0, positions[n] - center) +
                                                      Vector3D.CrossProduct(f1, positions[n + 1] - center) +
                                                      Vector3D.CrossProduct(f2, positions[n + 2] - center) +
                                                      Vector3D.CrossProduct(f3, positions[n + 3] - center));

                    n += 4;
                }
            }

            MeshGeometry3D mesh = new MeshGeometry3D();

            mesh.Positions          = positions;
            mesh.TextureCoordinates = textures;
            mesh.TriangleIndices    = triangles;

            GeometryModel3D geometryModel = new GeometryModel3D(mesh, clone);

            geometryModel.BackMaterial = clone;
            ModelVisual3D model = new ModelVisual3D();

            model.Content = geometryModel;
            viewport.Children.Add(model);

            DispatcherTimer timer        = new DispatcherTimer();
            int             t            = 0;
            double          opacityDelta = 1.0 / (Duration.TimeSpan.Seconds * 60.0);

            timer.Interval = TimeSpan.FromSeconds(1.0 / 60.0);
            timer.Tick    += delegate
            {
                t++;
                cloneBrush.Opacity = 1 - t * opacityDelta;
                if (cloneBrush.Opacity < opacityDelta)
                {
                    timer.Stop();
                    EndTransition(transitionElement, oldContent, newContent);
                    return;
                }
                mesh.Positions = null;
                AxisAngleRotation3D axisAngle = new AxisAngleRotation3D();
                RotateTransform3D   rotation  = new RotateTransform3D(axisAngle, new Point3D());
                for (int i = 0; i < positions.Count; i += 4)
                {
                    Vector3D velocity = velocities[i / 4];

                    axisAngle.Axis   = angularVelocities[i / 4];
                    axisAngle.Angle  = angularVelocities[i / 4].Length;
                    rotation.CenterX = centers[i / 4].X;
                    rotation.CenterY = centers[i / 4].Y;
                    rotation.CenterZ = centers[i / 4].Z;

                    positions[i]     = rotation.Transform(positions[i]) + velocity;
                    positions[i + 1] = rotation.Transform(positions[i + 1]) + velocity;
                    positions[i + 2] = rotation.Transform(positions[i + 2]) + velocity;
                    positions[i + 3] = rotation.Transform(positions[i + 3]) + velocity;

                    centers[i / 4] += velocity;
                }
                mesh.Positions = positions;
            };
            timer.Start();
        }
Пример #33
0
        public static MeshGeometry3D SaifToMesh(string directory)
        {
            Point3DCollection  verts              = new Point3DCollection();
            Int32Collection    tris               = new Int32Collection();
            Vector3DCollection normals            = new Vector3DCollection();
            PointCollection    textureCoordinates = new PointCollection();

            StreamReader reader = new StreamReader(directory);

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                string   IdentifiedChar = line.Substring(0, 3);
                string[] CurrentLine;

                switch (IdentifiedChar)
                {
                case "Ver":
                    try
                    {
                        string vertices = line;
                        CurrentLine = vertices.Split(' ');

                        for (int i = 1; i < CurrentLine.Length - 1; i++)
                        {
                            string[] vertStr = CurrentLine[i].Split(',');

                            Point3D vert = new Point3D()
                            {
                                X = double.Parse(vertStr[0].ToString()),
                                Y = double.Parse(vertStr[1].ToString()),
                                Z = double.Parse(vertStr[2].ToString()),
                            };

                            verts.Add(vert);
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString());
                        Environment.Exit(0);
                    }
                    break;

                case "Tri":
                    try
                    {
                        string triangles = line;
                        CurrentLine = triangles.Split(' ');

                        for (int i = 1; i < CurrentLine.Length - 1; i++)
                        {
                            tris.Add(int.Parse(CurrentLine[i]));
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString());
                        Environment.Exit(0);
                    }
                    break;

                case "Nor":
                    try
                    {
                        string normalz = line;
                        CurrentLine = normalz.Split(' ');

                        for (int i = 1; i < CurrentLine.Length - 1; i++)
                        {
                            string[] normStr = CurrentLine[i].Split(',');

                            Vector3D norm = new Vector3D()
                            {
                                X = double.Parse(normStr[0].ToString()),
                                Y = double.Parse(normStr[1].ToString()),
                                Z = double.Parse(normStr[2].ToString()),
                            };

                            normals.Add(norm);
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString());
                        Environment.Exit(0);
                    }
                    break;

                case "Tex":
                    try
                    {
                        string textCoords = line;
                        CurrentLine = textCoords.Split(' ');

                        for (int i = 1; i < CurrentLine.Length - 1; i++)
                        {
                            string[] coordStr = CurrentLine[i].Split(',');

                            Point coord = new Point()
                            {
                                X = double.Parse(coordStr[0]),
                                Y = double.Parse(coordStr[1])
                            };

                            textureCoordinates.Add(coord);
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString());
                        Environment.Exit(0);
                    }
                    break;

                default:
                    break;
                }
            }
            reader.Close();

            MeshGeometry3D loadedMesh = new MeshGeometry3D()
            {
                Positions          = verts,
                TriangleIndices    = tris,
                Normals            = normals,
                TextureCoordinates = textureCoordinates
            };

            return(loadedMesh);
        }
Пример #34
0
        private static void addSquare(Point3D p1, Point3D p2, Point3D p3, Point3D p4, Int32Collection triangles, Point3DCollection points, Dictionary <Point3D, int> pointMap)
        {
            var p1i = getIndex(p1, points, pointMap);
            var p2i = getIndex(p2, points, pointMap);
            var p3i = getIndex(p3, points, pointMap);
            var p4i = getIndex(p4, points, pointMap);

            triangles.Add(p3i);
            triangles.Add(p2i);
            triangles.Add(p1i);

            triangles.Add(p3i);
            triangles.Add(p1i);
            triangles.Add(p4i);
        }
Пример #35
0
        /*Применяет произвольное 3D-преобразование к изображению*/
        public static void ApplyTransform(string input, string output, Matrix3D matr)
        {
            Viewport3D  myViewport3D;
            BitmapImage image = new BitmapImage(new Uri(input));

            // Declare scene objects.
            myViewport3D = new Viewport3D();
            Model3DGroup    myModel3DGroup  = new Model3DGroup();
            GeometryModel3D myGeometryModel = new GeometryModel3D();
            ModelVisual3D   myModelVisual3D = new ModelVisual3D();
            // Defines the camera used to view the 3D object. In order to view the 3D object,
            // the camera must be positioned and pointed such that the object is within view
            // of the camera.
            PerspectiveCamera myPCamera = new PerspectiveCamera();

            // Specify where in the 3D scene the camera is.
            myPCamera.Position = new Point3D(0, 0, Math.Max(image.PixelWidth, image.PixelHeight) * 2);

            // Specify the direction that the camera is pointing.
            myPCamera.LookDirection = new Vector3D(0, 0, -1);

            // Define camera's horizontal field of view in degrees.
            myPCamera.FieldOfView = 60;

            // Asign the camera to the viewport
            myViewport3D.Camera = myPCamera;

            // Define the lights cast in the scene. Without light, the 3D object cannot
            // be seen. Note: to illuminate an object from additional directions, create
            // additional lights.
            AmbientLight al = new AmbientLight(Colors.White);

            myModel3DGroup.Children.Add(al);

            // The geometry specifes the shape of the 3D plane. In this sample, a flat sheet
            // is created.
            MeshGeometry3D myMeshGeometry3D = new MeshGeometry3D();

            // Create a collection of normal vectors for the MeshGeometry3D.
            Vector3DCollection myNormalCollection = new Vector3DCollection();

            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myNormalCollection.Add(new Vector3D(0, 0, 1));
            myMeshGeometry3D.Normals = myNormalCollection;

            // Create a collection of vertex positions for the MeshGeometry3D.
            Point3DCollection myPositionCollection = new Point3DCollection();

            myPositionCollection.Add(new Point3D(-image.PixelWidth / 2.0, -image.PixelHeight / 2.0, 0.5));
            myPositionCollection.Add(new Point3D(image.PixelWidth / 2.0, -image.PixelHeight / 2.0, 0.5));
            myPositionCollection.Add(new Point3D(image.PixelWidth / 2.0, image.PixelHeight / 2.0, 0.5));
            myPositionCollection.Add(new Point3D(image.PixelWidth / 2.0, image.PixelHeight / 2.0, 0.5));
            myPositionCollection.Add(new Point3D(-image.PixelWidth / 2.0, image.PixelHeight / 2.0, 0.5));
            myPositionCollection.Add(new Point3D(-image.PixelWidth / 2.0, -image.PixelHeight / 2.0, 0.5));
            myMeshGeometry3D.Positions = myPositionCollection;

            // Create a collection of texture coordinates for the MeshGeometry3D.
            PointCollection myTextureCoordinatesCollection = new PointCollection();

            Point p5  = new Point(0, 0);
            Point p34 = new Point(1, 0);
            Point p2  = new Point(1, 1);
            Point p16 = new Point(0, 1);

            myTextureCoordinatesCollection.Add(p16);
            myTextureCoordinatesCollection.Add(p2);
            myTextureCoordinatesCollection.Add(p34);
            myTextureCoordinatesCollection.Add(p34);
            myTextureCoordinatesCollection.Add(p5);
            myTextureCoordinatesCollection.Add(p16);

            myMeshGeometry3D.TextureCoordinates = myTextureCoordinatesCollection;

            // Create a collection of triangle indices for the MeshGeometry3D.
            Int32Collection myTriangleIndicesCollection = new Int32Collection();

            myTriangleIndicesCollection.Add(0);
            myTriangleIndicesCollection.Add(1);
            myTriangleIndicesCollection.Add(2);
            myTriangleIndicesCollection.Add(3);
            myTriangleIndicesCollection.Add(4);
            myTriangleIndicesCollection.Add(5);
            myMeshGeometry3D.TriangleIndices = myTriangleIndicesCollection;

            // Apply the mesh to the geometry model.
            myGeometryModel.Geometry = myMeshGeometry3D;

            // The material specifies the material applied to the 3D object.

            ImageBrush br = new ImageBrush(image);

            // Define material and apply to the mesh geometries.
            DiffuseMaterial myMaterial = new DiffuseMaterial(br);

            myGeometryModel.Material     = myMaterial;
            myGeometryModel.BackMaterial = myMaterial;

            MatrixTransform3D transform = new MatrixTransform3D(matr);

            myGeometryModel.Transform = transform;

            // Add the geometry model to the model group.
            myModel3DGroup.Children.Add(myGeometryModel);

            // Add the group of models to the ModelVisual3d.
            myModelVisual3D.Content = myModel3DGroup;
            myViewport3D.Children.Add(myModelVisual3D);

            //render Viewport3D into bitmap
            int width  = image.PixelWidth;
            int height = image.PixelHeight;

            myViewport3D.Width  = width;
            myViewport3D.Height = height;
            myViewport3D.Measure(new Size(width, height));
            myViewport3D.Arrange(new Rect(0, 0, width, height));

            RenderTargetBitmap rtb = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);

            rtb.Render(myViewport3D);

            //Save bitmap to file
            using (var fileStream = new FileStream(output, FileMode.Create))
            {
                BitmapEncoder encoder = new JpegBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(rtb));
                encoder.Save(fileStream);
            }
        }
Пример #36
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        /// <param name="vertices"></param>
        /// <param name="normals"></param>
        /// <param name="indices"></param>
        /// <param name="textures"></param>
        protected override void Triangulate(DependencyPropertyChangedEventArgs args,
                                            Point3DCollection vertices,
                                            Vector3DCollection normals,
                                            Int32Collection indices,
                                            PointCollection textures)
        {
            // Clear all four collections.
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            // Begin at the top end. Fill the collections.
            for (int stack = 0; stack <= EndStacks; stack++)
            {
                double y      = Length / 2;
                double radius = stack * Radius / EndStacks;
                int    top    = (stack + 0) * (Slices + 1);
                int    bot    = (stack + 1) * (Slices + 1);

                for (int slice = 0; slice <= Slices; slice++)
                {
                    double theta = slice * 2 * Math.PI / Slices;
                    double x     = -radius *Math.Sin(theta);

                    double z = -radius *Math.Cos(theta);

                    vertices.Add(new Point3D(x, y, z));
                    normals.Add(new Vector3D(0, 1, 0));
                    textures.Add(new Point((double)slice / Slices,
                                           Fold * stack / EndStacks));

                    if (stack < EndStacks && slice < Slices)
                    {
                        if (stack != 0)
                        {
                            indices.Add(top + slice);
                            indices.Add(bot + slice);
                            indices.Add(top + slice + 1);
                        }

                        indices.Add(top + slice + 1);
                        indices.Add(bot + slice);
                        indices.Add(bot + slice + 1);
                    }
                }
            }

            int offset = vertices.Count;

            // Length of the cylinder: Fill in the collections.
            for (int stack = 0; stack <= Stacks; stack++)
            {
                double y   = Length - stack * Length / Stacks - Length / 2;
                int    top = offset + (stack + 0) * (Slices + 1);
                int    bot = offset + (stack + 1) * (Slices + 1);

                for (int slice = 0; slice <= Slices; slice++)
                {
                    double theta = slice * 2 * Math.PI / Slices;
                    double x     = -Radius *Math.Sin(theta);

                    double z = -Radius *Math.Cos(theta);

                    vertices.Add(new Point3D(x, y, z));
                    normals.Add(new Vector3D(x, 0, z));
                    textures.Add(new Point((double)slice / Slices,
                                           Fold + (1 - 2 * Fold) * stack / Stacks));

                    if (stack < Stacks && slice < Slices)
                    {
                        indices.Add(top + slice);
                        indices.Add(bot + slice);
                        indices.Add(top + slice + 1);

                        indices.Add(top + slice + 1);
                        indices.Add(bot + slice);
                        indices.Add(bot + slice + 1);
                    }
                }
            }

            offset = vertices.Count;

            // Finish with the bottom end. Fill the collections.
            for (int stack = 0; stack <= EndStacks; stack++)
            {
                double y      = -Length / 2;
                double radius = (EndStacks - stack) * Radius / EndStacks;
                int    top    = offset + (stack + 0) * (Slices + 1);
                int    bot    = offset + (stack + 1) * (Slices + 1);

                for (int slice = 0; slice <= Slices; slice++)
                {
                    double theta = slice * 2 * Math.PI / Slices;
                    double x     = -radius *Math.Sin(theta);

                    double z = -radius *Math.Cos(theta);

                    vertices.Add(new Point3D(x, y, z));
                    normals.Add(new Vector3D(0, -1, 0));
                    textures.Add(new Point((double)slice / Slices,
                                           (1 - Fold) + Fold * stack / EndStacks));

                    if (stack < EndStacks && slice < Slices)
                    {
                        indices.Add(top + slice);
                        indices.Add(bot + slice);
                        indices.Add(top + slice + 1);

                        if (stack != EndStacks - 1)
                        {
                            indices.Add(top + slice + 1);
                            indices.Add(bot + slice);
                            indices.Add(bot + slice + 1);
                        }
                    }
                }
            }
        }
Пример #37
0
        public static MeshGeometry3D CreateMeshFrom(HeightMap map)
        {
            //collect points
            var originalPoints = new Point3D[map.VoxelCountX, map.VoxelCountY];

            var centerX = (map.GetPoint(map.VoxelCountX - 1, 0).X - map.GetPoint(0, 0).X) / 2;
            var centerY = (map.GetPoint(0, map.VoxelCountY - 1).Y - map.GetPoint(0, 0).Y) / 2;

            for (var xi = 0; xi < map.VoxelCountX; ++xi)
            {
                for (var yi = 0; yi < map.VoxelCountY; ++yi)
                {
                    var point  = map.GetPoint(xi, yi);
                    var height = map.GetHeight(xi, yi);
                    originalPoints[xi, yi] = new Point3D(point.X - centerX, point.Y - centerY, height);
                }
            }

            //fill the mesh
            var pointMap = new Dictionary <Point3D, int>(3 * originalPoints.Length);

            var points    = new Point3DCollection(2 * originalPoints.Length);
            var triangles = new Int32Collection(2 * originalPoints.Length);

            for (var xi = 0; xi < map.VoxelCountX - 1; ++xi)
            {
                for (var yi = 0; yi < map.VoxelCountY - 1; ++yi)
                {
                    var p1 = originalPoints[xi, yi];
                    var p2 = originalPoints[xi + 1, yi];
                    var p3 = originalPoints[xi + 1, yi + 1];
                    var p4 = originalPoints[xi, yi + 1];

                    var zp1 = new Point3D(p1.X, p1.Y, -1);
                    var zp2 = new Point3D(p2.X, p2.Y, -1);
                    var zp3 = new Point3D(p3.X, p3.Y, -1);
                    var zp4 = new Point3D(p4.X, p4.Y, -1);

                    addSquare(p1, p2, p3, p4, triangles, points, pointMap);
                    addSquare(zp1, zp2, zp3, zp4, triangles, points, pointMap);

                    /* var np2 = new Point3D(p2.X, p2.Y, p1.Z);
                     * var np3 = new Point3D(p3.X, p3.Y, p1.Z);
                     * var np4 = new Point3D(p4.X, p4.Y, p1.Z);
                     *
                     *
                     *
                     * addSquare(p1, np2, np3, np4, triangles, points, pointMap);
                     * addSquare(p1, np2, zp1, zp2, triangles, points, pointMap);
                     * addSquare(np2, np3, zp2, zp3, triangles, points, pointMap);
                     * addSquare(np3, np4, zp3, zp4, triangles, points, pointMap);
                     * addSquare(np4, p1, zp4, zp1, triangles, points, pointMap);
                     * addSquare(zp1, zp2, zp3, zp4, triangles, points, pointMap); */
                    //addSquare(p2Index, p3Index, getIndex(p3, points, pointMap), getIndex(p4, points, pointMap), triangles);
                }
            }

            var geometry = new MeshGeometry3D();

            geometry.Positions       = points;
            geometry.TriangleIndices = triangles;

            return(geometry);
        }
Пример #38
0
        /// <summary>
        /// Use the render packages returned from the visualization manager to update the visuals.
        /// The visualization event arguments will contain a set of render packages and an id representing
        /// the associated node. Visualizations for the background preview will return an empty id.
        /// </summary>
        /// <param name="e"></param>
        private void RenderDrawables(VisualizationEventArgs e)
        {
            //check the id, if the id is meant for another watch,
            //then ignore it
            if (e.Id != _id)
            {
                return;
            }

            var sw = new Stopwatch();

            sw.Start();

            Points         = null;
            Lines          = null;
            Mesh           = null;
            XAxes          = null;
            YAxes          = null;
            ZAxes          = null;
            PointsSelected = null;
            LinesSelected  = null;
            MeshSelected   = null;
            Text           = null;
            MeshCount      = 0;

            //separate the selected packages
            var packages = e.Packages.Where(x => x.Selected == false)
                           .Where(rp => rp.TriangleVertices.Count % 9 == 0)
                           .ToArray();
            var selPackages = e.Packages
                              .Where(x => x.Selected)
                              .Where(rp => rp.TriangleVertices.Count % 9 == 0)
                              .ToArray();

            //pre-size the points collections
            var pointsCount    = packages.Select(x => x.PointVertices.Count / 3).Sum();
            var selPointsCount = selPackages.Select(x => x.PointVertices.Count / 3).Sum();
            var points         = new Point3DCollection(pointsCount);
            var pointsSelected = new Point3DCollection(selPointsCount);

            //pre-size the lines collections
            //these sizes are conservative as the axis lines will be
            //taken from the linestripvertex collections as well.
            var lineCount     = packages.Select(x => x.LineStripVertices.Count / 3).Sum();
            var lineSelCount  = selPackages.Select(x => x.LineStripVertices.Count / 3).Sum();
            var lines         = new Point3DCollection(lineCount);
            var linesSelected = new Point3DCollection(lineSelCount);
            var redLines      = new Point3DCollection(lineCount);
            var greenLines    = new Point3DCollection(lineCount);
            var blueLines     = new Point3DCollection(lineCount);

            //pre-size the text collection
            var textCount = e.Packages.Count(x => x.DisplayLabels);
            var text      = new List <BillboardTextItem>(textCount);

            //http://blogs.msdn.com/b/timothyc/archive/2006/08/31/734308.aspx
            //presize the mesh collections
            var meshVertCount    = packages.Select(x => x.TriangleVertices.Count / 3).Sum();
            var meshVertSelCount = selPackages.Select(x => x.TriangleVertices.Count / 3).Sum();

            var mesh     = new MeshGeometry3D();
            var meshSel  = new MeshGeometry3D();
            var verts    = new Point3DCollection(meshVertCount);
            var vertsSel = new Point3DCollection(meshVertSelCount);
            var norms    = new Vector3DCollection(meshVertCount);
            var normsSel = new Vector3DCollection(meshVertSelCount);
            var tris     = new Int32Collection(meshVertCount);
            var trisSel  = new Int32Collection(meshVertSelCount);

            foreach (var package in packages)
            {
                ConvertPoints(package, points, text);
                ConvertLines(package, lines, redLines, greenLines, blueLines, text);
                ConvertMeshes(package, verts, norms, tris);
            }

            foreach (var package in selPackages)
            {
                ConvertPoints(package, pointsSelected, text);
                ConvertLines(package, linesSelected, redLines, greenLines, blueLines, text);
                ConvertMeshes(package, vertsSel, normsSel, trisSel);
            }

            sw.Stop();
            Debug.WriteLine(string.Format("RENDER: {0} ellapsed for updating background preview.", sw.Elapsed));

            var vm = (IWatchViewModel)DataContext;

            if (vm.CheckForLatestRenderCommand.CanExecute(e.TaskId))
            {
                vm.CheckForLatestRenderCommand.Execute(e.TaskId);
            }

            Dispatcher.Invoke(new Action <Point3DCollection, Point3DCollection,
                                          Point3DCollection, Point3DCollection, Point3DCollection, Point3DCollection,
                                          Point3DCollection, Point3DCollection, Vector3DCollection, Int32Collection,
                                          Point3DCollection, Vector3DCollection, Int32Collection, MeshGeometry3D,
                                          MeshGeometry3D, List <BillboardTextItem> >(SendGraphicsToView), DispatcherPriority.Render,
                              new object[] { points, pointsSelected, lines, linesSelected, redLines,
                                             greenLines, blueLines, verts, norms, tris, vertsSel, normsSel,
                                             trisSel, mesh, meshSel, text });
        }
				// Construction
	
				/// <summary />
				public Enumerator(Int32Collection tc) {
					m_collection = tc;
					m_index = -1;
					m_version = tc.m_version;
				}
Пример #40
0
        private void SendGraphicsToView(Point3DCollection points, Point3DCollection pointsSelected,
                                        Point3DCollection lines, Point3DCollection linesSelected, Point3DCollection redLines, Point3DCollection greenLines,
                                        Point3DCollection blueLines, Point3DCollection verts, Vector3DCollection norms, Int32Collection tris,
                                        Point3DCollection vertsSel, Vector3DCollection normsSel, Int32Collection trisSel, MeshGeometry3D mesh,
                                        MeshGeometry3D meshSel, List <BillboardTextItem> text)
        {
            points.Freeze();
            pointsSelected.Freeze();
            lines.Freeze();
            linesSelected.Freeze();
            redLines.Freeze();
            greenLines.Freeze();
            blueLines.Freeze();
            verts.Freeze();
            norms.Freeze();
            tris.Freeze();
            vertsSel.Freeze();
            normsSel.Freeze();
            trisSel.Freeze();

            Points                  = points;
            PointsSelected          = pointsSelected;
            Lines                   = lines;
            LinesSelected           = linesSelected;
            XAxes                   = redLines;
            YAxes                   = greenLines;
            ZAxes                   = blueLines;
            mesh.Positions          = verts;
            mesh.Normals            = norms;
            mesh.TriangleIndices    = tris;
            meshSel.Positions       = vertsSel;
            meshSel.Normals         = normsSel;
            meshSel.TriangleIndices = trisSel;
            Mesh         = mesh;
            MeshSelected = meshSel;
            Text         = text;
        }
			/// <summary />
			public void AddRange(Int32Collection collection) {
				++m_version;

				Capacity += collection.Count;
				System.Array.Copy(collection.m_array, 0, this.m_array, m_count, collection.m_count);
				m_count += collection.Count;
			}
Пример #42
0
        private GeometryModel3D CreateSquare(Point3D offset, System.Windows.Media.Color theColor,
                                             double sizeX = 0.5, double sizeY = 0.5)
        {
            GeometryModel3D myGeometryModel = new GeometryModel3D();
            // The geometry specifes the shape of the 3D plane. In this sample, a flat sheet is created.
            MeshGeometry3D myMeshGeometry3D = new MeshGeometry3D();

            float zVal = 1;
            // Create a collection of normal vectors for the MeshGeometry3D.
            Vector3DCollection myNormalCollection = new Vector3DCollection();

            myNormalCollection.Add(new Vector3D(0, 0, zVal));
            myNormalCollection.Add(new Vector3D(0, 0, zVal));
            myNormalCollection.Add(new Vector3D(0, 0, zVal));
            myNormalCollection.Add(new Vector3D(0, 0, zVal));
            myNormalCollection.Add(new Vector3D(0, 0, zVal));
            myNormalCollection.Add(new Vector3D(0, 0, zVal));
            myMeshGeometry3D.Normals = myNormalCollection;

            // Create a collection of vertex positions for the MeshGeometry3D.
            Point3DCollection myPositionCollection = new Point3DCollection();

            myPositionCollection.Add(new Point3D(-sizeX + offset.X, -sizeY + offset.Y, offset.Z));
            myPositionCollection.Add(new Point3D(sizeX + offset.X, -sizeY + offset.Y, offset.Z));
            myPositionCollection.Add(new Point3D(sizeX + offset.X, sizeY + offset.Y, offset.Z));
            myPositionCollection.Add(new Point3D(sizeX + offset.X, sizeY + offset.Y, offset.Z));
            myPositionCollection.Add(new Point3D(-sizeX + offset.X, sizeY + offset.Y, offset.Z));
            myPositionCollection.Add(new Point3D(-sizeX + offset.X, -sizeY + offset.Y, offset.Z));
            myMeshGeometry3D.Positions = myPositionCollection;

            // Create a collection of texture coordinates for the MeshGeometry3D.
            PointCollection myTextureCoordinatesCollection = new PointCollection();

            myTextureCoordinatesCollection.Add(new System.Windows.Point(0, 0));
            myTextureCoordinatesCollection.Add(new System.Windows.Point(1, 0));
            myTextureCoordinatesCollection.Add(new System.Windows.Point(1, 1));
            myTextureCoordinatesCollection.Add(new System.Windows.Point(1, 1));
            myTextureCoordinatesCollection.Add(new System.Windows.Point(0, 1));
            myTextureCoordinatesCollection.Add(new System.Windows.Point(0, 0));
            myMeshGeometry3D.TextureCoordinates = myTextureCoordinatesCollection;

            // Create a collection of triangle indices for the MeshGeometry3D.
            Int32Collection myTriangleIndicesCollection = new Int32Collection();

            myTriangleIndicesCollection.Add(0);
            myTriangleIndicesCollection.Add(1);
            myTriangleIndicesCollection.Add(2);
            myTriangleIndicesCollection.Add(3);
            myTriangleIndicesCollection.Add(4);
            myTriangleIndicesCollection.Add(5);
            myMeshGeometry3D.TriangleIndices = myTriangleIndicesCollection;

            // Apply the mesh to the geometry model.
            myGeometryModel.Geometry = myMeshGeometry3D;

            SolidColorBrush theBrush = new SolidColorBrush(theColor);

            //ImageBrush theImageBrush = new ImageBrush (new System.Windows.Media.Imaging.BitmapImage(new Uri(@"C:\Users\c_sim\Pictures\Img_7837.jpg"))) ;
            // Define material and apply to the mesh geometries.
            DiffuseMaterial myMaterial = new DiffuseMaterial(theBrush);

            //SpecularMaterial myMaterial = new SpecularMaterial(theBrush,50);
            myGeometryModel.Material     = myMaterial;
            myGeometryModel.BackMaterial = myMaterial;
            return(myGeometryModel);
        }
Пример #43
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; 
        }
Пример #44
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);
        }
Пример #45
0
		/// <summary>
		/// Returns collection of Site Wide AttributeSet objects for a given array category Ids.
		/// Each element of the array contains a VCS Id, if it exists for a given category Id. 
		/// </summary>
		/// <param name="catIds">int[]</param>
		/// <returns>Collection of site wide AttributeSet objects</returns>
		public IAttributeSetCollection GetSiteWideAttributeSetsForCategories(Int32Collection catIds) 
		{
			IAttributeSetCollection attrSetsList = new AttributeSetCollection();
			int i = 0;
			foreach(int catId in catIds) 
			{
				SiteWideCharacteristicsTypeCollection swAttrs = mCategoryCSProvider.GetSiteWideCharacteristics(catId.ToString());
				foreach(SiteWideCharacteristicsType swChar in swAttrs) 
				{
					AttributeSet swAst = new AttributeSet();
					swAst.attributeSetID = swChar.CharacteristicsSet.AttributeSetID;
					swAst.CategoryID = catId;
					swAst.CategoryOrdinal = i++;
					swAst.Name = swChar.CharacteristicsSet.Name;
					attrSetsList.Add(swAst);
				}
			}

			return attrSetsList;
		}
Пример #46
0
        public void GenerateSkyDome()
        {
            //use blender model
            SkyBrush = new ImageBrush();
            SkyBrush.ViewportUnits = BrushMappingMode.Absolute;
            SkyBrush.ImageSource   = new BitmapImage(new Uri("gfx/SkyDome.png", UriKind.Relative));
            material = new DiffuseMaterial(SkyBrush);

            SkyDomeMesh  = new MeshGeometry3D();
            SkyDomeModel = new GeometryModel3D();

            PositionBuffer = SkyDomeMesh.Positions;
            NormalBuffer   = SkyDomeMesh.Normals;
            TexcoordBuffer = SkyDomeMesh.TextureCoordinates;
            IndexBuffer    = SkyDomeMesh.TriangleIndices;

            int SkyDomeDist = ApplicationSettings.chunkSize * ApplicationSettings.renderDistance + ApplicationSettings.chunkSize;
            //int SkyDomeDist = 500;

            Vector3D Normal = new Vector3D(0, 0, -1);

            Point[] tex = new Point[14];
            tex[0] = new Point(0.2505, 0.005);
            tex[1] = new Point(0.4995, 0.005);

            tex[2] = new Point(0, 0.3383);
            tex[3] = new Point(0.250, 0.3383);
            tex[4] = new Point(0.5, 0.3383);
            tex[5] = new Point(0.75, 0.3383);
            tex[6] = new Point(1, 0.3383);

            tex[7]  = new Point(0, 0.6661);
            tex[8]  = new Point(0.25, 0.6661);
            tex[9]  = new Point(0.5, 0.6661);
            tex[10] = new Point(0.75, 0.6661);
            tex[11] = new Point(1, 0.6661);

            tex[12] = new Point(0.2505, 0.995);
            tex[13] = new Point(0.4995, 0.995);

            Point3D[] pos = new Point3D[8];
            pos[0] = new Point3D(-SkyDomeDist, -SkyDomeDist, -SkyDomeDist);
            pos[1] = new Point3D(-SkyDomeDist, SkyDomeDist, -SkyDomeDist);
            pos[2] = new Point3D(SkyDomeDist, -SkyDomeDist, -SkyDomeDist);
            pos[3] = new Point3D(SkyDomeDist, SkyDomeDist, -SkyDomeDist);
            pos[4] = new Point3D(-SkyDomeDist, -SkyDomeDist, SkyDomeDist);
            pos[5] = new Point3D(-SkyDomeDist, SkyDomeDist, SkyDomeDist);
            pos[6] = new Point3D(SkyDomeDist, -SkyDomeDist, SkyDomeDist);
            pos[7] = new Point3D(SkyDomeDist, SkyDomeDist, SkyDomeDist);

            //front
            PositionBuffer.Add(pos[1]);
            PositionBuffer.Add(pos[0]);
            PositionBuffer.Add(pos[2]);
            PositionBuffer.Add(pos[2]);
            PositionBuffer.Add(pos[3]);
            PositionBuffer.Add(pos[1]);
            //right
            PositionBuffer.Add(pos[3]);
            PositionBuffer.Add(pos[2]);
            PositionBuffer.Add(pos[6]);
            PositionBuffer.Add(pos[6]);
            PositionBuffer.Add(pos[7]);
            PositionBuffer.Add(pos[3]);
            //back
            PositionBuffer.Add(pos[7]);
            PositionBuffer.Add(pos[6]);
            PositionBuffer.Add(pos[4]);
            PositionBuffer.Add(pos[4]);
            PositionBuffer.Add(pos[5]);
            PositionBuffer.Add(pos[7]);
            //left
            PositionBuffer.Add(pos[5]);
            PositionBuffer.Add(pos[4]);
            PositionBuffer.Add(pos[0]);
            PositionBuffer.Add(pos[0]);
            PositionBuffer.Add(pos[1]);
            PositionBuffer.Add(pos[5]);
            //top
            PositionBuffer.Add(pos[3]);
            PositionBuffer.Add(pos[7]);
            PositionBuffer.Add(pos[5]);
            PositionBuffer.Add(pos[5]);
            PositionBuffer.Add(pos[1]);
            PositionBuffer.Add(pos[3]);
            //bottom
            PositionBuffer.Add(pos[0]);
            PositionBuffer.Add(pos[4]);
            PositionBuffer.Add(pos[6]);
            PositionBuffer.Add(pos[6]);
            PositionBuffer.Add(pos[2]);
            PositionBuffer.Add(pos[0]);

            for (int i = 0; i < SkyDomeMesh.Positions.Count; i++)
            {
                IndexBuffer.Add(i);
                NormalBuffer.Add(Normal);
            }
            //front
            TexcoordBuffer.Add(tex[3]);
            TexcoordBuffer.Add(tex[8]);
            TexcoordBuffer.Add(tex[9]);
            TexcoordBuffer.Add(tex[9]);
            TexcoordBuffer.Add(tex[4]);
            TexcoordBuffer.Add(tex[3]);
            //right
            TexcoordBuffer.Add(tex[4]);
            TexcoordBuffer.Add(tex[9]);
            TexcoordBuffer.Add(tex[10]);
            TexcoordBuffer.Add(tex[10]);
            TexcoordBuffer.Add(tex[5]);
            TexcoordBuffer.Add(tex[4]);
            //back
            TexcoordBuffer.Add(tex[5]);
            TexcoordBuffer.Add(tex[10]);
            TexcoordBuffer.Add(tex[11]);
            TexcoordBuffer.Add(tex[11]);
            TexcoordBuffer.Add(tex[6]);
            TexcoordBuffer.Add(tex[5]);
            //left
            TexcoordBuffer.Add(tex[2]);
            TexcoordBuffer.Add(tex[7]);
            TexcoordBuffer.Add(tex[8]);
            TexcoordBuffer.Add(tex[8]);
            TexcoordBuffer.Add(tex[3]);
            TexcoordBuffer.Add(tex[2]);
            //top
            TexcoordBuffer.Add(tex[0]);
            TexcoordBuffer.Add(tex[3]);
            TexcoordBuffer.Add(tex[4]);
            TexcoordBuffer.Add(tex[4]);
            TexcoordBuffer.Add(tex[1]);
            TexcoordBuffer.Add(tex[0]);
            //bottom
            TexcoordBuffer.Add(tex[8]);
            TexcoordBuffer.Add(tex[12]);
            TexcoordBuffer.Add(tex[13]);
            TexcoordBuffer.Add(tex[13]);
            TexcoordBuffer.Add(tex[9]);
            TexcoordBuffer.Add(tex[8]);

            SkyDomeModel          = new GeometryModel3D();
            SkyDomeModel.Geometry = SkyDomeMesh;
            SkyDomeModel.Material = material;

            MainWindow.AttachGeometry(SkyDomeModel, "SkyDome");
        }
Пример #47
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;
        }
Пример #48
0
        MeshGeometry3D GenMesh()
        {   // 00 - 01 - 02 - 03 ...
            //    /    /
            // 10 - 11 - 12
            // Nx * Ny Points
            // triangles = (Nx-1)*(Ny-1) * 2
            int Nx = 20;
            int Ny = 5;
            // th = 180 ~ 0 dth = + 180/(Nx-1)
            double th0 = -180;
            double dth = (0 - 360.0) / (double)(Nx - 1);
            double x0  = 0.5;

            //double R0 = 0.5;
            Point3D[,] p3Dm2D = new Point3D[Nx, Ny];
            for (int i = 0; i < Nx; i++)
            {
                for (int j = 0; j < Ny; j++)
                {
                    // Rectangle

                    /* double x = 1.0 / (double)(Nx - 1) * i;
                     * double y = 1.0 / (double)(Ny - 1) * j;
                     * double z = 0; */
                    // Cylinder
                    double th = th0 + i * dth;
                    double x  = x0 + R0 * Math.Cos(th / 180 * Math.PI);
                    double y  = 1.0 / (double)(Ny - 1) * j;
                    double z  = R0 * Math.Sin(th / 180 * Math.PI);
                    p3Dm2D[i, j] = new Point3D(x, y, z);
                }
            }
            Point[,] pTexture = new Point[Nx, Ny];
            for (int i = 0; i < Nx; i++)
            {
                for (int j = 0; j < Ny; j++)
                {
                    pTexture[i, j] = new Point(1.0 / (double)(Nx - 1) * i, 1.0 - (1.0 / (double)(Ny - 1) * j));
                }
            }
            MeshGeometry3D    mesh1 = new MeshGeometry3D();
            Point3DCollection pts   = new Point3DCollection();

            for (int i = 0; i < Nx; i++)
            {
                for (int j = 0; j < Ny; j++)
                {
                    pts.Add(p3Dm2D[i, j]);
                }
            }
            PointCollection tpts = new PointCollection();

            for (int i = 0; i < Nx; i++)
            {
                for (int j = 0; j < Ny; j++)
                {
                    tpts.Add(pTexture[i, j]);
                }
            }
            Int32Collection tri = new Int32Collection();

            // (i,j)  (1)    i+1,j (2)
            //
            // i, j+1 (0)   i+1, j+1 (3)
            // tri 0,1,2,2,3,1
            for (int i = 0; i < Nx - 1; i++)
            {
                for (int j = 0; j < Ny - 1; j++)
                {
                    tri.Add(j + Ny * i);             //1
                    tri.Add(j + 1 + Ny * i);         //0

                    tri.Add(j + Ny * (i + 1));       //2
                    tri.Add((j + 1) + Ny * (i + 1)); //3
                    tri.Add(j + Ny * (i + 1));       //2

                    tri.Add(j + 1 + Ny * i);         //0
                }
            }
            mesh1.Positions          = pts;
            mesh1.TextureCoordinates = tpts;
            mesh1.TriangleIndices    = tri;

            return(mesh1);
        }
		/// <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;
		}
        /// <summary>
        /// Triangulate a polygon using the cutting ears algorithm.
        /// </summary>
        /// <remarks>
        /// The algorithm does not support holes.
        /// </remarks>
        /// <param name="contour">
        /// the polygon contour
        /// </param>
        /// <returns>
        /// collection of triangle points
        /// </returns>
        public static Int32Collection Triangulate(IList <Point> contour)
        {
            // allocate and initialize list of indices in polygon
            var result = new Int32Collection();

            int n = contour.Count;

            if (n < 3)
            {
                return(null);
            }

            var V = new int[n];

            // we want a counter-clockwise polygon in V
            if (Area(contour) > 0)
            {
                for (int v = 0; v < n; v++)
                {
                    V[v] = v;
                }
            }
            else
            {
                for (int v = 0; v < n; v++)
                {
                    V[v] = (n - 1) - v;
                }
            }

            int nv = n;

            // remove nv-2 Vertices, creating 1 triangle every time
            int count = 2 * nv; // error detection

            for (int v = nv - 1; nv > 2;)
            {
                // if we loop, it is probably a non-simple polygon
                if (0 >= (count--))
                {
                    // ERROR - probable bad polygon!
                    return(null);
                }

                // three consecutive vertices in current polygon, <u,v,w>
                int u = v;
                if (nv <= u)
                {
                    u = 0; // previous
                }

                v = u + 1;
                if (nv <= v)
                {
                    v = 0; // new v
                }

                int w = v + 1;
                if (nv <= w)
                {
                    w = 0; // next
                }

                if (Snip(contour, u, v, w, nv, V))
                {
                    int s, t;

                    // true names of the vertices
                    int a = V[u];
                    int b = V[v];
                    int c = V[w];

                    // output Triangle
                    result.Add(a);
                    result.Add(b);
                    result.Add(c);

                    // remove v from remaining polygon
                    for (s = v, t = v + 1; t < nv; s++, t++)
                    {
                        V[s] = V[t];
                    }

                    nv--;

                    // resest error detection counter
                    count = 2 * nv;
                }
            }

            return(result);
        }
		/// <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);
		}
Пример #52
0
            private static Model3D GenerateTreeMap3DModel(int index, int count)
            {
                MeshGeometry3D meshGeometry3D = new MeshGeometry3D();

                Point3DCollection positions = new Point3DCollection();

                positions.Add(new Point3D(0, 0, 1));
                positions.Add(new Point3D(0, 0, 0));
                positions.Add(new Point3D(1, 0, 0));
                positions.Add(new Point3D(1, 0, 1));
                positions.Add(new Point3D(0, 1, 1));
                positions.Add(new Point3D(0, 1, 0));
                positions.Add(new Point3D(1, 1, 0));
                positions.Add(new Point3D(1, 1, 1));
                positions.Freeze();

                Int32Collection triangleIndices = new Int32Collection();

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

                triangleIndices.Add(2);
                triangleIndices.Add(3);
                triangleIndices.Add(0);

                triangleIndices.Add(4);
                triangleIndices.Add(7);
                triangleIndices.Add(6);

                triangleIndices.Add(6);
                triangleIndices.Add(5);
                triangleIndices.Add(4);

                triangleIndices.Add(0);
                triangleIndices.Add(3);
                triangleIndices.Add(7);

                triangleIndices.Add(7);
                triangleIndices.Add(4);
                triangleIndices.Add(0);

                triangleIndices.Add(1);
                triangleIndices.Add(5);
                triangleIndices.Add(6);

                triangleIndices.Add(6);
                triangleIndices.Add(2);
                triangleIndices.Add(1);

                triangleIndices.Add(3);
                triangleIndices.Add(2);
                triangleIndices.Add(6);

                triangleIndices.Add(6);
                triangleIndices.Add(7);
                triangleIndices.Add(3);

                triangleIndices.Add(0);
                triangleIndices.Add(4);
                triangleIndices.Add(5);

                triangleIndices.Add(5);
                triangleIndices.Add(7);
                triangleIndices.Add(0);

                triangleIndices.Freeze();

                // finally set the data
                meshGeometry3D.TriangleIndices = triangleIndices;
                meshGeometry3D.Positions       = positions;

                // create the geometry model
                GeometryModel3D geom3D = new GeometryModel3D();

                geom3D.Geometry = meshGeometry3D;

                Color           color           = ColorHelper.HsbToRgb(index / (float)count, .9f, 1f);
                SolidColorBrush solidColorBrush = color.ToBrush();

                solidColorBrush.Freeze();

                geom3D.Material = new DiffuseMaterial(solidColorBrush);

                return(geom3D);
            }
Пример #53
0
        ///<summary>Objects are added in this step as all gray.  Colors are set in a separate step.</summary>
        public void AddObjectGroup(D3ObjectGroup group)
        {
            _model3Dgroup = new Model3DGroup();
            DirectionalLight light = new DirectionalLight(Colors.WhiteSmoke, new Vector3D(-3, -3, -3));

            _model3Dgroup.Children.Add(light);
            DirectionalLight light2 = new DirectionalLight(Colors.LightGray, new Vector3D(2.8, -3, -3));

            _model3Dgroup.Children.Add(light2);
            //AmbientLight ambientLight=new AmbientLight(Colors.DarkGray);
            //_model3Dgroup.Children.Add(ambientLight);
            objectNames = new List <string>();
            objectNames.Add("light1");
            objectNames.Add("light2");            //to maintain 1:1
            for (int i = 0; i < group.D3Objects.Count; i++)
            {
                MeshGeometry3D    meshGeometry3D = new MeshGeometry3D();
                Point3DCollection points         = group.D3Objects[i].GenerateVertices();
                meshGeometry3D.Positions = points;
                PointCollection textures = group.D3Objects[i].GenerateTextures();
                meshGeometry3D.TextureCoordinates = textures;
                Vector3DCollection vectors = group.D3Objects[i].GenerateNormals();
                meshGeometry3D.Normals = vectors;
                Int32Collection indices = group.D3Objects[i].GenerateIndices();
                meshGeometry3D.TriangleIndices = indices;
                GeometryModel3D geometryModel3D = new GeometryModel3D();
                geometryModel3D.Geometry = meshGeometry3D;
                //materials
                MaterialGroup   materialGroup   = new MaterialGroup();
                DiffuseMaterial diffuseMaterial = new DiffuseMaterial();
                if (group.D3Objects[i].TextureMap != null)
                {
                    ImageBrush imageBrush = new ImageBrush(D3Helper.ConvertImage(group.D3Objects[i].TextureMap));
                    imageBrush.ViewportUnits = BrushMappingMode.Absolute;
                    ScaleTransform     scaleTransform     = new ScaleTransform(1, -1);         //scale y -1 to flip vertically
                    TranslateTransform translateTransform = new TranslateTransform(0, 1);      //shift up one after flipping
                    TransformGroup     transformGroup     = new TransformGroup();
                    transformGroup.Children.Add(scaleTransform);
                    transformGroup.Children.Add(translateTransform);
                    imageBrush.Transform  = transformGroup;
                    diffuseMaterial.Brush = imageBrush;
                }
                else if (group.TextureMap != null && group.D3Objects[i].VertexNormals[0].Texture != null)             //a group texture is specified and this object uses texture mapping
                {
                    ImageBrush imageBrush = new ImageBrush(D3Helper.ConvertImage(group.TextureMap));
                    imageBrush.ViewportUnits = BrushMappingMode.Absolute;
                    ScaleTransform     scaleTransform     = new ScaleTransform(1, -1);         //scale y -1 to flip vertically
                    TranslateTransform translateTransform = new TranslateTransform(0, 1);      //shift up one after flipping
                    TransformGroup     transformGroup     = new TransformGroup();
                    transformGroup.Children.Add(scaleTransform);
                    transformGroup.Children.Add(translateTransform);
                    imageBrush.Transform  = transformGroup;
                    diffuseMaterial.Brush = imageBrush;
                }
                else
                {
                    diffuseMaterial.Brush = new SolidColorBrush(Colors.Gray);
                    //diffuseMaterial.Color=Colors.Gray;//this didn't work.  Needs brush.
                }
                materialGroup.Children.Add(diffuseMaterial);
                //specular material at 1
                SpecularMaterial specularMaterial = new SpecularMaterial();
                specularMaterial.Brush         = new SolidColorBrush(Colors.White);
                specularMaterial.SpecularPower = 150;              //smaller numbers give more reflection.  150 is minimal specular.
                materialGroup.Children.Add(specularMaterial);
                geometryModel3D.Material = materialGroup;
                _model3Dgroup.Children.Add(geometryModel3D);
                objectNames.Add(group.D3Objects[i].Name);
            }
            ModelVisual3D modelVisual3D = new ModelVisual3D();

            modelVisual3D.Content = _model3Dgroup;
            myViewport.Children.Add(modelVisual3D);
        }
 public static void Add(this Int32Collection _this, Tuple <int, int, int> tuple)
 {
     _this.Add(tuple.Item1);
     _this.Add(tuple.Item2);
     _this.Add(tuple.Item3);
 }
Пример #55
0
//        public void LoadLayout(FieldLayOut layout, Control ctnControl, SectionFilterCollection sfcfilter, System.Windows.Forms.PropertyGrid propertyGrid)
        public void LoadLayout(FieldLayOut layout, SectionFilterCollection sections)
        {
            if (layout == null || layout.FieldTable == null)
            {
                return;
            }

            _layout = layout;

            Int32Collection nCols = _layout.ColumnsEachRow;

            int nRowCount = nCols.Count;

            if (nRowCount <= 0 || !LoadSectionFilters(nCols, sections))
            {
                return;
            }

            mainControl.Controls.Clear();

            Rectangle rect = mainControl.ClientRectangle;

            mainControl.BackColor = Control.DefaultBackColor;

            this.C_PropertyGrid.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.C_PropertyGrid_PropertyValueChanged);

            Buttons = new Button[nRowCount][];

            btnContainer = new Panel[nRowCount];

            int sfcindex = 0;


            int panelLocX     = rect.X;
            int panelLocY     = rect.Y;
            int nButtonHeight = 0;

            for (int i = 0; i < nRowCount; i++)
            {
                panelLocY    += nButtonHeight;
                nButtonHeight = (int)(rect.Height * this.GetMaxRadio(layout, i));

                btnContainer[i]             = new Panel();
                btnContainer[i].Name        = i.ToString();
                btnContainer[i].Location    = new Point(panelLocX, panelLocY);
                btnContainer[i].Size        = new Size(rect.Width, nButtonHeight);
                btnContainer[i].BorderStyle = BorderStyle.None;

                int iColCount = nCols[i];
                if (iColCount > 0)
                {
                    Buttons[i] = new Button[iColCount];
                }

                int buttonLocX = 0;

                int restWidth = this.GetRestWidth(i);               //Added this code at 2008-12-12 13:58:28@Simon

                for (int j = 0; j < iColCount; j++)
                {
                    Button newButton = new Button();
                    newButton.Location = new Point(buttonLocX, 0);
                    newButton.Size     = this.GetButtonSize(i, j);
                    if (restWidth > 0)
                    {
                        newButton.Width += 1;
                        restWidth--;
                    }
                    else if (restWidth < 0)
                    {
                        newButton.Width -= 1;
                        restWidth++;
                    }
                    buttonLocX         += newButton.Size.Width;
                    newButton.BackColor = Control.DefaultBackColor;


                    btntag          = new ButtonTags();
                    btntag.RowIndex = i;
                    btntag.ColIndex = j;
                    btntag.RowMax   = nRowCount - 1;
                    btntag.ColMax   = nRowCount - 1;
                    btntag.btnLoc   = new Point(newButton.Location.X, newButton.Location.X);
                    btntag.btnSize  = new Size(newButton.Width, newButton.Height);
                    btntag.filter   = sections[sfcindex];

                    sfcindex++;
                    newButton.Name = string.Format("Button{0}", sfcindex);
                    newButton.Text = btntag.filter.FilterName;
                    newButton.Tag  = btntag;



                    newButton.MouseDown  += new System.Windows.Forms.MouseEventHandler(MyMouseDown);
                    newButton.MouseLeave += new System.EventHandler(MyMouseLeave);
                    newButton.MouseMove  += new System.Windows.Forms.MouseEventHandler(MyMouseMove);
                    newButton.Click      += new System.EventHandler(MyClick);

                    Buttons[i][j] = newButton;
                    btnContainer[i].Controls.Add(newButton);
                }
                this.mainControl.Controls.Add(btnContainer[i]);
            }
        }
Пример #56
0
        /// <summary>
        /// Use the render packages returned from the visualization manager to update the visuals.
        /// The visualization event arguments will contain a set of render packages and an id representing
        /// the associated node. Visualizations for the background preview will return an empty id.
        /// </summary>
        /// <param name="e"></param>
        private void RenderDrawables(VisualizationEventArgs e)
        {
            //check the id, if the id is meant for another watch,
            //then ignore it
            if (e.Id != _id)
            {
                return;
            }

            var sw = new Stopwatch();

            sw.Start();

            Points         = null;
            Lines          = null;
            Mesh           = null;
            XAxes          = null;
            YAxes          = null;
            ZAxes          = null;
            PointsSelected = null;
            LinesSelected  = null;
            MeshSelected   = null;
            Text           = null;
            MeshCount      = 0;

            //separate the selected packages
            var packages    = e.Packages.Where(x => x.Selected == false).ToArray();
            var selPackages = e.Packages.Where(x => x.Selected).ToArray();

            //pre-size the points collections
            var pointsCount    = packages.Select(x => x.PointVertices.Count / 3).Sum();
            var selPointsCount = selPackages.Select(x => x.PointVertices.Count / 3).Sum();
            var points         = new Point3DCollection(pointsCount);
            var pointsSelected = new Point3DCollection(selPointsCount);

            //pre-size the lines collections
            //these sizes are conservative as the axis lines will be
            //taken from the linestripvertex collections as well.
            var lineCount     = packages.Select(x => x.LineStripVertices.Count / 3).Sum();
            var lineSelCount  = selPackages.Select(x => x.LineStripVertices.Count / 3).Sum();
            var lines         = new Point3DCollection(lineCount);
            var linesSelected = new Point3DCollection(lineSelCount);
            var redLines      = new Point3DCollection(lineCount);
            var greenLines    = new Point3DCollection(lineCount);
            var blueLines     = new Point3DCollection(lineCount);

            //pre-size the text collection
            var textCount = e.Packages.Count(x => x.DisplayLabels);
            var text      = new List <BillboardTextItem>(textCount);

            //http://blogs.msdn.com/b/timothyc/archive/2006/08/31/734308.aspx
            //presize the mesh collections
            var meshVertCount    = packages.Select(x => x.TriangleVertices.Count / 3).Sum();
            var meshVertSelCount = selPackages.Select(x => x.TriangleVertices.Count / 3).Sum();

            var mesh     = new MeshGeometry3D();
            var meshSel  = new MeshGeometry3D();
            var verts    = new Point3DCollection(meshVertCount);
            var vertsSel = new Point3DCollection(meshVertSelCount);
            var norms    = new Vector3DCollection(meshVertCount);
            var normsSel = new Vector3DCollection(meshVertSelCount);
            var tris     = new Int32Collection(meshVertCount);
            var trisSel  = new Int32Collection(meshVertSelCount);

            foreach (var package in packages)
            {
                ConvertPoints(package, points, text);
                ConvertLines(package, lines, redLines, greenLines, blueLines, text);
                ConvertMeshes(package, verts, norms, tris);
            }

            foreach (var package in selPackages)
            {
                ConvertPoints(package, pointsSelected, text);
                ConvertLines(package, linesSelected, redLines, greenLines, blueLines, text);
                ConvertMeshes(package, vertsSel, normsSel, trisSel);
            }

            points.Freeze();
            pointsSelected.Freeze();
            Points         = points;
            PointsSelected = pointsSelected;

            lines.Freeze();
            linesSelected.Freeze();
            redLines.Freeze();
            greenLines.Freeze();
            blueLines.Freeze();
            Lines         = lines;
            LinesSelected = linesSelected;
            XAxes         = redLines;
            YAxes         = greenLines;
            ZAxes         = blueLines;

            verts.Freeze();
            norms.Freeze();
            tris.Freeze();
            vertsSel.Freeze();
            normsSel.Freeze();
            trisSel.Freeze();

            mesh.Positions          = verts;
            mesh.Normals            = norms;
            mesh.TriangleIndices    = tris;
            meshSel.Positions       = vertsSel;
            meshSel.Normals         = normsSel;
            meshSel.TriangleIndices = trisSel;

            Mesh         = mesh;
            MeshSelected = meshSel;

            Text = text;

            sw.Stop();

            GC.Collect();

            Debug.WriteLine(string.Format("{0} ellapsed for updating background preview.", sw.Elapsed));
        }
 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();
 }
Пример #58
0
        private bool CreateMatrixPrintingTable()
        {
            if (MatrixInfo == null || !_HaveData || this.RootGroupInfo == null)
            {
                this.PrintingTable = null;
                return(false);
            }

            int m_Rows = MatrixInfo.GetMatrixGroupedRows(this);

            if (this.TableHeaders != null && this.TableHeaders.RowCount > 0 && this.TableHeaders.ColCount > 0) //2008-8-29 9:12:31@simon
            {
                m_Rows += this.TableHeaders.RowCount;                                                          //2008-8-29 9:12:37@simon
            }

            int m_Column = MatrixInfo.GetMatrixGroupedColumns(this.ShowRowIndicators);

            if (m_Rows <= 0 || m_Column <= 0)
            {
                this.PrintingTable = null;
                return(false);
            }

            System.Diagnostics.Debug.WriteLine(string.Format("Begin Create print table:{0}X{1}", m_Rows, m_Column));

            this.PrintingTable = new WebbTable(m_Rows, m_Column);

            MatrixInfo.SetMatrixColumnWidthAtFirst(this.PrintingTable, this.ShowRowIndicators);

            //Set value
            this.HeaderRows.Clear();
            this.SectionRows.Clear();
            this.TotalRows.Clear();
            this.BreakRows.Clear();
            this.ColumnStyleRows.Clear();

            this.SetTableValue();

            StyleBuilder.StyleRowsInfo m_StyleInfo = new Styles.StyleBuilder.StyleRowsInfo(this._HeaderRows, this._SectionRows, this._TotalRows, this.ShowRowIndicators, this.HaveHeader);
            Int32Collection            ignoreRows  = this.HeaderRows.Combine(this.HeaderRows, this.SectionRows, this.TotalRows);
            StyleBuilder styleBuilder = new StyleBuilder();


            #region Modify codes at 2008-11-4 15:45:04@Simon

            styleBuilder.BuildMatrixGroupStyle(this.PrintingTable, m_StyleInfo, this.MatrixInfo, this.Styles, ignoreRows);

            if (this.TableHeaders != null && this.TableHeaders.RowCount > 0 && this.TableHeaders.ColCount > 0)                    //Added this code at 2008-11-6 10:22:40@Simon
            {
                int minh         = 0;
                int i_Titleindex = 0;
                if (this.HeaderRows.Count > 0)
                {
                    foreach (int tl in this.HeaderRows)
                    {
                        if (i_Titleindex < tl)
                        {
                            i_Titleindex = tl;
                        }
                    }
                }
                if (i_Titleindex > minh)
                {
                    foreach (int col in this.TableHeaders.ColsToMerge)
                    {
                        IWebbTableCell Mergedcell = PrintingTable.GetCell(i_Titleindex, col);
                        this.PrintingTable.MergeCells(minh, i_Titleindex, col, col);
                        IWebbTableCell bordercell = PrintingTable.GetCell(minh, col);
                        if (this.HaveHeader)
                        {
                            bordercell.Text = Mergedcell.Text;
                            bordercell.CellStyle.StringFormat = Mergedcell.CellStyle.StringFormat;
                            if ((bordercell.CellStyle.StringFormat & StringFormatFlags.DirectionVertical) != 0)
                            {
                                bordercell.CellStyle.HorzAlignment = HorzAlignment.Far;
                                bordercell.CellStyle.VertAlignment = VertAlignment.Center;
                            }
                        }
                    }
                }
            }

            if (this.TableHeaders != null)
            {
                this.TableHeaders.SetHeadGridLine(this.PrintingTable, this.HeaderRows);
            }

            #endregion                                    //End Modify

            this.ApplyColumnWidthStyle(m_Column);
            this.ApplyRowHeightStyle(m_Rows);

            switch (this.CellSizeAutoAdapting)
            {
            case CellSizeAutoAdaptingTypes.NotUse:
                break;

            case CellSizeAutoAdaptingTypes.WordWrap:
                this.PrintingTable.AutoAdjustMatrixSize(this.ExControl.CreateGraphics(), true, false, this.MatrixInfo, this.ShowRowIndicators);
                break;

            case CellSizeAutoAdaptingTypes.OneLine:
                this.PrintingTable.AutoAdjustMatrixSize(this.ExControl.CreateGraphics(), false, false, this.MatrixInfo, this.ShowRowIndicators);
                break;
            }


            System.Diagnostics.Debug.WriteLine("Create print table completely");

            return(true);
        }
Пример #59
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;
        }
Пример #60
0
        //
        // Hits the ray against the mesh
        //
        internal override void RayHitTestCore(
            RayHitTestParameters rayParams,
            FaceType hitTestableFaces)
        {
            Debug.Assert(hitTestableFaces != FaceType.None,
                         "Caller should make sure we're trying to hit something");

            Point3DCollection positions = Positions;

            if (positions == null)
            {
                return;
            }

            Point3D  origin;
            Vector3D direction;

            rayParams.GetLocalLine(out origin, out direction);

            Int32Collection indices = TriangleIndices;

            // In the line case, we want to hit test all faces because we don't
            // have a direction. This may differ from what faces we want to
            // accept.
            FaceType facesToHit;

            if (rayParams.IsRay)
            {
                facesToHit = hitTestableFaces;
            }
            else
            {
                facesToHit = FaceType.Front | FaceType.Back;
            }


            //
            // This code duplication is unfortunate but necessary. Breaking it down into methods
            // further significantly impacts performance. About 5% improvement could be made
            // by unrolling this code below even more.
            //
            // If futher perf investigation is done with this code, be sure to test NGEN assemblies only
            // as JIT produces different, faster code than NGEN.
            //

            if (indices == null || indices.Count == 0)
            {
                FrugalStructList <Point3D> ps = positions._collection;
                int count = ps.Count - (ps.Count % 3);

                for (int i = count - 1; i >= 2; i -= 3)
                {
                    int i0 = i - 2;
                    int i1 = i - 1;
                    int i2 = i;

                    Point3D v0 = ps[i0];
                    Point3D v1 = ps[i1];
                    Point3D v2 = ps[i2];

                    double hitTime;
                    Point  barycentric;

                    // The line hit test is equivalent to a double sided
                    // triangle hit because it doesn't cull triangles based
                    // on winding
                    if (LineUtil.ComputeLineTriangleIntersection(
                            facesToHit,
                            ref origin,
                            ref direction,
                            ref v0,
                            ref v1,
                            ref v2,
                            out barycentric,
                            out hitTime
                            )
                        )
                    {
                        if (rayParams.IsRay)
                        {
                            ValidateRayHit(
                                rayParams,
                                ref origin,
                                ref direction,
                                hitTime,
                                i0,
                                i1,
                                i2,
                                ref barycentric
                                );
                        }
                        else
                        {
                            ValidateLineHit(
                                rayParams,
                                hitTestableFaces,
                                i0,
                                i1,
                                i2,
                                ref v0,
                                ref v1,
                                ref v2,
                                ref barycentric
                                );
                        }
                    }
                }
            }
            else // indexed mesh
            {
                FrugalStructList <Point3D> ps   = positions._collection;
                FrugalStructList <int>     idcs = indices._collection;

                int count = idcs.Count;
                int limit = ps.Count;

                for (int i = 2; i < count; i += 3)
                {
                    int i0 = idcs[i - 2];
                    int i1 = idcs[i - 1];
                    int i2 = idcs[i];

                    // Quit if we encounter an index out of range.
                    // This is okay because the triangles we ignore are not rendered.
                    //  (see: CMilMeshGeometry3DDuce::Realize)
                    if ((0 > i0 || i0 >= limit) ||
                        (0 > i1 || i1 >= limit) ||
                        (0 > i2 || i2 >= limit))
                    {
                        break;
                    }

                    Point3D v0 = ps[i0];
                    Point3D v1 = ps[i1];
                    Point3D v2 = ps[i2];

                    double hitTime;
                    Point  barycentric;

                    if (LineUtil.ComputeLineTriangleIntersection(
                            facesToHit,
                            ref origin,
                            ref direction,
                            ref v0,
                            ref v1,
                            ref v2,
                            out barycentric,
                            out hitTime
                            )
                        )
                    {
                        if (rayParams.IsRay)
                        {
                            ValidateRayHit(
                                rayParams,
                                ref origin,
                                ref direction,
                                hitTime,
                                i0,
                                i1,
                                i2,
                                ref barycentric
                                );
                        }
                        else
                        {
                            ValidateLineHit(
                                rayParams,
                                hitTestableFaces,
                                i0,
                                i1,
                                i2,
                                ref v0,
                                ref v1,
                                ref v2,
                                ref barycentric
                                );
                        }
                    }
                }
            }
        }