I have an input data from Upstream calculation. A punch of triangles not arranged in a sequence. Well I would like to divide them into different regions using x-axis values.
Assume triangle vertex (v1, v2, v3) for which i have v1 (x1, y1, z1) likewise for other triangles too.
I want to categorise them into three regions
for (int i=1; i<=Numberoftriagles, i++)
{
// some calculation with triangles vertex
while (x1<L1){
cout<< triangle << "1";
}
while (L1<x1<L2){
cout<< triangle << "2";
}
while (x1>L2){
cout<< triangle << "3";
}
}
Here my difficult is, I need to write two text file, which i couldn't do it yet
First i have multiple surfaces! I triangulate this surfaces into triangles and then from triangles, i extracted the three vertices. Then i used this verticies to calculate normal and want to export to text file. The text file should be two (one: for triangle normals and second: for range label). Well the code is very large starting from beginning and i used some other libraries also.
But my specific problem is to write the two text files!
Here i will explain it by example!
say i have many triangles of an object, i want to write their normal and corresponding label (which shows the region based on x-value of the triangle)
Now the code should look like as follow!
for (int i=1; i<=Numberoftriagles, i++)
{
// calculation of normal
while (x1<L1){
out1<< trianglenormal ;
out2<< "1";
}
while (L1<x1<L2){
out1<< trianglenormal;
out2 << "2";
}
while (x1>L2){
out1<< trianglenormal;
out2 << "3";
}
}
I tried the above code! It works! I could create two separate text files which is not organized
For example
you can either sort the output before you write to the files or you need to use stream pointers to tell where to write and flages to tell don't overwrite the already existing data.
to make that pointer/flag stuff clear:
lets say you have
1
1
2
2
and you want to add "1".
get the pointer after the "1"s, where the "2"s start, and set the flag, so the "2"s don't get overwritten.