From 843b34734c75ad640850466d49fe44af5d4a31cd Mon Sep 17 00:00:00 2001 From: jgv Date: Wed, 24 Oct 2018 16:38:18 +0300 Subject: [PATCH] Next version --- src/ChFi3d/ChFi3d_Builder.cxx | 144 ++++++++++++++++++++++++++------ src/ChFi3d/ChFi3d_Builder.hxx | 2 + src/ChFi3d/ChFi3d_Builder_6.cxx | 1 + 3 files changed, 122 insertions(+), 25 deletions(-) diff --git a/src/ChFi3d/ChFi3d_Builder.cxx b/src/ChFi3d/ChFi3d_Builder.cxx index 9dd623e219..98c0529199 100644 --- a/src/ChFi3d/ChFi3d_Builder.cxx +++ b/src/ChFi3d/ChFi3d_Builder.cxx @@ -82,6 +82,7 @@ #include #include #include +#include #ifdef OCCT_DEBUG #include @@ -109,6 +110,44 @@ extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time); extern Standard_Boolean ChFi3d_GettraceCHRON(); #endif +//======================================================================= +//function : FindProperSubShape +//purpose : +//======================================================================= + +TopoDS_Shape FindProperSubShape(const TopoDS_Shape& theNewFace, + const TopoDS_Shape& theShape) +{ + TopoDS_Shape NullShape; + + TopTools_IndexedMapOfShape Emap; + TopExp::MapShapes(theNewFace, TopAbs_EDGE, Emap); + + TopoDS_Iterator iter(theShape); + for (; iter.More(); iter.Next()) + { + const TopoDS_Shape& aShape = iter.Value(); + if (aShape.ShapeType() == TopAbs_FACE) + { + TopExp_Explorer Explo(aShape, TopAbs_EDGE); + for (; Explo.More(); Explo.Next()) + { + const TopoDS_Shape& anEdge = Explo.Current(); + if (Emap.Contains(anEdge)) + return theShape; + } + } + else + { + TopoDS_Shape aResult = FindProperSubShape(theNewFace, aShape); + if (!aResult.IsNull()) + return aResult; + } + } + + return NullShape; +} + //======================================================================= //function : BuildNewWire //purpose : @@ -599,6 +638,14 @@ void ChFi3d_Builder::Compute() //general fuse (compound of wires from a face, compound of new edges for this face) //method building new face from old and new edges //assembling of resulting shape from modified and unmodified faces. + + TopTools_ListOfShape aChFiFaces; + TopTools_IndexedDataMapOfShapeShape aFacesModifiedFaces; + + //Temporary + TopoDS_Shell aShell; + BB.MakeShell(aShell); + for (Standard_Integer i = 1; i <= myNewFaces.Extent(); i++) { TopoDS_Face aFace = TopoDS::Face(myNewFaces(i)); @@ -618,36 +665,83 @@ void ChFi3d_Builder::Compute() aNewEdge.Orientation(anOr); BB.Add(aNewEdges, aNewEdge); } - //BRepAlgoAPI_Fuse aFuse(aWires, aNewEdges); - BOPAlgo_Builder GenFuse; - GenFuse.AddArgument(aFace); - GenFuse.AddArgument(aNewEdges); - GenFuse.Perform(); - TopoDS_Shape aNewFace = aFace.EmptyCopied(); - const TopoDS_Shape& aResFuse = GenFuse.Shape(); - //const BOPCol_DataMapOfShapeListOfShape& ModifiedShapes = GenFuse.Images(); - const TopTools_DataMapOfShapeListOfShape& ModifiedShapes = GenFuse.Images(); - TopTools_IndexedDataMapOfShapeListOfShape VEmapOfNewFace; - TopExp::MapShapesAndAncestors(aResFuse, TopAbs_VERTEX, TopAbs_EDGE, VEmapOfNewFace); - TopoDS_Iterator itw(aFace); - for (; itw.More(); itw.Next()) + + if (myIndsChFiFaces.Contains(i)) //absolutely new face + { + TopoDS_Wire aWire; + BB.MakeWire(aWire); + TopoDS_Iterator iter(aNewEdges); + for (; iter.More(); iter.Next()) + BB.Add(aWire, iter.Value()); + BB.Add(aFace, aWire); + aChFiFaces.Append(aFace); + //Temporary + BB.Add(aShell, aFace); + } + else //a modified old face + { + //BRepAlgoAPI_Fuse aFuse(aWires, aNewEdges); + BOPAlgo_Builder GenFuse; + GenFuse.AddArgument(aFace); + GenFuse.AddArgument(aNewEdges); + GenFuse.Perform(); + TopoDS_Shape aNewFace = aFace.EmptyCopied(); + const TopoDS_Shape& aResFuse = GenFuse.Shape(); + //const BOPCol_DataMapOfShapeListOfShape& ModifiedShapes = GenFuse.Images(); + const TopTools_DataMapOfShapeListOfShape& ModifiedShapes = GenFuse.Images(); + TopTools_IndexedDataMapOfShapeListOfShape VEmapOfNewFace; + TopExp::MapShapesAndAncestors(aResFuse, TopAbs_VERTEX, TopAbs_EDGE, VEmapOfNewFace); + TopoDS_Iterator itw(aFace); + for (; itw.More(); itw.Next()) + { + const TopoDS_Shape& aWire = itw.Value(); + if (!ModifiedShapes.IsBound(aWire)) + continue; + const TopTools_ListOfShape& aListOfModified = ModifiedShapes(aWire); + TopTools_ListIteratorOfListOfShape itwm(aListOfModified); + for (; itwm.More(); itwm.Next()) + { + const TopoDS_Wire& aModifiedWire = TopoDS::Wire(itwm.Value()); + cout<<"a Modified Wire ..."<Perform(myDS); //jgv// diff --git a/src/ChFi3d/ChFi3d_Builder.hxx b/src/ChFi3d/ChFi3d_Builder.hxx index abdc46645d..e3b9f14eaf 100644 --- a/src/ChFi3d/ChFi3d_Builder.hxx +++ b/src/ChFi3d/ChFi3d_Builder.hxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -327,6 +328,7 @@ protected: //NCollection_IndexedDataMap myFaceNewEdges; TopTools_IndexedMapOfShape myNewFaces; TopTools_IndexedMapOfShape myNewEdges; + TColStd_MapOfInteger myIndsChFiFaces; Handle(TopOpeBRepBuild_HBuilder) myCoup; ChFiDS_ListOfStripe myListStripe; ChFiDS_StripeMap myVDataMap; diff --git a/src/ChFi3d/ChFi3d_Builder_6.cxx b/src/ChFi3d/ChFi3d_Builder_6.cxx index bbfa1c260b..c2e4b9f190 100644 --- a/src/ChFi3d/ChFi3d_Builder_6.cxx +++ b/src/ChFi3d/ChFi3d_Builder_6.cxx @@ -722,6 +722,7 @@ Standard_Boolean ChFi3d_Builder::StoreData(Handle(ChFiDS_SurfData)& Data, TopLoc_Location aLoc; BB.UpdateFace(aNewFace, Surf, aLoc, Precision::Confusion()); Standard_Integer IndNewFace = myNewFaces.Add(aNewFace); + myIndsChFiFaces.Add(IndNewFace); //ChFi3d_ListOfQualifiedEdge aList; TColStd_ListOfInteger aList; myFaceNewEdges.Add(IndNewFace, aList); -- 2.39.5