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

Probes #1050

Draft
wants to merge 55 commits into
base: master
Choose a base branch
from
Draft

Probes #1050

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
dad8aaf
fixed build with probe plugin
tobiasrau Jun 7, 2022
28681ca
added glyph summing prototype
tobiasrau Jun 7, 2022
93edac7
make install dlls dependent on cgal version
tobiasrau Jun 7, 2022
aec7277
fixed dll install for probes
tobiasrau Jun 7, 2022
325f451
removed pcl and 3rd party code
tobiasrau Jun 7, 2022
e377a7d
more 3rd party removal fixes
tobiasrau Jun 7, 2022
ffba311
fix imgui hack in probe interaction and dirtyness in glyph rendering
invor Jun 15, 2022
ba6aa15
Fix flag storage buffer usage
invor Jun 20, 2022
8a5718b
fixed representations
tobiasrau Jun 1, 2022
c185a6c
Merge branch 'probes' of github.com:tobiasrau/megamol into probes
tobiasrau Jun 23, 2022
5e2997f
Added icosphere to MeshBakery
invor Jun 24, 2022
46718b6
added spherical volume, changed structure and extension map to only h…
tobiasrau Jul 14, 2022
8f3128a
Add primitive type to gltf loader
invor Jul 16, 2022
3300783
temporary line shader
invor Jul 16, 2022
6343335
removed one wrong dirty cycle
tobiasrau Jul 18, 2022
6eb8dcf
update
tobiasrau Jul 18, 2022
045dc7a
Merge branch 'probes' of github.com:tobiasrau/megamol into probes
tobiasrau Jul 18, 2022
62da2e5
Merge remote-tracking branch 'upstream/master' into probes
invor Jul 20, 2022
063e756
fix mmstd includes
invor Jul 20, 2022
fa3a6dd
[WIP] Convert lines for OSPRay
tobiasrau Jul 21, 2022
4af865a
Merge branch 'probes' of ../megamol into probes
tobiasrau Jul 21, 2022
729df1b
tried to fix blend2d ended up making it optional instead
tobiasrau Jul 22, 2022
f73de15
fixed return in billboard
tobiasrau Jul 22, 2022
6d515c0
missing staged file for blend2d commit
tobiasrau Jul 22, 2022
894074e
added conversion of line data (obj, gltf) to ospray line geometry
tobiasrau Jul 22, 2022
520ef8a
mesh selector was doing strange things, fixed that
tobiasrau Jul 22, 2022
aa4d93e
Merge remote-tracking branch 'upstream/master' into probes
invor Aug 4, 2022
2aee1ca
Update probe_gl to new mesh_gl monolithic renderer desing
invor Aug 6, 2022
bec052d
Fix probe hull rendering, fix probe_gl shader namespace
invor Aug 9, 2022
e817cd3
Add save to texture feature for scalar probes
invor Aug 19, 2022
210beca
particle list selector now advances the datahash properly
tobiasrau Aug 24, 2022
959340e
mesh obj loader does not copy vertices anymore and keeps the original…
tobiasrau Aug 24, 2022
d4683f4
added slot required indicators
tobiasrau Aug 24, 2022
928bce8
added dual mesh sampling module, minor fixes
tobiasrau Aug 24, 2022
bc56e18
Merge branch 'probes' of github.com:tobiasrau/megamol into probes
tobiasrau Aug 24, 2022
3d2bef5
dual mesh sampling now works for spherical data sets
tobiasrau Aug 25, 2022
bf1607d
added levels to probe collection
tobiasrau Sep 28, 2022
8a12650
Fix old scalar glyph before archiving
invor Oct 5, 2022
c31cf52
New dial glyph background work in progress
invor Oct 5, 2022
a28e09a
Merge branch 'probes' of https://github.com/tobiasrau/megamol into pr…
invor Oct 5, 2022
7fa26c0
Fix function names
invor Oct 5, 2022
03b8652
Cleaning up glyph shaders
invor Oct 6, 2022
b5583a9
Add new scaler glpyh shader
invor Oct 6, 2022
8c0eaa1
added generateProbeLevels module
tobiasrau Oct 7, 2022
83bd9c5
added posibility to filter columns in computeDistance
tobiasrau Oct 7, 2022
a1ebb90
fixed dirty missbehavior in felx convert
tobiasrau Oct 7, 2022
65af923
probe placement now supports skipping edges and corners
tobiasrau Oct 7, 2022
79e0661
rename erase and shuffle proves
tobiasrau Oct 7, 2022
3570db0
fixes and improvements on dual mesh sampling
tobiasrau Oct 7, 2022
67ebb7b
Merge branch 'probes' of github.com:tobiasrau/megamol into probes
tobiasrau Oct 7, 2022
4828d12
added vector distribution probe
tobiasrau Oct 12, 2022
f700e06
added PBC kd tree adaptor
tobiasrau Oct 19, 2022
c833c3d
added relaxation algorithm in probe level generation
tobiasrau Oct 24, 2022
02178b9
put probe level depth as template param
tobiasrau Oct 24, 2022
a6156fa
added sub probes to first level
tobiasrau Oct 24, 2022
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
14 changes: 9 additions & 5 deletions externals/CMakeExternals.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ function(require_external NAME)
endif ()

