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

Compare commits

..

2 Commits

Author SHA1 Message Date
dorlov
f501c6ffe2 0033338: Coding - IGESToBRep_CurveAndSurface's method has unreachable code
Applied minor changes in Error Message descriptions and code formatting
2023-03-27 15:40:30 +01:00
dorlov
4c8350dd52 0033338: Coding - IGESToBRep_CurveAndSurface's method has unreachable code
Fixed unreachable code in IGESToBRep_CurveAndSurface::TransferGeometry method
2023-03-27 15:36:24 +01:00
3 changed files with 295 additions and 502 deletions

View File

@@ -226,304 +226,270 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::TransferCurveAndSurface
//function : TransferGeometry
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry
(const Handle(IGESData_IGESEntity)& start,
(const Handle(IGESData_IGESEntity)& theStart,
const Message_ProgressRange& theProgress)
{
// Declaration of messages//
// DCE 22/12/98
//Message_Msg msg1005("IGES_1005"); // Software error : start IsNull.
//Message_Msg msg1015("IGES_1015"); // invalid type or exception raising (software error).
//Message_Msg msg1010("IGES_1010"); // Not sameparameter.
// Message_Msg msg1015("IGES_1015");
//Message_Msg msg210 ("XSTEP_210");
//Message_Msg msg202 ("XSTEP_202");
////////////////////////////
TopoDS_Shape res;
gp_Trsf T408;
if (start.IsNull()) {
Message_Msg msg1005("IGES_1005"); // Software error : start IsNull.
SendFail(start, msg1005);
return res;
// Declaration of messages//
// DCE 22/12/98
//Message_Msg aMsg1005("IGES_1001"); // The type of the Start is not recognized
//Message_Msg aMsg1005("IGES_1005"); // Software error : the Start IsNull.
//Message_Msg aMsg1015("IGES_1015"); // invalid type or exception raising (software error).
//Message_Msg aMsg1010("IGES_1010"); // Not sameparameter.
//Message_Msg aMsg1015("IGES_1020"); // Associated entity IsNull
//Message_Msg aMsg1015("IGES_1025"); // No shape is found for the associated entity for the type 308
//Message_Msg aMsg1015("IGES_1030"); // No shape is found for the associated entity for the type 402
//Message_Msg aMsg1015("IGES_1035"); // The conversion of a Location is not possible
//Message_Msg aMsg210 ("XSTEP_210"); // No associated entities for the type 308
//Message_Msg aMsg202 ("XSTEP_202"); // No associated entities for the type 402
////////////////////////////
TopoDS_Shape aRes;
gp_Trsf aT408;
if (theStart.IsNull())
{
const Message_Msg aMsg1005("IGES_1005"); // Software error : start IsNull.
SendFail(theStart, aMsg1005);
return aRes;
}
// Read of the DE number and the type number of the entity
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
//Standard_Integer typeNumber = start->TypeNumber();
// sln 13.06.2002 OCC448: Avoid transferring invisible sub entities which
// logically depend on the one
Standard_Integer onlyvisible = Interface_Static::IVal("read.iges.onlyvisible");
if (IGESToBRep::IsCurveAndSurface(start)) {
if(onlyvisible && start->BlankStatus() == 1)
return res;
try {
const Standard_Integer anOnlyvisible = Interface_Static::IVal("read.iges.onlyvisible");
if (IGESToBRep::IsCurveAndSurface(theStart))
{
if(anOnlyvisible && theStart->BlankStatus() == 1)
return aRes;
try
{
OCC_CATCH_SIGNALS
res = TransferCurveAndSurface(start, theProgress);
aRes = TransferCurveAndSurface(theStart, theProgress);
}
catch(Standard_Failure const&) {
Message_Msg msg1015("IGES_1015");
SendFail(start, msg1015);
catch(Standard_Failure const&)
{
const Message_Msg aMsg1015("IGES_1015");
SendFail(theStart, aMsg1015);
}
return res;
return aRes;
}
//408 : SingularSubfigure
if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure)))
if (theStart->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure)))
{
if(onlyvisible && start->BlankStatus() == 1)
return res;
DeclareAndCast(IGESBasic_SingularSubfigure, st408, start);
Handle (IGESBasic_SubfigureDef) stsub = st408->Subfigure();
gp_XYZ trans = st408->Translation();
gp_Vec vectr(trans);
Standard_Real scunit = GetUnitFactor();
vectr.Multiply(scunit);
T408.SetTranslation(vectr);
if (st408->HasScaleFactor()) {
Standard_Real scalef = st408->ScaleFactor();
T408.SetScaleFactor(scalef);
}
if (HasShapeResult(stsub)) {
res = GetShapeResult(stsub);
}
else {
try {
OCC_CATCH_SIGNALS
res = TransferGeometry(stsub, theProgress);
}
catch(Standard_Failure const&) {
res.Nullify();
Message_Msg msg1015("IGES_1015");
SendFail( st408, msg1015);
}
if (!res.IsNull()) {
SetShapeResult(stsub,res);
}
}
}
// 308 : SubfigureDefinition
else if (start->IsKind(STANDARD_TYPE(IGESBasic_SubfigureDef))) {
DeclareAndCast(IGESBasic_SubfigureDef, st308, start);
TopoDS_Compound group;
BRep_Builder B;
B.MakeCompound (group);
if (st308->NbEntities() < 1) {
Message_Msg msg210 ("XSTEP_210");
SendFail( st308, msg210);
return res;
}
Message_ProgressScope PS (theProgress, "Subfigure item", st308->NbEntities());
for (Standard_Integer i=1; i <= st308->NbEntities() && PS.More(); i++)
{
Message_ProgressRange aRange = PS.Next();
TopoDS_Shape item;
if (st308->AssociatedEntity(i).IsNull()) {
Message_Msg msg1020("IGES_1020");
msg1020.Arg(i);
SendWarning( st308, msg1020);
continue;
}
if(onlyvisible && st308->AssociatedEntity(i)->BlankStatus() == 1 )
continue;
if (HasShapeResult(st308->AssociatedEntity(i)))
{
item = GetShapeResult(st308->AssociatedEntity(i));
}
else {
try {
OCC_CATCH_SIGNALS
item = TransferGeometry (st308->AssociatedEntity(i), aRange);
}
catch(Standard_Failure const&) {
item.Nullify();
Message_Msg msg1015("IGES_1015");
SendFail( st308->AssociatedEntity(i), msg1015);
}
}
if (item.IsNull()) {
Message_Msg msg1025("IGES_1025");
msg1025.Arg(i);
SendWarning (start,msg1025);
}
else {
B.Add(group, item);
SetShapeResult (st308->AssociatedEntity(i),item);
}
}
res = group;
}
else if (start->IsKind(STANDARD_TYPE(IGESBasic_Group))) {
if(onlyvisible && start->BlankStatus() == 1)
return res;
DeclareAndCast(IGESBasic_Group, st402f1, start);
TopoDS_Compound group;
BRep_Builder B;
B.MakeCompound (group);
if (st402f1->NbEntities() < 1) {
Message_Msg msg202 ("XSTEP_202");
msg202.Arg(st402f1->FormNumber());
SendFail(st402f1, msg202);
return res;
}
Message_ProgressScope PS (theProgress, "Group item", st402f1->NbEntities());
Standard_Boolean ProblemInGroup = Standard_False;
for (Standard_Integer i=1; i <= st402f1->NbEntities() && PS.More(); i++)
{
Message_ProgressRange aRange = PS.Next();
TopoDS_Shape item;
if (st402f1->Entity(i).IsNull()) {
Message_Msg msg1020("IGES_1020");
msg1020.Arg(i);
SendFail( st402f1, msg1020);
continue;
}
if(onlyvisible && st402f1->Entity(i)->BlankStatus() == 1)
continue;
if (HasShapeResult(st402f1->Entity(i))) {
item = GetShapeResult(st402f1->Entity(i));
}
else {
try {
OCC_CATCH_SIGNALS
item = TransferGeometry (st402f1->Entity(i), aRange);
}
catch(Standard_Failure const&) {
item.Nullify();
Message_Msg msg1015("IGES_1015");
SendFail(st402f1->Entity(i),msg1015);
}
}
if (item.IsNull()) {
//Message_Msg msg1030("IGES_1030");
//msg1030.Arg(st402f1->FormNumber());
//msg1030.Arg(i);
//SendWarning (st402f1,msg1030);
ProblemInGroup = Standard_True;
}
else {
B.Add(group, item);
SetShapeResult (st402f1->Entity(i),item);
}
}
res = group;
if(ProblemInGroup) {
Message_Msg msg1030("IGES_1030");
msg1030.Arg(st402f1->FormNumber());
SendWarning (st402f1,msg1030);
}
}
else if (start->IsKind(STANDARD_TYPE(IGESBasic_GroupWithoutBackP))) {
if(onlyvisible && start->BlankStatus() == 1)
return res;
DeclareAndCast(IGESBasic_GroupWithoutBackP, st402f7, start);
TopoDS_Compound group;
//unused Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(st402f7);
BRep_Builder B;
B.MakeCompound (group);
if (st402f7->NbEntities() < 1) {
Message_Msg msg202 ("XSTEP_202");
msg202.Arg(st402f7->FormNumber());
SendFail(st402f7, msg202);
return res;
}
Message_ProgressScope PS (theProgress, "Group item", st402f7->NbEntities());
Standard_Boolean ProblemInGroup = Standard_False;
for (Standard_Integer i=1; i <= st402f7->NbEntities() && PS.More(); i++)
{
Message_ProgressRange aRange = PS.Next();
TopoDS_Shape item;
if (st402f7->Entity(i).IsNull()) {
Message_Msg msg1020("IGES_1020");
msg1020.Arg(i);
SendFail( st402f7, msg1020);
continue;
}
if(onlyvisible && st402f7->Entity(i)->BlankStatus() == 1 )
continue;
if(anOnlyvisible && theStart->BlankStatus() == 1)
return aRes;
if (HasShapeResult(st402f7->Entity(i))) {
item = GetShapeResult(st402f7->Entity(i));
DeclareAndCast(IGESBasic_SingularSubfigure, aSt408, theStart);
Handle (IGESBasic_SubfigureDef) aStsub = aSt408->Subfigure();
const gp_XYZ aTrans = aSt408->Translation();
gp_Vec aVectr(aTrans);
const Standard_Real aScunit = GetUnitFactor();
aVectr.Multiply(aScunit);
aT408.SetTranslation(aVectr);
if (aSt408->HasScaleFactor())
{
const Standard_Real aScalef = aSt408->ScaleFactor();
aT408.SetScaleFactor(aScalef);
}
else {
try {
OCC_CATCH_SIGNALS
item = TransferGeometry (st402f7->Entity(i), aRange);
}
catch(Standard_Failure const&) {
item.Nullify();
Message_Msg msg1015("IGES_1015");
SendFail(st402f7->Entity(i),msg1015);
}
if (HasShapeResult(aStsub))
{
aRes = GetShapeResult(aStsub);
}
if (item.IsNull()) {
//Message_Msg msg1030("IGES_1030");
//msg1030.Arg(st402f7->FormNumber());
//msg1030.Arg(i);
//SendWarning (st402f7,msg1030);
ProblemInGroup = Standard_True;
}
else {
B.Add(group, item);
SetShapeResult (st402f7->Entity(i),item);
else
{
try
{
OCC_CATCH_SIGNALS
aRes = TransferGeometry(aStsub, theProgress);
}
catch(Standard_Failure const&)
{
aRes.Nullify();
const Message_Msg aMsg1015("IGES_1015");
SendFail(aSt408, aMsg1015);
}
if (!aRes.IsNull())
{
SetShapeResult(aStsub, aRes);
}
}
}
res = group;
if(ProblemInGroup) {
Message_Msg msg1030("IGES_1030");
msg1030.Arg(st402f7->FormNumber());
SendWarning (st402f7,msg1030);
// 308 : SubfigureDefinition
else if (theStart->IsKind(STANDARD_TYPE(IGESBasic_SubfigureDef)))
{
DeclareAndCast(IGESBasic_SubfigureDef, aSt308, theStart);
TopoDS_Compound aGroup;
BRep_Builder aBuilder;
aBuilder.MakeCompound (aGroup);
if (aSt308->NbEntities() < 1)
{
const Message_Msg aMsg210 ("XSTEP_210");
SendFail(aSt308, aMsg210);
return aRes;
}
Message_ProgressScope aPS (theProgress, "Subfigure item", aSt308->NbEntities());
for (Standard_Integer anIndx =1; anIndx <= aSt308->NbEntities() && aPS.More(); anIndx++)
{
Message_ProgressRange aRange = aPS.Next();
TopoDS_Shape anItem;
if (aSt308->AssociatedEntity(anIndx).IsNull())
{
Message_Msg aMsg1020("IGES_1020");
aMsg1020.Arg(anIndx);
SendWarning(aSt308, aMsg1020);
continue;
}
if(anOnlyvisible && aSt308->AssociatedEntity(anIndx)->BlankStatus() == 1)
continue;
if (HasShapeResult(aSt308->AssociatedEntity(anIndx)))
{
anItem = GetShapeResult(aSt308->AssociatedEntity(anIndx));
}
else
{
try
{
OCC_CATCH_SIGNALS
anItem = TransferGeometry (aSt308->AssociatedEntity(anIndx), aRange);
}
catch(Standard_Failure const&)
{
anItem.Nullify();
const Message_Msg aMsg1015("IGES_1015");
SendFail(aSt308->AssociatedEntity(anIndx), aMsg1015);
}
}
if (anItem.IsNull())
{
Message_Msg aMsg1025("IGES_1025");
aMsg1025.Arg(anIndx);
SendWarning (theStart, aMsg1025);
}
else
{
aBuilder.Add(aGroup, anItem);
SetShapeResult (aSt308->AssociatedEntity(anIndx), anItem);
}
}
aRes = aGroup;
}
// 402 : Group Associativity
else if (theStart->IsKind(STANDARD_TYPE(IGESBasic_Group)))
{
if(anOnlyvisible && theStart->BlankStatus() == 1)
return aRes;
DeclareAndCast(IGESBasic_Group, aSt402, theStart);
TopoDS_Compound aGroup;
BRep_Builder aBuilder;
aBuilder.MakeCompound (aGroup);
const Standard_Integer aNbEnt = aSt402->NbEntities();
if (aNbEnt < 1)
{
Message_Msg aMsg202 ("XSTEP_202");
aMsg202.Arg(aSt402->FormNumber());
SendFail(aSt402, aMsg202);
return aRes;
}
Message_ProgressScope aPS (theProgress, "Group item", aNbEnt);
Standard_Boolean aProblemInGroup = Standard_False;
for (Standard_Integer anIndx=1; anIndx <= aNbEnt && aPS.More(); anIndx++)
{
Message_ProgressRange aRange = aPS.Next();
TopoDS_Shape anItem;
if (aSt402->Entity(anIndx).IsNull())
{
Message_Msg aMsg1020("IGES_1020");
aMsg1020.Arg(anIndx);
SendFail(aSt402, aMsg1020);
continue;
}
if(anOnlyvisible && aSt402->Entity(anIndx)->BlankStatus() == 1)
continue;
if (HasShapeResult(aSt402->Entity(anIndx)))
{
anItem = GetShapeResult(aSt402->Entity(anIndx));
}
else
{
try
{
OCC_CATCH_SIGNALS
anItem = TransferGeometry (aSt402->Entity(anIndx), aRange);
}
catch(Standard_Failure const&)
{
anItem.Nullify();
const Message_Msg aMsg1015("IGES_1015");
SendFail(aSt402->Entity(anIndx), aMsg1015);
}
}
if (anItem.IsNull())
{
aProblemInGroup = Standard_True;
}
else
{
aBuilder.Add(aGroup, anItem);
SetShapeResult (aSt402->Entity(anIndx), anItem);
}
}
aRes = aGroup;
if(aProblemInGroup)
{
Message_Msg aMsg1030("IGES_1030");
aMsg1030.Arg(aSt402->FormNumber());
SendWarning (aSt402, aMsg1030);
}
}
else {
Message_Msg msg1001("IGES_1001");
msg1001.Arg(start->FormNumber());
SendFail (start,msg1001);
return res;
else
{
Message_Msg aMsg1001("IGES_1001");
aMsg1001.Arg(theStart->FormNumber());
SendFail (theStart, aMsg1001);
return aRes;
}
if (start->HasTransf()) {
gp_Trsf T;
if (theStart->HasTransf())
{
gp_Trsf aT;
SetEpsilon(1.E-04);
if (IGESData_ToolLocation::ConvertLocation(GetEpsilon(),start->CompoundLocation(),
T,GetUnitFactor())) {
if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure)))
{
gp_XYZ tra = T.TranslationPart();
gp_XYZ trans = T408.TranslationPart();
tra.Add(trans);
T.SetTranslationPart(tra);
Standard_Real sc = T.ScaleFactor();
Standard_Real scalef = T408.ScaleFactor();
sc = sc*scalef;
T.SetScaleFactor(sc);
}
TopLoc_Location L(T);
res.Move(L, Standard_False);
if (IGESData_ToolLocation::ConvertLocation(GetEpsilon(), theStart->CompoundLocation(),
aT, GetUnitFactor()))
{
if (theStart->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure)))
{
gp_XYZ aTra = aT.TranslationPart();
const gp_XYZ aTrans = aT408.TranslationPart();
aTra.Add(aTrans);
aT.SetTranslationPart(aTra);
Standard_Real aSc = aT.ScaleFactor();
const Standard_Real aScalef = aT408.ScaleFactor();
aSc = aSc*aScalef;
aT.SetScaleFactor(aSc);
}
const TopLoc_Location aLoc(aT);
aRes.Move(aLoc, Standard_False);
}
else {
Message_Msg msg1035("IGES_1035");
SendWarning (start,msg1035);
else
{
const Message_Msg aMsg1035("IGES_1035");
SendWarning (theStart, aMsg1035);
}
}
else {
if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure))) {
TopLoc_Location L(T408);
res.Move(L);
else
{
if (theStart->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure)))
{
const TopLoc_Location aLoc(aT408);
aRes.Move(aLoc);
}
}
return res;
}
return aRes;
}

