当前位置: 首页 > news >正文

做课内教学网站海外推广渠道

做课内教学网站,海外推广渠道,代理注册公司需要什么资料,wordpress的搭建环境搭建前一段事件看到VTK的一个例子: 该案例是vtk.js写的,觉得很有意思,个人正好也要用到,于是萌生了用C修改VTK源码来实现该功能的想法。原本以为很简单,只需要修改一下vtkResliceCursor就可以了,加上小球&#…

        前一段事件看到VTK的一个例子:

该案例是vtk.js写的,觉得很有意思,个人正好也要用到,于是萌生了用C++修改VTK源码来实现该功能的想法。原本以为很简单,只需要修改一下vtkResliceCursor就可以了,加上小球,加上几个Actor,就能实现,没想到该功能整花了我差不多一个月的时间。但也学到了不少知识,下面就该功能的实现效果和方法做个大致解说:

我实现的效果:

实现方法:

1,首先在vtkResliceCursor中定义六个小球的位置。因为是X,Y,Z三个轴,每个轴上两个小球,所以总共有六个小球。代码:

void vtkResliceCursor::BuildCursorGeometryWithoutHole()
{// 其他源码省略.......for (int i = 0; i < 3; i++){//wulc{this->SpherePoints[0][i] = this->Center[i] - sphereLength * this->XAxis[i];this->SpherePoints[1][i] = this->Center[i] + sphereLength * this->XAxis[i];this->SpherePoints[2][i] = this->Center[i] - sphereLength * this->YAxis[i];this->SpherePoints[3][i] = this->Center[i] + sphereLength * this->YAxis[i];this->SpherePoints[4][i] = this->Center[i] - sphereLength * this->ZAxis[i];this->SpherePoints[5][i] = this->Center[i] + sphereLength * this->ZAxis[i];}}// 其他源码省略.......
}sphereLength 是一个自定义的常数,也就是中心到小球的距离。可以是 30 ,40 ,50 .。。。。

 除此之外我们还要定义一个函数,通过该函数可以获取这六个小球的坐标。比如 GetPointPosition(double p[6][3]);

2,在vtkResliceCursorPicker中判断鼠标是否靠近小球中心位置,靠近小球坐标时,将鼠标光标变为手掌形状。判断方法就是鼠标的位置和小球位置的距离,其中有现成的代码:

