DoubleBoundingBox3D DoubleBoundingBox3D::fromString(const QString& text) { std::vector<double> raw = convertQString2DoubleVector(text); if (raw.size() != 6) return DoubleBoundingBox3D(0, 1, 0, 1, 0, 1); return DoubleBoundingBox3D((double*) &(*raw.begin())); }
DoubleBoundingBox3D TrackedStream::boundingBox() const { DoubleBoundingBox3D bounds; if(this->hasVideo()) bounds = DoubleBoundingBox3D(mVideoSource->getVtkImageData()->GetBounds()); return bounds; }
DoubleBoundingBox3D PointMetric::boundingBox() const { // convert both inputs to r space Vector3D p0_r = this->getRefCoord(); return DoubleBoundingBox3D(p0_r, p0_r); }
DoubleBoundingBox3D DoubleBoundingBox3D::fromCloud(std::vector<Vector3D> cloud) { if (cloud.empty()) return DoubleBoundingBox3D(0, 0, 0, 0, 0, 0); Vector3D a = cloud[0]; // min Vector3D b = cloud[0]; // max for (unsigned int i = 0; i < cloud.size(); ++i) { for (unsigned int j = 0; j < 3; ++j) { a[j] = std::min(a[j], cloud[i][j]); b[j] = std::max(b[j], cloud[i][j]); } } return DoubleBoundingBox3D(a, b); }
void PlusProtocol::translate(const igtl::ImageMessage::Pointer body) { CX_LOG_DEBUG() << "Image incoming to plusprotocol"; //DIMENSION int x = 0; int y = 1; int z = 2; //There seems to be a bug in the received images spacing from the plusserver /* float wrong_spacing[3]; body->GetSpacing(wrong_spacing); float right_spacing[3]; right_spacing[x] = wrong_spacing[x]; right_spacing[y] = wrong_spacing[z]; right_spacing[z] = 1; body->SetSpacing(right_spacing); */ int dimensions_p[3]; body->GetDimensions(dimensions_p); float spacing[3]; body->GetSpacing(spacing); int extent_p[3]; extent_p[x] = dimensions_p[x]-1; extent_p[y] = dimensions_p[y]-1; extent_p[z] = dimensions_p[z]-1; //IMAGE IGTLinkConversion converter; ImagePtr theImage = converter.decode(body); IGTLinkConversionBase baseConverter; double timestamp_ms = baseConverter.decode_timestamp(body).toMSecsSinceEpoch(); timestamp_ms = this->getSyncedTimestampForTransformsAndImages(timestamp_ms); theImage->setAcquisitionTime(QDateTime::fromMSecsSinceEpoch(timestamp_ms)); emit image(theImage); //PROBEDEFINITION ProbeDefinitionPtr definition(new ProbeDefinition); definition->setUseDigitalVideo(true); definition->setType(ProbeDefinition::tLINEAR); definition->setSpacing(Vector3D(spacing[x], spacing[y], spacing[z])); definition->setSize(QSize(dimensions_p[x], dimensions_p[y])); definition->setOrigin_p(Vector3D(dimensions_p[x]/2, 0, 0)); double depthstart_mm = 0; double depthend_mm = extent_p[y]*spacing[y]; double width_mm = extent_p[x]*spacing[x]; definition->setSector(depthstart_mm, depthend_mm, width_mm); definition->setClipRect_p(DoubleBoundingBox3D(0, extent_p[x], 0, extent_p[y], 0, extent_p[z])); emit probedefinition(mProbeToTrackerName, definition); }
//'copied' from OpenIGTLinkRTSource::updateSonixStatus() ProbeDefinitionPtr IGTLinkConversion::decode(IGTLinkUSStatusMessage::Pointer probeMessage, igtl::ImageMessage::Pointer imageMessage, ProbeDefinitionPtr base) { ProbeDefinitionPtr retval; if (base) retval = base; else retval = ProbeDefinitionPtr(new ProbeDefinition()); if (probeMessage) { // Update the parts of the probe data that is read from the probe message. retval->setType(ProbeDefinition::TYPE(probeMessage->GetProbeType())); retval->setSector( probeMessage->GetDepthStart(), probeMessage->GetDepthEnd(), probeMessage->GetWidth(), 0); retval->setOrigin_p(Vector3D(probeMessage->GetOrigin())); retval->setUid(probeMessage->GetDeviceName()); } if (imageMessage) { // Update the parts of the probe data that must be read from the image. // Retrive the image data float spacing[3]; // spacing (mm/pixel) int size[3]; // image dimension imageMessage->GetDimensions(size); imageMessage->GetSpacing(spacing); retval->setSpacing(Vector3D(spacing[0], spacing[1], spacing[2])); retval->setSize(QSize(size[0], size[1])); retval->setClipRect_p(DoubleBoundingBox3D(0, retval->getSize().width(), 0, retval->getSize().height(), 0, 0)); } return retval; // return this->decode(retval); }
ProbeDefinition createProbeDefinitionFromConfiguration(ProbeXmlConfigParser::Configuration config) { if(config.isEmpty()) return ProbeDefinition(); ProbeDefinition probeDefinition; if (config.mWidthDeg > 0.1) // Sector probe { double depthStart = config.mOffset * config.mPixelHeight; double depthEnd = config.mDepth * config.mPixelHeight + depthStart; double width = config.mWidthDeg * M_PI / 180.0;//width in radians probeDefinition = ProbeDefinition(ProbeDefinition::tSECTOR); probeDefinition.setSector(depthStart, depthEnd, width); } else //Linear probe { int widtInPixels = config.mRightEdge - config.mLeftEdge; double width = config.mPixelWidth * double(widtInPixels); //width in mm // correct for top/bottom edges if applicable double depthStart = double(config.mTopEdge-config.mOriginRow) * config.mPixelHeight; double depthEnd = double(config.mBottomEdge-config.mOriginRow) * config.mPixelHeight; probeDefinition = ProbeDefinition(ProbeDefinition::tLINEAR); probeDefinition.setSector(depthStart, depthEnd, width); } probeDefinition.setSpacing(Vector3D(config.mPixelWidth, config.mPixelHeight, 1)); probeDefinition.setSize(QSize(config.mImageWidth, config.mImageHeight)); probeDefinition.setOrigin_p(Vector3D(config.mOriginCol, config.mOriginRow, 0)); probeDefinition.setClipRect_p(DoubleBoundingBox3D(config.mLeftEdge,config.mRightEdge,config.mTopEdge,config.mBottomEdge,0,0)); probeDefinition.setTemporalCalibration(config.mTemporalCalibration); return probeDefinition; }
/**Create a bounding box based the following input: (xmin,ymin,xmax,ymax) */ DoubleBoundingBox3D DoubleBoundingBox3D::fromViewport(const double* data) { return DoubleBoundingBox3D(data[0], data[2], data[1], data[3], 0, 0); }
DoubleBoundingBox3D OutputVolumeParams::getExtent() { return DoubleBoundingBox3D(Vector3D::Zero(), mImage.getBounds()); }
DoubleBoundingBox3D Image::getInitialBoundingBox() const { return DoubleBoundingBox3D(-1, -1, -1, -1, -1, -1); }
/** get current cropping box in ref coords */ DoubleBoundingBox3D InteractiveCropper::getBoundingBox() { if (!mImage || !mBoxWidget) return DoubleBoundingBox3D(0,0,0,0,0,0); return mImage->getCroppingBox(); }
/**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); }