8000 Using Inbuilt Datastructures by Kushal-Shah-03 · Pull Request #893 · elalish/manifold · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Using Inbuilt Datastructures #893

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

Merged
merged 26 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
037f063
Removing VertexDatSource structure and Replacing it with Vec
Kushal-Shah-03 Aug 10, 2024
4313227
Merge branch 'elalish:master' into HullAlgov2
Kushal-Shah-03 Aug 10, 2024
ff28542
Integrated HalfEdge datastructure of Manifold (in progress)
Kushal-Shah-03 Aug 13, 2024
56af511
Merge remote-tracking branch 'origin/HullAlgov2' into HullAlgov2
Kushal-Shah-03 Aug 13, 2024
ad1e0a2
Changed QuickHull Class to accomodate VecView
Kushal-Shah-03 Aug 13, 2024
1043e4c
Formatting changes and modified erase
Kushal-Shah-03 Aug 13, 2024
c8d439f
Made the suggested changes
Kushal-Shah-03 Aug 13, 2024
7db3291
Impl Hull function working
Kushal-Shah-03 Aug 16, 2024
88d6f7e
Formatting
Kushal-Shah-03 Aug 16, 2024
7787cc0
Adding comments and making code more readable
Kushal-Shah-03 Aug 16, 2024
d08ad80
Made changes, added manifold namespace, removed multiple lines to add…
Kushal-Shah-03 Aug 17, 2024
50ad8db
Added the fix and corrected face indices to now match the expected in…
Kushal-Shah-03 Aug 17, 2024
d75cc31
Formatting
Kushal-Shah-03 Aug 17, 2024
8b3963e
Added comment as TODO and replaced std::cout with DEBUG_ASSERT
Kushal-Shah-03 Aug 18, 2024
d9edae6
move things around
pca 8000 006132 Aug 18, 2024
76d4126
remove custom HalfEdge data structure
pca006132 Aug 18, 2024
b46e7ce
Added MANIFOLD_EXCEPTIONS
Kushal-Shah-03 Aug 18, 2024
7303107
Revert "Added MANIFOLD_EXCEPTIONS"
pca006132 Aug 19, 2024
f95fe21
fix include
pca006132 Aug 19, 2024
fdaf121
format
pca006132 Aug 19, 2024
9432445
Made the suggested changes
Kushal-Shah-03 Aug 19, 2024
8c6525a
Fixed : processing disabled faces bug
Kushal-Shah-03 Aug 20, 2024
b0fbf4c
Removed unecessary comments
Kushal-Shah-03 Aug 20, 2024
24f4add
Trying atomic for j
Kushal-Shah-03 Aug 20, 2024
87aad9b
Suggested fix
Kushal-Shah-03 Aug 20, 2024
abfd857
Atomic Add should work
Kushal-Shah-03 Aug 20, 2024
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
29 changes: 29 additions & 0 deletions src/manifold/src/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,35 @@
Finish();
}

void Manifold::Impl::Hull(const std::vector<glm::vec3>& vertPos) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw why are we taking std::vector here? shouldn't we take VecView?

size_t numVert = vertPos.size();
if (numVert < 4) {
status_ = Error::InvalidConstruction;
return;
}

Vec<glm::dvec3> pointCloudVec(numVert);
manifold::transform(vertPos.begin(), vertPos.end(), pointCloudVec.begin(),
[](const glm::vec3& v) { return glm::dvec3(v); });

Check warning on line 490 in src/manifold/src/impl.cpp

View check run for this annotation

Codecov / codecov/patch

src/manifold/src/impl.cpp#L490

Added line #L490 was not covered by tests
QuickHull qh(pointCloudVec);
ConvexHull hull = qh.getConvexHullAsMesh(pointCloudVec, false);
// TODO : Once double PR lands, replace this with move
vertPos_.resize(hull.vertices.size());
manifold::transform(hull.vertices.begin(), hull.vertices.end(),
vertPos_.begin(),
[](const glm::dvec3& v) { return glm::vec3(v); });

Check warning on line 497 in src/manifold/src/impl.cpp

View check run for this annotation

Codecov / codecov/patch

src/manifold/src/impl.cpp#L497

Added line #L497 was not covered by tests
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make a note that we can replace with this move once our doubles PR lands.

halfedge_ = std::move(hull.halfedges);
meshRelation_.originalID = ReserveIDs(1);
CalculateBBox();
SetPrecision(bBox_.Scale() * kTolerance);
SplitPinchedVerts();
CalculateNormals();
InitializeOriginal();
CreateFaces({});
SimplifyTopology();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your analysis, but let's leave it to the next PR to optimize exactly what's needed here.

Finish();
}

/**
* Create either a unit tetrahedron, cube or octahedron. The cube is in the
* first octant, while the others are symmetric about the origin.
Expand Down
4 changes: 4 additions & 0 deletions src/manifold/src/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "manifold.h"
#include "optional_assert.h"
#include "polygon.h"
#include "quickhull.h"
#include "shared.h"
#include "sparse.h"
#include "utils.h"
Expand Down Expand Up @@ -189,5 +190,8 @@ struct Manifold::Impl {
void CreateTangents(int normalIdx);
void CreateTangents(std::vector<Smoothness>);
void Refine(std::function<int(glm::vec3)>);

// quickhull.cpp
void Hull(const std::vector<glm::vec3>& vertPos);
};
} // namespace manifold
34 changes: 10 additions & 24 deletions src/manifold/src/manifold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,35 +915,21 @@ ExecutionParams& ManifoldParams() { return manifoldParams; }
* hull.
*/
Manifold Manifold::Hull(const std::vector<glm::vec3>& pts) {
ZoneScoped;
const int numVert = pts.size();
if (numVert < 4) return Manifold();

std::vector<glm::dvec3> vertices(numVert);
for (int i = 0; i < numVert; i++) {
vertices[i] = {pts[i].x, pts[i].y, pts[i].z};
}

QuickHull qh;
// bools: correct triangle winding, and use original indices
auto hull = qh.getConvexHull(vertices, false, true);
const auto& triangles = hull.getIndexBuffer();
const int numTris = triangles.size() / 3;

Mesh mesh;
mesh.vertPos = pts;
mesh.triVerts.reserve(numTris);
for (int i = 0; i < numTris; i++) {
const int j = i * 3;
mesh.triVerts.push_back({triangles[j], triangles[j + 1], triangles[j + 2]});
}
return Manifold(mesh);
std::shared_ptr<Impl> impl = std::make_shared<Impl>();
impl->Hull(pts);
return Manifold(std::make_shared<CsgLeafNode>(impl));
}

/**
* Compute the convex hull of this manifold.
*/
Manifold Manifold::Hull() const { return Hull(GetMesh().vertPos); }
Manifold Manifold::Hull() const {
std::vector<glm::vec3> pts;
for (auto vertex : GetCsgLeafNode().GetImpl()->vertPos_) {
pts.push_back(vertex);
}
return Hull(pts);
}

/**
* Compute the convex hull enveloping a set of manifolds.
Expand Down
Loading
Loading
0