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.
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.