ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AcDbSubDMesh::convertToSurface Method execute too slowly

11 REPLIES 11
Reply
Message 1 of 12
475867377
470 Views, 11 Replies

AcDbSubDMesh::convertToSurface Method execute too slowly

i have create a AcDbSubDMesh,which has 12888 vertexs.then i convert it to a surface.when i call the convertToSurface Method firstly,it failed.then i call the convertToSurface Method again, setting bConvertAsSmooth false.it success. the two convertting take about 30 minutes .how can i reduce the convertting time?

475867377_0-1704331421809.png

 

11 REPLIES 11
Message 2 of 12
tbrammer
in reply to: 475867377

Converting a mesh with many vertices to a surface is a very complex task. 

 

It isn't clear how your input mesh looks like: Is it a closed body? Has it holes? Or is it just a N x M array of connected vertices? For a closed body you can try to create an AcDb3dSolid first and analyze its faces with the BREP API.

For an N x M array you could try to create an AcDbNurbSurface from the N x M controlpoints.

 

Also it isn't clear what you expect from the resulting surface: Shall each vertex be exactly on the surface? Do you prefer a smoothed surface or shall it reproduce the mesh with triangles and kinks? Do you want to "simplify" the geometry or reproduce it exactly? Do you want to reduce data?


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 4 of 12
475867377
in reply to: tbrammer

the vertexs are elevation points.i want to simulate the terrain by creating a surface through the elevation points.i use the delaunay algorithm to get a set of triangles.then i create the AcDbSubDMesh by vertexs and triangle faces which are ruleless.i want to simulate the terrain accurately.the mesh is not closed. are the ruleless faces lead to the longly executing? 

Message 5 of 12
tbrammer
in reply to: 475867377

If you can provide a NxM Mesh from your terrain data you could create NURBS data yourself.

I think it takes a lot of time to figure out a possible NxM mesh from arbitrary mesh data.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 6 of 12
475867377
in reply to: tbrammer

thank you .Actually i create a vertexArray and a faceArray,then i use  the api  setSubDMesh() to generate a AcDbSubDMesh entity.it is not a NxM mesh.the faceArray is a set of face which all are  triangles. geometric position of the faces are random.because i use delaunay opration to generate th...

Message 7 of 12
tbrammer
in reply to: 475867377


@475867377 wrote:

...it is not a NxM mesh.the faceArray is a set of face which all are  triangles. geometric position of the faces are random.because i use delaunay opration to generate the faces .if i can make the faces  adjacent one by one,will the time of generating mesh be shorter?


I don't think so. 

Can you tell me why you want to create an AcDbSurface from the AcDbSubDMesh at all?

You wrote that you need an exact representation of the mesh data - not a smoothed approximation. So you can't expect data reduction. So what benefit do you expect form an AcDbSurface?


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 8 of 12
475867377
in reply to: tbrammer

i am sorry for not replying timely.my purpose to build an AcDbSurface is that i need a surface to lay something.i need to know the project location of some points on the surface.it is important for me.i don't know other way to reach my purpose.i use the DEM points to build the surface by two ways,one is build with points row by row regularly,the other one is build with points randomly.the efficent is quite different.pls help me to...

Message 9 of 12
tbrammer
in reply to: 475867377

In this case I think the most efficient and easiest solution would be to calculate projected points ot each triangles plane and test whether they are within the triangle. See here.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 10 of 12
475867377
in reply to: tbrammer

thank you.there are a large amount of triangles and a large amount of points to project. so i worry about the efficient. another reason is that  i want to caculate the project point more smoothly.so i need a smooth surface to project point.

Message 11 of 12
tbrammer
in reply to: 475867377

You wrote: "I  create the AcDbSubDMesh by vertexs and triangle faces which are ruleless.i want to simulate the terrain accurately."

and: "i want to caculate the project point more smoothly".

So you want the terrain to be exact but smoothed. Sounds a bit contradictory - but I think I see your point.

You have a set of exact 3D points of terrain and the projection you are talking about shall just calculate a Z value for a given 2D point (X,Y) on the map. Is that right?

I would advise against using an AcDbSurface for this purpose. I really doubt that it would perform good.

I think you would gain the best performance if you build a spatial index of your terrain points that allows you to quickly find the N nearest points "under" each point p=(x,y). Than calculate an average height at p using an appropriate weight factor that depends upon the distance of p from the terrain point. But this is getting away from ObjectARX. I'm not an expert for this kind of calculation.

 

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 12 of 12
475867377
in reply to: tbrammer

 calculating a Z value for a given 2D point (X,Y) on the map is one part,another part is caculating project point on the surface and the project vectors are mostly not z_axis.such as caculating something's sunlight shadow on the surface at some time.my question is why two surface's efficient are so much different.one is quick,one is much slow.the only difference is the building way of surface .why?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost