Skip to content

Commit

Permalink
Set clang-format cpp style to modern C++ (f3d-app#1473)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk authored Jun 19, 2024
1 parent ca6bdfe commit 8c007af
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ ColumnLimit: 100
# For your commits to be compatible with clang 3.8
# you are best off running clang-format 3.8 on your
# system
Standard: Cpp03
Standard: Cpp11
...
2 changes: 1 addition & 1 deletion application/F3DOptionsParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ void ConfigurationOptions::PrintHelpPair(
//----------------------------------------------------------------------------
void ConfigurationOptions::PrintHelp(const cxxopts::Options& cxxOptions)
{
const std::vector<std::pair<std::string, std::string> > examples = {
const std::vector<std::pair<std::string, std::string>> examples = {
{ this->ExecutableName + " file.vtu -xtgans",
"View a unstructured mesh in a typical nice looking sciviz style" },
{ this->ExecutableName + " file.glb -tuqap --hdri-file=file.hdr --hdri-ambient --hdri-skybox",
Expand Down
2 changes: 1 addition & 1 deletion application/F3DStarter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class F3DStarter::F3DInternals
const std::regex escapedVarRe(escapedVar);
const std::regex substVarRe(substVar);

std::vector<std::pair<std::string, bool> > fragments;
std::vector<std::pair<std::string, bool>> fragments;
const auto callback = [&](const std::string& m)
{
if (std::regex_match(m, escapedVarRe))
Expand Down
6 changes: 3 additions & 3 deletions library/plugin/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class plugin
{
public:
plugin(const std::string& name, const std::string& desc, const std::string& vers,
const std::vector<std::shared_ptr<reader> >& readers)
const std::vector<std::shared_ptr<reader>>& readers)
: Name(name)
, Description(desc)
, Version(vers)
Expand Down Expand Up @@ -61,7 +61,7 @@ class plugin
/**
* Get the list of readers created by this plugin
*/
const std::vector<std::shared_ptr<reader> >& getReaders()
const std::vector<std::shared_ptr<reader>>& getReaders()
{
return this->Readers;
}
Expand All @@ -85,7 +85,7 @@ class plugin
std::string Name;
std::string Description;
std::string Version;
std::vector<std::shared_ptr<reader> > Readers;
std::vector<std::shared_ptr<reader>> Readers;
std::string Origin = "undefined";
};

Expand Down
2 changes: 1 addition & 1 deletion library/public/interactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class F3D_EXPORT interactor
/**
* Get a structure of strings describing default interactions.
*/
static const std::vector<std::pair<std::string, std::string> >& getDefaultInteractionsInfo();
static const std::vector<std::pair<std::string, std::string>>& getDefaultInteractionsInfo();

protected:
//! @cond
Expand Down
5 changes: 2 additions & 3 deletions library/src/image.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ image& image::operator=(const image& img) noexcept
}

//----------------------------------------------------------------------------
image::image(image&& img) noexcept : Internals(nullptr)
image::image(image&& img) noexcept
: Internals(nullptr)
{
std::swap(this->Internals, img.Internals);
}
Expand Down Expand Up @@ -512,11 +513,9 @@ const f3d::image& image::toTerminalText(std::ostream& stream) const
};

constexpr std::string_view EMPTY_BLOCK = " ";
// clang-format off
constexpr std::string_view TOP_BLOCK = u8"\u2580";
constexpr std::string_view BOTTOM_BLOCK = u8"\u2584";
constexpr std::string_view FULL_BLOCK = u8"\u2588";
// clang-format on
constexpr std::string_view EOL = "\n";

for (int y = 0; y < height; y += 2)
Expand Down
2 changes: 1 addition & 1 deletion library/src/interactor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace f3d
{
const std::vector<std::pair<std::string, std::string> >& interactor::getDefaultInteractionsInfo()
const std::vector<std::pair<std::string, std::string>>& interactor::getDefaultInteractionsInfo()
{
// clang-format off
static const std::vector<std::pair<std::string, std::string> > DefaultInteractionsInfo{
Expand Down
2 changes: 1 addition & 1 deletion library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ class interactor_impl::internals
vtkNew<vtkRenderWindowInteractor> VTKInteractor;
vtkNew<vtkF3DInteractorStyle> Style;
vtkSmartPointer<vtkF3DInteractorEventRecorder> Recorder;
std::map<unsigned long, std::pair<int, std::function<void()> > > TimerCallBacks;
std::map<unsigned long, std::pair<int, std::function<void()>>> TimerCallBacks;

vtkNew<vtkCellPicker> CellPicker;
vtkNew<vtkPointPicker> PointPicker;
Expand Down
12 changes: 6 additions & 6 deletions library/src/options.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class options::internals
{
public:
using OptionVariant =
std::variant<bool, int, double, std::string, std::vector<int>, std::vector<double> >;
std::variant<bool, int, double, std::string, std::vector<int>, std::vector<double>>;

template<typename T, typename U>
struct IsTypeValid;

template<typename T, typename... Ts>
struct IsTypeValid<T, std::variant<Ts...> > : public std::disjunction<std::is_same<T, Ts>...>
struct IsTypeValid<T, std::variant<Ts...>> : public std::disjunction<std::is_same<T, Ts>...>
{
};

Expand Down Expand Up @@ -390,13 +390,13 @@ std::string options::getAsString(const std::string& name) const
//----------------------------------------------------------------------------
std::vector<int> options::getAsIntVector(const std::string& name) const
{
return this->Internals->get<std::vector<int> >(name);
return this->Internals->get<std::vector<int>>(name);
}

//----------------------------------------------------------------------------
std::vector<double> options::getAsDoubleVector(const std::string& name) const
{
return this->Internals->get<std::vector<double> >(name);
return this->Internals->get<std::vector<double>>(name);
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -426,13 +426,13 @@ std::string& options::getAsStringRef(const std::string& name)
//----------------------------------------------------------------------------
std::vector<int>& options::getAsIntVectorRef(const std::string& name)
{
return this->Internals->getRef<std::vector<int> >(name);
return this->Internals->getRef<std::vector<int>>(name);
}

//----------------------------------------------------------------------------
std::vector<double>& options::getAsDoubleVectorRef(const std::string& name)
{
return this->Internals->getRef<std::vector<double> >(name);
return this->Internals->getRef<std::vector<double>>(name);
}

//----------------------------------------------------------------------------
Expand Down
18 changes: 9 additions & 9 deletions plugins/assimp/module/vtkF3DAssimpImporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -865,19 +865,19 @@ class vtkF3DAssimpImporter::vtkInternals
Assimp::Importer Importer;
const aiScene* Scene = nullptr;
std::string Description;
std::vector<vtkSmartPointer<vtkPolyData> > Meshes;
std::vector<vtkSmartPointer<vtkProperty> > Properties;
std::vector<vtkSmartPointer<vtkTexture> > EmbeddedTextures;
std::vector<vtkSmartPointer<vtkPolyData>> Meshes;
std::vector<vtkSmartPointer<vtkProperty>> Properties;
std::vector<vtkSmartPointer<vtkTexture>> EmbeddedTextures;
vtkIdType ActiveAnimation = 0;
std::vector<std::pair<std::string, vtkSmartPointer<vtkLight> > > Lights;
std::vector<std::pair<std::string, vtkSmartPointer<vtkLight>>> Lights;
std::vector<
std::pair<std::string, std::pair<vtkSmartPointer<vtkCamera>, vtkSmartPointer<vtkCamera> > > >
std::pair<std::string, std::pair<vtkSmartPointer<vtkCamera>, vtkSmartPointer<vtkCamera>>>>
Cameras;
vtkIdType ActiveCameraIndex = -1;
std::unordered_map<std::string, vtkSmartPointer<vtkActorCollection> > NodeActors;
std::unordered_map<std::string, vtkSmartPointer<vtkMatrix4x4> > NodeLocalMatrix;
std::unordered_map<std::string, vtkSmartPointer<vtkMatrix4x4> > NodeTRSMatrix;
std::unordered_map<std::string, vtkSmartPointer<vtkMatrix4x4> > NodeGlobalMatrix;
std::unordered_map<std::string, vtkSmartPointer<vtkActorCollection>> NodeActors;
std::unordered_map<std::string, vtkSmartPointer<vtkMatrix4x4>> NodeLocalMatrix;
std::unordered_map<std::string, vtkSmartPointer<vtkMatrix4x4>> NodeTRSMatrix;
std::unordered_map<std::string, vtkSmartPointer<vtkMatrix4x4>> NodeGlobalMatrix;
vtkF3DAssimpImporter* Parent;
};

Expand Down
4 changes: 2 additions & 2 deletions plugins/draco/module/vtkF3DDracoReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class vtkF3DDracoReader::vtkInternals
}

template<typename T>
static vtkSmartPointer<vtkAOSDataArrayTemplate<T> > FillArray(
static vtkSmartPointer<vtkAOSDataArrayTemplate<T>> FillArray(
int nbPoints, draco::PointAttribute* attribute)
{
vtkNew<vtkAOSDataArrayTemplate<T> > arr;
vtkNew<vtkAOSDataArrayTemplate<T>> arr;

arr->SetNumberOfComponents(attribute->num_components());
arr->SetNumberOfTuples(nbPoints);
Expand Down
2 changes: 1 addition & 1 deletion plugins/occt/module/vtkF3DOCCTReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class vtkF3DOCCTReader::vtkInternals
}
}

std::unordered_map<int, vtkSmartPointer<vtkPolyData> > ShapeMap;
std::unordered_map<int, vtkSmartPointer<vtkPolyData>> ShapeMap;
Handle(XCAFDoc_ShapeTool) ShapeTool;
#endif

Expand Down
8 changes: 4 additions & 4 deletions plugins/usd/module/vtkF3DUSDImporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1167,10 +1167,10 @@ class vtkF3DUSDImporter::vtkInternals
pxr::UsdStageRefPtr Stage = nullptr;

private:
std::unordered_map<std::string, vtkSmartPointer<vtkActor> > ActorMap;
std::unordered_map<std::string, vtkSmartPointer<vtkPolyData> > MeshMap;
std::unordered_map<std::string, vtkSmartPointer<vtkProperty> > ShaderMap;
std::unordered_map<std::string, vtkSmartPointer<vtkImageData> > TextureMap;
std::unordered_map<std::string, vtkSmartPointer<vtkActor>> ActorMap;
std::unordered_map<std::string, vtkSmartPointer<vtkPolyData>> MeshMap;
std::unordered_map<std::string, vtkSmartPointer<vtkProperty>> ShaderMap;
std::unordered_map<std::string, vtkSmartPointer<vtkImageData>> TextureMap;
double CurrentTime = 0.0;

class DiagDelegate : public pxr::TfDiagnosticMgr::Delegate
Expand Down
8 changes: 4 additions & 4 deletions python/F3DPythonBindings.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ PYBIND11_MODULE(pyf3d, module)
.def_static("text_distance", &f3d::utils::textDistance);

// f3d::interactor
py::class_<f3d::interactor, std::unique_ptr<f3d::interactor, py::nodelete> > interactor(
py::class_<f3d::interactor, std::unique_ptr<f3d::interactor, py::nodelete>> interactor(
module, "Interactor");
interactor //
.def("toggle_animation", &f3d::interactor::toggleAnimation, "Toggle the animation")
Expand Down Expand Up @@ -246,7 +246,7 @@ PYBIND11_MODULE(pyf3d, module)
.def_readwrite("face_indices", &f3d::mesh_t::face_indices);

// f3d::loader
py::class_<f3d::loader, std::unique_ptr<f3d::loader, py::nodelete> > loader(module, "Loader");
py::class_<f3d::loader, std::unique_ptr<f3d::loader, py::nodelete>> loader(module, "Loader");
loader //
.def("has_geometry_reader", &f3d::loader::hasGeometryReader)
.def("load_geometry", py::overload_cast<const std::string&, bool>(&f3d::loader::loadGeometry),
Expand All @@ -257,7 +257,7 @@ PYBIND11_MODULE(pyf3d, module)
"Load a surfacic mesh from memory", py::arg("mesh"), py::arg("reset") = false);

// f3d::camera
py::class_<f3d::camera, std::unique_ptr<f3d::camera, py::nodelete> > camera(module, "Camera");
py::class_<f3d::camera, std::unique_ptr<f3d::camera, py::nodelete>> camera(module, "Camera");
camera //
.def_property(
"position", [](f3d::camera& cam) { return cam.getPosition(); }, &f3d::camera::setPosition)
Expand Down Expand Up @@ -291,7 +291,7 @@ PYBIND11_MODULE(pyf3d, module)
.def_readwrite("angle", &f3d::camera_state_t::angle);

// f3d::window
py::class_<f3d::window, std::unique_ptr<f3d::window, py::nodelete> > window(module, "Window");
py::class_<f3d::window, std::unique_ptr<f3d::window, py::nodelete>> window(module, "Window");

py::enum_<f3d::window::Type>(window, "Type")
.value("NONE", f3d::window::Type::NONE)
Expand Down
12 changes: 6 additions & 6 deletions vtkext/private/module/vtkF3DGenericImporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,10 @@ void vtkF3DGenericImporter::UpdateTimeStep(double timestep)
}

//----------------------------------------------------------------------------
std::vector<std::pair<vtkActor*, vtkPolyDataMapper*> >
std::vector<std::pair<vtkActor*, vtkPolyDataMapper*>>
vtkF3DGenericImporter::GetGeometryActorsAndMappers()
{
std::vector<std::pair<vtkActor*, vtkPolyDataMapper*> > actorsAndMappers(
std::vector<std::pair<vtkActor*, vtkPolyDataMapper*>> actorsAndMappers(
this->Pimpl->Readers.size());

std::transform(this->Pimpl->Readers.cbegin(), this->Pimpl->Readers.cend(),
Expand All @@ -422,10 +422,10 @@ vtkF3DGenericImporter::GetGeometryActorsAndMappers()
}

//----------------------------------------------------------------------------
std::vector<std::pair<vtkActor*, vtkPointGaussianMapper*> >
std::vector<std::pair<vtkActor*, vtkPointGaussianMapper*>>
vtkF3DGenericImporter::GetPointSpritesActorsAndMappers()
{
std::vector<std::pair<vtkActor*, vtkPointGaussianMapper*> > actorsAndMappers(
std::vector<std::pair<vtkActor*, vtkPointGaussianMapper*>> actorsAndMappers(
this->Pimpl->Readers.size());

std::transform(this->Pimpl->Readers.cbegin(), this->Pimpl->Readers.cend(),
Expand All @@ -437,10 +437,10 @@ vtkF3DGenericImporter::GetPointSpritesActorsAndMappers()
}

//----------------------------------------------------------------------------
std::vector<std::pair<vtkVolume*, vtkSmartVolumeMapper*> >
std::vector<std::pair<vtkVolume*, vtkSmartVolumeMapper*>>
vtkF3DGenericImporter::GetVolumePropsAndMappers()
{
std::vector<std::pair<vtkVolume*, vtkSmartVolumeMapper*> > propsAndMappers(
std::vector<std::pair<vtkVolume*, vtkSmartVolumeMapper*>> propsAndMappers(
this->Pimpl->Readers.size());

std::transform(this->Pimpl->Readers.cbegin(), this->Pimpl->Readers.cend(),
Expand Down
8 changes: 4 additions & 4 deletions vtkext/private/module/vtkF3DGenericImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class vtkF3DGenericImporter : public vtkImporter
* Access to actors vectors. They all have the same size, which correspond to the number
* of added internal readers.
*/
std::vector<std::pair<vtkActor*, vtkPolyDataMapper*> > GetGeometryActorsAndMappers();
std::vector<std::pair<vtkActor*, vtkPointGaussianMapper*> > GetPointSpritesActorsAndMappers();
std::vector<std::pair<vtkVolume*, vtkSmartVolumeMapper*> > GetVolumePropsAndMappers();
std::vector<std::pair<vtkActor*, vtkPolyDataMapper*>> GetGeometryActorsAndMappers();
std::vector<std::pair<vtkActor*, vtkPointGaussianMapper*>> GetPointSpritesActorsAndMappers();
std::vector<std::pair<vtkVolume*, vtkSmartVolumeMapper*>> GetVolumePropsAndMappers();
///@}

/**
Expand All @@ -87,7 +87,7 @@ class vtkF3DGenericImporter : public vtkImporter
std::string Name;
int MaximumNumberOfComponents = 0;
std::vector<std::string> ComponentNames;
std::vector<std::array<double, 2> > ComponentRanges;
std::vector<std::array<double, 2>> ComponentRanges;
std::array<double, 2> MagnitudeRange = { std::numeric_limits<float>::max(),
std::numeric_limits<float>::min() };
std::vector<vtkDataArray*> Arrays;
Expand Down
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DWin32OutputWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void vtkF3DWin32OutputWindow::DisplayText(const char* text)
std::string str(text);
str = std::regex_replace(str, std::regex("\n"), "\r\n");

std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::wstring wstr = converter.from_bytes(str);
wstr += L"\r\n";

Expand Down
3 changes: 1 addition & 2 deletions webassembly/F3DEmscriptenBindings.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ EMSCRIPTEN_BINDINGS(f3d)
.function("resetCamera", &resetCamera, emscripten::allow_raw_pointers());

// f3d::interactor
emscripten::class_<f3d::interactor>("Interactor")
.function("start", &f3d::interactor::start);
emscripten::class_<f3d::interactor>("Interactor").function("start", &f3d::interactor::start);

// f3d::engine
emscripten::class_<f3d::engine> engine("Engine");
Expand Down
2 changes: 1 addition & 1 deletion winshellext/F3DShellExtension.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void RunOnJSONExtensions(fs::path modulePath, F callback)
{
std::wstring ret = L".";

std::wstring_convert<std::codecvt_utf8<wchar_t> > toUnicode;
std::wstring_convert<std::codecvt_utf8<wchar_t>> toUnicode;
ret += toUnicode.from_bytes(e.get<std::string>());

callback(ret);
Expand Down

0 comments on commit 8c007af

Please sign in to comment.