void SeriesDB::generateReconstruction(::fwData::Reconstruction::sptr rec) { rec->setIsVisible(true); rec->setOrganName("liver"); rec->setStructureType("Liver"); ::fwData::Image::sptr img = ::fwData::Image::New(); Image::generateRandomImage(img, ::fwTools::Type::create("uint16")); rec->setImage(img); ::fwData::Material::sptr material = ::fwData::Material::New(); material->ambient()->red() = 0.75f; material->ambient()->green() = 0.10f; material->ambient()->blue() = 0.56f; material->ambient()->alpha() = 0.8f; material->diffuse()->red() = 0.85f; material->diffuse()->green() = 0.20f; material->diffuse()->blue() = 0.66f; material->diffuse()->alpha() = 0.9f; rec->setMaterial(material); ::fwData::Mesh::sptr mesh = ::fwData::Mesh::New(); Mesh::generateMesh( mesh ); rec->setMesh(mesh); }
void DicomSegmentReader::readSurfaceSegmentation( ::fwData::Reconstruction::sptr a_reconstruction, ::gdcm::SmartPointer< ::gdcm::Segment > a_segment ) throw (::fwTools::Failed) { if (a_segment->GetSurfaceCount() != 1) throw ::fwTools::Failed("Unappropriated surface count for a segment"); //***** Set the reconstruction *****// // Organ Name // TODO : if empty, try to get label with DicomDictionarySegment a_reconstruction->setOrganName( a_segment->GetSegmentDescription()); OSLM_TRACE("Organ Name : " << a_reconstruction->getOrganName()); a_reconstruction->setStructureType(a_segment->GetSegmentLabel()); OSLM_TRACE("Structure type : " << a_reconstruction->getStructureType()); a_reconstruction->setIsAutomatic( ((a_segment->GetSegmentAlgorithmType() == ::gdcm::Segment::AUTOMATIC)? true : false) ); OSLM_TRACE("Reconstruction is automatic : " << a_reconstruction->getIsAutomatic()); }
void DicomSurface::convertToData(fwData::Reconstruction::sptr reconstruction) { // Get mesh ::fwData::Mesh::sptr mesh = ::fwData::Mesh::New(); // Initialize members const unsigned long sizePoints = m_pointCoordSize / 3; const unsigned long sizeCells = m_pointIndexSize / 3; mesh->setNumberOfPoints(sizePoints); mesh->setNumberOfCells(sizeCells); mesh->setCellDataSize(sizeCells * 3); mesh->adjustAllocatedMemory(); ::fwData::Array::sptr pointArray = mesh->getPointsArray(); ::fwData::Array::sptr cellData = mesh->getCellDataArray(); ::fwData::Array::sptr cellDataOffsets = mesh->getCellDataOffsetsArray(); ::fwData::Array::sptr cellTypes = mesh->getCellTypesArray(); ::fwComEd::helper::Array pointArrayHelper(pointArray); ::fwComEd::helper::Array cellDataHelper(cellData); ::fwComEd::helper::Array cellDataOffsetsHelper(cellDataOffsets); ::fwComEd::helper::Array cellTypesHelper(cellTypes); ::fwData::Mesh::PointValueType* points = pointArrayHelper.begin< ::fwData::Mesh::PointValueType >(); ::fwData::Mesh::CellValueType* cells = cellDataHelper.begin< ::fwData::Mesh::CellValueType >(); // Traverse DicomSurface components const float* pointCoordData = m_pointCoordData.get(); const uint32_t* pointIndexList = m_pointIndexList.get(); memcpy(points, pointCoordData, pointArray->getSizeInBytes()); for (unsigned long id = 0; id < sizeCells * 3; ++id) { *cells = static_cast< ::fwData::Mesh::CellValueType >(*pointIndexList); ++cells; ++pointIndexList; } std::fill(cellTypesHelper.begin< ::fwData::Mesh::CellTypes >(), cellTypesHelper.end< ::fwData::Mesh::CellTypes >(), static_cast< ::fwData::Mesh::CellTypes >(::fwData::Mesh::TRIANGLE)); cell_data_offset_generator cellDataOffsetGenerator; std::generate(cellDataOffsetsHelper.begin< ::fwData::Mesh::CellDataOffsetType >(), cellDataOffsetsHelper.end< ::fwData::Mesh::CellDataOffsetType >(), cellDataOffsetGenerator); if (m_normalCoordSize > 0) { const float *normalCoordData = m_normalCoordData.get(); mesh->allocatePointNormals(); ::fwData::Array::sptr normalArray = mesh->getPointNormalsArray(); ::fwComEd::helper::Array normalArrayHelper(normalArray); ::fwData::Mesh::NormalValueType* normals = normalArrayHelper.begin< ::fwData::Mesh::NormalValueType >(); memcpy(normals, normalCoordData, normalArray->getSizeInBytes()); } reconstruction->setMesh(mesh); }