if (WIN32)
set(BLEND2D_LIB "lib/blend2d.lib")
#set(BLEND2D_LIB "bin/blend2d.dll")
set(BLEND2D_IMPORT_LIB "lib/blend2d.lib")
else ()
set(BLEND2D_LIB "lib/libblend2d.a")
endif ()
Expand All @@ -240,15 +241,18 @@ function(require_external NAME)
add_external_project(blend2d STATIC
GIT_REPOSITORY https://github.com/blend2d/blend2d.git
GIT_TAG "8aeac6cb34b00898ae725bd76eb3bb2c7cffcf86"
BUILD_BYPRODUCTS "<INSTALL_DIR>/${BLEND2D_IMPORT_LIB}" "<INSTALL_DIR>/${BLEND2D_LIB}"
#BUILD_BYPRODUCTS "<INSTALL_DIR>/${BLEND2D_IMPORT_LIB}" "<INSTALL_DIR>/${BLEND2D_LIB}"
BUILD_BYPRODUCTS "<INSTALL_DIR>/${BLEND2D_IMPORT_LIB}"
CMAKE_ARGS
-DASMJIT_DIR=${SOURCE_DIR}
-DBLEND2D_STATIC=ON)

add_external_library(blend2d
DEPENDS asmjit
INCLUDE_DIR "include"
LIBRARY ${BLEND2D_LIB})
LIBRARY ${BLEND2D_IMPORT_LIB})
# LIBRARY ${BLEND2D_LIB}
# IMPORT_LIBRARY ${BLEND2D_IMPORT_LIB})

# chemfiles
elseif(NAME STREQUAL "chemfiles")
Expand Down Expand Up @@ -750,9 +754,9 @@ function(require_external NAME)
endif ()

if (WIN32)
set(QHULL_LIB "lib/qhull<SUFFIX>.lib")
set(QHULL_LIB "lib/qhull.lib")
else ()
set(QUHULL_LIB "lib/libqhull<SUFFIX>.a")
set(QUHULL_LIB "lib/libqhull.a")
endif ()

