Commit b8b15cb80b599a83be85af59d923af52a23b96cb

Authored by David Mayerich
1 parent 41229af1

further simplifications for FindSTIM

cmake/FindSTIM.cmake
... ... @@ -5,23 +5,12 @@ include(FindPackageHandleStandardArgs)
5 5  
6 6 set(STIM_ROOT $ENV{STIM_ROOT})
7 7  
8   -IF(NOT UNIX)
9   - IF(NOT STIM_ROOT)
10   - MESSAGE("ERROR: STIM_ROOT environment variable must be set!")
11   - ENDIF(NOT STIM_ROOT)
  8 +IF(NOT STIM_ROOT)
  9 + MESSAGE("ERROR: STIM_ROOT environment variable must be set!")
  10 +ENDIF(NOT STIM_ROOT)
12 11  
13   - FIND_PATH(STIM_INCLUDE_DIRS DOC "Path to GLFW include directory."
14   - NAMES stim/image/image.h
15   - PATHS ${STIM_ROOT})
16   -ENDIF(NOT UNIX)
17   -
18   -find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIRS)
19   -
20   -if(STIM_FOUND)
21   - set(STIM_INCLUDE_DIRS ${STIM_INCLUDE_DIRS})
22   -elseif(STIM_FOUND)
23   - message("STIM library not found. Set the STIM_ROOT environment variable to the STIM location.")
24   - message("STIMLIB can be found here: https://git.stim.ee.uh.edu/codebase/stimlib")
25   -endif(STIM_FOUND)
  12 + FIND_PATH(STIM_INCLUDE_DIRS DOC "Path to STIM include directory."
  13 + NAMES stim/image/image.h
  14 + PATHS ${STIM_ROOT})
26 15  
27 16 find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIRS)
... ...
stim/image/image.h
... ... @@ -247,10 +247,11 @@ public:
247 247 outfile.write((char*)img, sizeof(T) * R[0] * R[1] * R[2]);
248 248 outfile.close();
249 249 }
250   -
251   - cimg_library::CImg<T> cimg((unsigned int)R[1], (unsigned int)R[2], 1, (unsigned int)R[0]);
252   - get_noninterleaved(cimg.data());
253   - cimg.save(filename.c_str());
  250 + else {
  251 + cimg_library::CImg<T> cimg((unsigned int)R[1], (unsigned int)R[2], 1, (unsigned int)R[0]);
  252 + get_noninterleaved(cimg.data());
  253 + cimg.save(filename.c_str());
  254 + }
254 255 }
255 256  
256 257 /// Returns an image cast to the specified format
... ...
stim/visualization/obj.h
... ... @@ -183,7 +183,7 @@ protected:
183 183 void get_v(std::vector<unsigned>& v){
184 184 v.resize(size()); //resize the vector to match the number of vertices
185 185 for(unsigned int i = 0; i<size(); i++){ //for each vertex
186   - v[i] = at(i)[0]; //copy the vertex index (1st element of triplet)
  186 + v[i] = (unsigned)at(i)[0]; //copy the vertex index (1st element of triplet)
187 187 }
188 188 }
189 189  
... ... @@ -705,6 +705,13 @@ public:
705 705 stim::vec<T> v = V[vi];
706 706 return v;
707 707 }
  708 + std::vector< stim::vec<T> > getAllV() {
  709 + std::vector< stim::vec<T> > v(V.size());
  710 + for (unsigned i = 0; i < V.size(); i++)
  711 + v[i] = V[i];
  712 + return v;
  713 + }
  714 +
708 715 std::vector< stim::vec<T> > getAllV(std::vector<unsigned> vertexIndices){
709 716 std::vector< stim::vec<T> > allVerticesList;
710 717 for (unsigned int i=0; i<numV(); i++)
... ... @@ -785,7 +792,7 @@ public:
785 792 stim::vec<T> centroid(){
786 793  
787 794 //get the number of coordinates
788   - unsigned int N = V[0].size();
  795 + size_t N = V[0].size();
789 796  
790 797 //allocate space for the minimum and maximum coordinate points (bounding box corners)
791 798 stim::vec<float> vmin, vmax;
... ... @@ -793,9 +800,9 @@ public:
793 800 vmax.resize(N);
794 801  
795 802 //find the minimum and maximum value for each coordinate
796   - unsigned int NV = V.size();
797   - for(unsigned int v = 0; v < NV; v++)
798   - for(unsigned int i = 0; i < N; i++){
  803 + size_t NV = V.size();
  804 + for(size_t v = 0; v < NV; v++)
  805 + for(size_t i = 0; i < N; i++){
799 806  
800 807 if(V[v][i] < vmin[i])
801 808 vmin[i] = V[v][i];
... ... @@ -809,9 +816,35 @@ public:
809 816 return c;
810 817 }
811 818  
  819 + stim::vec<T> dimensions() {
  820 + //get the number of coordinates
  821 + size_t N = V[0].size();
  822 +
  823 + //allocate space for the minimum and maximum coordinate points (bounding box corners)
  824 + stim::vec<float> vmin, vmax;
  825 + vmin.resize(N);
  826 + vmax.resize(N);
  827 +
  828 + //find the minimum and maximum value for each coordinate
  829 + size_t NV = V.size();
  830 + for (size_t v = 0; v < NV; v++)
  831 + for (size_t i = 0; i < N; i++) {
  832 +
  833 + if (V[v][i] < vmin[i])
  834 + vmin[i] = V[v][i];
  835 + if (V[v][i] > vmax[i])
  836 + vmax[i] = V[v][i];
  837 + }
  838 +
  839 + //find the soze using the min and max points
  840 + stim::vec<T> d = vmax - vmin;
  841 +
  842 + return d;
  843 + }
  844 +
812 845 /// Returns the number of lines in the OBJ structure
813 846 unsigned int numL(){
814   - return L.size();
  847 + return (unsigned)L.size();
815 848 }
816 849  
817 850 /// Returns all points in the line corresponding to a given index
... ... @@ -993,6 +1026,12 @@ public:
993 1026  
994 1027 }
995 1028  
  1029 + /// Return the number of vertices in a line
  1030 + /// @param l is the line index
  1031 + unsigned getLineN(unsigned l) {
  1032 + return (unsigned)L[l].size();
  1033 + }
  1034 +
996 1035  
997 1036  
998 1037  
... ...