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() { ...@@ -121,42 +121,51 @@ Action::ApplyStatus RenderingOption::apply() {
comp->getProp("label")->SetVisibility(property("Label").toBool()); comp->getProp("label")->SetVisibility(property("Label").toBool());
// normal is a specific prop, create it only if needed // normal is a specific prop, create it only if needed
if (property("Normals").toBool() && comp->getProp("normals") == NULL) { if (comp->getProp("normals") == NULL) {
//-- get the surface (in order to have polygon only) if (property("Normals").toBool()) {
vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
surfaceFilter->SetInput(comp->getPointSet()); //-- get the surface (in order to have polygon only)
surfaceFilter->Update(); vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
surfaceFilter->SetInput(comp->getPointSet());
//-- generate the normals surfaceFilter->Update();
vtkSmartPointer<vtkPolyDataNormals> normalGenerator = vtkSmartPointer<vtkPolyDataNormals>::New();
normalGenerator->SetInputConnection(surfaceFilter->GetOutputPort()); //-- generate the normals
normalGenerator->ComputePointNormalsOn(); vtkSmartPointer<vtkPolyDataNormals> normalGenerator = vtkSmartPointer<vtkPolyDataNormals>::New();
normalGenerator->ComputeCellNormalsOff(); normalGenerator->SetInputConnection(surfaceFilter->GetOutputPort());
normalGenerator->SplittingOff(); normalGenerator->ComputePointNormalsOn();
normalGenerator->Update(); normalGenerator->ComputeCellNormalsOff();
normalGenerator->SplittingOff();
//-- create the arrow glyph for the surface normal normalGenerator->Update();
vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
vtkSmartPointer<vtkGlyph3D> arrowGlyph = vtkSmartPointer<vtkGlyph3D>::New(); //-- create the arrow glyph for the surface normal
arrowGlyph->ScalingOn(); vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
arrowGlyph->SetScaleFactor(comp->getBoundingRadius()/10.0); vtkSmartPointer<vtkGlyph3D> arrowGlyph = vtkSmartPointer<vtkGlyph3D>::New();
arrowGlyph->SetVectorModeToUseNormal(); arrowGlyph->ScalingOn();
arrowGlyph->SetScaleModeToScaleByVector(); arrowGlyph->SetScaleFactor(comp->getBoundingRadius()/10.0);
arrowGlyph->OrientOn(); arrowGlyph->SetVectorModeToUseNormal();
arrowGlyph->SetSourceConnection(arrowSource->GetOutputPort()); arrowGlyph->SetScaleModeToScaleByVector();
arrowGlyph->SetInputConnection(normalGenerator->GetOutputPort()); arrowGlyph->OrientOn();
arrowGlyph->SetSourceConnection(arrowSource->GetOutputPort());
vtkSmartPointer<vtkDataSetMapper> normalMapper = vtkSmartPointer<vtkDataSetMapper>::New(); arrowGlyph->SetInputConnection(normalGenerator->GetOutputPort());
normalMapper->SetInputConnection(arrowGlyph->GetOutputPort());
vtkSmartPointer<vtkDataSetMapper> normalMapper = vtkSmartPointer<vtkDataSetMapper>::New();
vtkSmartPointer<vtkActor> normalActor = vtkSmartPointer<vtkActor>::New(); normalMapper->SetInputConnection(arrowGlyph->GetOutputPort());
normalActor->SetMapper(normalMapper);
vtkSmartPointer<vtkActor> normalActor = vtkSmartPointer<vtkActor>::New();
//-- add the prop to the Component normalActor->SetMapper(normalMapper);
comp->addProp("normals",normalActor);
//-- 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) // refresh the viewers (here only the viewer of the last component, but should be ok)
......
...@@ -698,8 +698,18 @@ double Geometry::getBoundingRadius() { ...@@ -698,8 +698,18 @@ double Geometry::getBoundingRadius() {
// -------------------- setPointData -------------------- // -------------------- setPointData --------------------
void Geometry::setPointData(vtkSmartPointer<vtkDataArray> da) { void Geometry::setPointData(vtkSmartPointer<vtkDataArray> da) {
pointSet->GetPointData()->SetScalars(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(); 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