mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0026321: Crash in BRepMesh_FastDiscret::Add
BRepMesh_FaceAttribute: distinguish constructor and parameters initialization.
This commit is contained in:
parent
eb5c2ff415
commit
0a2a7b466d
@ -47,6 +47,28 @@ BRepMesh_FaceAttribute::BRepMesh_FaceAttribute()
|
||||
init();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepMesh_FaceAttribute::BRepMesh_FaceAttribute(
|
||||
const BRepMesh::HDMapOfVertexInteger& theBoundaryVertices,
|
||||
const BRepMesh::HDMapOfIntegerPnt& theBoundaryPoints)
|
||||
: myDefFace (0.),
|
||||
myUMin (0.),
|
||||
myUMax (0.),
|
||||
myVMin (0.),
|
||||
myVMax (0.),
|
||||
myDeltaX (1.),
|
||||
myDeltaY (1.),
|
||||
myMinStep (-1.),
|
||||
myStatus (BRepMesh_NoError),
|
||||
myAdaptiveMin (Standard_False),
|
||||
myBoundaryVertices(theBoundaryVertices),
|
||||
myBoundaryPoints (theBoundaryPoints)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
@ -55,7 +77,7 @@ BRepMesh_FaceAttribute::BRepMesh_FaceAttribute(
|
||||
const TopoDS_Face& theFace,
|
||||
const BRepMesh::HDMapOfVertexInteger& theBoundaryVertices,
|
||||
const BRepMesh::HDMapOfIntegerPnt& theBoundaryPoints,
|
||||
const Standard_Boolean theAdaptiveMin)
|
||||
const Standard_Boolean theAdaptiveMin)
|
||||
: myDefFace (0.),
|
||||
myUMin (0.),
|
||||
myUMax (0.),
|
||||
@ -81,6 +103,20 @@ BRepMesh_FaceAttribute::~BRepMesh_FaceAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepMesh_FaceAttribute::SetFace (
|
||||
const TopoDS_Face& theFace,
|
||||
const Standard_Boolean theAdaptiveMin)
|
||||
{
|
||||
myFace = theFace;
|
||||
myAdaptiveMin = theAdaptiveMin;
|
||||
|
||||
init ();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : init
|
||||
//purpose :
|
||||
|
@ -29,6 +29,13 @@ class BRepMesh_FaceAttribute : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor. Initializes empty attribute.
|
||||
//! @param theBoundaryVertices shared map of shape vertices.
|
||||
//! @param theBoundaryPoints shared discretization points of shape boundaries.
|
||||
Standard_EXPORT BRepMesh_FaceAttribute(
|
||||
const BRepMesh::HDMapOfVertexInteger& theBoundaryVertices,
|
||||
const BRepMesh::HDMapOfIntegerPnt& theBoundaryPoints);
|
||||
|
||||
//! Constructor.
|
||||
//! @param theFace face the attribute is created for.
|
||||
//! Used for default initialization. Attribute keeps reference
|
||||
@ -41,7 +48,7 @@ public:
|
||||
const TopoDS_Face& theFace,
|
||||
const BRepMesh::HDMapOfVertexInteger& theBoundaryVertices,
|
||||
const BRepMesh::HDMapOfIntegerPnt& theBoundaryPoints,
|
||||
const Standard_Boolean theAdaptiveMin);
|
||||
const Standard_Boolean theAdaptiveMin);
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT virtual ~BRepMesh_FaceAttribute();
|
||||
@ -54,6 +61,16 @@ public: //! @name main geometrical properties.
|
||||
return mySurface;
|
||||
}
|
||||
|
||||
//! Returns True in case if this attribute has already been intialized.
|
||||
inline Standard_Boolean IsInitialized () const
|
||||
{
|
||||
return !myFace.IsNull ();
|
||||
}
|
||||
|
||||
//! Initializes this attribute by the given face.
|
||||
Standard_EXPORT void SetFace (
|
||||
const TopoDS_Face& theFace,
|
||||
const Standard_Boolean theAdaptiveMin);
|
||||
|
||||
//! Returns forward oriented face to be used for calculations.
|
||||
inline const TopoDS_Face& Face() const
|
||||
|
@ -179,20 +179,16 @@ void BRepMesh_FastDiscret::resetDataStructure()
|
||||
//=======================================================================
|
||||
Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
{
|
||||
myAttribute.Nullify();
|
||||
GetFaceAttribute(theFace, myAttribute, Standard_True);
|
||||
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
|
||||
// Initialize face attributes
|
||||
myAttribute.Nullify();
|
||||
GetFaceAttribute(theFace, myAttribute);
|
||||
if (myAttribute.IsNull())
|
||||
{
|
||||
myAttribute = new BRepMesh_FaceAttribute(theFace,
|
||||
myBoundaryVertices, myBoundaryPoints,myParameters.AdaptiveMin);
|
||||
|
||||
myAttributes.Bind(theFace, myAttribute);
|
||||
}
|
||||
if (!myAttribute->IsInitialized ())
|
||||
myAttribute->SetFace (theFace, myParameters.AdaptiveMin);
|
||||
|
||||
BRepMesh::HIMapOfInteger& aVertexEdgeMap = myAttribute->ChangeVertexEdgeMap();
|
||||
BRepMesh::HDMapOfShapePairOfPolygon& aInternalEdges = myAttribute->ChangeInternalEdges();
|
||||
@ -565,15 +561,15 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
myAttribute->SetDeltaX(deltaX);
|
||||
myAttribute->SetDeltaY(deltaY);
|
||||
}
|
||||
|
||||
myAttribute->ChangeMeshNodes() =
|
||||
myAttribute->ChangeStructure()->Data()->Vertices();
|
||||
}
|
||||
catch(Standard_Failure)
|
||||
{
|
||||
myAttribute->SetStatus(BRepMesh_Failure);
|
||||
}
|
||||
|
||||
myAttribute->ChangeMeshNodes() =
|
||||
myAttribute->ChangeStructure()->Data()->Vertices();
|
||||
|
||||
myAttribute->ChangeStructure().Nullify();
|
||||
return myAttribute->GetStatus();
|
||||
}
|
||||
@ -923,13 +919,19 @@ void BRepMesh_FastDiscret::storePolygonSharedData(
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepMesh_FastDiscret::GetFaceAttribute(
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(BRepMesh_FaceAttribute)& theAttribute ) const
|
||||
Handle(BRepMesh_FaceAttribute)& theAttribute,
|
||||
const Standard_Boolean isForceCreate) const
|
||||
{
|
||||
if (myAttributes.IsBound(theFace))
|
||||
{
|
||||
theAttribute = myAttributes(theFace);
|
||||
return Standard_True;
|
||||
}
|
||||
else if (isForceCreate)
|
||||
{
|
||||
theAttribute = new BRepMesh_FaceAttribute(myBoundaryVertices, myBoundaryPoints);
|
||||
myAttributes.Bind(theFace, theAttribute);
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
@ -154,9 +154,15 @@ public:
|
||||
return mySharedFaces;
|
||||
}
|
||||
|
||||
//! Gives face attribute.
|
||||
Standard_EXPORT Standard_Boolean GetFaceAttribute
|
||||
( const TopoDS_Face& theFace, Handle(BRepMesh_FaceAttribute)& theAttribute ) const;
|
||||
//! Returns attribute descriptor for the given face.
|
||||
//! @param theFace face the attribute should be returned for.
|
||||
//! @param[out] theAttribute attribute found for the specified face.
|
||||
//! @param isForceCreate if True creates new attribute in case if there
|
||||
//! is no data for the given face.
|
||||
Standard_EXPORT Standard_Boolean GetFaceAttribute (
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(BRepMesh_FaceAttribute)& theAttribute,
|
||||
const Standard_Boolean isForceCreate = Standard_False) const;
|
||||
|
||||
//! Remove face attribute as useless to free locate memory.
|
||||
Standard_EXPORT void RemoveFaceAttribute( const TopoDS_Face& theFace );
|
||||
@ -346,7 +352,7 @@ private:
|
||||
TopoDS_Face myFace;
|
||||
|
||||
BRepMesh::DMapOfShapePairOfPolygon myEdges;
|
||||
BRepMesh::DMapOfFaceAttribute myAttributes;
|
||||
mutable BRepMesh::DMapOfFaceAttribute myAttributes;
|
||||
TopTools_DataMapOfShapeReal myMapdefle;
|
||||
|
||||
// Data shared for whole shape
|
||||
|
Loading…
x
Reference in New Issue
Block a user