1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0023766: Shape orientation processing mechanism redesign

Added missed file.
Added missed MDF_Tool.cxx.
Adding test cases for issue CR23766
This commit is contained in:
szy
2013-08-15 15:36:08 +04:00
committed by bugmaster
parent 602952413f
commit 7dcac1dfa0
31 changed files with 1214 additions and 117 deletions

View File

@@ -28,7 +28,8 @@ uses
NameType from TNaming,
NamedShape from TNaming,
ListOfNamedShape from TNaming,
ShapeEnum from TopAbs,
ShapeEnum from TopAbs,
Orientation from TopAbs,
Shape from TopoDS,
Label from TDF,
LabelMap from TDF,
@@ -54,7 +55,9 @@ is
Index (me : in out; I : Integer from Standard);
ContextLabel (me : in out; theLab : Label from TDF);
Orientation (me : in out; theOrientation : Orientation from TopAbs);
---Category: Queriyng
-- ========
@@ -75,6 +78,10 @@ is
ContextLabel (me) returns Label from TDF;
---C++: return const&
Orientation (me) returns Orientation from TopAbs;
---C++: inline
---C++: return const
---Category: Resolution
@@ -98,5 +105,6 @@ fields
myIndex : Integer from Standard;
myShape : Shape from TopoDS;
myContextLabel : Label from TDF;
myOrientation : Orientation from TopAbs;
end Name;

View File

@@ -1096,13 +1096,13 @@ static TopoDS_Shape FindShape(const TNaming_DataMapOfShapeMapOfShape& DM)
Standard_Boolean isCand(Standard_True); // aS is a Candidate
TNaming_DataMapIteratorOfDataMapOfShapeMapOfShape it2(DM);
for (;it2.More();it2.Next()) {
const TopoDS_Shape& aKey2 = it2.Key();
if(aKey2 == aKey1) continue;
const TNaming_MapOfShape& aMap2 = it2.Value();
if(!aMap2.Contains(aS)) isCand = Standard_False;
const TopoDS_Shape& aKey2 = it2.Key();
if(aKey2 == aKey1) continue;
const TNaming_MapOfShape& aMap2 = it2.Value();
if(!aMap2.Contains(aS)) isCand = Standard_False;
}
if(isCand)
List.Append(aS);
if(isCand)
List.Append(aS);
}
break;
}
@@ -2176,24 +2176,13 @@ const TDF_Label& TNaming_Name::ContextLabel() const
{
return myContextLabel;
}
/*
//=======================================================================
//function : Orientation
//purpose : Set
//=======================================================================
void TNaming_Name::Orientation(const Standard_Boolean theOrientation)
void TNaming_Name::Orientation(const TopAbs_Orientation theOrientation)
{
myOrientation = theOrientation;
}
//=======================================================================
//function : ContextLabel
//purpose : Get
//=======================================================================
const Standard_Boolean TNaming_Name::Orientation() const
{
return myOrientation;
}
*/

View File

@@ -0,0 +1,31 @@
// File: TNaming_Name.lxx
// Copyright: Open CASCADE 2013
// Created on: 2013-07-03
// Created by: Sergey Zaritchny
// Copyright (c) 1999-2013 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.
//=======================================================================
//function : Orientation
//purpose : Get
//=======================================================================
inline const TopAbs_Orientation TNaming_Name::Orientation() const
{
return myOrientation;
}

View File

