Esempio n. 1
0
eF32 eEditMesh::getMeshArea() const
{
    eF32 area = 0.0f;
    for (eU32 i=0; i<m_faces.size(); i++)
        area += getFaceArea(i);

    return area;
}
Esempio n. 2
0
void VortexSheetMesh::calcVorticity() {
    for (size_t tri = 0; tri < mTris.size(); tri++) {
        VortexSheetInfo& v = mVorticity.data[tri];        
        Vec3 e0 = getEdge(tri,0), e1 = getEdge(tri,1), e2 = getEdge(tri,2);
        Real area = getFaceArea(tri);
        
        if (area < 1e-10) {
            v.smokeAmount = 0;
            v.vorticity = 0;
        } else {
            v.smokeAmount = 0;            
            v.vorticity = (v.circulation[0]*e0 + v.circulation[1]*e1 + v.circulation[2]*e2) / area;
        }
    }
}
Esempio n. 3
0
eF32 eEditMesh::calculatePartialSurfaceSums(eArray<eF32>& partialSurfaceSums) const {
	eF32 areaSum = 0.0f;
	partialSurfaceSums.resize(getFaceCount());
	for (eU32 i=0; i<getFaceCount(); i++) {
		// Calc face area.
		areaSum += getFaceArea(i);
		// Add to sum.
		partialSurfaceSums[i] = areaSum;
	}

	eF32 invSum = 1.0f / areaSum;
	// normalize
	for (eU32 i=0; i<getFaceCount(); i++)
		partialSurfaceSums[i] *= invSum;
	return areaSum;
}
Esempio n. 4
0
void VortexSheetMesh::calcCirculation() {    
    for (size_t tri = 0; tri < mTris.size(); tri++) {
        VortexSheetInfo& v = mVorticity.data[tri];        
        Vec3 e0 = getEdge(tri,0), e1 = getEdge(tri,1), e2 = getEdge(tri,2);
        Real area = getFaceArea(tri);
        
        if (area < 1e-10 || normSquare(v.vorticity) < 1e-10) {
            v.circulation = 0;
            continue;
        }
        
        float cx, cy, cz;
        SolveOverconstraint34(e0.x, e0.y, e0.z, e1.x, e1.y, e1.z, e2.x, e2.y, e2.z, v.vorticity.x, v.vorticity.y, v.vorticity.z, cx, cy, cz);
        v.circulation = Vec3(cx, cy, cz) * area;
    }
}
void MeshDenoisingViaL0Minimization::calculateAreaBasedEdgeOperator(TriMesh &mesh,
                                                                    std::vector<TriMesh::Point> &area_based_edge_operator,
                                                                    std::vector< std::vector<TriMesh::VertexHandle> > &edge_vertex_handle,
                                                                    std::vector< std::vector<double> > &coef)
{
    std::vector<double> face_area;
    getFaceArea(mesh, face_area);

    area_based_edge_operator.resize((int)mesh.n_edges(), TriMesh::Point(0.0, 0.0, 0.0));
    std::vector<double> temp_coef(4, 0.0);
    coef.resize(mesh.n_edges(), temp_coef);
    std::vector<TriMesh::VertexHandle> vertex_handle(4);
    edge_vertex_handle.resize(mesh.n_edges(), vertex_handle);
    for(TriMesh::EdgeIter e_it = mesh.edges_begin(); e_it != mesh.edges_end(); e_it++)
    {
        if(!mesh.is_boundary(*e_it))
        {
            int index = e_it->idx();
            double edge_length = mesh.calc_edge_length(*e_it);

            // get four vertices correspond to edge *e_it
            TriMesh::HalfedgeHandle he = mesh.halfedge_handle(*e_it, 0);
            TriMesh::VertexHandle v1 = mesh.from_vertex_handle(he);
            TriMesh::VertexHandle v3 = mesh.to_vertex_handle(he);
            TriMesh::HalfedgeHandle he_next = mesh.next_halfedge_handle(he);
            TriMesh::VertexHandle v4 = mesh.to_vertex_handle(he_next);

            TriMesh::HalfedgeHandle he_oppo = mesh.opposite_halfedge_handle(he);
            TriMesh::HalfedgeHandle he_oppo_next = mesh.next_halfedge_handle(he_oppo);
            TriMesh::VertexHandle v2 = mesh.to_vertex_handle(he_oppo_next);

            // two faces
            TriMesh::FaceHandle f1 = mesh.face_handle(he);
            TriMesh::FaceHandle f2 = mesh.face_handle(he_oppo);

            // the area of two faces correspond to edge *e_it
            double area134 = face_area[f1.idx()];
            double area123 = face_area[f2.idx()];
            double totalArea = area123 + area134;

            TriMesh::Point p1 = mesh.point(v1);
            TriMesh::Point p2 = mesh.point(v2);
            TriMesh::Point p3 = mesh.point(v3);
            TriMesh::Point p4 = mesh.point(v4);

            TriMesh::Point p12 = p1 - p2;
            TriMesh::Point p13 = p1 - p3;
            TriMesh::Point p14 = p1 - p4;
            TriMesh::Point p23 = p2 - p3;
            TriMesh::Point p34 = p3 - p4;

            // calc coefficient
            temp_coef[0] = (area123 * (p34 | p13) - area134 * (p13 | p23)) / (edge_length * edge_length * totalArea);
            temp_coef[1] = area134 / totalArea;
            temp_coef[2] = (-area123 * (p13 | p14) - area134 * (p12 | p13)) / (edge_length * edge_length * totalArea);
            temp_coef[3] = area123 / totalArea;
            coef[index] = temp_coef;

            vertex_handle[0] = v1;
            vertex_handle[1] = v2;
            vertex_handle[2] = v3;
            vertex_handle[3] = v4;
            edge_vertex_handle[index] = vertex_handle;

            // calc area-based edge operator
            TriMesh::Point pt = p1 * temp_coef[0] + p2 * temp_coef[1] + p3 * temp_coef[2] + p4 * temp_coef[3];
            area_based_edge_operator[index] = pt;
        }
    }
}