Commit 06377931 authored by Cory Quammen's avatar Cory Quammen Committed by Kitware Robot
Browse files

Merge topic 'new_intersection'

7c50bd1e STYLE: Indentation and spaces pass
ffa7b459 Code changes per my review
482a51a2 Added new baseline for IntersectionPolyDataFilter3 test
2881f01c Added another test for intersection
6b2f5934 Braces indented and underscores in header removed
b09f1173 spaces after commas
bfc6d594

 Replaced the current Intersection filter with one with bug fixes
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1516
parents e9ec7be9 7c50bd1e
......@@ -26,6 +26,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestDistancePolyDataFilter.cxx
TestGraphWeightEuclideanDistanceFilter.cxx,NO_VALID
TestImageDataToPointSet.cxx,NO_VALID
TestIntersectionPolyDataFilter3.cxx
TestIntersectionPolyDataFilter2.cxx,NO_VALID
TestIntersectionPolyDataFilter.cxx
TestRectilinearGridToPointSet.cxx,NO_VALID
......@@ -57,4 +58,4 @@ if(NOT VTK_TEST_TIMEOUT_TestYoungsMaterialInterface)
set(VTK_TEST_TIMEOUT_TestYoungsMaterialInterface 300)
endif()
set_tests_properties(${vtk-module}Cxx-TestYoungsMaterialInterface
PROPERTIES TIMEOUT ${VTK_TEST_TIMEOUT_TestYoungsMaterialInterface})
\ No newline at end of file
PROPERTIES TIMEOUT ${VTK_TEST_TIMEOUT_TestYoungsMaterialInterface})
......@@ -46,6 +46,8 @@ int TestIntersectionPolyDataFilter2(int, char *[])
27.6875,
-27.4375};
double surfaceid[2];
double tolerance = 1e-6;
int intersects = vtkIntersectionPolyDataFilter
::TriangleTriangleIntersection(&thisCellTri[0],
&thisCellTri[3],
......@@ -54,7 +56,8 @@ int TestIntersectionPolyDataFilter2(int, char *[])
&otherCellTri[3],
&otherCellTri[6],
coplanar,
isectpt1, isectpt2);
isectpt1, isectpt2,
surfaceid, tolerance);
std::cerr << "First: "
<< thisCellTri[0] << ", "
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestIntersectionPolyDataFilter3.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <vtkIntersectionPolyDataFilter.h>
#include <vtkActor.h>
#include <vtkConeSource.h>
#include <vtkCubeSource.h>
#include <vtkLinearSubdivisionFilter.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkTriangleFilter.h>
int TestIntersectionPolyDataFilter3(int, char *[])
{
vtkSmartPointer<vtkCubeSource> cubeSource =
vtkSmartPointer<vtkCubeSource>::New();
cubeSource->SetCenter(0.0, 0.0, 0.0);
cubeSource->SetXLength(1.0);
cubeSource->SetYLength(1.0);
cubeSource->SetZLength(1.0);
cubeSource->Update();
vtkSmartPointer<vtkTriangleFilter> cubetriangulator =
vtkSmartPointer<vtkTriangleFilter>::New();
cubetriangulator->SetInputConnection(cubeSource->GetOutputPort());
vtkSmartPointer<vtkLinearSubdivisionFilter> cubesubdivider =
vtkSmartPointer<vtkLinearSubdivisionFilter>::New();
cubesubdivider->SetInputConnection(cubetriangulator->GetOutputPort());
cubesubdivider->SetNumberOfSubdivisions(3);
vtkSmartPointer<vtkPolyDataMapper> cubeMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
cubeMapper->SetInputConnection( cubesubdivider->GetOutputPort() );
cubeMapper->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> cubeActor =
vtkSmartPointer<vtkActor>::New();
cubeActor->SetMapper( cubeMapper );
cubeActor->GetProperty()->SetOpacity(.3);
cubeActor->GetProperty()->SetColor(1,0,0);
cubeActor->GetProperty()->SetInterpolationToFlat();
vtkSmartPointer<vtkConeSource> coneSource =
vtkSmartPointer<vtkConeSource>::New();
coneSource->SetCenter(0.0, 0.0, 0.0);
coneSource->SetRadius(0.5);
coneSource->SetHeight(2.0);
coneSource->SetResolution(10.0);
coneSource->SetDirection(1,0,0);
vtkSmartPointer<vtkTriangleFilter> conetriangulator =
vtkSmartPointer<vtkTriangleFilter>::New();
conetriangulator->SetInputConnection(coneSource->GetOutputPort());
vtkSmartPointer<vtkLinearSubdivisionFilter> conesubdivider =
vtkSmartPointer<vtkLinearSubdivisionFilter>::New();
conesubdivider->SetInputConnection(conetriangulator->GetOutputPort());
conesubdivider->SetNumberOfSubdivisions(3);
vtkSmartPointer<vtkPolyDataMapper> coneMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
coneMapper->SetInputConnection( conesubdivider->GetOutputPort() );
coneMapper->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> coneActor =
vtkSmartPointer<vtkActor>::New();
coneActor->SetMapper( coneMapper );
coneActor->GetProperty()->SetOpacity(.3);
coneActor->GetProperty()->SetColor(0,1,0);
coneActor->GetProperty()->SetInterpolationToFlat();
vtkSmartPointer<vtkIntersectionPolyDataFilter> intersectionPolyDataFilter =
vtkSmartPointer<vtkIntersectionPolyDataFilter>::New();
intersectionPolyDataFilter->SetInputConnection( 0, cubesubdivider->GetOutputPort() );
intersectionPolyDataFilter->SetInputConnection( 1, conesubdivider->GetOutputPort() );
intersectionPolyDataFilter->SetSplitFirstOutput(0);
intersectionPolyDataFilter->SetSplitSecondOutput(0);
intersectionPolyDataFilter->Update();
vtkSmartPointer<vtkPolyDataMapper> intersectionMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
intersectionMapper->SetInputConnection( intersectionPolyDataFilter->GetOutputPort() );
intersectionMapper->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> intersectionActor =
vtkSmartPointer<vtkActor>::New();
intersectionActor->SetMapper( intersectionMapper );
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->AddViewProp(cubeActor);
renderer->AddViewProp(coneActor);
renderer->AddViewProp(intersectionActor);
renderer->SetBackground(.1, .2, .3);
vtkSmartPointer<vtkRenderWindow> renderWindow
= vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer( renderer );
vtkSmartPointer<vtkRenderWindowInteractor> renWinInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renWinInteractor->SetRenderWindow( renderWindow );
intersectionPolyDataFilter->Print(std::cout);
renderWindow->Render();
renWinInteractor->Start();
return EXIT_SUCCESS;
}
......@@ -6,6 +6,7 @@ vtk_module(vtkFiltersGeneral
vtkFiltersCore
TEST_DEPENDS
vtkFiltersFlowPaths
vtkFiltersModeling
vtkIOLegacy
vtkIOXML
vtkImagingMath
......
......@@ -17,16 +17,43 @@
//
// vtkIntersectionPolyDataFilter computes the intersection between two
// vtkPolyData objects. The first output is a set of lines that marks
// the intersection of the input vtkPolyData objects. The second and
// third outputs are the first and second input vtkPolyData,
// the intersection of the input vtkPolyData objects. This contains five
// different attached data arrays:
//
// SurfaceID: Point data array that contains information about the origin
// surface of each point
//
// Input0CellID: Cell data array that contains the original
// cell ID number on the first input mesh
//
// Input1CellID: Cell data array that contains the original
// cell ID number on the second input mesh
//
// NewCell0ID: Cell data array that contains information about which cells
// of the remeshed first input surface it touches (If split)
//
// NewCell1ID: Cell data array that contains information about which cells
// on the remeshed second input surface it touches (If split)
//
// The second and third outputs are the first and second input vtkPolyData,
// respectively. Optionally, the two output vtkPolyData can be split
// along the intersection lines.
// along the intersection lines by remeshing. Optionally, the surface
// can be cleaned and checked at the end of the remeshing.
// If the meshes are split, The output vtkPolyDatas contain three possible
// data arrays:
//
// IntersectionPoint: This is a boolean indicating whether or not the point is
// on the boundary of the two input objects
//
// This code was contributed in the Insight Journal paper:
// "Boolean Operations on Surfaces in VTK Without External Libraries"
// by Cory Quammen, Chris Weigle C., Russ Taylor
// http://hdl.handle.net/10380/3262
// http://www.insight-journal.org/browse/publication/797
// BadTriangle: If the surface is cleaned and checked, this is a cell data array
// indicating whether or not the cell has edges with multiple neighbors
// A manifold surface will have 0 everywhere for this array!
//
// FreeEdge: If the surface is cleaned and checked, this is a cell data array
// indicating if the cell has any free edges. A watertight surface will have
// 0 everywhere for this array!
//
// Author: Adam Updegrove updega2@gmail.com
#ifndef vtkIntersectionPolyDataFilter_h
#define vtkIntersectionPolyDataFilter_h
......@@ -34,13 +61,19 @@
#include "vtkFiltersGeneralModule.h" // For export macro
#include "vtkPolyDataAlgorithm.h"
class VTKFILTERSGENERAL_EXPORT vtkIntersectionPolyDataFilter : public vtkPolyDataAlgorithm
class VTKFILTERSGENERAL_EXPORT vtkIntersectionPolyDataFilter :
public vtkPolyDataAlgorithm
{
public:
static vtkIntersectionPolyDataFilter *New();
vtkTypeMacro(vtkIntersectionPolyDataFilter, vtkPolyDataAlgorithm);
virtual void PrintSelf(ostream &os, vtkIndent indent);
// Description:
// Integer describing the number of intersection points and lines
vtkGetMacro(NumberOfIntersectionPoints, int);
vtkGetMacro(NumberOfIntersectionLines, int);
// Description:
// If on, the second output will be the first input mesh split by the
// intersection with the second input mesh. Defaults to on.
......@@ -55,31 +88,87 @@ public:
vtkSetMacro(SplitSecondOutput, int);
vtkBooleanMacro(SplitSecondOutput, int);
// Description:
// If on, the output split surfaces will contain information about which
// points are on the intersection of the two inputs. Default: ON
vtkGetMacro(ComputeIntersectionPointArray, int);
vtkSetMacro(ComputeIntersectionPointArray, int);
vtkBooleanMacro(ComputeIntersectionPointArray, int);
// Description:
// If on, the normals of the input will be checked. Default: OFF
vtkGetMacro(CheckInput, int);
vtkSetMacro(CheckInput, int);
vtkBooleanMacro(CheckInput, int);
// Description:
// If on, the output remeshed surfaces will be checked for bad cells and
// free edges. Default: ON
vtkGetMacro(CheckMesh, int);
vtkSetMacro(CheckMesh, int);
vtkBooleanMacro(CheckMesh, int);
// Description:
// Check the status of the filter after update. If the status is zero,
// there was an error in the operation. If status is one, everything
// went smoothly
vtkGetMacro(Status, int);
// Description:
// The tolerance for geometric tests in the filter
vtkGetMacro(Tolerance, double);
vtkSetMacro(Tolerance, double);
// Description:
// Given two triangles defined by points (p1, q1, r1) and (p2, q2,
// r2), returns whether the two triangles intersect. If they do,
// the endpoints of the line forming the intersection are returned
// in pt1 and pt2. The parameter coplanar is set to 1 if the
// triangles are coplanar and 0 otherwise.
static int TriangleTriangleIntersection(double p1[3], double q1[3], double r1[3],
double p2[3], double q2[3], double r2[3],
int &coplanar, double pt1[3], double pt2[3]);
// triangles are coplanar and 0 otherwise. The surfaceid array
// is filled with the surface on which the first and second
// intersection points resides, respectively. A geometric tolerance
// can be specified in the last argument.
static int TriangleTriangleIntersection(double p1[3], double q1[3],
double r1[3], double p2[3],
double q2[3], double r2[3],
int &coplanar, double pt1[3],
double pt2[3], double surfaceid[2],
double tolerance);
// Description:
// Function to clean and check the output surfaces for bad triangles and
// free edges
static void CleanAndCheckSurface(vtkPolyData *pd, double stats[2],
double tolerance);
// Description:
// Function to clean and check the inputs
static void CleanAndCheckInput(vtkPolyData *pd, double tolerance);
protected:
vtkIntersectionPolyDataFilter();
~vtkIntersectionPolyDataFilter();
vtkIntersectionPolyDataFilter(); //Constructor
~vtkIntersectionPolyDataFilter(); //Destructor
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*);
int FillInputPortInformation(int, vtkInformation*);
int RequestData(vtkInformation*, vtkInformationVector**,
vtkInformationVector*); //Update
int FillInputPortInformation(int, vtkInformation*); //Input,Output
private:
vtkIntersectionPolyDataFilter(const vtkIntersectionPolyDataFilter&); // Not implemented
void operator=(const vtkIntersectionPolyDataFilter&); // Not implemented
vtkIntersectionPolyDataFilter(const vtkIntersectionPolyDataFilter&); // Not implemented
void operator=(const vtkIntersectionPolyDataFilter&); // Not implemented
int NumberOfIntersectionPoints;
int NumberOfIntersectionLines;
int SplitFirstOutput;
int SplitSecondOutput;
int ComputeIntersectionPointArray;
int CheckMesh;
int CheckInput;
int Status;
double Tolerance;
class Impl;
class Impl; //Implementation class
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment