TubeBundle.h

00001 #ifndef __TUBE_BUNDLE_H__
00002 #define __TUBE_BUNDLE_H__
00003 
00004 #include <fstream>
00005 #include <assert.h>
00006 #include <vector>
00007 #include "PKFmanip.h"
00008 #include "Tube.h"
00009 #include "CurveBundle.h"
00010 
00011 template <class Vector>
00012 class TubeBundle : public PKFmanip {
00013 
00014   vector< Tube<Vector> > container;
00015 
00016   // Box that contains all the curves in container
00017   // Bottom left corner
00018   Vector _BBox_Min;
00019   // Upper right corner
00020   Vector _BBox_Max;
00021   // Center of mass
00022   Vector _Center;
00023 
00024   // this routine is called f.ex by makeMesh or scaleTubeRadius
00025   // to update the current bounging box and center value
00026   void computeBoundingBox();
00027 
00028   void init();
00029 
00030 public:
00031 
00032   void clear_tb();
00033 
00034   TubeBundle();
00035   TubeBundle(const char* filename);
00036   TubeBundle(const TubeBundle<Vector> &tb);
00037   TubeBundle(const CurveBundle<Vector> &cb);
00038   TubeBundle<Vector> &operator= (const TubeBundle<Vector> &tb);
00039   ~TubeBundle();
00040 
00041   int tubes() const;
00042   void newTube(const Tube<Vector>& t);
00043   void newTube(istream& in);
00044   Tube<Vector>& operator[](int c) ;
00045 
00046   void makeMesh(int N, int S, float R, float Tol = -1.0);
00047 
00048   void getBoundingBox(Vector & BBox_Min, Vector & BBox_Max);
00049   Vector & getCenter();
00050   void scaleTubeRadius(float NewRadius);
00051 
00052   /*
00053     TODO :
00054 
00055     scaleMesh, compute surface area and volume of the tube
00056     depending on coarsness of the mesh
00057   */
00058 
00059   int readPKF(const char* infile);
00060   int readXYZ(const char* infile);
00061   int readPKF(istream& in);
00062   int readData(const char* infile, const char* delimiter = " ");
00063 
00064   // friend ostream &operator<<(ostream &out, TubeBundle<Vector> &tb);
00065 
00066 };
00067 
00068 template <class Vector>
00069 inline ostream &operator<<(ostream &out, TubeBundle<Vector> &tb) {
00070 
00071   for (int i=0;i<tb.tubes();i++)
00072     out << tb[i] << endl;
00073 
00074   return out;
00075 }
00076 
00077 // We have templates and need all code in same file
00078 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00079 #include "../lib/TubeBundle.cpp"
00080 #endif
00081 
00082 #endif // __TUBE_BUNDLE_H__

Generated on Mon Feb 8 17:22:35 2010 for libbiarc by  doxygen 1.5.6