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());
	}
 /*! Create a vertex v that matches v2, which lies of the edge e1. */
 virtual void create_vertex(Halfedge_const_handle e1, Vertex_const_handle v2,
                            Vertex_handle v) const
 { v->set_data(e1->data() + v2->data()); }
 /*! Create a vertex v that matches v1, contained in the face f2. */
 virtual void create_vertex(Vertex_const_handle v1, Face_const_handle f2,
                            Vertex_handle v) const
 { v->set_data(v1->data() + f2->data());}
 /*! Create a vertex v that matches v1, which lies of the edge e2. */
 virtual void create_vertex(Vertex_const_handle  v1, Halfedge_const_handle e2,
                            Vertex_handle v) const
 { v->set_data(v1->data() + e2->data()); }
 /*! Create a vertex v that matches v2, contained in the face f1. */
 virtual void create_vertex(Face_const_handle f1, Vertex_const_handle v2,
                            Vertex_handle v) const
 { v->set_data(f1->data() + v2->data()); }
Beispiel #6
0
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";
	}

}