Convertion of Edges to Geom_Curve

Hi all,

I just started learning OpenCascade. I took a box shape, projected it onto an inclined plane. Identified the hidden lines. Now I want to get the geometrical properties of the edges (coordinates of end points for a line, center and radius for a circle etc.). When I try to convert the edges to Geom_Curve I get Null. Same thing with Geo2d_Curve. Can anyone please tell me what is wrong with the code ?

Thanks,
Sanjay

// make a box
TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(15.,15.,15.);

// project it onto a plane and identify hidden lines
Handle(HLRBRep_Algo) myAlgo;
myAlgo = new HLRBRep_Algo();
myAlgo->Add(theBox1,0);
Prs3d_Projector PP(FALSE,0.0, 1.0,1.0,1.0, 0.,4.,0., 0.,0.,1.0);
HLRAlgo_Projector PP1 = PP.Projector();
myAlgo->Projector(PP1);
myAlgo->Update();
myAlgo->Hide();
HLRBRep_HLRToShape aHLRToShape(myAlgo);

TopoDS_Shape VCompound = aHLRToShape.VCompound();
TopoDS_Shape Rg1LineVCompound = aHLRToShape.Rg1LineVCompound();
TopoDS_Shape RgNLineVCompound = aHLRToShape.RgNLineVCompound();
TopoDS_Shape OutLineVCompound = aHLRToShape.OutLineVCompound();
TopoDS_Shape IsoLineVCompound = aHLRToShape.IsoLineVCompound();
TopoDS_Shape HCompound = aHLRToShape.HCompound();
TopoDS_Shape Rg1LineHCompound = aHLRToShape.Rg1LineHCompound();
TopoDS_Shape RgNLineHCompound = aHLRToShape.RgNLineHCompound();
TopoDS_Shape OutLineHCompound = aHLRToShape.OutLineHCompound();
TopoDS_Shape IsoLineHCompound = aHLRToShape.IsoLineHCompound();

// make a face in which the above compounds lie
gp_Pln myplane;
myplane = gp_Pln(gp_Pnt(0.,0.,0.),gp_Dir(0.0,0.,1.));
Handle(Geom_Plane) myplanesurface = new Geom_Plane(myplane);
TopoDS_Shape tempface = BRepBuilderAPI_MakeFace(myplane,-100,100,-100,100);
TopoDS_Face aFace = TopoDS::Face(tempface);

// loop over edges in the projected view and convert them to geometrical entities
TopoDS_Edge anEdge;
TopExp_Explorer Ex;
Standard_Real first,last;
for (Ex.Init(VCompound,TopAbs_EDGE); Ex.More(); Ex.Next())
{
anEdge = TopoDS::Edge(Ex.Current());
Handle(Geom2d_Curve) ccc1 = BRep_Tool::CurveOnSurface(anEdge,aFace,first,last);
assert (!ccc1.IsNull ());

Handle(Geom_Curve) ccc2 = BRep_Tool::Curve(anEdge,first,last);
assert (!ccc2.IsNull ());
}

sanjayjoshi's picture

I got solution in one of the threads of this forum (Christian's response dated 2004-10-12). The geometric curve needs to be built first using

BRepLib::BuildCurve3d(anEdge);

Thanks Christian.

Thanks,
Sanjay

Kreshnik's picture

Hi,
These function doesn't exists on OCC 5.2 !

Kreshnik's picture