dmc icon indicating copy to clipboard operation
dmc copied to clipboard

How to provide input file

Open shalinsirwani opened this issue 7 years ago • 11 comments

How do I provide input file .

shalinsirwani avatar Aug 17 '19 16:08 shalinsirwani

Could you tell me what you want to input?

This algorithm is for meshing the function represented by Signed Distance Field. You need to implement the function which you want to represent.

planaria avatar Aug 17 '19 17:08 planaria

mri.raw.txt This is a raw file format remove .txt extension from it. It simply stores data as height X width X images(slices)

Example :- As this file contains 200 x 160 x 160

You can read data using fgetc () type of c language functions. I mean iterating 200 x 160 x 160 times you get value of 8 bits each time you read a character. I mean 0 to 255 in integer type.

So this is a sample file format , how do I process it in your tool???

shalinsirwani avatar Aug 18 '19 04:08 shalinsirwani

I guessed this data was not expressed in SDF (Signed Distance Field). This library does not have an interface to handle this data format directly. You need to define the SDF and implement some codes that builds the SDF from data.

As an example, this is the code I wrote with many guesses. Please note that this code is not strict. https://gist.github.com/planaria/a95d78d07922357544fbfaf2c15e7d7a

mri

planaria avatar Aug 18 '19 08:08 planaria

I forgot to push the modified code, so you will need to update this library to use the example code.

planaria avatar Aug 18 '19 08:08 planaria

Thanks for providing result . One more question . How much time it takes to process this file.???

shalinsirwani avatar Aug 18 '19 10:08 shalinsirwani

it takes few seconds in my environment.

planaria avatar Aug 18 '19 11:08 planaria

Thanks for sharing your code, @planaria.

Any guidance on how to format the SDF please? (3D std array?) That would be really helpful. Reading the main.cpp, it seems the "test_object" structure is the one creating the SDF but I could not fully understand what it does.

Also, can the process hanlde a binary array instead of SDF? If not, how to transform it? (I mean if what matters is the sign difference, would it be enough to put all 0 values to -1 for example?).

abdoulayediak avatar Jan 18 '23 00:01 abdoulayediak

SDF is just a function, there is no file format. The input to this library is a function, and you must create that function yourself.

planaria avatar Jan 18 '23 00:01 planaria

Hmm... it seems very obvious to you, but at least for me, it is not. For me an SDF is a 3x3 array of signed values. So when you say function, I imagine a function that writes such an array on the fly, perhaps?

If it is a case, then please a very basic example of what it should look like will be of great help, or just point out to me where an example of such a function is implemented in the code.

Thanks.

abdoulayediak avatar Jan 18 '23 02:01 abdoulayediak

SDF is not a 3x3 array. SDF is Signed Distance Fuction(Field), a function that takes a point and returns a signed distance. https://en.wikipedia.org/wiki/Signed_distance_function

The following example takes a point p and returns a signed distance. https://github.com/planaria/dmc/blob/master/src/main.cpp

auto cube1 = 1.0 - p.norm_l_inf();
auto cube2 = 1.0 - (p - dmc::vector<T, 3>(0.5, 0.5, 0.5)).norm_l_inf();

return std::min(cube1, -cube2);

If you want to use a 3x3 array as input, you must implement this as a function. The implementation is non-trivial and depends on how you define the function with the 3x3 array.

planaria avatar Jan 18 '23 04:01 planaria

Ok, it is getting clearer now. If I have an input mesh for example, I should provide to this library a function that will return the signed distance from a given point to that mesh.

Thanks for your quick replies, I will give it a try.

abdoulayediak avatar Jan 18 '23 04:01 abdoulayediak