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