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

0026396: Taper API result differs run-to-run for identical inputs

- all data maps where shape used as a key have been replaced with indexed data maps. Now index used for iteration through this map instead of shape-key.
- new test have been added. This test allows to test stability of DraftAngle-algo.
- alignment corrections...

Removing warnings
This commit is contained in:
isn 2015-10-08 10:32:41 +03:00 committed by bugmaster
parent 6fa29cbf06
commit 8cc2a23a8e
12 changed files with 1471 additions and 1379 deletions

View File

@ -1,8 +0,0 @@
#ifndef Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo_HeaderFile
#define Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo_HeaderFile
#include <Draft_DataMapOfEdgeEdgeInfo.hxx>
#endif

View File

@ -1,8 +0,0 @@
#ifndef Draft_DataMapIteratorOfDataMapOfFaceFaceInfo_HeaderFile
#define Draft_DataMapIteratorOfDataMapOfFaceFaceInfo_HeaderFile
#include <Draft_DataMapOfFaceFaceInfo.hxx>
#endif

View File

@ -1,8 +0,0 @@
#ifndef Draft_DataMapIteratorOfDataMapOfVertexVertexInfo_HeaderFile
#define Draft_DataMapIteratorOfDataMapOfVertexVertexInfo_HeaderFile
#include <Draft_DataMapOfVertexVertexInfo.hxx>
#endif

View File

@ -14,16 +14,15 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#ifndef Draft_DataMapOfEdgeEdgeInfo_HeaderFile #ifndef Draft_IndexedDataMapOfEdgeEdgeInfo_HeaderFile
#define Draft_DataMapOfEdgeEdgeInfo_HeaderFile #define Draft_IndexedDataMapOfEdgeEdgeInfo_HeaderFile
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <Draft_EdgeInfo.hxx> #include <Draft_EdgeInfo.hxx>
#include <TopTools_ShapeMapHasher.hxx> #include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx> #include <NCollection_IndexedDataMap.hxx>
typedef NCollection_DataMap<TopoDS_Edge,Draft_EdgeInfo,TopTools_ShapeMapHasher> Draft_DataMapOfEdgeEdgeInfo; typedef NCollection_IndexedDataMap<TopoDS_Edge,Draft_EdgeInfo,TopTools_ShapeMapHasher> Draft_IndexedDataMapOfEdgeEdgeInfo;
typedef NCollection_DataMap<TopoDS_Edge,Draft_EdgeInfo,TopTools_ShapeMapHasher>::Iterator Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo;
#endif #endif

View File

@ -14,16 +14,15 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#ifndef Draft_DataMapOfFaceFaceInfo_HeaderFile #ifndef Draft_IndexedDataMapOfFaceFaceInfo_HeaderFile
#define Draft_DataMapOfFaceFaceInfo_HeaderFile #define Draft_IndexedDataMapOfFaceFaceInfo_HeaderFile
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <Draft_FaceInfo.hxx> #include <Draft_FaceInfo.hxx>
#include <TopTools_ShapeMapHasher.hxx> #include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx> #include <NCollection_IndexedDataMap.hxx>
typedef NCollection_DataMap<TopoDS_Face,Draft_FaceInfo,TopTools_ShapeMapHasher> Draft_DataMapOfFaceFaceInfo; typedef NCollection_IndexedDataMap<TopoDS_Face,Draft_FaceInfo,TopTools_ShapeMapHasher> Draft_IndexedDataMapOfFaceFaceInfo;
typedef NCollection_DataMap<TopoDS_Face,Draft_FaceInfo,TopTools_ShapeMapHasher>::Iterator Draft_DataMapIteratorOfDataMapOfFaceFaceInfo;
#endif #endif

View File

@ -14,16 +14,15 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#ifndef Draft_DataMapOfVertexVertexInfo_HeaderFile #ifndef Draft_IndexedDataMapOfVertexVertexInfo_HeaderFile
#define Draft_DataMapOfVertexVertexInfo_HeaderFile #define Draft_IndexedDataMapOfVertexVertexInfo_HeaderFile
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <Draft_VertexInfo.hxx> #include <Draft_VertexInfo.hxx>
#include <TopTools_ShapeMapHasher.hxx> #include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx> #include <NCollection_IndexedDataMap.hxx>
typedef NCollection_DataMap<TopoDS_Vertex,Draft_VertexInfo,TopTools_ShapeMapHasher> Draft_DataMapOfVertexVertexInfo; typedef NCollection_IndexedDataMap<TopoDS_Vertex,Draft_VertexInfo,TopTools_ShapeMapHasher> Draft_IndexedDataMapOfVertexVertexInfo;
typedef NCollection_DataMap<TopoDS_Vertex,Draft_VertexInfo,TopTools_ShapeMapHasher>::Iterator Draft_DataMapIteratorOfDataMapOfVertexVertexInfo;
#endif #endif

View File

