Struct dzahui::mesh::mesh_builder::MeshBuilder
source · pub(crate) struct MeshBuilder {
location: String,
}
Expand description
General Information
Needs .obj. Needed elements to create mesh (1D, 2D or 3D). Builds real structure parsing .obj and distinguishing internal and boundary vertices.
Fields
location
- Path to .obj.
Fields§
§location: String
Implementations§
source§impl MeshBuilder
impl MeshBuilder
sourcepub(crate) fn new<B>(location: B) -> Selfwhere
B: AsRef<str>,
pub(crate) fn new<B>(location: B) -> Selfwhere
B: AsRef<str>,
Creates initial instance. Not to be used on it’s own. Use Mesh::build
.
sourcefn obj_vertex_checker<A>(line: &A) -> Result<Vec<f64>, Error>where
A: AsRef<str>,
fn obj_vertex_checker<A>(line: &A) -> Result<Vec<f64>, Error>where
A: AsRef<str>,
Checks wether a line starting with ’v ’ in an obj has the three vertices needed. Auxiliar function used inside build methods. Part of the checkup made to a given input file.
sourcefn obj_face_checker<A>(line: &A) -> Result<Vec<u32>, Error>where
A: AsRef<str>,
fn obj_face_checker<A>(line: &A) -> Result<Vec<u32>, Error>where
A: AsRef<str>,
Verifies the amount of face specifications per line is 3 and also that all of them have the correct syntax ‘a/b/c’. Auxiliar function used inside build methods. Part of the checkup made to a given input file.
sourcefn check_for_constant_coordinates(
&self
) -> Result<[HashMap<String, f32>; 3], Error>
fn check_for_constant_coordinates(
&self
) -> Result<[HashMap<String, f32>; 3], Error>
General information
Returns hashmap with every diferent value per coordinate inside .obj. It’s useful to check if a given .obj is a 2d or 1d mesh.
Parameters
&self
- Only the file in self is needed to make the verification.
sourcepub fn build_mesh_1d(self, height_multiplier: Option<f64>) -> Result<Mesh, Error>
pub fn build_mesh_1d(self, height_multiplier: Option<f64>) -> Result<Mesh, Error>
General Information
Builds a one dimensional mesh. Only a line of well defined points is needed. The method will create another paralell line to generate a bar copying every important element. Colors for mesh are inserted into vertices array, therefore, every vertex has 6 entries: 3 for coordinates and 3 for color (RGB), Faces are not needed in .obj for this method
Parameters
self
- Consumes builder.
sourcepub fn build_mesh_2d(self) -> Result<Mesh, Error>
pub fn build_mesh_2d(self) -> Result<Mesh, Error>
General Information
Builds a two dimensional mesh. A different approach needs to be taken to distinguish boundary vertices from internal ones. Algorithm consists on checking if a given edge from mesh appears once or more. If it appears only once, then the vertex is at the boundary (since it’s only adjacent to a single traingle), otherwise, it’s internal. Colors for mesh are inserted into vertices array, therefore, every vertex has 6 entries: 3 for coordinates and 3 for color (RGB).
Parameters
self
- Consumes builder.
sourcepub fn build_mesh_3d(self) -> Result<Mesh, Error>
pub fn build_mesh_3d(self) -> Result<Mesh, Error>
General Information
Builds a three dimensional mesh. A different approach needs to be taken to distinguish boundary vertices from internal ones. Algorithm not yet implemented Colors for mesh are inserted into vertices array, therefore, every vertex has 6 entries: 3 for coordinates and 3 for color (RGB).
Parameters
self
- Consumes builder.