Home > Back-end >  To traverse the list, complains, beyond the vector boundary
To traverse the list, complains, beyond the vector boundary

Time:10-16

QList : : iterator k;
For (k=GridIndxe_List. The begin (); k !=GridIndxe_List. End (); + + k)
{
Cout & lt; <* k & lt; }

CodePudding user response:

Code to stick all

CodePudding user response:

This code is right, wrong is positioning in this code? You read the newspaper in the wrong is the STD: : vector, not a QList

CodePudding user response:

# include & lt; QtCore/QCoreApplication>

# include & lt; QList>
# include & lt; QMultiHash>
# include & lt; QString>
# include & lt; QFileDialog>
# include & lt; Iostream>
# include "Octree. H"
# include & lt; Photo/octree/octree. H>
using namespace std;

Int main ()
{
Photo: : PointCloud : : Ptr cloud (new photo: : PointCloud//photo: : PointCloud : : Ptr cloud_with_normals (new photo: : PointCloud
The string fileName="";
Float searchRadius=0.0 f;
Cout<& lt;" Please enter the file name: ";
Cin> The fileName.

if(! OpenLasFile (cloud, fileName))
{
Cout<& lt;" Point cloud open failure!" system("pause");
return -1;
}//the size of the 3 d mesh,
Const float Xscale3d=0.2 f;
Const float Yscale3d=0.2 f;
Const float Zscale3d=0.05 f;
//grid of rows and columns, layer number of
Int RowNum, ColNum, LayerNum;
//define two points on the extremum for storage,
Photo: : PointXYZI minPt maxPt;
//get coordinates extremum,
Photo: : getMinMax3D (* cloud, minPt, maxPt);
Double X_Max=maxPt. X;
Double X_Min=minPt. X;
Double Y_Max=maxPt. Y;
Double Y_Min=minPt. Y;
Double Z_Max=maxPt. Z;
Double Z_Min=minPt. Z;
Double xscale wasn't entirely=(X_Max - X_Min)/2;
Double yscale=(Y_Max - Y_Min)/2;
Double zscale=(Z_Max - Z_Min)/2;
/* cout & lt; <"Coordinate extremum as follows" & lt; Cout & lt; Cout & lt; Cout & lt; Cout & lt; Cout & lt; Cout & lt;
//calculate the whole grid of rows and columns, layer number, rounded
RowNum=int ((X_Max - X_Min)/xscale wasn't entirely + 1);
ColNum=int ((Y_Max - Y_Min)/yscale + 1);
LayerNum=int ((Z_Max - Z_Min)/zscale + 1);

/* cout & lt; <"The ranks of grid layer as follows" & lt; Cout & lt; Cout & lt; Cout & lt; //calculate each point cloud's ranks, */

//photo: : PointCloud : : Ptr pointCloud (new photo: : PointCloud//each point in the 3 d mesh, linear index number
QList GridIndxe_List;//point cloud linear index number in the grid list,
QList GridPoint_List;
QList Grid3dIndex_List;//not empty three-dimensional grid index number list
//hash keys linear index
QList HashKey_List;//hash keys list
QList HashKey_List_Fir;
Int the row, col, layer;
Int d_row, d_col d_layer;
Unsigned int TempIndex=0;
Int root_node_code=80;
//create a new object QMultiHash point3dHash, hash table point3dHash will represent the entire three-dimensional grid,
QMultiHash Point3dHash;
/* cout & lt; Cout & lt; Cout & lt; For (int nIndex=0; NIndex & lt; Cloud - & gt; Points. The size (); NIndex++)
{
The row=int ((cloud - & gt; Points [nIndex]. X-ray X_Min)/xscale wasn't entirely) + 1;
Col=int ((cloud - & gt; Points [nIndex] y - minPt. Y)/yscale) + 1;
Layer=int ((cloud - & gt; Points [nIndex]. Z - minPt. Z)/zscale) + 1;
If (col==1 & amp; & The row==1 & amp; & Layer==1)
{
TempIndex=root_node_code + 1;
}
If (col==2 & amp; & The row==1 & amp; & Layer==1)
{
TempIndex=root_node_code + 2;
}
If (col==1 & amp; & The row==2 & amp; & Layer==1)
{
TempIndex=root_node_code + 3;
}
If (col==2 & amp; & The row==2 & amp; & Layer==1)
{
TempIndex=root_node_code + 4;
}
If (col==1 & amp; & The row==1 & amp; & Layer==2)
{
TempIndex=root_node_code + 5;
}
If (col==2 & amp; & The row==1 & amp; & Layer==2)
{
TempIndex=root_node_code + 6;
}
If (col==1 & amp; & The row==2 & amp; & Layer==2)
{
TempIndex=root_node_code + 7;
}
If (col==2 & amp; & The row==2 & amp; & Layer==2)
{
TempIndex=root_node_code + 8;
}
GridIndxe_List. Append (TempIndex);//each point cloud in 3 d mesh, linear index number, the following table values with point cloud of inside the cloud values listed in the table below,
//to store your first nIndex a point cloud into linear index for TempIndex grid,
//cout & lt; Point3dHash. Insert (TempIndex, cloud - & gt; Points [nIndex]);

}
//const QList & My_list=Point3dHash. Values (3);//linear index set for all three of the inside of the grid point cloud, on mylist list,
//for each 3 d mesh, the strength of the point cloud extremum
Vector nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull