avaxman / Directional

A library for Directional Field Synthesis, Design, and Processing.
176 stars 29 forks source link

505_Meshing rawfield computation for N=4 #55

Closed alshef closed 2 years ago

alshef commented 2 years ago

Hello,

I am trying to use code from 505_Meshing tutorial example to get mesh. The code from the repository works with tutorial data, but I do not understand how vase-4.rawfield was computed and how to run it with my own data.

To get vase-4.rawfield I tried to use code from 301_PowerFields (write_raw_field function) with vase.off, but the write function returned .rawfield with all zeros.

Could you please clarify how I can get the same vase-4.rawfield file as in 505 example, because I am new in geometry processing? As a result, I would like to be able to run the code from 505_Meshing with my own data.

avaxman commented 2 years ago

Hi, the processing is not exactly the same for both examples. But could you be a bit specific how you got the all zero example?

kieganlenihan commented 2 years ago

@avaxman I am having the same problem. The following block of code in tutorial/301_PowerFields is the culprit:

//Ghost mesh just showing field, to compare against constraints
  Eigen::VectorXcd constraintField = Eigen::VectorXcd::Zero(powerFieldHard.rows());
  for (int i=0;i<constFaces.size();i++)
    constraintField(constFaces(i))=powerFieldHard(constFaces(i));
  directional::power_to_raw(V, F,constraintField, N, rawField);

This block of code makes every entry in the output field, which is generated when running /tutorial/build/301_PowerFields and pressing w, 0 or -0. The problem however, is that commenting this block of code out is useless, because the resulting field will always yield a segfault when trying to create a quad mesh in 505_Meshing.

How to repeat the problem: 1) build all tutorials 2) execute 301_PowerFields with ./301_PowerFields_bin in the command line. 3) Comment out lines 88 and 89 in tutorial/505_Meshing 4) Change line 22 in tutorial/505_Meshing to #define NUM_N 1 5) Change line 89 in tutorial/505_Meshing to

directional::read_raw_field(TUTORIAL_SHARED_PATH "/rocker-arm2500-4.rawfield", N[0], rawField[0]);

6) Change line 117 in tutorial/505_Meshing to

hedra::polygonal_write_OFF(TUTORIAL_SHARED_PATH "/rocker-"+std::to_string(N[i])+"-generated.off", VPolyMesh[i], DPolyMesh[i], FPolyMesh[i]);

This will lead to a segfault, which means (with the current implementation of Directional), it is impossible to create ones own quad meshes

avaxman commented 2 years ago

Right. The issue is indeed that I overran the rawField variable in 301. I fixed it, and I then managed to run the written result in 501 as is (except changing the file/field loading names in 501, as follows). Sorry for the long time it took:

Screenshot 2022-06-20 at 12 12 30 Screenshot 2022-06-20 at 12 11 27 Screenshot 2022-06-20 at 12 11 23

The new code needed is (not part of the canonical directional): igl::readOBJ(TUTORIAL_SHARED_PATH "/rocker-arm2500.obj", VMeshWhole, FMeshWhole); directional::read_raw_field("/Users/amirvaxman/Directional/tutorial/shared/rocker-arm2500.rawfield", N, rawField); Should replace lines 96--97.