00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef SWC_SEGMENT_H
00010 #define SWC_SEGMENT_H
00011
00018 class SwcSegment
00019 {
00020 public:
00021 SwcSegment()
00022 : myIndex_( 0 ), type_( 0 ), radius_( 0.0 ),
00023 length_( 0.0 ), L_( 0.0 ),
00024 parent_( ~0U ),
00025 geometricalDistanceFromSoma_( 0.0 ),
00026 electrotonicDistanceFromSoma_( 0.0 )
00027 {;}
00028
00029 SwcSegment( const string& line );
00030
00031 SwcSegment( int i, short type,
00032 double x, double y, double z,
00033 double r, int parent );
00034 bool OK() const
00035 {
00036 return type_!=BadSegment && type_!=UNDEF && type_!=CUSTOM;
00037 }
00038
00039 void setBad() {
00040 type_ = BadSegment;
00041 }
00042
00043
00044 unsigned int parent() const {
00045 return parent_;
00046 }
00047
00048 void setParent( unsigned int pa ) {
00049 parent_ = pa;
00050 }
00051
00052 unsigned int myIndex() const {
00053 return myIndex_;
00054 }
00055
00056 void addChild( unsigned int kid ) {
00057 kids_.push_back( kid );
00058 }
00059
00060 void figureOutType();
00061
00062 const vector< int >& kids() const
00063 {
00064 return kids_;
00065 }
00066
00067 void replaceKids( const vector< int >& kids )
00068 {
00069 kids_ = kids;
00070 }
00071
00072 unsigned short type() const {
00073 return type_;
00074 }
00075
00076 double radius() const {
00077 return radius_;
00078 }
00079 double length() const {
00080 return length_;
00081 }
00082
00083 double L() const {
00084 return L_;
00085 }
00086
00087 double distance( const SwcSegment& other ) const {
00088 return v_.distance( other.v_ );
00089 }
00090
00091 const Vec& vec() const {
00092 return v_;
00093 }
00094
00095 void setGeometricalDistanceFromSoma( const SwcSegment& soma )
00096 {
00097 geometricalDistanceFromSoma_ = v_.distance( soma.v_ );
00098 }
00099
00100 void setCumulativeDistance( double len, double L,
00101 double pSoma, double eSoma )
00102 {
00103 length_ = len;
00104 L_ = L;
00105 pathDistanceFromSoma_ = pSoma;
00106 electrotonicDistanceFromSoma_ = eSoma;
00107 }
00108
00109 double getPathDistFromSoma() const {
00110 return pathDistanceFromSoma_;
00111 }
00112
00113 double getGeomDistFromSoma() const {
00114 return geometricalDistanceFromSoma_;
00115 }
00116
00117 double getElecDistFromSoma() const {
00118 return electrotonicDistanceFromSoma_;
00119 }
00120
00121
00122 static const short UNDEF;
00123 static const short SOMA;
00124 static const short AXON;
00125 static const short DEND;
00126 static const short APICAL;
00127 static const short FORK;
00128 static const short END;
00129 static const short CUSTOM;
00130
00131 static const short BadSegment;
00132 static const short AXON_FORK;
00133 static const short AXON_END;
00134 static const short APICAL_FORK;
00135 static const short APICAL_END;
00136
00137 static const string typeName[];
00138
00139 protected:
00140 unsigned int myIndex_;
00141
00153 short type_;
00154 Vec v_;
00155 double radius_;
00156 double length_;
00157 double L_;
00158 unsigned int parent_;
00159
00161 double pathDistanceFromSoma_;
00162
00164 double geometricalDistanceFromSoma_;
00165
00167 double electrotonicDistanceFromSoma_;
00168
00169 vector< int > kids_;
00170 };
00171
00172 class SwcBranch: public SwcSegment
00173 {
00174 public:
00175 SwcBranch( int i, const SwcSegment& start, double len, double L,
00176 const vector< int >& cable );
00177
00178 void printDiagnostics() const;
00179
00180 double r0;
00181 double r1;
00182
00184 double geomLength;
00185
00187 double pathLength;
00188
00189
00195 double electroLength;
00196
00202 vector< int > segs_;
00203 };
00204
00205 #endif // SWC_SEGMENT_H