Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8589851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:09:19+00:00 2026-06-11T23:09:19+00:00

I am implementing a scan line based polygon fill algorithm. I know the general

  • 0

I am implementing a scan line based polygon fill algorithm.
I know the general algorithm and I am now trying to implement it in C++.

I need to implement the edge table an active edge list.

I have made the active edge list a vector for easy inserting and removing dynamically.

The edge table however is a bit more confusing.

I am trying to implement the edge table using an array of vectors, and the vectors will contain a struct that I made.

Here is the struct.

struct Bucket
{
    // Fields of a bucket list
    int ymax, x, dx, dy, sum;
};

I have a for loop which iterates over an array of vertices passed in, and then it creates a bucket and inserts the bucket into the edge table at the ymin index for an edge.

My problem is that I am having a hard time looping over the edge table and accessing the individual buckets.

Here is the declaration of the array of vectors of buckets:

// This array is the edge table which has a max index of 300
    // The window for the program is never more than 300 by 300
    vector<Bucket> et[300];

Here is my for loop that’s iterating over the edge table trying to print out items.
I tried using an iterator and a normal int for the index, but neither works when trying to print out each bucket’s values.

// Debugging the edge table, prints out all buckets
    vector<Bucket>::iterator it;
    for(int j = 0; j < 300; j++)
    {
            for(it = et[j].begin(); it < et[j].end(); it++)
            {
//                printf(*it);
//                printf();
            }
            for(int q = 0; q < et[j].size(); q++)
            {
                printf("ymax = %d", q[0]);
            }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:09:21+00:00Added an answer on June 11, 2026 at 11:09 pm

    Thanks to playing around and help from Michael I was able to print out the values.
    This will now also help me to access these values when I am ready to iterate over the edge table and fill in the polygon.

    The correct way to print the values of the struct inside the vector was to use this for loop:

    vector<Bucket>::iterator it;
        for(int j = 0; j < 300; j++)
        {
            for(int q = 0; q < et[j].size(); q++)
            {
                printf("ymax = %d, x = %d, dx = %d, dy = %d, sum = %d,\n", et[j][q].ymax, et[j][q].x, et[j][q].dx, et[j][q].dy, et[j][q].sum);
            }
        }
    

    I hope this can help others who are also rusty at c++.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When implementing Serializable interface, in Java, we need to set it's serialVersionUID long. Is
When implementing a hash table using a good hash function (one where the probability
I'm implementing an algorithm that, in essence, is a series of matrix-matrix multiplications like
Implementing the basic algorithm using last array as a pivot in Java, is it
When implementing a client/server solutions, one of the questions you always need to answer
I am in need of a data storage type and algorithm for keeping track
I am trying to scan my webapplication classpath for all classes which implimenting certain
Implementing org.jscep.server.ScepServlet I need to provide an implementation for the method doEnroll ( List<X509Certificate>
I`m implementing a custom filesystem on Ubuntu using Fuse, but I need to trap
Implementing Interface just provide the skeleton of the method. If we know the exact

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.