mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-17 00:47:55 +05:00
PAL5838: fix done by PKV
This commit is contained in:
parent
325ab7e021
commit
7f6cfbbbcf
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : KeepShapesInside
|
//function : KeepShapesInside
|
||||||
//purpose : remove shapes that are outside of S from resul
|
//purpose : remove shapes that are outside of S from result
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void NMTAlgo_Splitter::KeepShapesInside (const TopoDS_Shape& S)
|
void NMTAlgo_Splitter::KeepShapesInside (const TopoDS_Shape& S)
|
||||||
{
|
{
|
||||||
@ -102,121 +102,150 @@
|
|||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : RemoveShapesInside
|
//function : RemoveShapesInside
|
||||||
//purpose : remove shapes that are inside S from resul
|
//purpose : remove shapes that are inside S from result
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void NMTAlgo_Splitter::RemoveShapesInside (const TopoDS_Shape& S)
|
void NMTAlgo_Splitter::RemoveShapesInside (const TopoDS_Shape& aS)
|
||||||
{
|
{
|
||||||
TopoDS_Iterator it;
|
TopoDS_Iterator it;
|
||||||
if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid
|
TopAbs_ShapeEnum aTypeS;
|
||||||
for (it.Initialize( S ); it.More(); it.Next())
|
//
|
||||||
RemoveShapesInside( it.Value());
|
aTypeS=aS.ShapeType();
|
||||||
|
if (aTypeS < TopAbs_SOLID) { // compound or compsolid
|
||||||
|
it.Initialize(aS);
|
||||||
|
for (; it.More(); it.Next()) {
|
||||||
|
const TopoDS_Shape& aSx=it.Value();
|
||||||
|
RemoveShapesInside(aSx);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Standard_Boolean isTool = Standard_False;
|
//
|
||||||
if (!myImageShape.HasImage( S )) {
|
Standard_Boolean bFromTool, bIsClosed;
|
||||||
//isTool = CheckTool( S );
|
Standard_Integer i, aNbE;
|
||||||
//if (!isTool) return;
|
TopoDS_Shape aIntFacesComp;
|
||||||
return;
|
TopoDS_Compound aC;
|
||||||
}
|
|
||||||
|
|
||||||
TopoDS_Shape IntFacesComp = FindFacesInside( S, Standard_False, Standard_True);
|
|
||||||
TopTools_IndexedMapOfShape MIF; // map of internal faces
|
TopTools_IndexedMapOfShape MIF; // map of internal faces
|
||||||
TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF);
|
|
||||||
|
|
||||||
if (MIF.IsEmpty()) return;
|
|
||||||
|
|
||||||
// add to MIF split faces of S
|
|
||||||
if (myImageShape.HasImage(S))
|
|
||||||
TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MIF);
|
|
||||||
|
|
||||||
// leave in the result only those shapes not having all face in MIF
|
|
||||||
|
|
||||||
TopoDS_Compound C;
|
|
||||||
myBuilder.MakeCompound(C);
|
|
||||||
|
|
||||||
// RMF : faces of removed shapes that encounter once
|
|
||||||
TopTools_MapOfShape RFM;
|
TopTools_MapOfShape RFM;
|
||||||
|
TopTools_MapIteratorOfMapOfShape itF;
|
||||||
for (it.Initialize( myShape ); it.More(); it.Next()) {
|
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
|
||||||
|
//
|
||||||
TopExp_Explorer expResF( it.Value(), TopAbs_FACE );
|
bFromTool=myToolShapes.Contains(aS);
|
||||||
for (; expResF.More(); expResF.Next())
|
//
|
||||||
if (!MIF.Contains( expResF.Current()))
|
if (!myImageShape.HasImage(aS)) {
|
||||||
break;
|
return;
|
||||||
|
|
||||||
if (expResF.More())
|
|
||||||
// add shape to result
|
|
||||||
myBuilder.Add( C, it.Value() );
|
|
||||||
else
|
|
||||||
// add faces of a removed shape to RFM
|
|
||||||
for (expResF.ReInit(); expResF.More(); expResF.Next()) {
|
|
||||||
const TopoDS_Shape& F = expResF.Current();
|
|
||||||
if ( ! RFM.Remove ( F ))
|
|
||||||
RFM.Add( F );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if (!isTool) {
|
aIntFacesComp = FindFacesInside(aS, Standard_False, Standard_True);
|
||||||
|
//
|
||||||
// rebuild S, it must remain in the result
|
TopExp::MapShapes(aIntFacesComp, TopAbs_FACE, MIF);
|
||||||
|
if (MIF.IsEmpty()) {
|
||||||
Standard_Boolean isClosed = Standard_False;
|
return;
|
||||||
switch (S.ShapeType()) {
|
}
|
||||||
case TopAbs_SOLID :
|
// add to MIF split faces of S
|
||||||
isClosed = Standard_True; break;
|
const TopoDS_Shape& aSIm=myImageShape.Image(aS).First();
|
||||||
case TopAbs_SHELL: {
|
TopExp::MapShapes(aSIm, TopAbs_FACE, MIF);
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape MEF;
|
//
|
||||||
TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, MEF);
|
// leave in the result only those shapes not having all face in MIF
|
||||||
Standard_Integer i;
|
myBuilder.MakeCompound(aC);
|
||||||
for (i=1; isClosed && i<=MEF.Extent(); ++i)
|
//
|
||||||
isClosed = ( MEF(i).Extent() != 1 );
|
// RFM : faces of removed shapes that encounter once
|
||||||
break;
|
it.Initialize(myShape);
|
||||||
}
|
for (; it.More(); it.Next()) {
|
||||||
default:
|
TopExp_Explorer expResF;
|
||||||
isClosed = Standard_False;
|
//
|
||||||
}
|
const TopoDS_Shape& aSR=it.Value();
|
||||||
if (isClosed) {
|
//
|
||||||
|
expResF.Init(aSR, TopAbs_FACE);
|
||||||
// add to a new shape external faces of removed shapes, ie those in RFM
|
for (; expResF.More(); expResF.Next()) {
|
||||||
|
const TopoDS_Shape& aFR=expResF.Current();
|
||||||
TopoDS_Shell Shell;
|
if (!MIF.Contains(aFR)) {
|
||||||
myBuilder.MakeShell( Shell );
|
break;
|
||||||
|
|
||||||
// exclude redundant internal face with edges encounterd only once
|
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape MEF;
|
|
||||||
TopTools_MapIteratorOfMapOfShape itF (RFM);
|
|
||||||
for ( ; itF.More(); itF.Next())
|
|
||||||
TopExp::MapShapesAndAncestors(itF.Key(), TopAbs_EDGE, TopAbs_FACE, MEF);
|
|
||||||
|
|
||||||
// add only faces forming a closed shell
|
|
||||||
for (itF.Reset() ; itF.More(); itF.Next())
|
|
||||||
{
|
|
||||||
TopExp_Explorer expE (itF.Key(), TopAbs_EDGE);
|
|
||||||
for (; expE.More(); expE.Next())
|
|
||||||
if (MEF.FindFromKey(expE.Current()).Extent() == 1)
|
|
||||||
break;
|
|
||||||
if (!expE.More())
|
|
||||||
myBuilder.Add( Shell, itF.Key());
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (S.ShapeType() == TopAbs_SOLID) {
|
//
|
||||||
TopoDS_Solid Solid;
|
if (expResF.More()) {
|
||||||
myBuilder.MakeSolid( Solid );
|
// add shape to result
|
||||||
myBuilder.Add (Solid, Shell);
|
myBuilder.Add(aC, aSR);
|
||||||
myBuilder.Add (C, Solid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
myBuilder.Add (C, Shell);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (myImageShape.HasImage( S )) {
|
// add faces of a removed shape to RFM
|
||||||
for (it.Initialize( myImageShape.Image(S).First()); it.More(); it.Next())
|
if (!bFromTool) { //modified by NIZNHY-PKV Thu Dec 23 09:55:39 2004 ft
|
||||||
myBuilder.Add (C, it.Value());
|
for (expResF.ReInit(); expResF.More(); expResF.Next()) {
|
||||||
}
|
const TopoDS_Shape& aF = expResF.Current();
|
||||||
|
if (!RFM.Remove(aF)) {
|
||||||
|
RFM.Add(aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//modified by NIZNHY-PKV Thu Dec 23 09:55:29 2004 ft
|
||||||
|
}
|
||||||
|
}// for (; it.More(); it.Next())
|
||||||
|
//
|
||||||
|
if (bFromTool) {
|
||||||
|
myShape=aC;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// bIsClosed
|
||||||
|
bIsClosed = Standard_False;
|
||||||
|
if (aTypeS==TopAbs_SOLID) {
|
||||||
|
bIsClosed = Standard_True;
|
||||||
|
}
|
||||||
|
else if (aTypeS==TopAbs_SHELL) {
|
||||||
|
aMEF.Clear();
|
||||||
|
TopExp::MapShapesAndAncestors(aS, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
||||||
|
aNbE=aMEF.Extent();
|
||||||
|
for (i=1; bIsClosed && i<=aNbE; ++i) {
|
||||||
|
bIsClosed=(aMEF(i).Extent()!=1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
myShape = C;
|
// rebuild S, it must remain in the result
|
||||||
|
if (bIsClosed) {
|
||||||
|
// add to a new shape external faces of removed shapes, ie those in RFM
|
||||||
|
TopoDS_Shell aShell;
|
||||||
|
//
|
||||||
|
myBuilder.MakeShell(aShell);
|
||||||
|
// exclude redundant internal face with edges encounterd only once
|
||||||
|
aMEF.Clear();
|
||||||
|
itF.Initialize (RFM);
|
||||||
|
for (; itF.More(); itF.Next()) {
|
||||||
|
const TopoDS_Shape& aF=itF.Key();
|
||||||
|
TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
||||||
|
}
|
||||||
|
// add only faces forming a closed shell
|
||||||
|
for (itF.Reset() ; itF.More(); itF.Next()) {
|
||||||
|
const TopoDS_Shape& aF=itF.Key();
|
||||||
|
TopExp_Explorer expE (aF, TopAbs_EDGE);
|
||||||
|
for (; expE.More(); expE.Next()) {
|
||||||
|
if (aMEF.FindFromKey(expE.Current()).Extent()==1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!expE.More()) {
|
||||||
|
myBuilder.Add(aShell, aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (aTypeS==TopAbs_SOLID) {
|
||||||
|
TopoDS_Solid aSolid;
|
||||||
|
//
|
||||||
|
myBuilder.MakeSolid(aSolid);
|
||||||
|
myBuilder.Add (aSolid, aShell);
|
||||||
|
myBuilder.Add (aC, aSolid);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
myBuilder.Add (aC, aShell);
|
||||||
|
}
|
||||||
|
} // if (bIsClosed) {
|
||||||
|
//
|
||||||
|
else {
|
||||||
|
it.Initialize(aSIm);
|
||||||
|
for (; it.More(); it.Next()) {
|
||||||
|
const TopoDS_Shape& aSx=it.Value();
|
||||||
|
myBuilder.Add (aC, aSx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
myShape=aC;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user