Replaced other tabs by spaces... should be clear now

This commit is contained in:
Thomas FORGIONE 2015-06-26 11:44:36 +02:00
parent 83f1b71240
commit 3ee36c9282
2 changed files with 74 additions and 74 deletions

View File

@ -218,51 +218,51 @@ genPaths(
void AnimatedMesh::associateBranches(std::vector<geo::Segment<float,3>> const& segments, geo::Mesh& mesh) void AnimatedMesh::associateBranches(std::vector<geo::Segment<float,3>> const& segments, geo::Mesh& mesh)
{ {
// stock each point at the index corresponding to the nearest segment // stock each point at the index corresponding to the nearest segment
for(unsigned int i=0;i<mesh.vertices.size();i++) for(unsigned int i=0;i<mesh.vertices.size();i++)
{ {
geo::Point<float> p = geo::Point<float>{i,mesh.vertices[i]}; geo::Point<float> p = geo::Point<float>{i,mesh.vertices[i]};
associatedSegment.push_back(findNearestSegment(segments, p)); associatedSegment.push_back(findNearestSegment(segments, p));
} }
} }
//finds the nearest segment to a point //finds the nearest segment to a point
unsigned int AnimatedMesh::findNearestSegment(std::vector<geo::Segment<float,3>> const& segments, geo::Point<float> const& p) unsigned int AnimatedMesh::findNearestSegment(std::vector<geo::Segment<float,3>> const& segments, geo::Point<float> const& p)
{ {
unsigned int nearestSegment = 0; unsigned int nearestSegment = 0;
float shortest_distance = std::numeric_limits<float>::max(); float shortest_distance = std::numeric_limits<float>::max();
for(unsigned int i=0;i<segments.size();i++) for(unsigned int i=0;i<segments.size();i++)
{ {
// find distance between point and segment // find distance between point and segment
float distance = geo::distanceToSegment(p.second, segments[i].first, segments[i].second); float distance = geo::distanceToSegment(p.second, segments[i].first, segments[i].second);
if (shortest_distance > distance) if (shortest_distance > distance)
{ {
shortest_distance = distance; shortest_distance = distance;
nearestSegment = i; nearestSegment = i;
} }
} }
return nearestSegment; return nearestSegment;
} }
void AnimatedMesh::findFaces(std::vector<unsigned int> const& associatedSegments, geo::Mesh& mesh, unsigned int nbSegments) void AnimatedMesh::findFaces(std::vector<unsigned int> const& associatedSegments, geo::Mesh& mesh, unsigned int nbSegments)
{ {
for (unsigned int i=0;i<nbSegments+1;i++) for (unsigned int i=0;i<nbSegments+1;i++)
{ {
facesPerSegment.push_back(std::vector<geo::Vector3<unsigned int>>{}); facesPerSegment.push_back(std::vector<geo::Vector3<unsigned int>>{});
} }
unsigned int segment; unsigned int segment;
for(unsigned int i=0;i<mesh.faces.size();i++) for(unsigned int i=0;i<mesh.faces.size();i++)
{ {
segment = associatedSegments[mesh.faces[i].x()]; segment = associatedSegments[mesh.faces[i].x()];
if ((segment == associatedSegments[mesh.faces[i].y()]) && (segment == associatedSegments[mesh.faces[i].z()])) if ((segment == associatedSegments[mesh.faces[i].y()]) && (segment == associatedSegments[mesh.faces[i].z()]))
{ {
facesPerSegment[segment].push_back(mesh.faces[i]); facesPerSegment[segment].push_back(mesh.faces[i]);
} }
else else
{ {
facesPerSegment[nbSegments].push_back(mesh.faces[i]); facesPerSegment[nbSegments].push_back(mesh.faces[i]);
} }
} }
} }

View File

@ -621,21 +621,21 @@ void Skeleton3D::meshExtremity(geo::Mesh& mesh, std::vector<std::vector<geo::Cir
if (profondeur==0) if (profondeur==0)
{ {
mesh.vertices.push_back(intersection); mesh.vertices.push_back(intersection);
for (unsigned int i=0;i<extremCircle.points.size();i++) for (unsigned int i=0;i<extremCircle.points.size();i++)
{ {
auto ip1 = extremCircle.points[i].first; auto ip1 = extremCircle.points[i].first;
if (i==extremCircle.points.size()-1) if (i==extremCircle.points.size()-1)
{ {
auto ip2 = extremCircle.points[0].first; auto ip2 = extremCircle.points[0].first;
mesh.faces.push_back(sortedIndexes(ip1,intersectionIndex,ip2,extremity.second)); mesh.faces.push_back(sortedIndexes(ip1,intersectionIndex,ip2,extremity.second));
} }
else else
{ {
auto ip2 = extremCircle.points[i+1].first; auto ip2 = extremCircle.points[i+1].first;
mesh.faces.push_back(sortedIndexes(ip1,intersectionIndex,ip2,extremity.second)); mesh.faces.push_back(sortedIndexes(ip1,intersectionIndex,ip2,extremity.second));
} }
} }
} }
else else
{ {
@ -648,13 +648,13 @@ void Skeleton3D::subdivision(geo::Mesh& mesh, unsigned int profondeur, geo::Circ
std::vector<std::vector<geo::Vector3f>> arcs; std::vector<std::vector<geo::Vector3f>> arcs;
for (unsigned int i=0;i<extremCircle.points.size();i++) for (unsigned int i=0;i<extremCircle.points.size();i++)
{ {
// compute the points build by subdivision on one arc (between a point on the extrem // compute the points build by subdivision on one arc (between a point on the extrem
// circle and the extremity) // circle and the extremity)
std::vector<geo::Vector3f> arc; std::vector<geo::Vector3f> arc;
arc.push_back(intersection); arc.push_back(intersection);
arcSubdivise(intersection, extremCircle.points[i].second, profondeur, arc, center, radius); arcSubdivise(intersection, extremCircle.points[i].second, profondeur, arc, center, radius);
arc.push_back(extremCircle.points[i].second); arc.push_back(extremCircle.points[i].second);
arcs.push_back(arc); arcs.push_back(arc);
} }
// Compute the mesh // Compute the mesh
@ -670,39 +670,39 @@ void Skeleton3D::subdivision(geo::Mesh& mesh, unsigned int profondeur, geo::Circ
// push all the new vertices // push all the new vertices
for (unsigned int i=0;i<arcs.size();i++) for (unsigned int i=0;i<arcs.size();i++)
{ {
for (unsigned int j=1;j<arcs[i].size()-1;j++) for (unsigned int j=1;j<arcs[i].size()-1;j++)
{ {
mesh.vertices.push_back(arcs[i][j]); mesh.vertices.push_back(arcs[i][j]);
} }
} }
//push the faces //push the faces
for (unsigned int i=0;i<arcs.size()-1;i++) for (unsigned int i=0;i<arcs.size()-1;i++)
{ {
auto courant = arcs[i]; auto courant = arcs[i];
for (unsigned int j=0;j<courant.size()-2;j++) for (unsigned int j=0;j<courant.size()-2;j++)
{ {
if (j==0) if (j==0)
{ {
mesh.faces.push_back(sortedIndexes(intersectionIndex, indexVertices + 1 + nbPoints, indexVertices + 1,t)); mesh.faces.push_back(sortedIndexes(intersectionIndex, indexVertices + 1 + nbPoints, indexVertices + 1,t));
} }
else else
{ {
mesh.faces.push_back(sortedIndexes(indexVertices + j, indexVertices + j + 1 + nbPoints, indexVertices + j + 1, t)); mesh.faces.push_back(sortedIndexes(indexVertices + j, indexVertices + j + 1 + nbPoints, indexVertices + j + 1, t));
mesh.faces.push_back(sortedIndexes(indexVertices + j, indexVertices + j + nbPoints, indexVertices + j + 1 + nbPoints, t)); mesh.faces.push_back(sortedIndexes(indexVertices + j, indexVertices + j + nbPoints, indexVertices + j + 1 + nbPoints, t));
} }
} }
// before last point // before last point
unsigned int i1 = extremCircle.points[i].first; unsigned int i1 = extremCircle.points[i].first;
unsigned int i2 = extremCircle.points[i+1].first; unsigned int i2 = extremCircle.points[i+1].first;
mesh.faces.push_back(sortedIndexes(indexVertices + nbPoints, i2, i1, t)); mesh.faces.push_back(sortedIndexes(indexVertices + nbPoints, i2, i1, t));
mesh.faces.push_back(sortedIndexes(indexVertices + nbPoints , indexVertices + 2*nbPoints , i2, t)); mesh.faces.push_back(sortedIndexes(indexVertices + nbPoints , indexVertices + 2*nbPoints , i2, t));
// increment the indexVertices // increment the indexVertices
indexVertices += nbPoints; indexVertices += nbPoints;
} }
@ -750,15 +750,15 @@ void Skeleton3D::arcSubdivise(geo::Vector3f pt1, geo::Vector3f pt2, unsigned int
// compute middle of arc // compute middle of arc
geo::Vector3f middleSegment; geo::Vector3f middleSegment;
middleSegment = (pt1+pt2)/2; middleSegment = (pt1+pt2)/2;
// projection on the sphere // projection on the sphere
geo::Vector3f direction = (middleSegment - center); geo::Vector3f direction = (middleSegment - center);
direction /= direction.norm(); direction /= direction.norm();
direction *= radius; direction *= radius;
geo::Vector3f middle = center + direction; geo::Vector3f middle = center + direction;
arcSubdivise(pt1, middle, profondeur-1, arc, center, radius); arcSubdivise(pt1, middle, profondeur-1, arc, center, radius);
arc.push_back(middle); arc.push_back(middle);
arcSubdivise(middle, pt2, profondeur-1, arc, center, radius); arcSubdivise(middle, pt2, profondeur-1, arc, center, radius);
} }
} }