MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::Cuda Namespace Reference

Classes

class  ComputePointsToDistanceVolume
 CUDA implementation of IComputePointsToDistanceVolumeByParts. More...
class  ComputeToolDistance
 CUDA implementation of tool distance computation. More...
struct  DeviceInfo
class  FastWindingNumber
class  PointsProjector
 CUDA-backed implementation of IPointsProjector. More...
class  PointsToMeshProjector
 Computes the closest point on mesh to each of given points on GPU. It caches data that necessary for computing. More...
class  Polyline2DataHolder
 Helper class to manage the GPU memory-backed buffers for Polyline2 data. More...
class  Polyline3DataHolder
 Helper class to manage the GPU memory-backed buffers for Polyline3 data. More...

Functions

Expected< DeviceInfo > getDeviceInfo ()
 Returns an error if CUDA is not available.
bool isCudaAvailable (int *driverVersion=nullptr, int *runtimeVersion=nullptr, int *computeMajor=nullptr, int *computeMinor=nullptr)
size_t getCudaAvailableMemory ()
 Returns available GPU memory in bytes.
size_t getCudaSafeMemoryLimit ()
 Returns maximum safe amount of free GPU memory that will be used for dynamic-sized buffers.
size_t maxBufferSize (size_t availableBytes, size_t elementCount, size_t elementBytes)
 Returns maximum buffer size in elements that can be allocated with given memory limit.
size_t maxBufferSizeAlignedByBlock (size_t availableBytes, const Vector2i &blockDims, size_t elementBytes)
size_t maxBufferSizeAlignedByBlock (size_t availableBytes, const Vector3i &blockDims, size_t elementBytes)
Expected< DistanceMap > distanceMapFromContours (const Polyline2 &polyline, const ContourToDistanceMapParams &params)
 Computes distance of 2d contours according to ContourToDistanceMapParams (works correctly only when withSign==false)
size_t distanceMapFromContoursHeapBytes (const Polyline2 &polyline, const ContourToDistanceMapParams &params)
 Computes memory consumption of distanceMapFromContours function.
float3 fromVec (const Vector3f &v)
 copy from CPU to GPU structs
int3 fromVec (const Vector3i &v)
Matrix4 fromXf (const MR::AffineXf3f &xf)
Expected< DistanceMap > computeDistanceMap (const Mesh &mesh, const MeshToDistanceMapParams &params, ProgressCallback cb={}, std::vector< MeshTriPoint > *outSamples=nullptr)
size_t computeDistanceMapHeapBytes (const Mesh &mesh, const MeshToDistanceMapParams &params, bool needOutSamples=false)
 Computes memory consumption of computeDistanceMap function.
template<typename BufferType, typename InputIt, typename GPUFunc, typename CPUFunc>
Expected< void > cudaPipeline (BufferType init, InputIt begin, InputIt end, GPUFunc gpuFunc, CPUFunc cpuFunc)
Expected< std::unique_ptr< PointCloudDataHolder > > copyDataFrom (const PointCloud &pc, bool copyNormals=false, const VertNormals *normals=nullptr)
 copy point cloud-related data to the GPU memory
size_t pointCloudHeapBytes (const PointCloud &pc, bool copyNormals=false, const VertNormals *normals=nullptr)
 return the amount of GPU memory required for PointCloudDataHolder
Expected< std::vector< MR::PointsProjectionResult > > findProjectionOnPoints (const PointCloud &pointCloud, const VertCoords &points, const FindProjectionOnPointsSettings &settings={})
 computes the closest points on point cloud to given points
size_t findProjectionOnPointsHeapBytes (const PointCloud &pointCloud, size_t pointsCount)
 returns the minimal amount of free GPU memory required for MR::Cuda::findProjectionOnPoints
Expected< MR::SimpleVolumeMinMax > pointsToDistanceVolume (const PointCloud &cloud, const MR::PointsToDistanceVolumeParams &params)
 makes SimpleVolume filled with signed distances to points with normals
