diff --git a/.gitmodules b/.gitmodules index 42f5a2df..d058f77b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,6 @@ path = deps/imgui/imgui url = https://github.com/ocornut/imgui.git branch = master -[submodule "deps/geometry-central"] - path = deps/geometry-central - url = https://github.com/nmwsharp/geometry-central.git - branch = master +[submodule "deps/glm"] + path = deps/glm + url = https://github.com/g-truc/glm.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 80a1b49e..cf47718c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STR # using Clang (linux or apple) or GCC message("Using clang/gcc compiler flags") SET(BASE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Werror -g3") - SET(DISABLED_WARNINGS " -Wno-unused-parameter -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-deprecated-declarations") + SET(DISABLED_WARNINGS " -Wno-unused-parameter -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-deprecated-declarations -Wno-missing-braces") SET(TRACE_INCLUDES " -H -Wno-error=unused-command-line-argument") # clang-specific things diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 6d9ebd1e..ad1d398f 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -12,13 +12,5 @@ add_subdirectory(glfw) ## Imgui add_subdirectory(imgui) -## Geometry Central -add_subdirectory(geometry-central) -set(GEOMETRY_CENTRAL_INCLUDE_DIRS ${GEOMETRY_CENTRAL_INCLUDE_DIRS} PARENT_SCOPE) - -if(HAVE_SUITESPARSE) - SET(HAVE_SUITESPARSE TRUE PARENT_SCOPE) -endif() - ## Argparse diff --git a/deps/geometry-central b/deps/geometry-central deleted file mode 160000 index 9574e205..00000000 --- a/deps/geometry-central +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9574e205b388a5b4176e02e2eab2c54d434b4038 diff --git a/deps/glm b/deps/glm new file mode 160000 index 00000000..20b3f4bd --- /dev/null +++ b/deps/glm @@ -0,0 +1 @@ +Subproject commit 20b3f4bd4268feea8b4867c6f0e3f1aa74a75bd1 diff --git a/include/polyscope/affine_remapper.ipp b/include/polyscope/affine_remapper.ipp index 93be94b6..9438e111 100644 --- a/include/polyscope/affine_remapper.ipp +++ b/include/polyscope/affine_remapper.ipp @@ -1,6 +1,6 @@ #pragma once -#include "geometrycentral/vector3.h" +#include "glm/glm.hpp" namespace polyscope { @@ -13,8 +13,8 @@ double FIELD_BIGNESS(T x) { return x; } template <> -double FIELD_BIGNESS(geometrycentral::Vector3 x) { - return geometrycentral::norm(x); +double FIELD_BIGNESS(glm::vec3 x) { + return glm::length(x); } // Multiplicative identity @@ -23,8 +23,8 @@ T FIELD_ONE() { return 1; } template <> -geometrycentral::Vector3 FIELD_ONE() { - return geometrycentral::Vector3{1., 1., 1.}; +glm::vec3 FIELD_ONE() { + return glm::vec3{1., 1., 1.}; } // Additive identity @@ -33,8 +33,8 @@ T FIELD_ZERO() { return 0; } template <> -geometrycentral::Vector3 FIELD_ZERO() { - return geometrycentral::Vector3::zero(); +glm::vec3 FIELD_ZERO() { + return glm::vec3{0., 0., 0.}; } }; // namespace diff --git a/include/polyscope/camera_view.h b/include/polyscope/camera_view.h index 7fc6d83c..7f889219 100644 --- a/include/polyscope/camera_view.h +++ b/include/polyscope/camera_view.h @@ -2,11 +2,9 @@ #include -#include "geometrycentral/vector3.h" - +#include "polyscope/camera_parameters.h" #include "polyscope/gl/gl_utils.h" #include "polyscope/structure.h" -#include "polyscope/camera_parameters.h" namespace polyscope { @@ -21,11 +19,10 @@ class Image { std::string name; size_t width, height; unsigned char* data; - }; class CameraView : public Structure { - public: +public: // === Member functions === // Construct a new camera view structure @@ -51,25 +48,24 @@ class CameraView : public Structure { virtual double lengthScale() override; // Axis-aligned bounding box for the structure - virtual std::tuple - boundingBox() override; + virtual std::tuple boundingBox() override; // === Quantity-related // Add an image with RGB components void setActiveImage(std::string name); void clearActiveImage(); void addImage(std::string name, unsigned char* I, size_t width, size_t height); - void removeImage(std::string name, bool errorIfNotPresent=false); + void removeImage(std::string name, bool errorIfNotPresent = false); // === Helpers void prepareCameraSkeleton(); // Get the points that describe the "skeleton" in world space. Frame is CCW, starting with upper right. // dirFrame is {lookDir, upDir, rightDir} - void getCameraPoints(Vector3& root, std::array& framePoints, std::array& dirFrame); - Vector3 location(); + void getCameraPoints(glm::vec3& root, std::array& framePoints, std::array& dirFrame); + glm::vec3 location(); + - void drawWireframe(); void drawImageView(); @@ -81,11 +77,10 @@ class CameraView : public Structure { // The camera parameters CameraParameters parameters; - private: - +private: // Quantities std::map images; - + // Drawing related things gl::GLProgram* cameraSkeletonProgram = nullptr; gl::GLProgram* pickProgram = nullptr; @@ -93,9 +88,5 @@ class CameraView : public Structure { gl::GLProgram* imageViewProgram = nullptr; static float globalImageTransparency; float cameraSkeletonScale; // the lengthscale cameras were first drawn with - - }; - - } diff --git a/include/polyscope/gl/colormaps.h b/include/polyscope/gl/colormaps.h index d3dcd81a..8e180077 100644 --- a/include/polyscope/gl/colormaps.h +++ b/include/polyscope/gl/colormaps.h @@ -2,9 +2,7 @@ #include -#include "geometrycentral/vector3.h" - -using namespace geometrycentral; +#include "polyscope/color_management.h" namespace polyscope { namespace gl { @@ -45,11 +43,11 @@ namespace gl { struct Colormap { std::string name; - std::vector values; + std::vector values; // Samples "val" from the colormap, where val is clamped to [0,1]. // Returns a vector3 of rgb values, each from [0,1] - Vector3 getValue(double val) const; + Color3f getValue(double val) const; }; diff --git a/include/polyscope/gl/colors.h b/include/polyscope/gl/colors.h index 44276896..c1ebf1a7 100644 --- a/include/polyscope/gl/colors.h +++ b/include/polyscope/gl/colors.h @@ -1,22 +1,18 @@ #pragma once -#include "geometrycentral/vector3.h" - -using namespace geometrycentral; - namespace polyscope { namespace gl { -const Vector3 RGB_TEAL = {0., 178./255., 178./255.}; -const Vector3 RGB_BLUE = {150./255., 154./255., 255./255.}; -const Vector3 RGB_SKYBLUE = {152./255., 158./255., 200./255.}; -const Vector3 RGB_ORANGE = {1., 0.5, 0.}; -const Vector3 RGB_BLACK = {0., 0., 0.}; -const Vector3 RGB_WHITE = {1., 1., 1.}; -const Vector3 RGB_RED = {0.8, 0., 0.}; -const Vector3 RGB_DARKGRAY = { .2, .2, .2 }; -const Vector3 RGB_LIGHTGRAY = { .8, .8, .8 }; -const Vector3 RGB_DARKRED = { .2, .0, .0 }; +const Color3f RGB_TEAL = {0., 178./255., 178./255.}; +const Color3f RGB_BLUE = {150./255., 154./255., 255./255.}; +const Color3f RGB_SKYBLUE = {152./255., 158./255., 200./255.}; +const Color3f RGB_ORANGE = {1., 0.5, 0.}; +const Color3f RGB_BLACK = {0., 0., 0.}; +const Color3f RGB_WHITE = {1., 1., 1.}; +const Color3f RGB_RED = {0.8, 0., 0.}; +const Color3f RGB_DARKGRAY = { .2, .2, .2 }; +const Color3f RGB_LIGHTGRAY = { .8, .8, .8 }; +const Color3f RGB_DARKRED = { .2, .0, .0 }; } // namespace gl } // namespace polyscope diff --git a/include/polyscope/gl/gl_utils.h b/include/polyscope/gl/gl_utils.h index cbb6ae9e..42cb99de 100644 --- a/include/polyscope/gl/gl_utils.h +++ b/include/polyscope/gl/gl_utils.h @@ -19,10 +19,6 @@ #include "polyscope/gl/shaders.h" #include "polyscope/view.h" -#include "geometrycentral/utilities.h" -#include "geometrycentral/vector2.h" -#include "geometrycentral/vector3.h" - namespace polyscope { namespace gl { @@ -70,15 +66,15 @@ class GLProgram { void setUniform(std::string name, float val); void setUniform(std::string name, double val); // WARNING casts down to float void setUniform(std::string name, float* val); - void setUniform(std::string name, Vector2 val); - void setUniform(std::string name, Vector3 val); + void setUniform(std::string name, glm::vec2 val); + void setUniform(std::string name, glm::vec3 val); void setUniform(std::string name, std::array val); void setUniform(std::string name, float x, float y, float z, float w); // = Attributes - void setAttribute(std::string name, const std::vector& data, bool update = false, int offset = 0, + void setAttribute(std::string name, const std::vector& data, bool update = false, int offset = 0, int size = -1); - void setAttribute(std::string name, const std::vector& data, bool update = false, int offset = 0, + void setAttribute(std::string name, const std::vector& data, bool update = false, int offset = 0, int size = -1); void setAttribute(std::string name, const std::vector& data, bool update = false, int offset = 0, int size = -1); @@ -101,8 +97,8 @@ class GLProgram { // Indices - void setIndex(std::vector indices); - void setIndex(std::vector indices); + void setIndex(std::vector>& indices); + void setIndex(std::vector& indices); void setPrimitiveRestartIndex(GLuint restartIndex); // Call once to initialize GLSL code used by multiple shaders diff --git a/include/polyscope/point_cloud.h b/include/polyscope/point_cloud.h index c3b330b7..e93091dd 100644 --- a/include/polyscope/point_cloud.h +++ b/include/polyscope/point_cloud.h @@ -2,7 +2,6 @@ #include -#include "geometrycentral/vector3.h" #include "polyscope/affine_remapper.h" #include "polyscope/color_management.h" #include "polyscope/gl/gl_utils.h" @@ -56,7 +55,7 @@ class PointCloud : public Structure { // === Member functions === // Construct a new point cloud structure - PointCloud(std::string name, const std::vector& points); + PointCloud(std::string name, const std::vector& points); ~PointCloud(); // Render the the structure on screen @@ -78,7 +77,7 @@ class PointCloud : public Structure { virtual double lengthScale() override; // Axis-aligned bounding box for the structure - virtual std::tuple boundingBox() override; + virtual std::tuple boundingBox() override; // === Quantities @@ -92,14 +91,14 @@ class PointCloud : public Structure { void addScalarQuantity(std::string name, const std::vector& value, DataType type = DataType::STANDARD); // Colors - void addColorQuantity(std::string name, const std::vector& value); + void addColorQuantity(std::string name, const std::vector& value); // Subsets // void addSubsetQuantity(std::string name, const std::vector& subsetIndicators); // void addSubsetQuantity(std::string name, const std::vector& subsetIndices); // Vectors - void addVectorQuantity(std::string name, const std::vector& value, + void addVectorQuantity(std::string name, const std::vector& value, VectorType vectorType = VectorType::STANDARD); @@ -110,7 +109,7 @@ class PointCloud : public Structure { void removeAllQuantities(); // The points that make up this point cloud - std::vector points; + std::vector points; // Misc data bool enabled = true; diff --git a/include/polyscope/polyscope.h b/include/polyscope/polyscope.h index 1c40188b..31a6486b 100644 --- a/include/polyscope/polyscope.h +++ b/include/polyscope/polyscope.h @@ -42,10 +42,10 @@ extern std::map> structures; extern double lengthScale; // axis-aligned bounding box for all registered structures -extern std::tuple boundingBox; +extern std::tuple boundingBox; // representative center for all registered structures -extern Vector3 center; +extern glm::vec3 center; // A callback function used to render a "user" gui extern std::function userCallback; @@ -60,8 +60,9 @@ extern size_t screenshotInd; // Register a structure with polyscope // `name` is a globally unique identifier for the structure bool registerStructure(Structure* structure, bool replaceIfPresent = true); -void registerPointCloud(std::string name, const std::vector& points, bool replaceIfPresent = true); -void registerSurfaceMesh(std::string name, Geometry* geom, bool replaceIfPresent = true); +void registerPointCloud(std::string name, const std::vector& points, bool replaceIfPresent = true); +void registerSurfaceMesh(std::string name, const std::vector& vertexPositions, + const std::vector>& faceIndices, bool replaceIfPresent = true); void registerCameraView(std::string name, CameraParameters p, bool replaceIfPresent = true); void registerRaySet(std::string name, const std::vector>& r, bool replaceIfPresent = true); diff --git a/include/polyscope/ray_set.h b/include/polyscope/ray_set.h index 9b0d2a80..55d441c8 100644 --- a/include/polyscope/ray_set.h +++ b/include/polyscope/ray_set.h @@ -2,7 +2,6 @@ #include -#include "geometrycentral/vector3.h" #include "polyscope/gl/gl_utils.h" #include "polyscope/structure.h" #include "polyscope/color_management.h" @@ -10,10 +9,10 @@ namespace polyscope { struct RayPoint { - RayPoint(geometrycentral::Vector3 v_, bool isInf = false) + RayPoint(glm::vec3 v_, bool isInf = false) : v(v_), isInfiniteDirection(isInf) {} - geometrycentral::Vector3 v; + glm::vec3 v; // if true, rather than being a point on a path this is a direction, along // which the ray heads to infinity @@ -47,7 +46,7 @@ class RaySet : public Structure { virtual double lengthScale() override; // Axis-aligned bounding box for the structure - virtual std::tuple + virtual std::tuple boundingBox() override; bool enabled = false; diff --git a/include/polyscope/ribbon_artist.h b/include/polyscope/ribbon_artist.h index 8368f887..230f0858 100644 --- a/include/polyscope/ribbon_artist.h +++ b/include/polyscope/ribbon_artist.h @@ -11,7 +11,7 @@ class RibbonArtist { // Input ribbon is a collection of lines; each line is a list of (position, normal) pairs. // - normalOffsetFraction is an offset, relative to polyscope::state::lengthScale, along which ribbons are offset in // the normal direction. - RibbonArtist(const std::vector>>& ribbons, + RibbonArtist(const std::vector>>& ribbons, double normalOffsetFraction = 1e-4); ~RibbonArtist(); @@ -27,7 +27,7 @@ class RibbonArtist { private: // Data - std::vector>> ribbons; + std::vector>> ribbons; double normalOffsetFraction; gl::GLProgram* program = nullptr; diff --git a/include/polyscope/standardize_data_array.h b/include/polyscope/standardize_data_array.h new file mode 100644 index 00000000..1d6756a1 --- /dev/null +++ b/include/polyscope/standardize_data_array.h @@ -0,0 +1,60 @@ +#pragma once + +#include +#include + +namespace polyscope { + +// Convert an array of scalar types +template +std::vector standardizeArray(const T& inputData, size_t expectedSize, std::string errorName = "") { + // Validate size + if (inputData.size() != expectedSize) { + throw std::runtime_error("Cannnot process array " + errorName + ". Expected size " + std::to_string(expectedSize) + + " but has size " + std::to_string(inputData.size())); + } + + // Copy data + std::vector dataOut(expectedSize); + for (size_t i = 0; i < expectedSize; i++) { + dataOut[i] = inputData[i]; + } + + return dataOut; +} + +// Convert between various low dimensional vector types +template +double accessVectorLikeValue(T& inVal, size_t ind) { + return inVal[ind]; +} +template <> +double accessVectorLikeValue, 2>(std::complex& inVal, size_t ind) { + if (ind == 0) { + return inVal.real(); + } else if (ind == 1) { + return inVal.imag(); + } + return -1.0; +} + +// Convert an array of low-dimensional vector types +template +std::vector standardizeVectorArray(const T& inputData, size_t expectedSize, std::string errorName = "") { + // Validate size + if (inputData.size() != expectedSize) { + throw std::runtime_error("Cannnot process array " + errorName + ". Expected size " + std::to_string(expectedSize) + + " but has size " + std::to_string(inputData.size())); + } + + // Copy data + std::vector dataOut(expectedSize); + for (size_t i = 0; i < expectedSize; i++) { + for (size_t j = 0; j < N; j++) { + dataOut[i][j] = accessVectorLikeValue(inputData[i], j); + } + } + + return dataOut; +} +} diff --git a/include/polyscope/structure.h b/include/polyscope/structure.h index 9883e2e4..41a7b6d6 100644 --- a/include/polyscope/structure.h +++ b/include/polyscope/structure.h @@ -4,8 +4,6 @@ #include #include -#include "geometrycentral/vector3.h" - namespace polyscope { @@ -49,7 +47,7 @@ class Structure { virtual double lengthScale() = 0; // Axis-aligned bounding box for the structure - virtual std::tuple + virtual std::tuple boundingBox() = 0; // === Member variables === diff --git a/include/polyscope/surface_color_quantity.h b/include/polyscope/surface_color_quantity.h index 76dea7ea..0deb7c8a 100644 --- a/include/polyscope/surface_color_quantity.h +++ b/include/polyscope/surface_color_quantity.h @@ -22,76 +22,52 @@ class SurfaceColorQuantity : public SurfaceQuantityThatDrawsFaces { class SurfaceColorVertexQuantity : public SurfaceColorQuantity { public: - SurfaceColorVertexQuantity(std::string name, VertexData& values_, SurfaceMesh* mesh_); + SurfaceColorVertexQuantity(std::string name, std::vector& values_, SurfaceMesh* mesh_); // ~SurfaceScalarVertexQuantity(); virtual gl::GLProgram* createProgram() override; void fillColorBuffers(gl::GLProgram* p); - void buildInfoGUI(VertexPtr v) override; + void buildVertexInfoGUI(size_t vInd) override; // === Members - VertexData values; + std::vector values; }; +template +void SurfaceMesh::addVertexColorQuantity(std::string name, const T& colors) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(colors, nVertices, "vertex color quantity " + name), this); + addSurfaceQuantity(q); +} + // ======================================================== -// ========== Face Scalar ========== +// ========== Face Color ========== // ======================================================== class SurfaceColorFaceQuantity : public SurfaceColorQuantity { public: - SurfaceColorFaceQuantity(std::string name, FaceData& values_, SurfaceMesh* mesh_); + SurfaceColorFaceQuantity(std::string name, std::vector& values_, SurfaceMesh* mesh_); // ~SurfaceScalarVertexQuantity(); virtual gl::GLProgram* createProgram() override; void fillColorBuffers(gl::GLProgram* p); - void buildInfoGUI(FacePtr f) override; - - // === Members - FaceData values; -}; - -/* -// ======================================================== -// ========== Edge Scalar ========== -// ======================================================== - -class SurfaceScalarEdgeQuantity : public SurfaceColorQuantity { - public: - SurfaceScalarEdgeQuantity(std::string name, EdgeData& values_, - SurfaceMesh* mesh_, - DataType dataType_ = DataType::STANDARD); - // ~SurfaceScalarVertexQuantity(); - - virtual gl::GLProgram* createProgram() override; - - void fillColorBuffers(gl::GLProgram* p); + void buildFaceInfoGUI(size_t fInd) override; // === Members - EdgeData values; + std::vector values; }; -// ======================================================== -// ========== Halfedge Scalar ========== -// ======================================================== +template +void SurfaceMesh::addFaceColorQuantity(std::string name, const T& colors) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(colors, nFaces, "face color quantity " + name), this); + addSurfaceQuantity(q); +} -class SurfaceScalarHalfedgeQuantity : public SurfaceColorQuantity { - public: - SurfaceScalarHalfedgeQuantity(std::string name, HalfedgeData& values_, - SurfaceMesh* mesh_, - DataType dataType_ = DataType::STANDARD); - // ~SurfaceScalarVertexQuantity(); - virtual gl::GLProgram* createProgram() override; - - void fillColorBuffers(gl::GLProgram* p); - - // === Members - HalfedgeData values; -}; -*/ -} // namespace polyscope \ No newline at end of file +} // namespace polyscope diff --git a/include/polyscope/surface_count_quantity.h b/include/polyscope/surface_count_quantity.h index 3f055f6e..9bb04b02 100644 --- a/include/polyscope/surface_count_quantity.h +++ b/include/polyscope/surface_count_quantity.h @@ -18,7 +18,7 @@ class SurfaceCountQuantity : public SurfaceQuantity { // The map that takes values to [0,1] for drawing AffineRemapper mapper; - std::vector> entries; + std::vector> entries; const int NO_INDEX = std::numeric_limits::min(); gl::GLProgram* program = nullptr; @@ -40,13 +40,13 @@ class SurfaceCountQuantity : public SurfaceQuantity { class SurfaceCountVertexQuantity : public SurfaceCountQuantity { public: - SurfaceCountVertexQuantity(std::string name, std::vector>& values_, SurfaceMesh* mesh_); + SurfaceCountVertexQuantity(std::string name, std::vector>& values_, SurfaceMesh* mesh_); // ~SurfaceCountVertexQuantity(); - void buildInfoGUI(VertexPtr v) override; + void buildVertexInfoGUI(size_t vInd) override; // === Members - std::map values; + std::map values; }; // ======================================================== @@ -55,15 +55,15 @@ class SurfaceCountVertexQuantity : public SurfaceCountQuantity { class SurfaceIsolatedScalarVertexQuantity : public SurfaceCountQuantity { public: - SurfaceIsolatedScalarVertexQuantity(std::string name, std::vector>& values_, + SurfaceIsolatedScalarVertexQuantity(std::string name, std::vector>& values_, SurfaceMesh* mesh_); // ~SurfaceCountVertexQuantity(); void drawUI() override; - void buildInfoGUI(VertexPtr v) override; + void buildVertexInfoGUI(size_t vInd) override; // === Members - std::map values; + std::map values; }; // ======================================================== @@ -72,13 +72,13 @@ class SurfaceIsolatedScalarVertexQuantity : public SurfaceCountQuantity { class SurfaceCountFaceQuantity : public SurfaceCountQuantity { public: - SurfaceCountFaceQuantity(std::string name, std::vector>& values_, SurfaceMesh* mesh_); + SurfaceCountFaceQuantity(std::string name, std::vector>& values_, SurfaceMesh* mesh_); // ~SurfaceCountVertexQuantity(); - void buildInfoGUI(FacePtr f) override; + void buildFaceInfoGUI(size_t f) override; // === Members - std::map values; + std::map values; }; diff --git a/include/polyscope/surface_distance_quantity.h b/include/polyscope/surface_distance_quantity.h index 2ec77d8f..dff2cabc 100644 --- a/include/polyscope/surface_distance_quantity.h +++ b/include/polyscope/surface_distance_quantity.h @@ -8,21 +8,21 @@ namespace polyscope { class SurfaceDistanceQuantity : public SurfaceQuantityThatDrawsFaces { public: - SurfaceDistanceQuantity(std::string name, VertexData& values_, SurfaceMesh* mesh_, bool signedDist = false); + SurfaceDistanceQuantity(std::string name, std::vector& values_, SurfaceMesh* mesh_, bool signedDist = false); void draw() override; void drawUI() override; void setProgramValues(gl::GLProgram* program) override; gl::GLProgram* createProgram() override; - void buildInfoGUI(VertexPtr v) override; + void buildVertexInfoGUI(size_t v) override; void fillColorBuffers(gl::GLProgram* p); void writeToFile(std::string filename = ""); // === Members - VertexData distances; + std::vector distances; bool signedDist; protected: @@ -37,5 +37,20 @@ class SurfaceDistanceQuantity : public SurfaceQuantityThatDrawsFaces { int iColorMap = 0; }; +template +void SurfaceMesh::addDistanceQuantity(std::string name, const T& distances) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(distances, nVertices, "distance quantity " + name), this, false); + addSurfaceQuantity(q); +} + +template +void SurfaceMesh::addSignedDistanceQuantity(std::string name, const T& distances) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(distances, nVertices, "signed distance quantity " + name), this, true); + addSurfaceQuantity(q); +} + + } // namespace polyscope diff --git a/include/polyscope/surface_input_curve_quantity.h b/include/polyscope/surface_input_curve_quantity.h index a6bbee20..b12b938b 100644 --- a/include/polyscope/surface_input_curve_quantity.h +++ b/include/polyscope/surface_input_curve_quantity.h @@ -5,8 +5,6 @@ #include "polyscope/histogram.h" #include "polyscope/surface_mesh.h" -#include "geometrycentral/mesh_embedded_curve.h" - namespace polyscope { class SurfaceInputCurveQuantity : public SurfaceQuantity { diff --git a/include/polyscope/surface_mesh.h b/include/polyscope/surface_mesh.h index b43162e2..49626804 100644 --- a/include/polyscope/surface_mesh.h +++ b/include/polyscope/surface_mesh.h @@ -1,14 +1,12 @@ #pragma once +#include #include -#include "geometrycentral/geometry.h" -#include "geometrycentral/halfedge_mesh.h" -#include "geometrycentral/vector3.h" - #include "polyscope/affine_remapper.h" #include "polyscope/color_management.h" #include "polyscope/gl/gl_utils.h" +#include "polyscope/standardize_data_array.h" #include "polyscope/structure.h" namespace polyscope { @@ -36,10 +34,10 @@ class SurfaceQuantity { virtual void drawUI() = 0; // Build GUI info about this element - virtual void buildInfoGUI(VertexPtr v); - virtual void buildInfoGUI(FacePtr f); - virtual void buildInfoGUI(EdgePtr e); - virtual void buildInfoGUI(HalfedgePtr he); + virtual void buildVertexInfoGUI(size_t vInd); + virtual void buildFaceInfoGUI(size_t fInd); + virtual void buildEdgeInfoGUI(size_t eInd); + virtual void buildHalfedgeInfoGUI(size_t heInd); // === Member variables === const std::string name; @@ -67,7 +65,8 @@ class SurfaceMesh : public Structure { // === Member functions === // Construct a new surface mesh structure - SurfaceMesh(std::string name, Geometry* geometry_); + SurfaceMesh(std::string name, const std::vector& vertexPositions_, + const std::vector>& faceIndices); ~SurfaceMesh(); // Render the the structure on screen @@ -89,50 +88,65 @@ class SurfaceMesh : public Structure { virtual double lengthScale() override; // Axis-aligned bounding box for the structure - virtual std::tuple boundingBox() override; + virtual std::tuple boundingBox() override; // === Quantity-related // general form - void addSurfaceQuantity(SurfaceQuantity* quantity); - void addSurfaceQuantity(SurfaceQuantityThatDrawsFaces* quantity); - SurfaceQuantity* getSurfaceQuantity(std::string name, bool errorIfAbsent = true); - - // Scalars - void addQuantity(std::string name, VertexData& value, DataType type = DataType::STANDARD); - void addQuantity(std::string name, FaceData& value, DataType type = DataType::STANDARD); - void addQuantity(std::string name, EdgeData& value, DataType type = DataType::STANDARD); - void addQuantity(std::string name, HalfedgeData& value, DataType type = DataType::STANDARD); - - // Distance - void addDistanceQuantity(std::string name, VertexData& distances); - void addSignedDistanceQuantity(std::string name, VertexData& distances); - - // Colors - void addColorQuantity(std::string name, VertexData& value); - void addColorQuantity(std::string name, FaceData& value); - - // Counts/Singularities/Indices/Values on isolated vertices - void addCountQuantity(std::string name, std::vector>& values); - void addCountQuantity(std::string name, std::vector>& values); - void addIsolatedVertexQuantity(std::string name, std::vector>& values); - - // Subsets - void addSubsetQuantity(std::string name, EdgeData& subset); - - // Selections - void addVertexSelectionQuantity(std::string name, VertexData& initialMembership); - void addInputCurveQuantity(std::string name); - - - // Vectors - void addVectorQuantity(std::string name, VertexData& value, VectorType vectorType = VectorType::STANDARD); - void addVectorQuantity(std::string name, FaceData& value, VectorType vectorType = VectorType::STANDARD); - void addVectorQuantity(std::string name, FaceData& value, int nSym = 1, - VectorType vectorType = VectorType::STANDARD); - void addVectorQuantity(std::string name, VertexData& value, int nSym = 1, - VectorType vectorType = VectorType::STANDARD); - void addVectorQuantity(std::string name, EdgeData& value); + void addSurfaceQuantity(std::shared_ptr quantity); + std::shared_ptr getSurfaceQuantity(std::string name, bool errorIfAbsent = true); + + // Scalars (expect double arrays) + template + void addVertexScalarQuantity(std::string name, const T& data, DataType type = DataType::STANDARD); + template + void addFaceScalarQuantity(std::string name, const T& data, DataType type = DataType::STANDARD); + template + void addEdgeScalarQuantity(std::string name, const T& data, DataType type = DataType::STANDARD); + template + void addHalfedgeScalarQuantity(std::string name, const T& data, DataType type = DataType::STANDARD); + + // Distance (expect double array) + template + void addDistanceQuantity(std::string name, const T& data); + template + void addSignedDistanceQuantity(std::string name, const T& data); + + // Colors (expect glm::vec3 array) + template + void addVertexColorQuantity(std::string name, const T& data); + template + void addFaceColorQuantity(std::string name, const T& data); + + // Counts/Values on isolated vertices (expect index/value pairs) + void addVertexCountQuantity(std::string name, std::vector>& values); + void addFaceCountQuantity(std::string name, std::vector>& values); + void addIsolatedVertexScalarQuantity(std::string name, std::vector>& values); + + // Subsets (expect char array) + template + void addSubsetQuantity(std::string name, const T& subset); + + // Vectors (expect vector array, inner type must be indexable with correct dimension) + template + void addVertexVectorQuantity(std::string name, const T& vectors, VectorType vectorType = VectorType::STANDARD); + template + void addFaceVectorQuantity(std::string name, const T& vectors, VectorType vectorType = VectorType::STANDARD); + template + void addFaceVectorQuantity(std::string name, const T& vectors, int nSym = 1, + VectorType vectorType = VectorType::STANDARD); + template + void addVertexVectorQuantity(std::string name, const T& vectors, int nSym = 1, + VectorType vectorType = VectorType::STANDARD); + template + void addOneFormIntrinsicVectorQuantity(std::string name, const T& data); // expects scalar + + + // I/O Selections + template + void addVertexSelectionQuantity(std::string name, const T& initialMembership); + //void addInputCurveQuantity(std::string name); + void removeQuantity(std::string name); void setActiveSurfaceQuantity(SurfaceQuantityThatDrawsFaces* q); @@ -140,12 +154,12 @@ class SurfaceMesh : public Structure { void removeAllQuantities(); // === Make a one-time selection - geometrycentral::VertexPtr selectVertex(); - geometrycentral::FacePtr selectFace(); + size_t selectVertex(); + size_t selectFace(); // === Mutate - - void updateGeometryPositions(Geometry* newGeometry); + + void updateGeometryPositions(const std::vector& newPositions); // === Helpers void deleteProgram(); @@ -154,14 +168,10 @@ class SurfaceMesh : public Structure { // === Member variables === bool enabled = true; - // The mesh (this is a copy of what was passed in) - geometrycentral::HalfedgeMesh* mesh; - geometrycentral::Geometry* geometry; - geometrycentral::HalfedgeMeshDataTransfer transfer; - - // The original mesh and geometry that were passed in - geometrycentral::HalfedgeMesh* originalMesh; - geometrycentral::Geometry* originalGeometry; + // The mesh! + std::vector vertexPositions; + std::vector> faceIndices; + size_t nVertices, nFaces, nEdges, nHalfedges, nInteriorHalfedges; static const std::string structureTypeName; SubColorManager colorManager; @@ -174,15 +184,16 @@ class SurfaceMesh : public Structure { // Picking helpers // One of these will be non-null on return - void getPickedElement(size_t localPickID, VertexPtr& vOut, FacePtr& fOut, EdgePtr& eOut, HalfedgePtr& heOut); + // void getPickedElement(size_t localPickID, size_t& vOut, size_t& fOut, size_t& eOut, size_t& heOut); + // Returns the face ands coordinates in that face of the last pick. fOut == FacePtr() if not in any face. Note that // you may needed to update the pick data, beacuse this uses mouse coordinates from the current state but possibly old // pick lookup results. - void getPickedFacePoint(FacePtr& fOut, Vector3& baryCoordOut); + // void getPickedFacePoint(FacePtr& fOut, glm::vec3& baryCoordOut); private: // Quantities - std::map quantities; + std::map> quantities; // Visualization settings Color3f baseColor; @@ -201,18 +212,14 @@ class SurfaceMesh : public Structure { // Within each set, uses the implicit ordering from the mesh data structure // Thest starts are LOCAL indices, indexing elements only with the mesh size_t facePickIndStart, edgePickIndStart, halfedgePickIndStart; - VertexData vInd; - FaceData fInd; - EdgeData eInd; - HalfedgeData heInd; - void buildVertexInfoGui(VertexPtr v); - void buildFaceInfoGui(FacePtr f); - void buildEdgeInfoGui(EdgePtr e); - void buildHalfedgeInfoGui(HalfedgePtr he); + void buildVertexInfoGui(size_t vInd); + void buildFaceInfoGui(size_t fInd); + void buildEdgeInfoGui(size_t eInd); + void buildHalfedgeInfoGui(size_t heInd); // Gui implementation details bool ui_smoothshade = true; - + // Drawing related things gl::GLProgram* program = nullptr; gl::GLProgram* pickProgram = nullptr; @@ -221,8 +228,8 @@ class SurfaceMesh : public Structure { // === Helper functions void fillGeometryBuffersSmooth(); void fillGeometryBuffersFlat(); - Vector2 projectToScreenSpace(Vector3 coord); - bool screenSpaceTriangleTest(FacePtr f, Vector2 testCoords, Vector3& bCoordOut); + glm::vec2 projectToScreenSpace(glm::vec3 coord); + bool screenSpaceTriangleTest(size_t fInd, glm::vec2 testCoords, glm::vec3& bCoordOut); }; // Make mesh element type printable @@ -242,4 +249,7 @@ inline std::ostream& operator<<(std::ostream& out, const MeshElement value) { return out << getMeshElementTypeName(value); } -} // namespace polyscope +} + + + diff --git a/include/polyscope/surface_scalar_quantity.h b/include/polyscope/surface_scalar_quantity.h index e021a67e..9686b5b2 100644 --- a/include/polyscope/surface_scalar_quantity.h +++ b/include/polyscope/surface_scalar_quantity.h @@ -38,7 +38,7 @@ class SurfaceScalarQuantity : public SurfaceQuantityThatDrawsFaces { class SurfaceScalarVertexQuantity : public SurfaceScalarQuantity { public: - SurfaceScalarVertexQuantity(std::string name, VertexData& values_, SurfaceMesh* mesh_, + SurfaceScalarVertexQuantity(std::string name, std::vector& values_, SurfaceMesh* mesh_, DataType dataType_ = DataType::STANDARD); // ~SurfaceScalarVertexQuantity(); @@ -46,20 +46,27 @@ class SurfaceScalarVertexQuantity : public SurfaceScalarQuantity { void fillColorBuffers(gl::GLProgram* p); - void buildInfoGUI(VertexPtr v) override; + void buildVertexInfoGUI(size_t vInd) override; virtual void writeToFile(std::string filename = "") override; // === Members - VertexData values; + std::vector values; }; +template +void SurfaceMesh::addVertexScalarQuantity(std::string name, const T& data, DataType type) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(data, nVertices, "vertex scalar quantity " + name), this, type); + addSurfaceQuantity(q); +} + // ======================================================== // ========== Face Scalar ========== // ======================================================== class SurfaceScalarFaceQuantity : public SurfaceScalarQuantity { public: - SurfaceScalarFaceQuantity(std::string name, FaceData& values_, SurfaceMesh* mesh_, + SurfaceScalarFaceQuantity(std::string name, std::vector& values_, SurfaceMesh* mesh_, DataType dataType_ = DataType::STANDARD); // ~SurfaceScalarVertexQuantity(); @@ -67,19 +74,26 @@ class SurfaceScalarFaceQuantity : public SurfaceScalarQuantity { void fillColorBuffers(gl::GLProgram* p); - void buildInfoGUI(FacePtr f) override; + void buildFaceInfoGUI(size_t fInd) override; // === Members - FaceData values; + std::vector values; }; +template +void SurfaceMesh::addFaceScalarQuantity(std::string name, const T& data, DataType type) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(data, nFaces, "face scalar quantity " + name), this, type); + addSurfaceQuantity(q); +} + // ======================================================== // ========== Edge Scalar ========== // ======================================================== class SurfaceScalarEdgeQuantity : public SurfaceScalarQuantity { public: - SurfaceScalarEdgeQuantity(std::string name, EdgeData& values_, SurfaceMesh* mesh_, + SurfaceScalarEdgeQuantity(std::string name, std::vector& values_, SurfaceMesh* mesh_, DataType dataType_ = DataType::STANDARD); // ~SurfaceScalarVertexQuantity(); @@ -87,20 +101,27 @@ class SurfaceScalarEdgeQuantity : public SurfaceScalarQuantity { void fillColorBuffers(gl::GLProgram* p); - void buildInfoGUI(EdgePtr e) override; + void buildEdgeInfoGUI(size_t edgeInd) override; // === Members - EdgeData values; + std::vector values; }; +template +void SurfaceMesh::addEdgeScalarQuantity(std::string name, const T& data, DataType type) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(data, nEdges, "edge scalar quantity " + name), this, type); + addSurfaceQuantity(q); +} + // ======================================================== // ========== Halfedge Scalar ========== // ======================================================== class SurfaceScalarHalfedgeQuantity : public SurfaceScalarQuantity { public: - SurfaceScalarHalfedgeQuantity(std::string name, HalfedgeData& values_, SurfaceMesh* mesh_, + SurfaceScalarHalfedgeQuantity(std::string name, std::vector& values_, SurfaceMesh* mesh_, DataType dataType_ = DataType::STANDARD); // ~SurfaceScalarVertexQuantity(); @@ -108,10 +129,17 @@ class SurfaceScalarHalfedgeQuantity : public SurfaceScalarQuantity { void fillColorBuffers(gl::GLProgram* p); - void buildInfoGUI(HalfedgePtr he) override; + void buildHalfedgeInfoGUI(size_t heInd) override; // === Members - HalfedgeData values; + std::vector values; }; +template +void SurfaceMesh::addHalfedgeScalarQuantity(std::string name, const T& data, DataType type) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(data, nHalfedges, "halfedge scalar quantity " + name), this, type); + addSurfaceQuantity(q); +} + } // namespace polyscope diff --git a/include/polyscope/surface_selection_quantity.h b/include/polyscope/surface_selection_quantity.h index 93f86c46..24c24bd8 100644 --- a/include/polyscope/surface_selection_quantity.h +++ b/include/polyscope/surface_selection_quantity.h @@ -31,22 +31,20 @@ class SurfaceSelectionQuantity : public SurfaceQuantityThatDrawsFaces { class SurfaceSelectionVertexQuantity : public SurfaceSelectionQuantity { public: - SurfaceSelectionVertexQuantity(std::string name, VertexData& membership_, SurfaceMesh* mesh_); + SurfaceSelectionVertexQuantity(std::string name, std::vector& membership_, SurfaceMesh* mesh_); // ~SurfaceSelectionVertexQuantity(); virtual gl::GLProgram* createProgram() override; void fillColorBuffers(gl::GLProgram* p); - void buildInfoGUI(VertexPtr v) override; + void buildVertexInfoGUI(size_t vInd) override; void userEdit() override; virtual void setProgramValues(gl::GLProgram* program) override; // === Members - VertexData membership; // 1 if in, 0 otherwise - VertexData getSelectionOnInputMesh(); // transfer the data back to the mesh that was passed in - + std::vector membership; // 1 if in, 0 otherwise private: @@ -56,6 +54,15 @@ class SurfaceSelectionVertexQuantity : public SurfaceSelectionQuantity { int mouseMemberAction = 0; }; +template +void SurfaceMesh::addVertexSelectionQuantity(std::string name, const T& initialMembership) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(initialMembership, nVertices, "vertex selection quantity " + name), this); + SurfaceSelectionVertexQuantity* q = new SurfaceSelectionVertexQuantity(name, initialMembership, this); + addSurfaceQuantity(q); +} + + /* // ======================================================== // ========== Face Selection ========== diff --git a/include/polyscope/surface_subset_quantity.h b/include/polyscope/surface_subset_quantity.h index 4c6f5513..5eb389dc 100644 --- a/include/polyscope/surface_subset_quantity.h +++ b/include/polyscope/surface_subset_quantity.h @@ -10,22 +10,30 @@ namespace polyscope { class SurfaceEdgeSubsetQuantity : public SurfaceQuantity { public: - SurfaceEdgeSubsetQuantity(std::string name, EdgeData& edgeSubset, SurfaceMesh* mesh_); + SurfaceEdgeSubsetQuantity(std::string name, std::vector& edgeSubset, SurfaceMesh* mesh_); ~SurfaceEdgeSubsetQuantity(); virtual void draw() override; virtual void drawUI() override; - EdgeData edgeSubset; + std::vector edgeSubset; int count; - virtual void buildInfoGUI(EdgePtr e) override; + virtual void buildEdgeInfoGUI(size_t eInd) override; private: float radius = 0.002; - std::array color; + Color3f color; gl::GLProgram* program = nullptr; }; +template +void SurfaceMesh::addSubsetQuantity(std::string name, const T& subset) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(subset, nEdges, "edge subset quantity " + name), this); + addSurfaceQuantity(q); +} + + } // namespace polyscope diff --git a/include/polyscope/surface_vector_quantity.h b/include/polyscope/surface_vector_quantity.h index 32632667..1bc8f92b 100644 --- a/include/polyscope/surface_vector_quantity.h +++ b/include/polyscope/surface_vector_quantity.h @@ -26,11 +26,11 @@ class SurfaceVectorQuantity : public SurfaceQuantity { // === Members const VectorType vectorType; - std::vector vectorRoots; - std::vector vectors; + std::vector vectorRoots; + std::vector vectors; float lengthMult; // longest vector will be this fraction of lengthScale (if not ambient) float radiusMult; // radius is this fraction of lengthScale - std::array vectorColor; + Color3f vectorColor; MeshElement definedOn; // A ribbon viz that is appropriate for some fields @@ -38,7 +38,7 @@ class SurfaceVectorQuantity : public SurfaceQuantity { bool ribbonEnabled = false; // The map that takes values to [0,1] for drawing - AffineRemapper mapper; + AffineRemapper mapper; void writeToFile(std::string filename = ""); @@ -49,68 +49,110 @@ class SurfaceVectorQuantity : public SurfaceQuantity { class SurfaceVertexVectorQuantity : public SurfaceVectorQuantity { public: - SurfaceVertexVectorQuantity(std::string name, VertexData& vectors_, SurfaceMesh* mesh_, + SurfaceVertexVectorQuantity(std::string name, std::vector& vectors_, SurfaceMesh* mesh_, VectorType vectorType_ = VectorType::STANDARD); - VertexData vectorField; + std::vector vectorField; - virtual void buildInfoGUI(VertexPtr v) override; + virtual void buildVertexInfoGUI(size_t vInd) override; }; +template +void SurfaceMesh::addVertexVectorQuantity(std::string name, const T& vectors, VectorType vectorType) { + std::shared_ptr q = std::make_shared( + name, standardizeVectorArray(vectors, nVertices, "vertex vector quantity " + name), this, + vectorType); + addSurfaceQuantity(q); +} class SurfaceFaceVectorQuantity : public SurfaceVectorQuantity { public: - SurfaceFaceVectorQuantity(std::string name, FaceData& vectors_, SurfaceMesh* mesh_, + SurfaceFaceVectorQuantity(std::string name, std::vector& vectors_, SurfaceMesh* mesh_, VectorType vectorType_ = VectorType::STANDARD); - FaceData vectorField; + std::vector vectorField; - virtual void buildInfoGUI(FacePtr f) override; + virtual void buildFaceInfoGUI(size_t fInd) override; }; +template +void SurfaceMesh::addFaceVectorQuantity(std::string name, const T& vectors, VectorType vectorType) { + std::shared_ptr q = std::make_shared( + name, standardizeVectorArray(vectors, nFaces, "face vector quantity " + name), this, vectorType); + addSurfaceQuantity(q); +} + + class SurfaceFaceIntrinsicVectorQuantity : public SurfaceVectorQuantity { public: - SurfaceFaceIntrinsicVectorQuantity(std::string name, FaceData& vectors_, SurfaceMesh* mesh_, int nSym = 1, - VectorType vectorType_ = VectorType::STANDARD); + SurfaceFaceIntrinsicVectorQuantity(std::string name, std::vector& vectors_, SurfaceMesh* mesh_, + int nSym = 1, VectorType vectorType_ = VectorType::STANDARD); - FaceData vectorField; + std::vector vectorField; int nSym; virtual void draw() override; void drawSubUI() override; - void buildInfoGUI(FacePtr f) override; + void buildFaceInfoGUI(size_t fInd) override; }; + +template +void SurfaceMesh::addFaceIntrinsicVectorQuantity(std::string name, const T& vectors, int nSym, VectorType vectorType) { + std::shared_ptr q = std::make_shared( + name, standardizeVectorArray(vectors, nFaces, "face intrinsic vector quantity " + name), this, + nSym, vectorType); + addSurfaceQuantity(q); +} + + class SurfaceVertexIntrinsicVectorQuantity : public SurfaceVectorQuantity { public: - SurfaceVertexIntrinsicVectorQuantity(std::string name, VertexData& vectors_, SurfaceMesh* mesh_, + SurfaceVertexIntrinsicVectorQuantity(std::string name, std::vector& vectors_, SurfaceMesh* mesh_, int nSym = 1, VectorType vectorType_ = VectorType::STANDARD); - VertexData vectorField; + std::vector vectorField; int nSym; virtual void draw() override; void drawSubUI() override; - void buildInfoGUI(VertexPtr v) override; + void buildVertexInfoGUI(size_t vInd) override; }; +template +void SurfaceMesh::addVertexIntrinsicVectorQuantity(std::string name, const T& vectors, int nSym, + VectorType vectorType) { + std::shared_ptr q = std::make_shared( + name, standardizeVectorArray(vectors, nFaces, "vertex intrinsic vector quantity " + name), this, + nSym, vectorType); + addSurfaceQuantity(q); +} + + class SurfaceOneFormIntrinsicVectorQuantity : public SurfaceVectorQuantity { public: - SurfaceOneFormIntrinsicVectorQuantity(std::string name, EdgeData& oneForm_, SurfaceMesh* mesh_); + SurfaceOneFormIntrinsicVectorQuantity(std::string name, std::vector& oneForm_, SurfaceMesh* mesh_); - EdgeData oneForm; - FaceData mappedVectorField; + std::vector oneForm; + std::vector mappedVectorField; virtual void draw() override; void drawSubUI() override; - void buildInfoGUI(EdgePtr e) override; - void buildInfoGUI(FacePtr f) override; + void buildEdgeInfoGUI(size_t eInd) override; + void buildFaceInfoGUI(size_t fInd) override; }; +template +void SurfaceMesh::addOneFormIntrinsicVectorQuantity(std::string name, const T& data) { + std::shared_ptr q = std::make_shared( + name, standardizeArray(data, nEdges, "one form intrinsic vector quantity " + name), this); + addSurfaceQuantity(q); +} + } // namespace polyscope diff --git a/include/polyscope/view.h b/include/polyscope/view.h index b41ee5c8..7156e09d 100644 --- a/include/polyscope/view.h +++ b/include/polyscope/view.h @@ -45,11 +45,11 @@ extern float flightTargetFov, flightInitialFov; // === View methods -void processTranslate(Vector2 delta); +void processTranslate(glm::vec2 delta); void processRotate(float delTheta, float delPhi); // Arcball roatation. startP and endP should be in [-1,1] -void processRotateArcball(Vector2 startP, Vector2 endP); +void processRotateArcball(glm::vec2 startP, glm::vec2 endP); void processClipPlaneShift(double amount); void processZoom(double amount); @@ -61,9 +61,9 @@ void flyToDefault(); glm::mat4 getCameraViewMatrix(); glm::mat4 getCameraPerspectiveMatrix(); -Vector3 getCameraWorldPosition(); +glm::vec3 getCameraWorldPosition(); -void getCameraFrame(Vector3& lookDir, Vector3& upDir, Vector3& rightDir); +void getCameraFrame(glm::vec3& lookDir, glm::vec3& upDir, glm::vec3& rightDir); // Flight-related void startFlightTo(const CameraParameters& p, float flightLengthInSeconds=.25); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 41cc6512..a7ddab99 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,11 +22,11 @@ add_library( target_include_directories(polyscope PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../include") target_include_directories(polyscope PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../deps/glfw/include") target_include_directories(polyscope PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../deps/glad/include") -target_include_directories(polyscope PUBLIC ${GEOMETRY_CENTRAL_INCLUDE_DIRS}) target_include_directories(polyscope PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../deps/imgui/imgui") target_include_directories(polyscope PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../deps/args") target_include_directories(polyscope PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../deps/json/include") target_include_directories(polyscope PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../deps/stb") +target_include_directories(polyscope PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../deps/glm") # Link settings target_link_libraries(polyscope imgui glfw ${GLFW_LIBRARIES} geometry-central) @@ -39,4 +39,4 @@ if(APPLE) target_link_libraries(polyscope ${cocoa_library} ${opengl_library} ${corevideo_library} ${iokit_library}) else() target_link_libraries(polyscope glad) -endif() \ No newline at end of file +endif() diff --git a/src/surface_input_curve_quantity.cpp b/src/surface_input_curve_quantity.cpp_ similarity index 100% rename from src/surface_input_curve_quantity.cpp rename to src/surface_input_curve_quantity.cpp_ diff --git a/src/surface_mesh.cpp b/src/surface_mesh.cpp index 8c5317e4..8b7eb704 100644 --- a/src/surface_mesh.cpp +++ b/src/surface_mesh.cpp @@ -6,16 +6,6 @@ #include "polyscope/pick.h" #include "polyscope/polyscope.h" -// Quantities -#include "polyscope/surface_color_quantity.h" -#include "polyscope/surface_count_quantity.h" -#include "polyscope/surface_distance_quantity.h" -#include "polyscope/surface_input_curve_quantity.h" -#include "polyscope/surface_scalar_quantity.h" -#include "polyscope/surface_selection_quantity.h" -#include "polyscope/surface_subset_quantity.h" -#include "polyscope/surface_vector_quantity.h" - #include "imgui.h" using namespace geometrycentral; @@ -837,23 +827,6 @@ void SurfaceMesh::addSurfaceQuantity(SurfaceQuantity* quantity) { } } -void SurfaceMesh::addSurfaceQuantity(SurfaceQuantityThatDrawsFaces* quantity) { - // Delete old if in use - bool wasEnabled = false; - if (quantities.find(quantity->name) != quantities.end()) { - wasEnabled = quantities[quantity->name]->enabled; - removeQuantity(quantity->name); - } - - // Store - quantities[quantity->name] = quantity; - - // Re-enable the quantity if we're replacing an enabled quantity - if (wasEnabled) { - quantity->enabled = true; - setActiveSurfaceQuantity(quantity); - } -} SurfaceQuantity* SurfaceMesh::getSurfaceQuantity(std::string name, bool errorIfAbsent) { // Check if exists @@ -868,100 +841,28 @@ SurfaceQuantity* SurfaceMesh::getSurfaceQuantity(std::string name, bool errorIfA } -void SurfaceMesh::addQuantity(std::string name, VertexData& value, DataType type) { - SurfaceScalarQuantity* q = new SurfaceScalarVertexQuantity(name, value, this, type); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addQuantity(std::string name, FaceData& value, DataType type) { - SurfaceScalarQuantity* q = new SurfaceScalarFaceQuantity(name, value, this, type); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addQuantity(std::string name, EdgeData& value, DataType type) { - SurfaceScalarQuantity* q = new SurfaceScalarEdgeQuantity(name, value, this, type); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addQuantity(std::string name, HalfedgeData& value, DataType type) { - SurfaceScalarQuantity* q = new SurfaceScalarHalfedgeQuantity(name, value, this, type); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addDistanceQuantity(std::string name, VertexData& distances) { - SurfaceDistanceQuantity* q = new SurfaceDistanceQuantity(name, distances, this, false); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addSignedDistanceQuantity(std::string name, VertexData& distances) { - SurfaceDistanceQuantity* q = new SurfaceDistanceQuantity(name, distances, this, true); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addColorQuantity(std::string name, VertexData& value) { - SurfaceColorQuantity* q = new SurfaceColorVertexQuantity(name, value, this); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addColorQuantity(std::string name, FaceData& value) { - SurfaceColorQuantity* q = new SurfaceColorFaceQuantity(name, value, this); - addSurfaceQuantity(q); -} -void SurfaceMesh::addCountQuantity(std::string name, std::vector>& values) { +void SurfaceMesh::addVertexCountQuantity(std::string name, const std::vector>& values) { SurfaceCountQuantity* q = new SurfaceCountVertexQuantity(name, values, this); addSurfaceQuantity(q); } -void SurfaceMesh::addIsolatedVertexQuantity(std::string name, std::vector>& values) { - SurfaceCountQuantity* q = new SurfaceIsolatedScalarVertexQuantity(name, values, this); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addCountQuantity(std::string name, std::vector>& values) { +void SurfaceMesh::addFaceCountQuantity(std::string name, const std::vector>& values) { SurfaceCountQuantity* q = new SurfaceCountFaceQuantity(name, values, this); addSurfaceQuantity(q); } -void SurfaceMesh::addSubsetQuantity(std::string name, EdgeData& subset) { - SurfaceEdgeSubsetQuantity* q = new SurfaceEdgeSubsetQuantity(name, subset, this); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addVertexSelectionQuantity(std::string name, VertexData& initialMembership) { - SurfaceSelectionVertexQuantity* q = new SurfaceSelectionVertexQuantity(name, initialMembership, this); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addInputCurveQuantity(std::string name) { - SurfaceInputCurveQuantity* q = new SurfaceInputCurveQuantity(name, this); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addVectorQuantity(std::string name, VertexData& value, VectorType vectorType) { - SurfaceVectorQuantity* q = new SurfaceVertexVectorQuantity(name, value, this, vectorType); - addSurfaceQuantity(q); -} - -void SurfaceMesh::addVectorQuantity(std::string name, FaceData& value, VectorType vectorType) { - SurfaceVectorQuantity* q = new SurfaceFaceVectorQuantity(name, value, this, vectorType); +void SurfaceMesh::addIsolatedVertexScalarQuantity(std::string name, const std::vector>& values) { + SurfaceCountQuantity* q = new SurfaceIsolatedScalarVertexQuantity(name, values, this); addSurfaceQuantity(q); } -void SurfaceMesh::addVectorQuantity(std::string name, FaceData& value, int nSym, VectorType vectorType) { - SurfaceVectorQuantity* q = new SurfaceFaceIntrinsicVectorQuantity(name, value, this, nSym, vectorType); - addSurfaceQuantity(q); -} -void SurfaceMesh::addVectorQuantity(std::string name, VertexData& value, int nSym, VectorType vectorType) { - SurfaceVectorQuantity* q = new SurfaceVertexIntrinsicVectorQuantity(name, value, this, nSym, vectorType); - addSurfaceQuantity(q); -} +//void SurfaceMesh::addInputCurveQuantity(std::string name) { + //SurfaceInputCurveQuantity* q = new SurfaceInputCurveQuantity(name, this); + //addSurfaceQuantity(q); +//} -void SurfaceMesh::addVectorQuantity(std::string name, EdgeData& value) { - SurfaceVectorQuantity* q = new SurfaceOneFormIntrinsicVectorQuantity(name, value, this); - addSurfaceQuantity(q); -} void SurfaceMesh::removeQuantity(std::string name) { if (quantities.find(name) == quantities.end()) {