Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mapping triangles after SolidUtils::TessellateSolidOrShell to Faces

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
1174 Views, 8 Replies

Mapping triangles after SolidUtils::TessellateSolidOrShell to Faces

Hello
I'm trying to rewrite my old triangulation code where triangulation was done face by face. SolidUtils::TessellateSolidOrShell works really good, but i need a color information, which i can't get from RevitTriangulatedSolidOrShell. I decided to map triangles manually by projecting triangle points on face (face.Project) and checking the distance. But this solution has few issues:
1. it's slow. nFace*nTriangles complexity. For geometry with 100k and more triangles it could take a lot of time.

2. some triangles are not mapped at all

3. some triangles are mapped to more that one face

 

Is there some other way to triangulate or get color information which i didn't find?

 

 

8 REPLIES 8
Message 2 of 9
jeremytammik
in reply to: Anonymous

Dear Erepb,

 

Yes, there is yes another possibility that you might want to consider. You could use the custom exporter:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.1

 

That returns the triangles processed by the Revit graphics pipeline and includes colour information.

 

Best regards, 

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 9
Anonymous
in reply to: jeremytammik

Thanks for response.

I tested this method, but looks like it also produces gaps between faces like face by face triangulation.

Message 4 of 9
jeremytammik
in reply to: Anonymous

Dear Erepb,

 

Oh dear, I am sorry to hear that.

 

The other option I can suggest is to fix up the holes yourself by matching vertices as they arrive, by ignoring any coordinate differences smaller than ca. 1 millimetre.

 

Simply implement a dictionary of all vertices encountered so far.

 

Each time you receive a new vertex, check whether it is close to another vertex already received. If so, use the one you already have instead of the new one received. 

 

That should fix all the holes automatically.

 

I used that lots of times in various samples on The Building Coder blog, e.g.:

 

http://thebuildingcoder.typepad.com/blog/2012/06/obj-model-export-considerations.html#6

 

http://thebuildingcoder.typepad.com/blog/2012/06/obj-model-export-considerations.html#7

 

 

Best regards, 

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 9
Anonymous
in reply to: jeremytammik

I already do this. But on the border of two faces number of points doesn't match. For example imagine curved wall and border between top face and one of the sides. Side face after triangulation has one extra point on the top comparing to the top face. This leads to very thin missed triangle. Look at the pictures in attach.

On the first you see the wall after face by face triangulation. Missing triangle is marked with blue color.
On the second picture i zoomed on the middle point of that triangle. As you see top face doesn't have that point.

I think that there is no way to get gap-free triangulation without loosing material information. I'll try to somehow fix gaps on my side then.

 

Message 6 of 9
jeremytammik
in reply to: Anonymous

Dear Erepb,

 

Oh dear (again). Yes, indeed, I have heard about and discussed the problematic behaviour you describe in the past as well.

 

Revit triangulates each face as efficiently as required - and as roughly as possible - to display it.

 

The required precision will vary from face to face, obviously, and causes the effect you describe.

 

This in turn causes problems for people interested in a closed shell, such as yourself.

 

This prompted the implementation of the TessellateSolidOrShell to solve the problem, which you already tried out.

 

Unfortunately, this method processes one body at a time and is less efficient than the other global processing methods.

 

Which takes us right back to square one.

 

I hope this clarifies the situation, at least.

 

Suggestion 1: develop a solution avoiding individual calls to TessellateSolidOrShell that tolerates these imprecisions, just like Revit's rendering pipeline and other workflows do.

 

Suggestion 2: implement a solution based on TessellateSolidOrShell to avoid these imprecisions and a workflow to drive it that is not time critical, e.g. overnight batch processing or something.

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 7 of 9
Anonymous
in reply to: jeremytammik

Thanks for your help.

One more question about Faces. Is it possible that faces in single Solid have different Material? Maybe there is no need to map triangles after TessellateSolidOrShell to Faces.

Message 8 of 9
jeremytammik
in reply to: Anonymous

Dear Erepb,

 

Good question.

 

Unfortunately, I believe that is perfectly possible.

 

To test, I would suggest using the Revit user interface paint tool to colour different parts of a single wall.

 

Please let us know what you find out.

 

Thank you!

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 9 of 9
jeremytammik
in reply to: jeremytammik

Dear Erepb,

 

Thank you for the conversation!

 

I summarised it on The Building Coder blog:

 

http://thebuildingcoder.typepad.com/blog/2014/05/tessellatesolidorshell-holes-versus-wholes.html

I hope this helps others as well.

Best regards,

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community