1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0023205: Patch for Naming improvement

1). Added persistence.
2) Removed not supported evolution - Replace.
QADraw commands were fixed .
Added TKBO to EXTERNLIB.
Modified test case: caf named_shape F6
This commit is contained in:
szy 2012-08-31 15:26:23 +04:00
parent 09121745ad
commit 1ec8a59e23
21 changed files with 684 additions and 263 deletions

View File

@ -42,7 +42,7 @@ static Standard_Character EvolutionToChar(const TNaming_Evolution theEvol)
case TNaming_MODIFY : return 'M'; case TNaming_MODIFY : return 'M';
case TNaming_DELETE : return 'D'; case TNaming_DELETE : return 'D';
case TNaming_SELECTED : return 'S'; case TNaming_SELECTED : return 'S';
case TNaming_REPLACE : return 'R'; // case TNaming_REPLACE : return 'R';
default: default:
Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown"); 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 'M': return TNaming_MODIFY;
case 'D': return TNaming_DELETE; case 'D': return TNaming_DELETE;
case 'S': return TNaming_SELECTED; case 'S': return TNaming_SELECTED;
case 'R': return TNaming_REPLACE; case 'R': return TNaming_MODIFY; //for compatibility //TNaming_REPLACE;
default: default:
Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown"); Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown");
} }
@ -211,9 +211,9 @@ Standard_Boolean BinMNaming_NamedShapeDriver::Paste
case TNaming_SELECTED : case TNaming_SELECTED :
aBuilder.Select(aNewShape, anOldShape); aBuilder.Select(aNewShape, anOldShape);
break; break;
case TNaming_REPLACE : // case TNaming_REPLACE :
aBuilder.Replace(anOldShape, aNewShape); // aBuilder.Replace(anOldShape, aNewShape);
break; // break;
default : default :
Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown"); Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown");
} }

View File

@ -56,6 +56,7 @@ static Standard_Character NameTypeToChar(const TNaming_NameType theNameType)
case TNaming_FILTERBYNEIGHBOURGS : return 'F'; case TNaming_FILTERBYNEIGHBOURGS : return 'F';
case TNaming_ORIENTATION : return 'O'; case TNaming_ORIENTATION : return 'O';
case TNaming_WIREIN : return 'W'; case TNaming_WIREIN : return 'W';
case TNaming_SHELLIN : return 'H';
default: default:
Standard_DomainError::Raise("TNaming_NameType:: Name Type Unknown"); 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 'F' : return TNaming_FILTERBYNEIGHBOURGS;
case 'O' : return TNaming_ORIENTATION; case 'O' : return TNaming_ORIENTATION;
case 'W' : return TNaming_WIREIN; case 'W' : return TNaming_WIREIN;
case 'H' : return TNaming_SHELLIN;
default: default:
Standard_DomainError::Raise("TNaming_NameType:: Name Type Unknown"); Standard_DomainError::Raise("TNaming_NameType:: Name Type Unknown");
} }

View File

@ -150,7 +150,8 @@ void MNaming_NamedShapeRetrievalDriver::Paste (
Bld.Select(NewShape, OldShape); break; Bld.Select(NewShape, OldShape); break;
} }
case TNaming_REPLACE :{ case TNaming_REPLACE :{
Bld.Replace(OldShape,NewShape); break; //Bld.Replace(OldShape,NewShape); break;
Bld.Modify(OldShape,NewShape); break;// for compatibility only
} }
default : default :
Standard_DomainError::Raise("TNaming_Evolution; enum term unknown"); Standard_DomainError::Raise("TNaming_Evolution; enum term unknown");

View File

@ -158,7 +158,7 @@ Standard_Integer EvolutionInt(const TNaming_Evolution i)
case TNaming_MODIFY : return 2; case TNaming_MODIFY : return 2;
case TNaming_DELETE : return 3; case TNaming_DELETE : return 3;
case TNaming_SELECTED : return 4; case TNaming_SELECTED : return 4;
case TNaming_REPLACE : return 5; //case TNaming_REPLACE : return 5;
default: default:
Standard_DomainError::Raise("TNaming_Evolution; enum term unknown"); Standard_DomainError::Raise("TNaming_Evolution; enum term unknown");
} }

View File

@ -73,6 +73,9 @@ static TNaming_NameType IntegerToNameType (const Standard_Integer I)
case 6 : return TNaming_SUBSTRACTION; case 6 : return TNaming_SUBSTRACTION;
case 7 : return TNaming_CONSTSHAPE; case 7 : return TNaming_CONSTSHAPE;
case 8 : return TNaming_FILTERBYNEIGHBOURGS; case 8 : return TNaming_FILTERBYNEIGHBOURGS;
case 9 : return TNaming_ORIENTATION;
case 10: return TNaming_WIREIN;
case 11: return TNaming_SHELLIN;
default : default :
Standard_DomainError::Raise("TNaming_NameType; enum term unknown "); Standard_DomainError::Raise("TNaming_NameType; enum term unknown ");
} }

View File

@ -78,6 +78,7 @@ static Standard_Integer NameTypeToInteger (const TNaming_NameType I)
case TNaming_FILTERBYNEIGHBOURGS : return 8; case TNaming_FILTERBYNEIGHBOURGS : return 8;
case TNaming_ORIENTATION : return 9; case TNaming_ORIENTATION : return 9;
case TNaming_WIREIN : return 10; case TNaming_WIREIN : return 10;
case TNaming_SHELLIN : return 11;
default : default :
Standard_DomainError::Raise("TNaming_NameType; enum term unknown "); Standard_DomainError::Raise("TNaming_NameType; enum term unknown ");
} }

