Reflection_Engine: allow for disabling recording the events
- 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
Assessment
This issue has not been assessed yet.