| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -5,6 +5,7 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#include "rod_generate.cuh" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#include "device_functions.h" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#include "float.h" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#include "ctime" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					py::array_t<float> add(int a, int b) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    py::array_t<float> res = py::array_t<float>(4); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -13,8 +14,8 @@ py::array_t<float> add(int a, int b) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ptr[0] = a - b; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ptr[1] = a + b; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ptr[2] = a * b; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ptr[3] = (float)a / b; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    res.resize({2,2}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ptr[3] = (float) a / b; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    res.resize({2, 2}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return res; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -29,14 +30,14 @@ g_rod_generate(int *beamData, int beamCnt, float *pointData, int pointCnt, cudaP | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    auto ix = blockIdx.x * blockDim.x + threadIdx.x; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    auto iy = blockIdx.y * blockDim.y + threadIdx.y; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    auto iz = blockIdx.z * blockDim.z + threadIdx.z; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    if (ix == 0 && iy == 0 && iz == 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        for (int i = 0; i < beamCnt; ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            printf("%d, %d\n", rod_beams(i, 0), rod_beams(i, 1)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        for(int i = 0; i < pointCnt; ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            printf("%f, %f, %f\n", rod_points(i, 0), rod_points(i, 1), rod_points(i, 2)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    if (ix == 0 && iy == 0 && iz == 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (int i = 0; i < beamCnt; ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            printf("%d, %d\n", rod_beams(i, 0), rod_beams(i, 1)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (int i = 0; i < pointCnt; ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            printf("%f, %f, %f\n", rod_points(i, 0), rod_points(i, 1), rod_points(i, 2)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    int cellCntX = extent->width / floatSize - 1; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    int cellCntY = extent->height - 1; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    int cellCntZ = extent->depth - 1; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -62,14 +63,14 @@ g_rod_generate(int *beamData, int beamCnt, float *pointData, int pointCnt, cudaP | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    row[ix] = FLT_MAX; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    auto aTmp = Eigen::Vector3f(rod_points.row(rod_beams(2, 1))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    printf("aTmp: (%f, %f, %f)\n", aTmp.x(), aTmp.y(), aTmp.z()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    printf("rod_beams.rows(): %ld\n", rod_beams.rows()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    for (int i = 0; i < rod_beams.rows(); ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto a = Eigen::Vector3f(rod_points.row(rod_beams(i, 0))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto b = Eigen::Vector3f(rod_points.row(rod_beams(i, 1))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto ab = b - a; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto ap = p - a; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto bp = p - b; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (ab.x() * bp.x() + ab.y() * bp.y() + ab.z() + bp.z() < 0 && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ab.x() * ap.x() + ab.y() * ap.y() + ab.z() * ap.z() > 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (ab.dot(bp) < 0 && ab.dot(ap) > 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            row[ix] = min(row[ix], (ap.cross(bp)).norm() / ab.norm()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            row[ix] = min(row[ix], min(ap.norm(), bp.norm())); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -79,7 +80,8 @@ g_rod_generate(int *beamData, int beamCnt, float *pointData, int pointCnt, cudaP | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					__host__ float * | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					h_rod_generate(float *h_sdf, const RodCrystal &rodCrystal, const Eigen::Vector3i &sampleCnt, const Eigen::Vector3f &sampleMin, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					h_rod_generate(float *h_sdf, const RodCrystal &rodCrystal, const Eigen::Vector3i &sampleCnt, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					               const Eigen::Vector3f &sampleMin, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					               const Eigen::Vector3f &sampleMax, float radius) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    int *d_beamData; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    size_t beamBytes = rodCrystal.rod_beams.rows() * rodCrystal.rod_beams.cols() * sizeof(int); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -182,8 +184,35 @@ h_rod_generate(float *h_sdf, const RodCrystal &rodCrystal, const Eigen::Vector3i | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return h_sdf; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					py::array_t<float> generate(int sampleX = 101, int sampleY = 101, int sampleZ = 101, float halfSampleRegion = 10) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// a case with 3*3*3 points (2*2*2 resolution) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					RodCrystal randomCrystal(int points_cnt, float axisMin, float axisMax, float threshold) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    Eigen::Matrix<float, Eigen::Dynamic, 3> rod_points; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    Eigen::Matrix<int, Eigen::Dynamic, 2> rod_beams; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    rod_points.resize(points_cnt, 3); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    srandom(time(nullptr)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const int MAX_SIZE = 1000; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    for (int i = 0; i < points_cnt; ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        rod_points(i, 0) = axisMin + static_cast<float>(random() % MAX_SIZE) / MAX_SIZE * (axisMax - axisMin); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        rod_points(i, 1) = axisMin + static_cast<float>(random() % MAX_SIZE) / MAX_SIZE * (axisMax - axisMin); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        rod_points(i, 2) = axisMin + static_cast<float>(random() % MAX_SIZE) / MAX_SIZE * (axisMax - axisMin); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    std::vector<std::pair<int, int>> rod_beams_tmp; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    for (int i = 0; i < points_cnt; ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (int j = i + 1; j < points_cnt; ++j) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if ((rod_points.row(i) - rod_points.row(j)).norm() < threshold) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                rod_beams_tmp.emplace_back(i, j); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    rod_beams.resize(rod_beams_tmp.size(), 2); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    for (int i = 0; i < rod_beams_tmp.size(); ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        rod_beams(i, 0) = rod_beams_tmp[i].first; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        rod_beams(i, 1) = rod_beams_tmp[i].second; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return {rod_points, rod_beams}; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					RodCrystal cube2() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    Eigen::Matrix<float, Eigen::Dynamic, 3> rod_points; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    rod_points.resize(27, 3); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    rod_points << 0, 0, 0, | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -214,6 +243,61 @@ py::array_t<float> generate(int sampleX = 101, int sampleY = 101, int sampleZ = | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            1, 2, 2, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            2, 2, 2; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    Eigen::Matrix<int, Eigen::Dynamic, 2> rod_beams; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    rod_beams.resize(54, 2); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    rod_beams << 0, 1, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    1, 2, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    3, 4, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    4, 5, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    6, 7, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    7, 8, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    0, 3, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    3, 6, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    1, 4, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    4, 7, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    2, 5, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    5, 8, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    9, 10, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    10, 11, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    12, 13, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    13, 14, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    15, 16, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    16, 17, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    9, 12, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    12, 15, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    10, 13, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    13, 16, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    11, 14, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    14, 17, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    18, 19, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    19, 20, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    21, 22, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    22, 23, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    24, 25, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    25, 26, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    18, 21, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    21, 24, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    19, 22, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    22, 25, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    20, 23, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    23, 26, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    0, 9, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    9, 18, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    1, 10, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    10, 19, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    2, 11, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    11, 20, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    3, 12, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    12, 21, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    4, 13, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    13, 22, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    5, 14, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    14, 23, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    6, 15, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    15, 24, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    7, 16, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    16, 25, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    8, 17, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    17, 26; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    rod_beams.resize(54, 2); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    rod_beams << 0, 1, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            1, 2, | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -269,14 +353,23 @@ py::array_t<float> generate(int sampleX = 101, int sampleY = 101, int sampleZ = | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            16, 25, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            8, 17, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            17, 26; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    RodCrystal rod(rod_points, rod_beams); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return {rod_points, rod_beams}; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					py::array_t<float> generate(int sampleX = 101, int sampleY = 101, int sampleZ = 101, float halfSampleRegion = 10) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// a case with 3*3*3 points (2*2*2 resolution) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    auto rod = cube2(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    auto rod = randomCrystal(60, 0, 2, 0.8); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    RodBVH bvh(rod); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    bvh.build(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    py::array_t<float> res = py::array_t<float>(sampleX * sampleY * sampleZ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    py::buffer_info buf = res.request(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    auto *ptr = (float *) buf.ptr; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    float *sdf = h_rod_generate(ptr, rod, Eigen::Vector3i(sampleX, sampleY, sampleZ), Eigen::Vector3f(-halfSampleRegion, -halfSampleRegion, -halfSampleRegion), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                Eigen::Vector3f(halfSampleRegion, halfSampleRegion, halfSampleRegion), 0.2f); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    float *sdf = h_rod_generate(ptr, rod, Eigen::Vector3i(sampleX, sampleY, sampleZ), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                Eigen::Vector3f(-halfSampleRegion, -halfSampleRegion, -halfSampleRegion), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                Eigen::Vector3f(halfSampleRegion, halfSampleRegion, halfSampleRegion), 0.14f); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    res.resize({sampleX, sampleY, sampleZ}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return res; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |