Files
UnrealEngineUWP/Engine/Plugins/Runtime/GeometryProcessing/Source/GeometryAlgorithms/Public/MinVolumeBox3.h
ryan schmidt 6437ecc4a1 GeometryCore: replace all usage of GeometryCore FVector3<T> with TVector<T>, remove FVector3<T> and GVector4<T>
#rb none
#rnx
#jira none
#preflight 614ce33574f7e70001ea822b

#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17617027 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v871-17566257)
#ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0

[CL 17617043 by ryan schmidt in ue5-release-engine-test branch]
2021-09-23 19:38:55 -04:00

67 lines
2.6 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 {
using namespace UE::Math;
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<TVector<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<TVector<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