Geometry — 3D#
Typedefs
-
typedef CGAL::Exact_predicates_exact_constructions_kernel EX_K#
-
typedef CGAL::Simple_cartesian<double> SC_Kernel#
-
typedef openvdb::FloatGrid SDF_Grid#
-
struct Indexed_Triangle#
- #include <primitives.h>
-
class SurfaceMesh#
- #include <SurfaceMesh.h>
A class for storing and manipulating triangle meshes.
Public Types
-
typedef CGAL::AABB_traits_3<SC_Kernel, AABBPrimitive> MeshAABBTraits#
-
typedef CGAL::AABB_tree<MeshAABBTraits> MeshAABBTree#
Public Functions
-
std::pair<glm::vec3, glm::vec3> bounding_box() const#
Returns the bounding box of the mesh.
- Returns:
The bounding box of the mesh
-
void center()#
Centers the mesh around the origin.
-
SDF_Grid::Ptr compute_sdf(glm::vec3 voxel_size, float exterior_band_width = 3.0f, float interior_band_width = 3.0f) const#
Returns the center of the mesh.
- Parameters:
voxel_size – The size of each voxel in the grid. This resolution does not need to match what you sample, and can be asymmetric.
exterior_band_width – The width of the exterior band of the SDF
interior_band_width – The width of the interior band of the SDF
- Returns:
The center of the mesh
-
double signed_distance(double x, double y, double z) const#
-
SurfaceMesh()#
Default constructor.
-
SurfaceMesh(std::string file_path, bool disable_validation = false)#
Constructor that loads a mesh from a file.
- Parameters:
file_path – The path to the file to load
-
SurfaceMesh(std::vector<glm::vec3> vertices, std::vector<Indexed_Triangle> triangles, bool disable_validation = false)#
Constructor that creates a mesh from vertices and triangles.
- Parameters:
vertices – The vertices of the mesh
triangles – The triangles of the mesh
-
void translate(glm::vec3 translation)#
Translates the mesh by a given translation vector.
- Parameters:
translation – The translation vector to apply to the mesh (mm)
-
std::vector<Indexed_Triangle> triangles() const#
Returns the triangles of the mesh.
- Returns:
The triangles of the mesh
-
std::vector<glm::vec3> vertices() const#
Returns the vertices of the mesh.
- Returns:
The vertices of the mesh
-
void write_stl(const std::string &output_file_name)#
Writes the mesh to a binary STL file.
- Parameters:
output_file_name – The name of the file to write to
Private Members
-
std::shared_ptr<Point_inside> m_inside_tester#
-
std::shared_ptr<MeshAABBTree> m_tree#
-
std::vector<Indexed_Triangle> m_triangles#
The triangles of the mesh.
Private Static Functions
-
static std::tuple<std::vector<glm::vec3>, std::vector<Indexed_Triangle>, glm::vec3, glm::vec3> LoadMeshFromFile(std::string file_path)#
Loads a mesh from a file.
- Parameters:
file_path – The path to the file to load
- Returns:
A tuple containing the vertices, triangles, minimum coordinate, and maximum coordinate of the mesh
-
static std::shared_ptr<CGALMesh> ToCGALMesh(std::vector<glm::vec3> vertices, std::vector<Indexed_Triangle> triangles)#
-
struct TriangleMeshDataAdapter#
An adapter for OpenVDB to use with mesh triangle/ vertex data.
Public Functions
-
inline void addTriangle(openvdb::Vec3I triangle)#
Add a triangle from the mesh to the adapter.
Note
triangles are stored as a Vec3I, where each element is the index of a vertex in the vertex array
- Parameters:
triangle – The triangle to add
-
inline void addVertex(openvdb::Vec3f vertex)#
Add a vertex from the mesh to the adapter.
- Parameters:
vertex – The vertex to add
-
inline void getIndexSpacePoint(size_t n, size_t v, openvdb::Vec3d &pos) const#
Return position pos in local grid index space for polygon n and vertex v.
- Parameters:
n – The polygon index
v – The vertex index
pos – The position of the vertex in local grid index space
-
inline size_t pointCount() const#
Total number of points (vertices in this case).
- Returns:
The number of points
-
inline size_t polygonCount() const#
Total number of polygons (triangles in this case).
- Returns:
The number of polygons
-
inline TriangleMeshDataAdapter(glm::vec3 voxel_size, long long vertex_count, long long triangle_count)#
Constructor.
- Parameters:
voxel_size – The size of each voxel in the grid. This resolution does not need to match what you sample, and can be asymmetric.
vertex_count – The number of vertices in the mesh- used to preallocate memory
triangle_count – The number of triangles in the mesh- used to preallocate memory
-
inline size_t vertexCount(size_t n) const#
Vertex count for polygon n (always 3 in this case because of triangles).
- Parameters:
n – The polygon index
Private Members
-
double m_inv_min_voxel_size#
The inverse of the minimum voxel size.
-
std::vector<openvdb::Vec3I> m_triangles#
The triangles of the mesh.
-
std::vector<openvdb::Vec3f> m_vertices#
The vertices of the mesh.
-
glm::vec3 m_voxel_size#
The size of each voxel in the grid. This resolution does not need to match what you sample, and can be asymmetric.
-
int tri_index = 0#
The index of the next triangle to add.
-
int vert_index = 0#
The index of the next vertex to add.
-
inline void addTriangle(openvdb::Vec3I triangle)#
-
typedef CGAL::AABB_traits_3<SC_Kernel, AABBPrimitive> MeshAABBTraits#
-
class CADPart#
- #include <cad_part.h>
A CAD geometry primitive.
The CAD is loaded from a file into memory and provides a signed distance adapter to the surface.
Note
This class supports STEP and IGES file formats.
Public Functions
-
CADPart() = default#
-
CADPart(TopoDS_Shape part)#
-
void export_as_stl(const std::string &path, double deflection = 0.1)#
-
void set_fast_mode(bool fast_mode, glm::vec3 voxel_size, double interior_bandwidth, double exterior_bandwidth, double deflection = 0.1)#
-
double signed_distance_to_surface(double x, double y, double z)#
Returns the signed distance to the surface of the CAD geometry.
- Parameters:
x – The x coordinate
y – The y coordinate
z – The z coordinate
-
std::shared_ptr<SurfaceMesh> to_surface_mesh(double deflection = 0.1)#
Private Types
-
typedef openvdb::FloatGrid GridType#
The type of grid used by OpenVDB.
-
CADPart() = default#
Typedefs
-
template<typename T>
using AABB_tetrahedron_traits = CGAL::AABB_traits_3<SC_Kernel, TetrahedronPrimitive<T>># Define the AABB traits for the TetrahedronPrimitive.
-
template<typename T>
using AABBTree = CGAL::AABB_tree<AABB_tetrahedron_traits<T>># Define the AABB tree for the TetrahedronPrimitive.
-
template<typename T>
class Tetrahedron# - #include <tetrahedron.h>
A class that represents a tetrahedron in 3D space.
This class is used to represent a tetrahedron in 3D space. The tetrahedron is defined by four points in 3D space. The class also stores a value (template) associated with each point in the tetrahedron. Methods are provided to interpolate given a point in space within the tetrahedron.
Public Functions
-
inline glm::vec3 barycenter() const#
Compute the barycenter of the tetrahedron.
- Returns:
The barycenter or center of mass of the tetrahedron
-
inline glm::vec4 barycentric_coordinates(const glm::vec3 &point) const#
Compute the barycentric coordinates of a point in space within the tetrahedron.
- Parameters:
point – The point in space to compute the barycentric coordinates for
- Returns:
The barycentric coordinates of the point
-
inline std::pair<glm::vec3, glm::vec3> bounding_box() const#
Compute the bounding box of the tetrahedron.
- Returns:
A pair of the minimum and maximum points of the bounding box
-
inline bool is_point_inside(const glm::vec3 &point) const#
Check if a point is inside the tetrahedron.
Note
depends on barycentric_coordinates()
- Parameters:
point – The point to check
- Returns:
True if the point is inside the tetrahedron, false otherwise
-
inline glm::vec3 max_point() const#
Compute the maximum point of the tetrahedron.
- Returns:
The maximum point of the tetrahedron
-
inline glm::vec3 min_point() const#
Compute the minimum point of the tetrahedron.
- Returns:
The minimum point of the tetrahedron
-
inline T sample(const glm::vec3 &point) const#
Interpolate a value at a point in space within the tetrahedron.
- Parameters:
point – The point in space to interpolate the value at
- Returns:
The interpolated value at the point
-
Tetrahedron() = default#
Constructor.
-
inline Tetrahedron(const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c, const glm::vec3 &d, const T &a_val, const T &b_val, const T &c_val, const T &d_val)#
Constructor.
- Parameters:
a – The first point of the tetrahedron
b – The second point of the tetrahedron
c – The third point of the tetrahedron
d – The fourth point of the tetrahedron
a_val – The value associated with the first point
b_val – The value associated with the second point
c_val – The value associated with the third point
d_val – The value associated with the fourth point
-
inline double volume() const#
Compute the volume of the tetrahedron.
- Returns:
The volume of the tetrahedron in mm^3
-
inline glm::vec3 barycenter() const#
-
template<typename T>
class TetrahedronPrimitive# - #include <tetrahedron.h>
Public Types
-
typedef const Tetrahedron<T> *Id#
Public Functions
-
inline TetrahedronPrimitive(Tetrahedron<T> *tet)#
Public Members
-
Tetrahedron<T> *m_ptr#
-
typedef const Tetrahedron<T> *Id#
Typedefs
-
typedef CGAL::Parallel_tag Concurrency_tag#
-
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel#
-
typedef CGAL::Mesh_triangulation_3<Mesh_domain, CGAL::Default, Concurrency_tag>::type Tr#
-
class TetrahedralMesh#
- #include <tetrahedral_mesh.h>
Class representing a tetrahedral mesh using CGAL.
Contains functions to write out the mesh.
Public Functions
-
inline size_t degree_of_freedom() const#
-
inline size_t number_of_elements() const#
-
inline size_t number_of_nodes() const#
-
TetrahedralMesh(const C3t3 &c3t3)#
Constructor that takes a C3t3 object.
- Parameters:
c3t3 – The C3t3 object
Writes the tetrahedral mesh to an INP file.
- Parameters:
filename – The filename to write to
root – Optional root node of the tree to sample material properties from
Public Static Functions
Creates a TetrahedralMesh from a tree using a static cell size.
Creates a TetrahedralMesh from a tree using a variable cell size based on the material properties gradient.
-
inline size_t degree_of_freedom() const#
-
class HexahedralMesh#
- #include <hexahedral_mesh.h>
Public Functions
-
void compute()#
-
inline std::vector<std::tuple<size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t>> elements() const#
-
inline std::unordered_map<uint8_t, std::vector<size_t>> material_assignments() const#
Private Functions
-
std::string getHashKey(double x, double y, double z)#
-
size_t insert_node(double x, double y, double z)#
Private Members
-
std::vector<std::tuple<size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t>> m_elements#
-
std::unordered_map<uint8_t, std::vector<size_t>> m_material_assignments#
-
std::unordered_map<std::string, size_t> m_node_map#
-
size_t m_x_voxels#
-
size_t m_y_voxels#
-
size_t m_z_voxels#
-
struct IndexedPoint#
-
void compute()#
Typedefs
-
using AABB_vcad_node_traits = CGAL::AABB_traits_3<SC_Kernel, VCADNodeBBoxPrimitive>#
-
using AABBVCADTree = CGAL::AABB_tree<AABB_vcad_node_traits>#