Clear Filters
Clear Filters

Change face colors of tetrahedron mesh

1 view (last 30 days)
I'm working with tetrahedrons and would like to change the color of them depending on their deformation. I have been trying but haven't found a solution.
I simplied it and tried this:
h=tetramesh(Tes,Graficos);
Color=get(h,'CData');
h=tetramesh(Tes,Graficos,'CData',Color);
What I wanted to do is just to get the color properties of the tetramesh and then assign it again, just to see if it works. I though is should work, since the form of the output COLOR should be "pure".
The output color is an structure array with the number of elements equal to the number of tetrahedron and in each cell there is an array 4x1. Each cell represents the color of each of the 4 faces of the tetrahedron.
This doesn't work and an error appeas:
??? Error using ==> patch
Value must be double or float
Error in ==> tetramesh at 100
h(n)=patch(x1,x2,x3,[1 1 1 1]*c(n),'FaceAlpha', 0.9,...
Could anyone help me with this problem? Why even taking the output of tetramesh, then it doesn't accept it?
Thanks a lot.
Carlos

Accepted Answer

Sean de Wolski
Sean de Wolski on 18 Apr 2012
what is:
class(x1)
class(x2)
class(x3)
class(c)
One of those will not be 'double' or 'single'. Convert that one to double using double().

More Answers (1)

Carlos
Carlos on 18 Apr 2012
Thanks for the quick answer Sean.
What I expected was that since Color was the output it shouldn't generate any problem since the format should be right. The solution that I have found is to go tetrahedron by tetrahedron applying the function patch and there assign the {i} element of the structure array with the colors of the vertices. I have taken information such as vertices and faces for the patch function with function get from h=tetramesh.

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!