How to get the dihedral angle of adjoin faces

Hi Bros, I try to calculate the dihedral angle of adjoin faces, whenever plane or surface. It seems a little challenging to me.

Mikhail Sazonov's picture

If your surfaces are not plane, the angle can be different if we go along the common edge. What is your intention?

linbei jianbaoxia's picture

Hi, Mikhail. Thanks for you reply.
Actually I try to extract the AAG(Attributed Adjacency Graph) from my step file. So I would like to know the concavity and convexity between adjacent surface. And the surface in my step file maybe planes or curved surface.

Mikhail Sazonov's picture

It is not a simple problem in general. You can study the source code of the files BOPTools_AlgoTools3D.cxx and BOPTools_AlgoTools.cxx, where the similar problem is solved.

linbei jianbaoxia's picture

Thank you very much, it's helpful for me. I will learn it. Bless you.

Rao Garimella's picture

You have to get the surface of each face and get the normal to the surface at the point you want to evaluate. Then you can get the angle between the two vectors. But you also have to be mindful of whether your normals are point into the volume you are interested in or out - so Face Orientation is also important.

tingliang shi's picture

Hi, I have a similar problem. When the model imported from IGS file expands the normal vector direction of computing surface, the vector direction is wrong. How to deal with this situation.
for (TopExp_Explorer xp(shape, TopAbs_FACE); xp.More(); xp.Next())
{
TopoDS_Face f = TopoDS::Face(xp.Current());
if (f.Orientation() == TopAbs_REVERSED)
{
f.Reversed(); //It never gets here,why ?
}
BRepGProp_Face analysisFace(f);
Standard_Real umin, umax, vmin, vmax;
analysisFace.Bounds(umin, umax, vmin, vmax);
Standard_Real midU, midV;
midU = (umin + umax) / 2;
midV = (vmin + vmax) / 2;
gp_Vec norm;
gp_Pnt midPoint;
analysisFace.Normal(midU, midV, midPoint, norm);//norm direction orientation material inside,why?
}

Mikhail Sazonov's picture

Are you sure you have a solid shape, and not a compound of faces? IGES may contain just a set of unoriented not-connected faces. You can use sewing tool to make shells, and then some other tools to make solids.

tingliang shi's picture

oh yeah,So I think I have a problem,The imported shape is actually a compound type .I'll try to do it your way.Thank you very much .

tingliang shi's picture

Hello, I confirm that it is expanded from an solid to Faces, but I found that the orientation of some faces is still wrong. Is it necessary to get the correct orientation after processing with repair tools(ShapeFix)? I tried to repair according to the manual and found the result is still wrong. Can you tell me some ways?

Mikhail Sazonov's picture

I cannot give you any advise without analysis of your file.

 

tingliang shi's picture

Ok, thank you.
My problem is to get the surface normal vector of the IGES model,The vector faces out of the material.
This is my test code.
But the resulting surface normal vector will be towards the interior of the model material.
void test()
{
BRep_Builder builder;

TopoDS_Shell shell;
builder.MakeShell(shell);

for (Standard_Integer i = 1; i <= nbShapes; i++) {
TopoDS_Shape aShape = aReader.Shape(i); //Shape loaded from igs files
builder.Add(shell, aShape);
}
BRepBuilderAPI_MakeSolid mkSolid;
ShapeUpgrade_ShellSewing sewShell;
mkSolid.Add(TopoDS::Shell(sewShell.ApplySewing(shell)));
TopoDS_Shape model = mkSolid.Solid();

ShapeFix_Shape fix(model);
fix.SetPrecision(Precision::Confusion());
fix.SetMinTolerance(Precision::Confusion());
fix.SetMaxTolerance(Precision::Confusion());

fix.Perform();

fix.FixWireTool()->Perform();
fix.FixFaceTool()->Perform();
fix.FixShellTool()->Perform();
fix.FixSolidTool()->Perform();
model = fix.FixSolidTool()->Shape();

for (TopExp_Explorer xp(model, TopAbs_FACE); xp.More(); xp.Next())
{
TopoDS_Face f = TopoDS::Face(xp.Current());

//I tried to fix it with a face, but it wasn't right
/* ShapeFix_Shape fix(f);
fix.SetPrecision(Precision::Confusion());
fix.SetMaxTolerance(Precision::Confusion());
fix.SetMaxTolerance(Precision::Confusion());
fix.Perform();
fix.FixWireTool()->Perform();
fix.FixFaceTool()->Perform();
f = TopoDS::Face(fix.Shape());*/

if (f.Orientation() == TopAbs_REVERSED) //debug have TopoAbs_forward or topoAbs_reversed
{
f.Reverse();
}
BRepGProp_Face analysisFace(f);
Standard_Real umin, umax, vmin, vmax;
analysisFace.Bounds(umin, umax, vmin, vmax);
Standard_Real midU, midV;
midU = (umin + umax) / 2;
midV = (vmin + vmax) / 2;
gp_Vec norm;
gp_Pnt midPoint;
analysisFace.Normal(midU, midV, midPoint, norm);//The obtained vector points to the side of the material.
}

}

Attachments: 
Mikhail Sazonov's picture

You should not reverse the face if it is reversed. Instead, you should reverse the vector of normal that you computed from the geometry.

if (f.Orientation() == TopAbs_REVERSED)
{
  norm.Reverse();
}

 

tingliang shi's picture

I succeeded according to this method, thank you very much.I have a new problem, so I'll try to study it.