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

Coding - Apply .clang-format formatting #286

Update empty method guards to new style with regex (see PR).
Used clang-format 18.1.8.
New actions to validate code formatting is added.
Update .clang-format with disabling of include sorting.
  It is temporary changes, then include will be sorted.
Apply formatting for /src and /tools folder.
The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
dpasukhi
2025-01-25 20:15:22 +00:00
parent dbba6f1289
commit a5a7b3185b
14005 changed files with 1273539 additions and 1195567 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -23,42 +23,20 @@
#include <Draw_Interpretor.hxx>
//! Provides methods for testing the mesh algorithms.
class MeshTest
class MeshTest
{
public:
DEFINE_STANDARD_ALLOC
//! Defines meshing commands
Standard_EXPORT static void Commands (Draw_Interpretor& DI);
Standard_EXPORT static void Commands(Draw_Interpretor& DI);
//! Defines plugin commands
Standard_EXPORT static void PluginCommands (Draw_Interpretor& DI);
Standard_EXPORT static void PluginCommands(Draw_Interpretor& DI);
protected:
private:
};
#endif // _MeshTest_HeaderFile

View File

@@ -29,55 +29,54 @@
#include <Precision.hxx>
//=======================================================================
//function : ComputeArea
//purpose : Computes area of the triangle given by its three points (either 2D or3D)
// function : ComputeArea
// purpose : Computes area of the triangle given by its three points (either 2D or3D)
//=======================================================================
static Standard_Real ComputeArea(const gp_XYZ& theP1,
const gp_XYZ& theP2,
const gp_XYZ& theP3)
static Standard_Real ComputeArea(const gp_XYZ& theP1, const gp_XYZ& theP2, const gp_XYZ& theP3)
{
return 0.5*(theP3 - theP1).Crossed(theP2 - theP1).Modulus();
return 0.5 * (theP3 - theP1).Crossed(theP2 - theP1).Modulus();
}
//=======================================================================
//function : ComputeArea
//purpose : Computes area of the triangle given by its three points (either 2D or3D)
// function : ComputeArea
// purpose : Computes area of the triangle given by its three points (either 2D or3D)
//=======================================================================
static Standard_Real ComputeArea(const gp_XY& theP1,
const gp_XY& theP2,
const gp_XY& theP3)
static Standard_Real ComputeArea(const gp_XY& theP1, const gp_XY& theP2, const gp_XY& theP3)
{
return 0.5*Abs((theP3 - theP1).Crossed(theP2 - theP1));
return 0.5 * Abs((theP3 - theP1).Crossed(theP2 - theP1));
}
//=======================================================================
//function : Perform
//purpose : Performs checking
// function : Perform
// purpose : Performs checking
//=======================================================================
void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
void MeshTest_CheckTopology::Perform(Draw_Interpretor& di)
{
TopTools_IndexedMapOfShape aMapF;
TopTools_IndexedMapOfShape aMapF;
TopTools_IndexedDataMapOfShapeListOfShape aMapEF;
TopExp::MapShapes (myShape, TopAbs_FACE, aMapF);
TopExp::MapShapesAndAncestors (myShape, TopAbs_EDGE, TopAbs_FACE, aMapEF);
TopExp::MapShapes(myShape, TopAbs_FACE, aMapF);
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, aMapEF);
// check polygons
Standard_Integer ie;
for (ie=1; ie <= aMapEF.Extent(); ie++) {
const TopoDS_Edge& aEdge = TopoDS::Edge(aMapEF.FindKey(ie));
for (ie = 1; ie <= aMapEF.Extent(); ie++)
{
const TopoDS_Edge& aEdge = TopoDS::Edge(aMapEF.FindKey(ie));
const TopTools_ListOfShape& aFaces = aMapEF(ie);
if (aFaces.Extent() < 2) continue;
if (aFaces.Extent() < 2)
continue;
// get polygon on first face
const TopoDS_Face& aFace1 = TopoDS::Face(aFaces.First());
TopLoc_Location aLoc1;
Handle(Poly_Triangulation) aT1 = BRep_Tool::Triangulation(aFace1, aLoc1);
const TopoDS_Face& aFace1 = TopoDS::Face(aFaces.First());
TopLoc_Location aLoc1;
Handle(Poly_Triangulation) aT1 = BRep_Tool::Triangulation(aFace1, aLoc1);
Handle(Poly_PolygonOnTriangulation) aPoly1 =
BRep_Tool::PolygonOnTriangulation(aEdge, aT1, aLoc1);
if (aPoly1.IsNull() || aT1.IsNull()) {
if (aPoly1.IsNull() || aT1.IsNull())
{
#ifdef OCCT_DEBUG
std::cout<<"problem getting PolygonOnTriangulation of edge "<<ie<<std::endl;
std::cout << "problem getting PolygonOnTriangulation of edge " << ie << std::endl;
#endif
continue;
}
@@ -86,38 +85,42 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
// cycle on other polygons
TopTools_ListIteratorOfListOfShape it(aFaces);
it.Next();
for (; it.More(); it.Next()) {
const TopoDS_Face& aFace2 = TopoDS::Face(it.Value());
TopLoc_Location aLoc2;
Handle(Poly_Triangulation) aT2 = BRep_Tool::Triangulation(aFace2, aLoc2);
for (; it.More(); it.Next())
{
const TopoDS_Face& aFace2 = TopoDS::Face(it.Value());
TopLoc_Location aLoc2;
Handle(Poly_Triangulation) aT2 = BRep_Tool::Triangulation(aFace2, aLoc2);
Handle(Poly_PolygonOnTriangulation) aPoly2 =
BRep_Tool::PolygonOnTriangulation(aEdge, aT2, aLoc2);
if (aPoly2.IsNull() || aT2.IsNull()) {
BRep_Tool::PolygonOnTriangulation(aEdge, aT2, aLoc2);
if (aPoly2.IsNull() || aT2.IsNull())
{
#ifdef OCCT_DEBUG
std::cout<<"problem getting PolygonOnTriangulation of edge "<<ie<<std::endl;
std::cout << "problem getting PolygonOnTriangulation of edge " << ie << std::endl;
#endif
continue;
continue;
}
const TColStd_Array1OfInteger& aNodes2 = aPoly2->Nodes();
// check equality of polygons lengths
if (aNodes2.Length() != aNodes1.Length()) {
myAsyncEdges.Append(ie);
break;
if (aNodes2.Length() != aNodes1.Length())
{
myAsyncEdges.Append(ie);
break;
}
// check distances between corresponding points
Standard_Real aSqDefle = BRep_Tool::Tolerance(aEdge);
aSqDefle *= aSqDefle;
Standard_Integer iF1 = aMapF.FindIndex(aFace1);
Standard_Integer iF2 = aMapF.FindIndex(aFace2);
Standard_Integer i1 = aNodes1.Lower();
Standard_Integer i2 = aNodes2.Lower();
const gp_Trsf &aTrsf1 = aFace1.Location().Transformation();
const gp_Trsf &aTrsf2 = aFace2.Location().Transformation();
for (; i1 <= aNodes1.Upper(); i1++, i2++) {
const gp_Pnt aP1 = aT1->Node (aNodes1[i1]).Transformed (aTrsf1);
const gp_Pnt aP2 = aT2->Node (aNodes2[i2]).Transformed (aTrsf2);
Standard_Integer iF1 = aMapF.FindIndex(aFace1);
Standard_Integer iF2 = aMapF.FindIndex(aFace2);
Standard_Integer i1 = aNodes1.Lower();
Standard_Integer i2 = aNodes2.Lower();
const gp_Trsf& aTrsf1 = aFace1.Location().Transformation();
const gp_Trsf& aTrsf2 = aFace2.Location().Transformation();
for (; i1 <= aNodes1.Upper(); i1++, i2++)
{
const gp_Pnt aP1 = aT1->Node(aNodes1[i1]).Transformed(aTrsf1);
const gp_Pnt aP2 = aT2->Node(aNodes2[i2]).Transformed(aTrsf2);
const Standard_Real aSqDist = aP1.SquareDistance(aP2);
if (aSqDist > aSqDefle)
{
@@ -133,42 +136,47 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
// check triangulations
Standard_Integer iF;
for (iF=1; iF <= aMapF.Extent(); iF++) {
const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(iF));
TopLoc_Location aLoc;
for (iF = 1; iF <= aMapF.Extent(); iF++)
{
const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(iF));
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
if (aT.IsNull()) {
di << "face " <<iF <<" has no triangulation\n";
if (aT.IsNull())
{
di << "face " << iF << " has no triangulation\n";
continue;
}
const gp_Trsf &aTrsf = aLoc.Transformation();
const gp_Trsf& aTrsf = aLoc.Transformation();
// remember boundary nodes
TColStd_PackedMapOfInteger aMapBndNodes;
TopExp_Explorer ex(aFace, TopAbs_EDGE);
for (; ex.More(); ex.Next()) {
const TopoDS_Edge& aEdge = TopoDS::Edge(ex.Current());
TopExp_Explorer ex(aFace, TopAbs_EDGE);
for (; ex.More(); ex.Next())
{
const TopoDS_Edge& aEdge = TopoDS::Edge(ex.Current());
Handle(Poly_PolygonOnTriangulation) aPoly =
BRep_Tool::PolygonOnTriangulation(aEdge, aT, aLoc);
if (aPoly.IsNull()) continue;
BRep_Tool::PolygonOnTriangulation(aEdge, aT, aLoc);
if (aPoly.IsNull())
continue;
const TColStd_Array1OfInteger& aNodes = aPoly->Nodes();
Standard_Integer i;
for (i=aNodes.Lower(); i <= aNodes.Upper(); i++)
aMapBndNodes.Add(aNodes(i));
Standard_Integer i;
for (i = aNodes.Lower(); i <= aNodes.Upper(); i++)
aMapBndNodes.Add(aNodes(i));
}
TColStd_PackedMapOfInteger aUsedNodes;
// check of free links and nodes
Poly_Connect aConn(aT);
Poly_Connect aConn(aT);
Standard_Integer nbTri = aT->NbTriangles(), i, j, n[3], t[3];
for (i = 1; i <= nbTri; i++) {
aT->Triangle (i).Get (n[0], n[1], n[2]);
aUsedNodes.Add (n[0]);
aUsedNodes.Add (n[1]);
aUsedNodes.Add (n[2]);
for (i = 1; i <= nbTri; i++)
{
aT->Triangle(i).Get(n[0], n[1], n[2]);
aUsedNodes.Add(n[0]);
aUsedNodes.Add(n[1]);
aUsedNodes.Add(n[2]);
const gp_Pnt aPts[3] = {aT->Node(n[0]).Transformed(aTrsf),
aT->Node(n[1]).Transformed(aTrsf),
@@ -182,10 +190,8 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
}
else if (aT->HasUVNodes())
{
const gp_XY aPUV[3] = {aT->UVNode(n[0]).XY(),
aT->UVNode(n[1]).XY(),
aT->UVNode(n[2]).XY()};
anArea = ComputeArea(aPUV[0], aPUV[1], aPUV[2]);
const gp_XY aPUV[3] = {aT->UVNode(n[0]).XY(), aT->UVNode(n[1]).XY(), aT->UVNode(n[2]).XY()};
anArea = ComputeArea(aPUV[0], aPUV[1], aPUV[2]);
if (anArea < Precision::SquarePConfusion())
{
mySmallTrianglesFaces.Append(iF);
@@ -194,70 +200,73 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
}
aConn.Triangles(i, t[0], t[1], t[2]);
for (j = 0; j < 3; j++) {
if (t[j] == 0) {
// free link found
Standard_Integer k = (j+1) % 3; // the following node of the edge
Standard_Integer n1 = n[j];
Standard_Integer n2 = n[k];
// skip if it is on boundary
if (aMapBndNodes.Contains(n1) && aMapBndNodes.Contains(n2))
continue;
if (!myMapFaceLinks.Contains(iF)) {
for (j = 0; j < 3; j++)
{
if (t[j] == 0)
{
// free link found
Standard_Integer k = (j + 1) % 3; // the following node of the edge
Standard_Integer n1 = n[j];
Standard_Integer n2 = n[k];
// skip if it is on boundary
if (aMapBndNodes.Contains(n1) && aMapBndNodes.Contains(n2))
continue;
if (!myMapFaceLinks.Contains(iF))
{
Handle(TColStd_HSequenceOfInteger) tmpSeq = new TColStd_HSequenceOfInteger;
myMapFaceLinks.Add(iF, tmpSeq);
myMapFaceLinks.Add(iF, tmpSeq);
}
Handle(TColStd_HSequenceOfInteger)& aSeq = myMapFaceLinks.ChangeFromKey(iF);
aSeq->Append(n1);
aSeq->Append(n2);
}
Handle(TColStd_HSequenceOfInteger)& aSeq = myMapFaceLinks.ChangeFromKey(iF);
aSeq->Append(n1);
aSeq->Append(n2);
}
}
}
// check of free nodes
Standard_Integer aNbNodes = aT->NbNodes();
for (Standard_Integer k = 1; k <= aNbNodes; k++)
if ( ! aUsedNodes.Contains(k) )
if (!aUsedNodes.Contains(k))
{
myFreeNodeFaces.Append (iF);
myFreeNodeNums.Append (k);
myFreeNodeFaces.Append(iF);
myFreeNodeNums.Append(k);
}
}
}
//=======================================================================
//function : GetFreeLink
//purpose : gets the numbers of nodes of a free link with the given index
// function : GetFreeLink
// purpose : gets the numbers of nodes of a free link with the given index
// in the face with the given index
//=======================================================================
void MeshTest_CheckTopology::GetFreeLink(const Standard_Integer theFaceIndex,
const Standard_Integer theLinkIndex,
Standard_Integer& theNode1,
Standard_Integer& theNode2) const
const Standard_Integer theLinkIndex,
Standard_Integer& theNode1,
Standard_Integer& theNode2) const
{
const Handle(TColStd_HSequenceOfInteger)& aSeq = myMapFaceLinks(theFaceIndex);
Standard_Integer aInd = (theLinkIndex-1)*2 + 1;
theNode1 = aSeq->Value(aInd);
theNode2 = aSeq->Value(aInd+1);
Standard_Integer aInd = (theLinkIndex - 1) * 2 + 1;
theNode1 = aSeq->Value(aInd);
theNode2 = aSeq->Value(aInd + 1);
}
//=======================================================================
//function : GetCrossFaceError
//purpose : gets the attributes of a cross face error with the given index
// function : GetCrossFaceError
// purpose : gets the attributes of a cross face error with the given index
//=======================================================================
void MeshTest_CheckTopology::GetCrossFaceError(const Standard_Integer theIndex,
Standard_Integer& theFace1,
Standard_Integer& theNode1,
Standard_Integer& theFace2,
Standard_Integer& theNode2,
Standard_Real& theValue) const
Standard_Integer& theFace1,
Standard_Integer& theNode1,
Standard_Integer& theFace2,
Standard_Integer& theNode2,
Standard_Real& theValue) const
{
Standard_Integer aInd = (theIndex-1)*4 + 1;
theFace1 = myErrors(aInd);
theNode1 = myErrors(aInd+1);
theFace2 = myErrors(aInd+2);
theNode2 = myErrors(aInd+3);
theValue = myErrorsVal(theIndex);
Standard_Integer aInd = (theIndex - 1) * 4 + 1;
theFace1 = myErrors(aInd);
theNode1 = myErrors(aInd + 1);
theFace2 = myErrors(aInd + 2);
theNode2 = myErrors(aInd + 3);
theValue = myErrorsVal(theIndex);
}

View File

@@ -42,86 +42,86 @@ class MeshTest_CheckTopology
public:
//! constructor
MeshTest_CheckTopology(const TopoDS_Shape& theShape)
: myShape(theShape) {}
: myShape(theShape)
{
}
//! performs checking
Standard_EXPORT void Perform(Draw_Interpretor& di);
//! returns the number of faces with free links
Standard_Integer NbFacesWithFL() const
{ return myMapFaceLinks.Extent(); }
Standard_Integer NbFacesWithFL() const { return myMapFaceLinks.Extent(); }
//! returns the number (in the shape) of a face with free links
//! with the given index
Standard_Integer GetFaceNumWithFL(const Standard_Integer theIndex) const
{ return myMapFaceLinks.FindKey(theIndex); }
{
return myMapFaceLinks.FindKey(theIndex);
}
//! returns the number free links on a face with the given index
Standard_Integer NbFreeLinks(const Standard_Integer theIndex) const
{ return myMapFaceLinks(theIndex)->Length() / 2; }
{
return myMapFaceLinks(theIndex)->Length() / 2;
}
//! gets the numbers of nodes of a free link with the given index
//! in the face with the given index
Standard_EXPORT void GetFreeLink(const Standard_Integer theFaceIndex,
const Standard_Integer theLinkIndex,
Standard_Integer& theNode1,
Standard_Integer& theNode2) const;
const Standard_Integer theLinkIndex,
Standard_Integer& theNode1,
Standard_Integer& theNode2) const;
//! returns the number of cross face errors
Standard_Integer NbCrossFaceErrors() const
{ return myErrorsVal.Length(); }
Standard_Integer NbCrossFaceErrors() const { return myErrorsVal.Length(); }
//! gets the attributes of a cross face error with the given index
Standard_EXPORT void GetCrossFaceError(const Standard_Integer theIndex,
Standard_Integer& theFace1,
Standard_Integer& theNode1,
Standard_Integer& theFace2,
Standard_Integer& theNode2,
Standard_Real& theValue) const;
Standard_Integer& theFace1,
Standard_Integer& theNode1,
Standard_Integer& theFace2,
Standard_Integer& theNode2,
Standard_Real& theValue) const;
//! returns the number of async edges
Standard_Integer NbAsyncEdges() const
{ return myAsyncEdges.Length(); }
Standard_Integer NbAsyncEdges() const { return myAsyncEdges.Length(); }
//! returns the number (in the shape) of an async edge with the given index
Standard_Integer GetAsyncEdgeNum(const Standard_Integer theIndex) const
{ return myAsyncEdges(theIndex); }
{
return myAsyncEdges(theIndex);
}
//! returns the number of free nodes
Standard_Integer NbFreeNodes() const
{ return myFreeNodeFaces.Length(); }
Standard_Integer NbFreeNodes() const { return myFreeNodeFaces.Length(); }
//! returns the number of face containing the Index-th detected free node,
//! and number of this node in the triangulation of that face
void GetFreeNodeNum (const Standard_Integer theIndex,
Standard_Integer& theFaceNum,
Standard_Integer& theNodeNum) const
{
void GetFreeNodeNum(const Standard_Integer theIndex,
Standard_Integer& theFaceNum,
Standard_Integer& theNodeNum) const
{
theFaceNum = myFreeNodeFaces(theIndex);
theNodeNum = myFreeNodeNums(theIndex);
}
//! Returns number of triangles with null area
Standard_Integer NbSmallTriangles() const
{
return mySmallTrianglesFaces.Length();
}
Standard_Integer NbSmallTriangles() const { return mySmallTrianglesFaces.Length(); }
//! returns the number of face containing the Index-th detected
//! returns the number of face containing the Index-th detected
//! small triangle and number of the problematic triangle in
//! this face.
void GetSmallTriangle(const Standard_Integer theIndex,
Standard_Integer& theFaceNum,
Standard_Integer& theNodeNum) const
Standard_Integer& theFaceNum,
Standard_Integer& theNodeNum) const
{
theFaceNum = mySmallTrianglesFaces(theIndex);
theNodeNum = mySmallTrianglesTriangles(theIndex);
}
private:
TopoDS_Shape myShape;
NCollection_IndexedDataMap<Standard_Integer,Handle(TColStd_HSequenceOfInteger)>
myMapFaceLinks;
TopoDS_Shape myShape;
NCollection_IndexedDataMap<Standard_Integer, Handle(TColStd_HSequenceOfInteger)> myMapFaceLinks;
TColStd_SequenceOfInteger myErrors;
TColStd_SequenceOfReal myErrorsVal;
@@ -131,7 +131,6 @@ private:
TColStd_SequenceOfInteger myFreeNodeNums;
TColStd_SequenceOfInteger mySmallTrianglesFaces;
TColStd_SequenceOfInteger mySmallTrianglesTriangles;
};
#endif

View File

@@ -24,8 +24,8 @@
// intended for use from debugger prompt (Command Window in Visual Studio)
//=======================================================================
//function : MeshTest_DrawLinks
//purpose : Draw links from mesh data structure of type BRepMesh_FaceAttribute
// function : MeshTest_DrawLinks
// purpose : Draw links from mesh data structure of type BRepMesh_FaceAttribute
//=======================================================================
Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* theDataStruct)
{
@@ -33,8 +33,10 @@ Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* the
{
return "Error: name or face attribute is null";
}
try {
const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData = *(Handle(BRepMesh_DataStructureOfDelaun)*)theDataStruct;
try
{
const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData =
*(Handle(BRepMesh_DataStructureOfDelaun)*)theDataStruct;
if (aMeshData.IsNull())
return "Null mesh data structure";
Standard_Integer nbLinks = aMeshData->NbLinks();
@@ -45,12 +47,12 @@ Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* the
const BRepMesh_Edge& aLink = aMeshData->GetLink(i);
if (aLink.Movability() == BRepMesh_Deleted)
continue;
Standard_Integer n1 = aLink.FirstNode();
Standard_Integer n2 = aLink.LastNode();
const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n1);
const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n2);
Standard_Integer n1 = aLink.FirstNode();
Standard_Integer n2 = aLink.LastNode();
const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n1);
const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n2);
Handle(Draw_Segment3D) aSeg = new Draw_Segment3D(gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0),
gp_Pnt(aV2.Coord().X(), aV2.Coord().Y(), 0),
gp_Pnt(aV2.Coord().X(), aV2.Coord().Y(), 0),
Draw_bleu);
Draw::Set((aName + "_" + i).ToCString(), aSeg);
}
@@ -63,8 +65,8 @@ Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* the
}
//=======================================================================
//function : MeshTest_DrawTriangles
//purpose : Draw triangles from mesh data structure of type BRepMesh_FaceAttribute
// function : MeshTest_DrawTriangles
// purpose : Draw triangles from mesh data structure of type BRepMesh_FaceAttribute
//=======================================================================
Standard_EXPORT const char* MeshTest_DrawTriangles(const char* theNameStr, void* theDataStruct)
{
@@ -72,8 +74,9 @@ Standard_EXPORT const char* MeshTest_DrawTriangles(const char* theNameStr, void*
{
return "Error: name or face attribute is null";
}
try {
const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData =
try
{
const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData =
*(Handle(BRepMesh_DataStructureOfDelaun)*)theDataStruct;
if (aMeshData.IsNull())
@@ -88,15 +91,15 @@ Standard_EXPORT const char* MeshTest_DrawTriangles(const char* theNameStr, void*
continue;
Standard_Integer n[3];
aMeshData->ElementNodes(aTri, n);
const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n[0]);
const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n[1]);
const BRepMesh_Vertex& aV3 = aMeshData->GetNode(n[2]);
gp_Pnt aP[4] = { gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0),
gp_Pnt(aV2.Coord().X(), aV2.Coord().Y(), 0),
gp_Pnt(aV3.Coord().X(), aV3.Coord().Y(), 0),
gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0) };
TColgp_Array1OfPnt aPnts(aP[0], 1, 4);
Handle(Poly_Polygon3D) aPoly = new Poly_Polygon3D(aPnts);
const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n[0]);
const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n[1]);
const BRepMesh_Vertex& aV3 = aMeshData->GetNode(n[2]);
gp_Pnt aP[4] = {gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0),
gp_Pnt(aV2.Coord().X(), aV2.Coord().Y(), 0),
gp_Pnt(aV3.Coord().X(), aV3.Coord().Y(), 0),
gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0)};
TColgp_Array1OfPnt aPnts(aP[0], 1, 4);
Handle(Poly_Polygon3D) aPoly = new Poly_Polygon3D(aPnts);
Handle(DrawTrSurf_Polygon3D) aDPoly = new DrawTrSurf_Polygon3D(aPoly);
Draw::Set((aName + "_" + i).ToCString(), aDPoly);
}

