mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0029293: Boolean Operations algorithm does not preserve the orientations of the faces
While building splits of faces (BOPAlgo_Builder::FillImagesFaces()) make sure that the orientation of the input face will be passed to its splits. Extend draw command "normals" with new key "[-print]" which allows printing values of the normal vector.
This commit is contained in:
parent
53a1447a00
commit
93964cc239
@ -265,7 +265,7 @@ void BOPAlgo_Builder::BuildSplitFaces()
|
|||||||
//
|
//
|
||||||
// Build temporary map of faces images to avoid rebuilding
|
// Build temporary map of faces images to avoid rebuilding
|
||||||
// of the faces without any IN or section edges
|
// of the faces without any IN or section edges
|
||||||
BOPCol_IndexedDataMapOfShapeListOfShape aFacesIm;
|
NCollection_IndexedDataMap<Standard_Integer, BOPCol_ListOfShape> aFacesIm;
|
||||||
//
|
//
|
||||||
aNbS=myDS->NbSourceShapes();
|
aNbS=myDS->NbSourceShapes();
|
||||||
//
|
//
|
||||||
@ -312,7 +312,7 @@ void BOPAlgo_Builder::BuildSplitFaces()
|
|||||||
TopoDS_Face aFD = BuildDraftFace(aF, myImages, myContext);
|
TopoDS_Face aFD = BuildDraftFace(aF, myImages, myContext);
|
||||||
if (!aFD.IsNull())
|
if (!aFD.IsNull())
|
||||||
{
|
{
|
||||||
aFacesIm(aFacesIm.Add(aF, BOPCol_ListOfShape())).Append(aFD);
|
aFacesIm(aFacesIm.Add(i, BOPCol_ListOfShape())).Append(aFD);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -457,13 +457,13 @@ void BOPAlgo_Builder::BuildSplitFaces()
|
|||||||
for (k = 0; k < aNbBF; ++k)
|
for (k = 0; k < aNbBF; ++k)
|
||||||
{
|
{
|
||||||
BOPAlgo_BuilderFace& aBF = aVBF(k);
|
BOPAlgo_BuilderFace& aBF = aVBF(k);
|
||||||
aFacesIm.Add(aBF.Face(), aBF.Areas());
|
aFacesIm.Add(myDS->Index(aBF.Face()), aBF.Areas());
|
||||||
}
|
}
|
||||||
|
|
||||||
aNbBF = aFacesIm.Extent();
|
aNbBF = aFacesIm.Extent();
|
||||||
for (k = 1; k <= aNbBF; ++k)
|
for (k = 1; k <= aNbBF; ++k)
|
||||||
{
|
{
|
||||||
const TopoDS_Face& aF = TopoDS::Face(aFacesIm.FindKey(k));
|
const TopoDS_Face& aF = TopoDS::Face(myDS->Shape(aFacesIm.FindKey(k)));
|
||||||
anOriF = aF.Orientation();
|
anOriF = aF.Orientation();
|
||||||
const BOPCol_ListOfShape& aLFR = aFacesIm(k);
|
const BOPCol_ListOfShape& aLFR = aFacesIm(k);
|
||||||
//
|
//
|
||||||
|
@ -1140,6 +1140,7 @@ static Standard_Integer normals (Draw_Interpretor& theDI,
|
|||||||
Standard_Boolean toUseMesh = Standard_False;
|
Standard_Boolean toUseMesh = Standard_False;
|
||||||
Standard_Real aLength = 10.0;
|
Standard_Real aLength = 10.0;
|
||||||
Standard_Integer aNbAlongU = 1, aNbAlongV = 1;
|
Standard_Integer aNbAlongU = 1, aNbAlongV = 1;
|
||||||
|
Standard_Boolean bPrint = Standard_False;
|
||||||
for (Standard_Integer anArgIter = 2; anArgIter< theArgNum; ++anArgIter)
|
for (Standard_Integer anArgIter = 2; anArgIter< theArgNum; ++anArgIter)
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aParam (theArgs[anArgIter]);
|
TCollection_AsciiString aParam (theArgs[anArgIter]);
|
||||||
@ -1204,9 +1205,13 @@ static Standard_Integer normals (Draw_Interpretor& theDI,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (aParam == "-print")
|
||||||
|
{
|
||||||
|
bPrint = Standard_True;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Syntax error: unknwon argument '" << aParam << "'\n";
|
std::cout << "Syntax error: unknown argument '" << aParam << "'\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1225,12 +1230,29 @@ static Standard_Integer normals (Draw_Interpretor& theDI,
|
|||||||
|
|
||||||
for (NCollection_DataMap<TopoDS_Face, NCollection_Vector<std::pair<gp_Pnt, gp_Pnt> > >::Iterator aFaceIt (aNormals); aFaceIt.More(); aFaceIt.Next())
|
for (NCollection_DataMap<TopoDS_Face, NCollection_Vector<std::pair<gp_Pnt, gp_Pnt> > >::Iterator aFaceIt (aNormals); aFaceIt.More(); aFaceIt.Next())
|
||||||
{
|
{
|
||||||
const Draw_Color aColor = DBRep_ColorOrientation (aFaceIt.Key().Orientation());
|
Standard_Boolean bReverse = Standard_False;
|
||||||
|
TopAbs_Orientation aFaceOri = aFaceIt.Key().Orientation();
|
||||||
|
const Draw_Color aColor = DBRep_ColorOrientation (aFaceOri);
|
||||||
|
if (aFaceOri == TopAbs_REVERSED)
|
||||||
|
bReverse = Standard_True;
|
||||||
|
|
||||||
for (NCollection_Vector<std::pair<gp_Pnt, gp_Pnt> >::Iterator aNormalsIt (aFaceIt.Value()); aNormalsIt.More(); aNormalsIt.Next())
|
for (NCollection_Vector<std::pair<gp_Pnt, gp_Pnt> >::Iterator aNormalsIt (aFaceIt.Value()); aNormalsIt.More(); aNormalsIt.Next())
|
||||||
{
|
{
|
||||||
const std::pair<gp_Pnt, gp_Pnt>& aVec = aNormalsIt.Value();
|
const std::pair<gp_Pnt, gp_Pnt>& aVec = aNormalsIt.Value();
|
||||||
Handle(Draw_Segment3D) aSeg = new Draw_Segment3D(aVec.first, aVec.second, aColor);
|
Handle(Draw_Segment3D) aSeg = new Draw_Segment3D(aVec.first, aVec.second, aColor);
|
||||||
dout << aSeg;
|
dout << aSeg;
|
||||||
|
if (bPrint)
|
||||||
|
{
|
||||||
|
// Make the normal vector from the points
|
||||||
|
gp_Vec aV(aVec.first, aVec.second);
|
||||||
|
if (bReverse)
|
||||||
|
aV.Reverse();
|
||||||
|
|
||||||
|
// Print values of the vector avoiding printing "-0" values
|
||||||
|
theDI << "(" << (aV.X() == 0 ? 0 : aV.X()) << ", "
|
||||||
|
<< (aV.Y() == 0 ? 0 : aV.Y()) << ", "
|
||||||
|
<< (aV.Z() == 0 ? 0 : aV.Z()) << ")\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1406,7 +1428,7 @@ void DBRep::BasicCommands(Draw_Interpretor& theCommands)
|
|||||||
theCommands.Add("treverse","treverse name1 name2 ...",__FILE__,orientation,g);
|
theCommands.Add("treverse","treverse name1 name2 ...",__FILE__,orientation,g);
|
||||||
theCommands.Add("complement","complement name1 name2 ...",__FILE__,orientation,g);
|
theCommands.Add("complement","complement name1 name2 ...",__FILE__,orientation,g);
|
||||||
theCommands.Add("invert","invert name, reverse subshapes",__FILE__,invert,g);
|
theCommands.Add("invert","invert name, reverse subshapes",__FILE__,invert,g);
|
||||||
theCommands.Add("normals","normals shape [Length {10}] [-NbAlongU {1}] [-NbAlongV {1}] [-UseMesh], display normals",__FILE__,normals,g);
|
theCommands.Add("normals","normals shape [Length {10}] [-NbAlongU {1}] [-NbAlongV {1}] [-UseMesh] [-print], display normals",__FILE__,normals,g);
|
||||||
theCommands.Add("nbshapes",
|
theCommands.Add("nbshapes",
|
||||||
"\n nbshapes s - shows the number of sub-shapes in <s>;\n nbshapes s -t - shows the number of sub-shapes in <s> counting the same sub-shapes with different location as different sub-shapes.",
|
"\n nbshapes s - shows the number of sub-shapes in <s>;\n nbshapes s -t - shows the number of sub-shapes in <s> counting the same sub-shapes with different location as different sub-shapes.",
|
||||||
__FILE__,nbshapes,g);
|
__FILE__,nbshapes,g);
|
||||||
|
33
tests/bugs/modalg_7/bug29293_1
Normal file
33
tests/bugs/modalg_7/bug29293_1
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
puts "========"
|
||||||
|
puts "OCC29293"
|
||||||
|
puts "========"
|
||||||
|
puts ""
|
||||||
|
#################################################
|
||||||
|
# Boolean Operations algorithm does not preserve the orientations of the faces
|
||||||
|
#################################################
|
||||||
|
|
||||||
|
brestore [locate_data_file bug29293_etchable_face_compound.brep] a
|
||||||
|
brestore [locate_data_file bug29293_top_shell.brep] b
|
||||||
|
|
||||||
|
bclearobjects
|
||||||
|
bcleartools
|
||||||
|
baddcompound a
|
||||||
|
baddtools b
|
||||||
|
bfillds
|
||||||
|
bbop result 0
|
||||||
|
|
||||||
|
checkshape result
|
||||||
|
checkprops result -s 411200
|
||||||
|
checknbshapes result -vertex 588 -edge 588 -wire 147 -face 147 -shell 147
|
||||||
|
|
||||||
|
|
||||||
|
# Check that the normal directions have been preserved.
|
||||||
|
# All faces from input shapes which could pass into result have normals
|
||||||
|
# directed stricly to the top (0, 0, 1). So, it is necessary to check
|
||||||
|
# that all faces from the result have the same normal direction.
|
||||||
|
|
||||||
|
foreach f [explode result f] {
|
||||||
|
if {![regexp "(0, 0, 1)" [normals $f -length 1 -print]]} {
|
||||||
|
puts "Error: the orientation is changed"
|
||||||
|
}
|
||||||
|
}
|
43
tests/bugs/modalg_7/bug29293_2
Normal file
43
tests/bugs/modalg_7/bug29293_2
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
puts "========"
|
||||||
|
puts "OCC29293"
|
||||||
|
puts "========"
|
||||||
|
puts ""
|
||||||
|
#################################################
|
||||||
|
# Boolean Operations algorithm does not preserve the orientations of the faces
|
||||||
|
#################################################
|
||||||
|
|
||||||
|
brestore [locate_data_file bug29293_etchable_face_compound.brep] a
|
||||||
|
brestore [locate_data_file bug29293_top_shell.brep] b
|
||||||
|
|
||||||
|
explode a f
|
||||||
|
explode b f
|
||||||
|
|
||||||
|
shape bsh Sh
|
||||||
|
add b_25 bsh
|
||||||
|
|
||||||
|
bclearobjects
|
||||||
|
bcleartools
|
||||||
|
baddobjects a_7
|
||||||
|
baddtools bsh
|
||||||
|
bfillds
|
||||||
|
bbop result 0
|
||||||
|
|
||||||
|
checkshape result
|
||||||
|
checkprops result -s 13460
|
||||||
|
checknbshapes result -vertex 4 -edge 4 -wire 1 -face 1 -shell 1
|
||||||
|
|
||||||
|
|
||||||
|
smallview
|
||||||
|
don result
|
||||||
|
fit
|
||||||
|
|
||||||
|
# Check that the normal directions have been preserved.
|
||||||
|
# Both input faces faces have normals
|
||||||
|
# directed stricly to the top (0, 0, 1). So, it is necessary to check
|
||||||
|
# that the reuslting face has the same normal direction.
|
||||||
|
|
||||||
|
if {![regexp "(0, 0, 100)" [normals result -length 100 -print]]} {
|
||||||
|
puts "Error: the orientation is changed"
|
||||||
|
}
|
||||||
|
|
||||||
|
checkview -screenshot -2d -path ${imagedir}/${test_image}_1.png
|
Loading…
x
Reference in New Issue
Block a user