diff --git a/Utilities/KWStyle/MITKHeader.h b/Utilities/KWStyle/MITKHeader.h index 08e538b72d..970cfe5a27 100644 --- a/Utilities/KWStyle/MITKHeader.h +++ b/Utilities/KWStyle/MITKHeader.h @@ -1,16 +1,15 @@ -/*========================================================================= +/*=================================================================== -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ \ No newline at end of file +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ diff --git a/Utilities/ipSegmentation/ipSegmentation.h b/Utilities/ipSegmentation/ipSegmentation.h index 57aa9ebc3f..31a689fb32 100644 --- a/Utilities/ipSegmentation/ipSegmentation.h +++ b/Utilities/ipSegmentation/ipSegmentation.h @@ -1,214 +1,213 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ /*! \mainpage \author Tobias Kunert, Thomas Boettger, Tobias Heimann (Deutsches Krebsforschungszentrum, Heidelberg) \date October 2002 The ipMITKSegmentation library manages the results of the segmentation process. It provides basic capabilities to modify segmentation images. It includes also an undo mechanism which allows to trace back the changes. */ #ifndef IPSEGMENTATION_H #define IPSEGMENTATION_H #include #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! \brief Defines the data type of the segmentation images. */ #define ipMITKSegmentationTYPE mitkIpUInt1_t #define ipMITKSegmentationTYPE_ID mitkIpPicUInt #define ipMITKSegmentationBPE 8 #define tagSEGMENTATION_EMPTY "SEGMENTATION_EMPTY" /*! \brief Initializes the segmentation. @param image the original image which will be segmented @return the segmentation. */ extern mitkIpPicDescriptor* ipMITKSegmentationNew (mitkIpPicDescriptor* image); /*! \brief Destroys the segmentation. @param segmentation the segmentation. */ extern void ipMITKSegmentationFree (mitkIpPicDescriptor* segmentation); /*! \brief Clears the segmentation data, i.e. the pixels will be set to zero. @param segmentation the segmentation */ extern void ipMITKSegmentationClear (mitkIpPicDescriptor* segmentation); /*! \brief Interpolates the shape of segmentations. @param pic1,pic2 the images of the segmentation @param ratio the ratio of the images, the ratios 0.0 and 1.0 will produce pic1 and pic2, accordingly. */ extern mitkIpPicDescriptor* ipMITKSegmentationInterpolate (mitkIpPicDescriptor* pic1, mitkIpPicDescriptor* pic2, const mitkIpFloat4_t ratio); /*! \brief The type of logical operation. */ enum LogicalOp { IPSEGMENTATION_OP /*! copy of input image */, IPSEGMENTATION_AND /*! logical and operator */, IPSEGMENTATION_OR /*! the or operator */, IPSEGMENTATION_XOR /*! the exclusive-or operator */ }; /*! \brief Combines the region with the segmentation image. @param points the array of points, each point is represented by a 2-D vector (x, y) @param segmentation the segmentation. @param num the number of points @param mask the image which restricts the operation to a particular region @param operation the operation which will be performed (see above) @param value the operand value of the operation \note The last point is automatically connected with the first one. */ extern void ipMITKSegmentationCombineRegion (mitkIpPicDescriptor* segmentation, const mitkIpInt4_t* const points, const int num, mitkIpPicDescriptor* mask, const int operation, int value); /*! \brief Enables the undo operation for the specified segmentation. @param segmentation the segmentation @param level the number of undo levels */ extern void ipMITKSegmentationUndoEnable (mitkIpPicDescriptor* segmentation, const mitkIpUInt1_t level); /*! \brief Disables the undo operation for the specified segmentation. The available data will be discarded. @param segmentation the segmentation */ extern void ipMITKSegmentationUndoDisable (mitkIpPicDescriptor* segmentation); /*! \brief Checks if the undo operation is enabled. @param segmentation the segmentation */ extern mitkIpBool_t ipMITKSegmentationUndoIsEnabled (mitkIpPicDescriptor* segmentation); /*! \brief Checks if any data for undo is available. pending? */ extern mitkIpBool_t ipMITKSegmentationUndoAvailable (mitkIpPicDescriptor* segmentation); /*! \brief Save the segmentation image before it is changed. @param segmentation the segmentation */ extern void ipMITKSegmentationUndoSave (mitkIpPicDescriptor* segmentation); /*! \brief Steps to the previous undo level. The data which has been saved before the last modifications will be restored. */ extern void ipMITKSegmentationUndo (mitkIpPicDescriptor* segmentation); #if defined(__cplusplus) || defined(c_plusplus) } #endif /*! Starts a 4 neighbourhood region growing at startOfs (y*picWidth+x) of the 2D image src. If relativeBounds is true, the region grows in [base-lowerBound, base+upperBound], in which base is the average color of the 9 pixels around startOfs. If relativeBounds is false, the region grows in [lowerBound, upperBound]. If maxIterations is > 0, the growing process is stopped after maxIterations. If segBuffer is 0, new memory for the segmented image is allocated and returned, else the segBuffer is used to store the result (has to be an 8-bit datatype, e.g. mitkIpUInt1_t). histBuffer must be 0 or a pointer to a 16-bit mitkIpPicUInt image of the same size as src. In case of the latter, history data is written to that buffer: the seed pixel gets a 1, all direct neighbours 2 etc. The buffer is not cleared in this function and can thus hold history data of several growing processes in different areas. */ extern mitkIpPicDescriptor* ipMITKSegmentationGrowRegion4N( mitkIpPicDescriptor *src, int startOfs, bool relativeBounds, float lowerBound, float upperBound, int maxIterations, mitkIpPicDescriptor *segBuffer, mitkIpPicDescriptor *histBuffer=0 ); /*! Same as the other ipMITKSegmentationGrowRegion4N with two additional return values: contourOfs holds the lowest point of the resulting region and is thus guaranteed to be part of the contour Take care: if the region could not grow at all (e.g. with fixed borders) contourOfs will be -1 !!! startCol holds the color that was used as base if relativeBounds is true */ extern mitkIpPicDescriptor* ipMITKSegmentationGrowRegion4N( mitkIpPicDescriptor *src, int startOfs, bool relativeBounds, float lowerBound, float upperBound, int maxIterations, mitkIpPicDescriptor *segBuffer, int &contourOfs, float &startCol, mitkIpPicDescriptor *histBuffer=0 ); /*! Replaces the 4 neighbourhood region around startOfs (y*picWidth+x) of the 2D segmented image seg with newValue. Seg has to be an 8-bit datatype, e.g. mitkIpUInt1_t. Returns the number of replaced pixels. If newValue is the same as the old value, the function returns 0. */ extern int ipMITKSegmentationReplaceRegion4N( mitkIpPicDescriptor *seg, int startOfs, mitkIpInt1_t newValue ); /*! Same as above, but for the 8 neighbourhood contour. */ extern float* ipMITKSegmentationGetContour8N( const mitkIpPicDescriptor *seg, int startOfs, int &numPoints, int &sizeBuffer, float *pointBuffer=0 ); typedef struct { float *traceline; // x/y points describing the calculated path - memory has to be freed! bool *onGradient; // flags for each point if path was calculated based on gradient (true) or on max distance (false) - memory has to be freed! int numPoints; // number of points in the path int absMin; // indexes the point at the narrowest part of the path bool cutIt; // true if a leak has been found float cutCoords[4]; // x1,y1,x2,y2 of the two contour points where the leak can be cut float *deleteCurve; // x/y points of the closed contour describing the leak region int deleteSize; // number of points in this contour } tCutResult; /*! Calculates a path from ofs to the origin of the growing process, when possible on the skeleton of the segmented area. The narrowest part of this path is used to create two cut points that are part of the contour and can later be used to split the segmentation. This funtion is useful for detecting and removing leaks in region growing. */ extern tCutResult ipMITKSegmentationGetCutPoints( mitkIpPicDescriptor *seg, mitkIpPicDescriptor *history, int ofs ); /*! Creates a grower history (i.e. the order in which a region grower would have segmented the area) of the given segmentation, origin of the grower is startOfs. histBuffer must be a 16bit unsigned int or 0, in the latter case the pic is created. */ extern mitkIpPicDescriptor* ipMITKSegmentationCreateGrowerHistory( mitkIpPicDescriptor *seg, int startOfs, mitkIpPicDescriptor *histBuffer ); /*! Splits a contour in two parts. contour is the original contour, cutCoords a pointer to an x1-y1-x2-y2 array that specifies the two points where the contour should be cut (these cutpoints must be points of the original contour!). part1 and part2 have to be float arrays of a sufficient size to store the two parts. The sizes of the two parts are returned in size1 and size2. */ extern void ipMITKSegmentationSplitContour( float *contour, int sizeContour, float *cutCoords, float *part1, int &size1, float *part2, int &size2 ); /*! Returns true if the specified point lies insede the contour, else returns false. */ extern bool ipMITKSegmentationIsInsideContour( float *contour, int sizeContour, float x, float y ); #endif diff --git a/Utilities/ipSegmentation/ipSegmentationContourExtraction.cpp b/Utilities/ipSegmentation/ipSegmentationContourExtraction.cpp index 165fe31f07..18d7c0a821 100755 --- a/Utilities/ipSegmentation/ipSegmentationContourExtraction.cpp +++ b/Utilities/ipSegmentation/ipSegmentationContourExtraction.cpp @@ -1,199 +1,198 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include #include "ipSegmentation.h" // only make macros available in local scope: namespace { // returns true if segmentation pixel at ofs is set, includes check for border pixels, i.e. border pixels do not result in returning true #define SEGSET(ofs) ( \ ((ofs)>=0 && (ofs)data) + (ofs)) != 0 ) && \ ( (ofs)%line != 0 || (pos+1)%line != 0 ) && \ ( (ofs+1)%line != 0 || (pos)%line != 0 ) \ ) // appends a point to result, sets finished to true if this point is the same as the first one // allocates new momory if necessary #define ADD_CONTOUR_POINT \ result[numPts*2] = xPos+xCorner[dir]; \ result[numPts*2+1] = yPos+yCorner[dir]; \ if (result[numPts*2]==result[0] && result[numPts*2+1]==result[1] && numPts>0) finished = true; \ numPts++; \ if (numPts==resSize) { \ resSize+=16+resSize/2; \ result = (float*)realloc( result, resSize*2*sizeof(float) ); \ if (!result) finished = true; \ } } template float* tmGetContour4N( const mitkIpPicDescriptor *seg, int startOfs, int &numPts, int &resSize, float *result ) // returns the number of contour points (xy-pairs) in result // optimized macros: DON'T TOUCH THE CODE (removed smiley, this is not funny but cruel for any maintainer!) { numPts = 0; int line = seg->n[0]; int maxOfs = seg->n[0] * seg->n[1]; int straight[4] = { 1, -line, -1, line }; int right[4] = { line, 1, -line, -1 }; float xMod[4] = { 1.0, 0.0, -1.0, 0.0 }; float yMod[4] = { 0.0, -1.0, 0.0, 1.0 }; float xCorner[4] = { 1.0, 1.0, 0.0, 0.0 }; float yCorner[4] = { 1.0, 0.0, 0.0, 1.0 }; int dir = 0; int pos = startOfs; float xPos = (float)(pos % line); float yPos = (float)(pos / line); while ( dir<4 && SEGSET( pos+right[dir] ) ) dir++; if (dir==4) return result; // no contour pixel bool finished = false; if (result==0) { resSize = 2048; result = (float*)malloc( resSize*2*sizeof(float) ); } do { if ( SEGSET( pos+right[dir] ) ) { // modify direction (turn right): dir = (dir-1) & 3; // modify position: pos += straight[dir]; xPos += xMod[dir]; yPos += yMod[dir]; } else if ( SEGSET( pos+straight[dir] ) ) { ADD_CONTOUR_POINT // modify position: pos += straight[dir]; xPos += xMod[dir]; yPos += yMod[dir]; } else { ADD_CONTOUR_POINT // modify direction (turn left): dir = (dir+1) & 3; } } while (!finished); return result; } float* ipMITKSegmentationGetContour4N( const mitkIpPicDescriptor *seg, int startOfs, int &numPoints, int &sizeBuffer, float *pointBuffer ) { float *newBuffer = NULL; mitkIpPicTypeMultiplexR4( tmGetContour4N, seg, newBuffer, startOfs, numPoints, sizeBuffer, pointBuffer ); return newBuffer; } template float* tmGetContour8N( const mitkIpPicDescriptor *seg, int startOfs, int &numPts, int &resSize, float *result ) // returns the number of contour points (xy-pairs) in result // optimized macros: DON'T TOUCH THE CODE ;-) { numPts = 0; int line = seg->n[0]; // width of segmentation in pixels int maxOfs = seg->n[0] * seg->n[1]; // memory offset of pixel just beyond bottom-right-most pixel of segmentation (not a valid offset) int straight[4] = { 1, -line, -1, line }; // right, top, left, down (memory offsets) int right[4] = { line, 1, -line, -1 }; // down, right, top, left float xMod[4] = { 1.0, 0.0, -1.0, 0.0 }; float yMod[4] = { 0.0, -1.0, 0.0, 1.0 }; float xCorner[4] = { 1.0, 1.0, 0.0, 0.0 }; float yCorner[4] = { 1.0, 0.0, 0.0, 1.0 }; int dir = 0; int pos = startOfs; // initial position, this is where the contour search starts float xPos = (float)(pos % line); // calculate x and y from the memory offset float yPos = (float)(pos / line); while ( dir<4 && SEGSET( pos+right[dir] ) ) dir++; if (dir==4) { // check diagonal pixels: dir = 0; while ( dir<4 && SEGSET( pos+right[dir]+straight[dir] ) ) dir++; if (dir==4) return result; // no contour pixel // chose next suitable neighbour: pos += straight[dir]; xPos += xMod[dir]; yPos += yMod[dir]; } bool finished = false; if (result==0) { resSize = 2048; result = (float*)malloc( resSize*2*sizeof(float) ); } // here xPos,yPos are on some pixel next to a segmentation pixel. Where is "next to"? This is defined by the value of dir and the offsets in right[dir]. // tries to complete the contour until a point is added that is identical to the first point do { if ( SEGSET( pos+right[dir] ) ) { // valgrind complaint: jump dependent on uninitialized value (from my current understanding this could only be some pixel value outside the image // modify direction (turn right): // this if will evaluate to true during the first iteration dir = (dir-1) & 3; // ok, some weird logic selects a new direction // modify position: pos += straight[dir]; // definitions of right and straight (plus xMod and yMod) lead to a counter-clockwise movement around the contour xPos += xMod[dir]; yPos += yMod[dir]; } else if ( SEGSET( pos+straight[dir] ) ) { ADD_CONTOUR_POINT // modify position: pos += straight[dir]; xPos += xMod[dir]; yPos += yMod[dir]; } else if ( SEGSET( pos+right[dir]+straight[dir] ) ) { // valgrind complaint: jump dependent on uninitialized value ADD_CONTOUR_POINT // modify position: pos += straight[dir]; xPos += xMod[dir]; yPos += yMod[dir]; // modify direction (turn right): dir = (dir-1) & 3; // modify position second time: pos += straight[dir]; xPos += xMod[dir]; yPos += yMod[dir]; } else { ADD_CONTOUR_POINT // modify direction (turn left): dir = (dir+1) & 3; } } while (!finished); return result; } float* ipMITKSegmentationGetContour8N( const mitkIpPicDescriptor *seg, int startOfs, int &numPoints, int &sizeBuffer, float *pointBuffer ) { float *newBuffer = NULL; mitkIpPicTypeMultiplexR4( tmGetContour8N, seg, newBuffer, startOfs, numPoints, sizeBuffer, pointBuffer ); return newBuffer; } diff --git a/Utilities/ipSegmentation/ipSegmentationContourUtils.cpp b/Utilities/ipSegmentation/ipSegmentationContourUtils.cpp index ea976e74de..497f565628 100755 --- a/Utilities/ipSegmentation/ipSegmentationContourUtils.cpp +++ b/Utilities/ipSegmentation/ipSegmentationContourUtils.cpp @@ -1,114 +1,113 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include "ipSegmentation.h" /** * Input: one contour (start and end point identical). array of floats. [x1 y1 x2 y2 ...] * Output: two contours (start and end point not neccessarily identical) * cutCoords: two points that define the cut (must not [should not be] be identical) * * S.....O * . . * . . * . . * . ------C2 S: Start of contour (two times in the array) * . ------- . C1: cut point 1 * C1------ . C2: cut point 2 * . O * . .. * . .. * . .. * . .. * O */ void ipMITKSegmentationSplitContour( float *contour, int sizeContour, float *cutCoords, float *part1, int &size1, float *part2, int &size2 ) { int cut1, cut2, i=0; bool cutReached; size1 = 0; size2 = 0; do { part1[2*size1] = contour[2*i]; part1[2*size1+1] = contour[2*i+1]; i++; size1++; cutReached = ( (cutCoords[0]==contour[2*i] && cutCoords[1]==contour[2*i+1]) || (cutCoords[2]==contour[2*i] && cutCoords[3]==contour[2*i+1]) ); } while (!cutReached); cut1 = i; part1[2*size1] = contour[2*i]; part1[2*size1+1] = contour[2*i+1]; size1++; do { part2[2*size2] = contour[2*i]; part2[2*size2+1] = contour[2*i+1]; i++; size2++; cutReached = ( (cutCoords[0]==contour[2*i] && cutCoords[1]==contour[2*i+1]) || (cutCoords[2]==contour[2*i] && cutCoords[3]==contour[2*i+1]) ); } while (!cutReached); cut2 = i; part2[2*size2] = contour[2*i]; part2[2*size2+1] = contour[2*i+1]; size2++; do { part1[2*size1] = contour[2*i]; part1[2*size1+1] = contour[2*i+1]; i++; size1++; } while (i #include "ipSegmentation.h" mitkIpPicDescriptor* ipMITKSegmentationCreateGrowerHistory( mitkIpPicDescriptor *seg, int startOfs, mitkIpPicDescriptor *histBuffer ) { std::queue ofsQueue; if (!seg) return 0; if (!histBuffer) { histBuffer = mitkIpPicCopyHeader( seg, histBuffer ); histBuffer->type = mitkIpPicUInt; histBuffer->bpe = 16; mitkIpUInt4_t size = _mitkIpPicSize( histBuffer ); histBuffer->data = malloc( size ); memset( histBuffer->data, 0, size ); // clear buffer } else { // check if dimension of histBuffer is valid, if not: change it! if (histBuffer->n[0] != seg->n[0] || histBuffer->n[1] != seg->n[1]) { histBuffer->n[0] = seg->n[0]; histBuffer->n[1] = seg->n[1]; mitkIpUInt4_t size = _mitkIpPicSize( histBuffer ); histBuffer->data = realloc( histBuffer->data, size ); if (histBuffer->data == 0) return 0; memset( histBuffer->data, 0, size ); // clear buffer } } // create a clear buffer to check wether a point has already been visited // (seg cannot be modifier and histBuffer can contain any value) mitkIpPicDescriptor *flagBuffer = mitkIpPicCopyHeader( seg, 0 ); mitkIpUInt4_t size = _mitkIpPicSize( flagBuffer ); flagBuffer->data = malloc( size ); memset( flagBuffer->data, 0, size ); *((mitkIpUInt1_t*)flagBuffer->data+startOfs) = 1; // flag pixel as visited int line = seg->n[0]; int maxOfs = (int)(line * seg->n[1]); int testOfs; mitkIpUInt1_t segVal, flagVal; int iteration = 0; int currentWave = 1; int nextWave = 0; ofsQueue.push( startOfs ); while (!ofsQueue.empty()) { int nextOfs = ofsQueue.front(); ofsQueue.pop(); currentWave--; *((mitkIpUInt2_t*)histBuffer->data+nextOfs) = (mitkIpUInt2_t)(iteration+1); // seed point should get history = 1 // check right: testOfs = nextOfs+1; if (testOfs%line!=0) { segVal = *((mitkIpUInt1_t*)seg->data+testOfs); flagVal = *((mitkIpUInt1_t*)flagBuffer->data+testOfs); if ( segVal != 0 && flagVal == 0) { ofsQueue.push( testOfs ); *((mitkIpUInt1_t*)flagBuffer->data+testOfs) = 1; // flag pixel as visited nextWave++; } } // check top: testOfs = nextOfs-line; if (testOfs > 0) { segVal = *((mitkIpUInt1_t*)seg->data+testOfs); flagVal = *((mitkIpUInt1_t*)flagBuffer->data+testOfs); if ( segVal != 0 && flagVal == 0) { ofsQueue.push( testOfs ); *((mitkIpUInt1_t*)flagBuffer->data+testOfs) = 1; // flag pixel as visited nextWave++; } } // check left: testOfs = nextOfs-1; if (nextOfs%line!=0) { segVal = *((mitkIpUInt1_t*)seg->data+testOfs); flagVal = *((mitkIpUInt1_t*)flagBuffer->data+testOfs); if ( segVal != 0 && flagVal == 0) { ofsQueue.push( testOfs ); *((mitkIpUInt1_t*)flagBuffer->data+testOfs) = 1; // flag pixel as visited nextWave++; } } // check bottom: testOfs = nextOfs+line; if (testOfs < maxOfs) { segVal = *((mitkIpUInt1_t*)seg->data+testOfs); flagVal = *((mitkIpUInt1_t*)flagBuffer->data+testOfs); if ( segVal != 0 && flagVal == 0) { ofsQueue.push( testOfs ); *((mitkIpUInt1_t*)flagBuffer->data+testOfs) = 1; // flag pixel as visited nextWave++; } } // check for number of iterations: if (currentWave == 0) { currentWave = nextWave; nextWave = 0; iteration++; } } mitkIpPicFree( flagBuffer ); return histBuffer; } diff --git a/Utilities/ipSegmentation/ipSegmentationP.h b/Utilities/ipSegmentation/ipSegmentationP.h index 8d8d218f6b..364776ad9e 100644 --- a/Utilities/ipSegmentation/ipSegmentationP.h +++ b/Utilities/ipSegmentation/ipSegmentationP.h @@ -1,91 +1,90 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef IPSEGMENTATIONP_H #define IPSEGMENTATIONP_H #include #include "ipSegmentationError.h" #ifndef IPSEGMENTATION_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define ipMITKSegmentationTYPE mitkIpUInt1_t #define ipMITKSegmentationTYPE_ID mitkIpPicUInt #define ipMITKSegmentationBPE 8 #define tagSEGMENTATION_EMPTY "SEGMENTATION_EMPTY" enum LogicalOp { IPSEGMENTATION_OP /*! copy of input image */, IPSEGMENTATION_AND /*! logical and operator */, IPSEGMENTATION_OR /*! the or operator */, IPSEGMENTATION_XOR /*! the exclusive-or operator */ }; extern void ipMITKSegmentationUndoSave (mitkIpPicDescriptor* segmentation); extern mitkIpBool_t ipMITKSegmentationUndoIsEnabled (mitkIpPicDescriptor* segmentation); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* IPSEGMTATION_H */ #define AND(TYPE, PIC, VALUE, X, Y) \ { \ TYPE* data = (TYPE*) (PIC)->data; \ mitkIpUInt4_t width = (PIC)->n[0]; \ int temp = (int) data [width * (mitkIpUInt4_t) Y + (mitkIpUInt4_t) X]; \ temp &= (int) VALUE; \ data [width * (mitkIpUInt4_t) Y + (mitkIpUInt4_t) X] = temp; \ } \ #define OR(TYPE, PIC, VALUE, X, Y) \ { \ TYPE* data = (TYPE*) (PIC)->data; \ mitkIpUInt4_t width = (PIC)->n[0]; \ int temp = (int) data [width * (mitkIpUInt4_t) Y + (mitkIpUInt4_t) X]; \ temp |= (int) VALUE; \ data [width * (mitkIpUInt4_t) Y + (mitkIpUInt4_t) X] = temp; \ } \ #define XOR(TYPE, PIC, VALUE, X, Y) \ { \ TYPE* data = (TYPE*) (PIC)->data; \ mitkIpUInt4_t width = (PIC)->n[0]; \ int temp = (int) data [width * (mitkIpUInt4_t) Y + (mitkIpUInt4_t) X]; \ temp ^= (int) VALUE; \ data [width * (mitkIpUInt4_t) Y + (mitkIpUInt4_t) X] = temp; \ } \ #define OP(TYPE, PIC, VALUE, X, Y) \ { \ TYPE* data = (TYPE*) (PIC)->data; \ mitkIpUInt4_t width = (PIC)->n[0]; \ data [width * (mitkIpUInt4_t) Y + (mitkIpUInt4_t) X] = VALUE; \ } \ #define MASK(TYPE, PIC, MSK, VALUE, X, Y, CMD) \ { \ if (!(MSK) || (((ipMITKSegmentationTYPE *)(MSK)->data)[(PIC)->n[0] * (mitkIpUInt4_t) (Y) + (mitkIpUInt4_t) (X)] > 0.0)) \ CMD(TYPE, PIC, VALUE, X, Y) \ } #endif diff --git a/Utilities/ipSegmentation/ipSegmentationRegionCutter.cpp b/Utilities/ipSegmentation/ipSegmentationRegionCutter.cpp index 8671096fb2..b74c5dc041 100755 --- a/Utilities/ipSegmentation/ipSegmentationRegionCutter.cpp +++ b/Utilities/ipSegmentation/ipSegmentationRegionCutter.cpp @@ -1,332 +1,331 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include #include #include "ipSegmentation.h" static ANNkd_tree *annTree; static ANNpoint queryPt; static ANNidxArray nnIdx; static ANNdistArray dists; // find next pixel in ANN: #define QUERY_DIST(qOfs) \ queryPt[0] = (float)(qOfs % line) + 0.5; \ queryPt[1] = (float)(qOfs / line) + 0.5; \ annTree->annkSearch( queryPt, 1, nnIdx, dists ); #define PROCESS_PIXEL \ histVal = *((mitkIpUInt2_t*)history->data+testOfs); \ segVal = *((mitkIpUInt1_t*)seg->data+testOfs); \ if ( segVal > 0 && histVal <= maxHist && testOfs!=oldOfs ) { \ grad = ipMITKSegmentationGetDistGradient( testOfs, seg ); \ QUERY_DIST(testOfs) \ if (grad maxDist) { \ maxDist = dists[0]; \ candOfs = testOfs; \ } \ } float ipMITKSegmentationGetDistGradient( int ofs, mitkIpPicDescriptor *seg ) { mitkIpUInt4_t unsignedOfs = ofs < 0 ? seg->n[0]*seg->n[1] - seg->n[0] : ofs; if (unsignedOfs < seg->n[0] || unsignedOfs >= seg->n[0]*seg->n[1] - seg->n[0]) // exclude image borders { return 1.0; // initialization value of minGrad (high gradient) } float x = (float)(ofs % seg->n[0]) + 0.5; float y = (float)(ofs / seg->n[0]) + 0.5; mitkIpUInt1_t segVal = 0; // initialize to stop valgrind's warning about "Conditional jump or move depends on uninitialised value(s)" queryPt[0] = x+1; queryPt[1] = y; annTree->annkSearch( queryPt, 1, nnIdx, dists ); float d1 = sqrt( dists[0] ); // right dist segVal = *((mitkIpUInt1_t*)seg->data+ofs+1); if (!segVal) d1 = -10.0; queryPt[0] = x-1; queryPt[1] = y; annTree->annkSearch( queryPt, 1, nnIdx, dists ); float d2 = sqrt( dists[0] ); // left dist segVal = *((mitkIpUInt1_t*)seg->data+ofs-1); if (!segVal) d2 = -10.0; queryPt[0] = x; queryPt[1] = y+1; annTree->annkSearch( queryPt, 1, nnIdx, dists ); float d3 = sqrt( dists[0] ); // lower dist segVal = *((mitkIpUInt1_t*)seg->data+ofs+seg->n[0]); if (!segVal) d3 = -10.0; queryPt[0] = x; queryPt[1] = y-1; annTree->annkSearch( queryPt, 1, nnIdx, dists ); float d4 = sqrt( dists[0] ); // upper dist segVal = *((mitkIpUInt1_t*)seg->data+ofs-seg->n[0]); if (!segVal) d4 = -10.0; float res = 0.5*(float)sqrt( (d1-d2)*(d1-d2) + (d3-d4)*(d3-d4) ); return res; } tCutResult ipMITKSegmentationGetCutPoints( mitkIpPicDescriptor *seg, mitkIpPicDescriptor *history, int ofs ) { bool debug(false); tCutResult res; int resContourSize = 5000; res.traceline = (float*)malloc( resContourSize*sizeof(float)*2 ); res.onGradient = (bool*)malloc( resContourSize*sizeof(bool) ); res.numPoints = 0; res.absMin = 0; res.cutIt = false; res.deleteCurve = 0; if (!history) return res; // no history! if (*((mitkIpUInt2_t*)history->data + ofs) == 0) return res; // ofs not inside known history // get one point on the contour: mitkIpUInt1_t *ptr = (mitkIpUInt1_t*)seg->data + ofs; int endLine = ((ofs / seg->n[0]) + 1) * seg->n[0] -1; int contourOfs = ofs; while (contourOfs!=endLine && *ptr!=0) { ptr++; contourOfs++; } if (*ptr == 0) contourOfs--; // get back on the contour! // extract the contour: int sizeContour, sizeBuffer; float *contour = ipMITKSegmentationGetContour8N( seg, contourOfs, sizeContour, sizeBuffer ); // init ANN tree with contour points: queryPt = annAllocPt( 2 ); ANNpointArray dataPts = annAllocPts( sizeContour, 2 ); nnIdx = new ANNidx[10]; dists = new ANNdist[10]; for (int i=0; in[0]; int maxOfs = line * history->n[1]; QUERY_DIST(ofs) float maxDist = dists[0]; float minDist = 10000; // current minimum distance from border float oldDist = 0; int candOfs = ofs; int nextOfs = -1; int oldOfs, testOfs, gradCand=-1; float grad, minGrad; bool skelettonReached = false; mitkIpUInt2_t histVal; mitkIpUInt1_t segVal; mitkIpUInt2_t maxHist = 10000; if (maxHist==0 && debug) printf( "maxHist = 0!\n" ); do { oldOfs = nextOfs; nextOfs = candOfs; // store point info: if (res.numPoints < resContourSize) { res.traceline[2*res.numPoints] = (float)(nextOfs % line) + 0.5; res.traceline[2*res.numPoints+1] = (float)(nextOfs / line) + 0.5; if (nextOfs==gradCand) res.onGradient[res.numPoints] = true; else res.onGradient[res.numPoints] = false; if (debug) { printf( "(%.f,%.f): H=%i, G=%i\n", res.traceline[2*res.numPoints], res.traceline[2*res.numPoints+1], *((mitkIpUInt2_t*)history->data+nextOfs), res.onGradient[res.numPoints] ); } res.numPoints++; if (res.numPoints == resContourSize) { resContourSize *= 2; // explodes, but such contours must be very strange res.traceline = (float*)realloc( res.traceline, resContourSize*sizeof(float)*2 ); res.onGradient = (bool*)realloc( res.onGradient, resContourSize*sizeof(bool) ); if ((res.traceline == NULL) || (res.onGradient == NULL)) { res.numPoints = 0; res.cutIt = false; return res; } } } maxHist = *((mitkIpUInt2_t*)history->data + nextOfs); // don't exceed this history! maxDist = 0; // clear maxDist minGrad = 1.0; // clear minGrad int traceSinceMin = res.numPoints - 1 - res.absMin; float weight = 20.0 / (20.0+traceSinceMin); if (weight < 0.5) weight = 0.5; QUERY_DIST(nextOfs) if (!skelettonReached && dists[0] < oldDist) { skelettonReached = true; if (debug) printf( "skeletton reached at %i, oldDist=%.1f, currentDist=%.1f\n", res.numPoints - 1, oldDist, dists[0] ); } oldDist = dists[0]; if (skelettonReached && weight*dists[0] < minDist) { minDist = dists[0]; res.absMin = res.numPoints - 1; // has already been increased } // check right: testOfs = nextOfs+1; if (testOfs%line!=0) { // check top right: PROCESS_PIXEL testOfs = nextOfs-line; if (testOfs > 0) { testOfs++; PROCESS_PIXEL } // check bottom right: testOfs = nextOfs+line; if (testOfs < maxOfs) { testOfs++; PROCESS_PIXEL } } // check top: testOfs = nextOfs-line; if (testOfs > 0) { PROCESS_PIXEL } // check left: testOfs = nextOfs-1; if (nextOfs%line!=0) { PROCESS_PIXEL // check top left: testOfs = nextOfs-line; if (testOfs > 0) { testOfs--; PROCESS_PIXEL } // check bottom left: testOfs = nextOfs+line; if (testOfs < maxOfs) { testOfs--; PROCESS_PIXEL } } // check bottom: testOfs = nextOfs+line; if (testOfs < maxOfs) { PROCESS_PIXEL } // check for run on gradient: if (minGrad < 0.5) { candOfs = gradCand; if (debug) printf( "." ); } else if (debug) printf( "x" ); } while (candOfs != nextOfs && maxHist > 0); if (res.absMin < (res.numPoints-10)) { res.absMin += (int)(sqrt(minDist)/2.0); // int cutX = (int)(res.traceline[2*res.absMin]-0.5); // int cutY = (int)(res.traceline[2*res.absMin+1]-0.5); // int cutOfs = cutX + line*cutY; // histVal = *((mitkIpUInt2_t*)history->data+cutOfs); // printf( "histVal at Cut=%i\n", histVal ); // if (histVal > 1) { res.cutIt = true; float cutXf = (float)res.traceline[2*res.absMin]; float cutYf = (float)res.traceline[2*res.absMin+1]; queryPt[0] = cutXf; queryPt[1] = cutYf; annTree->annkSearch( queryPt, 1, nnIdx, dists ); int cutIdx1 = nnIdx[0]; res.cutCoords[0] = contour[2*cutIdx1]; res.cutCoords[1] = contour[2*cutIdx1+1]; int cutIdx2 = cutIdx1; float minDist = 100000000; int testCnt = 0; for (int i=0; i (sizeContour/2)) idxDif = sizeContour - idxDif; if ( idxDif > 50 ) { float dist = (cutXf-contour[2*i])*(cutXf-contour[2*i]) + (cutYf-contour[2*i+1])*(cutYf-contour[2*i+1]); if (dist < minDist) { minDist = dist; cutIdx2 = i; } } else testCnt++; } res.cutCoords[2] = contour[2*cutIdx2]; res.cutCoords[3] = contour[2*cutIdx2+1]; if (debug) printf( "idx1=%i, idx2=%i, %i pts not evaluated.\n", cutIdx1, cutIdx2, testCnt ); if ((res.cutCoords[0] == res.cutCoords[2]) && (res.cutCoords[1] == res.cutCoords[3])) { free( contour ); // free ANN stuff: annDeallocPt( queryPt ); annDeallocPts( dataPts ); delete[] nnIdx; delete[] dists; delete annTree; res.cutIt = false; return res; } float *curve1 = (float*)malloc( 2*sizeof(float)*sizeContour ); float *curve2 = (float*)malloc( 2*sizeof(float)*sizeContour ); int sizeCurve1, sizeCurve2; ipMITKSegmentationSplitContour( contour, sizeContour, res.cutCoords, curve1, sizeCurve1, curve2, sizeCurve2 ); float clickX = (float)(ofs % line) + 0.5; float clickY = (float)(ofs / line) + 0.5; if (ipMITKSegmentationIsInsideContour( curve1, sizeCurve1, clickX, clickY )) { res.deleteCurve = curve1; res.deleteSize = sizeCurve1; free( curve2 ); } else { res.deleteCurve = curve2; res.deleteSize = sizeCurve2; free( curve1 ); } } free( contour ); // free ANN stuff: annDeallocPt( queryPt ); annDeallocPts( dataPts ); delete[] nnIdx; delete[] dists; delete annTree; return res; } diff --git a/Utilities/ipSegmentation/ipSegmentationRegionGrower.cpp b/Utilities/ipSegmentation/ipSegmentationRegionGrower.cpp index 34c75b7cf9..b3e838f5be 100755 --- a/Utilities/ipSegmentation/ipSegmentationRegionGrower.cpp +++ b/Utilities/ipSegmentation/ipSegmentationRegionGrower.cpp @@ -1,223 +1,222 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include #include #include #include "ipSegmentation.h" /* Starts a 4 neighbourhood region growing at startOfs (y*picWidth+x) of the 2D image src. If relativeBounds is true, the region grows in [base-lowerBound, base+upperBound], in which base is the average color of the 9 pixels around startOfs. If relativeBounds is false, the region grows in [lowerBound, upperBound]. If maxIterations is > 0, the growing process is stopped after maxIterations. If segBuffer is 0, new memory for the segmented image is allocated and returned, else the segBuffer is used to store the result (has to be an 8-bit datatype, e.g. mitkIpUInt1_t). histBuffer must be 0 or a pointer to a 16-bit mitkIpUInt1_t image of the same size as src. In case of the latter, history data is written to that buffer: the seed pixel gets a 1, all direct neighbours 2 etc. The buffer is not cleared in this function and can thus hold history data of several growing processes in different areas. */ template mitkIpPicDescriptor* tmGrowRegion4N( mitkIpPicDescriptor *src, int startOfs, bool relativeBounds, float lowerBoundFlt, float upperBoundFlt, int maxIterations, mitkIpPicDescriptor *segBuffer, int &contourOfs, float &startCol, mitkIpPicDescriptor *histBuffer ) { PicType lowerBound = static_cast(lowerBoundFlt); PicType upperBound = static_cast(upperBoundFlt); std::queue ofsQueue; if (maxIterations <= 0) maxIterations = 32000; if (!src) return 0; if (!segBuffer) { segBuffer = mitkIpPicCopyHeader( src, segBuffer ); segBuffer->type = mitkIpPicUInt; segBuffer->bpe = 8; mitkIpUInt4_t size = _mitkIpPicSize( segBuffer ); segBuffer->data = malloc( size ); } else { // check if dimension of segBuffer is valid, if not: change it! if (segBuffer->n[0] != src->n[0] || segBuffer->n[1] != src->n[1]) { segBuffer->n[0] = src->n[0]; segBuffer->n[1] = src->n[1]; mitkIpUInt4_t size = _mitkIpPicSize( segBuffer ); segBuffer->data = realloc( segBuffer->data, size ); if (segBuffer->data == 0) return 0; } } if (histBuffer) { // check if dimension of histBuffer is valid, if not: change it! if (histBuffer->n[0] != src->n[0] || histBuffer->n[1] != src->n[1]) { histBuffer->n[0] = src->n[0]; histBuffer->n[1] = src->n[1]; mitkIpUInt4_t size = _mitkIpPicSize( histBuffer ); histBuffer->data = realloc( histBuffer->data, size ); if (histBuffer->data == 0) return 0; memset( histBuffer->data, 0, size ); // clear buffer } } int line = segBuffer->n[0]; int maxOfs = (int)(line * segBuffer->n[1]); //PicType *start = ((PicType*)src->data) + startOfs; // init borders: PicType lowest, highest; if (relativeBounds) { // average base color from 3x3 block: // check for edges of image int offset; int numberOfValidOffsets = 0; int baseCol = 0; offset = startOfs; if ( (offset >= 0) && (offset < (int)(src->n[0] * src->n[1])) ) { baseCol += *((PicType*)(src->data)+offset); ++numberOfValidOffsets; } offset = startOfs+1; if ( (offset >= 0) && (offset < (int)(src->n[0] * src->n[1])) ) { baseCol += *((PicType*)(src->data)+offset); ++numberOfValidOffsets; } offset = startOfs+1-line; if ( (offset >= 0) && (offset < (int)(src->n[0] * src->n[1])) ) { baseCol += *((PicType*)(src->data)+offset); ++numberOfValidOffsets; } offset = startOfs-line; if ( (offset >= 0) && (offset < (int)(src->n[0] * src->n[1])) ) { baseCol += *((PicType*)(src->data)+offset); ++numberOfValidOffsets; } offset = startOfs-1-line; if ( (offset >= 0) && (offset < (int)(src->n[0] * src->n[1])) ) { baseCol += *((PicType*)(src->data)+offset); ++numberOfValidOffsets; } offset = startOfs-1; if ( (offset >= 0) && (offset < (int)(src->n[0] * src->n[1])) ) { baseCol += *((PicType*)(src->data)+offset); ++numberOfValidOffsets; } offset = startOfs-1+line; if ( (offset >= 0) && (offset < (int)(src->n[0] * src->n[1])) ) { baseCol += *((PicType*)(src->data)+offset); ++numberOfValidOffsets; } offset = startOfs+line; if ( (offset >= 0) && (offset < (int)(src->n[0] * src->n[1])) ) { baseCol += *((PicType*)(src->data)+offset); ++numberOfValidOffsets; } offset = startOfs+1+line; if ( (offset >= 0) && (offset < (int)(src->n[0] * src->n[1])) ) { baseCol += *((PicType*)(src->data)+offset); ++numberOfValidOffsets; } if ( numberOfValidOffsets > 0 ) baseCol = (PicType)( (float)baseCol / (float)numberOfValidOffsets ); lowest = baseCol - lowerBound; highest = baseCol + upperBound; startCol = (float)baseCol; } else { lowest = lowerBound; highest = upperBound; startCol = 0.0f; } memset( segBuffer->data, 0, _mitkIpPicSize(segBuffer) ); // clear buffer PicType value = *((PicType*)src->data+startOfs); if ( value >=lowest && value <=highest ) { ofsQueue.push( startOfs ); } contourOfs = -1; int testOfs; mitkIpUInt1_t segVal; int iteration = 0; int currentWave = 1; int nextWave = 0; while (!ofsQueue.empty() && iteration<=maxIterations) { int nextOfs = ofsQueue.front(); ofsQueue.pop(); currentWave--; *((mitkIpUInt1_t*)segBuffer->data+nextOfs) = 1; if (histBuffer) { *((mitkIpUInt2_t*)histBuffer->data+nextOfs) = (mitkIpUInt2_t)(iteration+1); // seed point should get history = 1 } if (nextOfs > contourOfs) contourOfs = nextOfs; // check right: testOfs = nextOfs+1; if (testOfs%line!=0) { segVal = *((mitkIpUInt1_t*)segBuffer->data+testOfs); if ( segVal == 0 ) { value = *((PicType*)src->data+testOfs); if ( value >=lowest && value <=highest ) { ofsQueue.push( testOfs ); nextWave++; *((mitkIpUInt1_t*)segBuffer->data+testOfs) = 2; } } } // check top: testOfs = nextOfs-line; if (testOfs > 0) { segVal = *((mitkIpUInt1_t*)segBuffer->data+testOfs); if ( segVal == 0 ) { value = *((PicType*)src->data+testOfs); if ( value >=lowest && value <=highest ) { ofsQueue.push( testOfs ); nextWave++; *((mitkIpUInt1_t*)segBuffer->data+testOfs) = 2; } } } // check left: testOfs = nextOfs-1; if (nextOfs%line!=0) { segVal = *((mitkIpUInt1_t*)segBuffer->data+testOfs); if ( segVal == 0 ) { value = *((PicType*)src->data+testOfs); if ( value >=lowest && value <=highest ) { ofsQueue.push( testOfs ); nextWave++; *((mitkIpUInt1_t*)segBuffer->data+testOfs) = 2; } } } // check bottom: testOfs = nextOfs+line; if (testOfs < maxOfs) { segVal = *((mitkIpUInt1_t*)segBuffer->data+testOfs); if ( segVal == 0 ) { value = *((PicType*)src->data+testOfs); if ( value >=lowest && value <=highest ) { ofsQueue.push( testOfs ); nextWave++; *((mitkIpUInt1_t*)segBuffer->data+testOfs) = 2; } } } // check for number of iterations: if (currentWave == 0) { currentWave = nextWave; nextWave = 0; iteration++; } } return segBuffer; } mitkIpPicDescriptor* ipMITKSegmentationGrowRegion4N( mitkIpPicDescriptor *src, int startOfs, bool relativeBounds, float lowerBound, float upperBound, int maxIterations, mitkIpPicDescriptor *segBuffer, mitkIpPicDescriptor *histBuffer ) { mitkIpPicDescriptor *result = 0; int contourOfs; float startCol; if (ipMITKSegmentationUndoIsEnabled (segBuffer)) { ipMITKSegmentationUndoSave (segBuffer); } mitkIpPicTypeMultiplexR9( tmGrowRegion4N, src, result, startOfs, relativeBounds, lowerBound, upperBound, maxIterations, segBuffer, contourOfs, startCol, histBuffer ); return result; } mitkIpPicDescriptor* ipMITKSegmentationGrowRegion4N( mitkIpPicDescriptor *src, int startOfs, bool relativeBounds, float lowerBound, float upperBound, int maxIterations, mitkIpPicDescriptor *segBuffer, int &contourOfs, float &startCol, mitkIpPicDescriptor *histBuffer ) { mitkIpPicDescriptor *result = 0; if (ipMITKSegmentationUndoIsEnabled (segBuffer)) { ipMITKSegmentationUndoSave (segBuffer); } mitkIpPicTypeMultiplexR9( tmGrowRegion4N, src, result, startOfs, relativeBounds, lowerBound, upperBound, maxIterations, segBuffer, contourOfs, startCol, histBuffer ); return result; } diff --git a/Utilities/ipSegmentation/ipSegmentationReplaceRegion.cpp b/Utilities/ipSegmentation/ipSegmentationReplaceRegion.cpp index fbb679def9..1832accd4a 100755 --- a/Utilities/ipSegmentation/ipSegmentationReplaceRegion.cpp +++ b/Utilities/ipSegmentation/ipSegmentationReplaceRegion.cpp @@ -1,91 +1,90 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include #include "ipSegmentation.h" int ipMITKSegmentationReplaceRegion4N( mitkIpPicDescriptor *seg, int startOfs, mitkIpInt1_t newValue ) { mitkIpPicTSV_t* tag; std::queue ofsQueue; if (ipMITKSegmentationUndoIsEnabled (seg)) { ipMITKSegmentationUndoSave (seg); } tag = mitkIpPicDelTag (seg, tagSEGMENTATION_EMPTY); if (tag) { mitkIpPicFreeTag (tag); } if (seg->bpe != 8) return 0; int line = seg->n[0]; int maxOfs = (int)(line * seg->n[1]); int testOfs; mitkIpInt1_t replaceMe = *((mitkIpInt1_t*)seg->data + startOfs); if (replaceMe == newValue) return 0; mitkIpInt1_t segVal; ofsQueue.push( startOfs ); *((mitkIpInt1_t*)seg->data+startOfs) = newValue; int regionSize = 0; while (!ofsQueue.empty()) { int nextOfs = ofsQueue.front(); ofsQueue.pop(); regionSize++; // check right: testOfs = nextOfs+1; if (testOfs%line!=0) { segVal = *((mitkIpInt1_t*)seg->data+testOfs); if ( segVal == replaceMe ) { ofsQueue.push( testOfs ); *((mitkIpInt1_t*)seg->data+testOfs) = newValue; } } // check top: testOfs = nextOfs-line; if (testOfs >= 0) { segVal = *((mitkIpInt1_t*)seg->data+testOfs); if ( segVal == replaceMe ) { ofsQueue.push( testOfs ); *((mitkIpInt1_t*)seg->data+testOfs) = newValue; } } // check left: testOfs = nextOfs-1; if (nextOfs%line!=0) { segVal = *((mitkIpInt1_t*)seg->data+testOfs); if ( segVal == replaceMe ) { ofsQueue.push( testOfs ); *((mitkIpInt1_t*)seg->data+testOfs) = newValue; } } // check bottom: testOfs = nextOfs+line; if (testOfs < maxOfs) { segVal = *((mitkIpInt1_t*)seg->data+testOfs); if ( segVal == replaceMe ) { ofsQueue.push( testOfs ); *((mitkIpInt1_t*)seg->data+testOfs) = newValue; } } } return regionSize; } diff --git a/Utilities/mbilog/mbilog.cpp b/Utilities/mbilog/mbilog.cpp index de28056105..9ff91b13ca 100644 --- a/Utilities/mbilog/mbilog.cpp +++ b/Utilities/mbilog/mbilog.cpp @@ -1,66 +1,68 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include #include "mbilog.h" static std::list backends; namespace mbilog { static const std::string NA_STRING = "n/a"; } void mbilog::RegisterBackend(mbilog::BackendBase* backend) { backends.push_back(backend); } void mbilog::UnregisterBackend(mbilog::BackendBase* backend) { backends.remove(backend); } void mbilog::DistributeToBackends(mbilog::LogMessage &l) { //Crop Message { std::string::size_type i = l.message.find_last_not_of(" \t\f\v\n\r"); l.message = (i != std::string::npos) ? l.message.substr(0, i+1) : ""; } //create dummy backend if there is no backend registered (so we have an output anyway) mbilog::BackendCout* dummyBackend = NULL; if(backends.empty()) { dummyBackend = new mbilog::BackendCout(); dummyBackend->SetFull(false); RegisterBackend(dummyBackend); } //iterate through all registered images and call the ProcessMessage() methods of the backends std::list::iterator i; for(i = backends.begin(); i != backends.end(); i++) (*i)->ProcessMessage(l); //if there was added a dummy backend remove it now if (dummyBackend != NULL) { UnregisterBackend(dummyBackend); delete dummyBackend; } } diff --git a/Utilities/mbilog/mbilog.h b/Utilities/mbilog/mbilog.h index 53e735095d..a926f40003 100644 --- a/Utilities/mbilog/mbilog.h +++ b/Utilities/mbilog/mbilog.h @@ -1,223 +1,225 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef _MBILOG_H #define _MBILOG_H #include #include "mbilogExports.h" #include "mbilogBackendBase.h" #include "mbilogBackendCout.h" #include "mbilogLogMessage.h" #include "mbilogLoggingTypes.h" #include "mbilogConfig.h" namespace mbilog { /** \brief Registeres a backend to the mbi logging mechanism. If a backend is registered here, all mbilog messages * are relayed to this backend through the method ProcessMessage. If no backend is registered the default * backend is used. */ void MBILOG_DLL_API RegisterBackend(BackendBase* backend); /** \brief Unregisters a backend. */ void MBILOG_DLL_API UnregisterBackend(BackendBase* backend); /** \brief Distributes the given message to all registered backends. Should only be called by objects * of the class pseudo stream. */ void MBILOG_DLL_API DistributeToBackends(LogMessage &l); /** Documentation * \brief An object of this class simulates a std::cout stream. This means messages can be added by * using the bit shift operator (<<). Should only be used by the macros defined in the file mbilog.h * \ingroup mbilog */ class MBILOG_DLL_API PseudoStream { protected: bool disabled; LogMessage msg; std::stringstream ss; public: inline PseudoStream( int level, const char* filePath, int lineNumber, const char* functionName) : disabled(false) , msg(LogMessage(level,filePath,lineNumber,functionName)) , ss(std::stringstream::out) { } /** \brief The message which is stored in the member ss is written to the backend. */ inline ~PseudoStream() { if(!disabled) { msg.message = ss.str(); msg.moduleName = MBILOG_MODULENAME; DistributeToBackends(msg); } } /** \brief Definition of the bit shift operator for this class.*/ template inline PseudoStream& operator<<(const T& data) { if(!disabled) { std::locale C("C"); std::locale originalLocale = ss.getloc(); ss.imbue(C); ss << data; ss.imbue( originalLocale ); } return *this; } /** \brief Definition of the bit shift operator for this class (for non const data).*/ template inline PseudoStream& operator<<(T& data) { if(!disabled) { std::locale C("C"); std::locale originalLocale = ss.getloc(); ss.imbue(C); ss << data; ss.imbue( originalLocale ); } return *this; } /** \brief Definition of the bit shift operator for this class (for functions).*/ inline PseudoStream& operator<<(std::ostream& (*func)(std::ostream&)) { if(!disabled) { std::locale C("C"); std::locale originalLocale = ss.getloc(); ss.imbue(C); ss << func; ss.imbue( originalLocale ); } return *this; } /** \brief Sets the category of this PseudoStream object. If there already is a category it is appended, seperated by a dot.*/ inline PseudoStream& operator()(const char *category) { if(!disabled) { if(msg.category.length()) msg.category+="."; msg.category+=category; } return *this; } /** \brief Enables/disables the PseudoStream. If set to false parsing and output is suppressed. */ inline PseudoStream& operator()(bool enabled) { disabled|=!enabled; return *this; } }; /** Documentation * \brief An object of this class simulates a std::cout stream but does nothing. This class is for dummy objects, bit shift * operators are availiable but doing nothing. Should only be used by the macros defined in the file mbilog.h * \ingroup mbilog */ class MBILOG_DLL_API NullStream { public: template inline NullStream& operator<<(const T& /*data*/) { return *this; } template inline NullStream& operator<<(T& /*data*/) { return *this; } inline NullStream& operator<<(std::ostream& (*)(std::ostream&)) { return *this; } inline NullStream& operator()(const char *) { return *this; } inline NullStream& operator()(bool) { return *this; } }; // /** \brief templated backend: one can define a class and a method to create a new backend. */ // template // struct DelegateBackend : public BackendBase // { // // typedef void(T::*Callback)(const mbilog::LogMessage&); // // DelegateBackend(T* obj, Callback callback) : m_Obj(obj), m_Callback(callback) // { // } // // void ProcessMessage(const mbilog::LogMessage& msg) // { // m_Obj->*m_Callback(msg); // } // // private: // // T* m_Obj; // Callback m_Callback; // }; } /** \brief Macros for different message levels. Creates an instance of class PseudoStream with the corresponding message level. * Other parameters are the name of the source file, line of the source code and function name which are generated * by the compiler. */ #define MBI_INFO mbilog::PseudoStream(mbilog::Info,__FILE__,__LINE__,__FUNCTION__) #define MBI_WARN mbilog::PseudoStream(mbilog::Warn,__FILE__,__LINE__,__FUNCTION__) #define MBI_ERROR mbilog::PseudoStream(mbilog::Error,__FILE__,__LINE__,__FUNCTION__) #define MBI_FATAL mbilog::PseudoStream(mbilog::Fatal,__FILE__,__LINE__,__FUNCTION__) /** \brief Macro for the debug messages. The messages are disabled if the cmake variable MBILOG_ENABLE_DEBUG is false. */ #ifdef MBILOG_ENABLE_DEBUG #define MBI_DEBUG mbilog::PseudoStream(mbilog::Debug,__FILE__,__LINE__,__FUNCTION__) #else #define MBI_DEBUG true ? mbilog::NullStream() : mbilog::NullStream() //this is magic by markus #endif #endif \ No newline at end of file diff --git a/Utilities/mbilog/mbilogBackendBase.cpp b/Utilities/mbilog/mbilogBackendBase.cpp index c5b1187e2b..a6c7b6e36b 100644 --- a/Utilities/mbilog/mbilogBackendBase.cpp +++ b/Utilities/mbilog/mbilogBackendBase.cpp @@ -1,20 +1,22 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include "mbilogBackendBase.h" mbilog::BackendBase::~BackendBase() {} diff --git a/Utilities/mbilog/mbilogBackendBase.h b/Utilities/mbilog/mbilogBackendBase.h index d810a11d70..cedb80efa3 100644 --- a/Utilities/mbilog/mbilogBackendBase.h +++ b/Utilities/mbilog/mbilogBackendBase.h @@ -1,47 +1,49 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef _mbilogBackendBase_H #define _mbilogBackendBase_H #include "mbilogExports.h" #include "mbilogLogMessage.h" namespace mbilog{ /** Documentation * \brief This class is an interface for logging backends that can be registered in the mbi logging mechanism. * * \ingroup mbilog */ class MBILOG_DLL_API BackendBase { public: virtual ~BackendBase(); /** \brief This method is called by the mbi logging mechanism if the object is registered in * the mbi logging mechanism and a logging message is emitted. * * \param logMessage Logging message which was emitted. * */ virtual void ProcessMessage(const mbilog::LogMessage& logMessage)=0; }; } #endif \ No newline at end of file diff --git a/Utilities/mbilog/mbilogBackendCout.cpp b/Utilities/mbilog/mbilogBackendCout.cpp index 6d9a2ab295..4adab0a5bf 100644 --- a/Utilities/mbilog/mbilogBackendCout.cpp +++ b/Utilities/mbilog/mbilogBackendCout.cpp @@ -1,48 +1,50 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include #include #include #include "mbilogBackendCout.h" mbilog::BackendCout::BackendCout() { m_useFullOutput=false; } mbilog::BackendCout::~BackendCout() { } void mbilog::BackendCout::SetFull(bool full) { m_useFullOutput = full; } void mbilog::BackendCout::ProcessMessage(const mbilog::LogMessage& l) { if(m_useFullOutput) FormatFull(l); else FormatSmart(l); } diff --git a/Utilities/mbilog/mbilogBackendCout.h b/Utilities/mbilog/mbilogBackendCout.h index 8e92ac8a5a..3f0bd5e994 100644 --- a/Utilities/mbilog/mbilogBackendCout.h +++ b/Utilities/mbilog/mbilogBackendCout.h @@ -1,63 +1,65 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef _mbilogBackendCout_H #define _mbilogBackendCout_H #include #include "mbilogExports.h" #include "mbilogTextBackendBase.h" #include "mbilogLogMessage.h" #include "mbilogLoggingTypes.h" namespace mbilog{ /** Documentation * \brief Default backend of the mbi logging mechanism. This backend is used if no other backend is registered. * The backend formats the logging messages to a normal string and writes them to std::cout. * \ingroup mbilog */ class MBILOG_DLL_API BackendCout : public TextBackendBase { public: BackendCout(); virtual ~BackendCout(); /** \brief This method is called by the mbi logging mechanism if the object is registered in * the mbi logging mechanism and a logging message is emitted. The method formats the * logging messages to a normal string (depending on formatting mode) and writes it to std::cout. * * \param logMessage Logging message. */ virtual void ProcessMessage(const mbilog::LogMessage &l ); /** \brief Sets the formatting mode. If true long messages will be displayed. Default is false (short/smart messages). * Long messages provide all informations and are also capable to be postproccessed (e.g. in a web viewer). */ void SetFull(bool full); private: /** \brief The formatting mode of this backend. True is full/long message formatting mode. False is short/smart * message formatting mode */ bool m_useFullOutput; }; } #endif \ No newline at end of file diff --git a/Utilities/mbilog/mbilogExports.h b/Utilities/mbilog/mbilogExports.h index df68852c9a..9326c3d52b 100644 --- a/Utilities/mbilog/mbilogExports.h +++ b/Utilities/mbilog/mbilogExports.h @@ -1,47 +1,46 @@ -/*========================================================================= +/*=================================================================== -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-05-19 21:14:21 +0200 (Di, 19 Mai 2009) $ -Version: $Revision: 17326 $ +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef mbilog_EXPORTS_H #define mbilog_EXPORTS_H #ifndef MBILOG_MODULENAME #if defined(_CMAKE_MODULENAME) #define MBILOG_MODULENAME _CMAKE_MODULENAME #else #define MBILOG_MODULENAME "n/a" #endif #endif /** * provide a macro for adding compiler specific export/import declarations * to classes. * This is needed for the export of symbols, when you build a DLL. Then write * * class MitkIGT_EXPORT ClassName : public SomeClass {}; */ #if defined(_WIN32) #ifdef mbilog_EXPORTS #define MBILOG_DLL_API __declspec(dllexport) #else #define MBILOG_DLL_API __declspec(dllimport) #endif #else #define MBILOG_DLL_API #endif #endif diff --git a/Utilities/mbilog/mbilogLogMessage.cpp b/Utilities/mbilog/mbilogLogMessage.cpp index 995c2b3464..ed6d3c5421 100644 --- a/Utilities/mbilog/mbilogLogMessage.cpp +++ b/Utilities/mbilog/mbilogLogMessage.cpp @@ -1,17 +1,19 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include "mbilogLogMessage.h" //TODO: delete? diff --git a/Utilities/mbilog/mbilogLogMessage.h b/Utilities/mbilog/mbilogLogMessage.h index 82d7dbff05..88bec4a5d5 100644 --- a/Utilities/mbilog/mbilogLogMessage.h +++ b/Utilities/mbilog/mbilogLogMessage.h @@ -1,79 +1,81 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef _mbilogLogMessage_H #define _mbilogLogMessage_H #include #include "mbilogExports.h" namespace mbilog{ /** Documentation * \brief An object of this class represents a single logging message (logging event) of the * mbi logging mechanism. Logging message should only be generated by the macros in the class mbilog.h * * \ingroup mbilog */ //todo convert to Struct class MBILOG_DLL_API LogMessage { public: //TODO: all member names m_[...] /** \brief Logging level which is defined in the enum mbilogLoggingTypes.h TODO: convert to enum.*/ const int level; // the data of the following section is generated by the c-compiler /** \brief File name of the source file where the logging message was emitted which is generated by the macros in file mbilog.h*/ const char* filePath; /** \brief Line of the source source file where the logging message was emitted which is generated by the macros in file mbilog.h*/ const int lineNumber; /** \brief Name of the method where the logging message was emitted which is generated by the macros in file mbilog.h*/ const char* functionName; // the data of the following section is generated by the mitk module system /** \brief Name of the module where the logging message was emitted which is generated by the macros in file mbilog.h. Is empty if there module defined.*/ const char* moduleName; // user parameters /** \brief Category of the logging event, which was defined by the user.*/ std::string category; /** \brief The actual logging message.*/ std::string message; LogMessage( const int _level, const char* _filePath, const int _lineNumber, const char* _functionName ) : level(_level) , filePath(_filePath) , lineNumber(_lineNumber) , functionName(_functionName) { } }; } #endif \ No newline at end of file diff --git a/Utilities/mbilog/mbilogLoggingTypes.h b/Utilities/mbilog/mbilogLoggingTypes.h index 6729ae9929..dcbe9be490 100644 --- a/Utilities/mbilog/mbilogLoggingTypes.h +++ b/Utilities/mbilog/mbilogLoggingTypes.h @@ -1,38 +1,37 @@ -/*========================================================================= +/*=================================================================== -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-05-19 21:14:21 +0200 (Di, 19 Mai 2009) $ -Version: $Revision: 17326 $ +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef _MBILOG_LOGGINGTYPES_H_ #define _MBILOG_LOGGINGTYPES_H_ namespace mbilog { /** \brief This enum defines the message/event levels of the mbi logging mechanism. * Info: TODO * Warn: TODO * Error: TODO * Fatal: TODO * Debug: TODO */ enum { Info, Warn, Error, Fatal, Debug }; } #endif \ No newline at end of file diff --git a/Utilities/mbilog/mbilogTextBackendBase.cpp b/Utilities/mbilog/mbilogTextBackendBase.cpp index d01d76e4bb..add073f05c 100644 --- a/Utilities/mbilog/mbilogTextBackendBase.cpp +++ b/Utilities/mbilog/mbilogTextBackendBase.cpp @@ -1,571 +1,573 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include "mbilogTextBackendBase.h" #include "mbilogLoggingTypes.h" #include "mbilogTextDictionary.h" #include #include #include #include #ifdef _WIN32 #define USE_WIN32COLOREDCONSOLE #include #endif static bool g_init=false; mbilog::TextBackendBase::~TextBackendBase() {} #ifdef USE_WIN32COLOREDCONSOLE static HANDLE g_hConsole; class AutoCategorize { protected: std::vector path; std::string current,category; int pos; void flush() { if(current.size()>0) { if(current.compare("..")==0) { if(path.size()>0) path.pop_back(); } else { path.push_back(current); } current=""; } } std::string simplify(std::string x) { bool redo; std::string lft(""),rgt(""); do { redo=false; for(int r=0; r < sizeof(mbilog::replace)/sizeof(char*); r+=2) { int s = static_cast( strlen(mbilog::replace[r]) ); int xs = static_cast( x.size() ); if(xs==s) { if( mbilog::replace[r+1][0] || !lft.empty() || !rgt.empty() ) if(x.compare(mbilog::replace[r])==0) x=mbilog::replace[r+1]; } else if(xs>s) { if(strncmp(mbilog::replace[r],&x.c_str()[xs-s],s)==0) { std::string rp = mbilog::replace[r+1]; if(!rp.empty()) rp[0]=toupper(rp[0]); x = x.substr(0,xs-s); rgt = rp + rgt; redo=true; } else if(strncmp(mbilog::replace[r],x.c_str(),s)==0) { std::string rp = mbilog::replace[r+1]; if(!rp.empty()) rp[0]=toupper(rp[0]); x=x.substr(s,xs-s); lft = lft + rp; redo=true; } } } } while(redo); x[0]=toupper(x[0]); x=lft+x+rgt; x[0]=tolower(x[0]); return x; } std::string concat(std::string a,std::string b,bool opt) { int as = static_cast( a.size() ); int bs = static_cast( b.size() ); if(opt && as <= bs) { if (as==bs && a.compare(b)==0) return a; if(strncmp(a.c_str(),b.c_str(),as)==0) { b=b.substr(as,bs-as); b[0]=tolower(b[0]); } } return a+"."+b; } bool search2p2(char *a,char *b,bool optimize=true) { int size = static_cast( path.size() ) - 3; for(int r=0;r( path.size() ) - 2; for(int r=0;r( path.size() ) - 2; for(int r=0;r( strlen(l.filePath) ); current = ""; for(int r = 0;r>> " << std::flush; ChangeColor( colorNormal ); std::cout << std::endl; */ // Give out start time ChangeColor( colorTime ); AppendTimeStamp(std::cout); std::cout << std::endl; } switch(l.level) { case mbilog::Info: break; case mbilog::Warn: colorTime = FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY; //colorText = FOREGROUND_RED|FOREGROUND_GREEN; colorCat = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY; showColon = false; forceCat = true; break; case mbilog::Error: colorTime = FOREGROUND_RED|FOREGROUND_INTENSITY; //colorText = FOREGROUND_RED; colorCat = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY; showColon = false; forceCat = true; break; case mbilog::Fatal: colorTime = FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY; //colorText = FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY; colorCat = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY; showColon = false; forceCat = true; break; case mbilog::Debug: colorTime = FOREGROUND_BLUE|FOREGROUND_INTENSITY; //colorText |= FOREGROUND_INTENSITY; showColon = false; break; } ChangeColor( colorTime ); std::locale C("C"); std::locale originalLocale = std::cout.getloc(); std::cout.imbue(C); std::cout << std::fixed << std::setprecision(2) << ((double)std::clock())/CLOCKS_PER_SEC << " "; std::cout.imbue( originalLocale ); // category { AutoCategorize ac(l); std::string pre=ac.GetPrefix(); std::string cat=ac.GetCategory(); cat = pre + cat; if(cat.empty()) cat = l.category; if(!cat.empty()) { ChangeColor( colorCat ); // static std::string lastCat; // if(forceCat||lastCat.compare(cat)) { std::cout << cat << std::flush; // lastCat = cat; } // else // std::cout << "..." << std::flush; if(showColon) { ChangeColor( FOREGROUND_BLUE | FOREGROUND_INTENSITY ); std::cout << ": " << std::flush; } else std::cout << " "; } } switch(l.level) { case mbilog::Info: break; case mbilog::Warn: ChangeColor( colorTime ); std::cout << "WARNING" << std::flush; ChangeColor( FOREGROUND_BLUE | FOREGROUND_INTENSITY ); std::cout << ": " << std::flush; break; case mbilog::Error: ChangeColor( colorTime ); std::cout << "ERROR" << std::flush; ChangeColor( FOREGROUND_BLUE | FOREGROUND_INTENSITY ); std::cout << ": " << std::flush; break; case mbilog::Fatal: ChangeColor( colorTime ); std::cout << "FATAL" << std::flush; ChangeColor( FOREGROUND_BLUE | FOREGROUND_INTENSITY ); std::cout << ": " << std::flush; break; case mbilog::Debug: ChangeColor( colorTime ); std::cout << "DBG" << std::flush; ChangeColor( FOREGROUND_BLUE | FOREGROUND_INTENSITY ); std::cout << ": " << std::flush; break; } ChangeColor( colorText ); std::cout << l.message << std::endl; ChangeColor( colorNormal ); } #endif diff --git a/Utilities/mbilog/mbilogTextBackendBase.h b/Utilities/mbilog/mbilogTextBackendBase.h index 8c99769163..b17a1e48e4 100644 --- a/Utilities/mbilog/mbilogTextBackendBase.h +++ b/Utilities/mbilog/mbilogTextBackendBase.h @@ -1,77 +1,79 @@ -/*========================================================================= +/*=================================================================== -Program: mbilog - logging for mitk / BlueBerry +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef _mbilogTextBackendBase_H #define _mbilogTextBackendBase_H #include "mbilogExports.h" #include "mbilogBackendBase.h" namespace mbilog{ /** Documentation * \brief This class is an abstract superclass for logging text backends. It adds string formatting methods * to the backend interface BackendBase. Accordingly backends that inherit from this class can be * registered in the mbi logging mechanism. * * \ingroup mbilog */ class MBILOG_DLL_API TextBackendBase : public BackendBase { public: virtual ~TextBackendBase(); /** \brief This method is called by the mbi logging mechanism if the object is registered in * the mbi logging mechanism and a logging message is emitted. * * \param logMessage Logging message which was emitted. * */ virtual void ProcessMessage(const mbilog::LogMessage& logMessage)=0; protected: /** \brief Method formats the given LogMessage in the smart/short format and writes it to std::cout. * \param threadID Can be set to the threadID where the logging message was emitted. Is 0 by default. */ void FormatSmart(const LogMessage &l,int threadID=0); /** \brief Method formats the given LogMessage in the full/long format and writes it to std::cout. * \param threadID Can be set to the threadID where the logging message was emitted. Is 0 by default. */ void FormatFull(const LogMessage &l,int threadID=0); /** \brief Method formats the given LogMessage in the smart/short format and writes it to the given std::ostream. * \param threadID Can be set to the threadID where the logging message was emitted. Is 0 by default. */ void FormatSmart(std::ostream &out, const LogMessage &l,int threadID=0); /** \brief Method formats the given LogMessage in the full/long format and writes it to the given std::ostream. * \param threadID Can be set to the threadID where the logging message was emitted. Is 0 by default. */ void FormatFull(std::ostream &out, const LogMessage &l,int threadID=0); /** \brief Writes the system time to the given stream.*/ void AppendTimeStamp(std::ostream& out); /** \brief Special variant of method FormatSmart which uses colored messages (only for windows).*/ //TODO: implement for linux? void FormatSmartWindows(const mbilog::LogMessage &l,int /*threadID*/); }; } #endif \ No newline at end of file diff --git a/Utilities/mbilog/mbilogTextDictionary.h b/Utilities/mbilog/mbilogTextDictionary.h index d07fc91c03..c3af69d457 100644 --- a/Utilities/mbilog/mbilogTextDictionary.h +++ b/Utilities/mbilog/mbilogTextDictionary.h @@ -1,250 +1,249 @@ -/*========================================================================= +/*=================================================================== -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-05-19 21:14:21 +0200 (Di, 19 Mai 2009) $ -Version: $Revision: 17326 $ +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef _MBILOG_TEXTDICTIONARY_H_ #define _MBILOG_TEXTDICTIONARY_H_ namespace mbilog { /** \brief This is a dictionary to replace long names of classes, * modules, etc. to shorter versions in the console output. */ static char *replace[] = { ".cpp", "", ".cxx", "", ".txx", "", ".h", "", ".hpp", "", ".hxx", "", ".c", "", "org.blueberry.", "", "org.mitk.gui.qt.", "", "org.mitk.", "", "qmitk", "", "mitk", "", "berry", "", "itk", "", "vtk", "", "qt", "", "object", "obj", "factory", "fac", "classes", "cls", "plugin", "plg", "widget", "wdgt", "interface", "itf", "service", "svc", "register", "reg", "perspective", "prs", "assessor", "ase", "atrophy", "atr", "bias", "bias", "field", "fld", "multi", "mlt", "contour", "cntr", "tools", "tls", "tool", "tl", "application", "app", "calculate", "calc", "subtract", "sub", "region", "reg", "tumor", "tum", "growing", "grow", "segmentation", "seg", "statistics", "stat", "imaging", "img", "image", "img", "diffusion", "dif", "registration", "reg", "navigation", "nav", "generation", "gen", "generator", "gen", "vector", "vec", "gradient", "grad", "flow", "flow", "paint", "pnt", "brush", "brsh", "volumetry", "vol", "volume", "vol", "mapper", "map", "filter", "flt", "surface", "sfc", "point", "pnt", "organ", "org", "multiple", "mlt", "corrector", "cor", "correction", "cor", "batch", "bat", "window", "wnd", "advisor", "adv", "editor", "edt", "material", "mat", "visualization", "vis", "measurement", "mes", "scene", "scn", "serialization", "ser", "deserializer", "dser", "serializer", "ser", "sandbox", "sb", "texture", "tex", "opengl", "ogl", "vessel", "vsl", "value", "val", "analysis", "ana", "patient", "pat", "body", "body", "diagnosis", "diag", "mesh", "mesh", "radial", "rad", "simple", "smp", "algorithms", "alg", "controllers", "con", "control", "con", "interactive", "ia", "interactions", "ia", "processing", "pro", "process", "pro", "rendering", "rnd", "renderer", "rnd", "render", "rnd", "datamanagement", "data", "management", "mng", "manager", "mng", "data", "data", "anatomy", "ana", "neuro", "neo", "automatic", "auto", "optimizer", "opt", "optimize", "opt", "binary", "bin", "liver", "liv", "lymph", "lym", "node", "node", "tree", "tree", "homogeneous", "hmgn", "threshold", "tsh", // "shapebased", "shp", "based", "bsd", "shape", "shp", "model", "mdl", "extension", "ext", "activator", "act", "dicom", "dicom", "browser", "brwr", "viewer", "view", "view", "view", "finder", "fnd", "indexer", "idx", "index", "idx", "rapid", "rpd", "gui", "gui", "slices", "slc", "slice", "slc", "about", "abt", "interpolator", "inp", "switcher", "swh", "planning", "plan", "planner", "plan", "plane", "pln", "plan", "plan", "workbench", "wrkbnc", "common", "com", "resection", "rsc", "translation", "trnsl", "rotation", "rot", "deformation", "dfrm", "shader", "shd", "repository", "rep", "initializer", "init", "dialog", "dlg", "download", "down", "upload", "up", "core", "core", "manual", "man", "leaf", "leaf", "internal", "int", "external", "ext", "platform", "pltfm", "method", "mthd", "pyramidal", "prmdl", "tracking", "trck", "track", "trck", "bspline", "bspl", "spline", "spl", "create", "crt", "erase", "ers", "auto", "auto", "crop", "crop", "file", "file", "io", "io", "2d", "2d", "3d", "3d", ".", "." }; } #endif \ No newline at end of file diff --git a/Utilities/qtsingleapplication/qthandlenewappinstance.cpp b/Utilities/qtsingleapplication/qthandlenewappinstance.cpp index 8b1da575d3..d73f78cd15 100644 --- a/Utilities/qtsingleapplication/qthandlenewappinstance.cpp +++ b/Utilities/qtsingleapplication/qthandlenewappinstance.cpp @@ -1,116 +1,115 @@ -/*========================================================================= +/*=================================================================== -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include "qthandlenewappinstance.h" #include "qtsingleapplication.h" #include #include // mkdtemp #ifdef Q_OS_WIN #include //#include #endif bool createTemporaryDir(QString& path) { QString baseName = QCoreApplication::applicationName(); if (baseName.isEmpty()) { baseName = QLatin1String("mitk_temp"); } QString templateName = QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX"); bool success = false; #ifdef Q_OS_WIN QString buffer = templateName; // Windows' mktemp believes 26 temp files per process ought to be enough for everyone (!) // Let's add a few random chars then, before the XXXXXX template. for (int i = 0 ; i < 4 ; ++i) buffer += QChar((qrand() & 0xffff) % (26) + 'A'); if (!buffer.endsWith(QLatin1String("XXXXXX"))) buffer += QLatin1String("XXXXXX"); //QFileSystemEntry baseEntry(buffer); //QFileSystemEntry::NativePath basePath = baseEntry.nativeFilePath(); QString basePath = QDir::toNativeSeparators(buffer); wchar_t* array = (wchar_t*)basePath.utf16(); if (_wmktemp(array) && ::CreateDirectoryW(array, 0)) { success = true; //QFileSystemEntry entry(QString::fromWCharArray(array), QFileSystemEntry::FromNativePath()); //path = entry.filePath(); path = QDir::fromNativeSeparators(QString::fromUtf16((const ushort*)array)); } #else QByteArray buffer = QFile::encodeName(templateName); if (!buffer.endsWith("XXXXXX")) buffer += "XXXXXX"; if (mkdtemp(buffer.data())) { // modifies buffer success = true; path = QFile::decodeName(buffer.constData()); } #endif return success; } QString handleNewAppInstance(QtSingleApplication* singleApp, int argc, char** argv, const QString& newInstanceArg) { if (singleApp->isRunning()) { QStringList args; bool newInstance = false; for (int i = 0; i < argc; ++i) { args << argv[i]; if (args.back().endsWith(newInstanceArg)) { newInstance = true; } } if (newInstance) { QString path; if (!createTemporaryDir(path)) { qCritical("Could not create temporary storage path for new application instance."); exit(EXIT_FAILURE); } qWarning("Forcing new application instance. The application data will be written to a temporary directory."); return path; } else { QByteArray ba; QDataStream msg(&ba, QIODevice::WriteOnly); msg << QString("$cmdLineArgs"); // This message contains command line arguments msg << args; if(singleApp->sendMessage(ba)) { exit(EXIT_SUCCESS); } else { qCritical("The running application seems to be frozen."); exit(EXIT_FAILURE); } } } return QString(); } diff --git a/Utilities/qtsingleapplication/qthandlenewappinstance.h b/Utilities/qtsingleapplication/qthandlenewappinstance.h index 11743f08cc..9256881f90 100644 --- a/Utilities/qtsingleapplication/qthandlenewappinstance.h +++ b/Utilities/qtsingleapplication/qthandlenewappinstance.h @@ -1,30 +1,29 @@ -/*========================================================================= +/*=================================================================== -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ +The Medical Imaging Interaction Toolkit (MITK) -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. -=========================================================================*/ +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #ifndef QTHANDLENEWAPPINSTANCE_H #define QTHANDLENEWAPPINSTANCE_H #include class QtSingleApplication; bool createTemporaryDir(QString& path); QString handleNewAppInstance(QtSingleApplication* singleApp, int argc, char** argv, const QString& newInstanceArg); #endif // QTHANDLENEWAPPINSTANCE_H