mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-06 18:26:22 +03:00
0025310: Regressions in visualization
- Memory management in the BRepMesh_FastDiscret class is changed. Now the unused face attributes is immediately removed.
This commit is contained in:
parent
15534713ba
commit
fcf15f5ca3
@ -70,12 +70,7 @@ BRepMesh_FaceAttribute::BRepMesh_FaceAttribute(
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
BRepMesh_FaceAttribute::~BRepMesh_FaceAttribute()
|
BRepMesh_FaceAttribute::~BRepMesh_FaceAttribute()
|
||||||
{
|
{
|
||||||
clearLocal();
|
Clear();
|
||||||
|
|
||||||
mySurfaceVertices.Clear();
|
|
||||||
mySurfacePoints->Clear();
|
|
||||||
|
|
||||||
myClassifier.Nullify();
|
|
||||||
myAllocator.Nullify();
|
myAllocator.Nullify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,19 +97,39 @@ void BRepMesh_FaceAttribute::init()
|
|||||||
ResetStructure();
|
ResetStructure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Clear
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void BRepMesh_FaceAttribute::Clear(
|
||||||
|
const Standard_Boolean isClearSurfaceDataOnly)
|
||||||
|
{
|
||||||
|
clearLocal(isClearSurfaceDataOnly);
|
||||||
|
|
||||||
|
mySurfaceVertices.Clear();
|
||||||
|
mySurfacePoints->Clear();
|
||||||
|
|
||||||
|
mySurface.Nullify();
|
||||||
|
myClassifier.Nullify();
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : clearLocal
|
//function : clearLocal
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void BRepMesh_FaceAttribute::clearLocal()
|
void BRepMesh_FaceAttribute::clearLocal(
|
||||||
|
const Standard_Boolean isClearSurfaceDataOnly)
|
||||||
{
|
{
|
||||||
myStructure.Nullify();
|
|
||||||
|
|
||||||
myLocation2D.Clear();
|
myLocation2D.Clear();
|
||||||
myVertexEdgeMap->Clear();
|
myVertexEdgeMap->Clear();
|
||||||
myInternalEdges->Clear();
|
|
||||||
|
|
||||||
myAllocator->Reset(Standard_False);
|
if (!isClearSurfaceDataOnly)
|
||||||
|
{
|
||||||
|
myInternalEdges->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
myStructure.Nullify();
|
||||||
|
myAllocator->Reset(isClearSurfaceDataOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -189,6 +189,11 @@ public: //! @name main geometrical properties.
|
|||||||
|
|
||||||
public: //! @name auxiliary structures
|
public: //! @name auxiliary structures
|
||||||
|
|
||||||
|
//! Clear face attribute.
|
||||||
|
//! @param isClearSurfaceDataOnly clears only surface attributes if true value is set.
|
||||||
|
Standard_EXPORT void Clear(
|
||||||
|
const Standard_Boolean isClearSurfaceDataOnly = Standard_False);
|
||||||
|
|
||||||
//! Resets mesh data structure.
|
//! Resets mesh data structure.
|
||||||
//! @returns reset data structure.
|
//! @returns reset data structure.
|
||||||
Standard_EXPORT Handle(BRepMesh_DataStructureOfDelaun)& ResetStructure();
|
Standard_EXPORT Handle(BRepMesh_DataStructureOfDelaun)& ResetStructure();
|
||||||
@ -330,7 +335,8 @@ private:
|
|||||||
const Standard_Real theLastParam) const;
|
const Standard_Real theLastParam) const;
|
||||||
|
|
||||||
//! Clears internal data structures local to face.
|
//! Clears internal data structures local to face.
|
||||||
void clearLocal();
|
void clearLocal(
|
||||||
|
const Standard_Boolean isClearSurfaceDataOnly = Standard_False);
|
||||||
|
|
||||||
//! Returns index of the given vertex if it exists in cache.
|
//! Returns index of the given vertex if it exists in cache.
|
||||||
//! @param theVertex vertex which index should be retrieved.
|
//! @param theVertex vertex which index should be retrieved.
|
||||||
|
@ -194,7 +194,7 @@ void BRepMesh_FastDiscret::Process(const TopoDS_Face& theFace) const
|
|||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
|
|
||||||
BRepMesh_FastDiscretFace aTool(GetAngle(), WithShare());
|
BRepMesh_FastDiscretFace aTool(GetAngle(), WithShare());
|
||||||
aTool.Add(anAttribute);
|
aTool.Perform(anAttribute);
|
||||||
}
|
}
|
||||||
catch (Standard_Failure)
|
catch (Standard_Failure)
|
||||||
{
|
{
|
||||||
@ -224,9 +224,10 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
|||||||
myAttributes.Bind(theFace, myAttribute);
|
myAttributes.Bind(theFace, myAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
myStructure = myAttribute->ResetStructure();
|
|
||||||
myVertexEdgeMap = myAttribute->ChangeVertexEdgeMap();
|
myVertexEdgeMap = myAttribute->ChangeVertexEdgeMap();
|
||||||
myInternalEdges = myAttribute->ChangeInternalEdges();
|
myInternalEdges = myAttribute->ChangeInternalEdges();
|
||||||
|
Handle(BRepMesh_DataStructureOfDelaun)& aStructure =
|
||||||
|
myAttribute->ResetStructure();
|
||||||
|
|
||||||
if (!myWithShare)
|
if (!myWithShare)
|
||||||
{
|
{
|
||||||
@ -346,7 +347,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
|||||||
Standard_Integer i1 = 1;
|
Standard_Integer i1 = 1;
|
||||||
for ( i1 = 1; i1 <= myVertexEdgeMap->Extent(); ++i1 )
|
for ( i1 = 1; i1 <= myVertexEdgeMap->Extent(); ++i1 )
|
||||||
{
|
{
|
||||||
const BRepMesh_Vertex& aVertex = myStructure->GetNode(myVertexEdgeMap->FindKey(i1));
|
const BRepMesh_Vertex& aVertex = aStructure->GetNode(myVertexEdgeMap->FindKey(i1));
|
||||||
|
|
||||||
++ipn;
|
++ipn;
|
||||||
|
|
||||||
@ -420,7 +421,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
|||||||
{
|
{
|
||||||
BRepMesh::HClassifier& aClassifier = myAttribute->ChangeClassifier();
|
BRepMesh::HClassifier& aClassifier = myAttribute->ChangeClassifier();
|
||||||
BRepMesh_WireChecker aDFaceChecker(aFace, Precision::PConfusion(),
|
BRepMesh_WireChecker aDFaceChecker(aFace, Precision::PConfusion(),
|
||||||
myInternalEdges, myVertexEdgeMap, myStructure,
|
myInternalEdges, myVertexEdgeMap, aStructure,
|
||||||
myumin, myumax, myvmin, myvmax, myInParallel );
|
myumin, myumax, myvmin, myvmax, myInParallel );
|
||||||
|
|
||||||
aDFaceChecker.ReCompute(aClassifier);
|
aDFaceChecker.ReCompute(aClassifier);
|
||||||
@ -435,7 +436,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
|||||||
++nbmaill;
|
++nbmaill;
|
||||||
|
|
||||||
// Clear the structure of links
|
// Clear the structure of links
|
||||||
myStructure = myAttribute->ResetStructure();
|
aStructure = myAttribute->ResetStructure();
|
||||||
|
|
||||||
|
|
||||||
for (Standard_Integer j = 1; j <= aFaceEdges.Length(); ++j)
|
for (Standard_Integer j = 1; j <= aFaceEdges.Length(); ++j)
|
||||||
@ -610,12 +611,15 @@ void BRepMesh_FastDiscret::addLinkToMesh(
|
|||||||
const Standard_Integer theLastNodeId,
|
const Standard_Integer theLastNodeId,
|
||||||
const TopAbs_Orientation theOrientation)
|
const TopAbs_Orientation theOrientation)
|
||||||
{
|
{
|
||||||
|
Handle(BRepMesh_DataStructureOfDelaun)& aStructure =
|
||||||
|
myAttribute->ChangeStructure();
|
||||||
|
|
||||||
if (theOrientation == TopAbs_FORWARD)
|
if (theOrientation == TopAbs_FORWARD)
|
||||||
myStructure->AddLink(BRepMesh_Edge(theFirstNodeId, theLastNodeId, BRepMesh_Frontier));
|
aStructure->AddLink(BRepMesh_Edge(theFirstNodeId, theLastNodeId, BRepMesh_Frontier));
|
||||||
else if (theOrientation == TopAbs_REVERSED)
|
else if (theOrientation == TopAbs_REVERSED)
|
||||||
myStructure->AddLink(BRepMesh_Edge(theLastNodeId, theFirstNodeId, BRepMesh_Frontier));
|
aStructure->AddLink(BRepMesh_Edge(theLastNodeId, theFirstNodeId, BRepMesh_Frontier));
|
||||||
else if (theOrientation == TopAbs_INTERNAL)
|
else if (theOrientation == TopAbs_INTERNAL)
|
||||||
myStructure->AddLink(BRepMesh_Edge(theFirstNodeId, theLastNodeId, BRepMesh_Fixed));
|
aStructure->AddLink(BRepMesh_Edge(theFirstNodeId, theLastNodeId, BRepMesh_Fixed));
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -364,7 +364,6 @@ private:
|
|||||||
|
|
||||||
// Fast access to attributes of current face
|
// Fast access to attributes of current face
|
||||||
Handle(BRepMesh_FaceAttribute) myAttribute;
|
Handle(BRepMesh_FaceAttribute) myAttribute;
|
||||||
Handle(BRepMesh_DataStructureOfDelaun) myStructure;
|
|
||||||
BRepMesh::HIMapOfInteger myVertexEdgeMap;
|
BRepMesh::HIMapOfInteger myVertexEdgeMap;
|
||||||
BRepMesh::HDMapOfShapePairOfPolygon myInternalEdges;
|
BRepMesh::HDMapOfShapePairOfPolygon myInternalEdges;
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape mySharedFaces;
|
TopTools_IndexedDataMapOfShapeListOfShape mySharedFaces;
|
||||||
|
@ -142,15 +142,25 @@ namespace {
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
BRepMesh_FastDiscretFace::BRepMesh_FastDiscretFace
|
BRepMesh_FastDiscretFace::BRepMesh_FastDiscretFace
|
||||||
(const Standard_Real theAngle,
|
(const Standard_Real theAngle,
|
||||||
const Standard_Boolean theWithShare) :
|
const Standard_Boolean theWithShare)
|
||||||
myAngle(theAngle), myWithShare(theWithShare),
|
: myAngle(theAngle), myWithShare(theWithShare),
|
||||||
myInternalVerticesMode(Standard_True)
|
myInternalVerticesMode(Standard_True)
|
||||||
{
|
{
|
||||||
myAllocator = new NCollection_IncAllocator(64000);
|
myAllocator = new NCollection_IncAllocator(64000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Add(face)
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void BRepMesh_FastDiscretFace::Perform(const Handle(BRepMesh_FaceAttribute)& theAttribute)
|
||||||
|
{
|
||||||
|
Add(theAttribute);
|
||||||
|
commitSurfaceTriangulation();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Add
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void BRepMesh_FastDiscretFace::Add(const Handle(BRepMesh_FaceAttribute)& theAttribute)
|
void BRepMesh_FastDiscretFace::Add(const Handle(BRepMesh_FaceAttribute)& theAttribute)
|
||||||
@ -1210,3 +1220,69 @@ void BRepMesh_FastDiscretFace::insertVertex(
|
|||||||
BRepMesh_Vertex aVertex(aPnt2d, aNbLocat, BRepMesh_Free);
|
BRepMesh_Vertex aVertex(aPnt2d, aNbLocat, BRepMesh_Free);
|
||||||
theVertices.Append(aVertex);
|
theVertices.Append(aVertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : commitSurfaceTriangulation
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void BRepMesh_FastDiscretFace::commitSurfaceTriangulation()
|
||||||
|
{
|
||||||
|
if (myAttribute.IsNull() || !myAttribute->IsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
TopoDS_Face aFace = myAttribute->Face();
|
||||||
|
BRepMesh_ShapeTool::NullifyFace(aFace);
|
||||||
|
|
||||||
|
Handle(BRepMesh_DataStructureOfDelaun)& aStructure = myAttribute->ChangeStructure();
|
||||||
|
const BRepMesh::MapOfInteger& aTriangles = aStructure->ElementsOfDomain();
|
||||||
|
|
||||||
|
if (aTriangles.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
BRepMesh::HIMapOfInteger& aVetrexEdgeMap = myAttribute->ChangeVertexEdgeMap();
|
||||||
|
|
||||||
|
// Store triangles
|
||||||
|
Standard_Integer aVerticesNb = aVetrexEdgeMap->Extent();
|
||||||
|
Standard_Integer aTrianglesNb = aTriangles.Extent();
|
||||||
|
Handle(Poly_Triangulation) aNewTriangulation =
|
||||||
|
new Poly_Triangulation(aVerticesNb, aTrianglesNb, Standard_True);
|
||||||
|
|
||||||
|
Poly_Array1OfTriangle& aPolyTrianges = aNewTriangulation->ChangeTriangles();
|
||||||
|
|
||||||
|
Standard_Integer aTriangeId = 1;
|
||||||
|
BRepMesh::MapOfInteger::Iterator aTriIt(aTriangles);
|
||||||
|
for (; aTriIt.More(); aTriIt.Next())
|
||||||
|
{
|
||||||
|
const BRepMesh_Triangle& aCurElem = aStructure->GetElement(aTriIt.Key());
|
||||||
|
|
||||||
|
Standard_Integer aNode[3];
|
||||||
|
aStructure->ElementNodes(aCurElem, aNode);
|
||||||
|
|
||||||
|
Standard_Integer aNodeId[3];
|
||||||
|
for (Standard_Integer i = 0; i < 3; ++i)
|
||||||
|
aNodeId[i] = aVetrexEdgeMap->FindIndex(aNode[i]);
|
||||||
|
|
||||||
|
aPolyTrianges(aTriangeId++).Set(aNodeId[0], aNodeId[1], aNodeId[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store mesh nodes
|
||||||
|
TColgp_Array1OfPnt& aNodes = aNewTriangulation->ChangeNodes();
|
||||||
|
TColgp_Array1OfPnt2d& aNodes2d = aNewTriangulation->ChangeUVNodes();
|
||||||
|
|
||||||
|
for (Standard_Integer i = 1; i <= aVerticesNb; ++i)
|
||||||
|
{
|
||||||
|
Standard_Integer aVertexId = aVetrexEdgeMap->FindKey(i);
|
||||||
|
const BRepMesh_Vertex& aVertex = aStructure->GetNode(aVertexId);
|
||||||
|
const gp_Pnt& aPoint = myAttribute->GetPoint(aVertex);
|
||||||
|
|
||||||
|
aNodes(i) = aPoint;
|
||||||
|
aNodes2d(i) = aVertex.Coord();
|
||||||
|
}
|
||||||
|
|
||||||
|
aNewTriangulation->Deflection(myAttribute->GetDefFace());
|
||||||
|
BRepMesh_ShapeTool::AddInFace(aFace, aNewTriangulation);
|
||||||
|
|
||||||
|
// Delete unused data
|
||||||
|
myStructure.Nullify();
|
||||||
|
myAttribute->Clear(Standard_True);
|
||||||
|
}
|
||||||
|
@ -55,6 +55,7 @@ public:
|
|||||||
const Standard_Boolean theWithShare = Standard_True);
|
const Standard_Boolean theWithShare = Standard_True);
|
||||||
|
|
||||||
Standard_EXPORT void Add(const Handle(BRepMesh_FaceAttribute)& theAttribute);
|
Standard_EXPORT void Add(const Handle(BRepMesh_FaceAttribute)& theAttribute);
|
||||||
|
Standard_EXPORT void Perform(const Handle(BRepMesh_FaceAttribute)& theAttribute);
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTI(BRepMesh_FastDiscretFace)
|
DEFINE_STANDARD_RTTI(BRepMesh_FastDiscretFace)
|
||||||
|
|
||||||
@ -134,6 +135,9 @@ private:
|
|||||||
const gp_XY& theUV,
|
const gp_XY& theUV,
|
||||||
BRepMesh::ListOfVertex& theVertices);
|
BRepMesh::ListOfVertex& theVertices);
|
||||||
|
|
||||||
|
//! Stores mesh into the face (without internal edges).
|
||||||
|
void commitSurfaceTriangulation();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Standard_Real myAngle;
|
Standard_Real myAngle;
|
||||||
|
@ -481,16 +481,16 @@ void BRepMesh_IncrementalMesh::commit()
|
|||||||
{
|
{
|
||||||
std::vector<TopoDS_Face>::iterator aFaceIt(myFaces.begin());
|
std::vector<TopoDS_Face>::iterator aFaceIt(myFaces.begin());
|
||||||
for (; aFaceIt != myFaces.end(); aFaceIt++)
|
for (; aFaceIt != myFaces.end(); aFaceIt++)
|
||||||
commitFace(*aFaceIt);
|
commitEdges(*aFaceIt);
|
||||||
|
|
||||||
discretizeFreeEdges();
|
discretizeFreeEdges();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : commitFace
|
//function : commitEdges
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void BRepMesh_IncrementalMesh::commitFace(const TopoDS_Face& theFace)
|
void BRepMesh_IncrementalMesh::commitEdges(const TopoDS_Face& theFace)
|
||||||
{
|
{
|
||||||
TopoDS_Face aFace = theFace;
|
TopoDS_Face aFace = theFace;
|
||||||
aFace.Orientation(TopAbs_FORWARD);
|
aFace.Orientation(TopAbs_FORWARD);
|
||||||
@ -499,8 +499,6 @@ void BRepMesh_IncrementalMesh::commitFace(const TopoDS_Face& theFace)
|
|||||||
if (!myMesh->GetFaceAttribute(aFace, aFaceAttribute))
|
if (!myMesh->GetFaceAttribute(aFace, aFaceAttribute))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BRepMesh_ShapeTool::NullifyFace(aFace);
|
|
||||||
|
|
||||||
if (!aFaceAttribute->IsValid())
|
if (!aFaceAttribute->IsValid())
|
||||||
{
|
{
|
||||||
myStatus |= aFaceAttribute->GetStatus();
|
myStatus |= aFaceAttribute->GetStatus();
|
||||||
@ -508,60 +506,18 @@ void BRepMesh_IncrementalMesh::commitFace(const TopoDS_Face& theFace)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TopLoc_Location aLoc = aFace.Location();
|
TopLoc_Location aLoc = aFace.Location();
|
||||||
Handle(Poly_Triangulation) aOldTriangulation = BRep_Tool::Triangulation(aFace, aLoc);
|
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLoc);
|
||||||
|
|
||||||
|
if (aTriangulation.IsNull())
|
||||||
|
{
|
||||||
|
aFaceAttribute->Clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
|
|
||||||
Handle(BRepMesh_DataStructureOfDelaun)& aStructure = aFaceAttribute->ChangeStructure();
|
|
||||||
const BRepMesh::MapOfInteger& aTriangles = aStructure->ElementsOfDomain();
|
|
||||||
if (aTriangles.IsEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
BRepMesh::HIMapOfInteger& aVetrexEdgeMap = aFaceAttribute->ChangeVertexEdgeMap();
|
|
||||||
|
|
||||||
// Store triangles
|
|
||||||
Standard_Integer aVerticesNb = aVetrexEdgeMap->Extent();
|
|
||||||
Standard_Integer aTrianglesNb = aTriangles.Extent();
|
|
||||||
Handle(Poly_Triangulation) aNewTriangulation =
|
|
||||||
new Poly_Triangulation(aVerticesNb, aTrianglesNb, Standard_True);
|
|
||||||
|
|
||||||
Poly_Array1OfTriangle& aPolyTrianges = aNewTriangulation->ChangeTriangles();
|
|
||||||
|
|
||||||
Standard_Integer aTriangeId = 1;
|
|
||||||
BRepMesh::MapOfInteger::Iterator aTriIt(aTriangles);
|
|
||||||
for (; aTriIt.More(); aTriIt.Next())
|
|
||||||
{
|
|
||||||
const BRepMesh_Triangle& aCurElem = aStructure->GetElement(aTriIt.Key());
|
|
||||||
|
|
||||||
Standard_Integer aNode[3];
|
|
||||||
aStructure->ElementNodes(aCurElem, aNode);
|
|
||||||
|
|
||||||
Standard_Integer aNodeId[3];
|
|
||||||
for (Standard_Integer i = 0; i < 3; ++i)
|
|
||||||
aNodeId[i] = aVetrexEdgeMap->FindIndex(aNode[i]);
|
|
||||||
|
|
||||||
aPolyTrianges(aTriangeId++).Set(aNodeId[0], aNodeId[1], aNodeId[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store mesh nodes
|
|
||||||
TColgp_Array1OfPnt& aNodes = aNewTriangulation->ChangeNodes();
|
|
||||||
TColgp_Array1OfPnt2d& aNodes2d = aNewTriangulation->ChangeUVNodes();
|
|
||||||
|
|
||||||
for (Standard_Integer i = 1; i <= aVerticesNb; ++i)
|
|
||||||
{
|
|
||||||
Standard_Integer aVertexId = aVetrexEdgeMap->FindKey(i);
|
|
||||||
const BRepMesh_Vertex& aVertex = aStructure->GetNode(aVertexId);
|
|
||||||
const gp_Pnt& aPoint = aFaceAttribute->GetPoint(aVertex);
|
|
||||||
|
|
||||||
aNodes(i) = aPoint;
|
|
||||||
aNodes2d(i) = aVertex.Coord();
|
|
||||||
}
|
|
||||||
|
|
||||||
aNewTriangulation->Deflection(aFaceAttribute->GetDefFace());
|
|
||||||
BRepMesh_ShapeTool::AddInFace(aFace, aNewTriangulation);
|
|
||||||
|
|
||||||
// Store discretization of edges
|
// Store discretization of edges
|
||||||
BRepMesh::HDMapOfShapePairOfPolygon& aInternalEdges = aFaceAttribute->ChangeInternalEdges();
|
BRepMesh::HDMapOfShapePairOfPolygon& aInternalEdges = aFaceAttribute->ChangeInternalEdges();
|
||||||
BRepMesh::DMapOfShapePairOfPolygon::Iterator aEdgeIt(*aInternalEdges);
|
BRepMesh::DMapOfShapePairOfPolygon::Iterator aEdgeIt(*aInternalEdges);
|
||||||
@ -572,12 +528,13 @@ void BRepMesh_IncrementalMesh::commitFace(const TopoDS_Face& theFace)
|
|||||||
const Handle(Poly_PolygonOnTriangulation)& aPolygon1 = aPolyPair.First();
|
const Handle(Poly_PolygonOnTriangulation)& aPolygon1 = aPolyPair.First();
|
||||||
const Handle(Poly_PolygonOnTriangulation)& aPolygon2 = aPolyPair.Last();
|
const Handle(Poly_PolygonOnTriangulation)& aPolygon2 = aPolyPair.Last();
|
||||||
|
|
||||||
BRepMesh_ShapeTool::NullifyEdge(aEdge, aOldTriangulation, aLoc);
|
|
||||||
if (aPolygon1 == aPolygon2)
|
if (aPolygon1 == aPolygon2)
|
||||||
BRepMesh_ShapeTool::UpdateEdge(aEdge, aPolygon1, aNewTriangulation, aLoc);
|
BRepMesh_ShapeTool::UpdateEdge(aEdge, aPolygon1, aTriangulation, aLoc);
|
||||||
else
|
else
|
||||||
BRepMesh_ShapeTool::UpdateEdge(aEdge, aPolygon1, aPolygon2, aNewTriangulation, aLoc);
|
BRepMesh_ShapeTool::UpdateEdge(aEdge, aPolygon1, aPolygon2, aTriangulation, aLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aFaceAttribute->Clear();
|
||||||
}
|
}
|
||||||
catch (Standard_Failure)
|
catch (Standard_Failure)
|
||||||
{
|
{
|
||||||
|
@ -189,8 +189,8 @@ private:
|
|||||||
//! Stores mesh to the shape.
|
//! Stores mesh to the shape.
|
||||||
void commit();
|
void commit();
|
||||||
|
|
||||||
//! Stores mesh to the face.
|
//! Stores mesh of internal edges to the face.
|
||||||
void commitFace(const TopoDS_Face& theFace);
|
void commitEdges(const TopoDS_Face& theFace);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -433,19 +433,22 @@ static Standard_Integer triangule(Draw_Interpretor& di, Standard_Integer nbarg,
|
|||||||
|
|
||||||
|
|
||||||
Bnd_Box aBox;
|
Bnd_Box aBox;
|
||||||
const Handle(BRepMesh_FastDiscret)& aFastDiscret = aDMesh->Mesher()->Mesh();
|
|
||||||
|
|
||||||
TopExp_Explorer aFaceIt(aShape, TopAbs_FACE);
|
TopExp_Explorer aFaceIt(aShape, TopAbs_FACE);
|
||||||
for (; aFaceIt.More(); aFaceIt.Next())
|
for (; aFaceIt.More(); aFaceIt.Next())
|
||||||
{
|
{
|
||||||
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
|
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
|
||||||
|
|
||||||
Handle(BRepMesh_FaceAttribute) anAttribute;
|
TopLoc_Location aLoc = aFace.Location();
|
||||||
if (aFastDiscret->GetFaceAttribute(aFace, anAttribute) && anAttribute->IsValid())
|
Handle(Poly_Triangulation) aTriangulation =
|
||||||
|
BRep_Tool::Triangulation(aFace, aLoc);
|
||||||
|
|
||||||
|
if (!aTriangulation.IsNull())
|
||||||
{
|
{
|
||||||
const Standard_Integer aNbPnts = anAttribute->LastPointId();
|
const Standard_Integer aLength = aTriangulation->NbNodes();
|
||||||
for (Standard_Integer i = 1; i < aNbPnts; ++i)
|
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
|
||||||
aBox.Add(anAttribute->GetPoint(i));
|
for (Standard_Integer i = 1; i <= aLength; ++i)
|
||||||
|
aBox.Add(aNodes(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include <Draw_ColorKind.hxx>
|
#include <Draw_ColorKind.hxx>
|
||||||
#include <Draw_Color.hxx>
|
#include <Draw_Color.hxx>
|
||||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||||
|
#include <TColStd_Array1OfInteger.hxx>
|
||||||
|
#include <Poly_Triangulation.hxx>
|
||||||
#include <Standard_RangeError.hxx>
|
#include <Standard_RangeError.hxx>
|
||||||
#include <BRepMesh_DegreeOfFreedom.hxx>
|
#include <BRepMesh_DegreeOfFreedom.hxx>
|
||||||
#include <BRepMesh_Edge.hxx>
|
#include <BRepMesh_Edge.hxx>
|
||||||
@ -31,6 +33,16 @@
|
|||||||
IMPLEMENT_STANDARD_HANDLE (MeshTest_DrawableMesh, Draw_Drawable3D)
|
IMPLEMENT_STANDARD_HANDLE (MeshTest_DrawableMesh, Draw_Drawable3D)
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(MeshTest_DrawableMesh, Draw_Drawable3D)
|
IMPLEMENT_STANDARD_RTTIEXT(MeshTest_DrawableMesh, Draw_Drawable3D)
|
||||||
|
|
||||||
|
typedef NCollection_Map<BRepMesh_Edge> BRepMesh_MapOfLinks;
|
||||||
|
|
||||||
|
static inline void addLink(const Standard_Integer theIndex1,
|
||||||
|
const Standard_Integer theIndex2,
|
||||||
|
BRepMesh_MapOfLinks& theMap)
|
||||||
|
{
|
||||||
|
BRepMesh_Edge anEdge(theIndex1, theIndex2, BRepMesh_Free);
|
||||||
|
theMap.Add(anEdge);
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : MeshTest_DrawableMesh
|
//function : MeshTest_DrawableMesh
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -221,28 +233,40 @@ void MeshTest_DrawableMesh::Dump(Standard_OStream&) const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void MeshTest_DrawableMesh::Whatis(Draw_Interpretor& theStream) const
|
void MeshTest_DrawableMesh::Whatis(Draw_Interpretor& theStream) const
|
||||||
{
|
{
|
||||||
|
const TopoDS_Shape& aShape = myMesher->Shape();
|
||||||
const Handle(BRepMesh_FastDiscret)& aMesh = myMesher->Mesh();
|
const Handle(BRepMesh_FastDiscret)& aMesh = myMesher->Mesh();
|
||||||
|
|
||||||
Standard_Integer aPointsNb = aMesh->NbBoundaryPoints();
|
Standard_Integer aPointsNb = aMesh->NbBoundaryPoints();
|
||||||
Standard_Integer aTrianglesNb = 0;
|
Standard_Integer aTrianglesNb = 0;
|
||||||
Standard_Integer aEdgesNb = 0;
|
Standard_Integer aEdgesNb = 0;
|
||||||
|
|
||||||
const TopoDS_Shape& aShape = myMesher->Shape();
|
TopLoc_Location aLocation;
|
||||||
|
Handle(Poly_Triangulation) aTriangulation;
|
||||||
|
|
||||||
TopExp_Explorer aFaceIt(aShape, TopAbs_FACE);
|
TopExp_Explorer aFaceIt(aShape, TopAbs_FACE);
|
||||||
for (; aFaceIt.More(); aFaceIt.Next())
|
for (; aFaceIt.More(); aFaceIt.Next())
|
||||||
{
|
{
|
||||||
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
|
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
|
||||||
|
|
||||||
Handle(BRepMesh_FaceAttribute) aAtrribure;
|
aTriangulation = BRep_Tool::Triangulation(aFace, aLocation);
|
||||||
if (!aMesh->GetFaceAttribute(aFace, aAtrribure) || !aAtrribure->IsValid())
|
if (aTriangulation.IsNull())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
aPointsNb += aAtrribure->ChangeSurfacePoints()->Extent();
|
// Count number of links
|
||||||
|
BRepMesh_MapOfLinks aMap;
|
||||||
|
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
|
||||||
|
for (Standard_Integer i = 1, v[3]; i <= aTriangles.Length(); ++i)
|
||||||
|
{
|
||||||
|
aTriangles(i).Get(v[0], v[1], v[2]);
|
||||||
|
|
||||||
Handle(BRepMesh_DataStructureOfDelaun)& aStructure =
|
addLink(v[0], v[1], aMap);
|
||||||
aAtrribure->ChangeStructure();
|
addLink(v[1], v[2], aMap);
|
||||||
|
addLink(v[2], v[0], aMap);
|
||||||
|
}
|
||||||
|
|
||||||
aTrianglesNb += aStructure->ElementsOfDomain().Extent();
|
aPointsNb += aTriangulation->NbNodes();
|
||||||
aEdgesNb += aStructure->LinksOfDomain().Extent();
|
aTrianglesNb += aTriangulation->NbTriangles();
|
||||||
|
aEdgesNb += aMap.Extent();
|
||||||
}
|
}
|
||||||
|
|
||||||
theStream << " 3d mesh\n";
|
theStream << " 3d mesh\n";
|
||||||
|
@ -14,13 +14,15 @@
|
|||||||
#include <XSDRAWSTLVRML_ToVRML.ixx>
|
#include <XSDRAWSTLVRML_ToVRML.ixx>
|
||||||
|
|
||||||
#include <Standard_Stream.hxx>
|
#include <Standard_Stream.hxx>
|
||||||
#include <BRepMesh_FastDiscret.hxx>
|
|
||||||
#include <BRepMesh_Triangle.hxx>
|
|
||||||
#include <BRepMesh_Edge.hxx>
|
|
||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
#include <BRepBndLib.hxx>
|
#include <BRepBndLib.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
#include <BRepMesh_DiscretFactory.hxx>
|
||||||
|
#include <Poly_Triangulation.hxx>
|
||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
|
||||||
#include <gp_Pnt.hxx> //ied_modif_for_compil_Nov-20-1998
|
#include <gp_Pnt.hxx> //ied_modif_for_compil_Nov-20-1998
|
||||||
|
|
||||||
@ -63,7 +65,6 @@ Standard_Real& XSDRAWSTLVRML_ToVRML::Deflection () { return myDeflecti
|
|||||||
// function : ToVRML::Write
|
// function : ToVRML::Write
|
||||||
// purpose : conversion of a Shape into VRML format for 3d visualisation
|
// purpose : conversion of a Shape into VRML format for 3d visualisation
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Boolean XSDRAWSTLVRML_ToVRML::Write
|
Standard_Boolean XSDRAWSTLVRML_ToVRML::Write
|
||||||
(const TopoDS_Shape& theShape, const Standard_CString theFileName) const
|
(const TopoDS_Shape& theShape, const Standard_CString theFileName) const
|
||||||
{
|
{
|
||||||
@ -82,19 +83,22 @@ Standard_Boolean XSDRAWSTLVRML_ToVRML::Write
|
|||||||
// shapetrigu: Boolean from Standard = Standard_False)
|
// shapetrigu: Boolean from Standard = Standard_False)
|
||||||
// returns mutable Discret from BRepMesh;
|
// returns mutable Discret from BRepMesh;
|
||||||
|
|
||||||
|
if ( !BRepTools::Triangulation (theShape, myDeflection) )
|
||||||
|
{
|
||||||
|
// retrieve meshing tool from Factory
|
||||||
|
BRepTools::Clean (theShape);
|
||||||
|
Handle(BRepMesh_DiscretRoot) aMeshAlgo =
|
||||||
|
BRepMesh_DiscretFactory::Get().Discret(theShape, myDeflection, 0.17);
|
||||||
|
|
||||||
|
if ( !aMeshAlgo.IsNull() )
|
||||||
|
{
|
||||||
|
aMeshAlgo->Perform();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bnd_Box aBox;
|
Bnd_Box aBox;
|
||||||
BRepBndLib::Add(theShape, aBox);
|
BRepBndLib::Add(theShape, aBox);
|
||||||
|
|
||||||
Handle(BRepMesh_FastDiscret) aDiscret =
|
|
||||||
new BRepMesh_FastDiscret( theShape,
|
|
||||||
myDeflection,
|
|
||||||
0.17,
|
|
||||||
aBox,
|
|
||||||
Standard_True,
|
|
||||||
Standard_False,
|
|
||||||
Standard_True,
|
|
||||||
Standard_True );
|
|
||||||
|
|
||||||
// Header of the VRML file
|
// Header of the VRML file
|
||||||
anOut << "#VRML V2.0 utf8" << endl;
|
anOut << "#VRML V2.0 utf8" << endl;
|
||||||
anOut << "Group {" << endl;
|
anOut << "Group {" << endl;
|
||||||
@ -133,24 +137,22 @@ Standard_Boolean XSDRAWSTLVRML_ToVRML::Write
|
|||||||
TopExp_Explorer aFaceIt(theShape, TopAbs_FACE);
|
TopExp_Explorer aFaceIt(theShape, TopAbs_FACE);
|
||||||
for (; aFaceIt.More(); aFaceIt.Next())
|
for (; aFaceIt.More(); aFaceIt.Next())
|
||||||
{
|
{
|
||||||
Handle(BRepMesh_FaceAttribute) anAttribute;
|
|
||||||
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
|
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
|
||||||
if (!aDiscret->GetFaceAttribute(aFace, anAttribute) || !anAttribute->IsValid())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Handle(BRepMesh_DataStructureOfDelaun)& aStructure =
|
TopLoc_Location aLoc = aFace.Location();
|
||||||
anAttribute->ChangeStructure();
|
Handle(Poly_Triangulation) aTriangulation =
|
||||||
|
BRep_Tool::Triangulation(aFace, aLoc);
|
||||||
|
|
||||||
const Standard_Integer aNbVertices = aStructure->NbNodes();
|
const Standard_Integer aLength = aTriangulation->NbNodes();
|
||||||
for (Standard_Integer i = 1; i <= aNbVertices; ++i)
|
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
|
||||||
|
for ( Standard_Integer i = 1; i <= aLength; ++i )
|
||||||
{
|
{
|
||||||
const BRepMesh_Vertex& aVertex = aStructure->GetNode(i);
|
const gp_Pnt& aPoint = aNodes(i);
|
||||||
const gp_Pnt& aPoint = anAttribute->GetPoint(aVertex);
|
|
||||||
|
|
||||||
anOut << " "
|
anOut << " "
|
||||||
<< aPoint.Coord().X() << " "
|
<< aPoint.X() << " "
|
||||||
<< aPoint.Coord().Y() << " "
|
<< aPoint.Y() << " "
|
||||||
<< aPoint.Coord().Z() << "," << endl;
|
<< aPoint.Z() << "," << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,22 +163,18 @@ Standard_Boolean XSDRAWSTLVRML_ToVRML::Write
|
|||||||
// Retrieves all the triangles in order to draw the facets
|
// Retrieves all the triangles in order to draw the facets
|
||||||
for (aFaceIt.Init(theShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
|
for (aFaceIt.Init(theShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
|
||||||
{
|
{
|
||||||
Handle(BRepMesh_FaceAttribute) anAttribute;
|
TopoDS_Face aFace = TopoDS::Face(aFaceIt.Current());
|
||||||
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
|
aFace.Orientation(TopAbs_FORWARD);
|
||||||
|
|
||||||
if (!aDiscret->GetFaceAttribute(aFace, anAttribute) || !anAttribute->IsValid())
|
TopLoc_Location aLoc = aFace.Location();
|
||||||
continue;
|
Handle(Poly_Triangulation) aTriangulation =
|
||||||
|
BRep_Tool::Triangulation(aFace, aLoc);
|
||||||
|
|
||||||
Handle(BRepMesh_DataStructureOfDelaun)& aStructure =
|
const Standard_Integer aNbTriangles = aTriangulation->NbTriangles();
|
||||||
anAttribute->ChangeStructure();
|
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
|
||||||
|
for ( Standard_Integer i = 1, v[3]; i <= aNbTriangles; ++i )
|
||||||
const Standard_Integer aNbTriangles = aStructure->NbElements();
|
|
||||||
for ( Standard_Integer i = 1; i <= aNbTriangles; ++i )
|
|
||||||
{
|
{
|
||||||
const BRepMesh_Triangle& aTriangle = aStructure->GetElement(i);
|
aTriangles(i).Get(v[0], v[1], v[2]);
|
||||||
|
|
||||||
Standard_Integer v[3];
|
|
||||||
aStructure->ElementNodes(aTriangle, v);
|
|
||||||
|
|
||||||
anOut << " "
|
anOut << " "
|
||||||
<< v[0] - 1 << ", "
|
<< v[0] - 1 << ", "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user