示例#1
0
DVec OCCFace::inertia() {
    DVec ret;
    GProp_GProps prop;
    BRepGProp::SurfaceProperties(this->getShape(), prop);
    gp_Mat mat = prop.MatrixOfInertia();
    ret.push_back(mat(1,1)); // Ixx
    ret.push_back(mat(2,2)); // Iyy
    ret.push_back(mat(3,3)); // Izz
    ret.push_back(mat(1,2)); // Ixy
    ret.push_back(mat(1,3)); // Ixz
    ret.push_back(mat(2,3)); // Iyz
    return ret;
}
Py::Object TopoShapeFacePy::getMatrixOfInertia(void) const
{
    GProp_GProps props;
    BRepGProp::SurfaceProperties(getTopoShapePtr()->getShape(), props);
    gp_Mat m = props.MatrixOfInertia();
    Base::Matrix4D mat;
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            mat[i][j] = m(i+1,j+1);
        }
    }
    return Py::Matrix(mat);
}
示例#3
0
bool ChCascadeDoc::GetVolumeProperties(const TopoDS_Shape& mshape,	///< pass the shape here
						const double density,				///< pass the density here 
						ChVector<>& center_position,		///< get the position center, respect to shape pos.
						ChVector<>& inertiaXX,				///< get the inertia diagonal terms
						ChVector<>& inertiaXY,				///< get the inertia extradiagonal terms
						double& volume,						///< get the volume
						double& mass						///< get the mass
						)
{
	if (mshape.IsNull()) 
		return false;

	GProp_GProps mprops;
	GProp_GProps vprops;
	BRepGProp::VolumeProperties(mshape,mprops);
	BRepGProp::VolumeProperties(mshape,vprops);

	mprops.Add(mprops, density);

	mass = mprops.Mass();
	volume = vprops.Mass();
	gp_Pnt G = mprops.CentreOfMass ();
	gp_Mat I = mprops.MatrixOfInertia();

	center_position.x = G.X();
	center_position.y = G.Y();
	center_position.z = G.Z();

	inertiaXX.x = I(1,1);
	inertiaXX.y = I(2,2);
	inertiaXX.z = I(3,3);
	inertiaXY.x = I(1,2);
	inertiaXY.y = I(1,3);
	inertiaXY.z = I(2,3);

	return true;
}