DiscussionsIssue archiveOther usage issues

Archived discussion

project shape onto a plane

Other usage issuesFri, 07/17/2009 - 02:186 replies

Browse this forum
QuestionAuthor

Hi all,

Can any one suggest me how to project a TopoDS_Shape onto a plane?
I can project a face.But,i'm unable to explore face out of this shape.

Please help!
Author

Discussion

6 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hi Author,

i dont have any experience with projections, but you can get the faces of the shape by using TopExp_Explorer.

TopoDS_Shape shape;
TopExp_Explorer faceExplorer(shape, TopAbs_FACE);

while(faceExplorer.More()){
TopoDS_Face currentFace = TopoDS::Face(faceExplorer.Current());
// do smth. with the face
faceExplorer.Next();
}

02Commenter-2

for the projection, you can use the HLR algorithms. check the sample.

Commenter-2

03Author

Is there any way to get outerbounds like outerwire of a shape?

04Commenter-3

Author,

To get out hole of a shell, you can use ShapeAnalysis_FreeBounds.
ShapeAnalysis_FreeBounds safb(compoundShape);
shape = safb.GetClosedWires ();
for(exp.Init(shape, TopAbs_WIRE); exp.More(); exp.Next())
{
hole = exp.Current();
}
PS: ShapeAnalysis_FreeBounds also find the inner holes of a face, so you should omit these holes.

-Ding

05Author

Hi,

This is the code I used to project a shape onto plane

Handle(HLRBRep_Algo)myAlgo = new HLRBRep_Algo();
myAlgo->Add(R);
Prs3d_Projector myProj(false,0, 0,0,zloc,0,0,1, 0,0,1);//zloc is z coordinate of projection point
myAlgo->Projector(myProj.Projector());
myAlgo->Update();
HLRBRep_HLRToShape aHLRToShape(myAlgo);
TopoDS_Shape Proj = aHLRToShape.VCompound();
Handle (AIS_Shape) DispP = new AIS_Shape(Proj);
myAISContext->Display(DispP,Standard_False);

Can anyone tell me what am I doing wrong here?

06Commenter-4

This works: Prs3d_Projector myProj(false,0, 0,0,zloc, 0,0,1, 0,1,0);

From doxygen documentation -
- DX, DY and DZ are the coordinates of the
projection vector;
- XUp, YUp and ZUp are the coordinates of the
vertical direction vector.

If you dig through the code, these two vectors are crossed to form a 3rd vector. So these two must be at 90 degrees to each other.