Skip to content

Commit

Permalink
add a few missing tests, fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nmwsharp committed Dec 24, 2023
1 parent 171c734 commit 6d10766
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/polyscope/parameterization_quantity.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ QuantityT* ParameterizationQuantity<QuantityT>::setStyle(ParamVizStyle newStyle)
exception("Cannot set parameterization visualization style to 'CHECKER_ISLANDS', no islands have been set");
newStyle = ParamVizStyle::CHECKER;
}
if (newStyle == ParamVizStyle::CHECKER_ISLANDS) {
cMap.setPassive("turbo"); // use turbo as default cmap for CHECKER_ISLANDS
}
Expand Down
5 changes: 4 additions & 1 deletion include/polyscope/volume_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class VolumeGrid : public QuantityStructure<VolumeGrid> {

// === Getters and setters for visualization settings

// Color of the mesh
// Color of the grid volume
VolumeGrid* setColor(glm::vec3 val);
glm::vec3 getColor();

Expand All @@ -136,6 +136,9 @@ class VolumeGrid : public QuantityStructure<VolumeGrid> {
VolumeGrid* setEdgeWidth(double newVal);
double getEdgeWidth();

// Scaling factor for the size of the little cubes
VolumeGrid* setCubeSizeFactor(double newVal);
double getCubeSizeFactor();

private:

Expand Down
3 changes: 2 additions & 1 deletion src/polyscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,8 @@ void draw(bool withUI, bool withContextCallback) {
}

// Execute the context callback, if there is one.
// This callback is a Polyscope implementation detail, which is distinct from the userCallback (which gets called above)
// This callback is a Polyscope implementation detail, which is distinct from the userCallback (which gets called
// above)
if (withContextCallback && contextStack.back().callback) {
(contextStack.back().callback)();
}
Expand Down
6 changes: 6 additions & 0 deletions src/volume_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ VolumeGrid* VolumeGrid::setEdgeWidth(double newVal) {
}
double VolumeGrid::getEdgeWidth() { return edgeWidth.get(); }

VolumeGrid* VolumeGrid::setCubeSizeFactor(double newVal) {
cubeSizeFactor = newVal;
requestRedraw();
return this;
}
double VolumeGrid::getCubeSizeFactor() { return cubeSizeFactor.get(); }

// === Register functions

Expand Down
17 changes: 17 additions & 0 deletions test/src/basics_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ TEST_F(PolyscopeTest, NestedShowWithFrameTick) {
polyscope::state::userCallback = nullptr;
}

TEST_F(PolyscopeTest, Unshow) {

int32_t count = 0;
auto showCallback = [&]() {
if (count > 1) {
polyscope::unshow();
}
count++;
};
polyscope::state::userCallback = showCallback;
polyscope::show(10);

EXPECT_LT(count, 4);

polyscope::state::userCallback = nullptr;
}

// Make sure that creating an empty buffer does not throw errors
TEST_F(PolyscopeTest, EmptyBuffer) {

Expand Down
29 changes: 28 additions & 1 deletion test/src/surface_mesh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,33 @@ TEST_F(PolyscopeTest, SurfaceMeshPick) {
polyscope::removeAllStructures();
}

TEST_F(PolyscopeTest, SurfaceMeshMark) {
auto psMesh = registerTriangleMesh();

// edges
size_t nEdges = 6;
std::vector<size_t> ePerm = {5, 3, 1, 2, 4, 0};
psMesh->setEdgePermutation(ePerm);
psMesh->markEdgesAsUsed();
polyscope::show(3);

// halfedges
std::vector<size_t> hePerm;
for (size_t i = 0; i < psMesh->nCorners(); i++) {
hePerm.push_back(5 + i);
}
psMesh->setHalfedgePermutation(hePerm);
psMesh->markHalfedgesAsUsed();
polyscope::show(3);

// corners
// (permutation is not required for this one)
psMesh->markCornersAsUsed();
polyscope::show(3);

polyscope::removeAllStructures();
}

TEST_F(PolyscopeTest, SurfaceMeshBackface) {
auto psMesh = registerTriangleMesh();

Expand Down Expand Up @@ -321,7 +348,7 @@ TEST_F(PolyscopeTest, SurfaceMeshCornerParam) {
q1->setIslandLabels(islandLabels);
q1->setStyle(polyscope::ParamVizStyle::CHECKER_ISLANDS);
polyscope::show(3);


// create the curve network
q1->createCurveNetworkFromSeams();
Expand Down
4 changes: 4 additions & 0 deletions test/src/volume_grid_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ TEST_F(PolyscopeTest, VolumeGridBasicOptions) {
// Edge width
psGrid->setEdgeWidth(0.5);
polyscope::show(3);

// Grid size factor
psGrid->setCubeSizeFactor(0.5);
polyscope::show(3);

polyscope::removeAllStructures();
}
Expand Down

0 comments on commit 6d10766

Please sign in to comment.