NPAL16373: EDF485: GetShapesOn... doesn't work with a wire. Use Poly_Polygon3D, if there are no faces.

This commit is contained in:
jfa 2007-06-21 13:01:53 +00:00
parent e624a896ef
commit 45ac6d194d
3 changed files with 75 additions and 33 deletions

View File

@ -41,6 +41,7 @@
#include <Poly_Triangle.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
@ -688,10 +689,22 @@ void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
aLP.Clear();
BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc);
if (aTRE.IsNull() || aPTE.IsNull()) {
Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc);
if (aPE.IsNull()) {
myErrorStatus=20; // no triangulation found
return;
}
const gp_Trsf& aTrsf=aLoc.Transformation();
const TColgp_Array1OfPnt& aNodes=aPE->Nodes();
//
aNbNodes=aPE->NbNodes();
Standard_Integer low = aNodes.Lower(), up = aNodes.Upper();
for (j=low+1; j<up; ++j) {
aP=aNodes(j).Transformed(aTrsf);
aLP.Append(aP);
}
}
else {
const gp_Trsf& aTrsf=aLoc.Transformation();
const TColgp_Array1OfPnt& aNodes=aTRE->Nodes();
//
@ -702,13 +715,13 @@ void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
aP=aNodes(aIndex).Transformed(aTrsf);
aLP.Append(aP);
}
}
//
aNb=aLP.Extent();
if (!aNb && myNbPntsMin) {
// try to fill it yourself
InnerPoints(aE, myNbPntsMin, aLP);
aNb=aLP.Extent();
}
}
//=======================================================================

View File

@ -41,6 +41,7 @@
#include <Poly_Triangle.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
@ -748,10 +749,22 @@
aLP.Clear();
BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc);
if (aTRE.IsNull() || aPTE.IsNull()) {
Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc);
if (aPE.IsNull()) {
myErrorStatus=20; // no triangulation found
return;
}
const gp_Trsf& aTrsf=aLoc.Transformation();
const TColgp_Array1OfPnt& aNodes=aPE->Nodes();
//
aNbNodes=aPE->NbNodes();
Standard_Integer low = aNodes.Lower(), up = aNodes.Upper();
for (j=low+1; j<up; ++j) {
aP=aNodes(j).Transformed(aTrsf);
aLP.Append(aP);
}
}
else {
const gp_Trsf& aTrsf=aLoc.Transformation();
const TColgp_Array1OfPnt& aNodes=aTRE->Nodes();
//
@ -762,13 +775,13 @@
aP=aNodes(aIndex).Transformed(aTrsf);
aLP.Append(aP);
}
}
//
aNb=aLP.Extent();
if (!aNb && myNbPntsMin) {
// try to fill it yourself
InnerPoints(aE, myNbPntsMin, aLP);
aNb=aLP.Extent();
}
}
//=======================================================================
@ -818,4 +831,3 @@
// 30- can not obtain the line from the link
// 40- point can not be classified
// 41- invalid data for classifier

View File

@ -2689,15 +2689,32 @@ TopoDS_Shape GEOMImpl_IShapesOperations::CompsolidToCompound (const TopoDS_Shape
//=======================================================================
bool GEOMImpl_IShapesOperations::CheckTriangulation (const TopoDS_Shape& aShape)
{
TopExp_Explorer exp (aShape, TopAbs_FACE);
if (!exp.More()) {
return false;
}
bool isTriangulation = true;
TopExp_Explorer exp (aShape, TopAbs_FACE);
if (exp.More())
{
TopLoc_Location aTopLoc;
Handle(Poly_Triangulation) aTRF;
aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc);
if (aTRF.IsNull()) {
isTriangulation = false;
}
}
else // no faces, try edges
{
TopExp_Explorer expe (aShape, TopAbs_EDGE);
if (!expe.More()) {
return false;
}
TopLoc_Location aLoc;
Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc);
if (aPE.IsNull()) {
isTriangulation = false;
}
}
if (!isTriangulation) {
// calculate deflection
Standard_Real aDeviationCoefficient = 0.001;