/----------------wulc---------------------------------------------------
int vtkResliceCursorPicker::IntersectPointWithPoint(double p1[3], double p2[3], double Points[], double tol)
{double pts[6][3] = { {0,0,0} };for (size_t i = 0; i < 6; i++){pts[i][0] = Points[3*i];pts[i][1] = Points[3*i + 1];pts[i][2] = Points[3 * i + 2];}int j = 0;for ( ; j < 6; j++){double X[4] = { pts[j][0], pts[j][1], pts[j][2], 1 };int i;double ray[3], rayFactor, projXYZ[3];for (i = 0; i < 3; i++){ray[i] = p2[i] - p1[i];}if ((rayFactor = vtkMath::Dot(ray, ray)) == 0.0){return 0;}const double t = (ray[0] * (X[0] - p1[0]) +ray[1] * (X[1] - p1[1]) +ray[2] * (X[2] - p1[2])) / rayFactor;if (t >= 0.0 && t <= 1.0){for (i = 0; i < 3; i++){projXYZ[i] = p1[i] + t * ray[i];if (fabs(X[i] - projXYZ[i]) > tol){break;}}if (i > 2) // within tolerance{return 1;}}}return 0;
}

 3,最后要在vtkResliceCursorActor类中添加小球,代码:

//wulcif (this->Renderer == nullptr) return;if (axisNormal == 1)//x-z平面{double* position = this->CursorAlgorithm->GetResliceCursor()->GetSpherePostion(2);if (fabs(position[0] - 0.0) > 0.001 || fabs(position[1] - 0.0) > 0.001 || fabs(position[2] - 0.0) > 0.001){this->SphereActor[2]->GetProperty()->SetColor(1, 0, 0);this->SphereActor[3]->GetProperty()->SetColor(1, 0, 0);this->SphereActor[2]->SetPosition(position[0], position[1], position[2]);this->SphereActor[3]->SetPosition(position[3], position[4], position[5]);position = this->CursorAlgorithm->GetResliceCursor()->GetSpherePostion(0);this->SphereActor[0]->GetProperty()->SetColor(0, 0, 1);this->SphereActor[1]->GetProperty()->SetColor(0, 0, 1);this->SphereActor[0]->SetPosition(position[0], position[1], position[2]);this->SphereActor[1]->SetPosition(position[3], position[4], position[5]);}}else if (axisNormal == 2)//x-y平面{double* position = this->CursorAlgorithm->GetResliceCursor()->GetSpherePostion(0);if (fabs(position[0] - 0.0) > 0.001 || fabs(position[1] - 0.0) > 0.001 || fabs(position[2] - 0.0) > 0.001){this->SphereActor[0]->GetProperty()->SetColor(0, 1, 0);this->SphereActor[1]->GetProperty()->SetColor(0, 1, 0);this->SphereActor[0]->SetPosition(position[0], position[1], position[2]);this->SphereActor[1]->SetPosition(position[3], position[4], position[5]);position = this->CursorAlgorithm->GetResliceCursor()->GetSpherePostion(1);this->SphereActor[2]->GetProperty()->SetColor(1, 0, 0);this->SphereActor[3]->GetProperty()->SetColor(1, 0, 0);this->SphereActor[2]->SetPosition(position[0], position[1], position[2]);this->SphereActor[3]->SetPosition(position[3], position[4], position[5]);}}else if (axisNormal == 0) //y-z平面{double* position = this->CursorAlgorithm->GetResliceCursor()->GetSpherePostion(2);if (fabs(position[0] - 0.0) > 0.001 || fabs(position[1] - 0.0) > 0.001 || fabs(position[2] - 0.0) > 0.001){this->SphereActor[0]->GetProperty()->SetColor(0, 1, 0);this->SphereActor[1]->GetProperty()->SetColor(0, 1, 0);this->SphereActor[0]->SetPosition(position[0], position[1], position[2]);this->SphereActor[1]->SetPosition(position[3], position[4], position[5]);position = this->CursorAlgorithm->GetResliceCursor()->GetSpherePostion(1);this->SphereActor[2]->GetProperty()->SetColor(0, 0, 1);this->SphereActor[3]->GetProperty()->SetColor(0, 0, 1);this->SphereActor[2]->SetPosition(position[0], position[1], position[2]);this->SphereActor[3]->SetPosition(position[3], position[4], position[5]);}}

这就可以了,欢迎小伙伴能够一块讨论。

http://www.tj-hxxt.cn/news/127702.html

相关文章:

  • 东莞招聘网人才网百度seo公司哪家最好
  • b站推广网站2024mmm不用下载网络兼职平台
  • 做网站周记搜索
  • 石家庄新华区网站建设网站seo快速
  • 长乐区建设局网站关键词排名优化易下拉排名
  • 广州高铁新建站在哪里线下推广都有什么方式
  • 深圳购物网站高级seo优化招聘
  • 网站关键词没被搜出来无锡网站优化
  • php动态网页源码贵阳关键词优化平台
  • 做网站怎么返回首页独立网站
  • 网站建设流程服务日本樱花免m38vcom费vps
  • 网站建设的行业分析关键词分类哪八种
  • 做一网站需要多少钱软文写作实训总结
  • 腾讯云10g数字盘做网站够么360搜索指数
  • 网站制作网站制作公司做一个个人网站
  • 顺德网站制作公司网址之家大全
  • 网站建设行业网站推广软文范例
  • 南京做网站建设的公司滨州网站seo
  • 政府门户网站建设的目的微信上如何投放广告
  • 建设网站申请四川最好的网络优化公司
  • wap手机网站开发平台开发
  • 招商网站大全五金电器企业获客方式
  • 网站建设 分类广告百度网站登录
  • 中小企业新闻网站建设百度推广运营公司
  • 网站样式侵权网站收录提交工具
  • 怎么建设网站seo综合检测
  • 广州的网站建设公司百度文库官网登录入口
  • 响应式手机网站制作优化大师怎么提交作业
  • 网站线上推广方式广州百度seo代理
  • 在网站后台备案号怎么改百度推广注册