Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit aa0fb014 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED no single instruction without brackets



Result after adding the --add-brackets option to astyle
Signed-off-by: Emmanuel Promayon's avatarEmmanuel Promayon <Emmanuel.Promayon@imag.fr>
parent 71b81769
......@@ -299,17 +299,20 @@ vtkSmartPointer<vtkImageData> GaussianFilter::itkProcessIIRGaussian(vtkSmartPoin
filterX->SetInput(vtkToItkFilter->GetOutput());
filterY->SetInput(filterX->GetOutput());
if (dim == 3)
if (dim == 3) {
filterZ->SetInput(filterY->GetOutput());
}
// Re-connect the obtained ITK imge to CamiTK via VTK image
typedef itk::ImageToVTKImageFilter<OutputImageType> itkToVtkFilterType;
typename itkToVtkFilterType::Pointer itkToVtkFilter = itkToVtkFilterType::New();
if (dim == 2)
if (dim == 2) {
itkToVtkFilter->SetInput(filterY->GetOutput());
else
}
else {
itkToVtkFilter->SetInput(filterZ->GetOutput());
}
itkToVtkFilter->Update();
......
......@@ -163,8 +163,9 @@ vtkSmartPointer<vtkImageData> MeanFilter::itkProcess(vtkSmartPointer<vtkImageDat
typename InputImageType::SizeType indexRadius;
indexRadius[0] = halfNeighborhoodSizeX;
indexRadius[1] = halfNeighborhoodSizeY;
if (dim == 3)
if (dim == 3) {
indexRadius[2] = halfNeighborhoodSizeZ;
}
filter->SetInput(vtkToItkFilter->GetOutput());
filter->SetRadius(indexRadius);
......
......@@ -166,8 +166,9 @@ vtkSmartPointer<vtkImageData> MedianFilter::itkProcess(vtkSmartPointer<vtkImageD
indexRadius[0] = halfNeighborhoodSizeX;
indexRadius[1] = halfNeighborhoodSizeY;
if (dim == 3)
if (dim == 3) {
indexRadius[2] = halfNeighborhoodSizeZ;
}
filter->SetInput(vtkToItkFilter->GetOutput());
filter->SetRadius(indexRadius);
......
......@@ -100,8 +100,9 @@ Action::ApplyStatus RegionGrowing::apply() {
ImageComponent * input = dynamic_cast<ImageComponent *> (getTargets().last());
// this call works only with a GUI (i.e. if theWidget exists)
if ((input == NULL) || (rgWidget == NULL))
if ((input == NULL) || (rgWidget == NULL)) {
return ABORTED;
}
// Get the parameters
filterBefore = rgWidget->isSmoothingChecked();
......
......@@ -96,10 +96,12 @@ DicomComponent::DicomComponent(DicomSerie* dicomSerie) throw(AbortException) : I
// create image data corresponding to the component
imageReader = vtkSmartPointer<vtkGDCMImageReader>::New();
if(fileNamesSorted->GetSize() == 1)
if(fileNamesSorted->GetSize() == 1) {
imageReader->SetFileName(fileNamesSorted->GetValue(0));
else
}
else {
imageReader->SetFileNames(fileNamesSorted);
}
imageReader->Update();
vtkSmartPointer<vtkImageData> rawData = imageReader->GetOutput();
......@@ -139,18 +141,21 @@ DicomComponent::DicomComponent(DicomSerie* dicomSerie) throw(AbortException) : I
setImageData(image, false, orientation);
// Wait for the LUT update in CamiTK and / or support for color image
if(getLut()) // sometimes ImageComponent happens not to have a lut, strange behaviour
if(getLut()) { // sometimes ImageComponent happens not to have a lut, strange behaviour
updateLUT();
else
}
else {
CAMITK_WARNING("DicomComponent", "Constructor", "Image's lut is null.");
}
}
// --------------- destructor -------------------
DicomComponent::~DicomComponent() {
if(serie)
if(serie) {
delete serie;
}
// if(imageReader)
// imageReader->Delete();
}
......@@ -178,8 +183,9 @@ camitk::ImageOrientationHelper::PossibleImageOrientations DicomComponent::readDi
gdcm::Scanner scanner;
gdcm::Tag iopTag = gdcm::Tag(0x0020, 0x0037);
scanner.AddTag(iopTag);
if(!scanner.Scan(fileNames)) // Definitively, scan should never failed, since DicomParser::parseDirectory() has already filter files.
if(!scanner.Scan(fileNames)) { // Definitively, scan should never failed, since DicomParser::parseDirectory() has already filter files.
CAMITK_ERROR("DicomComponent", "readDirectCosinesAngle", "Scan failed looking for tag (0x0020, 0x0037) Image Orientation Patient");
}
// Check value tag exists
gdcm::Scanner::TagToValue const &ttv = scanner.GetMapping(fileNames[0].c_str());
......@@ -212,65 +218,88 @@ camitk::ImageOrientationHelper::PossibleImageOrientations DicomComponent::readDi
// return the appropriate ImageOrientation corresponding to this cosines
// we only need to check one component of vector X and Y as they are colinear (other components are 0) to one of the frame vectors
if((x[0] == 1.0) && (y[1] == 1.0)) // identity matrix => Image frame is the scanner frame
if((x[0] == 1.0) && (y[1] == 1.0)) { // identity matrix => Image frame is the scanner frame
return ImageOrientationHelper::RAI;
}
// other cases Image frame is different
if(x[0] == 1.0) {
if(y[1] == -1.0)
if(y[1] == -1.0) {
return ImageOrientationHelper::RPS;
if(y[2] == 1.0)
}
if(y[2] == 1.0) {
return ImageOrientationHelper::RIP;
if(y[2] == -1.0)
}
if(y[2] == -1.0) {
return ImageOrientationHelper::RSA;
}
}
if(x[0] == -1.0) {
if(y[1] == 1.0)
if(y[1] == 1.0) {
return ImageOrientationHelper::LAS;
if(y[2] == -1.0)
}
if(y[2] == -1.0) {
return ImageOrientationHelper::LPI;
if(y[2] == 1.0)
}
if(y[2] == 1.0) {
return ImageOrientationHelper::LIA;
}
}
if(x[1] == 1.0) {
if(y[0] == 1.0)
if(y[0] == 1.0) {
return ImageOrientationHelper::ARS;
if(y[0] == -1.0)
}
if(y[0] == -1.0) {
return ImageOrientationHelper::ALI;
if(y[2] == 1.0)
}
if(y[2] == 1.0) {
return ImageOrientationHelper::AIR;
if(y[2] == -1.0)
}
if(y[2] == -1.0) {
return ImageOrientationHelper::ASL;
}
}
if(x[1] == -1.0) {
if(y[0] == 1.0)
if(y[0] == 1.0) {
return ImageOrientationHelper::PRI;
if(y[0] == -1.0)
}
if(y[0] == -1.0) {
return ImageOrientationHelper::PLS;
if(y[2] == 1.0)
}
if(y[2] == 1.0) {
return ImageOrientationHelper::PIL;
if(y[2] == -1.0)
}
if(y[2] == -1.0) {
return ImageOrientationHelper::PSR;
}
}
if(x[2] == 1.0) {
if(y[0] == 1.0)
if(y[0] == 1.0) {
return ImageOrientationHelper::IRA;
if(y[0] == -1.0)
}
if(y[0] == -1.0) {
return ImageOrientationHelper::ILP;
if(y[1] == 1.0)
}
if(y[1] == 1.0) {
return ImageOrientationHelper::IAL;
if(y[1] == -1.0)
}
if(y[1] == -1.0) {
return ImageOrientationHelper::IPR;
}
}
if(x[2] == -1.0) {
if(y[0] == 1.0)
if(y[0] == 1.0) {
return ImageOrientationHelper::SRP;
if(y[0] == -1.0)
}
if(y[0] == -1.0) {
return ImageOrientationHelper::SLA;
if(y[1] == 1.0)
}
if(y[1] == 1.0) {
return ImageOrientationHelper::SAR;
if(y[1] == -1.0)
}
if(y[1] == -1.0) {
return ImageOrientationHelper::SPL;
}
}
// should never return UNKNOW
......@@ -281,10 +310,13 @@ camitk::ImageOrientationHelper::PossibleImageOrientations DicomComponent::readDi
// --------------- roundCosine -------------------
double DicomComponent::roundCosine(const double & value) const {
if(value < -0.5)
if(value < -0.5) {
return -1.0;
if((value >= -0.5) && (value <= 0.5))
}
if((value >= -0.5) && (value <= 0.5)) {
return 0.0;
else
}
else {
return 1.0;
}
}
......@@ -85,8 +85,9 @@ Component * DicomComponentExtension::open(const QString & path) throw (AbortExce
lastOpenedComponent = new DicomComponent(serie);
break;
}
else
else {
delete serie;
}
}
}
......
......@@ -77,8 +77,9 @@ QList<DicomDialogEntry*> DicomDialog::getSelectedDicomDialogEntries() {
int nbOfElements = ui.tableWidget->rowCount();
for (int row = 0; row < nbOfElements; row++) {
if(ui.tableWidget->item(row, 0)->checkState())
if(ui.tableWidget->item(row, 0)->checkState()) {
selectedElements.append(dicomDialogEntries.at(row));
}
}
return selectedElements;
......
......@@ -63,11 +63,13 @@ QList<DicomSerie*> DicomParser::parseDirectory(const QString & directory) {
CAMITK_DEBUG("DicomParser", "parseDirectory", file +" is a DICOM image file");
imageFileNames.push_back(file);
}
else
else {
CAMITK_DEBUG("DicomParser", "parseDirectory", file +" is a DICOM file WITHOUT PixelData information");
}
}
else
else {
CAMITK_DEBUG("DicomParser", "parseDirectory", file +" is not a valid DICOM file");
}
}
// filter files per image and STUDY
......
......@@ -53,8 +53,9 @@ throw (AbortException) : ImageComponent(directoryName) {
void DicomItkComponent::createComponent(const QString directoryName, FilenamesContainerType filenames, QString name) {
if (!directoryName.isEmpty()) {
vtkSmartPointer<vtkImageData> img = readVolume(directoryName, filenames);
if(img)
if(img) {
setImageData(img, false);
}
setName(name);
}
}
......
......@@ -103,8 +103,9 @@ Component * DicomItkComponentExtension::open(const QString & directoryName) thro
QTextStream(&name) << it->first->protocolName << "_" << nVol;
if ((it->first->numberOfTemporalPositions.isEmpty()) ||
(it->first->numberOfTemporalPositions.toInt() == 1) ||
!(it->first->desInterlace->isChecked()))
!(it->first->desInterlace->isChecked())) {
res = new DicomItkComponent(directoryName, it->second, name);
}
else { // In case of temporal series, the volume are stored interlaced
int nbVols = it->first->numberOfTemporalPositions.toInt();
FileNamesContainerType allFiles = it->second;
......@@ -113,8 +114,9 @@ Component * DicomItkComponentExtension::open(const QString & directoryName) thro
nameVol.clear();
QTextStream(&nameVol) << name << "_" << volumeNo;
// Fill in volumeFiles with one out of nbVols file names
for (unsigned int n = volumeNo; n < allFiles.size(); n+= nbVols)
for (unsigned int n = volumeNo; n < allFiles.size(); n+= nbVols) {
volumeFiles.push_back(allFiles[n]);
}
QDateTime start = QDateTime::currentDateTime();
......@@ -244,8 +246,9 @@ bool DicomItkComponentExtension::findAllDicomSeries(const QString & directoryNam
bool DicomItkComponentExtension::chooseDicomSeriesIds() throw (AbortException) {
// If no volume -> error
if (theSeries.empty())
if (theSeries.empty()) {
throw new AbortException(std::string("No dicom volume series found in this directory\n"));
}
// If there is only one volume in the directory, don't bother to ask user, just open it
if (theSeries.size() == 1) {
......@@ -333,8 +336,9 @@ bool DicomItkComponentExtension::chooseDicomSeriesIds() throw (AbortException) {
connect(buttonBox, SIGNAL(rejected()), seriesChoiceDialog, SLOT(reject()));
// Show the window and manage the cancel case
if (seriesChoiceDialog->exec() != QDialog::Accepted)
if (seriesChoiceDialog->exec() != QDialog::Accepted) {
throw AbortException("Operation canceled\n");
}
return true;
}
......
......@@ -177,65 +177,88 @@ camitk::ImageOrientationHelper::PossibleImageOrientations DicomTreeSerieComponen
// return the appropriate ImageOrientation corresponding to this cosines
// we only need to check one component of vector X and Y as they are colinear (other components are 0) to one of the frame vectors
if((x[0] == 1.0) && (y[1] == 1.0)) // identity matrix => Image frame is the scanner frame
if((x[0] == 1.0) && (y[1] == 1.0)) { // identity matrix => Image frame is the scanner frame
return ImageOrientationHelper::RAI;
}
// other cases Image frame is different
if(x[0] == 1.0) {
if(y[1] == -1.0)
if(y[1] == -1.0) {
return ImageOrientationHelper::RPS;
if(y[2] == 1.0)
}
if(y[2] == 1.0) {
return ImageOrientationHelper::RIP;
if(y[2] == -1.0)
}
if(y[2] == -1.0) {
return ImageOrientationHelper::RSA;
}
}
if(x[0] == -1.0) {
if(y[1] == 1.0)
if(y[1] == 1.0) {
return ImageOrientationHelper::LAS;
if(y[2] == -1.0)
}
if(y[2] == -1.0) {
return ImageOrientationHelper::LPI;
if(y[2] == 1.0)
}
if(y[2] == 1.0) {
return ImageOrientationHelper::LIA;
}
}
if(x[1] == 1.0) {
if(y[0] == 1.0)
if(y[0] == 1.0) {
return ImageOrientationHelper::ARS;
if(y[0] == -1.0)
}
if(y[0] == -1.0) {
return ImageOrientationHelper::ALI;
if(y[2] == 1.0)
}
if(y[2] == 1.0) {
return ImageOrientationHelper::AIR;
if(y[2] == -1.0)
}
if(y[2] == -1.0) {
return ImageOrientationHelper::ASL;
}
}
if(x[1] == -1.0) {
if(y[0] == 1.0)
if(y[0] == 1.0) {
return ImageOrientationHelper::PRI;
if(y[0] == -1.0)
}
if(y[0] == -1.0) {
return ImageOrientationHelper::PLS;
if(y[2] == 1.0)
}
if(y[2] == 1.0) {
return ImageOrientationHelper::PIL;
if(y[2] == -1.0)
}
if(y[2] == -1.0) {
return ImageOrientationHelper::PSR;
}
}
if(x[2] == 1.0) {
if(y[0] == 1.0)
if(y[0] == 1.0) {
return ImageOrientationHelper::IRA;
if(y[0] == -1.0)
}
if(y[0] == -1.0) {
return ImageOrientationHelper::ILP;
if(y[1] == 1.0)
}
if(y[1] == 1.0) {
return ImageOrientationHelper::IAL;
if(y[1] == -1.0)
}
if(y[1] == -1.0) {
return ImageOrientationHelper::IPR;
}
}
if(x[2] == -1.0) {
if(y[0] == 1.0)
if(y[0] == 1.0) {
return ImageOrientationHelper::SRP;
if(y[0] == -1.0)
}
if(y[0] == -1.0) {
return ImageOrientationHelper::SLA;
if(y[1] == 1.0)
}
if(y[1] == 1.0) {
return ImageOrientationHelper::SAR;
if(y[1] == -1.0)
}
if(y[1] == -1.0) {
return ImageOrientationHelper::SPL;
}
}
// should never return UNKNOW
......@@ -246,12 +269,15 @@ camitk::ImageOrientationHelper::PossibleImageOrientations DicomTreeSerieComponen
// --------------- roundCosine -------------------
double DicomTreeSerieComponent::roundCosine(const double & value) const {
if(value < -0.5)
if(value < -0.5) {
return -1.0;
if((value >= -0.5) && (value <= 0.5))
}
if((value >= -0.5) && (value <= 0.5)) {
return 0.0;
else
}
else {
return 1.0;
}
}
// --------------- translate -------------------
......
......@@ -66,8 +66,9 @@ DicomTreeStudyComponent::DicomTreeStudyComponent(const std::vector< std::string
serieFileNames = ippsorter.GetFilenames();
// std::cout << "SERIE contains (after filering images (IPPSorter)) : " << serieFileNames.size() << " files" << std::endl;
if(serieFileNames.size() > 0)
if(serieFileNames.size() > 0) {
addChild(new DicomTreeSerieComponent(serieFileNames));
}
}
}
// --------------- destructor -------------------
......
......@@ -82,8 +82,9 @@ bool ItkImageComponentExtension::save(Component * c) const {
bool succeed = false;
ImageComponent *img = dynamic_cast<ImageComponent *>(c);
if (!img)
if (!img) {
return succeed;
}
// Instanciate the template function saveImage
// according to the input image type.
......@@ -92,10 +93,12 @@ bool ItkImageComponentExtension::save(Component * c) const {
int * dims = img->getImageData()->GetDimensions();
int dim = 0;
if (dims[2] == 0)
if (dims[2] == 0) {
dim = 2;
else
}
else {
dim = 3;
}
vtkSmartPointer<vtkImageData> data = img->getImageData();
......@@ -261,8 +264,9 @@ template<class ImageType> bool ItkImageComponentExtension::saveImage(ImageCompon
typedef itk::ImageFileWriter< ImageType > WriterType;
QString filename = img->getFileName();
if (filename.isEmpty())
if (filename.isEmpty()) {
return false;
}
vtkSmartPointer<vtkImageData> vtkImage = img->getImageData();
......
......@@ -77,8 +77,9 @@ Action::ApplyStatus GenerateModel::apply() {
if( originalFilename.isEmpty() ) {
// ask the user
originalFilename = QFileDialog::getSaveFileName( NULL, "Generate Model", "", "ModelingML (*.mml)" );
if( originalFilename.isNull() )
if( originalFilename.isNull() ) {
return ABORTED;
}
}
QString baseFilename = QFileInfo( originalFilename ).absolutePath() + "/" + QFileInfo( originalFilename ).completeBaseName();
......@@ -104,8 +105,9 @@ Action::ApplyStatus GenerateModel::apply() {
saveSOFAFile( baseFilename );
//-- 3) save LML, PML, and MML
if( !property( "SOFA Only" ).toBool() )
if( !property( "SOFA Only" ).toBool() ) {
saveMMLFiles( baseFilename );
}
// restore the normal cursor
QApplication::restoreOverrideCursor();
......@@ -147,8 +149,9 @@ void GenerateModel::saveSOFAFile( QString baseFilename ) {
scnFile << " <FixedConstraint template=\"Vec3d\" name=\"FixedConstraint\" indices=\"";
std::set<int>::const_iterator pos;
// preincrement and predecrement are usually faster than postincrement and postdecrement...
for( pos = fixedDOFIndex.begin(); pos != fixedDOFIndex.end(); ++pos )
for( pos = fixedDOFIndex.begin(); pos != fixedDOFIndex.end(); ++pos ) {
scnFile << *pos << " ";
}
scnFile << "\" />" << endl;
}
......@@ -167,8 +170,9 @@ void GenerateModel::saveMMLFiles( QString baseFilename ) {
Loads l;
Translation *t = new Translation();
std::set<int>::const_iterator pos;
for( pos = fixedDOFIndex.begin(); pos != fixedDOFIndex.end(); ++pos )
for( pos = fixedDOFIndex.begin(); pos != fixedDOFIndex.end(); ++pos ) {
t->addTarget( *pos );
}
t->setUnit( TranslationUnit::MM() );
Direction d;
d.setNullX();
......@@ -252,8 +256,9 @@ void GenerateModel::saveMMLFiles( QString baseFilename ) {
if (fixedDOFIndex.size()>0 && property( "Selection Is Constrained" ).toBool() ) {
StructuralComponent *fixedDof = new StructuralComponent( pml, "Fixed Dof" );
std::set<int>::const_iterator pos;
for( pos = fixedDOFIndex.begin(); pos != fixedDOFIndex.end(); ++pos )
for( pos = fixedDOFIndex.begin(); pos != fixedDOFIndex.end(); ++pos ) {
fixedDof->addStructure( pml->getAtom( *pos ) );
}
pml->getInformativeComponents()->addSubComponent( fixedDof );
}
......@@ -264,7 +269,8 @@ void GenerateModel::saveMMLFiles( QString baseFilename ) {
Application::open( mmlFilename );
}
else
else {
QMessageBox::warning(NULL,"Generating Error", "Problem while generating the model<br/>Sofa Simulator not supported");
}
}
......@@ -241,8 +241,9 @@ void CreateSC::updateCorners(PMLComponent * pmlComponent) {
double cellBounds[6];
bool cellBoundsIsNotEmpty = computeBoundsOfSelection(pmlComponent, "Selected Cells", cellBounds);
boundsInitialized = boundsInitialized || cellBoundsIsNotEmpty;
if (cellBoundsIsNotEmpty)
if (cellBoundsIsNotEmpty) {
mergeBounds(cellBounds, bounds);
}