这篇博客主要介绍V3d编程中的SWC文件
NeuronSWC——储存SWC中单个节点信息的单元
NeuronSWC point() //定义一个节点变量
point.type //节点的类型
point.x point.y point.z //访问节点的坐标
point.r//节点的半径
point.parent//节点的父节点索引,注意:返回的是point index
NeuronTree——储存SWC结构信息的单元
NeuronTree filetree //定义一个NeuronTree结构
//NeuronTree结构里包含了以下成员
QList <NeuronSWC> listNeuron // QList存储了给定类型的值的一个列表,而这些值可以
//通过索引访问(类似于数组),索引在这里就表示为SWC文件中数据部分的行号。
QHash <int, int> hashNeuron; // QHash是存储一一对应的行号和节点索引n。
关于Qlist的介绍参见介绍。访问某个节点的父节点需要通过QHash。
S2=filetree.listNeuron.at(filetree.hashNeuron.value(S1.parent));
从SWC中读取/添加节点
SWC文件中存储了一系列节点的信息,常常需要获取每个节点的新信息。 使用NeuronTree结构保存
// 读取NeuronTree
for(V3DLONG i=0;i<filetree.listNeuron.size();i++)
{
NeuronSWC S;
S=filetree.listNeuron.at(i);
}
//将新增节点S放入NeuronTree,用于新增SWC文件中的节点
S.n=filetree.listNeuron.size();
filetree.listNeuron.append(S);
filetree.hashNeuron.insert(S.n, filetree.listNeuron.size()-1)