mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-12 01:30:36 +05:00
0022495: [CEA 1058] Shape invalide after UnionFaces
This commit is contained in:
parent
97d9c2c6b1
commit
3866909ccc
58
src/BlockFix/BlockFix_UnionFaces.cxx
Executable file → Normal file
58
src/BlockFix/BlockFix_UnionFaces.cxx
Executable file → Normal file
@ -274,9 +274,6 @@ static Standard_Boolean IsEdgeValidToMerge(const TopoDS_Edge &theEdge,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
||||||
{
|
{
|
||||||
Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape;
|
|
||||||
TopoDS_Shape aResShape = myContext->Apply(Shape);
|
|
||||||
|
|
||||||
// Fill Map of faces as keys and list of solids or shells as items.
|
// Fill Map of faces as keys and list of solids or shells as items.
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape aMapFaceSoOrSh;
|
TopTools_IndexedDataMapOfShapeListOfShape aMapFaceSoOrSh;
|
||||||
|
|
||||||
@ -290,6 +287,8 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
(Shape, TopAbs_FACE, aType, aMapFaceSoOrSh);
|
(Shape, TopAbs_FACE, aType, aMapFaceSoOrSh);
|
||||||
|
|
||||||
// processing each solid
|
// processing each solid
|
||||||
|
Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
|
||||||
|
TopTools_MapOfShape aProcessed;
|
||||||
TopExp_Explorer exps;
|
TopExp_Explorer exps;
|
||||||
for (exps.Init(Shape, aType); exps.More(); exps.Next()) {
|
for (exps.Init(Shape, aType); exps.More(); exps.Next()) {
|
||||||
TopoDS_Shape aSoOrSh = exps.Current();
|
TopoDS_Shape aSoOrSh = exps.Current();
|
||||||
@ -298,11 +297,6 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
|
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
|
||||||
TopExp::MapShapesAndAncestors(aSoOrSh, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
TopExp::MapShapesAndAncestors(aSoOrSh, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
||||||
|
|
||||||
// map of processed shapes
|
|
||||||
TopTools_MapOfShape aProcessed;
|
|
||||||
|
|
||||||
Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
|
|
||||||
|
|
||||||
Standard_Integer NbModif = 0;
|
Standard_Integer NbModif = 0;
|
||||||
Standard_Boolean hasFailed = Standard_False;
|
Standard_Boolean hasFailed = Standard_False;
|
||||||
Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1);
|
Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1);
|
||||||
@ -324,8 +318,9 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
for (exp.Init(aSoOrSh, TopAbs_FACE); exp.More() && doUnion; exp.Next()) {
|
for (exp.Init(aSoOrSh, TopAbs_FACE); exp.More() && doUnion; exp.Next()) {
|
||||||
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
||||||
|
|
||||||
if (aProcessed.Contains(aFace))
|
if (aProcessed.Contains(aFace)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Standard_Integer dummy;
|
Standard_Integer dummy;
|
||||||
TopTools_SequenceOfShape edges;
|
TopTools_SequenceOfShape edges;
|
||||||
@ -338,6 +333,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
TopLoc_Location aBaseLocation;
|
TopLoc_Location aBaseLocation;
|
||||||
Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation);
|
Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation);
|
||||||
aBaseSurface = ClearRts(aBaseSurface);
|
aBaseSurface = ClearRts(aBaseSurface);
|
||||||
|
aBaseSurface = Handle(Geom_Surface)::DownCast(aBaseSurface->Copy());
|
||||||
|
|
||||||
// find adjacent faces to union
|
// find adjacent faces to union
|
||||||
Standard_Integer i;
|
Standard_Integer i;
|
||||||
@ -439,8 +435,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
// sorting any type of edges
|
// sorting any type of edges
|
||||||
aWire = TopoDS::Wire(aContext->Apply(aWire));
|
aWire = TopoDS::Wire(aContext->Apply(aWire));
|
||||||
|
|
||||||
TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD)));
|
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,aResult,Precision::Confusion());
|
||||||
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion());
|
|
||||||
sfw->FixReorder();
|
sfw->FixReorder();
|
||||||
Standard_Boolean isDegRemoved = Standard_False;
|
Standard_Boolean isDegRemoved = Standard_False;
|
||||||
if(!sfw->StatusReorder ( ShapeExtend_FAIL )) {
|
if(!sfw->StatusReorder ( ShapeExtend_FAIL )) {
|
||||||
@ -478,7 +473,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
Standard_Real f,l;
|
Standard_Real f,l;
|
||||||
//smh protection on NULL pcurve
|
//smh protection on NULL pcurve
|
||||||
Handle(Geom2d_Curve) c2d;
|
Handle(Geom2d_Curve) c2d;
|
||||||
if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) {
|
if(!sae.PCurve(sbwd->Edge(j),aResult,c2d,f,l)) {
|
||||||
aLastEdge--;
|
aLastEdge--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -499,8 +494,8 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
gp_XY aVec = anEnd-aStart;
|
gp_XY aVec = anEnd-aStart;
|
||||||
Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart));
|
Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart));
|
||||||
|
|
||||||
B.UpdateEdge(E,aLine,tmpF,0.);
|
B.UpdateEdge(E,aLine,aResult,0.);
|
||||||
B.Range(E,tmpF,0.,aVec.Modulus());
|
B.Range(E,aResult,0.,aVec.Modulus());
|
||||||
Handle(Geom_Curve) C3d;
|
Handle(Geom_Curve) C3d;
|
||||||
B.UpdateEdge(E,C3d,0.);
|
B.UpdateEdge(E,C3d,0.);
|
||||||
B.Degenerated(E,Standard_True);
|
B.Degenerated(E,Standard_True);
|
||||||
@ -585,30 +580,27 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
// ptv add fix same parameter
|
// ptv add fix same parameter
|
||||||
sfe.FixSameParameter(E, myTolerance);
|
sfe.FixSameParameter(E, myTolerance);
|
||||||
}
|
}
|
||||||
|
|
||||||
myContext->Replace(aSoOrSh, aResult);
|
|
||||||
}
|
}
|
||||||
//else
|
|
||||||
{
|
for (exp.Init(aSoOrSh, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||||
for (exp.Init(aSoOrSh, TopAbs_FACE); exp.More(); exp.Next()) {
|
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
||||||
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
|
||||||
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
|
sfw->SetContext(aContext);
|
||||||
sfw->SetContext(myContext);
|
sfw->SetPrecision(myTolerance);
|
||||||
sfw->SetPrecision(myTolerance);
|
sfw->SetMinTolerance(myTolerance);
|
||||||
sfw->SetMinTolerance(myTolerance);
|
sfw->SetMaxTolerance(Max(1.,myTolerance*1000.));
|
||||||
sfw->SetMaxTolerance(Max(1.,myTolerance*1000.));
|
sfw->SetFace(aFace);
|
||||||
sfw->SetFace(aFace);
|
for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) {
|
||||||
for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) {
|
TopoDS_Wire wire = TopoDS::Wire(iter.Value());
|
||||||
TopoDS_Wire wire = TopoDS::Wire(iter.Value());
|
sfw->Load(wire);
|
||||||
sfw->Load(wire);
|
sfw->FixReorder();
|
||||||
sfw->FixReorder();
|
sfw->FixShifted();
|
||||||
sfw->FixShifted();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end processing each solid
|
} // end processing each solid
|
||||||
|
|
||||||
aResShape = myContext->Apply(Shape);
|
const TopoDS_Shape aResShape = aContext->Apply(Shape);
|
||||||
|
|
||||||
return aResShape;
|
return aResShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user