View File

@@ -155,16 +155,8 @@ static TopoDS_Edge MakeEdge
TopoDS_Edge E;
B.MakeEdge (E,C3D,Precision::Confusion());
B.Add (E,V1); B.Add (E,V2);
if (!Precision::IsPositiveInfinite(U1) &&
!Precision::IsNegativeInfinite(U1))
{
B.UpdateVertex(V1, U1, E, 0.);
}
if (!Precision::IsPositiveInfinite(U2) &&
!Precision::IsNegativeInfinite(U2))
{
B.UpdateVertex(V2, U2, E, 0.);
}
B.UpdateVertex(V1, U1, E, 0.);
B.UpdateVertex(V2, U2, E, 0.);
return E;
}
@@ -310,17 +302,11 @@ void StepToTopoDS_TranslateEdge::Init(const Handle(StepShape_Edge)& aEdge,
// --- * a 3D Curve
// ----------------------------------------------------------
if (C->IsKind(STANDARD_TYPE(StepGeom_Pcurve)))
{
if ( C->IsKind(STANDARD_TYPE(StepGeom_Pcurve))) {
B.MakeEdge(E);
if (!V1.IsNull())
{
B.Add(E, V1);
}
if (!V2.IsNull())
{
B.Add(E, V2);
}
//:S4136 B.UpdateEdge (E,preci);
B.Add(E, V1);
B.Add(E, V2);
}
else if (C->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve)) ) {
// For SeamCurve and IntersectionCurve types
@@ -394,21 +380,6 @@ void StepToTopoDS_TranslateEdge::MakeFromCurve3D
done = Standard_False;
return;
}
//BRep_Builder aBuilder;
//if (V1.IsNull())
//{
// TopoDS_Vertex aTmpVert;
// const Standard_Real aFirst = C1->FirstParameter();
// aBuilder.MakeVertex(aTmpVert, C1->Value(aFirst), preci);
// V1 = aTmpVert;
//}
//if (V2.IsNull())
//{
// TopoDS_Vertex aTmpVert;
// const Standard_Real aFirst = C1->LastParameter();
// aBuilder.MakeVertex(aTmpVert, C1->Value(aFirst), preci);
// V2 = aTmpVert;
//}
// -- Statistics -- -> No Warning message
aTool.AddContinuity (C1);
BRep_Builder B;

