当前位置: 首页>>代码示例>>C++>>正文


C++ ARRAY::num方法代码示例

本文整理汇总了C++中ARRAY::num方法的典型用法代码示例。如果您正苦于以下问题:C++ ARRAY::num方法的具体用法?C++ ARRAY::num怎么用?C++ ARRAY::num使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ARRAY的用法示例。


在下文中一共展示了ARRAY::num方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Wpt

inline
Wpt
center (Wpt_list& pts, ARRAY<int>& N)
{
   Wpt ret = Wpt(0);
   for (int i = 0; i < N.num(); i++) {
      ret += pts[N[i]];
   }
   return ret / N.num();
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:10,代码来源:sps.C

示例2: HatchingSimplexDataFixed

/////////////////////////////////////
// get_visibility()
/////////////////////////////////////
void
HatchingGroupFixed::get_visibility(TAGformat &d)
{
   err_mesg(ERR_LEV_SPAM, "HatchingGroupFixed::get_visibility()"); 

   BMESH *m = _patch->mesh();
   if (LMESH::isa(m))
      m = ((LMESH*)m)->cur_mesh();

   int k, ctr=0;
   ARRAY<int> indices;
   CBface_list& faces = m->faces();

   *d >> indices;

   for (k=0; k<indices.num(); k++)
      {
         HatchingSimplexDataFixed *hsdf =
            HatchingSimplexDataFixed::find(faces[indices[k]]);
         if (!hsdf) 
            {
               hsdf = new HatchingSimplexDataFixed(faces[indices[k]]);
               ctr++;
            }
         hsdf->add(this);
      }

   err_mesg(ERR_LEV_SPAM, "HatchingGroupFixed::get_visibility() - Flagged %d tris and added %d new simplex data.", indices.num(), ctr); 


}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:34,代码来源:hatching_group_fixed.C

示例3:

void
UVdata::split(CEdgeStrip& strip)
{
   ARRAY<Bvert_list> chains;
   strip.get_chains(chains);
   for (int i=0; i<chains.num(); i++)
      split_chain(chains[i]);
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:8,代码来源:uv_data.C

示例4: assert

inline Wpt_list
get_pts(Bface_list& flist, ARRAY<Wvec>& blist)
{
   assert(flist.num() == blist.num());
   Wpt_list pts;
   for (int i = 0; i < flist.num(); i++) {
      Wpt pt;
      flist[i]->bc2pos(blist[i], pt);
      pts += pt;
   }
   return pts;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:12,代码来源:sps.C

示例5: dorand

inline
int
pick (ARRAY<QuadtreeNode*>& l)
{
   int ret = -1;
   double total_w = 0.0;
   for (int i = 0; i < l.num(); i++) {
      total_w += l[i]->get_weight();
   }
   double r = dorand() * total_w;
   
   total_w = 0.0;
   for (int i = 0; i < l.num(); i++) {
      total_w += l[i]->get_weight();
      if (total_w >= r) {
         ret = i;
         break;
      }
   }
   return ret;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:21,代码来源:sps.C

示例6: make_chain

int make_chain(ARRAY<NDCZpt*>& V, int (*cmp)(const void*, const void*)) 
{
	int i, j, s = 1; 	NDCZpt *tmp;
	V.sort(cmp);
	for (i=2; i<V.num(); i++) 
   {
      for (j=s; j>=1 ; j--)
         if ((det(NDCvec(*(V[i]) - *(V[j])),	NDCvec(*(V[j-1]) - *(V[j]))) > 0)) break;
		s = j+1;
		tmp = V[s]; V[s] = V[i]; V[i] = tmp;
	}
	return s;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:13,代码来源:hatching_group_fixed.C

示例7: QuadtreeNode

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);
   }
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:50,代码来源:sps.C

示例8: strip

inline void
show_polys(BMESH* m)
{
   // for debugging: show polyline edges of a mesh

   if (!m) return;
   // Construct filter that accepts unreached polyline edges 
   UnreachedSimplexFilter    unreached;
   PolylineEdgeFilter        poly;

   EdgeStrip strip(m->edges(), unreached + poly);
   ARRAY<Bvert_list> chains;
   strip.get_chains(chains);
   for (int i=0; i<chains.num(); i++)
      WORLD::show_polyline(chains[i].pts(), 3, Color::blue_pencil_d, 0.5);
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:16,代码来源:skin.C

示例9:

void
assign_weights(ARRAY<QuadtreeNode*>& fs, double regularity, CWpt& pt)
{
   double weight, d;
   QuadtreeNode* leaf;
   for (int i = 0; i < fs.num(); i++) {
      weight = 0.0;
      for (int j = 0; j < fs[i]->terms().num(); j++) {
         leaf = fs[i]->terms()[j];
         d = pt.dist(leaf->centroid());
         leaf->set_weight(distr_func(regularity, d) * leaf->area());
         weight += leaf->get_weight();
      }
      fs[i]->set_weight(weight);
   }
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:16,代码来源:sps.C

示例10: assert

void
SkinCurveMap::set_pts(CBsimplex_list& simps, ARRAY<Wvec>& bcs)
{
   assert(simps.num() == bcs.num());
   
   _simps = simps;
   _bcs = bcs;

   static bool debug = Config::get_var_bool("DEBUG_SKIN_CURVE_SETUV",false,true);

   if (debug) {
      cerr << "-- In SkinCurveMap::set_ptss() got hte following simp/bc pair list" << endl;
      int i;
      for (i = 0; i < _simps.num(); i++) {
         cerr << i << " " << _simps[i] << "; " << _bcs[i] << endl;
      }
      cerr << "-- End list" << endl;
   }

   // Notify dependents they're out of date and sign up to be
   // recomputed
   invalidate();
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:23,代码来源:skin.C

示例11: assert

void 
ProxySurface::trim_proxy_surface()
{
   assert(_proxy_mesh);

   int n = 0; //number of faces outside the bounding box   
   //get all the quads
   Bface_list faces = _proxy_mesh->faces();
   //clear out all the markings
   for(int i=0; i < faces.num(); ++i)
   {
      if(faces[i])
         ProxyData::set_mark(faces[i],this, false);
      //else
      //   cerr << "FACE is NULL" << endl;
   }
   //mark all the faces that do not overap bounding box
   for(int i=0; i < faces.num(); ++i)
   {
      if(faces[i]){
         bool t1 = (is_inside_bounding_box(faces[i]->e1())) ? true : false;
         bool t2 = (is_inside_bounding_box(faces[i]->e2())) ? true : false;
         bool t3 = (is_inside_bounding_box(faces[i]->e3())) ? true : false;
         
         // If all the edges are outside, then mark the face
         if(!t1 && !t2 && !t3){
            //cerr << "we can delete this face" << endl;
            ProxyData::set_mark(faces[i], this, true);
            n++;
         }
      }else {
         //cerr << "FACE is NULL" << endl;
      }
   }

   if(n < 1)
      return; 

   //for all verts check to see if all the faces that it is attached to has a marked
   Bvert_list verts = _proxy_mesh->verts();
   for(int i=0; i < verts.num(); ++i)
   {
      ARRAY<Bface*> ret;
      verts[i]->get_quad_faces(ret);
      // Make sure that all adjasent faces need to be deleted
      bool do_it=true;
      for(int k=0; k < ret.num(); ++k)
      {
         if(ret[k]){
            assert(ret[k]->is_quad());            
            if(!ProxyData::get_mark(ret[k], this) || !ProxyData::get_mark(ret[k]->quad_partner(), this))
            {
              // cerr << "vert degree " << verts[i]->p_degree() << endl;
               do_it = false;
               break;
            }
         }
      }
      if(do_it){
         UVpt remove_uv;
         UVdata::get_uv(verts[i], remove_uv);
         remove_vert_grid(remove_uv);

         _proxy_mesh->remove_vertex(verts[i]);
         _proxy_mesh->changed();
      }
   }
   //clean up faces
   Bface_list faces2 = _proxy_mesh->faces();
   for(int i=0; i < faces2.num(); ++i)
   {
      if(!(faces2[i]->is_quad()) || !(faces2[i]->quad_partner())){
         _proxy_mesh->remove_face(faces2[i]);
         _proxy_mesh->changed();
      }
      
   }

   //debug_grid();

   
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:82,代码来源:proxy_surface.C

示例12: ftemp

void 
remove_nodes(Bface_list& flist, ARRAY<Wvec>& blist, double min_dist, ARRAY<OctreeNode*>& t)
{
//    if (flist.num() != blist.num()) {
//       return;
//    }
   assert(flist.num() == blist.num());
   Wpt_list pts = get_pts(flist, blist);
   ARRAY< ARRAY<int> > N;
   ARRAY<bool> to_remove;
   for (int i = 0; i < pts.num(); i++) {
      N += ARRAY<int>();
      to_remove += false;
   }

   for (int i = 0; i < pts.num(); i++) {
      for (int j = 0; j < t[i]->neibors().num(); j++) {
         int index = t[i]->neibors()[j]->get_term_index();
         
         if (index < pts.num())
         {
            if (pts[i].dist(pts[index]) < min_dist) {
               N[i] += index;
               N[index] += i;
            }
         }
         else
         {
            //cerr << "Sps Warning, index > pts.num()" << endl;
         }

      }
   }

   priority_queue< Priority, vector<Priority> > queue;
   ARRAY<int> versions;
   for (int i = 0; i < pts.num(); i++) {
      if (!to_remove[i] && !N[i].empty()) {
         Priority p;
         p._priority = center(pts, N[i]).dist(pts[i]);
         p._index = i;
         p._version = 0;
         queue.push(p);
      }
      versions += 0;
   }

   while (!queue.empty()) {
      Priority p = queue.top();
      queue.pop();
      int r = p._index;
      if (p._version == versions[r]) {
         to_remove[r] = true;
         for (int i = 0; i < N[r].num(); i++) {
            N[N[r][i]] -= r;
            versions[N[r][i]]++;
            if (!N[N[r][i]].empty()) {
               Priority q;
               q._priority = center(pts, N[N[r][i]]).dist(pts[N[r][i]]);
               q._index = N[r][i];
               q._version = versions[N[r][i]];
               queue.push(q);
            }
         }
      }
   }
   versions.clear();

   Bface_list ftemp(flist);
   ARRAY<Wvec> btemp(blist);
   flist.clear();
   blist.clear();
   for (int i = 0; i < ftemp.num(); i++)
      if (!to_remove[i]) {
         flist += ftemp[i];
         blist += btemp[i];
      }
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:78,代码来源:sps.C

示例13: if

/////////////////////////////////////
// add()
/////////////////////////////////////
bool
HatchingGroupFixed::add(
   CNDCpt_list &pl,
   const ARRAY<double>&prl,
   int curve_type
   )
{
   int k;
   double a,b;
   Bface *f;

   // It happens:
   if (pl.empty()) 
   {
      err_mesg(ERR_LEV_ERROR, "HatchingGroupFixed:add() - Error: point list is empty!");
      return false;
   }
   if (prl.empty()) 
   {
      err_mesg(ERR_LEV_ERROR, "HatchingGroupFixed:add() - Error: pressure list is empty!");
      return false;
   }

   if (pl.num() != prl.num())
   {
      err_mesg(ERR_LEV_ERROR, "HatchingGroupFixed:add() - gesture pixel list and pressure list are not same length.");
      return false;
   }

   err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - smoothing gesture.");

   //Smooth the input gesture
   NDCpt_list              smoothpts;
   ARRAY<double>           smoothprl;
   if (!smooth_gesture(pl, smoothpts, prl, smoothprl, _params.anim_style()))
      return false;

   err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - clipping gesture to model.");

   NDCpt_list              ndcpts;
   ARRAY<double>           finalprl;
   clip_to_patch(smoothpts,ndcpts,smoothprl,finalprl);
   ndcpts.update_length();

   err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed::add() - Checking gesture silliness.");

   if (HatchingGroupBase::is_gesture_silly(ndcpts,_params.anim_style()))
   {
      err_mesg(ERR_LEV_WARN, "HatchingGroupFixed::add() - Punting silly gesture...");
      return false;
   }

   //Even if the user wants to project to create the
   //hatch, we continue with plane cutting to
   //generate a curve we can use to estimate
   //the mesh spacing so that the final projected
   //hatch is sampled evenly on the level of the mesh
   //spacing

   //Get the cutting line
   err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - fitting line.");
   if (!fit_line(ndcpts,a,b)) return false;

   //Slide to midpoint if desired
   if (Config::get_var_bool("HATCHING_GROUP_SLIDE_FIT",false,true)) 
      b = ndcpts.interpolate(0.5)[1] - (a*ndcpts.interpolate(0.5)[0]);

   err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - computing plane.");

   //Find the cutting plane
   Wplane wpPlane;
   f = compute_cutting_plane(_patch, a, b, ndcpts, wpPlane);
   if (!f) return false;
   else
   {
      if (!f->front_facing())
      {
         err_mesg(ERR_LEV_WARN, "HatchingGroupFixed::add() - Nearest pt. on fit line hit backfacing surface.");
         return false;
      }
   }

   err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - slicing mesh.");
   
   //Intersect the mesh to get a 3D curve
   Wpt_list wlList;
   slice_mesh_with_plane(f,wpPlane,wlList);

   err_mesg_cond(debug, ERR_LEV_SPAM, "HatchingGroupFixed:add() - cliping curve to gesture.");

   //Clip end of 3D curve to match gesture
   Wpt_list wlClipList;
   clip_curve_to_stroke(_patch, ndcpts, wlList, wlClipList);
   wlClipList.update_length();

   Wpt_list wlScaledList;

//.........这里部分代码省略.........
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:101,代码来源:hatching_group_fixed.C

示例14:

/////////////////////////////////////
// put_visibility()
/////////////////////////////////////
void
HatchingGroupFixed::put_visibility(TAGformat &d) const
{
   err_mesg(ERR_LEV_SPAM, "HatchingGroupFixed::put_visibility()"); 

   BMESH *m = _patch->mesh();
   if (LMESH::isa(m))
      m = ((LMESH*)m)->cur_mesh();

   int k;
   ARRAY<int> indices;
   CBface_list& faces = m->faces();
        
   for (k=0; k< faces.num(); k++)
      {
         HatchingSimplexDataFixed *hsdf = HatchingSimplexDataFixed::find(faces[k]);
         if (hsdf) 
            {
               if(hsdf->hack_exists(this))
                  indices += faces[k]->index();
            }
      }
   err_mesg(ERR_LEV_SPAM, "HatchingGroupFixed::put_visibility() - Stored %d tri indices.", indices.num()); 

   d.id();
   *d << indices;
   d.end_id();
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:31,代码来源:hatching_group_fixed.C

示例15: assert

/////////////////////////////////////
// recurse()
/////////////////////////////////////
void      
UVMapping::recurse(Bface *seed_f, rec_fun_t fun )
{           
   int k;
//   bool done = false;

   Bface*                  f;
   ARRAY<Bface*>   faces;

   assert(seed_f);

   faces.push(seed_f);

   while (faces.num()>0)
      {
         //Remove oldest face from end of queue
         f = faces.pop();

         //Skip if already seen
         if (!f->is_set(1))
            {
               f->set_bit(1);

               //If we get here, then this face *should* have uvdata
               //and *should* be unmapped
               UVdata* uvdata = UVdata::lookup(f);
               assert(uvdata);
               assert(uvdata->mapping()==0);

               //Do the action (add to map, or update limits, etc.)
               (this->*fun)(f);

               for (k=1; k<=3; k++)
                  {
                     Bedge *nxt_e = f->e(k);
                     assert(nxt_e);
                     Bface *nxt_f = nxt_e->other_face(f);
                     if (nxt_f)
                        {
                           UVdata *nxt_uvdata = UVdata::lookup(nxt_f);
                           if (nxt_uvdata)
                              {
                                 UVpt uva = uvdata->uv(k);
                                 UVpt uvb = uvdata->uv((k==3)?(1):(k+1));
                                 int nxt_k = ( (nxt_f->e1()==nxt_e)?(1):
                                               ((nxt_f->e2()==nxt_e)?(2):
                                                ((nxt_f->e3()==nxt_e)?(3):(0))));
                                 assert(nxt_k);
                                 UVpt nxt_uva = nxt_uvdata->uv(nxt_k);
                                 UVpt nxt_uvb = nxt_uvdata->uv((nxt_k==3)?(1):(nxt_k+1));

                                 //If neighboring face has uv, and the they match
                                 //we recurse into this next face
                                 if ((uva==nxt_uvb)&&(uvb==nxt_uva))
                                    {
                                       //Add to front of queue
                                       faces.push(nxt_f);
                                    }
                                 else {
                                    //Nothing
                                 }
                              }
                        }
                  }
            }
      }
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:70,代码来源:uv_mapping.C


注:本文中的ARRAY::num方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。