Open lukkio88 opened 4 years ago
Hi!
No, no command line options are implemented at this time.
Could certainly be done though. Just a matter of writing some argument-parsing code and calling the same methods the buttons in the UI call.
Can you just point out what's the main function (not the void main(...)
but the function that actually does the cutting) and how do I pass the options (like the optimizer options and everything)? So I have a starting point.
Thank you
Sure! The project structure is a bit hard to follow here; it's been extracted from a multi-project repo which is no longer in use :sweat_smile: I'd love to refactor all this, but just don't have the time at the moment.
The main class is the EulerianShapeOptimizer, which has all the parameters and main logic. It's not quuiiiite as simple as calling a single function in EulerianShapeOptimizer
to generate results---you will need to call a small handful of functions to mimic the way the GUI interacts with the class.
You can see the GUI interacting with the class here. That also includes the headers you should need for any other functions.
Off the top of my head, you'll want something like:
Geometry<Euclidean> geometry = /* load your geometry from file */
EulerianShapeOptimizer shapeOpt(geometry);
// set some parameters
shapeOpt.weightLengthRegularization = 1.0;
shapeOpt.weightHenckyDistortion = 3.0;
// initialize with normal clustering
VertexData<LabelVec> normalPhi = normalClusterMSDF(geometry, PI/3.0);
shapeOpt.setState(normalPhi);
shapeOpt.iIter = 0;
// step the optimization
for(size_t iter = 0; iter < 300; iter++) {
shapeOpt.doStep();
}
// save resulting patches
CornerData<Vector2> paramCoords;
Geometry<Euclidean>* cutGeodesicGeom = shapeOpt.getGeodesicFlattenedGeometry(paramCoords);
FaceData<int> faceComponents = computeFaceComponents(cutGeodesicGeom, paramCoords);
WavefrontOBJ::write("out.obj", *cutGeodesicGeom, paramCoords);
(I haven't run that code, so it almost certainly has problems, but hopefully it can get you started)
Thank you! Let me give it a go and I'll get back to you.
Hi, this was really helpful. Thank you so much, one very last question... Is there a way to normalize the texture coordiantes generated in the interval [0,1]? I know this is obviously an easy thing to do but maybe you've an API for this already.
Thank you
Great! Glad it's been helpful.
It doesn't look like there's any built-in function here for normalizing to the unit interval. But as you say that shouldn't be too difficult!
Best, Nick
Hi, is it possible to run your tool from command line without passing through the GUI?