
Thu, 04/17/2025 - 10:35
Forums:
I make a shape by BRepPrimAPI_MakeSphere,then perform my HLRProject function.The result is empty,no edge or vertex.Why?What should i do in HLRProject() function?
TopoDS_Shape HLRProject(const TopoDS_Shape& shape, const gp_Ax2& viewingDir)
{
if (shape.IsNull())
return TopoDS_Shape();
Handle(HLRBRep_Algo) aHlrAlgo = new HLRBRep_Algo();
HLRAlgo_Projector aProjector(viewingDir);
aHlrAlgo->Add(shape);
aHlrAlgo->Projector(aProjector);
aHlrAlgo->Update();
HLRBRep_HLRToShape aHlr2Shape(aHlrAlgo);
TopoDS_Shape visual_shape = aHlr2Shape.VCompound();
const gp_Trsf& T = aHlrAlgo->Projector().Transformation();
TopoDS_Shape TransRes = BRepBuilderAPI_Transform(visual_shape, T);
return visual_shape;
}
TEST(TEST_OCC, HLR)
{
TopoDS_Shape shape = BRepPrimAPI_MakeSphere(10.0);
TopoDS_Shape result = HLRProject(shape, gp_Ax2(gp_Pnt(0, 0, 20), gp_Dir(0., 0., 1.)));
//result is empty
//QtShowShape(result);
}
Sat, 04/19/2025 - 10:25
You may take a look at
VComputeHLR
command implementation in Draw Harness as a referenceocct.git\src\ViewerTest\ViewerTest_ObjectCommands.cxx
. There are also some HLR samples could be found in OCCT sample.HLRBRep_HLRToShape
returns not a single shape but a list of shapes in different categories via dedicated methods. This class has badly written documentation, but one may deduce:HLRBRep_HLRToShape::VCompound()
;HLRBRep_HLRToShape::HCompound()
;HLRBRep_HLRToShape::Rg1LineVCompound()
;HLRBRep_HLRToShape::Rg1LineHCompound()
;HLRBRep_HLRToShape::RgNLineVCompound()
;HLRBRep_HLRToShape::RgNLineHCompound()
;HLRBRep_HLRToShape::OutLineVCompound()
;HLRBRep_HLRToShape::OutLineHCompound()
;HLRBRep_HLRToShape::IsoLineVCompound()
;HLRBRep_HLRToShape::IsoLineHCompound()
.In your sample, you are looking for sharp edges of a sphere, but it has no sharp edges at all! The HLR of a sphere will have "silhouette" edges
HLRBRep_HLRToShape::OutLineVCompound()
.Fri, 04/25/2025 - 06:01
Thanks.It's detailed and helpful.