${GDCM_BINARY_DIR}/
)
-ADD_EXECUTABLE(WriteDicom WriteDicom.cxx)
-TARGET_LINK_LIBRARIES(WriteDicom gdcm)
ADD_EXECUTABLE(PrintDocument PrintDocument.cxx)
TARGET_LINK_LIBRARIES(PrintDocument gdcm)
+ADD_EXECUTABLE(PrintFile PrintFile.cxx)
+TARGET_LINK_LIBRARIES(PrintFile gdcm)
+
+ADD_EXECUTABLE(Write Write.cxx)
+TARGET_LINK_LIBRARIES(Write gdcm)
+
+ADD_EXECUTABLE(WriteDicom WriteDicom.cxx)
+TARGET_LINK_LIBRARIES(WriteDicom gdcm)
+
ADD_EXECUTABLE(WriteRead WriteRead.cxx)
TARGET_LINK_LIBRARIES(WriteRead gdcm)
// gdcmFile *e2;
gdcmHeader *e1;
- bool dropPriv = false;
- bool showSeq = true;
- bool niou = false;
std::string fileName;
- if (argc == 1) {
- std::cout << argv[0] <<
- " fileName" << std::endl <<
- " [nopriv] if you don't want to print Shadow groups" << std::endl <<
- " [noseq] if you don't want to 'go inside' the SQ's" << std::endl <<
- " [new] if you want a 'SeQuence indented' printing"<< std::endl;
- }
+ if (argc != 2) {
+ std::cout << " usage : PrintDocument fileName" << std::endl;
+ }
if (argc > 1) {
fileName=argv[1];
fileName += "/test.acr";
}
- for (int j=0;j<argc;j++) {
- if (strcmp(argv[j],"nopriv")==0)
- dropPriv=true;
- else if (strcmp(argv[j],"noseq")==0)
- showSeq=false;
- else if (strcmp(argv[j],"new")==0)
- niou = true;
- }
-
- //e2 = new gdcmFile(fileName.c_str(),false, showSeq, dropPriv);
- //e1 = e2->GetHeader();
-
e1= new gdcmHeader
- (fileName.c_str(),
- false, showSeq,
- dropPriv);
-
-// if (argc > 2) {
-// int level = atoi(argv[2]);
-// e1->SetPrintLevel(level);
-// }
+ (fileName.c_str(),false, true);
-e1->SetPrintLevel(2);
-
- //if (! niou)
- // e1->Print();
- //else if (showSeq)
- // e1->PrintNiceSQ();
- //else
- // e1->PrintNoSQ();
+ e1->SetPrintLevel(2);
- e1->Print();
+ e1->Print();
- std::cout << "\n\n" << std::endl;
- std::string transferSyntaxName = e1->GetTransfertSyntaxName();
- std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
-
- if ( transferSyntaxName != "Implicit VR - Little Endian"
- && transferSyntaxName != "Explicit VR - Little Endian"
- && transferSyntaxName != "Deflated Explicit VR - Little Endian"
- && transferSyntaxName != "Explicit VR - Big Endian"
- && transferSyntaxName != "Uncompressed ACR-NEMA" )
- {
- std::cout << std::endl << "==========================================="
- << std::endl;
- //e2->ParsePixelData();
- std::cout << std::endl << "==========================================="
- << std::endl;
- }
+ std::cout << "\n\n" << std::endl;
if(e1->IsReadable())
std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
--- /dev/null
+#include <iostream>
+
+#include "gdcmException.h"
+#include "gdcmCommon.h"
+
+#include "gdcmDictEntry.h"
+#include "gdcmDict.h"
+#include "gdcmDictSet.h"
+#include "gdcmHeader.h"
+#include "gdcmUtil.h"
+#include "gdcmBinEntry.h"
+#include "gdcmDocEntry.h"
+#include "gdcmDocEntrySet.h"
+#include "gdcmDocument.h"
+#include "gdcmElementSet.h"
+#include "gdcmSeqEntry.h"
+#include "gdcmSQItem.h"
+#include "gdcmValEntry.h"
+#include "gdcmFile.h"
+int main(int argc, char* argv[])
+{
+
+ gdcmHeader *e1;
+ gdcmFile *f1;
+ std::string fileName;
+ if (argc != 2) {
+ std::cout << " usage : PrintDocument fileName" << std::endl;
+ }
+
+ if (argc > 1) {
+ fileName=argv[1];
+ } else {
+ fileName += GDCM_DATA_ROOT;
+ fileName += "/test.acr";
+ }
+
+ e1= new gdcmHeader
+ (fileName.c_str(),false, true);
+
+ f1 = new gdcmFile(e1);
+
+ e1->SetPrintLevel(2);
+
+ e1->Print();
+
+ std::cout << "\n\n" << std::endl;
+
+ int dataSize = f1->GetImageDataSize();
+ std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
+ int nX,nY,nZ,sPP,planarConfig;
+ std::string pixelType;
+ nX=e1->GetXSize();
+ nY=e1->GetYSize();
+ nZ=e1->GetZSize();
+ std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
+
+ pixelType = e1->GetPixelType();
+ sPP = e1->GetSamplesPerPixel();
+ planarConfig = e1->GetPlanarConfiguration();
+
+ std::cout << " pixelType=" << pixelType
+ << " SampleserPixel=" << sPP
+ << " PlanarConfiguration=" << planarConfig
+ << std::endl
+ << " PhotometricInterpretation="
+ << e1->GetEntryByNumber(0x0028,0x0004)
+ << std::endl;
+
+ int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
+ std::cout << " NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
+
+ std::string transferSyntaxName = e1->GetTransfertSyntaxName();
+ std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
+
+ if ( transferSyntaxName != "Implicit VR - Little Endian"
+ && transferSyntaxName != "Explicit VR - Little Endian"
+ && transferSyntaxName != "Deflated Explicit VR - Little Endian"
+ && transferSyntaxName != "Explicit VR - Big Endian"
+ && transferSyntaxName != "Uncompressed ACR-NEMA" )
+ {
+ std::cout << std::endl << "==========================================="
+ << std::endl;
+ f1->ParsePixelData(); // gdcmFile Method :-(
+ std::cout << std::endl << "==========================================="
+ << std::endl;
+ }
+
+ if(e1->IsReadable())
+ std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
+ else
+ std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
+ std::cout<<std::flush;
+ delete e1;
+
+ return 0;
+
+}
--- /dev/null
+#include <iostream>
+#include "gdcm.h"
+#include "gdcmHeader.h"
+#include "gdcmDocument.h"
+
+#include <stdio.h>
+
+int main(int argc, char* argv[])
+{
+ std::string toto;
+ char zozo[200];
+
+ gdcmHeader* e1;
+ gdcmFile * f1;
+
+ //gdcmDocument * d; //not used
+ void* imageData;
+ int dataSize;
+
+ if (argc < 3) {
+ std::cerr << "usage: " << std::endl
+ << argv[0] << " fileName writtingMode "
+ << std::endl
+ << "(a : ACR, d : DICOM Implicit VR,"
+ << " x : DICOM Explicit VR, r : RAW)"
+ << std::endl;
+ return 0;
+ }
+/*
+ if (0) { // Just to keep the code for further use
+ std::cout <<std::endl << "-------- Test gdcmHeader ------" <<std::endl;
+ e1 = new gdcmHeaderHelper(argv[1]);
+ if (!f1->GetHeader()->IsReadable()) {
+ std::cout << "Sorry, not a DICOM / ACR File" <<std::endl;
+ exit(0);
+ }
+ std::cout << std::endl << "----------------------> after new gdcmHeader"
+ << std::endl;
+ e1->PrintEntry();
+ std::cout <<std::endl <<"---------------------------------------"
+ <<std::endl;
+ }
+*/
+
+ std::cout << std::endl
+ << "--------------------- file :" << argv[1]
+ << std::endl;
+
+ toto = argv[1];
+
+ e1 = new gdcmHeader(toto.c_str(), false, true);
+ if (!e1->IsReadable()) {
+ std::cerr << "Sorry, not a Readable DICOM / ACR File" <<std::endl;
+ return 0;
+ }
+ // e1->Print();
+
+ f1 = new gdcmFile(e1);
+// ---
+
+ dataSize = f1->GetImageDataSize();
+ std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
+ int nX,nY,nZ,sPP,planarConfig;
+ std::string pixelType, transferSyntaxName;
+ nX=e1->GetXSize();
+ nY=e1->GetYSize();
+ nZ=e1->GetZSize();
+ std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
+
+ pixelType = e1->GetPixelType();
+ sPP = e1->GetSamplesPerPixel();
+ planarConfig = e1->GetPlanarConfiguration();
+
+ std::cout << " pixelType=" << pixelType
+ << " SampleserPixel=" << sPP
+ << " PlanarConfiguration=" << planarConfig
+ << " PhotometricInterpretation="
+ << e1->GetEntryByNumber(0x0028,0x0004)
+ << std::endl;
+
+ int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
+ std::cout << "NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
+ transferSyntaxName = e1->GetTransfertSyntaxName();
+ std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
+
+ if ( transferSyntaxName != "Implicit VR - Little Endian"
+ && transferSyntaxName != "Explicit VR - Little Endian"
+ && transferSyntaxName != "Deflated Explicit VR - Little Endian"
+ && transferSyntaxName != "Explicit VR - Big Endian"
+ && transferSyntaxName != "Uncompressed ACR-NEMA" ) {
+ std::cout << std::endl << "==========================================="
+ << std::endl;
+ f1->ParsePixelData();
+ std::cout << std::endl << "==========================================="
+ << std::endl;
+ }
+ imageData= f1->GetImageData();
+
+ switch (argv[2][0]) {
+ case 'a' :
+ // ecriture d'un fichier ACR
+ // à partir d'un dcmHeader correct.
+
+ sprintf(zozo, "%s.ACR", toto.c_str());
+ printf ("WriteACR\n");
+ f1->WriteAcr(zozo);
+ break;
+
+ case 'd' :
+ // ecriture d'un fichier DICOM Implicit VR
+ // à partir d'un dcmHeader correct.
+
+ sprintf(zozo, "%s.DCM", toto.c_str());
+ printf ("WriteDCM Implicit VR\n");
+ f1->WriteDcmImplVR(zozo);
+ break;
+
+ case 'x' :
+ // ecriture d'un fichier DICOM Explicit VR
+ // à partir d'un dcmHeader correct.
+
+ sprintf(zozo, "%s.XDCM", toto.c_str());
+ std::cout << "WriteDCM Explicit VR" << std::endl;
+ f1->WriteDcmExplVR(zozo);
+ break;
+
+ case 'r' :
+ // Ecriture d'un Raw File, a afficher avec
+ // affim filein= dimx= dimy= nbit= signe=
+
+ sprintf(zozo, "%s.RAW", toto.c_str());
+ std::cout << "WriteRaw" << std::endl;
+ f1->WriteRawData(zozo);
+ break;
+
+ }
+ return 0;
+}
+
{
std::cerr << "Usage :" << std::endl << argv[0] <<
" HeaderFileName DataFileName" << std::endl;
- return 0;
+ return 0;
}
const char *first = argv[1];
gdcmFile *f1 = new gdcmFile( first );
-
+
const char *second = argv[2];
gdcmFile *f2 = new gdcmFile( second );
-
- // f1->PrintPubElVal();
-
+
// We assume that DICOM fields of second file actually exists :
-
+
std::string nbFrames = f2->GetHeader()->GetEntryByNumber(0x0028, 0x0008);
if(nbFrames != "gdcm::Unfound") {
f1->GetHeader()->ReplaceOrCreateByNumber( nbFrames, 0x0028, 0x0008);
f2->GetHeader()->GetEntryByNumber(0x0028, 0x0011), 0x0028, 0x0011); // nbCol
// Some other tags should be updated:
-
- // TODO : add a default value
+
+ // TODO : add a default value
// TODO : a function which take as input a list of tuple (gr, el)
// and that does the job
void *imageData = f2->GetImageData();
std::cout << "dataSize :" << dataSize << std::endl;
-
+
// TODO : Shouldn't we merge those two functions ?
f1->SetImageData( imageData, dataSize);
f1->GetHeader()->SetImageDataSize( dataSize );
-
+
f1->GetHeader()->Print();
-
+
std::string s0 = f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0000);
std::string s10 = f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0010);
std::cout << "lgr 7fe0, 0000 " << s0 << std::endl;
- std::cout << "lgr 7fe0, 0010 " << s10 << std::endl;
+ std::cout << "lgr 7fe0, 0010 " << s10 << std::endl;
std::cout << "WriteDCM" << std::endl;
f1->WriteDcmExplVR("WriteDicom.dcm");
- //f1->WriteDcmImplVR(resultat);
- //f1->WriteAcr(resultat);
return 0;
}