Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meld #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Meld #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,21 @@ SET( EXTERNAL_LIBS ${FASTSUM_LIBS} )

ADD_DEFINITIONS (${CPREPROCDEFS})

INCLUDE_DIRECTORIES( "src/glad" )
FILE(GLOB IMGUISOURCES "src/imgui/*.cpp" )
INCLUDE_DIRECTORIES( "src/tinyxml2" )
INCLUDE_DIRECTORIES( "src/tinyexpr" )
INCLUDE_DIRECTORIES( "src/cppcodec" )
INCLUDE_DIRECTORIES( "src/miniz" )
INCLUDE_DIRECTORIES( "lib" )
# For some of the GUI libraries who need glad
INCLUDE_DIRECTORIES( "lib/glad" )
# For some of the internal libraries who need nanoflann
INCLUDE_DIRECTORIES( "lib/nanoflann" )
# For some of the internal libraries who need nnls
INCLUDE_DIRECTORIES( "lib/eigen-nnls" )
INCLUDE_DIRECTORIES( "src" )

IF (CMAKE_COMPILER_IS_GNUCXX)
SET_SOURCE_FILES_PROPERTIES("src/imgui/imgui_draw.cpp" PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
ENDIF()

FILE(GLOB HEADERS "src/*.h" )
SET(SOURCES ${HEADERS}
"src/Simulation.cpp"
FILE(GLOB IMGUISOURCES "lib/imgui/*.cpp" )
SET(SOURCES "src/Simulation.cpp"
"src/FlowFeature.cpp"
"src/CollectionHelper.cpp"
"src/BoundaryFeature.cpp"
Expand All @@ -261,13 +261,13 @@ SET(SOURCES ${HEADERS}
"src/IglReadGeom.cpp"
"src/IglRefine.cpp"
"src/StatusFile.cpp"
"src/tinyxml2/tinyxml2.cpp"
"src/tinyexpr/tinyexpr.c" )
SET(GUI_SOURCES "src/glad/glad.c"
"lib/tinyxml2/tinyxml2.cpp"
"lib/tinyexpr/tinyexpr.c" )
SET(GUI_SOURCES "lib/glad/glad.c"
"src/ShaderHelper.cpp"
"src/FeatureDraw.cpp"
"src/miniz/miniz.c"
"src/miniz/FrameBufferToImage.cpp" )
"lib/miniz/miniz.c"
"lib/miniz/FrameBufferToImage.cpp" )

# create a binary for the GUI version
IF( BUILD_GUI )
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "Omega3D.h"

#define TE_NAT_LOG
#include "tinyexpr.h"
#include "json/json.hpp"
#include <tinyexpr/tinyexpr.h>
#include <json/json.hpp>

#include <Eigen/Geometry>

Expand Down
38 changes: 38 additions & 0 deletions src/BoundaryFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ void parse_boundary_json(std::vector<std::unique_ptr<BoundaryFeature>>& _flist,
// and pass the json object to the specific parser
_flist.back()->from_json(_jin);

// finally, generate the draw information
_flist.back()->create();
_flist.back()->generate_draw_geom();

std::cout << " finished " << _flist.back()->to_string() << std::endl;
}

Expand Down Expand Up @@ -150,6 +154,7 @@ bool BoundaryFeature::draw_creation_gui(std::vector<std::unique_ptr<BoundaryFeat
sim.add_body(bp);
}
bf->set_body(bp);
bf->create();
bf->generate_draw_geom();
bfs.emplace_back(std::move(bf));
bf = nullptr;
Expand All @@ -166,6 +171,39 @@ bool BoundaryFeature::draw_creation_gui(std::vector<std::unique_ptr<BoundaryFeat

return created;
}

void BoundaryFeature::draw_feature_list(std::vector<std::unique_ptr<BoundaryFeature>> &feat,
std::unique_ptr<BoundaryFeature> &editingFeat, int &edit_feat_index,
int &del_feat_index, bool &redraw, int &buttonIDs) {
for (int i=0; i<(int)feat.size(); ++i) {
ImGui::PushID(++buttonIDs);
if (ImGui::Checkbox("", feat[i]->addr_enabled())) { redraw = true; }
ImGui::PopID();

// add an "edit" button after the checkbox (so it's not easy to accidentally hit remove)
ImGui::SameLine();
ImGui::PushID(++buttonIDs);
if (ImGui::SmallButton("edit")) {
editingFeat = std::unique_ptr<BoundaryFeature>(feat[i]->copy());
edit_feat_index = i;
}
ImGui::PopID();

if (feat[i]->is_enabled()) {
ImGui::SameLine();
ImGui::Text("%s", feat[i]->to_string().c_str());
} else {
ImGui::SameLine();
ImGui::TextColored(ImVec4(0.5f,0.5f,0.5f,1.0f), "%s", feat[i]->to_string().c_str());
}

// add a "remove" button at the end of the line (so it's not easy to accidentally hit)
ImGui::SameLine();
ImGui::PushID(++buttonIDs);
if (ImGui::SmallButton("remove")) { del_feat_index = i; }
ImGui::PopID();
}
}
#endif

//
Expand Down
25 changes: 8 additions & 17 deletions src/BoundaryFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,34 @@ class BoundaryFeature : public Feature {
float _x,
float _y,
float _z)
: Feature(true),
m_bp(_bp),
m_external(_ext),
m_x(_x),
m_y(_y),
m_z(_z)
: Feature(_x, _y, _z, true, _bp),
m_external(_ext)
{}

virtual ~BoundaryFeature() = default;
virtual BoundaryFeature* copy() const = 0;

std::shared_ptr<Body> get_body() { return m_bp; }

virtual void debug(std::ostream& os) const = 0;
virtual std::string to_string() const = 0;
virtual std::string to_short_string() const = 0;
virtual void from_json(const nlohmann::json) = 0;
virtual nlohmann::json to_json() const = 0;
virtual void create() = 0;
virtual ElementPacket<float> init_elements(const float) const = 0;
//virtual std::vector<float> step_elements(const float) const = 0;
void set_body(std::shared_ptr<Body> _bp) { m_bp = _bp; }
virtual void generate_draw_geom() = 0;
virtual ElementPacket<float> get_draw_packet() { return m_draw; }
#ifdef USE_IMGUI
virtual bool draw_info_gui(const std::string) = 0;
#endif

#ifdef USE_IMGUI
static int obj_movement_gui(int &, char*, char*, char*, char*, char*, char*);
static bool draw_creation_gui(std::vector<std::unique_ptr<BoundaryFeature>> &, Simulation&);
virtual bool draw_info_gui(const std::string) = 0;
static void draw_feature_list(std::vector<std::unique_ptr<BoundaryFeature>> &, std::unique_ptr<BoundaryFeature> &,
int &, int &, bool &, int &);
#endif

protected:
std::shared_ptr<Body> m_bp;
bool m_external;
float m_x;
float m_y;
float m_z;
ElementPacket<float> m_draw;
};

std::ostream& operator<<(std::ostream& os, BoundaryFeature const& ff);
Expand Down
33 changes: 30 additions & 3 deletions src/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
* Feature.h - Parent class to all features
*
* (c)2019-20 Applied Scientific Research, Inc.
* Written by Mark J Stock <[email protected]>
* Mark J Stock <[email protected]>
* Blake B Hillier <[email protected]>
*/

#pragma once

#include "ElementPacket.h"

#include <iostream>
#include <vector>

Expand All @@ -16,16 +19,40 @@
class Feature {
public:
explicit
Feature(bool _enabled)
: m_enabled(_enabled)
Feature(float _x,
float _y,
float _z,
bool _enabled,
std::shared_ptr<Body> _bp)
: m_x(_x),
m_y(_y),
m_enabled(_enabled),
m_bp(_bp)
{}
~Feature() = default;
virtual Feature* copy() const = 0;

virtual void debug(std::ostream &) const = 0;
virtual std::string to_string() const = 0;
virtual void from_json(const nlohmann::json) = 0;
virtual nlohmann::json to_json() const = 0;
virtual ElementPacket<float> init_elements(float) const = 0;
virtual void generate_draw_geom() = 0;

void enable() { m_enabled = true; };
void disable() { m_enabled = false; };
bool is_enabled() const { return m_enabled; };
bool* addr_enabled() { return &m_enabled; };
ElementPacket<float> get_draw_packet() { return m_draw; }
std::shared_ptr<Body> get_body() { return m_bp; }
void set_body(std::shared_ptr<Body> _bp) { m_bp = _bp; }

protected:
float m_x;
float m_y;
float m_z;
bool m_enabled;
std::shared_ptr<Body> m_bp;
ElementPacket<float> m_draw;
};

33 changes: 33 additions & 0 deletions src/FlowFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,39 @@ bool FlowFeature::draw_creation_gui(std::vector<std::unique_ptr<FlowFeature>> &f
ImGui::EndPopup();
return created;
}

void FlowFeature::draw_feature_list(std::vector<std::unique_ptr<FlowFeature>> &feat,
std::unique_ptr<FlowFeature> &editingFeat, int &edit_feat_index,
int &del_feat_index, bool &redraw, int &buttonIDs) {
for (int i=0; i<(int)feat.size(); ++i) {
ImGui::PushID(++buttonIDs);
if (ImGui::Checkbox("", feat[i]->addr_enabled())) { redraw = true; }
ImGui::PopID();

// add an "edit" button after the checkbox (so it's not easy to accidentally hit remove)
ImGui::SameLine();
ImGui::PushID(++buttonIDs);
if (ImGui::SmallButton("edit")) {
editingFeat = std::unique_ptr<FlowFeature>(feat[i]->copy());
edit_feat_index = i;
}
ImGui::PopID();

if (feat[i]->is_enabled()) {
ImGui::SameLine();
ImGui::Text("%s", feat[i]->to_string().c_str());
} else {
ImGui::SameLine();
ImGui::TextColored(ImVec4(0.5f,0.5f,0.5f,1.0f), "%s", feat[i]->to_string().c_str());
}

// add a "remove" button at the end of the line (so it's not easy to accidentally hit)
ImGui::SameLine();
ImGui::PushID(++buttonIDs);
if (ImGui::SmallButton("remove")) { del_feat_index = i; }
ImGui::PopID();
}
}
#endif

//
Expand Down
26 changes: 9 additions & 17 deletions src/FlowFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,29 @@ class FlowFeature : public Feature {
float _y,
float _z,
std::shared_ptr<Body> _bp)
: Feature(true),
m_x(_x),
m_y(_y),
m_z(_z),
m_bp(_bp)
: Feature(_x, _y, _z, true, _bp)
{}
virtual ~FlowFeature() {}
virtual ~FlowFeature() = default;
virtual FlowFeature* copy() const = 0;

std::shared_ptr<Body> get_body() { return m_bp; }

virtual void debug(std::ostream& os) const = 0;
virtual std::string to_string() const = 0;
virtual void from_json(const nlohmann::json) = 0;
virtual nlohmann::json to_json() const = 0;
virtual ElementPacket<float> init_elements(float) const = 0;
virtual ElementPacket<float> step_elements(float) const = 0;
virtual void generate_draw_geom() = 0;
virtual ElementPacket<float> get_draw_packet() { return m_draw; }
#ifdef USE_IMGUI
static bool draw_creation_gui(std::vector<std::unique_ptr<FlowFeature>> &, const float);
virtual bool draw_info_gui(const std::string, const float) = 0;
#endif
// emit particles as vector of float4

protected:
float m_x;
float m_y;
float m_z;
ElementPacket<float> m_draw;
std::shared_ptr<Body> m_bp;
#ifdef USE_IMGUI
static bool draw_creation_gui(std::vector<std::unique_ptr<FlowFeature>> &, const float);
static void draw_feature_list(std::vector<std::unique_ptr<FlowFeature>> &, std::unique_ptr<FlowFeature> &, int &,
int &, bool &, int &);
#endif

// emit particles as vector of float4
};