View File

@@ -13,7 +13,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRep_Tool.hxx>
#include <BRepGProp.hxx>
#include <BRepMesh_DiscretFactory.hxx>
@@ -45,199 +44,210 @@
#include <Geom_BSplineCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
static Standard_Integer mpnames (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mpsetdefaultname (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mpgetdefaultname (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mpsetfunctionname (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mpgetfunctionname (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mperror (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mpparallel (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer triarea (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer tricheck (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer mpnames(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer mpsetdefaultname(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer mpgetdefaultname(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer mpsetfunctionname(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer mpgetfunctionname(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer mperror(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer mpincmesh(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer mpparallel(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer triarea(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer tricheck(Draw_Interpretor&, Standard_Integer, const char**);
//=================================================================================================
//=======================================================================
//function : PluginCommands
//purpose :
//=======================================================================
void MeshTest::PluginCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) {
if (done)
{
return;
}
done = Standard_True;
//
const char* g = "Mesh Commands";
// Commands
theCommands.Add("mpnames" , "use mpnames" , __FILE__, mpnames , g);
theCommands.Add("mpsetdefaultname" , "use mpsetdefaultname" , __FILE__, mpsetdefaultname , g);
theCommands.Add("mpgetdefaultname" , "use mpgetdefaultname" , __FILE__, mpgetdefaultname , g);
theCommands.Add("mpsetfunctionname", "use mpsetfunctionname", __FILE__, mpsetfunctionname , g);
theCommands.Add("mpgetfunctionname", "use mpgetfunctionname", __FILE__, mpgetfunctionname , g);
theCommands.Add("mperror" , "use mperror" , __FILE__, mperror , g);
theCommands.Add("mpincmesh" , "use mpincmesh" , __FILE__, mpincmesh , g);
theCommands.Add("mpparallel" , "mpparallel [toTurnOn] : show / set multi-threading flag for incremental mesh",
__FILE__, mpparallel, g);
theCommands.Add("triarea","shape [eps] (computes triangles and surface area)",__FILE__, triarea, g);
theCommands.Add("tricheck", "shape [-small] (checks triangulation of shape);\n"
"\"-small\"-option allows finding triangles with small area", __FILE__, tricheck, g);
theCommands.Add("mpnames", "use mpnames", __FILE__, mpnames, g);
theCommands.Add("mpsetdefaultname", "use mpsetdefaultname", __FILE__, mpsetdefaultname, g);
theCommands.Add("mpgetdefaultname", "use mpgetdefaultname", __FILE__, mpgetdefaultname, g);
theCommands.Add("mpsetfunctionname", "use mpsetfunctionname", __FILE__, mpsetfunctionname, g);
theCommands.Add("mpgetfunctionname", "use mpgetfunctionname", __FILE__, mpgetfunctionname, g);
theCommands.Add("mperror", "use mperror", __FILE__, mperror, g);
theCommands.Add("mpincmesh", "use mpincmesh", __FILE__, mpincmesh, g);
theCommands.Add("mpparallel",
"mpparallel [toTurnOn] : show / set multi-threading flag for incremental mesh",
__FILE__,
mpparallel,
g);
theCommands.Add("triarea",
"shape [eps] (computes triangles and surface area)",
__FILE__,
triarea,
g);
theCommands.Add("tricheck",
"shape [-small] (checks triangulation of shape);\n"
"\"-small\"-option allows finding triangles with small area",
__FILE__,
tricheck,
g);
}
//=======================================================================
//function : mpnames
//purpose :
//=======================================================================
static Standard_Integer mpnames (Draw_Interpretor& , Standard_Integer n, const char** )
//=================================================================================================
static Standard_Integer mpnames(Draw_Interpretor&, Standard_Integer n, const char**)
{
Standard_Integer aNb;
Standard_Integer aNb;
TColStd_MapIteratorOfMapOfAsciiString aIt;
//
if (n!=1) {
if (n != 1)
{
printf(" use mpnames\n");
return 0;
}
//
const TColStd_MapOfAsciiString& aMN=BRepMesh_DiscretFactory::Get().Names();
aNb=aMN.Extent();
if (!aNb) {
const TColStd_MapOfAsciiString& aMN = BRepMesh_DiscretFactory::Get().Names();
aNb = aMN.Extent();
if (!aNb)
{
printf(" *no names found\n");
return 0;
}
//
printf(" *available names:\n");
aIt.Initialize(aMN);
for (; aIt.More(); aIt.Next()) {
const TCollection_AsciiString& aName=aIt.Key();
for (; aIt.More(); aIt.Next())
{
const TCollection_AsciiString& aName = aIt.Key();
printf(" %s\n", aName.ToCString());
}
//
return 0;
}
//=======================================================================
//function : mpsetdefaultname
//purpose :
//=======================================================================
static Standard_Integer mpsetdefaultname (Draw_Interpretor& , Standard_Integer n, const char**a )
//=================================================================================================
static Standard_Integer mpsetdefaultname(Draw_Interpretor&, Standard_Integer n, const char** a)
{
TCollection_AsciiString aName;
//
if (n!=2) {
if (n != 2)
{
printf(" use mpsetdefaultname name\n");
return 0;
}
//
aName=a[1];
aName = a[1];
//
if (BRepMesh_DiscretFactory::Get().SetDefaultName (aName))
if (BRepMesh_DiscretFactory::Get().SetDefaultName(aName))
printf(" *ready\n");
else
printf(" *fault\n");
//
return 0;
}
//=======================================================================
//function : mpgetdefaultname
//purpose :
//=======================================================================
static Standard_Integer mpgetdefaultname (Draw_Interpretor& , Standard_Integer n, const char** )
//=================================================================================================
static Standard_Integer mpgetdefaultname(Draw_Interpretor&, Standard_Integer n, const char**)
{
if (n!=1) {
if (n != 1)
{
printf(" use mpgetdefaultname\n");
return 0;
}
//
const TCollection_AsciiString& aName=BRepMesh_DiscretFactory::Get().DefaultName();
const TCollection_AsciiString& aName = BRepMesh_DiscretFactory::Get().DefaultName();
printf(" *default name: %s\n", aName.ToCString());
//
return 0;
}
//=======================================================================
//function : mpsetfunctionname
//purpose :
//=======================================================================
static Standard_Integer mpsetfunctionname (Draw_Interpretor& , Standard_Integer n, const char**a )
//=================================================================================================
static Standard_Integer mpsetfunctionname(Draw_Interpretor&, Standard_Integer n, const char** a)
{
TCollection_AsciiString aName;
//
if (n!=2) {
if (n != 2)
{
printf(" use mpsetfunctionname name\n");
return 0;
}
//
aName=a[1];
aName = a[1];
//
if (BRepMesh_DiscretFactory::Get().SetFunctionName (aName))
if (BRepMesh_DiscretFactory::Get().SetFunctionName(aName))
printf(" *ready\n");
else
printf(" *fault\n");
//
return 0;
}
//=======================================================================
//function : mpgetdefaultname
//purpose :
//=======================================================================
static Standard_Integer mpgetfunctionname (Draw_Interpretor& , Standard_Integer n, const char** )
//=================================================================================================
static Standard_Integer mpgetfunctionname(Draw_Interpretor&, Standard_Integer n, const char**)
{
if (n!=1) {
if (n != 1)
{
printf(" use mpgetfunctionname\n");
return 0;
}
//
const TCollection_AsciiString& aName=BRepMesh_DiscretFactory::Get().FunctionName();
const TCollection_AsciiString& aName = BRepMesh_DiscretFactory::Get().FunctionName();
printf(" *function name: %s\n", aName.ToCString());
//
return 0;
}
//=======================================================================
//function : mperror
//purpose :
//=======================================================================
static Standard_Integer mperror (Draw_Interpretor& , Standard_Integer n, const char** )
//=================================================================================================
static Standard_Integer mperror(Draw_Interpretor&, Standard_Integer n, const char**)
{
BRepMesh_FactoryError aErr;
//
if (n!=1) {
if (n != 1)
{
printf(" use mperror\n");
return 0;
}
//
aErr=BRepMesh_DiscretFactory::Get().ErrorStatus();
aErr = BRepMesh_DiscretFactory::Get().ErrorStatus();
printf(" *ErrorStatus: %d\n", (int)aErr);
//
return 0;
}
//=======================================================================
//function :mpincmesh
//purpose :
//=======================================================================
static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer n, const char** a)
//=================================================================================================
static Standard_Integer mpincmesh(Draw_Interpretor&, Standard_Integer n, const char** a)
{
Standard_Real aDeflection, aAngle;
TopoDS_Shape aS;
TopoDS_Shape aS;
//
if (n<3) {
if (n < 3)
{
printf(" use mpincmesh s deflection [angle]\n");
return 0;
}
//
aS=DBRep::Get(a[1]);
if (aS.IsNull()) {
aS = DBRep::Get(a[1]);
if (aS.IsNull())
{
printf(" null shapes is not allowed here\n");
return 0;
}
//
aDeflection=Draw::Atof(a[2]);
aAngle=0.5;
if (n>3) {
aAngle=Draw::Atof(a[3]);
aDeflection = Draw::Atof(a[2]);
aAngle = 0.5;
if (n > 3)
{
aAngle = Draw::Atof(a[3]);
}
//
Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (aS,
aDeflection,
aAngle);
Handle(BRepMesh_DiscretRoot) aMeshAlgo =
BRepMesh_DiscretFactory::Get().Discret(aS, aDeflection, aAngle);
//
BRepMesh_FactoryError aErr = BRepMesh_DiscretFactory::Get().ErrorStatus();
if (aErr != BRepMesh_FE_NOERROR)
@@ -260,56 +270,63 @@ static Standard_Integer mpincmesh (Draw_Interpretor& , Standard_Integer n, const
return 0;
}
//#######################################################################
static Standard_Integer triarea (Draw_Interpretor& di, int n, const char ** a)
// #######################################################################
static Standard_Integer triarea(Draw_Interpretor& di, int n, const char** a)
{
if (n < 2) return 1;
if (n < 2)
return 1;
TopoDS_Shape shape = DBRep::Get(a[1]);
if (shape.IsNull()) return 1;
if (shape.IsNull())
return 1;
Standard_Real anEps = -1.;
if (n > 2)
anEps = Draw::Atof(a[2]);
TopTools_IndexedMapOfShape aMapF;
TopExp::MapShapes (shape, TopAbs_FACE, aMapF);
TopExp::MapShapes(shape, TopAbs_FACE, aMapF);
// detect if a shape has triangulation
Standard_Boolean hasPoly = Standard_False;
int i;
for (i=1; i <= aMapF.Extent(); i++) {
const TopoDS_Face& aFace = TopoDS::Face(aMapF(i));
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
if (!aPoly.IsNull()) {
int i;
for (i = 1; i <= aMapF.Extent(); i++)
{
const TopoDS_Face& aFace = TopoDS::Face(aMapF(i));
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace, aLoc);
if (!aPoly.IsNull())
{
hasPoly = Standard_True;
break;
}
}
// compute area by triangles
double aTriArea=0;
if (hasPoly) {
for (i=1; i <= aMapF.Extent(); i++) {
const TopoDS_Face& aFace = TopoDS::Face(aMapF(i));
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
if (aPoly.IsNull()) {
std::cout << "face "<<i<<" has no triangulation"<<std::endl;
double aTriArea = 0;
if (hasPoly)
{
for (i = 1; i <= aMapF.Extent(); i++)
{
const TopoDS_Face& aFace = TopoDS::Face(aMapF(i));
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace, aLoc);
if (aPoly.IsNull())
{
std::cout << "face " << i << " has no triangulation" << std::endl;
continue;
}
for (int j = 1; j <= aPoly->NbTriangles(); j++)
{
const Poly_Triangle tri = aPoly->Triangle (j);
int n1, n2, n3;
tri.Get (n1, n2, n3);
const gp_Pnt p1 = aPoly->Node (n1);
const gp_Pnt p2 = aPoly->Node (n2);
const gp_Pnt p3 = aPoly->Node (n3);
gp_Vec v1(p1, p2);
gp_Vec v2(p1, p3);
double ar = v1.CrossMagnitude(v2);
const Poly_Triangle tri = aPoly->Triangle(j);
int n1, n2, n3;
tri.Get(n1, n2, n3);
const gp_Pnt p1 = aPoly->Node(n1);
const gp_Pnt p2 = aPoly->Node(n2);
const gp_Pnt p3 = aPoly->Node(n3);
gp_Vec v1(p1, p2);
gp_Vec v2(p1, p3);
double ar = v1.CrossMagnitude(v2);
aTriArea += ar;
}
}
@@ -328,23 +345,26 @@ static Standard_Integer triarea (Draw_Interpretor& di, int n, const char ** a)
return 0;
}
//#######################################################################
Standard_Boolean IsEqual(const BRepMesh_Edge& theFirst, const BRepMesh_Edge& theSecond)
// #######################################################################
Standard_Boolean IsEqual(const BRepMesh_Edge& theFirst, const BRepMesh_Edge& theSecond)
{
return theFirst.IsEqual(theSecond);
}
static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
static Standard_Integer tricheck(Draw_Interpretor& di, int n, const char** a)
{
if (n < 2) return 1;
if (n < 2)
return 1;
TopoDS_Shape shape = DBRep::Get(a[1]);
if (shape.IsNull()) return 1;
if (shape.IsNull())
return 1;
const Standard_Boolean isToFindSmallTriangles = (n >= 3) ? (strcmp(a[2], "-small") == 0) : Standard_False;
const Standard_Boolean isToFindSmallTriangles =
(n >= 3) ? (strcmp(a[2], "-small") == 0) : Standard_False;
TopTools_IndexedMapOfShape aMapF;
TopExp::MapShapes (shape, TopAbs_FACE, aMapF);
TopExp::MapShapes(shape, TopAbs_FACE, aMapF);
const Standard_CString name = ".";
// execute check
@@ -353,40 +373,43 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
// dump info on free links inside the triangulation
Standard_Integer nbFree = 0;
Standard_Integer nbFac = aCheck.NbFacesWithFL(), i, k;
if (nbFac > 0) {
for (k=1; k <= nbFac; k++) {
Standard_Integer nbFac = aCheck.NbFacesWithFL(), i, k;
if (nbFac > 0)
{
for (k = 1; k <= nbFac; k++)
{
Standard_Integer nbEdge = aCheck.NbFreeLinks(k);
Standard_Integer iF = aCheck.GetFaceNumWithFL(k);
Standard_Integer iF = aCheck.GetFaceNumWithFL(k);
nbFree += nbEdge;
di << "free links of face " << iF << "\n";
const TopoDS_Shape& aShape = aMapF.FindKey(iF);
const TopoDS_Face& aFace = TopoDS::Face(aShape);
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
const gp_Trsf& trsf = aLoc.Transformation();
const TopoDS_Shape& aShape = aMapF.FindKey(iF);
const TopoDS_Face& aFace = TopoDS::Face(aShape);
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
const gp_Trsf& trsf = aLoc.Transformation();
TColgp_Array1OfPnt pnts(1,2);
TColgp_Array1OfPnt2d pnts2d(1,2);
for (i=1; i <= nbEdge; i++) {
TColgp_Array1OfPnt pnts(1, 2);
TColgp_Array1OfPnt2d pnts2d(1, 2);
for (i = 1; i <= nbEdge; i++)
{
Standard_Integer n1, n2;
aCheck.GetFreeLink(k, i, n1, n2);
di << "{" << n1 << " " << n2 << "} ";
pnts (1) = aT->Node (n1).Transformed (trsf);
pnts (2) = aT->Node (n2).Transformed (trsf);
Handle(Poly_Polygon3D) poly = new Poly_Polygon3D (pnts);
DrawTrSurf::Set (name, poly);
DrawTrSurf::Set (name, pnts(1));
DrawTrSurf::Set (name, pnts(2));
pnts(1) = aT->Node(n1).Transformed(trsf);
pnts(2) = aT->Node(n2).Transformed(trsf);
Handle(Poly_Polygon3D) poly = new Poly_Polygon3D(pnts);
DrawTrSurf::Set(name, poly);
DrawTrSurf::Set(name, pnts(1));
DrawTrSurf::Set(name, pnts(2));
if (aT->HasUVNodes())
{
pnts2d (1) = aT->UVNode (n1);
pnts2d (2) = aT->UVNode (n2);
Handle(Poly_Polygon2D) poly2d = new Poly_Polygon2D (pnts2d);
DrawTrSurf::Set (name, poly2d);
DrawTrSurf::Set (name, pnts2d(1));
DrawTrSurf::Set (name, pnts2d(2));
pnts2d(1) = aT->UVNode(n1);
pnts2d(2) = aT->UVNode(n2);
Handle(Poly_Polygon2D) poly2d = new Poly_Polygon2D(pnts2d);
DrawTrSurf::Set(name, poly2d);
DrawTrSurf::Set(name, pnts2d(1));
DrawTrSurf::Set(name, pnts2d(2));
}
}
di << "\n";
@@ -395,11 +418,13 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
// dump info on cross face errors
Standard_Integer nbErr = aCheck.NbCrossFaceErrors();
if (nbErr > 0) {
if (nbErr > 0)
{
di << "cross face errors: {face1, node1, face2, node2, distance}\n";
for (i=1; i <= nbErr; i++) {
for (i = 1; i <= nbErr; i++)
{
Standard_Integer iF1, n1, iF2, n2;
Standard_Real aVal;
Standard_Real aVal;
aCheck.GetCrossFaceError(i, iF1, n1, iF2, n2, aVal);
di << "{" << iF1 << " " << n1 << " " << iF2 << " " << n2 << " " << aVal << "} ";
}
@@ -408,9 +433,11 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
// dump info on edges
Standard_Integer nbAsync = aCheck.NbAsyncEdges();
if (nbAsync > 0) {
if (nbAsync > 0)
{
di << "async edges:\n";
for (i=1; i <= nbAsync; i++) {
for (i = 1; i <= nbAsync; i++)
{
Standard_Integer ie = aCheck.GetAsyncEdgeNum(i);
di << ie << " ";
}
@@ -419,20 +446,22 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
// dump info on free nodes
Standard_Integer nbFreeNodes = aCheck.NbFreeNodes();
if (nbFreeNodes > 0) {
if (nbFreeNodes > 0)
{
di << "free nodes (in pairs: face / node): \n";
for (i=1; i <= nbFreeNodes; i++) {
for (i = 1; i <= nbFreeNodes; i++)
{
Standard_Integer iface, inode;
aCheck.GetFreeNodeNum(i, iface, inode);
const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(iface));
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
const gp_Trsf& trsf = aLoc.Transformation();
DrawTrSurf::Set (name, aT->Node (inode).Transformed (trsf));
const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(iface));
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
const gp_Trsf& trsf = aLoc.Transformation();
DrawTrSurf::Set(name, aT->Node(inode).Transformed(trsf));
if (aT->HasUVNodes())
{
DrawTrSurf::Set (name, aT->UVNode (inode));
DrawTrSurf::Set(name, aT->UVNode(inode));
}
di << "{" << iface << " " << inode << "} ";
@@ -440,7 +469,7 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
di << "\n";
}
const Standard_Integer aNbSmallTriangles = isToFindSmallTriangles? aCheck.NbSmallTriangles() : 0;
const Standard_Integer aNbSmallTriangles = isToFindSmallTriangles ? aCheck.NbSmallTriangles() : 0;
if (aNbSmallTriangles > 0)
{
di << "triangles with null area (in pairs: face / triangle): \n";
@@ -449,18 +478,18 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
Standard_Integer aFaceId = 0, aTriID = 0;
aCheck.GetSmallTriangle(i, aFaceId, aTriID);
const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(aFaceId));
TopLoc_Location aLoc;
const gp_Trsf& aTrsf = aLoc.Transformation();
const Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
const Poly_Triangle &aTri = aT->Triangle(aTriID);
Standard_Integer aN1, aN2, aN3;
const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(aFaceId));
TopLoc_Location aLoc;
const gp_Trsf& aTrsf = aLoc.Transformation();
const Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
const Poly_Triangle& aTri = aT->Triangle(aTriID);
Standard_Integer aN1, aN2, aN3;
aTri.Get(aN1, aN2, aN3);
TColgp_Array1OfPnt aPoles(1, 4);
aPoles (1) = aPoles (4) = aT->Node (aN1).Transformed (aTrsf);
aPoles (2) = aT->Node (aN2).Transformed (aTrsf);
aPoles (3) = aT->Node (aN3).Transformed (aTrsf);
aPoles(1) = aPoles(4) = aT->Node(aN1).Transformed(aTrsf);
aPoles(2) = aT->Node(aN2).Transformed(aTrsf);
aPoles(3) = aT->Node(aN3).Transformed(aTrsf);
TColStd_Array1OfInteger aMults(1, 4);
aMults(1) = aMults(4) = 2;
@@ -471,7 +500,7 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
aKnots(2) = 2.0;
aKnots(3) = 3.0;
aKnots(4) = 4.0;
Handle(Geom_BSplineCurve) aBS = new Geom_BSplineCurve(aPoles, aKnots, aMults, 1);
DrawTrSurf::Set(name, aBS);
@@ -479,9 +508,9 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
if (aT->HasUVNodes())
{
TColgp_Array1OfPnt2d aPoles2d(1, 4);
aPoles2d (1) = aPoles2d (4) = aT->UVNode (aN1);
aPoles2d (2) = aT->UVNode (aN2);
aPoles2d (3) = aT->UVNode (aN3);
aPoles2d(1) = aPoles2d(4) = aT->UVNode(aN1);
aPoles2d(2) = aT->UVNode(aN2);
aPoles2d(3) = aT->UVNode(aN3);
Handle(Geom2d_BSplineCurve) aBS2d = new Geom2d_BSplineCurve(aPoles2d, aKnots, aMults, 1);
@@ -495,45 +524,39 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
}
// output errors summary to DRAW
if (nbFree > 0 ||
nbErr > 0 ||
nbAsync > 0 ||
nbFreeNodes > 0 ||
(aNbSmallTriangles > 0))
if (nbFree > 0 || nbErr > 0 || nbAsync > 0 || nbFreeNodes > 0 || (aNbSmallTriangles > 0))
{
di << "Free_links " << nbFree
<< " Cross_face_errors " << nbErr
<< " Async_edges " << nbAsync
<< " Free_nodes " << nbFreeNodes
<< " Small triangles " << aNbSmallTriangles << "\n";
di << "Free_links " << nbFree << " Cross_face_errors " << nbErr << " Async_edges " << nbAsync
<< " Free_nodes " << nbFreeNodes << " Small triangles " << aNbSmallTriangles << "\n";
}
Standard_Integer aFaceId = 1;
TopExp_Explorer aFaceExp(shape, TopAbs_FACE);
for ( ; aFaceExp.More(); aFaceExp.Next(), ++aFaceId)
TopExp_Explorer aFaceExp(shape, TopAbs_FACE);
for (; aFaceExp.More(); aFaceExp.Next(), ++aFaceId)
{
const TopoDS_Shape& aShape = aFaceExp.Current();
const TopoDS_Face& aFace = TopoDS::Face(aShape);
const TopoDS_Face& aFace = TopoDS::Face(aShape);
TopLoc_Location aLoc;
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
// Iterate boundary edges
NCollection_Map<BRepMesh_Edge> aBoundaryEdgeMap;
TopExp_Explorer anExp(aShape, TopAbs_EDGE);
for ( ; anExp.More(); anExp.Next() )
TopExp_Explorer anExp(aShape, TopAbs_EDGE);
for (; anExp.More(); anExp.Next())
{
TopLoc_Location anEdgeLoc;
const TopoDS_Edge& anEdge = TopoDS::Edge(anExp.Current());
Handle(Poly_PolygonOnTriangulation) aPoly = BRep_Tool::PolygonOnTriangulation(anEdge, aT, aLoc);
TopLoc_Location anEdgeLoc;
const TopoDS_Edge& anEdge = TopoDS::Edge(anExp.Current());
Handle(Poly_PolygonOnTriangulation) aPoly =
BRep_Tool::PolygonOnTriangulation(anEdge, aT, aLoc);
if (aPoly.IsNull())
{
continue;
}
const TColStd_Array1OfInteger& anIndices = aPoly->Nodes();
Standard_Integer aLower = anIndices.Lower();
Standard_Integer anUpper = anIndices.Upper();
Standard_Integer aLower = anIndices.Lower();
Standard_Integer anUpper = anIndices.Upper();
Standard_Integer aPrevNode = -1;
for (Standard_Integer j = aLower; j <= anUpper; ++j)
@@ -554,11 +577,11 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
}
NCollection_Map<BRepMesh_Edge> aFreeEdgeMap;
const Standard_Integer aTriNum = aT->NbTriangles();
for ( Standard_Integer aTriIndx = 1; aTriIndx <= aTriNum; aTriIndx++ )
const Standard_Integer aTriNum = aT->NbTriangles();
for (Standard_Integer aTriIndx = 1; aTriIndx <= aTriNum; aTriIndx++)
{
const Poly_Triangle aTri = aT->Triangle (aTriIndx);
Standard_Integer aTriNodes[3] = { aTri.Value(1), aTri.Value(2), aTri.Value(3)};
const Poly_Triangle aTri = aT->Triangle(aTriIndx);
Standard_Integer aTriNodes[3] = {aTri.Value(1), aTri.Value(2), aTri.Value(3)};
for (Standard_Integer j = 1; j <= 3; ++j)
{
@@ -582,27 +605,27 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
const gp_Trsf& trsf = aLoc.Transformation();
TColgp_Array1OfPnt pnts(1,2);
TColgp_Array1OfPnt2d pnts2d(1,2);
TColgp_Array1OfPnt pnts(1, 2);
TColgp_Array1OfPnt2d pnts2d(1, 2);
NCollection_Map<BRepMesh_Edge>::Iterator aMapIt(aFreeEdgeMap);
for (; aMapIt.More(); aMapIt.Next())
{
const BRepMesh_Edge& aLink = aMapIt.Key();
di << "{" << aLink.FirstNode() << " " << aLink.LastNode() << "} ";
pnts (1) = aT->Node (aLink.FirstNode()).Transformed (trsf);
pnts (2) = aT->Node (aLink.LastNode()).Transformed (trsf);
Handle(Poly_Polygon3D) poly = new Poly_Polygon3D (pnts);
DrawTrSurf::Set (name, poly);
DrawTrSurf::Set (name, pnts(1));
DrawTrSurf::Set (name, pnts(2));
pnts(1) = aT->Node(aLink.FirstNode()).Transformed(trsf);
pnts(2) = aT->Node(aLink.LastNode()).Transformed(trsf);
Handle(Poly_Polygon3D) poly = new Poly_Polygon3D(pnts);
DrawTrSurf::Set(name, poly);
DrawTrSurf::Set(name, pnts(1));
DrawTrSurf::Set(name, pnts(2));
if (aT->HasUVNodes())
{
pnts2d (1) = aT->UVNode (aLink.FirstNode());
pnts2d (2) = aT->UVNode (aLink.LastNode());
Handle(Poly_Polygon2D) poly2d = new Poly_Polygon2D (pnts2d);
DrawTrSurf::Set (name, poly2d);
DrawTrSurf::Set (name, pnts2d(1));
DrawTrSurf::Set (name, pnts2d(2));
pnts2d(1) = aT->UVNode(aLink.FirstNode());
pnts2d(2) = aT->UVNode(aLink.LastNode());
Handle(Poly_Polygon2D) poly2d = new Poly_Polygon2D(pnts2d);
DrawTrSurf::Set(name, poly2d);
DrawTrSurf::Set(name, pnts2d(1));
DrawTrSurf::Set(name, pnts2d(2));
}
}
di << "\n";
@@ -611,16 +634,14 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
return 0;
}
//=======================================================================
//function : mpparallel
//purpose :
//=======================================================================
static int mpparallel (Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
//=================================================================================================
static int mpparallel(Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
{
if (argc == 2)
{
Standard_Boolean isParallelOn = Draw::Atoi (argv[1]) == 1;
BRepMesh_IncrementalMesh::SetParallelDefault (isParallelOn);
Standard_Boolean isParallelOn = Draw::Atoi(argv[1]) == 1;
BRepMesh_IncrementalMesh::SetParallelDefault(isParallelOn);
}
std::cout << "Incremental Mesh, multi-threading "
<< (BRepMesh_IncrementalMesh::IsParallelDefault() ? "ON\n" : "OFF\n");