Commit d6b537319f09ef0d6eb0c8178733cb5212ad6ebf
Merge branch 'network'
Mergint updates to the stim::obj class.
Showing
2 changed files
with
74 additions
and
3 deletions
Show diff stats
stim/math/spharmonics.h
1 | #ifndef STIM_SPH_HARMONICS | 1 | #ifndef STIM_SPH_HARMONICS |
2 | #define STIM_SPH_HARMONICS | 2 | #define STIM_SPH_HARMONICS |
3 | 3 | ||
4 | - | 4 | +#include <stim/math/mathvec.h> |
5 | #include <boost/math/special_functions/spherical_harmonic.hpp> | 5 | #include <boost/math/special_functions/spherical_harmonic.hpp> |
6 | #include <vector> | 6 | #include <vector> |
7 | 7 |
stim/visualization/obj.h
@@ -8,6 +8,8 @@ | @@ -8,6 +8,8 @@ | ||
8 | #include <stim/parser/parser.h> | 8 | #include <stim/parser/parser.h> |
9 | #include <stim/math/mathvec.h> | 9 | #include <stim/math/mathvec.h> |
10 | 10 | ||
11 | +#include <ANN/ANN.h> | ||
12 | + | ||
11 | namespace stim{ | 13 | namespace stim{ |
12 | 14 | ||
13 | /** This class provides an interface for loading, saving, and working with Wavefront OBJ files. | 15 | /** This class provides an interface for loading, saving, and working with Wavefront OBJ files. |
@@ -41,7 +43,11 @@ protected: | @@ -41,7 +43,11 @@ protected: | ||
41 | using vec<T>::size; | 43 | using vec<T>::size; |
42 | using vec<T>::at; | 44 | using vec<T>::at; |
43 | 45 | ||
46 | + //basic constructors (call the stim::vector constructors) | ||
44 | vertex(){} | 47 | vertex(){} |
48 | + vertex(T x, T y) : stim::vec<T>(x, y){} | ||
49 | + vertex(T x, T y, T z) : stim::vec<T>(x, y, z){} | ||
50 | + vertex(T x, T y, T z, T w) : stim::vec<T>(x, y, z, w){} | ||
45 | 51 | ||
46 | //constructor creates a vertex from a line string | 52 | //constructor creates a vertex from a line string |
47 | vertex(std::string line){ | 53 | vertex(std::string line){ |
@@ -446,10 +452,10 @@ public: | @@ -446,10 +452,10 @@ public: | ||
446 | } | 452 | } |
447 | 453 | ||
448 | std::string line; | 454 | std::string line; |
455 | + getline(infile, line); //get the first line | ||
449 | while(infile){ | 456 | while(infile){ |
450 | 457 | ||
451 | - //create a variable to store a single line | ||
452 | - getline(infile, line); | 458 | + |
453 | 459 | ||
454 | //get the token representing the first parameter | 460 | //get the token representing the first parameter |
455 | token_type token = get_token(line); | 461 | token_type token = get_token(line); |
@@ -475,7 +481,14 @@ public: | @@ -475,7 +481,14 @@ public: | ||
475 | F.push_back(geometry(line)); | 481 | F.push_back(geometry(line)); |
476 | break; | 482 | break; |
477 | 483 | ||
484 | + case OBJ_L: | ||
485 | + L.push_back(geometry(line)); | ||
486 | + break; | ||
487 | + | ||
478 | }; | 488 | }; |
489 | + | ||
490 | + //get the next line | ||
491 | + getline(infile, line); | ||
479 | } | 492 | } |
480 | 493 | ||
481 | 494 | ||
@@ -528,6 +541,64 @@ public: | @@ -528,6 +541,64 @@ public: | ||
528 | return c; | 541 | return c; |
529 | } | 542 | } |
530 | 543 | ||
544 | + /// Returns the number of lines in the OBJ structure | ||
545 | + unsigned int numL(){ | ||
546 | + return L.size(); | ||
547 | + } | ||
548 | + | ||
549 | + /// Returns all points in the line corresponding to a given index | ||
550 | + | ||
551 | + /// @param i is the index of the desired line | ||
552 | + std::vector< stim::vec<T> > getL_V(unsigned int i){ | ||
553 | + | ||
554 | + //get the number of points in the specified line | ||
555 | + unsigned int nP = L[i].size(); | ||
556 | + | ||
557 | + //create a vector of points | ||
558 | + std::vector< stim::vec<T> > l; | ||
559 | + | ||
560 | + //set the size of the vector | ||
561 | + l.resize(nP); | ||
562 | + | ||
563 | + //copy the points from the point list to the stim vector | ||
564 | + unsigned int pi; | ||
565 | + for(unsigned int p = 0; p < nP; p++){ | ||
566 | + | ||
567 | + //get the index of the geometry point | ||
568 | + pi = L[i][p][0] - 1; | ||
569 | + | ||
570 | + //get the coordinates of the current point | ||
571 | + stim::vec<T> newP = V[pi]; | ||
572 | + | ||
573 | + //copy the point into the vector | ||
574 | + l[p] = newP; | ||
575 | + } | ||
576 | + | ||
577 | + return l; | ||
578 | + | ||
579 | + } | ||
580 | + | ||
581 | + /// Returns the vertex indices for the specified line | ||
582 | + /// @param i is the index of the line | ||
583 | + std::vector< unsigned int > getL_Vi(unsigned int i){ | ||
584 | + | ||
585 | + unsigned int nP = L[i].size(); | ||
586 | + | ||
587 | + std::vector< unsigned int > l; | ||
588 | + | ||
589 | + //set the size of the vector | ||
590 | + l.resize(nP); | ||
591 | + | ||
592 | + //copy the indices from the geometry structure to the array | ||
593 | + for(unsigned int p = 0; p < nP; p++){ | ||
594 | + | ||
595 | + l[p] = L[i][p][0]; | ||
596 | + | ||
597 | + } | ||
598 | + | ||
599 | + return l; | ||
600 | + | ||
601 | + } | ||
531 | 602 | ||
532 | }; | 603 | }; |
533 | 604 |