::fwData::Object::sptr CompositeConverter::fromIgtlMessage(const ::igtl::MessageBase::Pointer src) const { ::igtl::TrackingDataMessage::Pointer trackingMsg; trackingMsg = ::igtl::TrackingDataMessage::Pointer(dynamic_cast< ::igtl::TrackingDataMessage* >(src.GetPointer())); const int nbTrckingElement = trackingMsg->GetNumberOfTrackingDataElements(); FW_RAISE_EXCEPTION_IF(::igtlProtocol::exception::Conversion("TrackingDataElements"), nbTrckingElement < 0); ::fwData::Composite::sptr composite = ::fwData::Composite::New(); for(int i = 0; i < nbTrckingElement; ++i) { ::igtl::TrackingDataElement::Pointer trackElement = ::igtl::TrackingDataElement::New(); trackingMsg->GetTrackingDataElement(i, trackElement); const std::string name = trackElement->GetName(); ::fwData::TransformationMatrix3D::sptr transfoMatrix = ::fwData::TransformationMatrix3D::New(); (*composite)[name] = transfoMatrix; ::igtl::Matrix4x4 matrix; trackElement->GetMatrix(matrix); for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { transfoMatrix->setCoefficient(i, j, matrix[i][j]); } } } return composite; }
void DicomSeries::cachedDeepCopy(const ::fwData::Object::csptr& _source, DeepCopyCacheType& cache) { DicomSeries::csptr other = DicomSeries::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->::fwMedData::Series::cachedDeepCopy(_source, cache); m_numberOfInstances = other->m_numberOfInstances; m_SOPClassUIDs = other->m_SOPClassUIDs; m_computedTagValues = other->m_computedTagValues; m_firstInstanceNumber = other->m_firstInstanceNumber; m_dicomContainer.clear(); for(const auto& elt : other->m_dicomContainer) { const ::fwMemory::BufferObject::sptr& bufferSrc = elt.second; ::fwMemory::BufferObject::Lock lockerSource(bufferSrc); if( !bufferSrc->isEmpty() ) { ::fwMemory::BufferObject::sptr bufferDest = ::fwMemory::BufferObject::New(); ::fwMemory::BufferObject::Lock lockerDest(bufferDest); bufferDest->allocate(bufferSrc->getSize()); char* buffDest = static_cast< char* >( lockerDest.getBuffer() ); char* buffSrc = static_cast< char* >( lockerSource.getBuffer() ); std::copy(buffSrc, buffSrc + bufferSrc->getSize(), buffDest ); m_dicomContainer[elt.first] = bufferDest; } } }
void InsertSeries::cachedDeepCopy(const ::fwData::Object::csptr &_source, DeepCopyCacheType &cache) { InsertSeries::csptr other = InsertSeries::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source?_source->getClassname():std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->::fwMedData::Series::cachedDeepCopy(_source, cache); }
void TransformationMatrix3D::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) { TransformationMatrix3D::csptr other = TransformationMatrix3D::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source?_source->getClassname():std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldDeepCopy( _source, cache ); m_vCoefficients = other->m_vCoefficients; }
void String::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) { String::csptr other = String::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source?_source->getClassname():std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldDeepCopy( _source, cache ); m_value = other->m_value; }
void Graph::shallowCopy(const Object::csptr& _source ) { Graph::csptr other = Graph::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldShallowCopy( _source ); m_nodes = other->m_nodes; m_connections = other->m_connections; }
void Equipment::shallowCopy(const ::fwData::Object::csptr &_source) { Equipment::csptr other = Equipment::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source?_source->getClassname():std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldShallowCopy( _source ); m_attrInstitutionName = other->m_attrInstitutionName; }
void Line::shallowCopy(const Object::csptr &_source ) { Line::csptr other = Line::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source?_source->getClassname():std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldShallowCopy( _source ); m_position = other->m_position; m_direction = other->m_direction; }
void MultiFiles::cachedDeepCopy(const Object::csptr &source, DeepCopyCacheType &cache) { MultiFiles::csptr other = MultiFiles::dynamicConstCast(source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (source ? source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldDeepCopy( source, cache ); OSLM_FATAL("Not implemented." ); }
void Tag::cachedDeepCopy(const Object::csptr &source, DeepCopyCacheType &cache) { Tag::csptr other = Tag::dynamicConstCast(source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (source?source->getClassname():std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldDeepCopy( source, cache ); m_sType = other->m_sType; m_size = other->m_size; m_pointList = ::fwData::Object::copy(other->m_pointList, cache); }
void ActivitySeries::shallowCopy(const ::fwData::Object::csptr &_source) { ActivitySeries::csptr other = ActivitySeries::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source?_source->getClassname():std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->::fwMedData::Series::shallowCopy(_source); m_attrActivityConfigId = other->m_attrActivityConfigId; m_attrData = other->m_attrData; }
//------------------------------------------------------------------------------ void Edge::shallowCopy(const Object::csptr &_source ) { Edge::csptr other = Edge::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldShallowCopy( _source ); m_fromPortIdentifier = other->m_fromPortIdentifier; m_toPortIdentifier = other->m_toPortIdentifier; m_nature = other->m_nature; }
void Image::shallowCopy(const Object::csptr& _source ) { Image::csptr other = Image::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldShallowCopy( _source ); // Assign copyInformation( other ); m_dataArray = other->m_dataArray; }
void DicomSurface::setFromData(fwData::Reconstruction::csptr reconstruction) { // Get mesh ::fwData::Mesh::sptr mesh = reconstruction->getMesh(); FW_RAISE_EXCEPTION_IF(::gdcmIO::exception::Failed("Can't save this mesh. It must contain only triangles !"), !::fwDataTools::Mesh::hasUniqueCellType(mesh, ::fwData::Mesh::TRIANGLE)); ::fwData::Array::sptr pointArray = mesh->getPointsArray(); ::fwComEd::helper::Array pointArrayHelper(pointArray); ::fwData::Mesh::PointValueType* points = pointArrayHelper.begin< ::fwData::Mesh::PointValueType >(); ::fwData::Array::sptr cellData = mesh->getCellDataArray(); ::fwComEd::helper::Array cellDataHelper(cellData); ::fwData::Mesh::CellValueType* cells = cellDataHelper.begin< ::fwData::Mesh::CellValueType >(); // Initialize members m_pointCoordSize = mesh->getNumberOfPoints(); m_pointCoordData = ::boost::shared_ptr< float >(new float[3 * m_pointCoordSize]); m_pointIndexSize = mesh->getNumberOfCells(); m_pointIndexList = ::boost::shared_ptr< uint32_t >(new uint32_t[3 * m_pointIndexSize]); m_normalCoordSize = 0; // Traverse Mesh components float* pointCoordData = m_pointCoordData.get(); uint32_t* pointIndexList = m_pointIndexList.get(); memcpy(pointCoordData, points, pointArray->getSizeInBytes()); for (unsigned long id = 0; id < mesh->getCellDataSize(); ++id) { *pointIndexList = static_cast< uint32_t >(*cells); ++cells; ++pointIndexList; } if (mesh->getPointNormalsArray()) { ::fwData::Array::sptr normalArray = mesh->getPointNormalsArray(); ::fwComEd::helper::Array normalArrayHelper(normalArray); ::fwData::Mesh::NormalValueType* normals = normalArrayHelper.begin< ::fwData::Mesh::NormalValueType >(); m_normalCoordSize = mesh->getNumberOfPoints(); m_normalCoordData = ::boost::shared_ptr< float >(new float[3 * m_normalCoordSize]); float *normalCoordData = m_normalCoordData.get(); memcpy(normalCoordData, normals, normalArray->getSizeInBytes()); } }
Numeric::ValueType Numeric::valueFromString(const std::string &s, Numeric::NumericType type) { Numeric::ValueType res; SLM_ASSERT("Invalid variant type requested", EMPTY <= type && type <= DOUBLE); if ( type == EMPTY) { FW_RAISE_EXCEPTION_IF( ::fwAtoms::Exception( std::string("Unable to get numeric from '") + s + "'"), !(lexicalCast< ::boost::int64_t >(res, s) || lexicalCast< ::boost::uint64_t >(res, s) || lexicalCast< double >(res, s)) ); } else if ( type == INT) { FW_RAISE_EXCEPTION_IF( ::fwAtoms::Exception( std::string("Unable to get int64 numeric from '") + s + "'"), !lexicalCast< ::boost::int64_t >(res, s) ); } else if ( type == UINT) { FW_RAISE_EXCEPTION_IF( ::fwAtoms::Exception( std::string("Unable to get uint64 numeric from '") + s + "'"), !lexicalCast< ::boost::uint64_t >(res, s) ); } else if ( type == DOUBLE) { FW_RAISE_EXCEPTION_IF( ::fwAtoms::Exception( std::string("Unable to get double numeric from '") + s + "'"), !lexicalCast< double >(res, s) ); } return res; }
void DicomSeries::shallowCopy(const ::fwData::Object::csptr& _source) { DicomSeries::csptr other = DicomSeries::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->::fwMedData::Series::shallowCopy(_source); m_numberOfInstances = other->m_numberOfInstances; m_dicomContainer = other->m_dicomContainer; m_SOPClassUIDs = other->m_SOPClassUIDs; m_computedTagValues = other->m_computedTagValues; m_firstInstanceNumber = other->m_firstInstanceNumber; }
void Image::cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) { Image::csptr other = Image::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldDeepCopy( _source, cache ); // Assign copyInformation( other ); if( other->m_dataArray ) { m_dataArray = ::fwData::Object::copy(other->m_dataArray, cache); } }
void PacsConfiguration::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) { PacsConfiguration::csptr other = PacsConfiguration::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source?_source->getClassname():std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldDeepCopy( _source, cache ); m_attrLocalApplicationTitle = other->m_attrLocalApplicationTitle; m_attrPacsHostName = other->m_attrPacsHostName; m_attrPacsApplicationTitle = other->m_attrPacsApplicationTitle; m_attrPacsApplicationPort = other->m_attrPacsApplicationPort; m_attrMoveApplicationTitle = other->m_attrMoveApplicationTitle; m_attrMoveApplicationPort = other->m_attrMoveApplicationPort; m_attrRetrieveMethod = other->m_attrRetrieveMethod; }
void Series::cachedDeepCopy(const ::fwData::Object::csptr &_source, DeepCopyCacheType &cache) { Series::csptr other = Series::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldDeepCopy( other, cache ); m_patient = ::fwData::Object::copy(other->m_patient, cache); m_study = ::fwData::Object::copy(other->m_study, cache); m_equipment = ::fwData::Object::copy(other->m_equipment, cache); m_instanceUID = other->m_instanceUID; m_modality = other->m_modality; m_date = other->m_date; m_time = other->m_time; m_performingPhysiciansName = other->m_performingPhysiciansName; m_description = other->m_description; }
void Graph::cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) { Graph::csptr other = Graph::dynamicConstCast(_source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldDeepCopy( _source, cache ); std::map< ::fwData::Node::sptr, ::fwData::Node::sptr > correspondenceBetweenNodes; typedef std::pair< Edge::sptr, std::pair< Node::sptr, Node::sptr > > ConnectionContainerElt; m_nodes.clear(); for(const ::fwData::Node::sptr& node : other->m_nodes) { ::fwData::Node::sptr newNode = ::fwData::Object::copy(node, cache); bool addOK = this->addNode(newNode); OSLM_ASSERT("Node "<<newNode->getID() <<" can't be added ", addOK ); FwCoreNotUsedMacro(addOK); correspondenceBetweenNodes.insert(std::make_pair(node, newNode)); } m_connections.clear(); for(const ConnectionContainerElt& connection : other->m_connections) { // Edge deep copy . ::fwData::Edge::sptr newEdge = ::fwData::Object::copy(connection.first, cache); ::fwData::Node::sptr oldNode1 = (connection.second).first; ::fwData::Node::sptr oldNode2 = (connection.second).second; if ((correspondenceBetweenNodes.find(Node::constCast(oldNode1)) != correspondenceBetweenNodes.end()) && (correspondenceBetweenNodes.find(Node::constCast(oldNode2)) != correspondenceBetweenNodes.end())) { // Add new Edge this->addEdge(newEdge, correspondenceBetweenNodes[oldNode1], correspondenceBetweenNodes[oldNode2]); } } correspondenceBetweenNodes.clear(); }
std::string Numeric::getString() const { FW_RAISE_EXCEPTION_IF( ::fwAtoms::Exception("Empty numeric atom"), m_value.which() == 0); return ::boost::lexical_cast<std::string>(m_value); }
void SpatialFiducialsIOD::read(::fwMedData::Series::sptr series) throw (::fwGdcmIO::exception::Failed) { // Retrieve images ::fwMedData::ImageSeries::sptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series); SLM_ASSERT("ImageSeries should not be null.", imageSeries); ::fwData::Image::sptr image = imageSeries->getImage(); SLM_ASSERT("::fwData::Image not instanced", image); // Create GDCM Reader SPTR(::gdcm::Reader) reader = std::shared_ptr< ::gdcm::Reader >( new ::gdcm::Reader ); // Read the first file ::fwMedData::DicomSeries::DicomContainerType dicomContainer = m_dicomSeries->getDicomContainer(); if(dicomContainer.size() > 1) { m_logger->warning("More than one Spatial Fiducials item have been found in the series. " "Only the first one will be read."); } const ::fwMemory::BufferObject::sptr bufferObj = dicomContainer.begin()->second; const ::fwMemory::BufferManager::StreamInfo streamInfo = bufferObj->getStreamInfo(); SPTR(std::istream) is = streamInfo.stream; reader->SetStream(*is); const bool success = reader->Read(); FW_RAISE_EXCEPTION_IF(::fwGdcmIO::exception::Failed("Unable to read the DICOM instance \""+ bufferObj->getStreamInfo().fsFile.string()+ "\" using the GDCM Reader."), !success); // Create Information Entity helpers ::fwGdcmIO::reader::ie::SpatialFiducials spatialFiducialsIE( m_dicomSeries, reader, m_instance, imageSeries->getImage(), m_logger, m_progressCallback, m_cancelRequestedCallback); // Retrieve dataset const ::gdcm::DataSet& datasetRoot = reader->GetFile().GetDataSet(); // Retrieve Fiducial Set Sequence const ::gdcm::DataElement& fiducialSetSequenceDataElement = datasetRoot.GetDataElement( ::gdcm::Tag(0x0070, 0x031C) ); const ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > fiducialSetSequence = fiducialSetSequenceDataElement.GetValueAsSQ(); for(unsigned int i = 1; i <= fiducialSetSequence->GetNumberOfItems(); ++i) { ::gdcm::Item sequenceSetItem = fiducialSetSequence->GetItem(i); const ::gdcm::DataSet& sequenceSetDataset = sequenceSetItem.GetNestedDataSet(); const ::gdcm::DataElement& fiducialSequenceDataElement = sequenceSetDataset.GetDataElement( ::gdcm::Tag(0x0070, 0x031E) ); const ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > fiducialSequence = fiducialSequenceDataElement.GetValueAsSQ(); for(unsigned int j = 1; j <= fiducialSequence->GetNumberOfItems(); ++j) { ::gdcm::Item fiducialItem = fiducialSequence->GetItem(j); const ::gdcm::DataSet& fiducialDataset = fiducialItem.GetNestedDataSet(); const std::string shapeType = ::fwGdcmIO::helper::DicomDataReader::getTagValue<0x0070, 0x0306>(fiducialDataset); if(shapeType == "POINT") { spatialFiducialsIE.readLandmark(fiducialDataset); } else { m_logger->warning("Fiducial shape type not supported: \"" + shapeType + "\""); } } } }