Commit 7a009b29 authored by Alexis Girault's avatar Alexis Girault

Merge branch 'fix-normals-nontriangular-cells' into 'master'

BUG: Fix #122 black analytic objects

Closes #122

See merge request !160
parents aa4527fe 65f81868
......@@ -39,7 +39,7 @@ m_capsuleGeometry(capsule)
source->SetThetaResolution(10);
// Setup Mapper & Actor
this->setUpMapper(source->GetOutputPort());
this->setUpMapper(source->GetOutputPort(), true);
this->updateActorTransform();
}
......
......@@ -39,7 +39,7 @@ VTKCubeRenderDelegate::VTKCubeRenderDelegate(std::shared_ptr<Cube>cube) :
source->SetZLength(width);
// Setup Mapper & Actor
this->setUpMapper(source->GetOutputPort());
this->setUpMapper(source->GetOutputPort(), true);
this->updateActorTransform();
}
......
......@@ -53,7 +53,7 @@ VTKLineMeshRenderDelegate::VTKLineMeshRenderDelegate(std::shared_ptr<LineMesh> l
lines->SetPoints(points);
// Setup Mapper & Actor
this->setUpMapper(lines->GetOutputPort());
this->setUpMapper(lines->GetOutputPort(), true);
this->updateActorTransform();
}
......
......@@ -35,7 +35,7 @@ VTKPlaneRenderDelegate::VTKPlaneRenderDelegate(std::shared_ptr<Plane>plane) :
source->SetNormal(m_geometry->getNormal().data());
// Setup Mapper & Actor
this->setUpMapper(source->GetOutputPort());
this->setUpMapper(source->GetOutputPort(), true);
this->updateActorTransform();
}
......
......@@ -42,6 +42,7 @@
#include "vtkOpenGLPolyDataMapper.h"
#include "vtkOpenGLVertexBufferObject.h"
#include "vtkPolyDataNormals.h"
#include "vtkTriangleMeshPointNormals.h"
#include "vtkTransform.h"
......@@ -102,18 +103,26 @@ VTKRenderDelegate::make_delegate(std::shared_ptr<Geometry>geom)
}
void
VTKRenderDelegate::setUpMapper(vtkAlgorithmOutput *source)
VTKRenderDelegate::setUpMapper(vtkAlgorithmOutput *source, const bool rigid)
{
// Add normals
auto normalGen = vtkSmartPointer<vtkTriangleMeshPointNormals>::New();
vtkSmartPointer<vtkPolyDataAlgorithm> normalGen;
if (rigid)
{
normalGen = vtkSmartPointer<vtkPolyDataNormals>::New();
vtkPolyDataNormals::SafeDownCast(normalGen)->SplittingOff();
}
else
{
normalGen = vtkSmartPointer<vtkTriangleMeshPointNormals>::New();
}
normalGen->SetInputConnection(source);
m_mapper->SetInputConnection(normalGen->GetOutputPort());
// Disable auto Shift & Scale which is slow for deformable objects
// as it needs to compute a bounding box at every frame
auto mapper = dynamic_cast<vtkOpenGLPolyDataMapper*>(m_mapper.GetPointer());
if(mapper)
if(auto mapper = vtkOpenGLPolyDataMapper::SafeDownCast(m_mapper.GetPointer()))
{
mapper->SetVBOShiftScaleMethod(vtkOpenGLVertexBufferObject::DISABLE_SHIFT_SCALE);
}
......
......@@ -57,7 +57,7 @@ public:
///
/// \brief
///
void setUpMapper(vtkAlgorithmOutput *source);
void setUpMapper(vtkAlgorithmOutput *source, const bool rigid);
///
/// \brief
......
......@@ -37,7 +37,7 @@ VTKSphereRenderDelegate::VTKSphereRenderDelegate(std::shared_ptr<Sphere>sphere)
source->SetThetaResolution(20);
// Setup Mapper & Actor
this->setUpMapper(source->GetOutputPort());
this->setUpMapper(source->GetOutputPort(), true);
this->updateActorTransform();
}
......
......@@ -86,7 +86,7 @@ VTKSurfaceMeshRenderDelegate::VTKSurfaceMeshRenderDelegate(std::shared_ptr<Surfa
source->SetOutput(polydata);
// Setup Mapper & Actor
this->setUpMapper(source->GetOutputPort());
this->setUpMapper(source->GetOutputPort(), false);
this->updateActorTransform();
// Copy textures
......
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