1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +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
// commercial license or contractual agreement.
#ifndef Draft_DataMapOfEdgeEdgeInfo_HeaderFile
#define Draft_DataMapOfEdgeEdgeInfo_HeaderFile
#ifndef Draft_IndexedDataMapOfEdgeEdgeInfo_HeaderFile
#define Draft_IndexedDataMapOfEdgeEdgeInfo_HeaderFile
#include <TopoDS_Edge.hxx>
#include <Draft_EdgeInfo.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_DataMap<TopoDS_Edge,Draft_EdgeInfo,TopTools_ShapeMapHasher>::Iterator Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo;
typedef NCollection_IndexedDataMap<TopoDS_Edge,Draft_EdgeInfo,TopTools_ShapeMapHasher> Draft_IndexedDataMapOfEdgeEdgeInfo;
#endif

View File

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

View File

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

View File

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

View File

@ -20,9 +20,9 @@
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Draft_DataMapOfFaceFaceInfo.hxx>
#include <Draft_DataMapOfEdgeEdgeInfo.hxx>
#include <Draft_DataMapOfVertexVertexInfo.hxx>
#include <Draft_IndexedDataMapOfFaceFaceInfo.hxx>
#include <Draft_IndexedDataMapOfEdgeEdgeInfo.hxx>
#include <Draft_IndexedDataMapOfVertexVertexInfo.hxx>
#include <Standard_Boolean.hxx>
#include <TopoDS_Shape.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);
Draft_DataMapOfFaceFaceInfo myFMap;
Draft_DataMapOfEdgeEdgeInfo myEMap;
Draft_DataMapOfVertexVertexInfo myVMap;
Draft_IndexedDataMapOfFaceFaceInfo myFMap;
Draft_IndexedDataMapOfEdgeEdgeInfo myEMap;
Draft_IndexedDataMapOfVertexVertexInfo myVMap;
Standard_Boolean myComp;
TopoDS_Shape myShape;
TopoDS_Shape badShape;

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -4485,6 +4485,97 @@ static Standard_Integer OCC24537(
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
//purpose :
@ -4609,6 +4700,7 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
__FILE__, OCC26462, 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 ("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]