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

Compare commits

...

1 Commits

Author SHA1 Message Date
atychini
3b9283d92e 0027722: Data Exchange - STEP error for Ellipse revol shape
Bug was fixed by adding new constructor in ShapeAnalysis_Surface class. This constructor gets a TopoDS_Face as a parameter and bounds face with help of BRepTools:UVBounds().
Also I changed callable constructor in some places (where it looks more efficient) from ShapeAnalysis_Surface(const Handle(Geom_Surface)& S) to:
ShapeAnalysis_Surface(const TopoDS_Face& theFace)
2021-12-03 20:07:13 +03:00
12 changed files with 84 additions and 72 deletions

View File

@@ -30,7 +30,10 @@
#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <Bnd_Box.hxx>
#include <Bnd_Box2d.hxx>
#include <BndLib_Add3dCurve.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <ElSLib.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BoundedSurface.hxx>
@@ -108,6 +111,19 @@ ShapeAnalysis_Surface::ShapeAnalysis_Surface(const Handle(Geom_Surface)& S) :
myAdSur = new GeomAdaptor_Surface(mySurf);
}
ShapeAnalysis_Surface::ShapeAnalysis_Surface(const TopoDS_Face& theFace) :
myFace(theFace),
mySurf(BRep_Tool::Surface(theFace)),
myExtOK(Standard_False), //:30
myNbDeg(-1),
myIsos(Standard_False),
myIsoBoxes(Standard_False),
myGap(0.), myUDelt(0.01), myVDelt(0.01), myUCloseVal(-1), myVCloseVal(-1)
{
mySurf->Bounds(myUF, myUL, myVF, myVL);
myAdSur = new GeomAdaptor_Surface(mySurf);
}
//=======================================================================
//function : Init
//purpose :
@@ -166,12 +182,12 @@ void ShapeAnalysis_Surface::ComputeSingularities()
if (mySurf.IsNull()) return;
Standard_Real su1, sv1, su2, sv2;
// mySurf->Bounds(su1, su2, sv1, sv2);
Bounds(su1, su2, sv1, sv2);//modified by rln on 12/11/97 mySurf-> is deleted
myNbDeg = 0; //:r3
if (mySurf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
if (mySurf->IsKind(STANDARD_TYPE(Geom_ConicalSurface)))
{
Bounds(su1, su2, sv1, sv2);
Handle(Geom_ConicalSurface) conicS =
Handle(Geom_ConicalSurface)::DownCast(mySurf);
Standard_Real vApex = -conicS->RefRadius() / Sin(conicS->SemiAngle());
@@ -184,7 +200,9 @@ void ShapeAnalysis_Surface::ComputeSingularities()
myUIsoDeg[0] = Standard_False;
myNbDeg = 1;
}
else if (mySurf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) {
else if (mySurf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)))
{
Bounds(su1, su2, sv1, sv2);
Handle(Geom_ToroidalSurface) toroidS =
Handle(Geom_ToroidalSurface)::DownCast(mySurf);
Standard_Real minorR = toroidS->MinorRadius();
@@ -203,7 +221,9 @@ void ShapeAnalysis_Surface::ComputeSingularities()
myUIsoDeg[0] = myUIsoDeg[1] = Standard_False;
myNbDeg = (majorR > minorR ? 1 : 2);
}
else if (mySurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
else if (mySurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)))
{
Bounds(su1, su2, sv1, sv2);
myPreci[0] = myPreci[1] = 0;
myP3d[0] = mySurf->Value(su1, sv2); // Northern pole is first
myP3d[1] = mySurf->Value(su1, sv1);
@@ -217,10 +237,20 @@ void ShapeAnalysis_Surface::ComputeSingularities()
myNbDeg = 2;
}
else if ((mySurf->IsKind(STANDARD_TYPE(Geom_BoundedSurface))) ||
(mySurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) || //:b2 abv 18 Feb 98
(mySurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) ||
(mySurf->IsKind(STANDARD_TYPE(Geom_OffsetSurface)))) { //rln S4135
//rln S4135 //:r3
Bounds(su1, su2, sv1, sv2);
if (mySurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution)) && !myFace.IsNull())
{
Standard_Real aTmpU1 = 0, aTmpU2 = 0;
Bnd_Box2d B;
BRepTools::AddUVBounds(myFace, B);
if (!B.IsVoid())
{
B.Get(aTmpU1, myVF, aTmpU2, myVL);
}
}
myP3d[0] = myAdSur->Value(su1, 0.5 * (sv1 + sv2));
myFirstP2d[0].SetCoord(su1, sv2);
myLastP2d[0].SetCoord(su1, sv1);

View File

