您现在的位置:网站首页 > 经验分享 > 基于Rhino的三维鞋业CAD软件开发[
设计师介绍:

昵称:烦夫子
类别:界面/平面设计师
年龄:38
现所在地:北京

查看该设计师的主页>>

关注好友

统计中心

主页浏览总数:24259
总积分:89
文章数:88
作品数:70

基于Rhino的三维鞋业CAD软件开发[

作者:烦夫子  更新时间: 2007-11-19   浏览人数:17951  评论:0  
分享到:
开放源码:
                            RHINO三维图形开发平台
                                     [6]
 
// 自定义样条曲线绘制
CRhinoCommand::result CCommandmyDrawCurve::RunCommand( const CRhinoCommandContext& context )
{
  for(;;) {
 CRhinoDoc *doc = RhinoApp().ActiveDoc();
 //----------------------- debug curve draw --------------------
 CRhinoGetObject get;
  if (get.GetObjects(1,0) != CRhinoGetObject::object)
   return CRhinoCommand::cancel;
  CRhinoObjRef ōbj = get.Object(0);
  ON_NurbsCurve mycrv;
   const ON_Curve* crv = ON_Curve::Cast(obj.Geometry());
  crv->GetNurbForm(mycrv);
  int dimension = mycrv.Dimension();
  int cvnum = mycrv.m_cv_count;
     double *cvpoint;
  cvpoint = mycrv.m_cv;
  double *my_knot = mycrv.m_knot;
     int my_order = mycrv.m_order;
     ON_3dPoint cvpt;
     //得到指定的控制结点
  for (int k = 0; k < cvnum; k++){
     mycrv.GetCV(k,cvpt);
  }
  mycrv.InsertKnot(2,1);
 
     //---------------------- debug end -------------------------
  ON_NurbsCurve nurbcrv(3,0,4,7);
 
     //nurbcrv.MakeClampedUniformKnotVector();
     for(int i=0; i<7;i++)
            nurbcrv.SetCV( i, ON_3dPoint( i, i*i, 0));
     nurbcrv.SetCV(0, ON_3dPoint(-10,0,0));
     nurbcrv.SetCV(1, ON_3dPoint(0,10,0));
  nurbcrv.SetCV(2, ON_3dPoint(10,0,0));
  nurbcrv.SetCV(3, ON_3dPoint(20,-10,0)); 
  nurbcrv.SetCV(4, ON_3dPoint(30,0,0));
  nurbcrv.SetCV(5, ON_3dPoint(40,10,0));
  nurbcrv.SetCV(6, ON_3dPoint(50,0,0));

    for(int j=0; j            if( j<3)
                nurbcrv.SetKnot(j,0.0);
            else if(j<(nurbcrv.KnotCount()-3))
                nurbcrv.SetKnot(j,j-1);
            else
                nurbcrv.SetKnot(j,(nurbcrv.KnotCount()-1));
         };
     nurbcrv.SetKnot(0,0);
  nurbcrv.SetKnot(1,0);
     nurbcrv.SetKnot(2,0);
     nurbcrv.SetKnot(3,1);
  nurbcrv.SetKnot(4,2);
  nurbcrv.SetKnot(5,3);
  nurbcrv.SetKnot(6,4);
     nurbcrv.SetKnot(7,4);
  nurbcrv.SetKnot(8,4);
    ON_Interval dom = nurbcrv.Domain();
     int knotcount = nurbcrv.KnotCount();
  
     CRhinoCurveObject* my_cur_obj = new CRhinoCurveObject();
  my_cur_obj->SetCurve(nurbcrv);
  doc->AddObject(my_cur_obj,false,false);
  doc->Redraw();
     break;
  }
 return CRhinoCommand::success;
}
//
// END myDrawCurve command
(目前有0人发表看法,  我要发表评论
我要评论:
  只有登录后才能评论!
评论者: 匿名游客    (立即登录 或 注册)