Some Exception support

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Some Exception support

Postby Julio Jerez » Thu Nov 21, 2013 7:38 pm

can you show me the code fragment that you used to verify the vetex count?
That sounds like a serius bug.

also send me the off file, the FBX is not really reliably for this because it alter the mesh topology
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Some Exception support

Postby Bird » Fri Nov 22, 2013 11:29 am

Julio Jerez wrote:can you show me the code fragment that you used to verify the vetex count?
That sounds like a serius bug.

also send me the off file, the FBX is not really reliably for this because it alter the mesh topology

Here the code I'm using that hits the mismatched vertex counts in the spoon mesh. I haven't been able to export the Mesh to OFF format for some reason as mentioned in the previous post. I'll try to create the OFF file a different way today and get it to you.

-Bird

Code: Select all
TriMesh * NewtonMeshOps::newtonMeshToTriMesh (const NewtonMesh * const newtonMesh)
{   
   NewtonMeshTriangulate(newtonMesh);
   size_t vertexCount = NewtonMeshGetVertexCount(newtonMesh);
   int stride = NewtonMeshGetVertexStrideInByte(newtonMesh) / sizeof(dFloat64);
   dFloat64* const vertexList = NewtonMeshGetVertexArray(newtonMesh);

   size_t actualCount = 0;
   for (void* vertex = NewtonMeshGetFirstVertex(newtonMesh); vertex; vertex = NewtonMeshGetNextVertex(newtonMesh, vertex))
   {
      int index = NewtonMeshGetVertexIndex(newtonMesh, vertex) * stride;
      dFloat x = dFloat(vertexList[index + 0]);
      dFloat y = dFloat(vertexList[index + 1]);
      dFloat z = dFloat(vertexList[index + 2]);
      ++actualCount;
   }
   dAssert(actualCount == vertexCount );
}
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Some Exception support

Postby Julio Jerez » Fri Nov 22, 2013 12:03 pm

I added that code fragmen to the one I had and I tested with the spoon

Code: Select all
NewtonWorld* const world = ngdScene->GetNewtonWorld();
NewtonMesh* xxx = instance->GetMesh ();
NewtonCollision* collision =  NewtonCreateConvexHullFromMesh (world, xxx, 0, 0);
NewtonMesh* xxx1 = NewtonMeshCreateFromCollision(collision);
instance->SetMesh (xxx1);
instance->ConvertToTriangles();

NewtonMesh* newtonMesh = instance->GetMesh ();
int vertexCount = NewtonMeshGetVertexCount(newtonMesh);
int stride = NewtonMeshGetVertexStrideInByte(newtonMesh) / sizeof(dFloat64);
dFloat64* const vertexList = NewtonMeshGetVertexArray(newtonMesh);

int actualCount = 0;
for (void* vertex = NewtonMeshGetFirstVertex(newtonMesh); vertex; vertex = NewtonMeshGetNextVertex(newtonMesh, vertex))
{
   int index = NewtonMeshGetVertexIndex(newtonMesh, vertex) * stride;
   dFloat x = dFloat(vertexList[index + 0]);
   dFloat y = dFloat(vertexList[index + 1]);
   dFloat z = dFloat(vertexList[index + 2]);
   ++actualCount;
}
dAssert(actualCount == vertexCount );


but I got the same 1162 vertex count by both methods
Maybe this is because the mesh is already altered and the problem does happens, when it happen again just send me the OFF file and I test it.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Some Exception support

Postby Bird » Fri Nov 22, 2013 12:31 pm

but I got the same 1162 vertex count by both methods
Maybe this is because the mesh is already altered and the problem does happens, when it happen again just send me the OFF file and I test it.

I always get 1182 for actualCount and 1162 for vertexCount. I just tried again but without making the NewtonMeshTriangulate() call. This time actualCount = vertexCount = 1166.

Does instance->ConvertToTriangles() use the same code as NewtonMeshTriangulate() ?

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Some Exception support

Postby Julio Jerez » Fri Nov 22, 2013 3:00 pm

Bird wrote:Does instance->ConvertToTriangles() use the same code as NewtonMeshTriangulate() ?-Bird


is it simple call the lwe lever newton funtion
Code: Select all
void dMeshNodeInfo::ConvertToTriangles()
{
   NewtonMeshTriangulate (m_mesh);
}


are you using the vertex count tha you read, and using afte you do triagulation.
tringulation does execuet a delanuy mesh trainlation and soem time teh veter count o fteh putput is smalled tah teh vertex coun of the imput

say for example a quad have a point that spite a line, a simple ear or monotical trianglation you get 3 thiangles,
but of you do a deleanay triangulartion you get two trianagles and one dangling vertex, then the pack function remove the unused vertex.
this si because delanuai triangulation maximizes the triangle area of falt surfafaces.

you if do do that you should re read the vertex count.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Some Exception support

Postby Bird » Fri Nov 22, 2013 11:17 pm

are you using the vertex count tha you read, and using afte you do triagulation.


Yes, I triangulate first and then ask for the vertex count.
Here's the OFF file for the spoon. This is a slightly different spoon than before ... it's centered and I froze the subdivision surfaces before bringing it into LW. I get actualCount = 1170 and vertexCount = 1155 for this one.
http://hurleyworks.com/downloads/spoon20.zip

I wrote a LWO to OFF tool and to test it I wrote a program the scoured all my hard drives looking for LW objects, parsed them and saved out the geometry data in .OFF format. So now I have a folder that contains 7,641 OFF files. Only took 8 minutes. :)

A lot of the really huge OFF files crashed the Newton Model Viewer when I tried to load them. The biggest one that would load was a scanned human skull with 374,999 vertices and 749,998 triangles. The Standford XYZ dragon with 3,609,600 vertices and 7,219,045 triangles doesn't load.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Some Exception support

Postby Julio Jerez » Sun Nov 24, 2013 4:13 pm

Oh I see I was able to reproduce the error wit the OFF file.
Let me see what is wrong there.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Some Exception support

Postby Julio Jerez » Sun Nov 24, 2013 4:53 pm

Ok I see what was the problem, I though that a triangulation could not create new vertices. but I was wrong a constrained Delaney triangulation can in fact generate T joints,
Ideally this should never happens, but with meshes with very small faces some float lose integrity and the triangulation may fail a recognizing a flat strips of faces for triangulation.
when two strips that are in fact flat are counted as separated strips, they are processed as two constrained triangulation and they may generated T joints at the share perimeter.

T joints are not new vertices, but if you one uses a loop like you are doing, then some vertices will count more than once
Code: Select all
for (void* vertex = NewtonMeshGetFirstVertex(xxx1); vertex; vertex = NewtonMeshGetNextVertex(xxx1, vertex))
{
   ++actualCount;
}
 


The solution was simple I just need to call Repair T Joint after the triangulation. I was when converting to polygons. But I thought that for trigulation was no nessesary.
Please test it again.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Some Exception support

Postby Bird » Sun Nov 24, 2013 5:43 pm

Please test it again.

Working fine now. Thanks once again for the quick fix!

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest