<div>Hi everyone </div><div><br></div><div>I am trying to set the origin (the point about which all rotations take place) </div><div>of a vtkActor through a vtkProp3D pointer. </div><div><br></div><div>My actor is generated from a series of images containing binary segmentation masks</div>
<div>that I use to construct a surface through the pipeline below. </div><div><br></div><div>As I understand, because the vtkActor surface comes from ImageData whose origin </div><div>are a corner of an image (x,y) and a image slice (z); when I rotate or translate </div>
<div>the vtkActor it always rotates/translates from that point. </div><div><br></div><div>However, I would rather apply rotations/translations from a center of the vtkActor </div><div>surface determined from its bounding box - which I use to calculate a center and set</div>
<div>that point as a new origin for the actor. However, it has no effect and the rotations</div><div>still apply from the original vtkImageData origin. </div><div><br></div><div>Is there a way to set the origin of the vtkActor surface? or do I need to construct</div>
<div>a new copy surface actor independent of the vtkImageData to be able to set an </div><div>origin at the center of its bounding box? </div><div><br></div><div>Any suggestions are appreciated. </div><div><br></div><div>
Sergio </div><div><br></div><div>//// building the vtkActor from images </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtiReader = vtkXMLImageDataReader::New();</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>vtiReader->SetFileName("C:/code/epxZCTC_Demo/Debug/demo_103.vti");</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>vtiReader->WholeSlicesOff();</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>vtiReader->Update();</div><div><br></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>Image = vtkImageData::New();</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>Image->DeepCopy(vtiReader->GetOutput());</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>sgauss = vtkImageGaussianSmooth::New();</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>sgauss->SetInput(Image);</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>sgauss->SetDimensionality(3);</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>sgauss->SetStandardDeviation(0.25, 0.25, 0.25);</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>sgauss->SetRadiusFactor(1);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Cubes = vtkMarchingCubes::New();</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>Cubes->SetInputConnection(sgauss->GetOutputPort());</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>Cubes->SetNumberOfContours(1);</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>Cubes->ComputeScalarsOff();</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>Cubes->ComputeGradientsOff();</div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>Cubes->ComputeNormalsOff();</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>Cubes->SetValue(0,255);</div><div><br></div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>smoother = vtkSmoothPolyDataFilter::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>smoother->SetInputConnection(Cubes->GetOutputPort()); </div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>smoother->SetNumberOfIterations(300);</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>smoother->SetRelaxationFactor(0.01);</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>smoother->SetFeatureAngle(60);</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>smoother->FeatureEdgeSmoothingOff();</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>smoother->BoundarySmoothingOff();</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>smoother->SetConvergence(0);</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>normals = vtkPolyDataNormals::New();</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>normals->SetInputConnection(Cubes->GetOutputPort());</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>normals->FlipNormalsOn();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>strips = vtkStripper::New();</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>strips->SetInputConnection(smoother->GetOutputPort());</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Mapper = vtkPolyDataMapper::New();</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>Mapper->SetInputConnection(strips->GetOutputPort());</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>Mapper->ScalarVisibilityOff();</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Actor = vtkActor::New();</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>Actor->SetMapper(colonMapper);</div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>Actor->GetProperty()->SetDiffuseColor(1.0, 0.65, 0.65);</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>Actor->GetProperty()->SetDiffuse(0.70);</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>Actor->GetProperty()->SetSpecular(0.3);</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>Actor->GetProperty()->SetSpecularPower(10);</div>
<div><br></div><div>// setting a new origin for rotations</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkProp3D* picked_object = (vtkProp3D*) propList->GetItemAsObject(object);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>double tip[3], bounds[6], icenter[3], center[3], trans[3]; </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>UpdateLaser(styPoseE, tip);<span class="Apple-tab-span" style="white-space:pre">                        </span>// get Tip - new position for translation</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>picked_object->GetBounds(bounds); <span class="Apple-tab-span" style="white-space:pre">                </span>// picked_object get bounds</div><div><br>
</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>icenter[0] = (bounds[1]-bounds[0])/2;<span class="Apple-tab-span" style="white-space:pre">                </span>// initial center</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>icenter[1] = (bounds[3]-bounds[2])/2;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>icenter[2] = (bounds[5]-bounds[4])/2;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>picked_object->SetOrigin(icenter); <span class="Apple-tab-span" style="white-space:pre">                </span>// set origin to initial center</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>picked_object->SetPosition(icenter); </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>center[0] = tip[0]-icenter[0]; </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>center[1] = tip[1]-icenter[1]; </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>center[2] = tip[2]-icenter[2];</div><div><br></div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>trans[0] = center[0]+icenter[0]; <span class="Apple-tab-span" style="white-space:pre">                </span>// translation delta</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>trans[1] = center[1]+icenter[1]; </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>trans[2] = center[2]+icenter[2]; </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>objMtx = vtkMatrix4x4::New(); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>picked_object->GetMatrix(objMtx);<span class="Apple-tab-span" style="white-space:pre">                </span>// store picked_object current position + rotation</div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>objMtx->SetElement(0,3, 0.0); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>objMtx->SetElement(1,3, 0.0); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>objMtx->SetElement(2,3, 0.0); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>objMtx->SetElement(3,3, 1.0); </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>rotMtx = vtkMatrix4x4::New(); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>rotMtx->Identity(); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>rotMtx->SetElement(0,0, 0.9961); <span class="Apple-tab-span" style="white-space:pre">                </span>// rotation matrix to apply</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>rotMtx->SetElement(0,2, 0.0871); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>rotMtx->SetElement(2,0, -0.0871); </div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>rotMtx->SetElement(2,2, 0.9961); </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span> </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>t = vtkTransform::New(); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>t->Identity();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>t->Translate(trans[0], trans[1], trans[2]); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>t->Concatenate(objMtx);<span class="Apple-tab-span" style="white-space:pre">                        </span>// concatenate current obj transformation matrix</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>t->Concatenate(rotMtx);<span class="Apple-tab-span" style="white-space:pre">                        </span>// concatenate rotation delta</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>t->Translate(-icenter[0], -icenter[1], -icenter[2]); </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>nMtx = vtkMatrix4x4::New(); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>nMtx->DeepCopy(t->GetMatrix()); </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>picked_object->PokeMatrix(nMtx); </div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>this->RenWin->Render();</div>