示例#1
0
文件: anonymizer.cpp 项目: CAAP/Lua
static int basicProtection ( gdcm::Tag const &tag, const gdcm::Type type, gdcm::DataSet &ds ) {
    gdcm::DataElement de = ds.GetDataElement( tag );

    if ( canEmpty(tag, type) ) {
	de.Empty();
	ds.Replace( de );
	return 1;
    }

    gdcm::UIDGenerator uid;
    if ( isVRUI(tag) ) {
	const gdcm::ByteValue *bv;
	const char *oldUID = ( !de.IsEmpty() && (bv = de.GetByteValue()) ) ? bv->GetPointer() : "";
	// anonymize UID XXX
	const char *newUID = "DUMMY-UID"; //uid.Generate();
	de.SetByteValue( newUID, (uint32_t)strlen(newUID) );
    } else {
	const char *dummy = "DUMMY";
	//dummy = ( dummy = gdcm::DummyValueGenerator::Generate( "" ) )  "";
	// anonymize non-UID XXX
	de.SetByteValue( dummy, (uint32_t)strlen(dummy) );
    }
    ds.Replace( de );
    return 1;
}
示例#2
0
文件: anonymizer.cpp 项目: CAAP/Lua
static int replaceData( gdcm::Tag const &t, gdcm::DataSet &ds, const gdcm::DictEntry &entry, char const *str, gdcm::VL::Type const size ) {
    gdcm::DataElement de ( t );
    de.SetVR( ds.FindDataElement(t) ? ds.GetDataElement(t).GetVR() : entry.GetVR() );
    de.SetByteValue( str, size );
    ds.Replace( de );
    return 1;
}
示例#3
0
文件: anonymizer.cpp 项目: CAAP/Lua
static int recurseDataSet ( gdcm::DataSet &ds, gdcm::File &F ) {
    if ( ds.IsEmpty() ) {return 0;}

    static const gdcm::Tag *start = BasicApplicationLevelConfidentialityProfileAttributes;
    static const gdcm::Tag *ptr,*end = start + nIDs;
    const gdcm::IOD& iod = defs.GetIODFromFile( F );

    for(ptr = start; ptr != end; ++ptr) {
	const gdcm::Tag &tag = *ptr;
	if ( ds.FindDataElement( tag ) ) {
	    basicProtection( tag, iod.GetTypeFromTag(defs, tag), ds );
	}
    }

    gdcm::DataSet::ConstIterator it = ds.Begin();
    for (; it != ds.End() ;) {
	gdcm::DataElement de = *it++;
	gdcm::VR vr = gdcm::DataSetHelper::ComputeVR( F, ds, de.GetTag() );
	gdcm::SmartPointer<gdcm::SequenceOfItems> sqi = 0;

	if ( vr == gdcm::VR::SQ && (sqi = de.GetValueAsSQ()) ) {
	    de.SetValue( *sqi );
	    de.SetVLToUndefined();
	    gdcm::SequenceOfItems::SizeType i;
	    for (i = 1; i <= sqi->GetNumberOfItems(); i++ ) {
		gdcm::Item &item = sqi->GetItem( i );
		gdcm::DataSet &nested = item.GetNestedDataSet();
		recurseDataSet( nested, F );
	    }
	}

	ds.Replace( de ); // REPLACE
    }
    return 1;
}
示例#4
0
文件: anonymizer.cpp 项目: CAAP/Lua
static int emptyData( gdcm::Tag const &t, gdcm::DataSet &ds ) {
    gdcm::DataElement de( t );
    de.SetVR( gdcm::VR::SQ );
    ds.Replace( de );
    return 1;
}