本文整理汇总了C++中affinetransform3d::Pointer::SetMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::SetMatrix方法的具体用法?C++ Pointer::SetMatrix怎么用?C++ Pointer::SetMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类affinetransform3d::Pointer
的用法示例。
在下文中一共展示了Pointer::SetMatrix方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void mitk::BaseGeometry::_SetSpacing(const mitk::Vector3D& aSpacing, bool enforceSetSpacing){
if(mitk::Equal(m_Spacing, aSpacing) == false || enforceSetSpacing)
{
assert(aSpacing[0]>0 && aSpacing[1]>0 && aSpacing[2]>0);
m_Spacing = aSpacing;
AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix;
vnlmatrix = m_IndexToWorldTransform->GetMatrix().GetVnlMatrix();
mitk::VnlVector col;
col = vnlmatrix.get_column(0); col.normalize(); col*=aSpacing[0]; vnlmatrix.set_column(0, col);
col = vnlmatrix.get_column(1); col.normalize(); col*=aSpacing[1]; vnlmatrix.set_column(1, col);
col = vnlmatrix.get_column(2); col.normalize(); col*=aSpacing[2]; vnlmatrix.set_column(2, col);
Matrix3D matrix;
matrix = vnlmatrix;
AffineTransform3D::Pointer transform = AffineTransform3D::New();
transform->SetMatrix(matrix);
transform->SetOffset(m_IndexToWorldTransform->GetOffset());
SetIndexToWorldTransform(transform.GetPointer());
}
}
示例2: assert
void
PlaneGeometry::InitializeStandardPlane(
mitk::ScalarType width, ScalarType height,
const VnlVector &rightVector, const VnlVector &downVector,
const Vector3D *spacing )
{
assert(width > 0);
assert(height > 0);
VnlVector rightDV = rightVector; rightDV.normalize();
VnlVector downDV = downVector; downDV.normalize();
VnlVector normal = vnl_cross_3d(rightVector, downVector);
normal.normalize();
if(spacing!=NULL)
{
rightDV *= (*spacing)[0];
downDV *= (*spacing)[1];
normal *= (*spacing)[2];
}
AffineTransform3D::Pointer transform = AffineTransform3D::New();
Matrix3D matrix;
matrix.GetVnlMatrix().set_column(0, rightDV);
matrix.GetVnlMatrix().set_column(1, downDV);
matrix.GetVnlMatrix().set_column(2, normal);
transform->SetMatrix(matrix);
transform->SetOffset(m_IndexToWorldTransform->GetOffset());
ScalarType bounds[6] = { 0, width, 0, height, 0, 1 };
this->SetBounds( bounds );
this->SetIndexToWorldTransform( transform );
}
示例3: SetIndexToWorldTransform
void
PlaneGeometry::SetMatrixByVectors( const VnlVector &rightVector,
const VnlVector &downVector, ScalarType thickness )
{
VnlVector normal = vnl_cross_3d(rightVector, downVector);
normal.normalize();
normal *= thickness;
AffineTransform3D::Pointer transform = AffineTransform3D::New();
Matrix3D matrix;
matrix.GetVnlMatrix().set_column(0, rightVector);
matrix.GetVnlMatrix().set_column(1, downVector);
matrix.GetVnlMatrix().set_column(2, normal);
transform->SetMatrix(matrix);
transform->SetOffset(m_IndexToWorldTransform->GetOffset());
SetIndexToWorldTransform(transform);
}
示例4: SetIndexToWorldTransform
void
PlaneGeometry::SetMatrixByVectors( const VnlVector &rightVector,
const VnlVector &downVector, ScalarType thickness /* = 1.0 */ )
{
VnlVector normal = vnl_cross_3d(rightVector, downVector);
normal.normalize();
normal *= thickness;
// Crossproduct vnl_cross_3d is always righthanded, but that is okay here
// because in this method we create a new IndexToWorldTransform and
// a negative thickness could still make it lefthanded.
AffineTransform3D::Pointer transform = AffineTransform3D::New();
Matrix3D matrix;
matrix.GetVnlMatrix().set_column(0, rightVector);
matrix.GetVnlMatrix().set_column(1, downVector);
matrix.GetVnlMatrix().set_column(2, normal);
transform->SetMatrix(matrix);
transform->SetOffset(this->GetIndexToWorldTransform()->GetOffset());
SetIndexToWorldTransform(transform);
}
示例5: vnlmatrix
void
PlaneGeometry::InitializeStandardPlane( mitk::ScalarType width,
ScalarType height, const Vector3D & spacing,
PlaneGeometry::PlaneOrientation planeorientation,
ScalarType zPosition, bool frontside, bool rotated )
{
AffineTransform3D::Pointer transform;
transform = AffineTransform3D::New();
AffineTransform3D::MatrixType matrix;
AffineTransform3D::MatrixType::InternalMatrixType &vnlmatrix = matrix.GetVnlMatrix();
vnlmatrix.set_identity();
vnlmatrix(0,0) = spacing[0];
vnlmatrix(1,1) = spacing[1];
vnlmatrix(2,2) = spacing[2];
transform->SetIdentity();
transform->SetMatrix(matrix);
InitializeStandardPlane(width, height, transform.GetPointer(), planeorientation, zPosition, frontside, rotated);
}
示例6: isSameMatrix
unsigned int mitk::PlanePositionManagerService::AddNewPlanePosition ( const Geometry2D* plane, unsigned int sliceIndex )
{
for (unsigned int i = 0; i < m_PositionList.size(); ++i)
{
if (m_PositionList[i] != 0)
{
bool isSameMatrix(true);
bool isSameOffset(true);
isSameOffset = mitk::Equal(m_PositionList[i]->GetTransform()->GetOffset(), plane->GetIndexToWorldTransform()->GetOffset());
if(!isSameOffset || sliceIndex != m_PositionList[i]->GetPos())
continue;
isSameMatrix = mitk::MatrixEqualElementWise(m_PositionList[i]->GetTransform()->GetMatrix(), plane->GetIndexToWorldTransform()->GetMatrix());
if(isSameMatrix)
return i;
}
}
AffineTransform3D::Pointer transform = AffineTransform3D::New();
Matrix3D matrix;
matrix.GetVnlMatrix().set_column(0, plane->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(0));
matrix.GetVnlMatrix().set_column(1, plane->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(1));
matrix.GetVnlMatrix().set_column(2, plane->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2));
transform->SetMatrix(matrix);
transform->SetOffset(plane->GetIndexToWorldTransform()->GetOffset());
mitk::Vector3D direction;
direction[0] = plane->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2)[0];
direction[1] = plane->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2)[1];
direction[2] = plane->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2)[2];
direction.Normalize();
mitk::RestorePlanePositionOperation* newOp = new mitk::RestorePlanePositionOperation (OpRESTOREPLANEPOSITION, plane->GetExtent(0),
plane->GetExtent(1), plane->GetSpacing(), sliceIndex, direction, transform);
m_PositionList.push_back( newOp );
return GetNumberOfPlanePositions()-1;
}
示例7: assert
void mitk::TimeSlicedGeometry::InitializeEvenlyTimed(mitk::Geometry3D* geometry3D, unsigned int timeSteps)
{
assert(geometry3D!=NULL);
geometry3D->Register();
InitializeEmpty(timeSteps);
AffineTransform3D::Pointer transform = AffineTransform3D::New();
transform->SetMatrix(geometry3D->GetIndexToWorldTransform()->GetMatrix());
transform->SetOffset(geometry3D->GetIndexToWorldTransform()->GetOffset());
SetIndexToWorldTransform(transform);
SetBounds(geometry3D->GetBounds());
SetGeometry3D(geometry3D, 0);
SetEvenlyTimed();
UpdateInformation();
SetFrameOfReferenceID(geometry3D->GetFrameOfReferenceID());
SetImageGeometry(geometry3D->GetImageGeometry());
geometry3D->UnRegister();
}
示例8: assert
void
PlaneGeometry::InitializeStandardPlane( mitk::ScalarType width, ScalarType height,
const VnlVector &rightVector, const VnlVector &downVector,
const Vector3D *spacing )
{
assert(width > 0);
assert(height > 0);
VnlVector rightDV = rightVector; rightDV.normalize();
VnlVector downDV = downVector; downDV.normalize();
VnlVector normal = vnl_cross_3d(rightVector, downVector);
normal.normalize();
// Crossproduct vnl_cross_3d is always righthanded, but that is okay here
// because in this method we create a new IndexToWorldTransform and
// spacing with 1 or 3 negative components could still make it lefthanded.
if(spacing!=nullptr)
{
rightDV *= (*spacing)[0];
downDV *= (*spacing)[1];
normal *= (*spacing)[2];
}
AffineTransform3D::Pointer transform = AffineTransform3D::New();
Matrix3D matrix;
matrix.GetVnlMatrix().set_column(0, rightDV);
matrix.GetVnlMatrix().set_column(1, downDV);
matrix.GetVnlMatrix().set_column(2, normal);
transform->SetMatrix(matrix);
transform->SetOffset(this->GetIndexToWorldTransform()->GetOffset());
ScalarType bounds[6] = { 0, width, 0, height, 0, 1 };
this->SetBounds( bounds );
this->SetIndexToWorldTransform( transform );
}
示例9: isImageGeometry
//.........这里部分代码省略.........
// find data in xml structure
TiXmlElement *imageGeometryElem = geometryElem->FirstChildElement("image_geometry");
if (imageGeometryElem)
{
std::string igs = imageGeometryElem->GetText();
isImageGeometry = igs == "true" || igs == "TRUE" || igs == "1";
}
else
somethingMissing = true;
TiXmlElement *frameOfReferenceElem = geometryElem->FirstChildElement("frame_of_reference_id");
if (frameOfReferenceElem)
{
frameOfReferenceID = atoi(frameOfReferenceElem->GetText());
}
else
somethingMissing = true;
TiXmlElement *indexToWorldElem = geometryElem->FirstChildElement("index_to_world");
if (indexToWorldElem)
{
TiXmlElement *matrixElem = indexToWorldElem->FirstChildElement("matrix3x3");
TiXmlElement *offsetElem = indexToWorldElem->FirstChildElement("offset");
if (indexToWorldElem && offsetElem)
{
TiXmlElement *col0 = matrixElem->FirstChildElement("column_0");
TiXmlElement *col1 = matrixElem->FirstChildElement("column_1");
TiXmlElement *col2 = matrixElem->FirstChildElement("column_2");
if (col0 && col1 && col2)
{
somethingMissing |= TIXML_SUCCESS != col0->QueryDoubleAttribute("x", &matrix[0][0]);
somethingMissing |= TIXML_SUCCESS != col0->QueryDoubleAttribute("y", &matrix[1][0]);
somethingMissing |= TIXML_SUCCESS != col0->QueryDoubleAttribute("z", &matrix[2][0]);
somethingMissing |= TIXML_SUCCESS != col1->QueryDoubleAttribute("x", &matrix[0][1]);
somethingMissing |= TIXML_SUCCESS != col1->QueryDoubleAttribute("y", &matrix[1][1]);
somethingMissing |= TIXML_SUCCESS != col1->QueryDoubleAttribute("z", &matrix[2][1]);
somethingMissing |= TIXML_SUCCESS != col2->QueryDoubleAttribute("x", &matrix[0][2]);
somethingMissing |= TIXML_SUCCESS != col2->QueryDoubleAttribute("y", &matrix[1][2]);
somethingMissing |= TIXML_SUCCESS != col2->QueryDoubleAttribute("z", &matrix[2][2]);
}
else
somethingMissing = true;
somethingMissing |= TIXML_SUCCESS != offsetElem->QueryDoubleAttribute("x", &offset[0]);
somethingMissing |= TIXML_SUCCESS != offsetElem->QueryDoubleAttribute("y", &offset[1]);
somethingMissing |= TIXML_SUCCESS != offsetElem->QueryDoubleAttribute("z", &offset[2]);
}
else
somethingMissing = true;
TiXmlElement *boundsElem = geometryElem->FirstChildElement("bounds");
if (boundsElem)
{
TiXmlElement *minBoundsElem = boundsElem->FirstChildElement("min");
TiXmlElement *maxBoundsElem = boundsElem->FirstChildElement("max");
if (minBoundsElem && maxBoundsElem)
{
somethingMissing |= TIXML_SUCCESS != minBoundsElem->QueryDoubleAttribute("x", &bounds[0]);
somethingMissing |= TIXML_SUCCESS != minBoundsElem->QueryDoubleAttribute("y", &bounds[2]);
somethingMissing |= TIXML_SUCCESS != minBoundsElem->QueryDoubleAttribute("z", &bounds[4]);
somethingMissing |= TIXML_SUCCESS != maxBoundsElem->QueryDoubleAttribute("x", &bounds[1]);
somethingMissing |= TIXML_SUCCESS != maxBoundsElem->QueryDoubleAttribute("y", &bounds[3]);
somethingMissing |= TIXML_SUCCESS != maxBoundsElem->QueryDoubleAttribute("z", &bounds[5]);
}
else
somethingMissing = true;
}
else
somethingMissing = true;
}
else
somethingMissing = true;
if (somethingMissing)
{
MITK_ERROR << "XML structure of geometry inside a PointSet file broken. Refusing to build Geometry3D";
return nullptr;
}
else
{
Geometry3D::Pointer g = Geometry3D::New();
g->SetImageGeometry(isImageGeometry);
g->SetFrameOfReferenceID(frameOfReferenceID);
g->SetBounds(bounds);
AffineTransform3D::Pointer transform = AffineTransform3D::New();
transform->SetMatrix(matrix);
transform->SetOffset(offset);
g->SetIndexToWorldTransform(transform);
return g.GetPointer();
}
}
示例10: isImageGeometry
//.........这里部分代码省略.........
{
MITK_ERROR << "Could not parse all Geometry3D matrix coefficients!";
return nullptr;
}
} else
{
MITK_ERROR << "Parse error: expected Matrix3x3 child below Geometry3D node";
return nullptr;
}
// offset
if ( TiXmlElement* offsetElem = geometryElement->FirstChildElement("Offset")->ToElement() )
{
bool vectorComplete = true;
std::string offset_string[3];
vectorComplete &= TIXML_SUCCESS == offsetElem->QueryStringAttribute("x", &offset_string[0]);
vectorComplete &= TIXML_SUCCESS == offsetElem->QueryStringAttribute("y", &offset_string[1]);
vectorComplete &= TIXML_SUCCESS == offsetElem->QueryStringAttribute("z", &offset_string[2]);
if ( !vectorComplete )
{
MITK_ERROR << "Could not parse complete Geometry3D offset!";
return nullptr;
}
for ( unsigned int d = 0; d < 3; ++d )
try
{
offset[d] = boost::lexical_cast<double>(offset_string[d]);
}
catch ( boost::bad_lexical_cast& e )
{
MITK_ERROR << "Could not parse '" << offset_string[d] << "' as number: " << e.what();
return nullptr;
}
}
else
{
MITK_ERROR << "Parse error: expected Offset3D child below Geometry3D node";
return nullptr;
}
// bounds
if ( TiXmlElement* boundsElem = geometryElement->FirstChildElement("Bounds")->ToElement() )
{
bool vectorsComplete(true);
std::string bounds_string[6];
if ( TiXmlElement* minElem = boundsElem->FirstChildElement("Min")->ToElement() )
{
vectorsComplete &= TIXML_SUCCESS == minElem->QueryStringAttribute("x", &bounds_string[0]);
vectorsComplete &= TIXML_SUCCESS == minElem->QueryStringAttribute("y", &bounds_string[2]);
vectorsComplete &= TIXML_SUCCESS == minElem->QueryStringAttribute("z", &bounds_string[4]);
} else
{
vectorsComplete = false;
}
if ( TiXmlElement* maxElem = boundsElem->FirstChildElement("Max")->ToElement() )
{
vectorsComplete &= TIXML_SUCCESS == maxElem->QueryStringAttribute("x", &bounds_string[1]);
vectorsComplete &= TIXML_SUCCESS == maxElem->QueryStringAttribute("y", &bounds_string[3]);
vectorsComplete &= TIXML_SUCCESS == maxElem->QueryStringAttribute("z", &bounds_string[5]);
} else
{
vectorsComplete = false;
}
if ( !vectorsComplete )
{
MITK_ERROR << "Could not parse complete Geometry3D bounds!";
return nullptr;
}
for (unsigned int d = 0; d < 6; ++d)
try
{
bounds[d] = boost::lexical_cast<double>(bounds_string[d]);
}
catch (boost::bad_lexical_cast& e)
{
MITK_ERROR << "Could not parse '" << bounds_string[d] << "' as number: " << e.what();
return nullptr;
}
}
// build GeometryData from matrix/offset
AffineTransform3D::Pointer newTransform = AffineTransform3D::New();
newTransform->SetMatrix(matrix);
newTransform->SetOffset(offset);
Geometry3D::Pointer newGeometry = Geometry3D::New();
newGeometry->SetFrameOfReferenceID(frameOfReferenceID);
newGeometry->SetImageGeometry(isImageGeometry);
newGeometry->SetIndexToWorldTransform(newTransform);
newGeometry->SetBounds(bounds);
return newGeometry;
}