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; }