From 5bccf89d07af8ec102d3e351ccb7455841b1c1ad Mon Sep 17 00:00:00 2001 From: David Date: Fri, 5 Feb 2016 15:36:39 -0600 Subject: [PATCH] fixed some errors with loading networks as OBJ files --- stim/biomodels/fiber.h | 2 +- stim/biomodels/network.h | 3 +++ stim/visualization/obj.h | 26 ++++++++++++++++++-------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/stim/biomodels/fiber.h b/stim/biomodels/fiber.h index 944e625..c901dd4 100644 --- a/stim/biomodels/fiber.h +++ b/stim/biomodels/fiber.h @@ -430,7 +430,7 @@ public: ////resample a fiber in the network stim::fiber resample(T spacing) { - + std::cout<<"fiber::resample()"< v(3); //v-direction vector of the segment stim::vec p(3); //- intermediate point to be added diff --git a/stim/biomodels/network.h b/stim/biomodels/network.h index 30116fd..eada0c4 100644 --- a/stim/biomodels/network.h +++ b/stim/biomodels/network.h @@ -193,6 +193,7 @@ class network{ /// This function resamples all fibers in a network given a desired minimum spacing stim::network resample(T spacing){ + std::cout<<"network::resample()"< n; //create a new network that will be an exact copy, with resampled fibers n.V = V; //copy all vertices @@ -200,7 +201,9 @@ class network{ //copy all fibers, resampling them in the process for(unsigned e = 0; e < edges(); e++){ //for each edge in the edge list + std::cout<<"edge: "< #include +#include + namespace stim{ /** This class provides an interface for loading, saving, and working with Wavefront OBJ files. @@ -92,6 +94,9 @@ protected: //triplet used to specify geometric vertices consisting of a position vertex, texture vertex, and normal struct triplet : public std::vector{ + + //default constructor, empty triplet + triplet(){} //create a triplet given a parameter list (OBJ indices start at 1, so 0 can be used to indicate no value) triplet(unsigned int v, unsigned int vt = 0, unsigned int vn = 0){ @@ -162,10 +167,12 @@ protected: //create a temporary vector used to store string tokens std::vector tokens = stim::parser::split(line, ' '); + resize(tokens.size() - 1); //set the geometry size based on the number of tokens //for each triplet in the line for(unsigned int i = 1; i < tokens.size(); i++){ //construct the triplet and push it to the geometry - push_back( triplet(tokens[i]) ); + //push_back( triplet(tokens[i]) ); + at(i-1) = triplet(tokens[i]); } } @@ -173,14 +180,15 @@ protected: //returns a vector containing the vertex indices for the geometry void get_v(std::vector& v){ v.resize(size()); //resize the vector to match the number of vertices - for(unsigned int i = 0; i& vt){ vt.resize(size()); //resize the vector to match the number of vertices for(unsigned int i = 0; i& vn){ @@ -492,9 +500,10 @@ public: std::string line; getline(infile, line); //get the first line + unsigned int l = 0; while(infile){ - - + l++; + //unsigned int t = time(NULL); //get the token representing the first parameter token_type token = get_token(line); @@ -521,16 +530,17 @@ public: break; case OBJ_L: + L.push_back(geometry(line)); break; }; + //get the next line getline(infile, line); - } - + } //close the file infile.close(); -- libgit2 0.21.4