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

support cross clang 11 and gcc 9 + fixed all warnings

* clang now supported (but still not in CI)
* (nearly) gcc 9 and clang 11 warnings fixed
* fixed all CMake warnings (in CamiTK CE + generated CEP)
* include a new mechanisms to suppress extra warnings on
  external headers (namely VTK) with clang while keeping
  all internal warning (see CamiTKDisableWarnings for more
  information
* On Linux, you can now build CamiTK CE with clang or gcc
  and (independently) develop your CEP with clang or gcc
parent 31537939
......@@ -3,7 +3,7 @@
# CamiTK Community Edition CEP Set
#
#--------------------------------------------
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.13)
project(camitkcommunityedition)
......@@ -33,17 +33,11 @@ camitk_communityedition_packaging()
# Configure include-what-you-use to check the current target
include(camitk/test/CamiTKIncludeWhatYouUse)
# CamiTK requires C++11
if(${CMAKE_VERSION} VERSION_LESS "3.1.3")
# On MSVC C++11 is the default
if(UNIX)
# CMAKE_CXX_STANDARD not available for cmake 3.0.2 (as in debian old stable)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
else()
# All target after this declaration will be compile with c++11 policy
set(CMAKE_CXX_STANDARD 11)
endif()
# CamiTK requires C++17
# All target after this declaration will be compile with c++17 policy
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # for wider compatibility across plateforms and compiler
# Specific to SDK: first compile the SDK (it looks like a CEP but is sooooo special...)
add_subdirectory(sdk)
......
......@@ -33,7 +33,7 @@ if(SOFA_SUPPORT)
file(STRINGS ${SOFA_BUILD_DIR}/CMakeCache.txt SOFA_SOURCE_DIR_LINE REGEX "^Sofa_SOURCE_DIR:STATIC=(.*)$")
# 2. Use a regex to extract the path from the line
string(REGEX REPLACE "^Sofa_SOURCE_DIR:STATIC=(.*)$" "\\1" SOFA_SOURCE_DIR "${SOFA_SOURCE_DIR_LINE}")
message("Detected sofa source directory is ${SOFA_SOURCE_DIR}")
message(STATUS "Detected sofa source directory is ${SOFA_SOURCE_DIR}")
add_definitions(-DSOFA_SVN)
endif()
......
......@@ -75,7 +75,7 @@ if(SOFA_SUPPORT)
file(STRINGS ${SOFA_BUILD_DIR}/CMakeCache.txt SOFA_SOURCE_DIR_LINE REGEX "^Sofa_SOURCE_DIR:STATIC=(.*)$")
# 2. Use a regex to extract the path from the line
string(REGEX REPLACE "^Sofa_SOURCE_DIR:STATIC=(.*)$" "\\1" SOFA_SOURCE_DIR "${SOFA_SOURCE_DIR_LINE}")
message("Detected Sofa ${MML_SOFA_STABLE} source directory is ${SOFA_SOURCE_DIR}")
message(STATUS "Detected Sofa ${MML_SOFA_STABLE} source directory is ${SOFA_SOURCE_DIR}")
# fill the list of needed libraries
# the only way to find the required lib is to hack the files generated by cmake:
......
......@@ -52,7 +52,7 @@ public:
/// Method must be reimplemented when an ActionExtension is done,
/// the own actions of an extension are load there.
/// It is necessary to use the method Application::addAction(Action) for each action added in this method.
virtual void init();
virtual void init() override;
/// Method that return the action extension name
virtual QString getName() override {
......
......@@ -71,7 +71,7 @@ bool CreateSC::event(QEvent* e) {
// if the user change the boolean properties, update bounds
PMLComponent* pmlComponent = dynamic_cast<PMLComponent*>(getTargets().last());
if (pmlComponent != NULL && changeEvent->propertyName() == "Use PML Selection" || changeEvent->propertyName() == "Use Picking Selection") {
if (pmlComponent != nullptr && (changeEvent->propertyName() == "Use PML Selection" || changeEvent->propertyName() == "Use Picking Selection")) {
updateCorners(pmlComponent);
}
......
......@@ -51,7 +51,7 @@ public:
};
/// initialize all the actions
virtual void init();
virtual void init() override;
};
......
......@@ -43,6 +43,14 @@
#include <CellProperties.h>
// VTK stuff
// disable warning generated by clang about the surrounded headers
#include <CamiTKDisableWarnings>
#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkViewport.h>
#include <CamiTKReEnableWarnings>
#include<vtkUnstructuredGrid.h>
#include <vtkCellArray.h>
#include <vtkCell.h>
......@@ -57,12 +65,8 @@
#include <vtkVertex.h>
#include <vtkPolyVertex.h>
#include <vtkProp.h>
#include <vtkDataSetMapper.h>
#include <vtkProperty.h>
#include <vtkPolyDataMapper.h>
#include <vtkSphereSource.h>
#include <vtkGlyph3D.h>
#include <vtkViewport.h>
#include <vtkSelection.h>
#include <vtkDoubleArray.h>
#include <vtkDataSetAttributes.h>
......
......@@ -57,8 +57,12 @@ class AbortException;
#include "PMLComponentAPI.h"
// VTK includes
#include <vtkSelectionNode.h>
// disable warning generated by clang about the surrounded headers
#include <CamiTKDisableWarnings>
#include <vtkExtractSelection.h>
#include <CamiTKReEnableWarnings>
#include <vtkSelectionNode.h>
namespace std {
/** As the PhysicalModel atom index can be different to the node index (continuity in id is not mandatory in PML)
......
......@@ -198,7 +198,7 @@ bool PMLComponentExtension::save(camitk::Component* component) const {
vtkSmartPointer<vtkAbstractArray> idArray;
std::string selName;
for (int i = 0; i < meshComp->getNumberOfSelections(); i++) {
for (unsigned int i = 0; i < meshComp->getNumberOfSelections(); i++) {
// TODO : test if it is a cell selection
selName = meshComp->getSelectionAt(i)->GetSelectionList()->GetName();
scinf = new StructuralComponent(newPM, selName);
......
......@@ -46,7 +46,7 @@ void TargetList::add(const unsigned int index) {
#define isDigit(c) ((c)>='0' && (c)<='9')
void TargetList::add(const std::string s) {
size_t begin, end, len, i, j;
int begin, end, len, i, j;
// inits
len = s.size();
......
......@@ -64,7 +64,7 @@ public:
StoppingCriterion* getChild(const unsigned int i) override;
/// get stopping criterion name
std::string getName() = 0;
std::string getName() override = 0;
/// get Method Name
std::string getMethodString();
......
......@@ -94,7 +94,7 @@ endif()
# +---------------------+
# | ARTISYNTH SUPPORT |
# +---------------------+
set(MML_ARTISYNTH_BIN $ENV{MML_ARTISYNTH_BIN} CACHE FILE "Where to find artisynth binary")
set(MML_ARTISYNTH_BIN $ENV{MML_ARTISYNTH_BIN} CACHE PATH "Where to find artisynth binary")
set(MML_ARTISYNTH_WORKING_DIR $ENV{MML_ARTISYNTH_WORKING_DIR} CACHE PATH "Specify a folder for artisynth working files")
if((EXISTS ${MML_ARTISYNTH_BIN}) AND (EXISTS ${MML_ARTISYNTH_WORKING_DIR}))
# Compile ARTISYNTH simulator files (ON or OFF)
......
......@@ -45,11 +45,11 @@ public:
~InteractiveSimulator() override = default;
/// initialize the simulator
void init() = 0;
void init() override = 0;
/// end simultor
void end() = 0;
void end() override = 0;
/// get current position for one atom
void getPosition(int index, double position[3]) = 0;
void getPosition(int index, double position[3]) override = 0;
/**
* ask the simulator do to one step of the simulation
......@@ -58,7 +58,7 @@ public:
virtual void doMove(double dt) = 0;
/// Create a pml file from an imput file
void createPml(const char* inputFile, const char* pmlFile) = 0;
void createPml(const char* inputFile, const char* pmlFile) override = 0;
};
#endif // SIMULATOR_INTERACTIVESIMULATOR_H
......@@ -22,11 +22,11 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
// Stopping criteria includes
#include "MinThreshold.h"
// -------------------- constructor --------------------
MinThreshold::MinThreshold(mml::MinThreshold* m): Method(m), mappedObject(m) {
MinThreshold::MinThreshold(mml::MinThreshold* m): Method(m) {
value = m->minValue();
}
......
......@@ -56,8 +56,6 @@ public:
private:
/// value of the threshold
double value;
/// the xsdcxx object representing MinThreshold, used for serialization
mml::MinThreshold* mappedObject;
};
#endif // STOPPINGCRITERION_STOPPINGCRITERIA_METHODS_MINTHRESHOLD_H
......@@ -53,7 +53,7 @@ public:
~MultipleCriterion() override;
/// return true if the MultipleCriterion is reach
bool checkCriterion() = 0;
bool checkCriterion() override = 0;
/// get number of childre; return -1 for non multiple criteria
int getNumberOfChildren() override;
......@@ -62,7 +62,7 @@ public:
StoppingCriterion* getChild(const unsigned int i) override;
/// get stopping criterion name
std::string getName() = 0;
std::string getName() override = 0;
/// add child
void addChild(StoppingCriterion* sc);
......
......@@ -45,11 +45,11 @@ public:
~NonInteractiveSimulator() override = default;
/// initialize simulator
void init() = 0;
void init() override = 0;
/// end simultor
void end() = 0;
void end() override = 0;
/// get current position for one atom (use parameters)
void getPosition(int index, double position[3]) = 0;
void getPosition(int index, double position[3]) override = 0;
/** make entire simulation ans store results of all step
* @return true if calculation succeded
......@@ -61,7 +61,7 @@ public:
virtual int getMaxStep() = 0;
/// Create a pml file from an imput file
void createPml(const char* inputFile, const char* pmlFile) = 0;
void createPml(const char* inputFile, const char* pmlFile) override = 0;
......
......@@ -26,7 +26,7 @@
#include "Threshold.h"
// -------------------- constructor --------------------
Threshold::Threshold(mml::Threshold* m): Method(m), mappedObject(m) {
Threshold::Threshold(mml::Threshold* m): Method(m) {
value = m->maxValue();
}
......
......@@ -57,9 +57,6 @@ public:
private:
/// value of the threshold
double value;
/// the xsdcxx object representing Threshold, used for serialization
mml::Threshold* mappedObject;
};
#endif // STOPPINGCRITERION_STOPPINGCRITERIA_METHODS_THRESHOLD_H
......@@ -26,7 +26,7 @@
#include "TimePeriodThreshold.h"
// -------------------- constructor --------------------
TimePeriodThreshold::TimePeriodThreshold(mml::TimePeriodThreshold* m): Method(m), mappedObject(m) {
TimePeriodThreshold::TimePeriodThreshold(mml::TimePeriodThreshold* m): Method(m) {
value = m->minValue();
iterations = m->iterations();
increment = iterations;
......
......@@ -64,10 +64,6 @@ private:
/// Needed to keep an eye on consecutive win
int increment;
/// the xsdcxx object representing TimePeriodThreshold, used for serialization
mml::TimePeriodThreshold* mappedObject;
};
#endif // STOPPINGCRITERION_STOPPINGCRITERIA_METHODS_TIMEPERIODTHRESHOLD_H
......@@ -73,7 +73,19 @@ public:
* list of composing SC, then a cellRef tag is printed (otherwise the list
* of atom is printed).
*/
// as Cell inherits both Structure and StructuralComponent, it is correct to override
// the xmlPrint in StructuralComponent while reimplementing xmlPrint from Structure
#if defined(__has_warning)
# pragma GCC diagnostic push
# if __has_warning("-Woverloaded-virtual")
# pragma GCC diagnostic ignored "-Woverloaded-virtual"
# endif
#endif
void xmlPrint(std::ostream&, const StructuralComponent*) override;
#if defined(__has_warning)
# pragma GCC diagnostic pop
#endif
/** return true only if the parameter is equal to "MultiComponent" */
bool isInstanceOf(const char*) const override;
......
......@@ -42,17 +42,17 @@ public:
virtual ~ShowFrame() = default;
/// update the property visibility
virtual QWidget* getWidget();
virtual QWidget* getWidget() override;
/// manage change immediatly
virtual bool event(QEvent* e);
virtual bool event(QEvent* e) override;
/// Get the corresponding QAction (overriden to update the checked status)
QAction* getQAction(camitk::Component* target = nullptr) override;
public slots:
/// show/hide the frame depending on the user choice
virtual camitk::Action::ApplyStatus apply();
virtual camitk::Action::ApplyStatus apply() override;
private:
// block auto update during UI refresh
......
......@@ -69,9 +69,9 @@ void ImageLutModel::updateHistogram() {
int* dims = image->GetDimensions();
//-- build histogram
for (unsigned int i = 0; i < dims[0]; i++) {
for (unsigned int j = 0; j < dims[1]; j++) {
for (unsigned int k = 0; k < dims[2]; k++) {
for (unsigned int i = 0; i < (unsigned) dims[0]; i++) {
for (unsigned int j = 0; j < (unsigned) dims[1]; j++) {
for (unsigned int k = 0; k < (unsigned) dims[2]; k++) {
// using component 0 (== red in case of a color image)
greyLevels[getBinIndex(image->GetScalarComponentAsDouble(i,j,k,0))] += 1.0;
}
......@@ -89,7 +89,7 @@ void ImageLutModel::updateHistogram() {
// ---------------------------- getBinValue ----------------------------
double ImageLutModel::getBinValue(int index) {
if (index >=0 && index<nbHistoBins) {
if (index >=0 && index<(int)nbHistoBins) {
return greyLevels[index];
}
else {
......@@ -110,7 +110,7 @@ int ImageLutModel::getBinIndex(double value) {
index = 0;
}
else {
if (index >= nbHistoBins) {
if (index >= (int) nbHistoBins) {
index = nbHistoBins - 1;
}
}
......@@ -149,7 +149,7 @@ int ImageLutModel::getNumberOfBins() {
// ---------------------------- setNumberOfBins ----------------------------
void ImageLutModel::setNumberOfBins(int binCount) {
if (binCount != nbHistoBins) {
if (binCount != (int) nbHistoBins) {
nbHistoBins = std::min((unsigned) binCount, (unsigned) abs(maxValue - minValue + 1));
updateHistogram();
}
......
......@@ -313,7 +313,7 @@ void ImageLutWidget::drawGraphics() {
pen.setColor(histogramPen);
brush.setColor(histogramBrush);
pen.setWidthF(barPenSize);
for (unsigned int i = 0; i < model->getNumberOfBins(); i++) {
for (unsigned int i = 0; i < (unsigned) model->getNumberOfBins(); i++) {
QPointF a(QPointF(i*barWidth, height) - penAdjust);
QPointF b(QPointF((i+1)*barWidth, height - model->getBinValue(i)*yScale) - penAdjust);
ui.histogramGraphicsView->scene()->addRect(QRectF(a,b), pen, brush);
......
......@@ -30,8 +30,12 @@
#include <Log.h>
// Vtk includes
// disable warning generated by clang about the surrounded headers
#include <CamiTKDisableWarnings>
#include <vtkImageShiftScale.h>
#include <CamiTKReEnableWarnings>
#include <vtkCallbackCommand.h>
#include "vtkImageShiftScale.h"
#include <vtkImageResample.h>
using namespace camitk;
......
......@@ -187,7 +187,7 @@ void MultiPickingWidget::removeSeedNumber(int i, int j) {
break;
case VIEW_TABLE_INDEX:
point = pPM->getPixelIndexList()->at(ui.pointsTableWidget->currentRow());
img->pixelPicked(point.x() * spacing[0], point.y() * spacing[1], point.z() * spacing[2], img->getAxialSlices());//Need here the voxel coordinates (not voxel index, not voxel world coordinates)
img->pixelPicked(point.x() * spacing[0], point.y() * spacing[1], point.z() * spacing[2]);// the voxel coordinates ar needed here (not the voxel index, nor the voxel world coordinates)
Application::refresh();
break;
default:
......@@ -335,7 +335,7 @@ void MultiPickingWidget::manuallyModified(int i, int j) {
// If right pixel, pick the image at this point
// Cheat ! Say that your are its axial slice...
img->getAxialSlices()->setSlice(z);
img->pixelPicked(x, y, z, img->getAxialSlices());
img->pixelPicked(x, y, z);
Application::refresh();
pPM->modifyPixel(i);
......@@ -366,7 +366,7 @@ void MultiPickingWidget::manuallyModified(int i, int j) {
// If right pixel, pick the image at this point
// Cheat ! Say that your are its axial slice...
img->getAxialSlices()->setSlice(z);
img->pixelPicked(x, y, z, img->getAxialSlices());
img->pixelPicked(x, y, z);
Application::refresh();
pPM->modifyPixel(i);
......
......@@ -160,7 +160,6 @@ void PickedPixelMap::savePixelList(QString fileName) {
fileName += ".csv";
}
QVector3D coord2pix;
// write the points in a csv file
// the form is : index (int) | i (int) | j (int) | k (int) | x (double) | y (double) | z (double) |
ofstream myFile;
......
......@@ -32,11 +32,15 @@
#include <MeshComponent.h>
// -- vtk filters stuff
// disable warning generated by clang about the surrounded headers
#include <CamiTKDisableWarnings>
#include <vtkPolyDataWriter.h>
#include <CamiTKReEnableWarnings>
#include <vtkImageResample.h>
#include <vtkContourFilter.h>
#include <vtkPolyDataNormals.h>
#include <vtkPolyDataConnectivityFilter.h>
#include <vtkPolyDataWriter.h>
#include <vtkMarchingCubes.h>
#include <vtkPointSet.h>
#include <vtkCallbackCommand.h>
......
......@@ -42,15 +42,19 @@
#include <QMetaEnum>
// From Vtk
// disable warning generated by clang about the surrounded headers
#include <CamiTKDisableWarnings>
#include <vtkProperty.h>
#include <vtkCaptionActor2D.h>
#include <vtkAnnotatedCubeActor.h>
#include <vtkProperty2D.h>
#include <CamiTKReEnableWarnings>
#include <vtkImageReslice.h>
#include <vtkTransform.h>
#include <vtkAxesActor.h>
#include <vtkCaptionActor2D.h>
#include <vtkTextActor.h>
#include <vtkTextProperty.h>
#include <vtkProperty2D.h>
#include <vtkAnnotatedCubeActor.h>
#include <vtkAssembly.h>
#include <VtkMeshUtil.h>
......
......@@ -46,7 +46,7 @@ public:
virtual ~ShowCoronalSliceIn3D();
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget* getWidget();
virtual QWidget* getWidget() override;
/// Get the corresponding QAction (overriden to update the checked status)
QAction* getQAction(camitk::Component* target = nullptr) override;
......@@ -55,6 +55,6 @@ public slots:
/** this method is automatically called when the action is triggered.
* It gets all the targets' top level component and close them.
*/
virtual camitk::Action::ApplyStatus apply();
virtual camitk::Action::ApplyStatus apply() override;
};
#endif // SHOWCORONALSLICEIN3D_H
......@@ -46,7 +46,7 @@ public:
virtual ~ShowSagittalSliceIn3D();
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget* getWidget();
virtual QWidget* getWidget() override;
/// Get the corresponding QAction (overriden to update the checked status)
QAction* getQAction(camitk::Component* target = nullptr) override;
......@@ -55,6 +55,6 @@ public slots:
/** this method is automatically called when the action is triggered.
* It gets all the targets' top level component and close them.
*/
virtual camitk::Action::ApplyStatus apply();
virtual camitk::Action::ApplyStatus apply() override;
};
#endif // SHOWSAGITTALSLICEIN3D_H
......@@ -33,24 +33,26 @@
#include <Log.h>
// -- vtk stuff --
// disable warning generated by clang about the surrounded headers
#include <CamiTKDisableWarnings>
#include <vtkImageCast.h>
#include <vtkVolume.h>
#include <vtkPiecewiseFunction.h>
#if VTK_MAJOR_VERSION >= 7
#include <vtkFixedPointVolumeRayCastMapper.h>
#else
#include <vtkVolumeRayCastMapper.h>
#include <vtkVolumeRayCastCompositeFunction.h>
#endif
#include <vtkColorTransferFunction.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkVolumeProperty.h>
#include <vtkPolyData.h>
#include <vtkImageMagnitude.h>
#include <CamiTKReEnableWarnings>
#include <vtkPiecewiseFunction.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyData.h>
#include <vtkCellArray.h>
#include <vtkFloatArray.h>
#include <vtkPointData.h>
......
......@@ -63,11 +63,11 @@ public slots:
* \note getTargets() is automatically filtered so that it only contains compatible components,
* i.e., instances of ImageComponent (or a subclass).
*/
virtual camitk::Action::ApplyStatus apply();
virtual camitk::Action::ApplyStatus apply() override;
// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
// A special widget will be displaied to edit colors.
virtual QWidget* getWidget();
virtual QWidget* getWidget() override;
private:
......
......@@ -29,7 +29,11 @@
#include <Log.h>
#include <Application.h>
// disable warning generated by clang about the surrounded headers
#include <CamiTKDisableWarnings>
#include <vtkExtractSelection.h>
#include <CamiTKReEnableWarnings>
#include <vtkCallbackCommand.h>