Skip to content

Commit cea3e67

Browse files
committed
improve CleanMesh
1 parent fe0039e commit cea3e67

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

Common/Examples/CleanMesh.cxx

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
44
* Author : Sebastien Valette
55
*
6-
* This software is governed by the CeCILL-B license under French law and
7-
* abiding by the rules of distribution of free software. You can use,
8-
* modify and/ or redistribute the software under the terms of the CeCILL-B
9-
* license as circulated by CEA, CNRS and INRIA at the following URL
10-
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
6+
* This software is governed by the CeCILL-B license under French law and
7+
* abiding by the rules of distribution of free software. You can use,
8+
* modify and/ or redistribute the software under the terms of the CeCILL-B
9+
* license as circulated by CEA, CNRS and INRIA at the following URL
10+
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
1111
* or in the file LICENSE.txt.
1212
*
1313
* As a counterpart to the access to the source code and rights to copy,
1414
* modify and redistribute granted by the license, users are provided only
1515
* with a limited warranty and the software's author, the holder of the
1616
* economic rights, and the successive licensors have only limited
17-
* liability.
17+
* liability.
1818
*
1919
* The fact that you are presently reading this means that you have had
2020
* knowledge of the CeCILL-B license and that you accept its terms.
21-
* ------------------------------------------------------------------------ */
21+
* ------------------------------------------------------------------------ */
2222

2323
#include <vtkCommand.h>
2424
#include "vtkSurface.h"
@@ -28,9 +28,25 @@ int main( int argc, char *argv[] )
2828
{
2929
if (argc<3)
3030
{
31-
cout<<"Usage : CleanMesh input output"<<endl;
31+
cout<<"Usage : CleanMesh input output [-d 0/1]"<<endl;
3232
exit (1);
3333
}
34+
35+
36+
int display = 0; // defines whether there will be a graphic display (0: No, 1: yes)
37+
int ArgumentsIndex = 3;
38+
while (ArgumentsIndex < argc) {
39+
char* key = argv[ArgumentsIndex];
40+
char* value = argv[ArgumentsIndex + 1];
41+
42+
if (strcmp(key, "-d") == 0) {
43+
display = atoi(value);
44+
cout << "Display=" << display << endl;
45+
}
46+
47+
ArgumentsIndex += 2;
48+
}
49+
3450
vtkSurface *Mesh=vtkSurface::New();
3551
Mesh->CreateFromFile(argv[1]);
3652
vtkPolyData *OriginalMesh=vtkPolyData::New();
@@ -70,7 +86,7 @@ int main( int argc, char *argv[] )
7086
if (List->GetNumberOfIds()==1)
7187
NumberOfBoundaryEdges++;
7288
}
73-
if ((NumberOfNonManifoldEdges!=0)&&(NumberOfNonManifoldEdges+NumberOfBoundaryEdges>Rank))
89+
if (NumberOfNonManifoldEdges>0)
7490
{
7591
Mesh->DeleteFace(i);
7692
NumberOfCleanups++;
@@ -89,10 +105,14 @@ int main( int argc, char *argv[] )
89105
}
90106
}
91107

108+
92109
Mesh->CheckNormals();
93110
vtkSurface *CleanMesh=Mesh->CleanMemory();
94111
cout<<"Output : "<<endl;
95112
CleanMesh->DisplayMeshProperties();
113+
CleanMesh->WriteToFile(argv[2]);
114+
115+
if ( display == 0 ) exit( 0 );
96116

97117
RenderWindow *Window=RenderWindow::New();
98118
Window->SetInputData(OriginalMesh);

0 commit comments

Comments
 (0)