#include "utilities.h"
#include <TDF.hxx>
+#include <TDF_Tool.hxx>
#include <TDF_Data.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Reference.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Builder.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#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))
* 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;
+//}
//=============================================================================
}
}
+//=============================================================================
+/*!
+ * 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 :
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:
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;
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)
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;
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
+#include <TopoDS_Iterator.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <GEOMAlgo_IndexedDataMapOfPassKeyListOfShape.hxx>
#include <GEOMAlgo_PassKey.hxx>
#include <GEOMAlgo_Tools.hxx>
+//
+
+static
+ void GetSubShapes(const TopoDS_Shape& aS,
+ TopTools_IndexedMapOfShape& aMSS);
//=======================================================================
//function : GEOMAlgo_Gluer
//
aNbS=aMS.Extent();
if (aNbS) {
- Standard_Real aTol=1.e-7;
+ //Standard_Real aTol=1.e-7;
BOP_CorrectTolerances::CorrectCurveOnSurface(myResult);
}
}
{
myErrorStatus=0;
//
+ Standard_Boolean bHasNewSubShape;
Standard_Integer i, aNbF, aNbSDF, iErr;
TopoDS_Shape aNewShape;
TopTools_IndexedMapOfShape aMF;
}
//
// Images/Origins
+ //
aNbF=aMPKLF.Extent();
for (i=1; i<=aNbF; ++i) {
const TopTools_ListOfShape& aLSDF=aMPKLF(i);
}
//
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);
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;
else {
BOPTools_Tools::MakeSplitEdge(aEx, aVR1, aT1, aVR2, aT2, aNewEdge);
}
- //modified by NIZNHY-PKV Thu Dec 30 11:15:28 2004 t
}
//
//=======================================================================
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);
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);
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
//
//
// 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);
- }
-}
-*/
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
#ifndef _GEOMAlgo_ShapeAlgo_HeaderFile
#include <GEOMAlgo_ShapeAlgo.hxx>
#endif
#ifndef _TopAbs_ShapeEnum_HeaderFile
#include <TopAbs_ShapeEnum.hxx>
#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;
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;
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
TopTools_DataMapOfShapeListOfShape myImages;
TopTools_DataMapOfShapeShape myOrigins;
Standard_Integer myNbAlone;
+TopTools_ListOfShape myGenerated;
private:
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopoDS_Shape_HeaderFile
+#include <TopoDS_Shape.hxx>
+#endif
#ifndef _TopoDS_Edge_HeaderFile
#include <TopoDS_Edge.hxx>
#endif
#ifndef _TopoDS_Face_HeaderFile
#include <TopoDS_Face.hxx>
#endif
-#ifndef _TopTools_ListOfShape_HeaderFile
-#include <TopTools_ListOfShape.hxx>
-#endif
#ifndef _TopoDS_Vertex_HeaderFile
#include <TopoDS_Vertex.hxx>
#endif
#include "GEOMImpl_IGlue.hxx"
#include "GEOMImpl_Types.hxx"
+#include "GEOM_Object.hxx"
#include "GEOM_Function.hxx"
#include "GEOMAlgo_Gluer.hxx"
#include "utilities.h"
+#include <TDataStd_IntegerArray.hxx>
+
+#include <TopExp.hxx>
#include <TopoDS_Shape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
#include <Standard_NullObject.hxx>
#include <Standard_Failure.hxx>
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;
}
aMsg += TCollection_AsciiString( nbParamValueErrors );
MESSAGE(aMsg.ToCString());
}
+
+ return true;
}
//=============================================================================
#include <TFunction_Driver.hxx>
#include <TFunction_Logbook.hxx>
#include <TDataStd_Integer.hxx>
+#include <TDataStd_IntegerArray.hxx>
#include <TDF_Tool.hxx>
#include <BRepExtrema_ExtCF.hxx>
#include <gp_Lin.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
//#include <OSD_Timer.hxx>
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
#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
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); }
#include "GEOMImpl_PartitionDriver.hxx"
#include "GEOMImpl_IPartition.hxx"
#include "GEOMImpl_Types.hxx"
+
+#include "GEOM_Object.hxx"
#include "GEOM_Function.hxx"
#include <NMTAlgo_Splitter1.hxx>
+
+#include <TDataStd_IntegerArray.hxx>
+
#include <BRep_Tool.hxx>
#include <BRepAlgo.hxx>
+
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
#include <Standard_NullObject.hxx>
#include <Precision.hxx>
#include <gp_Pnt.hxx>
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
+ NMTAlgo_Splitter1 PS;
if (aType == PARTITION_PARTITION) {
Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes();
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;
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();
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);
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;
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
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.
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()) {
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,
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;
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;
}
//=======================================================================
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()) {
//
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;
}
//
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()) {
//
// 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
#ifndef _TopTools_MapOfOrientedShape_HeaderFile
#include <TopTools_MapOfOrientedShape.hxx>
#endif
+#ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#endif
#ifndef _NMTAlgo_Builder_HeaderFile
#include <NMTAlgo_Builder.hxx>
#endif
TopTools_MapOfShape myObjShapes;
TopTools_DataMapOfShapeShape myMapSIFC;
TopTools_ListOfShape myGenerated;
+TopTools_DataMapOfShapeListOfShape myModifiedFaces;
private:
//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);
//
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 :
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 :