View File

@ -63,7 +63,8 @@ static Standard_Integer BuildNamedShape (Draw_Interpretor& di,
aBuilder.Delete(aShape1); aBuilder.Delete(aShape1);
break; break;
case 'R': case 'R':
aBuilder.Replace(aShape1,aShape2); // aBuilder.Replace(aShape1,aShape2);
aBuilder.Modify(aShape1,aShape2);
break; break;
case 'S': case 'S':
aBuilder.Select(aShape1,aShape2); aBuilder.Select(aShape1,aShape2);

View File

@ -50,8 +50,8 @@ static const char* EvolutionString(TNaming_Evolution theEvolution) {
return "DELETE"; return "DELETE";
case TNaming_SELECTED : case TNaming_SELECTED :
return "SELECTED"; return "SELECTED";
case TNaming_REPLACE : // case TNaming_REPLACE :
return "REPLACE"; // return "REPLACE";
} }
return "UNKNOWN_Evolution"; return "UNKNOWN_Evolution";
} }

View File

@ -88,11 +88,11 @@ void QANewBRepNaming::LoadNamedShape (TNaming_Builder& theBuilder,
theBuilder.Modify(theOS, theNS); theBuilder.Modify(theOS, theNS);
break; break;
} }
case TNaming_REPLACE : // case TNaming_REPLACE :
{ // {
theBuilder.Replace(theOS, theNS); // theBuilder.Replace(theOS, theNS);
break; // break;
} // }
case TNaming_DELETE : case TNaming_DELETE :
{ {
theBuilder.Delete (theOS); theBuilder.Delete (theOS);

View File

@ -10,3 +10,4 @@ TKV2d
TKCDF TKCDF
TKLCAF TKLCAF
TKV3d TKV3d
TKBO

View File

@ -209,7 +209,8 @@ is
CONSTSHAPE, CONSTSHAPE,
FILTERBYNEIGHBOURGS, FILTERBYNEIGHBOURGS,
ORIENTATION, ORIENTATION,
WIREIN WIREIN,
SHELLIN
end NameType; end NameType;
class Name; class Name;
@ -355,6 +356,16 @@ is
---Purpose: Subtitutes shape in source structure ---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 <theWire>.
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 <theShell>.
---Purpose: Print of TNaming enumeration ---Purpose: Print of TNaming enumeration
-- ============================= -- =============================

View File

@ -52,6 +52,9 @@
#include <TNaming_DataMapOfShapePtrRefShape.hxx> #include <TNaming_DataMapOfShapePtrRefShape.hxx>
#include <TNaming_Tool.hxx> #include <TNaming_Tool.hxx>
#include <IntTools_FClass2d.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
// CopyShape // CopyShape
#include <TColStd_IndexedDataMapOfTransientTransient.hxx> #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
#include <TNaming_TranslateTool.hxx> #include <TNaming_TranslateTool.hxx>
@ -388,6 +391,7 @@ static void LoadNamedShape (TNaming_Builder& B,
case TNaming_SELECTED : case TNaming_SELECTED :
{ {
B.Select(NS,OS); B.Select(NS,OS);
break;
} }
default: default:
break; break;
@ -736,6 +740,10 @@ Standard_OStream& TNaming::Print (const TNaming_NameType NAME, Standard_OStream
case TNaming_WIREIN: case TNaming_WIREIN:
{ {
s <<"WIREIN"; break; s <<"WIREIN"; break;
}
case TNaming_SHELLIN:
{
s <<"SHELLIN"; break;
} }
default : default :
{ {
@ -945,6 +953,95 @@ TopoDS_Shape TNaming::FindUniqueContextSet(const TopoDS_Shape& Selection, const
return TopoDS_Shape(); return TopoDS_Shape();
} }
//=======================================================================
//function : OuterWire
//purpose : Returns True & <theWire> 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 & <theShell>, 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;
}

View File

@ -78,16 +78,6 @@ is
-- or merged in a Boolean operation. -- 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. ---Category: Load Selection.
Select (me : in out; aShape, inShape : Shape from TopoDS); Select (me : in out; aShape, inShape : Shape from TopoDS);
---Purpose: Add a Shape to the current label , This Shape is ---Purpose: Add a Shape to the current label , This Shape is

View File

@ -102,11 +102,6 @@ static void LoadNamedShape (TNaming_Builder& B,
B.Select(NS,OS); B.Select(NS,OS);
break; break;
} }
case TNaming_REPLACE :
{
B.Replace(OS,NS);
break;
}
} }
} }

View File

