Commit fe9c6302 authored by promayon's avatar promayon
Browse files

FIXED pointdata problem when values are outside intial/default [0,1] range

FIXED crash in rendering option displaying label or other when no normal actor present

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@215 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 78775699
......@@ -121,42 +121,51 @@ Action::ApplyStatus RenderingOption::apply() {
comp->getProp("label")->SetVisibility(property("Label").toBool());
// normal is a specific prop, create it only if needed
if (property("Normals").toBool() && comp->getProp("normals") == NULL) {
//-- get the surface (in order to have polygon only)
vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
surfaceFilter->SetInput(comp->getPointSet());
surfaceFilter->Update();
//-- generate the normals
vtkSmartPointer<vtkPolyDataNormals> normalGenerator = vtkSmartPointer<vtkPolyDataNormals>::New();
normalGenerator->SetInputConnection(surfaceFilter->GetOutputPort());
normalGenerator->ComputePointNormalsOn();
normalGenerator->ComputeCellNormalsOff();
normalGenerator->SplittingOff();
normalGenerator->Update();
//-- create the arrow glyph for the surface normal
vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
vtkSmartPointer<vtkGlyph3D> arrowGlyph = vtkSmartPointer<vtkGlyph3D>::New();
arrowGlyph->ScalingOn();
arrowGlyph->SetScaleFactor(comp->getBoundingRadius()/10.0);
arrowGlyph->SetVectorModeToUseNormal();
arrowGlyph->SetScaleModeToScaleByVector();
arrowGlyph->OrientOn();
arrowGlyph->SetSourceConnection(arrowSource->GetOutputPort());
arrowGlyph->SetInputConnection(normalGenerator->GetOutputPort());
vtkSmartPointer<vtkDataSetMapper> normalMapper = vtkSmartPointer<vtkDataSetMapper>::New();
normalMapper->SetInputConnection(arrowGlyph->GetOutputPort());
vtkSmartPointer<vtkActor> normalActor = vtkSmartPointer<vtkActor>::New();
normalActor->SetMapper(normalMapper);
//-- add the prop to the Component
comp->addProp("normals",normalActor);
if (comp->getProp("normals") == NULL) {
if (property("Normals").toBool()) {
//-- get the surface (in order to have polygon only)
vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
surfaceFilter->SetInput(comp->getPointSet());
surfaceFilter->Update();
//-- generate the normals
vtkSmartPointer<vtkPolyDataNormals> normalGenerator = vtkSmartPointer<vtkPolyDataNormals>::New();
normalGenerator->SetInputConnection(surfaceFilter->GetOutputPort());
normalGenerator->ComputePointNormalsOn();
normalGenerator->ComputeCellNormalsOff();
normalGenerator->SplittingOff();
normalGenerator->Update();
//-- create the arrow glyph for the surface normal
vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
vtkSmartPointer<vtkGlyph3D> arrowGlyph = vtkSmartPointer<vtkGlyph3D>::New();
arrowGlyph->ScalingOn();
arrowGlyph->SetScaleFactor(comp->getBoundingRadius()/10.0);
arrowGlyph->SetVectorModeToUseNormal();
arrowGlyph->SetScaleModeToScaleByVector();
arrowGlyph->OrientOn();
arrowGlyph->SetSourceConnection(arrowSource->GetOutputPort());
arrowGlyph->SetInputConnection(normalGenerator->GetOutputPort());
vtkSmartPointer<vtkDataSetMapper> normalMapper = vtkSmartPointer<vtkDataSetMapper>::New();
normalMapper->SetInputConnection(arrowGlyph->GetOutputPort());
vtkSmartPointer<vtkActor> normalActor = vtkSmartPointer<vtkActor>::New();
normalActor->SetMapper(normalMapper);
//-- add the prop to the Component
comp->addProp("normals",normalActor);
comp->getProp("normals")->SetVisibility(true);
}
// else: nothing todo there is no normal to display anyway
}
else {
// check weither to show the normals or no
comp->getProp("normals")->SetVisibility(property("Normals").toBool());
}
comp->getProp("normals")->SetVisibility(property("Normals").toBool());
}
// refresh the viewers (here only the viewer of the last component, but should be ok)
......
......@@ -698,8 +698,18 @@ double Geometry::getBoundingRadius() {
// -------------------- setPointData --------------------
void Geometry::setPointData(vtkSmartPointer<vtkDataArray> da) {
pointSet->GetPointData()->SetScalars(da);
if (da) {
pointSet->GetPointData()->SetActiveScalars(da->GetName());
// rescale colors
mapper->SetScalarVisibility(1);
double range[2] = {0,1};
pointSet->GetPointData()->GetScalars()->GetRange(range);
mapper->SetScalarRange(range);
}
// make sure the change is taking into account
pointSet->Modified();
pointSet->Update();
//mapper->Update();
mapper->Update();
}
}
......
Supports Markdown
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