Beispiel #1
0
const std::vector<CFpoint>& CFtopoPoint::VoronoiVertices( void ) const
{
    if( m_voronoi.empty() )
    {
        ConstDirsIt edge( GetDirsBegin() );

        do
        {
            const CFcircle&	neighborTopoPoint = *edge->GetPoint();

            edge++; if( edge == GetDirsEnd() ) edge = GetDirsBegin();

            CFcircle circum( *this, neighborTopoPoint, *edge->GetPoint() );

            m_voronoi.push_back( circum );
        }
        while( edge != GetDirsBegin() );
    }

    return m_voronoi;
}
Beispiel #2
0
int convert_triangle (struct surface *srf, struct face *f)
{
	int j, k, n_e, atm, comp, shape;
	int orn;
	int arc_orn[3];
	long ofn;
	long arc_number[3];
	double radius, circumference;
	double tri_center[3], tri_normal[3];
	char message[MAXLINE];
	char shape_string[24];
	struct vertex *tri_vtx[3];
	struct arc *arc_ptrs[3];
	struct arc *a;
	struct edge *ed;
	struct cycle *cyc, *fcyc;
	struct face *fac;
	struct variety *vty;
	struct phnvtx *pv;
	struct phnedg *pe;
	struct phntri *pt;
	struct phntri **head_phntri;
	struct phntri **tail_phntri;
	
	for (k = 0; k < 3; k++)
		tri_normal[k] = 0.0;
	if (f -> converted) return(1);	
	pt = allocate_phntri ();
	if (pt == NULL) {
		print_counts();
		set_error1 ("(convert_triangle): memory allocation failure");
		print_counts();
		return (0);
	}
	comp = f -> comp;
	ofn = f -> ofn;
	if (ofn <= 0) {
		sprintf(message, "convert_triangle: ofn = %8ld", ofn);
		set_error1(message);
		return(0);
	}
	cyc = f -> first_cycle;
	if (cyc == NULL) {
		inform("convert_triangle: no cycles");
		return (0);
	}
	n_e = 0;
	for (ed = cyc -> first_edge; ed != NULL; ed = ed -> next) {
		n_e++;
	}
	if (n_e > 3) {
		sprintf (message, "(convert_triangle): face with %d sides", n_e);
		set_error1 (message);
		sprintf (message, "ofn = %ld, lfn = %ld", f -> ofn, f -> lfn);
		set_error2 (message);
		return (0);
	}
	n_e = 0;
	for (ed = cyc -> first_edge; ed != NULL; ed = ed -> next) {
		a = ed -> arcptr;
		if (a == NULL) {
			set_error1 ("(convert_triangle): null arc");
			return (0);
		}
		if (n_e > 2) {
			sprintf (message, "(convert_triangle): face with %d sides", n_e);
			set_error1 (message);
			sprintf (message, "ofn = %ld, lfn = %ld", f -> ofn, f -> lfn);
			set_error2 (message);
			return (0);
		}
		orn = ed -> orn;
		arc_orn[n_e] = orn;
		arc_number[n_e] = a -> number;
		arc_ptrs[n_e] = a;
		tri_vtx[n_e] = a -> vtx[orn];
		if (tri_vtx[n_e] == NULL) {
			set_error1 ("(convert_triangle): null vertex");
			return (0);
		}
		n_e++;
	}
	fac = *(srf -> face_handles + ofn - 1);
	if (fac == NULL) {
		inform("convert_triangle: face_handles array has null face pointer");
		return (0);
	}
	fcyc = fac -> first_cycle;
	circumference = circum (fcyc);
	shape = fac -> shape;
	vty = fac -> vty;
	if (vty == NULL) {
		inform("convert_triangle: variety pointer is null");
		return (0);
	}
	radius = vty -> radii[0];
	get_tri_center (tri_vtx, tri_center, n_e);
	atm = point_choice (srf, tri_center, vty, shape);
	if (error()) {
		inform("convert_triangle: point_choice fails");
		return(0);
	}
	if (n_e < 3) {
		sprintf (message,
		"atom %d triangle has only %d sides, %hd cycles, %hd arcs",
			atm, n_e, fac -> n_cycle, fac -> n_arc);
		set_error1 (message);
		if (shape == CONVEX)
			strcpy (shape_string, "face shape = convex");
		else if (shape == SADDLE)
			strcpy (shape_string, "face shape = saddle");
		else if (shape == CONCAVE)
			strcpy (shape_string, "face shape = concave");
		else if (shape == FLAT)
			strcpy (shape_string, "face shape = flat");
		else if (shape == CYLINDRICAL)
			strcpy (shape_string, "face shape = cylindrical");
		sprintf (message,
		"%s, omega = %12.6f, circumference = %12.6f",
		shape_string, fac -> area / (radius * radius), circumference);
		set_error2 (message);
		return (0);
	}
	if(!get_normal (tri_vtx, tri_normal)) {
		informd2("warning: degenerate triangle, no normal computed");
	}
	/* store the data in the new structure */
	for (j = 0; j < 3; j++) {
		pt -> axis[j] = tri_normal[j];
		pt -> edg[j] = arc_ptrs[j] -> ped;
		pt -> orns[j] = arc_orn[j];
	}
	pt -> comp = (short) comp;
	pt -> atm = (short) atm;
	pt -> shape = (short) shape;
	/* property of each of three vertices */
	for (j = 0; j < 3; j++) {
		pe = pt -> edg[j];
		orn = pt -> orns[j];
		pv = pe -> pvt[orn];
		pv -> degree++;
		for (k = 0; k < 3; k++)
			pv -> outward[k] += tri_normal[k];
	}
	f -> converted = 1;
	head_phntri = srf -> heads + atm - 1;
	tail_phntri = srf -> tails + atm - 1;
	if (*head_phntri == (struct phntri *) NULL)
		*head_phntri = pt;
	else (*tail_phntri) -> next = pt;
	*tail_phntri = pt;
	srf -> n_phntri++;
	return(1);
}