Expected< void > pointsToDistanceVolumeByParts (const PointCloud &cloud, const MR::PointsToDistanceVolumeParams &params, std::function< Expected< void >(const SimpleVolumeMinMax &volume, int zOffset)> addPart, int layerOverlap)
size_t pointsToDistanceVolumeMemory (const PointCloud &cloud, const Vector3i &dims, const VertNormals *ptNormals)
 returns the minimal amount of free GPU memory required to build a distance volume with given dimensions
VertScalars computeSkyViewFactor (const Mesh &terrain, const VertCoords &samples, const VertBitSet &validSamples, const std::vector< MR::SkyPatch > &skyPatches, BitSet *outSkyRays=nullptr, std::vector< MR::MeshIntersectionResult > *outIntersections=nullptr)
BitSet findSkyRays (const Mesh &terrain, const VertCoords &samples, const VertBitSet &validSamples, const std::vector< MR::SkyPatch > &skyPatches, std::vector< MR::MeshIntersectionResult > *outIntersections=nullptr)
Expected< void > negatePicture (MR::Image &image)
 This function inverts Color value (255 - value in each channel except alpha)
void loadMRCudaDll ()
 call this function to load MRCuda shared library

Function Documentation

◆ computeDistanceMap()

Expected< DistanceMap > MR::Cuda::computeDistanceMap ( const Mesh & mesh,
const MeshToDistanceMapParams & params,
ProgressCallback cb = {},
std::vector< MeshTriPoint > * outSamples = nullptr )

computes distance (height) map for given projection parameters using float-precision for finding ray-mesh intersections, which is faster but less reliable

◆ computeDistanceMapHeapBytes()

size_t MR::Cuda::computeDistanceMapHeapBytes ( const Mesh & mesh,
const MeshToDistanceMapParams & params,
bool needOutSamples = false )

Computes memory consumption of computeDistanceMap function.

◆ copyDataFrom()

Expected< std::unique_ptr< PointCloudDataHolder > > MR::Cuda::copyDataFrom ( const PointCloud & pc,
bool copyNormals = false,
const VertNormals * normals = nullptr )

copy point cloud-related data to the GPU memory

◆ cudaPipeline()

template<typename BufferType, typename InputIt, typename GPUFunc, typename CPUFunc>
Expected< void > MR::Cuda::cudaPipeline ( BufferType init,
InputIt begin,
InputIt end,
GPUFunc gpuFunc,
CPUFunc cpuFunc )

Process data by blocks alternately by GPU and CPU. GPUFunc is executed in a separate thread. Both GPUFunc and CPUFunc must satisfy the following signature: MR::Expected<void> (*funcName) ( BufferType& buffer, InputIt::value_type value )

◆ distanceMapFromContours()

Expected< DistanceMap > MR::Cuda::distanceMapFromContours ( const Polyline2 & polyline,
const ContourToDistanceMapParams & params )

Computes distance of 2d contours according to ContourToDistanceMapParams (works correctly only when withSign==false)

◆ distanceMapFromContoursHeapBytes()

size_t MR::Cuda::distanceMapFromContoursHeapBytes ( const Polyline2 & polyline,
const ContourToDistanceMapParams & params )

Computes memory consumption of distanceMapFromContours function.

◆ findProjectionOnPoints()

Expected< std::vector< MR::PointsProjectionResult > > MR::Cuda::findProjectionOnPoints ( const PointCloud & pointCloud,
const VertCoords & points,
const FindProjectionOnPointsSettings & settings = {} )

computes the closest points on point cloud to given points

◆ findProjectionOnPointsHeapBytes()

size_t MR::Cuda::findProjectionOnPointsHeapBytes ( const PointCloud & pointCloud,
size_t pointsCount )

returns the minimal amount of free GPU memory required for MR::Cuda::findProjectionOnPoints

◆ fromVec() [1/2]

float3 MR::Cuda::fromVec ( const Vector3f & v)

copy from CPU to GPU structs

◆ fromVec() [2/2]

int3 MR::Cuda::fromVec ( const Vector3i & v)

◆ fromXf()

Matrix4 MR::Cuda::fromXf ( const MR::AffineXf3f & xf)

◆ pointCloudHeapBytes()

size_t MR::Cuda::pointCloudHeapBytes ( const PointCloud & pc,
bool copyNormals = false,
const VertNormals * normals = nullptr )

return the amount of GPU memory required for PointCloudDataHolder