void SolidDelegate::removeFace (Solid * pS, Face * f) 
{
	int i;
	HalfEdge * he = f->halfedge ();
	for(i=0; i<3; i++)
	{
		he = he->he_next ();
		Vertex * v = he->target ();
		if(v->halfedge () == he)
		{
			for(SolidEdgeIterator eiter(pS); !eiter.end (); ++eiter)
			{
				Edge * e = *eiter;
				HalfEdge * hhe = e->halfedge (0);
				if(hhe->target () == v && hhe != he)
				{
					v->halfedge () = hhe;
					break;
				}
				else if (e->halfedge (1) != NULL && e->halfedge (1)->target () == v && e->halfedge (1) != he)
				{
					v->halfedge () = e->halfedge (1);
					break;
				}
			}
		}
		if(v->halfedge () == he)
			v->halfedge () = NULL;
	}
	for(i=0; i<3; i++)
	{
		HalfEdge * nhe = he->he_next ();
	//	Vertex * v = he->target ();
		Edge * e = he->edge ();
		if(e->halfedge (1) == NULL)
		{
			removeEdge(pS, e);
			delete e;
			delete he;
		}
		else
		{
			if(e->halfedge (0) == he)
				e->halfedge (0) = e->halfedge (1);
			delete he;
			e->halfedge(1) = NULL;
		}
		he = nhe;
	}

	pS->m_faces.remove(f);
}
bool Face::include_edge(Edge *e)
{
	HalfEdge * he = m_halfedge;
	if(he->edge () == e || he->he_next ()->edge () == e || he->he_prev ()->edge () == e)
		return true;
	return false;
}
bool Face::include_vertex(Vertex *v)
{
	HalfEdge * he = m_halfedge;
	if(he->target () == v || he->source () == v || he->he_next ()->target () == v)
		return true;
	return false;

}
Exemple #4
0
	int superMi::assign_kuv_to_edge(Solid* mesh)
	{
		for (SolidEdgeIterator seiter(mesh); !seiter.end(); ++seiter){
			Edge* se = *seiter;
			se->kuv_h() = 0.0;
			//Point p1 = mesh->edgeVertex1(se)->point();
			//Point p3 = mesh->edgeVertex2(se)->point();

			//HalfEdge* he2 = se->halfedge(0)->ccw_rotate_about_source();
			//HalfEdge* he4 = se->halfedge(0)->clw_rotate_about_source();

			//Point p2 = he2->target()->point();
			//Point p4 = he4->target()->point();

			//double alpha =  ((p3 - p2)*(p1 - p2) / ((p3 - p2) ^ (p1 - p2)).norm()) / 2.0;
			//double beta =  ((p3 - p4)*(p1 - p4) / ((p3 - p4) ^ (p1 - p4)).norm()) / 2.0;

			//se->kuv_h() = alpha + beta;

			HalfEdge* he = se->halfedge(0);
			HalfEdge* nhe = he->he_next();
			HalfEdge* phe = he->he_prev();
			Face* hef = he->face();

			double nhel = (nhe->target()->point() - nhe->source()->point()).norm();
			double phel = (phe->target()->point() - phe->source()->point()).norm();
			double hel = (he->target()->point() - he->source()->point()).norm();

			se->kuv_h() += (nhel*nhel + phel*phel - hel*hel) / hef->area() / 8.0;

			he = se->halfedge(1);
			nhe = he->he_next();
			phe = he->he_prev();
			hef = he->face();
			nhel = (nhe->target()->point() - nhe->source()->point()).norm();
			phel = (phe->target()->point() - phe->source()->point()).norm();

			se->kuv_h() += (nhel*nhel + phel*phel - hel*hel) / hef->area() / 8.0;

			se->kuv_t() = 1.0;
			//std::cout << se->kuv() << std::endl;
		}

		return 0;
	}
Point Face::norm()
{
	HalfEdge * he = m_halfedge;
	Point p1 = he->target ()->point () - he->source ()->point ();
	Point p2 = he->he_next ()->target ()->point () - he->target ()->point ();
	Point n = p1 ^ p2;
	n /= n.norm ();
	return n;
}
HalfEdge * HalfEdge::clw_rotate_about_source()
{
	HalfEdge * he = he_sym();
	if( he == NULL ) return NULL;
	return he->he_next();
};