Open CASCADE学习|计算全局属性

本文介绍了如何在OpenCASCADETechnology(OCCT)的BRepGProp库中计算几何体的全局属性,如体积、质心、惯性矩等,并展示了通过示例代码获取这些属性的实例。
摘要由CSDN通过智能技术生成

对于一个系统全局属性有:

  • 质量(mass)

  • 质心(mass center)

  • 惯性张量(matrix of inertia)

  • 关于一个轴的矩(moment about an axis)

  • 关于一个轴的惯性半径(radius of gyration about an axis)

  • 惯性的主属性,比如主轴(principal axis),主矩(principal moments)和主惯性半径(principal radius of gyration)

在Open CASCADE Technology (OCCT)中,全局属性(如尺寸、质量、质心、惯性矩等)的计算是通过BRepGProp库来实现的。这个库提供了函数来计算几何形状的各种属性。

#include <TopoDS.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <GProp_GProps.hxx>  
#include <BRepGProp.hxx> 
#include <GProp_PrincipalProps.hxx> 

#include"Viewer.h"

int main(int argc, char* argv[])
{
    TopoDS_Shape box = BRepPrimAPI_MakeBox(1,2,3);
    GProp_GProps System;
    BRepGProp::LinearProperties(box, System);
    BRepGProp::SurfaceProperties(box, System);
    BRepGProp::VolumeProperties(box, System);
    BRepGProp::VolumeProperties(box, System);
    double out=System.Mass();
    gp_Pnt G = System.CentreOfMass();
    GProp_PrincipalProps Pp = System.PrincipalProperties();
    double Ixx=0, Iyy=0, Izz=0, Rxx=0, Ryy=0, Rzz=0;
    Pp.Moments (Ixx, Iyy, Izz);
    Pp.RadiusOfGyration (Ixx, Iyy, Izz);
    std::cout <<"volume=" << out << std::endl;
    std::cout << "CentreOfMass=(" << G.X()<<","<<G.Y()<<","<<G.Z() << ")" << std::endl;
    std::cout << "Ixx=" << Ixx << std::endl;
    std::cout << "Iyy=" << Iyy << std::endl;
    std::cout << "Izz=" << Izz << std::endl;
    std::cout << "Rxx=" << Rxx << std::endl;
    std::cout << "Ryy=" << Ryy << std::endl;
    std::cout << "Rzz=" << Rzz << std::endl;
    Viewer vout(50, 50, 500, 500);
    vout << box;
    vout.StartMessageLoop();
    return 0;
}

volume=6

CentreOfMass=(0.5,1,1.5)

Ixx=1.04083

Iyy=0.912871

Izz=0.645497

Rxx=0

Ryy=0

Rzz=0

  • 13
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值