-
Notifications
You must be signed in to change notification settings - Fork 114
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
Make create faces optional #935
Changes from all commits
a5f3f68
df66cb0
0d35b37
02bf8ab
017919a
65d2ca9
31f8429
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 |
---|---|---|
|
@@ -266,18 +266,9 @@ CsgLeafNode& Manifold::GetCsgLeafNode() const { | |
* runs. | ||
* | ||
* @param meshGL The input MeshGL. | ||
* @param propertyTolerance A vector of precision values for each property | ||
* beyond position. If specified, the propertyTolerance vector must have size = | ||
* numProp - 3. This is the amount of interpolation error allowed before two | ||
* neighboring triangles are considered to be on a property boundary edge. | ||
* Property boundary edges will be retained across operations even if the | ||
* triangles are coplanar. Defaults to 1e-5, which works well for most | ||
* properties in the [-1, 1] range. | ||
*/ | ||
Manifold::Manifold(const MeshGL& meshGL, | ||
const std::vector<float>& propertyTolerance) | ||
: pNode_(std::make_shared<CsgLeafNode>( | ||
std::make_shared<Impl>(meshGL, propertyTolerance))) {} | ||
Manifold::Manifold(const MeshGL& meshGL) | ||
: pNode_(std::make_shared<CsgLeafNode>(std::make_shared<Impl>(meshGL))) {} | ||
|
||
/** | ||
* Convert a MeshGL into a Manifold, retaining its properties and merging only | ||
|
@@ -299,10 +290,8 @@ Manifold::Manifold(const MeshGL& meshGL, | |
* triangles are coplanar. Defaults to 1e-5, which works well for most | ||
* properties in the [-1, 1] range. | ||
*/ | ||
Manifold::Manifold(const MeshGL64& meshGL64, | ||
const std::vector<double>& propertyTolerance) | ||
: pNode_(std::make_shared<CsgLeafNode>( | ||
std::make_shared<Impl>(meshGL64, propertyTolerance))) {} | ||
Manifold::Manifold(const MeshGL64& meshGL64) | ||
: pNode_(std::make_shared<CsgLeafNode>(std::make_shared<Impl>(meshGL64))) {} | ||
|
||
/** | ||
* Convert a Mesh into a Manifold. Will return an empty Manifold | ||
|
@@ -312,7 +301,7 @@ Manifold::Manifold(const MeshGL64& meshGL64, | |
* @param mesh The input Mesh. | ||
*/ | ||
Manifold::Manifold(const Mesh& mesh) { | ||
Impl::MeshRelationD relation = {(int)ReserveIDs(1)}; | ||
Impl::MeshRelationD relation; | ||
pNode_ = | ||
std::make_shared<CsgLeafNode>(std::make_shared<Impl>(mesh, relation)); | ||
} | ||
|
@@ -471,12 +460,20 @@ int Manifold::OriginalID() const { | |
* collapses those edges. In the process the relation to ancestor meshes is lost | ||
* and this new Manifold is marked an original. Properties are preserved, so if | ||
* they do not match across an edge, that edge will be kept. | ||
* | ||
* @param propertyTolerance A vector of precision values for each property | ||
* beyond position. If specified, the propertyTolerance vector must have size = | ||
* numProp - 3. This is the amount of interpolation error allowed before two | ||
* neighboring triangles are considered to be on a property boundary edge. | ||
* Property boundary edges will be retained across operations even if the | ||
* triangles are coplanar. Defaults to 1e-5, which works well for most | ||
* single-precision properties in the [-1, 1] range. | ||
*/ | ||
Manifold Manifold::AsOriginal() const { | ||
Manifold Manifold::AsOriginal( | ||
const std::vector<double>& propertyTolerance) const { | ||
auto newImpl = std::make_shared<Impl>(*GetCsgLeafNode().GetImpl()); | ||
newImpl->meshRelation_.originalID = ReserveIDs(1); | ||
newImpl->InitializeOriginal(); | ||
newImpl->CreateFaces(); | ||
newImpl->CreateFaces(propertyTolerance); | ||
newImpl->SimplifyTopology(); | ||
newImpl->Finish(); | ||
return Manifold(std::make_shared<CsgLeafNode>(newImpl)); | ||
|
@@ -645,13 +642,12 @@ Manifold Manifold::SetProperties( | |
if (triProperties.size() == 0) { | ||
const int numTri = NumTri(); | ||
triProperties.resize(numTri); | ||
int idx = 0; | ||
for (int i = 0; i < numTri; ++i) { | ||
for (const int j : {0, 1, 2}) { | ||
triProperties[i][j] = idx++; | ||
triProperties[i][j] = pImpl->halfedge_[3 * i + j].startVert; | ||
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. This bug was causing duplicate propVerts to be created unnecessarily. |
||
} | ||
} | ||
pImpl->meshRelation_.properties = Vec<double>(numProp * idx, 0); | ||
pImpl->meshRelation_.properties = Vec<double>(numProp * NumVert(), 0); | ||
} else { | ||
pImpl->meshRelation_.properties = Vec<double>(numProp * NumPropVert(), 0); | ||
} | ||
|
@@ -668,8 +664,6 @@ Manifold Manifold::SetProperties( | |
} | ||
|
||
pImpl->meshRelation_.numProp = numProp; | ||
pImpl->CreateFaces(); | ||
pImpl->Finish(); | ||
return Manifold(std::make_shared<CsgLeafNode>(pImpl)); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -830,14 +830,10 @@ void Manifold::Impl::Hull(VecView<vec3> vertPos) { | |
|
||
QuickHull qh(vertPos); | ||
std::tie(halfedge_, vertPos_) = qh.buildMesh(); | ||
meshRelation_.originalID = ReserveIDs(1); | ||
CalculateBBox(); | ||
SetPrecision(bBox_.Scale() * kTolerance); | ||
SplitPinchedVerts(); | ||
CalculateNormals(); | ||
InitializeOriginal(); | ||
CreateFaces({}); | ||
SimplifyTopology(); | ||
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. FYI @Kushal-Shah-03 I simplified the hull setup - hopefully improves the speed a bit. |
||
Finish(); | ||
} | ||
|
||
|
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.
FYI @pca006132 I fixed this as part of the rest of this cleanup.