Skip to content

Commit 9891cc2

Browse files
committed
Remove comments
1 parent 479c31f commit 9891cc2

File tree

2 files changed

+0
-331
lines changed

2 files changed

+0
-331
lines changed

src/drawer.cpp

Lines changed: 0 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ void Drawer::traverse_and_collect(const Key& key, std::vector<Node*>& visible_oc
566566
}
567567
}
568568

569-
570569
void Drawer::query_rendered_point()
571570
{
572571
pp.clear();
@@ -584,187 +583,3 @@ void Drawer::setPointSize(float size)
584583
{
585584
if (size > 0) this->point_size = size;
586585
}
587-
588-
589-
/*if (postprod)
590-
{
591-
std::vector<unsigned char> pixelData(width * height * 4); // Assuming RGBA
592-
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data());
593-
594-
// Step 3: Identify and fill holes
595-
int maxIterations = 5; // Number of passes to make
596-
for (int iter = 0; iter < maxIterations; ++iter) {
597-
for (int y = WS; y < height - WS; ++y) {
598-
for (int x = WS; x < width - WS; ++x) {
599-
int index = (y * width + x) * 4;
600-
if (isBackgroundPixel(pixelData[index], pixelData[index + 1], pixelData[index + 2], pixelData[index + 3]))
601-
{
602-
//pixelData[index] = 0; pixelData[index + 1] = 255; pixelData[index + 2] = 0;
603-
if (hasSurroundingForegroundPixels(pixelData, x, y, width)) {
604-
//pixelData[index] = 255; pixelData[index + 1] = 255; pixelData[index + 2] = 255;
605-
fillHole(pixelData, x, y, width);
606-
}
607-
}
608-
}
609-
}
610-
}
611-
612-
glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data());
613-
}*/
614-
615-
616-
// depth-buffer edge detection
617-
/*std::vector< GLfloat > depth( width * height, 0 );
618-
glReadPixels( 0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, &depth[0] );
619-
620-
// Linearize depth and convert to unsigned byte
621-
std::vector<GLubyte> depthImage(width * height);
622-
for (size_t i = 0; i < depth.size(); ++i) {
623-
float linearDepth = (2.0f * zNear) / (zFar + zNear - depth[i] * (zFar - zNear));
624-
depthImage[i] = static_cast<GLubyte>(linearDepth * 255.0f); // Map to [0, 255]
625-
}
626-
627-
int Gx[3][3] = {
628-
{-1, 0, 1},
629-
{-2, 0, 2},
630-
{-1, 0, 1}
631-
};
632-
633-
int Gy[3][3] = {
634-
{-1, -2, -1},
635-
{ 0, 0, 0},
636-
{ 1, 2, 1}
637-
};
638-
639-
std::vector<GLubyte> edgeImage(width * height, 0);
640-
641-
for (int y = 1; y < height - 1; ++y) {
642-
for (int x = 1; x < width - 1; ++x) {
643-
float gx = 0.0f;
644-
float gy = 0.0f;
645-
646-
for (int i = -1; i <= 1; ++i) {
647-
for (int j = -1; j <= 1; ++j) {
648-
gx += Gx[i + 1][j + 1] * depthImage[(y + i) * width + (x + j)];
649-
gy += Gy[i + 1][j + 1] * depthImage[(y + i) * width + (x + j)];
650-
}
651-
}
652-
653-
float gradient = sqrt(gx * gx + gy * gy);
654-
edgeImage[y * width + x] = static_cast<GLubyte>(std::min(gradient, 255.0f)); // Clamp to [0, 255]
655-
}
656-
}
657-
658-
// Step 4: Replace values >= 255 with 0
659-
for (size_t i = 0; i < edgeImage.size(); ++i) {
660-
if (edgeImage[i] >= 220) {
661-
edgeImage[i] = 0;
662-
}
663-
}
664-
665-
// Step 5: Find the new maximum value
666-
GLubyte newMaxValue = 0;
667-
for (size_t i = 0; i < edgeImage.size(); ++i) {
668-
if (edgeImage[i] > newMaxValue) {
669-
newMaxValue = edgeImage[i];
670-
}
671-
}
672-
673-
// Step 6: Rescale the image to the range [0, 255]
674-
if (newMaxValue > 0) { // Avoid division by zero
675-
for (size_t i = 0; i < edgeImage.size(); ++i) {
676-
edgeImage[i] = static_cast<GLubyte>((edgeImage[i] * 255.0f) / newMaxValue);
677-
}
678-
}
679-
680-
// Step 7: Create the shadow image
681-
std::vector<GLubyte> shadowImage(width * height * 4, 0); // Initialize as white with full alpha
682-
683-
for (int y = 0; y < height; ++y) {
684-
for (int x = 0; x < width; ++x) {
685-
size_t index = y * width + x;
686-
if (edgeImage[index] == 0) {
687-
// Set to black with some alpha value (e.g., 128 for semi-transparency)
688-
shadowImage[index * 4 + 0] = 0;
689-
shadowImage[index * 4 + 1] = 0;
690-
shadowImage[index * 4 + 2] = 0;
691-
shadowImage[index * 4 + 3] = 128; // Alpha value (0-255, where 0 is fully transparent and 255 is fully opaque)
692-
}
693-
}
694-
}
695-
696-
// Step 8: Enable blending and set blend function
697-
glEnable(GL_BLEND);
698-
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
699-
700-
// Step 9: Render the shadow image
701-
glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_BYTE, shadowImage.data());
702-
*/
703-
704-
/*
705-
* #define WS 5
706-
707-
bool isBackgroundPixel(unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
708-
// Define what you consider as a background pixel.
709-
// Example: A black pixel with full transparency.
710-
return (r < 200 && g < 200 && b < 200);
711-
}
712-
713-
bool hasSurroundingForegroundPixels(const std::vector<unsigned char>& pixelData, int x, int y, int width) {
714-
int offsets[] = {-WS, 0, WS}; // To iterate over neighboring pixels
715-
int n = 0;
716-
for (int dy : offsets) {
717-
for (int dx : offsets) {
718-
if (dx == 0 && dy == 0) continue; // Skip the center pixel itself
719-
720-
int neighborIndex = ((y + dy) * width + (x + dx)) * 4; // Calculate neighbor's index in the array
721-
unsigned char r = pixelData[neighborIndex];
722-
unsigned char g = pixelData[neighborIndex + 1];
723-
unsigned char b = pixelData[neighborIndex + 2];
724-
unsigned char a = pixelData[neighborIndex + 3];
725-
726-
if (!isBackgroundPixel(r, g, b, a)) {
727-
n++;
728-
}
729-
}
730-
}
731-
if (n >= 8) return true;
732-
return false; // No foreground pixels around
733-
}
734-
735-
void fillHole(std::vector<unsigned char>& pixelData, int x, int y, int width) {
736-
int offsets[] = {-WS, 0, WS}; // To iterate over neighboring pixels
737-
int rSum = 0, gSum = 0, bSum = 0, aSum = 0;
738-
int count = 0;
739-
740-
// Calculate the sum of the colors of the surrounding foreground pixels
741-
for (int dy : offsets) {
742-
for (int dx : offsets) {
743-
if (dx == 0 && dy == 0) continue; // Skip the center pixel itself
744-
745-
int neighborIndex = ((y + dy) * width + (x + dx)) * 4;
746-
unsigned char r = pixelData[neighborIndex];
747-
unsigned char g = pixelData[neighborIndex + 1];
748-
unsigned char b = pixelData[neighborIndex + 2];
749-
unsigned char a = pixelData[neighborIndex + 3];
750-
751-
if (!isBackgroundPixel(r, g, b, a)) {
752-
rSum += r;
753-
gSum += g;
754-
bSum += b;
755-
aSum += a;
756-
count++;
757-
}
758-
}
759-
}
760-
761-
// Avoid division by zero
762-
if (count > 0) {
763-
int index = (y * width + x) * 4;
764-
pixelData[index] = rSum / count;
765-
pixelData[index + 1] = gSum / count;
766-
pixelData[index + 2] = bSum / count;
767-
pixelData[index + 3] = aSum / count;
768-
}
769-
}*/
770-

src/lidRviewer.cpp

Lines changed: 0 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -173,149 +173,3 @@ void viewer(DataFrame df, std::string hnof)
173173
sdl_thread.detach(); // Detach the thread to allow it to run independently
174174
running = true;
175175
}
176-
177-
178-
/*void viewer(DataFrame df)
179-
{
180-
bool run = true;
181-
182-
SDL_Event event;
183-
184-
unsigned int width = 600;
185-
unsigned int height = 600;
186-
187-
Uint32 last_time, current_time, elapsed_time;
188-
189-
SDL_Init(SDL_INIT_VIDEO);
190-
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
191-
SDL_Window *window = SDL_CreateWindow("lidRviewer", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
192-
193-
SDL_GLContext glContext = SDL_GL_CreateContext(window);
194-
SDL_GL_SetSwapInterval(1); // Enable VSync
195-
196-
glMatrixMode(GL_PROJECTION);
197-
glLoadIdentity();
198-
gluPerspective(70, (double)width / height, zNear, zFar);
199-
200-
glEnable(GL_DEPTH_TEST); // Enable depth testing for z-culling
201-
glDepthFunc(GL_LEQUAL); // Set the type of depth-test
202-
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Nice perspective corrections
203-
204-
205-
glEnable(GL_POINT_SMOOTH); // Round point
206-
207-
glEnable(GL_LINE_SMOOTH); // Enable line anti-aliasing
208-
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
209-
210-
//glEnable(GL_MULTISAMPLE);
211-
//glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);
212-
213-
//glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); // Enable changing the point size
214-
215-
Drawer *drawer = new Drawer(window, df);
216-
drawer->camera.setRotateSensivity(0.1);
217-
drawer->camera.setZoomSensivity(10);
218-
drawer->camera.setPanSensivity(1);
219-
drawer->setPointSize(4);
220-
221-
222-
last_time = SDL_GetTicks();
223-
224-
while (run)
225-
{
226-
while (SDL_PollEvent(&event))
227-
{
228-
switch (event.type)
229-
{
230-
case SDL_QUIT:
231-
run = false;
232-
break;
233-
234-
case SDL_KEYDOWN:
235-
switch (event.key.keysym.sym)
236-
{
237-
case SDLK_ESCAPE:
238-
run = false;
239-
break;
240-
case SDLK_z:
241-
drawer->setAttribute(Attribute::Z);
242-
break;
243-
case SDLK_i:
244-
drawer->setAttribute(Attribute::I);
245-
break;
246-
case SDLK_c:
247-
drawer->setAttribute(Attribute::CLASS);
248-
break;
249-
case SDLK_r:
250-
case SDLK_g:
251-
case SDLK_b:
252-
drawer->setAttribute(Attribute::RGB);
253-
break;
254-
case SDLK_q:
255-
drawer->display_hide_spatial_index();
256-
break;
257-
case SDLK_l:
258-
drawer->display_hide_edl();
259-
break;
260-
case SDLK_PLUS:
261-
case SDLK_KP_PLUS:
262-
drawer->point_size_plus();
263-
break;
264-
case SDLK_MINUS:
265-
case SDLK_KP_MINUS:
266-
drawer->point_size_minus();
267-
break;
268-
default:
269-
drawer->camera.OnKeyboard(event.key);
270-
break;
271-
}
272-
break;
273-
274-
case SDL_MOUSEMOTION:
275-
drawer->camera.OnMouseMotion(event.motion);
276-
break;
277-
278-
case SDL_MOUSEBUTTONUP:
279-
case SDL_MOUSEBUTTONDOWN:
280-
drawer->camera.OnMouseEvent(event.button, SDL_MouseWheelEvent{}); // Pass an empty SDL_MouseWheelEvent
281-
break;
282-
283-
case SDL_MOUSEWHEEL:
284-
drawer->camera.OnMouseEvent(SDL_MouseButtonEvent{}, event.wheel); // Pass an empty SDL_MouseButtonEvent
285-
break;
286-
287-
case SDL_WINDOWEVENT:
288-
if (event.window.event == SDL_WINDOWEVENT_RESIZED)
289-
{
290-
width = event.window.data1;
291-
height = event.window.data2;
292-
glViewport(0, 0, width, height);
293-
glMatrixMode(GL_PROJECTION);
294-
glLoadIdentity();
295-
gluPerspective(70, (double)width / height, zNear, zFar);
296-
drawer->camera.changed = true;
297-
}
298-
break;
299-
}
300-
}
301-
302-
current_time = SDL_GetTicks();
303-
elapsed_time = current_time - last_time;
304-
305-
if (elapsed_time > time_per_frame)
306-
{
307-
drawer->draw();
308-
last_time = current_time;
309-
}
310-
else
311-
{
312-
SDL_Delay(time_per_frame - elapsed_time);
313-
}
314-
}
315-
316-
delete drawer;
317-
SDL_GL_DeleteContext(glContext); // Correctly delete OpenGL context
318-
SDL_DestroyWindow(window); // Correctly destroy window
319-
SDL_Quit();
320-
return;
321-
}*/

0 commit comments

Comments
 (0)