diff --git a/src/BinMNaming/BinMNaming_NamedShapeDriver.cxx b/src/BinMNaming/BinMNaming_NamedShapeDriver.cxx index 98c75245f3..30d6351e0e 100755 --- a/src/BinMNaming/BinMNaming_NamedShapeDriver.cxx +++ b/src/BinMNaming/BinMNaming_NamedShapeDriver.cxx @@ -42,7 +42,7 @@ static Standard_Character EvolutionToChar(const TNaming_Evolution theEvol) case TNaming_MODIFY : return 'M'; case TNaming_DELETE : return 'D'; case TNaming_SELECTED : return 'S'; - case TNaming_REPLACE : return 'R'; + // case TNaming_REPLACE : return 'R'; default: Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown"); } @@ -58,7 +58,7 @@ static TNaming_Evolution EvolutionToEnum(const Standard_Character theEvol) case 'M': return TNaming_MODIFY; case 'D': return TNaming_DELETE; case 'S': return TNaming_SELECTED; - case 'R': return TNaming_REPLACE; + case 'R': return TNaming_MODIFY; //for compatibility //TNaming_REPLACE; default: Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown"); } @@ -211,9 +211,9 @@ Standard_Boolean BinMNaming_NamedShapeDriver::Paste case TNaming_SELECTED : aBuilder.Select(aNewShape, anOldShape); break; - case TNaming_REPLACE : - aBuilder.Replace(anOldShape, aNewShape); - break; + // case TNaming_REPLACE : + // aBuilder.Replace(anOldShape, aNewShape); + // break; default : Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown"); } diff --git a/src/BinMNaming/BinMNaming_NamingDriver.cxx b/src/BinMNaming/BinMNaming_NamingDriver.cxx index 15817ce884..9484c8d58c 100755 --- a/src/BinMNaming/BinMNaming_NamingDriver.cxx +++ b/src/BinMNaming/BinMNaming_NamingDriver.cxx @@ -56,6 +56,7 @@ static Standard_Character NameTypeToChar(const TNaming_NameType theNameType) case TNaming_FILTERBYNEIGHBOURGS : return 'F'; case TNaming_ORIENTATION : return 'O'; case TNaming_WIREIN : return 'W'; + case TNaming_SHELLIN : return 'H'; default: Standard_DomainError::Raise("TNaming_NameType:: Name Type Unknown"); } @@ -77,6 +78,7 @@ static TNaming_NameType CharTypeToName(const Standard_Character theCharType) case 'F' : return TNaming_FILTERBYNEIGHBOURGS; case 'O' : return TNaming_ORIENTATION; case 'W' : return TNaming_WIREIN; + case 'H' : return TNaming_SHELLIN; default: Standard_DomainError::Raise("TNaming_NameType:: Name Type Unknown"); } diff --git a/src/MNaming/MNaming_NamedShapeRetrievalDriver.cxx b/src/MNaming/MNaming_NamedShapeRetrievalDriver.cxx index 91ad6cba3a..4cb3628f53 100755 --- a/src/MNaming/MNaming_NamedShapeRetrievalDriver.cxx +++ b/src/MNaming/MNaming_NamedShapeRetrievalDriver.cxx @@ -150,7 +150,8 @@ void MNaming_NamedShapeRetrievalDriver::Paste ( Bld.Select(NewShape, OldShape); break; } case TNaming_REPLACE :{ - Bld.Replace(OldShape,NewShape); break; + //Bld.Replace(OldShape,NewShape); break; + Bld.Modify(OldShape,NewShape); break;// for compatibility only } default : Standard_DomainError::Raise("TNaming_Evolution; enum term unknown"); diff --git a/src/MNaming/MNaming_NamedShapeStorageDriver.cxx b/src/MNaming/MNaming_NamedShapeStorageDriver.cxx index 7ee7dc3372..84ee517c61 100755 --- a/src/MNaming/MNaming_NamedShapeStorageDriver.cxx +++ b/src/MNaming/MNaming_NamedShapeStorageDriver.cxx @@ -158,7 +158,7 @@ Standard_Integer EvolutionInt(const TNaming_Evolution i) case TNaming_MODIFY : return 2; case TNaming_DELETE : return 3; case TNaming_SELECTED : return 4; - case TNaming_REPLACE : return 5; + //case TNaming_REPLACE : return 5; default: Standard_DomainError::Raise("TNaming_Evolution; enum term unknown"); } diff --git a/src/MNaming/MNaming_NamingRetrievalDriver.cxx b/src/MNaming/MNaming_NamingRetrievalDriver.cxx index 04ca82370b..508cb22977 100755 --- a/src/MNaming/MNaming_NamingRetrievalDriver.cxx +++ b/src/MNaming/MNaming_NamingRetrievalDriver.cxx @@ -73,6 +73,9 @@ static TNaming_NameType IntegerToNameType (const Standard_Integer I) case 6 : return TNaming_SUBSTRACTION; case 7 : return TNaming_CONSTSHAPE; case 8 : return TNaming_FILTERBYNEIGHBOURGS; + case 9 : return TNaming_ORIENTATION; + case 10: return TNaming_WIREIN; + case 11: return TNaming_SHELLIN; default : Standard_DomainError::Raise("TNaming_NameType; enum term unknown "); } diff --git a/src/MNaming/MNaming_NamingStorageDriver.cxx b/src/MNaming/MNaming_NamingStorageDriver.cxx index 11962f09f5..5836c08b3f 100755 --- a/src/MNaming/MNaming_NamingStorageDriver.cxx +++ b/src/MNaming/MNaming_NamingStorageDriver.cxx @@ -78,6 +78,7 @@ static Standard_Integer NameTypeToInteger (const TNaming_NameType I) case TNaming_FILTERBYNEIGHBOURGS : return 8; case TNaming_ORIENTATION : return 9; case TNaming_WIREIN : return 10; + case TNaming_SHELLIN : return 11; default : Standard_DomainError::Raise("TNaming_NameType; enum term unknown "); } diff --git a/src/QADNaming/QADNaming_BuilderCommands.cxx b/src/QADNaming/QADNaming_BuilderCommands.cxx index 0b2d395499..75c3977f07 100755 --- a/src/QADNaming/QADNaming_BuilderCommands.cxx +++ b/src/QADNaming/QADNaming_BuilderCommands.cxx @@ -63,7 +63,8 @@ static Standard_Integer BuildNamedShape (Draw_Interpretor& di, aBuilder.Delete(aShape1); break; case 'R': - aBuilder.Replace(aShape1,aShape2); +// aBuilder.Replace(aShape1,aShape2); + aBuilder.Modify(aShape1,aShape2); break; case 'S': aBuilder.Select(aShape1,aShape2); diff --git a/src/QADNaming/QADNaming_IteratorsCommands.cxx b/src/QADNaming/QADNaming_IteratorsCommands.cxx index aa4bcd71e6..cc6104438c 100755 --- a/src/QADNaming/QADNaming_IteratorsCommands.cxx +++ b/src/QADNaming/QADNaming_IteratorsCommands.cxx @@ -50,8 +50,8 @@ static const char* EvolutionString(TNaming_Evolution theEvolution) { return "DELETE"; case TNaming_SELECTED : return "SELECTED"; - case TNaming_REPLACE : - return "REPLACE"; +// case TNaming_REPLACE : +// return "REPLACE"; } return "UNKNOWN_Evolution"; } diff --git a/src/QANewBRepNaming/QANewBRepNaming.cxx b/src/QANewBRepNaming/QANewBRepNaming.cxx index 30190b4fa9..715eac0dbe 100755 --- a/src/QANewBRepNaming/QANewBRepNaming.cxx +++ b/src/QANewBRepNaming/QANewBRepNaming.cxx @@ -88,11 +88,11 @@ void QANewBRepNaming::LoadNamedShape (TNaming_Builder& theBuilder, theBuilder.Modify(theOS, theNS); break; } - case TNaming_REPLACE : - { - theBuilder.Replace(theOS, theNS); - break; - } +// case TNaming_REPLACE : +// { +// theBuilder.Replace(theOS, theNS); +// break; +// } case TNaming_DELETE : { theBuilder.Delete (theOS); diff --git a/src/TKCAF/EXTERNLIB b/src/TKCAF/EXTERNLIB index 5aa8272176..3fb4b53bf7 100755 --- a/src/TKCAF/EXTERNLIB +++ b/src/TKCAF/EXTERNLIB @@ -10,3 +10,4 @@ TKV2d TKCDF TKLCAF TKV3d +TKBO diff --git a/src/TNaming/TNaming.cdl b/src/TNaming/TNaming.cdl index 60fcea229a..ae3d5da455 100755 --- a/src/TNaming/TNaming.cdl +++ b/src/TNaming/TNaming.cdl @@ -209,7 +209,8 @@ is CONSTSHAPE, FILTERBYNEIGHBOURGS, ORIENTATION, - WIREIN + WIREIN, + SHELLIN end NameType; class Name; @@ -353,7 +354,17 @@ is To : in out Shape from TopoDS) returns Boolean from Standard; ---Purpose: Subtitutes shape in source structure + + + OuterWire(theFace: Face from TopoDS; theWire: out Wire from TopoDS) + returns Boolean from Standard; + --- Purpose: Returns True if outer wire is found and the found wire in . + OuterShell(theSolid: Solid from TopoDS; theShell: out Shell from TopoDS) + returns Boolean from Standard; + --- Purpose: Returns True if outer Shell is found and the found shell in . + + ---Purpose: Print of TNaming enumeration -- ============================= diff --git a/src/TNaming/TNaming.cxx b/src/TNaming/TNaming.cxx index 76e2287fe5..c252268d88 100755 --- a/src/TNaming/TNaming.cxx +++ b/src/TNaming/TNaming.cxx @@ -52,6 +52,9 @@ #include #include +#include +#include + // CopyShape #include #include @@ -388,6 +391,7 @@ static void LoadNamedShape (TNaming_Builder& B, case TNaming_SELECTED : { B.Select(NS,OS); + break; } default: break; @@ -736,6 +740,10 @@ Standard_OStream& TNaming::Print (const TNaming_NameType NAME, Standard_OStream case TNaming_WIREIN: { s <<"WIREIN"; break; + } + case TNaming_SHELLIN: + { + s <<"SHELLIN"; break; } default : { @@ -945,6 +953,95 @@ TopoDS_Shape TNaming::FindUniqueContextSet(const TopoDS_Shape& Selection, const return TopoDS_Shape(); } +//======================================================================= +//function : OuterWire +//purpose : Returns True & if Outer wire is found. +//======================================================================= +Standard_Boolean TNaming::OuterWire(const TopoDS_Face& theFace, TopoDS_Wire& theWire) +{ + TopoDS_Face aFx; + TopoDS_Wire aWx; + BRep_Builder aBB; + IntTools_FClass2d aFC; + Standard_Boolean bFlag(Standard_False); + Standard_Real aTol = BRep_Tool::Tolerance(theFace); + TopoDS_Iterator aIt(theFace); + for (; aIt.More(); aIt.Next()) { + aWx=*((TopoDS_Wire*)&aIt.Value()); + aFx = theFace; + aFx.EmptyCopy(); + aBB.Add(aFx, aWx); + aFC.Init(aFx, aTol); + bFlag = aFC.IsHole(); + if (!bFlag) + break; + } + theWire=aWx; + return !bFlag;// if bFlag == True - not found +} +//======================================================================= +//function : IsInternal +//purpose : +//======================================================================= +static Standard_Boolean IsInternal(const TopoDS_Shape& aSx) +{ + Standard_Boolean bInternal; + TopAbs_Orientation aOr; + TopoDS_Iterator aIt; + bInternal = Standard_False; + aIt.Initialize(aSx); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSy=aIt.Value(); + aOr=aSy.Orientation(); + bInternal = (aOr == TopAbs_INTERNAL || aOr == TopAbs_EXTERNAL); + break; + } + return bInternal; +} +//======================================================================= +//function : OuterShell +//purpose : returns True & , if Outer shell is found +//======================================================================= +Standard_Boolean TNaming::OuterShell(const TopoDS_Solid& theSolid, + TopoDS_Shell& theShell) +{ + TopoDS_Solid aSDx; + TopoDS_Shell aSHx; + TopAbs_State aState; + Standard_Boolean bFound(Standard_False); + Standard_Real aTol(1.e-7); + // + BRep_Builder aBB; + BRepClass3d_SolidClassifier aSC; + TopoDS_Iterator aIt(theSolid); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx = aIt.Value(); + + if (aSx.ShapeType() != TopAbs_SHELL) + continue; + if (IsInternal(aSx)) + continue; + // + aSHx = *((TopoDS_Shell*)&aSx); + // + aSDx = theSolid; + aSDx.EmptyCopy(); + // + aBB.Add(aSDx, aSHx); + // + aSC.Load(aSDx); + //BRepClass3d_SolidClassifier& aSC=aCtx.SolidClassifier(aSDx); + aSC.PerformInfinitePoint(aTol); + aState = aSC.State(); + if(aState == TopAbs_OUT) { + bFound = Standard_True; + break; + } + } + theShell = aSHx; + + return bFound; +} diff --git a/src/TNaming/TNaming_Builder.cdl b/src/TNaming/TNaming_Builder.cdl index 3bfc69f4f6..d869b74ca6 100755 --- a/src/TNaming/TNaming_Builder.cdl +++ b/src/TNaming/TNaming_Builder.cdl @@ -78,16 +78,6 @@ is -- or merged in a Boolean operation. -- - ---Category: Load changes - -- - Replace (me : in out; oldShape, newShape : Shape from TopoDS); - ---Purpose: Records the shape newShape which is a - -- modification of the shape oldShape but has a - -- different geometry as a result of the construction operation. - -- As an example, consider the case of a face - -- resulting from construction of a draft in a box or prism. - - ---Category: Load Selection. Select (me : in out; aShape, inShape : Shape from TopoDS); ---Purpose: Add a Shape to the current label , This Shape is diff --git a/src/TNaming/TNaming_DeltaOnModification.cxx b/src/TNaming/TNaming_DeltaOnModification.cxx index 6465bc7d4e..a12520f06d 100755 --- a/src/TNaming/TNaming_DeltaOnModification.cxx +++ b/src/TNaming/TNaming_DeltaOnModification.cxx @@ -102,11 +102,6 @@ static void LoadNamedShape (TNaming_Builder& B, B.Select(NS,OS); break; } - case TNaming_REPLACE : - { - B.Replace(OS,NS); - break; - } } } diff --git a/src/TNaming/TNaming_Name.cxx b/src/TNaming/TNaming_Name.cxx index ce984cd5e5..bb59d713ea 100755 --- a/src/TNaming/TNaming_Name.cxx +++ b/src/TNaming/TNaming_Name.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -83,6 +84,8 @@ //#define MDTV_DEB_MODUN //#define MDTV_DEB_FNB //#define MDTV_DEB_WIN +//#define MDTV_DEB_ARG +//#define MDTV_DEB_SHELL #ifdef MDTV_DEB #include #include @@ -113,7 +116,6 @@ void PrintEntries(const TDF_LabelMap& map) } } -#include //======================================================================= static void DbgTools_Write(const TopoDS_Shape& shape, const Standard_CString filename) @@ -180,14 +182,14 @@ static Standard_Boolean ValidArgs(const TNaming_ListOfNamedShape& Args) for (;it.More();it.Next()) { const Handle(TNaming_NamedShape)& aNS = it.Value(); if(aNS.IsNull()) { -#ifdef MDTV_DEB +#ifdef MDTV_DEB_ARG cout << "ValidArgs:: NS (Naming argument) is NULL" <IsEmpty()) { -#ifdef MDTV_DEB +#ifdef MDTV_DEB_ARG TCollection_AsciiString entry; TDF_Tool::Entry(aNS->Label(), entry); cout << "ValidArgs:: Empty NS, Label = " << entry <IsValid()) { -#ifdef MDTV_DEB +#ifdef MDTV_DEB_ARG TCollection_AsciiString entry; TDF_Tool::Entry(aNS->Label(), entry); cout << "ValidArgs::Not valid NS Label = " << entry <Label()); +#endif Standard_Boolean found = Standard_False; for (; it.More(); it.Next()) { if (!it.Shape().IsNull()) { +#ifdef MDTV_DEB_MODUN + if(!it.NamedShape().IsNull()) + PrintEntry(it.NamedShape()->Label()); +#endif if (it.NamedShape() == Context) { MS.Add(S); found = Standard_True; @@ -557,13 +567,16 @@ static void SearchModifUntil (const TDF_LabelMap& /*Valid*/, Standard_Integer k = 0; TCollection_AsciiString aNam1 = aGen1 + i + Und + j + ".brep"; DbgTools_Write(S, aNam1.ToCString()); + PrintEntry(aNS->Label());//NSLabel #endif - for (TNaming_Iterator itC (Target); itC.More(); itC.Next()) { // <- generated + TNaming_Iterator itC (Target); + for (; itC.More(); itC.Next()) { // <- generated const TopoDS_Shape& OS = itC.OldShape(); #ifdef MDTV_DEB_MODUN k++; TCollection_AsciiString aNam2 = aGen2 + i + Und + j + Und + k + ".brep"; DbgTools_Write(OS, aNam2.ToCString()); + PrintEntry(Target->Label());//Target Label #endif if (OS.IsSame(S)) { theMS.Add(S); @@ -1837,78 +1850,283 @@ static Standard_Boolean ORientation (const TDF_Label& L, //=========================================================================== //function : WireIN -//purpose : to solve WIREIN name; Index for case if the Face has several wires +//purpose : to solve WIREIN name //======================================================================= static Standard_Boolean WireIN(const TDF_Label& L, const TDF_LabelMap& Valid, - const TNaming_ListOfNamedShape& Args, - const Standard_Integer Index) + const TNaming_ListOfNamedShape& Args, + const Handle(TNaming_NamedShape)& Stop, + Standard_Integer Index) { Standard_Boolean aResult(Standard_False); if(!ValidArgs(Args)) return aResult; TopTools_MapOfShape MS; TDF_LabelMap Forbiden; - if (Args.Extent() != 1 ) + if (Args.Extent() < 1 ) Standard_ConstructionError::Raise("TNaming_Name::Solve"); - const Handle(TNaming_NamedShape)& A = Args.Last(); + const Handle(TNaming_NamedShape)& A = Args.First(); TNaming_NamingTool::CurrentShape (Valid,Forbiden,A,MS); + if (MS.Extent() != 1) return aResult; + TopTools_MapIteratorOfMapOfShape itM(MS); + const TopoDS_Shape& aCF = itM.Key() ; #ifdef MDTV_DEB_WIN cout <<"MS Extent = " < 0) { - indx = Index & 0x000000FF; - num = (Index & 0x0000FF00) >> 8; -#ifdef MDTV_DEB_WIN - cout <<"Kept indx = " << indx <<" maxNum" << num << endl; -#endif - } TNaming_Builder B(L); - for (TopTools_MapIteratorOfMapOfShape itM(MS); itM.More(); itM.Next()) { - const TopoDS_Shape& S = itM.Key() ; -#ifdef MDTV_DEB_WIN - if(!S.IsNull()) { - DbgTools_Write(S, "WireIN_S.brep"); - cout <<"WIREIN: ShapeType = " << S.ShapeType() << " TS = " << S.TShape()->This() < 0) { - if(num == aNum) aCase = 1;//exact solution - else if(aNum == 1) aCase = 2;// possible merge of initial wires - else aCase = 3; // indefinite description ==> compound which can include expected wire - } - - Standard_Integer i(0); - for (it2.Initialize(S);it2.More();it2.Next()) { -#ifdef MDTV_DEB_WIN - if(!it2.Value().IsNull()) { - DbgTools_Write(it2.Value(), "WireIN_it2Value.brep"); - cout <<"WIREIN: ShapeType = " << it2.Value().ShapeType() << " TS = " << it2.Value().TShape()->This() < 0 ) { //szy 26/03/10 - if(aCase == 1) { - if(i == indx) { - aResult = Standard_True; - B.Select(it2.Value(),it2.Value()); - break; - } - } else { - B.Select(it2.Value(),it2.Value()); - aResult = Standard_True; - } - } - else { - B.Select(it2.Value(),it2.Value()); + if(Index == 1 ){ //Outer wire case + TopoDS_Wire anOuterWire; + TNaming::OuterWire(TopoDS::Face(aCF), anOuterWire); + if(!anOuterWire.IsNull()) { + B.Select(anOuterWire, anOuterWire); aResult = Standard_True; } - } + } else { //has internal wires + TNaming_ListOfNamedShape ArgsE; + ArgsE.Assign(Args); + ArgsE.RemoveFirst(); + // fill Map with edges + TNaming_ListIteratorOfListOfNamedShape it(ArgsE); + TopTools_MapOfShape MS; + TDF_LabelMap Forbiden; + + TNaming_NamingTool::BuildDescendants (Stop, Forbiden);//fill Forbidden + TNaming_NamingTool::CurrentShape (Valid, Forbiden,it.Value(),MS); // fill MS with last modifications of the first additional argument + TopoDS_Shape CS = MakeShape(MS); + + TNaming_ShapesSet aSet(CS,TopAbs_EDGE);//fill internal map of shapeset by shapes of the specified type +#ifdef MDTV_DEB_WIN + TCollection_AsciiString entry; + TDF_Tool::Entry(it.Value()->Label(), entry); + TCollection_AsciiString Nam("Arg_"); + TCollection_AsciiString aNam = Nam + entry + "_" + "2.brep"; + DbgTools_Write(CS, aNam.ToCString()); + Standard_Integer ii = 2; +#endif + it.Next(); + for (; it.More(); it.Next()) { +#ifdef MDTV_DEB_WIN + TDF_Tool::Entry(it.Value()->Label(), entry); +#endif + MS.Clear(); + TNaming_NamingTool::CurrentShape (Valid, Forbiden,it.Value(),MS);// fill MS with last modifications of the it.Value() + CS = MakeShape(MS); + TNaming_ShapesSet OS(CS,TopAbs_EDGE); + aSet.Add(OS); //concatenate both shapesets + +#ifdef MDTV_DEB_WIN + ii++; + TCollection_AsciiString aNm = Nam + entry + "_" + ii + ".brep"; + DbgTools_Write(CS, aNm.ToCString()); + cout <<"Arg: Entry = " <Label(), entry); + TCollection_AsciiString Nam("Arg_"); + TCollection_AsciiString aNam = Nam + entry + "_" + "2.brep"; + DbgTools_Write(CS, aNam.ToCString()); + Standard_Integer ii = 2; +#endif + it.Next(); + for (; it.More(); it.Next()) { +#ifdef MDTV_DEB_SHELL + TDF_Tool::Entry(it.Value()->Label(), entry); +#endif + MS.Clear(); + TNaming_NamingTool::CurrentShape (Valid, Forbiden,it.Value(),MS);// fill MS with last modifications of the it.Value() + CS = MakeShape(MS); + TNaming_ShapesSet OS(CS,TopAbs_FACE); + aSet.Add(OS); //concatenate both shapesets + +#ifdef MDTV_DEB_SHELL + ii++; + TCollection_AsciiString aNm = Nam + entry + "_" + ii + ".brep"; + DbgTools_Write(CS, aNm.ToCString()); + cout <<"Arg: Entry = " <myNode == 0L) myAtt->myEvolution = TNaming_REPLACE; - else { - if (myAtt->myEvolution != TNaming_REPLACE) - Standard_ConstructionError::Raise("TNaming_Builder : not same evolution"); - } - - if (oldShape.IsSame(newShape)) { -#ifdef DEB - cout <<"TNaming_Builder::Modify : oldShape IsSame newShape"<IsBound(oldShape)) { - pos = new TNaming_RefShape(oldShape); - myMap->Bind(oldShape,pos); - } - else - pos = myMap->ChangeFind(oldShape); - - TNaming_RefShape* pns; - if (!myMap->IsBound(newShape)) { - pns = new TNaming_RefShape(newShape); - myMap->Bind(newShape,pns); - } - else - pns = myMap->ChangeFind(newShape); - - TNaming_Node* pdn = new TNaming_Node(pos,pns); - myAtt->Add(pdn); - UpdateFirstUseOrNextSameShape (pos,pdn); - UpdateFirstUseOrNextSameShape (pns,pdn); - -} - //======================================================================= static const TopoDS_Shape& DummyShapeToStoreOrientation (const TopAbs_Orientation Or) { @@ -1720,59 +1677,3 @@ Standard_Integer TNaming_Tool::ValidUntil (const TopoDS_Shape& S, } return Until; } - - -//======================================================================= -//function : OldPaste -//purpose : -//======================================================================= - -void TNaming_NamedShape::OldPaste(const Handle(TDF_Attribute)& into, - const Handle(TDF_RelocationTable)& /*Tab*/) -const -{ - TDF_Label Lab = into->Label(); - if (Lab.IsNull()) { - Standard_NullObject::Raise("TNaming_NamedShape::Paste"); - } - //TDF_Insertor Ins(Lab); - //TNaming_Builder B(Ins); - TNaming_Builder B(Lab); - - TNaming_Iterator It (this); - for ( ;It.More() ; It.Next()) { - const TopoDS_Shape& OS = It.OldShape(); - const TopoDS_Shape& NS = It.NewShape(); - TNaming_Evolution Status = It.Evolution(); - switch (Status) { - case TNaming_PRIMITIVE : - { - B.Generated(NS); - break; - } - case TNaming_GENERATED : - { - B.Generated(OS,NS); - break; - } - case TNaming_MODIFY : - { - B.Modify(OS,NS); - break; - } - case TNaming_DELETE : - { - B.Delete (OS); - break; - } - case TNaming_SELECTED : - { - B.Select(NS,OS); - break; - } - case TNaming_REPLACE : - B.Replace(OS,NS); - } - } -} - diff --git a/src/TNaming/TNaming_Naming.cxx b/src/TNaming/TNaming_Naming.cxx index 4b268233c6..090e7eb6c0 100755 --- a/src/TNaming/TNaming_Naming.cxx +++ b/src/TNaming/TNaming_Naming.cxx @@ -53,8 +53,13 @@ #include #include #include +#include #include #include +#include +#include +#include +#include // #include #include #include @@ -926,7 +931,7 @@ static Handle(TNaming_NamedShape) BuildNameInNS (const TDF_Label& { // il faut determiner un nouveau context et un nouveau Stop. - // it is necessary to determine new a context and a new Stop + // it is necessary to determine a new context and a new Stop TopoDS_Shape SC; Handle(TNaming_NamedShape) NewStop = Stop; @@ -1248,9 +1253,12 @@ static void BuildScope (TNaming_Scope& MDF, } } +//======================================================================= +//function : HasAncFace +//purpose : Returns True & if ancestor face is found //======================================================================= static Standard_Boolean HasAncFace(const TopoDS_Shape& Context, - const TopoDS_Shape& W, TopoDS_Shape& Face) + const TopoDS_Shape& W, TopoDS_Shape& Face, Standard_Boolean& isOuter) { Standard_Boolean hasFace(Standard_False); if(W.ShapeType() != TopAbs_WIRE) @@ -1259,14 +1267,22 @@ static Standard_Boolean HasAncFace(const TopoDS_Shape& Context, for(;exp.More(); exp.Next()) { for (TopoDS_Iterator it(exp.Current()) ; it.More(); it.Next()) { if(it.Value().IsEqual(W)) {// is the Wire ? - Face = exp.Current(); - if(!Face.IsNull()) { - hasFace = Standard_True; - // cout << "HasAncFace: TS = " <This() <ChangeName(); + theName.ShapeType(Selection.ShapeType()); + theName.Shape(Selection); + } + + TNaming_Name& theName = Naming->ChangeName(); + TopoDS_Shape aSolid; + Standard_Boolean isOuter(Standard_False); + Standard_Boolean hasSolid = HasAncSolid(Context, Selection, aSolid, isOuter); + if(hasSolid && Selection.ShapeType() > Context.ShapeType()) { + theName.Type(TNaming_SHELLIN);// SHELLIN + + if(Context.ShapeType() == TopAbs_SOLID) { + for (TopoDS_Iterator it(Context) ; it.More(); it.Next()) { +#ifdef MDTV_DEB_TSOL + Write(it.Value(), "Shell_inSo.brep"); +#endif + if(it.Value().IsEqual(Selection)) { + found = Standard_True; + break; + } + } + if(found) { + // solid => aSolid which is also a context + Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(Context,F); + if(!aNS.IsNull()) + theName.ContextLabel(aNS->Label()); + theName.Append(aNS); + if(isOuter) { + theName.Index(1); + } else { //not OuterShell + theName.Index(-1); + for (TopExp_Explorer exp(Selection,TopAbs_FACE) ; exp.More(); exp.Next()) { + if(exp.Current().IsNull()) continue; + theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); + } + } + } else + return BuildNS (F,Selection, TNaming_UNKNOWN); + } else { + // context is not SOLID + //theName.Append(BuildName (Naming->Label(),MDF,aSolid,Context,Stop,Geom));//########### + if(isOuter) { +#ifdef MDTV_DEB_TSOL + Write(aSolid, "foundSolid.brep"); +#endif + theName.Index(1); + Handle (TNaming_Naming) NamingSo = TNaming_Naming::Insert(F); + TNaming_Name& theNameSo = NamingSo->ChangeName(); + theNameSo.ShapeType(aSolid.ShapeType()); + theNameSo.Shape(aSolid); + theNameSo.Type(TNaming_UNION); + Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(Context,F); + if(!aNS.IsNull()) + theNameSo.ContextLabel(aNS->Label()); + for (TopExp_Explorer exp(aSolid,TopAbs_FACE) ; exp.More(); exp.Next()) + theNameSo.Append(BuildName (NamingSo->Label(),MDF,exp.Current(),Context,Stop,Geom)); + NamingSo->GetName().Solve(NamingSo->Label(),MDF.GetValid()); + aNS.Nullify(); + NamingSo->Label().FindAttribute(TNaming_NamedShape::GetID(),aNS); + theName.Append(aNS); + } else { + theName.Index(-1); + // - name Solid: theName.Append(BuildName (Naming->Label(),MDF, aSolid,Context,Stop,Geom)); + Handle (TNaming_Naming) NamingSo = TNaming_Naming::Insert(F); + TNaming_Name& theNameSo = NamingSo->ChangeName(); + theNameSo.ShapeType(aSolid.ShapeType()); + theNameSo.Shape(aSolid); + theNameSo.Type(TNaming_UNION); + Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(Context,F); + if(!aNS.IsNull()) + theNameSo.ContextLabel(aNS->Label()); + for (TopExp_Explorer exp(aSolid,TopAbs_FACE) ; exp.More(); exp.Next()) + theNameSo.Append(BuildName (NamingSo->Label(),MDF,exp.Current(),Context,Stop,Geom)); + NamingSo->GetName().Solve(NamingSo->Label(),MDF.GetValid()); + aNS.Nullify(); + NamingSo->Label().FindAttribute(TNaming_NamedShape::GetID(),aNS); + theName.Append(aNS); + + for (TopExp_Explorer exp(Selection,TopAbs_FACE) ; exp.More(); exp.Next()) { + if(exp.Current().IsNull()) continue; + theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); + } + } + }// + } + else { // => no Solid + theName.Type(TNaming_UNION); + Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(Context,F); + if(!aNS.IsNull()) + theName.ContextLabel(aNS->Label()); + for (TopExp_Explorer exp(Selection,TopAbs_FACE) ; exp.More(); exp.Next()) { + if(exp.Current().IsNull()) continue; + theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); + } + } + //Naming->GetName().Solve(Naming->Label(),MDF.GetValid()); + Naming->Label().FindAttribute(TNaming_NamedShape::GetID(),NS); + return NS; +} + //======================================================================= //function : BuildAggregationNam //purpose : @@ -1489,6 +1671,8 @@ static void BuildAggregationName (const TDF_Label& F, if(aS.ShapeType() == TopAbs_WIRE) { aNS = BuildNameWire (aNaming->Label(), MDF, aS, Context,Stop,Geom); } + else if(aS.ShapeType() == TopAbs_SHELL) + aNS = BuildNameShell (aNaming->Label(), MDF, aS, Context,Stop,Geom); else { for (TopExp_Explorer exp(aS,atomTyp) ; exp.More(); exp.Next()) { aName.Append(BuildName (aNaming->Label(),MDF,exp.Current(),Context,Stop,Geom)); @@ -1578,7 +1762,7 @@ Handle(TNaming_NamedShape) TNaming_Naming::Name (const TDF_Label& F, TopoDS_Iterator it(itw.Value()); for(int i=1;it.More();it.Next(),i++) { if(it.Value().IsEqual(S)) { - theName.Index(i); + theName.Index(i);//We use this field to save a Seam Shape Index; Before this field was used for GENERATED only found = Standard_True; #ifdef MDTV_OR cout << "ORDER = " << i <Label(), MDF, S, Context,Stop,Geom); - else { - theName.Type(TNaming_UNION); - for (TopExp_Explorer exp(S,atomType) ; exp.More(); exp.Next()) { - theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); - } - } + NS = BuildNameWire (Naming->Label(), MDF, S, Context,Stop,Geom); + else if(S.ShapeType() == TopAbs_SHELL) { + NS = BuildNameShell (Naming->Label(), MDF, S, Context,Stop,Geom); + } + else { + theName.Type(TNaming_UNION); + for (TopExp_Explorer exp(S,atomType) ; exp.More(); exp.Next()) { + theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); + } + } } #else for (TopoDS_Iterator it(S) ; it.More(); it.Next()) { diff --git a/src/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx b/src/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx index 9200ebea96..88f021ca62 100755 --- a/src/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx +++ b/src/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx @@ -160,9 +160,9 @@ Standard_Boolean XmlMNaming_NamedShapeDriver::Paste case TNaming_SELECTED: aBld.Select(aNewShape, anOldShape); break; - case TNaming_REPLACE: - aBld.Replace(anOldShape,aNewShape); - break; + // case TNaming_REPLACE: + // aBld.Replace(anOldShape,aNewShape); + // break; default: Standard_DomainError::Raise("TNaming_Evolution; enum term unknown"); } @@ -248,7 +248,7 @@ static const XmlObjMgt_DOMString& EvolutionString(const TNaming_Evolution i) case TNaming_MODIFY : return ::EvolModifyString(); case TNaming_DELETE : return ::EvolDeleteString(); case TNaming_SELECTED : return ::EvolSelectedString(); - case TNaming_REPLACE : return ::EvolReplaceString(); + // case TNaming_REPLACE : return ::EvolReplaceString(); default: Standard_DomainError::Raise("TNaming_Evolution; enum term unknown"); } @@ -274,7 +274,7 @@ static TNaming_Evolution EvolutionEnum (const XmlObjMgt_DOMString& theString) else if (theString.equals (::EvolSelectedString())) aResult = TNaming_SELECTED; else if (theString.equals (::EvolReplaceString())) - aResult = TNaming_REPLACE; + aResult = TNaming_MODIFY; // for compatibility //TNaming_REPLACE; else Standard_DomainError::Raise ("TNaming_Evolution; string value without enum term equivalence"); diff --git a/src/XmlMNaming/XmlMNaming_NamingDriver.cxx b/src/XmlMNaming/XmlMNaming_NamingDriver.cxx index f6f22e74ab..229b7e9091 100755 --- a/src/XmlMNaming/XmlMNaming_NamingDriver.cxx +++ b/src/XmlMNaming/XmlMNaming_NamingDriver.cxx @@ -52,7 +52,8 @@ IMPLEMENT_DOMSTRING (NTSubtractionString, "subtraction") IMPLEMENT_DOMSTRING (NTConstShapeString, "constshape") IMPLEMENT_DOMSTRING (NTFilterByNeighString, "filterbyneigh") IMPLEMENT_DOMSTRING (NTOrientationString, "orientation") -IMPLEMENT_DOMSTRING (NTWireInString, "wirein") +IMPLEMENT_DOMSTRING (NTWireInString, "wirein") +IMPLEMENT_DOMSTRING (NTShellInString, "shellin") IMPLEMENT_DOMSTRING (ShCompoundString, "compound") IMPLEMENT_DOMSTRING (ShCompsolidString, "compsolid") @@ -329,6 +330,7 @@ static const XmlObjMgt_DOMString& NameTypeToString (const TNaming_NameType theE) case TNaming_FILTERBYNEIGHBOURGS : return ::NTFilterByNeighString(); case TNaming_ORIENTATION : return ::NTOrientationString(); case TNaming_WIREIN : return ::NTWireInString(); + case TNaming_SHELLIN : return ::NTShellInString(); default: Standard_DomainError::Raise("TNaming_NameType; enum term unknown "); } @@ -397,6 +399,8 @@ static TNaming_NameType NameTypeFromString (const XmlObjMgt_DOMString& theString aResult = TNaming_ORIENTATION; else if (theString.equals (::NTWireInString())) aResult = TNaming_WIREIN; + else if (theString.equals (::NTShellInString())) + aResult = TNaming_SHELLIN; else Standard_DomainError::Raise ("TNaming_NameType; string value without enum term equivalence"); diff --git a/tests/caf/named_shape/F6 b/tests/caf/named_shape/F6 old mode 100644 new mode 100755 index d39de68a33..19368d74e1 --- a/tests/caf/named_shape/F6 +++ b/tests/caf/named_shape/F6 @@ -95,7 +95,7 @@ set SL2 [TestMultipleSelection D $Prism 0] #12 modify NewCommand D -PntOffset D $Pnt1 40 25 skip +PntOffset D $Pnt1 20 25 skip #13 recompute NewCommand D