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.
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.
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.
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?
}
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.
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?
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();
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.
}
Sun, 03/27/2022 - 22:44
If your surfaces are not plane, the angle can be different if we go along the common edge. What is your intention?
Mon, 03/28/2022 - 05:29
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.
Mon, 03/28/2022 - 10:32
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.
Mon, 03/28/2022 - 10:59
Thank you very much, it's helpful for me. I will learn it. Bless you.
Wed, 04/13/2022 - 04:19
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.
Thu, 04/21/2022 - 17:50
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?
}
Thu, 04/21/2022 - 16:55
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.
Thu, 04/21/2022 - 17:46
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 .
Fri, 04/22/2022 - 12:07
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?
Fri, 04/22/2022 - 12:56
I cannot give you any advise without analysis of your file.
Fri, 04/22/2022 - 14:06
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.
}
}
Fri, 04/22/2022 - 14:41
You should not reverse the face if it is reversed. Instead, you should reverse the vector of normal that you computed from the geometry.
Fri, 04/22/2022 - 14:49
I succeeded according to this method, thank you very much.I have a new problem, so I'll try to study it.