Skip to content

Commit

Permalink
removed refine mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
edin45 committed Mar 22, 2023
1 parent de14341 commit 4a28d6a
Showing 1 changed file with 8 additions and 32 deletions.
40 changes: 8 additions & 32 deletions lib/scanningScreen/scanningScreenModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ScanningScreenModel {


String databasePath = "$outputPath${slash}temp${slash}database.db";
int totalStepNumber = 11;
int totalStepNumber = 10;

var shell = Shell();

Expand Down Expand Up @@ -220,9 +220,9 @@ class ScanningScreenModel {
}

double decimationFactorMeshRecon = 1;
int meshReconRetrys = 1;
int meshReconRetrys = 1;

while (!File("$outputPath${slash}temp${slash}model_surface.mvs").existsSync()) {
while (!File("$outputPath${slash}temp${slash}model_surface.mvs").existsSync()) {

if(decimationFactorMeshRecon == 1.0) {

Expand All @@ -244,54 +244,30 @@ class ScanningScreenModel {
}
meshReconRetrys++;

}
}

if (view.stop) {
stop(view);
return;
}

view.status = "10/$totalStepNumber Refining Mesh";
view.setState(() {});

int refineModelRetrys = 1;

while (!File("$outputPath${slash}temp${slash}model_refined.mvs").existsSync()) {

if(refineModelRetrys > 1) {
view.status = "10/$totalStepNumber Refining Mesh, failed, retrying (decimate: ${0.5+(refineModelRetrys/2)}, resolution-level: ${1+refineModelRetrys})";
view.setState(() {});
}

await runCommand("\"${openMvsPath}RefineMesh\" -i \"$outputPath${slash}temp${slash}model_surface.mvs\" -o \"$outputPath${slash}temp${slash}model_refined.mvs\" --decimate ${0.5+(refineModelRetrys/2)} --resolution-level ${1+refineModelRetrys} --working-folder \"$outputPath${slash}temp\"",[]);

if(refineModelRetrys == 20) {
view.status = "Failed, went wrong at refine mesh";
view.setState(() {});
return;
}

refineModelRetrys++;

}

view.status = "11/$totalStepNumber Texturing Mesh";
view.status = "10/$totalStepNumber Texturing Mesh";
view.setState(() {});

int texreconRetrys = 1;

while(!File("$outputPath${slash}textured.obj").existsSync()) {

if(texreconRetrys > 1) {
view.status = "11/$totalStepNumber Texturing Mesh, failed retrying with decimation-factor: ${1+((texreconRetrys-1)/2)}";
view.status = "10/$totalStepNumber Texturing Mesh, failed retrying with decimation-factor: ${1+((texreconRetrys-1)/2)}";
view.setState(() {});
// await runCommand("\"${resizeImagesPath}resizeImages\" -i \"${imagesPath}\" -r ${texrecon_retrys*0.7}", []);
await runCommand("\"${decimateMeshPath}decimateMesh\" -m \"$outputPath${slash}temp${slash}model_refined.ply\" -o \"$outputPath${slash}temp\" -t ${1+((texreconRetrys-1)/2)}", []);
await runCommand("\"${decimateMeshPath}decimateMesh\" -m \"$outputPath${slash}temp${slash}model_surface.ply\" -o \"$outputPath${slash}temp\" -t ${1+((texreconRetrys-1)/2)}", []);
}

print('working folder: $imagesPath');

await Process.run('"${texReconPath}texrecon" .${slash} "$outputPath${slash}temp${slash}${texreconRetrys > 1 ? "model_surface_decimated" : "model_refined"}.ply" "${outputPath}${slash}textured"',[],workingDirectory: texreconRetrys > 1 && false ? "${imagesPath}${slash}downres" : imagesPath).then((ProcessResult results) {
await Process.run('"${texReconPath}texrecon" .${slash} "$outputPath${slash}temp${slash}model_surface${texreconRetrys > 1 ? "_decimated" : ""}.ply" "${outputPath}${slash}textured"',[],workingDirectory: texreconRetrys > 1 && false ? "${imagesPath}${slash}downres" : imagesPath).then((ProcessResult results) {
String err = results.stderr.toString();
print('err: $err');
if (err.contains('Permission denied') || err.contains("PermissionDenied")) {
Expand Down

0 comments on commit 4a28d6a

Please sign in to comment.