HLRBRep_Algo to Add a Sphere ,the result is empty.

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);
}
gkv311 n's picture

You may take a look at VComputeHLR command implementation in Draw Harness as a reference occt.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:

  • visible sharp edges (of C0-continuity) HLRBRep_HLRToShape::VCompound();
  • hidden sharp edges (of C0-continuity) HLRBRep_HLRToShape::HCompound();
  • visible smooth edges (G1-continuity between two surfaces) HLRBRep_HLRToShape::Rg1LineVCompound();
  • hidden smooth edges (G1-continuity between two surfaces) HLRBRep_HLRToShape::Rg1LineHCompound();
  • visible sewn edges (of CN-continuity on one surface) HLRBRep_HLRToShape::RgNLineVCompound();
  • hidden sewn edges (of CN-continuity on one surface) HLRBRep_HLRToShape::RgNLineHCompound();
  • visible outline edges ("silhouette") HLRBRep_HLRToShape::OutLineVCompound();
  • hidden outline edges ("silhouette") HLRBRep_HLRToShape::OutLineHCompound();
  • visible isoparameters HLRBRep_HLRToShape::IsoLineVCompound();
  • hidden isoparameters 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().

pload MODELING VISUALIZATION
psphere s 10
box s 10 10 20
vinit View1
vcomputehlr s r -algoType algo 0 0 20 0 0 1 0 1 0
top
fit
lws-sys's picture

Thanks.It's detailed and helpful.