Commit 22f9267c authored by Ken Martin's avatar Ken Martin Committed by Code Review

Merge topic 'composite_fix' into master

5cc2de81 Fixes for composite poly data mapper2
parents f576c1a8 5cc2de81
......@@ -346,7 +346,7 @@ public:
// typically done as part of the rendering process. The alpha parameter
// allows the blending of the scalars with an additional alpha (typically
// which comes from a vtkActor, etc.)
vtkUnsignedCharArray *MapScalars(double alpha);
virtual vtkUnsignedCharArray *MapScalars(double alpha);
// Description:
// Set/Get the light-model color mode.
......
......@@ -75,6 +75,9 @@ protected:
// orchistrates the process, much of the work is done in other methods
virtual void UpdateShader(vtkgl::CellBO &cellBO, vtkRenderer *ren, vtkActor *act);
// override to use the block opacity
virtual vtkUnsignedCharArray *MapScalars(double alpha);
private:
vtkCompositeMapperHelper(const vtkCompositeMapperHelper&); // Not implemented.
void operator=(const vtkCompositeMapperHelper&); // Not implemented.
......@@ -82,6 +85,11 @@ private:
vtkStandardNewMacro(vtkCompositeMapperHelper);
vtkUnsignedCharArray *vtkCompositeMapperHelper::MapScalars(double alpha)
{
return this->Superclass::MapScalars(this->Parent->BlockState.Opacity.top());
}
void vtkCompositeMapperHelper::SetCameraShaderParameters(vtkgl::CellBO &cellBO,
vtkRenderer *ren, vtkActor *actor)
{
......@@ -545,8 +553,9 @@ void vtkCompositePolyDataMapper2::RenderBlock(vtkRenderer *renderer,
{
helper = vtkCompositeMapperHelper::New();
helper->Parent = this;
helper->SetStatic(1);
this->CopyMapperValuesToHelper(helper);
this->Helpers.insert(std::make_pair(ds, helper));
helper->SetInputData(ds);
}
else
{
......@@ -587,6 +596,12 @@ void vtkCompositePolyDataMapper2::RenderBlock(vtkRenderer *renderer,
}
void vtkCompositePolyDataMapper2::CopyMapperValuesToHelper(vtkCompositeMapperHelper *helper)
{
helper->vtkMapper::ShallowCopy(this);
helper->SetStatic(1);
}
// ---------------------------------------------------------------------------
// Description:
// Method initiates the mapping process. Generally sent by the actor
......@@ -617,6 +632,15 @@ void vtkCompositePolyDataMapper2::Render(vtkRenderer *ren, vtkActor *actor)
}
else // otherwise just reinitialize the shaders
{
// if we have changed recopy our mapper settings to the helpers
if (this->GetMTime() > this->HelperMTime)
{
std::map<const vtkDataSet*, vtkCompositeMapperHelper *>::iterator miter = this->Helpers.begin();
for (;miter != this->Helpers.end(); miter++)
{
this->CopyMapperValuesToHelper(miter->second);
}
}
// reset initialized flag on the shaders we use
std::map<const vtkShaderProgram *, bool>::iterator miter = this->ShadersInitialized.begin();
for (;miter != this->ShadersInitialized.end(); miter++)
......
......@@ -119,6 +119,10 @@ protected:
bool GetShaderInitialized(vtkShaderProgram *);
void SetShaderInitialized(vtkShaderProgram *, bool);
// copy values to the helpers
void CopyMapperValuesToHelper(vtkCompositeMapperHelper *helper);
class RenderBlockState
{
public:
......
......@@ -258,19 +258,14 @@ std::string replace(std::string source, const std::string &search,
const std::string replace, bool all)
{
std::string::size_type pos = 0;
bool first = true;
while ((pos = source.find(search, 0)) != std::string::npos)
{
source.replace(pos, search.length(), replace);
pos += search.length();
if (first)
if (!all)
{
first = false;
if (!all)
{
return source;
}
return source;
}
pos += search.length();
}
return source;
}
......
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