1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
int j=0;
for(size_t i = 0;i<lss.size();i++) {
int k = j+1;
matrix[j][0]=lss[i].v[0].x;
matrix[j][1]=lss[i].v[0].y;
matrix[j][2]=lss[i].v[0].z;
matrix[k][0]=lss[i].v[1].x;
matrix[k][1]=lss[i].v[1].y;
matrix[k][2]=lss[i].v[1].z;
j=j+2;
}
std::sort(matrix.begin(), matrix.end(), compare2);
matrix.erase(std::unique(matrix.begin(), matrix.end()),matrix.end());
matrix.push_back(std::vector<double>(3, 0));//add a new element at the end to close contour
int p = matrix.size()-1;//get adress of last element
//copy first element to end to close contour
matrix[p][0]=matrix[0][0];
matrix[p][1]=matrix[0][1];
matrix[p][2]=matrix[0][2];
int o=0;
//print vector matrix
for (size_t i=0; i<((matrix.size())); i++) {
int k=o+1;
x2=xdiff+matrix[o][0];
y2=ydiff+matrix[o][1];
z2=zdiff+matrix[o][2];
a2=xdiff+matrix[k][0];
b2=ydiff+matrix[k][1];
c2=zdiff+matrix[k][2];
fprintf(f, "X8=%f, Y8=%f, Z8=%f \n", x2,y2,z2);
fprintf(f, "X9=%f, Y9=%f, Z9=%f \n", a2,b2,c2);
o=o+2;
}
|