PAL7508: Development of new block functionalities. GetInPlace() now works for the case of solids.

This commit is contained in:
jfa 2005-02-02 12:38:58 +00:00
parent d4ecb90145
commit 25ebdee483
8 changed files with 492 additions and 245 deletions

View File

@ -808,6 +808,15 @@ void GEOMAlgo_Gluer::MakeFace(const TopoDS_Face& aF,
// //
aBB.Add(newWire, aER); aBB.Add(newWire, aER);
} }
//modified by NIZNHY-PKV Mon Jan 31 17:26:36 2005f
//
TopTools_ListOfShape aLW;
//
aLW.Append(aW);
myImages.Bind(newWire, aLW);
myOrigins.Bind(aW, newWire);
//
//modified by NIZNHY-PKV Mon Jan 31 17:26:41 2005 t
aBB.Add(newFace, newWire); aBB.Add(newFace, newWire);
} }
aNewFace=newFace; aNewFace=newFace;
@ -928,9 +937,12 @@ const TopTools_ListOfShape& GEOMAlgo_Gluer::Modified (const TopoDS_Shape& aS)
myGenerated.Clear(); myGenerated.Clear();
// //
aType=aS.ShapeType(); aType=aS.ShapeType();
if (aType==TopAbs_FACE || if (aType==TopAbs_VERTEX ||
aType==TopAbs_EDGE || aType==TopAbs_EDGE ||
aType==TopAbs_VERTEX) { aType==TopAbs_WIRE || //modified by NIZNHY-PKV Mon Jan 31 17:18:36 2005ft
aType==TopAbs_FACE ||
aType==TopAbs_SHELL || //modified by NIZNHY-PKV Mon Jan 31 17:18:36 2005ft
aType==TopAbs_SOLID) { //modified by NIZNHY-PKV Mon Jan 31 17:18:36 2005ft
if(myOrigins.IsBound(aS)) { if(myOrigins.IsBound(aS)) {
const TopoDS_Shape& aSnew=myOrigins.Find(aS); const TopoDS_Shape& aSnew=myOrigins.Find(aS);
if (!aSnew.IsSame(aS)) { if (!aSnew.IsSame(aS)) {

View File

@ -1407,7 +1407,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace
TDF_Label aHistoryLabel = aWhereFunction->GetHistoryEntry(Standard_False); TDF_Label aHistoryLabel = aWhereFunction->GetHistoryEntry(Standard_False);
if (aHistoryLabel.IsNull()) { if (aHistoryLabel.IsNull()) {
SetErrorCode("History for an operation, produced the shape, does not exist."); SetErrorCode("Modifications history does not exist for the shape under consideration.");
return NULL; return NULL;
} }
@ -1436,32 +1436,34 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace
TDF_Label anArgumentHistoryLabel = TDF_Label anArgumentHistoryLabel =
aWhereFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_False); aWhereFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_False);
if (anArgumentHistoryLabel.IsNull()) { if (anArgumentHistoryLabel.IsNull()) {
SetErrorCode("History for this entity does not exist."); // Lost History of operation argument. Possibly, all its entities was removed.
SetErrorCode(OK);
return NULL; return NULL;
} }
TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(aWhatIndex, Standard_False); TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(aWhatIndex, Standard_False);
if (aWhatHistoryLabel.IsNull()) { if (aWhatHistoryLabel.IsNull()) {
SetErrorCode("History for this entity does not exist."); // Removed entity
SetErrorCode(OK);
return NULL; return NULL;
} }
Handle(TDataStd_IntegerArray) anIntegerArray; Handle(TDataStd_IntegerArray) anIntegerArray;
if (!aWhatHistoryLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)) { if (!aWhatHistoryLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)) {
SetErrorCode("Empty history. Possibly, this entity is absent in result."); SetErrorCode("Error: Empty modifications history for the sought shape.");
return NULL; return NULL;
} }
aModifiedArray = anIntegerArray->Array(); aModifiedArray = anIntegerArray->Array();
if (aModifiedArray->Length() == 0) { if (aModifiedArray->Length() == 0) {
SetErrorCode("This entity is absent in result."); SetErrorCode("Error: Empty modifications history for the sought shape.");
return NULL; return NULL;
} }
} }
} }
if (!isFound) { if (!isFound) {
SetErrorCode("Not found in arguments."); SetErrorCode("The sought shape does not belong to any operation argument.");
return NULL; return NULL;
} }
} }

View File

@ -305,7 +305,7 @@ gp_Vec NextNormal(const TopoDS_Edge& E,
p.SetY( p.Y() + dir.Y()*duv ); p.SetY( p.Y() + dir.Y()*duv );
gp_Pnt Ps; gp_Pnt Ps;
gp_Vec Norm, V1, V2, VV1, VV2; gp_Vec Norm, V1, V2;
Sf->D1( p.X(), p.Y(), Ps, V1, V2); Sf->D1( p.X(), p.Y(), Ps, V1, V2);
Norm = V1.Crossed(V2); Norm = V1.Crossed(V2);

View File

@ -138,7 +138,14 @@ is
aShape : Shape from TopoDS) aShape : Shape from TopoDS)
returns Shape from TopoDS returns Shape from TopoDS
is protected; is protected;
--modified by NIZNHY-PKV Tue Feb 1 10:24:39 2005f
FindImage(me:out;
aS : Shape from TopoDS;
aLIms: out ListOfShape from TopTools)
is protected;
--modified by NIZNHY-PKV Tue Feb 1 10:24:47 2005t
fields fields
myDoneStep : ShapeEnum from TopAbs is protected; -- rebuilt level myDoneStep : ShapeEnum from TopAbs is protected; -- rebuilt level
myBuilder : Builder from BRep is protected; myBuilder : Builder from BRep is protected;

View File

@ -116,6 +116,7 @@ Standard_EXPORT void MakeSolids(const TopoDS_Shape& Solid,TopTools_ListOfShape
Standard_EXPORT TopoDS_Shape FindFacesInside(const TopoDS_Shape& S,const Standard_Boolean CheckClosed = Standard_False,const Standard_Boolean All = Standard_False) ; Standard_EXPORT TopoDS_Shape FindFacesInside(const TopoDS_Shape& S,const Standard_Boolean CheckClosed = Standard_False,const Standard_Boolean All = Standard_False) ;
Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Shape& S1,const TopoDS_Shape& S2) ; Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Shape& S1,const TopoDS_Shape& S2) ;
Standard_EXPORT TopoDS_Shape GetOriginalShape(const TopoDS_Shape& aShape) const; Standard_EXPORT TopoDS_Shape GetOriginalShape(const TopoDS_Shape& aShape) const;
Standard_EXPORT void FindImage(const TopoDS_Shape& aS,TopTools_ListOfShape& aLIms) ;
// Fields PROTECTED // Fields PROTECTED

View File

@ -5,34 +5,54 @@
#include <NMTAlgo_Splitter.ixx> #include <NMTAlgo_Splitter.ixx>
#include <TopExp_Explorer.hxx>
#include <Precision.hxx>
#include <gp_Pnt.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx> #include <TopoDS_Compound.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx> #include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx> #include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx> #include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx> #include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopExp.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx> #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopoDS.hxx> #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
#include <TopoDS_Edge.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Face.hxx> #include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <NMTAlgo_Loop3d.hxx>
#include <Precision.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepClass3d_SolidClassifier.hxx> #include <BRepClass3d_SolidClassifier.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS_Solid.hxx>
#include <NMTAlgo_Loop3d.hxx> #include <NMTAlgo_Loop3d.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
//
//modified by NIZNHY-PKV Tue Feb 1 12:12:39 2005 f
static
void RefineShells(const TopoDS_Shape& ,
TopTools_ListOfShape&);
static
void RefineSolids(const TopoDS_Shape& ,
TopTools_ListOfShape&);
//modified by NIZNHY-PKV Tue Feb 1 12:12:43 2005 t
//======================================================================= //=======================================================================
//function : ShellsAndSolids //function : ShellsAndSolids
//purpose : //purpose :
//======================================================================= //=======================================================================
void NMTAlgo_Splitter::ShellsAndSolids() void NMTAlgo_Splitter::ShellsAndSolids()
{ {
Standard_Boolean bMakeSolids; Standard_Boolean bMakeSolids;
TopAbs_ShapeEnum aType; TopAbs_ShapeEnum aType;
@ -93,8 +113,8 @@
//function : MakeShells //function : MakeShells
//purpose : split S into compound of shells //purpose : split S into compound of shells
//======================================================================= //=======================================================================
void NMTAlgo_Splitter::MakeShells(const TopoDS_Shape& aS, void NMTAlgo_Splitter::MakeShells(const TopoDS_Shape& aS,
TopTools_ListOfShape& aLNS) TopTools_ListOfShape& aLNS)
{ {
NMTAlgo_Loop3d aShellMaker; NMTAlgo_Loop3d aShellMaker;
// //
@ -106,17 +126,14 @@
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);
} }
// //
aLNS=aShellMaker.MakeShells(myAddedFacesMap); aLNS=aShellMaker.MakeShells(myAddedFacesMap);
//modified by NIZNHY-PKV Tue Feb 1 14:11:11 2005 f
RefineShells(aS, aLNS);
//modified by NIZNHY-PKV Tue Feb 1 14:11:14 2005 t
// //
// Add faces added to new shell to myAddedFacesMap: // Add faces added to new shell to myAddedFacesMap:
// avoid rebuilding twice common part of 2 solids. // avoid rebuilding twice common part of 2 solids.
@ -136,8 +153,8 @@
//function : MakeSolids //function : MakeSolids
//purpose : make solids out of Shells //purpose : make solids out of Shells
//======================================================================= //=======================================================================
void NMTAlgo_Splitter::MakeSolids(const TopoDS_Shape& theSolid, void NMTAlgo_Splitter::MakeSolids(const TopoDS_Shape& theSolid,
TopTools_ListOfShape& theShellList) TopTools_ListOfShape& theShellList)
{ {
// for a solid wrapping other shells or solids without intersection, // for a solid wrapping other shells or solids without intersection,
// it is necessary to find shells making holes in it // it is necessary to find shells making holes in it
@ -168,7 +185,7 @@
TopoDS_Solid Solid; TopoDS_Solid Solid;
myBuilder.MakeSolid( Solid ); myBuilder.MakeSolid( Solid );
myBuilder.Add (Solid, aShell); myBuilder.Add (Solid, aShell);
aNewSolids.Append (Solid); aNewSolids.Append (Solid);
} }
} }
@ -204,8 +221,12 @@
myBuilder.Add (aSolid, aHole); myBuilder.Add (aSolid, aHole);
} }
} }
//
theShellList.Clear(); theShellList.Clear();
theShellList.Append( aNewSolids ); //modified by NIZNHY-PKV Tue Feb 1 15:06:16 2005 f
RefineSolids(theSolid, aNewSolids);
//modified by NIZNHY-PKV Tue Feb 1 15:06:21 2005 t
theShellList.Append(aNewSolids);
} }
//======================================================================= //=======================================================================
@ -254,15 +275,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()) {
@ -271,6 +292,7 @@
} }
// //
// 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
@ -307,75 +329,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, sameDom1, sameDom2, isSectionE; Standard_Boolean GoodOri, inside;
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
isSectionE=IsSectionEdge(E); //const TopoDS_Edge& OrigE = TopoDS::Edge (myImagesEdges.Root(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
aFace1 = TopoDS::Face(itl.Value()); TopoDS_Face 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
anOrigFace = aFace1; TopoDS_Shape anOrigFace = aFace1;
if (myImagesFaces.IsImage(aFace1)){ if (myImagesFaces.IsImage(aFace1)){
anOrigFace = TopoDS::Face(myImagesFaces.Root(aFace1)); anOrigFace = myImagesFaces.Root(aFace1);
} }
// //
//modified by NIZNHY-PKV Fri Dec 24 10:59:45 2004 f TopoDS_Shape aFace2;
/* if ( !isSectionE ) {
TopoDS_Face aFace2; while (itl.More()) {
// aFace2 = itl.Value();
if (!isSectionE) {
while (itl.More()) { //#2
aFace2 = TopoDS::Face(itl.Value());
// //
anOrigFace2 = aFace2; TopoDS_Shape anOrigFace2 = aFace2;
if (myImagesFaces.IsImage(aFace2)) { if (myImagesFaces.IsImage(aFace2)) {
anOrigFace2 = TopoDS::Face(myImagesFaces.Root(aFace2)); anOrigFace2 = 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);
@ -384,91 +406,94 @@
aFace2.Nullify(); aFace2.Nullify();
} }
itl.Initialize( LSF ); itl.Initialize( LSF );
} // if (!isSectionE) { }
*/
//modified by NIZNHY-PKV Fri Dec 24 10:59:52 2004 t
//
// check that anOrigFace is not same domain with CSF faces it intersects // check that anOrigFace is not same domain with CSF faces it intersects
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();
// //
//faces of CSF sharing E Standard_Boolean sameDom1 = anOrigFace.IsSame( origF1 );
// Standard_Boolean sameDom2 = anOrigFace.IsSame( origF2 );
const TopTools_ListOfShape& FL = DMEF.FindFromKey(E);
const TopoDS_Face& aFE1=TopoDS::Face(FL.First()); if (!(sameDom1 || sameDom2) && HasSameDomainF( TopoDS::Face(anOrigFace) )) {
const TopoDS_Face& aFE2=TopoDS::Face(FL.Last()); sameDom1 = IsSameDomainF( TopoDS::Face(anOrigFace), TopoDS::Face(origF1));
//
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, aFE1, aFE2, 1, dot, GoodOri); inside = NMTAlgo_Loop3d::IsInside (E,
if (inside || (dot + Precision::Angular() >= 1.0)) { TopoDS::Face(FL.First()),
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_Face& aShapeFace = sameDom1 ? aFE2 : aFE1; const TopoDS_Shape& aShapeFace = sameDom1 ? FL.Last() : FL.First();
// analyse aFace1 state // analyse aFace1 state
inside = NMTAlgo_Loop3d::IsInside (E, aShapeFace, aFace1, 1, dot, GoodOri); inside = NMTAlgo_Loop3d::IsInside (E, TopoDS::Face(aShapeFace), aFace1,
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_Face& aShapeFace2 = sameDom1 ? aFE1 : aFE2; const TopoDS_Shape& aShapeFace2 = sameDom1 ? FL.First() : FL.Last();
if (aShapeFace2 != aShapeFace){ if (aShapeFace2 != aShapeFace){
inside = inside = NMTAlgo_Loop3d::IsInside (E, TopoDS::Face(aShapeFace2), aFace1,
NMTAlgo_Loop3d::IsInside(E, aShapeFace2, aFace1, 1, dot, GoodOri); 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, put it back to the maps // aFace2 state is not clear, it will be analysed alone,
MFP.Add(aFace2); // put it back to the maps
LSF.Append(aFace2); MFP.Add( 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);
// //
@ -652,8 +677,8 @@
//purpose : Return True if the first vertex of S1 inside S2. //purpose : Return True if the first vertex of S1 inside S2.
// If S1.IsNull(), check infinite point against S2. // If S1.IsNull(), check infinite point against S2.
//======================================================================= //=======================================================================
Standard_Boolean NMTAlgo_Splitter::IsInside (const TopoDS_Shape& theS1, Standard_Boolean NMTAlgo_Splitter::IsInside (const TopoDS_Shape& theS1,
const TopoDS_Shape& theS2) const TopoDS_Shape& theS2)
{ {
BRepClass3d_SolidClassifier aClassifier( theS2 ); BRepClass3d_SolidClassifier aClassifier( theS2 );
// //
@ -670,13 +695,12 @@
// //
return ( aClassifier.State() == TopAbs_IN ); return ( aClassifier.State() == TopAbs_IN );
} }
//======================================================================= //=======================================================================
//function : GetOriginalShape //function : GetOriginalShape
//purpose : Return the shape aShape originates from. aShape //purpose : Return the shape aShape originates from. aShape
// should be a face or more complex result shape // should be a face or more complex result shape
//======================================================================= //=======================================================================
TopoDS_Shape NMTAlgo_Splitter::GetOriginalShape(const TopoDS_Shape& theShape) const TopoDS_Shape NMTAlgo_Splitter::GetOriginalShape(const TopoDS_Shape& theShape) const
{ {
TopoDS_Shape anOrigShape; TopoDS_Shape anOrigShape;
@ -689,3 +713,116 @@
} }
return anOrigShape; return anOrigShape;
} }
//modified by NIZNHY-PKV Tue Feb 1 11:56:24 2005f
//=======================================================================
//function :RefineShells
//purpose :
//=======================================================================
void RefineShells(const TopoDS_Shape& aS,
TopTools_ListOfShape& aLNS)
{
Standard_Boolean bFound;
Standard_Integer iS, jS, aNbSOrs, aNbSIms, aNbFOrs, aNbFIms, kFOrs, aNb;
TopTools_ListIteratorOfListOfShape aIt;
TopTools_IndexedMapOfShape aMSOrs, aMSIms, aMFOrs, aMFIms;
TopTools_IndexedDataMapOfShapeShape aMImOr;
TopTools_ListOfShape aLS;
//
TopExp::MapShapes(aS, TopAbs_SHELL, aMSOrs);
aIt.Initialize(aLNS);
for (;aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSh=aIt.Value();
aMSIms.Add(aSh);
}
//
aNbSOrs=aMSOrs.Extent();
aNbSIms=aMSIms.Extent();
//
for (iS=1; iS<=aNbSOrs; ++iS) {
const TopoDS_Shape& aSOr=aMSOrs(iS);
aMFOrs.Clear();
TopExp::MapShapes(aSOr, TopAbs_FACE, aMFOrs);
aNbFOrs=aMFOrs.Extent();
//
for (jS=1; jS<=aNbSIms; ++jS) {
const TopoDS_Shape& aSIm=aMSIms(jS);
if (aMImOr.Contains(aSIm)) {
continue;
}
//
aMFIms.Clear();
TopExp::MapShapes(aSIm, TopAbs_FACE, aMFIms);
aNbFIms=aMFIms.Extent();
//
if (aNbFIms==aNbFOrs) {
bFound=Standard_True;
for (kFOrs=1; kFOrs<=aNbFOrs; ++kFOrs) {
const TopoDS_Shape& aFOr=aMFOrs(kFOrs);
if (!aMFIms.Contains(aFOr)) {
bFound=Standard_False;
break; //next aSIm
}
}
if (bFound){
aMImOr.Add(aSIm, aSOr);
break; //next aSOr
}
} //if (aNbFIms==aNbFOrs)
}
}
//
aNb=aMImOr.Extent();
aIt.Initialize(aLNS);
for (;aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSh=aIt.Value();
if (aMImOr.Contains(aSh)) {
const TopoDS_Shape& aSOr=aMImOr.FindFromKey(aSh);
aLS.Append(aSOr);
}
else {
aLS.Append(aSh);
}
}
//
aLNS.Clear();
aLNS.Append(aLS);
}
//=======================================================================
//function :RefineSolids
//purpose :
//=======================================================================
void RefineSolids(const TopoDS_Shape& aSolidOr,
TopTools_ListOfShape& aLNS)
{
Standard_Integer aNb, iS, aNbSOrs, aNbSIms;
TopoDS_Shape aSolidIm;
TopTools_IndexedMapOfShape aMSOrs, aMSIms;
//
aNb=aLNS.Extent();
if (aNb!=1) {
return;
}
//
aSolidIm=aLNS.First();
TopExp::MapShapes(aSolidOr, TopAbs_SHELL, aMSOrs);
TopExp::MapShapes(aSolidIm, TopAbs_SHELL, aMSIms);
aNbSOrs=aMSOrs.Extent();
aNbSIms=aMSIms.Extent();
if (aNbSOrs!=aNbSIms) {
return;
}
//
for (iS=1; iS<=aNbSOrs; ++iS) {
const TopoDS_Shape& aSOr=aMSOrs(iS);
if (!aMSIms.Contains(aSOr)) {
return;
}
}
//
aLNS.Clear();
aLNS.Append(aSolidOr);
}
//modified by NIZNHY-PKV Tue Feb 1 11:56:28 2005t

View File

@ -5,23 +5,25 @@
#include <NMTAlgo_Splitter.ixx> #include <NMTAlgo_Splitter.ixx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopExp.hxx>
#include <TopoDS_Compound.hxx> #include <TopoDS_Compound.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Solid.hxx> #include <TopoDS_Solid.hxx>
#include <TopoDS_Shell.hxx> #include <TopoDS_Shell.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx> #include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx> #include <TopTools_ListIteratorOfListOfShape.hxx>
#include <NMTTools_DSFiller.hxx> #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <NMTDS_ShapesDataStructure.hxx>
#include <NMTTools_PaveFiller.hxx>
#include <BOPTools_PInterferencePool.hxx> #include <BOPTools_PInterferencePool.hxx>
#include <BOPTools_InterferencePool.hxx> #include <BOPTools_InterferencePool.hxx>
#include <BOPTools_CArray1OfEEInterference.hxx> #include <BOPTools_CArray1OfEEInterference.hxx>
@ -29,6 +31,11 @@
#include <BOPTools_CArray1OfESInterference.hxx> #include <BOPTools_CArray1OfESInterference.hxx>
#include <BOPTools_ESInterference.hxx> #include <BOPTools_ESInterference.hxx>
#include <NMTDS_ShapesDataStructure.hxx>
#include <NMTTools_PaveFiller.hxx>
#include <NMTTools_DSFiller.hxx>
#include <NMTAlgo_Tools.hxx>
//======================================================================= //=======================================================================
//function : KeepShapesInside //function : KeepShapesInside
//purpose : remove shapes that are outside of S from result //purpose : remove shapes that are outside of S from result
@ -122,10 +129,7 @@
TopTools_MapOfShape RFM; TopTools_MapOfShape RFM;
TopTools_MapIteratorOfMapOfShape itF; TopTools_MapIteratorOfMapOfShape itF;
// //
//modified by NIZNHY-PKV Wed Dec 22 18:56:27 2004 f
isTool=myToolShapes.Contains(S); isTool=myToolShapes.Contains(S);
//modified by NIZNHY-PKV Wed Dec 22 18:56:31 2004 t
//
//isTool = Standard_False; //isTool = Standard_False;
if (!myImageShape.HasImage( S )) { if (!myImageShape.HasImage( S )) {
return; return;
@ -174,7 +178,7 @@
} }
}// for (; it.More(); it.Next()) }// for (; it.More(); it.Next())
// //
//modified by NIZNHY-PKV Wed Dec 22 18:59:46 2004 f //
TopoDS_Compound aCx; TopoDS_Compound aCx;
// //
myBuilder.MakeCompound(aCx); myBuilder.MakeCompound(aCx);
@ -183,7 +187,6 @@
const TopoDS_Shape& aF=itF.Key(); const TopoDS_Shape& aF=itF.Key();
myBuilder.Add(aCx, aF); myBuilder.Add(aCx, aF);
} }
//modified by NIZNHY-PKV Wed Dec 22 18:59:48 2004 t
// //
if (!isTool) { if (!isTool) {
// rebuild S, it must remain in the result // rebuild S, it must remain in the result
@ -253,117 +256,75 @@
// //
myShape = C; myShape = C;
} }
//modified by NIZNHY-PKV Mon Jan 24 10:19:30 2005 f //
//modified by NIZNHY-PKV Tue Feb 1 16:02:29 2005 f
//======================================================================= //=======================================================================
//function : Modified //function : Modified
//purpose : //purpose :
//======================================================================= //=======================================================================
const TopTools_ListOfShape& NMTAlgo_Splitter::Modified (const TopoDS_Shape& S) const TopTools_ListOfShape& NMTAlgo_Splitter::Modified (const TopoDS_Shape& S)
{ {
TopAbs_ShapeEnum aType; TopAbs_ShapeEnum aType;
TopTools_ListIteratorOfListOfShape it;
TopTools_MapOfShape aMap;
TopExp_Explorer anExp;
// //
myGenerated.Clear(); myGenerated.Clear();
//
aType=S.ShapeType(); aType=S.ShapeType();
// //
switch (aType) { switch (aType) {
case TopAbs_FACE: { case TopAbs_SOLID:
if (myModifiedFaces.IsBound(S)) { case TopAbs_FACE:
anExp.Init(myShape, aType); case TopAbs_EDGE:
for(; anExp.More(); anExp.Next()) { case TopAbs_VERTEX:
aMap.Add(anExp.Current()); FindImage(S, myGenerated);
}
//
const TopTools_ListOfShape& aLS=myModifiedFaces.Find(S);
it.Initialize(aLS);
for (; it.More(); it.Next()) {
const TopoDS_Shape& aFx=it.Value();
if (!aFx.IsSame(S)) {
if (aMap.Contains(aFx)) {
myGenerated.Append(aFx);
}
}
}
}
}
break; break;
//
case TopAbs_EDGE: { case TopAbs_SHELL:
if (myImagesEdges.HasImage(S)) {
anExp.Init(myShape, aType);
for(; anExp.More(); anExp.Next()) {
aMap.Add(anExp.Current());
}
//
const TopTools_ListOfShape& aLE=myImagesEdges.Image(S);
it.Initialize(aLE);
for (; it.More(); it.Next()) {
const TopoDS_Shape& aEx=it.Value();
if (!aEx.IsSame(S)) {
if(aMap.Contains(aEx)) {
myGenerated.Append(aEx);
}
}
}
}
}
break; break;
//
case TopAbs_VERTEX: { case TopAbs_WIRE:
Standard_Integer aNbS, anIndex, i, aSDVInd;
//
const NMTTools_DSFiller& aDSF = Filler();
const NMTTools_PaveFiller& aPF = aDSF.PaveFiller();
const NMTDS_ShapesDataStructure& aDS = aDSF.DS();
//
aNbS = aDS.NumberOfSourceShapes();
anIndex = 0;
//
for(i=1; i<=aNbS; ++i) {
const TopoDS_Shape& aS = aDS.Shape(i);
if(S.IsSame(aS)) {
anIndex = i;
break;
}
}
//
if(!anIndex) {
break;//return myGenerated;
}
//
aSDVInd=aPF.FindSDVertex(anIndex);
if(!aSDVInd) {
break;//return myGenerated;
}
//
const TopoDS_Shape& aSDV=aDS.Shape(aSDVInd);
//
anExp.Init(myShape, aType);
for(; anExp.More(); anExp.Next()) {
const TopoDS_Shape& aVx=anExp.Current();
if(aSDV.IsSame(aVx)) {
myGenerated.Append(aSDV);
break;
}
}
}
break; break;
//
default: default:
break; break;
} // switch (aType) { }
// //
return myGenerated; return myGenerated;
} }
//modified by NIZNHY-PKV Mon Jan 24 10:28:40 2005 t //modified by NIZNHY-PKV Tue Feb 1 16:02:33 2005 t
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean NMTAlgo_Splitter::IsDeleted (const TopoDS_Shape& S)
{
const TopTools_ListOfShape& aL = Modified(S);
if(aL.Extent() != 0) return Standard_False;
TopTools_MapOfShape aMap;
TopExp_Explorer anExp;
TopAbs_ShapeEnum aType = S.ShapeType();
if(aType == TopAbs_VERTEX ||
aType == TopAbs_EDGE ||
aType == TopAbs_FACE ) {
anExp.Init(myShape, aType);
for(; anExp.More(); anExp.Next()) {
if(S.IsSame(anExp.Current())) return Standard_False;
}
}
return Standard_True;
}
//======================================================================= //=======================================================================
//function : Generated //function : Generated
//purpose : //purpose :
//======================================================================= //=======================================================================
const TopTools_ListOfShape& NMTAlgo_Splitter::Generated(const TopoDS_Shape& S) const TopTools_ListOfShape& NMTAlgo_Splitter::Generated(const TopoDS_Shape& S)
{ {
myGenerated.Clear(); myGenerated.Clear();
TopTools_ListIteratorOfListOfShape it; TopTools_ListIteratorOfListOfShape it;
@ -531,43 +492,169 @@
if(!aMap.Contains(it.Value())) { if(!aMap.Contains(it.Value())) {
myGenerated.Remove(it); myGenerated.Remove(it);
} }
} }
} }
return myGenerated; return myGenerated;
} }
return myGenerated; return myGenerated;
} }
//modified by NIZNHY-PKV Tue Feb 1 10:26:18 2005f
//======================================================================= //=======================================================================
//function : IsDeleted //function : FindImage
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean NMTAlgo_Splitter::IsDeleted (const TopoDS_Shape& S) void NMTAlgo_Splitter::FindImage(const TopoDS_Shape& aS,
TopTools_ListOfShape& aLIms)
{ {
const TopTools_ListOfShape& aL = Modified(S); TopAbs_ShapeEnum aType;
if(aL.Extent() != 0) return Standard_False; //
aType=aS.ShapeType();
TopTools_MapOfShape aMap; //
TopExp_Explorer anExp; if (aType==TopAbs_SOLID) {
Standard_Boolean bHasImage, bHasInternalFaces;
TopAbs_ShapeEnum aType = S.ShapeType(); Standard_Integer i, aNbSd;
TopTools_IndexedMapOfShape aMSo, aMSd;
if(aType == TopAbs_VERTEX || TopoDS_Iterator aIt;
aType == TopAbs_EDGE || TopTools_IndexedDataMapOfShapeListOfShape aMFS;
aType == TopAbs_FACE ) { TopTools_ListIteratorOfListOfShape aItLS;
//
bHasInternalFaces=myMapSIFC.IsBound(aS);
if (bHasInternalFaces){
TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS);
//
const TopoDS_Shape& aIFC=myMapSIFC.Find(aS);
//
aIt.Initialize(aIFC);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aIF=aIt.Value();
if (aMFS.Contains(aIF)) {
const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aIF);
//
aItLS.Initialize(aLS);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSx=aItLS.Value();
aMSd.Add(aSx);
}
}
}
//
aNbSd=aMSd.Extent();
if (aNbSd) {
for (i=1; i<=aNbSd; ++i) {
const TopoDS_Shape& aSx=aMSd(i);
if (!aSx.IsSame(aS)) {
aLIms.Append(aSx);
}
}
return;
}
}
//
bHasImage=myImageShape.HasImage(aS);
if (!bHasImage) {
return;
}
//
TopoDS_Shape aSd;
//
TopExp::MapShapes(myShape, TopAbs_SOLID, aMSo);
//
const TopoDS_Shape& aFC=myImageShape.Image(aS).First();
bHasImage=NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd);
if (bHasImage) {
if (!aSd.IsSame(aS)) {
aLIms.Append(aSd);
}
}
} //if (aType==TopAbs_SOLID) {
//==
else if (aType==TopAbs_FACE) {
TopTools_MapOfShape aMap;
TopTools_ListIteratorOfListOfShape aIt;
TopExp_Explorer anExp;
//
if (myModifiedFaces.IsBound(aS)) {
anExp.Init(myShape, aType);
for(; anExp.More(); anExp.Next()) {
aMap.Add(anExp.Current());
}
//
const TopTools_ListOfShape& aLS=myModifiedFaces.Find(aS);
aIt.Initialize(aLS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aFx=aIt.Value();
if (!aFx.IsSame(aS)) {
if (aMap.Contains(aFx)) {
aLIms.Append(aFx);
}
}
}
}
} // else if (aType==TopAbs_FACE)
//==
else if (aType==TopAbs_EDGE) {
TopTools_MapOfShape aMap;
TopTools_ListIteratorOfListOfShape aIt;
TopExp_Explorer anExp;
//
if (myImagesEdges.HasImage(aS)) {
anExp.Init(myShape, aType);
for(; anExp.More(); anExp.Next()) {
aMap.Add(anExp.Current());
}
//
const TopTools_ListOfShape& aLE=myImagesEdges.Image(aS);
aIt.Initialize(aLE);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aEx=aIt.Value();
if (!aEx.IsSame(aS)) {
if(aMap.Contains(aEx)) {
aLIms.Append(aEx);
}
}
}
}
}// else if (aType==TopAbs_EDGE)
//==
else if (aType==TopAbs_VERTEX) {
Standard_Integer aNbS, anIndex, i, aSDVInd;
TopExp_Explorer anExp;
//
const NMTTools_DSFiller& aDSF = Filler();
const NMTTools_PaveFiller& aPF = aDSF.PaveFiller();
const NMTDS_ShapesDataStructure& aDS = aDSF.DS();
//
aNbS = aDS.NumberOfSourceShapes();
anIndex = 0;
//
for(i=1; i<=aNbS; ++i) {
const TopoDS_Shape& aSx = aDS.Shape(i);
if(aS.IsSame(aSx)) {
anIndex = i;
break;
}
}
//
if(!anIndex) {
return;
}
//
aSDVInd=aPF.FindSDVertex(anIndex);
if(!aSDVInd) {
return;
}
//
const TopoDS_Shape& aSDV=aDS.Shape(aSDVInd);
//
anExp.Init(myShape, aType); anExp.Init(myShape, aType);
for(; anExp.More(); anExp.Next()) { for(; anExp.More(); anExp.Next()) {
if(S.IsSame(anExp.Current())) return Standard_False; const TopoDS_Shape& aVx=anExp.Current();
if(aSDV.IsSame(aVx)) {
aLIms.Append(aSDV);
break;
}
} }
}// else if (aType==TopAbs_VERTEX)
}
return Standard_True;
} }
//modified by NIZNHY-PKV Tue Feb 1 10:26:22 2005t

View File

@ -479,6 +479,7 @@
// //
aNbFSo=aMFSo.Extent(); aNbFSo=aMFSo.Extent();
if (aNbFSo!=aNbF) { if (aNbFSo!=aNbF) {
bFound=Standard_False;
continue; continue;
} }
// //