Пример #1
0
        private void SelectSampleImageFolder(object sender, RoutedEventArgs e)
        {
            var folderPath = ExecutionDirInfoHelper.GetExecutionPath() + @"\SamplePhotos";

            InvokeSelectFolderEvent(new SelectFolderEventArgs {
                FolderPath = folderPath
            });
        }
Пример #2
0
        public static void WritePolygonsToXamlFile(string strTemplateLocation, string strFilePath, IEnumerable <Point3D> lstPolygonPts, bool writeTextures)
        {
            if (lstPolygonPts.Count() < 3 || lstPolygonPts.Count() % 3 > 0)
            {
                throw new Exception("Invalid number of points supplied for the polygons. Each polygon should be a triangle consisting of three vertices.");
            }

            //if no template is found, use the default template
            if (string.IsNullOrEmpty(strTemplateLocation))
            {
                strTemplateLocation = string.Format(@"{0}\{1}\{2}", ExecutionDirInfoHelper.GetExecutionPath(),
                                                    "Xaml", "ModelTemplateWithNoTexture.xaml");
            }

            //Load the template
            var objXamlDoc = new XmlDocument();

            objXamlDoc.Load(strTemplateLocation);

            //Access the required node positions
            if (objXamlDoc.DocumentElement == null)
            {
                throw new Exception("The xml document could not be loaded.");
            }

            var objCoordinatesNode = objXamlDoc.DocumentElement.GetElementsByTagName("MeshGeometry3D.Positions");
            var objTexturesNode    =
                objXamlDoc.DocumentElement.GetElementsByTagName("MeshGeometry3D.TextureCoordinates");
            var objIndicesNode = objXamlDoc.DocumentElement.GetElementsByTagName("MeshGeometry3D.TriangleIndices");

            if (objCoordinatesNode[0] == null || objIndicesNode[0] == null)
            {
                throw new Exception("Could not find the nodes to write the model data in the xaml template.");
            }
            if (writeTextures && objTexturesNode[0] == null)
            {
                throw new Exception(
                          "Could not find the nodes to write the texture information in the xaml template.");
            }

            //Write all the coordinates
            var objCoordinates = new StringBuilder("");
            var objTextures    = new StringBuilder("");
            var objIndices     = new StringBuilder("");
            var intIndexPos    = 0;

            //Initialize values used for calculating texture coordinates
            var dblMinX = 0d;
            var dblMaxX = 0d;
            var dblMinY = 0d;
            var dblMaxY = 0d;

            if (writeTextures)
            {
                GetMinMaxXyValues(lstPolygonPts, out dblMinX, out dblMaxX, out dblMinY, out dblMaxY);
            }

            foreach (var objPt in lstPolygonPts)
            {
                if (objCoordinates.Length > 0)
                {
                    //Attach a comma
                    objCoordinates.Append(",");
                    objTextures.Append(",");
                    objIndices.Append(",");
                }
                objCoordinates.Append(String.Format("{0},{1},{2}", objPt.X, objPt.Y, objPt.Z));

                objIndices.Append(String.Format("{0}", intIndexPos));
                intIndexPos += 1;

                if (writeTextures)
                {
                    //Calculate texture values
                    double dblTexX;
                    double dblTexY;
                    GetTextureCoordinates(out dblTexX, out dblTexY, objPt, dblMinX, dblMaxX, dblMinY, dblMaxY);
                    objTextures.Append(String.Format("{0},{1}", dblTexX, dblTexY));
                }

                //TODO: Write the normals too
            }

            objCoordinatesNode[0].InnerText = objCoordinates.ToString();
            if (writeTextures)
            {
                objTexturesNode[0].InnerText = objTextures.ToString();
            }
            objIndicesNode[0].InnerText = objIndices.ToString();

            objXamlDoc.Save(strFilePath);
        }
        private static string GetFilePath()
        {
            var outputPath = ExecutionDirInfoHelper.GetExecutionPath();

            return(string.Format(@"{0}\HideScreenStartDialogFlags.xml", outputPath));
        }
Пример #4
0
 private string GetTemplatePath()
 {
     return(ExecutionDirInfoHelper.GetExecutionPath() + @"\Xaml\ModelTemplate.xaml");
 }