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_Triangle.hxx>
#include <Poly_PolygonOnTriangulation.hxx> #include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx> #include <Poly_Triangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Geom_Curve.hxx> #include <Geom_Curve.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
@ -688,19 +689,32 @@ void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
aLP.Clear(); aLP.Clear();
BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc); BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc);
if (aTRE.IsNull() || aPTE.IsNull()) { if (aTRE.IsNull() || aPTE.IsNull()) {
myErrorStatus=20; // no triangulation found Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc);
return; 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 gp_Trsf& aTrsf=aLoc.Transformation();
const TColgp_Array1OfPnt& aNodes=aTRE->Nodes(); const TColgp_Array1OfPnt& aNodes=aTRE->Nodes();
// //
aNbNodes=aPTE->NbNodes(); aNbNodes=aPTE->NbNodes();
const TColStd_Array1OfInteger& aInds=aPTE->Nodes(); const TColStd_Array1OfInteger& aInds=aPTE->Nodes();
for (j=2; j<aNbNodes; ++j) { for (j=2; j<aNbNodes; ++j) {
aIndex=aInds(j); aIndex=aInds(j);
aP=aNodes(aIndex).Transformed(aTrsf); aP=aNodes(aIndex).Transformed(aTrsf);
aLP.Append(aP); aLP.Append(aP);
}
} }
// //
aNb=aLP.Extent(); aNb=aLP.Extent();
@ -708,7 +722,6 @@ void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
// try to fill it yourself // try to fill it yourself
InnerPoints(aE, myNbPntsMin, aLP); InnerPoints(aE, myNbPntsMin, aLP);
aNb=aLP.Extent(); aNb=aLP.Extent();
} }
} }
//======================================================================= //=======================================================================

View File

@ -41,6 +41,7 @@
#include <Poly_Triangle.hxx> #include <Poly_Triangle.hxx>
#include <Poly_PolygonOnTriangulation.hxx> #include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx> #include <Poly_Triangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Geom_Curve.hxx> #include <Geom_Curve.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
@ -748,19 +749,32 @@
aLP.Clear(); aLP.Clear();
BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc); BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc);
if (aTRE.IsNull() || aPTE.IsNull()) { if (aTRE.IsNull() || aPTE.IsNull()) {
myErrorStatus=20; // no triangulation found Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc);
return; 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 gp_Trsf& aTrsf=aLoc.Transformation();
const TColgp_Array1OfPnt& aNodes=aTRE->Nodes(); const TColgp_Array1OfPnt& aNodes=aTRE->Nodes();
// //
aNbNodes=aPTE->NbNodes(); aNbNodes=aPTE->NbNodes();
const TColStd_Array1OfInteger& aInds=aPTE->Nodes(); const TColStd_Array1OfInteger& aInds=aPTE->Nodes();
for (j=2; j<aNbNodes; ++j) { for (j=2; j<aNbNodes; ++j) {
aIndex=aInds(j); aIndex=aInds(j);
aP=aNodes(aIndex).Transformed(aTrsf); aP=aNodes(aIndex).Transformed(aTrsf);
aLP.Append(aP); aLP.Append(aP);
}
} }
// //
aNb=aLP.Extent(); aNb=aLP.Extent();
@ -768,7 +782,6 @@
// try to fill it yourself // try to fill it yourself
InnerPoints(aE, myNbPntsMin, aLP); InnerPoints(aE, myNbPntsMin, aLP);
aNb=aLP.Extent(); aNb=aLP.Extent();
} }
} }
//======================================================================= //=======================================================================
@ -818,4 +831,3 @@
// 30- can not obtain the line from the link // 30- can not obtain the line from the link
// 40- point can not be classified // 40- point can not be classified
// 41- invalid data for classifier // 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) bool GEOMImpl_IShapesOperations::CheckTriangulation (const TopoDS_Shape& aShape)
{ {
bool isTriangulation = true;
TopExp_Explorer exp (aShape, TopAbs_FACE); TopExp_Explorer exp (aShape, TopAbs_FACE);
if (!exp.More()) { if (exp.More())
return false; {
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;
}
} }
TopLoc_Location aTopLoc; if (!isTriangulation) {
Handle(Poly_Triangulation) aTRF;
aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc);
if (aTRF.IsNull()) {
// calculate deflection // calculate deflection
Standard_Real aDeviationCoefficient = 0.001; Standard_Real aDeviationCoefficient = 0.001;