From 395bf92486f42e2bb55e22e3dc3836814811ce41 Mon Sep 17 00:00:00 2001 From: iasonmanolas Date: Tue, 12 Jul 2022 13:12:33 +0300 Subject: [PATCH] Refactoring --- simulationmesh.cpp | 43 +++++++++++++++++++++++++++++++------------ simulationmesh.hpp | 7 +++++++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/simulationmesh.cpp b/simulationmesh.cpp index 8434c7f..b7f95d3 100755 --- a/simulationmesh.cpp +++ b/simulationmesh.cpp @@ -253,6 +253,23 @@ void SimulationMesh::updateElementalFrames() { } } +#ifdef POLYSCOPE_DEFINED +polyscope::CurveNetwork *SimulationMesh::registerForDrawing( + const std::optional> &desiredColor, const bool &shouldEnable) +{ + const double drawingRadius = getBeamDimensions()[0].b + / (std::sqrt( + 2.0)); //polyscope can only draw a circular cross section + // std::cout << __FUNCTION__ << " revert this" << std::endl; + return VCGEdgeMesh::registerForDrawing(desiredColor, /*0.08*/ drawingRadius, shouldEnable); +} + +void SimulationMesh::unregister() const +{ + VCGEdgeMesh::unregister(); +} +#endif + void SimulationMesh::setBeamCrossSection( const CrossSectionType &beamDimensions) { for (size_t ei = 0; ei < EN(); ei++) { @@ -268,20 +285,22 @@ void SimulationMesh::setBeamMaterial(const double &pr, const double &ym) { } } -std::vector SimulationMesh::getBeamDimensions() { - std::vector beamDimensions(EN()); - for (size_t ei = 0; ei < EN(); ei++) { - beamDimensions[ei] = elements[ei].dimensions; - } - return beamDimensions; +std::vector SimulationMesh::getBeamDimensions() +{ + std::vector beamDimensions(EN()); + for (size_t ei = 0; ei < EN(); ei++) { + beamDimensions[ei] = elements[ei].dimensions; + } + return beamDimensions; } -std::vector SimulationMesh::getBeamMaterial() { - std::vector beamMaterial(EN()); - for (size_t ei = 0; ei < EN(); ei++) { - beamMaterial[ei] = elements[ei].material; - } - return beamMaterial; +std::vector SimulationMesh::getBeamMaterial() +{ + std::vector beamMaterial(EN()); + for (size_t ei = 0; ei < EN(); ei++) { + beamMaterial[ei] = elements[ei].material; + } + return beamMaterial; } bool SimulationMesh::load(const std::string &plyFilename) diff --git a/simulationmesh.hpp b/simulationmesh.hpp index d6c8d57..5ac43cb 100755 --- a/simulationmesh.hpp +++ b/simulationmesh.hpp @@ -59,6 +59,13 @@ public: void reset(); SimulationMesh(); void updateElementalFrames(); + +#ifdef POLYSCOPE_DEFINED + polyscope::CurveNetwork *registerForDrawing( + const std::optional> &desiredColor = std::nullopt, + const bool &shouldEnable = true); + void unregister() const; +#endif }; struct Element {