[Insight-users] [vtkusers] AND-filter for vtkPolyData (was extract/selectcoincident points/cells)

alex Dowson alexdowson at hotmail.com
Tue Sep 18 23:54:42 EDT 2012


Dear Roman

You can download from given link using SVN.

http://code.google.com/p/carve/

Also let me know what is result when you test it .


Alex




-----Original Message----- 
From: Dr. Roman Grothausmann
Sent: Tuesday, September 18, 2012 7:12 PM
To: alex Dowson
Subject: Re: [vtkusers] AND-filter for vtkPolyData (was 
extract/selectcoincident points/cells)

Dear Alex,

On 18/09/12 15:17, alex Dowson wrote:
> I had used carve CSG
> library was good. You can check also that with loading ply or stl file
> directly.

Is that the one You mean: http://carve-csg.com/ ? I can't find a
download link, did You ask for it by email?

Thanks
Roman

>
>
> Alex
>
>
> -----Original Message----- From: Dr. Roman Grothausmann
> Sent: Tuesday, September 18, 2012 6:39 PM
> To: alex Dowson
> Cc: VTK Mailing List
> Subject: Re: [vtkusers] AND-filter for vtkPolyData (was
> extract/selectcoincident points/cells)
>
> Dear Alex,
>
>
> Thanks for Your quick reply.
>
> On 18/09/12 08:54, alex Dowson wrote:
>> I seen your mesh data but I am not understand what you want to do ?
>
> The two meshes originate from DiscreteMarchingCubes, which as Bill
> wrote, generates coincident faces on two adjacent segmented surfaces,
> i.e. adjacent labels in a voxel data set.
>
> I want to extract all coincident faces, i.e. the faces that both meshes
> share where they "touch".
> The vtkBooleanOperationPolyDataFilter result
> (intersec_3284-3307_raw.vtp) is very close, except for one triangle (the
> blue one in intersec_3284-3307_raw_03_01.png), that does not meet this
> requirement to have a coincident counter part in the other mesh. As it
> is said in the article describing vtkBooleanOperationPolyDataFilter, it
> has problems with coplanar trangles. Since coincident triangles are also
> coplanar, I expect the inappropriate triangle in the result originates
> from this unhandled coplanar cases. Amazingly, the result is nonetheless
> quite good.
>
> I noticed now, that the one vertex, that has no coincident
> counter-vertex on the other mesh, has a "Distance" > 0 (as it should
> be). Therefore, I can remove it (and the resulting inappropriate
> triangle, blue) just with vtkThreshold.
> However, when I run the code on many different meshes, I'd like to be
> sure that no other similar cases arise (possible not handled properly
> with just an additional vtkThreshold).
>
>> 1) Do you want to join this two mesh in single ?
>
> No. I want to extract their intersection that, in this special case,
> only consists of coincident faces, i.e. has no volume.
>
>> 2) Because there is only small part to intersection since it's boundary
>> does not overlap. See in images has two parts you can see only small
>> part is overlap and that will be ur final result
>> from intersection and that's it producing right now.
>
> Nearly, the one blue excess triangle (and the mentioned problems with
> coplanar triangles in the describing text for
> vtkBooleanOperationPolyDataFilter) worries me.
>
> Many thanks for looking into this.
> Roman
>
>>
>>
>> -----Original Message----- From: Dr. Roman Grothausmann
>> Sent: Tuesday, September 18, 2012 11:29 AM
>> To: alex Dowson
>> Subject: Re: [vtkusers] AND-filter for vtkPolyData (was
>> extract/selectcoincident points/cells)
>>
>> Dear Alex!
>>
>>
>> n 18/09/12 06:43, alex Dowson wrote:
>>> Dear Dr.Roman
>>>
>>> can you show picture of your two input mesh or vtp file ?
>>
>> An visualization and the vtp files are in the tbz of my last post. I
>> attached them here as well.
>>
>> Many thanks for looking into this
>> Roman
>>
>>
>>>
>>>
>>> alex
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> -----Original Message----- From: Dr. Roman Grothausmann
>>> Sent: Monday, September 17, 2012 7:03 PM
>>> To: alexdowson at hotmail.com ; jothybasu at gmail.com
>>> Cc: VTK Mailing List ; Cory Quammen
>>> Subject: Re: Fwd: Re: [vtkusers] AND-filter for vtkPolyData (was
>>> extract/selectcoincident points/cells)
>>>
>>> Dear Alex, dear Jothy,
>>>
>>>
>>> Many thanks for Your hint to use vtkBooleanOperationPolyDataFilter 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
>>> vtkBooleanOperationPolyDataFilter 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
>>> vtkBooleanOperationPolyDataFilter 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 <vtkBooleanOperationPolyDataFilter.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();
>>>
>>> vtkBooleanOperationPolyDataFilter *boolean=
>>> vtkBooleanOperationPolyDataFilter::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 <vtkBooleanOperationPolyDataFilter.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
>>> vtkStreamingDemandDrivenPipeline (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>
>>>> 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/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 



More information about the Insight-users mailing list