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
  • /
  • operations.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:d8dd70797960c6d7dc4aa0fafae6743841e9c765

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 ...
operations.docu
/** \page mesh_operations Some basic operations: Flipping and collapsing edges

In this section you will learn about some basic operations on a mesh that %OpenMesh
already provides. Comprising the flipping of edges in a triangle mesh as well as
collapsing edges by joining the two adjacent vertices.

\li \ref op_flip
\li \ref op_collapse

\section op_flip Flipping edges in triangle meshes

Considering two adjacent faces of a triangle mesh, there exist exactly two
different configurations of the inner edge. Calling the function
OpenMesh::TriConnectivity::flip(EdgeHandle _eh) will flip the specified edge to
its opposite orientation as shown in the illustration below.

\image html mesh.flip.png "Flipping edges in a triangle mesh"

So, the following snippet of code shows how to use this in your applications:

\code
TriMesh mesh;

// Add some vertices
TriMesh::VertexHandle vhandle[4];

vhandle[0] = mesh.add_vertex(MyMesh::Point(0, 0, 0));
vhandle[1] = mesh.add_vertex(MyMesh::Point(0, 1, 0));
vhandle[2] = mesh.add_vertex(MyMesh::Point(1, 1, 0));
vhandle[3] = mesh.add_vertex(MyMesh::Point(1, 0, 0));

// Add two faces
std::vector<TriMesh::VertexHandle> face_vhandles;

face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[0]);
mesh.add_face(face_vhandles);

face_vhandles.clear();

face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]);
mesh.add_face(face_vhandles);

// Now the edge adjacent to the two faces connects
// vertex vhandle[0] and vhandle[2].

// Find this edge and then flip it
for(TriMesh::EdgeIter it = mesh.edges_begin(); it != mesh.edges_end(); ++it) {

	if(!mesh.is_boundary(*it)) {
		// Flip edge
		mesh.flip(*it);
	}
}

// The edge now connects vertex vhandle[1] and vhandle[3].
\endcode


\section op_collapse Collapsing edges

In this section you will learn how to collapse edges such that the
two adjacent vertices join. %OpenMesh provides the function OpenMesh::PolyConnectivity::collapse(HalfedgeHandle _heh) to
perform this operation. This will collapse the from-vertex (remeber that halfedges are directed)
to the to-vertex of the halfedge as illustrated below. Note that collapsing edges
might cause topological inconsistencies to your mesh. You should verify consistency after
collapsing edges by calling OpenMesh::PolyConnectivity::is_collapse_ok(). 

\note You have to request status attributes in order to use the collapse and delete functions!

\image html mesh.collapse.png "Collapsing will always be performed in the direction the halfedge points to."

A simple code example related to the illustration might look like this:

\code
  PolyMesh mesh;

  // Request required status flags
  mesh.request_vertex_status();
  mesh.request_edge_status();
  mesh.request_face_status();

  // Add some vertices as in the illustration above
  PolyMesh::VertexHandle vhandle[7];
  vhandle[0] = mesh.add_vertex(MyMesh::Point(-1, 1, 0));
  vhandle[1] = mesh.add_vertex(MyMesh::Point(-1, 3, 0));
  vhandle[2] = mesh.add_vertex(MyMesh::Point(0, 0, 0));
  vhandle[3] = mesh.add_vertex(MyMesh::Point(0, 2, 0));
  vhandle[4] = mesh.add_vertex(MyMesh::Point(0, 4, 0));
  vhandle[5] = mesh.add_vertex(MyMesh::Point(1, 1, 0));
  vhandle[6] = mesh.add_vertex(MyMesh::Point(1, 3, 0));

  // Add three quad faces
  std::vector<PolyMesh::VertexHandle> face_vhandles;
  face_vhandles.push_back(vhandle[1]);
  face_vhandles.push_back(vhandle[0]);
  face_vhandles.push_back(vhandle[2]);
  face_vhandles.push_back(vhandle[3]);
  mesh.add_face(face_vhandles);

  face_vhandles.clear();
  face_vhandles.push_back(vhandle[1]);
  face_vhandles.push_back(vhandle[3]);
  face_vhandles.push_back(vhandle[5]);
  face_vhandles.push_back(vhandle[4]);
  mesh.add_face(face_vhandles);

  face_vhandles.clear();
  face_vhandles.push_back(vhandle[3]);
  face_vhandles.push_back(vhandle[2]);
  face_vhandles.push_back(vhandle[6]);
  face_vhandles.push_back(vhandle[5]);
  mesh.add_face(face_vhandles);

  // Now find the edge between vertex vhandle[2]
  // and vhandle[3]
  for(PolyMesh::HalfedgeIter it = mesh.halfedges_begin(); it != mesh.halfedges_end(); ++it) {
    if( mesh.to_vertex_handle(*it) == vhandle[3] &&
        mesh.from_vertex_handle(*it) == vhandle[2])
    {
      // Collapse edge
      mesh.collapse(*it);
      break;
    }
  }

  // Our mesh now looks like in the illustration above after the collapsing.

\endcode

*/
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