Skip to content
Snippets Groups Projects
Commit 3fbe806b authored by Jean-Marie Favreau's avatar Jean-Marie Favreau
Browse files

Correct several bugs

parent 23d01fd4
No related branches found
No related tags found
No related merge requests found
......@@ -160,7 +160,7 @@ def main():
mtiling.adjustQuads()
mapping = mtiling.parameterize()
print "Save mapping (" + outputFileParam + ")..."
mapping.save(outputFile)
mapping.save(outputFileParam)
if __name__ == "__main__":
main()
......@@ -59,22 +59,28 @@ void MTile::addNeighbour(const MTile & mtile) {
MTiling::MTiling(Mesh & m) : mesh(m) {
std::deque<MeshPart> cc = m.getConnectedComponents();
unsigned int i = 1;
unsigned int i = 0;
// build the connected components
for(std::deque<MeshPart>::iterator c = cc.begin(); c != cc.end(); ++c, ++i)
mtiles.push_back(MTile(*c, i));
// set the flags according to the CC
mesh.setPointFlag(-1);
MeshManipulator mManip(mesh);
mManip.computeFlagsUsingCC();
for(std::vector<MTile>::const_iterator t = mtiles.begin(); t != mtiles.end(); ++t) {
assert(mesh.point((*t).getInsidePoint()).getFlag() == -1);
mManip.computeCCUsingPointsSimple((*t).getInsidePoint(), -1, (*t).getId());
}
// compute multipoints
std::map<Coord3D, std::vector<VertexID>, Coord3D::ltCoord> mPoints = mesh.computeMultiPointsByCoords();
// add multipoints and neighbours to the tiles
for(std::map<Coord3D, std::vector<VertexID>, Coord3D::ltCoord>::const_iterator mpl = mPoints.begin(); mpl != mPoints.end(); ++mpl) {
for(std::vector<VertexID>::const_iterator mp = (*mpl).second.begin(); mp != (*mpl).second.end(); ++mp)
for(std::vector<VertexID>::const_iterator mp = (*mpl).second.begin(); mp != (*mpl).second.end(); ++mp) {
assert(mtiles[mesh.point(*mp).getFlag()].getId() == (unsigned int)(mesh.point(*mp).getFlag()));
mtiles[mesh.point(*mp).getFlag()].addMultiPoint(*mp);
}
setNeighbourConnections((*mpl).second);
}
......@@ -96,7 +102,7 @@ void MTiling::setNeighbourConnections(const std::vector<VertexID> & mPoints) {
}
// then check if the other multipoints have same location
for(std::vector<VertexID>::const_iterator pp = p + 1; p != mPoints.end(); ++p) {
for(std::vector<VertexID>::const_iterator pp = p + 1; pp != mPoints.end(); ++pp) {
for(std::deque<VertexID>::const_iterator nbPP = mesh.point(*pp).getNeighbours().begin();
nbPP != mesh.point(*pp).getNeighbours().end(); ++nbPP) {
const Point3D & nPPC = mesh.point(*nbPP);
......@@ -118,15 +124,10 @@ void MTiling::adjustQuads() {
Mapping2D3D MTiling::parameterize() {
Mapping2D3D mapping(mesh);
std::deque<MeshPart> cc = mesh.getConnectedComponents();
assert(cc.size() == mtiles.size());
std::deque<MeshPart>::iterator c = cc.begin();
std::vector<MTile>::const_iterator t = mtiles.begin();
for(; c != cc.end(); ++c, ++t) {
Mesh ccMesh = (*c).buildCropMesh();
MeshPart::IDTranslator idTranslator(*c);
for(std::vector<MTile>::const_iterator t = mtiles.begin(); t != mtiles.end(); ++t) {
MeshPart mPart(mesh, (*t).getInsidePoint());
Mesh ccMesh = mPart.buildCropMesh();
MeshPart::IDTranslator idTranslator(mPart);
if (((*t).getGenus() != 0) || (*t).getNbBoundaries() != 1)
throw Exception("Wrong topology configuration");
......@@ -134,11 +135,15 @@ Mapping2D3D MTiling::parameterize() {
Mapping2D3D rMapping(ccMesh);
if ((*t).getNbMultiPoints() == 4) {
QuadParameterizationFloater mParam;
assert(mPart.hasPoint((*t).getMultiPoint(0)));
assert(mPart.hasPoint((*t).getMultiPoint(1)));
assert(mPart.hasPoint((*t).getMultiPoint(2)));
assert(mPart.hasPoint((*t).getMultiPoint(3)));
rMapping = mParam.parameterize(ccMesh,
(*t).getMultiPoint(0),
(*t).getMultiPoint(1),
(*t).getMultiPoint(2),
(*t).getMultiPoint(3));
idTranslator.g2l((*t).getMultiPoint(0)),
idTranslator.g2l((*t).getMultiPoint(1)),
idTranslator.g2l((*t).getMultiPoint(2)),
idTranslator.g2l((*t).getMultiPoint(3)));
}
else {
DiscParameterizationFloater mParam;
......@@ -150,6 +155,9 @@ Mapping2D3D MTiling::parameterize() {
mapping[idTranslator.l2g(lID)] = *p2D;
}
// the mesh is flatten
mapping.isFlatten();
return mapping;
}
......@@ -71,6 +71,9 @@ namespace Taglut {
/** add a neighbour tile */
void addNeighbour(const MTile & mtile);
/** accessor */
inline VertexID getInsidePoint() const { return v; }
/** accessor */
inline unsigned int getId() const { return id; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment