diff --git a/cmake/FindSTIM.cmake b/cmake/FindSTIM.cmake index c05f9f6..cb2bcc7 100644 --- a/cmake/FindSTIM.cmake +++ b/cmake/FindSTIM.cmake @@ -5,23 +5,12 @@ include(FindPackageHandleStandardArgs) set(STIM_ROOT $ENV{STIM_ROOT}) -IF(NOT UNIX) - IF(NOT STIM_ROOT) - MESSAGE("ERROR: STIM_ROOT environment variable must be set!") - ENDIF(NOT STIM_ROOT) +IF(NOT STIM_ROOT) + MESSAGE("ERROR: STIM_ROOT environment variable must be set!") +ENDIF(NOT STIM_ROOT) - FIND_PATH(STIM_INCLUDE_DIRS DOC "Path to GLFW include directory." - NAMES stim/image/image.h - PATHS ${STIM_ROOT}) -ENDIF(NOT UNIX) - -find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIRS) - -if(STIM_FOUND) - set(STIM_INCLUDE_DIRS ${STIM_INCLUDE_DIRS}) -elseif(STIM_FOUND) - message("STIM library not found. Set the STIM_ROOT environment variable to the STIM location.") - message("STIMLIB can be found here: https://git.stim.ee.uh.edu/codebase/stimlib") -endif(STIM_FOUND) + FIND_PATH(STIM_INCLUDE_DIRS DOC "Path to STIM include directory." + NAMES stim/image/image.h + PATHS ${STIM_ROOT}) find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIRS) diff --git a/stim/image/image.h b/stim/image/image.h index 61ffe8d..7cc10ce 100644 --- a/stim/image/image.h +++ b/stim/image/image.h @@ -247,10 +247,11 @@ public: outfile.write((char*)img, sizeof(T) * R[0] * R[1] * R[2]); outfile.close(); } - - cimg_library::CImg cimg((unsigned int)R[1], (unsigned int)R[2], 1, (unsigned int)R[0]); - get_noninterleaved(cimg.data()); - cimg.save(filename.c_str()); + else { + cimg_library::CImg cimg((unsigned int)R[1], (unsigned int)R[2], 1, (unsigned int)R[0]); + get_noninterleaved(cimg.data()); + cimg.save(filename.c_str()); + } } /// Returns an image cast to the specified format diff --git a/stim/visualization/obj.h b/stim/visualization/obj.h index a788b4c..967dee6 100644 --- a/stim/visualization/obj.h +++ b/stim/visualization/obj.h @@ -183,7 +183,7 @@ protected: void get_v(std::vector& v){ v.resize(size()); //resize the vector to match the number of vertices for(unsigned int i = 0; i v = V[vi]; return v; } + std::vector< stim::vec > getAllV() { + std::vector< stim::vec > v(V.size()); + for (unsigned i = 0; i < V.size(); i++) + v[i] = V[i]; + return v; + } + std::vector< stim::vec > getAllV(std::vector vertexIndices){ std::vector< stim::vec > allVerticesList; for (unsigned int i=0; i centroid(){ //get the number of coordinates - unsigned int N = V[0].size(); + size_t N = V[0].size(); //allocate space for the minimum and maximum coordinate points (bounding box corners) stim::vec vmin, vmax; @@ -793,9 +800,9 @@ public: vmax.resize(N); //find the minimum and maximum value for each coordinate - unsigned int NV = V.size(); - for(unsigned int v = 0; v < NV; v++) - for(unsigned int i = 0; i < N; i++){ + size_t NV = V.size(); + for(size_t v = 0; v < NV; v++) + for(size_t i = 0; i < N; i++){ if(V[v][i] < vmin[i]) vmin[i] = V[v][i]; @@ -809,9 +816,35 @@ public: return c; } + stim::vec dimensions() { + //get the number of coordinates + size_t N = V[0].size(); + + //allocate space for the minimum and maximum coordinate points (bounding box corners) + stim::vec vmin, vmax; + vmin.resize(N); + vmax.resize(N); + + //find the minimum and maximum value for each coordinate + size_t NV = V.size(); + for (size_t v = 0; v < NV; v++) + for (size_t i = 0; i < N; i++) { + + if (V[v][i] < vmin[i]) + vmin[i] = V[v][i]; + if (V[v][i] > vmax[i]) + vmax[i] = V[v][i]; + } + + //find the soze using the min and max points + stim::vec d = vmax - vmin; + + return d; + } + /// Returns the number of lines in the OBJ structure unsigned int numL(){ - return L.size(); + return (unsigned)L.size(); } /// Returns all points in the line corresponding to a given index @@ -993,6 +1026,12 @@ public: } + /// Return the number of vertices in a line + /// @param l is the line index + unsigned getLineN(unsigned l) { + return (unsigned)L[l].size(); + } + -- libgit2 0.21.4