Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified source code for added compatibility on MacOS #30

Open
wants to merge 21 commits into
base: michael
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e10db84
Modified AppVeyor build configuration settings
michizhou Jun 11, 2019
c56303d
Added installation of new software by AppVeyor
michizhou Jun 11, 2019
339892e
Modified AppVeyor build compilation settings
michizhou Jun 12, 2019
5645606
Changed paths for AppVeyor build libraries
michizhou Jun 12, 2019
548d888
Added return value to header function
michizhou Jun 12, 2019
e52ce30
Revised AppVeyor library compilation paths
michizhou Jun 12, 2019
0c5fd0e
Modified AppVeyor after build command script
michizhou Jun 13, 2019
7e186e0
Added Travis build instance
michizhou Jun 14, 2019
d8799ed
Modified Travis compiler environment settings
michizhou Jun 14, 2019
1b7fb81
Updated Travis build compiler configuration
michizhou Jun 17, 2019
fc05c3a
Modified source code for added compatibility on MacOS
michizhou Jul 17, 2019
525b13a
Changed features for rendering and UI functionality on MacOS
michizhou Jul 22, 2019
0013a21
Resolved MacOS bounding polygon selection and rendering issues
michizhou Jul 24, 2019
35e12f7
Added dependencies for debug group functions
michizhou Jul 24, 2019
b38e0ec
Added MacOS environment builds to Travis
michizhou Jul 24, 2019
246fe30
Modified OpenMP and Qt5 compilation settings
michizhou Jul 25, 2019
91116d1
Refactored helper functions and state constants
michizhou Jul 25, 2019
ccdc39a
Added onto comments and debug helper function
michizhou Jul 25, 2019
db06ce5
Modified debug helper function implementation
michizhou Jul 26, 2019
1964a44
Corrected mouse coordinate discrepancies with scaling
michizhou Jul 29, 2019
441b955
Addendum 1
michizhou Jul 31, 2019
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
30 changes: 27 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,37 @@ clone_folder: C:\projects\fish_deformation
branches:
only:
- master
- michael
install:
- git submodule update --init --recursive
- cinstall: python
build:
parallel: true
build_script:
- echo Running cmake...
- echo Running cmake ..
- cd c:\tools\vcpkg
- .\vcpkg.exe --triplet x64-windows install mpir mpfr
- cd c:\projects\fish_deformation
- set PATH=C:\Python%PYTHON%-x64;C:\Python%PYTHON%-x64\Scripts;%PATH%
- mkdir build
- cd build
- cmake -G "Visual Studio 15 2017 Win64" -T "host=x64" ..
- msbuild %MSBuildOptions% fish_deformation
- cmake -G "Visual Studio 15 2017 Win64"
-DCMAKE_PREFIX_PATH="C:/Qt/5.10.1/msvc2017_64/lib/cmake"
-DMPFR_INCLUDE_DIR:PATH="C:/tools/vcpkg/installed/x64-windows/include"
-DMPFR_LIBRARIES:FILEPATH="C:/tools/vcpkg/installed/x64-windows/lib/mpfr.lib"
-DGMP_INCLUDE_DIR:PATH="C:/tools/vcpkg/installed/x64-windows/include"
-DGMP_LIBRARIES:FILEPATH="C:/tools/vcpkg/installed/x64-windows/lib/mpir.lib"
-DBOOST_ROOT="C:/Libraries/boost_1_65_1" ../
- set MSBuildOptions=/v:m /p:Configuration=Release /p:Platform=x64
- msbuild %MSBuildOptions% fish_deformation.sln
after_build:
- cd ..
- mkdir unwind
- copy build\src\Release\unwind.exe unwind
- copy build\src\Release\mpir.dll unwind
- cd C:\Qt\latest\msvc2017_64\bin
- windeployqt C:\projects\fish_deformation\unwind\unwind.exe
- cd C:\projects\fish_deformation
- 7z a unwind.zip .\unwind\*
artifacts:
- path: unwind.zip
71 changes: 71 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
dist: trusty
sudo: true
language: cpp
cache: ccache
branches:
only:
- master
- michael
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- cmake
- g++-6
- gcc-6
- g++-7
- gcc-7
- libblas-dev
- libboost-filesystem-dev
- libboost-system-dev
- libboost-thread-dev
- libglu1-mesa-dev
- liblapack-dev
- libmpfr-dev
- libpython3-dev
- python3-setuptools
- qt5-default
- xorg-dev
homebrew:
packages:
- ccache
matrix:
include:
- os: linux
compiler: gcc-6
env:
- MATRIX_EVAL="export CC=gcc-6 CXX=g++-6 CONFIG=Release PYTHON=python3"
- os: linux
compiler: gcc-7
env:
- MATRIX_EVAL="export CC=gcc-7 CXX=g++-7 CONFIG=Release PYTHON=python3"
- os: linux # same config like above but with -DLIBIGL_USE_STATIC_LIBRARY=OFF to test static and header-only builds
compiler: gcc-7
env:
- MATRIX_EVAL="export CC=gcc-7 CXX=g++-7 CONFIG=Release PYTHON=python3 CMAKE_EXTRA='-DLIBIGL_USE_STATIC_LIBRARY=OFF'"
- os: linux
compiler: gcc-7
env:
- MATRIX_EVAL="export CC=gcc-7 CXX=g++-7 CONFIG=Release PYTHON=python3 CMAKE_EXTRA='-DLIBIGL_EIGEN_VERSION=3.3.7'"

