Vector<Vector3> ConcavePolygonShape::_gen_debug_mesh_lines() {

	Set<DrawEdge> edges;

	PoolVector<Vector3> data=get_faces();
	int datalen=data.size();
	ERR_FAIL_COND_V( (datalen%3)!=0,Vector<Vector3>() );

	PoolVector<Vector3>::Read r=data.read();

	for(int i=0;i<datalen;i+=3) {

		for(int j=0;j<3;j++) {

			DrawEdge de(r[i+j],r[i+((j+1)%3)]);
			edges.insert(de);
		}

	}

	Vector<Vector3> points;
	points.resize(edges.size()*2);
	int idx=0;
	for (Set<DrawEdge>::Element*E=edges.front();E;E=E->next()) {

		points[idx+0]=E->get().a;
		points[idx+1]=E->get().b;
		idx+=2;
	}

	return points;

}
Exemple #2
0
//returns -1 on fail, number of vertices on success
int load_off_mesh(FILE* fp, jmesh *jm){
    fseek(fp, 0, SEEK_SET); //ensure we are at the start of the file

    if(is_off_file(fp) != 0){
        fprintf(stderr, "not an off file\n");
        return -1;
    }

    int i;
    i=get_verts_faces(fp, jm);
    if(i != 3){
        fprintf(stderr,"off file corrupt on line 2\n");
        return -1;
    }
    i=get_tuples(fp, jm);
    if(i != jm->nvert){
        fprintf(stderr,"off file corrupt on tuple line %d\n", i);
        return -1;
    }
    i=get_faces(fp, jm);
    if(i != jm->ntri){
        fprintf(stderr,"off file corrupt on polygon line %d\n", i);
        return -1;
    }
    get_normals(jm);
    get_centroid(jm, jm->center);
    return i;
}
static GstFlowReturn
kms_image_overlay_transform_frame_ip (GstVideoFilter * filter,
    GstVideoFrame * frame)
{
  KmsImageOverlay *imageoverlay = KMS_IMAGE_OVERLAY (filter);
  GstMapInfo info;
  GstStructure *faces;
  GSList *faces_list;

  gst_buffer_map (frame->buffer, &info, GST_MAP_READ);

  kms_image_overlay_initialize_images (imageoverlay, frame);
  imageoverlay->priv->cvImage->imageData = (char *) info.data;

  GST_OBJECT_LOCK (imageoverlay);
  faces = g_queue_pop_head (imageoverlay->priv->events_queue);

  while (faces != NULL) {

    kms_image_overlay_get_timestamp (imageoverlay, faces);
    GST_DEBUG ("buffer pts %" G_GUINT64_FORMAT, frame->buffer->pts);
    GST_DEBUG ("event pts %" G_GUINT64_FORMAT, imageoverlay->priv->pts);
    GST_DEBUG ("queue length %d",
        g_queue_get_length (imageoverlay->priv->events_queue));

    if (imageoverlay->priv->pts == frame->buffer->pts) {
      faces_list = get_faces (faces);

      if (faces_list != NULL) {
        if (imageoverlay->priv->costume != NULL) {
          kms_image_overlay_display_detections_overlay_img (imageoverlay,
              faces_list);
        }
        g_slist_free_full (faces_list, cvrect_free);
      }
      gst_structure_free (faces);
      break;
    } else if (imageoverlay->priv->pts < frame->buffer->pts) {
      gst_structure_free (faces);
    } else {
      g_queue_push_head (imageoverlay->priv->events_queue, faces);
      break;
    }
    faces = g_queue_pop_head (imageoverlay->priv->events_queue);
  }

  GST_OBJECT_UNLOCK (imageoverlay);

  gst_buffer_unmap (frame->buffer, &info);

  return GST_FLOW_OK;
}
Exemple #4
0
Ref<Shape> Mesh::create_trimesh_shape() const {

	PoolVector<Face3> faces = get_faces();
	if (faces.size() == 0)
		return Ref<Shape>();

	PoolVector<Vector3> face_points;
	face_points.resize(faces.size() * 3);

	for (int i = 0; i < face_points.size(); i++) {

		Face3 f = faces.get(i / 3);
		face_points.set(i, f.vertex[i % 3]);
	}

	Ref<ConcavePolygonShape> shape = memnew(ConcavePolygonShape);
	shape->set_faces(face_points);
	return shape;
}
Exemple #5
0
Variant ConcavePolygonShapeSW::get_data() const {

	return get_faces();
}
/* This function creates an array of font definitions. Each entry corresponds to one of 
   the Graphviz PS fonts.  The font definitions contain the generic font name and a list 
   of equivalent fonts that can be used in place of the PS font if the PS font is not 
   available on the system
*/
static availfont_t *gv_get_ps_fontlist(PangoFontMap * fontmap)
{
    PangoFontFamily **families;
    PangoFontFamily *family;
    fontdef_t* gv_ps_fontdef;
    int n_families;
    int i, j, k, array_sz, availfaces;
    availfont_t *gv_af_p, *gv_afs;
    const char *name;
    char *family_name;

    /* Get a list of font families installed on the system */
    pango_font_map_list_families(fontmap, &families, &n_families);

    /* Setup a pointer to available font structs */
    gv_af_p = N_NEW(GV_FONT_LIST_SIZE, availfont_t);

    for (j = 0; j < GV_FONT_LIST_SIZE; j++) {
	/* get the Graphviz PS font information and create the
	   available font definition structs */
	gv_afs = gv_af_p+j;
	gv_ps_fontdef = gv_ps_fontdefs+j;
	gv_afs->gv_ps_fontname = gv_ps_fontdef->fontname;
	family_name = NULL;
	/* Search the installed system font families for the current 
	   Graphvis PS font family name, i.e. AvantGarde */
	for (i = 0; i < n_families; i++) {
	    family = families[i];
	    name = pango_font_family_get_name(family);
	    /* if a match is found get the installed font faces */
	    if (strcasecmp(gv_ps_fontdef->fontname, name) == 0) {
		family_name = strdup(name);
		availfaces = get_faces(family);
	    }
	    if (family_name)
		break;
	}
	/* if a match is not found on the primary Graphviz font family,
	   search for a match on the equivalent font family names */
	if (!family_name) {
	    array_sz = gv_ps_fontdef->eq_sz;
	    for (k = 0; k < array_sz; k++) {
		for (i = 0; i < n_families; i++) {
		    family = families[i];
		    name = pango_font_family_get_name(family);
		    if (strcasecmp(gv_ps_fontdef->equiv[k], name) == 0) {
			family_name = strdup(name);
			availfaces = get_faces(family);
			break;
		    }
		}
		if (family_name)
		    break;
	    }
	}
	/* if a match is not found on the equivalent font family names, search
	   for a match on the generic family name assigned to the Graphviz PS font */
	if (!family_name) {
	    for (i = 0; i < n_families; i++) {
		family = families[i];
		name = pango_font_family_get_name(family);
		if (strcasecmp(gv_ps_fontdef->generic_name, name) == 0) {
		    family_name = strdup(name);
		    availfaces = get_faces(family);
		    break;
		}
	    }
	}
	/* if not match is found on the generic name, set the available font
	   name to NULL */
	if (family_name && availfaces) {
	    gv_afs->fontname = family_name;
	    gv_afs->faces = availfaces;
	} else {
	    gv_afs->fontname = NULL;
	    gv_afs->faces = 0;
	}
    }
    g_free(families);
#ifdef DEBUG
    display_available_fonts(gv_af_p);
#endif
/* Free the Graphviz PS font definitions */
    return (gv_af_p);
}