Exemple #1
0
void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
{
	orientation = !orientation;
	ViewEdge::vertex_iterator v;
	ViewEdge::vertex_iterator vend;
	ViewEdge::vertex_iterator vfirst;
	Vec3r previous, current;
	if (true == orientation) {
		v = iViewEdge->vertices_begin();
		vfirst = v;
		vend = iViewEdge->vertices_end();
	}
	else {
		v = iViewEdge->vertices_last();
		vfirst = v;
		vend = iViewEdge->vertices_end();
	}

	if (!_Vertices.empty()) {
		previous = _Vertices.front()->point2d();
		if (orientation)
			++v;
		else
			--v;
		// Ensure the continuity of underlying FEdges
		CurvePoint *cp = _Vertices.front(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.f);
		SVertex *sv_last = cp->A();
		SVertex *sv_curr = (*v);
		FEdge *fe = (orientation) ? iViewEdge->fedgeA() : iViewEdge->fedgeB();
		FEdge *fe2 = fe->duplicate();
		fe2->setVertexA(sv_curr);
		fe2->setVertexB(sv_last);
		sv_last->AddFEdge(fe2);
		sv_curr->AddFEdge(fe2);
		sv_curr->shape()->AddEdge(fe2);
	}
	else {
		previous = (*v)->point2d();
	}
	do {
		current = (*v)->point2d();
		Curve::push_vertex_front((*v));
		//_Length += (current - previous).norm();
		previous = current;
		if (orientation)
			++v;
		else
			--v;
	} while ((v != vend) && (v != vfirst));

	if (v == vfirst) {
		//Add last one:
		current = (*v)->point2d();
		Curve::push_vertex_front(*v);
		//_Length += (current - previous).norm();
	}

	if (!_fedgeB)
		_fedgeB = (orientation) ? iViewEdge->fedgeB() : iViewEdge->fedgeA();
}
Exemple #2
0
FEdge *CurvePoint::getFEdge(Interface0D& inter)
{
	CurvePoint *iVertexB = dynamic_cast<CurvePoint*>(&inter);
	if (!iVertexB) {
		cerr << "Warning: CurvePoint::getFEdge() failed to cast the given 0D element to CurvePoint." << endl;
		return 0;
	}
	if (((__A == iVertexB->__A) && (__B == iVertexB->__B)) ||
	    ((__A == iVertexB->__B) && (__B == iVertexB->__A)))
	{
		return __A->getFEdge(*__B);
	}
	if (__B == 0) {
		if (iVertexB->__B == 0)
			return __A->getFEdge(*(iVertexB->__A));
		else if (iVertexB->__A == __A)
			return __A->getFEdge(*(iVertexB->__B));
		else if (iVertexB->__B == __A)
			return __A->getFEdge(*(iVertexB->__A));
	}
	if (iVertexB->__B == 0) {
		if (iVertexB->__A == __A)
			return __B->getFEdge(*(iVertexB->__A));
		else if (iVertexB->__A == __B)
			return __A->getFEdge(*(iVertexB->__A));
	}
	if (__B == iVertexB->__A) {
		if ((_t2d != 1) && (iVertexB->_t2d == 0))
			return __A->getFEdge(*__B);
		if ((_t2d == 1) && (iVertexB->_t2d != 0))
			return iVertexB->__A->getFEdge(*(iVertexB->__B));
	}
	if (__B == iVertexB->__B) {
		if ((_t2d != 1) && (iVertexB->_t2d == 1))
			return __A->getFEdge(*__B);
		if ((_t2d == 1) && (iVertexB->_t2d != 1))
			return iVertexB->__A->getFEdge(*(iVertexB->__B));
	}
	if (__A == iVertexB->__A) {
		if ((_t2d == 0) && (iVertexB->_t2d != 0))
			return iVertexB->__A->getFEdge(*(iVertexB->__B));
		if ((_t2d != 0) && (iVertexB->_t2d == 0))
			return __A->getFEdge(*__B);
	}
	if (__A == iVertexB->__B) {
		if ((_t2d == 0) && (iVertexB->_t2d != 1))
			return iVertexB->__A->getFEdge(*(iVertexB->__B));
		if ((_t2d != 0) && (iVertexB->_t2d == 1))
			return __A->getFEdge(*__B);
	}
#if 0
	if (G.debug & G_DEBUG_FREESTYLE) {
		printf("__A           0x%p p (%f, %f)\n", __A, __A->getPoint2D().x(), __A->getPoint2D().y());
		printf("__B           0x%p p (%f, %f)\n", __B, __B->getPoint2D().x(), __B->getPoint2D().y());
		printf("iVertexB->A() 0x%p p (%f, %f)\n", iVertexB->A(), iVertexB->A()->getPoint2D().x(),
		                                          iVertexB->A()->getPoint2D().y());
		printf("iVertexB->B() 0x%p p (%f, %f)\n", iVertexB->B(), iVertexB->B()->getPoint2D().x(),
		                                          iVertexB->B()->getPoint2D().y());
		printf("_t2d            %f p (%f, %f)\n", _t2d, getPoint2D().x(), getPoint2D().y());
		printf("iVertexB->t2d() %f p (%f, %f)\n", iVertexB->t2d(), iVertexB->getPoint2D().x(),
		       iVertexB->getPoint2D().y());
	}
#endif
	cerr << "Warning: CurvePoint::getFEdge() failed." << endl;

	return NULL;
}