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 6131173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:56:36+00:00 2026-05-23T16:56:36+00:00

This is more of a design question than a graphics question, but here’s a

  • 0

This is more of a design question than a graphics question, but here’s a bit of background: I’m writing a program using OpenGL (in Java, with JOGL) that can load a mesh from a .obj file and render it. No problems so far, but I need to be able to apply a series of filters or transformations to the mesh, e.g.

  • Tessellating the faces
  • Adding random noise to the vertices
  • Applying a smoothing algorithm to the noisy mesh
  • Colouring the mesh (which may or may not be based on both the smoothed mesh and the original clean mesh)

Several of these filters would be applied in order. I also want to provide some kind of consistent interface for other people to write their own (possibly general) filters. How would I go about this?

The main problem is that the filters may require different sets of parameters, e.g. one smoothing algorithm may require two parameters to be chosen by the user (at runtime, using the GUI), whereas another might require none. Similarly some colouring algorithms may require only the smoothed mesh and an RGB colour, another might require both the smoothed mesh and the clean mesh (which it generates the colours from). So the call might look like:

mesh = smoothingFilter1.filter(mesh, booleanParam);

but it might be completely different:

mesh = smoothingFilter2.filter(mesh, intParam1, intParam2, floatParam);

Obviously my code needs to be capable of invoking a general filtering method. Would it be a good idea to define an abstract class or interface for a Filter with an unimplemented method for registering itself (and its required parameters) with some kind of controlling class? Seems pretty complicated but I can’t think of any other way to get the program to work with a filter method that has an arbitrary signature. I’m not even sure this idea would work…

Is there a design pattern for handling this type of situation?

  • 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-05-23T16:56:37+00:00Added an answer on May 23, 2026 at 4:56 pm

    Actually you don’t need the parameters at all. Mesh filter(Mesh mesh); would suffice.
    Move the other parameters to the constructor of the different concrete implementations of the filters.

    Looks something like this:

    Filter smoothingFilter1 = new FirstFilter(booleanParam);    
    mesh = smoothingFilter1.filter(mesh);
    
    Filter smoothingFilter2 = new SecondFilter( intParam1, intParam2, floatParam);    
    mesh = smoothingFilter2.filter(mesh);
    

    For instantiating you can use something along the lines of:

    public interface AbstractFilterFactory {
      Params getRequiredParams();
      Filter createFilter(Params params);
    }
    
    public interface Params {
     // some interface that describes specific parameters that are required
     // probably a collection of Parameter classes which has name, type and value information. 
    }
    
    public class FirstFilterFactory implements AbstractFilterFactory {
      // return a concrete params object use that to instantiate a concrete filter.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is more UI/Design-ish than hard-core programming is. Background: I've been coding in
Ok this is more of a PHP question than mongodb but since i am
So this question is more around the design decision than anything else.Essientially, I want
This is a more a philosophical question about Apple's design decisions than a question
I guess this is more a design pattern question than a SQL one. In
This question was asked already here , but rather than answering the specific question,
This question is more aimed at good design practices rather than exceptions and stacks.
This is more a design question than anything else... I really like Scala's case
This is more of a general design question, but it will be implemented in
This is a design question rather than a Java-specific question, but I'm designing it

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.