Files
UnrealEngineUWP/Engine/Plugins/Experimental/GeometryProcessing/Source/GeometryAlgorithms/Public/MinVolumeBox3.h
Ryan Schmidt 8fd2394228 GeometryProcessing:
- Add MakeBoundsFromIndices() utility functions to TAxisAlignedBox3 to simplify computing bounding-box of point sets
- FDynamicMesh3::GetVertexFrame() can now take an externally-provided normal, and so now can be used without computing VertexNormals attribute
- Add FModuloIteration to IteratorUtil for doing quasi-random-ish iterations over index ranges
- Add CollectVertexPositions() to MeshIndexUtil.h, for creating arrays/sets of vertex positions as a one-liner
- Add FMeshWeights::CotanWeightsBlendSafe() to support cotan-based smoothing of arbitrary properties
- Add TMinVolumeBox3::SolveSubsample() which will (quasi-randomly) subsample a set of the input points to reduce cost of box computation
#rb david.hill
#rnx
#jira none

[CL 16450731 by Ryan Schmidt in ue5-main branch]
2021-05-25 12:13:39 -04:00

65 lines
2.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "VectorTypes.h"
#include "OrientedBoxTypes.h"
#include "Templates/PimplPtr.h"
class FProgressCancel;
namespace UE {
namespace Geometry {
template <typename RealType> struct TMinVolumeBox3Internal;
/**
* Calculate a Minimal-Volume Oriented Box for a set of 3D points.
* This internally first computes the Convex Hull of the point set.
* The minimal box is then guaranteed to be aligned with one of the faces of the convex hull.
* Note that this is increasingly expensive as the Convex Hull face count increases.
*/
template<typename RealType>
class TMinVolumeBox3
{
public:
/**
* Calculate the minimal box for the given point set.
* @param NumPoints number of points in the set, ie GetPointFunc can be called for any integer in range [0...NumPoints)
* @param GetPointFunc function that returns a 3D point for a valid Index
* @param bUseExactBox If true, high-precision number types are used for the minimal-box calculation, rather than doubles. This is *much* slower but more accurate (but not recommended).
* @return true if minimal box was found
*/
bool Solve(int32 NumPoints, TFunctionRef<FVector3<RealType>(int32)> GetPointFunc, bool bUseExactBox = false, FProgressCancel* Progress = nullptr);
/**
* Calculate the minimal box for a Subsampling of MaxPoints points of a point set
* @param NumPoints number of points in the set, ie GetPointFunc can be called for any integer in range [0...NumPoints)
* @param NumSamplePoints maximum number of points to sample from NumPoints. Currently a random-ish subset is selected.
* @param GetPointFunc function that returns a 3D point for a valid Index
* @param bUseExactBox If true, high-precision number types are used for the minimal-box calculation, rather than doubles. This is *much* slower but more accurate (but not recommended).
* @return true if minimal box was found
*/
bool SolveSubsample(int32 NumPoints, int32 NumSamplePoints, TFunctionRef<FVector3<RealType>(int32)> GetPointFunc, bool bUseExactBox = false, FProgressCancel* Progress = nullptr);
/** @return true if minimal box is available */
bool IsSolutionAvailable() const;
/** @return minimal box in BoxOut */
void GetResult(TOrientedBox3<RealType>& BoxOut);
protected:
void Initialize(int32 NumPoints, bool bUseExactBox);
TPimplPtr<TMinVolumeBox3Internal<RealType>> Internal;
};
typedef TMinVolumeBox3<float> FMinVolumeBox3f;
typedef TMinVolumeBox3<double> FMinVolumeBox3d;
} // end namespace UE::Geometry
} // end namespace UE