-
-
Notifications
You must be signed in to change notification settings - Fork 231
Use flying edges for mesh generation #1741
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
Changes from 8 commits
69f9bee
4b9474b
0e9ec3b
973fe51
bcb02c4
762e943
febd8e7
46ca336
f37cd36
6507df7
63324fe
6afb548
ca76e51
8de667a
f7bbfc8
0a60847
38dcb07
77d870e
e06bbc8
b33f001
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| #include "vector.h" | ||
|
|
||
| #include <vector> | ||
| #include <array> // Include this for std::array | ||
|
|
||
| namespace Avogadro { | ||
| namespace Core { | ||
|
|
@@ -23,9 +24,7 @@ class Mutex; | |
| /** | ||
| * @class Cube cube.h <avogadro/core/cube.h> | ||
| * @brief Provide a data structure for regularly spaced 3D grids. | ||
| * @author Marcus D. Hanwell | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| */ | ||
|
|
||
| class AVOGADROCORE_EXPORT Cube | ||
| { | ||
| public: | ||
|
|
@@ -118,7 +117,7 @@ class AVOGADROCORE_EXPORT Cube | |
| bool setLimits(const Molecule& mol, float spacing, float padding); | ||
|
|
||
| /** | ||
| * @return Vector containing all the data in a one-dimensional array. | ||
| * @return Pointer to the vector containing all the data in a one-dimensional array. | ||
| */ | ||
| std::vector<float>* data(); | ||
| const std::vector<float>* data() const; | ||
|
|
@@ -133,6 +132,11 @@ class AVOGADROCORE_EXPORT Cube | |
| */ | ||
| bool addData(const std::vector<float>& values); | ||
|
|
||
| /** | ||
| * @return Const iterator to the beginning of a specific row in the cube data. | ||
| */ | ||
| std::vector<float>::const_iterator getRowIter(size_t j, size_t k) const; | ||
|
|
||
| /** | ||
| * @return Index of the point closest to the position supplied. | ||
| * @param pos Position to get closest index for. | ||
|
|
@@ -201,7 +205,7 @@ class AVOGADROCORE_EXPORT Cube | |
| * @param value Value to fill the cube with. | ||
| */ | ||
| void fill(float value); | ||
|
|
||
| /** | ||
| * Sets all indices in a Z stripe of the cube to the specified value. | ||
| * @param i x component of the position. | ||
|
|
@@ -215,12 +219,12 @@ class AVOGADROCORE_EXPORT Cube | |
| ); | ||
|
|
||
| /** | ||
| * @return The minimum value at any point in the Cube. | ||
| * @return The minimum value at any point in the Cube. | ||
| */ | ||
| float minValue() const { return m_minValue; } | ||
|
|
||
| /** | ||
| * @return The maximum value at any point in the Cube. | ||
| * @return The maximum value at any point in the Cube. | ||
| */ | ||
| float maxValue() const { return m_maxValue; } | ||
|
|
||
|
|
@@ -235,11 +239,51 @@ class AVOGADROCORE_EXPORT Cube | |
| */ | ||
| Mutex* lock() const { return m_lock; } | ||
|
|
||
| // Add declarations for the functions defined in cube.cpp | ||
| /** | ||
| * Compute the gradient at a specific point in the cube. | ||
| * @param i x index | ||
| * @param j y index | ||
| * @param k z index | ||
| * @return Gradient vector at the specified point. | ||
| */ | ||
| std::array<float, 3> computeGradient(size_t i, size_t j, size_t k) const; | ||
|
|
||
| /** | ||
| * Get the values of the eight corners of a cube cell. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite sure I understand from the docs here. I've got some index (i, j, k) into the cube. What's the "cell" of the cube? Is it just going to get me the corners of the entire cube? If so, why do I need i, j, k parameters? |
||
| * @param i x index | ||
| * @param j y index | ||
| * @param k z index | ||
| * @return Array of values at the eight corners. | ||
| */ | ||
| std::array<float, 8> getValsCube(size_t i, size_t j, size_t k) const; | ||
|
|
||
|
|
||
| std::array<std::array<float, 3>, 8> getGradCube(size_t i, size_t j, size_t k) const; | ||
| /** | ||
| * Get the data value at the specified indices. | ||
| * @param i x index | ||
| * @param j y index | ||
| * @param k z index | ||
| * @return Value at the specified indices. | ||
| */ | ||
| float getData(size_t i, size_t j, size_t k) const; | ||
|
|
||
| /** | ||
| * Get the positions of the eight corners of a cube cell. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, what's the "cell" here? Are these the min, max of the corners of the cube? If so, why do you need the i, j, k? |
||
| * @param i x index | ||
| * @param j y index | ||
| * @param k z index | ||
| * @return Array of positions at the eight corners. | ||
| */ | ||
| std::array<std::array<float, 3>, 8> getPosCube(size_t i, size_t j, size_t k) const; | ||
|
|
||
| protected: | ||
| std::vector<float> m_data; | ||
| Vector3 m_min, m_max, m_spacing; | ||
| Vector3i m_points; | ||
| float m_minValue, m_maxValue; | ||
| // Removed conflicting 'data' member variable | ||
| std::string m_name; | ||
| Type m_cubeType; | ||
| Mutex* m_lock; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,6 +122,10 @@ class AVOGADROCORE_EXPORT Mesh | |
| */ | ||
| const Vector3f* vertex(int n) const; | ||
|
|
||
| bool setTriangles(const std::vector<std::array<size_t, 3> >& values); | ||
| const std::vector<std::array<size_t, 3> >& triangles() const; | ||
|
|
||
|
|
||
| /** | ||
| * Clear the vertices vector and assign new values. | ||
| */ | ||
|
|
@@ -141,10 +145,10 @@ class AVOGADROCORE_EXPORT Mesh | |
| /** | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't understand why you're removing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But i was unable to find where we were using numnormals() in our actual code?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're not, currently. But since this is a |
||
| * @return The number of normals. | ||
| */ | ||
| unsigned int numNormals() const | ||
| { | ||
| return static_cast<unsigned int>(m_normals.size()); | ||
| } | ||
| // unsigned int numNormals() const | ||
| // { | ||
| // return static_cast<unsigned int>(m_normals.size()); | ||
| // } | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
|
|
||
| /** | ||
| * @return Pointer to the first normal of the specified triangle. | ||
|
|
@@ -228,6 +232,7 @@ class AVOGADROCORE_EXPORT Mesh | |
| Core::Array<Vector3f> m_vertices; | ||
| Core::Array<Vector3f> m_normals; | ||
| Core::Array<Color3f> m_colors; | ||
| std::vector<std::array<size_t, 3> > tris; | ||
| std::string m_name; | ||
| bool m_stable; | ||
| float m_isoValue; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I can recheck and could say here's the issue lies.
When I was having different dimensions (as a non-uniform grid), lets say
m_points.x() != m_points.y() != m_points.z()it was showing me a discrete mesh. (looking like the parts of the mesh has been seperated).So I thought to use the equal points as a workaround but it leads to the wrong orientation. Any tip for fixing it? @ghutchis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, but that doesn't work. Most "cubes" are going to be rectangular solids. They have equal spacing, but different number of points along different axes. Caffeine is a good example here, since it's fairly flat, but kinda a rectangle in the other two dimensions.
CH4 or water aren't great examples because they're roughly cubic.
This code definitely shouldn't change. You can't compute the spacing this way because the number of points will be different along different axes.
I see the weird "mesh" when I revert the changes to this code, but that just means the bug is somewhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes... I got it. Will look into the code again and try to find out the issue tomorrow. Thanks for your reply.