Example #1
0
static void
define_offset(
   Bvert* v,
   CVertMapper& tmap,
   CVertMapper& bmap,
   CWvec& n,
   Primitive* p
   )
{
   assert(v);
   double h = compute_h(v);

   // apply the offset to top and bottom verts:
   Bvert* tv = tmap.a_to_b(v);
   assert(tv);
   tv->offset_loc(n*h);
   Bvert* bv = bmap.a_to_b(v);
   assert(bv);
   bv->offset_loc(-n*h);

   // create xf memes
   Bface_list one_ring;
   v->get_all_faces(one_ring);
   DiskMap* frame = DiskMap::create(one_ring, false, v);
   p->create_xf_meme((Lvert*)tv, frame);
   p->create_xf_meme((Lvert*)bv, frame);
   p->add_input(frame);
}
Example #2
0
inline bool
create_sides(
   CBface_list& faces,
   CVertMapper& tmap,
   CVertMapper& bmap,
   Primitive* p
   )
{
   assert(p && tmap.is_valid() && bmap.is_valid());
   Bface_list ret;

   EdgeStrip boundary = faces.get_boundary();
   assert(!boundary.empty());

   EdgeStrip top_strip = tmap.a_to_b(boundary);
   EdgeStrip bot_strip = bmap.a_to_b(boundary);
   assert(!(top_strip.empty() || bot_strip.empty()));

   UVpt a, b, c, d;
   Bedge *top_e, *bot_e;
   Bface *top_f, *bot_f;
   Bvert *v1, *v2, *v3, *v4;
   for (int i = 0; i < top_strip.num(); i++) {
      top_e = top_strip.edge(i);
      bot_e = bot_strip.edge(i);
      top_f = top_e->get_face();
      bot_f = bot_e->get_face();
      v1 = top_strip.vert(i);
      v2 = top_e->other_vertex(v1);
      v3 = bot_strip.vert(i);
      v4 = bot_e->other_vertex(v3);
      bool has_uv = UVdata::get_uvs(top_f, a, b, c);
      if (has_uv) {
         assert(top_f->is_quad() && bot_f->is_quad());
         a = UVdata::get_uv(v1, top_f);
         b = UVdata::get_uv(v2, top_f);
         c = UVdata::get_uv(v3, bot_f);
         d = UVdata::get_uv(v4, bot_f);
         if (c[0]==0 && d[0]==0) 
            c[0] = d[0] = a[0]+abs((UVdata::get_uv(top_f->other_vertex(v1, v2), top_f))[0]-a[0]);
         if (top_f->other_vertex(top_f->weak_edge()) == v1)
            p->add_quad(v1, v3, v4, v2, a, c, d, b);
         else {
            assert(top_f->other_vertex(top_f->weak_edge()) == v2);
            p->add_quad(v3, v4, v2, v1, c, d, b, a);
         }
      } else {
         p->add_quad(v1, v3, v4, v2);
      }
   }

   return true;
}
Example #3
0
inline void
report(CVertMapper& mapper, Cstr_ptr& msg)
{
   err_msg("  %s: %d verts to %d verts, %d edges to %d edges",
           **msg,
           mapper.A().num(),
           mapper.B().num(),
           mapper.a_edges().num(),
           mapper.a_to_b(mapper.a_edges()).num());
}
Example #4
0
inline bool 
copy_edge(Bedge* a, CVertMapper& vmap)
{
   // copy edge attributes, e.g. from skel to skin

   Bedge* b = vmap.a_to_b(a);
   if (!(a && b))
      return false;

   if (a->is_weak())
      b->set_bit(Bedge::WEAK_BIT);

   // more?

   return true;
}
Example #5
0
inline VertMapper
subdiv_mapper(CVertMapper& pmap)
{
   Bedge_list a_edges = pmap.a_edges();
   Bedge_list b_edges = pmap.a_to_b(a_edges);
   assert(a_edges.num() == b_edges.num());

   if (0 && debug) {
      err_msg("parents: verts: %d --> %d, edges: %d --> %d",
              pmap.A().num(), pmap.B().num(), a_edges.num(), b_edges.num());
      err_msg("children: verts: %d --> %d",
              (child_verts<Bvert_list,Lvert>(pmap.A()) +
               child_verts<Bedge_list,Ledge>(a_edges)).num(),
              (child_verts<Bvert_list,Lvert>(pmap.B()) +
               child_verts<Bedge_list,Ledge>(b_edges)).num());

      Bvert_list c = (child_verts<Bvert_list,Lvert>(pmap.A()) +
                      child_verts<Bedge_list,Ledge>(a_edges));
      if (c.has_duplicates()) {
         err_msg("*** child verts have duplicates ***");
         if (pmap.A().has_duplicates()) {
            err_msg("  A verts have duplicates");
         }
         if (pmap.a_edges().has_duplicates()) {
            err_msg("  A edges have duplicates");
         }
         if (child_verts<Bvert_list,Lvert>(pmap.A()).has_duplicates()) {
            err_msg("  vert children have duplicates");
         }
         if (child_verts<Bedge_list,Ledge>(pmap.a_edges()).has_duplicates()) {
            err_msg("  edge children have duplicates");
         }
         WORLD::show_pts(c.pts());
      }
   }

   return VertMapper(
      child_verts<Bvert_list,Lvert>(pmap.A()) +
      child_verts<Bedge_list,Ledge>(a_edges),
      child_verts<Bvert_list,Lvert>(pmap.B()) +
      child_verts<Bedge_list,Ledge>(b_edges)
      );
}