mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0032922: Data Exchange, STEP - The torus is stored incorrectly in STEP format
Problem: the complete surface of the torus is not stored correctly in STEP format due to the fact that the edges are not properly ordered. Change: added a mode for reordering edges in the wire with simultaneous use of 2d and 3d information (ShapeAnalysis_WireOrder). The new mode is used for torus-like surfaces before saving to STEP format. Result: Torus correctly stored.
This commit is contained in:
@@ -260,7 +260,7 @@ void ShapeAnalysis_Wire::SetSurface (const Handle(Geom_Surface)& surface,
|
||||
const Standard_Boolean mode3d)
|
||||
{
|
||||
ShapeAnalysis_WireOrder sawo;
|
||||
CheckOrder (sawo, isClosed, mode3d);
|
||||
CheckOrder (sawo, isClosed, mode3d, Standard_False);
|
||||
myStatusOrder = myStatus;
|
||||
return StatusOrder (ShapeExtend_DONE);
|
||||
}
|
||||
@@ -550,54 +550,94 @@ void ShapeAnalysis_Wire::SetSurface (const Handle(Geom_Surface)& surface,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Wire::CheckOrder(ShapeAnalysis_WireOrder& sawo,
|
||||
Standard_Boolean ShapeAnalysis_Wire::CheckOrder(ShapeAnalysis_WireOrder &sawo,
|
||||
const Standard_Boolean isClosed,
|
||||
const Standard_Boolean mode3d)
|
||||
const Standard_Boolean theMode3D,
|
||||
const Standard_Boolean theModeBoth)
|
||||
{
|
||||
if ( ! mode3d && myFace.IsNull() ) {
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||
if ((!theMode3D || theModeBoth) && myFace.IsNull())
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
sawo.SetMode ( mode3d, ( mode3d ? myPrecision : ::Precision::PConfusion() ) );
|
||||
Standard_Integer i, nb = myWire->NbEdges();
|
||||
sawo.SetMode(theMode3D, 0.0, theModeBoth);
|
||||
Standard_Integer nb = myWire->NbEdges();
|
||||
ShapeAnalysis_Edge EA;
|
||||
for (i = 1; i <= nb; i ++) {
|
||||
Standard_Boolean isAll2dEdgesOk = Standard_True;
|
||||
for (Standard_Integer i = 1; i <= nb; i++)
|
||||
{
|
||||
TopoDS_Edge E = myWire->Edge(i);
|
||||
if ( mode3d ) {
|
||||
TopoDS_Vertex V1 = EA.FirstVertex (E);
|
||||
TopoDS_Vertex V2 = EA.LastVertex (E);
|
||||
gp_XYZ aP1XYZ, aP2XYZ;
|
||||
gp_XY aP1XY, aP2XY;
|
||||
if (theMode3D || theModeBoth)
|
||||
{
|
||||
TopoDS_Vertex V1 = EA.FirstVertex(E);
|
||||
TopoDS_Vertex V2 = EA.LastVertex(E);
|
||||
if (V1.IsNull() || V2.IsNull())
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||
return Standard_False;
|
||||
}
|
||||
gp_Pnt p1 = BRep_Tool::Pnt (V1);
|
||||
gp_Pnt p2 = BRep_Tool::Pnt (V2);
|
||||
sawo.Add (p1.XYZ(),p2.XYZ());
|
||||
}
|
||||
else {
|
||||
Standard_Real f,l;
|
||||
Handle(Geom2d_Curve) c2d;
|
||||
TopoDS_Shape tmpF = myFace.Oriented(TopAbs_FORWARD);
|
||||
if ( ! EA.PCurve(E,TopoDS::Face(tmpF),c2d,f,l) ) {
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||
return Standard_False;
|
||||
else
|
||||
{
|
||||
aP1XYZ = BRep_Tool::Pnt(V1).XYZ();
|
||||
aP2XYZ = BRep_Tool::Pnt(V2).XYZ();
|
||||
}
|
||||
sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY());
|
||||
}
|
||||
if (!theMode3D || theModeBoth)
|
||||
{
|
||||
Standard_Real f, l;
|
||||
Handle(Geom2d_Curve) c2d;
|
||||
TopoDS_Shape tmpF = myFace.Oriented (TopAbs_FORWARD);
|
||||
if (!EA.PCurve(E, TopoDS::Face (tmpF), c2d, f, l))
|
||||
{
|
||||
// if mode is 2d, then we can nothing to do, else we can switch to 3d mode
|
||||
if (!theMode3D && !theModeBoth)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||
return Standard_False;
|
||||
}
|
||||
else
|
||||
{
|
||||
isAll2dEdgesOk = Standard_False;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aP1XY = c2d->Value(f).XY();
|
||||
aP2XY = c2d->Value(l).XY();
|
||||
}
|
||||
}
|
||||
if (theMode3D && !theModeBoth)
|
||||
{
|
||||
sawo.Add (aP1XYZ, aP2XYZ);
|
||||
}
|
||||
else if (!theMode3D && !theModeBoth)
|
||||
{
|
||||
sawo.Add (aP1XY, aP2XY);
|
||||
}
|
||||
else
|
||||
{
|
||||
sawo.Add (aP1XYZ, aP2XYZ, aP1XY, aP2XY);
|
||||
}
|
||||
}
|
||||
sawo.Perform(isClosed);
|
||||
// need to switch to 3d mode
|
||||
if (theModeBoth && !isAll2dEdgesOk)
|
||||
{
|
||||
sawo.SetMode (Standard_True, 0.0, Standard_False);
|
||||
}
|
||||
sawo.Perform (isClosed);
|
||||
Standard_Integer stat = sawo.Status();
|
||||
switch (stat) {
|
||||
switch (stat)
|
||||
{
|
||||
case 0: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK); break;
|
||||
case 1: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); break;
|
||||
case 2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break;
|
||||
case 2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break; // this value is not returned
|
||||
case -1: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3); break;
|
||||
case -2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4); break;
|
||||
case 3: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE5); break;//only shifted
|
||||
case -10: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL1); break;
|
||||
case -2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4); break; // this value is not returned
|
||||
case 3: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE5); break; // only shifted
|
||||
case -10: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL1); break; // this value is not returned
|
||||
}
|
||||
return LastCheckStatus (ShapeExtend_DONE);
|
||||
}
|
||||
|
@@ -232,7 +232,8 @@ public:
|
||||
//! Analyzes the order of the edges in the wire,
|
||||
//! uses class WireOrder for that purpose.
|
||||
//! Flag <isClosed> defines if the wire is closed or not
|
||||
//! Flag <mode3d> defines which mode is used (3d or 2d)
|
||||
//! Flag <theMode3D> defines 3D or 2d mode.
|
||||
//! Flag <theModeBoth> defines miscible mode and the flag <theMode3D> is ignored.
|
||||
//! Returns False if wire is already ordered (tail-to-head),
|
||||
//! True otherwise.
|
||||
//! Use returned WireOrder object for deeper analysis.
|
||||
@@ -243,7 +244,10 @@ public:
|
||||
//! DONE3: not the same edges orientation (some need to be reversed)
|
||||
//! DONE4: as DONE3 and gaps more than myPrecision
|
||||
//! FAIL : algorithm failed (could not detect order)
|
||||
Standard_EXPORT Standard_Boolean CheckOrder (ShapeAnalysis_WireOrder& sawo, const Standard_Boolean isClosed = Standard_True, const Standard_Boolean mode3d = Standard_True);
|
||||
Standard_EXPORT Standard_Boolean CheckOrder(ShapeAnalysis_WireOrder &sawo,
|
||||
Standard_Boolean isClosed = Standard_True,
|
||||
Standard_Boolean theMode3D = Standard_True,
|
||||
Standard_Boolean theModeBoth = Standard_False);
|
||||
|
||||
//! Checks connected edges (num-th and preceding).
|
||||
//! Tests with starting preci from <SBWD> or with <prec> if
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TColgp_HSequenceOfXY.hxx>
|
||||
#include <TColgp_HSequenceOfXYZ.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
@@ -41,12 +42,10 @@ class gp_XY;
|
||||
//! This allows to use this tool, either on existing wire, or on
|
||||
//! data just taken from a file (coordinates are easy to get)
|
||||
//!
|
||||
//! It can work, either in 2D, or in 3D, but not miscible
|
||||
//! Warning about tolerance : according to the mode (2D/3D), it
|
||||
//! must be given as 2D or 3D (i.e. metric) tolerance, uniform
|
||||
//! on the whole list
|
||||
//! It can work, either in 2D, or in 3D, or miscible mode
|
||||
//! The tolerance for each mode is fixed
|
||||
//!
|
||||
//! Two phases : firstly add the couples (start,end)
|
||||
//! Two phases : firstly add the couples (start, end)
|
||||
//! secondly perform then get the result
|
||||
class ShapeAnalysis_WireOrder
|
||||
{
|
||||
@@ -54,17 +53,24 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Empty constructor
|
||||
Standard_EXPORT ShapeAnalysis_WireOrder();
|
||||
|
||||
//! Creates a WireOrder.
|
||||
//! Flag <theMode3D> defines 3D or 2d mode.
|
||||
//! Flag <theModeBoth> defines miscible mode and the flag <theMode3D> is ignored.
|
||||
//! Warning: Parameter <theTolerance> is not used in algorithm.
|
||||
Standard_EXPORT ShapeAnalysis_WireOrder (const Standard_Boolean theMode3D,
|
||||
const Standard_Real theTolerance,
|
||||
const Standard_Boolean theModeBoth = Standard_False);
|
||||
|
||||
//! Creates a WireOrder in 3D (if mode3d is True) or 2D (if False)
|
||||
//! with a tolerance
|
||||
Standard_EXPORT ShapeAnalysis_WireOrder(const Standard_Boolean mode3d, const Standard_Real tol);
|
||||
|
||||
//! Sets new values. Clears the connexion list
|
||||
//! If <mode3d> changes, also clears the edge list (else, doesn't)
|
||||
Standard_EXPORT void SetMode (const Standard_Boolean mode3d, const Standard_Real tol);
|
||||
//! Sets new values.
|
||||
//! Clears the edge list if the mode (<theMode3D> or <theModeBoth> ) changes.
|
||||
//! Clears the connexion list.
|
||||
//! Warning: Parameter <theTolerance> is not used in algorithm.
|
||||
Standard_EXPORT void SetMode (const Standard_Boolean theMode3D,
|
||||
const Standard_Real theTolerance,
|
||||
const Standard_Boolean theModeBoth = Standard_False);
|
||||
|
||||
//! Returns the working tolerance
|
||||
Standard_EXPORT Standard_Real Tolerance() const;
|
||||
@@ -72,12 +78,18 @@ public:
|
||||
//! Clears the list of edges, but not mode and tol
|
||||
Standard_EXPORT void Clear();
|
||||
|
||||
//! Adds a couple of points 3D (start,end)
|
||||
Standard_EXPORT void Add (const gp_XYZ& start3d, const gp_XYZ& end3d);
|
||||
//! Adds a couple of points 3D (start, end)
|
||||
Standard_EXPORT void Add (const gp_XYZ& theStart3d, const gp_XYZ& theEnd3d);
|
||||
|
||||
//! Adds a couple of points 2D (start,end)
|
||||
Standard_EXPORT void Add (const gp_XY& start2d, const gp_XY& end2d);
|
||||
//! Adds a couple of points 2D (start, end)
|
||||
Standard_EXPORT void Add (const gp_XY& theStart2d, const gp_XY& theEnd2d);
|
||||
|
||||
//! Adds a couple of points 3D and 2D (start, end)
|
||||
Standard_EXPORT void Add (const gp_XYZ& theStart3d,
|
||||
const gp_XYZ& theEnd3d,
|
||||
const gp_XY& theStart2d,
|
||||
const gp_XY& theEnd2d);
|
||||
|
||||
//! Returns the count of added couples of points (one per edges)
|
||||
Standard_EXPORT Standard_Integer NbEdges() const;
|
||||
|
||||
@@ -87,12 +99,11 @@ public:
|
||||
Standard_EXPORT Standard_Boolean& KeepLoopsMode();
|
||||
|
||||
//! Computes the better order
|
||||
//! If <closed> is True (D) considers also closure
|
||||
//! Optimised if the couples were already in order
|
||||
//! The criterium is : two couples in order if distance between
|
||||
//! end-prec and start-cur is less then starting tolerance <tol>
|
||||
//! Else, the smallest distance is reached
|
||||
//! Gap corresponds to a smallest distance greater than <tol>
|
||||
//! Warning: Parameter <closed> not used
|
||||
Standard_EXPORT void Perform (const Standard_Boolean closed = Standard_True);
|
||||
|
||||
//! Tells if Perform has been done
|
||||
@@ -102,23 +113,20 @@ public:
|
||||
//! Returns the status of the order (0 if not done) :
|
||||
//! 0 : all edges are direct and in sequence
|
||||
//! 1 : all edges are direct but some are not in sequence
|
||||
//! 2 : in addition, unresolved gaps remain
|
||||
//! -1 : some edges are reversed, but no gap remain
|
||||
//! -2 : some edges are reversed and some gaps remain
|
||||
//! -10 : COULD NOT BE RESOLVED, Failure on Reorder
|
||||
//! gap : regarding starting <tol>
|
||||
//! 3 : edges in sequence are just shifted in forward or reverse manner
|
||||
Standard_EXPORT Standard_Integer Status() const;
|
||||
|
||||
//! Returns the number of original edge which correspond to the
|
||||
//! newly ordered number <n>
|
||||
//! Warning : the returned value is NEGATIVE if edge should be reversed
|
||||
Standard_EXPORT Standard_Integer Ordered (const Standard_Integer n) const;
|
||||
Standard_EXPORT Standard_Integer Ordered (const Standard_Integer theIdx) const;
|
||||
|
||||
//! Returns the values of the couple <num>, as 3D values
|
||||
Standard_EXPORT void XYZ (const Standard_Integer num, gp_XYZ& start3d, gp_XYZ& end3d) const;
|
||||
Standard_EXPORT void XYZ (const Standard_Integer theIdx, gp_XYZ& theStart3D, gp_XYZ& theEnd3D) const;
|
||||
|
||||
//! Returns the values of the couple <num>, as 2D values
|
||||
Standard_EXPORT void XY (const Standard_Integer num, gp_XY& start2d, gp_XY& end2d) const;
|
||||
Standard_EXPORT void XY (const Standard_Integer theIdx, gp_XY& theStart2D, gp_XY& theEnd2D) const;
|
||||
|
||||
//! Returns the gap between a couple and its preceding
|
||||
//! <num> is considered ordered
|
||||
@@ -135,48 +143,40 @@ public:
|
||||
//! Returns, for the chain n0 num, starting and ending numbers of
|
||||
//! edges. In the list of ordered edges (see Ordered for originals)
|
||||
Standard_EXPORT void Chain (const Standard_Integer num, Standard_Integer& n1, Standard_Integer& n2) const;
|
||||
|
||||
|
||||
//! Determines the couples of edges for which end and start fit
|
||||
//! inside a given gap. Queried by NbCouples and Couple
|
||||
//! Warning: function isn't implemented
|
||||
Standard_EXPORT void SetCouples (const Standard_Real gap);
|
||||
|
||||
|
||||
//! Returns the count of computed couples
|
||||
Standard_EXPORT Standard_Integer NbCouples() const;
|
||||
|
||||
|
||||
//! Returns, for the couple n0 num, the two implied edges
|
||||
//! In the list of ordered edges
|
||||
Standard_EXPORT void Couple (const Standard_Integer num, Standard_Integer& n1, Standard_Integer& n2) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
// the mode in which the algorithm works
|
||||
enum ModeType
|
||||
{
|
||||
Mode2D,
|
||||
Mode3D,
|
||||
ModeBoth
|
||||
};
|
||||
|
||||
|
||||
|
||||
Standard_Boolean myKeepLoops;
|
||||
Handle(TColStd_HArray1OfInteger) myOrd;
|
||||
Handle(TColStd_HArray1OfInteger) myChains;
|
||||
Handle(TColStd_HArray1OfInteger) myCouples;
|
||||
Handle(TColgp_HSequenceOfXYZ) myXYZ;
|
||||
Handle(TColgp_HSequenceOfXY) myXY;
|
||||
Standard_Real myTol;
|
||||
Standard_Real myGap;
|
||||
Standard_Integer myStat;
|
||||
Standard_Boolean myMode;
|
||||
|
||||
|
||||
Standard_Boolean myKeepLoops;
|
||||
ModeType myMode;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _ShapeAnalysis_WireOrder_HeaderFile
|
||||
|
Reference in New Issue
Block a user