Beispiel #1
0
	int superMi::mass_center(Solid* mesh)
	{

		Point center = { 0, 0, 0 };
		double mass = 0;
		for (SolidVertexIterator sviter(mesh); !sviter.end(); ++sviter){
			Vertex* sv = *sviter;

			center += sv->point() * sv->area();
			mass += sv->area();

		}
		center /= mass;

		for (SolidVertexIterator sviter(mesh); !sviter.end(); ++sviter){
			Vertex* sv = *sviter;
			sv->point() -= center;
			sv->point() /= sv->point().norm();
		}

		return 0;
	}
Beispiel #2
0
	int superMi::area(Solid* mesh)
	{
		for (SolidFaceIterator sfiter(mesh); !sfiter.end(); ++sfiter){
			Face* sf = *sfiter;
			Point p[3]; int i = 0;
			for (FaceVertexIterator fviter(sf); !fviter.end(); ++fviter){
				Vertex* fv = *fviter;
				p[i++] = fv->point();
			}
			sf->area() = ((p[1] - p[0]) ^ (p[2] - p[0])).norm() / 2.0;
		}

		for (SolidVertexIterator sviter(mesh); !sviter.end(); ++sviter){
			Vertex* sv = *sviter;
			double area = 0;
			for (VertexFaceIterator vfiter(sv); !vfiter.end(); ++vfiter){
				Face* vf = *vfiter;
				area += vf->area();
			}
			sv->area() = area / 3.0;
		}

		return 0;
	}