1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-18 14:27:39 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

186
src/StepToTopoDS/StepToTopoDS.cdl Executable file
View File

@@ -0,0 +1,186 @@
-- File: StepToTopoDS.cdl
-- Created: Wed Jul 28 11:00:52 1993
-- Author: Martine LANGLOIS
-- <mla@mastox>
---Copyright: Matra Datavision 1993
package StepToTopoDS
--- Purpose: This package implements the mapping between AP214
-- Shape representation and CAS.CAD Shape Representation.
-- The source schema is Part42 (which is included in AP214)
uses TopoDS, StdFail, TCollection, TColStd, BRep, Geom, Geom2d,
GeomAdaptor, Extrema, gp, Transfer, Geom2dAPI,
StepRepr, StepGeom, StepShape, TopTools
is
-- -----------
-- enumeration
-- -----------
enumeration BuilderError is
BuilderDone,
BuilderOther
end;
enumeration TranslateShellError is
TranslateShellDone,
TranslateShellOther
end;
enumeration TranslateFaceError is
TranslateFaceDone,
TranslateFaceOther
end;
enumeration TranslateEdgeLoopError is
TranslateEdgeLoopDone,
TranslateEdgeLoopOther
end;
enumeration TranslateEdgeError is
TranslateEdgeDone,
TranslateEdgeOther
end;
enumeration TranslateVertexError is
TranslateVertexDone,
TranslateVertexOther
end;
enumeration TranslateVertexLoopError is
TranslateVertexLoopDone,
TranslateVertexLoopOther
end;
enumeration TranslatePolyLoopError is
TranslatePolyLoopDone,
TranslatePolyLoopOther
end;
enumeration GeometricToolError is
GeometricToolDone,
GeometricToolIsDegenerated,
GeometricToolHasNoPCurve,
GeometricToolWrong3dParameters,
GeometricToolNoProjectiOnCurve,
GeometricToolOther
end;
-- ---------------
-- Package Classes
-- ---------------
private deferred class Root;
class TranslateShell;
class TranslateFace;
class TranslateEdgeLoop;
class TranslateEdge;
class TranslateVertex;
class TranslatePolyLoop;
class TranslateVertexLoop;
class TranslateCompositeCurve;
class TranslateCurveBoundedSurface;
class Builder;
class MakeTransformed;
class GeometricTool;
-- class DegeneratedTool;
class Tool;
class CartesianPointHasher;
class PointPair;
class PointPairHasher;
class NMTool;
-- --------------------
-- Instanciated Classes
-- --------------------
class DataMapOfRI instantiates
DataMap from TCollection
(RepresentationItem from StepRepr,
Shape from TopoDS,
MapTransientHasher from TColStd);
class DataMapOfRINames instantiates
DataMap from TCollection
(AsciiString from TCollection,
Shape from TopoDS,
AsciiString from TCollection);
class DataMapOfTRI instantiates
DataMap from TCollection
(TopologicalRepresentationItem from StepShape,
Shape from TopoDS,
MapTransientHasher from TColStd);
class PointEdgeMap instantiates
DataMap from TCollection
(PointPair from StepToTopoDS,
Edge from TopoDS,
PointPairHasher from StepToTopoDS);
class PointVertexMap instantiates
DataMap from TCollection
(CartesianPoint from StepGeom,
Vertex from TopoDS,
CartesianPointHasher from StepToTopoDS);
-- class ExtPCOnS instantiates
-- GExtPC from Extrema(CurveOnSurface from GeomAdaptor,
-- CurveOnSurfaceTool from GeomAdaptor,
-- ExtPElC from Extrema,
-- Pnt from gp,
-- Vec from gp,
-- POnCurv from Extrema,
-- SequenceOfPOnCurv from Extrema);
-- --------------
-- Package Method
-- --------------
DecodeBuilderError (Error : BuilderError from StepToTopoDS)
returns HAsciiString from TCollection;
DecodeShellError (Error : TranslateShellError from StepToTopoDS)
returns HAsciiString from TCollection;
DecodeFaceError (Error : TranslateFaceError from StepToTopoDS)
returns HAsciiString from TCollection;
DecodeEdgeError (Error : TranslateEdgeError from StepToTopoDS)
returns HAsciiString from TCollection;
DecodeVertexError (Error : TranslateVertexError from StepToTopoDS)
returns HAsciiString from TCollection;
DecodeVertexLoopError (Error : TranslateVertexLoopError from StepToTopoDS)
returns HAsciiString from TCollection;
DecodePolyLoopError (Error : TranslatePolyLoopError from StepToTopoDS)
returns HAsciiString from TCollection;
DecodeGeometricToolError (Error : GeometricToolError from StepToTopoDS)
returns CString from Standard;
end StepToTopoDS;

181
src/StepToTopoDS/StepToTopoDS.cxx Executable file
View File

@@ -0,0 +1,181 @@
// File: StepToTopoDS.cxx
// Created: Tue Jan 3 11:15:46 1995
// Author: Frederic MAUPAS
// <fma@stylox>
#include <StepToTopoDS.ixx>
Handle(TCollection_HAsciiString) StepToTopoDS::DecodeBuilderError(const StepToTopoDS_BuilderError Error)
{
Handle(TCollection_HAsciiString) mess;
switch(Error)
{
case StepToTopoDS_BuilderDone:
{
mess = new TCollection_HAsciiString("Builder Done");
break;
}
case StepToTopoDS_BuilderOther:
{
mess = new TCollection_HAsciiString("Builder Other");
break;
}
}
return mess;
}
Handle(TCollection_HAsciiString) StepToTopoDS::DecodeShellError(const StepToTopoDS_TranslateShellError Error)
{
Handle(TCollection_HAsciiString) mess;
switch(Error)
{
case StepToTopoDS_TranslateShellDone:
{
mess = new TCollection_HAsciiString("Translate Shell Done");
break;
}
case StepToTopoDS_TranslateShellOther:
{
mess = new TCollection_HAsciiString("Translate Shell Other");
break;
}
}
return mess;
}
Handle(TCollection_HAsciiString) StepToTopoDS::DecodeFaceError(const StepToTopoDS_TranslateFaceError Error)
{
Handle(TCollection_HAsciiString) mess;
switch(Error)
{
case StepToTopoDS_TranslateFaceDone:
{
mess = new TCollection_HAsciiString("Translate Face Done");
break;
}
case StepToTopoDS_TranslateFaceOther:
{
mess = new TCollection_HAsciiString("Translate Face Other");
break;
}
}
return mess;
}
Handle(TCollection_HAsciiString) StepToTopoDS::DecodeEdgeError(const StepToTopoDS_TranslateEdgeError Error)
{
Handle(TCollection_HAsciiString) mess;
switch(Error)
{
case StepToTopoDS_TranslateEdgeDone:
{
mess = new TCollection_HAsciiString("Translate Edge Done");
break;
}
case StepToTopoDS_BuilderOther:
{
mess = new TCollection_HAsciiString("Translate Edge Other");
break;
}
}
return mess;
}
Handle(TCollection_HAsciiString) StepToTopoDS::DecodeVertexError(const StepToTopoDS_TranslateVertexError Error)
{
Handle(TCollection_HAsciiString) mess;
switch(Error)
{
case StepToTopoDS_TranslateVertexDone:
{
mess = new TCollection_HAsciiString("Translate Vertex Done");
break;
}
case StepToTopoDS_TranslateVertexOther:
{
mess = new TCollection_HAsciiString("Translate Vertex Other");
break;
}
}
return mess;
}
Handle(TCollection_HAsciiString) StepToTopoDS::DecodeVertexLoopError(const StepToTopoDS_TranslateVertexLoopError Error)
{
Handle(TCollection_HAsciiString) mess;
switch(Error)
{
case StepToTopoDS_TranslateVertexLoopDone:
{
mess = new TCollection_HAsciiString("Translate VertexLoop Done");
break;
}
case StepToTopoDS_TranslateVertexLoopOther:
{
mess = new TCollection_HAsciiString("Translate VertexLoop Other");
break;
}
}
return mess;
}
Handle(TCollection_HAsciiString) StepToTopoDS::DecodePolyLoopError(const StepToTopoDS_TranslatePolyLoopError Error)
{
Handle(TCollection_HAsciiString) mess;
switch(Error)
{
case StepToTopoDS_TranslatePolyLoopDone:
{
mess = new TCollection_HAsciiString("Translate PolyLoop Done");
break;
}
case StepToTopoDS_TranslatePolyLoopOther:
{
mess = new TCollection_HAsciiString("Translate PolyLoop Other");
break;
}
}
return mess;
}
Standard_CString StepToTopoDS::DecodeGeometricToolError(const StepToTopoDS_GeometricToolError Error)
{
Standard_CString mess="";
switch(Error)
{
case StepToTopoDS_GeometricToolDone:
{
mess = Standard_CString(" Geometric Tool is done");
break;
}
case StepToTopoDS_GeometricToolIsDegenerated:
{
mess = Standard_CString(" an Edge is degenerated");
break;
}
case StepToTopoDS_GeometricToolHasNoPCurve:
{
mess = Standard_CString(" SurfaceCurve does not contain a PCurve lying on the BasisSurface");
break;
}
case StepToTopoDS_GeometricToolWrong3dParameters:
{
mess = Standard_CString(" the update of 3D-Parameters failed");
break;
}
case StepToTopoDS_GeometricToolNoProjectiOnCurve:
{
mess = Standard_CString(" the projection of a VertexPoint on the curve3d failed");
break;
}
case StepToTopoDS_GeometricToolOther:
{
mess = Standard_CString(" GeometricTool failed");
break;
}
}
return mess;
}

View File

@@ -0,0 +1,107 @@
-- File: StepToTopoDS_Builder.cdl
-- Created: Fri Dec 16 14:49:51 1994
-- Author: Frederic MAUPAS
-- <fma@stylox>
---Copyright: Matra Datavision 1994
class Builder from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose:
--
uses
ManifoldSolidBrep from StepShape,
BrepWithVoids from StepShape,
FacetedBrep from StepShape,
FacetedBrepAndBrepWithVoids from StepShape,
ShellBasedSurfaceModel from StepShape,
EdgeBasedWireframeModel from StepShape,
FaceBasedSurfaceModel from StepShape,
GeometricSet from StepShape,
Shape from TopoDS,
BuilderError from StepToTopoDS,
TransientProcess from Transfer,
NMTool from StepToTopoDS
raises NotDone from StdFail
is
Create returns Builder from StepToTopoDS;
Create (S : ManifoldSolidBrep from StepShape;
TP : TransientProcess from Transfer )
returns Builder from StepToTopoDS;
Create (S : BrepWithVoids from StepShape;
TP : TransientProcess from Transfer )
returns Builder from StepToTopoDS;
Create ( S : FacetedBrep from StepShape;
TP : TransientProcess from Transfer )
returns Builder from StepToTopoDS;
Create (S : FacetedBrepAndBrepWithVoids from StepShape;
TP : TransientProcess from Transfer )
returns Builder from StepToTopoDS;
Create (S : ShellBasedSurfaceModel from StepShape;
TP : TransientProcess from Transfer;
NMTool : in out NMTool from StepToTopoDS )
returns Builder from StepToTopoDS;
Create ( S : GeometricSet from StepShape;
TP : TransientProcess from Transfer )
returns Builder from StepToTopoDS;
Init (me : in out;
S : ManifoldSolidBrep from StepShape;
TP : TransientProcess from Transfer );
Init (me : in out;
S : BrepWithVoids from StepShape;
TP : TransientProcess from Transfer );
Init (me : in out;
S : FacetedBrep from StepShape;
TP : TransientProcess from Transfer );
Init (me : in out;
S : FacetedBrepAndBrepWithVoids from StepShape;
TP : TransientProcess from Transfer );
Init (me : in out;
S : ShellBasedSurfaceModel from StepShape;
TP : TransientProcess from Transfer;
NMTool : in out NMTool from StepToTopoDS );
Init (me : in out;
S : EdgeBasedWireframeModel from StepShape;
TP : TransientProcess from Transfer );
Init (me : in out;
S : FaceBasedSurfaceModel from StepShape;
TP : TransientProcess from Transfer );
Init (me : in out;
S : GeometricSet from StepShape;
TP : TransientProcess from Transfer );
Value (me) returns Shape from TopoDS
raises NotDone
is static;
---C++: return const&
Error (me) returns BuilderError from StepToTopoDS
is static;
fields
myError : BuilderError from StepToTopoDS;
myResult : Shape from TopoDS;
end Builder;

View File

@@ -0,0 +1,835 @@
// File: StepToTopoDS_Builder.cxx
// Created: Tue Jan 3 11:26:22 1995
// Author: Frederic MAUPAS
// <fma@stylox>
//:i6 abv 17 Sep 98: ProSTEP TR9 r0601-ct.stp: to be able read GeometricSet
//gka 11.01.99 file PRO7755.stp #2018: work-around error in BRepLib_MakeFace
//:n4 abv 12.02.99: S4132: treatment of GEOMETRIC_SETs implemented
//:o7 abv 18.02.99: bm1_sy_fuel.stp #1427(items 1,2) protection against null entity
//abv,gka 05.04.99 S4136: parameter names changed; avoid extra call to FixSameParameter
#include <stdio.h>
#include <StepToTopoDS_Builder.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Interface_Static.hxx>
#include <TransferBRep.hxx>
#include <StepToTopoDS_Tool.hxx>
#include <StepToTopoDS_DataMapOfTRI.hxx>
#include <StepToTopoDS_TranslateShell.hxx>
#include <StepToTopoDS_TranslateCompositeCurve.hxx>
#include <StepToTopoDS_TranslateCurveBoundedSurface.hxx>
//#include <StepShape_VertexShell.hxx>
#include <StepShape_Shell.hxx>
#include <StepShape_OpenShell.hxx>
#include <StepShape_OrientedClosedShell.hxx> //:e0
#include <StepGeom_Surface.hxx>
#include <StepGeom_Curve.hxx>
#include <StepGeom_CartesianPoint.hxx>
#include <StepGeom_CompositeCurve.hxx>
#include <StepGeom_RectangularCompositeSurface.hxx>
#include <StepGeom_SurfacePatch.hxx>
#include <StepShape_GeometricSetSelect.hxx>
#include <StepToGeom_MakeCurve.hxx>
#include <StepToGeom_MakeCartesianPoint.hxx>
#include <StepToGeom_MakeSurface.hxx>
#include <Geom_Surface.hxx>
#include <Geom_BoundedSurface.hxx>
#include <Geom_Curve.hxx>
#include <Geom_CartesianPoint.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepLib.hxx>
#include <BRep_Builder.hxx>
#include <Precision.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Compound.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <StepShape_ConnectedEdgeSet.hxx>
#include <StepShape_EdgeBasedWireframeModel.hxx>
#include <StepShape_HArray1OfConnectedEdgeSet.hxx>
#include <StepToTopoDS_TranslateEdge.hxx>
#include <StepShape_HArray1OfEdge.hxx>
#include <TopoDS.hxx>
#include <StepShape_HArray1OfConnectedFaceSet.hxx>
#include <StepToTopoDS_TranslateFace.hxx>
#include <StepShape_HArray1OfFace.hxx>
#include <Message_ProgressSentry.hxx>
#include <Message_Messenger.hxx>
static void ResetPreci (const TopoDS_Shape& S, Standard_Real maxtol)
{
//:S4136
Standard_Integer modetol = Interface_Static::IVal("read.maxprecision.mode");
if (modetol) {
ShapeFix_ShapeTolerance STU;
STU.LimitTolerance (S,Precision::Confusion(),maxtol);
}
// Standard_Real ratio = Interface_Static::RVal("XSTEP.readprecision.ratio");
// if (ratio >= 1) {
// Standard_Real lastpre = Interface_Static::RVal("lastpreci");
// ShapeFix_ShapeTolerance STU;
// STU.LimitTolerance (S,lastpre/ratio,lastpre*ratio);
// }
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Empty constructor
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder()
{
done = Standard_False;
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor with a ManifoldSolidBrep
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_ManifoldSolidBrep)& aManifoldSolid,
const Handle(Transfer_TransientProcess)& TP)
{
Init(aManifoldSolid, TP);
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor woth a BrepWithVoids
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_BrepWithVoids)& aBRepWithVoids,
const Handle(Transfer_TransientProcess)& TP)
{
Init(aBRepWithVoids, TP);
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor with a FacetedBrep
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_FacetedBrep)& aFB,
const Handle(Transfer_TransientProcess)& TP)
{
Init(aFB, TP);
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor with a FacetedBrepAndBrepWithVoids
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_FacetedBrepAndBrepWithVoids)& aFBABWV,
const Handle(Transfer_TransientProcess)& TP)
{
Init(aFBABWV, TP);
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor with a ShellBasedSurfaceModel
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_ShellBasedSurfaceModel)& aSBSM,
const Handle(Transfer_TransientProcess)& TP,
StepToTopoDS_NMTool& NMTool)
{
Init(aSBSM, TP, NMTool);
}
// ============================================================================
// Method : Init
// Purpose : Init with a ManifoldSolidBrep
// ============================================================================
void StepToTopoDS_Builder::Init
(const Handle(StepShape_ManifoldSolidBrep)& aManifoldSolid,
const Handle(Transfer_TransientProcess)& TP)
{
Handle(Message_Messenger) sout = TP->Messenger();
// Initialisation of the Tool
StepToTopoDS_Tool myTool;
StepToTopoDS_DataMapOfTRI aMap;
myTool.Init(aMap, TP);
// Start Mapping
Handle(StepShape_ClosedShell) aCShell;
aCShell = aManifoldSolid->Outer();
StepToTopoDS_TranslateShell myTranShell;
myTranShell.SetPrecision(Precision());
myTranShell.SetMaxTol(MaxTol());
// Non-manifold topology is not referenced by ManifoldSolidBrep (ssv; 14.11.2010)
StepToTopoDS_NMTool dummyNMTool;
myTranShell.Init(aCShell, myTool, dummyNMTool);
if (myTranShell.IsDone()) {
TopoDS_Shape Sh = myTranShell.Value();
Sh.Closed(Standard_True);
//BRepLib::SameParameter(Sh);
TopoDS_Solid S;
BRep_Builder B;
B.MakeSolid(S);
B.Add(S,Sh);
myResult = S;
myError = StepToTopoDS_BuilderDone;
done = Standard_True;
// Get Statistics :
if ( TP->TraceLevel() > 2 )
{
sout << "Geometric Statitics : " << endl;
sout << " Surface Continuity : - C0 : " << myTool.C0Surf() << endl;
sout << " - C1 : " << myTool.C1Surf() << endl;
sout << " - C2 : " << myTool.C2Surf() << endl;
sout << " Curve Continuity : - C0 : " << myTool.C0Cur3() << endl;
sout << " - C1 : " << myTool.C1Cur3() << endl;
sout << " - C2 : " << myTool.C2Cur3() << endl;
sout << " PCurve Continuity : - C0 : " << myTool.C0Cur2() << endl;
sout << " - C1 : " << myTool.C1Cur2() << endl;
sout << " - C2 : " << myTool.C2Cur2() << endl;
}
//:S4136 ShapeFix::SameParameter (S,Standard_False);
ResetPreci (S, MaxTol());
}
else {
TP->AddWarning(aCShell," OuterShell from ManifoldSolidBrep not mapped to TopoDS");
myError = StepToTopoDS_BuilderOther;
done = Standard_False;
}
}
// ============================================================================
// Method : Init
// Purpose : Init with a BrepWithVoids
// ============================================================================
void StepToTopoDS_Builder::Init
(const Handle(StepShape_BrepWithVoids)& aBRepWithVoids,
const Handle(Transfer_TransientProcess)& TP)
{
Handle(Message_Messenger) sout = TP->Messenger();
// Initialisation of the Tool
StepToTopoDS_Tool myTool;
StepToTopoDS_DataMapOfTRI aMap;
myTool.Init(aMap, TP);
// Start Mapping
Standard_Integer Nb = aBRepWithVoids->NbVoids();
Handle(StepShape_ClosedShell) aCShell;
TopoDS_Solid S;
TopoDS_Shape Sh;
BRep_Builder B;
B.MakeSolid(S);
Message_ProgressSentry PS ( TP->GetProgress(), "Shell", 0, Nb+1, 1 );
StepToTopoDS_TranslateShell myTranShell;
myTranShell.SetPrecision(Precision());//gka
myTranShell.SetMaxTol(MaxTol());
// OuterBound
aCShell = aBRepWithVoids->Outer();
// Non-manifold topology is not referenced by BrepWithVoids (ssv; 14.11.2010)
StepToTopoDS_NMTool dummyNMTool;
myTranShell.Init(aCShell, myTool, dummyNMTool);
PS.Next();
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
Sh.Closed(Standard_True);
//BRepLib::SameParameter(Sh);
B.MakeSolid(S);
B.Add(S,Sh);
myResult = S;
myError = StepToTopoDS_BuilderDone;
done = Standard_True;
}
else {
TP->AddWarning(aCShell," OuterShell from BrepWithVoids not mapped to TopoDS");
myError = StepToTopoDS_BuilderOther;
done = Standard_False;
return;
}
// Voids
for (Standard_Integer i=1; i<=Nb && PS.More(); i++, PS.Next()) {
aCShell = aBRepWithVoids->VoidsValue(i);
myTranShell.Init(aCShell, myTool, dummyNMTool);
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
Sh.Closed(Standard_True);
//:e0 abv 25 Mar 98: void should be an OrientedShell
Handle(StepShape_OrientedClosedShell) aOCShell = aBRepWithVoids->VoidsValue(i);
if ( ! aOCShell.IsNull() && ! aOCShell->Orientation() ) Sh.Reverse();
//BRepLib::SameParameter(Sh);
B.Add(S,Sh);
}
else {
TP->AddWarning
(aCShell," A Void from BrepWithVoids not mapped to TopoDS");
}
}
myResult = S;
// Get Statistics :
if ( TP->TraceLevel() > 2 )
{
sout << "Geometric Statitics : " << endl;
sout << " Surface Continuity : - C0 : " << myTool.C0Surf() << endl;
sout << " - C1 : " << myTool.C1Surf() << endl;
sout << " - C2 : " << myTool.C2Surf() << endl;
sout << " Curve Continuity : - C0 : " << myTool.C0Cur3() << endl;
sout << " - C1 : " << myTool.C1Cur3() << endl;
sout << " - C2 : " << myTool.C2Cur3() << endl;
sout << " PCurve Continuity : - C0 : " << myTool.C0Cur2() << endl;
sout << " - C1 : " << myTool.C1Cur2() << endl;
sout << " - C2 : " << myTool.C2Cur2() << endl;
}
//:S4136 ShapeFix::SameParameter (S,Standard_False);
ResetPreci (S, MaxTol());
}
// ============================================================================
// Method : Init
// Purpose : Init with a FacetedBrep
// ============================================================================
void StepToTopoDS_Builder::Init(const Handle(StepShape_FacetedBrep)& aFB,
const Handle(Transfer_TransientProcess)& TP)
{
// Initialisation of the Tool
StepToTopoDS_Tool myTool;
StepToTopoDS_DataMapOfTRI aMap;
myTool.Init(aMap, TP);
// Start Mapping
Handle(StepShape_ClosedShell) aCShell;
aCShell = aFB->Outer();
TopoDS_Shape Sh;
StepToTopoDS_TranslateShell myTranShell;
myTranShell.SetPrecision(Precision()); //gka
myTranShell.SetMaxTol(MaxTol());
// Non-manifold topology is not referenced by FacetedBrep (ss; 14.11.2010)
StepToTopoDS_NMTool dummyNMTool;
myTranShell.Init(aCShell, myTool, dummyNMTool);
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
Sh.Closed(Standard_True);
//BRepLib::SameParameter(Sh);
myTool.ClearEdgeMap();
myTool.ClearVertexMap();
TopoDS_Solid S;
BRep_Builder B;
B.MakeSolid(S);
B.Add(S,Sh);
myResult = S;
myError = StepToTopoDS_BuilderDone;
done = Standard_True;
}
else {
TP->AddWarning
(aCShell," OuterShell from FacetedBrep not mapped to TopoDS");
myError = StepToTopoDS_BuilderOther;
done = Standard_True;
}
}
// ============================================================================
// Method : Init
// Purpose : Init with a FacetedBrepAndBrepWithVoids
// ============================================================================
void StepToTopoDS_Builder::Init
(const Handle(StepShape_FacetedBrepAndBrepWithVoids)& aFBABWV,
const Handle(Transfer_TransientProcess)& TP)
{
// Initialisation of the Tool
StepToTopoDS_Tool myTool;
StepToTopoDS_DataMapOfTRI aMap;
myTool.Init(aMap, TP);
// Start Mapping
Handle(StepShape_ClosedShell) aCShell;
aCShell = aFBABWV->Outer();
TopoDS_Shape Sh;
StepToTopoDS_TranslateShell myTranShell;
myTranShell.SetPrecision(Precision()); //gka
myTranShell.SetMaxTol(MaxTol());
// Non-manifold topology is not referenced by FacetedBrepAndBrepWithVoids (ss; 14.11.2010)
StepToTopoDS_NMTool dummyNMTool;
myTranShell.Init(aCShell, myTool, dummyNMTool);
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
Sh.Closed(Standard_True);
//BRepLib::SameParameter(Sh);
TopoDS_Solid S;
BRep_Builder B;
B.MakeSolid(S);
B.Add(S,Sh);
Standard_Integer Nb, i;
Nb = aFBABWV->NbVoids();
for ( i=1; i<=Nb; i++ ) {
aCShell = aFBABWV->VoidsValue(i);
myTranShell.Init(aCShell, myTool, dummyNMTool);
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
Sh.Closed(Standard_True);
//BRepLib::SameParameter(Sh);
B.Add(S,Sh);
}
else {
TP->AddWarning
(aCShell," A Void from FacetedBrepAndBrepWithVoids not mapped to TopoDS");
}
}
myResult = S;
myError = StepToTopoDS_BuilderDone;
done = Standard_True;
}
else {
TP->AddWarning
(aCShell," OuterShell from FacetedBrepAndBrepWithVoids not mapped to TopoDS");
done = Standard_False;
myError = StepToTopoDS_BuilderOther;
}
}
// ============================================================================
// Method : Init
// Purpose : Init with a ShellBasedSurfaceModel
// ============================================================================
void StepToTopoDS_Builder::Init
(const Handle(StepShape_ShellBasedSurfaceModel)& aSBSM,
const Handle(Transfer_TransientProcess)& TP,
StepToTopoDS_NMTool& NMTool)
{
Handle(Message_Messenger) sout = TP->Messenger();
// Initialisation of the Tool
StepToTopoDS_Tool myTool;
StepToTopoDS_DataMapOfTRI aMap;
myTool.Init(aMap, TP);
// Start Mapping
Standard_Integer Nb = aSBSM->NbSbsmBoundary();
StepShape_Shell aShell;
//Handle(StepShape_VertexShell) aVertexShell;
Handle(StepShape_OpenShell) aOpenShell;
Handle(StepShape_ClosedShell) aClosedShell;
TopoDS_Compound S;
//TopoDS_Shape Sh;
TopoDS_Shape Shl;
BRep_Builder B;
B.MakeCompound(S);
StepToTopoDS_TranslateShell myTranShell;
myTranShell.SetPrecision(Precision());
myTranShell.SetMaxTol(MaxTol());
Message_ProgressSentry PS ( TP->GetProgress(), "Shell", 0, Nb, 1 );
for (Standard_Integer i=1; i<=Nb && PS.More(); i++, PS.Next()) {
//for (Standard_Integer i=1; i<=Nb; i++) {
aShell = aSBSM->SbsmBoundaryValue(i);
//aVertexShell = aShell.VertexShell();
aOpenShell = aShell.OpenShell();
aClosedShell = aShell.ClosedShell();
//if (!aVertexShell.IsNull()) {
//TP->AddWarning
//(aVertexShell,
//" VertexShell from ShellBasedSurfaceModel not mapped to TopoDS");
//}
//else
if (!aOpenShell.IsNull()) {
myTranShell.Init(aOpenShell, myTool, NMTool);
if (myTranShell.IsDone()) {
//Sh = myTranShell.Value();
//Sh.Closed(Standard_False);
//BRepLib::SameParameter(Sh);
//B.Add(S,Sh);
Shl = TopoDS::Shell(myTranShell.Value());
Shl.Closed(Standard_False);
B.Add(S,Shl);
}
else {
TP->AddWarning
(aOpenShell," OpenShell from ShellBasedSurfaceModel not mapped to TopoDS");
}
}
else if (!aClosedShell.IsNull()) {
myTranShell.Init(aClosedShell, myTool, NMTool);
if (myTranShell.IsDone()) {
//Sh = myTranShell.Value();
//Sh.Closed(Standard_True);
//BRepLib::SameParameter(Sh);
//B.Add(S,Sh);
Shl = TopoDS::Shell(myTranShell.Value());
Shl.Closed(Standard_True);
B.Add(S,Shl);
}
else {
TP->AddWarning
(aClosedShell," ClosedShell from ShellBasedSurfaceModel not mapped to TopoDS");
}
}
}
if(Nb>1)
myResult = S;
else
myResult = Shl;
myError = StepToTopoDS_BuilderDone;
done = Standard_True;
// Get Statistics :
if ( TP->TraceLevel() > 2 )
{
sout << "Geometric Statitics : " << endl;
sout << " Surface Continuity : - C0 : " << myTool.C0Surf() << endl;
sout << " - C1 : " << myTool.C1Surf() << endl;
sout << " - C2 : " << myTool.C2Surf() << endl;
sout << " Curve Continuity : - C0 : " << myTool.C0Cur3() << endl;
sout << " - C1 : " << myTool.C1Cur3() << endl;
sout << " - C2 : " << myTool.C2Cur3() << endl;
sout << " PCurve Continuity : - C0 : " << myTool.C0Cur2() << endl;
sout << " - C1 : " << myTool.C1Cur2() << endl;
sout << " - C2 : " << myTool.C2Cur2() << endl;
}
//:S4136 ShapeFix::SameParameter (S,Standard_False);
ResetPreci (S, MaxTol());
ResetPreci (Shl, MaxTol()); //skl
}
// ============================================================================
// Method : Init
// Purpose : Init with a EdgeBasedWireframeModel
// ============================================================================
void StepToTopoDS_Builder::Init (const Handle(StepShape_EdgeBasedWireframeModel)& aEBWM,
const Handle(Transfer_TransientProcess)& TP)
{
myResult.Nullify();
Handle(StepShape_HArray1OfConnectedEdgeSet) boundary = aEBWM->EbwmBoundary();
if ( boundary.IsNull() || boundary->Length() <1 ) {
TP->AddWarning ( aEBWM, "List of boundaries is empty" );
return;
}
StepToTopoDS_Tool myTool;
StepToTopoDS_DataMapOfTRI aMap;
myTool.Init(aMap, TP);
StepToTopoDS_TranslateEdge myTranEdge;
myTranEdge.SetPrecision(Precision());
myTranEdge.SetMaxTol(MaxTol());
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound ( C );
StepToTopoDS_NMTool dummyNMTool;
for ( Standard_Integer i=1; i <= boundary->Length(); i++ ) {
Handle(StepShape_ConnectedEdgeSet) ces = boundary->Value(i);
if ( ces.IsNull() ) continue;
Handle(StepShape_HArray1OfEdge) edges = ces->CesEdges();
if ( edges.IsNull() || edges->Length() <1 ) {
TP->AddWarning ( ces, "No edges in connected_edge_set" );
continue;
}
TopoDS_Wire W;
for ( Standard_Integer j=1; j <= edges->Length(); j++ ) {
myTranEdge.Init (edges->Value(j), myTool, dummyNMTool);
if ( ! myTranEdge.IsDone() ) continue;
TopoDS_Edge E = TopoDS::Edge(myTranEdge.Value());
if (E.IsNull()) continue; // NULL, on saute
if ( W.IsNull() ) B.MakeWire ( W );
B.Add ( W, E );
}
if ( W.IsNull() ) continue;
B.Add ( C, W );
if ( myResult.IsNull() ) myResult = W;
else myResult = C;
}
myError = ( myResult.IsNull() ? StepToTopoDS_BuilderDone : StepToTopoDS_BuilderOther );
done = ! myResult.IsNull();
ResetPreci (myResult, MaxTol());
}
// ============================================================================
// Method : Init
// Purpose : Init with a FaceBasedSurfaceModel
// ============================================================================
void StepToTopoDS_Builder::Init (const Handle(StepShape_FaceBasedSurfaceModel)& aFBSM,
const Handle(Transfer_TransientProcess)& TP)
{
myResult.Nullify();
Handle(StepShape_HArray1OfConnectedFaceSet) boundary = aFBSM->FbsmFaces();
if ( boundary.IsNull() || boundary->Length() <1 ) {
TP->AddWarning ( aFBSM, "List of faces is empty" );
return;
}
StepToTopoDS_Tool myTool;
StepToTopoDS_DataMapOfTRI aMap;
myTool.Init(aMap, TP);
StepToTopoDS_TranslateFace myTranFace;
myTranFace.SetPrecision(Precision());
myTranFace.SetMaxTol(MaxTol());
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound ( C );
// Non-manifold topology is not mapped via FaceBasedSurfaceModel (ssv; 14.11.2010)
StepToTopoDS_NMTool dummyNMTool;
for ( Standard_Integer i=1; i <= boundary->Length(); i++ ) {
Handle(StepShape_ConnectedFaceSet) cfs = boundary->Value(i);
if ( cfs.IsNull() ) continue;
Handle(StepShape_HArray1OfFace) faces = cfs->CfsFaces();
if ( faces.IsNull() || faces->Length() <1 ) {
TP->AddWarning ( cfs, "No faces in connected_face_set" );
continue;
}
TopoDS_Shell S;
for ( Standard_Integer j=1; j <= faces->Length(); j++ ) {
Handle(StepShape_FaceSurface) fs = Handle(StepShape_FaceSurface)::DownCast ( faces->Value(j) );
myTranFace.Init(fs, myTool, dummyNMTool);
if ( ! myTranFace.IsDone() ) continue;
TopoDS_Face F = TopoDS::Face(myTranFace.Value());
if (F.IsNull()) continue; // NULL, on saute
if ( S.IsNull() ) B.MakeShell ( S );
B.Add ( S, F );
}
if ( S.IsNull() ) continue;
B.Add ( C, S );
if ( myResult.IsNull() ) myResult = S;
else myResult = C;
}
myError = ( myResult.IsNull() ? StepToTopoDS_BuilderDone : StepToTopoDS_BuilderOther );
done = ! myResult.IsNull();
ResetPreci (myResult, MaxTol());
}
// ***start DTH Apr/6
// ============================================================================
// Method : Init
// Purpose : Init with a GeometricCurveSet
// ============================================================================
//:i6 abv 17 Sep 98: ProSTEP TR9 r0601-ct.stp: to be able read GS: GeometricCurveSet -> GeometricSet
static TopoDS_Face TranslateBoundedSurf (const Handle(StepGeom_Surface) &surf)
{
TopoDS_Face res;
Handle(Geom_Surface) theSurf;
if (!StepToGeom_MakeSurface::Convert(surf,theSurf) || //:i6: protection
!theSurf->IsKind(STANDARD_TYPE(Geom_BoundedSurface))) return res;
//gka 11.01.99 file PRO7755.stp entity #2018 surface #1895: error BRepLib_MakeFace func IsDegenerated
BRepBuilderAPI_MakeFace myMkFace(theSurf);
return myMkFace.Face();
}
void StepToTopoDS_Builder::Init
(const Handle(StepShape_GeometricSet)& GCS,
const Handle(Transfer_TransientProcess)& TP)
{
// Initialisation of the Tool
// StepToTopoDS_Tool myTool;
// StepToTopoDS_DataMapOfTRI aMap;
// myTool.Init(aMap, TP);
// Start Mapping
TopoDS_Compound S;
BRep_Builder B;
B.MakeCompound(S);
TopoDS_Edge theEdge;
Standard_Integer i;
Standard_Real preci = Precision(); //gka
Standard_Real maxtol = MaxTol();
Standard_Integer nbElem = GCS->NbElements();
for (i = 1; i <= nbElem ; i++) {
StepShape_GeometricSetSelect aGSS = GCS->ElementsValue(i);
Handle(Standard_Transient) ent = aGSS.Value();
TopoDS_Shape res = TransferBRep::ShapeResult ( TP, ent );
if ( ! res.IsNull() ) { // already translated
B.Add ( S, res );
continue;
}
//:o7 abv 18 Feb 99: bm1_sy_fuel.stp #1427(1,2) protection against null entity
if ( ent.IsNull() ) {
char buff[100];
sprintf ( buff, "Entity %d is a Null entity", i );
TP->AddWarning (GCS,buff);
continue;
}
// try curve
else if ( ent->IsKind(STANDARD_TYPE(StepGeom_Curve)) ) {
Handle(StepGeom_Curve) aCrv = Handle(StepGeom_Curve)::DownCast ( ent );
// try composite_curve
Handle(StepGeom_CompositeCurve) CC = Handle(StepGeom_CompositeCurve)::DownCast(aCrv);
if ( ! CC.IsNull() ) {
StepToTopoDS_TranslateCompositeCurve TrCC;
TrCC.SetPrecision(preci);
TrCC.SetMaxTol(maxtol);
TrCC.Init( CC, TP );
if ( TrCC.IsDone() ) res = TrCC.Value();
}
else { // try other curves
Handle(Geom_Curve) aGeomCrv;
try {
OCC_CATCH_SIGNALS
StepToGeom_MakeCurve::Convert(aCrv,aGeomCrv);
}
catch(Standard_Failure) {
Handle(Message_Messenger) sout = TP->Messenger();
sout<<"StepToTopoDS, GeometricSet, elem "<<i<<" of "<<nbElem<<": exception ";
sout<<Standard_Failure::Caught()->GetMessageString() << endl;
}
if ( ! aGeomCrv.IsNull() ) {
BRepBuilderAPI_MakeEdge anEdge(aGeomCrv, aGeomCrv->FirstParameter(), aGeomCrv->LastParameter());
if ( anEdge.IsDone() ) res = anEdge.Edge();
}
}
}
// try point
else if ( ent->IsKind(STANDARD_TYPE(StepGeom_CartesianPoint)) ) {
Handle(StepGeom_CartesianPoint) aPnt = Handle(StepGeom_CartesianPoint)::DownCast ( ent );
Handle(Geom_CartesianPoint) thePnt;
if (StepToGeom_MakeCartesianPoint::Convert(aPnt,thePnt)) {
BRepBuilderAPI_MakeVertex myMkVtx(thePnt->Pnt());
if ( myMkVtx.IsDone() ) res = myMkVtx.Vertex();
}
}
// Element should finally be a Surface
else if ( ent->IsKind(STANDARD_TYPE(StepGeom_Surface)) ) {
Handle(StepGeom_Surface) aSurf =
Handle(StepGeom_Surface)::DownCast(ent);
// try curve_bounded_surf
if ( ent->IsKind(STANDARD_TYPE(StepGeom_CurveBoundedSurface)) ) {
Handle(StepGeom_CurveBoundedSurface) CBS =
Handle(StepGeom_CurveBoundedSurface)::DownCast(aSurf);
StepToTopoDS_TranslateCurveBoundedSurface TrCBS;
TrCBS.SetPrecision(preci);
TrCBS.SetMaxTol(maxtol);
TrCBS.Init( CBS, TP );
if ( TrCBS.IsDone() ) res = TrCBS.Value();
}
// try RectangularCompositeSurface
else if ( ent->IsKind(STANDARD_TYPE(StepGeom_RectangularCompositeSurface)) ) {
Handle(StepGeom_RectangularCompositeSurface) RCS =
Handle(StepGeom_RectangularCompositeSurface)::DownCast(aSurf);
Standard_Integer nbi = RCS->NbSegmentsI();
Standard_Integer nbj = RCS->NbSegmentsJ();
TopoDS_Compound C;
B.MakeCompound ( C );
for ( Standard_Integer ii=1; ii <= nbi; ii++ )
for ( Standard_Integer j=1; j <= nbj; j++ ) {
Handle(StepGeom_SurfacePatch) patch = RCS->SegmentsValue ( ii, j );
TopoDS_Face f = TranslateBoundedSurf ( patch->ParentSurface() );
if ( ! f.IsNull() ) B.Add ( C, f );
}
res = C;
}
// try other surfs
else res = TranslateBoundedSurf ( aSurf );
}
else TP->AddWarning (ent," Entity is not a Curve, Point or Surface");
if ( ! res.IsNull() ) {
B.Add(S, res);
TransferBRep::SetShapeResult ( TP, ent, res );
}
else TP->AddWarning (ent," Entity not mapped to TopoDS");
}
myResult = S;
myError = StepToTopoDS_BuilderDone;
done = Standard_True;
}
// ***end DTH Apr/6
// ============================================================================
// Method : Value
// Purpose : Returns the result of the mapping
// ============================================================================
const TopoDS_Shape& StepToTopoDS_Builder::Value() const
{
StdFail_NotDone_Raise_if(!done,"");
return myResult;
}
// ============================================================================
// Method : Error
// Purpose : Returns the Builder Error code
// ============================================================================
StepToTopoDS_BuilderError StepToTopoDS_Builder::Error() const
{
return myError;
}

View File

@@ -0,0 +1,21 @@
-- File: StepToTopoDS_CartesianPointHasher.cdl
-- Created: Mon Aug 30 12:14:19 1993
-- Author: Martine LANGLOIS
-- <mla@nonox>
---Copyright: Matra Datavision 1993
class CartesianPointHasher from StepToTopoDS
uses
CartesianPoint from StepGeom
is
HashCode(myclass; K : CartesianPoint from StepGeom; Upper : Integer)
returns Integer;
---Purpose: Returns a HasCode value for the CartesianPoint
IsEqual(myclass; K1, K2 : CartesianPoint from StepGeom) returns Boolean;
---Purpose: Returns True when the two CartesianPoint are the same
end CartesianPointHasher;

View File

@@ -0,0 +1,31 @@
// File: StepToTopoDS_CartesianPointHasher.cxx
// Created: Mon Aug 30 12:26:11 1993
// Author: Martine LANGLOIS
// <mla@nonox>
#include <StepToTopoDS_CartesianPointHasher.ixx>
#include <StepGeom_CartesianPoint.hxx>
//=======================================================================
//function : HashCode
//purpose :
//=======================================================================
Standard_Integer StepToTopoDS_CartesianPointHasher::HashCode
(const Handle(StepGeom_CartesianPoint)& K, const Standard_Integer Upper)
{
return ::HashCode(K,Upper);
}
//=======================================================================
//function : IsEqual
//purpose :
//=======================================================================
Standard_Boolean StepToTopoDS_CartesianPointHasher::IsEqual
(const Handle(StepGeom_CartesianPoint)& K1,
const Handle(StepGeom_CartesianPoint)& K2)
{
return (K1 == K2);
}

View File

@@ -0,0 +1,61 @@
-- File: StepToTopoDS_GeometricTool.cdl
-- Created: Thu Jan 5 15:56:59 1995
-- Author: Frederic MAUPAS
-- <fma@stylox>
---Copyright: Matra Datavision 1995
class GeometricTool from StepToTopoDS
---Purpose: This class contains some algorithmic services
-- specific to the mapping STEP to CAS.CADE
uses
Tool from StepToTopoDS,
SurfaceCurve from StepGeom,
Surface from StepGeom,
Pcurve from StepGeom,
EdgeLoop from StepShape,
Edge from StepShape,
Curve from Geom2d,
Line from Geom2d,
Curve from Geom,
Surface from Geom,
Pnt2d from gp,
Pnt from gp,
Face from TopoDS,
Wire from TopoDS,
Edge from TopoDS,
Vertex from TopoDS
is
PCurve(myclass;
SC : SurfaceCurve from StepGeom;
S : Surface from StepGeom;
PC : out Pcurve from StepGeom;
last : Integer = 0)
returns Integer;
IsSeamCurve(myclass;
SC : SurfaceCurve from StepGeom;
S : Surface from StepGeom;
E : Edge from StepShape;
EL : EdgeLoop from StepShape)
returns Boolean;
IsLikeSeam(myclass;
SC : SurfaceCurve from StepGeom;
S : Surface from StepGeom;
E : Edge from StepShape;
EL : EdgeLoop from StepShape)
returns Boolean;
UpdateParam3d(myclass; C : Curve from Geom;
w1, w2 : in out Real from Standard;
preci : Real)
returns Boolean;
end GeometricTool from StepToTopoDS;

View File

