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


C++ ON_Brep::GetMesh方法代码示例

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


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

示例1:

vtkActor* gfxRhino3D::createActor(const ON_Object *object, double red, double green, double blue){
  ON_Brep *brep;
  ON_SimpleArray<const ON_Mesh*> cmsh;
  int i, j, k, l, npts;
  double x1,x2,x3,x4, y1,y2,y3,y4, z1,z2,z3,z4;
  
  // Add Meshes to list
  parentObject->points = vtkSmartPointer<vtkPoints>::New();
  vtkSmartPointer<vtkCellArray> list = vtkSmartPointer<vtkCellArray>::New();
   
  brep=0;
  brep = (ON_Brep*)ON_Brep::Cast(object);
  if (brep){
    brep->GetMesh(ON::render_mesh, cmsh);
    if (cmsh.Count()>0){
      for (l=0;l<cmsh.Count();l++){
        npts=parentObject->points->GetNumberOfPoints();
        for (j=0;j<cmsh[l]->m_V.Count();j++) parentObject->points->InsertNextPoint(cmsh[l]->m_V[j].x, cmsh[l]->m_V[j].y, cmsh[l]->m_V[j].z);
        for (j=0;j<cmsh[l]->m_F.Count();j++){  
          if (cmsh[l]->m_F[j].IsTriangle()){
            vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
            for (k=0;k<3;k++) triangle->GetPointIds()->SetId(k,cmsh[l]->m_F[j].vi[k]+npts);
            list->InsertNextCell(triangle);
          }else{
            vtkSmartPointer<vtkQuad> quad = vtkSmartPointer<vtkQuad>::New();
            for (k=0;k<4;k++) quad->GetPointIds()->SetId(k,cmsh[l]->m_F[j].vi[k]+npts);
            list->InsertNextCell(quad);
          }
        }
      }
    }
  }
  
  //Create a polydata object and add data
  vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
  polydata->SetPoints(parentObject->points);
  polydata->SetPolys(list);
  
  //Create Mapper
  vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
  mapper->SetInput(polydata);
  mapper->SetScalarRange(0.,1.);
  
  //Create Actor
  vtkActor *tmpActor = vtkActor::New();
  tmpActor->SetMapper(mapper);
  tmpActor->GetProperty()->SetInterpolationToGouraud();

 // void  SetInterpolationToFlat()
//  void  SetInterpolationToGouraud()
//  void  SetInterpolationToPhong()

  tmpActor->GetProperty()->SetColor(red, green, blue);
  return tmpActor;  
}
开发者ID:TimB-QNA,项目名称:AeroTelemetry,代码行数:55,代码来源:gfxRhino3D.cpp


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