add_external_project(qhull STATIC
Expand Down
24 changes: 19 additions & 5 deletions plugins/datatools/src/AddParticleColors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,33 @@ bool megamol::datatools::AddParticleColors::manipulateData(
core::view::CallGetTransferFunction* cgtf = _tf_slot.CallAs<core::view::CallGetTransferFunction>();
if (cgtf == nullptr)
return false;
if (!(*cgtf)())
if (!(*cgtf)(0))
return false;

outData = inData;

if (_frame_id != inData.FrameID() || _in_data_hash != inData.DataHash() || cgtf->IsDirty()) {
auto const tf = cgtf->GetTextureData();
auto const tf_size = cgtf->TextureSize();
const auto cgtf_dirty = cgtf->IsDirty();
if (_frame_id != inData.FrameID() || _in_data_hash != inData.DataHash() || cgtf_dirty) {

auto const pl_count = outData.GetParticleListCount();
assert(pl_count > 0);
_colors.clear();
_colors.resize(pl_count);

auto global_min_i = outData.AccessParticles(0).GetMinColourIndexValue();
auto global_max_i = outData.AccessParticles(0).GetMaxColourIndexValue();
for (unsigned int plidx = 0; plidx < pl_count; ++plidx) {
auto& parts = outData.AccessParticles(plidx);
auto const min_i = parts.GetMinColourIndexValue();
auto const max_i = parts.GetMaxColourIndexValue();
global_min_i = std::min(global_min_i,min_i);
global_max_i = std::max(global_max_i, max_i);
}

cgtf->SetRange({global_min_i,global_max_i});
if (!(*cgtf)(0))
return false;
auto const tf = cgtf->GetTextureData();
auto const tf_size = cgtf->TextureSize();
for (unsigned int plidx = 0; plidx < pl_count; ++plidx) {
auto& parts = outData.AccessParticles(plidx);
if (parts.GetColourDataType() != geocalls::SimpleSphericalParticles::COLDATA_FLOAT_I &&
Expand Down
11 changes: 11 additions & 0 deletions plugins/datatools/src/ParticleListSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ datatools::ParticleListSelector::ParticleListSelector(void)
: AbstractParticleManipulator("outData", "indata")
, listIndexSlot("listIndex", "The thinning factor. Only each n-th particle will be kept.") {
this->listIndexSlot.SetParameter(new core::param::IntParam(0, 0));
listIndexSlot.SetUpdateCallback(&datatools::ParticleListSelector::paramChanged);
this->MakeSlotAvailable(&this->listIndexSlot);
}

Expand Down Expand Up @@ -48,6 +49,16 @@ bool datatools::ParticleListSelector::manipulateData(
outData.SetParticleListCount(1);
outData.AccessParticles(0) = inData.AccessParticles(idx);
}
if (_param_changed) {
auto current_hash = outData.DataHash();
outData.SetDataHash(++current_hash);
_param_changed = false;
}

return true;
}

bool datatools::ParticleListSelector::paramChanged(core::param::ParamSlot& p) {
_param_changed = true;
return true;
}
2 changes: 2 additions & 0 deletions plugins/datatools/src/ParticleListSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ class ParticleListSelector : public AbstractParticleManipulator {
* @return True on success
*/
virtual bool manipulateData(geocalls::MultiParticleDataCall& outData, geocalls::MultiParticleDataCall& inData);
bool paramChanged(core::param::ParamSlot& p);

private:
/** The list selection index */
core::param::ParamSlot listIndexSlot;
bool _param_changed = false;
};

} /* end namespace datatools */
Expand Down
2 changes: 1 addition & 1 deletion plugins/mesh/include/mesh/MeshDataAccessCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MeshDataAccessCollection {
public:
enum ValueType { BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, INT, UNSIGNED_INT, HALF_FLOAT, FLOAT, DOUBLE };
enum AttributeSemanticType { POSITION, NORMAL, COLOR, TEXCOORD, TANGENT, UNKNOWN, ID };
enum PrimitiveType { TRIANGLES, QUADS, LINES, LINE_STRIP, TRIANGLE_FAN };
enum PrimitiveType { TRIANGLES, QUADS, LINES, LINE_STRIP, TRIANGLE_FAN, TRIANGLE_STRIP };

static constexpr unsigned int convertToGLType(ValueType value_type) {
unsigned int retval = 0;
Expand Down
165 changes: 142 additions & 23 deletions plugins/mesh/src/MeshBakery.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
#include "MeshBakery.h"

#include <glm/glm.hpp>

#include "mmcore/param/EnumParam.h"
#include "mmcore/param/FloatParam.h"
#include "mmcore/param/IntParam.h"

megamol::mesh::MeshBakery::MeshBakery()
: AbstractMeshDataSource()
, m_version(0)
, m_geometry_type("GeometryType", "...") {
this->m_geometry_type << new megamol::core::param::EnumParam(0);
this->m_geometry_type.Param<megamol::core::param::EnumParam>()->SetTypePair(0, "Quad");
this->m_geometry_type.Param<megamol::core::param::EnumParam>()->SetTypePair(1, "Cone");
this->MakeSlotAvailable(&this->m_geometry_type);
, m_geometry_type("GeometryType", "...")
, m_icosphere_radius("IcosphereRadius","...")
, m_icosphere_subdivs("IcosphereSubdivs", "")
{
m_geometry_type << new megamol::core::param::EnumParam(2);
m_geometry_type.Param<megamol::core::param::EnumParam>()->SetTypePair(0, "Quad");
m_geometry_type.Param<megamol::core::param::EnumParam>()->SetTypePair(1, "Cone");
m_geometry_type.Param<megamol::core::param::EnumParam>()->SetTypePair(2, "Icosphere");
MakeSlotAvailable(&m_geometry_type);

m_icosphere_radius << new megamol::core::param::FloatParam(1.0f,0.0f);
MakeSlotAvailable(&m_icosphere_radius);

m_icosphere_subdivs << new megamol::core::param::IntParam(0,0);
MakeSlotAvailable(&m_icosphere_subdivs);
}

megamol::mesh::MeshBakery::~MeshBakery() {
this->Release();
Release();
}

bool megamol::mesh::MeshBakery::create(void) {
Expand Down Expand Up @@ -43,40 +57,55 @@ bool megamol::mesh::MeshBakery::getMeshDataCallback(core::Call& caller) {
auto mesh_access_collections = rhs_mesh_call->getData();
}

if (m_geometry_type.IsDirty()) {
bool something_has_changed =
m_geometry_type.IsDirty() || m_icosphere_radius.IsDirty() || m_icosphere_subdivs.IsDirty();

if (m_vertex_positions.empty() || something_has_changed) {
//TODO bad move, but necessary right now. chaining is broken with this
clearMeshAccessCollection();

m_geometry_type.ResetDirty();
m_icosphere_radius.ResetDirty();
m_icosphere_subdivs.ResetDirty();

++m_version;

std::array<float, 6> bbox;

// init default bounding box
bbox[0] = -1.0f;
bbox[1] = -1.0f;
bbox[2] = -1.0f;
bbox[3] = 1.0f;
bbox[4] = 1.0f;
bbox[5] = 1.0f;

auto geometry_type = m_geometry_type.Param<core::param::EnumParam>()->Value();

//TODO call geometry generating functions
switch (geometry_type) {
case 0:
m_icosphere_radius.Param<megamol::core::param::FloatParam>()->SetGUIVisible(false);
m_icosphere_subdivs.Param<megamol::core::param::IntParam>()->SetGUIVisible(false);
break;
case 1:
m_icosphere_radius.Param<megamol::core::param::FloatParam>()->SetGUIVisible(false);
m_icosphere_subdivs.Param<megamol::core::param::IntParam>()->SetGUIVisible(false);
createConeGeometry();
break;
case 2:
m_icosphere_radius.Param<megamol::core::param::FloatParam>()->SetGUIVisible(true);
m_icosphere_subdivs.Param<megamol::core::param::IntParam>()->SetGUIVisible(true);
createIcosphereGeometry(m_icosphere_radius.Param<megamol::core::param::FloatParam>()->Value(),
static_cast<unsigned int>(m_icosphere_subdivs.Param<megamol::core::param::IntParam>()->Value()));
for (auto& val : bbox) {
val *= m_icosphere_radius.Param<megamol::core::param::FloatParam>()->Value();
}
break;
default:
break;
}

std::array<float, 6> bbox;

bbox[0] = std::numeric_limits<float>::max();
bbox[1] = std::numeric_limits<float>::max();
bbox[2] = std::numeric_limits<float>::max();
bbox[3] = std::numeric_limits<float>::min();
bbox[4] = std::numeric_limits<float>::min();
bbox[5] = std::numeric_limits<float>::min();

bbox[0] = -1.0f;
bbox[1] = -1.0f;
bbox[2] = -1.0f;
bbox[3] = 1.0f;
bbox[4] = 1.0f;
bbox[5] = 1.0f;

std::vector<MeshDataAccessCollection::VertexAttribute> mesh_attributes;
MeshDataAccessCollection::IndexData mesh_indices;

Expand Down Expand Up @@ -200,3 +229,93 @@ void megamol::mesh::MeshBakery::createConeGeometry() {
m_indices.push_back(i + segments);
}
}

void megamol::mesh::MeshBakery::createIcosphereGeometry(float radius, unsigned int subdivisions) {

m_vertex_positions.clear();
m_vertex_normals.clear();
m_vertex_tangents.clear();
m_vertex_uvs.clear();
m_vertex_colors.clear();
m_indices.clear();

// Create intial icosahedron
float x = 0.525731112119133606f * radius;
float z = 0.850650808352039932f * radius;
float nx = 0.525731112119133606f;
float nz = 0.850650808352039932f;

m_vertex_positions = {-x, 0.0f, z, x, 0.0f, z, -x, 0.0f, -z, x, 0.0f, -z, 0.0f, z, x, 0.0f, z, -x, 0.0f, -z, x,
0.0f, -z, -x, z, x, 0.0f, -z, x, 0.0f, z, -x, 0.0f, -z, -x, 0.0f};
m_vertex_normals = {-nx, 0.0f, nz, nx, 0.0f, nz, -nx, 0.0f, -nz, nx, 0.0f, -nz, 0.0f, nz, nx, 0.0f, nz, -nx, 0.0f,
-nz, nx, 0.0f, -nz, -nx, nz, nx, 0.0f, -nz, nx, 0.0f, nz, -nx, 0.0f, -nz, -nx, 0.0f};
m_indices = {0, 4, 1, 0, 9, 4, 9, 5, 4, 4, 5, 8, 4, 8, 1, 8, 10, 1, 8, 3, 10, 5, 3, 8, 5, 2, 3, 2, 7, 3, 7, 10, 3,
7, 6, 10, 7, 11, 6, 11, 0, 6, 0, 1, 6, 6, 1, 10, 9, 0, 11, 9, 11, 2, 9, 2, 5, 7, 2, 11};

// Subdivide icosahedron
for (unsigned int subdivs = 0; subdivs < subdivisions; subdivs++) {
std::vector<uint32_t> refined_indices;
refined_indices.reserve(m_indices.size() * 3);

for (int i = 0; i < m_indices.size(); i = i + 3) {
unsigned int idx1 = m_indices[i];
unsigned int idx2 = m_indices[i + 1];
unsigned int idx3 = m_indices[i + 2];

glm::vec3 newVtx1((m_vertex_positions[idx1 * 3 + 0] + m_vertex_positions[idx2 * 3 + 0]),
(m_vertex_positions[idx1 * 3 + 1] + m_vertex_positions[idx2 * 3 + 1]),
(m_vertex_positions[idx1 * 3 + 2] + m_vertex_positions[idx2 * 3 + 2]));
newVtx1 = glm::normalize(newVtx1);
newVtx1 *= radius;

glm::vec3 newVtx2((m_vertex_positions[idx2 * 3 + 0] + m_vertex_positions[idx3 * 3 + 0]),
(m_vertex_positions[idx2 * 3 + 1] + m_vertex_positions[idx3 * 3 + 1]),
(m_vertex_positions[idx2 * 3 + 2] + m_vertex_positions[idx3 * 3 + 2]));
newVtx2 = glm::normalize(newVtx2);
newVtx2 *= radius;

glm::vec3 newVtx3((m_vertex_positions[idx3 * 3 + 0] + m_vertex_positions[idx1 * 3 + 0]),
(m_vertex_positions[idx3 * 3 + 1] + m_vertex_positions[idx1 * 3 + 1]),
(m_vertex_positions[idx3 * 3 + 2] + m_vertex_positions[idx1 * 3 + 2]));
newVtx3 = glm::normalize(newVtx3);
newVtx3 *= radius;

glm::vec3 newVtxNrml1((m_vertex_normals[idx1 * 3 + 0] + m_vertex_normals[idx2 * 3 + 0]),
(m_vertex_normals[idx1 * 3 + 1] + m_vertex_normals[idx2 * 3 + 1]),
(m_vertex_normals[idx1 * 3 + 2] + m_vertex_normals[idx2 * 3 + 2]));
newVtxNrml1 = glm::normalize(newVtx1);

glm::vec3 newVtxNrml2((m_vertex_normals[idx2 * 3 + 0] + m_vertex_normals[idx3 * 3 + 0]),
(m_vertex_normals[idx2 * 3 + 1] + m_vertex_normals[idx3 * 3 + 1]),
(m_vertex_normals[idx2 * 3 + 2] + m_vertex_normals[idx3 * 3 + 2]));
newVtxNrml2 = glm::normalize(newVtx2);

glm::vec3 newVtxNrml3((m_vertex_normals[idx3 * 3 + 0] + m_vertex_normals[idx1 * 3 + 0]),
(m_vertex_normals[idx3 * 3 + 1] + m_vertex_normals[idx1 * 3 + 1]),
(m_vertex_normals[idx3 * 3 + 2] + m_vertex_normals[idx1 * 3 + 2]));
newVtxNrml3 = glm::normalize(newVtx3);

unsigned int newIdx1 = static_cast<unsigned int>(m_vertex_positions.size() / 3);
m_vertex_positions.insert(m_vertex_positions.end(), {newVtx1.x, newVtx1.y, newVtx1.z});
m_vertex_normals.insert(m_vertex_normals.end(), {newVtxNrml1.x, newVtxNrml1.y, newVtxNrml1.z});

unsigned int newIdx2 = newIdx1 + 1;
m_vertex_positions.insert(m_vertex_positions.end(), {newVtx2.x, newVtx2.y, newVtx2.z});
m_vertex_normals.insert(m_vertex_normals.end(), {newVtxNrml2.x, newVtxNrml2.y, newVtxNrml2.z});

unsigned int newIdx3 = newIdx2 + 1;
m_vertex_positions.insert(m_vertex_positions.end(), {newVtx3.x, newVtx3.y, newVtx3.z});
m_vertex_normals.insert(m_vertex_normals.end(), {newVtxNrml3.x, newVtxNrml3.y, newVtxNrml3.z});

refined_indices.insert(refined_indices.end(),
{idx1, newIdx1, newIdx3, newIdx1, idx2, newIdx2, newIdx3, newIdx1, newIdx2, newIdx3, newIdx2, idx3});
}

m_indices.clear();
m_indices = refined_indices;
}

// fill unused attributes with zeros for now
m_vertex_tangents.resize(m_vertex_normals.size());
m_vertex_uvs.resize((m_vertex_normals.size() / 3) * 2);
}
8 changes: 8 additions & 0 deletions plugins/mesh/src/MeshBakery.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class MeshBakery : public AbstractMeshDataSource {

void createConeGeometry();

void createIcosphereGeometry(float radius, unsigned int subdivisions);

uint32_t m_version;

std::vector<float> m_vertex_positions;
Expand All @@ -85,6 +87,12 @@ class MeshBakery : public AbstractMeshDataSource {

/** Parameter for selecting the geometry to be generated */
megamol::core::param::ParamSlot m_geometry_type;

/** Parameter for setting icosphere radius */
megamol::core::param::ParamSlot m_icosphere_radius;

/** Parameter for setting icosphere subdivisions */
megamol::core::param::ParamSlot m_icosphere_subdivs;
};

} // namespace mesh
Expand Down
Loading