0
Wrong number of normal vectors.
This discussion was imported from CodePlex
everytimer wrote at 2014-03-12 08:38:
I'm importing a geometry from a file reading the vertices of the figures. For each type I've wrote the correct indices, for example:
What can I do to fix this situation? I know that there is a method called add triangles but It would be a bit difficult to implement for me right now.
public GeometryModel3D Generate3D()
{
GeometryModel3D My3DModel = new GeometryModel3D(); //Materials ommited
List<Point3D> puntos = new List<Point3D>();
List<int> indices = new List<int>();
if (Elementos[i] is CTRIA3)
{
Point3D p1 = Elementos[i].Grids[0].ToPoint();
Point3D p2 = Elementos[i].Grids[1].ToPoint();
Point3D p3 = Elementos[i].Grids[2].ToPoint();
puntos.Add(p1);
puntos.Add(p2);
puntos.Add(p3);
int n = puntos.Count;
indices.Add(n - 3);
indices.Add(n - 2);
indices.Add(n - 1);
}
if (Elementos[i] is CQUAD4)
{
Point3D p1 = Elementos[i].Grids[0].ToPoint();
Point3D p2 = Elementos[i].Grids[1].ToPoint();
Point3D p3 = Elementos[i].Grids[2].ToPoint();
Point3D p4 = Elementos[i].Grids[3].ToPoint();
puntos.Add(p1);
puntos.Add(p2);
puntos.Add(p3);
puntos.Add(p4);
int n = puntos.Count;
indices.Add(n - 4);
indices.Add(n - 3);
indices.Add(n - 2);
indices.Add(n - 4);
indices.Add(n - 2);
indices.Add(n - 1);
}
//More geometric stuff
Mesh3D mesh = new Mesh3D(puntos, indices);
MeshBuilder mb = new MeshBuilder(false, false); //I've tried the default constructor too
mb.AddCylinder(new Point3D(0, 0, 0), new Point3D(100, 100, 100), 5, 20);
mb.Append(mesh.ToMeshGeometry3D()); //I've tried switching the order
//My3DModel.Geometry = mesh.ToMeshGeometry3D();
My3DModel.Geometry = mb.ToMesh();
return My3DModel;
}
What I want is to use both, manually created figures and using MeshBuilder class (for tubes, cones etc). But if I use the append method to try than, even if I do not add any stuff with the MeshBuilder I get this exception:An unhandled exception of type 'System.InvalidOperationException' occurred in HelixToolkit.Wpf.dllAdditional information: Wrong number of normal vectors.
What can I do to fix this situation? I know that there is a method called add triangles but It would be a bit difficult to implement for me right now.
objo wrote at 2014-03-12 15:56:
This looks like a bug in Mesh3D or MeshBuilder. I don't think you need to use a Mesh3D here. Try to use a
mb.Append(puntos, indices)
Customer support service by UserEcho