void MetricNamesRep::setColoredTextList(std::vector<std::pair<QColor, QString> > text, Eigen::Array2d pos, vtkViewport *vp)
{
    mDisplayText.clear();

    if (vp==0)
    {
        vp = this->getRenderer();
    }
//	if (vp==0)
//	{
//		return;
//	}

    DoubleBoundingBox3D bb;
    bb = this->findNormalizedBoundingBoxAroundText(text, pos, vp);
    double meanHeight = bb.range()[1]/text.size();

    for (unsigned i=0; i<text.size(); ++i)
    {
        TextDisplayPtr rep;
        rep.reset( new TextDisplay( text[i].second, text[i].first, 	mFontSize) );
        rep->textProperty()->SetJustificationToLeft();
        rep->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();

        Vector3D currentPos = bb.bottomLeft() + (meanHeight*i)*Eigen::Vector3d::UnitY();
        rep->setPosition(currentPos);
        rep->setRenderer(this->getRenderer());

        mDisplayText.push_back(rep);
    }
}
Beispiel #2
0
void Rect3D::updatePosition(const DoubleBoundingBox3D bb, const Transform3D& M)
{
	mPoints = vtkPointsPtr::New();
	mPoints->InsertPoint(0, M.coord(bb.corner(0,0,0)).begin());
	mPoints->InsertPoint(1, M.coord(bb.corner(0,1,0)).begin());
	mPoints->InsertPoint(2, M.coord(bb.corner(1,1,0)).begin());
	mPoints->InsertPoint(3, M.coord(bb.corner(1,0,0)).begin());
	mPolyData->SetPoints(mPoints);
}
std::vector<int> InteractiveCropper::getDimensions()
{
	std::vector<int> dimensions;
	if(!mImage)
		return dimensions;

	double spacing_x = 1;
	double spacing_y = 1;
	double spacing_z = 1;
	mImage->getBaseVtkImageData()->GetSpacing(spacing_x, spacing_y, spacing_z);

	DoubleBoundingBox3D bb = getBoxWidgetSize();
	int dim_x = (bb.begin()[1] - bb.begin()[0])/spacing_x + 1; //adding 1 because of some rounding errors, is there a better way to do this?
	int dim_y = (bb.begin()[3] - bb.begin()[2])/spacing_y + 1;
	int dim_z = (bb.begin()[5] - bb.begin()[4])/spacing_z + 1;
	dimensions.push_back(dim_x);
	dimensions.push_back(dim_y);
	dimensions.push_back(dim_z);

	return dimensions;
}
Beispiel #4
0
/**Normalize volume defined by in to volume defined by out.
 *
 * This is intended for creating transforms from one viewport to another, i.e.
 * the two boxes should be aligned and differ only in translation + scaling.
 */
Transform3D createTransformNormalize(const DoubleBoundingBox3D& in, const DoubleBoundingBox3D& out)
{
	// translate input bottomleft to origin, scale, translate back to output bottomleft.
	Transform3D T0 = createTransformTranslate(-in.bottomLeft());
	Vector3D inrange = in.range();
	Vector3D outrange = out.range();
	Vector3D scale;

	// check for zero input dimensions
	for (unsigned i = 0; i < scale.size(); ++i)
	{
		if (fabs(inrange[i]) < 1.0E-5)
			scale[i] = 0;
		else
			scale[i] = outrange[i] / inrange[i];
	}
	Transform3D S = createTransformScale(scale);
	Transform3D T1 = createTransformTranslate(out.bottomLeft());
	Transform3D M = T1 * S * T0;
	return M;
}
/** Initialize the volue parameters with sensible defaults.
 */
OutputVolumeParams::OutputVolumeParams(DoubleBoundingBox3D extent, double inputSpacing, double maxVolumeSize) :
	mInputSpacing(inputSpacing), mMaxVolumeSize(maxVolumeSize), mValid(false)
{
	mImage.setSpacingKeepDim(Eigen::Array3d(inputSpacing, inputSpacing, inputSpacing));
	mImage.setDimKeepBoundsAlignSpacing(extent.range());

	this->constrainVolumeSize();

	if(mImage.getDim().minCoeff() <= 1) //At least one of the dimensions <= 1
		mValid = false;
	else
		mValid = true;
}
Vector3D CustomMetric::getScale() const
{
	if (!mScaleToP1 || !this->getModel() || this->getModel()->getType() == "image")
		return Vector3D::Ones();

	DoubleBoundingBox3D bounds = this->getModel()->boundingBox();
	bounds = transform(this->getModel()->get_rMd(), bounds);

	std::vector<Vector3D> coords = mArguments->getRefCoords();
	double height = (coords[1] - coords[0]).length();

	Vector3D dir = this->getDirection();
	double p0 = dot(coords[0], dir);
	double p1 = dot(coords[1], dir);

	height = p1 - p0;
	height -= (mOffsetFromP0 + mOffsetFromP1);

	Vector3D scale(1,
				   height/bounds.range()[1],
			1);
	return scale;
}
Beispiel #7
0
DoubleBoundingBox3D DoubleBoundingBox3D::unionWith(const DoubleBoundingBox3D& other) const
{
	std::vector<Vector3D> cloud;
	cloud.push_back(corner(0,0,0));
	cloud.push_back(other.corner(0,0,0));
	cloud.push_back(corner(0,0,1));
	cloud.push_back(other.corner(0,0,1));
	cloud.push_back(corner(0,1,0));
	cloud.push_back(other.corner(0,1,0));
	cloud.push_back(corner(0,1,1));
	cloud.push_back(other.corner(0,1,1));
	cloud.push_back(corner(1,0,0));
	cloud.push_back(other.corner(1,0,0));
	cloud.push_back(corner(1,0,1));
	cloud.push_back(other.corner(1,0,1));
	cloud.push_back(corner(1,1,0));
	cloud.push_back(other.corner(1,1,0));
	cloud.push_back(corner(1,1,1));
	cloud.push_back(other.corner(1,1,1));
	return fromCloud(cloud);
}
Beispiel #8
0
bool similar(const DoubleBoundingBox3D& a, const DoubleBoundingBox3D& b, double tol)
{
	return similar(a.bottomLeft(), b.bottomLeft(), tol) && similar(a.topRight(), b.topRight(), tol);
}
Beispiel #9
0
/**Transform bb using the transform m.
 * Only the two defining corners are actually transformed.
 */
DoubleBoundingBox3D transform(const Transform3D& m, const DoubleBoundingBox3D& bb)
{
	Vector3D a = m.coord(bb.bottomLeft());
	Vector3D b = m.coord(bb.topRight());
	return DoubleBoundingBox3D(a, b);
}