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

0023106: BRepMesh_IncrementalMesh returns wrong status

Fix compilation errors on Linux platform

Squeeze compilation warnings on Linux

Fix regressions

Back RemoveFaceAttribute for further reasons

Fix retrieving of polygon by index

Fix applying of location

Test case for issue CR23106

Fix memory leak regression 'test bugs vis bug79' occurred due to incorrect memory cleaning of inherited objects by MMgtRaw::Free through BRepMesh_IEdgeTool;

Replace BRepMesh_PDiscretRoot by pure pointer to BRepMesh_DiscretRoot;

Fix IVtkOCC_ShapeMesher.
This commit is contained in:
oan
2014-09-26 16:31:27 +04:00
committed by bugmaster
parent 709e97a0c1
commit ceb418e13f
41 changed files with 3926 additions and 3595 deletions

View File

@@ -394,36 +394,30 @@ static void MeshStats(const TopoDS_Shape& theSape,
static Standard_Integer triangule(Draw_Interpretor& di, Standard_Integer nbarg, const char** argv)
{
if (nbarg < 4) return 1;
Standard_Boolean save = Standard_False;
if (nbarg < 4)
return 1;
const char *id1 = argv[2];
TopoDS_Shape S = DBRep::Get(id1);
if (S.IsNull()) return 1;
TopoDS_Shape aShape = DBRep::Get(id1);
if (aShape.IsNull())
return 1;
di << argv[1] << " ";
Standard_Real Deflect=Draw::Atof(argv[3]);
if (Deflect<=0.) {
di << " Donner la fleche !" << "\n";
Standard_Real aDeflection = Draw::Atof(argv[3]);
if (aDeflection <= 0.)
{
di << " Incorrect value of deflection!" << "\n";
return 1;
}
if (nbarg >4) {
save = (Draw::Atoi(argv[4])==1);
}
Handle(MeshTest_DrawableMesh) aDMesh =
new MeshTest_DrawableMesh(aShape, aDeflection);
Standard_Boolean partage=Standard_True;
if (nbarg>5) {
partage=Draw::Atoi(argv[5])==1;
}
Handle(MeshTest_DrawableMesh) DM =
new MeshTest_DrawableMesh(S,Deflect,partage, save);
Draw::Set(argv[1],DM);
Draw::Set(argv[1], aDMesh);
Standard_Integer nbn, nbl, nbe;
MeshStats(S, nbe, nbl, nbn);
MeshStats(aShape, nbe, nbl, nbn);
di<<"(Resultat ("<<nbe<<" mailles) ("<<nbl<<" aretes) ("<<nbn<<" sommets))"<<"\n";
@@ -437,16 +431,36 @@ static Standard_Integer triangule(Draw_Interpretor& di, Standard_Integer nbarg,
}
}*/
Bnd_Box bobo;
for (Standard_Integer lepnt=1; lepnt<DM->Mesh()->NbPoint3d(); lepnt++) {
bobo.Add(DM->Mesh()->Point3d(lepnt));
Bnd_Box aBox;
const Handle(BRepMesh_FastDiscret)& aFastDiscret = aDMesh->Mesher()->Mesh();
TopExp_Explorer aFaceIt(aShape, TopAbs_FACE);
for (; aFaceIt.More(); aFaceIt.Next())
{
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
Handle(BRepMesh_FaceAttribute) anAttribute;
if (aFastDiscret->GetFaceAttribute(aFace, anAttribute) && anAttribute->IsValid())
{
const Standard_Integer aNbPnts = anAttribute->LastPointId();
for (Standard_Integer i = 1; i < aNbPnts; ++i)
aBox.Add(anAttribute->GetPoint(i));
}
}
Standard_Real x,y,z,X,Y,Z;
bobo.Get(x,y,z,X,Y,Z);
Standard_Real delta=Max(X-x,Max(Y-y,Z-z));
if (delta>0) delta=Deflect/delta;
di << " Fleche de " << delta << " fois la taille de l''objet." << "\n";
Standard_Real aDelta = 0.;
if (!aBox.IsVoid())
{
Standard_Real x, y, z, X, Y, Z;
aBox.Get(x, y, z, X, Y, Z);
aDelta = Max(X - x, Max(Y - y, Z - z));
if (aDelta > 0.0)
aDelta = aDeflection / aDelta;
}
di << " Ratio between deflection and total shape size is " << aDelta << "\n";
return 0;
}
@@ -546,36 +560,60 @@ return 0;
//function : vertices
//purpose :
//=======================================================================
static Standard_Integer vertices (Draw_Interpretor&, Standard_Integer n, const char** a)
static Standard_Integer vertices(
Draw_Interpretor& /*di*/,
Standard_Integer /*argc*/,
const char** /*argv*/)
{
if (n < 3) return 1;
return 0;
Handle(MeshTest_DrawableMesh) D =
Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(a[1]));
if (D.IsNull()) return 1;
TopoDS_Shape S = DBRep::Get(a[2]);
if (S.IsNull()) return 1;
// TODO: OAN re-implement this command according changes in BRepMesh
//if (argc < 3)
// return 1;
TopExp_Explorer ex;
TColStd_SequenceOfInteger& vseq = D->Vertices();
Handle(BRepMesh_FastDiscret) M = D->Mesh();
//Handle(MeshTest_DrawableMesh) aDrawableMesh =
// Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(argv[1]));
//if (aDrawableMesh.IsNull())
// return 1;
// the faces
for (ex.Init(S,TopAbs_FACE);ex.More();ex.Next()) {
BRepMeshCol::MapOfInteger vtx;
M->VerticesOfDomain(vtx);
for (BRepMeshCol::MapOfInteger::Iterator it(vtx); it.More(); it.Next())
vseq.Append(it.Key());
}
//TopoDS_Shape aShape = DBRep::Get(argv[2]);
//if (aShape.IsNull())
// return 1;
//TColStd_SequenceOfInteger& aVertexSeq = aDrawableMesh->Vertices();
//Handle(BRepMesh_FastDiscret) aMesh = aDrawableMesh->Mesh();
// the edges
//for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE);ex.More();ex.Next()) {
//TopExp_Explorer aFaceIt(aShape, TopAbs_FACE);
//for (; aFaceIt.More(); aFaceIt.Next())
//{
// const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
// Handle(BRepMesh_FaceAttribute) aAttribute;
// if (aMesh->GetFaceAttribute(aFace, aAttribute))
// {
// Handle(BRepMesh_DataStructureOfDelaun) aStructure = aAttribute->EditStructure();
// // Recuperate from the map of edges.
// const BRepMeshCol::MapOfInteger& aEdgeMap = aStructure->LinksOfDomain();
// // Iterator on edges.
// BRepMeshCol::MapOfInteger aVertices;
// BRepMeshCol::MapOfInteger::Iterator aEdgeIt(aEdgeMap);
// for (; aEdgeIt.More(); aEdgeIt.Next())
// {
// const BRepMesh_Edge& aEdge = aStructure->GetLink(aEdgeIt.Key());
// aVertices.Add(aEdge.FirstNode());
// aVertices.Add(aEdge.LastNode());
// }
// BRepMeshCol::MapOfInteger::Iterator anIt(vtx);
// for ( ; anIt.More(); anIt.Next() )
// aVertexSeq.Append(anIt.Key());
// }
//}
Draw::Repaint();
return 0;
//Draw::Repaint();
//return 0;
}
//=======================================================================
@@ -1504,7 +1542,7 @@ void MeshTest::Commands(Draw_Interpretor& theCommands)
theCommands.Add("incmesh","incmesh shape deflection [inParallel (0/1) : 0 by default]",__FILE__, incrementalmesh, g);
theCommands.Add("MemLeakTest","MemLeakTest",__FILE__, MemLeakTest, g);
theCommands.Add("fastdiscret","fastdiscret shape deflection [shared [nbiter]]",__FILE__, fastdiscret, g);
theCommands.Add("mesh","mesh result Shape deflection [save partage]",__FILE__, triangule, g);
theCommands.Add("mesh","mesh result Shape deflection",__FILE__, triangule, g);
theCommands.Add("addshape","addshape meshname Shape [deflection]",__FILE__, addshape, g);
//theCommands.Add("smooth","smooth meshname",__FILE__, smooth, g);
//theCommands.Add("edges","edges mesh shape, highlight the edges",__FILE__,edges, g);

View File

@@ -26,8 +26,7 @@
#include <BRepMesh_Vertex.hxx>
#include <BRepMesh_Triangle.hxx>
#include <BRepMesh_DataStructureOfDelaun.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <TopExp_Explorer.hxx>
IMPLEMENT_STANDARD_HANDLE (MeshTest_DrawableMesh, Draw_Drawable3D)
IMPLEMENT_STANDARD_RTTIEXT(MeshTest_DrawableMesh, Draw_Drawable3D)
@@ -36,9 +35,8 @@ IMPLEMENT_STANDARD_RTTIEXT(MeshTest_DrawableMesh, Draw_Drawable3D)
//function : MeshTest_DrawableMesh
//purpose :
//=======================================================================
MeshTest_DrawableMesh::MeshTest_DrawableMesh() :
myDeflection(1.), myinshape(Standard_False)
MeshTest_DrawableMesh::MeshTest_DrawableMesh()
: myDeflection(1.)
{
}
@@ -46,56 +44,41 @@ myDeflection(1.), myinshape(Standard_False)
//function : MeshTest_DrawableMesh
//purpose :
//=======================================================================
MeshTest_DrawableMesh::MeshTest_DrawableMesh(const TopoDS_Shape& S,
const Standard_Real Deflect,
const Standard_Boolean Partage,
const Standard_Boolean inshape) :
myDeflection(Deflect), myinshape(inshape)
MeshTest_DrawableMesh::MeshTest_DrawableMesh(const TopoDS_Shape& theShape,
const Standard_Real theDeflection)
: myDeflection(theDeflection)
{
Bnd_Box B;
BRepBndLib::Add(S, B);
myMesh = new BRepMesh_FastDiscret(S, Deflect, 0.5, B, Partage, inshape);
Add(theShape);
}
//=======================================================================
//function : MeshTest_DrawableMesh
//purpose :
//=======================================================================
MeshTest_DrawableMesh::MeshTest_DrawableMesh(const Handle(BRepMesh_FastDiscret)& Tr):
myDeflection(1.0)
MeshTest_DrawableMesh::MeshTest_DrawableMesh(
const Handle(BRepMesh_IncrementalMesh)& theMesher)
: myDeflection(1.)
{
myMesh = Tr;
myMesher = theMesher;
if (!myMesher.IsNull())
myDeflection = myMesher->Deflection();
}
//=======================================================================
//function : MeshTest_DrawableMesh
//purpose :
//=======================================================================
void MeshTest_DrawableMesh::Add(const TopoDS_Shape& S)
void MeshTest_DrawableMesh::Add(const TopoDS_Shape& theShape)
{
Bnd_Box B;
BRepBndLib::Add(S, B);
if (myMesh.IsNull())
myMesh=new BRepMesh_FastDiscret(S, myDeflection, 0.5, B, myinshape);
else
myMesh->Perform(S);
}
//=======================================================================
//function : AddInShape
//purpose :
//=======================================================================
void MeshTest_DrawableMesh::AddInShape(const Standard_Boolean inshape)
{
myinshape = inshape;
if (myMesher.IsNull())
{
myMesher = new BRepMesh_IncrementalMesh;
myMesher->SetDeflection(myDeflection);
myMesher->SetAngle(0.5);
}
myMesher->SetShape(theShape);
myMesher->Perform();
}
//=======================================================================
@@ -172,18 +155,15 @@ void MeshTest_DrawableMesh::DrawOn(Draw_Display& /*D*/) const
//function : Copy
//purpose :
//=======================================================================
Handle(Draw_Drawable3D) MeshTest_DrawableMesh::Copy() const
{
Handle(MeshTest_DrawableMesh) D = new MeshTest_DrawableMesh();
return D;
return new MeshTest_DrawableMesh(myMesher);
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void MeshTest_DrawableMesh::Dump(Standard_OStream&) const
{
// Should be reimplemented
@@ -239,24 +219,45 @@ void MeshTest_DrawableMesh::Dump(Standard_OStream&) const
//function : Whatis
//purpose :
//=======================================================================
void MeshTest_DrawableMesh::Whatis(Draw_Interpretor& S) const
void MeshTest_DrawableMesh::Whatis(Draw_Interpretor& theStream) const
{
S << " 3d mesh\n";
S << " - Triangles : " << myMesh->NbTriangles() << "\n";
S << " - Edges : " << myMesh->NbEdges() << "\n";
S << " - Vertices : " << myMesh->NbVertices() << "\n";
S << " - Point3d : " << myMesh->NbPoint3d() << "\n";
const Handle(BRepMesh_FastDiscret)& aMesh = myMesher->Mesh();
Standard_Integer aPointsNb = aMesh->NbBoundaryPoints();
Standard_Integer aTrianglesNb = 0;
Standard_Integer aEdgesNb = 0;
const TopoDS_Shape& aShape = myMesher->Shape();
TopExp_Explorer aFaceIt(aShape, TopAbs_FACE);
for (; aFaceIt.More(); aFaceIt.Next())
{
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
Handle(BRepMesh_FaceAttribute) aAtrribure;
if (!aMesh->GetFaceAttribute(aFace, aAtrribure) || !aAtrribure->IsValid())
continue;
aPointsNb += aAtrribure->ChangeSurfacePoints()->Extent();
Handle(BRepMesh_DataStructureOfDelaun)& aStructure =
aAtrribure->ChangeStructure();
aTrianglesNb += aStructure->ElementsOfDomain().Extent();
aEdgesNb += aStructure->LinksOfDomain().Extent();
}
theStream << " 3d mesh\n";
theStream << " - Triangles : " << aTrianglesNb << "\n";
theStream << " - Edges : " << aEdgesNb << "\n";
theStream << " - Point3d : " << aPointsNb << "\n";
}
//=======================================================================
//function : Mesh
//function : Mesher
//purpose :
//=======================================================================
Handle(BRepMesh_FastDiscret) MeshTest_DrawableMesh::Mesh() const
const Handle(BRepMesh_IncrementalMesh)& MeshTest_DrawableMesh::Mesher() const
{
return myMesh;
return myMesher;
}
@@ -264,7 +265,6 @@ Handle(BRepMesh_FastDiscret) MeshTest_DrawableMesh::Mesh() const
//function : Edges
//purpose :
//=======================================================================
TColStd_SequenceOfInteger& MeshTest_DrawableMesh::Edges()
{
return myEdges;
@@ -275,7 +275,6 @@ TColStd_SequenceOfInteger& MeshTest_DrawableMesh::Edges()
//function : Vertices
//purpose :
//=======================================================================
TColStd_SequenceOfInteger& MeshTest_DrawableMesh::Vertices()
{
return myVertices;
@@ -285,7 +284,6 @@ TColStd_SequenceOfInteger& MeshTest_DrawableMesh::Vertices()
//function : Triangles
//purpose :
//=======================================================================
TColStd_SequenceOfInteger& MeshTest_DrawableMesh::Triangles()
{
return myTriangles;

View File

@@ -16,7 +16,7 @@
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <BRepMesh_FastDiscret.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <Draw_Drawable3D.hxx>
#include <Handle_Draw_Drawable3D.hxx>
@@ -37,40 +37,38 @@ public:
Standard_EXPORT MeshTest_DrawableMesh();
Standard_EXPORT MeshTest_DrawableMesh(const TopoDS_Shape& S,const Standard_Real Deflect,const Standard_Boolean Partage,const Standard_Boolean InShape = Standard_False);
Standard_EXPORT MeshTest_DrawableMesh(const TopoDS_Shape& theShape,
const Standard_Real theDeflection);
Standard_EXPORT MeshTest_DrawableMesh(const Handle(BRepMesh_FastDiscret)& Tr);
Standard_EXPORT MeshTest_DrawableMesh(const Handle(BRepMesh_IncrementalMesh)& theMesher);
Standard_EXPORT void AddInShape(const Standard_Boolean inshape) ;
Standard_EXPORT void Add(const TopoDS_Shape& theShape);
Standard_EXPORT void Add(const TopoDS_Shape& S) ;
Standard_EXPORT TColStd_SequenceOfInteger& Edges();
Standard_EXPORT TColStd_SequenceOfInteger& Edges() ;
Standard_EXPORT TColStd_SequenceOfInteger& Vertices();
Standard_EXPORT TColStd_SequenceOfInteger& Vertices() ;
Standard_EXPORT TColStd_SequenceOfInteger& Triangles();
Standard_EXPORT TColStd_SequenceOfInteger& Triangles() ;
Standard_EXPORT void DrawOn(Draw_Display& theDisplay) const;
Standard_EXPORT void DrawOn(Draw_Display& dis) const;
Standard_EXPORT virtual Handle_Draw_Drawable3D Copy() const;
Standard_EXPORT virtual Handle_Draw_Drawable3D Copy() const;
Standard_EXPORT virtual void Dump(Standard_OStream& theStream) const;
Standard_EXPORT virtual void Dump(Standard_OStream& S) const;
Standard_EXPORT virtual void Whatis(Draw_Interpretor& theDi) const;
Standard_EXPORT virtual void Whatis(Draw_Interpretor& S) const;
Standard_EXPORT Handle(BRepMesh_FastDiscret) Mesh() const;
Standard_EXPORT const Handle(BRepMesh_IncrementalMesh)& Mesher() const;
DEFINE_STANDARD_RTTI(MeshTest_DrawableMesh)
private:
Handle(BRepMesh_FastDiscret) myMesh;
Standard_Real myDeflection;
TColStd_SequenceOfInteger myEdges;
TColStd_SequenceOfInteger myVertices;
TColStd_SequenceOfInteger myTriangles;
Standard_Boolean myinshape;
Handle(BRepMesh_IncrementalMesh) myMesher;
Standard_Real myDeflection;
TColStd_SequenceOfInteger myEdges;
TColStd_SequenceOfInteger myVertices;
TColStd_SequenceOfInteger myTriangles;
};
DEFINE_STANDARD_HANDLE(MeshTest_DrawableMesh, Draw_Drawable3D)

View File

@@ -23,7 +23,7 @@
#include <BRepMesh_DiscretRoot.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <Bnd_Box.hxx>
#include <BRepMesh_PDiscretRoot.hxx>
#include <BRepMesh_DiscretRoot.hxx>
#include <Draw.hxx>
#include <DBRep.hxx>
#include <TopTools_IndexedMapOfShape.hxx>