Add a New Comment (Rich Markup)
( Jump to the original submission )
You are correct. So I suggest to compute normals ('exact') and store as Field of type 'elemn'. Then smooth normals is just convert Field to type 'node', and facet normals is convert to type 'elemc'. In all cases normalize. Note that convert back to type 'elemn' will not recover the originals, so it makes sense to keep them stored as elemn, and return the converted field when needed.
Fine for me to use only ndim==2, but I am not sure if maybe it is also good to set them for ndim==3 on all the facets of all elements, not only on the border, but it could be more tedious to implement. with 'averaged nodal element normals' i mean the results of
gt.averageNormals(self.coords, self.elems)
for facet then it is correct as I did?
normals = gt.polygonNormals(self.coords[self.elems]) normals = normalize(normals.mean(axis=1))
For ndim==3, it would indeed set the normals on the element facets. But it might be better to leave that to the BorderMesh. I suggest therefore to only set normals for ndim==2. I think the normals should always be normalized. 'facet' mode is: every face with n nodes has n normals at the nodes. Take the average of these n normals. I do not understand what your 'averaged nodal element normals' is. I guess it is just another representation of the 'smooth' normals? Which would then be the smooth normals (at the nodes) Fieldconverted to the element nodes. No matter where we store the normals in the Mesh, it would certainly be an object of type 'Field', so that it can easily be converted.
Hi benedict in the exampLe you can see how it work with all the changes you want, and the different dimensionalities ndim<2 normals all aligned to z dir ndim==2 ok ndim>2 what we should do here, get the faces? only the border? the normal for a solid element does not make any sense A NORMALIZE parameter is needed to convert the fields, i did not use the convertField in setFieldNormals for this reason, otherwise it can be used, the facet is ambiguous. averaged on the single element normals or averaged on the averaged nodal element normals? in the example I decided to use the exact element normals (not averaged). if the user wants the smooth face can convert from 'smooth'. the only option left out from the previous code is the AVERAGED normals at each node for each element, (knd of a 'smooth exact') which cannot be retieved in other ways I think if we dont set it explicitly. it can also be useful in some cases For the storage, i dont know, though if we want to use the convert for the non listed cases i am not sure which way is more convenient (file #32062)
It had another look at this code. It would be interesting to implement some of this at the Mesh level, probably as a predefined attribute 'normals', which can then also be used for the rendering. There are some questions to be answered first though:
Field so they can be converted to other entities. ** 'exact': normals at each node for each element, defined by product of two edges of the element ending at that node. These are the exact normals for the rendered geometry. ** 'smooth': averaged at the nodes, giving the rendered surface a smooth look. ** 'facet': averaged over each element, giving the surface a faceted look.
or in the Mesh Fields with specialized keys e.g. '_normals_e' '_normals_s' and '_normals_f'? with a speci
Any update on the suggested functions. Where can be included? somewhere in mesh_ext or in a field to predefine some fields?
Hi In the example in attachment there are 2 functions to set the normals 1 setting the normals directly in the field 2 converts to using convertField.ยต The latter does not have normalized normals. Maybe we can include a normalization parameter in field. I am not sure where this should go and if you like the implementation. (file #31365)
Do not add it to the Mesh class: it will only increase the confusion. If you are working with triangles only: TriSurface has avgVertexNormals(), and areaNormals()[1] provides the facet normals. For the Mesh class, you can use a Field instance, which can then easily be converted. But for plexitudes > 3, how do you define element normals? The Mesh class should probably get a normals setter, which allows setting by an array/Field or automatically according to a value - 'smooth': averaged normals at the nodes - 'faceted': averaged normals at the elements - default: individual values at the element vertices
Hi benedict sorry I was referring to setNormals.I imagined it was for the GUI. Though I need element normals/ merged nodal coords in many applications and with the vtk interface so every time I have to mean over the axes. Can I put then a property getNormals which does not store the normals?
Is this about the Mesh.normals attribute? It is not clear to me how you can put options there. The Mesh.normals attribute should always be (nelems,nplex,3), because that is required by the shader programs. The attribute is set by Mesh.setNormals, which is AFAIK only used in webgl.py. This method is not well documented, becuase the setting of the normals attribute is a quick hack to get some GUI feature working. Direct setting of the attribute should be discouraged, and we should use the Field class to automatically multiplex the data to the required shape for use in the renderer. Note that a single normal per element is not very useful, unless the elements are triangles.
now the normals are returned only at the nodes elements with shape nelems,nplex,3 with options 'auto','avg'. can I put options 'autoAtElems', 'avgAtElems' for normals of shape elems,3 and 'autoAtnodes', 'avgAtnodq' for normals of shape ncoords,3?
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach Files: Comment:
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Only logged-in users can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Follow 2 latest changes.
Copyright © 2023 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Source Code
Powered by Savane 3.12