Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Michael Migliore
VTK
Commits
342ae7ee
Commit
342ae7ee
authored
Jun 14, 2017
by
Sujin Philip
Browse files
Add vtkmTriangleMeshPointNormals filter
parent
a12181f9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Accelerators/Vtkm/CMakeLists.txt
View file @
342ae7ee
...
...
@@ -44,6 +44,7 @@ set(headers
vtkmAverageToCells.h
vtkmGradient.h
vtkmPolyDataNormals.h
vtkmTriangleMeshPointNormals.h
)
#implementation of the algorithms for cpu accelerators
...
...
@@ -62,6 +63,7 @@ set(cpu_accelerator_srcs
vtkmConnectivityExec.cxx
vtkmGradient.cxx
vtkmPolyDataNormals.cxx
vtkmTriangleMeshPointNormals.cxx
vtkmlib/Portals.cxx
vtkmlib/ImplicitFunctionConverter.cxx
)
...
...
@@ -82,6 +84,7 @@ set(cuda_accelerator_srcs
vtkmConnectivityExec.cu
vtkmGradient.cu
vtkmPolyDataNormals.cu
vtkmTriangleMeshPointNormals.cu
vtkmlib/Portals.cu
vtkmlib/ImplicitFunctionConverter.cu
)
...
...
Accelerators/Vtkm/Testing/Cxx/CMakeLists.txt
View file @
342ae7ee
...
...
@@ -15,6 +15,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestVTKMPolyDataNormals.cxx
TestVTKMThreshold.cxx
TestVTKMThreshold2.cxx
TestVTKMTriangleMeshPointNormals.cxx
)
vtk_test_cxx_executable
(
${
vtk-module
}
CxxTests tests
RENDERING_FACTORY
...
...
Accelerators/Vtkm/Testing/Cxx/TestVTKMTriangleMeshPointNormals.cxx
0 → 100644
View file @
342ae7ee
/*=========================================================================
Program: Visualization Toolkit
Module: TestVTKMTriangleMeshPointNormals.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
"vtkActor.h"
#include
"vtkArrowSource.h"
#include
"vtkCamera.h"
#include
"vtkCleanPolyData.h"
#include
"vtkGlyph3D.h"
#include
"vtkInteractorStyleTrackballCamera.h"
#include
"vtkNew.h"
#include
"vtkPolyDataMapper.h"
#include
"vtkRegressionTestImage.h"
#include
"vtkRenderer.h"
#include
"vtkRenderWindow.h"
#include
"vtkRenderWindowInteractor.h"
#include
"vtkTesting.h"
#include
"vtkTriangleFilter.h"
#include
"vtkmTriangleMeshPointNormals.h"
#include
"vtkXMLPolyDataReader.h"
int
TestVTKMTriangleMeshPointNormals
(
int
argc
,
char
*
argv
[])
{
vtkSmartPointer
<
vtkTesting
>
testHelper
=
vtkSmartPointer
<
vtkTesting
>::
New
();
testHelper
->
AddArguments
(
argc
,
argv
);
if
(
!
testHelper
->
IsFlagSpecified
(
"-D"
))
{
std
::
cerr
<<
"Error: -D /path/to/data was not specified."
;
return
EXIT_FAILURE
;
}
std
::
string
dataRoot
=
testHelper
->
GetDataRoot
();
std
::
string
fileName
=
dataRoot
+
"/Data/cow.vtp"
;
std
::
cout
<<
fileName
<<
std
::
endl
;
// reader
vtkNew
<
vtkXMLPolyDataReader
>
reader
;
reader
->
SetFileName
(
fileName
.
c_str
());
// triangle filter
vtkNew
<
vtkTriangleFilter
>
triFilter
;
triFilter
->
SetInputConnection
(
reader
->
GetOutputPort
());
// cleaning filter
vtkNew
<
vtkCleanPolyData
>
cleanFilter
;
cleanFilter
->
SetInputConnection
(
triFilter
->
GetOutputPort
());
// normals
vtkNew
<
vtkmTriangleMeshPointNormals
>
normFilter
;
normFilter
->
SetInputConnection
(
cleanFilter
->
GetOutputPort
());
// mapper, actor
vtkNew
<
vtkPolyDataMapper
>
mapper
;
mapper
->
SetInputConnection
(
normFilter
->
GetOutputPort
());
vtkNew
<
vtkActor
>
actor
;
actor
->
SetMapper
(
mapper
.
GetPointer
());
// glyphs
vtkNew
<
vtkArrowSource
>
glyphsource
;
vtkNew
<
vtkGlyph3D
>
glyph
;
glyph
->
SetInputConnection
(
normFilter
->
GetOutputPort
());
glyph
->
SetSourceConnection
(
glyphsource
->
GetOutputPort
());
glyph
->
SetVectorModeToUseNormal
();
glyph
->
SetColorModeToColorByVector
();
glyph
->
SetScaleModeToScaleByVector
();
glyph
->
SetScaleFactor
(
0.5
);
vtkNew
<
vtkPolyDataMapper
>
glyphmapper
;
glyphmapper
->
SetInputConnection
(
glyph
->
GetOutputPort
());
vtkNew
<
vtkActor
>
glyphactor
;
glyphactor
->
SetMapper
(
glyphmapper
.
GetPointer
());
// renderer
vtkNew
<
vtkRenderer
>
renderer
;
renderer
->
AddActor
(
actor
.
GetPointer
());
renderer
->
AddActor
(
glyphactor
.
GetPointer
());
renderer
->
SetBackground
(
0.0
,
0.0
,
0.0
);
renderer
->
ResetCamera
();
// renderwindow, interactor
vtkNew
<
vtkRenderWindow
>
renWin
;
renWin
->
AddRenderer
(
renderer
.
GetPointer
());
renWin
->
SetSize
(
300
,
300
);
renWin
->
SetMultiSamples
(
0
);
vtkNew
<
vtkRenderWindowInteractor
>
iren
;
iren
->
SetRenderWindow
(
renWin
.
GetPointer
());
iren
->
Initialize
();
renWin
->
Render
();
int
retVal
=
vtkRegressionTestImage
(
renWin
.
GetPointer
());
if
(
retVal
==
vtkRegressionTester
::
DO_INTERACTOR
)
{
vtkNew
<
vtkInteractorStyleTrackballCamera
>
iStyle
;
iren
->
SetInteractorStyle
(
iStyle
.
GetPointer
());
renWin
->
SetSize
(
1000
,
1000
);
iren
->
Start
();
}
return
!
retVal
;
}
Accelerators/Vtkm/Testing/Data/Baseline/TestVTKMTriangleMeshPointNormals.png.md5
0 → 100644
View file @
342ae7ee
569e622f83dc58a6c9dcc614a4ed621f
Accelerators/Vtkm/vtkmTriangleMeshPointNormals.cu
0 → 100644
View file @
342ae7ee
/*=========================================================================
Program: Visualization Toolkit
Module: vtkmTriangleMeshPointNormals.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
"vtkmTriangleMeshPointNormals.cxx"
Accelerators/Vtkm/vtkmTriangleMeshPointNormals.cxx
0 → 100644
View file @
342ae7ee
/*=========================================================================
Program: Visualization Toolkit
Module: vtkmTriangleMeshPointNormals.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
"vtkmTriangleMeshPointNormals.h"
#include
"vtkCellArray.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"
namespace
{
struct
InputFilterPolicy
:
public
vtkmInputFilterPolicy
{
using
UnstructuredCellSetList
=
vtkm
::
ListTagBase
<
vtkm
::
cont
::
vtkmCellSetSingleType
>
;
};
}
vtkStandardNewMacro
(
vtkmTriangleMeshPointNormals
)
//------------------------------------------------------------------------------
void
vtkmTriangleMeshPointNormals
::
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
)
{
this
->
Superclass
::
PrintSelf
(
os
,
indent
);
}
//------------------------------------------------------------------------------
vtkmTriangleMeshPointNormals
::
vtkmTriangleMeshPointNormals
()
=
default
;
vtkmTriangleMeshPointNormals
::~
vtkmTriangleMeshPointNormals
()
=
default
;
//------------------------------------------------------------------------------
int
vtkmTriangleMeshPointNormals
::
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
()));
// check if polydata is in supported format
if
(
input
->
GetVerts
()
->
GetNumberOfCells
()
!=
0
||
input
->
GetLines
()
->
GetNumberOfCells
()
!=
0
||
input
->
GetStrips
()
->
GetNumberOfCells
()
!=
0
||
(
input
->
GetPolys
()
->
GetNumberOfConnectivityEntries
()
%
4
)
!=
0
)
{
vtkErrorMacro
(
<<
"This filter only works with polydata containing just triangles."
);
return
0
;
}
// 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
;
}
vtkm
::
filter
::
PolicyBase
<
InputFilterPolicy
>
policy
;
vtkm
::
filter
::
SurfaceNormals
filter
;
filter
.
SetGenerateCellNormals
(
false
);
filter
.
SetGeneratePointNormals
(
true
);
filter
.
SetPointNormalsName
(
"Normals"
);
auto
result
=
filter
.
Execute
(
in
,
policy
);
if
(
!
result
.
IsValid
())
{
vtkWarningMacro
(
<<
"VTKm SurfaceNormals algorithm failed to run."
<<
"Falling back to vtkTriangleMeshPointNormals."
);
return
this
->
Superclass
::
RequestData
(
request
,
inputVector
,
outputVector
);
}
if
(
!
fromvtkm
::
Convert
(
result
.
GetDataSet
(),
output
,
input
))
{
vtkErrorMacro
(
<<
"Unable to convert VTKm DataSet back to VTK"
);
return
0
;
}
vtkSmartPointer
<
vtkDataArray
>
pointNormals
=
output
->
GetPointData
()
->
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
());
}
return
1
;
}
Accelerators/Vtkm/vtkmTriangleMeshPointNormals.h
0 → 100644
View file @
342ae7ee
/*=========================================================================
Program: Visualization Toolkit
Module: vtkmTriangleMeshPointNormals.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 vtkmTriangleMeshPointNormals_h
#define vtkmTriangleMeshPointNormals_h
#include
"vtkTriangleMeshPointNormals.h"
#include
"vtkAcceleratorsVTKmModule.h"
// for export macro
class
VTKACCELERATORSVTKM_EXPORT
vtkmTriangleMeshPointNormals
:
public
vtkTriangleMeshPointNormals
{
public:
vtkTypeMacro
(
vtkmTriangleMeshPointNormals
,
vtkTriangleMeshPointNormals
)
void
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
)
VTK_OVERRIDE
;
static
vtkmTriangleMeshPointNormals
*
New
();
protected:
vtkmTriangleMeshPointNormals
();
~
vtkmTriangleMeshPointNormals
();
int
RequestData
(
vtkInformation
*
,
vtkInformationVector
**
,
vtkInformationVector
*
)
VTK_OVERRIDE
;
private:
vtkmTriangleMeshPointNormals
(
const
vtkmTriangleMeshPointNormals
&
)
VTK_DELETE_FUNCTION
;
void
operator
=
(
const
vtkmTriangleMeshPointNormals
&
)
VTK_DELETE_FUNCTION
;
};
#endif // vtkmTriangleMeshPointNormals_h
// VTK-HeaderTest-Exclude: vtkmTriangleMeshPointNormals.h
Write
Preview
Supports
Markdown
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