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

Classes

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

MRCUDA_API bool isCudaAvailable (int *driverVersion=nullptr, int *runtimeVersion=nullptr, int *computeMajor=nullptr, int *computeMinor=nullptr)
 
MRCUDA_API size_t getCudaAvailableMemory ()
 
MRCUDA_API size_t getCudaSafeMemoryLimit ()
 
MRCUDA_API size_t maxBufferSize (size_t availableBytes, size_t elementCount, size_t elementBytes)
 
MRCUDA_API size_t maxBufferSizeAlignedByBlock (size_t availableBytes, const Vector2i &blockDims, size_t elementBytes)
 
MRCUDA_API size_t maxBufferSizeAlignedByBlock (size_t availableBytes, const Vector3i &blockDims, size_t elementBytes)
 
MRCUDA_API Expected< DistanceMapdistanceMapFromContours (const Polyline2 &polyline, const ContourToDistanceMapParams &params)
 Computes distance of 2d contours according to ContourToDistanceMapParams (works correctly only when withSign==false)
 
MRCUDA_API size_t distanceMapFromContoursHeapBytes (const Polyline2 &polyline, const ContourToDistanceMapParams &params)
 Computes memory consumption of distanceMapFromContours function.
 
MRCUDA_API float3 fromVec (const Vector3f &v)
 
MRCUDA_API int3 fromVec (const Vector3i &v)
 
MRCUDA_API Matrix4 fromXf (const MR::AffineXf3f &xf)
 
MRCUDA_API Expected< DistanceMapcomputeDistanceMap (const Mesh &mesh, const MeshToDistanceMapParams &params, ProgressCallback cb={}, std::vector< MeshTriPoint > *outSamples=nullptr)
 
MRCUDA_API 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)
 
MRCUDA_API Expected< std::unique_ptr< PointCloudDataHolder > > copyDataFrom (const PointCloud &pc, bool copyNormals=false, const std::vector< Vector3f > *normals=nullptr)
 copy point cloud-related data to the GPU memory
 
MRCUDA_API size_t pointCloudHeapBytes (const PointCloud &pc, bool copyNormals=false, const std::vector< Vector3f > *normals=nullptr)
 return the amount of GPU memory required for MR::Cuda::PointCloudDataHolder
 
MRCUDA_API Expected< std::vector< MR::PointsProjectionResult > > findProjectionOnPoints (const PointCloud &pointCloud, const std::vector< Vector3f > &points, const FindProjectionOnPointsSettings &settings={})
 computes the closest points on point cloud to given points
 
MRCUDA_API size_t findProjectionOnPointsHeapBytes (const PointCloud &pointCloud, size_t pointsCount)
 returns the minimal amount of free GPU memory required for MR::Cuda::findProjectionOnPoints
 
MRCUDA_API Expected< MR::SimpleVolumeMinMax > pointsToDistanceVolume (const PointCloud &cloud, const MR::PointsToDistanceVolumeParams &params)
 makes SimpleVolume filled with signed distances to points with normals
 
MRCUDA_API Expected< void > pointsToDistanceVolumeByParts (const PointCloud &cloud, const MR::PointsToDistanceVolumeParams &params, std::function< Expected< void >(const SimpleVolumeMinMax &volume, int zOffset)> addPart, int layerOverlap)
 
MRCUDA_API 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)
 
MRCUDA_API BitSet findSkyRays (const Mesh &terrain, const VertCoords &samples, const VertBitSet &validSamples, const std::vector< MR::SkyPatch > &skyPatches, std::vector< MR::MeshIntersectionResult > *outIntersections=nullptr)
 
MRCUDA_API Expected< void > negatePicture (MR::Image &image)
 
MRCUDA_API void loadMRCudaDll ()
 

Variables

struct MR_BIND_IGNORE PointCloudDataHolder
 

Function Documentation

◆ computeDistanceMap()

MRCUDA_API 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()

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

Computes memory consumption of computeDistanceMap function.

◆ computeSkyViewFactor()

MRCUDA_API VertScalars MR::Cuda::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 )
nodiscard

computes relative radiation in each valid sample point by emitting rays from that point in the sky: the radiation is 1.0f if all rays reach the sky not hitting the terrain; the radiation is 0.0f if all rays do not reach the sky because they are intercepted by the terrain;