@ -35,6 +35,7 @@
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopoDS_Compound.hxx> #include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx> #include <TopTools_MapIteratorOfMapOfShape.hxx>
@ -83,6 +84,8 @@
//#define MDTV_DEB_MODUN //#define MDTV_DEB_MODUN
//#define MDTV_DEB_FNB //#define MDTV_DEB_FNB
//#define MDTV_DEB_WIN //#define MDTV_DEB_WIN
//#define MDTV_DEB_ARG
//#define MDTV_DEB_SHELL
#ifdef MDTV_DEB #ifdef MDTV_DEB
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <TDF_Tool.hxx> #include <TDF_Tool.hxx>
@ -113,7 +116,6 @@ void PrintEntries(const TDF_LabelMap& map)
} }
} }
#include <BRepTools.hxx>
//======================================================================= //=======================================================================
static void DbgTools_Write(const TopoDS_Shape& shape, static void DbgTools_Write(const TopoDS_Shape& shape,
const Standard_CString filename) const Standard_CString filename)
@ -180,14 +182,14 @@ static Standard_Boolean ValidArgs(const TNaming_ListOfNamedShape& Args)
for (;it.More();it.Next()) { for (;it.More();it.Next()) {
const Handle(TNaming_NamedShape)& aNS = it.Value(); const Handle(TNaming_NamedShape)& aNS = it.Value();
if(aNS.IsNull()) { if(aNS.IsNull()) {
#ifdef MDTV_DEB #ifdef MDTV_DEB_ARG
cout << "ValidArgs:: NS (Naming argument) is NULL" <<endl; cout << "ValidArgs:: NS (Naming argument) is NULL" <<endl;
#endif #endif
return Standard_False; return Standard_False;
} }
else else
if(aNS->IsEmpty()) { if(aNS->IsEmpty()) {
#ifdef MDTV_DEB #ifdef MDTV_DEB_ARG
TCollection_AsciiString entry; TCollection_AsciiString entry;
TDF_Tool::Entry(aNS->Label(), entry); TDF_Tool::Entry(aNS->Label(), entry);
cout << "ValidArgs:: Empty NS, Label = " << entry <<endl; cout << "ValidArgs:: Empty NS, Label = " << entry <<endl;
@ -196,7 +198,7 @@ static Standard_Boolean ValidArgs(const TNaming_ListOfNamedShape& Args)
} }
else else
if(!aNS->IsValid()) { if(!aNS->IsValid()) {
#ifdef MDTV_DEB #ifdef MDTV_DEB_ARG
TCollection_AsciiString entry; TCollection_AsciiString entry;
TDF_Tool::Entry(aNS->Label(), entry); TDF_Tool::Entry(aNS->Label(), entry);
cout << "ValidArgs::Not valid NS Label = " << entry <<endl; cout << "ValidArgs::Not valid NS Label = " << entry <<endl;
@ -508,9 +510,17 @@ static Standard_Boolean FindModifUntil (TNaming_NewShapeIterator& it,
const TopoDS_Shape& S, const TopoDS_Shape& S,
const Handle(TNaming_NamedShape)& Context) const Handle(TNaming_NamedShape)& Context)
{ {
#ifdef MDTV_DEB_MODUN
if(!Context.IsNull())
PrintEntry(Context->Label());
#endif
Standard_Boolean found = Standard_False; Standard_Boolean found = Standard_False;
for (; it.More(); it.Next()) { for (; it.More(); it.Next()) {
if (!it.Shape().IsNull()) { if (!it.Shape().IsNull()) {
#ifdef MDTV_DEB_MODUN
if(!it.NamedShape().IsNull())
PrintEntry(it.NamedShape()->Label());
#endif
if (it.NamedShape() == Context) { if (it.NamedShape() == Context) {
MS.Add(S); MS.Add(S);
found = Standard_True; found = Standard_True;
@ -557,13 +567,16 @@ static void SearchModifUntil (const TDF_LabelMap& /*Valid*/,
Standard_Integer k = 0; Standard_Integer k = 0;
TCollection_AsciiString aNam1 = aGen1 + i + Und + j + ".brep"; TCollection_AsciiString aNam1 = aGen1 + i + Und + j + ".brep";
DbgTools_Write(S, aNam1.ToCString()); DbgTools_Write(S, aNam1.ToCString());
PrintEntry(aNS->Label());//NSLabel
#endif #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(); const TopoDS_Shape& OS = itC.OldShape();
#ifdef MDTV_DEB_MODUN #ifdef MDTV_DEB_MODUN
k++; k++;
TCollection_AsciiString aNam2 = aGen2 + i + Und + j + Und + k + ".brep"; TCollection_AsciiString aNam2 = aGen2 + i + Und + j + Und + k + ".brep";
DbgTools_Write(OS, aNam2.ToCString()); DbgTools_Write(OS, aNam2.ToCString());
PrintEntry(Target->Label());//Target Label
#endif #endif
if (OS.IsSame(S)) { if (OS.IsSame(S)) {
theMS.Add(S); theMS.Add(S);
@ -1837,75 +1850,280 @@ static Standard_Boolean ORientation (const TDF_Label& L,
//=========================================================================== //===========================================================================
//function : WireIN //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, static Standard_Boolean WireIN(const TDF_Label& L,
const TDF_LabelMap& Valid, const TDF_LabelMap& Valid,
const TNaming_ListOfNamedShape& Args, const TNaming_ListOfNamedShape& Args,
const Standard_Integer Index) const Handle(TNaming_NamedShape)& Stop,
Standard_Integer Index)
{ {
Standard_Boolean aResult(Standard_False); Standard_Boolean aResult(Standard_False);
if(!ValidArgs(Args)) return aResult; if(!ValidArgs(Args)) return aResult;
TopTools_MapOfShape MS; TopTools_MapOfShape MS;
TDF_LabelMap Forbiden; TDF_LabelMap Forbiden;
if (Args.Extent() != 1 ) if (Args.Extent() < 1 )
Standard_ConstructionError::Raise("TNaming_Name::Solve"); 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); 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 #ifdef MDTV_DEB_WIN
cout <<"MS Extent = " <<MS.Extent() <<endl; cout <<"MS Extent = " <<MS.Extent() <<endl;
DbgTools_Write(aCF, "Context_Face.brep");
#endif #endif
Standard_Integer indx(0), num(0);
if(Index > 0) {
indx = Index & 0x000000FF;
num = (Index & 0x0000FF00) >> 8;
#ifdef MDTV_DEB_WIN
cout <<"Kept indx = " << indx <<" maxNum" << num << endl;
#endif
}
TNaming_Builder B(L); TNaming_Builder B(L);
for (TopTools_MapIteratorOfMapOfShape itM(MS); itM.More(); itM.Next()) { if(Index == 1 ){ //Outer wire case
const TopoDS_Shape& S = itM.Key() ; TopoDS_Wire anOuterWire;
#ifdef MDTV_DEB_WIN TNaming::OuterWire(TopoDS::Face(aCF), anOuterWire);
if(!S.IsNull()) { if(!anOuterWire.IsNull()) {
DbgTools_Write(S, "WireIN_S.brep"); B.Select(anOuterWire, anOuterWire);
cout <<"WIREIN: ShapeType = " << S.ShapeType() << " TS = " << S.TShape()->This() <<endl; 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 = " <<entry <<" TShape = " << CS.TShape() <<endl;
#endif #endif
Standard_Integer aNum(0), aCase(0);
TopoDS_Iterator it2(S);
for (;it2.More();it2.Next()) aNum++;
if(Index > 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 #ifdef MDTV_DEB_WIN
if(!it2.Value().IsNull()) { cout <<"WIREIN: " << " Internal Map ext = " << aSet.Map().Extent()<<endl;
DbgTools_Write(it2.Value(), "WireIN_it2Value.brep"); TopTools_MapIteratorOfMapOfShape it1 (aSet.Map());
cout <<"WIREIN: ShapeType = " << it2.Value().ShapeType() << " TS = " << it2.Value().TShape()->This() <<endl; for (int i=1;it1.More();it1.Next(),i++) {
cout << "Map("<<i<<"): TShape = " << it1.Key().TShape() << " Orient = " << it1.Key().Orientation() <<" Type = " <<
it1.Key().ShapeType()<<endl;
}
TopExp_Explorer exp(aCF, TopAbs_EDGE);
for(int i =1;exp.More();exp.Next(), i++) {
cout << "Context_Face("<<i<<"): TShape = " << exp.Current().TShape() << " Orient = " << exp.Current().Orientation() <<endl;
} }
#endif #endif
i++; //end for edges
if(it2.Value().ShapeType() == TopAbs_WIRE) {
if(Index > 0 ) { //szy 26/03/10 for (TopoDS_Iterator itF(aCF); itF.More(); itF.Next()) {// find the expected wire in the face
if(aCase == 1) { const TopoDS_Shape& S = itF.Value();//wire
if(i == indx) { if(!S.IsNull()) {
#ifdef MDTV_DEB_WIN
DbgTools_Write(S, "WireIN_S.brep");
cout <<"WIREIN: ShapeType = " << S.ShapeType() << " TS = " << S.TShape()->This() <<endl;
#endif
if(S.ShapeType() == TopAbs_WIRE) {
TopTools_MapOfShape aView;
Standard_Integer aNum(0x7FFFFFFF);
for (TopoDS_Iterator it(S);it.More();it.Next())
aView.Add(it.Value());// edges of wire of the face in map
TopTools_MapIteratorOfMapOfShape it (aSet.Map());
aNum = aView.Extent();
if(aNum == aSet.Map().Extent()) {
for (;it.More();it.Next()) {
if(aView.Contains(it.Key())) {
aNum--;
}
}
}
if(aNum == 0) {
B.Select(S, S);
aResult = Standard_True; aResult = Standard_True;
B.Select(it2.Value(),it2.Value());
break; break;
} }
} else {
B.Select(it2.Value(),it2.Value());
aResult = Standard_True;
} }
} }
else { } //
B.Select(it2.Value(),it2.Value());
if(!aResult) {
TopoDS_Wire anOuterWire;
TNaming::OuterWire(TopoDS::Face(aCF), anOuterWire);
if(!anOuterWire.IsNull()) {
for (TopoDS_Iterator itF(aCF); itF.More(); itF.Next()) {
const TopoDS_Shape& S = itF.Value();//wire
if(!S.IsNull()&& S.ShapeType() == TopAbs_WIRE) {
if(S.IsEqual(anOuterWire)) continue;
B.Select(S, S);
}
}
}
}
}
return aResult;
}
//===========================================================================
//function : ShellIN
//purpose : to solve SHELLIN name
//===========================================================================
static Standard_Boolean ShellIN(const TDF_Label& L,
const TDF_LabelMap& Valid,
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 )
Standard_ConstructionError::Raise("TNaming_Name::Solve");
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& aCSO = itM.Key() ;
#ifdef MDTV_DEB_SHELL
cout <<"MS Extent = " <<MS.Extent() <<endl;
DbgTools_Write(aCSO, "Context_Solid.brep");
#endif
TNaming_Builder B(L);
if(Index == 1 ){ //Outer Shell case
TopoDS_Shell anOuterShell;
TNaming::OuterShell(TopoDS::Solid(aCSO), anOuterShell);
if(!anOuterShell.IsNull()) {
B.Select(anOuterShell, anOuterShell);
aResult = Standard_True; aResult = Standard_True;
#ifdef MDTV_DEB_SHELL
cout << "Outer Shell case" <<endl;
PrintEntry(L);
DbgTools_Write(anOuterShell, "ShellOut_S.brep");
it.Initialize(aCSO);
for(;it.More();it.Next()){
DbgTools_Write(it.Value(), "ShOut_S.brep");
}
#endif
}
} else { //has internal Shells
TNaming_ListOfNamedShape ArgsF;
ArgsF.Assign(Args);
ArgsF.RemoveFirst();
// fill Map with faces
TNaming_ListIteratorOfListOfNamedShape it(ArgsF);
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_FACE);//fill internal map of shapeset by shapes of the specified type
#ifdef MDTV_DEB_SHELL
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_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 = " <<entry <<" TShape = " << CS.TShape() <<endl;
#endif
}
#ifdef MDTV_DEB_SHELL
cout <<"SHELLIN: " << " Internal Map ext = " << aSet.Map().Extent()<<endl;
TopTools_MapIteratorOfMapOfShape it1 (aSet.Map());
for (int i=1;it1.More();it1.Next(),i++) {
cout << "Map("<<i<<"): TShape = " << it1.Key().TShape() << " Orient = " << it1.Key().Orientation() <<" Type = " <<
it1.Key().ShapeType()<<endl;
}
TopExp_Explorer exp(aCSO, TopAbs_FACE);
for(int i = 1;exp.More();exp.Next(), i++) {
cout << "Context_Solid("<<i<<"): TShape = " << exp.Current().TShape() << " Orient = " << exp.Current().Orientation() <<endl;
}
#endif
//end for faces
for (TopoDS_Iterator itS(aCSO); itS.More(); itS.Next()) {// find the expected shell in the solid
const TopoDS_Shape& S = itS.Value();//shell
if(!S.IsNull()) {
#ifdef MDTV_DEB_SHELL
DbgTools_Write(S, "ShellIN_S.brep");
cout <<"SHELLIN: ShapeType = " << S.ShapeType() << " TS = " << S.TShape()->This() <<endl;
#endif
if(S.ShapeType() == TopAbs_SHELL) {
TopTools_MapOfShape aView;
Standard_Integer aNum(0x7FFFFFFF);
for (TopoDS_Iterator it(S);it.More();it.Next())
aView.Add(it.Value());// faces of shell of the solid in map
aNum = aView.Extent();
if(aNum == aSet.Map().Extent()) {
TopTools_MapIteratorOfMapOfShape it (aSet.Map());
for (;it.More();it.Next()) {
if(aView.Contains(it.Key())) {
aNum--;
}
}
}
if(aNum == 0) {
B.Select(S, S);
aResult = Standard_True;
break;
}
}
}
} //
if(!aResult) {
TopoDS_Shell anOuterShell;
TNaming::OuterShell(TopoDS::Solid(aCSO), anOuterShell);
if(!anOuterShell.IsNull()) {
for (TopoDS_Iterator itS(aCSO); itS.More(); itS.Next()) {
const TopoDS_Shape& S = itS.Value();//shell
if(!S.IsNull()&& S.ShapeType() == TopAbs_SHELL) {
if(S.IsEqual(anOuterShell)) continue;
B.Select(S, S);
}
} }
} }
} }
@ -1944,6 +2162,9 @@ Standard_Boolean TNaming_Name::Solve(const TDF_Label& aLab,
const TDF_LabelMap& Valid) const const TDF_LabelMap& Valid) const
{ {
Standard_Boolean Done = 0; Standard_Boolean Done = 0;
#ifdef MDTV_DEB_WIN
PrintEntry(aLab);
#endif
try { try {
switch (myType) { switch (myType) {
case TNaming_UNKNOWN : case TNaming_UNKNOWN :
@ -1998,7 +2219,20 @@ Standard_Boolean TNaming_Name::Solve(const TDF_Label& aLab,
} }
case TNaming_WIREIN: case TNaming_WIREIN:
{ {
Done = WireIN (aLab,Valid,myArgs,myIndex); #ifdef MDTV_DEB_WIN
cout << "Name::Solve: NameType = " << myType << " ";
PrintEntry(aLab);
#endif
Done = WireIN (aLab,Valid,myArgs,myStop,myIndex);
break;
}
case TNaming_SHELLIN:
{
#ifdef MDTV_DEB_SHELL
cout << "Name::Solve: NameType = " << myType << " ";
PrintEntry(aLab);
#endif
Done = ShellIN (aLab,Valid,myArgs,myStop,myIndex);
break; break;
} }
} }

View File

@ -139,13 +139,6 @@ is
-- attribute may be a brand new one or a new version -- attribute may be a brand new one or a new version
-- of the previous one. -- of the previous one.
OldPaste(me;
intoAttribute : mutable Attribute from TDF;
aRelocTationable : mutable RelocationTable from TDF);
References(me; aDataSet : DataSet from TDF) References(me; aDataSet : DataSet from TDF)
is redefined; is redefined;
---Purpose: Adds the directly referenced attributes and labels ---Purpose: Adds the directly referenced attributes and labels

View File

@ -837,49 +837,6 @@ void TNaming_Builder::Modify(const TopoDS_Shape& oldShape,
} }
//=======================================================================
//function : Modify
//purpose :
//=======================================================================
void TNaming_Builder::Replace(const TopoDS_Shape& oldShape,
const TopoDS_Shape& newShape)
{
if (myAtt->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"<<endl;
#endif
return;
}
TNaming_RefShape* pos;
if (!myMap->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) static const TopoDS_Shape& DummyShapeToStoreOrientation (const TopAbs_Orientation Or)
{ {
@ -1720,59 +1677,3 @@ Standard_Integer TNaming_Tool::ValidUntil (const TopoDS_Shape& S,
} }
return Until; 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);
}
}
}

View File

@ -53,8 +53,13 @@
#include <TColStd_MapIteratorOfMapOfInteger.hxx> #include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TopTools_MapIteratorOfMapOfOrientedShape.hxx> #include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
#include <TopTools_HArray1OfShape.hxx> #include <TopTools_HArray1OfShape.hxx>
#include <BRepTools.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
// #include <TNaming_NCollections.hxx> // #include <TNaming_NCollections.hxx>
#include <NCollection_Map.hxx> #include <NCollection_Map.hxx>
#include <NCollection_DataMap.hxx> #include <NCollection_DataMap.hxx>
@ -926,7 +931,7 @@ static Handle(TNaming_NamedShape) BuildNameInNS (const TDF_Label&
{ {
// il faut determiner un nouveau context et un nouveau Stop. // 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; TopoDS_Shape SC;
Handle(TNaming_NamedShape) NewStop = Stop; Handle(TNaming_NamedShape) NewStop = Stop;
@ -1248,9 +1253,12 @@ static void BuildScope (TNaming_Scope& MDF,
} }
} }
//=======================================================================
//function : HasAncFace
//purpose : Returns True & <Face> if ancestor face is found
//======================================================================= //=======================================================================
static Standard_Boolean HasAncFace(const TopoDS_Shape& Context, 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); Standard_Boolean hasFace(Standard_False);
if(W.ShapeType() != TopAbs_WIRE) if(W.ShapeType() != TopAbs_WIRE)
@ -1263,6 +1271,14 @@ static Standard_Boolean HasAncFace(const TopoDS_Shape& Context,
if(!Face.IsNull()) { if(!Face.IsNull()) {
hasFace = Standard_True; hasFace = Standard_True;
// cout << "HasAncFace: TS = " <<theFace.TShape()->This() <<endl; // cout << "HasAncFace: TS = " <<theFace.TShape()->This() <<endl;
const TopoDS_Face aFace(TopoDS::Face(Face));
TopoDS_Wire anOuterW;
if(TNaming::OuterWire(aFace, anOuterW)) {
if(!anOuterW.IsNull() && anOuterW.IsEqual(W))
isOuter = Standard_True;
else
isOuter = Standard_False;
}
break; break;
} }
} }
@ -1297,8 +1313,9 @@ static Handle(TNaming_NamedShape) BuildNameWire (const TDF_Label&
TNaming_Name& theName = Naming->ChangeName(); TNaming_Name& theName = Naming->ChangeName();
TopoDS_Shape aFace; TopoDS_Shape aFace;
Standard_Boolean hasFace = HasAncFace(Context, Selection, aFace); Standard_Boolean isOuter(Standard_False);
if(Selection.ShapeType() == TopAbs_WIRE && Context.ShapeType() < Selection.ShapeType() && hasFace) { Standard_Boolean hasFace = HasAncFace(Context, Selection, aFace, isOuter);
if(hasFace && Selection.ShapeType() > Context.ShapeType()) {
theName.Type(TNaming_WIREIN); theName.Type(TNaming_WIREIN);
if(Context.ShapeType() == TopAbs_FACE) { if(Context.ShapeType() == TopAbs_FACE) {
for (TopoDS_Iterator it(Context) ; it.More(); it.Next()) { for (TopoDS_Iterator it(Context) ; it.More(); it.Next()) {
@ -1310,32 +1327,39 @@ static Handle(TNaming_NamedShape) BuildNameWire (const TDF_Label&
} }
} }
} }
if(!found)
return BuildNS (F,Selection, TNaming_UNKNOWN);
} else {
Standard_Integer indx(0), i(0);
for (TopoDS_Iterator it(aFace); it.More(); it.Next()) {
i++;
if(it.Value().IsEqual(Selection)) {
found = Standard_True;
theName.Append(BuildName (Naming->Label(),MDF,aFace,Context,Stop,Geom));
indx = i;
}
}
if(found) { if(found) {
const Standard_Integer num(i); theName.Append(BuildName (Naming->Label(),MDF,aFace,Context,Stop,Geom));
indx = indx | num << 8; if(isOuter) {
//cout << " final Index = " << indx <<endl; theName.Index(1);
theName.Index(indx); } else {
theName.Index(-1);
for (TopExp_Explorer exp(Selection,TopAbs_EDGE) ; exp.More(); exp.Next()) {
if(exp.Current().IsNull()) continue;
if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) continue;
theName.Append(TNaming_Naming::Name(Naming->Label(),exp.Current(),Context, Geom, 1, 0));
}
}
} else } else
return BuildNS (F,Selection, TNaming_UNKNOWN); return BuildNS (F,Selection, TNaming_UNKNOWN);
} else { // context is not Face
theName.Append(BuildName (Naming->Label(),MDF,aFace,Context,Stop,Geom));
if(isOuter) {
theName.Index(1);
} else {
for (TopExp_Explorer exp(Selection,TopAbs_EDGE) ; exp.More(); exp.Next()) {
if(exp.Current().IsNull()) continue;
if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) continue;
theName.Append(TNaming_Naming::Name(Naming->Label(),exp.Current(),Context, Geom, 1, 0));
} }
} }
else { }//
}
else { // => no Face
theName.Type(TNaming_UNION); theName.Type(TNaming_UNION);
for (TopExp_Explorer exp(Selection,TopAbs_EDGE) ; exp.More(); exp.Next()) { for (TopExp_Explorer exp(Selection,TopAbs_EDGE) ; exp.More(); exp.Next()) {
if(exp.Current().IsNull()) continue; if(exp.Current().IsNull()) continue;
if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) continue;//03.03.2010 if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) continue;
theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom));
} }
} }
@ -1408,11 +1432,13 @@ static Standard_Integer RepeatabilityInContext(const TopoDS_Shape& Selection,
// Write(Selection, "Repeat_Selection.brep"); // Write(Selection, "Repeat_Selection.brep");
// Write(Context, "Repeat_Context.brep"); // Write(Context, "Repeat_Context.brep");
if (Context.ShapeType() < Selection.ShapeType()) { if (Context.ShapeType() < Selection.ShapeType()) {
if(Selection.ShapeType() != TopAbs_SHELL) {
for (TopExp_Explorer exp(Context,Selection.ShapeType()); exp.More(); exp.Next()) { for (TopExp_Explorer exp(Context,Selection.ShapeType()); exp.More(); exp.Next()) {
if (exp.Current().IsSame(Selection)) if (exp.Current().IsSame(Selection))
aNum++; aNum++;
} }
} }
}
else if(Selection.ShapeType() == TopAbs_COMPOUND) { else if(Selection.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(Selection); TopoDS_Iterator it(Selection);
for(;it.More();it.Next()) { for(;it.More();it.Next()) {
@ -1431,6 +1457,162 @@ static Standard_Integer RepeatabilityInContext(const TopoDS_Shape& Selection,
#endif #endif
return aNum; return aNum;
} }
//=======================================================================
//function : HasAncSolid
//purpose : Returns true if Sh has ancestor solid in this context
//=======================================================================
static Standard_Boolean HasAncSolid(const TopoDS_Shape& Context,
const TopoDS_Shape& Sh, TopoDS_Shape& Solid,
Standard_Boolean& isOuter)
{
Standard_Boolean hasSolid(Standard_False);
if(Sh.ShapeType() != TopAbs_SHELL)
return hasSolid;
TopExp_Explorer exp(Context, TopAbs_SOLID);
for(;exp.More(); exp.Next()) {
for (TopoDS_Iterator it(exp.Current()) ; it.More(); it.Next()) {
if(it.Value().IsEqual(Sh)) {// is the Solid ?
Solid = exp.Current();
if(!Solid.IsNull()) {
hasSolid = Standard_True;
TopoDS_Shell anOuterShell;
if(TNaming::OuterShell(TopoDS::Solid(Solid), anOuterShell)) {
#ifdef MDTV_DEB_TSOL
Write(anOuterShell, "OuterShell.brep");
#endif
if(!anOuterShell.IsNull() && anOuterShell.IsEqual(Sh))
isOuter = Standard_True;
else
isOuter = Standard_False;
}
break;
}
}
}
if(hasSolid) break;
}
return hasSolid;
}
//=======================================================================
//function : BuildNameShell
//purpose : Names Shell
//=======================================================================
static Handle(TNaming_NamedShape) BuildNameShell (const TDF_Label& F,
TNaming_Scope& MDF,
const TopoDS_Shape& Selection,
const TopoDS_Shape& Context,
const Handle(TNaming_NamedShape)& Stop,
const Standard_Boolean Geom)
{
Handle (TNaming_NamedShape) NS;
Standard_Boolean found(Standard_False);
Handle (TNaming_Naming) Naming;
if(!F.FindAttribute(TNaming_Naming::GetID(), Naming)) {
Naming = new TNaming_Naming ();
F.AddAttribute (Naming);
TNaming_Name& theName = Naming->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 //function : BuildAggregationNam
//purpose : //purpose :
@ -1489,6 +1671,8 @@ static void BuildAggregationName (const TDF_Label& F,
if(aS.ShapeType() == TopAbs_WIRE) { if(aS.ShapeType() == TopAbs_WIRE) {
aNS = BuildNameWire (aNaming->Label(), MDF, aS, Context,Stop,Geom); 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 { else {
for (TopExp_Explorer exp(aS,atomTyp) ; exp.More(); exp.Next()) { for (TopExp_Explorer exp(aS,atomTyp) ; exp.More(); exp.Next()) {
aName.Append(BuildName (aNaming->Label(),MDF,exp.Current(),Context,Stop,Geom)); 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()); TopoDS_Iterator it(itw.Value());
for(int i=1;it.More();it.Next(),i++) { for(int i=1;it.More();it.Next(),i++) {
if(it.Value().IsEqual(S)) { 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; found = Standard_True;
#ifdef MDTV_OR #ifdef MDTV_OR
cout << "ORDER = " << i <<endl; cout << "ORDER = " << i <<endl;
@ -1705,6 +1889,9 @@ Handle(TNaming_NamedShape) TNaming_Naming::Name (const TDF_Label& F,
} else { } else {
if(S.ShapeType() == TopAbs_WIRE) if(S.ShapeType() == TopAbs_WIRE)
NS = BuildNameWire (Naming->Label(), MDF, S, 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 { else {
theName.Type(TNaming_UNION); theName.Type(TNaming_UNION);
for (TopExp_Explorer exp(S,atomType) ; exp.More(); exp.Next()) { for (TopExp_Explorer exp(S,atomType) ; exp.More(); exp.Next()) {

View File

@ -160,9 +160,9 @@ Standard_Boolean XmlMNaming_NamedShapeDriver::Paste
case TNaming_SELECTED: case TNaming_SELECTED:
aBld.Select(aNewShape, anOldShape); aBld.Select(aNewShape, anOldShape);
break; break;
case TNaming_REPLACE: // case TNaming_REPLACE:
aBld.Replace(anOldShape,aNewShape); // aBld.Replace(anOldShape,aNewShape);
break; // break;
default: default:
Standard_DomainError::Raise("TNaming_Evolution; enum term unknown"); 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_MODIFY : return ::EvolModifyString();
case TNaming_DELETE : return ::EvolDeleteString(); case TNaming_DELETE : return ::EvolDeleteString();
case TNaming_SELECTED : return ::EvolSelectedString(); case TNaming_SELECTED : return ::EvolSelectedString();
case TNaming_REPLACE : return ::EvolReplaceString(); // case TNaming_REPLACE : return ::EvolReplaceString();
default: default:
Standard_DomainError::Raise("TNaming_Evolution; enum term unknown"); 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())) else if (theString.equals (::EvolSelectedString()))
aResult = TNaming_SELECTED; aResult = TNaming_SELECTED;
else if (theString.equals (::EvolReplaceString())) else if (theString.equals (::EvolReplaceString()))
aResult = TNaming_REPLACE; aResult = TNaming_MODIFY; // for compatibility //TNaming_REPLACE;
else else
Standard_DomainError::Raise Standard_DomainError::Raise
("TNaming_Evolution; string value without enum term equivalence"); ("TNaming_Evolution; string value without enum term equivalence");

View File

@ -53,6 +53,7 @@ IMPLEMENT_DOMSTRING (NTConstShapeString, "constshape")
IMPLEMENT_DOMSTRING (NTFilterByNeighString, "filterbyneigh") IMPLEMENT_DOMSTRING (NTFilterByNeighString, "filterbyneigh")
IMPLEMENT_DOMSTRING (NTOrientationString, "orientation") IMPLEMENT_DOMSTRING (NTOrientationString, "orientation")
IMPLEMENT_DOMSTRING (NTWireInString, "wirein") IMPLEMENT_DOMSTRING (NTWireInString, "wirein")
IMPLEMENT_DOMSTRING (NTShellInString, "shellin")
IMPLEMENT_DOMSTRING (ShCompoundString, "compound") IMPLEMENT_DOMSTRING (ShCompoundString, "compound")
IMPLEMENT_DOMSTRING (ShCompsolidString, "compsolid") IMPLEMENT_DOMSTRING (ShCompsolidString, "compsolid")
@ -329,6 +330,7 @@ static const XmlObjMgt_DOMString& NameTypeToString (const TNaming_NameType theE)
case TNaming_FILTERBYNEIGHBOURGS : return ::NTFilterByNeighString(); case TNaming_FILTERBYNEIGHBOURGS : return ::NTFilterByNeighString();
case TNaming_ORIENTATION : return ::NTOrientationString(); case TNaming_ORIENTATION : return ::NTOrientationString();
case TNaming_WIREIN : return ::NTWireInString(); case TNaming_WIREIN : return ::NTWireInString();
case TNaming_SHELLIN : return ::NTShellInString();
default: default:
Standard_DomainError::Raise("TNaming_NameType; enum term unknown "); Standard_DomainError::Raise("TNaming_NameType; enum term unknown ");
} }
@ -397,6 +399,8 @@ static TNaming_NameType NameTypeFromString (const XmlObjMgt_DOMString& theString
aResult = TNaming_ORIENTATION; aResult = TNaming_ORIENTATION;
else if (theString.equals (::NTWireInString())) else if (theString.equals (::NTWireInString()))
aResult = TNaming_WIREIN; aResult = TNaming_WIREIN;
else if (theString.equals (::NTShellInString()))
aResult = TNaming_SHELLIN;
else else
Standard_DomainError::Raise Standard_DomainError::Raise
("TNaming_NameType; string value without enum term equivalence"); ("TNaming_NameType; string value without enum term equivalence");

2
tests/caf/named_shape/F6 Normal file → Executable file
View File

@ -95,7 +95,7 @@ set SL2 [TestMultipleSelection D $Prism 0]
#12 modify #12 modify
NewCommand D NewCommand D
PntOffset D $Pnt1 40 25 skip PntOffset D $Pnt1 20 25 skip
#13 recompute #13 recompute
NewCommand D NewCommand D