コード例 #1
0
        public static Matrix3d Rotation_ToOriginAxes(this Matrix3d mat, PointCloud cloudOrigin)
        {
            PointCloud target = new PointCloud();

            target.Add(new Vertex(1, 0, 0));
            target.Add(new Vertex(0, 1, 0));
            target.Add(new Vertex(0, 0, 1));

            return(mat.RotationCoordinateChange(cloudOrigin, target));
        }
コード例 #2
0
ファイル: IOUtils.cs プロジェクト: whigg/PointClouds
        /// <summary>
        /// Reads only position and color information (No normals, texture, triangles etc. etc)
        /// </summary>
        /// <param name="fileOBJ"></param>
        /// <param name="myNewModel"></param>
        public static PointCloud ReadObjFile_ToPointCloud(string fileOBJ)
        {
            PointCloud myPCL             = new PointCloud();
            string     line              = string.Empty;
            uint       indexInPointCloud = 0;

            try
            {
                using (StreamReader streamReader = new StreamReader(fileOBJ))
                {
                    //Part p = new Part();
                    Vertex vertex = new Vertex();
                    //myNewModel.Part = new List<Part>();
                    while (!streamReader.EndOfStream)
                    {
                        line = streamReader.ReadLine().Trim();
                        while (line.EndsWith("\\"))
                        {
                            line = line.Substring(0, line.Length - 1) + streamReader.ReadLine().Trim();
                        }
                        string   str1         = GlobalVariables.TreatLanguageSpecifics(line);
                        string[] strArrayRead = str1.Split();
                        if (strArrayRead.Length >= 0)
                        {
                            switch (strArrayRead[0].ToLower())
                            {
                            //case "mtllib":
                            //    if (strArrayRead.Length < 2)
                            //    {
                            //        System.Windows.Forms.MessageBox.Show("Error reading obj file in line : " + line);
                            //    }

                            //    myNewModel.GetTexture(strArrayRead[1], fileOBJ);
                            //    break;
                            case "v":    //Vertex
                                vertex       = HelperReadVertex(strArrayRead);
                                vertex.Index = indexInPointCloud;
                                indexInPointCloud++;
                                myPCL.Add(vertex);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception err)
            {
                System.Windows.Forms.MessageBox.Show("Error reading obj file - Vertices: " + line + " ; " + err.Message);
            }
            return(myPCL);
        }