BHoM / BHoM/BHoM_Engine

Reflection_Engine: allow for disabling recording the events

Open
#2,589 3 comments 1 reaction 4 assignees Claimed by @pawelbaran View on GitHub
type:feature
Dominant language
C#
Stars
30
Forks
13
Avg merge
7d 10h
Merged PRs (30d)
5

Description

#### Description:

Together with @tiagogrossi we just approached an interesting problem (actually, I have been there before myself, but never picked it up so far). Namely, we have the following pseudocode trying to offset `PolyCurve loop`, and if the offset is self-intersecting then returning its bounding rectangle instead:

```
PolyCurve offset = loop.Offset(1);
if (offset.IsSelfIntersecting())
offset = //create rectangle;
```

In case of resultant self-intersection, `Offset` method starts recording warnings, which is valid. However, in our case, we do not want to expose them to the user because the offset is not a part of the final output (it is overwritten by the rectangle).

So ideally, we would like to be able to instruct Reflection not to record events for a moment:

```
BH.Engine.Reflection.Compute.StopRecordingEvents(EventType.Warning);
PolyCurve offset = loop.Offset(1);
if (offset.IsSelfIntersecting())
offset = //create rectangle;

BH.Engine.Reflection.Compute.StartRecordingEvents(EventType.Warning);
```

What do you think about it? Technically this could be realised using a private `bool` field checked on calls to `RecordEvent` and switched using `StopRecordingEvents` and `StartRecordingEvents`. This is however far from perfect, firstly because of the private field being shared by a few methods and secondly likely to become problematic in case of multithreading.

Happy to hear others' opinion @al-fisher @adecler @FraserGreenroyd @alelom @IsakNaslundBh

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.