Skip to content

Commit

Permalink
Add radius field data to the armature polydata
Browse files Browse the repository at this point in the history
See Issue #13680
  • Loading branch information
vovythevov committed Jan 9, 2013
1 parent a61df61 commit 811e884
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Libs/VTK/Widgets/vtkArmatureWidget.cxx
Expand Up @@ -21,6 +21,7 @@
// Bender includes
#include "vtkArmatureRepresentation.h"
#include "vtkArmatureWidget.h"
#include "vtkBoneEnvelopeRepresentation.h"
#include "vtkBoneRepresentation.h"
#include "vtkCylinderBoneRepresentation.h"
#include "vtkDoubleConeBoneRepresentation.h"
Expand Down Expand Up @@ -231,6 +232,10 @@ vtkArmatureWidget::vtkArmatureWidget()
transforms->SetNumberOfComponents(12);
transforms->SetName("Transforms");
this->PolyData->GetCellData()->AddArray(transforms.GetPointer());
vtkNew<vtkDoubleArray> envelopeRadiuses;
envelopeRadiuses->SetNumberOfComponents(1);
envelopeRadiuses->SetName("EnvelopeRadiuses");
this->PolyData->GetCellData()->AddArray(envelopeRadiuses.GetPointer());

// Init bones properties
vtkBoneRepresentation* defaultRep = vtkBoneRepresentation::New();
Expand Down Expand Up @@ -1032,6 +1037,9 @@ void vtkArmatureWidget::UpdatePolyData()
vtkDoubleArray* transforms = vtkDoubleArray::SafeDownCast(
this->PolyData->GetCellData()->GetArray("Transforms"));
transforms->Reset();
vtkDoubleArray* envelopeRadiuses = vtkDoubleArray::SafeDownCast(
this->PolyData->GetCellData()->GetArray("EnvelopeRadiuses"));
envelopeRadiuses->Reset();
this->PolyData->Reset();
for (NodeIteratorType it = this->Bones->begin();
it != this->Bones->end(); ++it)
Expand All @@ -1057,6 +1065,14 @@ void vtkArmatureWidget::UpdatePolyData()
memcpy(transform, rotation, 3*3*sizeof(double));
memcpy(transform[3], translation, 3*sizeof(double));
transforms->InsertNextTuple(transform[0]);

double radius = 0.0;
vtkBoneRepresentation* boneRep = (*it)->Bone->GetBoneRepresentation();
if (boneRep)
{
radius = boneRep->GetEnvelope()->GetRadius();
}
envelopeRadiuses->InsertNextValue(radius);
}
}

Expand Down

0 comments on commit 811e884

Please sign in to comment.