Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision c2ea6fbae2634487a33181bb44d1508b19a4507c authored by Jan Möbius on 23 November 2022, 15:04:04 UTC, committed by Jan Möbius on 23 November 2022, 15:04:04 UTC
Merge branch 'fix_calc_normal_for_edges' into 'master'
Fix calc_normal for edges

See merge request OpenMesh/OpenMesh!325
2 parent s 3f328cd + 121ff40
  • Files
  • Changes
  • 2d0c205
  • /
  • Doc
  • /
  • tutorial_06.docu
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:c2ea6fbae2634487a33181bb44d1508b19a4507c
directory badge
swh:1:dir:83d80ecaf3ffe2b50dfbe0365d52d7add12e01b8
content badge
swh:1:cnt:04984f27dc6111391142a6df02deb6b1cae1077c

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
tutorial_06.docu
/** \page tutorial_06 Using mesh attributes and traits

this example shows how to change the data type for positions, normals, colors, and texture,

In the previous tutorial (\ref tutorial_05) we learned to use standard
properties by calling the appropriate \c request method.
Unlike the custom properties, where the user specifies the
data type by passing the type to the handle (e.g. \c
MyMesh::FPropHandleT< <b>int</b>>), the data types of the standard
properties are defined by so-called mesh traits. With traits we can
customize and extend the mesh data structure. We can do this by
changing two important features

-# changing data type for positions, normals, colors, and texture
   coordinates 
-# extend mesh entities Vertex, Face, Edge, and Halfedge
   (see tutorial '\ref tutorial_07')

Let's start. Every custom traits should derive from the default traits

\dontinclude 06-attributes/attributes.cc 
\skipline struct MyTraits

As mentioned, we can change the basic data types for the basic types
\c MyMesh::Point, \c MyMesh::Normal, \c MyMesh::Color, and \c MyMesh::TexCoord.
We can use the provided vector class or we use a
different one from another library. Here we simply replace the default
type \c OpenMesh::Vec3f (defined in the \c OpenMesh::DefaultTraits)
for positions and normals with \c OpenMesh::Vec3d

\skipline Vec3d
\skipline Vec3d

(In general it's better to have the same scalar type for the point and
normal vector, for instance \c double in this case. Otherwise we have
to cast quite a lot depending on the implementation of the vector class.)

Be aware that these settings overwrite the ones of the parent traits
class! As we usually derive from the DefaultTraits let's have a close look.

Actually the struct \c OpenMesh::DefaultTraits is merely empty. It solely
defines the types for \c Point, \c Normal, \c TexCoord, and \c Color
and one attribute, that we used implicitly all the time:

\skipline HalfedgeAttributes

The attribute \c PrevHalfedge is different, as it does not control a
property.  Yet it has a great impact on the resulting mesh type, as it
adds additional information to the halfedge structure. The impact
is twofold:

-# fast access to previous halfedge
-# increase of memory consumption

Using this feature depends highly on our needs. One situation where
the previous halfedges are quite handy, is the mesh member function
add_face(). The execution time for the member function drops
dramatically, when the information about the previous halfedge is
available. Usually we want to have this information. But if not, because we
must save memory, we can easily remove it with

\skipline HalfedgeAttributes

Then we need 8 bytes less per edge, which can be quite a lot as one can
derive from the Euler formula <b style="background-color:#FFFFFF;">(\f$V-E+F=2 (1-g)\f$)</b>, that for a regular
triangle meshes with genus <b style="background-color:#FFFFFF;">\f$g=0\f$</b> the number of edges
<b style="background-color:#FFFFFF;">\f$E\f$</b> is approximately
three times the number of vertices <b style="background-color:#FFFFFF;">\f$V\f$: \f$ E \approx 3 \cdot V\f$</b>.

The complete source looks like this:

\include 06-attributes/attributes.cc

*/
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API