MCPcopy Create free account
hub / github.com/OpenPathGuidingLibrary/openpgl / export_samples

Function export_samples

tools/openpgl_debug/openpgl_debug.cpp:647–712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

645}
646
647void export_samples(DebugParams &debugParams)
648{
649 std::cout << "Export Samples as OBJ:" << std::endl;
650 std::cout << " -samples " << debugParams.samples_file_names[0] << std::endl;
651 std::cout << " -out " << debugParams.obj_out_file_name << std::endl;
652 std::ofstream objFile;
653 objFile.open(debugParams.obj_out_file_name.c_str());
654
655 openpgl::cpp::SampleStorage sampleStorage(debugParams.samples_file_names[0]);
656
657 bool pointsOnly = true;
658 std::vector<openpgl::cpp::SampleData> subSampledData;
659 subSampledData.reserve(sampleStorage.GetSizeSurface() + sampleStorage.GetSizeVolume());
660 for (size_t i = 0; i < sampleStorage.GetSizeSurface(); i++)
661 {
662 subSampledData.push_back(sampleStorage.GetSampleSurface(i));
663 }
664 for (size_t i = 0; i < sampleStorage.GetSizeVolume(); i++)
665 {
666 subSampledData.push_back(sampleStorage.GetSampleVolume(i));
667 }
668
669 for (auto &sample : subSampledData)
670 {
671 objFile << "v " << sample.position.x << "\t" << sample.position.y << "\t" << sample.position.z << std::endl;
672 if (!pointsOnly)
673 {
674#ifdef OPENPGL_DIRECTION_COMPRESSION
675 pgl_vec3f dir = openpgl::cpp::DecompressDirection(sample.direction);
676#else
677 pgl_vec3f dir = sample.direction;
678#endif
679 pgl_vec3f samplePosition = sample.position;
680 pgl_vec3f pos2;
681 pos2.x = samplePosition.x + dir.x * sample.distance;
682 pos2.y = samplePosition.y + dir.y * sample.distance;
683 pos2.z = samplePosition.z + dir.z * sample.distance;
684 objFile << "v " << pos2.x << "\t" << pos2.y << "\t" << pos2.z << std::endl;
685 objFile << "v " << sample.position.x << "\t" << sample.position.y << "\t" << sample.position.z << std::endl;
686 }
687 }
688
689 for (auto &sample : subSampledData)
690 {
691#ifdef OPENPGL_DIRECTION_COMPRESSION
692 pgl_vec3f dir = openpgl::cpp::DecompressDirection(sample.direction);
693#else
694 pgl_vec3f dir = sample.direction;
695#endif
696 objFile << "vn " << dir.x << "\t" << dir.y << "\t" << dir.z << std::endl;
697 if (!pointsOnly)
698 {
699 objFile << "vn " << dir.x << "\t" << dir.y << "\t" << dir.z << std::endl;
700 objFile << "vn " << dir.x << "\t" << dir.y << "\t" << dir.z << std::endl;
701 }
702 }
703
704 if (!pointsOnly)

Callers 1

mainFunction · 0.85

Calls 8

DecompressDirectionFunction · 0.85
GetSizeSurfaceMethod · 0.80
GetSizeVolumeMethod · 0.80
GetSampleSurfaceMethod · 0.80
GetSampleVolumeMethod · 0.80
reserveMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected