----------------- GetvtkTransform ----------------- Compute the transformation to orient the plane with a local coordinates system given by tangent and normal.
| 77 | // given by tangent and normal. |
| 78 | // |
| 79 | vtkTransform * |
| 80 | GetvtkTransform(double pos[3], double nrm[3], double xhat[3]) |
| 81 | { |
| 82 | using util = sv3::SegmentationUtils; |
| 83 | |
| 84 | /* |
| 85 | double pos[3],nrm[3],xhat[3]; |
| 86 | |
| 87 | pos[0]=pathPoint.pos[0]; |
| 88 | pos[1]=pathPoint.pos[1]; |
| 89 | pos[2]=pathPoint.pos[2]; |
| 90 | |
| 91 | nrm[0]=pathPoint.tangent[0]; |
| 92 | nrm[1]=pathPoint.tangent[1]; |
| 93 | nrm[2]=pathPoint.tangent[2]; |
| 94 | |
| 95 | xhat[0]=pathPoint.rotation[0]; |
| 96 | xhat[1]=pathPoint.rotation[1]; |
| 97 | xhat[2]=pathPoint.rotation[2]; |
| 98 | */ |
| 99 | |
| 100 | double zhat[3]={0,0,1}; |
| 101 | double theta = util::math_radToDeg(util::math_angleBtw3DVectors(zhat,nrm)); |
| 102 | |
| 103 | double axis[3]; |
| 104 | util::math_cross(axis,zhat,nrm); |
| 105 | |
| 106 | vtkTransform* tmpTr = vtkTransform::New(); |
| 107 | tmpTr->Identity(); |
| 108 | tmpTr->RotateWXYZ(theta,axis); |
| 109 | |
| 110 | vtkPoints* tmpPt = vtkPoints::New(); |
| 111 | tmpPt->InsertNextPoint(1, 0, 0); |
| 112 | |
| 113 | vtkPolyData* tmpPd = vtkPolyData::New(); |
| 114 | tmpPd->SetPoints(tmpPt); |
| 115 | |
| 116 | vtkTransformPolyDataFilter* tmpTf = vtkTransformPolyDataFilter::New(); |
| 117 | tmpTf->SetInputDataObject(tmpPd); |
| 118 | tmpTf->SetTransform(tmpTr); |
| 119 | tmpTf->Update(); |
| 120 | double pt[3]; |
| 121 | tmpTf->GetOutput()->GetPoint(0,pt); |
| 122 | |
| 123 | tmpTr->Delete(); |
| 124 | tmpPt->Delete(); |
| 125 | tmpPd->Delete(); |
| 126 | tmpTf->Delete(); |
| 127 | |
| 128 | double rot = util::math_radToDeg(util::math_angleBtw3DVectors(pt,xhat)); |
| 129 | |
| 130 | double x[3]; |
| 131 | util::math_cross(x,pt,xhat); |
| 132 | double d = util::math_dot(x,nrm); |
| 133 | if (d < 0.0) { |
| 134 | rot=-rot; |
| 135 | } |
| 136 |
no test coverage detected