@@ -0,0 +1,350 @@
// File: StepToTopoDS_GeometricTool.cxx
// Created: Fri Jan 6 11:34:51 1995
// Author: Frederic MAUPAS
// <fma@stylox>
//pdn 11.01.99 #144 bm1_pe_t4 protection of exceptions in draw
// abv 13.04.99 S4136: eliminate BRepAPI::Precision()
#include <StepToTopoDS_GeometricTool.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <StepToTopoDS.hxx>
//#include <StepToTopoDS_ExtPCOnS.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <StepGeom_PcurveOrSurface.hxx>
#include <StepGeom_Pcurve.hxx>
#include <StepGeom_Line.hxx>
#include <StepGeom_CartesianPoint.hxx>
#include <StepGeom_Vector.hxx>
#include <StepGeom_Direction.hxx>
#include <StepGeom_SeamCurve.hxx>
#include <StepRepr_DefinitionalRepresentation.hxx>
#include <StepShape_OrientedEdge.hxx>
//#include <BRepAPI.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <gp_Vec2d.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <GeomAbs_Shape.hxx>
#include <GeomAbs_CurveType.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <Geom2dAPI_InterCurveCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom_BoundedCurve.hxx>
#include <Geom_Line.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_BSplineCurve.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <Precision.hxx>
#include <Transfer_TransientProcess.hxx>
// ----------------------------------------------------------------------------
// Method : HasPCurve
// Purpose : returns true if the surface curve has at least one pcurve lying
//on the surface
// ----------------------------------------------------------------------------
Standard_Integer StepToTopoDS_GeometricTool::PCurve
(const Handle(StepGeom_SurfaceCurve)& SurfCurve,
const Handle(StepGeom_Surface)& BasisSurf,
Handle(StepGeom_Pcurve)& thePCurve, const Standard_Integer last)
{
Standard_Integer NbAssGeom = SurfCurve->NbAssociatedGeometry();
thePCurve.Nullify();
for (Standard_Integer i= last+1; i<=NbAssGeom; i++) {
thePCurve = SurfCurve->AssociatedGeometryValue(i).Pcurve();
if (!thePCurve.IsNull()) {
if (thePCurve->BasisSurface() == BasisSurf) return i;
}
}
thePCurve.Nullify();
return 0;
}
// ----------------------------------------------------------------------------
// Method : IsSeamCurve
// Purpose : Two edges of the same wire references the same oriented edge
// Then the surface_curve is a seam curve
// ----------------------------------------------------------------------------
Standard_Boolean StepToTopoDS_GeometricTool::IsSeamCurve
(const Handle(StepGeom_SurfaceCurve)& SurfCurve,
const Handle(StepGeom_Surface)& Surf,
const Handle(StepShape_Edge)& StepEdge,
const Handle(StepShape_EdgeLoop)& EdgeLoop)
{
if (!Handle(StepGeom_SeamCurve)::DownCast(SurfCurve).IsNull())
return Standard_True;
if (SurfCurve->NbAssociatedGeometry() != 2) return Standard_False;
Handle(StepGeom_Pcurve) StepPCurve1 =
SurfCurve->AssociatedGeometryValue(1).Pcurve();
Handle(StepGeom_Pcurve) StepPCurve2 =
SurfCurve->AssociatedGeometryValue(2).Pcurve();
// Do the two pcurves lye on the same surface ?
if ((!StepPCurve1.IsNull() && !StepPCurve2.IsNull()) &&
(StepPCurve1->BasisSurface() == Surf) &&
(StepPCurve2->BasisSurface()== Surf)) {
Standard_Integer NbEdge = EdgeLoop->NbEdgeList();
Standard_Integer nbOE = 0;
Handle(StepShape_OrientedEdge) OrEdge;
for (Standard_Integer i = 1; i <= NbEdge; i ++ ) {
OrEdge = EdgeLoop->EdgeListValue(i);
if (StepEdge == OrEdge->EdgeElement()) nbOE ++;
}
// two oriented edges of the same wire share the same edge
if (nbOE == 2) return Standard_True;
}
return Standard_False;
}
// ----------------------------------------------------------------------------
// Method : IsLikeSeam
// Purpose : The two pcurves lies on the same surface but on different wires.
// This is typical situation in CATIA BRep : a cylinder is coded
// with two faces on the same 'Closed' BSplineSurf, which in the
// range of gp_Resolution is not identified as closed
// ----------------------------------------------------------------------------
Standard_Boolean StepToTopoDS_GeometricTool::IsLikeSeam
(const Handle(StepGeom_SurfaceCurve)& SurfCurve,
const Handle(StepGeom_Surface)& Surf,
const Handle(StepShape_Edge)& StepEdge,
const Handle(StepShape_EdgeLoop)& EdgeLoop)
{
if (SurfCurve->NbAssociatedGeometry() != 2) return Standard_False;
Handle(StepGeom_Pcurve) StepPCurve1 =
SurfCurve->AssociatedGeometryValue(1).Pcurve();
Handle(StepGeom_Pcurve) StepPCurve2 =
SurfCurve->AssociatedGeometryValue(2).Pcurve();
// Do the two pcurves lye on the same surface ?
if ((!StepPCurve1.IsNull() && !StepPCurve2.IsNull()) &&
(StepPCurve1->BasisSurface() == Surf) &&
(StepPCurve2->BasisSurface() == Surf)) {
Standard_Integer NbEdge = EdgeLoop->NbEdgeList();
Standard_Integer nbOE = 0;
Handle(StepShape_OrientedEdge) OrEdge;
for (Standard_Integer i = 1; i <= NbEdge; i ++ ) {
OrEdge = EdgeLoop->EdgeListValue(i);
if (StepEdge == OrEdge->EdgeElement()) nbOE ++;
}
// the two oriented edges are not in the same wire
if (nbOE == 1) {
// check is the two pcurve are not indentical ?
Handle(StepGeom_Line) line1 = Handle(StepGeom_Line)::DownCast
(StepPCurve1->ReferenceToCurve()->ItemsValue(1));
Handle(StepGeom_Line) line2 = Handle(StepGeom_Line)::DownCast
(StepPCurve2->ReferenceToCurve()->ItemsValue(1));
if (!line1.IsNull() && !line2.IsNull()) {
// Same Origin in X OR Y && Same Vector ??
// WITHIN A given tolerance !!!
Standard_Real DeltaX = Abs(line1->Pnt()->CoordinatesValue(1) -
line2->Pnt()->CoordinatesValue(1));
Standard_Real DeltaY = Abs(line1->Pnt()->CoordinatesValue(2) -
line2->Pnt()->CoordinatesValue(2));
Standard_Real DeltaDirX =
Abs(line1->Dir()->Orientation()->DirectionRatiosValue(1) -
line2->Dir()->Orientation()->DirectionRatiosValue(1));
Standard_Real DeltaDirY =
Abs(line1->Dir()->Orientation()->DirectionRatiosValue(2) -
line2->Dir()->Orientation()->DirectionRatiosValue(2));
Standard_Real preci2d = Precision::PConfusion(); //:S4136: Parametric(BRepAPI::Precision(),10);
if ((DeltaX < preci2d) || (DeltaY < preci2d))
return ((DeltaDirX < preci2d) && (DeltaDirY < preci2d));
else return Standard_False;
// Warning : la manipulation de tolerances dans ce contexte est un
// peu trop dangeureux.
// il serait preferable de plus de ne pas restreindre au
// cas de deux lignes.
// un mode plus convenable de detection serait de se servir
// des isos (ou bords naturels) de la surface de base
// et de detecter que les deux courbes se trouvent sur le
// bord de fermeture.
// il faut toutefois prevoir le cas ou les deux courbes
// sont confondues (ex : CATIA, "couture" de separation
// en deux faces d un support periodique.
// Ce travail reste evidement A FAIRE !!! ...
}
else return Standard_False;
}
return Standard_False;
}
return Standard_False;
}
// ----------------------------------------------------------------------------
// Method : UpdateParam3d
// Purpose : According to the type of curve update parameter (w1>w2)
// This situation occurs when an edge crosses the parametric origin.
// ----------------------------------------------------------------------------
Standard_Boolean StepToTopoDS_GeometricTool::UpdateParam3d
(const Handle(Geom_Curve)& theCurve, Standard_Real& w1, Standard_Real& w2,
const Standard_Real preci)
{
// w1 et/ou w2 peuvent etre en dehors des bornes naturelles de la courbe.
// On donnera alors la valeur en bout a w1 et/ou w2
Standard_Real cf = theCurve->FirstParameter();
Standard_Real cl = theCurve->LastParameter();
// Standard_Real preci = BRepAPI::Precision();
if (theCurve->IsKind(STANDARD_TYPE(Geom_BoundedCurve)) && !theCurve->IsClosed()) {
if (w1 < cf) {
#ifdef DEBUG
cout << "Update Edge First Parameter to Curve First Parameter" << endl;
#endif
w1 = cf;
}
else if (w1 > cl) {
#ifdef DEBUG
cout << "Update Edge First Parameter to Curve Last Parameter" << endl;
#endif
w1 = cl;
}
if (w2 < cf) {
#ifdef DEBUG
cout << "Update Edge Last Parameter to Curve First Parameter" << endl;
#endif
w2 = cf;
}
else if (w2 > cl) {
#ifdef DEBUG
cout << "Update Edge Last Parameter to Curve Last Parameter" << endl;
#endif
w2 = cl;
}
}
if (w1 < w2) return Standard_True;
if (theCurve->IsPeriodic())
ElCLib::AdjustPeriodic(cf,cl,Precision::PConfusion(),w1,w2); //:a7 abv 11 Feb 98: preci -> PConfusion()
else if (theCurve->IsClosed()) {
// l'un des points projecte se trouve sur l'origine du parametrage
// de la courbe 3D. L algo a donne cl +- preci au lieu de cf ou vice-versa
// DANGER precision 3d applique a une espace 1d
// w2 = cf au lieu de w2 = cl
if (Abs(w2 - cf) < Precision::PConfusion() /*preci*/) w2 = cl ;
// w1 = cl au lieu de w1 = cf
else if (Abs(w1 - cl) < Precision::PConfusion() /*preci*/) w1 = cf;
// on se trouve dans un cas ou l origine est traversee
// illegal sur une courbe fermee non periodique
// on inverse quand meme les parametres !!!!!!
else {
//:S4136 abv 20 Apr 99: r0701_ug.stp #6230: add check in 3d
if ( theCurve->Value(w1).Distance(theCurve->Value(cf)) < preci ) w1 = cf;
if ( theCurve->Value(w2).Distance(theCurve->Value(cl)) < preci ) w2 = cl;
if ( w1 > w2 ) {
#ifdef DEBUG
cout << "Warning : parameter range of edge crossing non periodic curve origin" << endl;
#endif
Standard_Real tmp = w1;
w1 = w2;
w2 = tmp;
}
}
}
// The curve is closed within the 3D tolerance
else if (theCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
Handle(Geom_BSplineCurve) aBSpline =
Handle(Geom_BSplineCurve)::DownCast(theCurve);
if (aBSpline->StartPoint().Distance(aBSpline->EndPoint()) <= preci ) {
//:S4136 <= BRepAPI::Precision()) {
// l'un des points projecte se trouve sur l'origine du parametrage
// de la courbe 3D. L algo a donne cl +- preci au lieu de cf ou vice-versa
// DANGER precision 3d applique a une espace 1d
// w2 = cf au lieu de w2 = cl
if (Abs(w2 - cf) < Precision::PConfusion() /*preci*/) w2 = cl ;
// w1 = cl au lieu de w1 = cf
else if (Abs(w1 - cl) < Precision::PConfusion() /*preci*/) w1 = cf;
// on se trouve dans un cas ou l origine est traversee
// illegal sur une courbe fermee non periodique
// on inverse quand meme les parametres !!!!!!
else {
#ifdef DEBUG
cout << "Warning : parameter range of edge crossing non periodic curve origin" << endl;
#endif
Standard_Real tmp = w1;
w1 = w2;
w2 = tmp;
}
}
//abv 15.03.00 #72 bm1_pe_t4 protection of exceptions in draw
else if ( w1 > w2 ) {
#ifdef DEBUG
cout << "Warning: parameter range is bad; curve reversed" << endl;
#endif
w1 = theCurve->ReversedParameter ( w1 );
w2 = theCurve->ReversedParameter ( w2 );
theCurve->Reverse();
}
//:j9 abv 11 Dec 98: PRO7747 #4875, after :j8: else
if (w1 == w2) { //gka 10.07.1998 file PRO7656 entity 33334
w1 = cf; w2 = cl;
return Standard_False;
}
}
else {
#ifdef DEBUG
cout << "UpdateParam3d Failed" << endl;
cout << " - Curve Type : " << theCurve->DynamicType() << endl;
cout << " - Param 1 : " << w1 << endl;
cout << " - Param 2 : " << w2 << endl;
#endif
//abv 15.03.00 #72 bm1_pe_t4 protection of exceptions in draw
if ( w1 > w2 ) {
#ifdef DEBUG
cout << "Warning: parameter range is bad; curve reversed" << endl;
#endif
w1 = theCurve->ReversedParameter ( w1 );
w2 = theCurve->ReversedParameter ( w2 );
theCurve->Reverse();
}
//pdn 11.01.99 #144 bm1_pe_t4 protection of exceptions in draw
if (w1 == w2) {
w1 -= Precision::PConfusion();
w2 += Precision::PConfusion();
}
return Standard_False;
}
return Standard_True;
}

View File

@@ -0,0 +1,59 @@
-- File: StepToTopoDS_MakeTransformed.cdl
-- Created: Mon Apr 28 14:13:07 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class MakeTransformed from StepToTopoDS inherits Root
---Purpose : Produces instances by Transformation of a basic item
uses Trsf from gp, Shape from TopoDS,
TransientProcess from Transfer,
Axis2Placement3d from StepGeom,
CartesianTransformationOperator3d from StepGeom,
MappedItem from StepRepr
is
Create returns MakeTransformed;
Compute (me : in out; Origin, Target : Axis2Placement3d from StepGeom)
returns Boolean;
---Purpose : Computes a transformation to pass from an Origin placement to
-- a Target placement. Returns True when done
-- If not done, the transformation will by Identity
Compute (me : in out; Operator : CartesianTransformationOperator3d from StepGeom) returns Boolean;
---Purpose : Computes a transformation defined by an operator 3D
Transformation (me) returns Trsf from gp;
---Purpose : Returns the computed transformation (Identity if not yet or
-- if failed)
---C++ : return const &
Transform (me; shape : in out Shape from TopoDS) returns Boolean;
---Purpose : Applies the computed transformation to a shape
-- Returns False if the transformation is Identity
TranslateMappedItem (me : in out; mapit : MappedItem from StepRepr;
TP : mutable TransientProcess from Transfer)
returns Shape;
---Purpose : Translates a MappedItem. More precisely
-- A MappedItem has a MappingSource and a MappingTarget
-- MappingSource has a MappedRepresentation and a MappingOrigin
-- MappedRepresentation is the basic item to be instanced
-- MappingOrigin is the starting placement
-- MappingTarget is the final placement
--
-- Hence, the transformation from MappingOrigin and MappingTarget
-- is computed, the MappedRepr. is converted to a Shape, then
-- transformed as an instance of this Shape
fields
theTrsf : Trsf from gp;
end MakeTransformed;

View File

@@ -0,0 +1,115 @@
//:n7 abv 16.02.99: treatment of CARTESIAN_TRSF_OP_3D placed to StepGeom_MkTransformed3d
// sln 23.10.2001. CTS23496: Verifying on error creation of directions is added (StepToTopoDS_MakeTransformed::Compute(...) function)
#include <StepToTopoDS_MakeTransformed.ixx>
#include <Transfer_Binder.hxx>
#include <TransferBRep_ShapeBinder.hxx>
#include <StepToGeom_MakeAxis2Placement.hxx>
#include <Geom_Axis2Placement.hxx>
#include <gp_Ax3.hxx>
#include <gp_TrsfForm.hxx>
#include <TopLoc_Location.hxx>
#include <StepRepr_RepresentationMap.hxx>
#include <StepRepr_Representation.hxx>
// + pour CartesianOperator3d
#include <Geom_CartesianPoint.hxx>
#include <Geom_Direction.hxx>
#include <StepGeom_CartesianPoint.hxx>
#include <StepGeom_Direction.hxx>
#include <StepToGeom_MakeCartesianPoint.hxx>
#include <StepToGeom_MakeDirection.hxx>
#include <StepToGeom_MakeTransformation3d.hxx>
StepToTopoDS_MakeTransformed::StepToTopoDS_MakeTransformed ()
{
}
Standard_Boolean StepToTopoDS_MakeTransformed::Compute
(const Handle(StepGeom_Axis2Placement3d)& Origin,
const Handle(StepGeom_Axis2Placement3d)& Target)
{
theTrsf = gp_Trsf(); // reinit
if (Origin.IsNull() || Target.IsNull()) return Standard_False;
// sln 23.10.2001 : If the directions have not been created do nothing.
Handle(Geom_Axis2Placement) theOrig;
if (!StepToGeom_MakeAxis2Placement::Convert(Origin,theOrig))
return Standard_False;
Handle(Geom_Axis2Placement) theTarg;
if (!StepToGeom_MakeAxis2Placement::Convert(Target,theTarg))
return Standard_False;
const gp_Ax3 ax3Orig(theOrig->Ax2());
const gp_Ax3 ax3Targ(theTarg->Ax2());
// ne pas se tromper de sens !
theTrsf.SetTransformation(ax3Targ, ax3Orig);
return Standard_True;
}
Standard_Boolean StepToTopoDS_MakeTransformed::Compute
(const Handle(StepGeom_CartesianTransformationOperator3d)& Operator)
{
return StepToGeom_MakeTransformation3d::Convert(Operator,theTrsf);
}
const gp_Trsf& StepToTopoDS_MakeTransformed::Transformation () const
{
return theTrsf;
}
Standard_Boolean StepToTopoDS_MakeTransformed::Transform
(TopoDS_Shape& shape) const
{
if (theTrsf.Form() == gp_Identity) return Standard_False;
TopLoc_Location theLoc(theTrsf);
shape.Move (theLoc);
// shape.Location(theLoc);
return Standard_True;
}
TopoDS_Shape StepToTopoDS_MakeTransformed::TranslateMappedItem
(const Handle(StepRepr_MappedItem)& mapit,
const Handle(Transfer_TransientProcess)& TP)
{
TopoDS_Shape theResult;
// Positionnement : 2 formules
// 1/ Ax2 dans Source et comme Target : passage de Source a Target
// 2/ CartesianOperator3d comme Target : on applique
Handle(StepGeom_Axis2Placement3d) Origin =
Handle(StepGeom_Axis2Placement3d)::DownCast(mapit->MappingSource()
->MappingOrigin());
Handle(StepGeom_Axis2Placement3d) Target =
Handle(StepGeom_Axis2Placement3d)::DownCast(mapit->MappingTarget());
Handle(StepGeom_CartesianTransformationOperator3d) CartOp =
Handle(StepGeom_CartesianTransformationOperator3d)::DownCast(mapit->MappingTarget());
// Handle(StepRepr_ItemDefinedTransformation) ItemDef =
// Handle(StepRepr_ItemDefinedTransformation)::DownCast(mapit->MappingTarget());
Standard_Boolean ok = Standard_False;
if (!Origin.IsNull() && !Target.IsNull()) ok = Compute (Origin,Target);
else if (!CartOp.IsNull()) ok = Compute (CartOp);
if (!ok) TP->AddWarning (mapit,"Mapped Item, case not recognized, location ignored");
// La Shape, et la mise en position
Handle(StepRepr_Representation) maprep = mapit->MappingSource()->MappedRepresentation();
Handle(Transfer_Binder) binder = TP->Find(maprep);
if (binder.IsNull()) binder = TP->Transferring(maprep);
Handle(TransferBRep_ShapeBinder) shbinder =
Handle(TransferBRep_ShapeBinder)::DownCast(binder);
if (shbinder.IsNull()) TP->AddWarning(mapit,"No Shape Produced");
else {
theResult = shbinder->Result();
Transform (theResult);
}
return theResult;
}

View File

@@ -0,0 +1,105 @@
-- File: StepToTopoDS_NMTool.cdl
-- Created: Mon Nov 15 10:00:00 2010
-- Author: Sergey SLYADNEV
-- <sergey.slyadnev@opencascade.com>
class NMTool from StepToTopoDS
---Purpose: Provides data to process non-manifold topology when
-- reading from STEP.
uses
DataMapOfRI from StepToTopoDS,
DataMapOfRINames from StepToTopoDS,
RepresentationItem from StepRepr,
Shape from TopoDS,
AsciiString from TCollection,
ListOfShape from TopTools
is
Create returns NMTool from StepToTopoDS;
Create(MapOfRI : DataMapOfRI from StepToTopoDS;
MapOfRINames : DataMapOfRINames from StepToTopoDS)
returns NMTool from StepToTopoDS;
Init(me : in out;
MapOfRI : DataMapOfRI from StepToTopoDS;
MapOfRINames : DataMapOfRINames from StepToTopoDS);
SetActive(me : in out;
isActive : Boolean);
IsActive(me : in out)
returns Boolean;
CleanUp(me: in out);
IsBound(me : in out;
RI : RepresentationItem from StepRepr)
returns Boolean from Standard;
IsBound(me : in out;
RIName : AsciiString from TCollection)
returns Boolean from Standard;
Bind(me : in out;
RI : RepresentationItem from StepRepr;
S : Shape from TopoDS);
Bind(me : in out;
RIName : AsciiString from TCollection;
S : Shape from TopoDS);
Find(me : in out;
RI : RepresentationItem from StepRepr)
returns Shape from TopoDS;
---C++: return const &
Find(me : in out;
RIName : AsciiString from TCollection)
returns Shape from TopoDS;
---C++: return const &
RegisterNMEdge(me : in out;
Edge : Shape from TopoDS);
IsSuspectedAsClosing(me : in out;
BaseShell : Shape from TopoDS;
SuspectedShell : Shape from TopoDS)
returns Boolean;
IsPureNMShell(me : in out;
Shell : Shape from TopoDS)
returns Boolean;
SetIDEASCase(me : in out;
IDEASCase : Boolean);
IsIDEASCase(me : in out)
returns Boolean;
isEdgeRegisteredAsNM(me : in out;
Edge : Shape from TopoDS)
returns Boolean
is private;
isAdjacentShell(me : in out;
ShellA : Shape from TopoDS;
ShellB : Shape from TopoDS)
returns Boolean
is private;
fields
myRIMap : DataMapOfRI from StepToTopoDS;
myRINamesMap : DataMapOfRINames from StepToTopoDS;
myNMEdges : ListOfShape from TopTools;
myIDEASCase : Boolean;
myActiveFlag : Boolean;
end NMTool;

View File