@ -18,8 +18,6 @@
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepTools.hxx> #include <BRepTools.hxx>
#include <Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo.hxx>
#include <Draft_DataMapIteratorOfDataMapOfFaceFaceInfo.hxx>
#include <Draft_EdgeInfo.hxx> #include <Draft_EdgeInfo.hxx>
#include <Draft_FaceInfo.hxx> #include <Draft_FaceInfo.hxx>
#include <Draft_Modification.hxx> #include <Draft_Modification.hxx>
@ -129,44 +127,60 @@ Standard_Boolean Draft_Modification::Add(const TopoDS_Face& F,
void Draft_Modification::Remove(const TopoDS_Face& F) void Draft_Modification::Remove(const TopoDS_Face& F)
{ {
if (!myFMap.IsBound(F) || myComp) { if (!myFMap.Contains(F) || myComp) {
Standard_NoSuchObject::Raise(); Standard_NoSuchObject::Raise();
} }
conneF.Clear(); conneF.Clear();
TopTools_ListIteratorOfListOfShape ltod; TopTools_ListIteratorOfListOfShape ltod;
curFace = myFMap(F).RootFace(); curFace = myFMap.FindFromKey(F).RootFace();
Draft_DataMapIteratorOfDataMapOfFaceFaceInfo itf(myFMap); for (Standard_Integer i = 1; i <= myFMap.Extent(); i++)
while (itf.More()) { {
const TopoDS_Face& theF = itf.Key(); const TopoDS_Face& theF = myFMap.FindKey(i);
if (myFMap(theF).RootFace().IsSame(curFace)) { if (myFMap.FindFromKey(theF).RootFace().IsSame(curFace)) {
conneF.Append(theF); conneF.Append(theF);
if (theF.IsSame(badShape)) { if (theF.IsSame(badShape)) {
badShape.Nullify(); badShape.Nullify();
} }
} }
itf.Next();
} }
ltod.Initialize(conneF); ltod.Initialize(conneF);
Standard_Integer IndToReplace = 0;
while (ltod.More()) { while (ltod.More()) {
myFMap.UnBind(TopoDS::Face(ltod.Value())); IndToReplace = myFMap.FindIndex(TopoDS::Face(ltod.Value()));
if (IndToReplace)
{
Standard_Integer LInd = myFMap.Extent();
TopoDS_Face LF = myFMap.FindKey(LInd);
Draft_FaceInfo LFInfo = myFMap.FindFromIndex(LInd);
myFMap.RemoveLast();
if (IndToReplace != LInd)
myFMap.Substitute(IndToReplace, LF, LFInfo);
}
ltod.Next(); ltod.Next();
} }
conneF.Clear(); conneF.Clear();
Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo ite(myEMap); for (Standard_Integer i = 1; i <= myEMap.Extent(); i++)
while (ite.More()) { {
const TopoDS_Edge& theE = ite.Key(); const TopoDS_Edge& theE = myEMap.FindKey(i);
if (myEMap(theE).RootFace().IsSame(curFace)) { if (myEMap.FindFromKey(theE).RootFace().IsSame(curFace))
conneF.Append(theE); conneF.Append(theE);
} }
ite.Next();
}
ltod.Initialize(conneF); ltod.Initialize(conneF);
while (ltod.More()) { while (ltod.More()) {
myEMap.UnBind(TopoDS::Edge(ltod.Value())); IndToReplace = myFMap.FindIndex(TopoDS::Face(ltod.Value()));
if (IndToReplace)
{
Standard_Integer LInd = myEMap.Extent();
TopoDS_Edge LF = myEMap.FindKey(LInd);
Draft_EdgeInfo LFInfo = myEMap.FindFromIndex(LInd);
myEMap.RemoveLast();
if (IndToReplace != LInd)
myEMap.Substitute(IndToReplace, LF, LFInfo);
}
ltod.Next(); ltod.Next();
} }
} }
@ -212,22 +226,21 @@ const TopoDS_Shape& Draft_Modification::ProblematicShape() const
const TopTools_ListOfShape & Draft_Modification::ConnectedFaces(const TopoDS_Face& F) const TopTools_ListOfShape & Draft_Modification::ConnectedFaces(const TopoDS_Face& F)
{ {
if (!myFMap.IsBound(F)) { if (!myFMap.Contains(F)) {
Standard_NoSuchObject::Raise(); Standard_NoSuchObject::Raise();
} }
if (!IsDone()) { if (!IsDone()) {
StdFail_NotDone::Raise(); StdFail_NotDone::Raise();
} }
conneF.Clear(); conneF.Clear();
curFace = myFMap(F).RootFace(); curFace = myFMap.FindFromKey(F).RootFace();
Draft_DataMapIteratorOfDataMapOfFaceFaceInfo itf(myFMap); for (Standard_Integer i = 1; i <= myFMap.Extent(); i++)
while (itf.More()) { {
const TopoDS_Face& theF = itf.Key(); const TopoDS_Face& theF = myFMap.FindKey(i);
if (myFMap(theF).RootFace().IsSame(curFace)) { if (myFMap.FindFromKey(theF).RootFace().IsSame(curFace)) {
conneF.Append(theF); conneF.Append(theF);
} }
itf.Next();
} }
return conneF; return conneF;
@ -248,13 +261,12 @@ const TopTools_ListOfShape & Draft_Modification::ModifiedFaces()
} }
conneF.Clear(); conneF.Clear();
Draft_DataMapIteratorOfDataMapOfFaceFaceInfo itf(myFMap); for (Standard_Integer i = 1; i <= myFMap.Extent(); i++)
while (itf.More()) { {
const TopoDS_Face& theF = itf.Key(); const TopoDS_Face& theF = myFMap.FindKey(i);
if (!myFMap(theF).RootFace().IsNull()) { if (!myFMap.FindFromKey(theF).RootFace().IsNull()) {
conneF.Append(theF); conneF.Append(theF);
} }
itf.Next();
} }
return conneF; return conneF;
@ -277,7 +289,7 @@ Standard_Boolean Draft_Modification::NewSurface(const TopoDS_Face& F,
{ {
if (!IsDone()) {Standard_DomainError::Raise();} if (!IsDone()) {Standard_DomainError::Raise();}
if (!myFMap.IsBound(F) || !myFMap(F).NewGeometry()) { if (!myFMap.Contains(F) || !myFMap.FindFromKey(F).NewGeometry()) {
return Standard_False; return Standard_False;
} }
@ -289,7 +301,7 @@ Standard_Boolean Draft_Modification::NewSurface(const TopoDS_Face& F,
L.Identity(); L.Identity();
S = myFMap(F).Geometry(); S = myFMap.FindFromKey(F).Geometry();
return Standard_True; return Standard_True;
} }
@ -307,17 +319,17 @@ Standard_Boolean Draft_Modification::NewCurve(const TopoDS_Edge& E,
{ {
if (!IsDone()) {Standard_DomainError::Raise();} if (!IsDone()) {Standard_DomainError::Raise();}
if (!myEMap.IsBound(E)) if (!myEMap.Contains(E))
return Standard_False; return Standard_False;
const Draft_EdgeInfo& Einf= myEMap(E); const Draft_EdgeInfo& Einf= myEMap.FindFromKey(E);
if (!myEMap(E).NewGeometry()) if (!myEMap.FindFromKey(E).NewGeometry())
return Standard_False; return Standard_False;
Tol = Einf.Tolerance(); Tol = Einf.Tolerance();
Tol = Max(Tol, BRep_Tool::Tolerance(E)); Tol = Max(Tol, BRep_Tool::Tolerance(E));
L.Identity(); L.Identity();
C = myEMap(E).Geometry(); C = myEMap.FindFromKey(E).Geometry();
return Standard_True; return Standard_True;
@ -335,12 +347,12 @@ Standard_Boolean Draft_Modification::NewPoint(const TopoDS_Vertex& V,
{ {
if (!IsDone()) {Standard_DomainError::Raise();}; if (!IsDone()) {Standard_DomainError::Raise();};
if (!myVMap.IsBound(V)) { if (!myVMap.Contains(V)) {
return Standard_False; return Standard_False;
} }
Tol = BRep_Tool::Tolerance(V); Tol = BRep_Tool::Tolerance(V);
P = myVMap(V).Geometry(); P = myVMap.FindFromKey(V).Geometry();
return Standard_True; return Standard_True;
} }
@ -360,16 +372,16 @@ Standard_Boolean Draft_Modification::NewCurve2d(const TopoDS_Edge& E,
if (!IsDone()) {Standard_DomainError::Raise();}; if (!IsDone()) {Standard_DomainError::Raise();};
if (!myEMap.IsBound(E)) { if (!myEMap.Contains(E)) {
return Standard_False; return Standard_False;
} }
Standard_Real Fp,Lp; Standard_Real Fp,Lp;
BRep_Tool::Range(NewE,Fp,Lp); BRep_Tool::Range(NewE,Fp,Lp);
Handle(Geom_Surface) SB = myFMap(F).Geometry(); Handle(Geom_Surface) SB = myFMap.FindFromKey(F).Geometry();
const Draft_EdgeInfo& Einf = myEMap(E); const Draft_EdgeInfo& Einf = myEMap.FindFromKey(E);
if ( Einf.FirstFace().IsSame(F) && !Einf.FirstPC().IsNull()) { if ( Einf.FirstFace().IsSame(F) && !Einf.FirstPC().IsNull()) {
C = Einf.FirstPC(); C = Einf.FirstPC();
} }
@ -378,7 +390,7 @@ Standard_Boolean Draft_Modification::NewCurve2d(const TopoDS_Edge& E,
} }
else { else {
if (!myEMap(E).NewGeometry()) { if (!myEMap.FindFromKey(E).NewGeometry()) {
Standard_Real Fpi,Lpi; Standard_Real Fpi,Lpi;
BRep_Tool::Range(E,Fpi,Lpi); BRep_Tool::Range(E,Fpi,Lpi);
if (Fpi <= Fp && Fp <= Lpi && Fpi <= Lp && Lp <= Lpi) { if (Fpi <= Fp && Fp <= Lpi && Fpi <= Lp && Lp <= Lpi) {
@ -390,7 +402,7 @@ Standard_Boolean Draft_Modification::NewCurve2d(const TopoDS_Edge& E,
// if (!BRep_Tool::IsClosed(E,F)) { // if (!BRep_Tool::IsClosed(E,F)) {
BRep_Tool::Range(NewE,Fp,Lp); BRep_Tool::Range(NewE,Fp,Lp);
Handle(Geom_TrimmedCurve) TC = new Geom_TrimmedCurve(myEMap(E).Geometry(), Handle(Geom_TrimmedCurve) TC = new Geom_TrimmedCurve(myEMap.FindFromKey(E).Geometry(),
Fp,Lp); Fp,Lp);
Fp = TC->FirstParameter(); Fp = TC->FirstParameter();
Lp = TC->LastParameter(); Lp = TC->LastParameter();
@ -464,12 +476,12 @@ Standard_Boolean Draft_Modification::NewParameter(const TopoDS_Vertex& V,
if (!IsDone()) {Standard_DomainError::Raise();}; if (!IsDone()) {Standard_DomainError::Raise();};
if (!myVMap.IsBound(V)) { if (!myVMap.Contains(V)) {
return Standard_False; return Standard_False;
} }
P = myVMap(V).Parameter(E); P = myVMap.ChangeFromKey(V).Parameter(E);
Handle(Geom_Curve) GC = myEMap(E).Geometry(); Handle(Geom_Curve) GC = myEMap.FindFromKey(E).Geometry();
Handle(Standard_Type) typc = GC->DynamicType(); Handle(Standard_Type) typc = GC->DynamicType();
if (typc == STANDARD_TYPE(Geom_TrimmedCurve)) { if (typc == STANDARD_TYPE(Geom_TrimmedCurve)) {
GC = Handle(Geom_TrimmedCurve)::DownCast(GC); GC = Handle(Geom_TrimmedCurve)::DownCast(GC);
@ -479,8 +491,8 @@ Standard_Boolean Draft_Modification::NewParameter(const TopoDS_Vertex& V,
if (GC->IsClosed()) { if (GC->IsClosed()) {
TopoDS_Vertex FV = TopExp::FirstVertex(E); TopoDS_Vertex FV = TopExp::FirstVertex(E);
Standard_Real paramf; Standard_Real paramf;
if (myVMap.IsBound(FV)) { if (myVMap.Contains(FV)) {
paramf = myVMap(FV).Parameter(E); paramf = myVMap.ChangeFromKey(FV).Parameter(E);
} }
else { else {
paramf = BRep_Tool::Parameter(FV,E); paramf = BRep_Tool::Parameter(FV,E);

View File

@ -20,9 +20,9 @@
#include <Standard.hxx> #include <Standard.hxx>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <Draft_DataMapOfFaceFaceInfo.hxx> #include <Draft_IndexedDataMapOfFaceFaceInfo.hxx>
#include <Draft_DataMapOfEdgeEdgeInfo.hxx> #include <Draft_IndexedDataMapOfEdgeEdgeInfo.hxx>
#include <Draft_DataMapOfVertexVertexInfo.hxx> #include <Draft_IndexedDataMapOfVertexVertexInfo.hxx>
#include <Standard_Boolean.hxx> #include <Standard_Boolean.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <Draft_ErrorStatus.hxx> #include <Draft_ErrorStatus.hxx>
@ -184,9 +184,9 @@ private:
Standard_EXPORT Handle(Geom_Surface) NewSurface (const Handle(Geom_Surface)& S, const TopAbs_Orientation OriS, const gp_Dir& Direction, const Standard_Real Angle, const gp_Pln& NeutralPlane); Standard_EXPORT Handle(Geom_Surface) NewSurface (const Handle(Geom_Surface)& S, const TopAbs_Orientation OriS, const gp_Dir& Direction, const Standard_Real Angle, const gp_Pln& NeutralPlane);
Draft_DataMapOfFaceFaceInfo myFMap; Draft_IndexedDataMapOfFaceFaceInfo myFMap;
Draft_DataMapOfEdgeEdgeInfo myEMap; Draft_IndexedDataMapOfEdgeEdgeInfo myEMap;
Draft_DataMapOfVertexVertexInfo myVMap; Draft_IndexedDataMapOfVertexVertexInfo myVMap;
Standard_Boolean myComp; Standard_Boolean myComp;
TopoDS_Shape myShape; TopoDS_Shape myShape;
TopoDS_Shape badShape; TopoDS_Shape badShape;

View File

@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <Adaptor3d_CurveOnSurface.hxx> #include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor3d_HCurveOnSurface.hxx> #include <Adaptor3d_HCurveOnSurface.hxx>
#include <Adaptor3d_SurfaceOfLinearExtrusion.hxx> #include <Adaptor3d_SurfaceOfLinearExtrusion.hxx>
@ -25,9 +24,6 @@
#include <BRepExtrema_ExtPC.hxx> #include <BRepExtrema_ExtPC.hxx>
#include <BRepLib_MakeFace.hxx> #include <BRepLib_MakeFace.hxx>
#include <BRepTools.hxx> #include <BRepTools.hxx>
#include <Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo.hxx>
#include <Draft_DataMapIteratorOfDataMapOfFaceFaceInfo.hxx>
#include <Draft_DataMapIteratorOfDataMapOfVertexVertexInfo.hxx>
#include <Draft_EdgeInfo.hxx> #include <Draft_EdgeInfo.hxx>
#include <Draft_FaceInfo.hxx> #include <Draft_FaceInfo.hxx>
#include <Draft_Modification.hxx> #include <Draft_Modification.hxx>
@ -105,8 +101,8 @@
#include <TopTools_MapIteratorOfMapOfShape.hxx> #include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
static Standard_Boolean Choose(const Draft_DataMapOfFaceFaceInfo&, static Standard_Boolean Choose(const Draft_IndexedDataMapOfFaceFaceInfo&,
Draft_DataMapOfEdgeEdgeInfo&, Draft_IndexedDataMapOfEdgeEdgeInfo&,
const TopoDS_Vertex&, const TopoDS_Vertex&,
Draft_VertexInfo&, Draft_VertexInfo&,
GeomAdaptor_Curve&, GeomAdaptor_Curve&,
@ -147,7 +143,7 @@ Standard_Boolean Draft_Modification::InternalAdd(const TopoDS_Face& F,
const Standard_Boolean Flag) const Standard_Boolean Flag)
{ {
if (myFMap.IsBound(F)) { if (myFMap.Contains(F)) {
return (badShape.IsNull()); return (badShape.IsNull());
} }
@ -275,9 +271,9 @@ Standard_Boolean Draft_Modification::InternalAdd(const TopoDS_Face& F,
if (postponed || S != NewS) { if (postponed || S != NewS) {
Draft_FaceInfo FI(NewS,Standard_True); Draft_FaceInfo FI(NewS,Standard_True);
FI.RootFace(curFace); FI.RootFace(curFace);
myFMap.Bind(F,FI); myFMap.Add(F,FI);
if (postponed) { if (postponed) {
myFMap(F).ChangeCurve() = theCircle; myFMap.ChangeFromKey(F).ChangeCurve() = theCircle;
} }
} }
@ -285,7 +281,7 @@ Standard_Boolean Draft_Modification::InternalAdd(const TopoDS_Face& F,
TopTools_MapOfShape MapOfE; TopTools_MapOfShape MapOfE;
while (expl.More() && badShape.IsNull()) { while (expl.More() && badShape.IsNull()) {
const TopoDS_Edge& edg = TopoDS::Edge(expl.Current()); const TopoDS_Edge& edg = TopoDS::Edge(expl.Current());
if (!myEMap.IsBound(edg)) { if (!myEMap.Contains(edg)) {
Standard_Boolean addedg = Standard_False; Standard_Boolean addedg = Standard_False;
Standard_Boolean addface = Standard_False; Standard_Boolean addface = Standard_False;
TopoDS_Face OtherF; TopoDS_Face OtherF;
@ -323,7 +319,7 @@ Standard_Boolean Draft_Modification::InternalAdd(const TopoDS_Face& F,
} }
if (addedg) { if (addedg) {
if (postponed) { if (postponed) {
myFMap(F).Add(OtherF); myFMap.ChangeFromKey(F).Add(OtherF);
} }
Standard_Real f,l; Standard_Real f,l;
TopLoc_Location L; TopLoc_Location L;
@ -369,7 +365,7 @@ Standard_Boolean Draft_Modification::InternalAdd(const TopoDS_Face& F,
EInf.ChangeGeometry() = NewC; EInf.ChangeGeometry() = NewC;
EInf.RootFace(curFace); EInf.RootFace(curFace);
myEMap.Bind(edg,EInf); myEMap.Add(edg,EInf);
MapOfE.Add(edg); MapOfE.Add(edg);
if (addface) { if (addface) {
Standard_Boolean Fl = Flag; Standard_Boolean Fl = Flag;
@ -382,12 +378,33 @@ Standard_Boolean Draft_Modification::InternalAdd(const TopoDS_Face& F,
Handle(Standard_Type) typS = alocalSurface->DynamicType(); Handle(Standard_Type) typS = alocalSurface->DynamicType();
if (typS == STANDARD_TYPE(Geom_CylindricalSurface) || if (typS == STANDARD_TYPE(Geom_CylindricalSurface) ||
typS == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) { typS == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) {
if ( myFMap.IsBound(F)) { if ( myFMap.Contains(F)) {
if ( Flag == Standard_False && !postponed) { if ( Flag == Standard_False && !postponed) {
myFMap.UnBind(F); Standard_Integer IndToReplace = myFMap.FindIndex(F);
if (IndToReplace) {
Standard_Integer LInd = myFMap.Extent();
TopoDS_Face LF = myFMap.FindKey(LInd);
Draft_FaceInfo LFInfo = myFMap.FindFromIndex(LInd);
myFMap.RemoveLast();
if (IndToReplace != LInd)
myFMap.Substitute(IndToReplace, LF, LFInfo);
}
TopTools_MapIteratorOfMapOfShape itm(MapOfE); TopTools_MapIteratorOfMapOfShape itm(MapOfE);
for ( ; itm.More(); itm.Next()) for ( ; itm.More(); itm.Next())
myEMap.UnBind(TopoDS::Edge(itm.Key())); {
Standard_Integer IndToReplace = myEMap.FindIndex(TopoDS::Edge(itm.Key()));
if ( IndToReplace )
{
Standard_Integer LInd = myEMap.Extent();
TopoDS_Edge LE = myEMap.FindKey(LInd);
Draft_EdgeInfo LEInfo = myEMap.FindFromIndex(LInd);
myEMap.RemoveLast();
if (IndToReplace != LInd)
myEMap.Substitute(IndToReplace, LE, LEInfo);
}
}
} }
} }
} }
@ -411,8 +428,6 @@ Standard_Boolean Draft_Modification::Propagate ()
if (!badShape.IsNull()) return Standard_False; if (!badShape.IsNull()) return Standard_False;
Draft_DataMapIteratorOfDataMapOfFaceFaceInfo itf(myFMap);
// Set all edges and vertices of modified faces // Set all edges and vertices of modified faces
TopoDS_Face F; TopoDS_Face F;
TopoDS_Edge E; TopoDS_Edge E;
@ -420,36 +435,36 @@ Standard_Boolean Draft_Modification::Propagate ()
TopExp_Explorer editer; TopExp_Explorer editer;
TopExp_Explorer vtiter; TopExp_Explorer vtiter;
while (itf.More()) { for (Standard_Integer i = 1; i <= myFMap.Extent(); i++)
const TopoDS_Face& Fc = itf.Key(); {
const TopoDS_Face& Fc = myFMap.FindKey(i);
// Exploration of the edges of the face // Exploration of the edges of the face
editer.Init(Fc,TopAbs_EDGE); editer.Init(Fc,TopAbs_EDGE);
while (editer.More()) { while (editer.More()) {
E = TopoDS::Edge(editer.Current()); E = TopoDS::Edge(editer.Current());
if (!myEMap.IsBound(E)) { if (!myEMap.Contains(E)) {
Draft_EdgeInfo EInf(Standard_True); Draft_EdgeInfo EInf(Standard_True);
myEMap.Bind(E,EInf); myEMap.Add(E,EInf);
} }
myEMap(E).Add(Fc); myEMap.ChangeFromKey(E).Add(Fc);
// Exploration of the vertices of the edge // Exploration of the vertices of the edge
vtiter.Init(E,TopAbs_VERTEX); vtiter.Init(E,TopAbs_VERTEX);
while (vtiter.More()) { while (vtiter.More()) {
V = TopoDS::Vertex(vtiter.Current()); V = TopoDS::Vertex(vtiter.Current());
if (!myVMap.IsBound(V)) { if (!myVMap.Contains(V)) {
Draft_VertexInfo VInf; Draft_VertexInfo VInf;
myVMap.Bind(V,VInf); myVMap.Add(V,VInf);
} }
myVMap(V).Add(E); myVMap.ChangeFromKey(V).Add(E);
myVMap(V).ChangeParameter(E) = BRep_Tool::Parameter(V, E); myVMap.ChangeFromKey(V).ChangeParameter(E) = BRep_Tool::Parameter(V, E);
vtiter.Next(); vtiter.Next();
} }
editer.Next(); editer.Next();
} }
itf.Next();
} }
@ -458,10 +473,9 @@ Standard_Boolean Draft_Modification::Propagate ()
// Set edges containing modified vertices. // Set edges containing modified vertices.
Draft_DataMapIteratorOfDataMapOfVertexVertexInfo itv(myVMap); for (Standard_Integer i = 1; i <= myVMap.Extent(); i++)
{
while (itv.More()) { const TopoDS_Vertex& Vt = myVMap.FindKey(i);
const TopoDS_Vertex& Vt = itv.Key();
// Exploration of the ancestors of the vertex // Exploration of the ancestors of the vertex
anc.Init(myShape,TopAbs_EDGE); anc.Init(myShape,TopAbs_EDGE);
@ -478,29 +492,26 @@ Standard_Boolean Draft_Modification::Propagate ()
vtiter.Next(); vtiter.Next();
} }
if (found) { if (found) {
if (!myEMap.IsBound(E)) { if (!myEMap.Contains(E)) {
Draft_EdgeInfo EInf(Standard_False); Draft_EdgeInfo EInf(Standard_False);
myEMap.Bind(E,EInf); myEMap.Add(E,EInf);
} }
myVMap(Vt).Add(E); myVMap.ChangeFromKey(Vt).Add(E);
myVMap(Vt).ChangeParameter(E) = BRep_Tool::Parameter(Vt, E); myVMap.ChangeFromKey(Vt).ChangeParameter(E) = BRep_Tool::Parameter(Vt, E);
} }
anc.Next(); anc.Next();
} }
itv.Next();
} }
// Set faces containing modified edges // Set faces containing modified edges
for (Standard_Integer i = 1; i <= myEMap.Extent(); i++)
Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo ite(myEMap); {
const TopoDS_Edge& Ed = myEMap.FindKey(i);
while (ite.More()) {
const TopoDS_Edge& Ed = ite.Key();
TopTools_ListIteratorOfListOfShape it; TopTools_ListIteratorOfListOfShape it;
for (it.Initialize(myEFMap.FindFromKey(Ed)); it.More(); it.Next()) { for (it.Initialize(myEFMap.FindFromKey(Ed)); it.More(); it.Next()) {
F = TopoDS::Face(it.Value()); F = TopoDS::Face(it.Value());
if (!myFMap.IsBound(F)) { if (!myFMap.Contains(F)) {
TopLoc_Location L; TopLoc_Location L;
Handle(Geom_Surface) S = BRep_Tool::Surface(F,L); Handle(Geom_Surface) S = BRep_Tool::Surface(F,L);
Handle(Geom_Surface) NewS = Handle(Geom_Surface) NewS =
@ -516,25 +527,24 @@ Standard_Boolean Draft_Modification::Propagate ()
Standard_Real deltav = 10.*(vmax-vmin); Standard_Real deltav = 10.*(vmax-vmin);
vmin = vmin - deltav; vmin = vmin - deltav;
vmax = vmax + deltav; vmax = vmax + deltav;
NewS = NewS = new Geom_RectangularTrimmedSurface(NewS,0.,2.*M_PI,vmin,vmax);
new Geom_RectangularTrimmedSurface(NewS,0.,2.*M_PI,vmin,vmax);
} }
} }
Draft_FaceInfo FInf(NewS,Standard_False); Draft_FaceInfo FInf(NewS,Standard_False);
myFMap.Bind(F,FInf); myFMap.Add(F,FInf);
} }
myEMap(Ed).Add(F); myEMap.ChangeFromKey(Ed).Add(F);
} }
ite.Next();
} }
// Try to add faces for free borders... // Try to add faces for free borders...
// JAG 09.11.95 // JAG 09.11.95
ite.Initialize(myEMap); for (Standard_Integer i = 1; i <= myEMap.Extent(); i++)
for (; ite.More(); ite.Next()) { {
Draft_EdgeInfo& Einf = myEMap(ite.Key()); Draft_EdgeInfo& Einf = myEMap.ChangeFromIndex(i);
if (Einf.NewGeometry() && Einf.Geometry().IsNull() && if (Einf.NewGeometry() &&
Einf.Geometry().IsNull() &&
Einf.SecondFace().IsNull()) { Einf.SecondFace().IsNull()) {
TopLoc_Location Loc; TopLoc_Location Loc;
@ -544,7 +554,8 @@ Standard_Boolean Draft_Modification::Propagate ()
Handle(Geom_Surface) S2; Handle(Geom_Surface) S2;
Standard_Real f,l; Standard_Real f,l;
Handle(Geom_Curve) C = BRep_Tool::Curve(ite.Key(),Loc,f,l); const TopoDS_Edge& EK = myEMap.FindKey(i);
Handle(Geom_Curve) C = BRep_Tool::Curve(EK,Loc,f,l);
C = Handle(Geom_Curve)::DownCast(C->Transformed(Loc.Transformation())); C = Handle(Geom_Curve)::DownCast(C->Transformed(Loc.Transformation()));
if (C->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) { if (C->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) {
C = Handle(Geom_TrimmedCurve)::DownCast(C)->BasisCurve(); C = Handle(Geom_TrimmedCurve)::DownCast(C)->BasisCurve();
@ -570,27 +581,28 @@ Standard_Boolean Draft_Modification::Propagate ()
} }
else { else {
badShape = TopoDS::Edge(ite.Key()); badShape = EK;
errStat = Draft_EdgeRecomputation; errStat = Draft_EdgeRecomputation;
break; // leave from for break; // leave from for
} }
} }
else { // on the plane else { // on the plane
Draft_DataMapIteratorOfDataMapOfVertexVertexInfo anewitv(myVMap); for (Standard_Integer j = 1; j <= myVMap.Extent(); j++)
while (anewitv.More()) { {
Draft_VertexInfo& Vinf = myVMap(anewitv.Key()); Draft_VertexInfo& Vinf = myVMap.ChangeFromIndex(j);
for (Vinf.InitEdgeIterator();Vinf.MoreEdge();Vinf.NextEdge()) { for (Vinf.InitEdgeIterator();Vinf.MoreEdge();Vinf.NextEdge()) {
if (Vinf.Edge().IsSame(ite.Key())) { if (Vinf.Edge().IsSame(EK)) {
break; break;
} }
} }
if (Vinf.MoreEdge()) { if (Vinf.MoreEdge()) {
for (Vinf.InitEdgeIterator();Vinf.MoreEdge();Vinf.NextEdge()) { for (Vinf.InitEdgeIterator();Vinf.MoreEdge();Vinf.NextEdge()) {
const TopoDS_Edge& edg = Vinf.Edge(); const TopoDS_Edge& edg = Vinf.Edge();
if (!edg.IsSame(ite.Key())) { if (!edg.IsSame(EK)) {
if (!myEMap(edg).FirstFace().IsSame(Einf.FirstFace()) && const Draft_EdgeInfo& EI = myEMap.FindFromKey(edg);
(myEMap(edg).SecondFace().IsNull() || if (!EI.FirstFace().IsSame(Einf.FirstFace()) &&
!myEMap(edg).SecondFace().IsSame(Einf.FirstFace()))) { (EI.SecondFace().IsNull() ||
!EI.SecondFace().IsSame(Einf.FirstFace()))) {
break; break;
} }
} }
@ -614,7 +626,7 @@ Standard_Boolean Draft_Modification::Propagate ()
HCur = new GeomAdaptor_HCurve(C); HCur = new GeomAdaptor_HCurve(C);
} }
else { else {
badShape = TopoDS::Edge(ite.Key()); badShape = EK;
errStat = Draft_EdgeRecomputation; errStat = Draft_EdgeRecomputation;
break; // leave from while break; // leave from while
} }
@ -642,13 +654,13 @@ Standard_Boolean Draft_Modification::Propagate ()
} }
else { else {
badShape = TopoDS::Edge(ite.Key()); badShape = EK;
errStat = Draft_EdgeRecomputation; errStat = Draft_EdgeRecomputation;
break; // leave from while break; // leave from while
} }
break; break;
} }
anewitv.Next(); //j++;
} }
} }
@ -658,7 +670,7 @@ Standard_Boolean Draft_Modification::Propagate ()
B.MakeFace(TheNewFace,S2,Precision::Confusion()); B.MakeFace(TheNewFace,S2,Precision::Confusion());
Einf.Add(TheNewFace); Einf.Add(TheNewFace);
Draft_FaceInfo FI(S2,Standard_False); Draft_FaceInfo FI(S2,Standard_False);
myFMap.Bind(TheNewFace,FI); myFMap.Add(TheNewFace,FI);
} }
else { else {
break; // leave from for break; // leave from for
@ -689,23 +701,24 @@ void Draft_Modification::Perform ()
// Calculate eventual faces // Calculate eventual faces
Draft_DataMapIteratorOfDataMapOfFaceFaceInfo itf(myFMap); for (Standard_Integer i = 1; i <= myFMap.Extent(); i++)
while (itf.More()) { {
Draft_FaceInfo& Finf = myFMap(itf.Key()); const TopoDS_Face& FK = myFMap.FindKey(i);
Draft_FaceInfo& Finf = myFMap.ChangeFromIndex(i);
if (Finf.NewGeometry() && Finf.Geometry().IsNull()) { if (Finf.NewGeometry() && Finf.Geometry().IsNull()) {
const TopoDS_Face& F1 = Finf.FirstFace(); const TopoDS_Face& F1 = Finf.FirstFace();
const TopoDS_Face& F2 = Finf.SecondFace(); const TopoDS_Face& F2 = Finf.SecondFace();
if (F1.IsNull() || F2.IsNull()) { if (F1.IsNull() || F2.IsNull()) {
errStat = Draft_FaceRecomputation; errStat = Draft_FaceRecomputation;
badShape = TopoDS::Face(itf.Key()); badShape = FK;
return; return;
} }
Handle(Geom_Surface) S1 = myFMap(F1).Geometry(); Handle(Geom_Surface) S1 = myFMap.FindFromKey(F1).Geometry();
Handle(Geom_Surface) S2 = myFMap(F2).Geometry(); Handle(Geom_Surface) S2 = myFMap.FindFromKey(F2).Geometry();
if (S1.IsNull() || S2.IsNull()) { if (S1.IsNull() || S2.IsNull()) {
errStat = Draft_FaceRecomputation; errStat = Draft_FaceRecomputation;
badShape = TopoDS::Face(itf.Key()); badShape = FK;
return; return;
} }
if (S1->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { if (S1->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
@ -720,7 +733,7 @@ void Draft_Modification::Perform ()
Handle(Geom_Plane) P2 = Handle(Geom_Plane)::DownCast(S2); Handle(Geom_Plane) P2 = Handle(Geom_Plane)::DownCast(S2);
if (P1.IsNull() || P2.IsNull()) { if (P1.IsNull() || P2.IsNull()) {
errStat = Draft_FaceRecomputation; errStat = Draft_FaceRecomputation;
badShape = TopoDS::Face(itf.Key()); badShape = FK;
return; return;
} }
gp_Pln pp1 = P1->Pln(); gp_Pln pp1 = P1->Pln();
@ -729,7 +742,7 @@ void Draft_Modification::Perform ()
Precision::Angular(),Precision::Confusion()); Precision::Angular(),Precision::Confusion());
if (!i2p.IsDone() || i2p.TypeInter() != IntAna_Line) { if (!i2p.IsDone() || i2p.TypeInter() != IntAna_Line) {
errStat = Draft_FaceRecomputation; errStat = Draft_FaceRecomputation;
badShape = TopoDS::Face(itf.Key()); badShape = FK;
return; return;
} }
@ -737,7 +750,7 @@ void Draft_Modification::Perform ()
// Preserve the same direction as the base face // Preserve the same direction as the base face
Handle(Geom_Surface) RefSurf = Handle(Geom_Surface) RefSurf =
BRep_Tool::Surface(TopoDS::Face(itf.Key())); BRep_Tool::Surface(FK);
if (RefSurf->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { if (RefSurf->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
RefSurf = RefSurf =
Handle(Geom_RectangularTrimmedSurface)::DownCast(RefSurf) Handle(Geom_RectangularTrimmedSurface)::DownCast(RefSurf)
@ -754,8 +767,7 @@ void Draft_Modification::Perform ()
else if (RefSurf->DynamicType() == else if (RefSurf->DynamicType() ==
STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) { STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) {
DirRef = DirRef =
Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(RefSurf) Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(RefSurf)->Direction();
->Direction();
} }
if (extrdir.Dot(DirRef) < 0.) extrdir.Reverse(); if (extrdir.Dot(DirRef) < 0.) extrdir.Reverse();
@ -769,7 +781,7 @@ void Draft_Modification::Perform ()
new Geom_SurfaceOfLinearExtrusion(CCir, extrdir); new Geom_SurfaceOfLinearExtrusion(CCir, extrdir);
Standard_Real umin, umax, vmin, vmax; Standard_Real umin, umax, vmin, vmax;
BRepTools::UVBounds(TopoDS::Face(itf.Key()),umin,umax,vmin,vmax); BRepTools::UVBounds(FK,umin,umax,vmin,vmax);
if (!Precision::IsNegativeInfinite(vmin) && if (!Precision::IsNegativeInfinite(vmin) &&
!Precision::IsPositiveInfinite(vmax)) { !Precision::IsPositiveInfinite(vmax)) {
Standard_Real deltav = 2.*(vmax-vmin); Standard_Real deltav = 2.*(vmax-vmin);
@ -786,7 +798,6 @@ void Draft_Modification::Perform ()
NewS = new Geom_RectangularTrimmedSurface(NewS,0.,1.9*M_PI,vmin,vmax); NewS = new Geom_RectangularTrimmedSurface(NewS,0.,1.9*M_PI,vmin,vmax);
Finf.ChangeGeometry() = NewS; Finf.ChangeGeometry() = NewS;
} }
itf.Next();
} }
// Calculate new edges. // Calculate new edges.
@ -795,12 +806,12 @@ void Draft_Modification::Perform ()
Handle(Geom_Curve) C, newC; Handle(Geom_Curve) C, newC;
Standard_Real f,l; Standard_Real f,l;
TopLoc_Location L; TopLoc_Location L;
Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo ite(myEMap);
while (ite.More()) { for (Standard_Integer ii = 1; ii <= myEMap.Extent(); ii++)
Draft_EdgeInfo& Einf = myEMap(ite.Key()); {
Draft_EdgeInfo& Einf = myEMap.ChangeFromIndex(ii);
const TopoDS_Edge& theEdge = TopoDS::Edge(ite.Key()); const TopoDS_Edge& theEdge = TopoDS::Edge(myEMap.FindKey(ii));
C = BRep_Tool::Curve(theEdge,L,f,l); C = BRep_Tool::Curve(theEdge,L,f,l);
C = Handle(Geom_Curve)::DownCast(C->Transformed(L.Transformation())); C = Handle(Geom_Curve)::DownCast(C->Transformed(L.Transformation()));
@ -811,8 +822,8 @@ void Draft_Modification::Perform ()
const TopoDS_Face& FirstFace = Einf.FirstFace(); const TopoDS_Face& FirstFace = Einf.FirstFace();
const TopoDS_Face& SecondFace = Einf.SecondFace(); const TopoDS_Face& SecondFace = Einf.SecondFace();
S1 = myFMap(FirstFace).Geometry(); S1 = myFMap.FindFromKey(FirstFace).Geometry();
S2 = myFMap(SecondFace).Geometry(); S2 = myFMap.FindFromKey(SecondFace).Geometry();
Standard_Integer detrompeur = 0; Standard_Integer detrompeur = 0;
@ -820,8 +831,8 @@ void Draft_Modification::Perform ()
TopoDS_Vertex FV = TopExp::FirstVertex(theEdge); TopoDS_Vertex FV = TopExp::FirstVertex(theEdge);
TopoDS_Vertex LV = TopExp::LastVertex(theEdge); TopoDS_Vertex LV = TopExp::LastVertex(theEdge);
Standard_Real pmin = 0.; Standard_Real pmin = 0.;
Standard_Real prmfv = BRep_Tool::Parameter(FV,ite.Key()); Standard_Real prmfv = BRep_Tool::Parameter(FV, theEdge);
Standard_Real prmlv = BRep_Tool::Parameter(LV,ite.Key()); Standard_Real prmlv = BRep_Tool::Parameter(LV, theEdge);
gp_Pnt pfv, plv; gp_Pnt pfv, plv;
gp_Vec d1fv,d1lv, newd1; gp_Vec d1fv,d1lv, newd1;
C->D1(prmfv,pfv,d1fv); C->D1(prmfv,pfv,d1fv);
@ -920,8 +931,8 @@ void Draft_Modification::Perform ()
Einf.ChangeSecondPC() = L2d; Einf.ChangeSecondPC() = L2d;
} }
else { else {
S1 = myFMap(Einf.FirstFace()).Geometry(); S1 = myFMap.FindFromKey(Einf.FirstFace()).Geometry();
S2 = myFMap(Einf.SecondFace()).Geometry(); S2 = myFMap.FindFromKey(Einf.SecondFace()).Geometry();
// PCurves are not calculated immediately for 2 reasons: // PCurves are not calculated immediately for 2 reasons:
@ -933,7 +944,7 @@ void Draft_Modification::Perform ()
if (!i2s.IsDone() || i2s.NbLines() <= 0) { if (!i2s.IsDone() || i2s.NbLines() <= 0) {
errStat = Draft_EdgeRecomputation; errStat = Draft_EdgeRecomputation;
badShape = TopoDS::Edge(ite.Key()); badShape = theEdge;
return; return;
} }
@ -1062,7 +1073,7 @@ void Draft_Modification::Perform ()
} }
if (imin == 0) { if (imin == 0) {
errStat = Draft_EdgeRecomputation; errStat = Draft_EdgeRecomputation;
badShape = TopoDS::Edge(ite.Key()); badShape = theEdge;
return; return;
} }
@ -1189,7 +1200,7 @@ void Draft_Modification::Perform ()
if (FirstCurve.IsNull()) { if (FirstCurve.IsNull()) {
errStat = Draft_EdgeRecomputation; errStat = Draft_EdgeRecomputation;
badShape = TopoDS::Edge(ite.Key()); badShape = theEdge;
return; return;
} }
@ -1241,11 +1252,11 @@ void Draft_Modification::Perform ()
const TopoDS_Face& F1 = Einf.FirstFace(); const TopoDS_Face& F1 = Einf.FirstFace();
const TopoDS_Face& F2 = Einf.SecondFace(); const TopoDS_Face& F2 = Einf.SecondFace();
Handle(Geom_Surface) aLocalS1 = myFMap(F1).Geometry(); Handle(Geom_Surface) aLocalS1 = myFMap.FindFromKey(F1).Geometry();
Handle(Geom_Surface) aLocalS2 = myFMap(F2).Geometry(); Handle(Geom_Surface) aLocalS2 = myFMap.FindFromKey(F2).Geometry();
if (aLocalS1.IsNull() || aLocalS2.IsNull()) { if (aLocalS1.IsNull() || aLocalS2.IsNull()) {
errStat = Draft_EdgeRecomputation; errStat = Draft_EdgeRecomputation;
badShape = TopoDS::Edge(ite.Key()); badShape = theEdge;
return; return;
} }
if (aLocalS1->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { if (aLocalS1->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
@ -1340,22 +1351,21 @@ void Draft_Modification::Perform ()
if (!T.IsNull()) C = T->BasisCurve(); if (!T.IsNull()) C = T->BasisCurve();
Einf.ChangeGeometry() = C; Einf.ChangeGeometry() = C;
} }
ite.Next();
} }
// Calculate new vertices. // Calculate new vertices.
Draft_DataMapIteratorOfDataMapOfVertexVertexInfo itv(myVMap);
Handle(GeomAdaptor_HCurve) HAC = new GeomAdaptor_HCurve; Handle(GeomAdaptor_HCurve) HAC = new GeomAdaptor_HCurve;
Handle(GeomAdaptor_HSurface) HAS = new GeomAdaptor_HSurface; Handle(GeomAdaptor_HSurface) HAS = new GeomAdaptor_HSurface;
while (itv.More()) { for (Standard_Integer ii = 1; ii <= myVMap.Extent(); ii++)
{
GeomAdaptor_Curve AC; GeomAdaptor_Curve AC;
GeomAdaptor_Surface AS; GeomAdaptor_Surface AS;
Draft_VertexInfo& Vinf = myVMap(itv.Key()); const TopoDS_Vertex& TVV = myVMap.FindKey(ii);
if (!Choose(myFMap,myEMap,itv.Key(),Vinf,AC,AS)) { Draft_VertexInfo& Vinf = myVMap.ChangeFromIndex(ii);
if (!Choose(myFMap,myEMap,TVV,Vinf,AC,AS)) {
// no concerted edge => alignment of two consecutive edges. // no concerted edge => alignment of two consecutive edges.
gp_Pnt pvt; gp_Pnt pvt;
@ -1364,8 +1374,8 @@ void Draft_Modification::Perform ()
if (Vinf.MoreEdge()) { if (Vinf.MoreEdge()) {
const TopoDS_Edge& Edg1 = Vinf.Edge(); const TopoDS_Edge& Edg1 = Vinf.Edge();
//const Draft_EdgeInfo& Einf1 = myEMap(Edg1); //const Draft_EdgeInfo& Einf1 = myEMap(Edg1);
Draft_EdgeInfo& Einf1 = myEMap(Edg1); Draft_EdgeInfo& Einf1 = myEMap.ChangeFromKey(Edg1);
gp_Pnt vtori = BRep_Tool::Pnt(itv.Key()); gp_Pnt vtori = BRep_Tool::Pnt(TVV);
//Einf1.Geometry()->D0(Vinf.Parameter(Edg1), pvt); //Einf1.Geometry()->D0(Vinf.Parameter(Edg1), pvt);
GeomAPI_ProjectPointOnCurve Projector( vtori, Einf1.Geometry() ); //patch GeomAPI_ProjectPointOnCurve Projector( vtori, Einf1.Geometry() ); //patch
pvt = Projector.NearestPoint(); pvt = Projector.NearestPoint();
@ -1384,7 +1394,7 @@ void Draft_Modification::Perform ()
if (Vinf.MoreEdge()) { if (Vinf.MoreEdge()) {
const TopoDS_Edge& Edg2 = Vinf.Edge(); const TopoDS_Edge& Edg2 = Vinf.Edge();
//const Draft_EdgeInfo& Einf2 = myEMap(Edg2); //const Draft_EdgeInfo& Einf2 = myEMap(Edg2);
Draft_EdgeInfo& Einf2 = myEMap(Edg2); Draft_EdgeInfo& Einf2 = myEMap.ChangeFromKey(Edg2);
// Standard_Real f; // Standard_Real f;
gp_Pnt opvt; gp_Pnt opvt;
Einf2.Geometry()->D0(Vinf.Parameter(Edg2), opvt); Einf2.Geometry()->D0(Vinf.Parameter(Edg2), opvt);
@ -1404,8 +1414,8 @@ void Draft_Modification::Perform ()
Standard_Real param = Parameter(Einf2.Geometry(), pvt, done); Standard_Real param = Parameter(Einf2.Geometry(), pvt, done);
if (done != 0) if (done != 0)
{ {
S1 = myFMap(Einf2.FirstFace()).Geometry(); S1 = myFMap.FindFromKey(Einf2.FirstFace()).Geometry();
S2 = myFMap(Einf2.SecondFace()).Geometry(); S2 = myFMap.FindFromKey(Einf2.SecondFace()).Geometry();
Vinf.ChangeParameter(Edg2) = SmartParameter( Einf2, BRep_Tool::Tolerance(Edg2), pvt, done, S1, S2 ); Vinf.ChangeParameter(Edg2) = SmartParameter( Einf2, BRep_Tool::Tolerance(Edg2), pvt, done, S1, S2 );
} }
else else
@ -1418,34 +1428,35 @@ void Draft_Modification::Perform ()
Standard_Real param = Parameter(Einf1.Geometry(), pvt, done); Standard_Real param = Parameter(Einf1.Geometry(), pvt, done);
if (done != 0) if (done != 0)
{ {
S1 = myFMap(Einf1.FirstFace()).Geometry(); S1 = myFMap.FindFromKey(Einf1.FirstFace()).Geometry();
S2 = myFMap(Einf1.SecondFace()).Geometry(); S2 = myFMap.FindFromKey(Einf1.SecondFace()).Geometry();
Vinf.ChangeParameter(Edg1) = SmartParameter( Einf1, BRep_Tool::Tolerance(Edg1), pvt, done, S1, S2 ); Vinf.ChangeParameter(Edg1) = SmartParameter( Einf1, BRep_Tool::Tolerance(Edg1), pvt, done, S1, S2 );
} }
else else
Vinf.ChangeParameter(Edg1) = param; Vinf.ChangeParameter(Edg1) = param;
itv.Next();
continue; continue;
} }
errStat = Draft_VertexRecomputation; errStat = Draft_VertexRecomputation;
badShape = TopoDS::Vertex(itv.Key()); badShape = TVV;
return; return;
} }
IntCurveSurface_HInter myintcs; IntCurveSurface_HInter myintcs;
HAC->Set(AC); HAC->Set(AC);
HAS->Set(AS); HAS->Set(AS);
myintcs.Perform(HAC,HAS); myintcs.Perform(HAC,HAS);
if (!myintcs.IsDone()) { if (!myintcs.IsDone()) {
errStat = Draft_VertexRecomputation; errStat = Draft_VertexRecomputation;
badShape = TopoDS::Vertex(itv.Key()); badShape = TVV;
return; return;
} }
gp_Pnt vtori = BRep_Tool::Pnt(itv.Key()); gp_Pnt vtori = BRep_Tool::Pnt(TVV);
gp_Pnt pvt; gp_Pnt pvt;
Standard_Integer nbsol = myintcs.NbPoints(); Standard_Integer nbsol = myintcs.NbPoints();
@ -1455,7 +1466,7 @@ void Draft_Modification::Perform ()
if(!extr.IsDone() || extr.NbExt() == 0) { if(!extr.IsDone() || extr.NbExt() == 0) {
errStat = Draft_VertexRecomputation; errStat = Draft_VertexRecomputation;
badShape = TopoDS::Vertex(itv.Key()); badShape = TVV;
return; return;
} }
@ -1498,28 +1509,27 @@ void Draft_Modification::Perform ()
for (Vinf.InitEdgeIterator();Vinf.MoreEdge(); Vinf.NextEdge()) { for (Vinf.InitEdgeIterator();Vinf.MoreEdge(); Vinf.NextEdge()) {
const TopoDS_Edge& Edg = Vinf.Edge(); const TopoDS_Edge& Edg = Vinf.Edge();
//const Draft_EdgeInfo& Einf = myEMap(Edg); //const Draft_EdgeInfo& Einf = myEMap(Edg);
Draft_EdgeInfo& Einf = myEMap(Edg); Draft_EdgeInfo& Einf = myEMap.ChangeFromKey(Edg);
//Vinf.ChangeParameter(Edg) = Parameter(Einf.Geometry(),pvt); //Vinf.ChangeParameter(Edg) = Parameter(Einf.Geometry(),pvt);
Standard_Integer done; Standard_Integer done;
Standard_Real param = Parameter(Einf.Geometry(), pvt, done); Standard_Real param = Parameter(Einf.Geometry(), pvt, done);
if (done != 0) if (done != 0)
{ {
S1 = myFMap(Einf.FirstFace()).Geometry(); S1 = myFMap.FindFromKey(Einf.FirstFace()).Geometry();
S2 = myFMap(Einf.SecondFace()).Geometry(); S2 = myFMap.FindFromKey(Einf.SecondFace()).Geometry();
Vinf.ChangeParameter(Edg) = SmartParameter( Einf, BRep_Tool::Tolerance(Edg), pvt, done, S1, S2 ); Vinf.ChangeParameter(Edg) = SmartParameter( Einf, BRep_Tool::Tolerance(Edg), pvt, done, S1, S2 );
} }
else else
Vinf.ChangeParameter(Edg) = param; Vinf.ChangeParameter(Edg) = param;
} }
itv.Next();
} }
} }
// small loop of validation/protection // small loop of validation/protection
for (Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo ite(myEMap); for (Standard_Integer i = 1; i <= myEMap.Extent(); i++)
ite.More(); ite.Next()) { {
const TopoDS_Edge& edg = TopoDS::Edge(ite.Key()); const TopoDS_Edge& edg = TopoDS::Edge(myEMap.FindKey(i));
TopoDS_Vertex Vf,Vl; TopoDS_Vertex Vf,Vl;
TopExp::Vertices(edg,Vf,Vl); TopExp::Vertices(edg,Vf,Vl);
@ -1540,7 +1550,7 @@ void Draft_Modification::Perform ()
// pl = gc->LastParameter(); // pl = gc->LastParameter();
// pf = gc->FirstParameter(); // pf = gc->FirstParameter();
// } // }
Handle( Geom_Curve ) theCurve = myEMap(edg).Geometry(); Handle( Geom_Curve ) theCurve = myEMap.FindFromKey(edg).Geometry();
if (theCurve->IsClosed()) if (theCurve->IsClosed())
{ {
// pf >= pl // pf >= pl
@ -1558,14 +1568,14 @@ void Draft_Modification::Perform ()
} }
if (pl <= pf) { if (pl <= pf) {
errStat = Draft_EdgeRecomputation; errStat = Draft_EdgeRecomputation;
badShape = TopoDS::Edge(ite.Key()); badShape = edg;
return; return;
} }
} }
if (myVMap.IsBound( Vf )) if (myVMap.Contains( Vf ))
myVMap(Vf).ChangeParameter(edg) = pf; myVMap.ChangeFromKey(Vf).ChangeParameter(edg) = pf;
if (myVMap.IsBound( Vl )) if (myVMap.Contains( Vl ))
myVMap(Vl).ChangeParameter(edg) = pl; myVMap.ChangeFromKey(Vl).ChangeParameter(edg) = pl;
} }
} }
@ -1824,8 +1834,8 @@ Handle(Geom_Curve) Draft_Modification::NewCurve
//purpose : //purpose :
//======================================================================= //=======================================================================
static Standard_Boolean Choose(const Draft_DataMapOfFaceFaceInfo& theFMap, static Standard_Boolean Choose(const Draft_IndexedDataMapOfFaceFaceInfo& theFMap,
Draft_DataMapOfEdgeEdgeInfo& theEMap, Draft_IndexedDataMapOfEdgeEdgeInfo& theEMap,
const TopoDS_Vertex& Vtx, const TopoDS_Vertex& Vtx,
Draft_VertexInfo& Vinf, Draft_VertexInfo& Vinf,
GeomAdaptor_Curve& AC, GeomAdaptor_Curve& AC,
@ -1837,7 +1847,7 @@ static Standard_Boolean Choose(const Draft_DataMapOfFaceFaceInfo& theFMap,
// Find a regular edge with null SecondFace // Find a regular edge with null SecondFace
while (Vinf.MoreEdge()) { while (Vinf.MoreEdge()) {
const TopoDS_Edge& E1 = Vinf.Edge(); const TopoDS_Edge& E1 = Vinf.Edge();
const Draft_EdgeInfo& Einf1 = theEMap(E1); const Draft_EdgeInfo& Einf1 = theEMap.FindFromKey(E1);
if (Einf1.SecondFace().IsNull()) { if (Einf1.SecondFace().IsNull()) {
break; break;
} }
@ -1856,7 +1866,7 @@ static Standard_Boolean Choose(const Draft_DataMapOfFaceFaceInfo& theFMap,
const TopoDS_Edge& Eref = Vinf.Edge(); const TopoDS_Edge& Eref = Vinf.Edge();
//const Draft_EdgeInfo& Einf = theEMap(Eref); //const Draft_EdgeInfo& Einf = theEMap(Eref);
Draft_EdgeInfo& Einf = theEMap(Eref); Draft_EdgeInfo& Einf = theEMap.ChangeFromKey(Eref);
AC.Load(Einf.Geometry()); AC.Load(Einf.Geometry());
@ -1870,8 +1880,8 @@ static Standard_Boolean Choose(const Draft_DataMapOfFaceFaceInfo& theFMap,
Standard_Real param = Parameter( C, BRep_Tool::Pnt(Vtx), done ); Standard_Real param = Parameter( C, BRep_Tool::Pnt(Vtx), done );
if (done != 0) if (done != 0)
{ {
Handle( Geom_Surface ) S1 = theFMap(Einf.FirstFace()).Geometry(); Handle( Geom_Surface ) S1 = theFMap.FindFromKey(Einf.FirstFace()).Geometry();
Handle( Geom_Surface ) S2 = theFMap(Einf.SecondFace()).Geometry(); Handle( Geom_Surface ) S2 = theFMap.FindFromKey(Einf.SecondFace()).Geometry();
prm = SmartParameter( Einf, BRep_Tool::Tolerance(Eref), BRep_Tool::Pnt(Vtx), done, S1, S2 ); prm = SmartParameter( Einf, BRep_Tool::Tolerance(Eref), BRep_Tool::Pnt(Vtx), done, S1, S2 );
} }
else else
@ -1885,7 +1895,7 @@ static Standard_Boolean Choose(const Draft_DataMapOfFaceFaceInfo& theFMap,
const TopoDS_Edge& Edg = Vinf.Edge(); const TopoDS_Edge& Edg = Vinf.Edge();
if (!Edg.IsSame(Eref)) { if (!Edg.IsSame(Eref)) {
//const Draft_EdgeInfo& Einfo = theEMap(Edg); //const Draft_EdgeInfo& Einfo = theEMap(Edg);
Draft_EdgeInfo& Einfo = theEMap(Edg); Draft_EdgeInfo& Einfo = theEMap.ChangeFromKey(Edg);
if (!Einfo.SecondFace().IsNull() && if (!Einfo.SecondFace().IsNull() &&
BRep_Tool::Continuity(Edg,Einfo.FirstFace(),Einfo.SecondFace()) BRep_Tool::Continuity(Edg,Einfo.FirstFace(),Einfo.SecondFace())
<= GeomAbs_C0) { <= GeomAbs_C0) {
@ -1896,8 +1906,8 @@ static Standard_Boolean Choose(const Draft_DataMapOfFaceFaceInfo& theFMap,
Standard_Real anewparam = Parameter( C, BRep_Tool::Pnt(Vtx), anewdone ); Standard_Real anewparam = Parameter( C, BRep_Tool::Pnt(Vtx), anewdone );
if (anewdone != 0) if (anewdone != 0)
{ {
Handle( Geom_Surface ) S1 = theFMap(Einfo.FirstFace()).Geometry(); Handle( Geom_Surface ) S1 = theFMap.FindFromKey(Einfo.FirstFace()).Geometry();
Handle( Geom_Surface ) S2 = theFMap(Einfo.SecondFace()).Geometry(); Handle( Geom_Surface ) S2 = theFMap.FindFromKey(Einfo.SecondFace()).Geometry();
prm = SmartParameter( Einfo, BRep_Tool::Tolerance(Edg), BRep_Tool::Pnt(Vtx), anewdone, S1, S2 ); prm = SmartParameter( Einfo, BRep_Tool::Tolerance(Edg), BRep_Tool::Pnt(Vtx), anewdone, S1, S2 );
} }
else else
@ -1915,23 +1925,23 @@ static Standard_Boolean Choose(const Draft_DataMapOfFaceFaceInfo& theFMap,
return Standard_False; return Standard_False;
} }
const Draft_EdgeInfo& Einf2 = theEMap(Vinf.Edge()); const Draft_EdgeInfo& Einf2 = theEMap.FindFromKey(Vinf.Edge());
if (!Einf.SecondFace().IsNull()) { if (!Einf.SecondFace().IsNull()) {
if (Einf2.FirstFace().IsSame(Einf.FirstFace()) || if (Einf2.FirstFace().IsSame(Einf.FirstFace()) ||
Einf2.FirstFace().IsSame(Einf.SecondFace())) { Einf2.FirstFace().IsSame(Einf.SecondFace())) {
AS.Load(theFMap(Einf2.SecondFace()).Geometry()); AS.Load(theFMap.FindFromKey(Einf2.SecondFace()).Geometry());
} }
else { else {
AS.Load(theFMap(Einf2.FirstFace()).Geometry()); AS.Load(theFMap.FindFromKey(Einf2.FirstFace()).Geometry());
} }
} }
else { else {
if (Einf2.FirstFace().IsSame(Einf.FirstFace())) { if (Einf2.FirstFace().IsSame(Einf.FirstFace())) {
AS.Load(theFMap(Einf2.SecondFace()).Geometry()); AS.Load(theFMap.FindFromKey(Einf2.SecondFace()).Geometry());
} }
else { else {
AS.Load(theFMap(Einf2.FirstFace()).Geometry()); AS.Load(theFMap.FindFromKey(Einf2.FirstFace()).Geometry());
} }
} }
return Standard_True; return Standard_True;

View File

@ -1,11 +1,8 @@
Draft.cxx Draft.cxx
Draft.hxx Draft.hxx
Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo.hxx Draft_IndexedDataMapOfEdgeEdgeInfo.hxx
Draft_DataMapIteratorOfDataMapOfFaceFaceInfo.hxx Draft_IndexedDataMapOfFaceFaceInfo.hxx
Draft_DataMapIteratorOfDataMapOfVertexVertexInfo.hxx Draft_IndexedDataMapOfVertexVertexInfo.hxx
Draft_DataMapOfEdgeEdgeInfo.hxx
Draft_DataMapOfFaceFaceInfo.hxx
Draft_DataMapOfVertexVertexInfo.hxx
Draft_EdgeInfo.cxx Draft_EdgeInfo.cxx
Draft_EdgeInfo.hxx Draft_EdgeInfo.hxx
Draft_ErrorStatus.hxx Draft_ErrorStatus.hxx

View File

@ -4485,6 +4485,97 @@ static Standard_Integer OCC24537(
return 0; return 0;
} }
#include <TopExp.hxx>
#include <BRepOffsetAPI_DraftAngle.hxx>
#include <vector>
static TopoDS_Shape taper(const TopoDS_Shape &shape, const TopoDS_Face &face_a, const TopoDS_Face &face_b, Standard_Real angle)
{
// Use maximum face-to-taper z-offset.
const gp_Pln neutral_plane(gp_Ax3(gp_Pnt(0.0, 0.0, 140.0), gp_Dir(0.0, 0.0, 1.0)));
// Draft angle needs to be in radians, and flipped to adhere to our own (arbitrary) draft
// angle definition.
const Standard_Real draft_angle = -(angle / 180.0) * M_PI;
// Add face to draft. The first argument indicates that all material added/removed during
// drafting is located below the neutral plane
BRepOffsetAPI_DraftAngle drafter(shape);
drafter.Add(face_a, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
drafter.Add(face_b, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
drafter.Build();
return drafter.Shape();
}
static void dumpShapeVertices(const TopoDS_Shape &shape, std::vector<Standard_Real>& coords)
{
TopTools_IndexedMapOfShape shape_vertices;
TopExp::MapShapes(shape, TopAbs_VERTEX, shape_vertices);
for (Standard_Integer i = 1; i <= shape_vertices.Extent(); i++)
{
gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(shape_vertices(i)));
coords.push_back(p.X());
coords.push_back(p.Y());
coords.push_back(p.Z());
}
}
static void GetCoords(const Standard_CString& path_to_file, std::vector<Standard_Real>& coords)
{
TopoDS_Shape shape;
BRep_Builder builder;
BRepTools::Read(shape, path_to_file, builder);
TopTools_IndexedMapOfShape shape_faces;
TopExp::MapShapes(shape, TopAbs_FACE, shape_faces);
TopoDS_Face face_a = TopoDS::Face(shape_faces(1));
TopoDS_Face face_b = TopoDS::Face(shape_faces(5));
dumpShapeVertices(taper(shape, face_a, face_b, 5.0), coords);
}
static Standard_Integer OCC26396 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
{
if (theArgc < 2)
{
theDI << "Error: path to file is missing\n";
return 1;
}
const int maxInd = 50;
std::vector<Standard_Real> ref_coords;
ref_coords.reserve(100);
Standard_Boolean Stat = Standard_True;
GetCoords(theArgv[1], ref_coords);
std::vector<Standard_Real> coords;
coords.reserve(100);
for (int i = 1; i < maxInd; i++)
{
GetCoords(theArgv[1], coords);
if (coords.size() != ref_coords.size())
{
Stat = Standard_False;
break;
}
for (size_t j = 0; j < coords.size(); j++)
if (Abs(ref_coords[j] - coords[j]) > RealEpsilon())
{
Stat = Standard_False;
break;
}
coords.clear();
}
if (!Stat)
theDI << "Error: unstable results";
else
theDI << "test OK";
return 0;
}
//======================================================================= //=======================================================================
//function : OCC26750 //function : OCC26750
//purpose : //purpose :
@ -4609,6 +4700,7 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
__FILE__, OCC26462, group); __FILE__, OCC26462, group);
theCommands.Add ("OCC26313", "OCC26313 result shape", __FILE__, OCC26313, group); theCommands.Add ("OCC26313", "OCC26313 result shape", __FILE__, OCC26313, group);
theCommands.Add ("OCC26396", "OCC26396 shape_file_path", __FILE__, OCC26396, group);
theCommands.Add ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group); theCommands.Add ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group);
theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group); theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group);

View File

@ -0,0 +1,8 @@
puts "================"
puts "OCC26396"
puts "================"
puts ""
pload QAcommands
OCC26396 [locate_data_file bug26396_shape.brep]