示例#1
0
bool ON_Brep::Morph( const ON_SpaceMorph& morph )
{
  bool rc = IsMorphable();
  if ( rc )
  {
    ON_Surface* srf = const_cast<ON_Surface*>(m_F[0].SurfaceOf());
    
    if ( srf->IsMorphable() )
    {
      rc = srf->Morph(morph);
    }
    else
    {
      ON_NurbsSurface* new_srf = srf->NurbsSurface();
      if ( !new_srf )
        return false;
      rc = new_srf->Morph(morph);
      if (rc)
      {
        int si = m_F[0].m_si;
        m_F[0].SetProxySurface(new_srf);
        delete srf;
        srf = new_srf;
        m_S[si] = srf;
        DestroyMesh(ON::any_mesh,true);
      }
      else
      {
        delete new_srf;
        new_srf = 0;
      }
    }
    
    if ( rc )
    {
      double tol = 0.01; 
      rc = RebuildEdges( m_F[0], tol, true, true );

      DestroyMesh(ON::analysis_mesh);
      DestroyMesh(ON::preview_mesh);
      ON_Mesh* mesh = const_cast<ON_Mesh*>(m_F[0].Mesh(ON::render_mesh));
      if ( mesh )
        mesh->EvaluateMeshGeometry( *srf );
    }
  }
  return rc;
}