@@ -0,0 +1,226 @@
// File: StepToTopoDS_NMTool.cxx
// Created: Mon Nov 15 11:00:00 2010
// Author: Sergey SLYADNEV
// <sergey.slyadnev@opencascade.com>
#include <StepToTopoDS_NMTool.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Shape.hxx>
// ============================================================================
// Method : StepToTopoDS_NMTool
// Purpose : Default constructor
// ============================================================================
StepToTopoDS_NMTool::StepToTopoDS_NMTool() {
myIDEASCase = Standard_False;
myActiveFlag = Standard_False;
}
// ============================================================================
// Method : StepToTopoDS_NMTool
// Purpose : Constructor with a Map for Representation Items and their names
// ============================================================================
StepToTopoDS_NMTool::StepToTopoDS_NMTool(const StepToTopoDS_DataMapOfRI& MapOfRI,
const StepToTopoDS_DataMapOfRINames& MapOfRINames) {
myIDEASCase = Standard_False;
myActiveFlag = Standard_False;
Init(MapOfRI, MapOfRINames);
}
// ============================================================================
// Method : Init
// Purpose : Initializes internal maps of the tool with the passed ones
// ============================================================================
void StepToTopoDS_NMTool::Init(const StepToTopoDS_DataMapOfRI& MapOfRI,
const StepToTopoDS_DataMapOfRINames& MapOfRINames) {
myRIMap = MapOfRI;
myRINamesMap = MapOfRINames;
}
// ============================================================================
// Method : SetActive
// Purpose : Turns the tool ON/OFF (OFF by default)
// ============================================================================
void StepToTopoDS_NMTool::SetActive(const Standard_Boolean isActive) {
myActiveFlag = isActive;
}
// ============================================================================
// Method : IsActive
// Purpose : TRUE if active, FALSE - otherwise
// ============================================================================
Standard_Boolean StepToTopoDS_NMTool::IsActive() {
return myActiveFlag;
}
// ============================================================================
// Method : CleanUp
// Purpose : Clears all internal containers
// ============================================================================
void StepToTopoDS_NMTool::CleanUp() {
myRIMap.Clear();
myRINamesMap.Clear();
}
// ============================================================================
// Method : IsBound
// Purpose : Indicates weither a RI is bound or not in the Map
// ============================================================================
Standard_Boolean StepToTopoDS_NMTool::IsBound(const Handle(StepRepr_RepresentationItem)& RI) {
return myRIMap.IsBound(RI);
}
// ============================================================================
// Method : IsBound
// Purpose : Indicates weither a RI is bound or not in the Map by name
// ============================================================================
Standard_Boolean StepToTopoDS_NMTool::IsBound(const TCollection_AsciiString& RIName) {
return myRINamesMap.IsBound(RIName);
}
// ============================================================================
// Method : Bind
// Purpose : Binds a RI with a Shape in the Map
// ============================================================================
void StepToTopoDS_NMTool::Bind(const Handle(StepRepr_RepresentationItem)& RI, const TopoDS_Shape& S) {
myRIMap.Bind(RI, S);
}
// ============================================================================
// Method : Bind
// Purpose : Binds a RI's name with a Shape in the Map
// ============================================================================
void StepToTopoDS_NMTool::Bind(const TCollection_AsciiString& RIName, const TopoDS_Shape& S) {
myRINamesMap.Bind(RIName, S);
}
// ============================================================================
// Method : Find
// Purpose : Returns the Shape corresponding to the bounded RI
// ============================================================================
const TopoDS_Shape& StepToTopoDS_NMTool::Find(const Handle(StepRepr_RepresentationItem)& RI) {
return myRIMap.Find(RI);
}
// ============================================================================
// Method : Find
// Purpose : Returns the Shape corresponding to the bounded RI's name
// ============================================================================
const TopoDS_Shape& StepToTopoDS_NMTool::Find(const TCollection_AsciiString& RIName) {
return myRINamesMap.Find(RIName);
}
// ============================================================================
// Method : RegisterNMEdge
// Purpose : Register non-manifold Edge in the internal storage if it wasn't
// registered before
// ============================================================================
void StepToTopoDS_NMTool::RegisterNMEdge(const TopoDS_Shape& Edge) {
if ( !this->isEdgeRegisteredAsNM(Edge) )
myNMEdges.Append(Edge);
}
// ============================================================================
// Method : IsSuspectedAsClosing
// Purpose : Checks whether SuspectedShell is pure non-manifold and adjacent
// to BaseShell
// ============================================================================
Standard_Boolean StepToTopoDS_NMTool::IsSuspectedAsClosing(const TopoDS_Shape& BaseShell,
const TopoDS_Shape& SuspectedShell) {
return this->IsPureNMShell(SuspectedShell) &&
this->isAdjacentShell(BaseShell, SuspectedShell);
}
// ============================================================================
// Method : SetIDEASCase
// Purpose : Sets myIDEASCase flag (I-DEAS-like STP is processed)
// ============================================================================
void StepToTopoDS_NMTool::SetIDEASCase(const Standard_Boolean IDEASCase) {
myIDEASCase = IDEASCase;
}
// ============================================================================
// Method : GetIDEASCase
// Purpose : Gets myIDEASCase flag (I-DEAS-like STP is processed)
// ============================================================================
Standard_Boolean StepToTopoDS_NMTool::IsIDEASCase() {
return myIDEASCase;
}
// ============================================================================
// Method : IsPureNMShell
// Purpose : Checks if the Shell passed contains only non-manifold Edges
// ============================================================================
Standard_Boolean StepToTopoDS_NMTool::IsPureNMShell(const TopoDS_Shape& Shell) {
Standard_Boolean result = Standard_True;
TopExp_Explorer edgeExp(Shell, TopAbs_EDGE);
for ( ; edgeExp.More(); edgeExp.Next() ) {
TopoDS_Shape currentEdge = edgeExp.Current();
if ( !this->isEdgeRegisteredAsNM(currentEdge) ) {
result = Standard_False;
break;
}
}
return result;
}
// ============================================================================
// Method : isEdgeRegisteredAsNM
// Purpose : Checks if the Edge passed is registered as non-manifold one
// ============================================================================
Standard_Boolean StepToTopoDS_NMTool::isEdgeRegisteredAsNM(const TopoDS_Shape& Edge) {
Standard_Boolean result = Standard_False;
TopTools_ListIteratorOfListOfShape it(myNMEdges);
for ( ; it.More(); it.Next() ) {
TopoDS_Shape currentShape = it.Value();
if ( currentShape.IsSame(Edge) ) {
result = Standard_True;
break;
}
}
return result;
}
// ============================================================================
// Method : isAdjacentShell
// Purpose : Checks if the ShellA is adjacent to the ShellB
// ============================================================================
Standard_Boolean StepToTopoDS_NMTool::isAdjacentShell(const TopoDS_Shape& ShellA,
const TopoDS_Shape& ShellB) {
if ( ShellA.IsSame(ShellB) )
return Standard_False;
TopExp_Explorer edgeExpA(ShellA, TopAbs_EDGE);
for ( ; edgeExpA.More(); edgeExpA.Next() ) {
TopoDS_Shape currentEdgeA = edgeExpA.Current();
TopExp_Explorer edgeExpB(ShellB, TopAbs_EDGE);
for ( ; edgeExpB.More(); edgeExpB.Next() ) {
TopoDS_Shape currentEdgeB = edgeExpB.Current();
if ( currentEdgeA.IsSame(currentEdgeB) )
return Standard_True;
}
}
return Standard_False;
}

View File

@@ -0,0 +1,28 @@
-- File: StepToTopoDS_PointPair.cdl
-- Created: Fri Aug 6 12:38:21 1993
-- Author: Martine LANGLOIS
-- <mla@mastox>
---Copyright: Matra Datavision 1993
class PointPair from StepToTopoDS
---Purpose: Stores a pair of Points from step
uses
CartesianPoint from StepGeom
is
Create(P1, P2 : CartesianPoint from StepGeom)
returns PointPair from StepToTopoDS;
fields
myP1 : CartesianPoint from StepGeom;
myP2 : CartesianPoint from StepGeom;
friends
class PointPairHasher from StepToTopoDS
end PointPair;

View File

@@ -0,0 +1,20 @@
// File: StepToTopoDS_PointPair.cxx
// Created: Fri Aug 6 12:45:32 1993
// Author: Martine LANGLOIS
// <mla@mastox>
#include <StepToTopoDS_PointPair.ixx>
//=======================================================================
//function : StepToTopoDS_PointPair
//purpose :
//=======================================================================
StepToTopoDS_PointPair::StepToTopoDS_PointPair
(const Handle(StepGeom_CartesianPoint)& P1,
const Handle(StepGeom_CartesianPoint)& P2) :
myP1(P1),
myP2(P2)
{
}

View File

@@ -0,0 +1,21 @@
-- File: StepToTopoDS_PointPairHasher.cdl
-- Created: Fri Aug 6 12:42:06 1993
-- Author: Martine LANGLOIS
-- <mla@mastox>
---Copyright: Matra Datavision 1993
class PointPairHasher from StepToTopoDS
uses
PointPair from StepToTopoDS
is
HashCode(myclass; K : PointPair from StepToTopoDS; Upper : Integer)
returns Integer;
---Purpose: Returns a HasCode value for the PointPair
IsEqual(myclass; K1, K2 : PointPair from StepToTopoDS) returns Boolean;
---Purpose: Returns True when the two PointPair are the same
end PointPairHasher;

View File

@@ -0,0 +1,31 @@
// File: StepToTopoDS_PointPairHasher.cxx
// Created: Fri Aug 6 12:47:37 1993
// Author: Martine LANGLOIS
// <mla@mastox>
#include <StepToTopoDS_PointPairHasher.ixx>
//=======================================================================
//function : HashCode
//purpose :
//=======================================================================
Standard_Integer StepToTopoDS_PointPairHasher::HashCode
(const StepToTopoDS_PointPair& P, const Standard_Integer Upper)
{
return (::HashCode(P.myP1,Upper) + ::HashCode(P.myP2,Upper)) % Upper;
}
//=======================================================================
//function : IsEqual
//purpose :
//=======================================================================
Standard_Boolean StepToTopoDS_PointPairHasher::IsEqual
(const StepToTopoDS_PointPair& P1,
const StepToTopoDS_PointPair& P2)
{
return (((P1.myP1 == P2.myP1) && (P1.myP2 == P2.myP2)) ||
((P1.myP1 == P2.myP2) && (P1.myP2 == P2.myP1)));
}

View File

@@ -0,0 +1,46 @@
-- File: StepToTopoDS_Root.cdl
-- Created: Wed Jul 28 11:50:02 1993
-- Author: Martine LANGLOIS
-- <mla@mastox>
---Copyright: Matra Datavision 1993
private deferred class Root from StepToTopoDS
---Purpose : This class implements the common services for
-- all classes of StepToTopoDS which report error
-- and sets and returns precision.
is
Initialize returns Root from StepToTopoDS;
IsDone(me) returns Boolean is static;
---C++: inline
Precision(me) returns Real from Standard is static;
---Purpose : Returns the value of "MyPrecision"
---C++: inline
SetPrecision(me : in out ; preci : Real from Standard) is static;
---Purpose : Sets the value of "MyPrecision"
---C++: inline
MaxTol(me) returns Real from Standard is static;
---Purpose : Returns the value of "MaxTol"
---C++: inline
SetMaxTol(me : in out ; maxpreci : Real from Standard) is static;
---Purpose : Sets the value of MaxTol
---C++: inline
fields
done : Boolean is protected;
--Equal True if everything is ok, False otherwise.
myPrecision : Real from Standard;
myMaxTol : Real from Standard;
end Root;

View File

@@ -0,0 +1,20 @@
// File: StepToTopoDS_Root.cxx
// Created: Thu Apr 8 17:45:20 1999
// Author: data exchange team
// <det@doomox.nnov.matra-dtv.fr>
// gka 13.04.99 S4136: add myPrecision and myMaxTol fields
#include <StepToTopoDS_Root.ixx>
#include <Precision.hxx>
//=======================================================================
//function : StepToTopoDS_Root
//purpose :
//=======================================================================
StepToTopoDS_Root::StepToTopoDS_Root () : done(Standard_False)
{
myPrecision = myMaxTol = Precision::Confusion();
}

View File

@@ -0,0 +1,62 @@
// File: StepToTopoDS_Root.cxx
// Created: Wed Jul 28 11:57:52 1993
// Author: Martine LANGLOIS
// <mla@mastox>
#include <StepToTopoDS_Root.hxx>
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
inline Standard_Boolean StepToTopoDS_Root::IsDone () const
{
return done;
}
//=======================================================================
//function : Precision
//purpose :
//=======================================================================
inline Standard_Real StepToTopoDS_Root::Precision() const
{
return myPrecision;
}
//=======================================================================
//function : SetPrecision
//purpose :
//=======================================================================
inline void StepToTopoDS_Root::SetPrecision(const Standard_Real preci)
{
myPrecision = preci;
}
//=======================================================================
//function : MaxTol
//purpose :
//=======================================================================
inline Standard_Real StepToTopoDS_Root::MaxTol() const
{
return myMaxTol;
}
//=======================================================================
//function : SetMaxTol
//purpose :
//=======================================================================
inline void StepToTopoDS_Root::SetMaxTol(const Standard_Real maxpreci)
{
myMaxTol = maxpreci;
}

View File

@@ -0,0 +1,140 @@
-- File: StepToTopoDS_Tool.cdl
-- Created: Fri Dec 16 14:50:53 1994
-- Author: Frederic MAUPAS
-- <fma@stylox>
---Copyright: Matra Datavision 1994
class Tool from StepToTopoDS
---Purpose: This Tool Class provides Information to build
-- a Cas.Cad BRep from a ProSTEP Shape model.
uses
DataMapOfTRI from StepToTopoDS,
PointPair from StepToTopoDS,
PointVertexMap from StepToTopoDS,
PointEdgeMap from StepToTopoDS,
TopologicalRepresentationItem from StepShape,
CartesianPoint from StepGeom,
Edge from TopoDS,
Vertex from TopoDS,
Shape from TopoDS,
Curve from Geom2d,
Curve from Geom,
Surface from Geom,
TransientProcess from Transfer
is
Create returns Tool from StepToTopoDS;
Create(Map : DataMapOfTRI from StepToTopoDS;
TP : TransientProcess from Transfer)
returns Tool from StepToTopoDS;
Init(me : in out;
Map : DataMapOfTRI from StepToTopoDS;
TP : TransientProcess from Transfer);
IsBound(me : in out;
TRI : TopologicalRepresentationItem from StepShape)
returns Boolean from Standard;
Bind(me : in out;
TRI : TopologicalRepresentationItem from StepShape;
S : Shape from TopoDS);
Find(me : in out;
TRI : TopologicalRepresentationItem from StepShape)
returns Shape from TopoDS;
---C++: return const &
ClearEdgeMap(me : in out);
IsEdgeBound(me : in out;
PP : PointPair from StepToTopoDS)
returns Boolean from Standard;
BindEdge(me : in out;
PP : PointPair from StepToTopoDS;
E : Edge from TopoDS);
FindEdge(me : in out;
PP : PointPair from StepToTopoDS)
returns Edge from TopoDS;
---C++: return const &
ClearVertexMap(me : in out);
IsVertexBound(me : in out;
PG : CartesianPoint from StepGeom)
returns Boolean from Standard;
BindVertex(me : in out;
P : CartesianPoint from StepGeom;
V : Vertex from TopoDS);
FindVertex(me : in out;
P : CartesianPoint from StepGeom)
returns Vertex from TopoDS;
---C++: return const &
ComputePCurve(me : in out;
B : Boolean from Standard);
ComputePCurve(me) returns Boolean from Standard;
TransientProcess(me) returns TransientProcess from Transfer;
-- Statistics
AddContinuity (me : in out; GeomSurf : Surface from Geom);
AddContinuity (me : in out; GeomCurve : Curve from Geom);
AddContinuity (me : in out; GeomCur2d : Curve from Geom2d);
C0Surf(me) returns Integer from Standard;
C1Surf(me) returns Integer from Standard;
C2Surf(me) returns Integer from Standard;
C0Cur2(me) returns Integer from Standard;
C1Cur2(me) returns Integer from Standard;
C2Cur2(me) returns Integer from Standard;
C0Cur3(me) returns Integer from Standard;
C1Cur3(me) returns Integer from Standard;
C2Cur3(me) returns Integer from Standard;
fields
myDataMap : DataMapOfTRI from StepToTopoDS;
myVertexMap : PointVertexMap from StepToTopoDS;
myEdgeMap : PointEdgeMap from StepToTopoDS;
myComputePC : Boolean from Standard;
myTransProc : TransientProcess from Transfer;
-- Statistics :
-- Surface continuity
myNbC0Surf : Integer from Standard;
myNbC1Surf : Integer from Standard;
myNbC2Surf : Integer from Standard;
-- Curve2d continuity
myNbC0Cur2 : Integer from Standard;
myNbC1Cur2 : Integer from Standard;
myNbC2Cur2 : Integer from Standard;
-- Curve3d continuity
myNbC0Cur3 : Integer from Standard;
myNbC1Cur3 : Integer from Standard;
myNbC2Cur3 : Integer from Standard;
end Tool;

View File

@@ -0,0 +1,299 @@
// File: StepToTopoDS_Tool.cxx
// Created: Tue Jan 3 11:34:47 1995
// Author: Frederic MAUPAS
// <fma@stylox>
// Complement : CKY, alimentation du TransientProcess
// (Bind general; BindVertex ?)
#include <StepToTopoDS_Tool.ixx>
#include <TransferBRep.hxx>
// ============================================================================
// Method : StepToTopoDS_Tool::StepToTopoDS_Tool
// Purpose : Empty Constructor
// ============================================================================
StepToTopoDS_Tool::StepToTopoDS_Tool() {}
// ============================================================================
// Method : StepToTopoDS_Tool::StepToTopoDS_Tool
// Purpose : Constructor with a Map and a TransientProcess
// ============================================================================
StepToTopoDS_Tool::StepToTopoDS_Tool(const StepToTopoDS_DataMapOfTRI& Map,
const Handle(Transfer_TransientProcess)& TP)
{
Init(Map, TP);
}
// ============================================================================
// Method : Init
// Purpose : Init with a Map
// ============================================================================
void StepToTopoDS_Tool::Init(const StepToTopoDS_DataMapOfTRI& Map,
const Handle(Transfer_TransientProcess)& TP)
{
myComputePC = Standard_False;
StepToTopoDS_PointVertexMap aVertexMap;
StepToTopoDS_PointEdgeMap aEdgeMap;
myDataMap = Map;
myVertexMap = aVertexMap;
myEdgeMap = aEdgeMap;
myTransProc = TP;
myNbC0Surf = myNbC1Surf = myNbC2Surf = 0;
myNbC0Cur2 = myNbC1Cur2 = myNbC2Cur2 = 0;
myNbC0Cur3 = myNbC1Cur3 = myNbC2Cur3 = 0;
}
// ============================================================================
// Method : StepToTopoDS_Tool::IsBound
// Purpose : Indicates weither a TRI is bound or not in the Map
// ============================================================================
Standard_Boolean StepToTopoDS_Tool::IsBound(const Handle(StepShape_TopologicalRepresentationItem)& TRI)
{
return myDataMap.IsBound(TRI);
}
// ============================================================================
// Method : StepToTopoDS_Tool::Bind
// Purpose : Binds a TRI with a Shape in the Map
// ============================================================================
void StepToTopoDS_Tool::Bind(const Handle(StepShape_TopologicalRepresentationItem)& TRI, const TopoDS_Shape& S)
{
myDataMap.Bind(TRI, S);
TransferBRep::SetShapeResult (myTransProc,TRI,S);
}
// ============================================================================
// Method : StepToTopoDS_Tool::Find
// Purpose : Returns the Shape corresponding to the bounded TRI
// ============================================================================
const TopoDS_Shape& StepToTopoDS_Tool::Find(const Handle(StepShape_TopologicalRepresentationItem)& TRI)
{
return myDataMap.Find(TRI);
}
// ============================================================================
// Method : StepToTopoDS_Tool::ClearEdgeMap
// Purpose :
// ============================================================================
void StepToTopoDS_Tool::ClearEdgeMap()
{
myEdgeMap.Clear();
}
// ============================================================================
// Method : StepToTopoDS_Tool::IsEdgeBound
// Purpose :
// ============================================================================
Standard_Boolean StepToTopoDS_Tool::IsEdgeBound(const StepToTopoDS_PointPair& PP)
{
return myEdgeMap.IsBound(PP);
}
// ============================================================================
// Method : StepToTopoDS_Tool_BindEdge
// Purpose :
// ============================================================================
void StepToTopoDS_Tool::BindEdge(const StepToTopoDS_PointPair& PP, const TopoDS_Edge& E)
{
myEdgeMap.Bind(PP, E);
}
// ============================================================================
// Method : StepToTopoDS_Tool::FindEdge
// Purpose :
// ============================================================================
const TopoDS_Edge& StepToTopoDS_Tool::FindEdge(const StepToTopoDS_PointPair& PP)
{
return myEdgeMap.Find(PP);
}
// ============================================================================
// Method : StepToTopoDS_Tool::ClearVertexMap
// Purpose :
// ============================================================================
void StepToTopoDS_Tool::ClearVertexMap()
{
myVertexMap.Clear();
}
// ============================================================================
// Method : StepToTopoDS_Tool::IsVertexBound
// Purpose :
// ============================================================================
Standard_Boolean StepToTopoDS_Tool::IsVertexBound(const Handle(StepGeom_CartesianPoint)& PG)
{
return myVertexMap.IsBound(PG);
}
// ============================================================================
// Method : StepToTopoDS_Tool::BindVertex
// Purpose :
// ============================================================================
void StepToTopoDS_Tool::BindVertex(const Handle(StepGeom_CartesianPoint)& P, const TopoDS_Vertex& V)
{
myVertexMap.Bind(P, V);
#ifdef DEBUG
TransferBRep::SetShapeResult (myTransProc,P,V);
#endif
}
// ============================================================================
// Method : StepToTopoDS_Tool::FindVertex
// Purpose :
// ============================================================================
const TopoDS_Vertex& StepToTopoDS_Tool::FindVertex(const Handle(StepGeom_CartesianPoint)& P)
{
return myVertexMap.Find(P);
}
// ============================================================================
// Method : ComputePCurve
// Purpose :
// ============================================================================
void StepToTopoDS_Tool::ComputePCurve(const Standard_Boolean B)
{
myComputePC = B;
}
// ============================================================================
// Method : ComputePCurve
// Purpose :
// ============================================================================
Standard_Boolean StepToTopoDS_Tool::ComputePCurve() const
{
return myComputePC;
}
// ============================================================================
// Method : StepToTopoDS_Tool::TransientProcess
// Purpose : Returns the TransientProcess
// ============================================================================
Handle(Transfer_TransientProcess) StepToTopoDS_Tool::TransientProcess() const
{
return myTransProc;
}
//===========
// AddStatistics
//===========
void StepToTopoDS_Tool::AddContinuity (const Handle(Geom_Surface)& GeomSurf)
{
switch(GeomSurf->Continuity())
{
case GeomAbs_C0: myNbC0Surf ++; break;
case GeomAbs_C1: myNbC1Surf ++; break;
default: myNbC2Surf ++;
}
}
void StepToTopoDS_Tool::AddContinuity (const Handle(Geom_Curve)& GeomCurve)
{
switch(GeomCurve->Continuity())
{
case GeomAbs_C0: myNbC0Cur3 ++; break;
case GeomAbs_C1: myNbC1Cur3 ++; break;
default: myNbC2Cur3 ++;
}
}
void StepToTopoDS_Tool::AddContinuity (const Handle(Geom2d_Curve)& GeomCur2d)
{
switch(GeomCur2d->Continuity())
{
case GeomAbs_C0: myNbC0Cur2 ++; break;
case GeomAbs_C1: myNbC1Cur2 ++; break;
default: myNbC2Cur2 ++;
}
}
//===========
// Statistics
//===========
Standard_Integer StepToTopoDS_Tool::C0Surf() const
{
return myNbC0Surf;
}
Standard_Integer StepToTopoDS_Tool::C1Surf() const
{
return myNbC1Surf;
}
Standard_Integer StepToTopoDS_Tool::C2Surf() const
{
return myNbC2Surf;
}
//===========
// Statistics
//===========
Standard_Integer StepToTopoDS_Tool::C0Cur2() const
{
return myNbC0Cur2;
}
Standard_Integer StepToTopoDS_Tool::C1Cur2() const
{
return myNbC1Cur2;
}
Standard_Integer StepToTopoDS_Tool::C2Cur2() const
{
return myNbC2Cur2;
}
//===========
// Statistics
//===========
Standard_Integer StepToTopoDS_Tool::C0Cur3() const
{
return myNbC0Cur3;
}
Standard_Integer StepToTopoDS_Tool::C1Cur3() const
{
return myNbC1Cur3;
}
Standard_Integer StepToTopoDS_Tool::C2Cur3() const
{
return myNbC2Cur3;
}

View File

@@ -0,0 +1,64 @@
-- File: StepToTopoDS_TranslateCompositeCurve.cdl
-- Created: Fri Feb 12 13:17:04 1999
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class TranslateCompositeCurve from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose: Translate STEP entity composite_curve to TopoDS_Wire
-- If surface is given, the curve is assumed to lie on that
-- surface and in case if any segment of it is a
-- curve_on_surface, the pcurve for that segment will be taken.
-- Note: a segment of composite_curve may be itself
-- composite_curve. Only one-level protection against
-- cyclic references is implemented.
uses
TransientProcess from Transfer,
CompositeCurve from StepGeom,
Surface from StepGeom,
Surface from Geom,
Wire from TopoDS
is
Create returns TranslateCompositeCurve;
---Purpose: Empty constructor
Create (CC: CompositeCurve from StepGeom;
TP: TransientProcess from Transfer)
returns TranslateCompositeCurve;
---Purpose: Translates standalone composite_curve
Create (CC: CompositeCurve from StepGeom;
TP: TransientProcess from Transfer;
S : Surface from StepGeom;
Surf: Surface from Geom)
returns TranslateCompositeCurve;
---Purpose: Translates composite_curve lying on surface
Init (me: in out;
CC: CompositeCurve from StepGeom;
TP: TransientProcess from Transfer)
returns Boolean;
---Purpose: Translates standalone composite_curve
Init (me: in out;
CC: CompositeCurve from StepGeom;
TP: TransientProcess from Transfer;
S : Surface from StepGeom;
Surf: Surface from Geom)
returns Boolean;
---Purpose: Translates composite_curve lying on surface
Value (me) returns Wire from TopoDS;
---Purpose: Returns result of last translation or null wire if failed.
---C++: return const &
fields
myWire: Wire from TopoDS;
end TranslateCompositeCurve;

View File

