Use transform matrix(from image properties) instead of direct calc.
This commit is contained in:
@@ -479,12 +479,9 @@ void infinitiViewer::ChangeSlice(vtkObject *, unsigned long eventid, void *calld
|
||||
}
|
||||
|
||||
void infinitiViewer::GetSlicePoint(double *point) {
|
||||
double focusPoint[4] = {.0, .0, .0, 1.0};
|
||||
double focusPoint[4] = {point[0], point[1], point[2], 1.0};
|
||||
Renderer->GetActiveCamera()->GetFocalPoint(focusPoint);
|
||||
matrix->MultiplyPoint(focusPoint, focusPoint);
|
||||
focusPoint[0] += imageDataOrigin[0];
|
||||
focusPoint[1] += imageDataOrigin[1];
|
||||
focusPoint[2] += imageDataOrigin[2];
|
||||
ModelToWorldMatrix->MultiplyPoint(focusPoint, focusPoint);
|
||||
point[0] = focusPoint[0];
|
||||
point[1] = focusPoint[1];
|
||||
point[2] = focusPoint[2];
|
||||
@@ -538,10 +535,7 @@ vtkPoints* infinitiViewer::GetSliceBoundPoints() {
|
||||
for (vtkIdType i = 0; i < pts->GetNumberOfPoints(); ++i) {
|
||||
double temp[4] = {.0, .0, .0, 1.};
|
||||
pts->GetPoint(i, temp);
|
||||
matrix->MultiplyPoint(temp, temp);
|
||||
temp[0] = temp[0] + imageDataOrigin[0];
|
||||
temp[1] = temp[1] + imageDataOrigin[1];
|
||||
temp[2] = temp[2] + imageDataOrigin[2];
|
||||
ModelToWorldMatrix->MultiplyPoint(temp, temp);
|
||||
worldPts->InsertNextPoint(temp);
|
||||
}
|
||||
return worldPts;
|
||||
@@ -549,17 +543,12 @@ vtkPoints* infinitiViewer::GetSliceBoundPoints() {
|
||||
|
||||
void infinitiViewer::updateReferenceLine(vtkPoints* worldPts){
|
||||
//model to world
|
||||
matrix->Invert();
|
||||
for (vtkIdType i = 0; i < worldPts->GetNumberOfPoints(); ++i) {
|
||||
double temp[4] = {.0, .0, .0, 1.};
|
||||
worldPts->GetPoint(i, temp);
|
||||
temp[0] = temp[0] - imageDataOrigin[0];
|
||||
temp[1] = temp[1] - imageDataOrigin[1];
|
||||
temp[2] = temp[2] - imageDataOrigin[2];
|
||||
matrix->MultiplyPoint(temp, temp);
|
||||
WorldToModelMatrix->MultiplyPoint(temp, temp);
|
||||
referenceLine->setPoint(i,temp);
|
||||
}
|
||||
matrix->Invert();
|
||||
Render();
|
||||
}
|
||||
|
||||
@@ -570,13 +559,8 @@ void infinitiViewer::modifiedReferenceLine(){
|
||||
}
|
||||
|
||||
void infinitiViewer::SyncSlicePoint(double *point) {
|
||||
double focusPoint[4] = {.0, .0, .0, 1.0};
|
||||
focusPoint[0] = point[0] - imageDataOrigin[0];
|
||||
focusPoint[1] = point[1] - imageDataOrigin[1];
|
||||
focusPoint[2] = point[2] - imageDataOrigin[2];
|
||||
matrix->Invert();
|
||||
matrix->MultiplyPoint(focusPoint, focusPoint);
|
||||
matrix->Invert();
|
||||
double focusPoint[4] = {point[0], point[1], point[2], 1.0};
|
||||
WorldToModelMatrix->MultiplyPoint(focusPoint, focusPoint);
|
||||
double f[3] = {.0, .0, .0};
|
||||
Renderer->GetActiveCamera()->GetFocalPoint(f);
|
||||
double bounds[6] = {.0, .0, .0, .0, .0, .0};
|
||||
@@ -1124,31 +1108,12 @@ void infinitiViewer::InitCornerInfo(ExtendMedicalImageProperties *pSeries) {
|
||||
m_cornerInfo.ConstAnno[TOP_RIGHT_PRIVACY].append("\n");
|
||||
m_cornerInfo.ConstAnno[TOP_RIGHT_PRIVACY].append("****");
|
||||
m_cornerInfo.ConstAnno[TOP_RIGHT_PRIVACY].append("\n");
|
||||
}
|
||||
|
||||
double *d = pSeries->GetDirectionCosine();
|
||||
double xVector[3] = {d[0], d[1], d[2]};
|
||||
double yVector[3] = {d[3], d[4], d[5]};
|
||||
double zVector[3] = {0, 0, 0};
|
||||
vtkMath::Cross(xVector, yVector, zVector);
|
||||
|
||||
|
||||
matrix->Zero();
|
||||
matrix->SetElement(0, 0, xVector[0]);
|
||||
matrix->SetElement(1, 0, xVector[1]);
|
||||
matrix->SetElement(2, 0, xVector[2]);
|
||||
matrix->SetElement(0, 1, yVector[0]);
|
||||
matrix->SetElement(1, 1, yVector[1]);
|
||||
matrix->SetElement(2, 1, yVector[2]);
|
||||
matrix->SetElement(0, 2, zVector[0]);
|
||||
matrix->SetElement(1, 2, zVector[1]);
|
||||
matrix->SetElement(2, 2, zVector[2]);
|
||||
matrix->SetElement(3, 3, 1);
|
||||
// matrix->Invert();
|
||||
|
||||
double *p = pSeries->GetPosition();
|
||||
imageDataOrigin[0] = p[0];
|
||||
imageDataOrigin[1] = p[1];
|
||||
imageDataOrigin[2] = p[2];
|
||||
void infinitiViewer::SetCoordsTransformMatrix(ExtendMedicalImageProperties *pSeries) const {
|
||||
OrientationMatrix->DeepCopy(pSeries->GetOrientationMatrix());
|
||||
WorldToModelMatrix->DeepCopy(pSeries->GetWorldToModelMatrix());
|
||||
ModelToWorldMatrix->DeepCopy(pSeries->GetModelToWorldMatrix());
|
||||
}
|
||||
|
||||
void infinitiViewer::InitTopLeftCornerInfo(const std::string &lbl_ser_num, const std::string &ser_num) {
|
||||
@@ -1263,7 +1228,7 @@ void infinitiViewer::SetSliceOrientation(int orientation) {
|
||||
int infinitiViewer::GetWorldSliceOrientation() {
|
||||
double orientations[4] = {.0, .0, .0, 1.0};
|
||||
orientations[SliceOrientation] = 1.0;
|
||||
matrix->MultiplyPoint(orientations, orientations);
|
||||
OrientationMatrix->MultiplyPoint(orientations, orientations);
|
||||
return (int) abs(round(1.0 * orientations[1]) + round(2.0 * orientations[2]));
|
||||
}
|
||||
|
||||
@@ -1332,13 +1297,13 @@ void infinitiViewer::UpdateOrientationInfo() {
|
||||
double viewRightVector[4] = {0, 0, 0, 1};
|
||||
|
||||
//top and bottom
|
||||
matrix->MultiplyPoint(viewUp, viewUpVector);
|
||||
OrientationMatrix->MultiplyPoint(viewUp, viewUpVector);
|
||||
int flag = getOrientationIndex(viewUpVector);
|
||||
cornerAnnotation->SetText(TOP_MIDDLE, dds[flag]);
|
||||
cornerAnnotation->SetText(BOTTOM_MIDDLE, dds[getOppositeOrientation(flag)]);
|
||||
|
||||
//left and right
|
||||
matrix->MultiplyPoint(viewRight, viewRightVector);
|
||||
OrientationMatrix->MultiplyPoint(viewRight, viewRightVector);
|
||||
flag = getOrientationIndex(viewRightVector);
|
||||
cornerAnnotation->SetText(RIGHT_MIDDLE, dds[flag]);
|
||||
cornerAnnotation->SetText(LEFT_MIDDLE, dds[getOppositeOrientation(flag)]);
|
||||
|
||||
@@ -393,6 +393,8 @@ vtkTypeMacro(infinitiViewer, vtkObject);
|
||||
|
||||
virtual void UpdateOrientation();
|
||||
|
||||
void SetCoordsTransformMatrix(ExtendMedicalImageProperties *pSeries) const;
|
||||
|
||||
protected:
|
||||
infinitiViewer();
|
||||
|
||||
@@ -424,10 +426,12 @@ private:
|
||||
void operator=(const infinitiViewer &) = delete;
|
||||
|
||||
std::vector<std::vector<double>> fusion_tf_vector;
|
||||
|
||||
//for convert vtkEvent to Qt signal
|
||||
vtkSignalRaiser raiser;
|
||||
|
||||
QList<Measure *> *list = nullptr;
|
||||
|
||||
MeasureStore *measureStore;
|
||||
|
||||
void raiseEvent(vtkObject *sender, unsigned long eventId, void *callData = nullptr) {
|
||||
@@ -454,12 +458,13 @@ private:
|
||||
vtkTextActor *OpacityActor;
|
||||
vtkCornerAnnotation *cornerAnnotation;
|
||||
vtkScalarBarActor *bar;
|
||||
|
||||
vtkNew<RulerLegendActor> ruler;
|
||||
vtkNew<ReferenceLineLegendActor> referenceLine;
|
||||
vtkNew<vtkMatrix4x4> matrix;
|
||||
DicomCornerInfo m_cornerInfo;
|
||||
vtkNew<vtkMatrix4x4> OrientationMatrix;
|
||||
vtkNew<vtkMatrix4x4> WorldToModelMatrix;
|
||||
vtkNew<vtkMatrix4x4> ModelToWorldMatrix;
|
||||
|
||||
DicomCornerInfo m_cornerInfo;
|
||||
int SliceOrientation;
|
||||
int FirstRender;
|
||||
int Slice;
|
||||
@@ -467,11 +472,9 @@ private:
|
||||
int currentPresetIndex = 1;
|
||||
vtkTypeBool Fusion = false;
|
||||
vtkTypeBool firstFusion = true;
|
||||
|
||||
double FusionOpacity = 0.5;
|
||||
bool rulerActive = false;
|
||||
char SOP_UID[20] = {0};
|
||||
double imageDataOrigin[3] = {.0, .0, .0};
|
||||
double defaultProjection[3][3] = {
|
||||
{1.,0.,0.},
|
||||
{0.,1.,0.},
|
||||
|
||||
@@ -155,6 +155,7 @@ void DicomImageView::loadSeries(SeriesImageSet *series) {
|
||||
.arg(time)
|
||||
.arg(series->GetProperty()->GetSeriesDescription()));
|
||||
mImageViewer->SetInputData(mSeries->GetData());
|
||||
mImageViewer->SetCoordsTransformMatrix(series->GetProperty());
|
||||
mImageViewer->InitCornerInfo(series->GetProperty());
|
||||
mImageViewer->SetupImageViewer();
|
||||
mImageViewer->UpdateOrientationInfo();
|
||||
|
||||
Reference in New Issue
Block a user