From 8bc9b430c5f9f3cf77539fee550f1b56769d3893 Mon Sep 17 00:00:00 2001 From: smh Date: Wed, 28 Jan 2004 14:08:37 +0000 Subject: [PATCH] MPV: Merge V1_2d --- src/DisplayGUI/DisplayGUI.cxx | 1 + src/EntityGUI/EntityGUI_SubShapeDlg.cxx | 2 +- src/GEOM/GEOM_Gen_i.cc | 9 ++- src/GEOMBase/GEOMBase.cxx | 5 +- src/GEOMToolsGUI/GEOMToolsGUI.cxx | 14 +++-- src/GEOM_SWIG/geompy.py | 4 +- src/OBJECT/GEOM_AISShape.cxx | 10 ++-- src/OBJECT/GEOM_Actor.cxx | 8 ++- src/OBJECT/GEOM_Actor.h | 4 +- src/OBJECT/GEOM_AssemblyBuilder.cxx | 8 +-- .../OperationGUI_PartitionDlg.cxx | 13 +++-- src/PARTITION/Partition_Inter2d.cxx | 7 ++- src/PARTITION/Partition_Inter3d.cxx | 39 ++++++++----- src/PARTITION/Partition_Spliter.cdl | 1 + src/PARTITION/Partition_Spliter.cxx | 55 ++++++++++++------- src/PARTITION/Partition_Spliter.hxx | 1 + 16 files changed, 117 insertions(+), 64 deletions(-) diff --git a/src/DisplayGUI/DisplayGUI.cxx b/src/DisplayGUI/DisplayGUI.cxx index b42972f89..73235ed1b 100644 --- a/src/DisplayGUI/DisplayGUI.cxx +++ b/src/DisplayGUI/DisplayGUI.cxx @@ -440,6 +440,7 @@ void DisplayGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO } Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); aSh->SetShadingColor(myDisplayGUI->myGeomBase->myShadingColor); + aSh->SetInfiniteState(Shape.Infinite()); Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myDisplayGUI->myGeomGUI->GetFatherior(), "GEOM"); IO->setEntry(obj->GetID()); aSh->setIO(IO); diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx index 28923363f..b782a2bd2 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx @@ -198,7 +198,7 @@ void EntityGUI_SubShapeDlg::ClickOnApply() QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); /* Reset all arguments and local context to allow user a new selection ...*/ - this->ResetStateOfDialog(); + //this->ResetStateOfDialog(); return; } diff --git a/src/GEOM/GEOM_Gen_i.cc b/src/GEOM/GEOM_Gen_i.cc index 3816897ae..c5b9bf2a7 100644 --- a/src/GEOM/GEOM_Gen_i.cc +++ b/src/GEOM/GEOM_Gen_i.cc @@ -452,7 +452,9 @@ SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; aSeq->length(1); // Prepare a file name to open - TCollection_AsciiString aNameWithExt(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())); + TCollection_AsciiString aNameWithExt(""); + if (isMultiFile) + aNameWithExt = TCollection_AsciiString(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())); aNameWithExt += TCollection_AsciiString("_GEOM.sgd"); aSeq[0] = CORBA::string_dup(aNameWithExt.ToCString()); // Build a full file name of temporary file @@ -493,7 +495,10 @@ CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, isMultiFile); // Prepare a file name to open - TCollection_AsciiString aNameWithExt(aSeq[0]); + TCollection_AsciiString aNameWithExt(""); + if (isMultiFile) + aNameWithExt = TCollection_AsciiString(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())); + aNameWithExt += TCollection_AsciiString("_GEOM.sgd"); TCollection_AsciiString aFullName = aTmpDir + aNameWithExt; // Open document diff --git a/src/GEOMBase/GEOMBase.cxx b/src/GEOMBase/GEOMBase.cxx index 438a1e541..fd8b537af 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -490,13 +490,13 @@ bool GEOMBase::Display(GEOM::GEOM_Shape_ptr aShape, Standard_CString name) anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap("ICON_OBJBROWSER_Geometry"); + aStudyBuilder->DefineComponentInstance(father, myGeom); QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); if(aLocked) aStudy->GetProperties()->SetLocked(true); op->finish(); } - aStudyBuilder->DefineComponentInstance(father, myGeom); father->ComponentIOR(myGeomGUI->GetFatherior()); TCollection_AsciiString nameG(""); @@ -540,6 +540,7 @@ bool GEOMBase::Display(GEOM::GEOM_Shape_ptr aShape, Standard_CString name) OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); Handle(GEOM_AISShape) theResult = new GEOM_AISShape(shape, nameG.ToCString()); + theResult->SetInfiniteState(shape.Infinite()); theResult->SetShadingColor(myShadingColor); IO = new GEOM_InteractiveObject(aShape->Name(), myGeomGUI->GetFatherior(), "GEOM"); theResult->setIO(IO); @@ -595,12 +596,12 @@ bool GEOMBase::AddInStudy(bool selection, const Handle(SALOME_InteractiveObject) anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap("ICON_OBJBROWSER_Geometry"); + aStudyBuilder->DefineComponentInstance(father, myGeom); if (aLocked) aStudy->GetProperties()->SetLocked(true); op->finish(); } - aStudyBuilder->DefineComponentInstance(father, myGeom); father->ComponentIOR(myGeomGUI->GetFatherior()); SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry()); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index fe0e3cc9c..5eddb4047 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -313,7 +313,7 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { QAD_PyEditor* PyEditor = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getPyEditor(); PyEditor->setText("from GEOM_usinggeom import *\n"); - PyEditor->setText(">>> "); + //PyEditor->setText(">>> "); PyEditor->handleReturn(); break; } @@ -533,6 +533,9 @@ void GEOMToolsGUI::OnEditDelete() SALOMEDS::AttributeIOR_var anIOR; SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + QAD_Operation* op = new SALOMEGUI_ImportOperation( QAD_Application::getDesktop()->getActiveStudy() ); + op->start(); + Standard_Boolean deleted = false; for(;It.More();It.Next()) { Handle(SALOME_InteractiveObject) IObject = It.Value(); if(IObject->hasEntry()) { @@ -598,15 +601,16 @@ void GEOMToolsGUI::OnEditDelete() /* Erase objects in Study */ SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); if(!obj->_is_nil()) { - QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy()); - op->start(); aStudyBuilder->RemoveObject(obj); - op->finish(); + deleted = true; } } /* IObject->hasEntry() */ } /* more/next */ + if (deleted) op->finish(); + else op->abort(); + /* Clear any previous selection */ Sel->ClearIObjects(); QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); @@ -742,11 +746,11 @@ bool GEOMToolsGUI::Import(int aState) anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" ); + aStudyBuilder->DefineComponentInstance( father, myGeom ); if (aLocked) aStudy->GetProperties()->SetLocked(true); op->finish(); } // if (aLocked) return false; - aStudyBuilder->DefineComponentInstance( father, myGeom ); father->ComponentIOR(myGeomGUI->GetFatherior()); QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(myGeomGUI->GetNbGeom()++); diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index 1e74b2938..4cfc0184f 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -115,7 +115,7 @@ def addToStudy(aShape, aName): #NRI : BugID 1682 : sg = SALOMEGUI_Swig() #NRI : BugID 1682 : sg.updateObjBrowser(0) - salome.sg.updateObjBrowser(0) +# salome.sg.updateObjBrowser(0) return id def addToStudyInFather(aFather, aShape, aName): @@ -141,7 +141,7 @@ def addToStudyInFather(aFather, aShape, aName): addArguments( aShape ) #NRI : BugID 1682 : sg.updateObjBrowser(0) - salome.sg.updateObjBrowser(0) +# salome.sg.updateObjBrowser(0) return id # ----------------------------------------------------------------------------- diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx index e87917f5e..81c83d1d3 100644 --- a/src/OBJECT/GEOM_AISShape.cxx +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -103,11 +103,11 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn(); Graphic3d_MaterialAspect aMatAspect; - aMatAspect.SetAmbient( 1 ); - aMatAspect.SetDiffuse( 0 ); - aMatAspect.SetEmissive( 0 ); - aMatAspect.SetShininess(1 ); - aMatAspect.SetSpecular( 0 ); + aMatAspect.SetAmbient( 0.5 ); + aMatAspect.SetDiffuse( 0.5 ); + aMatAspect.SetEmissive( 0.5 ); + aMatAspect.SetShininess(0.5 ); + aMatAspect.SetSpecular( 0.5 ); myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect); myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Graphic3d_NOM_JADE); diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx index 0602bc5ca..dde683ac8 100644 --- a/src/OBJECT/GEOM_Actor.cxx +++ b/src/OBJECT/GEOM_Actor.cxx @@ -76,6 +76,7 @@ GEOM_Actor::GEOM_Actor() this->ishighlighted = false; this->subshape = false; + this->myIsInfinite = false; } GEOM_Actor::~GEOM_Actor() @@ -171,6 +172,7 @@ void GEOM_Actor::SetShadingProperty(vtkProperty* Prop) { // Mapper creating function //------------------------------------------------------------- void GEOM_Actor::CreateMapper(int theMode) { + this->myIsInfinite = myShape.Infinite(); if(myShape.ShapeType() == TopAbs_VERTEX) { gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(myShape)); this->SetPosition(aPnt.X(),aPnt.Y(),aPnt.Z()); @@ -220,7 +222,9 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper) } if(!ishighlighted) { - if(myDisplayMode >= 1) { + if ( ispreselected ) + this->Property = PreviewProperty; + else if(myDisplayMode >= 1) { // SHADING this->Property = ShadingProperty; } @@ -228,8 +232,6 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper) this->Property = WireframeProperty; } - if ( ispreselected ) - this->Property = PreviewProperty; } this->Property->Render(this, ren); diff --git a/src/OBJECT/GEOM_Actor.h b/src/OBJECT/GEOM_Actor.h index c40dd1001..cc6295159 100644 --- a/src/OBJECT/GEOM_Actor.h +++ b/src/OBJECT/GEOM_Actor.h @@ -93,7 +93,8 @@ class VTKOCC_EXPORT GEOM_Actor : public SALOME_Actor { // Color void SetColor(float r,float g,float b); void GetColor(float& r,float& g,float& b); - + + virtual bool IsInfinite() {return myIsInfinite;} protected: GEOM_Actor(); @@ -110,6 +111,7 @@ class VTKOCC_EXPORT GEOM_Actor : public SALOME_Actor { private: bool subshape; + bool myIsInfinite; TopoDS_Shape myShape; double deflection; diff --git a/src/OBJECT/GEOM_AssemblyBuilder.cxx b/src/OBJECT/GEOM_AssemblyBuilder.cxx index 39aca3d9c..6c0f4df92 100644 --- a/src/OBJECT/GEOM_AssemblyBuilder.cxx +++ b/src/OBJECT/GEOM_AssemblyBuilder.cxx @@ -69,7 +69,7 @@ void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp, { // Shading like default OCC material FaceProp->SetRepresentationToSurface(); - FaceProp->SetInterpolation(1); + FaceProp->SetInterpolationToGouraud(); FaceProp->SetAmbient(1.0); FaceProp->SetDiffuse(1.0); FaceProp->SetSpecular(0.4); @@ -109,9 +109,9 @@ void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp, // Wireframe for Preview edge EdgePVProp->SetRepresentationToWireframe(); - EdgePVProp->SetAmbientColor(0, 1, 1); - EdgePVProp->SetDiffuseColor(0, 1, 1); - EdgePVProp->SetSpecularColor(0, 1, 1); + EdgePVProp->SetAmbientColor(1, 1, 0); + EdgePVProp->SetDiffuseColor(1, 1, 0); + EdgePVProp->SetSpecularColor(1, 1, 0); // Wireframe for vertex VertexProp->SetRepresentationToWireframe(); diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx index add70022d..fb93269dd 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -205,14 +205,19 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); if(nbSel < 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + myListShapes.length(0); myOkListShapes = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) + } else if(myEditCurrentArgument == GroupPoints->LineEdit2) { + myListTools.length(0); myOkListTools = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit3) + } else if(myEditCurrentArgument == GroupPoints->LineEdit3) { + myListRemoveInside.length(0); myOkKeepShape = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit4) + } else if(myEditCurrentArgument == GroupPoints->LineEdit4) { + myListKeepInside.length(0); myOkRemoveShape = false; + } return; } diff --git a/src/PARTITION/Partition_Inter2d.cxx b/src/PARTITION/Partition_Inter2d.cxx index 54b25e6e9..f8fa4931e 100644 --- a/src/PARTITION/Partition_Inter2d.cxx +++ b/src/PARTITION/Partition_Inter2d.cxx @@ -241,11 +241,14 @@ TopoDS_Vertex Partition_Inter2d::AddVonE(const TopoDS_Vertex& theV, if (!OnE1 && !OnE2 && !theF.IsNull()) { - // analitically find vertices E1 and E2 must pass trough + // if 3 faces intersects each others, 3 new edges on them must pass + // through one vertex but real intersection points of each + // pair of edges are sometimes more far than a tolerance. + // Try to analitically find vertices that E1 and E2 must pass trough TopoDS_Shape F1 = getOtherShape( theF, AsDes->Ascendant( E1 )); TopoDS_Shape F2 = getOtherShape( theF, AsDes->Ascendant( E2 )); - if (!F1.IsNull() && !F2.IsNull()) + if (!F1.IsNull() && !F2.IsNull() && !F1.IsSame( F2 )) { OnE1 = findVOnE ( theV, E1, E2, F1, F2, AsDes, V1 ); OnE2 = findVOnE ( theV, E2, E1, F1, F2, AsDes, V2 ); diff --git a/src/PARTITION/Partition_Inter3d.cxx b/src/PARTITION/Partition_Inter3d.cxx index 7724b73f1..e9bf649ce 100644 --- a/src/PARTITION/Partition_Inter3d.cxx +++ b/src/PARTITION/Partition_Inter3d.cxx @@ -67,7 +67,6 @@ using namespace std; #include #include #include -#include #include #include #include @@ -136,10 +135,10 @@ void Partition_Inter3d::CompletPart3d(const TopTools_ListOfShape& SetOfFaces1, // avoid intersecting faces of one shape TopoDS_Shape S1; if (FaceShapeMap.IsBound(F1)) S1 = FaceShapeMap.Find(F1); - // avoid intersecting faces sharing vertices, suppose they belong to - // shapes sharing same faces - TopTools_IndexedMapOfShape VM; - TopExp::MapShapes( F1, TopAbs_VERTEX, VM); + + // to filter faces sharing an edge + TopTools_IndexedMapOfShape EM; + TopExp::MapShapes( F1, TopAbs_EDGE, EM); TColStd_ListIteratorOfListOfInteger itLI = BOS.Compare(F1); for (; itLI.More(); itLI.Next()) { @@ -152,13 +151,22 @@ void Partition_Inter3d::CompletPart3d(const TopTools_ListOfShape& SetOfFaces1, if (!S1.IsNull() && S1.IsSame(S2)) continue; // descendants of one shape - TopExp_Explorer expV (F2, TopAbs_VERTEX); - for ( ; expV.More(); expV.Next()) - if (VM.Contains( expV.Current() )) + TopExp_Explorer expE (F2, TopAbs_EDGE); + for ( ; expE.More(); expE.Next()) + if (EM.Contains( expE.Current() )) break; - if (expV.More()) - continue; // faces have a common edge - + if (expE.More()) + { + // faces have a common edge, check if they are a tool and a face + // generated by the tool in another shape; in that case they are + // to be intersected + TopLoc_Location L1, L2; + Handle(Geom_Surface) S1 = BRep_Tool::Surface( F1, L1 ); + Handle(Geom_Surface) S2 = BRep_Tool::Surface( F2, L2 ); + if ( S1 != S2 || L1 != L2 ) + continue; + } + F1.Orientation(TopAbs_FORWARD); F2.Orientation(TopAbs_FORWARD); FacesPartition(F1,F2); @@ -210,8 +218,7 @@ static void PutInBounds (const TopoDS_Face& F, // UPeriodic, sometimes it is in domain but nontheless it has // wrong position. // Check pcurve position by 3D point - if (S->IsKind(STANDARD_TYPE( Geom_SphericalSurface )) || - S->IsKind(STANDARD_TYPE( Geom_ToroidalSurface ))) + if (S->IsKind(STANDARD_TYPE( Geom_SphericalSurface ))) { // get point on the surface gp_Pnt Ps = S->Value( Pm.X(), Pm.Y() ); @@ -472,11 +479,17 @@ void Partition_Inter3d::Inter3D(const TopoDS_Face& F1, TopoDS_Edge se = TopoDS::Edge( itLSE.Value() ); + // move itLSE to the next se Standard_Integer ancRank = DS.AncestorRank(se); if (ME[ancRank-1].Contains( se )) + { LSE.Remove( itLSE ); // se is an edge of face it intersects + continue; + } else + { itLSE.Next(); + } const TopoDS_Face& F = (ancRank == 1) ? F2 : F1; diff --git a/src/PARTITION/Partition_Spliter.cdl b/src/PARTITION/Partition_Spliter.cdl index 0fc9b5be5..75537b498 100644 --- a/src/PARTITION/Partition_Spliter.cdl +++ b/src/PARTITION/Partition_Spliter.cdl @@ -163,6 +163,7 @@ fields myEqualEdges : MapOfShape from TopTools; -- equal splits myNewSection : MapOfShape from TopTools; -- new secton edges myClosedShapes : MapOfShape from TopTools; + mySharedFaces : MapOfShape from TopTools; -- faces shared by several shapes myWrappingSolid: MapOfShape from TopTools; -- solids having other shapes inside myFaceShapeMap : DataMapOfShapeShape from TopTools; -- to find a shape by face diff --git a/src/PARTITION/Partition_Spliter.cxx b/src/PARTITION/Partition_Spliter.cxx index 8dd5d136d..dc4900963 100644 --- a/src/PARTITION/Partition_Spliter.cxx +++ b/src/PARTITION/Partition_Spliter.cxx @@ -208,9 +208,10 @@ void Partition_Spliter::Clear() myListShapes.Clear(); myMapFaces.Clear(); myMapTools.Clear(); - myClosedShapes.Clear(); myEqualEdges.Clear(); myNewSection.Clear(); + myClosedShapes.Clear(); + mySharedFaces.Clear(); myWrappingSolid.Clear(); myFaceShapeMap.Clear(); @@ -520,7 +521,8 @@ void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) MakeShells (S , NSL); if (makeSolids && S.ShapeType() == TopAbs_SOLID ) MakeSolids( S, NSL ); - + + // store new shells or solids TopTools_ListIteratorOfListOfShape itNSL (NSL); for ( ; itNSL.More(); itNSL.Next()) myBuilder.Add (myShape, itNSL.Value()); @@ -593,7 +595,7 @@ void Partition_Spliter::MakeSolids(const TopoDS_Shape & theSolid, } } - // find outer a shell most close to each hole shell + // find an outer shell most close to each hole shell TopTools_DataMapOfShapeShape aInOutMap; for (aShellIt.Initialize( aHoleShells ); aShellIt.More(); aShellIt.Next()) { @@ -913,42 +915,46 @@ TopoDS_Shape Partition_Spliter::FindFacesInside(const TopoDS_Shape& theShape, Standard_Boolean isSolid = (theShape.ShapeType() == TopAbs_SOLID); if (All || isSolid) // All is for sub-result removal { + // loop on not used faces; checked faces will be removed from MFP + // during the loop for ( itm.Initialize( MFP ); itm.More(); itm.Next() ) { - TopoDS_Shape aFace = itm.Key(); + const TopoDS_Shape & aFace = itm.Key(); - // find a shape aFace originates from + // a shape which aFace originates from TopoDS_Shape anOrigShape = GetOriginalShape( aFace ); - // find out if all faces of anOrigShape are not in MFP + // find out if all split faces of anOrigShape are not in MFP // and by the way remove them from MFP Standard_Boolean isAllOut = Standard_True; TopoDS_Shape aSplitFaces = anOrigShape; if (myImageShape.HasImage(anOrigShape)) aSplitFaces = myImageShape.Image(anOrigShape).First(); - TopTools_ListOfShape aSplitFaceL; + TopTools_ListOfShape aSplitFaceL; // faces candidate to be kept for (expl.Init( aSplitFaces, TopAbs_FACE ); expl.More(); expl.Next()) { const TopoDS_Shape & aSpFace = expl.Current(); - // a tool face which become object has image but the whole tool shape has not + // a tool face which became object has image but the whole tool shape has not if (myImageShape.HasImage( aSpFace )) { TopExp_Explorer exF (myImageShape.Image( aSpFace ).First(), TopAbs_FACE ); for ( ; exF.More(); exF.Next() ) { aSplitFaceL.Append( exF.Current() ); - if ( ! MFP.Remove( exF.Current() )) - isAllOut = Standard_False; + if ( ! MFP.Remove( exF.Current() ) && isAllOut ) + // a shared face might be removed from MFP during a prev loop + isAllOut = mySharedFaces.Contains( exF.Current() ); } } else { aSplitFaceL.Append( aSpFace ); - if ( ! MFP.Remove( aSpFace )) - isAllOut = Standard_False; + if ( ! MFP.Remove( aSpFace ) && isAllOut) + // a shared face might be removed from MFP during a prev loop + isAllOut = mySharedFaces.Contains( aSpFace ); } } - itm.Initialize( MFP ); + itm.Initialize( MFP ); // iterate remaining faces if ( !isAllOut ) continue; @@ -1301,15 +1307,17 @@ TopoDS_Shape Partition_Spliter::MakeFaces (const TopoDS_Shape& S) myImagesFaces.Bind(F,LNF); // replace the result faces that have already been built - // during same domain faces reconstruction - if (myInter3d.HasSameDomainF( F )) { - // build map edge to same domain faces + // during same domain faces reconstruction done earlier + if (myInter3d.HasSameDomainF( F )) + { + // build map edge to same domain faces: EFM TopTools_IndexedDataMapOfShapeListOfShape EFM; TopTools_MapOfShape SDFM; // avoid doubling itl.Initialize( myInter3d.SameDomain( F )); for (; itl.More(); itl.Next()) { if ( !myImagesFaces.HasImage( itl.Value() )) continue; + // loop on splits of a SD face TopTools_ListIteratorOfListOfShape itNF; itNF.Initialize (myImagesFaces.Image( itl.Value() )); for ( ; itNF.More(); itNF.Next()) { @@ -1320,7 +1328,7 @@ TopoDS_Shape Partition_Spliter::MakeFaces (const TopoDS_Shape& S) TopExp::MapShapesAndAncestors(SDF, TopAbs_EDGE, TopAbs_FACE, EFM); } } - // do replace + // do replace faces in the LNF TopTools_ListOfShape LOF; if ( !EFM.IsEmpty() ) itl.Initialize( LNF ); @@ -1335,13 +1343,15 @@ TopoDS_Shape Partition_Spliter::MakeFaces (const TopoDS_Shape& S) Standard_Real dot; Partition_Loop3d::IsInside (E, TopoDS::Face(NF), TopoDS::Face(SDF), 1, dot, GoodOri); - if (dot < 0) { + if (dot < 0) + { + // NF and SDF are on different side of E if (SDFL.Extent() == 1) { itl.Next(); continue; } else - SDF = SDFL.Last(); + SDF = SDFL.Last(); // next face must be on the same side } gp_Vec V1 = Partition_Loop3d::Normal( E, TopoDS::Face( NF )); gp_Vec V2 = Partition_Loop3d::Normal( E, TopoDS::Face( SDF )); @@ -1351,6 +1361,9 @@ TopoDS_Shape Partition_Spliter::MakeFaces (const TopoDS_Shape& S) if (!myImagesFaces.HasImage( NF )) myImagesFaces.Bind( NF, SDF ); + // mySharedFaces is used in FindFacesInside() + mySharedFaces.Add( SDF ); + LOF.Prepend ( SDF ); LNF.Remove (itl); } @@ -1367,9 +1380,11 @@ TopoDS_Shape Partition_Spliter::MakeFaces (const TopoDS_Shape& S) myImagesFaces.Bind(F,LNF); } } // if (myImagesFaces.HasImage( F )) - + + // fill the resulting compound for (itl.Initialize(LNF); itl.More(); itl.Next()) myBuilder.Add ( C, itl.Value()); + } // loop on faces of S return C; diff --git a/src/PARTITION/Partition_Spliter.hxx b/src/PARTITION/Partition_Spliter.hxx index 61700cecb..2f9e102bb 100644 --- a/src/PARTITION/Partition_Spliter.hxx +++ b/src/PARTITION/Partition_Spliter.hxx @@ -124,6 +124,7 @@ TopTools_MapOfShape myMapTools; TopTools_MapOfShape myEqualEdges; TopTools_MapOfShape myNewSection; TopTools_MapOfShape myClosedShapes; +TopTools_MapOfShape mySharedFaces; TopTools_MapOfShape myWrappingSolid; TopTools_DataMapOfShapeShape myFaceShapeMap; TopTools_DataMapOfShapeShape myInternalFaces;