Esempio n. 1
0
/*****************************************************************
 * UVdata
 *****************************************************************/
UVdata::UVdata(Bsimplex* s) :
   SimplexData(key(), s),
   _uv_valid(false),
   _calc_type(SIMPLE_CALC),     // default: simple subdiv scheme
   _did_subdiv(false),
   _mapping(0) 
{
   // The constructor is called (internally) only when the given
   // simplex does not already have a UVdata associated with it.
   //
   // UVdata gets looked-up by its classname.

   // For face data, slather UVdatas all over the
   // vertices and edges:
   if (is_face(s)) {
      Bface* f = (Bface*)s;
      get_data(f->v1());
      get_data(f->v2());
      get_data(f->v3());
      get_data(f->e1());
      get_data(f->e2());
      get_data(f->e3());

      // XXX - 
      //   If the UVdata is created on a pre-existing face
      //   that has already generated its subdivision
      //   elements, then currently the UVdatas won't be
      //   created on those subdivision elements ...
   }
}
Esempio n. 2
0
void 
visit(OctreeNode* node,  
      double regularity, Bface_list& flist, ARRAY<Wvec>& blist)
{
   if (node->get_leaf()) {
      if (node->get_disp()) {
         // subdivision
         ARRAY<QuadtreeNode*> fs;
         Bface_list temp;
         for (int i = 0; i < node->intersects().num(); i++) {
            Bface* f = node->intersects()[i];
            temp += f;
            fs += new QuadtreeNode(f->v1()->loc(), f->v2()->loc(), f->v3()->loc());
            fs.last()->build_quadtree(node, regularity);
            fs.last()->set_terms();
         }

         // assign weights
         assign_weights(fs, regularity, node->center());
         
         // pick a triangle
         int t = pick(fs);

         // moved below; want to ensure flist and blist stay in sync:
//         flist += temp[t];

         //set node face
         Bface_list ftemp;
         ftemp += temp[t];
         node->set_face(ftemp);

         // pick a point
         int p = pick(fs[t]->terms());
         if (p != -1) {
            Wvec bc;
            temp[t]->project_barycentric(fs[t]->terms()[p]->urand_pick(), bc);
            blist += bc;
            flist += temp[t]; // moved from above
            node->set_point(bc);
         }

         for (int i = 0; i < fs.num(); i++)
            delete fs[i];
         fs.clear();
      }
   } else {
      for (int i = 0; i < 8; i++)
         visit(node->get_children()[i], regularity, flist, blist);
   }
}
Esempio n. 3
0
void 
OctreeNode::build_octree(int height) 
{

   if (_leaf || _height == height) 
      return;

   int i, j;
   Wpt_list pts;
   points(pts);

   for (i = 0; i < 8; i++) {
      _children[i] = new OctreeNode((pts[0]+pts[i])/2, (pts[i]+pts[7])/2, 
                                    _height+1, this);
   }

   for (j = 0; j < _intersects.num(); j++) {
      Bface* f = _intersects[j];

      for (i = 0; i < 8; i++) {
         OctreeNode* n = _children[i];
         if (n->contains(f->v1()->loc()) && n->contains(f->v2()->loc())
             && n->contains(f->v3()->loc())) {
            n->intersects() += f;
            break;
         } else if (n->overlaps(bface_bbox(f))) {
            n->intersects() += f;
         }
      }
   }

   for (i = 0; i < 8; i++) {
      if (_height+1 == height) {
         _children[i]->set_leaf(true);
         _children[i]->set_disp(true);
      }
      if (_children[i]->intersects().empty()) {
         _children[i]->set_leaf(true);
         _children[i]->set_disp(false);
      }
      _children[i]->build_octree(height);
   }

}