install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
- eval "${MATRIX_EVAL}"
- ccache --max-size=5.0G
- ccache -V && ccache --show-stats && ccache --zero-stats

script:
# Tutorials and tests
- mkdir build
- pushd build
- cmake ${CMAKE_EXTRA}
-DCMAKE_BUILD_TYPE=$CONFIG
-DLIBIGL_CHECK_UNDEFINED=ON
-DLIBIGL_WITH_CGAL=ON
../
- make -j8
- ctest --verbose
- popd
- rm -rf build
- ccache --show-stats
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(fish_deformation)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/voroffset/cmake)

set(CMAKE_PREFIX_PATH /usr/local/opt/qt/lib/cmake)



Expand Down Expand Up @@ -110,8 +110,8 @@ file(GLOB CT_SRCS external/Segmentangling/ContourTree/*.cpp)
set(CT_INCLUDE_DIRS external/Segmentangling/ContourTree)
list(REMOVE_ITEM CT_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/external/Segmentangling/ContourTree/main.cpp")
add_library(contourtree STATIC ${CT_SRCS})
target_compile_options(contourtree PRIVATE "-fopenmp")
target_link_libraries(contourtree Qt5::Core Qt5::Widgets -fopenmp spdlog)
# target_compile_options(contourtree PRIVATE "-fopenmp")
target_link_libraries(contourtree Qt5::Core Qt5::Widgets spdlog)
target_include_directories(contourtree PUBLIC ${CT_INCLUDE_DIRS})
target_compile_definitions(contourtree PUBLIC CONTOUR_TREE_USE_SPDLOG)

Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ bool init(igl::opengl::glfw::Viewer& viewer) {
ct_logger->set_level(CONTOURTREE_LOGGER_LEVEL);
contourtree::Logger::setLogger(ct_logger);

#ifdef WIN32
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(log_opengl_debug, NULL);
#endif
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want glDebugMessageCallback on Linux too.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You moved other stuff to a helper function, let's wrap this in a helper function called init_opengl_debug() (or something more appropriate if you want). You can put the function alongside the other helper functions you wrote.


return false;
}
Expand Down
13 changes: 12 additions & 1 deletion src/ui/bounding_polygon_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,25 @@ bool Bounding_Polygon_Menu::post_draw() {

int window_width, window_height;
glfwGetWindowSize(viewer->window, &window_width, &window_height);
#ifdef __APPLE__
fwilliams marked this conversation as resolved.
Show resolved Hide resolved
glViewport(-scaling_factor*window_width*view_hsplit, -(1.0+view_vsplit)*window_height,
scaling_factor*window_width, (scaling_factor*scaling_factor)*(1.0-view_vsplit)*window_height);
widget_2d.position = glm::vec2(0.f, view_vsplit*window_height/(scaling_factor*scaling_factor));
widget_2d.size = glm::vec2(window_width*view_hsplit, (1.0-view_vsplit)*window_height/scaling_factor);
#else
glViewport(0, 0, window_width, window_height);

widget_2d.position = glm::vec2(0.f, view_vsplit*window_height);
widget_2d.size = glm::vec2(window_width*view_hsplit, (1.0-view_vsplit)*window_height);
#endif
ret = widget_2d.post_draw(state.cage.keyframe_for_index(current_cut_index), is_2d_widget_in_focus());

#ifdef __APPLE__
Eigen::Vector4f widget_3d_viewport(scaling_factor*view_hsplit*window_width, scaling_factor*view_vsplit*window_height,
scaling_factor*(1.0-view_hsplit)*window_width, scaling_factor*(1.0-view_vsplit)*window_height);
#else
Eigen::Vector4f widget_3d_viewport(view_hsplit*window_width, view_vsplit*window_height,
(1.0-view_hsplit)*window_width, (1.0-view_vsplit)*window_height);
#endif
viewer->core.viewport = widget_3d_viewport;
if (draw_straight) {
ret = widget_3d.post_draw_straight(G4f(widget_3d_viewport), state.cage.keyframe_for_index(current_cut_index));
Expand Down
1 change: 1 addition & 0 deletions src/ui/bounding_polygon_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Bounding_Polygon_Menu : public FishUIViewerPlugin {

void post_draw_transfer_function();

float scaling_factor = 2.0; // Scaling factor for window sizes of the two menus
float view_hsplit = 0.5; // Horizontal split for the two menus (normalized distance
float view_vsplit = 0.2; // Vertical split for the bottom menu (normalized distance from the bottom)

Expand Down
12 changes: 12 additions & 0 deletions src/ui/bounding_widget_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
//
// Render the slice of the volume for this keyframe into an OpenGL texture
//
#ifdef WIN32
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Render slice");
#endif
{
glUseProgram(plane.program);
glBindVertexArray(empty_vao);
Expand Down Expand Up @@ -600,13 +602,17 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
glBindVertexArray(0);
glUseProgram(0);
}
#ifdef WIN32
glPopDebugGroup();
#endif


//
// Render the bounding-box, center, and axes into the same texture
//
#ifdef WIN32
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Render polygon");
#endif
fwilliams marked this conversation as resolved.
Show resolved Hide resolved
{
const glm::vec2 centroid_2d = G2f(kf->centroid_2d());
const glm::vec2 r_axis = G2f(kf->right_rotated_2d()), u_axis = G2f(kf->up_rotated_2d());
Expand Down Expand Up @@ -647,7 +653,9 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
}
}
}
#ifdef WIN32
glPopDebugGroup();
#endif

// Restore the framebuffer and viewport
glBindFramebuffer(GL_FRAMEBUFFER, 0);
Expand All @@ -658,7 +666,9 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
//
// Blit the texture we just rendered to the screen
//
#ifdef WIN32
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Texture Blit");
#endif
{
int width;
int height;
Expand Down Expand Up @@ -709,7 +719,9 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
glBindVertexArray(0);
glUseProgram(0);
}
#ifdef WIN32
glPopDebugGroup();
#endif
glEnable(GL_DEPTH_TEST);

return false;
Expand Down
4 changes: 4 additions & 0 deletions src/ui/endpoint_selection_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ void EndPoint_Selection_Menu::deinitialize() {
bool EndPoint_Selection_Menu::pre_draw() {
int window_width, window_height;
glfwGetWindowSize(viewer->window, &window_width, &window_height);
#ifdef __APPLE__
viewer->core.viewport = Eigen::RowVector4f(2.0*view_hsplit*window_width, 0, 2.0*(1.0-view_hsplit)*window_width, 2.0*window_height);
fwilliams marked this conversation as resolved.
Show resolved Hide resolved
#else
viewer->core.viewport = Eigen::RowVector4f(view_hsplit*window_width, 0, (1.0-view_hsplit)*window_width, window_height);
#endif

bool ret = FishUIViewerPlugin::pre_draw();
const Eigen::MatrixXd& TV = state.dilated_tet_mesh.TV;
Expand Down
26 changes: 26 additions & 0 deletions src/ui/selection_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ void Selection_Menu::initialize() {
void Selection_Menu::draw_selection_volume() {
int window_width, window_height;
glfwGetWindowSize(viewer->window, &window_width, &window_height);
#ifdef __APPLE__
Eigen::RowVector4f viewport(2.0*view_hsplit*window_width, 0, 2.0*(1.0-view_hsplit)*window_width, 2.0*window_height);
fwilliams marked this conversation as resolved.
Show resolved Hide resolved
#else
Eigen::RowVector4f viewport(view_hsplit*window_width, 0, (1.0-view_hsplit)*window_width, window_height);
#endif
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
viewer->core.viewport = viewport;

Expand Down Expand Up @@ -203,6 +207,28 @@ bool Selection_Menu::key_down(int key, int modifiers) {
return false;
}

bool Selection_Menu::mouse_down(int button, int modifier) {
fwilliams marked this conversation as resolved.
Show resolved Hide resolved
double current_press_time = glfwGetTime();
bool left_mouse = glfwGetMouseButton(viewer->window, GLFW_MOUSE_BUTTON_1) == GLFW_PRESS;
bool right_mouse = glfwGetMouseButton(viewer->window, GLFW_MOUSE_BUTTON_2) == GLFW_PRESS;
if (left_mouse || right_mouse) {
if (!is_first_button_down) {
is_first_button_down = left_mouse || right_mouse;
mouse_down_time = current_press_time;
}
else {
double delta_time = current_press_time - mouse_down_time;
mouse_down_time = 0.0;
is_first_button_down = false;
if (delta_time < mouse_click_threshold) { // CLICK
should_select = true;
return true;
}
}
}
return false;
}

bool Selection_Menu::post_draw() {
bool ret = FishUIViewerPlugin::post_draw();

Expand Down
5 changes: 5 additions & 0 deletions src/ui/selection_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Selection_Menu : public FishUIViewerPlugin {
void deinitialize();

bool key_down(int key, int modifiers) override;
bool mouse_down(int button, int modifier) override;
bool post_draw() override;

private:
Expand All @@ -30,6 +31,10 @@ class Selection_Menu : public FishUIViewerPlugin {
Parameters rendering_params;
SelectionRenderer selection_renderer;

double mouse_down_time = 0.0;
double mouse_click_threshold = 0.2;
bool is_first_button_down = false;

glm::vec2 clicked_mouse_position = { 0.f, 0.f };
bool is_currently_interacting = false;
int current_interaction_index = -1;
Expand Down
1 change: 1 addition & 0 deletions src/utils/bounding_cage.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ class BoundingCage {

bool bump(double amount) {
this->_origin += amount * this->normal();
return true;
}

/// Rotate the coordinate frame counter-clockwise about the normal axis
Expand Down
16 changes: 16 additions & 0 deletions src/utils/gl/point_line_rendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ void PointLineRenderer::destroy() {


bool PointLineRenderer::update_polyline_3d(int polyline_id, GLfloat* vertices, GLfloat* colors, GLsizei num_vertices, PolylineStyle style) {
#ifdef WIN32
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "update_polyline_3d");
#endif
if (polyline_id >= _polylines.size() || polyline_id < 0) {
return false;
}
Expand All @@ -93,12 +95,16 @@ bool PointLineRenderer::update_polyline_3d(int polyline_id, GLfloat* vertices, G

glBindBuffer(GL_ARRAY_BUFFER, 0);

#ifdef WIN32
glPopDebugGroup();
#endif
return true;
}

bool PointLineRenderer::update_polyline_3d(int polyline_id, GLfloat* vertices, glm::vec4 color, GLsizei num_vertices, PolylineStyle style) {
#ifdef WIN32
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "update_polyline_3d");
#endif
if (polyline_id >= _polylines.size() || polyline_id < 0) {
return false;
}
Expand All @@ -123,13 +129,17 @@ bool PointLineRenderer::update_polyline_3d(int polyline_id, GLfloat* vertices, g
glDisableVertexAttribArray(1);
glBindVertexArray(0);

#ifdef WIN32
glPopDebugGroup();
#endif
return true;
}


int PointLineRenderer::add_polyline_3d(GLfloat* vertices, GLfloat* colors, GLsizei num_vertices, PolylineStyle style) {
#ifdef WIN32
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "add_polyline_3d");
#endif

Polyline polyline;

Expand Down Expand Up @@ -170,13 +180,17 @@ int PointLineRenderer::add_polyline_3d(GLfloat* vertices, GLfloat* colors, GLsiz
_polylines.push_back(polyline);
}

#ifdef WIN32
glPopDebugGroup();
#endif

return polyline_id;
}

int PointLineRenderer::add_polyline_3d(GLfloat* vertices, glm::vec4 color, GLsizei num_vertices, PolylineStyle style) {
#ifdef WIN32
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "add_polyline_3d");
#endif

Polyline polyline;

Expand Down Expand Up @@ -210,7 +224,9 @@ int PointLineRenderer::add_polyline_3d(GLfloat* vertices, glm::vec4 color, GLsiz
_polylines.push_back(polyline);
}

#ifdef WIN32
glPopDebugGroup();
#endif

return polyline_id;
}
Expand Down
Loading