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


C++ ON_Brep类代码示例

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


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

示例1: brep_build_bvh

int
brep_build_bvh(struct brep_specific* bs, struct rt_brep_internal* bi)
{
    ON_TextLog tl(stderr);
    ON_Brep* brep = bs->brep;
    if (brep == NULL || !brep->IsValid(&tl)) {
	bu_log("brep is NOT valid");
	return -1;
    }

    bs->bvh = new BBNode(brep->BoundingBox());

    // need to extract faces, and build bounding boxes for each face,
    // then combine the face BBs back up, combining them together to
    // better split the hierarchy
    std::list<SurfaceTree*> surface_trees;
    ON_BrepFaceArray& faces = brep->m_F;
    for (int i = 0; i < faces.Count(); i++) {
        TRACE1("Face: " << i);
	ON_BrepFace& face = faces[i];

	SurfaceTree* st = new SurfaceTree(&face);
	face.m_face_user.p = st;
	brep_preprocess_trims(face, st);

	// add the surface bounding volumes to a list, so we can build
	// down a hierarchy from the brep bounding volume
	surface_trees.push_back(st);
    }

    brep_bvh_subdivide(bs->bvh, surface_trees);

    return 0;
}
开发者ID:cciechad,项目名称:brlcad,代码行数:34,代码来源:brep.cpp

示例2: MakeBilinearSurface

CRhinoCommand::result CCommandTestHistoryExample::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoCommand::result rc  = CRhinoCommand::failure; 

  CRhinoGetObject go;
  go.SetCommandPrompt(L"Pick two curves");
  go.SetGeometryFilter(CRhinoGetObject::curve_object);
  go.GetObjects(2,2);
  if( go.Result()== CRhinoGet::object && 
      go.ObjectCount()==2)
  {
    CRhinoObjRef CObj0 = go.Object(0);
    CRhinoObjRef CObj1 = go.Object(1);
    const ON_Curve* c0 = CObj0.Curve();
    const ON_Curve* c1 = CObj1.Curve();
    if( c0 && c1)
    {
      ON_Surface* pSrf = MakeBilinearSurface( *c0, *c1);
      ON_Brep brep;
      if(pSrf && brep.Create(pSrf))
      {
        CRhinoHistory history(*this);
        WriteHistory(history,  CObj0, CObj1);
        context.m_doc.AddBrepObject(brep,NULL,&history);
        rc  = CRhinoCommand::success; 
      }
    }

  }

  return rc;
}
开发者ID:buonmethuoc,项目名称:Rhino4Samples_CPP,代码行数:32,代码来源:cmdTestHistoryExample.cpp

示例3: DuplicateSurface

ON_Brep* ON_Surface::BrepForm( ON_Brep* brep ) const
{
  ON_Brep* pBrep = NULL;
  if ( brep )
    brep->Destroy();
  // 26 August 2008 Dale Lear - fixed bug
  //    When this function was called on an ON_SurfaceProxy
  //ON_Surface* pSurface = Duplicate();
  ON_Surface* pSurface = DuplicateSurface();
  if ( pSurface )
  {
    if ( brep )
      pBrep = brep;
    else
      pBrep = new ON_Brep();
    if ( !pBrep->Create(pSurface) )
    {
      if ( pSurface )
      {
        delete pSurface;
        pSurface = NULL;
      }
      if ( !brep )
        delete pBrep;
      pBrep = NULL;
    }
  }
  return pBrep;
}
开发者ID:Bastl34,项目名称:PCL,代码行数:29,代码来源:opennurbs_surface.cpp

示例4:

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

示例5: ON_BrepExtrudeHelper_MakeCap

static
bool ON_BrepExtrudeHelper_MakeCap(
          ON_Brep& brep,
          int bottom_loop_index,
          const ON_3dVector path_vector,
          const int* side_face_index
          )
{
  bool bCap = true;
  // make cap
  if ( !ON_BrepExtrudeHelper_CheckLoop( brep, bottom_loop_index ) )
    return false;
  brep.m_F.Reserve(brep.m_F.Count() + 1);
  brep.m_L.Reserve(brep.m_L.Count() + 1);
  const ON_BrepLoop& bottom_loop = brep.m_L[bottom_loop_index];
  const ON_BrepFace& bottom_face = brep.m_F[bottom_loop.m_fi];
  const ON_Surface* bottom_surface = bottom_face.SurfaceOf();
  ON_Surface* top_surface = bottom_surface->Duplicate();
  top_surface->Translate( path_vector );
  int top_surface_index = brep.AddSurface( top_surface );
  ON_BrepFace& top_face = brep.NewFace( top_surface_index );

  bCap = ON_BrepExtrudeHelper_MakeTopLoop( brep, top_face, bottom_loop_index, path_vector, side_face_index );
  if ( bCap )
  {
    ON_BrepLoop& top_loop = brep.m_L[brep.m_L.Count()-1];
    if ( bottom_loop.m_type == ON_BrepLoop::inner )
    {
      // we capped an inner boundary
      // top_loop.m_type = ON_BrepLoop::outer; // done in ON_BrepExtrudeHelper_MakeTopLoop
      brep.FlipLoop(top_loop);
    }
    else if ( bottom_loop.m_type == ON_BrepLoop::outer )
    {
      // we capped an outer boundary
      // top_loop.m_type = ON_BrepLoop::outer; // done in ON_BrepExtrudeHelper_MakeTopLoop
      brep.FlipFace(top_face);
    }
  }
  else
  {
    // delete partially made cap face
    brep.DeleteFace( top_face, false );
    delete brep.m_S[top_surface_index];
    brep.m_S[top_surface_index] = 0;
  }
  return bCap;
}
开发者ID:ToMadoRe,项目名称:v4r,代码行数:48,代码来源:opennurbs_brep_extrude.cpp

示例6: MakeTrimmedFace

static void MakeTrimmedFace( ON_Brep& brep,
     int si,      // index of 3d surface
     int s_dir,   // orientation of surface with respect to surfce
     int v0, int v1, int v2, // Indices of corner vertices
     int e0,     // index of first edge
     int e0_dir,  // orientation of edge
     int e1,     // index of second edge
     int e1_dir,  // orientation of edge
     int e2,     // index of third edge
     int e2_dir  // orientation of edge
                           )
{
	//Add new face to brep
  ON_BrepFace& face = brep.NewFace(si);

	//Create loop and trims for the face
  MakeTrimmingLoop( brep, face,
                v0, v1, v2, 
                e0, e0_dir, 
                e1, e1_dir, 
                e2, e2_dir 
                );

	//Set face direction relative to surface direction
  face.m_bRev = (s_dir == -1);
}
开发者ID:buonmethuoc,项目名称:Rhino4Samples_CPP,代码行数:26,代码来源:cmdTestTrimmedPlaneSample.cpp

示例7: MakeTwistedCubeFace

static void MakeTwistedCubeFace( ON_Brep& brep,
     int si,      // index of 3d surface
     int s_dir,   // orientation of surface with respect to brep
     //int vSWi, int vSEi, int vNEi, int vNWi, // Indices of corner vertices listed in SW,SE,NW,NE order
     int eSi,     // index of edge on south side of surface
     int eS_dir,  // orientation of edge with respect to surface trim
     int eEi,     // index of edge on south side of surface
     int eE_dir,  // orientation of edge with respect to surface trim
     int eNi,     // index of edge on south side of surface
     int eN_dir,  // orientation of edge with respect to surface trim
     int eWi,     // index of edge on south side of surface
     int eW_dir   // orientation of edge with respect to surface trim
                                )
{
  ON_BrepFace& face = brep.NewFace(si);

  MakeTwistedCubeTrimmingLoop( brep, face,
                //vSWi, vSEi, vNEi, vNWi, 
                eSi, eS_dir, 
                eEi, eE_dir, 
                eNi, eN_dir, 
                eWi, eW_dir 
                );

  face.m_bRev = (s_dir == -1);
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:26,代码来源:example_brep.cpp

示例8: MakeTwistedCubeEdge

void
MakeTwistedCubeEdge(ON_Brep& brep, int from, int to, int curve)
{
    ON_BrepVertex& v0 = brep.m_V[from];
    ON_BrepVertex& v1 = brep.m_V[to];
    ON_BrepEdge& edge = brep.NewEdge(v0,v1,curve);
    edge.m_tolerance = 0.0; // exact!
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例9: GetOtherFace

// ANSWER:
// An ON_BrepEdge is connector for joining ON_BrepTrim objects and representing
// a 3-D location of the seam they form.  An Edge can connect 1 or more trims.
// In the case of a simple "joined edge" there will be 2 trims, one from each
// adjacent face. In a closed face, like a cylinder, the trims will be different
// on each side of the face, and they will both be in the same loop and belong to
// the same face.
static const ON_BrepFace* GetOtherFace(const ON_BrepTrim* trim)
{
  ON_BrepFace* face = 0;
  if (0 == trim)  
    return 0;

  ON_Brep* brep = trim->Brep();
  if (0 == brep)
    return 0;

  const ON_BrepEdge* edge = trim->Edge();
  if (0 == edge)
    return 0;

  // Trim count on a proper joined edge should be 2.
  const int trim_count = edge->TrimCount();
  if (trim_count < 2)
    return 0;  // Not joined
  if (trim_count > 2)
    return 0;  // Joined to more than one other surface (non-manifold)

  for (int i = 0; i < trim_count; i++)
  {
    // Look for a trim that's not the same as the input one
    // edge->m_ti is an array of indexes of the trims connected to an edge
    const ON_BrepTrim* other_trim = brep->Trim(edge->m_ti[i]);
    if (0 != other_trim && trim != other_trim)
    {
      // There is another trim on the edge, and its not the same as the input one.
      // So get the face it belonge to.
      face = other_trim->Face();

      // You can also get the loop on the other side of the edge
      //const ON_BrepLoop* other_loop = other_trim->Loop();

      // Or the surface geometry of the face
      //const ON_Surface* srf = face->SurfaceOf();

      break;
    }
  }

  return face;
}
开发者ID:KingOfMazes,项目名称:Rhino5Samples_CPP,代码行数:51,代码来源:cmdSampleAdjacentBrepFace.cpp

示例10: Cobb_Sphere

/* TODO - Need to find a more compact, efficient way to
 * do this - shouldn't need 24 3d curves... */
ON_Brep *
Cobb_Sphere(double UNUSED(radius), ON_3dPoint *UNUSED(origin))
{
    ON_Brep *b = ON_Brep::New();

    // Patch 1 of 6
    ON_BezierSurface *b1 = ON_CobbSphereFace(0, 0);
    ON_NurbsSurface *p1_nurb = ON_NurbsSurface::New();
    b1->GetNurbForm(*p1_nurb);
    b->NewFace(*p1_nurb);

    // Patch 2 of 6
    ON_BezierSurface *b2 = ON_CobbSphereFace(90, 0);
    ON_NurbsSurface *p2_nurb = ON_NurbsSurface::New();
    b2->GetNurbForm(*p2_nurb);
    b->NewFace(*p2_nurb);

    // Patch 3 of 6
    ON_BezierSurface *b3 = ON_CobbSphereFace(180, 0);
    ON_NurbsSurface *p3_nurb = ON_NurbsSurface::New();
    b3->GetNurbForm(*p3_nurb);
    b->NewFace(*p3_nurb);

    // Patch 4 of 6
    ON_BezierSurface *b4 = ON_CobbSphereFace(270, 0);
    ON_NurbsSurface *p4_nurb = ON_NurbsSurface::New();
    b4->GetNurbForm(*p4_nurb);
    b->NewFace(*p4_nurb);

    // Patch 5 of 6
    ON_BezierSurface *b5 = ON_CobbSphereFace(90, 90);
    ON_NurbsSurface *p5_nurb = ON_NurbsSurface::New();
    b5->GetNurbForm(*p5_nurb);
    b->NewFace(*p5_nurb);

    // Patch 6 of 6
    ON_BezierSurface *b6 = ON_CobbSphereFace(90, 270);
    ON_NurbsSurface *p6_nurb = ON_NurbsSurface::New();
    b6->GetNurbForm(*p6_nurb);
    b->NewFace(*p6_nurb);


    b->Standardize();
    b->Compact();

    return b;
}
开发者ID:,项目名称:,代码行数:49,代码来源:

示例11: ON_BrepExtrudeVertex

int ON_BrepExtrudeVertex( 
          ON_Brep& brep,
          int vertex_index,
          const ON_Curve& path_curve
          )
{
  ON_3dVector path_vector;
  if ( vertex_index < 0 && vertex_index >= brep.m_V.Count() )
    return false;
  if ( !ON_BrepExtrudeHelper_CheckPathCurve(path_curve,path_vector) )
    return false;
  ON_Curve* c3 = path_curve.Duplicate();
  brep.m_V.Reserve( brep.m_V.Count() + 1 );
  ON_BrepVertex& v0 = brep.m_V[vertex_index];
  ON_BrepVertex& v1 = brep.NewVertex( v0.point + path_vector, 0.0 );
  c3->Translate( v0.point - c3->PointAtStart() );
  int c3i = brep.AddEdgeCurve( c3 );
  ON_BrepEdge& edge = brep.NewEdge( v0, v1, c3i );
  edge.m_tolerance = 0.0;
  return true;
}
开发者ID:ToMadoRe,项目名称:v4r,代码行数:21,代码来源:opennurbs_brep_extrude.cpp

示例12: ON_Brep_CopyTrims

RH_C_FUNCTION ON_Brep* ON_Brep_CopyTrims( const ON_BrepFace* pConstBrepFace, const ON_Surface* pConstSurface, double tolerance)
{
  ON_Brep* rc = NULL;

  if( pConstBrepFace && pConstSurface )
  {
    ON_Brep* brep = pConstBrepFace->Brep();
    int fi = pConstBrepFace->m_face_index;

    ON_Brep* brp = brep->DuplicateFace(fi, FALSE);
    ON_Surface* srf = pConstSurface->DuplicateSurface();
    
    int si = brp->AddSurface(srf);
    brp->m_F[0].ChangeSurface(si);

    if (brp->RebuildEdges(brp->m_F[0], tolerance, TRUE, TRUE))
    { brp->Compact(); }
    else
    { delete brp; }

    rc = brp;
  }

  return rc;
}
开发者ID:HanselYan,项目名称:rhinocommon,代码行数:25,代码来源:on_brep.cpp

示例13: ChangeTrimVertex

static
bool ChangeTrimVertex( 
         ON_Brep& brep,
         ON_BrepTrim& trim,
         int trim_end,
         int old_vi,
         int new_vi,
         bool bUpdateEdge,
         bool bUpdateMates
         )
{
  // used by ON_Brep::ReplaceSurface() to change trim ends
  if ( trim_end != 0 && trim_end != 1 )
    return false;
  if ( trim.m_vi[trim_end] != old_vi )
    return false;
  if ( old_vi == new_vi )
    return true;
  trim.m_vi[trim_end] = new_vi;

  ON_BrepVertex* v = brep.Vertex(old_vi);
  if ( v )
    v->m_tolerance = ON_UNSET_VALUE;
  v = brep.Vertex(new_vi);
  if ( v )
    v->m_tolerance = ON_UNSET_VALUE;

  bool rc = true;
  if ( bUpdateEdge )
  {
    ON_BrepEdge* edge = brep.Edge(trim.m_ei);
    if ( 0 == edge )
      return true;
    int edge_end = trim.m_bRev3d ? 1-trim_end : trim_end;
    rc = ChangeEdgeVertex( brep, *edge, edge_end, old_vi, new_vi, bUpdateMates );
  }

  return true;
}
开发者ID:ckvk,项目名称:opennurbs,代码行数:39,代码来源:opennurbs_brep_changesrf.cpp

示例14: ON_BrepFace_BrepExtrudeFace

RH_C_FUNCTION ON_Brep* ON_BrepFace_BrepExtrudeFace(const ON_Brep* pConstBrep, int face_index, const ON_Curve* pConstCurve, bool bCap)
{
  ON_Brep* rc = NULL;
  if( pConstBrep && pConstCurve )
  {
    if( face_index >= 0 && face_index < pConstBrep->m_F.Count() )
    {
      ON_Brep* pNewBrep = ON_Brep::New( *pConstBrep );
      if( pNewBrep )
      {
        pNewBrep->DestroyMesh( ON::any_mesh );
        int result = ON_BrepExtrudeFace( *pNewBrep, face_index, *pConstCurve, bCap );
        // 0 == failure, 1 or 2 == success
        if( 0 == result )
          delete pNewBrep;
        else
          rc = pNewBrep;
      }
    }
  }
  return rc;
}
开发者ID:HanselYan,项目名称:rhinocommon,代码行数:22,代码来源:on_brep.cpp

示例15: CreateOneEdge

static void CreateOneEdge( ON_Brep& brep,
                         int vi0, // index of start vertex
                         int vi1, // index of end vertex
                         int c3i  // index of 3d curve
                         )
{
  ON_BrepVertex& v0 = brep.m_V[vi0];
  ON_BrepVertex& v1 = brep.m_V[vi1];
  ON_BrepEdge& edge = brep.NewEdge(v0,v1,c3i);
  edge.m_tolerance = 0.0;  // this simple example is exact - for models with
                           // non-exact data, set tolerance as explained in
                           // definition of ON_BrepEdge.
}
开发者ID:buonmethuoc,项目名称:Rhino4Samples_CPP,代码行数:13,代码来源:cmdTestTrimmedPlaneSample.cpp


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