@@ -14,6 +14,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapeAnalysis_Surface_HeaderFile
#define _ShapeAnalysis_Surface_HeaderFile
@@ -24,6 +25,7 @@
#include <Bnd_Box.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <TColgp_SequenceOfPnt2d.hxx>
#include <TopoDS_Face.hxx>
class Geom_Surface;
class Geom_Curve;
@@ -63,6 +65,9 @@ public:
//! Creates an analyzer object on the basis of existing surface
Standard_EXPORT ShapeAnalysis_Surface(const Handle(Geom_Surface)& S);
//! Creates an analyzer object on the basis of existing face
Standard_EXPORT ShapeAnalysis_Surface(const TopoDS_Face& theFace);
//! Loads existing surface
Standard_EXPORT void Init (const Handle(Geom_Surface)& S);
@@ -309,7 +314,7 @@ public:
protected:
TopoDS_Face myFace;
Handle(Geom_Surface) mySurf;
Handle(GeomAdaptor_Surface) myAdSur;
Extrema_ExtPS myExtPS;

View File

@@ -682,8 +682,7 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex (const TopoDS_V
}
Standard_Real aTol = BRep_Tool::Tolerance(anewV);
if(!hasRepr || (fromSurf != toSurf || fromLoc != toLoc)) {
Handle(Geom_Surface) aS = BRep_Tool::Surface(toFace);
Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(aS);
Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(toFace);
gp_Pnt2d aP2d = aSurfTool->ValueOfUV(apv,Precision::Confusion());
apar1 = aP2d.X();
apar2 = aP2d.Y();

View File

@@ -178,7 +178,7 @@ void ShapeAnalysis_Wire::SetFace(const TopoDS_Face& face)
{
myFace = face;
if(!face.IsNull())
mySurf = new ShapeAnalysis_Surface ( BRep_Tool::Surface ( myFace ) );
mySurf = new ShapeAnalysis_Surface (myFace);
}
//=======================================================================

View File

@@ -817,7 +817,7 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire (ShapeFix_WireSegment &wir
BRep_Builder B;
ShapeFix_WireSegment result;
Handle(ShapeAnalysis_Surface) aSurfTool =
new ShapeAnalysis_Surface ( BRep_Tool::Surface (myFace) );
new ShapeAnalysis_Surface ( myFace );
Standard_Integer nbSplits = indexes.Length();
ShapeAnalysis_Edge sae;
Standard_Integer start = 1;
@@ -1210,7 +1210,7 @@ Standard_Boolean ShapeFix_ComposeShell::SplitByLine (ShapeFix_WireSegment &wire,
Standard_Boolean isnonmanifold = (wire.Orientation() == TopAbs_INTERNAL);
//gka correction for non-manifold vertices SAMTECH
if(wire.IsVertex()) {
Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface ( BRep_Tool::Surface (myFace) );
Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface ( myFace );
TopoDS_Vertex aVert = wire.GetVertex();
gp_Pnt aP3d = BRep_Tool::Pnt(aVert);
gp_Pnt2d aP2d = aSurfTool->ValueOfUV(aP3d,Precision::Confusion());
@@ -2339,8 +2339,7 @@ static gp_Pnt2d GetMiddlePoint (const ShapeFix_WireSegment wire,
if(wire.IsVertex()) {
TopoDS_Vertex aV = wire.GetVertex();
gp_Pnt aP3D = BRep_Tool::Pnt(aV );
Handle(Geom_Surface) surf = BRep_Tool::Surface(face);
Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(surf);
Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(face);
return aSurfTool->ValueOfUV(aP3D,Precision::Confusion());
}
Bnd_Box2d box;
@@ -2402,9 +2401,8 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch (TopTools_SequenceOfShape &faces,
// make pseudo-face,
TopoDS_Face pf;
B.MakeFace ( pf, surf, myLoc, ::Precision::Confusion() );
Handle(Geom_Surface) atSurf = BRep_Tool::Surface(pf);
Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(atSurf);
Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(pf);
TopTools_SequenceOfShape roots;
Standard_Integer i; // svv #1
for ( i = 1; i <= loops.Length(); i++ ) {

View File

@@ -255,7 +255,7 @@ void ShapeFix_EdgeProjAux::Init2d (const Standard_Real preci)
//:S4136 Standard_Real preci = BRepAPI::Precision();
//pdn to manage degenerated case
if (V1.IsSame(V2)) {
Handle(ShapeAnalysis_Surface) stsu = new ShapeAnalysis_Surface (theSurface);
Handle(ShapeAnalysis_Surface) stsu = new ShapeAnalysis_Surface (myFace);
gp_Pnt2d aPt1,aPt2;
Standard_Real firstpar,lastpar;
if (stsu->DegeneratedValues(Pt1,preci,aPt1,aPt2,firstpar,lastpar)){

View File

@@ -254,7 +254,7 @@ void ShapeFix_Face::Init (const Handle(ShapeAnalysis_Surface)& surf,
void ShapeFix_Face::Init (const TopoDS_Face& face)
{
myStatus = 0;
mySurf = new ShapeAnalysis_Surface ( BRep_Tool::Surface (face) );
mySurf = new ShapeAnalysis_Surface ( face );
myFwd = ( face.Orientation() != TopAbs_REVERSED );
myFace = face;
myShape = myFace;

View File

@@ -800,7 +800,7 @@ Standard_Boolean ShapeFix_IntersectionTool::FindVertAndSplitEdge
{
// find needed vertex from edge2 and split edge1 using it
ShapeAnalysis_Edge sae;
Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface(BRep_Tool::Surface(face));
Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface(face);
gp_Pnt pi1 = GetPointOnEdge(edge1,sas,Crv1,param1);
BRep_Builder B;
TopoDS_Vertex V;
@@ -869,7 +869,7 @@ Standard_Boolean ShapeFix_IntersectionTool::FixSelfIntersectWire
// step 2 : intersection of non-adjacent edges
ShapeFix_DataMapOfShapeBox2d boxes;
(void)CreateBoxes2d(sewd,face,boxes);
Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface(BRep_Tool::Surface(face));
Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface(face);
NbSplit=0;
NbCut=0;
@@ -1488,7 +1488,7 @@ Standard_Boolean ShapeFix_IntersectionTool::FixIntersectingWires
}
Standard_Boolean isDone = Standard_False; //gka 06.09.04
ShapeAnalysis_Edge sae;
Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface (BRep_Tool::Surface (face));
Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface (face);
// precompute edge boxes for all wires
NCollection_Sequence<ShapeFix_DataMapOfShapeBox2d> aSeqWirEdgeBoxes;

View File

@@ -159,7 +159,7 @@ Standard_Boolean ShapeUpgrade_ClosedFaceDivide::SplitSurface()
if(!doSplit) {
//pdn try to define geometric closure.
Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface( surf );
Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface( face );
Standard_Boolean uclosed = sas->IsUClosed(Precision());
Standard_Boolean vclosed = sas->IsVClosed(Precision());
Standard_Real U1, U2, V1, V2;

View File

@@ -1793,8 +1793,7 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const TopTools_SequenceOfShape&
for (Standard_Integer ii = 1; ii <= ResPCurves.Length(); ii++)
{
const TopoDS_Face& aFace = TopoDS::Face (aFaceSeq(ii));
Handle(Geom_Surface) aSurf = BRep_Tool::Surface (aFace);
Handle(ShapeAnalysis_Surface) aSAS = new ShapeAnalysis_Surface (aSurf);
Handle(ShapeAnalysis_Surface) aSAS = new ShapeAnalysis_Surface (aFace);
ShapeConstruct_ProjectCurveOnSurface aToolProj;
aToolProj.Init (aSAS, Precision::Confusion());
Handle(Geom2d_Curve) aNewPCurve;

28
tests/bugs/step/bug27722 Normal file
View File

@@ -0,0 +1,28 @@
puts "==================================================="
puts "0027722: Data Exchange - STEP er-ror for Ellipse revol shape"
puts "==================================================="
puts ""
pload MODELING XDE VISUALIZATION
ellipse ge 0 0 20 10
mkedge te ge 0 pi/2.0
revol re te 0 0 0 0 1 0 360
# save to STEP in mode: As Is.
stepwrite a re ${imagedir}/${casename}.stp
# read STEP
stepread ${imagedir}/${casename}.stp sr *
ttranslate sr_1 50 0 0
checkshape sr_1
checkprops sr_1 -equal re
vinit view1
vclear
vdisplay -dispmode 1 -3d sr_1 re
vtrihedron vt
vfit
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
file delete ${imagedir}/orig.stp

View File

@@ -1,47 +0,0 @@
puts "TODO OCC27722 ALL: Faulty shapes in variables faulty_1 to faulty_"
puts "TODO OCC27722 ALL: Error : is WRONG because number of "
puts "========"
puts "OCC27722"
puts "========"
puts ""
######################################
# STEP error for Ellipse revol shape
######################################
catch {exec rm ${imagedir}/bug27722.stp}
ellipse ge 0 0 20 10
mkedge te ge 0 pi/2.0
revol re te 0 0 0 0 1 0 360
set i_Vertex 0
set i_Edge 0
set i_Wire 0
set i_Face 0
set i_Shell 0
set i_Solid 0
set i_CSolid 0
set i_Compound 0
set i_Shape 0
set bug_info [string trim [checkshape re]]
if {$bug_info == "This shape seems to be valid"} {
set nb_info [string trim [nbshapes re]]
set i_Vertex [string trim [lindex $nb_info 7]]
set i_Edge [string trim [lindex $nb_info 10]]
set i_Wire [string trim [lindex $nb_info 13]]
set i_Face [string trim [lindex $nb_info 16]]
set i_Shell [string trim [lindex $nb_info 19]]
set i_Solid [string trim [lindex $nb_info 22]]
set i_CSolid [string trim [lindex $nb_info 25]]
set i_Compound [string trim [lindex $nb_info 28]]
set i_Shape [string trim [lindex $nb_info 31]]
} else {
puts "ERROR: Problem of test case functionality. Should be additionally investigated."
}
stepwrite a re ${imagedir}/bug27722.stp
stepread ${imagedir}/bug27722.stp sr *
checkshape sr_1
checknbshapes sr_1 -vertex ${i_Vertex} -edge ${i_Edge} -wire ${i_Wire} -face ${i_Face} -shell ${i_Shell} -solid ${i_Solid} -compsolid ${i_CSolid} -compound ${i_Compound} -shape ${i_Shape}