本文整理汇总了C++中ZSwcTree::updateIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ ZSwcTree::updateIterator方法的具体用法?C++ ZSwcTree::updateIterator怎么用?C++ ZSwcTree::updateIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZSwcTree
的用法示例。
在下文中一共展示了ZSwcTree::updateIterator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hookIter
pair<Swc_Tree_Node*, Swc_Tree_Node*> ZSwcConnector::identifyConnection(
const ZSwcTree &hook, const ZSwcTree &loop)
{
pair<Swc_Tree_Node*, Swc_Tree_Node*> conn;
loop.updateIterator(SWC_TREE_ITERATOR_DEPTH_FIRST);
m_dist = Infinity;
ZSwcTree::TerminalIterator hookIter(&hook);
ZSwcTree::DepthFirstIterator loopIter(&loop);
while (loopIter.hasNext()) {
Swc_Tree_Node *tn = loopIter.next();
if (SwcTreeNode::isRegular(tn)) {
hookIter.begin();
while (hookIter.hasNext()) {
Swc_Tree_Node *head = hookIter.next();
double d = SwcTreeNode::scaledDistance(
head, tn, m_resolution.voxelSizeX(), m_resolution.voxelSizeY(),
m_resolution.voxelSizeZ());
if (d < m_dist) {
m_dist = d;
conn.first = head;
conn.second = const_cast<Swc_Tree_Node*>(tn);
}
}
}
}
return conn;
}
示例2: setupModelData
void ZSwcNodeObjsModel::setupModelData(ZObjsItem *parent)
{
QList<QVariant> data;
m_typeToRow.clear();
m_swcTreeNodeToRow.clear();
m_swcTreeNodeToType.clear();
m_typeToRow[SwcTreeNode::TERMINAL] = 0;
m_typeToRow[SwcTreeNode::BRANCH_POINT] = 1;
data.clear();
data << "Termini" << "id" << "type" << "radius" << "x" << "y" << "z"
<< "label";
ZObjsItem *terminalItem = new ZObjsItem(data, NULL, parent);
terminalItem->setCheckState(Qt::Checked);
parent->appendChild(terminalItem);
data.clear();
data << "Branch Points" << "id" << "type" << "radius" << "x" << "y" << "z"
<< "label";
ZObjsItem *branchPointItem = new ZObjsItem(data, NULL, parent);
branchPointItem->setCheckState(Qt::Checked);
parent->appendChild(branchPointItem);
int terminalRow = 0;
int branchPointRow = 0;
QList<ZSwcTree*> swcList = m_doc->getSwcList();
for (int i=0; i<swcList.size(); i++) {
data.clear();
ZSwcTree *swcTree = swcList.at(i);
//ZObjsItem *nodeParent = new ZObjsItem(data, swcTree, parent);
//nodeParent->setCheckState(swcTree->isVisible() ? Qt::Checked : Qt::Unchecked);
//nodeParent->setToolTip(QString("source: %1").arg(QString::fromStdString(swcTree->source())));
//parent->appendChild(nodeParent);
swcTree->updateIterator(SWC_TREE_ITERATOR_DEPTH_FIRST); //depth first
for (Swc_Tree_Node *tn = swcTree->begin(); tn != swcTree->end(); tn = swcTree->next()) {
if (!SwcTreeNode::isVirtual(tn)) {
data.clear();
data << "" << tn->node.id << tn->node.type << tn->node.d << tn->node.x
<< tn->node.y << tn->node.z << tn->node.label << "";
if (SwcTreeNode::isBranchPoint(tn)) {
m_swcTreeNodeToType[tn] = SwcTreeNode::BRANCH_POINT;
m_swcTreeNodeToRow[tn] = branchPointRow++;
ZObjsItem *node = new ZObjsItem(data, tn, branchPointItem);
branchPointItem->appendChild(node);
} else if (SwcTreeNode::isRoot(tn) || SwcTreeNode::isLeaf(tn)) {
m_swcTreeNodeToType[tn] = SwcTreeNode::TERMINAL;
m_swcTreeNodeToRow[tn] = terminalRow++;
ZObjsItem *node = new ZObjsItem(data, tn, terminalItem);
terminalItem->appendChild(node);
}
}
}
}
}
示例3: computeLayerRange
std::vector<Swc_Tree_Node*> ZSwcRangeAnalyzer::getOutsideNode(
const ZSwcTree &host, const ZSwcTree &targetTree)
{
std::vector<Swc_Tree_Node*> nodeArray;
std::vector<ZEllipsoid> range = computeLayerRange(host);
ZSwcNodeCompositeSelector selector;
for (std::vector<ZEllipsoid>::iterator iter = range.begin();
iter != range.end(); ++iter) {
iter->setCenterX(0);
iter->setCenterY(0);
ZSwcNodeEllipsoidRangeSelector *childSelector =
new ZSwcNodeEllipsoidRangeSelector;
childSelector->setExpandFactor(3.0);
//iter->print();
/*
iter->setSize(iter->getXRadius() + sqrt(iter->getXRadius()),
iter->getYRadius() + sqrt(iter->getYRadius()),
iter->getZRadius() + sqrt(iter->getZRadius()) * 5);
*/
childSelector->setRange(*iter);
selector.addSelector(childSelector);
}
std::vector<ZEllipsoid> range2 = computeLayerRange(targetTree);
std::vector<ZPoint> pointArray = computerLayerCentroid(targetTree);
Swc_Tree_Node bufferNode;
targetTree.updateIterator(SWC_TREE_ITERATOR_DEPTH_FIRST);
for (Swc_Tree_Node *tn = targetTree.begin(); tn != NULL;
tn = targetTree.next()) {
if (SwcTreeNode::isRegular(tn)) {
bufferNode = *tn;
for (size_t i = 0; i < range2.size(); ++i) {
if (range2[i].containsPoint(
SwcTreeNode::x(tn), SwcTreeNode::y(tn), SwcTreeNode::z(tn))) {
SwcTreeNode::translate(&bufferNode, -pointArray[i].x(),
-pointArray[i].y(), 0.0);
break;
}
}
if (!selector.isSelected(&bufferNode)) {
nodeArray.push_back(tn);
}
}
}
return nodeArray;
}
示例4: featureArray
std::vector<double> ZSwcLayerShollFeatureAnalyzer::computeFeature(
Swc_Tree_Node *tn)
{
TZ_ASSERT(tn != NULL, "null pointer");
std::vector<double> featureArray(2, 0);
ZSwcTree tree;
tree.setDataFromNodeRoot(tn);
tree.updateIterator(SWC_TREE_ITERATOR_BREADTH_FIRST);
double baseZ = SwcTreeNode::z(tn);
featureArray[0] = baseZ;
Swc_Tree_Node *iter = tree.begin();
//while (SwcTreeNode::isRoot(iter)) {
while (SwcTreeNode::isVirtual(iter)) {
iter = tree.next();
}
double upZ = baseZ - m_layerMargin;
double downZ = baseZ + m_layerMargin;
for (; iter != NULL; iter = iter->next) {
Swc_Tree_Node *parent = iter->parent;
double minZ = iter->node.z;
double maxZ = parent->node.z;
if (minZ > maxZ) {
minZ = parent->node.z;
maxZ = iter->node.z;
}
/*
double r1 = SwcTreeNode::radius(iter);
double r2 = SwcTreeNode::radius(parent);
*/
if (minZ <= downZ && maxZ >= upZ) {
featureArray[1] += 1.0;
}
}
#ifdef _DEBUG_
if (featureArray[1] == 0.0) {
cout << "debug here" << endl;
}
#endif
tree.setData(NULL, ZSwcTree::FREE_WRAPPER);
return featureArray;
}
示例5:
pair<Swc_Tree_Node*, Swc_Tree_Node*> ZSwcConnector::identifyConnection(
const ZSwcPath &hook, const ZSwcTree &loop)
{
pair<Swc_Tree_Node*, Swc_Tree_Node*> conn;
if (!hook.empty()) {
loop.updateIterator(SWC_TREE_ITERATOR_DEPTH_FIRST);
Swc_Tree_Node *head = hook.front();
Swc_Tree_Node *tail = hook.back();
m_dist = Infinity;
for (const Swc_Tree_Node *tn = loop.begin(); tn != NULL; tn = loop.next()) {
if (SwcTreeNode::isRegular(tn)) {
double d = SwcTreeNode::scaledDistance(
head, tn, m_resolution.voxelSizeX(), m_resolution.voxelSizeY(),
m_resolution.voxelSizeZ());
if (d < m_dist) {
m_dist = d;
conn.first = head;
conn.second = const_cast<Swc_Tree_Node*>(tn);
}
if (tail != NULL) {
d = SwcTreeNode::scaledDistance(
tail, tn, m_resolution.voxelSizeX(), m_resolution.voxelSizeY(),
m_resolution.voxelSizeZ());
if (d < m_dist) {
m_dist = d;
conn.first = tail;
conn.second = const_cast<Swc_Tree_Node*>(tn);
}
}
}
}
}
return conn;
}
示例6: center
vector<double> ZSwcShollFeatureAnalyzer::computeFeature(Swc_Tree_Node *tn)
{
vector<SwcNodePair> distanceArray;
vector<double> crossingNumberArray;
ZPoint center(tn->node.x, tn->node.y, tn->node.z);
ZSwcTree sourceTree;
sourceTree.setDataFromNodeRoot(tn);
//cout << sourceTree.data()->root << endl;
sourceTree.updateIterator(SWC_TREE_ITERATOR_DEPTH_FIRST, false);
double maxLength = 0.0;
for (Swc_Tree_Node *tn = sourceTree.begin(); tn != sourceTree.end();
tn = sourceTree.next()) {
if (Swc_Tree_Node_Is_Regular(tn) && !Swc_Tree_Node_Is_Root(tn)) {
//Compute the central distances of the current node and its parent
SwcNodePair distancePair;
ZPoint v1(Swc_Tree_Node_X(tn), Swc_Tree_Node_Y(tn),
Swc_Tree_Node_Z(tn));
ZPoint v2(Swc_Tree_Node_X(tn->parent),
Swc_Tree_Node_Y(tn->parent),
Swc_Tree_Node_Z(tn->parent));
double d1 = v1.distanceTo(center);
double d2 = v2.distanceTo(center);
//Make sure that distancePair.first < distancePair.second
if (d1 > d2) {
distancePair.first = d2;
distancePair.second = d1;
distancePair.firstNode = tn->parent;
distancePair.secondNode = tn;
} else {
distancePair.first = d1;
distancePair.second = d2;
distancePair.firstNode = tn;
distancePair.secondNode = tn->parent;
}
//Calculate the distance between v1 and v2
double length = v1.distanceTo(v2);
if (length > maxLength) {
maxLength = length;
}
distanceArray.push_back(distancePair);
}
}
sort(distanceArray.begin(), distanceArray.end(),
SwcNodePairLessThan());
int startIndex = 0;
int endIndex = 0;
int lastIndex = int(distanceArray.size()) - 1;
for (double r = m_shollStart; r <= m_shollEnd; r += m_shollRadius) {
if (startIndex <= lastIndex) {
//Update start index and end index
while (distanceArray[startIndex].first < r - maxLength) {
startIndex++;
if (startIndex > lastIndex) {
break;
}
}
if (endIndex <= lastIndex) {
while (distanceArray[endIndex].first < r) {
endIndex++;
if (endIndex > lastIndex) {
break;
}
}
}
//Crossing test
int crossingNumber = 0;
if (startIndex <= lastIndex) {
for (int i = startIndex; i < endIndex; ++i) {
//If a crossing point is detected
if (distanceArray[i].second >= r) {
crossingNumber += 1.0;
}
}
}
crossingNumberArray.push_back(crossingNumber);
} else {
crossingNumberArray.push_back(0);
}
}
//cout << sourceTree.data()->root << endl;
sourceTree.setData(NULL, ZSwcTree::FREE_WRAPPER);
return crossingNumberArray;
}
示例7: select
ZSwcTreeNodeArray ZSwcNodeDistSelector::select(const ZSwcTree &tree) const
{
tree.setLabel(0);
ZSwcTreeNodeArray nodeArray;
tree.updateIterator(SWC_TREE_ITERATOR_DEPTH_FIRST);
Swc_Tree_Node *tn = tree.begin();
if (SwcTreeNode::isVirtual(tn)) {
tn = tree.next();
}
if (SwcTreeNode::isRegular(tn)) {
nodeArray.push_back(tn);
SwcTreeNode::setLabel(tn, 1);
}
for (; tn != NULL; tn = tree.next()) {
double dist = 0.0;
Swc_Tree_Node *parent = tn;
while (parent != NULL) {
dist += SwcTreeNode::length(parent);
if (dist > m_minDistance) {
nodeArray.push_back(tn);
SwcTreeNode::setLabel(tn, 1);
}
parent = SwcTreeNode::parent(parent);
if ((parent == NULL) || SwcTreeNode::label(parent) > 0) {
break;
}
}
}
#if 0
#ifdef _DEBUG_2
tree.print();
#endif
tree.updateIterator(SWC_TREE_ITERATOR_LEAF);
for (Swc_Tree_Node *tn = tree.begin(); tn != NULL; tn = tree.next()) {
nodeArray.push_back(tn);
SwcTreeNode::setLabel(tn, 2);
double dist = 0;
Swc_Tree_Node *parent = SwcTreeNode::parent(tn);
if (SwcTreeNode::label(parent) > 0 || SwcTreeNode::isVirtual(parent)) {
continue;
}
dist += SwcTreeNode::length(tn);
while (SwcTreeNode::isRegular(parent)) {
SwcTreeNode::setLabel(parent, 1);
if (dist >= m_minDistance) {
nodeArray.push_back(parent);
dist = 0;
SwcTreeNode::setLabel(parent, 2);
}
dist += SwcTreeNode::length(parent);
parent = SwcTreeNode::parent(parent);
if (SwcTreeNode::label(parent) > 0) {
break;
}
}
}
#endif
return nodeArray;
}