void add_neighbourhood_to_hullPoints(pointVector& hullPoints, const Vertex_const_handle& vert, const double& tapeSize) { Point_3 pnt = vert->point(); hullPoints.push_back(pnt); // Add vertex point Nef_polyhedron::SVertex_const_iterator svcIt = vert->svertices_begin(), svcItEND = vert->svertices_end(); CGAL_For_all(svcIt,svcItEND) { Vector_3 vecR(pnt,svcIt->target()->point()); Vector_3 vecRnew = vecR * tapeSize / std::sqrt(CGAL::to_double(vecR.squared_length())); if ((vecR.squared_length()-OVERLAP_DIST_THRESHOLD) > vecRnew.squared_length()) hullPoints.push_back(pnt+vecRnew); // Add svertex neighbourhood point (tapesize away from vertex) else hullPoints.push_back(svcIt->target()->point()); }
void Mesh::saveSubMesh(const QString& filename, const TIndexList& facesList) const { QFile file(filename); file.open(QFile::WriteOnly | QFile::Truncate); file.setTextModeEnabled(true); QTextStream out(&file); out << "OFF\n"; int nVtx = numVtx(); int newIndexCounter = 0; // do we need only a subset of the vertices? QVector<int> newToOld; QHash<int, int> oldToNew; // old index -> new index. if (facesList.size() != numFaces()) { for(TIndexList::const_iterator pfi = facesList.constBegin(); pfi != facesList.constEnd(); ++pfi) { Face_const_handle f = find_facet(*pfi); for(int vfi = 0; vfi < f->size(); ++vfi) { int vi = f->vertexIndex(vfi); if (!oldToNew.contains(vi)) oldToNew.insert(vi, newIndexCounter++); } } newToOld.resize(newIndexCounter); // invert the map because we want a map from new to old for(QHash<int, int>::iterator hit = oldToNew.begin(); hit != oldToNew.end(); ++hit) { newToOld[hit.value()] = hit.key(); } nVtx = newIndexCounter; } // number of vertices, faces, 0 out << nVtx << " " << facesList.size() << " 0\n"; for(int i = 0; i < nVtx; ++i) { Vertex_const_handle v; if (newIndexCounter > 0) v = find_vertex(newToOld[i]); else v = find_vertex(i); const Vec3 &p = v->point(); out << p.x << " " << p.y << " " << p.z << "\n"; } for(TIndexList::const_iterator pfi = facesList.constBegin(); pfi != facesList.constEnd(); ++pfi) { Face_const_handle f = find_facet(*pfi); out << f->size(); for(int vfi = 0; vfi < f->size(); ++vfi) { int fii = f->vertexIndex(vfi); if (newIndexCounter > 0) fii = oldToNew[fii]; out << " " << fii; } out << "\n"; } }