本文整理汇总了C++中ZSwcTree::setDataFromNodeRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ ZSwcTree::setDataFromNodeRoot方法的具体用法?C++ ZSwcTree::setDataFromNodeRoot怎么用?C++ ZSwcTree::setDataFromNodeRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZSwcTree
的用法示例。
在下文中一共展示了ZSwcTree::setDataFromNodeRoot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSwcByRegionSampling
ZSwcTree* ZSwcGenerator::createSwcByRegionSampling(
const ZVoxelArray &voxelArray, double radiusAdjustment)
{
#ifdef _DEBUG_2
voxelArray.print();
#endif
ZDoubleVector voxelSizeArray(voxelArray.size());
const std::vector<ZVoxel> &voxelData = voxelArray.getInternalData();
//Retrieve voxel size
for (size_t i = 0; i < voxelSizeArray.size(); ++i) {
voxelSizeArray[i] = -voxelData[i].value();
}
std::vector<int> indexArray;
voxelSizeArray.sort(indexArray);
std::vector<bool> sampled(voxelArray.size(), true);
for (size_t i = 1; i < voxelArray.size(); ++i) {
size_t currentVoxelIndex = indexArray[i];
const ZVoxel ¤tVoxel = voxelData[currentVoxelIndex];
for (size_t j = 0; j < i; ++j) {
size_t prevVoxelIndex = indexArray[j];
if (sampled[prevVoxelIndex]) {
const ZVoxel &prevVoxel = voxelData[prevVoxelIndex];
double dist = currentVoxel.distanceTo(prevVoxel);
if (dist < prevVoxel.value()) {
sampled[currentVoxelIndex] = false;
break;
}
}
}
}
Swc_Tree_Node *prevTn = NULL;
for (size_t i = 0; i < voxelArray.size(); ++i) {
if (sampled[i]) {
Swc_Tree_Node *tn = SwcTreeNode::makePointer();
SwcTreeNode::setPos(
tn, voxelData[i].x(), voxelData[i].y(), voxelData[i].z());
SwcTreeNode::setRadius(
tn, voxelData[i].value() + radiusAdjustment);
Swc_Tree_Node_Set_Parent(tn, prevTn);
prevTn = tn;
}
}
ZSwcTree *tree = new ZSwcTree;
tree->setDataFromNodeRoot(prevTn);
return tree;
}
示例2: featureArray
std::vector<double> ZSwcTrunkSizeFeatureAnalyzer::computeFeature(Swc_Tree_Node *tn)
{
ZSwcTree tree;
tree.setDataFromNodeRoot(tn);
tree.labelTrunkLevel(m_trunkAnalyzer);
vector<double> featureArray(1);
featureArray[0] =
SwcTreeNode::downstreamSize(tn, SwcTreeNode::labelDifference);
return featureArray;
}
示例3: 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;
}
示例4: 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;
}