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

  • Home
  • SEARCH
  • 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 8904159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:03:15+00:00 2026-06-15T02:03:15+00:00

I have a function that looks something like the code below. Its purpose is

  • 0

I have a function that looks something like the code below. Its purpose is to take triangle facets one at a time from an array of points where each three points is one facet, and tessellate them, replacing the facet with a list of smaller facets whose side lengths don’t exceed nodeSize.

Naturally, this function is time consuming for any realistic facet mesh. I’d like to refactor it to use some coarse parallelization. However, Parallel.For doesn’t appear to have a way to step through indices in an array at intervals while preserving the index number.

Bearing in mind that the SplitTriangle function inside the loop is computationally not conducive itself to parallelization, how could I refactor this function?

Protected Shared Function SplitTriangles(Points As IEnumerable(Of Point3D), nodeSize As Single) As List(Of Point3D)
    Dim resultList As New List(Of Point3D)

        For i As Integer = 0 To Points.Count - 1 Step 3
            resultList.AddRange(SplitTriangle(Points(i), Points(i + 1), Points(i + 2), nodeSize * 4))
        Next

    Return resultList
End Function
  • 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-15T02:03:16+00:00Added an answer on June 15, 2026 at 2:03 am

    You could use the Enumerable.Range() function to generate the indices for you. I’m not overly familiar with VB.NET, so I’m going to write this in C#.

    Enumerable.Range(0, Points.Count / 3).AsParallel().ForAll( loopVar => {
        var i = loopVar * 3;
        resultList.AddRange(SplitTriangle(Points(i), Points(i + 1), Points(i + 2), nodeSize * 4))
    });
    

    UPDATE
    I think this version would be thread safe, but you should check to ensure that it is and that the results are in the correct order.

    resultList = Enumerable.Range(0, Points.Count / 3).AsParallel().SelectMany( loopVar => {
        var i = loopVar * 3;
        return SplitTriangle(Points(i), Points(i + 1), Points(i + 2), nodeSize * 4);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code in a couple of different functions that looks something like
I have a constexpr function that looks something like this: constexpr int foo(int bar)
I have a script that looks like this #!/bin/bash function something() { echo hello
I have code that looks like this: var baseClass = function() { // CODE
I have some code that looks like this: var MyObject = function () {
Inside my .aspx I have some JSON code that looks like this: function someFunctionName()
i have a function that looks like this. function startChatSession($items) { foreach ($test as
I have a autoload function that looks like so: function __autoload_HTTP_Client($class_name) { $HC =
I have a JavaScript function that looks like this: function recalculateWhatIfCurrentRate(aEle, aChangedLabel, recordID, yearEndCurrentRate)
I have a DOM structure which looks something like below - <div id='MyDiv'> <span>Hello

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.