@@ -0,0 +1,251 @@
// File: StepToTopoDS_TranslateCompositeCurve.cxx
// Created: Fri Feb 12 13:29:35 1999
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
//:o3 abv 17.02.99: r0301_db.stp #57082: apply FixReorder to composite curve
//:s5 abv 22.04.99 Adding debug printouts in catch {} blocks
#include <StepToTopoDS_TranslateCompositeCurve.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Interface_Static.hxx>
#include <Precision.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <StepGeom_Pcurve.hxx>
#include <StepGeom_SurfaceCurve.hxx>
#include <StepGeom_PcurveOrSurface.hxx>
#include <StepGeom_CompositeCurveSegment.hxx>
#include <StepToGeom_MakeCurve.hxx>
#include <StepToTopoDS_TranslateEdge.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
#include <ShapeExtend_WireData.hxx>
#include <ShapeFix_Wire.hxx>
//=======================================================================
//function : Create
//purpose :
//=======================================================================
StepToTopoDS_TranslateCompositeCurve::StepToTopoDS_TranslateCompositeCurve () {}
//=======================================================================
//function : Create
//purpose :
//=======================================================================
StepToTopoDS_TranslateCompositeCurve::StepToTopoDS_TranslateCompositeCurve (
const Handle(StepGeom_CompositeCurve) &CC,
const Handle(Transfer_TransientProcess) &TP)
{
Init ( CC, TP );
}
//=======================================================================
//function : Create
//purpose :
//=======================================================================
StepToTopoDS_TranslateCompositeCurve::StepToTopoDS_TranslateCompositeCurve (
const Handle(StepGeom_CompositeCurve) &CC,
const Handle(Transfer_TransientProcess) &TP,
const Handle(StepGeom_Surface) &S,
const Handle(Geom_Surface) &Surf)
{
Init ( CC, TP, S, Surf );
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean StepToTopoDS_TranslateCompositeCurve::Init (const Handle(StepGeom_CompositeCurve) &CC,
const Handle(Transfer_TransientProcess) &TP)
{
Handle(StepGeom_Surface) S;
Handle(Geom_Surface) Surf;
return Init ( CC, TP, S, Surf );
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean StepToTopoDS_TranslateCompositeCurve::Init (const Handle(StepGeom_CompositeCurve) &CC,
const Handle(Transfer_TransientProcess) &TP,
const Handle(StepGeom_Surface) &S,
const Handle(Geom_Surface) &Surf)
{
myWire.Nullify();
if ( CC.IsNull() ) return Standard_False;
Standard_Boolean SurfMode = ( ! S.IsNull() && ! Surf.IsNull() );
Standard_Boolean isClosed = Standard_False;
if ( SurfMode ) {
Standard_Integer modepcurve = Interface_Static::IVal("read.surfacecurve.mode");
if ( modepcurve ==-3 ) SurfMode = Standard_False;
}
Handle(ShapeExtend_WireData) sbwd = new ShapeExtend_WireData;
Standard_Integer nbs = CC->NbSegments();
for ( Standard_Integer i=1; i <= nbs; i++ ) {
Handle(StepGeom_CompositeCurveSegment) ccs = CC->SegmentsValue ( i );
if ( ccs.IsNull() ) {
TP->AddFail ( CC, "Null segment" );
return Standard_False;
}
Handle(StepGeom_Curve) crv = ccs->ParentCurve();
if ( crv.IsNull() ) {
TP->AddFail ( CC, "Segment has null parent curve" );
return Standard_False;
}
isClosed = ( ccs->Transition() != StepGeom_tcDiscontinuous );
// if segment is itself a composite_curve, translate recursively
if ( crv->IsKind(STANDARD_TYPE(StepGeom_CompositeCurve)) ) {
if ( crv == CC ) { // cyclic reference protection
TP->AddFail (ccs, "Cyclic reference; segment dropped" );
continue;
}
Handle(StepGeom_CompositeCurve) cc = Handle(StepGeom_CompositeCurve)::DownCast ( crv );
if ( ! Init ( cc, TP, S, Surf ) || myWire.IsNull() ) continue;
Standard_Integer nb = sbwd->NbEdges() + 1;
for ( TopoDS_Iterator it ( myWire ); it.More(); it.Next() ) {
TopoDS_Edge edge = TopoDS::Edge ( it.Value() );
if ( ccs->SameSense() ) sbwd->Add ( edge );
else {
edge.Reverse();
sbwd->Add ( edge, nb > sbwd->NbEdges() ? 0 : nb );
}
}
myWire.Nullify();
continue;
}
// ordinary segment
// detect pcurve and 3d curve
Handle(StepGeom_Pcurve) pcurve = Handle(StepGeom_Pcurve)::DownCast ( crv );
if ( pcurve.IsNull() ) {
Handle(StepGeom_SurfaceCurve) sc = Handle(StepGeom_SurfaceCurve)::DownCast ( crv );
if ( ! sc.IsNull() ) {
crv = sc->Curve3d();
if ( SurfMode ) { // find proper pcurve
for ( Standard_Integer j=1; j <= sc->NbAssociatedGeometry(); j++ ) {
StepGeom_PcurveOrSurface PCorS = sc->AssociatedGeometryValue ( j );
Handle(StepGeom_Pcurve) pc = PCorS.Pcurve();
if ( pc.IsNull() || pc->BasisSurface() != S ) continue;
pcurve = pc;
if ( ccs->SameSense() ) break;
}
}
}
}
else {
if ( ! SurfMode || pcurve->BasisSurface() != S ) pcurve.Nullify();
crv.Nullify();
}
// prepare edge
TopoDS_Edge edge;
// translate 3d curve, if present
if ( ! crv.IsNull() ) {
try {
OCC_CATCH_SIGNALS
Handle(Geom_Curve) c3d;
if (StepToGeom_MakeCurve::Convert(crv,c3d)) {
BRepBuilderAPI_MakeEdge MkEdge ( c3d, c3d->FirstParameter(), c3d->LastParameter() );
if ( MkEdge.IsDone() ) edge = MkEdge.Edge();
}
}
catch(Standard_Failure) {
#ifdef DEB
cout << "Warning: StepToTopoDS_TranslateCompositeCurve: Exception: ";
Standard_Failure::Caught()->Print(cout); cout << endl;
#endif
}
}
// translate pcurve, if available
if ( ! pcurve.IsNull() ) {
try {
OCC_CATCH_SIGNALS
StepToTopoDS_TranslateEdge TrE;
Handle(Geom2d_Curve) c2d = TrE.MakePCurve ( pcurve, Surf );
if ( ! c2d.IsNull() ) {
if ( edge.IsNull() ) {
BRepBuilderAPI_MakeEdge MkEdge ( c2d, Surf, c2d->FirstParameter(), c2d->LastParameter() );
if ( MkEdge.IsDone() ) edge = MkEdge.Edge();
}
else {
BRep_Builder B;
TopLoc_Location L;
B.UpdateEdge ( edge, c2d, Surf, L, 0. );
B.Range ( edge, Surf, L, c2d->FirstParameter(), c2d->LastParameter() );
B.SameRange ( edge, Standard_False );
B.SameParameter ( edge, Standard_False );
}
}
}
catch(Standard_Failure) {
#ifdef DEB
cout << "Warning: StepToTopoDS_TranslateCompositeCurve: Exception: ";
Standard_Failure::Caught()->Print(cout); cout << endl;
#endif
}
}
if ( edge.IsNull() ) {
TP->AddFail ( crv, "Curve can not be translated");
continue;
}
if ( ! ccs->SameSense() ) edge.Reverse();
sbwd->Add ( edge );
}
if ( sbwd->NbEdges() <=0 ) {
TP->AddFail ( CC, "Translation gives no result" );
return Standard_False;
}
// connect wire; all other fixes are left for caller
Standard_Real preci = Precision();
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
sfw->Load ( sbwd );
sfw->SetPrecision ( preci );
sfw->ClosedWireMode() = isClosed;
sfw->FixReorder(); //:o3 abv 17 Feb 99: r0301_db.stp #57082
if ( sfw->StatusReorder ( ShapeExtend_DONE ) ) {
TP->AddWarning ( CC, "Segments were disordered; fixed" );
}
sfw->FixConnected ( preci );
if ( sfw->StatusConnected ( ShapeExtend_FAIL ) ) {
TP->AddWarning ( CC, "Segments are not connected" );
}
myWire = sbwd->Wire();
done = ( sbwd->NbEdges() >0 );
return Standard_True;
}
//=======================================================================
//function : Value
//purpose : return resulting wire
//=======================================================================
const TopoDS_Wire& StepToTopoDS_TranslateCompositeCurve::Value () const
{
return myWire;
}

View File

@@ -0,0 +1,40 @@
-- File: StepToTopoDS_TranslateCurveBoundedSurface.cdl
-- Created: Fri Feb 12 13:30:22 1999
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class TranslateCurveBoundedSurface from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose: Translate curve_bounded_surface into TopoDS_Face
uses
TransientProcess from Transfer,
CurveBoundedSurface from StepGeom,
Face from TopoDS
is
Create returns TranslateCurveBoundedSurface;
---Purpose: Create empty tool
Create (CBS: CurveBoundedSurface from StepGeom;
TP: TransientProcess from Transfer)
returns TranslateCurveBoundedSurface;
---Purpose: Translate surface
Init (me: in out;
CBS: CurveBoundedSurface from StepGeom;
TP: TransientProcess from Transfer)
returns Boolean;
---Purpose: Translate surface
Value (me) returns Face from TopoDS;
---Purpose: Returns result of last translation or null wire if failed.
---C++: return const &
fields
myFace: Face from TopoDS;
end TranslateCurveBoundedSurface;

View File

@@ -0,0 +1,125 @@
// File: StepToTopoDS_TranslateCurveBoundedSurface.cxx
// Created: Fri Feb 12 13:30:17 1999
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
//#4 szv S4163: optimization
//: abv 07.04.99 S4136: turn off fixing intersection of non-adjacent edges
#include <StepToTopoDS_TranslateCurveBoundedSurface.ixx>
#include <Precision.hxx>
#include <Geom_BoundedSurface.hxx>
#include <StepToGeom_MakeSurface.hxx>
#include <StepGeom_HArray1OfSurfaceBoundary.hxx>
#include <StepToTopoDS_TranslateCompositeCurve.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <StepGeom_BSplineSurface.hxx>
#include <ShapeAlgo.hxx>
#include <ShapeAlgo_AlgoContainer.hxx>
//=======================================================================
//function : StepToTopoDS_TranslateCurveBoundedSurface
//purpose :
//=======================================================================
StepToTopoDS_TranslateCurveBoundedSurface::StepToTopoDS_TranslateCurveBoundedSurface ()
{
}
//=======================================================================
//function : StepToTopoDS_TranslateCurveBoundedSurface
//purpose :
//=======================================================================
StepToTopoDS_TranslateCurveBoundedSurface::StepToTopoDS_TranslateCurveBoundedSurface (
const Handle(StepGeom_CurveBoundedSurface) &CBS,
const Handle(Transfer_TransientProcess) &TP)
{
Init ( CBS, TP );
}
Standard_Boolean StepToTopoDS_TranslateCurveBoundedSurface::Init (
const Handle(StepGeom_CurveBoundedSurface) &CBS,
const Handle(Transfer_TransientProcess) &TP)
{
myFace.Nullify();
if ( CBS.IsNull() ) return Standard_False;
// translate basis surface
Handle(StepGeom_Surface) S = CBS->BasisSurface();
Handle(Geom_Surface) Surf;
if ( !StepToGeom_MakeSurface::Convert(S,Surf) ) {
TP->AddFail ( CBS, "Basis surface not translated" );
return Standard_False;
}
// abv 30.06.00: trj4_k1_geo-tu.stp #108: do as in TranslateFace
// pdn to force bsplsurf to be periodic
Handle(StepGeom_BSplineSurface) sgbss = Handle(StepGeom_BSplineSurface)::DownCast(S);
if (!sgbss.IsNull()) {
/*
StepGeom_BSplineSurfaceForm form = sgbss->SurfaceForm();
if ((form == StepGeom_bssfCylindricalSurf)||
(form == StepGeom_bssfConicalSurf)||
(form == StepGeom_bssfSphericalSurf)||
(form == StepGeom_bssfToroidalSurf)||
(form == StepGeom_bssfSurfOfRevolution)||
(form == StepGeom_bssfGeneralisedCone)||
(form == StepGeom_bssfUnspecified))
*/
{
Handle(Geom_Surface) periodicSurf = ShapeAlgo::AlgoContainer()->ConvertToPeriodic (Surf);
if(!periodicSurf.IsNull()) {
TP->AddWarning(S,"Surface forced to be periodic");
Surf = periodicSurf;
}
}
}
// create face
BRep_Builder B;
B.MakeFace ( myFace, Surf, Precision::Confusion() );
// add natural bound if implicit
if ( CBS->ImplicitOuter() ) {
if ( Surf->IsKind(STANDARD_TYPE(Geom_BoundedSurface)) ) {
BRepBuilderAPI_MakeFace mf (Surf);
myFace = mf.Face();
}
else TP->AddWarning ( CBS, "Cannot make natural bounds on infinite surface" );
}
// translate boundaries
Handle(StepGeom_HArray1OfSurfaceBoundary) bnd = CBS->Boundaries();
Standard_Integer nb = bnd->Length();
for ( Standard_Integer i=1; i <= nb; i++ ) {
Handle(StepGeom_CompositeCurve) cc = bnd->Value ( i ).BoundaryCurve();
if ( cc.IsNull() ) continue;
StepToTopoDS_TranslateCompositeCurve TrCC ( cc, TP, S, Surf );
if ( ! TrCC.IsDone() ) {
TP->AddWarning ( CBS, "Boundary not translated" );
continue;
}
B.Add ( myFace, TrCC.Value() );
}
done = ! myFace.IsNull();
return done;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const TopoDS_Face &StepToTopoDS_TranslateCurveBoundedSurface::Value () const
{
return myFace;
}

View File

@@ -0,0 +1,71 @@
-- File: StepToTopoDS_TranslateEdge.cdl
-- Created: Fri Dec 16 14:48:04 1994
-- Author: Frederic MAUPAS
-- <fma@stylox>
---Copyright: Matra Datavision 1994
class TranslateEdge from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose:
--
uses
Edge from StepShape,
Tool from StepToTopoDS,
TranslateEdgeError from StepToTopoDS,
Shape from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
Curve from Geom2d,
Surface from Geom,
EdgeCurve from StepShape,
Curve from StepGeom,
Vertex from StepShape,
Pcurve from StepGeom,
NMTool from StepToTopoDS
raises NotDone from StdFail
is
Create returns TranslateEdge;
Create (E : Edge from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS)
returns TranslateEdge;
Init (me : in out;
E : Edge from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS);
MakeFromCurve3D (me : in out; C3D : Curve from StepGeom;
EC : EdgeCurve from StepShape; -- for messages
Vend : Vertex from StepShape; -- case of null edge
preci : Real; E : in out Edge from TopoDS;
V1, V2 : in out Vertex from TopoDS;
T : in out Tool from StepToTopoDS);
---Purpose: Warning! C3D is assumed to be a Curve 3D ...
-- other cases to checked before calling this
MakePCurve (me; PCU : Pcurve from StepGeom; ConvSurf : Surface from Geom)
returns Curve from Geom2d;
-- Null if failed
Value (me) returns Shape from TopoDS
raises NotDone
is static;
---C++: return const &
Error (me) returns TranslateEdgeError from StepToTopoDS;
fields
myError : TranslateEdgeError from StepToTopoDS;
myResult : Shape from TopoDS;
end TranslateEdge;

View File

@@ -0,0 +1,514 @@
// File: StepToTopoDS_TranslateEdge.cxx
// Created: Tue Jan 3 11:52:00 1995
// Author: Frederic MAUPAS
// <fma@stylox>
//: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 <Geom_Curve.hxx>
#include <GeomAbs_Shape.hxx>
#include <Geom_Line.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <gp_Lin.hxx>
#include <ShapeAnalysis_Curve.hxx>
#include <ShapeConstruct_Curve.hxx>
#include <StepShape_EdgeCurve.hxx>
#include <StepShape_OrientedEdge.hxx>
#include <StepGeom_Curve.hxx>
//#include <StepGeom_Polyline.hxx>
#include <StepGeom_Pcurve.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 <UnitsMethods.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*/,
StepToTopoDS_Tool& aTool,
const Handle(StepShape_TopologicalRepresentationItem)& /*tobind*/)
{
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
cout << "------------------------------------" << endl;
cout << "MakeEdge Error : " << ME.Error()<<" - ";
#endif
switch(ME.Error())
{
case (BRepLib_EdgeDone): return;
case (BRepLib_PointProjectionFailed):
TP->AddFail(orig," Point Projection failed");
break;
case (BRepLib_ParameterOutOfRange):
TP->AddFail(orig," Parameter Out Of Range");
break;
case (BRepLib_DifferentPointsOnClosedCurve):
TP->AddFail(orig," Different Points on Closed Curve");
break;
case (BRepLib_PointWithInfiniteParameter):
TP->AddFail(orig," Point with infinite Parameter");
break;
case (BRepLib_DifferentsPointAndParameter):
if (!ShapeConstruct_Curve().AdjustCurve
(myCurve,BRep_Tool::Pnt(V1),BRep_Tool::Pnt(V2),Standard_True,Standard_True))
TP->AddFail(orig," Different Points and Parameters");
else TP->AddWarning(orig,"Different Points and Parameters, adjusted");
break;
case (BRepLib_LineThroughIdenticPoints):
TP->AddFail(orig," Line through identic Points");
break;
}
#ifdef DEBUG
cout << "Original Type : " << orig->DynamicType() << endl;
cout << "3D Curve Type : " << myCurve->DynamicType() << endl;
cout << "First Parameter : " << U1 << endl;
gp_Pnt p1 = BRep_Tool::Pnt(V1);
// cout << "First Point : ";
cout << "First Vertex : "<<p1.X()<<" "<<p1.Y()<<" "<<p1.Z()<<" ";
cout << "Distance Point - Vertex : ";
Standard_Real d1 = p1.Distance(myCurve->Value(U1));
cout << d1 << endl;
cout << "Last Parameter : " << U2 << endl;
gp_Pnt p2 = BRep_Tool::Pnt(V2);
// cout << "Last Point : ";
cout << "Last Vertex : "<<p2.X()<<" "<<p2.Y()<<" "<<p2.Z()<<" ";
cout << "Distance Point - Vertex : ";
Standard_Real d2 = BRep_Tool::Pnt(V2).Distance(myCurve->Value(U2));
cout << d2 << endl;
#endif
}
// ============================================================================
// Method : StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge
// Purpose : Empty Constructor
// ============================================================================
static Handle(Geom_Curve) MakeCurve
(const Handle(StepGeom_Curve)& C1, const Handle(Transfer_TransientProcess) TP)
{
Handle(Geom_Curve) C2 = Handle(Geom_Curve)::DownCast (TP->FindTransient(C1));
if (!C2.IsNull()) return C2;
if (StepToGeom_MakeCurve::Convert(C1,C2))
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)
{
// fait son edge quoi qu il arrive
BRep_Builder B;
TopoDS_Edge E;
B.MakeEdge (E,C3D,Precision::Confusion());//preci);
B.Add (E,V1); B.Add (E,V2);
B.UpdateVertex(V1, U1, E, 0.);//preci);
B.UpdateVertex(V2, U2, E, 0.);//preci);
return E;
}
StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge()
{
done = Standard_False;
}
// ============================================================================
// Method : StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge()
// Purpose : Constructor with an Edge and a Tool
// ============================================================================
StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge(const Handle(StepShape_Edge)& E,
StepToTopoDS_Tool& T,
StepToTopoDS_NMTool& NMTool)
{
Init(E, T, NMTool);
}
// ============================================================================
// Method : Init
// Purpose : Init with an Edge and a Tool.
// This method builds an Edge With 2 Vertices and 2 Parameters.
// The Edge is always build like FORWARD (BRepLib_MakeEdge)
// ============================================================================
void StepToTopoDS_TranslateEdge::Init(const Handle(StepShape_Edge)& aEdge,
StepToTopoDS_Tool& aTool,
StepToTopoDS_NMTool& NMTool)
{
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
Handle(StepShape_OrientedEdge) OE =
Handle(StepShape_OrientedEdge)::DownCast(aEdge);
Handle(StepShape_Edge) wEdge = aEdge;
if ( ! OE.IsNull() ) wEdge = OE->EdgeElement();
Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(wEdge);
if (aTool.IsBound(EC)) {
myResult = aTool.Find(EC);
if (BRep_Tool::Degenerated(TopoDS::Edge(myResult))) {
TP->AddWarning(EC,"Degenerated Edge in several faces : transferred for each face");
}
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;
}
}
// [BEGIN] Proceed with non-manifold cases (ssv; 12.11.2010)
if ( NMTool.IsActive() && NMTool.IsBound(EC) ) {
TopoDS_Shape existingShape = NMTool.Find(EC);
// Reverse shape's orientation if needed
if ( !OE->Orientation() )
existingShape.Reverse();
myResult = existingShape;
myError = StepToTopoDS_TranslateEdgeDone;
done = Standard_True;
return;
}
// [END] Proceed with non-manifold cases (ssv; 12.11.2010)
// [BEGIN] Proceed with I-DEAS-like STP (ssv; 15.11.2010)
const Handle(TCollection_HAsciiString) anECName = EC->Name();
if ( NMTool.IsIDEASCase() && !anECName.IsNull() && !anECName->IsEmpty() &&
NMTool.IsBound(anECName->String()) ) {
TopoDS_Shape existingShape = NMTool.Find(anECName->String());
// Reverse shape's orientation if needed
if ( !OE->Orientation() )
existingShape.Reverse();
// Register Edge for final processing (I-DEAS case)
NMTool.RegisterNMEdge(existingShape);
myResult = existingShape;
myError = StepToTopoDS_TranslateEdgeDone;
done = Standard_True;
return;
}
// [END] Proceed with I-DEAS-like STP (ssv; 15.11.2010)
BRep_Builder B;
// Standard_Real preci = BRepAPI::Precision();
// Standard_Real precision = BRepAPI::Precision();
Handle(StepGeom_Curve) C = EC->EdgeGeometry();
TopoDS_Edge E;
Handle(StepShape_Vertex) Vstart, Vend;
// -----------------------------------------------------------
// Extract the start and end Vertices corresponding to FORWARD
// (following the geometrical sense)
// -----------------------------------------------------------
// Standard_Boolean OrientedEdgeOrientation = OE->Orientation();
Standard_Boolean EdgeCurveSameSense = EC->SameSense();
if (EdgeCurveSameSense) {
Vstart = EC->EdgeStart();
Vend = EC->EdgeEnd();
}
else {
Vend = EC->EdgeStart();
Vstart = EC->EdgeEnd();
}
TopoDS_Vertex V1, V2;
StepToTopoDS_TranslateVertex myTranVertex1(Vstart, aTool, NMTool);
StepToTopoDS_TranslateVertex myTranVertex2(Vend, aTool, NMTool);
if (myTranVertex1.IsDone()) {
V1 = TopoDS::Vertex(myTranVertex1.Value());
V1.Orientation(TopAbs_FORWARD);
}
if (Vend == Vstart) {
V2 = V1;
V2.Orientation(TopAbs_REVERSED);
}
else if (myTranVertex2.IsDone()) {
V2 = TopoDS::Vertex(myTranVertex2.Value());
V2.Orientation(TopAbs_REVERSED);
}
done = Standard_True;
// ----------------------------------------------------------
// --- The EdgeCurve Geometry is of StepGeom_Curve Type
// --- It can be : * a Pcurve : no 3D curve is constructed
// --- * a Surface Curve, Intersection Curve
// --- or a Seam Curve
// --- * a 3D Curve
// ----------------------------------------------------------
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, V2);
}
else if (C->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve)) ) {
// qui reprend les types SeamCurve et IntersectionCurve
// --- 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
if (done) {
//:S4136 B.SameRange(E, Standard_False);
//:S4136 B.SameParameter(E, Standard_False);
aTool.Bind(EC,E);
// Bind Edge in NM tool (ssv; 15.11.2010)
if ( NMTool.IsActive() ) {
NMTool.Bind(EC, E);
if ( NMTool.IsIDEASCase() && !anECName.IsNull() && !anECName->IsEmpty() )
NMTool.Bind(anECName->String(), E);
}
myResult = E;
myError = StepToTopoDS_TranslateEdgeDone;
}
}
// ============================================================================
// Method : MakeFromCurve3D
// Purpose : case of a Curve 3D (alone or in SurfaceCurve)
// ============================================================================
// auxiliary function
//:e6 abv 16 Apr 98: ProSTEP TR8, r0601_sy.stp, #14907
static void GetCartesianPoints ( const Handle(StepShape_EdgeCurve)& EC,
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_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();
}
}
void StepToTopoDS_TranslateEdge::MakeFromCurve3D
(const Handle(StepGeom_Curve)& C3D, const Handle(StepShape_EdgeCurve)& EC,
const Handle(StepShape_Vertex)& Vend,
const Standard_Real preci, TopoDS_Edge& E,
TopoDS_Vertex& V1, TopoDS_Vertex& V2,
StepToTopoDS_Tool& aTool)
{
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
Handle(Geom_Curve) C1 = MakeCurve(C3D,TP);
if (C1.IsNull()) {
TP->AddFail(C3D," Make Geom_Curve (3D) failed");
myError = StepToTopoDS_TranslateEdgeOther;
done = Standard_False;
return;
}
// -- Statistics -- -> No Warning message
aTool.AddContinuity (C1);
BRep_Builder B;
Standard_Real temp1,temp2, U1,U2;
gp_Pnt pproj;
gp_Pnt pv1 = BRep_Tool::Pnt(V1);
gp_Pnt pv2 = BRep_Tool::Pnt(V2);
//:e6 abv
gp_Pnt pnt1 = pv1, pnt2 = pv2;
if ( V1.IsSame ( V2 ) ) GetCartesianPoints ( EC, pnt1, pnt2 );
ShapeAnalysis_Curve sac;
temp1 = sac.Project (C1,pnt1,preci,pproj,U1,Standard_False);
temp2 = sac.Project (C1,pnt2,preci,pproj,U2,Standard_False);
if (!StepToTopoDS_GeometricTool::UpdateParam3d(C1, U1, U2, preci))
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 );
temp1 = pU1.Distance ( pv1 );
temp2 = pU2.Distance ( pv2 );
if ( temp1 > preci || temp2 > preci ) {
TP->AddWarning (C3D,"Poor result from projection vertex / curve 3d");
}
B.UpdateVertex ( V1, 1.000001*temp1 ); //:h6 abv 14 Jul 98: PRO8845 #2746: *=1.0001
B.UpdateVertex ( V2, 1.000001*temp2 ); //:h6
BRepLib_MakeEdge ME(C1, V1, V2, U1, U2);
if (ME.IsDone()) {
E = ME.Edge();
B.Range ( E, U1, U2 ); // abv 14 Mar 00: trj3_pm1-ug.stp #91739, edge 2
}
else {
if (ME.Error() == BRepLib_DifferentPointsOnClosedCurve) {
// The Edge could be closed and trimmed by 2 Differents
// Vertices
if (C1->IsClosed()) {
// Attention : il faudra mettre a jour la topologie des
// vertex pour avoir des edges cul a cul ...... Good Luck!
aTool.Bind (Vend,V1);
TopoDS_Shape aLocalShape = V1.Reversed();
V2 = TopoDS::Vertex(aLocalShape);
ME.Init(C1, V1, V2, U1, U2);
if (ME.IsDone()) {
TP->AddWarning(EC, "Wrong topology corrected : Closed Edge with TWO different Vertices");
E = ME.Edge();
}
else {
DecodeMakeEdgeError(ME, C3D, C1, V1, V2, U1, U2, aTool, EC);
E = MakeEdge (C1,V1,V2,U1,U2);//preci
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; // ????
// 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
done = Standard_True;
if (!V1.IsSame(V2)) {
TP->AddFail(EC, "This edge has null arc length");
gp_Pnt P1 = BRep_Tool::Pnt(V1);
gp_Pnt P2 = BRep_Tool::Pnt(V2);
gp_Vec avec (P1,P2); gp_Dir adir (avec); gp_Lin alin (P1,adir);
C1 = new Geom_Line (alin);
U1 = 0.; U2 = P1.Distance(P2);
E = MakeEdge (C1,V1,V2,U1,U2);//,preci
}
else {
TP->AddFail(EC,"NULL EDGE, SKIPPED");
myResult.Nullify();
return;
}
}
}
else {
DecodeMakeEdgeError(ME, C3D, C1, V1, V2, U1, U2, aTool, EC);
E = MakeEdge (C1,V1,V2,U1,U2);//,preci
myError = StepToTopoDS_TranslateEdgeDone; // ????
done = Standard_True;
}
}
}
// ============================================================================
// Method : MakePCurve
// Purpose : Computes an individual pcurve (i.e. curve 2d)
// ============================================================================
Handle(Geom2d_Curve) StepToTopoDS_TranslateEdge::MakePCurve
(const Handle(StepGeom_Pcurve)& PCU, const Handle(Geom_Surface)& ConvSurf) const
{
Handle(Geom2d_Curve) C2d;
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)) {
// -- if the surface is a RectangularTrimmedSurface,
// -- send the BasisSurface.
C2d = UnitsMethods::DegreeToRadian(C2d, ConvSurf);
}
return C2d;
}
// ============================================================================
// Method : Value
// Purpose : Returns the mapped edge
// ============================================================================
const TopoDS_Shape& StepToTopoDS_TranslateEdge::Value() const
{
StdFail_NotDone_Raise_if(!done,"");
return myResult;
}
// ============================================================================
// Method : Error
// Purpose : Returns the error code
// ============================================================================
StepToTopoDS_TranslateEdgeError StepToTopoDS_TranslateEdge::Error() const
{
return myError;
}

View File

@@ -0,0 +1,62 @@
-- File: StepToTopoDS_TranslateEdgeLoop.cdl
-- Created: Wed Mar 29 08:20:18 1995
-- Author: Frederic MAUPAS
-- <fma@pronox>
---Copyright: Matra Datavision 1995
class TranslateEdgeLoop from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose:
--
uses
FaceBound from StepShape,
Surface from StepGeom,
Tool from StepToTopoDS,
TranslateEdgeLoopError from StepToTopoDS,
Shape from TopoDS,
Surface from Geom,
Face from TopoDS,
NMTool from StepToTopoDS
raises NotDone from StdFail
is
Create returns TranslateEdgeLoop;
Create (FB : FaceBound from StepShape;
F : Face from TopoDS;
S : Surface from Geom;
SS : Surface from StepGeom;
ss : Boolean from Standard;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS)
returns TranslateEdgeLoop;
Init (me : in out;
FB : FaceBound from StepShape;
F : Face from TopoDS;
S : Surface from Geom;
SS : Surface from StepGeom;
ss : Boolean from Standard;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS);
Value (me) returns Shape from TopoDS
raises NotDone
is static;
---C++: return const &
Error (me) returns TranslateEdgeLoopError from StepToTopoDS;
fields
myError : TranslateEdgeLoopError from StepToTopoDS;
myResult : Shape from TopoDS;
end TranslateEdgeLoop;

View File

@@ -0,0 +1,724 @@
// File: StepToTopoDS_TranslateEdgeLoop.cxx
// Created: Wed Mar 29 08:40:15 1995
// Author: Frederic MAUPAS
// <fma@pronox>
// gka 21.08.98 PRO7656
// gka 15.12.98 UKI60591 #1274560
//pdn 18.12.98 to keep pcurves
//:o0 abv 16.02.99: POLYLINE allowed as 3d curve of edge
//: abv 07.04.99: S4136: improve tolerance management and dealing with pcurves
// rln 02.06.99 removing #include <StepToTopoDS_DegeneratedTool.hxx>
// smh 31.01.01 BUC60810 : IsNull protection
#include <StepToTopoDS_TranslateEdgeLoop.ixx>
#include <StepToTopoDS.hxx>
#include <StepToTopoDS_TranslateVertex.hxx>
#include <StepToTopoDS_TranslateEdge.hxx>
#include <StepToTopoDS_GeometricTool.hxx>
#include <ShapeAnalysis_Curve.hxx>
#include <StepToGeom_MakeCurve2d.hxx>
#include <StepToGeom_MakeCurve.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <StepShape_EdgeLoop.hxx>
#include <StepShape_Edge.hxx>
#include <StepShape_OrientedEdge.hxx>
#include <StepGeom_Curve.hxx>
#include <StepShape_EdgeCurve.hxx>
#include <StepGeom_Pcurve.hxx>
//#include <StepGeom_Polyline.hxx>
#include <StepGeom_SurfaceCurve.hxx>
#include <StepRepr_DefinitionalRepresentation.hxx>
#include <StepGeom_PcurveOrSurface.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <BRep_ListOfCurveRepresentation.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <TopLoc_Location.hxx>
#include <TopAbs.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_BoundedCurve.hxx>
#include <Geom2d_Line.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
#include <Interface_Static.hxx>
#include <Transfer_TransientProcess.hxx>
#include <TopoDS_Iterator.hxx>
#include <ShapeFix_EdgeProjAux.hxx>
#include <ShapeAnalysis_Edge.hxx>
#include <ShapeExtend_WireData.hxx>
#include <ShapeBuild_Edge.hxx>
#include <ShapeAlgo.hxx>
#include <ShapeAlgo_AlgoContainer.hxx>
#include <ShapeAlgo_ToolContainer.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
// ============================================================================
// Method : RemoveSinglePCurve
// Purpose :
// ============================================================================
static void RemoveSinglePCurve (const TopoDS_Edge& aEdge, const TopoDS_Face& aFace)
{
ShapeBuild_Edge().RemovePCurve (aEdge, aFace);
}
// ============================================================================
// Method : RemovePCurves
// Purpose :
// ============================================================================
static void RemovePCurves(const TopoDS_Wire& aWire, const TopoDS_Face& aFace)
{
TopExp_Explorer EdgeExp(aWire, TopAbs_EDGE);
while (EdgeExp.More()) {
const TopoDS_Edge& myEdge = TopoDS::Edge(EdgeExp.Current());
RemoveSinglePCurve(myEdge,aFace);
EdgeExp.Next();
}
}
// ============================================================================
// Method : CheckPCurves
// Purpose : Checks the pcurves topological trimming parameter consistency
// and deviation between 2D ans 3D
// ============================================================================
static void CheckPCurves (TopoDS_Wire& aWire, const TopoDS_Face& aFace,
const Standard_Boolean isPlane,const Standard_Real preci )
{
if (isPlane) { RemovePCurves (aWire,aFace);return; }
BRep_Builder B;
Standard_Real w1, w2, cf, cl;
Handle(Geom_Surface) mySurf = BRep_Tool::Surface(aFace);
Handle(ShapeExtend_WireData) sbwd = new ShapeExtend_WireData ( aWire );
for (Standard_Integer i = 1; i <= sbwd->NbEdges(); i++) {
const TopoDS_Edge& myEdge = sbwd->Edge(i);
// B.SameRange( myEdge, Standard_True );
// B.SameParameter ( myEdge, Standard_True );
// First Check : 2D Parameters on Edge :
// Case 1 : w1 == w2 illegal => Drop the PCurve
// Case 2 : on bounded curve w1 < FirstParameter => w1 = FirstParameter
// w2 > LastParameter => w2 = LastParameter
Handle(Geom2d_Curve) thePC;
ShapeAnalysis_Edge sae;
if (!sae.PCurve (myEdge, aFace, thePC, w1, w2, Standard_False )) {
continue;
}
cf = thePC->FirstParameter();
cl = thePC->LastParameter();
if (w1 == w2) {
RemoveSinglePCurve(myEdge,aFace);
#ifdef DEBUG
cout<<"Removing pcuve w1=w2"<<endl;
#endif
continue;
}
if (w1 < cf) {
B.Range(myEdge, aFace, cf, w2);
w1 = cf;
}
if (w2 > cl) {
B.Range(myEdge, aFace, w1, cl);
w2 = cf;
}
// advanced check
XSAlgo::AlgoContainer()->CheckPCurve (myEdge, aFace, preci, sbwd->IsSeam(i) );
}
}
// ============================================================================
// Method : StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop
// Purpose : Empty Constructor
// ============================================================================
StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop()
{
done = Standard_False;
}
// ============================================================================
// Method : StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop
// Purpose : Constructor with a FaceSurface and a Tool
// ============================================================================
StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop(const Handle(StepShape_FaceBound)& FB,
const TopoDS_Face& Face,
const Handle(Geom_Surface)& GeomSurf,
const Handle(StepGeom_Surface)& StepSurf,
const Standard_Boolean sameSense,
StepToTopoDS_Tool& T,
StepToTopoDS_NMTool& NMTool) {
Init(FB, Face, GeomSurf, StepSurf, sameSense, T, NMTool);
}
// ============================================================================
// Method : Init
// Purpose : Init with a EdgeLoop and a Tool
// ============================================================================
void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& FaceBound,
const TopoDS_Face& Face,
const Handle(Geom_Surface)& GeomSurf,
const Handle(StepGeom_Surface)& StepSurf,
const Standard_Boolean sameSense,
StepToTopoDS_Tool& aTool,
StepToTopoDS_NMTool& NMTool) {
done = Standard_True;
Handle(StepShape_EdgeLoop) EL =
Handle(StepShape_EdgeLoop)::DownCast(FaceBound->Bound());
if (aTool.IsBound(EL)) {
myResult = TopoDS::Wire(aTool.Find(EL));
myError = StepToTopoDS_TranslateEdgeLoopDone;
done = Standard_True;
return;
}
Standard_Integer modepcurve = Interface_Static::IVal("read.surfacecurve.mode");
// 0,1 : suivre le code, 2 : ne prendre que pcurve, 3 : ne prendre que C3D
BRep_Builder B;
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
Standard_Real preci = Precision();
TopoDS_Wire W;
TopoDS_Edge E;
TopoDS_Vertex V;
// Standard_Real U1,U2, U1a, U1b, U2a, U2b;
Standard_Boolean isSeam, isLikeSeam;
Handle(StepShape_Edge) StepEdge, StepEdge1;
Handle(StepShape_OrientedEdge) OrEdge1, OrEdge2;
Handle(StepGeom_Curve) StepCurve, StepCurve1, StepCurve2;
// Handle(StepGeom_Pcurve) StepPCurve, StepPCurve1, StepPCurve2;
Handle(StepRepr_DefinitionalRepresentation) DRI, Dri1, Dri2;
Handle(Geom2d_Curve) C2d, C2d1, C2d2, WhichC2d1, WhichC2d2;
// unused gp_Pnt Pdeb, Pmil, Pfin, pV1, pV2;
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;
return;
}
// PTV 16.09.2000
// default value set as Standard_True (if not correct see logic of algorithm).
Standard_Boolean hasPcurve = Standard_True;
Standard_Boolean isPlane = GeomSurf->IsKind(STANDARD_TYPE(Geom_Plane));
Handle(Geom_Surface) ConvSurf = GeomSurf;
if (GeomSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
Handle(Geom_RectangularTrimmedSurface) theRTS =
Handle(Geom_RectangularTrimmedSurface)::DownCast(GeomSurf);
ConvSurf = theRTS->BasisSurface();
}
aTool.ComputePCurve(Standard_False);
// What is the Wire Orientation
Standard_Boolean ForwardWire = FaceBound->Orientation();
// --- Initialize target Wire ---
B.MakeWire(W);
// Standard_Integer lastpcurve = 0;
// -----------------------------------------------
// Preparation : Make Vertices + Curves3d
// Hence, a closed curve limited by distinct vertices
// will give a unique vertex (if same coords)
//
// In addition : detect shared PCurve (cf SYRKO)
// This case may not be processed, PCurves has to be recomputed from scratch
// -----------------------------------------------
// Standard_Integer theSame = 1; //gka 15.12.98
for (j=1; j<=NbEdge; j++ ) {
OrEdge1 = EL->EdgeListValue(j);
StepEdge = OrEdge1->EdgeElement();
// if(j>1 && StepEdge == StepEdge1) theSame++; //gka 15.12.98
StepEdge1 = StepEdge; //
Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(StepEdge);
Handle(StepGeom_Curve) C = EC->EdgeGeometry();
if (C->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve))) {
Handle(StepGeom_SurfaceCurve) Sc = Handle(StepGeom_SurfaceCurve)::DownCast(C);
C = Sc->Curve3d();
// if (modepcurve != 3) {
// lastpcurve = StepToTopoDS_GeometricTool::PCurve (Sc,StepSurf,StepPCurve1);
// if (StepPCurve1 == StepPCurve) modepcurve = -1;
// StepPCurve = StepPCurve1;
// }
}
//// else if (C->IsKind(STANDARD_TYPE(StepGeom_Polyline))) { }
// else if (C->IsKind(STANDARD_TYPE(StepGeom_Pcurve))) {
// if (modepcurve != 3) {
// if (C == StepPCurve) modepcurve = -1;
// StepPCurve = Handle(StepGeom_Pcurve)::DownCast(C);
// }
// }
Handle(Geom_Curve) C1;
if (!C.IsNull()) {
C1 = Handle(Geom_Curve)::DownCast (TP->FindTransient(C));
if (C1.IsNull()) {
if (StepToGeom_MakeCurve::Convert(C,C1))
TP->BindTransient (C,C1);
}
}
Handle(StepShape_Vertex) Vstart, Vend;
if (EC->SameSense()) {
Vstart = EC->EdgeStart();
Vend = EC->EdgeEnd();
}
else {
Vend = EC->EdgeStart();
Vstart = EC->EdgeEnd();
}
Standard_Boolean istV = aTool.IsBound(Vstart);
Standard_Boolean iseV = aTool.IsBound(Vend);
TopoDS_Vertex V1, V2;
StepToTopoDS_TranslateVertex myTranVertex1(Vstart, aTool, NMTool);
StepToTopoDS_TranslateVertex myTranVertex2(Vend, aTool, NMTool);
if (myTranVertex1.IsDone()) {
V1 = TopoDS::Vertex(myTranVertex1.Value());
}
// if (Vend == Vstart) { cas normal deja assure par aTool
// aTool.Bind (Vend,V1);
// }
// else
if (myTranVertex2.IsDone()) {
V2 = TopoDS::Vertex(myTranVertex2.Value());
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);
//Fixed = Standard_False;
//aTool.Bind (Vend,V1);
if (!C1.IsNull() && !C1->IsClosed() && Fixed)
TP->AddWarning(EL->EdgeListValue(j),
"Vertex of same coordinates, set confused");
}
}
}
// if (NbEdge!=1 && theSame == NbEdge) {
// TP->AddWarning(EL,"Wire was ignored. All edges are the same.");
// done = Standard_False;
// return;
// }
// Fixed=Standard_True;
// if (modepcurve == -1) {
// modepcurve = 3;
// TP->AddWarning(EL,"Shared Pcurve not allowed, Pcurves are recomputed");
// }
//:f6 abv 29 Apr 98: BUC50070 #3815: make sure that each two edges are
// connected by the same vertex; else check that vertices confuse
// 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 (j=1; j<=NbEdge; j++ ) {
OrEdge1 = EL->EdgeListValue ( j );
OrEdge2 = EL->EdgeListValue ( j < NbEdge ? j + 1 : 1 );
Handle(StepShape_EdgeCurve) EC1 =
Handle(StepShape_EdgeCurve)::DownCast ( OrEdge1->EdgeElement() );
Handle(StepShape_EdgeCurve) EC2 =
Handle(StepShape_EdgeCurve)::DownCast ( OrEdge2->EdgeElement() );
Handle(StepShape_Vertex) Vs1, Vs2,Vs11,Vs22;
Vs1 = ( OrEdge1->Orientation() ? EC1->EdgeEnd() : EC1->EdgeStart() );
Vs2 = ( OrEdge2->Orientation() ? EC2->EdgeStart() : EC2->EdgeEnd() );
Vs11 = ( OrEdge1->Orientation() ? EC1->EdgeStart() : EC1->EdgeEnd());
Vs22 = ( OrEdge2->Orientation() ? EC2->EdgeEnd() : EC2->EdgeStart() );
if((Vs1 == Vs2) || (Vs1 == Vs22) || (Vs2 == Vs11) || (Vs22 == Vs11)) continue;
//?? if ( Vs1.IsSame(Vs2) ) continue; // OK
StepToTopoDS_TranslateVertex myTranVertex1 (Vs1, aTool, NMTool);
StepToTopoDS_TranslateVertex myTranVertex2 (Vs2, aTool, NMTool);
TopoDS_Vertex V1, V2;
if ( myTranVertex1.IsDone() )
V1 = TopoDS::Vertex ( myTranVertex1.Value() );
if ( myTranVertex2.IsDone() )
V2 = TopoDS::Vertex ( myTranVertex2.Value() );
if ( V1.IsNull() || V2.IsNull() ) continue; // not treated
if ( V1.IsSame(V2) ) continue; // OK
gp_Pnt p1 = BRep_Tool::Pnt(V1);
gp_Pnt p2 = BRep_Tool::Pnt(V2);
Standard_Boolean locFixed = Standard_True;
if (p1.Distance(p2) <= preci) {
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;
if ( locFixed ) TP->AddWarning(EL,"Adjacent edges do not have common vertex; set confused");
else TP->AddWarning(EL,"Adjacent edges are not connected");
}
// -----------------------------------------------
// Iteration on each Oriented Edge of the EdgeLoop
// -----------------------------------------------
for (j=1; j<=NbEdge; j++ ) {
Standard_Boolean ThereIsLikeSeam = Standard_False;
#ifdef DEBUG
cout << " Processing Edge :" << j << endl;
#endif
OrEdge1 = EL->EdgeListValue(j);
StepEdge = OrEdge1->EdgeElement();
Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(StepEdge);
// ----------------
// Map the StepEdge
// ----------------
StepToTopoDS_TranslateEdge myTranEdge;
myTranEdge.SetPrecision(preci);
myTranEdge.SetMaxTol(MaxTol());
myTranEdge.Init(OrEdge1, aTool, NMTool);
if (myTranEdge.IsDone()) {
E = TopoDS::Edge(myTranEdge.Value());
if (E.IsNull()) continue; // NULL, on saute
Handle(StepGeom_Curve) C = EC->EdgeGeometry();
if (OrEdge1->Orientation() && EC->SameSense())
E.Orientation(TopAbs_FORWARD);
else if (!OrEdge1->Orientation() && !EC->SameSense())
E.Orientation(TopAbs_FORWARD);
else E.Orientation(TopAbs_REVERSED);
isSeam = isLikeSeam = Standard_False;
// ------------------------------------------
// Map the StepEdge parametric representation
// ------------------------------------------
// --------------------------------------------
// CASE 1 : The Edge Geometry is of Pcurve Type
// --------------------------------------------
if (C->IsKind(STANDARD_TYPE(StepGeom_Pcurve))) {
Handle(StepGeom_Pcurve) StepPCurve = Handle(StepGeom_Pcurve)::DownCast(C);
C2d = myTranEdge.MakePCurve (StepPCurve,ConvSurf);
// -- Statistics --
aTool.AddContinuity (C2d);
}
// -----------------------------------------
// CASE 2 : The curve is a SurfaceCurve i.e.
// - a 3D Curve (mandatory)
// - 2 PCurveOrSurface
// If modepcurve = 3, PCurve are ignored here
// -----------------------------------------
else if (modepcurve == 3) {
aTool.ComputePCurve(Standard_True);
hasPcurve = Standard_False;
}
else if (C->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve)) ) {
// recouvre les cas SeamCurve et IntersectionCurve
Handle(StepGeom_SurfaceCurve) SurfCurve =
Handle(StepGeom_SurfaceCurve)::DownCast(C);
Handle(StepGeom_Pcurve) StepPCurve, StepPCurve1, StepPCurve2;
Standard_Integer lastpcurve = StepToTopoDS_GeometricTool::PCurve(SurfCurve,StepSurf,StepPCurve,0);
hasPcurve = !StepPCurve.IsNull();
// De toute facon, on recalcule
if (isPlane) hasPcurve = Standard_False;
// -------------------------------------------
// --- Special Mapping Cases : ---
// --- the SurfaceCurve is a SeamCurve ---
// --- or is like a seam curve ---
// --- (see CATIA cylinder) ---
// -------------------------------------------
isLikeSeam = StepToTopoDS_GeometricTool::IsLikeSeam(SurfCurve,StepSurf,StepEdge,EL);
isSeam = StepToTopoDS_GeometricTool::IsSeamCurve(SurfCurve, StepSurf,StepEdge, EL);
if (isSeam || isLikeSeam) {
// isLikeSeam = Two faces on the same Surface
StepPCurve1 = SurfCurve->AssociatedGeometryValue(1).Pcurve();
StepPCurve2 = SurfCurve->AssociatedGeometryValue(2).Pcurve();
if (StepPCurve1.IsNull() || StepPCurve2.IsNull()) hasPcurve = Standard_False; //smh : BUC60810
else {
C2d1 = myTranEdge.MakePCurve (StepPCurve1,ConvSurf);
C2d2 = myTranEdge.MakePCurve (StepPCurve2,ConvSurf);
hasPcurve = (!C2d1.IsNull() && !C2d2.IsNull());
}
if (isLikeSeam) {
suspectE = E;
ThereIsLikeSeam = Standard_True;
hasPcurve = Standard_True;
}
}
else if (hasPcurve) {
// GeometricTool : Pcurve a retourne StepPCurve
while (lastpcurve > 0) {
C2d1 = myTranEdge.MakePCurve (StepPCurve,ConvSurf);
if (C2d1.IsNull()) {
hasPcurve = Standard_False;
break;
}
else C2d = C2d1;
lastpcurve = StepToTopoDS_GeometricTool::PCurve(SurfCurve,StepSurf,StepPCurve,lastpcurve);
// -- Statistics --
aTool.AddContinuity (C2d);
}
}
if (!hasPcurve) {
// The edge geometry has no 2D representation
aTool.ComputePCurve(Standard_True);
}
}
// ----------------------------------------------------------
// CASE 3 : The EdgeCurve Geometry is not a Pcurve
// nor a SurfaceCurve (i.e. it is a single 3D curve)
// ----------------------------------------------------------
else {
aTool.ComputePCurve(Standard_True);
hasPcurve = Standard_False;
}
// ----------------------------------
// update the edge with the pcurve(s)
// ----------------------------------
if (hasPcurve && (isSeam || ThereIsLikeSeam)) {
// -----------------------------------------------------------
// The Edge is a Seam Edge : The pcurve wich is FORWARD has to
// be identified
// -----------------------------------------------------------
if ((!C2d1.IsNull()) && (!C2d2.IsNull())) {
TopAbs_Orientation CumulO, EdgeO, WireO, FaceO;
EdgeO = E.Orientation();
if (ForwardWire) WireO = TopAbs_FORWARD;
else WireO = TopAbs_REVERSED;
if (sameSense) FaceO = TopAbs_FORWARD;
else FaceO = TopAbs_REVERSED;
CumulO = TopAbs::Compose(EdgeO, WireO);
CumulO = TopAbs::Compose(CumulO, FaceO);
Standard_Boolean ForwardEdge = (CumulO == TopAbs_FORWARD);
// if(!ThereIsLikeSeam) ForwardEdge = Standard_True;
Standard_Integer forwardPC =
ShapeAnalysis_Curve().SelectForwardSeam (C2d1,C2d2);
if (forwardPC == 0) {
TP->AddFail(StepEdge," Seam curve not mapped");
done = Standard_False;
myError = StepToTopoDS_TranslateEdgeLoopOther;
continue;
}
else if (!ForwardEdge) forwardPC = 3 - forwardPC; // inverser 1-2
if (forwardPC == 1) {
if(isSeam) {
// When the edge is a Seam, it is better to find the topological
// trimming right now.
// Remarque : pour bien faire, il faudrait, si necessaire, recalculer
// les trois courbes de maniere a ce qu`elles soient
// immediatement Same Range et Same Parameter.
B.UpdateEdge(E, C2d1, C2d2, Face, 0.);
//:S4136 FindParameter(C2d1, C2d2, E, Face, preci);
}
else
B.UpdateEdge(E, C2d1, Face, 0.); //preci
}
else {
if(isSeam) {
// When the edge is a Seam, it is better to find the topological
// trimming right now.
B.UpdateEdge(E, C2d2, C2d1, Face, 0.);
//:S4136 FindParameter(C2d1, C2d2, E, Face, preci);
}
else
B.UpdateEdge(E, C2d2, Face, 0.);
}
}
else {
TP->AddFail(StepEdge," Seam curve not mapped");
done = Standard_False;
myError = StepToTopoDS_TranslateEdgeLoopOther;
continue;
}
}
else {
// ---------------------------
// The Edge is a "normal" edge
// ---------------------------
if (hasPcurve) {
if ( !C2d.IsNull() && !isLikeSeam ) {
B.UpdateEdge(E, C2d, Face, 0.);
}
else {
TP->AddFail(StepEdge," Edge: Trimming of 2D curve failed");
// cout << "2D curve type : " << C2d->DynamicType() << endl;
done = Standard_False;
myError = StepToTopoDS_TranslateEdgeLoopOther;
continue;
}
}
}
if (!E.IsNull()) {
// B.Add(W,E); -- DABORD regarder degeneree manquante !!!
}
else {
TP->AddFail(StepEdge," an Edge not mapped");
done = Standard_False;
myError = StepToTopoDS_TranslateEdgeLoopOther;
// continue;
}
}
else { // The Edge is Not mapped => switch to next wire ?
TP->AddFail(StepEdge," an Edge not mapped");
done = Standard_False;
myError = StepToTopoDS_TranslateEdgeLoopOther;
// continue;
}
if (done) B.Add (W,E); // on le fait ici. Sauf si erreur rencontree ... !
else {
Handle(StepShape_Vertex) Vs1, Vs2;
Vs1 = StepEdge->EdgeStart();
Vs2 = StepEdge->EdgeEnd();
if(!Vs1.IsNull() && !Vs2.IsNull() && Vs1==Vs2) {
done = Standard_True;
TP->AddFail(EL," Edge with equal vertices failed, scipped");
}
}
}
// The EdgeLoop is binded in the Wire
if (!done) {
TP->AddFail(EL,"At least one edge failed : wire not done");
return;
}
aTool.Bind(EL, W);
// ----------------------------------------------
// Computes the 2D parameter of Vertices on Edges
// ----------------------------------------------
//pdn compute parameter of Vertices using progecting
if (!aTool.ComputePCurve())
for (TopoDS_Iterator EdgeIt(W);EdgeIt.More();EdgeIt.Next()){
TopoDS_Edge edge = TopoDS::Edge(EdgeIt.Value());
Handle(ShapeFix_EdgeProjAux) myEdgePro = ShapeAlgo::AlgoContainer()->ToolContainer()->EdgeProjAux();
myEdgePro->Init (Face, edge);
myEdgePro->Compute(preci);
if (myEdgePro->IsFirstDone() && myEdgePro->IsLastDone()) {
B.Range(edge, Face,myEdgePro->FirstParam(), myEdgePro->LastParam());
}
else {
RemoveSinglePCurve(edge, Face);
#ifdef DEBUG
cout <<"Removing after prj"<<endl;
#endif
}
}
myResult = W;
myError = StepToTopoDS_TranslateEdgeLoopDone;
done = Standard_True;
// Check des PCurves SYSTEMATIQUE, s il n y en a que quelques unes
// if (isPlane) RemovePCurves (W, Face);
// else CheckPCurves (W, Face);
CheckPCurves (W, Face,isPlane,preci);
// --------------------------------------------
// Control the UVLoop (Closed and Head To Tail)
// --------------------------------------------
// StepToTopoDS_GeometricToolError tError =
// StepToTopoDS_GeometricTool::CloseUV(W, Face, aTool);
// if(tError != StepToTopoDS_GeometricToolDone) {
// TP->AddWarning(StepEdge,StepToTopoDS::DecodeGeometricToolError(tError));
// }
return;
}
// ============================================================================
// Method : Value
// Purpose : Return the mapped Shape
// ============================================================================
const TopoDS_Shape& StepToTopoDS_TranslateEdgeLoop::Value() const
{
StdFail_NotDone_Raise_if(!done,"");
return myResult;
}
// ============================================================================
// Method : Error
// Purpose : Return the TranslateEdgeLoop error
// ============================================================================
StepToTopoDS_TranslateEdgeLoopError StepToTopoDS_TranslateEdgeLoop::Error() const
{
return myError;
}

View File

@@ -0,0 +1,50 @@
-- File: StepToTopoDS_TranslateFace.cdl
-- Created: Fri Dec 16 14:47:08 1994
-- Author: Frederic MAUPAS
-- <fma@stylox>
---Copyright: Matra Datavision 1994
class TranslateFace from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose:
--
uses
FaceSurface from StepShape,
Tool from StepToTopoDS,
TranslateFaceError from StepToTopoDS,
Shape from TopoDS,
NMTool from StepToTopoDS
raises NotDone from StdFail
is
Create returns TranslateFace;
Create (FS : FaceSurface from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS)
returns TranslateFace;
Init (me : in out;
FS : FaceSurface from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS);
Value (me) returns Shape from TopoDS
raises NotDone
is static;
---C++: return const &
Error (me) returns TranslateFaceError from StepToTopoDS;
fields
myError : TranslateFaceError from StepToTopoDS;
myResult : Shape from TopoDS;
end TranslateFace;

View File

@@ -0,0 +1,398 @@
// File: StepToTopoDS_TranslateFace.cxx
// Created: Tue Jan 3 13:55:11 1995
// Author: Frederic MAUPAS
// <fma@stylox>
// pdn 30.11.98: fixes improved
// pdn 20.12.98: to keep pcurves
// pdn 28.12.98: PRO10366 shifting pcurve between two singularities
//:p4 abv, pdn 23.02.99: PRO9234 #15720: call BRepTools::Update() for faces
//:q7 abv 23.03.99: bm4_al_eye.stp #53710: remove pseudo-seams
// rln 31.03.99 S4135: prohibit fixing intersection of non-adjacent edges (temporarily)
//#4 szv S4163: optimization
//%19 pdn 17.04.99 using ShapeFix_Wire::FixEdgeCurves instead of ShapeFix_PCurves
// smh 31.01.01 Bad data in file : case of vertex loop on plane face
// sln 01.10.2001 BUC61003. StepToTopoDS_TranslateFace::Init function is corrected (verifying Handle(...).IsNull() is added)
#include <StepToTopoDS_TranslateFace.ixx>
#include <StepToTopoDS.hxx>
#include <StepToGeom_MakeSurface.hxx>
#include <StepToTopoDS_TranslateVertexLoop.hxx>
#include <StepToTopoDS_TranslatePolyLoop.hxx>
#include <StepToTopoDS_TranslateEdgeLoop.hxx>
#include <StepShape_EdgeCurve.hxx>
#include <StepShape_VertexLoop.hxx>
#include <StepShape_EdgeLoop.hxx>
#include <StepShape_PolyLoop.hxx>
#include <StepGeom_Surface.hxx>
#include <StepShape_FaceBound.hxx>
#include <StepShape_FaceOuterBound.hxx>
#include <StepShape_OrientedEdge.hxx>
#include <StepShape_Edge.hxx>
//#3 rln 16/02/98
#include <BRep_TEdge.hxx>
#include <BRep_TVertex.hxx>
#include <Geom_BoundedSurface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <GeomAbs_Shape.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAdaptor_HSurface.hxx>
//#include <GeomAdaptor_Curve.hxx>
//#include <GeomAdaptor_CurveOnSurface.hxx>
#include <Geom2d_Curve.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>//#3 rln 16/02/98
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>//rln 28/01/98
#include <TopoDS_Wire.hxx>
#include <BRepTools.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRep_Builder.hxx>//rln 28/01/98
#include <BRep_Tool.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Precision.hxx>
// Provisoire, pour VertexLoop
#include <Geom_SphericalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <StepGeom_OffsetSurface.hxx> //:d4
#include <StepGeom_BSplineSurfaceForm.hxx>
#include <StepGeom_BSplineSurface.hxx>
#include <ShapeAlgo.hxx>
#include <ShapeAlgo_AlgoContainer.hxx>
#include <TopoDS_Iterator.hxx>
// To proceed with I-DEAS-like STP (ssv; 15.11.2010)
#include <TCollection_HAsciiString.hxx>
//#define DEBUG
// ============================================================================
// Method : StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace
// Purpose : Empty Constructor
// ============================================================================
StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace()
{
done = Standard_False;
}
// ============================================================================
// Method : StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace
// Purpose : Constructor with a FaceSurface and a Tool
// ============================================================================
StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace
(const Handle(StepShape_FaceSurface)& FS, StepToTopoDS_Tool& T, StepToTopoDS_NMTool& NMTool)
{
Init(FS, T, NMTool);
}
// ============================================================================
// Method : Init
// Purpose : Init with a FaceSurface and a Tool
// ============================================================================
void StepToTopoDS_TranslateFace::Init
(const Handle(StepShape_FaceSurface)& FS, StepToTopoDS_Tool& aTool, StepToTopoDS_NMTool& NMTool)
{
done = Standard_True;
if (aTool.IsBound(FS)) {
myResult = TopoDS::Face(aTool.Find(FS));
myError = StepToTopoDS_TranslateFaceDone;
done = Standard_True;
return;
}
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
// ----------------------------------------------
// Map the Face Geometry and create a TopoDS_Face
// ----------------------------------------------
Handle(StepGeom_Surface) StepSurf = FS->FaceGeometry();
// sln 01.10.2001 BUC61003. If corresponding entity was read with error StepSurface may be NULL. In this case we exit from function
if ( StepSurf.IsNull() ) {
TP->AddFail(StepSurf," Surface has not been created");
myError = StepToTopoDS_TranslateFaceOther;
done = Standard_False;
return;
}
// [BEGIN] Added to process non-manifold topology (ssv; 14.11.2010)
if ( NMTool.IsActive() && NMTool.IsBound(StepSurf) ) {
TopoDS_Shape existingShape = NMTool.Find(StepSurf);
// Reverse shape's orientation for the next shell
existingShape.Reverse();
myResult = existingShape;
myError = StepToTopoDS_TranslateFaceDone;
done = Standard_True;
return;
}
// [END] Added to process non-manifold topology (ssv; 14.11.2010)
if (StepSurf->IsKind(STANDARD_TYPE(StepGeom_OffsetSurface))) //:d4 abv 12 Mar 98
TP->AddWarning(StepSurf," Type OffsetSurface is out of scope of AP 214");
Handle(Geom_Surface) GeomSurf;
if (!StepToGeom_MakeSurface::Convert(StepSurf,GeomSurf))
{
TP->AddFail(StepSurf," Surface has not been created");
myError = StepToTopoDS_TranslateFaceOther;
done = Standard_False;
return;
}
// pdn to force bsplsurf to be periodic
Handle(StepGeom_BSplineSurface) sgbss = Handle(StepGeom_BSplineSurface)::DownCast(StepSurf);
if (!sgbss.IsNull()) {
/*
StepGeom_BSplineSurfaceForm form = sgbss->SurfaceForm();
if ((form == StepGeom_bssfCylindricalSurf)||
(form == StepGeom_bssfConicalSurf)||
(form == StepGeom_bssfSphericalSurf)||
(form == StepGeom_bssfToroidalSurf)||
(form == StepGeom_bssfSurfOfRevolution)||
(form == StepGeom_bssfGeneralisedCone)||
(form == StepGeom_bssfUnspecified))
*/
{
Handle(Geom_Surface) periodicSurf = ShapeAlgo::AlgoContainer()->ConvertToPeriodic (GeomSurf);
if(!periodicSurf.IsNull()) {
TP->AddWarning(StepSurf,"Surface forced to be periodic");
GeomSurf = periodicSurf;
}
}
}
Standard_Boolean sameSense = FS->SameSense();
// -- Statistics --
aTool.AddContinuity (GeomSurf);
TopoDS_Face F;
BRep_Builder B;
B.MakeFace ( F, GeomSurf, Precision::Confusion() );
// ----------------------------------
// Iterate on each FaceBounds (Wires)
// ----------------------------------
Handle(StepShape_FaceBound) FaceBound;
Handle(StepShape_Loop) Loop;
StepToTopoDS_TranslateVertexLoop myTranVL;
StepToTopoDS_TranslatePolyLoop myTranPL;
StepToTopoDS_TranslateEdgeLoop myTranEdgeLoop;
Standard_Integer NbBnd = FS->NbBounds();
// -- Critere de couture simple (CKY, JAN97)
// surface periodique (typiquement un cylindre)
// 2 face bounds, chacun avec un edge loop d une seule edge
// cette edge est fermee, c-a-d vtx-deb = vtx-fin (pour les deux edges)
// est-ce suffisant (verifier que ce sont deux outer-bounds ... ?? comment ?)
// Alors on peut dire : face a deux bords dont la couture manque
// La couture est entre les deux vertex
// TopoDS_Wire W1,W2;
// Standard_Boolean fautcoudre =
// ( (NbBnd == 2) && (GeomSurf->IsUClosed() || GeomSurf->IsVClosed()) );
for (Standard_Integer i = 1; i <= NbBnd; i ++) {
#ifdef DEBUG
cout << " Processing Wire : " << i << endl;
#endif
FaceBound = FS->BoundsValue(i);
Loop = FaceBound->Bound();
// ------------------------
// The Loop is a VertexLoop
// ------------------------
if (Loop->IsKind(STANDARD_TYPE(StepShape_VertexLoop))) {
//:S4136 STF.Closed() = Standard_False;
// PROBLEME si SPHERE ou TORE
// Il faudra faire un wire complet, a condition que le point porte sur la face
// En attendant, on ne fait rien
Handle(StepShape_VertexLoop) VL = Handle(StepShape_VertexLoop)::DownCast(Loop);
// abv 10.07.00 pr1sy.stp: vertex_loop can be wrong; so just make natural bounds
if (GeomSurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
BRepBuilderAPI_MakeFace mf (GeomSurf);
for (TopoDS_Iterator it(mf); it.More(); it.Next() )
B.Add ( F, it.Value() );
continue;
}
if (//GeomSurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ||
GeomSurf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) ) {
// TP->AddWarning(VL," VertexLoop on Cone or Torus NOT YET IMPLEMENTED");
continue;
}
if (GeomSurf->IsKind(STANDARD_TYPE(Geom_Plane)) ) {
TP->AddWarning(VL,"VertexLoop on plane is ignored");
continue; //smh : BUC60809
}
myTranVL.SetPrecision(Precision());//gka
myTranVL.SetMaxTol(MaxTol());
myTranVL.Init(VL, aTool, NMTool);
if (myTranVL.IsDone()) {
B.Add ( F, myTranVL.Value() );
}
else {
TP->AddWarning(VL," a VertexLoop not mapped to TopoDS");
}
}
// ----------------------
// The Loop is a PolyLoop
// ----------------------
else if (Loop->IsKind(STANDARD_TYPE(StepShape_PolyLoop))) {
//:S4136 STF.Closed() = Standard_False;
Handle(StepShape_PolyLoop) PL = Handle(StepShape_PolyLoop)::DownCast(Loop);
F.Orientation ( FS->SameSense() ? TopAbs_FORWARD : TopAbs_REVERSED);
myTranPL.SetPrecision(Precision()); //gka
myTranPL.SetMaxTol(MaxTol());
myTranPL.Init(PL, aTool, GeomSurf, F);
if (myTranPL.IsDone()) {
TopoDS_Wire W = TopoDS::Wire(myTranPL.Value());
W.Orientation ( FaceBound->Orientation() ? TopAbs_FORWARD : TopAbs_REVERSED);
B.Add ( F, W );
}
else {
TP->AddWarning(PL," a PolyLoop not mapped to TopoDS");
}
}
// -----------------------
// The Loop is an EdgeLoop
// -----------------------
else if (Loop->IsKind(STANDARD_TYPE(StepShape_EdgeLoop))) {
//:S4136 if (STF.Closed()) {
//:S4136 Handle(StepShape_EdgeLoop) EL =
//:S4136 Handle(StepShape_EdgeLoop)::DownCast(FaceBound->Bound());
//:S4136 if (EL->NbEdgeList() != 1) STF.Closed() = Standard_False;
//:S4136 }
TopoDS_Wire W;
myTranEdgeLoop.SetPrecision(Precision()); //gka
myTranEdgeLoop.SetMaxTol(MaxTol());
myTranEdgeLoop.Init(FaceBound, F, GeomSurf, StepSurf, sameSense, aTool, NMTool);
if (myTranEdgeLoop.IsDone()) {
W = TopoDS::Wire(myTranEdgeLoop.Value());
// STEP Face_Surface orientation :
// if the topological orientation is opposite to the geometric
// orientation of the surface => the underlying topological
// orientation are not implicitly reversed
// this is the case in CAS.CADE => If the face_surface is reversed,
// the wire orientation has to be explictly reversed
if (FaceBound->Orientation()) {
// *DTH* if (sameSense || GeomSurf->IsKind(STANDARD_TYPE(Geom_Plane)))
W.Orientation (sameSense ? TopAbs_FORWARD : TopAbs_REVERSED);
}
else {
// *DTH* if (sameSense || GeomSurf->IsKind(STANDARD_TYPE(Geom_Plane)))
W.Orientation (sameSense ? TopAbs_REVERSED : TopAbs_FORWARD);
}
// -----------------------------
// The Wire is added to the Face
// -----------------------------
B.Add ( F, W );
}
else {
// Il y a eu un probleme dans le mapping : On perd la Face
// (facon de parler ...) Pas de moyen aujourd hui de recuperer
// au moins toutes les geometries (Points, Courbes 3D, Surface)
TP->AddFail(Loop," EdgeLoop not mapped to TopoDS");
//if(GeomSurf->IsKind(STANDARD_TYPE(Geom_BoundedSurface))) {
//Standard_Real su1, sv1, su2, sv2;
//GeomSurf->Bounds(su1, su2, sv1, sv2);
//if(sv1 == -Precision::Infinite()) sv1 = 0.;
//if(sv2 == Precision::Infinite()) sv2 = 1.;
//BRepBuilderAPI_MakeFace mkf(GeomSurf,su1,su2,sv1,sv2);
//if (mkf.IsDone()) {
// done shall be standard false but no recipient to
// to store uncompletally mapped topology
// see Improvment Resquest DPA/126/95
//myResult = mkf.Face();
//done = Standard_True;
//}
//}
// CKY JAN-97 : un Wire manque, eh bien on continue quand meme !!
// sauf si OuterBound : la c est quand meme pas bien normal ...
if (FaceBound->IsKind(STANDARD_TYPE(StepShape_FaceOuterBound))) {
TP->AddWarning(FS,"No Outer Bound : Face not done");
// return;
}
continue;
// myError = StepToTopoDS_TranslateFaceOther;
// done = Standard_False;
// return;
}
}
else {
// Type not yet implemented or non sens
TP->AddFail(Loop," Type of loop not yet implemented");
#ifdef DEBUG
cout << Loop->DynamicType() << endl;
#endif
continue;
// done = Standard_False;
// myError = StepToTopoDS_TranslateFaceOther;
// return;
}
}
F.Orientation ( FS->SameSense() ? TopAbs_FORWARD : TopAbs_REVERSED);
aTool.Bind(FS,F);
// Register face in NM tool (ssv; 14.11.2010)
if ( NMTool.IsActive() )
NMTool.Bind(StepSurf, F);
myResult = F;
myError = StepToTopoDS_TranslateFaceDone;
done = Standard_True;
}
// ============================================================================
// Method : Value
// Purpose : Return the mapped Shape
// ============================================================================
const TopoDS_Shape& StepToTopoDS_TranslateFace::Value() const
{
StdFail_NotDone_Raise_if(!done,"");
return myResult;
}
// ============================================================================
// Method : Error
// Purpose : Return the TranslateFace error
// ============================================================================
StepToTopoDS_TranslateFaceError StepToTopoDS_TranslateFace::Error() const
{
return myError;
}

View File

@@ -0,0 +1,53 @@
-- File: StepToTopoDS_TranslatePolyLoop.cdl
-- Created: Fri Dec 16 14:49:27 1994
-- Author: Frederic MAUPAS
-- <fma@stylox>
---Copyright: Matra Datavision 1994
class TranslatePolyLoop from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose:
--
uses
PolyLoop from StepShape,
TranslatePolyLoopError from StepToTopoDS,
Tool from StepToTopoDS,
Surface from Geom,
Face from TopoDS,
Shape from TopoDS
raises NotDone from StdFail
is
Create returns TranslatePolyLoop;
Create (PL : PolyLoop from StepShape;
T : in out Tool from StepToTopoDS;
S : Surface from Geom;
F : Face from TopoDS)
returns TranslatePolyLoop;
Init (me : in out;
PL : PolyLoop from StepShape;
T : in out Tool from StepToTopoDS;
S : Surface from Geom;
F : Face from TopoDS);
Value (me) returns Shape from TopoDS
raises NotDone
is static;
---C++: return const &
Error (me) returns TranslatePolyLoopError from StepToTopoDS;
fields
myError : TranslatePolyLoopError from StepToTopoDS;
myResult : Shape from TopoDS;
end TranslatePolyLoop;

View File

@@ -0,0 +1,192 @@
// File: StepToTopoDS_TranslatePolyLoop.cxx
// Created: Tue Jan 3 13:58:54 1995
// Author: Frederic MAUPAS
// <fma@stylox>
//gka,abv 14.09.99: S4136: eliminate BRepAPI::Precision()
#include <StepToTopoDS_TranslatePolyLoop.ixx>
#include <StepToTopoDS_PointPair.hxx>
#include <StepToGeom_MakeCartesianPoint.hxx>
#include <BRep_Builder.hxx>
//#include <BRepAPI.hxx>
#include <ElSLib.hxx>
#include <ShapeAnalysis_Surface.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <Geom2d_Line.hxx>
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Geom_CartesianPoint.hxx>
#include <gp_Vec2d.hxx>
#include <StepGeom_HArray1OfCartesianPoint.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Precision.hxx>
// ============================================================================
// Method :
// Purpose :
// ============================================================================
StepToTopoDS_TranslatePolyLoop::StepToTopoDS_TranslatePolyLoop()
{
done = Standard_False;
}
// ============================================================================
// Method :
// Purpose :
// ============================================================================
StepToTopoDS_TranslatePolyLoop::StepToTopoDS_TranslatePolyLoop(const Handle(StepShape_PolyLoop)& PL, StepToTopoDS_Tool& T, const Handle(Geom_Surface)& S, const TopoDS_Face& F)
{
Init (PL, T, S, F);
}
// ============================================================================
// Method :
// Purpose :
// ============================================================================
void StepToTopoDS_TranslatePolyLoop::Init(const Handle(StepShape_PolyLoop)& PL, StepToTopoDS_Tool& aTool, const Handle(Geom_Surface)& GeomSurf, const TopoDS_Face& TopoFace)
{
if (!aTool.IsBound(PL)) {
BRep_Builder B;
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
//:S4136 Standard_Real preci = BRepAPI::Precision();
Standard_Integer i;
Handle(StepGeom_CartesianPoint) P1,P2;
Handle(Geom_CartesianPoint) GP1, GP2;
TopoDS_Vertex V1, V2;
TopoDS_Edge E;
TopoDS_Wire W;
Handle(Geom_Line) L;
Handle(Geom2d_Line) L2d;
gp_Vec V;
gp_Vec2d V2d;
Standard_Real Magn;
Handle(Geom_Plane) SP = Handle(Geom_Plane)::DownCast(GeomSurf);
if (SP.IsNull()) TP->AddFail(PL,"Surface not planar in a FacetedBRep !");
Handle(ShapeAnalysis_Surface) STSU = new ShapeAnalysis_Surface ( GeomSurf );
Standard_Integer Nb = PL->NbPolygon();
Handle(StepGeom_HArray1OfCartesianPoint) Poly =
new StepGeom_HArray1OfCartesianPoint(1, Nb+1);
for ( i=1; i<=Nb; i++ )
Poly->SetValue(i, PL->PolygonValue(i));
Nb++;
Poly->SetValue(Nb, PL->PolygonValue(1));
P1 = Poly->Value(1);
StepToGeom_MakeCartesianPoint::Convert(P1,GP1);
if (aTool.IsVertexBound(P1)) {
V1 = aTool.FindVertex(P1);
}
else {
B.MakeVertex(V1, GP1->Pnt(), Precision::Confusion()); //:S4136: preci
aTool.BindVertex(P1,V1);
}
B.MakeWire(W);
for ( i=2; i<=Nb; i++){
P2 = Poly->Value(i);
if (P1 == P2) continue; // peut arriver (KK) CKY 9-DEC-1997
StepToTopoDS_PointPair PP(P1, P2);
StepToGeom_MakeCartesianPoint::Convert(P2,GP2);
TopoDS_Shape aBoundEdge;
Standard_Boolean isbound = aTool.IsEdgeBound(PP);
if ( !isbound) {
if (aTool.IsVertexBound(P2)) {
V2 = aTool.FindVertex(P2);
}
else {
B.MakeVertex(V2, GP2->Pnt(), Precision::Confusion()); //:S4136: preci
aTool.BindVertex(P2,V2);
}
V = gp_Vec( GP1->Pnt(), GP2->Pnt());
L = new Geom_Line( GP1->Pnt() , gp_Dir(V) );
B.MakeEdge(E, L, Precision::Confusion()); //:S4136: preci
V1.Orientation(TopAbs_FORWARD);
V2.Orientation(TopAbs_REVERSED);
B.Add(E, V1);
B.Add(E, V2);
Magn = V.Magnitude();
B.UpdateVertex(V1, 0., E, 0. ); //:S4136: preci
B.UpdateVertex(V2, Magn, E, 0. ); //:S4136: preci
}
else {
aBoundEdge = aTool.FindEdge(PP);
E = TopoDS::Edge(aBoundEdge);
// Il faut qu en finale l edge soit vue
// - via sa premiere face, orientation combinee = celle de cette premiere face
// - via sa deuxieme face, orientation combinee INVERSE de la precedente
if (TopoFace.Orientation() == TopAbs_FORWARD) E.Reverse();
V2 = aTool.FindVertex(P2);
// Standard_Real u1,v1,u2,v2;
// ElSLib::Parameters(SP->Pln(), GP1->Pnt(), u1, v1);
// ElSLib::Parameters(SP->Pln(), GP2->Pnt(), u2, v2);
// V2d = gp_Vec2d( gp_Pnt2d(u1,v1), gp_Pnt2d(u2,v2) );
// L2d = new Geom2d_Line( gp_Pnt2d(u1,v1), gp_Dir2d(V2d) );
}
gp_Pnt2d V2p1 = STSU->ValueOfUV (GP1->Pnt(), Precision());
gp_Pnt2d V2p2 = STSU->ValueOfUV (GP2->Pnt(), Precision());
if (E.Orientation() == TopAbs_FORWARD) {
V2d = gp_Vec2d( V2p1, V2p2 );
L2d = new Geom2d_Line( V2p1, gp_Dir2d(V2d) );
} else {
V2d = gp_Vec2d( V2p2, V2p1 );
L2d = new Geom2d_Line( V2p2, gp_Dir2d(V2d) );
}
B.UpdateEdge(E, L2d, TopoFace, 0.);
// E.Orientation(TopAbs_FORWARD);
TopoDS_Edge EB = E; // pour le binding : cumul des orientations !
EB.Orientation (TopoFace.Orientation());
if (!isbound) aTool.BindEdge(PP, EB);
if (!E.IsNull()) {
B.Add(W,E);
}
P1 = P2;
GP1 = GP2;
V1 = V2;
}
aTool.Bind(PL, W);
myResult = W;
myError = StepToTopoDS_TranslatePolyLoopDone;
done = Standard_True;
}
else {
myResult = TopoDS::Wire(aTool.Find(PL));
myError = StepToTopoDS_TranslatePolyLoopDone;
done = Standard_True;
}
}
// ============================================================================
// Method :
// Purpose :
// ============================================================================
const TopoDS_Shape& StepToTopoDS_TranslatePolyLoop::Value() const
{
StdFail_NotDone_Raise_if(!done,"");
return myResult;
}
// ============================================================================
// Method :
// Purpose :
// ============================================================================
StepToTopoDS_TranslatePolyLoopError StepToTopoDS_TranslatePolyLoop::Error() const
{
return myError;
}

View File

@@ -0,0 +1,50 @@
-- File: StepToTopoDS_TranslateShell.cdl
-- Created: Fri Dec 16 14:46:06 1994
-- Author: Frederic MAUPAS
-- <fma@stylox>
---Copyright: Matra Datavision 1994
class TranslateShell from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose:
--
uses
Shape from TopoDS,
TranslateShellError from StepToTopoDS,
Tool from StepToTopoDS,
ConnectedFaceSet from StepShape,
NMTool from StepToTopoDS
raises NotDone from StdFail
is
Create returns TranslateShell;
Create (CFS : ConnectedFaceSet from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS)
returns TranslateShell;
Init (me : in out;
CFS : ConnectedFaceSet from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS);
Value (me) returns Shape from TopoDS
raises NotDone
is static;
---C++: return const &
Error (me) returns TranslateShellError from StepToTopoDS;
fields
myError : TranslateShellError from StepToTopoDS;
myResult : Shape from TopoDS;
end TranslateShell;

View File

@@ -0,0 +1,122 @@
// File: StepToTopoDS_TranslateShell.cxx
// Created: Tue Jan 3 14:01:53 1995
// Author: Frederic MAUPAS
// <fma@stylox>
//: gka 09.04.99: S4136: improving tolerance management
#include <StepToTopoDS_TranslateShell.ixx>
#include <StepToTopoDS_TranslateFace.hxx>
#include <StepShape_FaceSurface.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Face.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Message_ProgressIndicator.hxx>
#include <Message_ProgressSentry.hxx>
// ============================================================================
// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
// Purpose : Empty Constructor
// ============================================================================
StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
{
done = Standard_False;
}
// ============================================================================
// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
// Purpose : Constructor with a ConnectedFaceSet and a Tool
// ============================================================================
StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& T, StepToTopoDS_NMTool& NMTool)
{
Init(CFS, T, NMTool);
}
// ============================================================================
// Method : Init
// Purpose : Init with a ConnectedFaceSet and a Tool
// ============================================================================
void StepToTopoDS_TranslateShell::Init
(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& aTool, StepToTopoDS_NMTool& NMTool)
{
if (!aTool.IsBound(CFS)) {
BRep_Builder B;
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
Standard_Integer NbFc = CFS->NbCfsFaces();
TopoDS_Shell Sh;
B.MakeShell(Sh);
TopoDS_Face F;
TopoDS_Shape S;
Handle(StepShape_Face) StepFace;
StepToTopoDS_TranslateFace myTranFace;
myTranFace.SetPrecision(Precision()); //gka
myTranFace.SetMaxTol(MaxTol());
Message_ProgressSentry PS ( TP->GetProgress(), "Face", 0, NbFc, 1 );
for (Standard_Integer i=1; i<=NbFc && PS.More(); i++, PS.Next()) {
#ifdef DEBUG
cout << "Processing Face : " << i << endl;
#endif
StepFace = CFS->CfsFacesValue(i);
Handle(StepShape_FaceSurface) theFS =
Handle(StepShape_FaceSurface)::DownCast(StepFace);
if (!theFS.IsNull()) {
myTranFace.Init(theFS, aTool, NMTool);
if (myTranFace.IsDone()) {
S = myTranFace.Value();
F = TopoDS::Face(S);
B.Add(Sh, F);
}
else { // Warning only + add FaceSurface file Identifier
TP->AddWarning(theFS," a Face from Shell not mapped to TopoDS");
}
}
else { // Warning : ajouter identifier
TP->AddWarning(StepFace," Face is not of FaceSurface Type; not mapped to TopoDS");
}
}
myResult = Sh;
aTool.Bind(CFS, myResult);
myError = StepToTopoDS_TranslateShellDone;
done = Standard_True;
}
else {
myResult = TopoDS::Shell(aTool.Find(CFS));
myError = StepToTopoDS_TranslateShellDone;
done = Standard_True;
}
}
// ============================================================================
// Method : Value
// Purpose : Return the mapped Shape
// ============================================================================
const TopoDS_Shape& StepToTopoDS_TranslateShell::Value() const
{
StdFail_NotDone_Raise_if(!done,"");
return myResult;
}
// ============================================================================
// Method : Error
// Purpose : Return the TranslateShell Error code
// ============================================================================
StepToTopoDS_TranslateShellError StepToTopoDS_TranslateShell::Error() const
{
return myError;
}

View File

@@ -0,0 +1,50 @@
-- File: StepToTopoDS_TranslateVertex.cdl
-- Created: Fri Dec 16 14:48:28 1994
-- Author: Frederic MAUPAS
-- <fma@stylox>
---Copyright: Matra Datavision 1994
class TranslateVertex from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose:
--
uses
Vertex from StepShape,
TranslateVertexError from StepToTopoDS,
Tool from StepToTopoDS,
Shape from TopoDS,
NMTool from StepToTopoDS
raises NotDone from StdFail
is
Create returns TranslateVertex;
Create (V : Vertex from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS)
returns TranslateVertex;
Init (me : in out;
V : Vertex from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS);
Value (me) returns Shape from TopoDS
raises NotDone
is static;
---C++: return const &
Error (me) returns TranslateVertexError from StepToTopoDS;
fields
myError : TranslateVertexError from StepToTopoDS;
myResult : Shape from TopoDS;
end TranslateVertex;

View File

@@ -0,0 +1,125 @@
// File: StepToTopoDS_TranslateVertex.cxx
// Created: Tue Jan 3 15:00:17 1995
// Author: Frederic MAUPAS
// <fma@stylox>
//: gka 09.04.99: S4136: eliminate BRepAPI::Precision()
#include <StepToTopoDS_TranslateVertex.ixx>
#include <StepToGeom_MakeCartesianPoint.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRep_Builder.hxx>
//#include <BRepAPI.hxx>
#include <StepGeom_Point.hxx>
#include <StepGeom_CartesianPoint.hxx>
#include <StepShape_VertexPoint.hxx>
#include <StepShape_Vertex.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Precision.hxx>
// For I-DEAS-like processing (ssv; 15.11.2010)
#include <TCollection_HAsciiString.hxx>
// ============================================================================
// Method : StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex
// Purpose : Empty Constructor
// ============================================================================
StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex()
{
done = Standard_False;
}
// ============================================================================
// Method : StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex
// Purpose : Constructor with a Vertex and a Tool
// ============================================================================
StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex(const Handle(StepShape_Vertex)& V,
StepToTopoDS_Tool& T,
StepToTopoDS_NMTool& NMTool)
{
Init(V, T, NMTool);
}
// ============================================================================
// Method : Init
// Purpose : Init with a Vertex and a Tool
// ============================================================================
void StepToTopoDS_TranslateVertex::Init(const Handle(StepShape_Vertex)& aVertex,
StepToTopoDS_Tool& aTool,
StepToTopoDS_NMTool& NMTool)
{
if (!aTool.IsBound(aVertex)) {
// [BEGIN] Proceed with non-manifold topology (ssv; 14.11.2010)
if ( NMTool.IsActive() && NMTool.IsBound(aVertex) ) {
myResult = NMTool.Find(aVertex);
myError = StepToTopoDS_TranslateVertexDone;
done = Standard_True;
return;
}
// [END] Proceed with non-manifold topology (ssv; 14.11.2010)
// [BEGIN] Proceed with I-DEAS-like STP (ssv; 15.11.2010)
const Handle(TCollection_HAsciiString) aVName = aVertex->Name();
if ( NMTool.IsActive() && NMTool.IsIDEASCase() &&
!aVName.IsNull() && !aVName->IsEmpty() && NMTool.IsBound(aVName->String()) ) {
myResult = NMTool.Find(aVName->String());
myError = StepToTopoDS_TranslateVertexDone;
done = Standard_True;
return;
}
// [END] Proceed with I-DEAS-like STP (ssv; 15.11.2010)
//:S4136 Standard_Real preci = BRepAPI::Precision();
const Handle(StepShape_VertexPoint) VP = Handle(StepShape_VertexPoint)::DownCast(aVertex);
const Handle(StepGeom_Point) P = VP->VertexGeometry();
const Handle(StepGeom_CartesianPoint) P1 = Handle(StepGeom_CartesianPoint)::DownCast(P);
Handle(Geom_CartesianPoint) P2;
StepToGeom_MakeCartesianPoint::Convert(P1,P2);
BRep_Builder B;
TopoDS_Vertex V;
B.MakeVertex(V, P2->Pnt(), Precision::Confusion()); //:S4136: preci
aTool.Bind(aVertex,V);
// Register Vertex in NM tool (ssv; 14.11.2010)
if ( NMTool.IsActive() ) {
NMTool.Bind(aVertex, V);
if ( NMTool.IsIDEASCase() && !aVName.IsNull() && !aVName->IsEmpty() )
NMTool.Bind(aVName->String(), V);
}
myResult = V;
}
else {
myResult = TopoDS::Vertex(aTool.Find(aVertex));
}
myError = StepToTopoDS_TranslateVertexDone;
done = Standard_True;
}
// ============================================================================
// Method : Value
// Purpose : Return the mapped Shape
// ============================================================================
const TopoDS_Shape& StepToTopoDS_TranslateVertex::Value() const
{
StdFail_NotDone_Raise_if(!done,"");
return myResult;
}
// ============================================================================
// Method : Error
// Purpose : Return the TranslateVertex Error Code
// ============================================================================
StepToTopoDS_TranslateVertexError StepToTopoDS_TranslateVertex::Error() const
{
return myError;
}

View File

@@ -0,0 +1,50 @@
-- File: StepToTopoDS_TranslateVertexLoop.cdl
-- Created: Fri Dec 16 14:48:54 1994
-- Author: Frederic MAUPAS
-- <fma@stylox>
---Copyright: Matra Datavision 1994
class TranslateVertexLoop from StepToTopoDS
inherits Root from StepToTopoDS
---Purpose:
--
uses
VertexLoop from StepShape,
TranslateVertexLoopError from StepToTopoDS,
Tool from StepToTopoDS,
Shape from TopoDS,
NMTool from StepToTopoDS
raises NotDone from StdFail
is
Create returns TranslateVertexLoop;
Create (VL : VertexLoop from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS)
returns TranslateVertexLoop;
Init (me : in out;
VL : VertexLoop from StepShape;
T : in out Tool from StepToTopoDS;
NMTool : in out NMTool from StepToTopoDS);
Value (me) returns Shape from TopoDS
raises NotDone
is static;
---C++: return const &
Error (me) returns TranslateVertexLoopError from StepToTopoDS;
fields
myError : TranslateVertexLoopError from StepToTopoDS;
myResult : Shape from TopoDS;
end TranslateVertexLoop;

View File

@@ -0,0 +1,112 @@
// File: StepToTopoDS_TranslateVertexLoop.cxx
// Created: Tue Jan 3 15:41:27 1995
// Author: Frederic MAUPAS/Dieter THIEMANN
// <fma@stylox>
//: gka 09.04.99: S4136: eliminate BRepAPI::Precision()
#include <StepToTopoDS_TranslateVertexLoop.ixx>
#include <BRep_Builder.hxx>
//#include <BRepAPI.hxx>
#include <StepShape_Vertex.hxx>
#include <StepToTopoDS_TranslateVertex.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <Transfer_TransientProcess.hxx>
// ============================================================================
// Method : StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop
// Purpose : Empty Constructor
// ============================================================================
StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop()
{
}
// ============================================================================
// Method : StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop
// Purpose : Constructor with a VertexLoop and a Tool
// ============================================================================
StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop(const Handle(StepShape_VertexLoop)& VL,
StepToTopoDS_Tool& T,
StepToTopoDS_NMTool& NMTool)
{
Init(VL, T, NMTool);
}
// ============================================================================
// Method : Init
// Purpose : Init with a VertexLoop and a Tool
// ============================================================================
void StepToTopoDS_TranslateVertexLoop::Init(const Handle(StepShape_VertexLoop)& VL,
StepToTopoDS_Tool& aTool,
StepToTopoDS_NMTool& NMTool)
{
// A Vertex Loop shall be mapped onto a Vertex + Edge + Wire;
if (!aTool.IsBound(VL)) {
BRep_Builder B;
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
//:S4136 Standard_Real preci = BRepAPI::Precision();
Handle(StepShape_Vertex) Vtx;
TopoDS_Vertex V1,V2;
TopoDS_Edge E;
TopoDS_Wire W;
Vtx = VL->LoopVertex();
StepToTopoDS_TranslateVertex myTranVtx(Vtx, aTool, NMTool);
if (myTranVtx.IsDone()) {
V1 = TopoDS::Vertex(myTranVtx.Value());
V2 = TopoDS::Vertex(myTranVtx.Value());
}
else {
TP->AddWarning(VL,"VertexLoop not mapped to TopoDS ");
myError = StepToTopoDS_TranslateVertexLoopOther;
done = Standard_False;
return;
}
V1.Orientation(TopAbs_FORWARD);
V2.Orientation(TopAbs_REVERSED);
B.MakeEdge(E);
B.Add(E, V1);
B.Add(E, V2);
B.Degenerated(E, Standard_True);
B.MakeWire(W);
B.Add(W, E);
aTool.Bind(VL, W);
myResult = W;
myError = StepToTopoDS_TranslateVertexLoopDone;
done = Standard_True;
}
else {
myResult = TopoDS::Wire(aTool.Find(VL));
myError = StepToTopoDS_TranslateVertexLoopDone;
done = Standard_True;
}
}
// ============================================================================
// Method : Value
// Purpose : Return the mapped Shape
// ============================================================================
const TopoDS_Shape& StepToTopoDS_TranslateVertexLoop::Value() const
{
StdFail_NotDone_Raise_if(!done,"");
return myResult;
}
// ============================================================================
// Method : Error
// Purpose : Return the TranslateVertexLoop Error code
// ============================================================================
StepToTopoDS_TranslateVertexLoopError StepToTopoDS_TranslateVertexLoop::Error() const
{
return myError;
}