static AbstractLoaderModel()
 {
     // get all available importers
     s_importers = new Dictionary <string, AbstractLoaderModel>();
     foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies())
     {
         foreach (Type tp in ass.GetTypes())
         {
             if (!tp.IsAbstract && tp.IsClass && typeof(AbstractLoaderModel).IsAssignableFrom(tp))
             {
                 AbstractLoaderModel importer = Activator.CreateInstance(tp) as AbstractLoaderModel;
                 if (importer == null)
                 {
                     continue;
                 }
                 foreach (String ext in importer.Extensions)
                 {
                     s_importers.Add(ext, importer);
                 }
             }
         }
     }
 }
示例#2
0
        public void Load()
        {
            this.loader = AbstractLoaderModel.GetLoader(this.path);
            //throw new IOException(String.Format("O Arquivo {0} tem o formato inválido ou está corrompido!",
            //                                    this.path));
            if (this.loader != null)
            {
                this.loader.OnElementLoaded += this.TriangleModel_OnElementLoaded;
                this.triangles = this.loader.Load();
                this.loader.Dispose();
                this.boundBox = this.loader.BoundBox;
                //float len = Math.Abs(this.boundBox.PMax.Y - this.boundBox.PMin.Y);

                float scale = 50 / this.boundBox.HalfVector.Length;
                this.boundBox.Scale(scale);
                //this.boundBox.Translate(-this.boundBox.Center.ToVector3D());
                for (int i = 0; i < this.triangles.Length; i++)
                {

                    this.triangles[i].Wireframed = this.Wireframed;
                    this.triangles[i].Scale(scale);
                    //this.triangles[i].Translate(-this.boundBox.Center.ToVector3D());
                }
                //this.manager = new NoAccerelationStructure<Triangle>(this.triangles);
                this.manager = new Octree<Triangle>(this.boundBox, this.triangles);
                //this.manager = new KDTreeTriangleManager(new List<Triangle>(triangles));
                if (this.OnInitBuild != null)
                {
                    this.OnInitBuild();
                }
                DateTime antes = DateTime.Now;
                this.manager.Optimize();
                //((ITransformable3D)this.manager).Translate(-(this.boundBox.Center.X), -(this.boundBox.Center.Y), -(this.boundBox.Center.Z));
                //this.manager.Optimize();
                if (this.OnEndBuild != null)
                {
                    this.OnEndBuild(DateTime.Now.Subtract(antes));
                }
            }
        }
示例#3
0
        public void Dispose()
        {
            if (this.loader != null)
            {
                this.loader.Dispose();
            }

            this.triangles = null;
            this.manager = null;
            this.loader = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }