EMAN2
Public Member Functions | Public Attributes | List of all members
EMAN::TomoObject Class Reference

#include <tomoseg.h>

Public Member Functions

 TomoObject (vector< Vec3i > allpt, float md=1, int slice=0)
 
void write_imod (FILE *fp)
 
int get_size ()
 
int bend ()
 
void enlong (EMData *bwmap, EMData *skelmap)
 

Public Attributes

vector< int > ptid
 
vector< int > segid
 
vector< Vec3iallpoints
 
float maxdist
 
int nowslice
 

Detailed Description

Definition at line 35 of file tomoseg.h.

Constructor & Destructor Documentation

◆ TomoObject()

TomoObject::TomoObject ( vector< Vec3i allpt,
float  md = 1,
int  slice = 0 
)

Definition at line 36 of file tomoseg.cpp.

36 {
37 nowslice=slice;
38 maxdist=md;
39 // find one end point
40 for (int i=0; i<(int)allpt.size(); i++){
41 if (allpt[i][2]==1){
42 allpoints.push_back(allpt[i]);
43 allpt[i][2]=-1;
44 break;
45 }
46 }
47
48 // sort points from one endpoint to the other
49 for (int i=0; i<(int)allpt.size()-1; i++){
50 float mindst=1e10;
51 int nxti=-1;
52 Vec3i nowp=allpoints.back();
53 for (int j=0; j<(int)allpt.size(); j++){
54 if (allpt[j][2]>0){
55 float dst=(allpt[j][0]-nowp[0])*(allpt[j][0]-nowp[0])+(allpt[j][1]-nowp[1])*(allpt[j][1]-nowp[1]);
56 if (dst<mindst){
57 mindst=dst;
58 nxti=j;
59 }
60 }
61 }
62 if (nxti>=0){
63 allpoints.push_back(allpt[nxti]);
64 allpt[nxti][2]=-1;
65 }
66 else
67 break;
68 }
69// for (int i=0; i<(int)allpoints.size(); i++)
70// printf("(%d,%d)",allpoints[i][0],allpoints[i][1]);
71// printf("\n");
72 ptid.push_back(0);
73 ptid.push_back((int)allpoints.size()-1);
74
75
76 // break into line segments
77 while(1){
78 int newpt=bend();
79 if (newpt>0){
80 ptid.push_back(newpt);
81 sort(ptid.begin(),ptid.end());
82// for (int i=0; i<ptid.size(); i++) printf("%d\t",ptid[i]);
83// printf("\n");
84
85 }
86 else
87 break;
88 }
89
90}
vector< int > ptid
Definition: tomoseg.h:49
vector< Vec3i > allpoints
Definition: tomoseg.h:51
float maxdist
Definition: tomoseg.h:52

References allpoints, bend(), maxdist, nowslice, and ptid.

Member Function Documentation

◆ bend()

int TomoObject::bend ( )

Definition at line 92 of file tomoseg.cpp.

92 {
93 // distance to current line segments
94 float maxd=maxdist;
95 int newpt=-1;
96 for (int i=1; i<(int)ptid.size(); i++){
97 int x1=allpoints[ptid[i-1]][0],y1=allpoints[ptid[i-1]][1];
98 int x2=allpoints[ptid[i]][0],y2=allpoints[ptid[i]][1];
99 for (int j=ptid[i-1]; j<ptid[i]; j++){
100 int x0=allpoints[j][0],y0=allpoints[j][1];
101 float dst=DistToLine(x0,y0,x1,y1,x2,y2);
102 if (dst>maxd){
103 maxd=dst;
104 newpt=j;
105 }
106 }
107
108 }
109 return newpt;
110}
float DistToLine(int x0, int y0, int x1, int y1, int x2, int y2)
Definition: tomoseg.cpp:32

References allpoints, DistToLine(), maxdist, and ptid.

Referenced by TomoObject().

◆ enlong()

void TomoObject::enlong ( EMData bwmap,
EMData skelmap 
)

Definition at line 123 of file tomoseg.cpp.

123 {
124 // first push the current segment in.
125 int myid=skelmap->get_value_at(allpoints[0][0],allpoints[0][1]);
126 segid.push_back(myid);
127
128 //
129
130}
vector< int > segid
Definition: tomoseg.h:50

References allpoints, and segid.

◆ get_size()

int TomoObject::get_size ( )

Definition at line 119 of file tomoseg.cpp.

119 {
120 return (int)ptid.size();
121}

References ptid.

◆ write_imod()

void TomoObject::write_imod ( FILE *  fp)

Definition at line 112 of file tomoseg.cpp.

112 {
113 fprintf(fp,"color 0 1 0 0\nopen\ncontour 0 0 %d\n",(int)ptid.size());
114 for (int i=0; i<(int)ptid.size(); i++){
115 fprintf(fp,"%d %d %d\n",allpoints[ptid[i]][0],allpoints[ptid[i]][1],nowslice);
116 }
117}

References allpoints, nowslice, and ptid.

Member Data Documentation

◆ allpoints

vector<Vec3i> EMAN::TomoObject::allpoints

Definition at line 51 of file tomoseg.h.

Referenced by bend(), enlong(), TomoObject(), and write_imod().

◆ maxdist

float EMAN::TomoObject::maxdist

Definition at line 52 of file tomoseg.h.

Referenced by bend(), and TomoObject().

◆ nowslice

int EMAN::TomoObject::nowslice

Definition at line 53 of file tomoseg.h.

Referenced by TomoObject(), and write_imod().

◆ ptid

vector<int> EMAN::TomoObject::ptid

Definition at line 49 of file tomoseg.h.

Referenced by bend(), get_size(), TomoObject(), and write_imod().

◆ segid

vector<int> EMAN::TomoObject::segid

Definition at line 50 of file tomoseg.h.

Referenced by enlong().


The documentation for this class was generated from the following files: