OrcaSlicer/deps_src/libigl/igl/loop.h
Ian Bassi 68fdfcf0eb
BBS Port: Mesh Subdivision (#12150)
Ported from BBS
You can now right-click a part and choose Subdivide Part to apply Loop subdivision with multiple iterations. This is useful for models with low original mesh resolution.

> [!NOTE]
> 1. Only meshes without non-manifold edges are supported.
> 2. Color attributes will be lost after subdivision. We recommend subdividing first, then painting and applying colors.

Not perfect and it can break some features but a nice to have and we can improve it.
https://github.com/user-attachments/assets/33f10e49-f6dc-44d3-8c21-9e12e1fe23dc

Best case scenario a sphere:
Each picture is a Mesh subdivision step over the other
<img width="541" height="495" alt="260202_164257_orca-slicer" src="https://github.com/user-attachments/assets/e62b3f4d-ee6b-4451-95a4-40a154d3a405" />
<img width="541" height="495" alt="260202_164302_%pn" src="https://github.com/user-attachments/assets/f7399457-be8d-45e7-b93f-f42064dadd64" />
<img width="541" height="495" alt="260202_164306_%pn" src="https://github.com/user-attachments/assets/55370035-219f-4b7f-94f4-9b31733820d6" />
<img width="541" height="495" alt="260202_164310_%pn" src="https://github.com/user-attachments/assets/3be8c904-cc6f-4efe-b4f8-f390b50d310c" />
2026-02-12 08:42:01 +08:00

63 lines
1.9 KiB
C++

// This file is part of libigl, a simple c++ geometry processing library.
//
// Copyright (C) 2016 Oded Stein <oded.stein@columbia.edu>
//
// This Source Code Form is subject to the terms of the Mozilla Public License
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
// obtain one at http://mozilla.org/MPL/2.0/.
#ifndef IGL_LOOP_H
#define IGL_LOOP_H
#include <igl/igl_inline.h>
#include <Eigen/Core>
#include <Eigen/Sparse>
namespace igl
{
// LOOP Given the triangle mesh [V, F], where n_verts = V.rows(), computes
// newV and a sparse matrix S s.t. [newV, newF] is the subdivided mesh where
// newV = S*V.
//
// Inputs:
// n_verts an integer (number of mesh vertices)
// F an m by 3 matrix of integers of triangle faces
// Outputs:
// S a sparse matrix (will become the subdivision matrix)
// newF a matrix containing the new faces
template <
typename DerivedF,
typename SType,
typename DerivedNF>
IGL_INLINE bool loop(
const int n_verts,
const Eigen::PlainObjectBase<DerivedF> & F,
Eigen::SparseMatrix<SType>& S,
Eigen::PlainObjectBase<DerivedNF> & NF);
// LOOP Given the triangle mesh [V, F], computes number_of_subdivs steps of loop subdivision and outputs the new mesh [newV, newF]
//
// Inputs:
// V an n by 3 matrix of vertices
// F an m by 3 matrix of integers of triangle faces
// number_of_subdivs an integer that specifies how many subdivision steps to do
// Outputs:
// NV a matrix containing the new vertices
// NF a matrix containing the new faces
template <
typename DerivedV,
typename DerivedF,
typename DerivedNV,
typename DerivedNF>
IGL_INLINE bool loop(
const Eigen::PlainObjectBase<DerivedV>& V,
const Eigen::PlainObjectBase<DerivedF>& F,
Eigen::PlainObjectBase<DerivedNV>& NV,
Eigen::PlainObjectBase<DerivedNF>& NF,
const int number_of_subdivs = 1);
}
#ifndef IGL_STATIC_LIBRARY
# include "loop.cpp"
#endif
#endif