PAL5249: Problem in Partition algorithm. Fix done by PKV.

This commit is contained in:
jfa 2005-01-17 11:54:03 +00:00
parent 96003c9a54
commit 06137bb35d
2 changed files with 98 additions and 88 deletions

View File

@ -285,12 +285,20 @@
// //
aNbSd=aMSd.Extent(); aNbSd=aMSd.Extent();
if (!aNbSd) { if (!aNbSd) {
//modified by NIZNHY-PKV Thu Dec 23 15:07:46 2004 f
Standard_Boolean bFound;
//modified by NIZNHY-PKV Thu Dec 23 15:07:49 2004 t
TopoDS_Shape aSd; TopoDS_Shape aSd;
// //
const TopoDS_Shape& aFC=myImageShape.Image(aS).First(); const TopoDS_Shape& aFC=myImageShape.Image(aS).First();
NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd); //modified by NIZNHY-PKV Thu Dec 23 15:08:17 2004 f
// //NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd);
aMSd.Add(aSd); //aMSd.Add(aSd);
bFound=NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd);
if (!aSd.IsNull()) {
aMSd.Add(aSd);
}
//modified by NIZNHY-PKV Thu Dec 23 15:09:02 2004 t
} }
aMCS.Add(aS, aMSd); aMCS.Add(aS, aMSd);
} //for ( ;aItS.More(); aItS.Next()) } //for ( ;aItS.More(); aItS.Next())

View File

@ -106,7 +106,13 @@
if (myClosedShapes.Contains(aS)) { if (myClosedShapes.Contains(aS)) {
// //
// internal faces compound // internal faces compound
//modified by NIZNHY-PKV Thu Dec 23 16:34:05 2004 f
Standard_Integer aNbIF;
//
aNbIF=myInternalFaces.Extent();
//modified by NIZNHY-PKV Thu Dec 23 16:34:07 2004 t
TopoDS_Shape aIFC=FindFacesInside(aS, Standard_True); TopoDS_Shape aIFC=FindFacesInside(aS, Standard_True);
aNbIF=myInternalFaces.Extent();
aShellMaker.AddSectionFaces(aIFC); aShellMaker.AddSectionFaces(aIFC);
} }
// //
@ -248,15 +254,15 @@
// get data for internal faces search // get data for internal faces search
// =================================== // ===================================
// //
// compound of split faces of theShape
const TopoDS_Shape& CSF = myImageShape.Image(theShape).First();
//
TopTools_MapOfShape MSE, MFP; TopTools_MapOfShape MSE, MFP;
TopTools_DataMapOfShapeListOfShape DMSEFP; TopTools_DataMapOfShapeListOfShape DMSEFP;
TopTools_IndexedDataMapOfShapeListOfShape DMEF;
TopTools_MapIteratorOfMapOfShape itm; TopTools_MapIteratorOfMapOfShape itm;
TopTools_ListOfShape EmptyL; TopTools_ListOfShape EmptyL;
TopTools_ListIteratorOfListOfShape itl; TopTools_ListIteratorOfListOfShape itl;
//
// compound of split faces of theShape
const TopoDS_Shape& CSF=myImageShape.Image(theShape).First();
// MSE filling: map of new section edges of CSF // MSE filling: map of new section edges of CSF
expl.Init(CSF, TopAbs_EDGE); expl.Init(CSF, TopAbs_EDGE);
for (; expl.More(); expl.Next()) { for (; expl.More(); expl.Next()) {
@ -265,7 +271,6 @@
} }
// //
// DMEF: map edge of CSF - faces of CSF // DMEF: map edge of CSF - faces of CSF
TopTools_IndexedDataMapOfShapeListOfShape DMEF;
TopExp::MapShapesAndAncestors(CSF, TopAbs_EDGE, TopAbs_FACE, DMEF); TopExp::MapShapesAndAncestors(CSF, TopAbs_EDGE, TopAbs_FACE, DMEF);
// //
// Fill // Fill
@ -302,75 +307,75 @@
} }
}//for (;itl.More(); itl.Next()) }//for (;itl.More(); itl.Next())
// //
// add tool faces... (is absent)
//
// =========================== // ===========================
// find faces inside theShape // find faces inside theShape
// =========================== // ===========================
Standard_Boolean skipAlreadyAdded = Standard_False; Standard_Boolean skipAlreadyAdded = Standard_False;
Standard_Boolean GoodOri, inside; Standard_Boolean GoodOri, inside, sameDom1, sameDom2, isSectionE;
Standard_Real dot; Standard_Real dot;
TopoDS_Face aFace1, anOrigFace, origF1, origF2; //, anOrigFace2;
TopTools_ListOfShape KeepFaces; TopTools_ListOfShape KeepFaces;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit;
//
// iterate on section edges, check faces of other shapes // iterate on section edges, check faces of other shapes
// sharing section edges and put internal faces to KeepFaces // sharing section edges and put internal faces to KeepFaces
Mapit.Initialize(DMSEFP); Mapit.Initialize(DMSEFP);
for (; Mapit.More() ; Mapit.Next() ) { for (; Mapit.More() ; Mapit.Next() ) {
// a new edge of theShape // a new edge of theShape
const TopoDS_Edge& E = TopoDS::Edge (Mapit.Key()); const TopoDS_Edge& E = TopoDS::Edge (Mapit.Key());
// an original edge of which E is a split //
//const TopoDS_Edge& OrigE = TopoDS::Edge (myImagesEdges.Root(E)); isSectionE=IsSectionEdge(E);
// does OrigE itself splits a face //
Standard_Boolean isSectionE=IsSectionEdge(E);//(OrigE);
// split faces of other shapes sharing E // split faces of other shapes sharing E
TopTools_ListOfShape& LSF = DMSEFP.ChangeFind(E); TopTools_ListOfShape& LSF = DMSEFP.ChangeFind(E);
//
itl.Initialize( LSF ); itl.Initialize( LSF );
while (itl.More()) { while (itl.More()) {
// a split faces of other shape // a split faces of other shape
TopoDS_Face aFace1 = TopoDS::Face(itl.Value()); aFace1 = TopoDS::Face(itl.Value());
// remove aFace1 form DMSEFP and MFP // remove aFace1 form DMSEFP and MFP
LSF.Remove( itl ); // == itl.Next(); LSF.Remove( itl ); // == itl.Next();
if (!MFP.Remove( aFace1 )) if (!MFP.Remove( aFace1 ))
continue; // was not is MFP ( i.e already checked) continue; // was not is MFP ( i.e already checked)
//
// check if aFace1 was already added to 2 shells // check if aFace1 was already added to 2 shells
if (!All && if (!All &&
myAddedFacesMap.Contains(aFace1) && myAddedFacesMap.Contains(aFace1) &&
myAddedFacesMap.Contains(aFace1.Reversed())) { myAddedFacesMap.Contains(aFace1.Reversed())) {
skipAlreadyAdded = Standard_True; skipAlreadyAdded = Standard_True;
//modified by NIZNHY-PKV Wed Feb 11 16:11:53 2004 f
//continue;
//modified by NIZNHY-PKV Wed Feb 11 16:35:48 2004 t
} }
// //
// find another face which originates from the same face as aFace1: // find another face which originates from the same face as aFace1:
// usually aFace2 is internal if aFace1 is not and vice versa // usually aFace2 is internal if aFace1 is not and vice versa
TopoDS_Shape anOrigFace = aFace1; anOrigFace = aFace1;
if (myImagesFaces.IsImage(aFace1)){ if (myImagesFaces.IsImage(aFace1)){
anOrigFace = myImagesFaces.Root(aFace1); anOrigFace = TopoDS::Face(myImagesFaces.Root(aFace1));
} }
// //
TopoDS_Shape aFace2; //modified by NIZNHY-PKV Fri Dec 24 10:59:45 2004 f
if ( !isSectionE ) { /*
while (itl.More()) { TopoDS_Face aFace2;
aFace2 = itl.Value(); //
if (!isSectionE) {
while (itl.More()) { //#2
aFace2 = TopoDS::Face(itl.Value());
// //
TopoDS_Shape anOrigFace2 = aFace2; anOrigFace2 = aFace2;
if (myImagesFaces.IsImage(aFace2)) { if (myImagesFaces.IsImage(aFace2)) {
anOrigFace2 = myImagesFaces.Root(aFace2); anOrigFace2 = TopoDS::Face(myImagesFaces.Root(aFace2));
} }
// //
if (!MFP.Contains( aFace2 )) { if (!MFP.Contains( aFace2 )) {
LSF.Remove( itl ); LSF.Remove( itl );
continue; continue;
} }
//if (anOrigFace.IsSame( myImagesFaces.Root( aFace2 ))) //
if (anOrigFace.IsSame(anOrigFace2)) { if (anOrigFace.IsSame(anOrigFace2)) {
break; break;
} }
itl.Next(); itl.Next();
} }// while (itl.More()) { #2
//
if (itl.More()) { // aFace2 found, remove it from maps if (itl.More()) { // aFace2 found, remove it from maps
LSF.Remove( itl ); LSF.Remove( itl );
MFP.Remove(aFace2); MFP.Remove(aFace2);
@ -379,94 +384,91 @@
aFace2.Nullify(); aFace2.Nullify();
} }
itl.Initialize( LSF ); itl.Initialize( LSF );
} } // if (!isSectionE) {
*/
// check that anOrigFace is not same domain with CSF faces it intersects //modified by NIZNHY-PKV Fri Dec 24 10:59:52 2004 t
const TopTools_ListOfShape& FL = DMEF.FindFromKey(E); //faces of CSF sharing E
const TopoDS_Shape& origF1 = myImagesFaces.IsImage(FL.First()) ?
myImagesFaces.Root(FL.First()) : FL.First();
const TopoDS_Shape& origF2 = myImagesFaces.IsImage(FL.Last()) ?
myImagesFaces.Root(FL.Last()) : FL.Last();
// //
Standard_Boolean sameDom1 = anOrigFace.IsSame( origF1 ); // check that anOrigFace is not same domain with CSF faces it intersects
Standard_Boolean sameDom2 = anOrigFace.IsSame( origF2 ); //
//faces of CSF sharing E
if (!(sameDom1 || sameDom2) && HasSameDomainF( TopoDS::Face(anOrigFace) )) { //
sameDom1 = IsSameDomainF( TopoDS::Face(anOrigFace), TopoDS::Face(origF1)); const TopTools_ListOfShape& FL = DMEF.FindFromKey(E);
const TopoDS_Face& aFE1=TopoDS::Face(FL.First());
const TopoDS_Face& aFE2=TopoDS::Face(FL.Last());
//
origF1=aFE1;
if (myImagesFaces.IsImage(aFE1)) {
origF1=TopoDS::Face(myImagesFaces.Root(aFE1));
}
origF2=aFE2;
if (myImagesFaces.IsImage(aFE2)) {
origF2=TopoDS::Face(myImagesFaces.Root(aFE2));
}
//
sameDom1 = anOrigFace.IsSame( origF1 );
sameDom2 = anOrigFace.IsSame( origF2 );
//
if (!(sameDom1 || sameDom2) && HasSameDomainF(anOrigFace)) {
sameDom1 = IsSameDomainF(anOrigFace, origF1);
if (origF1 == origF2) { if (origF1 == origF2) {
sameDom2 = sameDom1; sameDom2 = sameDom1;
} }
else{
IsSameDomainF( TopoDS::Face(anOrigFace), TopoDS::Face(origF2));
}
} }
//
if (sameDom1 && sameDom2){ if (sameDom1 && sameDom2){
continue; continue;
} }
//
if (sameDom1 || sameDom2) { if (sameDom1 || sameDom2) {
inside = NMTAlgo_Loop3d::IsInside (E, inside = NMTAlgo_Loop3d::IsInside (E, aFE1, aFE2, 1, dot, GoodOri);
TopoDS::Face(FL.First()), if (inside || (dot + Precision::Angular() >= 1.0)) {
TopoDS::Face(FL.Last()),
1, dot, GoodOri);
if (inside || (dot + Precision::Angular() >= 1.0))
continue; // E is convex between origF1 and origF2 or they are tangent continue; // E is convex between origF1 and origF2 or they are tangent
}
} }
// //
// keep one of found faces // Keep one of found faces
//
//face of CSF sharing E //face of CSF sharing E
const TopoDS_Shape& aShapeFace = sameDom1 ? FL.Last() : FL.First(); const TopoDS_Face& aShapeFace = sameDom1 ? aFE2 : aFE1;
// analyse aFace1 state // analyse aFace1 state
inside = NMTAlgo_Loop3d::IsInside (E, TopoDS::Face(aShapeFace), aFace1, inside = NMTAlgo_Loop3d::IsInside (E, aShapeFace, aFace1, 1, dot, GoodOri);
1, dot, GoodOri);
// if (inside && isSectionE) {
if (inside) { //IFV 27.08.04 if (inside) { //IFV 27.08.04
// aFace1 must be tested with both adjacent faces of CSF // aFace1 must be tested with both adjacent faces of CSF
const TopoDS_Shape& aShapeFace2 = sameDom1 ? FL.First() : FL.Last(); const TopoDS_Face& aShapeFace2 = sameDom1 ? aFE1 : aFE2;
if (aShapeFace2 != aShapeFace){ if (aShapeFace2 != aShapeFace){
inside = NMTAlgo_Loop3d::IsInside (E, TopoDS::Face(aShapeFace2), aFace1, inside =
1, dot, GoodOri); NMTAlgo_Loop3d::IsInside(E, aShapeFace2, aFace1, 1, dot, GoodOri);
} }
} }
// //
// store internal face // store internal face
if (inside) if (inside) {
KeepFaces.Append(aFace1); KeepFaces.Append(aFace1);
}
//
//modified by NIZNHY-PKV Fri Dec 24 11:02:55 2004 f
/*
else if (!aFace2.IsNull()) { else if (!aFace2.IsNull()) {
if (dot + Precision::Angular() >= 1.0) { if (dot + Precision::Angular() >= 1.0) {
// aFace2 state is not clear, it will be analysed alone, // aFace2 state is not clear, it will be analysed alone, put it back to the maps
// put it back to the maps MFP.Add(aFace2);
MFP.Add( aFace2 ); LSF.Append(aFace2);
LSF.Append( aFace2 );
} }
else else {
KeepFaces.Append(aFace2); KeepFaces.Append(aFace2);
}
} }
} */
} //modified by NIZNHY-PKV Fri Dec 24 11:03:03 2004 t
}// while (itl.More()) {
}// for (; Mapit.More() ; Mapit.Next() ) {
//
// =================================================== // ===================================================
// add not distributed faces connected with KeepFaces // add not distributed faces connected with KeepFaces
// =================================================== // ===================================================
// ultimate list of internal faces // ultimate list of internal faces
TopTools_ListOfShape KeptFaces; TopTools_ListOfShape KeptFaces;
// //
// add to MFP not split tool faces as well, they may be connected with
// tool faces interfering with theShape
/*
itm.Initialize(myMapTools);
for (; itm.More(); itm.Next() ) {
const TopoDS_Shape& aToolFace = itm.Key();
if (!myImageShape.HasImage(aToolFace)){
MFP.Add (aToolFace);
}
}
*/
//
if (MFP.IsEmpty()) if (MFP.IsEmpty())
KeptFaces.Append (KeepFaces); KeptFaces.Append (KeepFaces);
// //