Need help for component that calculates Brep Volumes

Sorry, not to help you with coding but sharing general thought.

In situations like this, we should be able to switch to faster algorithms by removing unnecesary outputs (by this minus button, like in e.g. Explode Tree).
We can already modify components by choosing if they run in parallel computing mode. Only problem is that some users would probably like to have different default output set, so some user settings to this regard would be handy.

2 Likes

This would be great, because it would mean less components overall.
I hope this will be available in 2030 when GH2 comes out !
Meanwhile, I really could use fast components for area and volume…

Hi @osuire

RhinoMath is a static class not a namespace. So adding a using statement is incorrect.

You can use the RhinoMath class like this:

var unset = RhinoMath.UnsetValue;

– Dale

@dale OK, got it : RhinoMath is a class of the “Rhino” Namespace which was not declared in your script, and that’s why I got the error message in the first place.

Now that I’ve added the “RhinoMath.UnsetValue” line successfully, well… it still doesn’t work : If I have an empty branch, the component just fills in the holes with the next values available.

Could someone PLEASE HELP ME ?

I mean, there HAS to be a standard non-hacky way of dealing with empty branches, right ?

Hi @osuire,

Sorry for not paying more attention to this.

Does the JustArea component works the same as the Area component when task capable is enabled? That is, both components do not take empty branches into account? Or does JustArea work differently?

Other than turning off parallel computing or cleaning out empty branches, this is about all I can come up with:

protected override void SolveInstance(IGH_DataAccess data)
{
  // Set some default return value just in case
  // we encounter an empty branch. The value you 
  // set is up to you...
  data.SetData(0, -1.0);

  if (InPreSolve)
  {
    IGH_GeometricGoo geometry = null;
    if (!data.GetData(0, ref geometry))
      return;

    Task<SolveResults> task = Task.Run(() => ComputeArea(geometry), CancelToken);
    TaskList.Add(task);
    return;
  }

  if (!GetSolveResults(data, out SolveResults result))
  {
    IGH_GeometricGoo geometry = null;
    if (!data.GetData(0, ref geometry))
      return;

    result = ComputeArea(geometry);
  }

  if (null != result)
  {
    data.SetData(0, result.Area);
  }
}

Maybe this helps?

– Dale

Hi Dale,

Area and Volume calculations absolutely need to be as fast as they can be and it is extremely unpractical that they are crippled by the centroid calculation, so yes, I think it deserves attention.

Well, it would have taken you less time to try it out for yourself than to write this sentence :slight_smile: , but here’s the answer :


Test area Volume.gh (20.8 KB)
As you can see, the Vanilla component works as expected… except it’s much too slowwwwwwwwwwwwww.

Well, I’ll try it, thanks ; idealy, I should spend a few months training on C#, and I’d probably end up finding a solution to this, but that is just not possible at the moment, as I am starting a business.
I just need a solution to this problem, and if possible one that does not require me to mess around too much in Visual Studio.

OK, I’ve pushed an update to SampleGhTaskAreaComponent.cs. See if this works any better.

– Dale

Thanks Dale, it works this time ; would you mind posting the same for volumes ? :

I updated this when I updated the Area sample…

1 Like

It seems to work great.

Thanks Dale.

RH-64836 is fixed in the latest WIP

2 Likes