// Created on: 2001-11-26 // Created by: Sergey ZARITCHNY // Copyright (c) 2001-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public // License Version 6.5 (the "License"). You may not use the content of this file // except in compliance with the License. Please obtain a copy of the License // at http://www.opencascade.org and read it completely before using this file. // // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. // // The Original Code and all software distributed under the License is // distributed on an "AS IS" basis, without warranty of any kind, and the // Initial Developer 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 the rights and limitations under the License. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEB #include #endif #define SOURCES_SUBLABEL 1 //======================================================================= //function : QANewBRepNaming_Gluing //purpose : //======================================================================= QANewBRepNaming_Gluing::QANewBRepNaming_Gluing() {} //======================================================================= //function : QANewBRepNaming_Gluing //purpose : //======================================================================= QANewBRepNaming_Gluing::QANewBRepNaming_Gluing(const TDF_Label& ResultLabel):QANewBRepNaming_TopNaming(ResultLabel) {} //======================================================================= //function : Init //purpose : //======================================================================= void QANewBRepNaming_Gluing::Init(const TDF_Label& ResultLabel) { if(ResultLabel.IsNull()) Standard_NullObject::Raise("QANewBRepNaming_Gluing::Init The Result label is Null ..."); myResultLabel = ResultLabel; } //======================================================================= //function : Load //purpose : //======================================================================= void QANewBRepNaming_Gluing::Load(QANewModTopOpe_Glue& theMkGluing) { TopoDS_Shape aResShape = theMkGluing.Shape(); const TopoDS_Shape& anObjShape = theMkGluing.Shape1(); const TopoDS_Shape& aToolShape = theMkGluing.Shape2(); const TopAbs_ShapeEnum& anObjectType = ShapeType(anObjShape); if (aResShape.IsNull()) { #ifdef MDTV_DEB cout<<"QANewBRepNaming_Gluing::Load(): The result of the Gluing operation is null"<Set(0); TNaming_Builder aBuilder (ResultLabel()); TopoDS_Shape aResult = theMkGluing.Shape(); if (aResult.ShapeType() == TopAbs_COMPOUND) { Standard_Integer aNbSubResults = 0; TopoDS_Iterator anItr(aResult); for (; anItr.More(); anItr.Next()) aNbSubResults++; if (aNbSubResults == 1) { anItr.Initialize(aResult); if (anItr.More()) aResult = anItr.Value(); } } if (theMkGluing.Shape1().IsNull()) aBuilder.Generated(aResult); else { aBuilder.Generated(theMkGluing.Shape1(), aResult); // mpv:? } } //======================================================================= //function : IsResultChanged //purpose : //======================================================================= Standard_Boolean QANewBRepNaming_Gluing::IsResultChanged(QANewModTopOpe_Glue& theMkGluing) const { TopoDS_Shape aResShape = theMkGluing.Shape(); if (theMkGluing.Shape().ShapeType() == TopAbs_COMPOUND) { Standard_Integer aNbSubResults = 0; TopoDS_Iterator anItr(theMkGluing.Shape()); for (; anItr.More(); anItr.Next()) aNbSubResults++; if (aNbSubResults == 1) { anItr.Initialize(theMkGluing.Shape()); if (anItr.More()) aResShape = anItr.Value(); } } return theMkGluing.Shape1().IsSame(aResShape); } //======================================================================= //function : LoadModifiedShapes //purpose : //======================================================================= void QANewBRepNaming_Gluing::LoadModifiedShapes(QANewModTopOpe_Glue& theMkGluing) const { const Standard_Integer aNumTypes = 1; const TopAbs_ShapeEnum aTypes[] = {TopAbs_FACE/*,TopAbs_EDGE,TopAbs_VERTEX*/}; #ifdef MDTV_DEB const char aNames[][20] = {"ModifiedFaces"/*,"ModifiedEdges","ModifiedVertexes"*/}; #endif Standard_Integer aShapeNum; TDF_Label aLabel = ResultLabel().FindChild(1,Standard_True); Handle(TNaming_NamedShape) aNS; while(aLabel.FindAttribute(TNaming_NamedShape::GetID(),aNS)) { if (aNS->Evolution() == TNaming_MODIFY) break; aLabel = aLabel.Father().FindChild(aLabel.Tag()+1,Standard_True); } for(Standard_Integer a=0;aAppend(theIdentifier); myUnique.Add(theUnique, *aNewList); } else { myUnique.ChangeFromKey(theUnique).Append(theIdentifier); } } //======================================================================= //function : RecomputeUnique //purpose : //======================================================================= void QANewBRepNaming_Gluing::RecomputeUnique(QANewModTopOpe_Glue& theMkGluing) { const Standard_Integer aNumTypes = 3; const TopAbs_ShapeEnum aTypes[] = {TopAbs_FACE,TopAbs_EDGE,TopAbs_VERTEX}; // special case: edges may be divided, these edges (new and modified) // we try to sort in the algorithm returned lists order myUnique.Clear(); Standard_Integer aNext; TopExp_Explorer anExp(myContext, TopAbs_EDGE); TopTools_ListIteratorOfListOfShape anEdgesIterator; for(;anExp.More();anExp.Next()) { for(aNext=0;aNext<2;aNext++) { TopoDS_Edge aFullEdge = TopoDS::Edge(anExp.Current()); if (aNext == 0) anEdgesIterator.Initialize(theMkGluing.Generated(aFullEdge)); else anEdgesIterator.Initialize(theMkGluing.Modified(aFullEdge)); for (;anEdgesIterator.More();anEdgesIterator.Next()) if (anEdgesIterator.Value().ShapeType() == TopAbs_EDGE) { TopoDS_Edge aDivEdge = TopoDS::Edge(anEdgesIterator.Value()); if (!TopExp::FirstVertex(aDivEdge).IsNull()) { // divided edge must have at least one vertex if (TopExp::FirstVertex(aFullEdge).IsNull()) AddToTheUnique(aDivEdge,aFullEdge); else if (!TopExp::LastVertex(aDivEdge).IsNull())//if full edge have at least one vertex, subedges must have two if (TopExp::LastVertex(aFullEdge).IsNull()) { if (BRep_Tool::Pnt(TopExp::FirstVertex(aFullEdge)). IsEqual(BRep_Tool::Pnt(TopExp::FirstVertex(aDivEdge)),Precision::Confusion())) AddToTheUnique(aDivEdge,aFullEdge); else if (BRep_Tool::Pnt(TopExp::FirstVertex(aFullEdge)). IsEqual(BRep_Tool::Pnt(TopExp::LastVertex(aDivEdge)),Precision::Confusion())) AddToTheUnique(aDivEdge,aFullEdge); } else { Standard_Integer aCounter = 0; if (BRep_Tool::Pnt(TopExp::FirstVertex(aFullEdge)). IsEqual(BRep_Tool::Pnt(TopExp::FirstVertex(aDivEdge)),Precision::Confusion()) || BRep_Tool::Pnt(TopExp::FirstVertex(aFullEdge)). IsEqual(BRep_Tool::Pnt(TopExp::LastVertex(aDivEdge)),Precision::Confusion())) aCounter++; if (BRep_Tool::Pnt(TopExp::LastVertex(aFullEdge)). IsEqual(BRep_Tool::Pnt(TopExp::FirstVertex(aDivEdge)),Precision::Confusion()) || BRep_Tool::Pnt(TopExp::LastVertex(aFullEdge)). IsEqual(BRep_Tool::Pnt(TopExp::LastVertex(aDivEdge)),Precision::Confusion())) aCounter++; if (aCounter!=2) AddToTheUnique(aDivEdge,aFullEdge); } } } } } aNext = 2; Standard_Integer aDividedIndex = myUnique.Extent();; // accumulate all shapes, modifyed from shape1 while(aNext) { for(Standard_Integer a=0;aSet(0); // get all source shapes (in the given order) TopTools_MapOfShape aShapes; TopTools_ListOfShape aSortedShapes; Standard_Integer anIndex; for(anIndex=1;anIndex<=myUnique.Extent();anIndex++) { TopTools_ListIteratorOfListOfShape anIter2(myUnique.FindFromIndex(anIndex)); for(;anIter2.More();anIter2.Next()) { if (!aShapes.Contains(anIter2.Value())) { aShapes.Add(anIter2.Value()); aSortedShapes.Append(anIter2.Value()); } } } // put all source shapes to the sources label sublabels TopTools_ListIteratorOfListOfShape aSortedIterator(aSortedShapes); for(aLabel = aLabel.NewChild();aShapes.Extent();aLabel = aLabel.Father().NewChild()) { Handle(TNaming_NamedShape) aNS; if (aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { // old shape resolving TDF_LabelMap aValid; aValid.Assign(myLog); TNaming_Selector aSel(aLabel); aSel.Solve(aValid); TopoDS_Shape aShape = aSel.NamedShape()->Get(); if (aShapes.Contains(aShape)) { theSources.Bind(aShape,aLabel.Tag()); aShapes.Remove(aShape); } } else { // add new shape for(;aSortedIterator.More();aSortedIterator.Next()) { TopoDS_Shape aShape = aSortedIterator.Value();; if (aShapes.Contains(aShape)) { theSources.Bind(aShape,aLabel.Tag()); aShapes.Remove(aShape); TNaming_Selector aSelector(aLabel); if (!aSelector.Select(aShape,myContext)) { #ifdef MDTV_DEB cout<<"Can't do naming"<Evolution() == TNaming_MODIFY) continue; Handle(TDataStd_IntegerArray) anArray; if (aLabel.FindAttribute(TDataStd_IntegerArray::GetID(),anArray)) { // old unique with dependencies Standard_Integer a; for(a = anIndex;a<=myUnique.Extent();a++) { if (alreadyUsed.Contains(a)) continue; if (myUnique.FindFromIndex(a).Extent()!=anArray->Upper()) continue; // cout<<"a="<Upper();a1>=1;a1--) if (anArray->Value(a1) == aValue) break; if (a1 == 0) aEq = Standard_False; } // cout<<"eq="< 1) { for (itr.Initialize(MS.Shape()); itr.More(); itr.Next()) { TNaming_Builder bContent(Content()); bContent.Generated(itr.Value()); } } } }