std::ostream& operator<<(std::ostream& os, FlowFeature const& ff);
Expand Down
33 changes: 33 additions & 0 deletions src/MeasureFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,39 @@ bool MeasureFeature::draw_creation_gui(std::vector<std::unique_ptr<MeasureFeatur
ImGui::EndPopup();
return created;
}

void MeasureFeature::draw_feature_list(std::vector<std::unique_ptr<MeasureFeature>> &feat,
std::unique_ptr<MeasureFeature> &editingFeat, int &edit_feat_index,
int &del_feat_index, bool &redraw, int &buttonIDs) {
for (int i=0; i<(int)feat.size(); ++i) {
ImGui::PushID(++buttonIDs);
if (ImGui::Checkbox("", feat[i]->addr_enabled())) { redraw = true; }
ImGui::PopID();

// add an "edit" button after the checkbox (so it's not easy to accidentally hit remove)
ImGui::SameLine();
ImGui::PushID(++buttonIDs);
if (ImGui::SmallButton("edit")) {
editingFeat = std::unique_ptr<MeasureFeature>(feat[i]->copy());
edit_feat_index = i;
}
ImGui::PopID();

if (feat[i]->is_enabled()) {
ImGui::SameLine();
ImGui::Text("%s", feat[i]->to_string().c_str());
} else {
ImGui::SameLine();
ImGui::TextColored(ImVec4(0.5f,0.5f,0.5f,1.0f), "%s", feat[i]->to_string().c_str());
}

// add a "remove" button at the end of the line (so it's not easy to accidentally hit)
ImGui::SameLine();
ImGui::PushID(++buttonIDs);
if (ImGui::SmallButton("remove")) { del_feat_index = i; }
ImGui::PopID();
}
}
#endif

float MeasureFeature::jitter(const float _z, const float _ips) const {
Expand Down
Loading