本帖最后由 firescript 于 2024-2-12 10:10 编辑
//读取STL文件
float * STL_X = NULL;
float * STL_Y = NULL;
float * STL_Z = NULL;
unsigned long STL_NB = 0; //STL_NB个点
ReadSTLFile(pathName,STL_X,STL_Y,STL_Z,STL_NB);
//记录STL_X/Y/Z中不重复的点为STL_New_X/Y/Z
float * STL_New_X = new float[STL_NB];
float * STL_New_Y = new float[STL_NB];
float * STL_New_Z = new float[STL_NB];
STL_New_X[0] = STL_X[0];
STL_New_Y[0] = STL_Y[0];
STL_New_Z[0] = STL_Z[0];
int STL_New_NB = 1; //第一个点肯定不重复
//ioNoVertices记录STL_NB个点在STL_New_X/Y/Z中的索引
int * ioNoVertices = new int[STL_NB];
ioNoVertices[0] = 1; //索引为1
for (int i=1;i<STL_NB;i++)
{
CATBoolean isOK = CATTrue;
for (int j=0;j<STL_New_NB;j++)
{
if( (STL_X[i]==STL_New_X[j]) && (STL_Y[i]==STL_New_Y[j]) && (STL_Z[i]==STL_New_Z[j]) )
{
isOK = CATFalse;
ioNoVertices[i] = j+1;
break;
}
}
if(isOK == CATTrue)
{
STL_New_X[STL_New_NB] = STL_X[i];
STL_New_Y[STL_New_NB] = STL_Y[i];
STL_New_Z[STL_New_NB] = STL_Z[i];
STL_New_NB++;
ioNoVertices[i] = STL_New_NB;
}
}
请教这个算法如何多线程处理。
|