vtkCellPicker 中部分点法相异常

vtkSmartPointer<vtkCellPicker> m_cellPicker;

double* ijk = m_cellPicker->GetPickNormal();

获取的发现反向,造成这样情况的原因可能选择的面是片体(壳),需要把片体或者壳缝合或者转换为实体正常。 

  业务情况导入STEP,在VTK中渲染,选择面上的点法相异常,增加STEP导入后获取组合体中片体,然后缝合片体。下面方法还是有些问题的,缝合的片体可以转换为实体,但是运行后没有实体显示转换失败,没有好的方法解决。

TopoDS_Shape dmuCADReader::CreateSolidFromFaces(TopoDS_Shape theTopoDS_Shape)
{
    std::vector<TopoDS_Face> faces;
    TopoDS_Shape sewedShape ;
    try
    {

    
    for (TopExp_Explorer explorer(theTopoDS_Shape, TopAbs_COMPOUND); explorer.More(); explorer.Next()) {

        TopoDS_Shape subshape = explorer.Current();
        int n = 0;
        
        for (TopExp_Explorer explorersub(subshape, TopAbs_FACE); explorersub.More(); explorersub.Next())
        {
            TopoDS_Face theface = TopoDS::Face(explorersub.Current());
            faces.push_back(theface);
            //builder.Add(newCompound, theface);
        }

    }


    BRep_Builder builder;

    // 创建一个壳并将所有面添加到壳中
    TopoDS_Shell shell;
    builder.MakeShell(shell);

    for (const auto& face : faces) {
        builder.Add(shell, face);
    }

    // 使用 BRepBuilderAPI_Sewing 来缝合壳
    BRepBuilderAPI_Sewing sewing;
    sewing.Add(shell);
    sewing.Perform();
    sewedShape = sewing.SewedShape();

    // 创建实体
    //TopoDS_Solid solid;
    //builder.MakeSolid(solid);

     如果缝合的形状是有效的壳,使用它来创建实体
    //if (sewedShape.ShapeType() == TopAbs_SHELL) {
    //    TopoDS_Shell sewedShell = TopoDS::Shell(sewedShape);
    //    builder.Add(solid, sewedShell);
    //}
    return sewedShape;
    //return solid;
    }
    catch (const std::exception&)
    {
        return sewedShape;
    }
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

和光同尘 、Y_____

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值