Forums » Forum général »
Creating a scene out of non sorted indices.
Added by Hackenberg Jan over 8 years ago
Hi
I do not know if this problem can occur at a lot of places. Inside my pipeline I slice the cloud into two. I process one and merge the result with the second again. While both result of processed slice one as well as slice two have still sorted indices contained, the merged cloud does not have ordered indices anymore, if my steps add first all indices of processed slice 1 and then the indices of slice two. I took the code how to merge from ONF_StepMergeScenesByModality. If I pass this unsorted cloud which is supposed to be sorted to another step a simple iteration can result in an endless loop from what my qDebug() output tells me. Endless means in the order of cloudsize x cloudsize.
The solution is to add instead of adding to my CT PointCloudIndex
const CT_AbstractPointCloudIndex *pointCloudIndex = itemCpy_cloud_in->getPointCloudIndex();
I add the index to a std::vector<size_t> temp, call std::sort(temp.begin(),temp.end()) , then iterate over the sorted vector temp and add member by member finally to pointCloudIndex. To be honest I do not know if CT has a sorting solution inbuild. I did not find one at least after some research. If there is not a sorting possibility for CT_AbstractPointCloudIndex a public wrap function for this would be nice if possible. It is for my time constraints too deep in core.
The theory behind: CT has a vector of points with indices 1,2,3,4. Without breaking CT Philosophie it should be possible to produce two subvectors 1,3 and 2,4. If I merge like I found in the named step, I get 1,3,2,4. I further assume that the Iterator I use assumes a sorted vec. If not std or whatever is behind it seems to provide the brute force solution to iterate over the whole vector to find next(). For iterating over n points now nxn operations are needed, for the sorted one only n. My debug at least produced for each 1000 processed points one line every 10-30 seconds which would be explainable if what I write is true for 160 Mio Points.
I hope this is considered helpful, if it is a workaround whcih can be prevented in better usage let me know.
Jan
Replies (1)
RE: Creating a scene out of non sorted indices. - Added by Piboule Alexandre over 8 years ago
Hello,
For your output cloud you can use following syntaxe :
CT_PointCloudIndexVector *outCloudIndex = new CT_PointCloudIndexVector(); outCloudIndex->setSortType(CT_PointCloudIndexVector::NotSorted); // optimization // here add the indices to the cloud outCloudIndex outCloudIndex->setSortType(CT_PointCloudIndexVector::SortedInAscendingOrder); // this will sort the indices
I hope it helps.
Alexandre.