Class Mesh¶
Defined in File mesh.h
Class Documentation¶
-
class Mesh¶
A collection of Triangles.
Public Functions
-
explicit Mesh(const std::vector<Triangle> &tris)¶
Constructs a Mesh from a vector of Triangles.
- Parameters:
tris[in] A vector of Triangles.
-
explicit Mesh(std::vector<Triangle> &&tris)¶
Constructs a Mesh from a vector of Triangles.
- Parameters:
tris[in] A vector of Triangles.
-
bool load_from_stl(const std::string &path)¶
Populates this Mesh with Triangles parsed from the contents of an STL file.
- Parameters:
path[in] The path to the STL file.
- Returns:
true if parsing the file succeeded.
-
bool load_from_stl_bytes(const std::vector<uint8_t> &bytes)¶
Populates this Mesh with Triangles parsed from the contents of an STL file.
- Parameters:
bytes[in] A vector of bytes, which should be the contents of an STL file.
- Returns:
true if parsing the bytes succeeded.
-
void save_stl_binary(std::ostream &output_stream) const¶
Writes the Triangles in this Mesh to an STL file in binary format.
- Parameters:
output_stream[in] An ostream (perhaps an ofstream) to write the STL ascii-formatted content to.
-
void save_stl_binary(const std::string &path) const¶
Writes the Triangles in this Mesh to an STL file in binary format.
- Parameters:
path[in] The path to the STL file to write to.
-
bool load_from_stl_stream(std::istream &input_stream)¶
Populates this Mesh with Triangles parsed from the provided istream.
- Parameters:
input_stream[in] An istream (perhaps an ifstream) which contains STL ascii-formatted content.
- Returns:
true if parsing the file succeeded.
-
const std::vector<Triangle> &triangles() const¶
Returns the Triangles.
- Returns:
A vector of Triangles.
-
bool closest_and_farthest_intersections(const Ray &beam, BoundsF &z) const¶
Returns the nearest and farthest distances the given ray intersects with the Mesh.
- Parameters:
beam[in] The Ray to test for intersections.
z[out] A BoundsF to populate with the near and far intersection distances.
- Returns:
true if there was at least one intersection, false otherwise.
-
std::multiset<float> intersection_distances(const Ray &beam) const¶
Returns the distances to all intersections between the Mesh and the given Ray.
- Parameters:
beam[in] The Ray to test for intersections.
- Returns:
A multiset of floats representing the distances to all intersections.
-
bool intersects_with_bounding_sphere(const Ray &beam) const¶
Returns true iff the beam intersects with the bounding sphere.
- Parameters:
beam[in] The Ray to test for intersection with the bounding sphere
- Returns:
true if the beam intersects with the bounding sphere, false otherwise
-
inline bool operator==(const Mesh &rhs) const¶
Returns true if this Mesh equals another Mesh.
- Parameters:
rhs[in] The other Mesh to compare against
- Returns:
True if the two Meshes are equal, false otherwise
-
inline bool operator!=(const Mesh &rhs) const¶
Returns true if this Mesh does not equal another Mesh.
- Parameters:
rhs[in] The other Mesh to compare against
- Returns:
True if the two Meshes are not equal, false otherwise
-
const BoundingSphere &bounding_sphere() const¶
Returns the bounding sphere of this Mesh.
- Returns:
The bounding sphere.
-
explicit Mesh(const std::vector<Triangle> &tris)¶