[Back to Blog](/blog) # New Automatic Level of Detail Selection for Progressive Meshes (Part 2 of 2)

Egor Slupko January 14, 2021 [\#Visualize](/blog/tag/visualize) [\#level of details](/blog/tag/level-details) [\#getting started](/blog/tag/getting-started)

<a class="a2a_button_facebook"></a><a class="a2a_button_twitter"></a><a class="a2a_button_linkedin"></a>

This is the second article in a series about automatic level of detail (LOD) selection. For the first article in the series, see [Part 1](https://www.opendesign.com/blog/2020/december/new-automatic-lod-selection-progressive-meshes-part-1-2).

Visualize SDK 21.4 supports automatic level of detail selection for OdTvProgressiveMeshData. You can enable it by calling:

```
virtual OdTvResult setAutoLODSelection( LODAutoSelectType autoSelectType ) = 0;
```

where autoSelectType is one of the LODAutoSelectType values:

- OdTvProgressiveMeshData::kAutoLOD\_None disables automatic LOD selection.
- OdTvProgressiveMeshData::kAutoLOD\_SqrInterpolation enables OdGiProgressiveMesh::kSqrInterpolation LOD selection.
- OdTvProgressiveMeshData::kAutoLOD\_SqrtInterpolation enables OdGiProgressiveMesh::kSqrtInterpolation LOD selection.
- OdTvProgressiveMeshData::kAutoLOD\_CustomInterpolation enables OdGiProgressiveMesh::kCustom LOD selection.

Interpolation parameters can be specified using the following methods:

```
virtual OdTvResult setAutoLODSelectMaxInterpolationThreshold( OdUInt32 nMax ) = 0;
virtual OdTvResult setAutoLODSelectMinInterpolationThreshold( OdUInt32 nMin ) = 0;
```

#### Visualize SDK custom LOD interpolation example

The OdTvCustomInterpolation class is used to provide a custom interpolation for the level of detail. Because Visualize SDK does not provide linear interpolation for the level of detail, it is a custom implementation:

```
class LinearInterpolation : public OdTvCustomInterpolation
{
public:
  virtual OdUInt32 interpolate( OdUInt32 minX, OdUInt32 minY, OdUInt32 maxX, OdUInt32 maxY, OdUInt32 x ) const
  {
    //interpolation: Y = A * x + B, where minY = A * minX + B and maxY = A * maxX + B
    double A = ( (double)( maxY - minY ) ) / ( (double)( maxX - minX ) );
    double B = maxY - A * maxX;
    return OdUInt32( A * x + B );
  }
};
…
LinearInterpolation* interp = new LinearInterpolation();
pPM->setAutoLODCustomInterpolation( interp );
pPM->setAutoLODSelection ( OdTvProgressiveMeshData::kAutoLOD_CustomInterpolation );
```

All properties of an OdTvProgressiveMeshData object are saved in a .vsf file. However, a pointer to OdTvCustomInterpolation cannot be saved. So, OdTvProgressiveMeshData calls the OdTvCustomInterpolation::interpolate() method for each value in the interval returned by getAutoLODSelectInterpolationThresholds() while saved. After loading, the OdTvProgressiveMeshData object uses this data to perform custom interpolation until a new pointer to the OdTvCustomInterpolation object is specified.

## Get started today

**Try ODA software free for 60 days.  
No risk, no credit card required.**

[Try for Free](https://www.opendesign.com/free-trial)
