コード例 #1
0
ファイル: Curve.cpp プロジェクト: yuwuyi/ImgViewer
int Curve::CreateBoundaryLoop(Vertex * startV)
{
	HalfEdge * he = startV->most_ccw_out_halfedge();
	if (!he->edge()->boundary())
	{
		he = startV->most_clw_out_halfedge();
		assert(he->edge()->boundary());
	}
	return CreateBoundaryLoop(he);
}
コード例 #2
0
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;
}
コード例 #3
0
ファイル: Curve.cpp プロジェクト: yuwuyi/ImgViewer
int Curve::TraceFeatureCurve(Mesh * mesh, HalfEdge * heStart)
{
	helist.clear();
	MeshUtility::MarkSharpEdges(mesh);
	HalfEdge * che = heStart;
	Edge * ce = che->edge();
	if (!ce->sharp())
	{
		std::cerr << "Error: the input halfedge is not a feature edge!" << std::endl;
		return 0;
	}
	helist.push_back(che);

	Vertex * startV = che->source();
	Vertex * cv = che->target();

	while (cv!=startV)
	{
		bool flag = false;
		for (VertexOutHalfedgeIterator vhe(mesh, cv); !vhe.end(); ++vhe)
		{
			HalfEdge * he = *vhe;
			if (he->edge()->sharp() && he->edge() != ce)
			{
				che = he;
				cv = che->target();
				ce = che->edge();				
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			std::cerr << "Cannot find a circle!" << std::endl;
			helist.clear();
			return 0;
		}

		helist.push_back(che);
		if (che->target() == startV)
		{
			//succeed
			return helist.size();
		}	
	}
	return helist.size();
}
コード例 #4
0
ファイル: Curve.cpp プロジェクト: yuwuyi/ImgViewer
bool Curve::RobustTraceBoundaryLoop(HalfEdge* startHe, int & loopSize)
{
	HalfEdge * che = startHe;
	if (!che->source()->boundary() || !che->target()->boundary())
	{
		std::cerr << "Error: the input halfedge is not on the boundary!" << std::endl;
		loopSize=0;
		return false;
	}
	bool ccw;
	Vertex * ver = che->source();
	HalfEdge * the = ver->most_ccw_out_halfedge();
	if (the == che)
	{ //Possiblly ccw is right, except the case that there is only one out halfedge starting from ver
		//in that case, check one more step forward is enough
		HalfEdge * tempthe = the->target()->most_ccw_out_halfedge();
		if (tempthe->edge()->boundary())
			ccw = true;
		else
		{
			assert(ver->most_ccw_out_halfedge() == ver->most_clw_out_halfedge());
			ccw = false;
		}
	}
	else
	{
		ccw = false;
		the = ver->most_clw_out_halfedge();
		assert(the == che);
	}
	the = che;
	std::vector<HalfEdge *>::iterator finditer;
	while (the->target() != ver)
	{
		finditer = std::find(helist.begin(), helist.end(), the);
		if (finditer != helist.end())
		{//found
			std::cerr << "Possible Error: not go back to the starting point!" << std::endl;
			helist.erase(helist.begin(), finditer-1);
			loopSize =  helist.size();
			return false;
		}
		else
		{//not found
			helist.push_back(the);
		}	
		
		if (ccw)
			the = the->target()->most_ccw_out_halfedge();
		else 
			the = the->target()->most_clw_out_halfedge();
	}
	helist.push_back(the);
	loopSize = helist.size();
	return true;
}
コード例 #5
0
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);
}
コード例 #6
0
ファイル: Curve.cpp プロジェクト: yuwuyi/ImgViewer
void Curve::TraceBoundary(HalfEdge * startHe, Vertex * endV)
{
	HalfEdge * che = startHe;
	if (!che->source()->boundary() || !che->target()->boundary())
	{
		std::cerr << "Error: the input halfedge is not on the boundary!" << std::endl;
		return;
	}
	bool ccw;
	Vertex * ver = che->source();
	HalfEdge * the = ver->most_ccw_out_halfedge();
	if (the == che)
	{ //Possiblly ccw is right, except the case that there is only one out halfedge starting from ver
		//in that case, check one more step forward is enough
		HalfEdge * tempthe = the->target()->most_ccw_out_halfedge();
		if (tempthe->edge()->boundary())
			ccw = true;
		else
		{
			assert(ver->most_ccw_out_halfedge() == ver->most_clw_out_halfedge());
			ccw = false;
		}
	}
	else
	{
		ccw = false;
		the = ver->most_clw_out_halfedge();
		assert(the == che);
	}
	the = che;
	std::vector<HalfEdge *>::iterator finditer;

	while (the->vertex() != endV)
	{
		helist.push_back(the);
		if (ccw)
			the = the->target()->most_ccw_out_halfedge();
		else 
			the = the->target()->most_clw_out_halfedge();
		if (helist.size()>10000000)
		{
			assert(0);
		}
	}
}