public static void SetModelTriangles(Model3D myModel, List <Triangle> listTriangle)
        {
            Part p = new Part();

            p.Triangles = listTriangle;
            myModel.Parts.Add(p);
            myModel.CalculateBoundingBox(true);

            //TimeCalc.ShowLastTimeSpan("Bounding Box");
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileOBJ"></param>
        /// <param name="myNewModel"></param>
        private static void readOBJfile(string fileOBJ, Model3D myNewModel)
        {
            string line         = string.Empty;
            int    indexInModel = -1;

            try
            {
                using (StreamReader streamReader = new StreamReader(fileOBJ))
                {
                    Part   p      = new Part();
                    Vertex vertex = new Vertex();
                    myNewModel.Parts = 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         = GeneralSettings.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 (mtllib) in line : " + line);
                                }

                                myNewModel.GetTexture(strArrayRead[1], fileOBJ);
                                break;

                            case "v":    //Vertex
                                vertex = IOUtils.HelperReadVertex(strArrayRead);
                                indexInModel++;
                                vertex.IndexInModel = indexInModel;
                                myNewModel.vertexList.Add(vertex);
                                break;

                            case "vt":    //Texture
                                if (strArrayRead.Length < 3)
                                {
                                    System.Windows.Forms.MessageBox.Show("Error reading obj file (Vertex) in line : " + line);
                                }
                                Vector3d vector1 = new Vector3d(0.0, 0.0, 0.0);
                                double.TryParse(strArrayRead[1], NumberStyles.Float | NumberStyles.AllowThousands, (IFormatProvider)null, out vector1.X);
                                double.TryParse(strArrayRead[2], NumberStyles.Float | NumberStyles.AllowThousands, (IFormatProvider)null, out vector1.Y);
                                myNewModel.TextureCoords.Add(new float[2] {
                                    (float)vector1.X, (float)vector1.Y
                                });
                                break;

                            case "vn":    //Normals
                                if (strArrayRead.Length < 4)
                                {
                                    System.Windows.Forms.MessageBox.Show("Error reading obj file (Normals) in line : " + line);
                                }
                                Vector3d vector2 = new Vector3d(0.0, 0.0, 0.0);
                                double.TryParse(strArrayRead[1], NumberStyles.Float | NumberStyles.AllowThousands, (IFormatProvider)null, out vector2.X);
                                double.TryParse(strArrayRead[2], NumberStyles.Float | NumberStyles.AllowThousands, (IFormatProvider)null, out vector2.Y);
                                double.TryParse(strArrayRead[3], NumberStyles.Float | NumberStyles.AllowThousands, (IFormatProvider)null, out vector2.Z);
                                //vector2.NormalizeNew();
                                myNewModel.Normals.Add(vector2);
                                break;

                            case "f":
                                Triangle a = helper_ReadTriangle(strArrayRead, myNewModel);
                                p.Triangles.Add(a);
                                break;

                            case "g":
                                if (p.Triangles.Count > 0)
                                {
                                    p.ColorOverall = myNewModel.TextureBitmap != null ? new Vector3d(1.0, 1.0, 1.0) : new Vector3d(0.3 * Math.Cos((double)(23 * myNewModel.Parts.Count)) + 0.5, 0.5 * Math.Cos((double)(17 * myNewModel.Parts.Count + 1)) + 0.5, 0.5 * Math.Cos((double)myNewModel.Parts.Count) + 0.5);
                                    myNewModel.Parts.Add(new Part(p));
                                }
                                if (strArrayRead.Length > 1)
                                {
                                    p.Name = str1.Replace(strArrayRead[1], "");
                                }
                                p.Triangles.Clear();
                                break;
                            }
                        }
                    }
                    if (p.Triangles.Count > 0)
                    {
                        p.ColorOverall = new Vector3d(1.0, 1.0, 1.0);
                        myNewModel.Parts.Add(p);
                    }
                    else
                    {
                        AssignTriangleAndPartFromVertex(myNewModel);
                    }
                    streamReader.Close();
                    myNewModel.Helper_AdaptNormalsForEachVertex();
                    myNewModel.CalculateBoundingBox(true);
                }
            }
            catch (Exception err)
            {
                System.Windows.Forms.MessageBox.Show("Error reading obj file (general): " + line + " ; " + err.Message);
            }
        }