[vtkusers] Fwd: Re: AND-filter for vtkPolyData (was extract/selectcoincident points/cells)

Bill Lorensen bill.lorensen at gmail.com
Mon Sep 17 15:42:29 EDT 2012


Were the two isosurfaces generated by DiscreteMarchingCubes from the same
segmented data? DiscreteMarchingCubes will generate coincident faces on two
adjacent segmented surfaces.

What are you trying to accomplish? Are you trying to see the facves that
lie in between two segmented surfaces?

On Mon, Sep 17, 2012 at 9:33 AM, Dr. Roman Grothausmann <
grothausmann.roman at mh-hannover.de> wrote:

> Dear Alex, dear Jothy,
>
>
> Many thanks for Your hint to use vtkBooleanOperationPolyDataFil**ter for
> this. It basically works but it seems not completely exact. I've attached
> an image that shows two touching blobs (raw meshes generated by
> discreteMarchingCubes, in attached tbz), one is rendered yellow, the other
> as wire frame. The intersection result (code below) of
> vtkBooleanOperationPolyDataFil**ter is rendered in blue, therefore it
> looks grey where it overlaps with the yellow faces. As you can see, one
> triangle is blue nonetheless. It exists on the blob rendered as wire frame
> but has no counter part on the yellow one, therefore does not belong to the
> set of coincident faces nor does the one corner point belong to the set of
> coincident vertices.
> Since I do not really need a boolean operation (including surface
> intersections) and since Cory Quammen's publication on
> vtkBooleanOperationPolyDataFil**ter mentions that coplanar face are
> problematic and not treated specially, I thought that
> vtkDistancePolyDataFilter combined with a ThresholdBetween(0.0,0.0) on the
> point-data "Distance" would do the trick. However, I realized from a test,
> that there can be coincident vertices that do not belong to coincident
> faces. Now, I would need a method to find all faces in the second mesh
> which are made up completely by all the vertices from the first mesh with
> "Distance"==0. (Using GetPointCells for all verts with "Distance"==0 seems
> not to help here, since this way "border" cells/triangles incorporating
> only one ore two of the verts are selected as well.)
> Using "Distance"==0 for the cell-data, does not work either because it
> contains cell-to-point distance (not cell-to-cell distance). Therefore, it
> needs a ThresholdBetween(0.0, t) where t is slightly greater than 0 (I used
> t=0.01 in the code below). As the two meshes originate from marching-cubes,
> I guess an upper limit for t could be deduced from the theory which would
> still grantee that only coincident faces are selected this way, but I do
> not know for sure how to deduce this upper limit for t.
>
> Do You have any ideas how to solve this problem?
>
> Thanks for Your help or hints.
> Roman
>
> /////find and extract coincident vertices and faces of two marching cubes
> meshes
>
> #include <vtkXMLPolyDataReader.h>//for vtp-files
> // #include <vtkPolyDataReader.h>//for vtk-files
> #include <**vtkBooleanOperationPolyDataFil**ter.h>
> #include <vtkXMLPolyDataWriter.h>//for vtp-files
>
> int main(int argc, char* argv[]){
>     if( argc <= 3 )
>         {
>         std::cerr << "Usage: " << argv[0];
>         std::cerr << " inputMesh0";
>         std::cerr << " inputMesh1";
>         std::cerr << " outputMesh";
>         std::cerr << std::endl;
>         return EXIT_FAILURE;
>         }
>
>     if(!(strcasestr(argv[1],".vtp"**))) {
>         std::cout << "The input should end with .vtp" << std::endl;
>         return -1;
>         }
>
>     if(!(strcasestr(argv[2],".vtp"**))) {
>         std::cout << "The input should end with .vtp" << std::endl;
>         return -1;
>         }
>
>     //vtkPolyDataReader *reader = vtkPolyDataReader::New(); //*.vtk
>     vtkXMLPolyDataReader *reader0 = vtkXMLPolyDataReader::New(); //*.vtp
>
>     reader0->SetFileName(argv[1]);
>     reader0->Update();
>
>     vtkXMLPolyDataReader *reader1 = vtkXMLPolyDataReader::New(); //*.vtp
>
>     reader1->SetFileName(argv[2]);
>     reader1->Update();
>
>     vtkBooleanOperationPolyDataFil**ter *boolean=
> vtkBooleanOperationPolyDataFil**ter::New();
>     boolean->SetInputConnection(0, reader0->GetOutputPort());
>     boolean->SetInputConnection(1, reader1->GetOutputPort());
>     boolean->**SetOperationToIntersection();
>
>     vtkXMLPolyDataWriter *Pwriter = vtkXMLPolyDataWriter::New();
>     //vtkDataSetWriter *Pwriter = vtkDataSetWriter::New();
>
>     Pwriter->SetFileName(argv[3]);
>     Pwriter->SetInputConnection(**boolean->GetOutputPort(0));
>     Pwriter->Update();
>
>
>     return EXIT_SUCCESS;
>     }
>
> ______________________________**______________________________**_______
>
>
> /////find and extract coincident vertices and faces of two marching cubes
> meshes
> //// there can be coincident verts that do not belong to coincident
> faces!!!
>
>
> #include <vtkXMLPolyDataReader.h>//for vtp-files
> // #include <vtkPolyDataReader.h>//for vtk-files
> //#include <**vtkBooleanOperationPolyDataFil**ter.h>
> #include <vtkDistancePolyDataFilter.h>
> #include <vtkThreshold.h>
> #include <vtkGeometryFilter.h>
> #include <vtkXMLPolyDataWriter.h>//for vtp-files
>
> int main(int argc, char* argv[]){
>     if( argc != 4 )
>         {
>         std::cerr << "Usage: " << argv[0];
>         std::cerr << " inputMesh0";
>         std::cerr << " inputMesh1";
>         std::cerr << " outputMesh";
>         std::cerr << std::endl;
>         return EXIT_FAILURE;
>         }
>
>     if(!(strcasestr(argv[1],".vtp"**))) {
>         std::cout << "The input should end with .vtp" << std::endl;
>         return -1;
>         }
>
>     if(!(strcasestr(argv[2],".vtp"**))) {
>         std::cout << "The input should end with .vtp" << std::endl;
>         return -1;
>         }
>
>     if(!(strcasestr(argv[3],".vtp"**))) {
>         std::cout << "The input should end with .vtp" << std::endl;
>         return -1;
>         }
>
>     //vtkPolyDataReader *reader = vtkPolyDataReader::New(); //*.vtk
>     vtkXMLPolyDataReader *reader0 = vtkXMLPolyDataReader::New(); //*.vtp
>
>     reader0->SetFileName(argv[1]);
>     reader0->Update();
>
>     vtkXMLPolyDataReader *reader1 = vtkXMLPolyDataReader::New(); //*.vtp
>
>     reader1->SetFileName(argv[2]);
>     reader1->Update();
>
>     vtkDistancePolyDataFilter *polydist= vtkDistancePolyDataFilter::**
> New();
>     polydist->SetInputConnection(**0, reader0->GetOutputPort());
>     polydist->SetInputConnection(**1, reader1->GetOutputPort());
>     polydist->SignedDistanceOff();
>     //polydist->**ComputeSecondDistanceOff(); //causes:
>         /*
>           ERROR: In /home/grothama/sda8/programme/**
> VTK/Filtering/vtkExecutive.**cxx, line 756
>           vtkStreamingDemandDrivenPipeli**ne (0x1d2a800): Algorithm
> vtkDistancePolyDataFilter(**0x1d29890) returned failure for request:
> vtkInformation (0x1d4e040)
>           Debug: Off
>           Modified Time: 757
>           Reference Count: 1
>           Registered Events: (none)
>           Request: REQUEST_DATA
>           ALGORITHM_AFTER_FORWARD: 1
>           FROM_OUTPUT_PORT: 0
>           FORWARD_DIRECTION: 0
>         */
>     polydist->Update();
>
>     vtkThreshold *thresh= vtkThreshold::New();
>     thresh->SetInputConnection(**polydist->GetOutputPort());
>     //thresh->**SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_**ASSOCIATION_POINTS,
> "Distance"); // FIELD_ASSOCIATION_VERTICES
>     //thresh->**SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_**ASSOCIATION_POINTS,
> vtkDataSetAttributes::SCALARS)**; // FIELD_ASSOCIATION_VERTICES
>     thresh->**SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_**ASSOCIATION_CELLS,
> "Distance"); // FIELD_ASSOCIATION_VERTICES
>     //thresh->**SetAttributeModeToUsePointData**();
>     thresh->ThresholdBetween(0.0,**0.01);
>
>     vtkGeometryFilter *usg2poly= vtkGeometryFilter::New();
>     usg2poly->SetInputConnection(**thresh->GetOutputPort());
>
>     vtkXMLPolyDataWriter *Pwriter = vtkXMLPolyDataWriter::New();
>     //vtkDataSetWriter *Pwriter = vtkDataSetWriter::New();
>
>     Pwriter->SetFileName(argv[3]);
>     //Pwriter->SetInputConnection(**polydist->GetOutputPort());
>     Pwriter->SetInputConnection(**usg2poly->GetOutputPort());
>     Pwriter->Update();
>
>
>     return EXIT_SUCCESS;
>     }
>
>
>
> On 17/09/12 10:10, Roman Grothausmann wrote:
>
>>
>>
>>
>> -------- Original Message --------
>> Subject: Re: [vtkusers] AND-filter for vtkPolyData (was
>> extract/selectcoincident points/cells)
>> Date: Wed, 5 Sep 2012 10:49:20 +0200
>> From: Roman Grothausmann <roman.grothausmann at helmholtz-**berlin.de<roman.grothausmann at helmholtz-berlin.de>
>> >
>> To: alex Dowson <alexdowson at hotmail.com>, VTK Mailing List
>> <vtkusers at vtk.org>
>>
>> Hello Alex,
>>
>>
>> Many thanks for the hint, I had not thought of boolean operation for
>> this since the only overlap, ie the union, would consist only of a
>> surface, not a volume. I'll give it a try and see if it results in what
>> I need. It could work since for the meshes I look at I can rule out that
>> they could also have volume unions.
>>
>> Thanks again for Your hint
>> Roman
>>
>> On 05.09.2012 09:15, alex Dowson wrote:
>>
>>> Hi
>>>
>>> Have you tried CSG Boolean filter in VTK ? Check this class
>>>
>>> http://www.vtk.org/doc/**nightly/html/**classvtkBooleanOperationPolyDa**
>>> taFilter.html<http://www.vtk.org/doc/nightly/html/classvtkBooleanOperationPolyDataFilter.html>
>>>
>>>
>>>
>>> Also you can use implicit boolean operation filter for that.
>>>
>>>
>>>
>>>
>>> -----Original Message----- From: Roman Grothausmann
>>> Sent: Wednesday, September 05, 2012 12:42 PM
>>> To: VTK Mailing List
>>> Subject: [vtkusers] AND-filter for vtkPolyData (was
>>> extract/selectcoincident points/cells)
>>>
>>> Dear mailing list members,
>>>
>>>
>>> Is there a kind of AND-filter for vtkPolyData-meshes which I could use
>>> to extract/select coincident points/cells of two meshes?
>>>
>>> Thanks for any hints or help
>>> Roman
>>>
>>> On 31.08.2012 14:53, Roman Grothausmann wrote:
>>>
>>>> Dear mailing list members,
>>>>
>>>>
>>>> There are many filters in VTK to clean/merge coincident points but I
>>>> could not find a single filter that extracts/selects coincident
>>>> points/cells.
>>>> I would need it to extract the sub-mesh of two or more
>>>> vtkPolyData-meshes where these meshes overlap, e.g. when a
>>>> vtkDiscreteMarchingCubes surface is generated of two or more labels that
>>>> directly touch each other in voxel space.
>>>> Or is there a way to just generate a mesh of the area where both labels
>>>> touch?
>>>>
>>>> Any help or hints are very much appreciated
>>>> Roman
>>>>
>>>>
>>>
>>
> --
> Dr. Roman Grothausmann
>
> Tomographie und Digitale Bildverarbeitung
> Tomography and Digital Image Analysis
>
> Institut für Funktionelle und Angewandte Anatomie, OE 4120
> Medizinische Hochschule Hannover
> Carl-Neuberg-Str. 1
> 30625 Hannover
>
> Tel. +49 511 532-9574
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>


-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120917/a290a5a9/attachment.htm>


More information about the vtkusers mailing list