Commit 63de7d0b1dd814d80414ce5d083f8e101f3f8eb5

Authored by pranathivemuri
1 parent 54259237

added functions to return a string of array without brackets for obj exporting from a network

Showing 1 changed file with 18 additions and 10 deletions   Show diff stats
stim/visualization/network.h
... ... @@ -577,26 +577,34 @@ class network{
577 577 }
578 578 ofs.close();
579 579 }
580   - void
581   - myfunction (T i) { // function:
582   - std::cout << ' ' << i;
583   - }
584   - ///exports the graph.
  580 + void removeCharsFromString(std::string &str, char* charsToRemove ) {
  581 + for ( unsigned int i = 0; i < strlen(charsToRemove); ++i ) {
  582 + str.erase( remove(str.begin(), str.end(), charsToRemove[i]), str.end() );
  583 + }
  584 + }
  585 + ///exports the network graph to obj
585 586 void
586 587 to_obj()
587 588 {
588 589 std::ofstream ofs;
589 590 ofs.open("Graph.obj", std::ofstream::out | std::ofstream::app);
  591 + int num;
  592 + num = V.size();
  593 + string *strArray = new string[num];
590 594 for(int i = 0; i < V.size(); i++)
591 595 {
592   - std::vector<T> myvector;
593   - myvector = V[i]
594   - ofs << "v " << for_each (myvector.begin(), myvector.end(), myfunction) << "\n";
595   -
  596 + std::string str;
  597 + str = V[i].str();
  598 + removeCharsFromString(str, "[],");
  599 + ofs << "v " << str << "\n";
  600 + removeCharsFromString(str," ");
  601 + strArray[i] = str;
596 602 }
597 603 for(unsigned int i = 0; i < E.size(); i++)
598 604 {
599   - ofs << "l " << E[i]->str() << "\n";
  605 + std::string str;
  606 + str = E[i]->strObj(strArray, num);
  607 + ofs << "l " << str << "\n";
600 608 }
601 609 ofs.close();
602 610 }
... ...