Parameters
outSkyRays- optional output bitset where for every valid sample #i its rays are stored at indices [i*numPatches; (i+1)*numPatches), 0s for occluded rays (hitting the terrain) and 1s for the ones which don't hit anything and reach the sky
outIntersections- optional output vector of MeshIntersectionResult for every valid sample point

◆ copyDataFrom()

MRCUDA_API Expected< std::unique_ptr< PointCloudDataHolder > > MR::Cuda::copyDataFrom ( const PointCloud & pc,
bool copyNormals = false,
const std::vector< Vector3f > * 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()

MRCUDA_API 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()

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

Computes memory consumption of distanceMapFromContours function.

◆ findProjectionOnPoints()

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

computes the closest points on point cloud to given points

◆ findProjectionOnPointsHeapBytes()

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

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

◆ findSkyRays()

MRCUDA_API BitSet MR::Cuda::findSkyRays ( const Mesh & terrain,
const VertCoords & samples,
const VertBitSet & validSamples,
const std::vector< MR::SkyPatch > & skyPatches,
std::vector< MR::MeshIntersectionResult > * outIntersections = nullptr )
nodiscard

In each valid sample point tests the rays from that point in the sky;

Returns
bitset where for every valid sample #i its rays are stored at indices [i*numPatches; (i+1)*numPatches), 0s for occluded rays (hitting the terrain) and 1s for the ones which don't hit anything and reach the sky
Parameters
outIntersections- optional output vector of MeshIntersectionResult for every valid sample point

◆ fromVec() [1/2]

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

◆ fromVec() [2/2]

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

◆ fromXf()

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

◆ getCudaAvailableMemory()

MRCUDA_API size_t MR::Cuda::getCudaAvailableMemory ( )

◆ getCudaSafeMemoryLimit()

MRCUDA_API size_t MR::Cuda::getCudaSafeMemoryLimit ( )

◆ isCudaAvailable()

MRCUDA_API bool MR::Cuda::isCudaAvailable ( int * driverVersion = nullptr,
int * runtimeVersion = nullptr,
int * computeMajor = nullptr,
int * computeMinor = nullptr )

◆ loadMRCudaDll()

MRCUDA_API void MR::Cuda::loadMRCudaDll ( )

◆ maxBufferSize()

MRCUDA_API size_t MR::Cuda::maxBufferSize ( size_t availableBytes,
size_t elementCount,
size_t elementBytes )

◆ maxBufferSizeAlignedByBlock() [1/2]

MRCUDA_API size_t MR::Cuda::maxBufferSizeAlignedByBlock ( size_t availableBytes,
const Vector2i & blockDims,
size_t elementBytes )

◆ maxBufferSizeAlignedByBlock() [2/2]

MRCUDA_API size_t MR::Cuda::maxBufferSizeAlignedByBlock ( size_t availableBytes,
const Vector3i & blockDims,
size_t elementBytes )

◆ negatePicture()

MRCUDA_API Expected< void > MR::Cuda::negatePicture ( MR::Image & image)

◆ pointCloudHeapBytes()

MRCUDA_API size_t MR::Cuda::pointCloudHeapBytes ( const PointCloud & pc,
bool copyNormals = false,
const std::vector< Vector3f > * normals = nullptr )

return the amount of GPU memory required for MR::Cuda::PointCloudDataHolder

◆ pointsToDistanceVolume()

MRCUDA_API Expected< MR::SimpleVolumeMinMax > MR::Cuda::pointsToDistanceVolume ( const PointCloud & cloud,
const MR::PointsToDistanceVolumeParams & params )

makes SimpleVolume filled with signed distances to points with normals

◆ pointsToDistanceVolumeByParts()

MRCUDA_API Expected< void > MR::Cuda::pointsToDistanceVolumeByParts ( const PointCloud & cloud,
const MR::PointsToDistanceVolumeParams & params,
std::function< Expected< void >(const SimpleVolumeMinMax &volume, int zOffset)> addPart,
int layerOverlap )

makes SimpleVolume filled with signed distances to points with normals populate the volume by parts to the given callback

Variable Documentation

◆ PointCloudDataHolder

struct MR_BIND_IGNORE MR::Cuda::PointCloudDataHolder