Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/polyscope/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ POLYSCOPE_DEFINE_ENUM_NAMES(VolumeMeshElement,
{VolumeMeshElement::CELL, "Cell"}
);

enum class VolumeCellType { TET = 0, HEX };
enum class VolumeCellType { TET = 0, HEX, PRISM, PYRAMID};
POLYSCOPE_DEFINE_ENUM_NAMES(VolumeCellType,
{VolumeCellType::TET, "Tet"},
{VolumeCellType::HEX, "Hex"}
{VolumeCellType::HEX, "Hex"},
{VolumeCellType::PRISM, "Prism"},
{VolumeCellType::PYRAMID, "Pyramid"}
);

enum class VolumeGridElement { NODE = 0, CELL };
Expand Down
33 changes: 31 additions & 2 deletions include/polyscope/volume_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ class VolumeMesh : public Structure {
void fillGeometryBuffers(render::ShaderProgram& p);
void fillSliceGeometryBuffers(render::ShaderProgram& p);
static const std::vector<std::vector<std::array<size_t, 3>>>& cellStencil(VolumeCellType type);

static const std::vector<std::vector<size_t>>& cellFaces(VolumeCellType type);
// For each (face, triangle, edge-within-triangle), whether that edge is a real polygon boundary edge.
// Indexed as [face][tri][k], paralleling cellStencil().
static const std::vector<std::vector<std::array<bool, 3>>>& cellRealEdgeStencil(VolumeCellType type);
// Slice plane listeners
std::vector<polyscope::SlicePlane*> volumeSlicePlaneListeners;
void addSlicePlaneListener(polyscope::SlicePlane* sp);
Expand Down Expand Up @@ -256,9 +259,25 @@ class VolumeMesh : public Structure {
// clang-format off
static const std::vector<std::vector<std::array<size_t, 3>>> stencilTet;
static const std::vector<std::vector<std::array<size_t, 3>>> stencilHex;
static const std::vector<std::vector<std::array<size_t, 3>>> stencilPrism;
static const std::vector<std::vector<std::array<size_t, 3>>> stencilPyramid;
static const std::vector<std::vector<size_t>> facesTet;
static const std::vector<std::vector<size_t>> facesHex;
static const std::vector<std::vector<size_t>> facesPrism;
static const std::vector<std::vector<size_t>> facesPyramid;

static const std::array<std::array<size_t, 8>, 8> rotationMap;
static const std::array<std::array<std::array<size_t, 4>, 6>, 4> diagonalMap;

// precomputed real-edge flags: [face][tri][k] = is edge k of that triangle a polygon boundary edge?
static std::vector<std::vector<std::array<bool, 3>>> realEdgeStencilTet;
static std::vector<std::vector<std::array<bool, 3>>> realEdgeStencilHex;
static std::vector<std::vector<std::array<bool, 3>>> realEdgeStencilPrism;
static std::vector<std::vector<std::array<bool, 3>>> realEdgeStencilPyramid;

static bool constantDataInitialized;
static void initializeConstantData();

// clang-format off

// === Quantity adders
Expand All @@ -278,12 +297,22 @@ class VolumeMesh : public Structure {
};

// Register functions

// Register a volume mesh with all tetrahedral cells. tetIndices has shape (nTets, 4).
template <class V, class C>
VolumeMesh* registerTetMesh(std::string name, const V& vertexPositions, const C& tetIndices);

// Register a volume mesh with all hexahedral cells. hexIndices has shape (nHexes, 8).
template <class V, class C>
VolumeMesh* registerHexMesh(std::string name, const V& vertexPositions, const C& hexIndices);

// Register a volume mesh with general mixed cell types (tet, hex, prism, pyramid). cellIndices has shape (nCells, 8);
// cells with fewer than 8 vertices are right-padded with negative indices to indicate unused slots.
template <class V, class C>
VolumeMesh* registerVolumeMesh(std::string name, const V& vertexPositions, const C& hexIndices);
VolumeMesh* registerVolumeMesh(std::string name, const V& vertexPositions, const C& cellIndices);

// Register a volume mesh from separate tet and hex index arrays.
// Cells are ordered with all tets first, then all hexes. Note that pyrams and prisms are also supported, but not from this function.
template <class V, class Ct, class Ch>
VolumeMesh* registerTetHexMesh(std::string name, const V& vertexPositions, const Ct& tetIndices, const Ch& hexIndices);

Expand Down
4 changes: 2 additions & 2 deletions include/polyscope/volume_mesh.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ VolumeMesh* registerHexMesh(std::string name, const V& vertexPositions, const F&
}

template <class V, class F>
VolumeMesh* registerVolumeMesh(std::string name, const V& vertexPositions, const F& faceIndices) {
VolumeMesh* registerVolumeMesh(std::string name, const V& vertexPositions, const F& cellIndices) {
checkInitialized();

VolumeMesh* s = new VolumeMesh(name, standardizeVectorArray<glm::vec3, 3>(vertexPositions),
standardizeVectorArray<std::array<uint32_t, 8>, 8>(faceIndices));
standardizeVectorArray<std::array<uint32_t, 8>, 8>(cellIndices));

bool success = registerStructure(s);
if (!success) {
Expand Down
1 change: 1 addition & 0 deletions src/slice_plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ void SlicePlane::setSliceGeomUniforms(render::ShaderProgram& p) {


void SlicePlane::setVolumeMeshToInspect(std::string meshname) {
requestRedraw();
VolumeMesh* oldMeshToInspect = inspectedMeshName == "" ? nullptr : polyscope::getVolumeMesh(inspectedMeshName);
if (oldMeshToInspect != nullptr) {
oldMeshToInspect->removeSlicePlaneListener(this);
Expand Down
Loading