c# - Optimize WPF for large STL files -


i new wpf , wondering: there way optimize performance of wpf(c#) when working large meshes? have stl file read (~160000 triangles) , use instructions here. program workflow is:

  1. load stl file byte array

  2. read points , normals data byte array custom class point3d , vector3d variables

  3. use method similar "private model3dgroup createtrianglemodel()"

  4. load resulting model3dgroup of triangles in modelvisual3d model

  5. this.mainviewport.children.add(model);

is there more direct way load points/normals/triangles/surfaces viewport avoid of steps? see same data reused in different structures. 1 structure passing same data next.

*the biggest overhead in step 3. , concern when load 1000 triangles takes 458ms, 2000 takes 1280ms, 4000 - 4076ms , on geometrically progressing. other steps execute in flash.

**i thought rendering biggest timespender, seems loading data points meshes models groups.

basically have stlmodel holds array of stltriangles(a class containing 3 vertice points3d , 1 normal vector3d):

model3dgroup model3d = new model3dgroup();                 material objectmaterial = new diffusematerial(new solidcolorbrush(colors.coral));                 geometrymodel3d triangle;                 meshgeometry3d mesh;                 modelvisual3d solidmodel3d = new modelvisual3d();                  stlmodel.loadtriangles();                  (int = 0; < stlmodel.triangles.length; i++)                 {                     mesh = new meshgeometry3d();                     mesh.positions.add(stlmodel.triangles[i].vertex1);                     mesh.positions.add(stlmodel.triangles[i].vertex2);                     mesh.positions.add(stlmodel.triangles[i].vertex3);                     mesh.triangleindices.add(0);                     mesh.triangleindices.add(1);                     mesh.triangleindices.add(2);                     mesh.normals.add(stlmodel.triangles[i].normal);                     mesh.normals.add(stlmodel.triangles[i].normal);                     mesh.normals.add(stlmodel.triangles[i].normal);                      triangle = new geometrymodel3d(mesh, objectmaterial);                      model3d.children.add(triangle);                 }                  solidmodel3d.content = model3d;                  this.mainviewport.children.add(solidmodel3d); 


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -