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


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

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


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

示例1: RunCommand

CRhinoCommand::result CCommandSampleUnrollSurface::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoGetObject go;
  go.SetCommandPrompt( L"Select surface or polysurface to unroll" );
  go.SetGeometryFilter( CRhinoGetObject::surface_object | CRhinoGetObject::polysrf_object );
  go.EnableSubObjectSelect( FALSE );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() != CRhinoCommand::success )
    return go.CommandResult();

  const CRhinoObject* pObject = go.Object(0).Object();
  const ON_Brep* pBrep = go.Object(0).Brep();
  if( 0 == pObject || 0 == pBrep )
    return CRhinoCommand::failure;

  bool bExplode = false;

  ON_Brep* p3dBrep = 0;
  int i, type = -1;
  if(1 == pBrep->m_F.Count() )
  {
    p3dBrep = pBrep->DuplicateFace( 0, false );
    type = 0;
  }
  else
  {
    p3dBrep = static_cast<ON_Brep*>( pBrep->Duplicate() );
    type = 1;
  }

  if( 0 == p3dBrep )
    return CRhinoCommand::failure;

  p3dBrep->Compact();
  for( i = 0; i < p3dBrep->m_F.Count(); i++ )
    p3dBrep->RebuildEdges( p3dBrep->m_F[i], 0.00001, true, true );
  p3dBrep->ShrinkSurfaces();

  ReverseVReversedSurfaces( p3dBrep );

  CRhinoUnroll Unroller( p3dBrep, context.m_doc.AbsoluteTolerance(), 0.1 );
  int irc = Unroller.PrepareFaces();
  if( 0 == irc )
  {
    bool ok = Unroller.FlattenFaces();
    if( ok )
    {
      int flat_face_count = Unroller.CreateFlatBreps( bExplode, 2.0 );
      if( flat_face_count )
      {
        ON_SimpleArray<ON_Brep*> flat_breps;
        ON_ClassArray< ON_SimpleArray<ON_Curve*> > flat_curves;
        ON_ClassArray< ON_SimpleArray<ON_3dPoint> > flat_points;
        ON_ClassArray< ON_SimpleArray<ON_TextDot*> > flat_dots;
        Unroller.CollectResults( flat_breps, flat_curves, flat_points, flat_dots );

        if( !bExplode && flat_breps.Count() > 1 )
        {
          ON_Brep* pJoinedBrep = ON_Brep::New();
          if( pJoinedBrep )
          {
            for( i = 0; i < flat_breps.Count(); i++ )
            {
              if( flat_breps[i] != 0 )
                pJoinedBrep->Append( *flat_breps[i] );
            }
            int joins = RhinoJoinBrepNakedEdges( *pJoinedBrep );
            flat_breps.Empty();
            flat_breps.Append( pJoinedBrep );
          }
        }

        CRhinoObjectAttributes att = pObject->Attributes();
        att.m_uuid = ON_nil_uuid;
        att.RemoveFromAllGroups();

        for( i = 0; i < flat_breps.Count(); i++ )
        {
          CRhinoBrepObject* flat_obj = new CRhinoBrepObject( att );
          flat_obj->SetBrep( flat_breps[i] );
          if( !context.m_doc.AddObject(flat_obj) )
            delete flat_obj; // Don't leak...
        }
      }
    }

    delete p3dBrep; // Don't leak...
  }

  context.m_doc.Redraw();

  return CRhinoCommand::success;
}
开发者ID:KingOfMazes,项目名称:Rhino5Samples_CPP,代码行数:93,代码来源:cmdSampleUnrollSurface.cpp


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