-// File: StepToTopoDS_TranslateEdge.cxx
-// Created: Tue Jan 3 11:52:00 1995
-// Author: Frederic MAUPAS
-// <fma@stylox>
+// Created on: 1995-01-03
+// Created by: Frederic MAUPAS
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
//:o0 abv 16.02.99: POLYLINE allowed as 3d curve of edge
//gka,abv 05.04.99: S4136: improving tolerance management, eliminate BRepAPI::Precision()
-#include <StepToTopoDS_TranslateEdge.ixx>
-
-#include <StepToTopoDS.hxx>
-#include <StepToTopoDS_TranslateVertex.hxx>
-#include <StepToTopoDS_GeometricTool.hxx>
-#include <StepToGeom_MakeCurve.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepLib.hxx>
#include <BRepLib_MakeEdge.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom_CartesianPoint.hxx>
#include <Geom_Curve.hxx>
-#include <GeomAbs_Shape.hxx>
-
#include <Geom_Line.hxx>
-#include <gp_Vec.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAbs_Shape.hxx>
+#include <GeomAdaptor_Curve.hxx>
#include <gp_Dir.hxx>
#include <gp_Lin.hxx>
-
+#include <gp_Vec.hxx>
+#include <Precision.hxx>
#include <ShapeAnalysis_Curve.hxx>
#include <ShapeConstruct_Curve.hxx>
-
-#include <StepShape_EdgeCurve.hxx>
-#include <StepShape_OrientedEdge.hxx>
+#include <StdFail_NotDone.hxx>
+#include <StepGeom_CartesianPoint.hxx>
#include <StepGeom_Curve.hxx>
-//#include <StepGeom_Polyline.hxx>
#include <StepGeom_Pcurve.hxx>
+#include <StepGeom_Polyline.hxx>
#include <StepGeom_SurfaceCurve.hxx>
-#include <Transfer_TransientProcess.hxx>
-//#include <TransferBRep.hxx>
-
-#include <GeomAdaptor_Curve.hxx>
-#include <GCPnts_AbscissaPoint.hxx>
-#include <Precision.hxx>
-
-#include <StepToGeom_MakeCurve2d.hxx>
#include <StepRepr_DefinitionalRepresentation.hxx>
+#include <StepShape_Edge.hxx>
+#include <StepShape_EdgeCurve.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_TranslateVertex.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <Transfer_TransientProcess.hxx>
#include <UnitsMethods.hxx>
+#include <Standard_Failure.hxx>
+//#include <StepGeom_Polyline.hxx>
+//#include <TransferBRep.hxx>
//:d8
-#include <StepShape_VertexPoint.hxx>
-#include <StepGeom_CartesianPoint.hxx>
-#include <StepToGeom_MakeCartesianPoint.hxx>
-#include <Geom_CartesianPoint.hxx>
-
// Used in I-DEAS-like STP processing (ssv; 15.11.2010)
-#include <TCollection_HAsciiString.hxx>
-
//#define DEBUG
-
-
// ============================================================================
// Method : DecodeMakeEdgeError
// Purpose :
// ============================================================================
-
static void DecodeMakeEdgeError(const BRepLib_MakeEdge& ME,
const Handle(Standard_Transient)& orig,
const Handle(Geom_Curve)& myCurve,
const TopoDS_Vertex& V1,
const TopoDS_Vertex& V2,
- const Standard_Real& /*U1*/,
- const Standard_Real& /*U2*/,
+ const Standard_Real& U1,
+ const Standard_Real& U2,
StepToTopoDS_Tool& aTool,
const Handle(StepShape_TopologicalRepresentationItem)& /*tobind*/)
{
+ (void)U1, (void)U2; // avoid compiler warning
+
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
-// if (!myCurve.IsNull() && !tobind.IsNull()) {
-// TransferBRep::SetShapeResult
-// (TP,tobind, MakeEdge(myCurve,V1,V2,U1,U2,BRepAPI::Precision()) );
-// aTool.Bind (tobind,E); SURTOUT PAS : noter pour debug/erreur
-// }
-#ifdef DEBUG
+
+#ifdef OCCT_DEBUG
cout << "------------------------------------" << endl;
cout << "MakeEdge Error : " << ME.Error()<<" - ";
#endif
TP->AddFail(orig," Line through identic Points");
break;
}
-#ifdef DEBUG
+#ifdef OCCT_DEBUG
cout << "Original Type : " << orig->DynamicType() << endl;
cout << "3D Curve Type : " << myCurve->DynamicType() << endl;
cout << "First Parameter : " << U1 << endl;
{
Handle(Geom_Curve) C2 = Handle(Geom_Curve)::DownCast (TP->FindTransient(C1));
if (!C2.IsNull()) return C2;
- if (StepToGeom_MakeCurve::Convert(C1,C2))
+ C2 = StepToGeom::MakeCurve (C1);
+ if (! C2.IsNull())
TP->BindTransient (C1,C2);
return C2;
}
static TopoDS_Edge MakeEdge
(const Handle(Geom_Curve)& C3D,
const TopoDS_Vertex& V1, const TopoDS_Vertex& V2,
- const Standard_Real U1, const Standard_Real U2) //, const Standard_Real preci)
+ const Standard_Real U1, const Standard_Real U2)
{
-// fait son edge quoi qu il arrive
BRep_Builder B;
TopoDS_Edge E;
- B.MakeEdge (E,C3D,Precision::Confusion());//preci);
+ B.MakeEdge (E,C3D,Precision::Confusion());
B.Add (E,V1); B.Add (E,V2);
- B.UpdateVertex(V1, U1, E, 0.);//preci);
- B.UpdateVertex(V2, U2, E, 0.);//preci);
+ B.UpdateVertex(V1, U1, E, 0.);
+ B.UpdateVertex(V2, U2, E, 0.);
return E;
}
+// ============================================================================
+// Method : StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge()
+// Purpose :
+// ============================================================================
+
StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge()
{
done = Standard_False;
else {
myError = StepToTopoDS_TranslateEdgeDone;
done = Standard_True;
-// BRep_Builder B;
//:S4136 B.SameRange(TopoDS::Edge(myResult), Standard_False); //:a5 abv 11 Feb 98
//:S4136 B.SameParameter(TopoDS::Edge(myResult), Standard_False);//:a5
return;
BRep_Builder B;
-// Standard_Real preci = BRepAPI::Precision();
-
-// Standard_Real precision = BRepAPI::Precision();
-
Handle(StepGeom_Curve) C = EC->EdgeGeometry();
+ if( C.IsNull())
+ {
+ TP->AddFail(EC," Geom Curve in EdgeCurve is equal to 0");
+ myError = StepToTopoDS_TranslateEdgeOther;
+ done = Standard_False;
+ return;
+ }
TopoDS_Edge E;
Handle(StepShape_Vertex) Vstart, Vend;
// (following the geometrical sense)
// -----------------------------------------------------------
-// Standard_Boolean OrientedEdgeOrientation = OE->Orientation();
- Standard_Boolean EdgeCurveSameSense = EC->SameSense();
+ Standard_Boolean EdgeCurveSameSense = EC->SameSense();
if (EdgeCurveSameSense) {
Vstart = EC->EdgeStart();
if ( C->IsKind(STANDARD_TYPE(StepGeom_Pcurve))) {
B.MakeEdge(E);
//:S4136 B.UpdateEdge (E,preci);
- B.Add(E, V1); // ?? en fin de TranslateEdgeLoop
+ B.Add(E, V1);
B.Add(E, V2);
}
else if (C->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve)) ) {
- // qui reprend les types SeamCurve et IntersectionCurve
+ // For SeamCurve and IntersectionCurve types
// --- The Edge Geometry is a Surface Curve ---
// --- (3d + 2 Pcurve Or Surface) ---
Handle(StepGeom_SurfaceCurve) Sc =
Handle(StepGeom_SurfaceCurve)::DownCast(C);
Handle(StepGeom_Curve) C1 = Sc->Curve3d();
-// if (C1->IsKind(STANDARD_TYPE(StepGeom_Polyline))) {
-// B.MakeEdge(E);
-// B.UpdateEdge (E,preci);
-// B.Add(E, V1); // ?? en fin de TranslateEdgeLoop
-// B.Add(E, V2);
-// }
-// else {
MakeFromCurve3D (C1,EC,Vend,Precision(), E,V1,V2 , aTool);
-// }
}
-// else if (C->IsKind(STANDARD_TYPE(StepGeom_Polyline))) {
-// B.MakeEdge(E);
-// B.UpdateEdge (E,preci);
-// B.Add(E, V1); // ?? en fin de TranslateEdgeLoop
-// B.Add(E, V2);
-// }
else {
// --- The Edge Geometry is a Single 3d Curve ---
MakeFromCurve3D (C,EC,Vend,Precision(), E,V1,V2 , aTool);
}
- // On force les flags SameRange et SameParameter a Standard_False
+ // Force set flags SameRange and SameParameter to Standard_False
if (done) {
//:S4136 B.SameRange(E, Standard_False);
//:S4136 B.SameParameter(E, Standard_False);
gp_Pnt &P1, gp_Pnt &P2)
{
for ( Standard_Integer i=1; i<=2; i++ ) {
- const Handle(StepShape_Vertex) V = ( (Standard_Boolean)(i==1) == EC->SameSense() ? EC->EdgeStart() : EC->EdgeEnd() );
+ const Handle(StepShape_Vertex) V = ((i == 1) == EC->SameSense() ? EC->EdgeStart() : EC->EdgeEnd() );
const Handle(StepShape_VertexPoint) VP = Handle(StepShape_VertexPoint)::DownCast(V);
if ( VP.IsNull() ) continue;
const Handle(StepGeom_CartesianPoint) P = Handle(StepGeom_CartesianPoint)::DownCast(VP->VertexGeometry());
- Handle(Geom_CartesianPoint) CP;
- StepToGeom_MakeCartesianPoint::Convert(P,CP);
- ( i==1 ? P1 : P2 ) = CP->Pnt();
+ Handle(Geom_CartesianPoint) CP = StepToGeom::MakeCartesianPoint (P);
+ ( i==1 ? P1 : P2 ) = CP->Pnt();
}
}
+// ============================================================================
+// Method : StepToTopoDS_TranslateEdge::MakeFromCurve3D()
+// Purpose :
+// ============================================================================
+
void StepToTopoDS_TranslateEdge::MakeFromCurve3D
(const Handle(StepGeom_Curve)& C3D, const Handle(StepShape_EdgeCurve)& EC,
const Handle(StepShape_Vertex)& Vend,
TP->AddWarning(C3D,"Update of 3D-Parameters has failed");
//:d5: instead of AdjustCurve above which is incorrect if U1 and U2 are not ends
- gp_Pnt pU1 = C1->Value ( U1 ), pU2 = C1->Value ( U2 );
+ GeomAdaptor_Curve aCA(C1);
+ gp_Pnt pU1 = aCA.Value ( U1 ), pU2 = aCA.Value ( U2 );
temp1 = pU1.Distance ( pv1 );
temp2 = pU2.Distance ( pv2 );
if ( temp1 > preci || temp2 > preci ) {
}
else {
if (ME.Error() == BRepLib_DifferentPointsOnClosedCurve) {
- // The Edge could be closed and trimmed by 2 Differents
- // Vertices
+ // The Edge could be closed and trimmed by 2 Different vertices
if (C1->IsClosed()) {
- // Attention : il faudra mettre a jour la topologie des
- // vertex pour avoir des edges cul a cul ...... Good Luck!
+ // Attention : topology updating
aTool.Bind (Vend,V1);
TopoDS_Shape aLocalShape = V1.Reversed();
V2 = TopoDS::Vertex(aLocalShape);
}
else {
DecodeMakeEdgeError(ME, C3D, C1, V1, V2, U1, U2, aTool, EC);
- E = MakeEdge (C1,V1,V2,U1,U2);//preci
- myError = StepToTopoDS_TranslateEdgeDone; // ????
+ E = MakeEdge (C1,V1,V2,U1,U2);
+ myError = StepToTopoDS_TranslateEdgeDone;
done = Standard_True;
// return;
}
else {
// Then, this is should be coded as degenerated
// To be performed later !!!
-// DecodeMakeEdgeError(ME, C3D, C1, V1, V2, U1, U2, aTool, EC);
- myError = StepToTopoDS_TranslateEdgeDone; // ????
+ myError = StepToTopoDS_TranslateEdgeDone;
// Bon, on la fait cette petite edge, mais faudra repasser
// pour l enlever ET FUSIONNER LES VERTEX, pour tout le shell !
// courbe trop petite pour etre mise -> fait planter
}
else {
DecodeMakeEdgeError(ME, C3D, C1, V1, V2, U1, U2, aTool, EC);
- E = MakeEdge (C1,V1,V2,U1,U2);//,preci
- myError = StepToTopoDS_TranslateEdgeDone; // ????
+ E = MakeEdge (C1,V1,V2,U1,U2);
+ myError = StepToTopoDS_TranslateEdgeDone;
done = Standard_True;
}
}
const Handle(StepRepr_DefinitionalRepresentation) DRI = PCU->ReferenceToCurve();
if( DRI.IsNull()) return C2d;
const Handle(StepGeom_Curve) StepCurve = Handle(StepGeom_Curve)::DownCast(DRI->ItemsValue(1));
- if (StepToGeom_MakeCurve2d::Convert(StepCurve,C2d)) {
+ try
+ {
+ C2d = StepToGeom::MakeCurve2d (StepCurve);
+ if (! C2d.IsNull()) {
// -- if the surface is a RectangularTrimmedSurface,
// -- send the BasisSurface.
- C2d = UnitsMethods::DegreeToRadian(C2d, ConvSurf);
+ C2d = UnitsMethods::DegreeToRadian(C2d, ConvSurf);
+ }
+
+ }
+ catch(Standard_Failure)
+ {
+ return C2d;
}
return C2d;
}
const TopoDS_Shape& StepToTopoDS_TranslateEdge::Value() const
{
- StdFail_NotDone_Raise_if(!done,"");
+ StdFail_NotDone_Raise_if (!done, "StepToTopoDS_TranslateEdge::Value() - no result");
return myResult;
}