Skip to content

Commit

Permalink
Exposes aggressiveness factor
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy committed Oct 23, 2018
1 parent 01d24b7 commit 80de58a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ make
| -outputFile | Path to PLY mesh output ||
| -maxVertexCount | Target number of vertices for the output mesh. This number is not always guaranteed to be reached. Defaults to `100000` | |
| -maxTileLength | Max length of a tile. Smaller values take longer to process but reduce memory usage by splitting the meshing process into tiles. Defaults to `1000`. | |
| -aggressiveness | Value between `1` and `10` that specifies how "aggressive" the mesh simplification process should be at each iteration. Higher values simplify the mesh more aggressively but can decrease the fidelity of the mesh. Defaults to `5`. | |
| -bandNum | Raster band # to use. Defaults to `1`. | |
| -rtc | Use Relative To Center (RTC) X/Y coordinates in the output PLY mesh. This can be useful since most 3D visualization software use floating coordinate precision to represent vertices and using absolute coordinates might lead to jittering artifacts. | |
| -verbose | Print verbose output. | |
10 changes: 6 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@ cmdLineParameter< char* >
cmdLineParameter< int >
MaxVertexCount( "maxVertexCount" ) ,
MaxTileLength( "maxTileLength" ) ,
Aggressiveness ( "aggressiveness" ) ,
BandNum ( "bandNum" );
cmdLineReadable
Rtc ( "rtc" ),
Verbose( "verbose" );

cmdLineReadable* params[] = {
&InputFile , &OutputFile ,
&MaxVertexCount , &MaxTileLength, &BandNum,
&MaxVertexCount , &MaxTileLength, &Aggressiveness, &BandNum,
&Rtc, &Verbose ,
NULL
};
Expand All @@ -90,6 +91,7 @@ void help(char *ex){
<< "\t -" << OutputFile.name << " <output PLY mesh>" << std::endl
<< "\t [-" << MaxVertexCount.name << " <target number vertices> (Default: 100000)]" << std::endl
<< "\t [-" << MaxTileLength.name << " <max length of a tile. Smaller values take longer to process but reduce memory usage by splitting the meshing process into tiles.> (Default: 1000)]" << std::endl
<< "\t [-" << Aggressiveness.name << " <simplification aggressiveness factor. Higher values simplify the mesh more aggressively but can decrease the fidelity of the mesh. ([1-10] Default: 5)]" << std::endl
<< "\t [-" << BandNum.name << " <Band number> (Default: 1)]" << std::endl
<< "\t [-" << Rtc.name << "]" << std::endl
<< "\t [-" << Verbose.name << "]" << std::endl;
Expand Down Expand Up @@ -288,9 +290,7 @@ void simplify(int target_count){
return;
}

const double AGRESSIVENESS = 5.0;

Simplify::simplify_mesh(target_count, AGRESSIVENESS, Verbose.set);
Simplify::simplify_mesh(target_count, static_cast<double>(Aggressiveness.value), Verbose.set);
if ( Simplify::triangles.size() >= start_size) {
std::cerr << "Unable to reduce mesh.\n";
exit(EXIT_FAILURE);
Expand Down Expand Up @@ -322,8 +322,10 @@ int main(int argc, char **argv) {
if( !InputFile.set || !OutputFile.set ) help(argv[0]);
if ( !MaxVertexCount.set ) MaxVertexCount.value = 100000;
if ( !MaxTileLength.set ) MaxTileLength.value = 1000;
if ( !Aggressiveness.set ) Aggressiveness.value = 5;
if ( !BandNum.set ) BandNum.value = 1;

Aggressiveness.value = std::min(10, std::max(1, Aggressiveness.value));
logWriter.verbose = Verbose.set;
logWriter.outputFile = "dem2mesh.txt";
logArgs(params, logWriter);
Expand Down

0 comments on commit 80de58a

Please sign in to comment.