View File

@@ -22,27 +22,21 @@
// rln 02.06.99 removing #include <StepToTopoDS_DegeneratedTool.hxx>
// smh 31.01.01 BUC60810 : IsNull protection
#include <StepToTopoDS_TranslateEdgeLoop.hxx>
#include <BRep_Builder.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_Tool.hxx>
#include <ElCLib.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <gp_Dir.hxx>
#include <Geom_Plane.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_Surface.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom2d_Curve.hxx>
#include <GeomToStep_MakeCartesianPoint.hxx>
#include <gp_Pnt.hxx>
#include <Interface_Static.hxx>
#include <Precision.hxx>
#include <ShapeAlgo.hxx>
#include <ShapeAlgo_AlgoContainer.hxx>
#include <ShapeAlgo_ToolContainer.hxx>
#include <Geom_Line.hxx>
#include <ShapeAnalysis_Curve.hxx>
#include <ShapeAnalysis_Edge.hxx>
#include <ShapeBuild_Edge.hxx>
@@ -58,13 +52,13 @@
#include <StepShape_FaceBound.hxx>
#include <StepShape_OrientedEdge.hxx>
#include <StepShape_Vertex.hxx>
#include <StepShape_VertexPoint.hxx>
#include <StepToGeom.hxx>
#include <StepToTopoDS.hxx>
#include <StepToTopoDS_GeometricTool.hxx>
#include <StepToTopoDS_NMTool.hxx>
#include <StepToTopoDS_Tool.hxx>
#include <StepToTopoDS_TranslateEdge.hxx>
#include <StepToTopoDS_TranslateEdgeLoop.hxx>
#include <StepToTopoDS_TranslateVertex.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
@@ -80,26 +74,6 @@
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
// ============================================================================
// Method : MakeCurveFromStep
// Purpose :
// ============================================================================
static Handle(Geom_Curve) MakeCurveFromStep (const Handle(StepGeom_Curve)& theStepCurve,
const Handle(Transfer_TransientProcess) theTP)
{
Handle(Geom_Curve) aResCurve = Handle(Geom_Curve)::DownCast(theTP->FindTransient(theStepCurve));
if (!aResCurve.IsNull())
{
return aResCurve;
}
aResCurve = StepToGeom::MakeCurve(theStepCurve);
if (!aResCurve.IsNull())
{
theTP->BindTransient(theStepCurve, aResCurve);
}
return aResCurve;
}
// ============================================================================
// Method : RemoveSinglePCurve
// Purpose :
@@ -246,13 +220,21 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
BRep_Builder B;
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
const Standard_Real preci = Precision();
Standard_Real preci = Precision();
TopoDS_Wire W;
TopoDS_Edge E;
TopoDS_Vertex V;
Handle(Geom2d_Curve) C2d, C2d1, C2d2;
Standard_Boolean isSeam, isLikeSeam;
const Standard_Integer NbEdge = EL->NbEdgeList();
Handle(StepShape_OrientedEdge) OrEdge1, OrEdge2;
Handle(StepGeom_Curve) StepCurve, StepCurve1, StepCurve2;
Handle(StepRepr_DefinitionalRepresentation) DRI, Dri1, Dri2;
Handle(Geom2d_Curve) C2d, C2d1, C2d2, WhichC2d1, WhichC2d2;
TopoDS_Edge suspectE; //:f1, degEdge;
Standard_Integer j, NbEdge = EL->NbEdgeList();
if (NbEdge == 0) {
TP->AddWarning(EL, "Wire not done. EdgeLoop does not contain edges.");
done = Standard_False;
@@ -287,9 +269,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
// This case may not be processed, PCurves has to be recomputed from scratch
// -----------------------------------------------
// Standard_Integer theSame = 1; //gka 15.12.98
NCollection_Map<Handle(StepShape_OrientedEdge)> aIncorrectEdges;
for (Standard_Integer j=1; j<=NbEdge; j++) {
Handle(StepShape_OrientedEdge) OrEdge1 = EL->EdgeListValue(j);
for (j=1; j<=NbEdge; j++) {
OrEdge1 = EL->EdgeListValue(j);
if (OrEdge1.IsNull() || OrEdge1->EdgeElement().IsNull())
{
@@ -355,38 +337,21 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
StepToTopoDS_TranslateVertex myTranVertex1(Vstart, aTool, NMTool);
StepToTopoDS_TranslateVertex myTranVertex2(Vend, aTool, NMTool);
if (myTranVertex1.IsDone())
{
if (myTranVertex1.IsDone()) {
V1 = TopoDS::Vertex(myTranVertex1.Value());
}
if (myTranVertex2.IsDone())
{
if (myTranVertex2.IsDone()) {
V2 = TopoDS::Vertex(myTranVertex2.Value());
}
if (!V1.IsNull() && !V2.IsNull())
{
gp_Pnt aPnt1 = BRep_Tool::Pnt(V1);
gp_Pnt aPnt2 = BRep_Tool::Pnt(V2);
if (aPnt1.Distance(aPnt2) <= Precision::Confusion())
{
Standard_Boolean aIsFixed = Standard_True;
if (!iseV)
{
aTool.Bind(Vend, V1);
}
else if (!istV)
{
aTool.Bind(Vstart, V2);
}
else
{
aTool.Bind(Vend, V1);
}
if (!C1.IsNull() && !C1->IsClosed() && aIsFixed)
{
gp_Pnt p1 = BRep_Tool::Pnt(V1);
gp_Pnt p2 = BRep_Tool::Pnt(V2);
if (p1.Distance(p2) <= Precision::Confusion()) { //:S4136: preci) {
Standard_Boolean Fixed = Standard_True;
if (!iseV) aTool.Bind(Vend, V1); //gka 21.08.1998 bug PRO7656
else if (!istV) aTool.Bind (Vstart, V2);
else aTool.Bind (Vend, V1);
if (!C1.IsNull() && !C1->IsClosed() && Fixed)
TP->AddWarning(EL->EdgeListValue(j),
"Vertex of same coordinates, set confused");
}
"Vertex of same coordinates, set confused");
}
}
}
@@ -396,141 +361,32 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
// and make it be one vertex
// NOTE: this is done only for the case if at least one of edges
// was not yet translated; else nothing will help
for (Standard_Integer anEdgeInd = 1; anEdgeInd <= NbEdge; anEdgeInd++)
{
Handle(StepShape_OrientedEdge) anOrEdge1 =
EL->EdgeListValue(anEdgeInd);
Handle(StepShape_OrientedEdge) anOrEdge2 =
EL->EdgeListValue(anEdgeInd < NbEdge ? anEdgeInd + 1 : 1);
if (anOrEdge1.IsNull() || anOrEdge2.IsNull())
for (j=1; j<=NbEdge; j++) {
OrEdge1 = EL->EdgeListValue (j);
OrEdge2 = EL->EdgeListValue (j < NbEdge ? j + 1 : 1);
if (OrEdge1.IsNull() || OrEdge2.IsNull())
continue;
if (!anOrEdge1->EdgeElement().IsNull() &&
anOrEdge1->EdgeElement()->IsKind(STANDARD_TYPE(StepShape_OrientedEdge)))
{
anOrEdge1 = Handle(StepShape_OrientedEdge)::DownCast(anOrEdge1->EdgeElement());
}
if (!anOrEdge2->EdgeElement().IsNull() &&
anOrEdge2->EdgeElement()->IsKind(STANDARD_TYPE(StepShape_OrientedEdge)))
{
anOrEdge2 = Handle(StepShape_OrientedEdge)::DownCast(anOrEdge2->EdgeElement());
}
Handle(StepShape_EdgeCurve) aEC1 =
Handle(StepShape_EdgeCurve)::DownCast(anOrEdge1->EdgeElement());
const Handle(StepShape_EdgeCurve) aEC2 =
Handle(StepShape_EdgeCurve)::DownCast(anOrEdge2->EdgeElement());
if (aEC1.IsNull() || aEC2.IsNull()) // see #29979
Handle(StepShape_EdgeCurve) EC1 =
Handle(StepShape_EdgeCurve)::DownCast (OrEdge1->EdgeElement());
Handle(StepShape_EdgeCurve) EC2 =
Handle(StepShape_EdgeCurve)::DownCast (OrEdge2->EdgeElement());
if (EC1.IsNull() || EC2.IsNull()) // see #29979
{
continue;
}
Handle(StepShape_Vertex) aVs1 = anOrEdge1->Orientation() ? aEC1->EdgeEnd() : aEC1->EdgeStart();
Handle(StepShape_Vertex) aVs2 = anOrEdge2->Orientation() ? aEC2->EdgeStart() : aEC2->EdgeEnd();
Handle(StepShape_Vertex) Vs1, Vs2, Vs11, Vs22;
Vs1 = (OrEdge1->Orientation() ? EC1->EdgeEnd() : EC1->EdgeStart());
Vs2 = (OrEdge2->Orientation() ? EC2->EdgeStart() : EC2->EdgeEnd());
Handle(StepShape_Vertex) aVs11 = anOrEdge1->Orientation() ? aEC1->EdgeStart() : aEC1->EdgeEnd();
const Handle(StepShape_Vertex) aVs22 = anOrEdge2->Orientation() ? aEC2->EdgeEnd() : aEC2->EdgeStart();
Vs11 = (OrEdge1->Orientation() ? EC1->EdgeStart() : EC1->EdgeEnd());
Vs22 = (OrEdge2->Orientation() ? EC2->EdgeEnd() : EC2->EdgeStart());
if (!aVs1.IsNull() && !aVs11.IsNull() &&
((aVs1 == aVs2) || (aVs1 == aVs22) || (aVs2 == aVs11) || (aVs22 == aVs11)))
{
//continue;
}
if (aVs1.IsNull())
{
aIncorrectEdges.Add(anOrEdge1);
if (aVs2.IsNull())
{
Handle(Geom_Curve) aCurve;
const Handle(Geom_Curve) aCurveFirst = MakeCurveFromStep(aEC1->EdgeGeometry(), TP);
const Handle(Geom_Curve) aCurveSecond = MakeCurveFromStep(aEC2->EdgeGeometry(), TP);
Standard_Real aLast = Precision::Infinite();
aCurve = aCurveFirst;
aLast = anOrEdge1->Orientation() ? aCurve->LastParameter() : aCurve->FirstParameter();
if (Precision::IsPositiveInfinite(aLast) ||
Precision::IsNegativeInfinite(aLast))
{
aCurve = aCurveSecond;
aLast = anOrEdge2->Orientation() ? aCurve->FirstParameter() : aCurve->LastParameter();
}
gp_Pnt aStartP;
Standard_Boolean aIsFinded = Standard_False;
if (Precision::IsPositiveInfinite(aLast) ||
Precision::IsNegativeInfinite(aLast))
{
//if (anOrEdge2->Orientation())
//{
// aLast = 0.0;
//}
//else
//{
aCurve = aCurveFirst;
Handle(StepShape_VertexPoint) VP = Handle(StepShape_VertexPoint)::DownCast(aVs22);
Handle(StepGeom_Point) P = VP->VertexGeometry();
Handle(StepGeom_CartesianPoint) P1 = Handle(StepGeom_CartesianPoint)::DownCast(P);
Handle(Geom_CartesianPoint) P2 = StepToGeom::MakeCartesianPoint(P1);
gp_Pnt aLastPnt = P2->Pnt();
VP = Handle(StepShape_VertexPoint)::DownCast(aVs11);
P = VP->VertexGeometry();
P1 = Handle(StepGeom_CartesianPoint)::DownCast(P);
P2 = StepToGeom::MakeCartesianPoint(P1);
gp_Pnt aFirstPnt = P2->Pnt();
aLast = anOrEdge1->Orientation() ? aLastPnt.Distance(aFirstPnt) : 0.0;
if (aCurveFirst->IsKind(STANDARD_TYPE(Geom_Line)))
{
Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(aCurveFirst);
aStartP = aFirstPnt.XYZ() + ((aLine->Position().Direction().XYZ() * aLastPnt.Distance(aFirstPnt)) * (anOrEdge1->Orientation() ? 1 : -1));
aIsFinded = Standard_True;
}
//}
}
if (!aIsFinded)
{
aStartP = aCurve->Value(aLast);
}
GeomToStep_MakeCartesianPoint aMkPoint(aStartP);
const Handle(StepGeom_CartesianPoint) aGpms = aMkPoint.Value();
const Handle(StepShape_VertexPoint) aVSP0 =
new StepShape_VertexPoint();
const Handle(TCollection_HAsciiString) aName =
new TCollection_HAsciiString("");
aVSP0->Init(aName, aGpms);
aVs2 = aVSP0;
}
if (!aVs2.IsNull())
{
aVs1 = aVs2;
if (anOrEdge1->Orientation())
{
aEC1->SetEdgeEnd(aVs1);
}
else
{
aEC1->SetEdgeStart(aVs1);
}
if (anOrEdge2->Orientation())
{
aEC2->SetEdgeStart(aVs1);
}
else
{
aEC2->SetEdgeEnd(aVs1);
}
}
}
else if (aVs2.IsNull())
{
aVs2 = aVs1;
if (anOrEdge2->Orientation())
{
aEC2->SetEdgeStart(aVs1);
}
else
{
aEC2->SetEdgeEnd(aVs1);
}
}
StepToTopoDS_TranslateVertex myTranVertex1 (aVs1, aTool, NMTool);
StepToTopoDS_TranslateVertex myTranVertex2 (aVs2, aTool, NMTool);
if ((Vs1 == Vs2) || (Vs1 == Vs22) || (Vs2 == Vs11) || (Vs22 == Vs11)) continue;
StepToTopoDS_TranslateVertex myTranVertex1 (Vs1, aTool, NMTool);
StepToTopoDS_TranslateVertex myTranVertex2 (Vs2, aTool, NMTool);
TopoDS_Vertex V1, V2;
if (myTranVertex1.IsDone())
@@ -544,8 +400,8 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
gp_Pnt p2 = BRep_Tool::Pnt(V2);
Standard_Boolean locFixed = Standard_True;
if (p1.Distance(p2) <= preci) {
if (! aTool.IsBound (aEC1)) aTool.Bind (aVs1, V2);
else if (! aTool.IsBound (aEC2)) aTool.Bind (aVs2, V1);
if (! aTool.IsBound (EC1)) aTool.Bind (Vs1, V2);
else if (! aTool.IsBound (EC2)) aTool.Bind (Vs2, V1);
else locFixed = Standard_False;
}
else locFixed = Standard_False;
@@ -557,7 +413,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
// Iteration on each Oriented Edge of the EdgeLoop
// -----------------------------------------------
for (Standard_Integer j=1; j<=NbEdge; j++) {
for (j=1; j<=NbEdge; j++) {
Standard_Boolean ThereIsLikeSeam = Standard_False;
@@ -565,7 +421,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
std::cout << " Processing Edge :" << j << std::endl;
#endif
Handle(StepShape_OrientedEdge) OrEdge1 = EL->EdgeListValue(j);
OrEdge1 = EL->EdgeListValue(j);
if (OrEdge1.IsNull() || OrEdge1->EdgeElement().IsNull())
continue;
@@ -574,7 +430,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
OrEdge1 = Handle(StepShape_OrientedEdge)::DownCast (OrEdge1->EdgeElement());
Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(OrEdge1->EdgeElement());
if (EC.IsNull()/* || aIncorrectEdges.Contains(OrEdge1)*/)
if (EC.IsNull())
{
continue;
}
@@ -602,8 +458,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
E.Orientation(TopAbs_FORWARD);
else E.Orientation(TopAbs_REVERSED);
Standard_Boolean isSeam = Standard_False;
Standard_Boolean isLikeSeam = Standard_False;
isSeam = isLikeSeam = Standard_False;
// ------------------------------------------
// Map the StepEdge parametric representation
@@ -671,6 +526,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
}
if (isLikeSeam) {
suspectE = E;
ThereIsLikeSeam = Standard_True;
hasPcurve = Standard_True;
}