@@ -832,30 +832,6 @@ void TNaming_Builder::Modify(const TopoDS_Shape& oldShape,
}
//=======================================================================
//function : DummyShapeToStoreOrientation
//=======================================================================
static const TopoDS_Shape& DummyShapeToStoreOrientation (const TopAbs_Orientation Or)
{
gp_Pnt aPnt(0,0,0);
static TopoDS_Vertex aVForward, aVRev;
switch(Or) {
case TopAbs_FORWARD:
if(aVForward.IsNull()) {
aVForward = BRepBuilderAPI_MakeVertex (aPnt).Vertex();
aVForward.Orientation(TopAbs_FORWARD);
}
return aVForward;
case TopAbs_REVERSED:
if(aVRev.IsNull()) {
aVRev = BRepBuilderAPI_MakeVertex (aPnt).Vertex();
aVRev.Orientation(TopAbs_REVERSED);
}
return aVRev;
}
return aVForward;
}
//=======================================================================
//function : Select
//purpose :
@@ -869,24 +845,13 @@ void TNaming_Builder::Select (const TopoDS_Shape& S,
Standard_ConstructionError::Raise("TNaming_Builder : not same evolution");
}
TNaming_RefShape* pos;
if(S.ShapeType() != TopAbs_VERTEX &&
(S.Orientation() == TopAbs_FORWARD || S.Orientation() == TopAbs_REVERSED)) {
const TopoDS_Shape& aV = DummyShapeToStoreOrientation (S.Orientation());
if (!myShapes->myMap.IsBound(aV)) {
pos = new TNaming_RefShape(aV);
myShapes->myMap.Bind(aV,pos);
} else
pos = myShapes->myMap.ChangeFind(aV);
} else {
if (!myShapes->myMap.IsBound(InS)) {
pos = new TNaming_RefShape(InS);
myShapes->myMap.Bind(InS,pos);
}
else
pos = myShapes->myMap.ChangeFind(InS);
TNaming_RefShape* pos;
if (!myShapes->myMap.IsBound(InS)) {
pos = new TNaming_RefShape(InS);
myShapes->myMap.Bind(InS,pos);
}
else
pos = myShapes->myMap.ChangeFind(InS);
TNaming_RefShape* pns;
if (!myShapes->myMap.IsBound(S)) {

View File

@@ -231,6 +231,7 @@ static Handle(TNaming_NamedShape) BuildNS (const TDF_Label& F,
TNaming_Name& theName = Naming->ChangeName();
theName.ShapeType(S.ShapeType());
theName.Shape(S);
theName.Orientation(S.Orientation());
theName.Type(Name);
TNaming_Builder B(Naming->Label());
B.Select(S,S);
@@ -823,6 +824,7 @@ static Standard_Boolean Filter (const TDF_Label& F,
TNaming_Name& theName = NF->ChangeName();
theName.ShapeType(S.ShapeType());
theName.Shape(S);
theName.Orientation(S.Orientation());
theName.Type(TNaming_FILTERBYNEIGHBOURGS);
theName.Append(NS);
theName.StopNamedShape (Until);
@@ -1004,6 +1006,7 @@ static Handle(TNaming_NamedShape) BuildName (const TDF_Label& F
TNaming_Name& theName = Naming->ChangeName();
theName.ShapeType(Selection.ShapeType());
theName.Shape(Selection);
theName.Orientation(Selection.Orientation());
theName.Type(Ident.Type());
#ifdef MDTV_DEB_MOD
cout <<"BuildName: Inserted Naming Att at ";
@@ -1124,7 +1127,8 @@ static Handle(TNaming_NamedShape) BuildName (const TDF_Label& F
Naming = TNaming_Naming::Insert(F);
TNaming_Name& theName = Naming->ChangeName();
theName.ShapeType(Selection.ShapeType());
theName.Shape(Selection); //szy 21.10.03
theName.Shape(Selection);
theName.Orientation(Selection.Orientation());
theName.Type(TNaming_GENERATION);
theName.Append(TNaming_Tool::NamedShape(Selection,F));
theName.Append(NewNS);
@@ -1304,7 +1308,8 @@ static Handle(TNaming_NamedShape) BuildNameWire (const TDF_Label&
F.AddAttribute (Naming);
TNaming_Name& theName = Naming->ChangeName();
theName.ShapeType(Selection.ShapeType());
theName.Shape(Selection);
theName.Shape(Selection);
theName.Orientation(Selection.Orientation());
}
TNaming_Name& theName = Naming->ChangeName();
@@ -1510,7 +1515,8 @@ static Handle(TNaming_NamedShape) BuildNameShell (const TDF_Label& F,
F.AddAttribute (Naming);
TNaming_Name& theName = Naming->ChangeName();
theName.ShapeType(Selection.ShapeType());
theName.Shape(Selection);
theName.Shape(Selection);
theName.Orientation(Selection.Orientation());
}
TNaming_Name& theName = Naming->ChangeName();
@@ -1628,6 +1634,7 @@ static void BuildAggregationName (const TDF_Label& F,
TNaming_Name& theName = Naming->ChangeName();
theName.ShapeType(S.ShapeType());
theName.Shape(S);
theName.Orientation(S.Orientation());
}
#ifdef MDTV_DEB_CC
cout <<"BuildAggregationName ==> ";
@@ -1660,7 +1667,8 @@ static void BuildAggregationName (const TDF_Label& F,
Handle (TNaming_Naming) aNaming = TNaming_Naming::Insert(F);
TNaming_Name& aName = aNaming->ChangeName();
aName.ShapeType(aS.ShapeType());
aName.Shape(aS);
aName.Shape(aS);
theName.Orientation(aS.Orientation());
aName.Type(TNaming_UNION);
if (atomTyp != TopAbs_SHAPE) {
@@ -1742,6 +1750,7 @@ Handle(TNaming_NamedShape) TNaming_Naming::Name (const TDF_Label& F,
theName.ShapeType(S.ShapeType());
theName.Shape(S);
theName.Type(TNaming_ORIENTATION);
theName.Orientation(S.Orientation());
if (!TNaming_Selector::IsIdentified (F, S, NS, Geom))
NS = TNaming_Naming::Name(Naming->Label(),S,Context,Geom,0);
@@ -1847,6 +1856,7 @@ Handle(TNaming_NamedShape) TNaming_Naming::Name (const TDF_Label& F,
theName.ShapeType(S.ShapeType());// modified by vro 05.09.00
theName.Shape(S);
theName.Orientation(S.Orientation());
if(S.ShapeType() != TopAbs_WIRE)
theName.Type(TNaming_UNION);

View File

@@ -26,6 +26,8 @@
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TNaming_OldShapeIterator.hxx>
#include <TNaming_Tool.hxx>
#include <TNaming_Naming.hxx>
#include <TDF_ChildIterator.hxx>
#ifdef DEB
//#define MDTV_DEB_DESC
//#define MDTV_DEB_APPLY
@@ -173,11 +175,30 @@ void TNaming_NamingTool::CurrentShape(const TDF_LabelMap& Valid,
Standard_Boolean YaOrientationToApply(Standard_False);
TopAbs_Orientation OrientationToApply(TopAbs_FORWARD);
if(Att->Evolution() == TNaming_SELECTED) {
if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX &&
!itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX) {
YaOrientationToApply = Standard_True;
OrientationToApply = itL.OldShape().Orientation();
}
if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX) {//OR-N
Handle (TNaming_Naming) aNaming;
Lab.FindAttribute(TNaming_Naming::GetID(), aNaming);
if(!aNaming.IsNull()) {
if(aNaming->GetName().Type() == TNaming_ORIENTATION) {
OrientationToApply = aNaming->GetName().Orientation();
} else {
Handle (TNaming_Naming) aNaming2;
TDF_ChildIterator it(aNaming->Label());
for(;it.More();it.Next()) {
const TDF_Label& aLabel = it.Value();
aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming2);
if(!aNaming2.IsNull()) {
if(aNaming2->GetName().Type() == TNaming_ORIENTATION) {
OrientationToApply = aNaming2->GetName().Orientation();
break;
}
}
}
}
if(OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED)
YaOrientationToApply = Standard_True;
}
} //
}
TNaming_NewShapeIterator it(itL);
if (!it.More()) {

View File

@@ -403,7 +403,7 @@ Standard_Boolean TNaming_Selector::Select (const TopoDS_Shape& Selection,
Handle(TNaming_Naming) N = new TNaming_Naming ();
N->ChangeName().Type(TNaming_IDENTITY);
N->ChangeName().Append(NS);
N->ChangeName().Orientation(Selection.Orientation());
#ifdef BUC60862
// inserted by vro 06.09.00:
N->ChangeName().ShapeType(Selection.ShapeType());

View File

@@ -41,6 +41,7 @@
#include <TDF_AttributeMap.hxx>
#include <TDF_Tool.hxx>
#include <TDF_MapIteratorOfAttributeMap.hxx>
#include <TDF_ChildIterator.hxx>
#include <TopExp_Explorer.hxx>
#include <TNaming_ListIteratorOfListOfNamedShape.hxx>
#endif
@@ -143,7 +144,6 @@ static TopoDS_Shape MakeShape (const TopTools_MapOfShape& MS)
//function : GetShape
//purpose :
//=======================================================================
TopoDS_Shape TNaming_Tool::GetShape(const Handle(TNaming_NamedShape)& NS)
{
TNaming_Iterator itL (NS);
@@ -151,14 +151,39 @@ TopoDS_Shape TNaming_Tool::GetShape(const Handle(TNaming_NamedShape)& NS)
if(NS->Evolution() == TNaming_SELECTED) {
for (; itL.More(); itL.Next()) {
if(!itL.NewShape().IsNull()) {
if(itL.NewShape().ShapeType() != TopAbs_VERTEX &&
!itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX) {
const TopoDS_Shape& aS = itL.NewShape().Oriented(itL.OldShape().Orientation());
MS.Add(aS);
} else
MS.Add(itL.NewShape());
}
}
if(itL.NewShape().ShapeType() != TopAbs_VERTEX ) { //OR-N
Handle (TNaming_Naming) aNaming;
NS->Label().FindAttribute(TNaming_Naming::GetID(), aNaming);
if(!aNaming.IsNull()) {
if(aNaming->GetName().Orientation() == TopAbs_FORWARD ||
aNaming->GetName().Orientation() == TopAbs_REVERSED) {
TopoDS_Shape aS = itL.NewShape();
if(aNaming->GetName().Type() == TNaming_ORIENTATION) {
aS.Orientation(aNaming->GetName().Orientation());
} else {
Handle (TNaming_Naming) aNaming2;
TDF_ChildIterator it(aNaming->Label());
for(;it.More();it.Next()) {
const TDF_Label& aLabel = it.Value();
aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming2);
if(!aNaming2.IsNull()) {
if(aNaming2->GetName().Type() == TNaming_ORIENTATION) {
aS.Orientation(aNaming2->GetName().Orientation());
break;
}
}
}
}
MS.Add(aS);
} else
MS.Add(itL.NewShape());
} else
MS.Add(itL.NewShape());
} //
else
MS.Add(itL.NewShape());
}
}
} else
for (; itL.More(); itL.Next()) {
if (!itL.NewShape().IsNull()) MS.Add(itL.NewShape());
@@ -214,15 +239,35 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const Handle(TNaming_NamedShape)& Att)
for (; itL.More(); itL.Next()) {
const TopoDS_Shape& S = itL.NewShape();
if (S.IsNull()) continue;
//OR-N
Standard_Boolean YaOrientationToApply(Standard_False);
TopAbs_Orientation OrientationToApply(TopAbs_FORWARD);
if(Att->Evolution() == TNaming_SELECTED) {
if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX &&
!itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX) {
YaOrientationToApply = Standard_True;
OrientationToApply = itL.OldShape().Orientation();
}
}
if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX) {
Handle (TNaming_Naming) aNaming;
Att->Label().FindAttribute(TNaming_Naming::GetID(), aNaming);
if(!aNaming.IsNull()) {
if(aNaming->GetName().Type() == TNaming_ORIENTATION) {
OrientationToApply = aNaming->GetName().Orientation();
} else {
Handle (TNaming_Naming) aNaming2;
TDF_ChildIterator it(aNaming->Label());
for(;it.More();it.Next()) {
const TDF_Label& aLabel = it.Value();
aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming2);
if(!aNaming2.IsNull()) {
if(aNaming2->GetName().Type() == TNaming_ORIENTATION) {
OrientationToApply = aNaming2->GetName().Orientation();
break;
}
}
}
}
if(OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED)
YaOrientationToApply = Standard_True;
}
}
} //
TNaming_NewShapeIterator it(itL);
if (!it.More()) {
MS.Add(S);
@@ -259,15 +304,35 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const Handle(TNaming_NamedShape)& Att,
for (; itL.More(); itL.Next()) {
const TopoDS_Shape& S = itL.NewShape();
if (S.IsNull()) continue;
//OR-N
Standard_Boolean YaOrientationToApply(Standard_False);
TopAbs_Orientation OrientationToApply(TopAbs_FORWARD);
if(Att->Evolution() == TNaming_SELECTED) {
if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX &&
!itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX) {
YaOrientationToApply = Standard_True;
OrientationToApply = itL.OldShape().Orientation();
if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX) {
Handle (TNaming_Naming) aNaming;
Att->Label().FindAttribute(TNaming_Naming::GetID(), aNaming);
if(!aNaming.IsNull()) {
if(aNaming->GetName().Type() == TNaming_ORIENTATION) {
OrientationToApply = aNaming->GetName().Orientation();
} else {
Handle (TNaming_Naming) aNaming2;
TDF_ChildIterator it(aNaming->Label());
for(;it.More();it.Next()) {
const TDF_Label& aLabel = it.Value();
aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming2);
if(!aNaming2.IsNull()) {
if(aNaming2->GetName().Type() == TNaming_ORIENTATION) {
OrientationToApply = aNaming2->GetName().Orientation();
break;
}
}
}
}
if(OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED)
YaOrientationToApply = Standard_True;
}
}
}
} //
TNaming_NewShapeIterator it(itL);
if (!it.More()) {
MS.Add(S);