Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Michael Migliore
VTK
Commits
a12181f9
Commit
a12181f9
authored
Jun 14, 2017
by
Sujin Philip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add vtkmPolyDataNormals filter
parent
55aee9b9
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
350 additions
and
0 deletions
+350
-0
Accelerators/Vtkm/CMakeLists.txt
Accelerators/Vtkm/CMakeLists.txt
+3
-0
Accelerators/Vtkm/Testing/Cxx/CMakeLists.txt
Accelerators/Vtkm/Testing/Cxx/CMakeLists.txt
+1
-0
Accelerators/Vtkm/Testing/Cxx/TestVTKMPolyDataNormals.cxx
Accelerators/Vtkm/Testing/Cxx/TestVTKMPolyDataNormals.cxx
+153
-0
Accelerators/Vtkm/Testing/Data/Baseline/TestVTKMPolyDataNormals.png.md5
...tkm/Testing/Data/Baseline/TestVTKMPolyDataNormals.png.md5
+1
-0
Accelerators/Vtkm/vtkmFilterPolicy.h
Accelerators/Vtkm/vtkmFilterPolicy.h
+1
-0
Accelerators/Vtkm/vtkmPolyDataNormals.cu
Accelerators/Vtkm/vtkmPolyDataNormals.cu
+15
-0
Accelerators/Vtkm/vtkmPolyDataNormals.cxx
Accelerators/Vtkm/vtkmPolyDataNormals.cxx
+135
-0
Accelerators/Vtkm/vtkmPolyDataNormals.h
Accelerators/Vtkm/vtkmPolyDataNormals.h
+41
-0
No files found.
Accelerators/Vtkm/CMakeLists.txt
View file @
a12181f9
...
...
@@ -43,6 +43,7 @@ set(headers
vtkmLevelOfDetail.h
vtkmAverageToCells.h
vtkmGradient.h
vtkmPolyDataNormals.h
)
#implementation of the algorithms for cpu accelerators
...
...
@@ -60,6 +61,7 @@ set(cpu_accelerator_srcs
vtkmCellSetSingleType.cxx
vtkmConnectivityExec.cxx
vtkmGradient.cxx
vtkmPolyDataNormals.cxx
vtkmlib/Portals.cxx
vtkmlib/ImplicitFunctionConverter.cxx
)
...
...
@@ -79,6 +81,7 @@ set(cuda_accelerator_srcs
vtkmCellSetSingleType.cu
vtkmConnectivityExec.cu
vtkmGradient.cu
vtkmPolyDataNormals.cu
vtkmlib/Portals.cu
vtkmlib/ImplicitFunctionConverter.cu
)
...
...
Accelerators/Vtkm/Testing/Cxx/CMakeLists.txt
View file @
a12181f9
...
...
@@ -12,6 +12,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestVTKMLevelOfDetail.cxx
TestVTKMMarchingCubes.cxx
TestVTKMMarchingCubes2.cxx
TestVTKMPolyDataNormals.cxx
TestVTKMThreshold.cxx
TestVTKMThreshold2.cxx
)
...
...
Accelerators/Vtkm/Testing/Cxx/TestVTKMPolyDataNormals.cxx
0 → 100644
View file @
a12181f9
/*=========================================================================
Program: Visualization Toolkit
Module: TestVTKMExtractVOI.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 "vtkmPolyDataNormals.h"
#include "vtkActor.h"
#include "vtkArrowSource.h"
#include "vtkCamera.h"
#include "vtkCellCenters.h"
#include "vtkCellData.h"
#include "vtkCleanPolyData.h"
#include "vtkCylinderSource.h"
#include "vtkGlyph3D.h"
#include "vtkNew.h"
#include "vtkPointData.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkTriangleFilter.h"
namespace
{
void
MakeInputDataSet
(
vtkPolyData
*
ds
)
{
vtkNew
<
vtkCylinderSource
>
cylinder
;
cylinder
->
SetRadius
(
1.0
);
cylinder
->
SetResolution
(
8
);
cylinder
->
CappingOn
();
vtkNew
<
vtkTriangleFilter
>
triangle
;
triangle
->
SetInputConnection
(
cylinder
->
GetOutputPort
());
vtkNew
<
vtkCleanPolyData
>
clean
;
clean
->
SetInputConnection
(
triangle
->
GetOutputPort
());
clean
->
Update
();
ds
->
ShallowCopy
(
clean
->
GetOutput
());
ds
->
GetPointData
()
->
Initialize
();
ds
->
GetCellData
()
->
Initialize
();
}
}
int
TestVTKMPolyDataNormals
(
int
argc
,
char
*
argv
[])
{
vtkNew
<
vtkPolyData
>
input
;
MakeInputDataSet
(
input
.
GetPointer
());
vtkNew
<
vtkmPolyDataNormals
>
normals
;
normals
->
SetInputData
(
input
.
GetPointer
());
normals
->
ComputePointNormalsOn
();
normals
->
ComputeCellNormalsOn
();
// cylinder mapper and actor
vtkNew
<
vtkPolyDataMapper
>
cylinderMapper
;
cylinderMapper
->
SetInputData
(
input
.
GetPointer
());
vtkNew
<
vtkActor
>
cylinderActor
;
cylinderActor
->
SetMapper
(
cylinderMapper
.
GetPointer
());
vtkSmartPointer
<
vtkProperty
>
cylinderProperty
;
cylinderProperty
.
TakeReference
(
cylinderActor
->
MakeProperty
());
cylinderProperty
->
SetRepresentationToWireframe
();
cylinderProperty
->
SetColor
(
0.3
,
0.3
,
0.3
);
cylinderActor
->
SetProperty
(
cylinderProperty
.
GetPointer
());
vtkNew
<
vtkArrowSource
>
arrow
;
// point normals
vtkNew
<
vtkGlyph3D
>
pnGlyphs
;
pnGlyphs
->
SetInputConnection
(
normals
->
GetOutputPort
());
pnGlyphs
->
SetSourceConnection
(
arrow
->
GetOutputPort
());
pnGlyphs
->
SetScaleFactor
(
0.5
);
pnGlyphs
->
OrientOn
();
pnGlyphs
->
SetVectorModeToUseNormal
();
vtkNew
<
vtkPolyDataMapper
>
pnMapper
;
pnMapper
->
SetInputConnection
(
pnGlyphs
->
GetOutputPort
());
vtkNew
<
vtkActor
>
pnActor
;
pnActor
->
SetMapper
(
pnMapper
.
GetPointer
());
vtkNew
<
vtkRenderer
>
pnRenderer
;
pnRenderer
->
AddActor
(
cylinderActor
.
GetPointer
());
pnRenderer
->
AddActor
(
pnActor
.
GetPointer
());
pnRenderer
->
ResetCamera
();
pnRenderer
->
GetActiveCamera
()
->
SetPosition
(
0.0
,
4.5
,
7.5
);
// cell normals
vtkNew
<
vtkCellCenters
>
cells
;
cells
->
SetInputConnection
(
normals
->
GetOutputPort
());
vtkNew
<
vtkGlyph3D
>
cnGlyphs
;
cnGlyphs
->
SetInputConnection
(
cells
->
GetOutputPort
());
cnGlyphs
->
SetSourceConnection
(
arrow
->
GetOutputPort
());
cnGlyphs
->
SetScaleFactor
(
0.5
);
cnGlyphs
->
OrientOn
();
cnGlyphs
->
SetVectorModeToUseNormal
();
vtkNew
<
vtkPolyDataMapper
>
cnMapper
;
cnMapper
->
SetInputConnection
(
cnGlyphs
->
GetOutputPort
());
vtkNew
<
vtkActor
>
cnActor
;
cnActor
->
SetMapper
(
cnMapper
.
GetPointer
());
vtkNew
<
vtkRenderer
>
cnRenderer
;
cnRenderer
->
AddActor
(
cylinderActor
.
GetPointer
());
cnRenderer
->
AddActor
(
cnActor
.
GetPointer
());
cnRenderer
->
ResetCamera
();
cnRenderer
->
GetActiveCamera
()
->
SetPosition
(
0.0
,
8.0
,
0.1
);
// render
vtkNew
<
vtkRenderWindow
>
renWin
;
renWin
->
SetSize
(
600
,
300
);
pnRenderer
->
SetViewport
(
0.0
,
0.0
,
0.5
,
1.0
);
renWin
->
AddRenderer
(
pnRenderer
.
GetPointer
());
cnRenderer
->
SetViewport
(
0.5
,
0.0
,
1.0
,
1.0
);
renWin
->
AddRenderer
(
cnRenderer
.
GetPointer
());
vtkNew
<
vtkRenderWindowInteractor
>
iren
;
iren
->
SetRenderWindow
(
renWin
.
GetPointer
());
iren
->
Initialize
();
renWin
->
Render
();
int
retVal
=
vtkRegressionTestImage
(
renWin
.
GetPointer
());
if
(
retVal
==
vtkRegressionTester
::
DO_INTERACTOR
)
{
iren
->
Start
();
}
return
!
retVal
;
}
Accelerators/Vtkm/Testing/Data/Baseline/TestVTKMPolyDataNormals.png.md5
0 → 100644
View file @
a12181f9
27479f1dc3745f0a8cec5bf401a429cf
Accelerators/Vtkm/vtkmFilterPolicy.h
View file @
a12181f9
...
...
@@ -203,6 +203,7 @@ struct CellListUnstructuredInVTK
struct
CellListUnstructuredOutVTK
:
vtkm
::
ListTagBase
<
vtkm
::
cont
::
CellSetExplicit
<>
,
vtkm
::
cont
::
CellSetSingleType
<>
,
vtkm
::
cont
::
vtkmCellSetExplicitAOS
,
vtkm
::
cont
::
vtkmCellSetSingleType
,
vtkm
::
cont
::
CellSetPermutation
<
vtkm
::
cont
::
vtkmCellSetExplicitAOS
>
,
vtkm
::
cont
::
CellSetPermutation
<
vtkm
::
cont
::
vtkmCellSetSingleType
>>
{
...
...
Accelerators/Vtkm/vtkmPolyDataNormals.cu
0 → 100644
View file @
a12181f9
/*=========================================================================
Program: Visualization Toolkit
Module: vtkmPolyDataNormals.cu
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 "vtkmPolyDataNormals.cxx"
Accelerators/Vtkm/vtkmPolyDataNormals.cxx
0 → 100644
View file @
a12181f9
/*=========================================================================
Program: Visualization Toolkit
Module: vtkmPolyDataNormals.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 "vtkmPolyDataNormals.h"
#include "vtkCellData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkSmartPointer.h"
#include "vtkmlib/ArrayConverters.h"
#include "vtkmlib/PolyDataConverter.h"
#include "vtkmlib/Storage.h"
#include "vtkmCellSetExplicit.h"
#include "vtkmCellSetSingleType.h"
#include "vtkmFilterPolicy.h"
#include "vtkm/filter/SurfaceNormals.h"
vtkStandardNewMacro
(
vtkmPolyDataNormals
)
//------------------------------------------------------------------------------
void
vtkmPolyDataNormals
::
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
)
{
this
->
Superclass
::
PrintSelf
(
os
,
indent
);
}
//------------------------------------------------------------------------------
vtkmPolyDataNormals
::
vtkmPolyDataNormals
()
{
// change defaults from parent
this
->
Splitting
=
0
;
this
->
Consistency
=
0
;
this
->
FlipNormals
=
0
;
this
->
ComputePointNormals
=
1
;
this
->
ComputeCellNormals
=
0
;
this
->
AutoOrientNormals
=
0
;
}
//------------------------------------------------------------------------------
vtkmPolyDataNormals
::~
vtkmPolyDataNormals
()
=
default
;
//------------------------------------------------------------------------------
int
vtkmPolyDataNormals
::
RequestData
(
vtkInformation
*
request
,
vtkInformationVector
**
inputVector
,
vtkInformationVector
*
outputVector
)
{
// get the info objects
vtkInformation
*
inInfo
=
inputVector
[
0
]
->
GetInformationObject
(
0
);
vtkInformation
*
outInfo
=
outputVector
->
GetInformationObject
(
0
);
// get the input and output
vtkPolyData
*
input
=
vtkPolyData
::
SafeDownCast
(
inInfo
->
Get
(
vtkDataObject
::
DATA_OBJECT
()));
vtkPolyData
*
output
=
vtkPolyData
::
SafeDownCast
(
outInfo
->
Get
(
vtkDataObject
::
DATA_OBJECT
()));
// convert the input dataset to a vtkm::cont::DataSet
vtkm
::
cont
::
DataSet
in
=
tovtkm
::
Convert
(
input
);
if
(
in
.
GetNumberOfCoordinateSystems
()
<=
0
||
in
.
GetNumberOfCellSets
()
<=
0
)
{
vtkErrorMacro
(
<<
"Could not convert vtk dataset to vtkm dataset"
);
return
0
;
}
vtkmInputFilterPolicy
policy
;
vtkm
::
cont
::
DataSet
out
;
// check for flags that vtkm filter cannot handle
bool
unsupported
=
this
->
Splitting
||
this
->
Consistency
||
this
->
FlipNormals
;
bool
vtkmSuccess
=
false
;
if
(
!
unsupported
)
{
vtkm
::
filter
::
SurfaceNormals
filter
;
filter
.
SetGenerateCellNormals
(
this
->
ComputeCellNormals
);
filter
.
SetCellNormalsName
(
"Normals"
);
filter
.
SetGeneratePointNormals
(
this
->
ComputePointNormals
);
filter
.
SetPointNormalsName
(
"Normals"
);
auto
result
=
filter
.
Execute
(
in
,
policy
);
if
(
result
.
IsValid
())
{
out
=
result
.
GetDataSet
();
vtkmSuccess
=
true
;
}
}
if
(
!
vtkmSuccess
)
{
vtkWarningMacro
(
<<
"VTKm SurfaceNormals algorithm failed to run"
<<
(
unsupported
?
": unsupported settings."
:
"."
)
<<
"Falling back to vtkPolyDataNormals."
);
return
this
->
Superclass
::
RequestData
(
request
,
inputVector
,
outputVector
);
}
if
(
!
fromvtkm
::
Convert
(
out
,
output
,
input
))
{
vtkErrorMacro
(
<<
"Unable to convert VTKm DataSet back to VTK"
);
return
0
;
}
vtkSmartPointer
<
vtkDataArray
>
pointNormals
=
output
->
GetPointData
()
->
GetArray
(
"Normals"
);
vtkSmartPointer
<
vtkDataArray
>
cellNormals
=
output
->
GetCellData
()
->
GetArray
(
"Normals"
);
output
->
GetPointData
()
->
CopyNormalsOff
();
output
->
GetPointData
()
->
PassData
(
input
->
GetPointData
());
output
->
GetCellData
()
->
CopyNormalsOff
();
output
->
GetCellData
()
->
PassData
(
input
->
GetPointData
());
if
(
pointNormals
)
{
output
->
GetPointData
()
->
SetNormals
(
pointNormals
.
GetPointer
());
}
if
(
cellNormals
)
{
output
->
GetCellData
()
->
SetNormals
(
cellNormals
.
GetPointer
());
}
return
1
;
}
Accelerators/Vtkm/vtkmPolyDataNormals.h
0 → 100644
View file @
a12181f9
/*=========================================================================
Program: Visualization Toolkit
Module: vtkmPolyDataNormals.h
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.
=========================================================================*/
#ifndef vtkmPolyDataNormals_h
#define vtkmPolyDataNormals_h
#include "vtkPolyDataNormals.h"
#include "vtkAcceleratorsVTKmModule.h" // for export macro
class
VTKACCELERATORSVTKM_EXPORT
vtkmPolyDataNormals
:
public
vtkPolyDataNormals
{
public:
vtkTypeMacro
(
vtkmPolyDataNormals
,
vtkPolyDataNormals
)
void
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
)
VTK_OVERRIDE
;
static
vtkmPolyDataNormals
*
New
();
protected:
vtkmPolyDataNormals
();
~
vtkmPolyDataNormals
();
int
RequestData
(
vtkInformation
*
,
vtkInformationVector
**
,
vtkInformationVector
*
)
VTK_OVERRIDE
;
private:
vtkmPolyDataNormals
(
const
vtkmPolyDataNormals
&
)
VTK_DELETE_FUNCTION
;
void
operator
=
(
const
vtkmPolyDataNormals
&
)
VTK_DELETE_FUNCTION
;
};
#endif // vtkmPolyDataNormals_h
// VTK-HeaderTest-Exclude: vtkmPolyDataNormals.h
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment