コード例 #1
0
ファイル: Mesh.cpp プロジェクト: rohan-sawhney/geodesics
void Mesh::computeFaceGradients(Eigen::MatrixXd& gradients, const Eigen::VectorXd& u) const
{
    for (FaceCIter f = faces.begin(); f != faces.end(); f++) {
        
        Eigen::Vector3d gradient;
        gradient.setZero();
        Eigen::Vector3d normal = f->normal();
        normal.normalize();
        
        HalfEdgeCIter he = f->he;
        do {
            double ui = u(he->next->next->vertex->index);
            Eigen::Vector3d ei = he->next->vertex->position - he->vertex->position;
            
            gradient += ui * normal.cross(ei);
            
            he = he->next;
        } while (he != f->he);
        
        gradient /= (2.0 * f->area());
        gradient.normalize();
        
        gradients.row(f->index) = -gradient;
    }
}
コード例 #2
0
ファイル: Mesh.cpp プロジェクト: JianpingCAI/course
 double Mesh::area( void ) const
 {
    double sum = 0.0;
    for( FaceCIter f = faces.begin();
        f != faces.end();
        f ++ )
    {
       sum += f->area();
    }
    return sum;
 }