# Adding Roemer's Boolean Filter as a Remote Module

**URL:** https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635
**Category:** Development
**Created:** [August 21, 2019, 10:07pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635 "2019-08-21T22:07:25Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [August 21, 2019, 10:07pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/1 "2019-08-21T22:07:25Z")

</div>

@Ron84 I am working on a [Merge Request](https://gitlab.kitware.com/vtk/vtk/merge_requests/5879) to add Roland Roemer’s Boolean operator filter as a Remote Module. Roemer’s class is supposedly more robust than the existing filters and has several features listed in the [README.md description](https://github.com/zippy84/vtkbool/blob/master/README.md).

So far I have:

1. Forked his [vtkbool repo](https://github.com/zippy84/vtkbool).
2. Modified his top-level [CMakeLists.txt file](https://github.com/lorensen/vtkbool/blob/master/CMakeLists.txt) to either add the remote module Boolean or behave as his original CMakeLists.txt.
3. I have not needed to change any other of the original files.

I have tried to suppress many warning in his code with compile options. However, this has become unmanageable across multiple compilers. I would like to repair these warnings.

Also, some method names differ from the method names in the existing [vtkBooleanOperationPolyDataFilter](https://vtk.org/doc/nightly/html/classvtkBooleanOperationPolyDataFilter.html) and [vtktLoopBooleanPolyDataFilter](https://vtk.org/doc/nightly/html/classvtkLoopBooleanPolyDataFilter.html#details).

Roemer’s class uses these methods:

```auto
    void SetOperModeToUnion ()
    void SetOperModeToIntersection ()
    void SetOperModeToDifference ()
    void SetOperModeToDifference2 ()

```

while the existing classes use:

```auto
  void SetOperationToUnion()
  void SetOperationToIntersection()
  void SetOperationToDifference() 

```

I’m soliciting feedback as to the best approach:

1. Forget adding it as a remote module. Use the filter as is described [here](https://github.com/zippy84/vtkbool/blob/master/README.md).
2. Change Reomer’s’ API to match VTK’s.
3. Since we can’t tolerate warnings, repair the warnings by changing the original source and retain the changes only in the forked repo.
4. Generate a PR to merge our changes into Roemer’s repo.

Thanks,

Bill

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)
#### Post date: [August 21, 2019, 11:25pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/2 "2019-08-21T23:25:06Z")

</div>

Bill,

We’ve been trying Ronald’s code and it does usually work better for us too. We’d been thinking to bring up a discussion about getting it into VTK, but you beat us to it. 🙂

I’m not a git expert, but why a ‘remote module’, why not just bring it into VTK proper?

I guess the best path will especially depend on Ronald’s feedback…

Perhaps we should consider getting rid of the existing vtkBooleanOperationPolyDataFilter? Or rather, gut its implementation (replace it with Ronald’s) but maintain its public API.

Sean

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [August 22, 2019, 12:00am UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/3 "2019-08-22T00:00:27Z")

</div>

> [@seanm](#):
>
> I’m not a git expert, but why a ‘remote module’, why not just bring it into VTK proper?

Bringing it in as a remote module reduces VTK’s commitment to maintaining this code going forward. If it turns out to be essential after vetting as a remote module, then bringing it into VTK proper is a logical next step if the benefit outweighs the code maintenance costs. `vtkBooleanOperationPolyDataFilter` probably should have been a remote module when it was first integrated, but I don’t recall that the mechanism was available at the time. It did start life as a [VTK Journal article](https://www.vtkjournal.org/browse/publication/797).

> [@seanm](#):
>
> Perhaps we should consider getting rid of the existing vtkBooleanOperationPolyDataFilter? Or rather, gut its implementation (replace it with Ronald’s) but maintain its public API.

Aside from differences in AP, one thing `vtkBooleanOperationPolyDataFilter` does that the code under consideration doesn’t do is interpolate point data, so it isn’t at present a drop in replacement. I don’t know how much work it would be to implement that, but I spent a good amount of time getting it working in the original `vtkIntersectionPolyDataFilter`.

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [August 22, 2019, 12:44am UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/4 "2019-08-22T00:44:56Z")

</div>

Ronald’s filters would take a lot of work to bring into VTK proper. It lacks VTK style and uses several other of his files in three subdirectories. VTK classes are usually self-contained. For now, the short putt is to make it a Remote Module.

Bill

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [August 22, 2019, 1:27pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/5 "2019-08-22T13:27:21Z")

</div>

Currently a remote module is the best way. It should be a part of VTK when the remaining problems have been solved. The missing interpolation of PointData, the missing mesh optimizer … Especially the optimizer is really important for the filter.

I don’t want that API changes. Please leave it as it is!

One problem could be the static class member of `Point`. It has to be initialized before you can use the filter. I think `int Point::_tag = 0;` must be replaced with something other. Any ideas?

When I change my code, how could I merge them into @lorensen fork? I don’t know the right procedure for that. Should I create a PR when I have something new? And what’s with smaller patches?

@lorensen Could you please change “A new boolean operation filter by Ronald Romer” to “A new boolean operation filter by Ronald R **ö** mer”?

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [August 22, 2019, 10:31pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/6 "2019-08-22T22:31:12Z")

</div>

@Ron84 Can you place parens to correct this warning:  
Tools.cxx: In function ‘bool TestPIP(PolyType&, Point&)’:  
[CTest: warning matched] Remote/Boolean/Tools.cxx:204:28: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]  
&& (a.y \< pt.y && b.y \>= pt.y

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)
#### Post date: [August 23, 2019, 2:36pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/7 "2019-08-23T14:36:34Z")

</div>

OK, sounds reasonable. We can help with testing and fixing warnings and the like. We have various datasets that cause problems with the existing class, they could form the basis of some unit tests.

Sean

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [August 23, 2019, 2:41pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/8 "2019-08-23T14:41:16Z")

</div>

There are unit-tests. Just enable VTKBOOL\_TESTING.

I will fix the parentheses-warnings this evening.

---

<div class="post-metadata">

### Author: ![kayarre](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kayarre/32/808_2.png) [@kayarre](https://discourse.vtk.org/u/kayarre)
#### Post date: [August 24, 2019, 4:05pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/9 "2019-08-24T16:05:56Z")

</div>

Very excited about this getting brought in!  
Thank you all for this work effort!

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [August 26, 2019, 10:26pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/10 "2019-08-26T22:26:14Z")

</div>

@lorensen I fixed most of the warnings in my repository. Except for sign-compare…

I’m comparing size\_t with int. A classical mistake… How could I resolve it? Static cast from size\_t to int?

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [August 26, 2019, 10:43pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/11 "2019-08-26T22:43:38Z")

</div>

I have lots of changes. You should wait until I’m done with mine. A  
merge would be impossible if you make changes.

---

<div class="post-metadata">

### Author: ![kayarre](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kayarre/32/808_2.png) [@kayarre](https://discourse.vtk.org/u/kayarre)
#### Post date: [September 5, 2019, 1:41am UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/12 "2019-09-05T01:41:02Z")

</div>

@lorensen do you have a branch in progress to peruse.

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)
#### Post date: [September 5, 2019, 1:56am UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/13 "2019-09-05T01:56:38Z")

</div>

Ronald, static cast from size\_t to int can truncate, perhaps better to upcast from int to size\_t. Either way there is a signedness difference though. Best solution will depend on the exact code.

Regarding tests, yes, there are some currently, I mean we can contribute more tests, including some that lead to unexpected/undesired failure.

Sean

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [September 5, 2019, 2:29am UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/14 "2019-09-05T02:29:25Z")

</div>

I’ll have a usable MR in a day or two.

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [September 5, 2019, 4:41pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/15 "2019-09-05T16:41:30Z")

</div>

> [@seanm](#):
>
> we can contribute more tests

Who is “we”?

What kind of tests? Only some complex models?

Have you analysed vtkbool with valgrind? There are a few errors when running `valgrind --tool=memcheck --leak-check=full ./testing 12`.

It doesn’t make sense to me. Any of you?

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [September 6, 2019, 10:38pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/16 "2019-09-06T22:38:55Z")

</div>

I’m making progress. Still some OSX linking issues.

I converted your tests in testing (which I had to rename to tests because OSX is case insensitive for file names) to a standard VTK test. I also added a regression test that mimics the existing vtk boolean operation tests.

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [September 6, 2019, 10:56pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/17 "2019-09-06T22:56:26Z")

</div>

I just ran valgrind with my version and have no errors reported.

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [September 6, 2019, 11:15pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/18 "2019-09-06T23:15:31Z")

</div>

Here is the output of valgrind. I’m using gcc 9.1.0 and VTK 8.2.0 on Arch Linux.

> **[View Paste x6sfh](https://paste.ee/p/x6sfh)**
>
> Paste.ee - View Paste x6sfh

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [September 6, 2019, 11:18pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/19 "2019-09-06T23:18:08Z")

</div>

We’re testing two different source trees. Let’s worry about valgrind when I get a workable version on all platforms,

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [September 14, 2019, 10:52pm UTC](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635/20 "2019-09-14T22:52:31Z")

</div>

@lorensen When will you be done with it?

[Next page](https://discourse.vtk.org/t/adding-roemers-boolean-filter-as-a-remote-module/1635.md?page=2)
