Skip to content

Commit

Permalink
split non manif properly, corrected wrong assert)
Browse files Browse the repository at this point in the history
  • Loading branch information
maggio-a committed Oct 5, 2018
1 parent ae87b37 commit bebf1b7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/mesh_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,11 @@ bool BuildShell(Mesh& shell, FaceGroup& fg, ParameterizationGeometry targetGeome

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

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

auto ia = GetFaceIndexAttribute(shell);
Expand Down Expand Up @@ -687,6 +687,7 @@ bool BuildShell(Mesh& shell, FaceGroup& fg, ParameterizationGeometry targetGeome
// compute the singular values of the transformation matrix, s2 > s1
// ref for the formula: smith&schaefer 2015 bijective,
Eigen::Matrix2d phi = ComputeTransformationMatrix(x10, x20, u10, u20);

double bcplus = std::pow(phi(0, 1) + phi(1, 0), 2.0);
double bcminus = std::pow(phi(0, 1) - phi(1, 0), 2.0);
double adplus = std::pow(phi(0, 0) + phi(1, 1), 2.0);
Expand All @@ -695,7 +696,7 @@ bool BuildShell(Mesh& shell, FaceGroup& fg, ParameterizationGeometry targetGeome
double s_max = 0.5 * (std::sqrt(bcplus + adminus) + std::sqrt(bcminus + adplus));

double interpolationFactor = 1.0 - (s_min / s_max);
ensure_condition(interpolationFactor > 0);
ensure_condition(interpolationFactor >= 0);
ensure_condition(interpolationFactor <= 1);
ensure_condition(std::isfinite(interpolationFactor));

Expand Down
5 changes: 4 additions & 1 deletion src/parameterization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,10 @@ int ParameterizerObject::PlaceCutWithConesUntilThreshold(double conformalScaling

tri::Clean<Mesh>::RemoveDuplicateVertex(shell);
tri::UpdateTopology<Mesh>::FaceFace(shell);
tri::Clean<Mesh>::SplitNonManifoldVertex(shell, 0.15);
int splitCount;
while ((splitCount = tri::Clean<Mesh>::SplitNonManifoldVertex(shell, 0.15)) > 0) {
tri::Allocator<Mesh>::CompactEveryVector(shell);
}
tri::Allocator<Mesh>::CompactEveryVector(shell);

ComputeBoundaryInfo(shell);
Expand Down
2 changes: 1 addition & 1 deletion src/texture_optimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ RasterizationBasedPacker::PackingStats Pack(GraphHandle graph, const PackingOpti
packingParam.pad = 2;
} else {
sizeUnit = 2048;
packingParam.pad = 8;
packingParam.pad = 4;
}

std::vector<Point2i> containerVec;
Expand Down
16 changes: 13 additions & 3 deletions viewer/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,15 @@ int MainCmd(Mesh& m, GraphHandle graph, TextureObjectHandle textureObject, Args
int c = ParameterizeGraph(gm, strategy, tolerance);
if (c > 0) std::cout << "WARNING: " << c << " regions were not parameterized correctly" << std::endl;

PackingOptions opts = { RasterizationBasedPacker::Parameters::CostFuncEnum::MinWastedSpace, true, true, true, false };
Pack(gm.Graph(), opts);
if (gm.Graph()->Count() < 500) {
std::cout << "Packing " << gm.Graph()->Count() << " regions in low resolution with permutations" << std::endl;
PackingOptions opts = { RasterizationBasedPacker::Parameters::CostFuncEnum::MinWastedSpace, true, true, true, false };
Pack(gm.Graph(), opts);
} else {
std::cout << "Packing " << gm.Graph()->Count() << " regions in high resolution" << std::endl;
PackingOptions opts = { RasterizationBasedPacker::Parameters::CostFuncEnum::MinWastedSpace, false, false, true, false };
Pack(gm.Graph(), opts);
}

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

int numVertexSplit = tri::Clean<Mesh>::SplitNonManifoldVertex(m, 0);
int numVertexSplit = 0;
int nv;
while ((nv = tri::Clean<Mesh>::SplitNonManifoldVertex(m, 0)) > 0)
numVertexSplit += nv;
if (numVertexSplit > 0)
std::cout << "Mesh was not vertex manifold, split " << numVertexSplit << " vertices" << std::endl;

Expand Down

0 comments on commit bebf1b7

Please sign in to comment.