Skip to content

Commit bebf1b7

Browse files
committed
split non manif properly, corrected wrong assert)
1 parent ae87b37 commit bebf1b7

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

src/mesh_graph.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,11 @@ bool BuildShell(Mesh& shell, FaceGroup& fg, ParameterizationGeometry targetGeome
484484

485485
tri::UpdateTopology<Mesh>::FaceFace(shell);
486486

487-
int splitCount = tri::Clean<Mesh>::SplitNonManifoldVertex(shell, 0.15);
488-
if (splitCount > 0) {
487+
int splitCount;
488+
while ((splitCount = tri::Clean<Mesh>::SplitNonManifoldVertex(shell, 0.15)) > 0) {
489489
std::cout << "Mesh was not vertex-manifold, " << splitCount << " vertices split" << std::endl;
490+
tri::Allocator<Mesh>::CompactEveryVector(shell);
490491
}
491-
tri::Allocator<Mesh>::CompactEveryVector(shell);
492492
//tri::io::Exporter<Mesh>::Save(shell, "shell.obj", tri::io::Mask::IOM_ALL);
493493

494494
auto ia = GetFaceIndexAttribute(shell);
@@ -687,6 +687,7 @@ bool BuildShell(Mesh& shell, FaceGroup& fg, ParameterizationGeometry targetGeome
687687
// compute the singular values of the transformation matrix, s2 > s1
688688
// ref for the formula: smith&schaefer 2015 bijective,
689689
Eigen::Matrix2d phi = ComputeTransformationMatrix(x10, x20, u10, u20);
690+
690691
double bcplus = std::pow(phi(0, 1) + phi(1, 0), 2.0);
691692
double bcminus = std::pow(phi(0, 1) - phi(1, 0), 2.0);
692693
double adplus = std::pow(phi(0, 0) + phi(1, 1), 2.0);
@@ -695,7 +696,7 @@ bool BuildShell(Mesh& shell, FaceGroup& fg, ParameterizationGeometry targetGeome
695696
double s_max = 0.5 * (std::sqrt(bcplus + adminus) + std::sqrt(bcminus + adplus));
696697

697698
double interpolationFactor = 1.0 - (s_min / s_max);
698-
ensure_condition(interpolationFactor > 0);
699+
ensure_condition(interpolationFactor >= 0);
699700
ensure_condition(interpolationFactor <= 1);
700701
ensure_condition(std::isfinite(interpolationFactor));
701702

src/parameterization.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,10 @@ int ParameterizerObject::PlaceCutWithConesUntilThreshold(double conformalScaling
705705

706706
tri::Clean<Mesh>::RemoveDuplicateVertex(shell);
707707
tri::UpdateTopology<Mesh>::FaceFace(shell);
708-
tri::Clean<Mesh>::SplitNonManifoldVertex(shell, 0.15);
708+
int splitCount;
709+
while ((splitCount = tri::Clean<Mesh>::SplitNonManifoldVertex(shell, 0.15)) > 0) {
710+
tri::Allocator<Mesh>::CompactEveryVector(shell);
711+
}
709712
tri::Allocator<Mesh>::CompactEveryVector(shell);
710713

711714
ComputeBoundaryInfo(shell);

src/texture_optimization.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ RasterizationBasedPacker::PackingStats Pack(GraphHandle graph, const PackingOpti
792792
packingParam.pad = 2;
793793
} else {
794794
sizeUnit = 2048;
795-
packingParam.pad = 8;
795+
packingParam.pad = 4;
796796
}
797797

798798
std::vector<Point2i> containerVec;

viewer/viewer.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,15 @@ int MainCmd(Mesh& m, GraphHandle graph, TextureObjectHandle textureObject, Args
7474
int c = ParameterizeGraph(gm, strategy, tolerance);
7575
if (c > 0) std::cout << "WARNING: " << c << " regions were not parameterized correctly" << std::endl;
7676

77-
PackingOptions opts = { RasterizationBasedPacker::Parameters::CostFuncEnum::MinWastedSpace, true, true, true, false };
78-
Pack(gm.Graph(), opts);
77+
if (gm.Graph()->Count() < 500) {
78+
std::cout << "Packing " << gm.Graph()->Count() << " regions in low resolution with permutations" << std::endl;
79+
PackingOptions opts = { RasterizationBasedPacker::Parameters::CostFuncEnum::MinWastedSpace, true, true, true, false };
80+
Pack(gm.Graph(), opts);
81+
} else {
82+
std::cout << "Packing " << gm.Graph()->Count() << " regions in high resolution" << std::endl;
83+
PackingOptions opts = { RasterizationBasedPacker::Parameters::CostFuncEnum::MinWastedSpace, false, false, true, false };
84+
Pack(gm.Graph(), opts);
85+
}
7986

8087
std::cout << "Rendering texture..." << std::endl;
8188
TextureObjectHandle newTexture = RenderTexture(m, textureObject, args.filter, InterpolationMode::Linear, nullptr);
@@ -169,7 +176,10 @@ int main(int argc, char *argv[])
169176
if (zeroArea > 0)
170177
std::cout << "Removed " << zeroArea << " zero area faces" << std::endl;
171178

172-
int numVertexSplit = tri::Clean<Mesh>::SplitNonManifoldVertex(m, 0);
179+
int numVertexSplit = 0;
180+
int nv;
181+
while ((nv = tri::Clean<Mesh>::SplitNonManifoldVertex(m, 0)) > 0)
182+
numVertexSplit += nv;
173183
if (numVertexSplit > 0)
174184
std::cout << "Mesh was not vertex manifold, split " << numVertexSplit << " vertices" << std::endl;
175185

0 commit comments

Comments
 (0)