MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / calcFromVector

Method calcFromVector

source/MRCuda/MRCudaFastWindingNumber.cpp:87–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87Expected<void> FastWindingNumber::calcFromVector( std::vector<float>& res, const std::vector<Vector3f>& points, float beta, FaceId skipFace, const ProgressCallback& cb )
88{
89 MR_TIMER;
90 return prepareData_( subprogress( cb, 0.0, 0.5f ) ).and_then( [&]() -> Expected<void>
91 {
92 const auto totalSize = points.size();
93 const auto bufferSize = maxBufferSize( getCudaSafeMemoryLimit(), totalSize, sizeof( float ) + sizeof( float3 ) );
94
95 DynamicArray<float3> cudaPoints;
96 CUDA_LOGE_RETURN_UNEXPECTED( cudaPoints.resize( bufferSize ) );
97 if ( !reportProgress( cb, 0.6f ) )
98 return unexpectedOperationCanceled();
99
100 DynamicArrayF cudaResult;
101 CUDA_LOGE_RETURN_UNEXPECTED( cudaResult.resize( bufferSize ) );
102
103 res.resize( points.size() );
104
105 const auto cb1 = subprogress( cb, 0.60f, 1.00f );
106 const auto iterCount = chunkCount( totalSize, bufferSize );
107 size_t iterIndex = 0;
108
109 for ( const auto [offset, size] : splitByChunks( totalSize, bufferSize ) )
110 {
111 const auto cb2 = subprogress( cb1, iterIndex++, iterCount );
112
113 CUDA_LOGE_RETURN_UNEXPECTED( cudaPoints.copyFrom( points.data() + offset, size ) );
114
115 fastWindingNumberFromVector( cudaPoints.data(), data_->toData(), cudaResult.data(), beta, int( skipFace ), size );
116 CUDA_LOGE_RETURN_UNEXPECTED( cudaGetLastError() );
117 if ( !reportProgress( cb2, 0.25f ) )
118 return unexpectedOperationCanceled();
119
120 CUDA_LOGE_RETURN_UNEXPECTED( cudaResult.copyTo( res.data() + offset, size ) );
121 if ( !reportProgress( cb2, 1.00f ) )
122 return unexpectedOperationCanceled();
123 }
124
125 return {};
126 } );
127}
128
129Expected<void> FastWindingNumber::calcSelfIntersections( FaceBitSet& res, float beta, const ProgressCallback& cb )
130{

Callers

nothing calls this directly

Calls 13

subprogressFunction · 0.85
maxBufferSizeFunction · 0.85
getCudaSafeMemoryLimitFunction · 0.85
reportProgressFunction · 0.85
chunkCountFunction · 0.85
splitByChunksFunction · 0.85
copyFromMethod · 0.80
toDataMethod · 0.80
copyToMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected