From: jfa Date: Thu, 27 Jan 2005 15:22:36 +0000 (+0000) Subject: PAL7508: Development of GetInPlace() functionality X-Git-Tag: V2_2_0b2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b7cff0a4ec43ee005440c53e196b5c94f076dbca;hp=1dfcc16fdf4be8ed98d5a4b343a7b49c35b58cee;p=modules%2Fgeom.git PAL7508: Development of GetInPlace() functionality --- diff --git a/src/GEOM/GEOM_Function.cxx b/src/GEOM/GEOM_Function.cxx index e11f8cf7b..4112c03ad 100644 --- a/src/GEOM/GEOM_Function.cxx +++ b/src/GEOM/GEOM_Function.cxx @@ -7,6 +7,7 @@ using namespace std; #include "utilities.h" #include +#include #include #include #include @@ -25,6 +26,8 @@ using namespace std; #include #include +#include +#include #include #include #include @@ -36,6 +39,8 @@ using namespace std; #define ARGUMENT_LABEL 1 #define RESULT_LABEL 2 #define DESCRIPTION_LABEL 3 +#define HISTORY_LABEL 4 + #define ARGUMENTS _label.FindChild((ARGUMENT_LABEL)) #define ARGUMENT(thePosition) _label.FindChild((ARGUMENT_LABEL)).FindChild((thePosition)) #define SUB_ARGUMENT(thePos1, thePos2) _label.FindChild((ARGUMENT_LABEL)).FindChild((thePos1)).FindChild((thePos2)) @@ -542,38 +547,38 @@ Handle(TColStd_HSequenceOfTransient) GEOM_Function::GetReferenceList(int thePosi * SetShape */ //============================================================================= -void GEOM_Function::SetShape(int thePosition, const TopoDS_Shape& theShape) -{ - _isDone = false; - if(thePosition <= 0 || theShape.IsNull()) return; - - TDF_Label anArgLabel = ARGUMENT(thePosition); - TNaming_Builder aBuilder(anArgLabel); - aBuilder.Generated(theShape); - - _isDone = true; - return; -} - +//void GEOM_Function::SetShape(int thePosition, const TopoDS_Shape& theShape) +//{ +// _isDone = false; +// if(thePosition <= 0 || theShape.IsNull()) return; +// +// TDF_Label anArgLabel = ARGUMENT(thePosition); +// TNaming_Builder aBuilder(anArgLabel); +// aBuilder.Generated(theShape); +// +// _isDone = true; +// return; +//} +// //============================================================================= /*! * GetShape */ //============================================================================= -TopoDS_Shape GEOM_Function::GetShape(int thePosition) -{ - _isDone = false; - TopoDS_Shape aShape; - if(thePosition <= 0) return aShape; - - TDF_Label anArgLabel = ARGUMENT(thePosition); - Handle(TNaming_NamedShape) aNS; - if(!anArgLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape; - - aShape = aNS->Get(); - _isDone = true; - return aShape; -} +//TopoDS_Shape GEOM_Function::GetShape(int thePosition) +//{ +// _isDone = false; +// TopoDS_Shape aShape; +// if(thePosition <= 0) return aShape; +// +// TDF_Label anArgLabel = ARGUMENT(thePosition); +// Handle(TNaming_NamedShape) aNS; +// if(!anArgLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape; +// +// aShape = aNS->Get(); +// _isDone = true; +// return aShape; +//} //============================================================================= @@ -589,6 +594,49 @@ void GEOM_Function::GetDependency(TDF_LabelSequence& theSeq) } } +//============================================================================= +/*! + * GetHistoryEntry + */ +//============================================================================= +TDF_Label GEOM_Function::GetHistoryEntry (const Standard_Boolean create) +{ + return _label.FindChild(HISTORY_LABEL, create); +} + +//============================================================================= +/*! + * GetArgumentHistoryEntry + */ +//============================================================================= +TDF_Label GEOM_Function::GetArgumentHistoryEntry (const TDF_Label& theArgumentRefEntry, + const Standard_Boolean create) +{ + TColStd_ListOfInteger anArgumentRefTags; + TDF_Tool::TagList(theArgumentRefEntry, anArgumentRefTags); + Standard_Integer anArgumentRefLabelPos = anArgumentRefTags.Extent(); + + TDF_Label aHistoryLabel = GetHistoryEntry(create); + if (aHistoryLabel.IsNull()) + return aHistoryLabel; + Standard_Integer aHistoryLabelPos = aHistoryLabel.Depth() + 1; + + Standard_Integer itag; + TDF_Label aHistoryCurLabel = aHistoryLabel; + TColStd_ListIteratorOfListOfInteger aListIter (anArgumentRefTags); + for (itag = 1; itag <= aHistoryLabelPos; itag++) { + aListIter.Next(); + } + for (; itag <= anArgumentRefLabelPos; itag++) { + aHistoryCurLabel = aHistoryCurLabel.FindChild(aListIter.Value(), create); + if (aHistoryCurLabel.IsNull()) + return aHistoryCurLabel; + aListIter.Next(); + } + + return aHistoryCurLabel; +} + //======================================================================= //function : GEOM_Function_Type_ //purpose : diff --git a/src/GEOM/GEOM_Function.hxx b/src/GEOM/GEOM_Function.hxx index be5c192f1..92879bf0c 100644 --- a/src/GEOM/GEOM_Function.hxx +++ b/src/GEOM/GEOM_Function.hxx @@ -222,16 +222,24 @@ public: Handle(TColStd_HSequenceOfTransient) GetReferenceList (int thePosition); //Sets a TopoDS_Shape argument at position thePosition - void SetShape(int thePosition, const TopoDS_Shape& theShape); + //void SetShape(int thePosition, const TopoDS_Shape& theShape); //Returns a TopoDS_Shape argument at position thePosition - TopoDS_Shape GetShape(int thePosition); + //TopoDS_Shape GetShape(int thePosition); //Returns true if the last method succided bool IsDone() { return _isDone; } //Returns a sequence of the external dependencies of this function - void GetDependency(TDF_LabelSequence& theSeq); + void GetDependency(TDF_LabelSequence& theSeq); + + //Returns top label of this function's history tree + TDF_Label GetHistoryEntry (const Standard_Boolean create = Standard_True); + + //Returns history label, corresponding to the label, + //on which a reference on argument is stored + TDF_Label GetArgumentHistoryEntry (const TDF_Label& theArgumentRefEntry, + const Standard_Boolean create = Standard_True); private: diff --git a/src/GEOMAlgo/GEOMAlgo_Gluer.cdl b/src/GEOMAlgo/GEOMAlgo_Gluer.cdl index a28e365ef..a8c778b6e 100755 --- a/src/GEOMAlgo/GEOMAlgo_Gluer.cdl +++ b/src/GEOMAlgo/GEOMAlgo_Gluer.cdl @@ -41,6 +41,22 @@ is AloneShapes(me) returns Integer from Standard; + --modified by NIZNHY-PKV Fri Jan 21 14:16:58 2005f- + Modified(me:out; + S : Shape from TopoDS) + returns ListOfShape from TopTools; + ---C++: return const & + + Generated(me:out; + S : Shape from TopoDS) + returns ListOfShape from TopTools; + ---C++: return const & + + IsDeleted (me:out; + S : Shape from TopoDS) + returns Boolean from Standard; + --modified by NIZNHY-PKV Fri Jan 21 14:17:04 2005t + CheckData(me:out) is redefined protected; @@ -97,6 +113,11 @@ is aFR : Face from TopoDS; aF : Face from TopoDS) returns Boolean from Standard + is protected; + + HasNewSubShape(me; + aS : Shape from TopoDS) + returns Boolean from Standard is protected; -- Images(me) @@ -113,5 +134,8 @@ fields myImages : DataMapOfShapeListOfShape from TopTools is protected; myOrigins : DataMapOfShapeShape from TopTools is protected; myNbAlone : Integer from Standard is protected; - +---- + myGenerated : ListOfShape from TopTools is protected; +---- + end Gluer; diff --git a/src/GEOMAlgo/GEOMAlgo_Gluer.cxx b/src/GEOMAlgo/GEOMAlgo_Gluer.cxx index bd497c1f3..b63e99eea 100755 --- a/src/GEOMAlgo/GEOMAlgo_Gluer.cxx +++ b/src/GEOMAlgo/GEOMAlgo_Gluer.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -60,6 +61,11 @@ #include #include #include +// + +static + void GetSubShapes(const TopoDS_Shape& aS, + TopTools_IndexedMapOfShape& aMSS); //======================================================================= //function : GEOMAlgo_Gluer @@ -318,7 +324,7 @@ void GEOMAlgo_Gluer::MakeSolids() // aNbS=aMS.Extent(); if (aNbS) { - Standard_Real aTol=1.e-7; + //Standard_Real aTol=1.e-7; BOP_CorrectTolerances::CorrectCurveOnSurface(myResult); } } @@ -394,6 +400,7 @@ void GEOMAlgo_Gluer::MakeShapes(const TopAbs_ShapeEnum aType) { myErrorStatus=0; // + Standard_Boolean bHasNewSubShape; Standard_Integer i, aNbF, aNbSDF, iErr; TopoDS_Shape aNewShape; TopTools_IndexedMapOfShape aMF; @@ -442,6 +449,7 @@ void GEOMAlgo_Gluer::MakeShapes(const TopAbs_ShapeEnum aType) } // // Images/Origins + // aNbF=aMPKLF.Extent(); for (i=1; i<=aNbF; ++i) { const TopTools_ListOfShape& aLSDF=aMPKLF(i); @@ -451,19 +459,36 @@ void GEOMAlgo_Gluer::MakeShapes(const TopAbs_ShapeEnum aType) } // const TopoDS_Shape& aS1=aLSDF.First(); - if (aType==TopAbs_FACE) { - TopoDS_Face aNewFace; - // - const TopoDS_Face& aF1=TopoDS::Face(aS1); - MakeFace(aF1, aNewFace); - aNewShape=aNewFace; + // + //modified by NIZNHY-PKV Fri Jan 21 15:34:00 2005 f + // + bHasNewSubShape=Standard_True; + // prevent creation of a new shape if there are not + // new subshapes of aSS among the originals + if (aNbSDF==1) { + bHasNewSubShape=HasNewSubShape(aS1); + if (!bHasNewSubShape) { + aNewShape=aS1; + aNewShape.Orientation(TopAbs_FORWARD); + } } - else if (aType==TopAbs_EDGE) { - TopoDS_Edge aNewEdge; - // - const TopoDS_Edge& aE1=TopoDS::Edge(aS1); - MakeEdge(aE1, aNewEdge); - aNewShape=aNewEdge; + //modified by NIZNHY-PKV Fri Jan 21 15:34:05 2005 t + // + if (bHasNewSubShape) {//modified by NIZNHY-PKV Fri Jan 21 15:34:10 2005ft + if (aType==TopAbs_FACE) { + TopoDS_Face aNewFace; + // + const TopoDS_Face& aF1=TopoDS::Face(aS1); + MakeFace(aF1, aNewFace); + aNewShape=aNewFace; + } + else if (aType==TopAbs_EDGE) { + TopoDS_Edge aNewEdge; + // + const TopoDS_Edge& aE1=TopoDS::Edge(aS1); + MakeEdge(aE1, aNewEdge); + aNewShape=aNewEdge; + } } // myImages.Bind(aNewShape, aLSDF); @@ -676,7 +701,6 @@ void GEOMAlgo_Gluer::MakeVertex(const TopTools_ListOfShape& aLV, void GEOMAlgo_Gluer::MakeEdge(const TopoDS_Edge& aE, TopoDS_Edge& aNewEdge) { - //modified by NIZNHY-PKV Thu Dec 30 11:15:23 2004 f myErrorStatus=0; // Standard_Boolean bIsDE; @@ -723,7 +747,6 @@ void GEOMAlgo_Gluer::MakeEdge(const TopoDS_Edge& aE, else { BOPTools_Tools::MakeSplitEdge(aEx, aVR1, aT1, aVR2, aT2, aNewEdge); } - //modified by NIZNHY-PKV Thu Dec 30 11:15:28 2004 t } // //======================================================================= @@ -766,7 +789,7 @@ void GEOMAlgo_Gluer::MakeFace(const TopoDS_Face& aF, aER=TopoDS::Edge(myOrigins.Find(aE)); // aER.Orientation(TopAbs_FORWARD); - if (!BRep_Tool::Degenerated(aER)) {//modified by NIZNHY-PKV Thu Dec 30 11:31:37 2004 ft + if (!BRep_Tool::Degenerated(aER)) { // build p-curve if (bIsUPeriodic) { GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(aER, aFFWD, aUMin, aUMax); @@ -808,11 +831,11 @@ Standard_Boolean GEOMAlgo_Gluer::IsToReverse(const TopoDS_Face& aFR, aExp.Init(aF, TopAbs_EDGE); for (; aExp.More(); aExp.Next()) { const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); - //modified by NIZNHY-PKV Thu Dec 30 11:38:05 2004 f + // if (BRep_Tool::Degenerated(aE)) { continue; } - //modified by NIZNHY-PKV Thu Dec 30 11:38:08 2004 t + // const TopoDS_Edge& aER=TopoDS::Edge(myOrigins.Find(aE)); // aC3D=BRep_Tool::Curve(aE, aT1, aT2); @@ -836,7 +859,111 @@ Standard_Boolean GEOMAlgo_Gluer::IsToReverse(const TopoDS_Face& aFR, return bRet; } // - +//modified by NIZNHY-PKV Fri Jan 21 10:55:42 2005 f +//======================================================================= +//function : HasNewSubShape +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer::HasNewSubShape(const TopoDS_Shape& aS)const +{ + Standard_Boolean bRet; + Standard_Integer i, aNbSS; + TopTools_IndexedMapOfShape aMSS; + // + GetSubShapes(aS, aMSS); + // + bRet=Standard_False; + aNbSS=aMSS.Extent(); + for (i=1; i<=aNbSS; ++i) { + const TopoDS_Shape& aSS=aMSS(i); + if (aSS.ShapeType()==TopAbs_WIRE) { + continue; + } + // + bRet=!myOrigins.IsBound(aSS); + if (bRet) { + return bRet; + } + // + const TopoDS_Shape& aSSIm=myOrigins.Find(aSS); + bRet=!aSSIm.IsSame(aSS); + if (bRet) { + return bRet; + } + } + return bRet; +} +//======================================================================= +//function : GetSubShapes +//purpose : +//======================================================================= +void GetSubShapes(const TopoDS_Shape& aS, + TopTools_IndexedMapOfShape& aMSS) +{ + Standard_Integer aR; + TopAbs_ShapeEnum aType; + TopoDS_Iterator aIt; + // + aType=aS.ShapeType(); + aR=(Standard_Integer)aType+1; + if (aR>TopAbs_VERTEX) { + return; + } + // + aIt.Initialize(aS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSS=aIt.Value(); + aMSS.Add(aSS); + GetSubShapes(aSS, aMSS); + } +} +//======================================================================= +//function : Modified +//purpose : +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_Gluer::Modified (const TopoDS_Shape& aS) +{ + TopAbs_ShapeEnum aType; + // + myGenerated.Clear(); + // + aType=aS.ShapeType(); + if (aType==TopAbs_FACE || + aType==TopAbs_EDGE || + aType==TopAbs_VERTEX) { + if(myOrigins.IsBound(aS)) { + const TopoDS_Shape& aSnew=myOrigins.Find(aS); + if (!aSnew.IsSame(aS)) { + myGenerated.Append(aSnew); + } + } + } + // + return myGenerated; +} +//======================================================================= +//function : Generated +//purpose : +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_Gluer::Generated(const TopoDS_Shape& ) +{ + myGenerated.Clear(); + return myGenerated; +} +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer::IsDeleted (const TopoDS_Shape& aS) +{ + Standard_Boolean bRet=Standard_False; + // + const TopTools_ListOfShape& aL=Modified(aS); + bRet=!aL.IsEmpty(); + // + return bRet; +} +//modified by NIZNHY-PKV Fri Jan 21 10:59:21 2005 t // // ErrorStatus // @@ -854,37 +981,3 @@ Standard_Boolean GEOMAlgo_Gluer::IsToReverse(const TopoDS_Face& aFR, // // 1 - some shapes can not be glued by faces // -/* -//======================================================================= -//function : BuildResult -//purpose : -//======================================================================= -void GEOMAlgo_Gluer::BuildResult() -{ - Standard_Boolean bAdded; - TopoDS_Compound aCmp; - BRep_Builder aBB; - TopAbs_ShapeEnum aType; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; - // - aBB.MakeCompound(aCmp); - // - bAdded=Standard_False; - aItIm.Initialize(myImages); - for (; aItIm.More(); aItIm.Next()) { - const TopoDS_Shape& aIm=aItIm.Key(); - aType=aIm.ShapeType(); - if(aType==TopAbs_SOLID) { - bAdded=Standard_True; - aBB.Add(aCmp, aIm); - } - } - myResult=aCmp; - // - if (bAdded) { - Standard_Real aTol=1.e-7; - BOP_CorrectTolerances::CorrectCurveOnSurface(myResult); - //BRepLib::SameParameter(myResult, aTol, bAdded); - } -} -*/ diff --git a/src/GEOMAlgo/GEOMAlgo_Gluer.hxx b/src/GEOMAlgo/GEOMAlgo_Gluer.hxx index af5faefa1..994b717fa 100644 --- a/src/GEOMAlgo/GEOMAlgo_Gluer.hxx +++ b/src/GEOMAlgo/GEOMAlgo_Gluer.hxx @@ -37,16 +37,20 @@ #ifndef _Standard_Integer_HeaderFile #include #endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif #ifndef _GEOMAlgo_ShapeAlgo_HeaderFile #include #endif #ifndef _TopAbs_ShapeEnum_HeaderFile #include #endif +class TopTools_ListOfShape; +class TopoDS_Shape; class TopoDS_Edge; class GEOMAlgo_PassKey; class TopoDS_Face; -class TopTools_ListOfShape; class TopoDS_Vertex; class TopTools_DataMapOfShapeListOfShape; class TopTools_DataMapOfShapeShape; @@ -83,6 +87,9 @@ Standard_EXPORT void SetCheckGeometry(const Standard_Boolean aFlag) ; Standard_EXPORT Standard_Boolean CheckGeometry() const; Standard_EXPORT virtual void Perform() ; Standard_EXPORT Standard_Integer AloneShapes() const; +Standard_EXPORT const TopTools_ListOfShape& Modified(const TopoDS_Shape& S) ; +Standard_EXPORT const TopTools_ListOfShape& Generated(const TopoDS_Shape& S) ; +Standard_EXPORT Standard_Boolean IsDeleted(const TopoDS_Shape& S) ; Standard_EXPORT const TopTools_DataMapOfShapeListOfShape& Images() const; Standard_EXPORT const TopTools_DataMapOfShapeShape& Origins() const; @@ -109,6 +116,7 @@ Standard_EXPORT void MakeVertex(const TopTools_ListOfShape& aLV,TopoDS_Vertex& Standard_EXPORT void MakeEdge(const TopoDS_Edge& aEdge,TopoDS_Edge& aNewEdge) ; Standard_EXPORT void MakeFace(const TopoDS_Face& aFace,TopoDS_Face& aNewEdge) ; Standard_EXPORT Standard_Boolean IsToReverse(const TopoDS_Face& aFR,const TopoDS_Face& aF) ; +Standard_EXPORT Standard_Boolean HasNewSubShape(const TopoDS_Shape& aS) const; // Fields PROTECTED @@ -118,6 +126,7 @@ Standard_Real myTol; TopTools_DataMapOfShapeListOfShape myImages; TopTools_DataMapOfShapeShape myOrigins; Standard_Integer myNbAlone; +TopTools_ListOfShape myGenerated; private: diff --git a/src/GEOMAlgo/GEOMAlgo_Gluer.jxx b/src/GEOMAlgo/GEOMAlgo_Gluer.jxx index f56c73fa8..a80b13204 100644 --- a/src/GEOMAlgo/GEOMAlgo_Gluer.jxx +++ b/src/GEOMAlgo/GEOMAlgo_Gluer.jxx @@ -1,3 +1,9 @@ +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif #ifndef _TopoDS_Edge_HeaderFile #include #endif @@ -7,9 +13,6 @@ #ifndef _TopoDS_Face_HeaderFile #include #endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif #ifndef _TopoDS_Vertex_HeaderFile #include #endif diff --git a/src/GEOMImpl/GEOMImpl_GlueDriver.cxx b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx index 8eb0ffb4f..f2af73996 100644 --- a/src/GEOMImpl/GEOMImpl_GlueDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx @@ -4,13 +4,21 @@ using namespace std; #include "GEOMImpl_IGlue.hxx" #include "GEOMImpl_Types.hxx" +#include "GEOM_Object.hxx" #include "GEOM_Function.hxx" #include "GEOMAlgo_Gluer.hxx" #include "utilities.h" +#include + +#include #include +#include +#include +#include + #include #include @@ -97,6 +105,51 @@ TopoDS_Shape GEOMImpl_GlueDriver::GlueFacesWithWarnings (const TopoDS_Shape& the aRes = aGluer.Result(); + // Fill history to be used by GetInPlace functionality + TopTools_IndexedMapOfShape aResIndices; + TopExp::MapShapes(aRes, aResIndices); + + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + // history for all argument shapes + TDF_LabelSequence aLabelSeq; + aFunction->GetDependency(aLabelSeq); + Standard_Integer nbArg = aLabelSeq.Length(); + + for (Standard_Integer iarg = 1; iarg <= nbArg; iarg++) { + + TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg); + + Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel); + TopoDS_Shape anArgumentShape = anArgumentObject->GetValue(); + + TopTools_IndexedMapOfShape anArgumentIndices; + TopExp::MapShapes(anArgumentShape, anArgumentIndices); + Standard_Integer nbArgumentEntities = anArgumentIndices.Extent(); + + // Find corresponding label in history + TDF_Label anArgumentHistoryLabel = + aFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_True); + + for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) { + TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie); + const TopTools_ListOfShape& aModified = aGluer.Modified(anEntity); + Standard_Integer nbModified = aModified.Extent(); + + if (nbModified > 0) { + TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True); + Handle(TDataStd_IntegerArray) anAttr = + TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified); + + TopTools_ListIteratorOfListOfShape itM (aModified); + for (int im = 1; itM.More(); itM.Next(), ++im) { + int id = aResIndices.FindIndex(itM.Value()); + anAttr->SetValue(im, id); + } + } + } + } + return aRes; } diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index 144455fce..774ef28e2 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -197,6 +197,8 @@ bool GEOMImpl_IHealingOperations::GetOperatorParameters( const string theOperati aMsg += TCollection_AsciiString( nbParamValueErrors ); MESSAGE(aMsg.ToCString()); } + + return true; } //============================================================================= diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 6db0d8776..071b5c3df 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -27,6 +27,7 @@ using namespace std; #include #include #include +#include #include #include @@ -64,6 +65,8 @@ using namespace std; #include #include #include +#include +#include //#include @@ -1383,46 +1386,112 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace if (aWhere.IsNull() || aWhat.IsNull()) return NULL; //Fill array of indices - TopTools_IndexedMapOfShape anIndices; - TopExp::MapShapes(aWhere, anIndices); - -// Handle(TColStd_HArray1OfInteger) anArray = -// new TColStd_HArray1OfInteger (1, listSS.Extent()); -// TopTools_ListIteratorOfListOfShape itSub (listSS); -// for (int index = 1; itSub.More(); itSub.Next(), ++index) { -// int id = anIndices.FindIndex(itSub.Value()); -// anArray->SetValue(index, id); -// } -// -// //Add a new group object -// Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theShape, anArray); -// -// //Set a GROUP type -// aGroup->SetType(GEOM_GROUP); -// -// //Set a sub shape type -// TDF_Label aFreeLabel = aGroup->GetFreeLabel(); -// TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType); -// -// //Make a Python command -// TCollection_AsciiString anEntry, aDescr; -// TDF_Tool::Entry(aGroup->GetEntry(), anEntry); -// aDescr += anEntry; -// aDescr += " = IShapesOperations.GetInPlace("; -// TDF_Tool::Entry(theShapeWhere->GetEntry(), anEntry); -// aDescr += anEntry + ","; -// TDF_Tool::Entry(theShapeWhat->GetEntry(), anEntry); -// aDescr += anEntry + ")"; -// -// Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); -// aFunction->SetDescription(aDescr); - -// SetErrorCode(OK); -// return aGroup; - SetErrorCode("Not yet implemented"); - return NULL; -} + Handle(TColStd_HArray1OfInteger) aModifiedArray; + + Handle(GEOM_Function) aWhereFunction = theShapeWhere->GetLastFunction(); + + TopTools_IndexedMapOfShape aWhereIndices; + TopExp::MapShapes(aWhere, aWhereIndices); + + if (aWhereIndices.Contains(aWhat)) { + + // entity was not changed by the operation + Standard_Integer aWhatIndex = aWhereIndices.FindIndex(aWhat); + aModifiedArray = new TColStd_HArray1OfInteger(1,1); + aModifiedArray->SetValue(1, aWhatIndex); + + } else { + + TDF_Label aHistoryLabel = aWhereFunction->GetHistoryEntry(Standard_False); + if (aHistoryLabel.IsNull()) { + SetErrorCode("History for an operation, produced the shape, does not exist."); + return NULL; + } + + // search in history for all argument shapes + Standard_Boolean isFound = Standard_False; + + TDF_LabelSequence aLabelSeq; + aWhereFunction->GetDependency(aLabelSeq); + Standard_Integer nbArg = aLabelSeq.Length(); + + for (Standard_Integer iarg = 1; iarg <= nbArg && !isFound; iarg++) { + + TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg); + + Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel); + TopoDS_Shape anArgumentShape = anArgumentObject->GetValue(); + + TopTools_IndexedMapOfShape anArgumentIndices; + TopExp::MapShapes(anArgumentShape, anArgumentIndices); + + if (anArgumentIndices.Contains(aWhat)) { + isFound = Standard_True; + Standard_Integer aWhatIndex = anArgumentIndices.FindIndex(aWhat); + + // Find corresponding label in history + TDF_Label anArgumentHistoryLabel = + aWhereFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_False); + if (anArgumentHistoryLabel.IsNull()) { + SetErrorCode("History for this entity does not exist."); + return NULL; + } + + TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(aWhatIndex, Standard_False); + if (aWhatHistoryLabel.IsNull()) { + SetErrorCode("History for this entity does not exist."); + return NULL; + } + + Handle(TDataStd_IntegerArray) anIntegerArray; + if (!aWhatHistoryLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)) { + SetErrorCode("Empty history. Possibly, this entity is absent in result."); + return NULL; + } + aModifiedArray = anIntegerArray->Array(); + if (aModifiedArray->Length() == 0) { + SetErrorCode("This entity is absent in result."); + return NULL; + } + } + } + + if (!isFound) { + SetErrorCode("Not found in arguments."); + return NULL; + } + } + + //Add a new object + Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray); + + if (aModifiedArray->Length() > 1) { + //Set a GROUP type + aResult->SetType(GEOM_GROUP); + + //Set a sub shape type + TDF_Label aFreeLabel = aResult->GetFreeLabel(); + TopAbs_ShapeEnum aShapeType = aWhat.ShapeType(); + TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)aShapeType); + } + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IShapesOperations.GetInPlace("; + TDF_Tool::Entry(theShapeWhere->GetEntry(), anEntry); + aDescr += anEntry + ","; + TDF_Tool::Entry(theShapeWhat->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + Handle(GEOM_Function) aFunction = aResult->GetFunction(1); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aResult; +} //======================================================================= //function : SortShapes diff --git a/src/GEOMImpl/GEOMImpl_ITranslate.hxx b/src/GEOMImpl/GEOMImpl_ITranslate.hxx index 886f7744f..83566e04d 100755 --- a/src/GEOMImpl/GEOMImpl_ITranslate.hxx +++ b/src/GEOMImpl/GEOMImpl_ITranslate.hxx @@ -6,14 +6,12 @@ #define TRANSLATE_ARG_POINT1 1 #define TRANSLATE_ARG_POINT2 2 #define TRANSLATE_ARG_VECTOR 3 -#define TRANSLATE_ARG_REF 4 -#define TRANSLATE_ARG_SHAPE 5 #define TRANSLATE_ARG_ORIGINAL 6 -#define TRANSLATE_ARG_STEP1 7 -#define TRANSLATE_ARG_NBITER1 8 -#define TRANSLATE_ARG_STEP2 9 -#define TRANSLATE_ARG_NBITER2 10 -#define TRANSLATE_ARG_VECTOR2 11 +#define TRANSLATE_ARG_STEP1 7 +#define TRANSLATE_ARG_NBITER1 8 +#define TRANSLATE_ARG_STEP2 9 +#define TRANSLATE_ARG_NBITER2 10 +#define TRANSLATE_ARG_VECTOR2 11 #define TRANSLATE_ARG_DX 12 #define TRANSLATE_ARG_DY 13 #define TRANSLATE_ARG_DZ 14 @@ -36,10 +34,6 @@ class GEOMImpl_ITranslate Handle(GEOM_Function) GetVector() { return _func->GetReference(TRANSLATE_ARG_VECTOR); } - void SetShape(const TopoDS_Shape& theShape) { _func->SetShape(TRANSLATE_ARG_SHAPE, theShape); } - - TopoDS_Shape GetShape() { return _func->GetShape(TRANSLATE_ARG_SHAPE); } - void SetOriginal(Handle(GEOM_Function) theOriginal) { _func->SetReference(TRANSLATE_ARG_ORIGINAL, theOriginal); } Handle(GEOM_Function) GetOriginal() { return _func->GetReference(TRANSLATE_ARG_ORIGINAL); } diff --git a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx index 5f284c488..61f3fde20 100644 --- a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx @@ -3,11 +3,17 @@ using namespace std; #include "GEOMImpl_PartitionDriver.hxx" #include "GEOMImpl_IPartition.hxx" #include "GEOMImpl_Types.hxx" + +#include "GEOM_Object.hxx" #include "GEOM_Function.hxx" #include + +#include + #include #include + #include #include #include @@ -15,7 +21,10 @@ using namespace std; #include #include #include +#include +#include +#include #include #include #include @@ -52,6 +61,7 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const Standard_Integer aType = aFunction->GetType(); TopoDS_Shape aShape; + NMTAlgo_Splitter1 PS; if (aType == PARTITION_PARTITION) { Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); @@ -65,7 +75,6 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const nbshapes += aShapes->Length() + aTools->Length(); nbshapes += aKeepIns->Length() + aRemIns->Length(); - NMTAlgo_Splitter1 PS; TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes); // add object shapes that are in ListShapes; @@ -135,11 +144,6 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const PS.RemoveShapesInside(aShape_i); } - aShape = PS.Shape(); - - if (!BRepAlgo::IsValid(aShape)) { - Standard_ConstructionError::Raise("Partition aborted : non valid shape result"); - } } else if (aType == PARTITION_HALF) { Handle(GEOM_Function) aRefShape = aCI.GetShape(); Handle(GEOM_Function) aRefPlane = aCI.GetPlane(); @@ -150,8 +154,6 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const Standard_NullObject::Raise("In Half Partition a shape or a plane is null"); } - NMTAlgo_Splitter1 PS; - // add object shapes that are in ListShapes; PS.AddShape(aShapeArg); @@ -162,19 +164,61 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const PS.SetRemoveWebs(Standard_False); PS.Build(aShapeArg.ShapeType()); - aShape = PS.Shape(); - - if (!BRepAlgo::IsValid(aShape)) { - Standard_ConstructionError::Raise("Partition aborted : non valid shape result"); - } - } - else { + } else { } + aShape = PS.Shape(); if (aShape.IsNull()) return 0; + if (!BRepAlgo::IsValid(aShape)) { + Standard_ConstructionError::Raise("Partition aborted : non valid shape result"); + } + aFunction->SetValue(aShape); + // Fill history to be used by GetInPlace functionality + TopTools_IndexedMapOfShape aResIndices; + TopExp::MapShapes(aShape, aResIndices); + + // history for all argument shapes + TDF_LabelSequence aLabelSeq; + aFunction->GetDependency(aLabelSeq); + Standard_Integer nbArg = aLabelSeq.Length(); + + for (Standard_Integer iarg = 1; iarg <= nbArg; iarg++) { + + TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg); + + Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel); + TopoDS_Shape anArgumentShape = anArgumentObject->GetValue(); + + TopTools_IndexedMapOfShape anArgumentIndices; + TopExp::MapShapes(anArgumentShape, anArgumentIndices); + Standard_Integer nbArgumentEntities = anArgumentIndices.Extent(); + + // Find corresponding label in history + TDF_Label anArgumentHistoryLabel = + aFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_True); + + for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) { + TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie); + const TopTools_ListOfShape& aModified = PS.Modified(anEntity); + Standard_Integer nbModified = aModified.Extent(); + + if (nbModified > 0) { + TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True); + Handle(TDataStd_IntegerArray) anAttr = + TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified); + + TopTools_ListIteratorOfListOfShape itM (aModified); + for (int im = 1; itM.More(); itM.Next(), ++im) { + int id = aResIndices.FindIndex(itM.Value()); + anAttr->SetValue(im, id); + } + } + } + } + log.SetTouched(Label()); return 1; diff --git a/src/GEOM_SWIG/GEOM_TestOthers.py b/src/GEOM_SWIG/GEOM_TestOthers.py index 220b37e24..55429a96b 100644 --- a/src/GEOM_SWIG/GEOM_TestOthers.py +++ b/src/GEOM_SWIG/GEOM_TestOthers.py @@ -353,3 +353,23 @@ def TestOtherOperations (geompy, math): geompy.addToStudy(vertex_i, "Vertex on Sphere (center = (0, 0, 0), r = 100)") # GetInPlace(theShapeWhere, theShapeWhat) + box5 = geompy.MakeBoxDXDYDZ(100, 100, 100) + box6 = geompy.MakeTranslation(box5, 50, 50, 0) + + part = geompy.MakePartition([box5], [box6]) + geompy.addToStudy(part, "Partitioned") + + ibb = 5 + box_list = [box5, box6] + for abox in box_list: + geompy.addToStudy(abox, "Box " + `ibb`) + box_faces = geompy.SubShapeAll(abox, geompy.ShapeType["FACE"]) + ifa = 1 + for aface in box_faces: + geompy.addToStudyInFather(abox, aface, "Face" + `ifa`) + refl_box_face = geompy.GetInPlace(part, aface) + if refl_box_face is not None: + geompy.addToStudyInFather(part, refl_box_face, + "Reflection of Face " + `ifa` + " of box " + `ibb`) + ifa = ifa + 1 + ibb = ibb + 1 diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index a4a9db5a3..656c22bae 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -2009,7 +2009,7 @@ def MakeHexa2Faces(F1, F2): print "MakeHexa2Faces : ", BlocksOp.GetErrorCode() return anObj -def MakeHexa2Faces(F1, F2): +def GetPoint(theShape, theX, theY, theZ, theEpsilon): """ * Get a vertex, found in the given shape by its coordinates. * \param theShape Block or a compound of blocks. diff --git a/src/NMTAlgo/NMTAlgo_Builder.cxx b/src/NMTAlgo/NMTAlgo_Builder.cxx index c7a902f06..315b36b68 100644 --- a/src/NMTAlgo/NMTAlgo_Builder.cxx +++ b/src/NMTAlgo/NMTAlgo_Builder.cxx @@ -511,6 +511,18 @@ continue; } // + //modified by NIZNHY-PKV Fri Jan 21 17:01:10 2005 f + if (aNbSp==1) { + const BOPTools_PaveBlock& aPB1=aLPB.First(); + const BOPTools_PaveBlock& aPBR1=pPF->RealPaveBlock(aPB1); + nSp=aPBR1.Edge(); + const TopoDS_Shape& aSp1=aDS.Shape(nSp); + if (aSp1.IsSame(aE)) { + continue; + } + } + //modified by NIZNHY-PKV Fri Jan 21 17:01:14 2005 t + // aLSp.Clear(); aIt.Initialize(aLPB); for (; aIt.More(); aIt.Next()) { diff --git a/src/NMTAlgo/NMTAlgo_Splitter.cdl b/src/NMTAlgo/NMTAlgo_Splitter.cdl index 761c051f3..c928426df 100644 --- a/src/NMTAlgo/NMTAlgo_Splitter.cdl +++ b/src/NMTAlgo/NMTAlgo_Splitter.cdl @@ -19,7 +19,8 @@ uses Shape from TopoDS, MapOfOrientedShape from TopTools, IndexedMapOfShape from TopTools, - DataMapOfShapeShape from TopTools, + DataMapOfShapeShape from TopTools, + DataMapOfShapeListOfShape from TopTools, ListOfShape from TopTools, MapOfShape from TopTools, AsDes from BRepAlgo, @@ -166,5 +167,8 @@ fields myMapSIFC : DataMapOfShapeShape from TopTools is protected; ----vv myGenerated : ListOfShape from TopTools is protected; + --modified by NIZNHY-PKV Mon Jan 24 09:45:10 2005f + myModifiedFaces: DataMapOfShapeListOfShape from TopTools is protected; + --modified by NIZNHY-PKV Mon Jan 24 09:45:14 2005t ----^^ end Splitter; diff --git a/src/NMTAlgo/NMTAlgo_Splitter.cxx b/src/NMTAlgo/NMTAlgo_Splitter.cxx index 83b82b84d..9b85beebc 100644 --- a/src/NMTAlgo/NMTAlgo_Splitter.cxx +++ b/src/NMTAlgo/NMTAlgo_Splitter.cxx @@ -114,6 +114,9 @@ static myObjShapes.Clear(); myToolShapes.Clear(); myMapSIFC.Clear(); + //modified by NIZNHY-PKV Mon Jan 24 09:47:37 2005f + myModifiedFaces.Clear(); + //modified by NIZNHY-PKV Mon Jan 24 09:47:41 2005t myErrorStatus=0; } //======================================================================= @@ -472,10 +475,13 @@ static TopTools_ListIteratorOfListOfShape aItS, aItFI; TopExp_Explorer aExp; TopAbs_Orientation aOriFS; - TopoDS_Face aFIx; + TopoDS_Face aFIx, aFIy; BRep_Builder aBB; // myImageShape.Clear(); + //modified by NIZNHY-PKV Mon Jan 24 09:48:15 2005f + myModifiedFaces.Clear(); + //modified by NIZNHY-PKV Mon Jan 24 09:48:18 2005t // aItS.Initialize(myListShapes); for ( ;aItS.More(); aItS.Next()) { @@ -490,6 +496,14 @@ static // if (!myImagesFaces.HasImage(aFS)) { myQueryShapes.Add(aFS); + //modified by NIZNHY-PKV Mon Jan 24 09:50:42 2005 f + if (!myModifiedFaces.IsBound(aFS)) { + TopTools_ListOfShape aLS; + // + aLS.Append(aFS); + myModifiedFaces.Bind(aFS, aLS); + } + //modified by NIZNHY-PKV Mon Jan 24 09:50:44 2005 t continue; } // @@ -510,10 +524,28 @@ static aFSDIx.Reverse(); } myQueryShapes.Add(aFSDIx); + //modified by NIZNHY-PKV Mon Jan 24 09:56:06 2005f + aFIy=aFSDIx; + //modified by NIZNHY-PKV Mon Jan 24 09:56:09 2005t } else { myQueryShapes.Add(aFIx); + //modified by NIZNHY-PKV Mon Jan 24 09:56:06 2005f + aFIy=aFIx; + //modified by NIZNHY-PKV Mon Jan 24 09:56:09 2005t + } + //modified by NIZNHY-PKV Mon Jan 24 09:53:38 2005f + if (!myModifiedFaces.IsBound(aFS)) { + TopTools_ListOfShape aLS; + // + aLS.Append(aFIy); + myModifiedFaces.Bind(aFS, aLS); + } + else { + TopTools_ListOfShape& aLS=myModifiedFaces.ChangeFind(aFS); + aLS.Append(aFIy); } + //modified by NIZNHY-PKV Mon Jan 24 09:53:43 2005t } }//for (; aExp.More(); aExp.Next()) { // diff --git a/src/NMTAlgo/NMTAlgo_Splitter.hxx b/src/NMTAlgo/NMTAlgo_Splitter.hxx index 0609ad516..d22864b39 100644 --- a/src/NMTAlgo/NMTAlgo_Splitter.hxx +++ b/src/NMTAlgo/NMTAlgo_Splitter.hxx @@ -1,16 +1,23 @@ // File generated by CPPExt (Value) -// Copyright (C) 1991,1995 by -// -// MATRA DATAVISION, FRANCE +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. // -// This software is furnished in accordance with the terms and conditions -// of the contract and with the inclusion of the above copyright notice. -// This software or any other copy thereof may not be provided or otherwise -// be made available to any other person. No title to an ownership of the -// software is hereby transferred. +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. // -// At the termination of the contract, the software and all copies of this -// software must be deleted. +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. #ifndef _NMTAlgo_Splitter_HeaderFile #define _NMTAlgo_Splitter_HeaderFile @@ -36,6 +43,9 @@ #ifndef _TopTools_MapOfOrientedShape_HeaderFile #include #endif +#ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile +#include +#endif #ifndef _NMTAlgo_Builder_HeaderFile #include #endif @@ -130,6 +140,7 @@ TopTools_MapOfShape myToolShapes; TopTools_MapOfShape myObjShapes; TopTools_DataMapOfShapeShape myMapSIFC; TopTools_ListOfShape myGenerated; +TopTools_DataMapOfShapeListOfShape myModifiedFaces; private: diff --git a/src/NMTAlgo/NMTAlgo_Splitter_2.cxx b/src/NMTAlgo/NMTAlgo_Splitter_2.cxx index d50bc6d3d..337c98435 100644 --- a/src/NMTAlgo/NMTAlgo_Splitter_2.cxx +++ b/src/NMTAlgo/NMTAlgo_Splitter_2.cxx @@ -104,48 +104,45 @@ //function : RemoveShapesInside //purpose : remove shapes that are inside S from result //======================================================================= - void NMTAlgo_Splitter::RemoveShapesInside (const TopoDS_Shape& aS) + void NMTAlgo_Splitter::RemoveShapesInside (const TopoDS_Shape& S) { TopoDS_Iterator it; - TopAbs_ShapeEnum aTypeS; - // - aTypeS=aS.ShapeType(); - if (aTypeS < TopAbs_SOLID) { // compound or compsolid - it.Initialize(aS); + if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid + it.Initialize( S ); for (; it.More(); it.Next()) { - const TopoDS_Shape& aSx=it.Value(); - RemoveShapesInside(aSx); + RemoveShapesInside( it.Value()); } return; } // - Standard_Boolean bFromTool, bIsClosed; - Standard_Integer i, aNbE; - TopoDS_Shape aIntFacesComp; - TopoDS_Compound aC; + Standard_Boolean isTool; + TopoDS_Shape IntFacesComp; + TopoDS_Compound C; TopTools_IndexedMapOfShape MIF; // map of internal faces TopTools_MapOfShape RFM; TopTools_MapIteratorOfMapOfShape itF; - TopTools_IndexedDataMapOfShapeListOfShape aMEF; // - bFromTool=myToolShapes.Contains(aS); + //modified by NIZNHY-PKV Wed Dec 22 18:56:27 2004 f + isTool=myToolShapes.Contains(S); + //modified by NIZNHY-PKV Wed Dec 22 18:56:31 2004 t // - if (!myImageShape.HasImage(aS)) { - return; + //isTool = Standard_False; + if (!myImageShape.HasImage( S )) { + return; } // - aIntFacesComp = FindFacesInside(aS, Standard_False, Standard_True); + IntFacesComp = FindFacesInside( S, Standard_False, Standard_True); // - TopExp::MapShapes(aIntFacesComp, TopAbs_FACE, MIF); + TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF); if (MIF.IsEmpty()) { return; } // add to MIF split faces of S - const TopoDS_Shape& aSIm=myImageShape.Image(aS).First(); + const TopoDS_Shape& aSIm=myImageShape.Image(S).First(); TopExp::MapShapes(aSIm, TopAbs_FACE, MIF); // // leave in the result only those shapes not having all face in MIF - myBuilder.MakeCompound(aC); + myBuilder.MakeCompound(C); // // RFM : faces of removed shapes that encounter once it.Initialize(myShape); @@ -164,90 +161,99 @@ // if (expResF.More()) { // add shape to result - myBuilder.Add(aC, aSR); + myBuilder.Add(C, aSR); } else { // add faces of a removed shape to RFM - if (!bFromTool) { //modified by NIZNHY-PKV Thu Dec 23 09:55:39 2004 ft - for (expResF.ReInit(); expResF.More(); expResF.Next()) { - const TopoDS_Shape& aF = expResF.Current(); - if (!RFM.Remove(aF)) { - RFM.Add(aF); - } + 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; - } + //modified by NIZNHY-PKV Wed Dec 22 18:59:46 2004 f + TopoDS_Compound aCx; // - // 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); - } + myBuilder.MakeCompound(aCx); + itF.Initialize (RFM); + for (; itF.More(); itF.Next()) { + const TopoDS_Shape& aF=itF.Key(); + myBuilder.Add(aCx, aF); } + //modified by NIZNHY-PKV Wed Dec 22 18:59:48 2004 t // - // 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 (!isTool) { + // rebuild S, it must remain in the result + Standard_Boolean isClosed = Standard_False; + switch (S.ShapeType()) { + case TopAbs_SOLID : + isClosed = Standard_True; break; + case TopAbs_SHELL: { + TopTools_IndexedDataMapOfShapeListOfShape MEF; + TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, MEF); + Standard_Integer i; + for (i=1; isClosed && i<=MEF.Extent(); ++i) { + isClosed = ( MEF(i).Extent() != 1 ); } + break; + } + default: + isClosed = Standard_False; } // - if (aTypeS==TopAbs_SOLID) { - TopoDS_Solid aSolid; + if (isClosed) { + // add to a new shape external faces of removed shapes, ie those in RFM + TopoDS_Shell Shell; + myBuilder.MakeShell(Shell); + // exclude redundant internal face with edges encounterd only once + TopTools_IndexedDataMapOfShapeListOfShape MEF; // - myBuilder.MakeSolid(aSolid); - myBuilder.Add (aSolid, aShell); - myBuilder.Add (aC, aSolid); - } + itF.Initialize (RFM); + for ( ; itF.More(); itF.Next()) { + const TopoDS_Shape& aF=itF.Key(); + TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, MEF); + } + // 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 (MEF.FindFromKey(expE.Current()).Extent() == 1) { + break; + } + } + if (!expE.More()) { + myBuilder.Add( Shell, aF); + } + else { + //int a=0; + } + } + + if (S.ShapeType() == TopAbs_SOLID) { + TopoDS_Solid Solid; + myBuilder.MakeSolid( Solid ); + myBuilder.Add (Solid, Shell); + myBuilder.Add (C, Solid); + } + else { + myBuilder.Add (C, Shell); + } + } // if (isClosed) { 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); + it.Initialize(aSIm); + for (; it.More(); it.Next()) { + myBuilder.Add (C, it.Value()); + } } } // - myShape=aC; + myShape = C; } - + //modified by NIZNHY-PKV Mon Jan 24 10:19:30 2005 f //======================================================================= //function : Modified //purpose : @@ -255,81 +261,104 @@ const TopTools_ListOfShape& NMTAlgo_Splitter::Modified (const TopoDS_Shape& S) { - myGenerated.Clear(); + TopAbs_ShapeEnum aType; TopTools_ListIteratorOfListOfShape it; TopTools_MapOfShape aMap; TopExp_Explorer anExp; - - if(S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_EDGE) { - - if(S.ShapeType() == TopAbs_FACE) { - if (myImagesFaces.HasImage( S )) { - it.Initialize(myImagesFaces.Image(S)); - anExp.Init(myShape, TopAbs_FACE); + // + myGenerated.Clear(); + aType=S.ShapeType(); + // + switch (aType) { + case TopAbs_FACE: { + if (myModifiedFaces.IsBound(S)) { + anExp.Init(myShape, aType); + for(; anExp.More(); anExp.Next()) { + aMap.Add(anExp.Current()); + } + // + 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); + } + } + } } } - else { - if (myImagesEdges.HasImage( S )) { - it.Initialize(myImagesEdges.Image(S)); - anExp.Init(myShape, TopAbs_EDGE); + break; + // + case TopAbs_EDGE: { + 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); + } + } + } } } - - for(; anExp.More(); anExp.Next()) { - aMap.Add(anExp.Current()); - } - - for (; it.More(); it.Next()) { - if(aMap.Contains(it.Value())) { - myGenerated.Append(it.Value()); + break; + // + case TopAbs_VERTEX: { + 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; + } } - } - - return myGenerated; - - } - - if(S.ShapeType() == TopAbs_VERTEX) { - - const NMTTools_DSFiller& aDSF = Filler(); - const NMTTools_PaveFiller& aPF = aDSF.PaveFiller(); - const NMTDS_ShapesDataStructure& aDS = aDSF.DS(); - - Standard_Integer aNbS = aDS.NumberOfSourceShapes(); - Standard_Integer anIndex = 0, i; - - 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; } - - } - - if(anIndex == 0) return myGenerated; - - Standard_Integer aSDVInd = aPF.FindSDVertex(anIndex); - - if(aSDVInd == 0) return myGenerated; - - const TopoDS_Shape aSDV = aDS.Shape(aSDVInd); - - anExp.Init(myShape, TopAbs_VERTEX); - for(; anExp.More(); anExp.Next()) { - - if(aSDV.IsSame(anExp.Current())) { - myGenerated.Append(aSDV); - break; + // + 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; + // + default: + break; + } // switch (aType) { + // return myGenerated; } +//modified by NIZNHY-PKV Mon Jan 24 10:28:40 2005 t //======================================================================= //function : Generated //purpose :