[[Home]](../index) [[Mesh Edit]](../meshedit/overview) [[Path Tracer]](../pathtracer/overview) [[Animation]](../animation/overview) --- # Beveling Here we provide some additional detail about the bevel operations and their implementation in Scotty3D. Each bevel operation has two components: 1. a method that modifies the _connectivity_ of the mesh, creating new beveled elements, and 2. a method the updates the _geometry_ of the mesh, insetting and offseting the new vertices according to user input. The methods that update the connectivity are `HalfedgeMesh::bevel_vertex`, `halfedgeMesh::bevel_edge`, and `HalfedgeMesh::bevel_face`. The methods that update geometry are `HalfedgeMesh::bevel_vertex_positions`, `HalfedgeMesh::extruve_vertex_position`, `HalfedgeMesh::bevel_edge_positions`, and `HalfedgeMesh::bevel_face_positions`. `HalfedgeMesh::extrude_vertex` will update both connectivity and geometry, as it should first perform a flat bevel on the vertex, and then insert a vertex into the new face. TODO: not used in stanford The methods for updating connectivity can be implemented following the general strategy outlined in [edge flip tutorial](./edge_flip). **Note that the methods that update geometry will be called repeatedly for the same bevel, in order to adjust positions according to user mouse input. See the gif in the [User Guide](../guide/model).** To update the _geometry_ of a beveled element, you are provided with the following data: * `start_positions` - These are the original vertex positions of the beveled mesh element, without any insetting or offsetting. * `face` - This is a reference to the face currently being beveled. This was returned by one of the connectivity functions. * `tangent_offset` - The amount by which the new face should be inset (i.e., "shrunk" or "expanded") * `normal_offset` - (faces only) The amount by which the new face should be offset in the normal direction. Also note that we provide code to gather the halfedges contained in the beveled face, creating the array `new_halfedges`. You should only have to update the position (`Vertex::pos`) of the vertices associated with this list of halfedges. The basic recipe for updating these positions is: * Iterate over the list of halfedges (`new_halfedges`) * Grab the vertex coordinates that are needed to compute the new, updated vertex coordinates (this could be a mix of values from `start_positions`, or the members `Vertex::pos`) * Compute the updated vertex positions using the current values of `tangent_offset` (and possibly `normal_offset`) * Store the new vertex positions in `Vertex::pos` _for the vertices of the new, beveled polygon only_ (i.e., the vertices associated with each of `new_halfedges`). The reason for storing `new_halfedges` and `start_positions` in an array is that it makes it easy to access positions "to the left" and "to the right" of a given vertex. For instance, suppose we want to figure out the offset from the corner of a polygon. We might want to compute some geometric quantity involving the three vertex positions `start_positions[i-1]`, `start_positions[i]`, and `start_positions[i+1]` (as well as `inset`), then set the new vertex position `new_halfedges[i]->vertex()->pos` to this new value: