1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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

1
src/IGESToBRep/FILES Executable file
View File

@@ -0,0 +1 @@
project.pxx

121
src/IGESToBRep/IGESToBRep.cdl Executable file
View File

@@ -0,0 +1,121 @@
-- File: IGESToBRep.cdl
-- Created: Tue Mar 22 16:47:32 1994
-- Author: Frederic UNTEREINER
-- <fun@ecolox>
---Copyright: Matra Datavision 1994
package IGESToBRep
---Purpose : Provides tools in order to transfer IGES entities
-- to CAS.CADE.
uses
Interface,
Transfer,
MoniTool,
Message,
IGESData,
IGESBasic,
IGESGeom,
IGESSolid,
gp,
Geom,
Geom2d,
TColGeom,
TColGeom2d,
TColStd,
TopoDS,
TopTools,
ShapeExtend,
ShapeAnalysis
is
class CurveAndSurface;
class BasicSurface;
class BasicCurve;
class TopoSurface;
class TopoCurve;
class BRepEntity;
class IGESBoundary;
class Reader;
class Actor;
class AlgoContainer;
class ToolContainer;
Init;
---Purpose: Creates and initializes default AlgoContainer.
SetAlgoContainer (aContainer: AlgoContainer from IGESToBRep);
---Purpose: Sets default AlgoContainer
AlgoContainer returns AlgoContainer from IGESToBRep;
---Purpose: Returns default AlgoContainer
IsCurveAndSurface(start : IGESEntity from IGESData)
returns Boolean;
---Purpose: Return True if the IGESEntity can be transfered by
-- TransferCurveAndSurface.
-- ex: All IGESEntity from IGESGeom
IsBasicCurve (start : IGESEntity from IGESData)
returns Boolean;
---Purpose: Return True if the IGESEntity can be transfered by
-- TransferBasicCurve.
-- ex: CircularArc, ConicArc, Line, CopiousData,
-- BSplineCurve, SplineCurve... from IGESGeom :
-- 104,110,112,126
IsBasicSurface(start : IGESEntity from IGESData)
returns Boolean;
---Purpose: Return True if the IGESEntity can be transfered by
-- TransferBasicSurface.
-- ex: BSplineSurface, SplineSurface... from IGESGeom :
-- 114,128
IsTopoCurve(start : IGESEntity from IGESData)
returns Boolean;
---Purpose: Return True if the IGESEntity can be transfered by
-- TransferTopoCurve.
-- ex: all Curves from IGESGeom :
-- all basic curves,102,130,142,144
IsTopoSurface(start : IGESEntity from IGESData)
returns Boolean;
---Purpose: Return True if the IGESEntity can be transfered by
-- TransferTopoSurface.
-- ex: All Surfaces from IGESGeom :
-- all basic surfaces,108,118,120,122,141,143
IsBRepEntity (start : IGESEntity from IGESData)
returns Boolean;
---Purpose: Return True if the IGESEntity can be transfered by
-- TransferBRepEntity.
-- ex: VertexList, EdgeList, Loop, Face, Shell,
-- Manifold Solid BRep Object from IGESSolid :
-- 502, 504, 508, 510, 514, 186.
WriteShape(shape : Shape from TopoDS;
number : Integer from Standard);
---Purpose: Creates a file Shape_'number' with the shape being
-- able to be restored by Draw.
IGESCurveToSequenceOfIGESCurve (curve : IGESEntity from IGESData;
sequence: out HSequenceOfTransient from TColStd)
returns Integer;
TransferPCurve (fromedge: Edge from TopoDS;
toedge : Edge from TopoDS;
face : Face from TopoDS)
returns Boolean;
end IGESToBRep;

358
src/IGESToBRep/IGESToBRep.cxx Executable file
View File

@@ -0,0 +1,358 @@
// File: IGESToBRep.cxx
// Created: Tue Mar 22 16:47:32 1994
// Author: GUYOT and UNTEREINER
// <fun@ecolox>
//-Copyright: Matra Datavision 1994
// 21.12.98 rln, gka S4054
// 06.01.99 pdn transmission from ShapeTool_MakeWire back to BRepAPI_MakeWire
// 19.03.99 abv //:q5: code improvement, unnecessary includes removed
//S4181 pdn 15.04.99 Recognition of elementary surfaces as basic.
#include <IGESToBRep.ixx>
#include <Standard_Stream.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESGeom_RuledSurface.hxx>
#include <IGESGeom_SurfaceOfRevolution.hxx>
#include <IGESGeom_TabulatedCylinder.hxx>
#include <IGESGeom_OffsetSurface.hxx>
#include <IGESGeom_TrimmedSurface.hxx>
#include <IGESGeom_Boundary.hxx>
#include <IGESGeom_BoundedSurface.hxx>
#include <IGESGeom_BSplineCurve.hxx>
#include <IGESGeom_BSplineSurface.hxx>
#include <IGESGeom_CircularArc.hxx>
#include <IGESGeom_ConicArc.hxx>
#include <IGESGeom_Line.hxx>
#include <IGESGeom_CompositeCurve.hxx>
#include <IGESGeom_CopiousData.hxx>
#include <IGESGeom_CurveOnSurface.hxx>
#include <IGESGeom_OffsetCurve.hxx>
#include <IGESGeom_Plane.hxx>
#include <IGESGeom_Point.hxx>
#include <IGESGeom_SplineCurve.hxx>
#include <IGESGeom_SplineSurface.hxx>
#include <IGESSolid_VertexList.hxx>
#include <IGESSolid_EdgeList.hxx>
#include <IGESSolid_Loop.hxx>
#include <IGESSolid_Face.hxx>
#include <IGESSolid_Shell.hxx>
#include <IGESSolid_ManifoldSolid.hxx>
#include <IGESSolid_PlaneSurface.hxx>
#include <IGESBasic_SingleParent.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Precision.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Wire.hxx>
#include <TopLoc_Location.hxx>
#include <Interface_Macros.hxx>
/* Just used for WriteShape */
#include <stdio.h>
#include <TCollection_HAsciiString.hxx>
#include <BRepTools.hxx>
//:21
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <BRep_Builder.hxx>
#include <GeomLib.hxx>
#include <IGESSolid_CylindricalSurface.hxx>
#include <IGESSolid_ConicalSurface.hxx>
#include <IGESSolid_SphericalSurface.hxx>
#include <IGESSolid_ToroidalSurface.hxx>
#include <XSAlgo.hxx>
// =========================
// == Selection Members ==
// =========================
static Handle(IGESToBRep_AlgoContainer) theContainer;
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void IGESToBRep::Init()
{
static Standard_Boolean init = Standard_False;
if (init) return;
init = Standard_True;
XSAlgo::Init();
theContainer = new IGESToBRep_AlgoContainer;
}
//=======================================================================
//function : SetAlgoContainer
//purpose :
//=======================================================================
void IGESToBRep::SetAlgoContainer(const Handle(IGESToBRep_AlgoContainer)& aContainer)
{
theContainer = aContainer;
}
//=======================================================================
//function : AlgoContainer
//purpose :
//=======================================================================
Handle(IGESToBRep_AlgoContainer) IGESToBRep::AlgoContainer()
{
return theContainer;
}
//=======================================================================
//function : IsCurveAndSurface
//purpose : Return True if the IgesEntity can be transfered
// by TransferCurveAndSurface
//=======================================================================
Standard_Boolean IGESToBRep::IsCurveAndSurface(const Handle(IGESData_IGESEntity)& start)
{
//S4054
if (start.IsNull()) return Standard_False;
if (IsTopoCurve(start)) return Standard_True;
if (IsTopoSurface(start)) return Standard_True;
if (IsBRepEntity(start)) return Standard_True;
return Standard_False;
}
//=======================================================================
//function : IsBasicCurve
//purpose : Return True if the IgesEntity can be transfered
// by TransferBasicCurve
//=======================================================================
Standard_Boolean IGESToBRep::IsBasicCurve(const Handle(IGESData_IGESEntity)& start)
{
//S4054
if (start.IsNull()) return Standard_False;
if (start->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_Line))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_ConicArc))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_CopiousData))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_SplineCurve))) return Standard_True;
return Standard_False;
}
//=======================================================================
//function : IsBasicSurface
//purpose : Return True if the IgesEntity can be transfered
// by TransferBasicSurface
//=======================================================================
Standard_Boolean IGESToBRep::IsBasicSurface(const Handle(IGESData_IGESEntity)& start)
{
//S4054
if (start.IsNull()) return Standard_False;
if (start->IsKind(STANDARD_TYPE(IGESGeom_BSplineSurface))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_SplineSurface))) return Standard_True;
//S4181 pdn 15.04.99 added to basic surfaces
if (start->IsKind(STANDARD_TYPE(IGESSolid_PlaneSurface))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESSolid_CylindricalSurface))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESSolid_ConicalSurface))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESSolid_SphericalSurface))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESSolid_ToroidalSurface))) return Standard_True;
return Standard_False;
}
//=======================================================================
//function : IsTopoCurve
//purpose : Return True if the IgesEntity can be transfered
// by TransferTopoCurve
//=======================================================================
Standard_Boolean IGESToBRep::IsTopoCurve(const Handle(IGESData_IGESEntity)& start)
{
//S4054
if (start.IsNull()) return Standard_False;
if (IsBasicCurve(start)) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_CompositeCurve))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_CurveOnSurface))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_Boundary))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_Point))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_OffsetCurve))) return Standard_True;
return Standard_False;
}
//=======================================================================
//function : IsTopoSurface
//purpose : Return True if the IgesEntity can be transfered
// by TransferTopoSurface
//=======================================================================
Standard_Boolean IGESToBRep::IsTopoSurface(const Handle(IGESData_IGESEntity)& start)
{
//S4054
if (start.IsNull()) return Standard_False;
if (IsBasicSurface(start)) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_TrimmedSurface))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_SurfaceOfRevolution))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_TabulatedCylinder))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_RuledSurface))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_Plane))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_BoundedSurface))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESGeom_OffsetSurface))) return Standard_True;
//S4181 pdn 15.04.99 removing to basic surface
//if (start->IsKind(STANDARD_TYPE(IGESSolid_PlaneSurface))) return Standard_True;
// SingleParent, cas particulier (Face Trouee : ne contient que des PLANE)
if (start->IsKind(STANDARD_TYPE(IGESBasic_SingleParent))) {
DeclareAndCast(IGESBasic_SingleParent,sp,start);
if (!sp->SingleParent()->IsKind(STANDARD_TYPE(IGESGeom_Plane))) return Standard_False;
Standard_Integer nb = sp->NbChildren();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (!sp->Child(i)->IsKind(STANDARD_TYPE(IGESGeom_Plane))) return Standard_False;
}
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : IsBRepEntity
//purpose : Return True if the IgesEntity can be transfered
// by TransferBRepEntity
//=======================================================================
Standard_Boolean IGESToBRep::IsBRepEntity(const Handle(IGESData_IGESEntity)& start)
{
//S4054
if (start.IsNull()) return Standard_False;
if (start->IsKind(STANDARD_TYPE(IGESSolid_Face))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESSolid_Shell))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESSolid_ManifoldSolid))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESSolid_VertexList))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESSolid_EdgeList))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(IGESSolid_Loop))) return Standard_True;
return Standard_False;
}
//=======================================================================
//function : WriteShape
//purpose : Creates a file Shape_'number'
//=======================================================================
void IGESToBRep::WriteShape(const TopoDS_Shape& shape,
const Standard_Integer number)
{
char fname[110];
sprintf(fname, "Shape_%d",number);
ofstream f(fname,ios::out);
cout << "Output file name : " << fname << endl;
f << "DBRep_DrawableShape\n";
BRepTools::Write(shape, f);
f.close();
}
//=======================================================================
//function : IGESCurveToSequenceOfIGESCurve
//purpose : Creates a sequence of IGES curves from IGES curve:
// - if curve is CompositeCurve its components are recursively added,
// - if curve is ordinary IGES curve it is simply added
// - otherwise (Null or not curve) it is ignored
//remark : if sequence is Null it is created, otherwise it is appended
//returns : number of curves in sequence
//example : (A B (C (D ( E F) G) H)) -> (A B C D E F G H)
//=======================================================================
Standard_Integer IGESToBRep::IGESCurveToSequenceOfIGESCurve(const Handle(IGESData_IGESEntity)& curve,
Handle(TColStd_HSequenceOfTransient)& sequence)
{
if (sequence.IsNull()) sequence = new TColStd_HSequenceOfTransient;
if (!curve.IsNull()) {
if (curve->IsKind (STANDARD_TYPE (IGESGeom_CompositeCurve))) {
Handle(IGESGeom_CompositeCurve) comp = Handle(IGESGeom_CompositeCurve)::DownCast (curve);
for (Standard_Integer i = 1; i <= comp->NbCurves(); i++) {
Handle(TColStd_HSequenceOfTransient) tmpsequence;
IGESCurveToSequenceOfIGESCurve (comp->Curve (i), tmpsequence);
sequence->Append (tmpsequence);
}
}
else if (IGESToBRep::IsTopoCurve (curve) &&
! curve->IsKind (STANDARD_TYPE (IGESGeom_Point)))
sequence->Append (curve);
}
return sequence->Length();
}
//=======================================================================
//function : TransferPCurve
//purpose : Copies pcurve on face <face> from <fromedge> to <toedge>
// If <toedge> already has pcurve on that <face>, <toedge> becomes
// a seam-edge; if both pcurves are not SameRange, the SameRange is
// called. Returns False if pcurves are not made SameRange
// Making <toedge> SameParameter should be done outside the method (???)
//=======================================================================
Standard_Boolean IGESToBRep::TransferPCurve (const TopoDS_Edge& fromedge, const TopoDS_Edge& toedge, const TopoDS_Face& face)
{
Standard_Boolean result = Standard_True;
Standard_Real olda, oldb, a, b;
Handle(Geom2d_Curve) oldpcurve = BRep_Tool::CurveOnSurface (toedge, face, olda, oldb),
pcurve = BRep_Tool::CurveOnSurface (fromedge, face, a, b );
BRep_Builder B;
if (!oldpcurve.IsNull()) {
if (olda != a || oldb != b) {
try {
OCC_CATCH_SIGNALS
Handle(Geom2d_Curve) newpcurve;
GeomLib::SameRange (Precision::PConfusion(), oldpcurve, olda, oldb, a, b, newpcurve);
if (!newpcurve.IsNull()) {
olda = a; oldb = b; oldpcurve = newpcurve;
}
else {
#ifdef DEB
cout << "Warning: IGESToBRep::TransferPCurve: pcurves are not SameRange" << endl;
#endif
result = Standard_False;
}
}
catch(Standard_Failure) {
#ifdef DEB
cout << "\n**IGESToBRep::TransferPCurve: Exception in SameRange : ";
Standard_Failure::Caught()->Print(cout);
#endif
result = Standard_False;
}
}
if (toedge.Orientation() == TopAbs_FORWARD)
B.UpdateEdge (toedge,
Handle(Geom2d_Curve)::DownCast (pcurve->Copy()),
Handle(Geom2d_Curve)::DownCast (oldpcurve->Copy()), face, 0);
else
B.UpdateEdge (toedge,
Handle(Geom2d_Curve)::DownCast (oldpcurve->Copy()),
Handle(Geom2d_Curve)::DownCast (pcurve->Copy()), face, 0);
}
else {
olda = a; oldb = b;
B.UpdateEdge (toedge, Handle(Geom2d_Curve)::DownCast (pcurve->Copy()), face, 0);
}
B.Range (toedge, face, a, b);
Standard_Real first, last;
if (!BRep_Tool::Curve (toedge, first, last).IsNull() && (first != a || last != b))
B.SameRange (toedge, Standard_False);
else
B.SameRange (toedge, Standard_True);
return result;
}

View File

@@ -0,0 +1,49 @@
-- File: IGESToBRep_Actor.cdl
-- Created: Thu Nov 3 14:59:07 1994
-- Author: Marie Jose MARTZ
-- <mjm@minox>
---Copyright: Matra Datavision 1994
class Actor from IGESToBRep
inherits ActorOfTransientProcess from Transfer
---Purpose : This class performs the transfer of an Entity from
-- IGESToBRep
--
-- I.E. for each type of Entity, it invokes the appropriate Tool
-- then returns the Binder which contains the Result
uses TransientProcess, Binder, InterfaceModel from Interface
is
Create returns mutable Actor from IGESToBRep;
SetModel (me : mutable; model : InterfaceModel from Interface);
SetContinuity (me : mutable; continuity : Integer from Standard = 0);
---Purpose By default continuity = 0
-- if continuity = 1 : try C1
-- if continuity = 2 : try C2
GetContinuity (me) returns Integer from Standard;
---Purpose : Return "thecontinuity"
Recognize (me : mutable; start : Transient) returns Boolean is redefined;
Transfer (me : mutable; start : Transient; TP : mutable TransientProcess)
returns mutable Binder is redefined;
UsedTolerance (me) returns Real;
---Purpose : Returns the tolerance which was actually used, either from
-- the file or from statics
fields
themodel : InterfaceModel from Interface;
thecontinuity : Integer;
theeps : Real;
end Actor;

View File

@@ -0,0 +1,204 @@
#include <Standard_ErrorHandler.hxx>
#include <IGESToBRep_Actor.ixx>
#include <Standard_Failure.hxx>
#include <IGESToBRep.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESData_IGESModel.hxx>
#include <IGESData_GlobalSection.hxx>
#include <IGESToBRep_CurveAndSurface.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Static.hxx>
#include <TopoDS_Shape.hxx>
#include <TransferBRep.hxx>
#include <TransferBRep_ShapeBinder.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <BRepLib.hxx>
#include <ShapeExtend_Explorer.hxx>
//=======================================================================
//function : IGESToBRep_Actor
//purpose :
//=======================================================================
IGESToBRep_Actor::IGESToBRep_Actor ()
{ thecontinuity = 0; theeps = 0.0001; }
//=======================================================================
//function : SetModel
//purpose :
//=======================================================================
void IGESToBRep_Actor::SetModel (const Handle(Interface_InterfaceModel)& model)
{
themodel = model;
theeps = Handle(IGESData_IGESModel)::DownCast(themodel)->GlobalSection().Resolution();
}
//=======================================================================
//function : SetContinuity
//purpose :
//=======================================================================
void IGESToBRep_Actor::SetContinuity (const Standard_Integer continuity)
{
thecontinuity = continuity;
}
//=======================================================================
//function : GetContinuity
//purpose :
//=======================================================================
Standard_Integer IGESToBRep_Actor::GetContinuity () const
{
return thecontinuity;
}
//=======================================================================
//function : Recognize
//purpose :
//=======================================================================
Standard_Boolean IGESToBRep_Actor::Recognize
(const Handle(Standard_Transient)& start)
{
DeclareAndCast(IGESData_IGESModel,mymodel,themodel);
DeclareAndCast(IGESData_IGESEntity,ent,start);
if (ent.IsNull()) return Standard_False;
// Cas reconnus
Standard_Integer typnum = ent->TypeNumber();
Standard_Integer fornum = ent->FormNumber();
if (IGESToBRep::IsCurveAndSurface(ent) ||
(typnum == 402 && (fornum == 1 || fornum == 7 ||
fornum == 14 || fornum == 15) ||
(typnum == 408 ) || (typnum == 308)))
return Standard_True;
// Cas restants : non reconnus
return Standard_False;
}
//=======================================================================
//function : EncodeRegul
//purpose : INTERNAL to encode regularity on edges
//=======================================================================
static Standard_Boolean EncodeRegul (const TopoDS_Shape& sh)
{
Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle");
if (sh.IsNull()) return Standard_True;
if (tolang <= 0) return Standard_True;
try {
OCC_CATCH_SIGNALS
BRepLib::EncodeRegularity (sh,tolang);
}
catch(Standard_Failure) {
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : TrimTolerances
//purpose : Trims tolerances of the shape according to static parameters
//
//=======================================================================
static void TrimTolerances (const TopoDS_Shape& shape,
const Standard_Real tol)
{
if( Interface_Static::IVal("read.maxprecision.mode")==1) {
ShapeFix_ShapeTolerance SFST;
SFST.LimitTolerance (shape, 0, Max(tol,Interface_Static::RVal ("read.maxprecision.val")));
}
}
//=======================================================================
//function : Transfer
//purpose :
//=======================================================================
Handle(Transfer_Binder) IGESToBRep_Actor::Transfer
(const Handle(Standard_Transient)& start, const Handle(Transfer_TransientProcess)& TP)
{
DeclareAndCast(IGESData_IGESModel,mymodel,themodel);
DeclareAndCast(IGESData_IGESEntity,ent,start);
if (mymodel.IsNull() || ent.IsNull()) return NullResult();
Standard_Integer anum = mymodel->Number(start);
if(!Interface_Static::IVal("read.iges.faulty.entities") && mymodel->IsErrorEntity(anum))
return NullResult();
TopoDS_Shape shape;
// appeler le transfert seulement si type OK
Standard_Integer typnum = ent->TypeNumber();
Standard_Integer fornum = ent->FormNumber();
Standard_Real eps;
if (IGESToBRep::IsCurveAndSurface(ent) ||
(typnum == 402 && (fornum == 1 || fornum == 7||
fornum == 14 || fornum == 15)) ||
(typnum == 408) || (typnum == 308)) {
XSAlgo::AlgoContainer()->PrepareForTransfer();
IGESToBRep_CurveAndSurface CAS;
CAS.SetModel(mymodel);
CAS.SetContinuity(thecontinuity);
CAS.SetTransferProcess(TP);
Standard_Integer Ival = Interface_Static::IVal("read.precision.mode");
if ( Ival == 0)
eps = mymodel->GlobalSection().Resolution();
else
eps = Interface_Static::RVal("read.precision.val"); //:10 ABV 11 Nov 97
//:10 eps = BRepAPI::Precision();
Ival = Interface_Static::IVal("read.iges.bspline.approxd1.mode");
CAS.SetModeApprox ( (Ival > 0) );
Ival = Interface_Static::IVal("read.surfacecurve.mode");
CAS.SetSurfaceCurve (Ival);
if (eps > 1.E-08) {
CAS.SetEpsGeom(eps);
theeps = eps*CAS.GetUnitFactor();
// Interface_Static::SetRVal("lastpreci",theeps);
}
Standard_Integer nbTPitems = TP->NbMapped();
{
try {
OCC_CATCH_SIGNALS
shape = CAS.TransferGeometry(ent);
}
catch(Standard_Failure) {
shape.Nullify();
}
}
// fixing shape
// shape = XSAlgo::AlgoContainer()->PerformFixShape( shape, TP, theeps, CAS.GetMaxTol() );
Handle(Standard_Transient) info;
shape = XSAlgo::AlgoContainer()->ProcessShape( shape, theeps, CAS.GetMaxTol(),
"read.iges.resource.name",
"read.iges.sequence", info );
XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
}
// if (!shape.IsNull()) TransferBRep::SameParameter (shape,Standard_False,eps);
ShapeExtend_Explorer SBE;
if (SBE.ShapeType(shape,Standard_True) != TopAbs_SHAPE) {
if (!shape.IsNull()) {
EncodeRegul (shape);
//#74 rln 03.03.99 S4135
TrimTolerances (shape, UsedTolerance());
// Shapes().Append(shape);
}
}
Handle(TransferBRep_ShapeBinder) binder;
if (!shape.IsNull()) binder = new TransferBRep_ShapeBinder(shape);
return binder;
}
Standard_Real IGESToBRep_Actor::UsedTolerance () const
{ return theeps; }

View File

@@ -0,0 +1,34 @@
-- File: IGESToBRep_AlgoContainer.cdl
-- Created: Mon Feb 7 13:05:53 2000
-- Author: data exchange team
-- <det@kinox>
---Copyright: Matra Datavision 2000
class AlgoContainer from IGESToBRep inherits TShared from MMgt
---Purpose:
uses
ToolContainer from IGESToBRep
is
Create returns mutable AlgoContainer from IGESToBRep;
---Purpose: Empty constructor
SetToolContainer (me: mutable; TC: ToolContainer from IGESToBRep);
---C++ : inline
---Purpose: Sets ToolContainer
ToolContainer (me) returns ToolContainer from IGESToBRep;
---C++ : inline
---Purpose: Returns ToolContainer
fields
myTC : ToolContainer from IGESToBRep;
end AlgoContainer;

View File

@@ -0,0 +1,18 @@
// File: IGESToBRep_AlgoContainer.cxx
// Created: Mon Feb 7 13:07:15 2000
// Author: data exchange team
// <det@kinox>
#include <IGESToBRep_AlgoContainer.ixx>
//=======================================================================
//function : IGESToBRep_AlgoContainer
//purpose :
//=======================================================================
IGESToBRep_AlgoContainer::IGESToBRep_AlgoContainer()
{
myTC = new IGESToBRep_ToolContainer;
}

View File

@@ -0,0 +1,29 @@
// File: IGESToBRep_AlgoContainer.lxx
// Created: Mon Feb 7 13:07:48 2000
// Author: data exchange team
// <det@kinox>
#include <IGESToBRep_AlgoContainer.hxx>
//=======================================================================
//function : SetToolContainer
//purpose :
//=======================================================================
inline void IGESToBRep_AlgoContainer::SetToolContainer(const Handle(IGESToBRep_ToolContainer)& TC)
{
myTC = TC;
}
//=======================================================================
//function : ToolContainer
//purpose :
//=======================================================================
inline Handle(IGESToBRep_ToolContainer) IGESToBRep_AlgoContainer::ToolContainer() const
{
return myTC;
}

View File

@@ -0,0 +1,90 @@
-- File: IGESToBRep_BRepEntity.cdl
-- Created: Wed Sep 28 10:55:01 1994
-- Author: Marie Jose MARTZ
-- <mjm@stylox>
---Copyright: Matra Datavision 1994
class BRepEntity from IGESToBRep inherits CurveAndSurface from IGESToBRep
---Purpose : Provides methods to transfer BRep entities
-- ( VertexList 502, EdgeList 504, Loop 508,
-- Face 510, Shell 514, ManifoldSolid 186)
-- from IGES to CASCADE.
uses
CurveAndSurface from IGESToBRep,
IGESEntity from IGESData,
VertexList from IGESSolid,
EdgeList from IGESSolid,
Loop from IGESSolid,
Face from IGESSolid,
Shell from IGESSolid,
ManifoldSolid from IGESSolid,
Face from TopoDS,
Shape from TopoDS,
Vertex from TopoDS,
Trsf2d from gp
is
Create returns BRepEntity;
---Purpose : Creates a tool BRepEntity ready to run, with
-- epsilons set to 1.E-04, TheModeTopo to True, the
-- optimization of the continuity to False.
Create(CS : CurveAndSurface from IGESToBRep) returns BRepEntity;
---Purpose : Creates a tool BRepEntity ready to run and sets its
-- fields as CS's.
Create(eps : Real;
epsGeom : Real;
epsCoeff : Real;
mode : Boolean;
modeapprox : Boolean;
optimized : Boolean) returns BRepEntity;
---Purpose : Creates a tool BRepEntity ready to run.
TransferBRepEntity (me : in out;
start : IGESEntity from IGESData)
returns Shape from TopoDS;
---Purpose : Transfer the BRepEntity" : Face, Shell or ManifoldSolid.
TransferVertex (me : in out;
start : VertexList from IGESSolid;
index : Integer from Standard)
returns Vertex from TopoDS;
---Purpose : Transfer the entity number "index" of the VertexList "start"
TransferEdge (me : in out;
start : EdgeList from IGESSolid;
index : Integer from Standard)
returns Shape from TopoDS;
---Purpose : Transfer the entity number "index" of the EdgeList "start".
TransferLoop (me : in out;
start : Loop from IGESSolid;
Face : Face from TopoDS;
trans : Trsf2d from gp;
uFact :Real)
returns Shape from TopoDS;
---Purpose : Transfer the Loop Entity
TransferFace (me : in out;
start : Face from IGESSolid)
returns Shape from TopoDS;
---Purpose : Transfer the Face Entity
TransferShell (me : in out;
start : Shell from IGESSolid)
returns Shape from TopoDS;
---Purpose : Transfer the Shell Entity
TransferManifoldSolid (me : in out;
start : ManifoldSolid from IGESSolid)
returns Shape from TopoDS;
---Purpose : Transfer the ManifoldSolid Entity
end BRepEntity;

View File

@@ -0,0 +1,652 @@
//=======================================================================
//file : IGESToBRep_BRepEntity.cxx
//purpose : Members to transfert any BRepEntity into TopoDS_Shape
//=======================================================================
// 21.12.98 rln, gka S4054
//#62 rln 10.01.99 PRO17015
//:q5 abv 19.03.99 unnecessary includes removed
//pdn 12.03.99 S4135 Constructing vertex with minimal tolerance
//:r1 abv 25.03.99 CTS21655.igs, CTS18545.igs: apply FixOrientation to whole face
//S4181 pdn 20.04.99 implementing of reading IGES elementary surfaces.
//pdn 20.04.99 CTS22655 avoid of exceptions in case of empty loops
#include <Standard_ErrorHandler.hxx>
#include <IGESToBRep_BRepEntity.ixx>
#include <IGESToBRep.hxx>
#include <IGESToBRep_BasicCurve.hxx>
#include <IGESToBRep_BasicSurface.hxx>
#include <IGESToBRep_CurveAndSurface.hxx>
#include <IGESToBRep_TopoCurve.hxx>
#include <IGESToBRep_TopoSurface.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <gp.hxx>
#include <gp_Pnt.hxx>
#include <IGESBasic_SingleParent.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESData_HArray1OfIGESEntity.hxx>
#include <IGESData_ToolLocation.hxx>
#include <IGESGeom_Boundary.hxx>
#include <IGESGeom_BoundedSurface.hxx>
#include <IGESGeom_CurveOnSurface.hxx>
#include <IGESGeom_Plane.hxx>
#include <IGESGeom_TrimmedSurface.hxx>
#include <Interface_Macros.hxx>
#include <Precision.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopExp.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <Transfer_TransientProcess.hxx>
#include <stdio.h>
#include <gp_Vec2d.hxx>//rln
#include <ShapeExtend_WireData.hxx>
#include <ShapeBuild_Edge.hxx>
#include <IGESToBRep_IGESBoundary.hxx>
#include <Message_Msg.hxx>
#include <TCollection_HAsciiString.hxx>
#include <IGESData_IGESModel.hxx>
//#include <ShapeFix_Face.hxx>
#include <IGESToBRep_AlgoContainer.hxx>
#include <IGESToBRep_ToolContainer.hxx>
#include <Message_ProgressSentry.hxx>
// mjm le 10/10/96 on force la continuity a 0 en attendant de pouvoir
// travailler sur wire en non plus edge.
//=======================================================================
//function : IGESToBRep_BRepEntity
//purpose :
//=======================================================================
IGESToBRep_BRepEntity::IGESToBRep_BRepEntity()
:IGESToBRep_CurveAndSurface()
{
SetModeTransfer(Standard_False);
SetContinuity(0);
}
//=======================================================================
//function : IGESToBRep_BRepEntity
//purpose :
//=======================================================================
IGESToBRep_BRepEntity::IGESToBRep_BRepEntity
(const IGESToBRep_CurveAndSurface& CS)
:IGESToBRep_CurveAndSurface(CS)
{
SetContinuity(0);
}
//=======================================================================
//function : IGESToBRep_BRepEntity
//purpose :
//=======================================================================
IGESToBRep_BRepEntity::IGESToBRep_BRepEntity
(const Standard_Real eps,
const Standard_Real epsCoeff,
const Standard_Real epsGeom,
const Standard_Boolean mode,
const Standard_Boolean modeapprox,
const Standard_Boolean optimized)
:IGESToBRep_CurveAndSurface(eps, epsCoeff, epsGeom, mode, modeapprox,
optimized)
{
SetContinuity(0);
}
//=======================================================================
//function : TransferBRepEntity
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_BRepEntity::TransferBRepEntity
(const Handle(IGESData_IGESEntity)& start)
{
TopoDS_Shape res;
if (start->IsKind(STANDARD_TYPE(IGESSolid_Face))) {
DeclareAndCast(IGESSolid_Face, st510, start);
res = TransferFace(st510);
}
else if (start->IsKind(STANDARD_TYPE(IGESSolid_Shell))) {
DeclareAndCast(IGESSolid_Shell, st514, start);
res = TransferShell(st514);
}
else if (start->IsKind(STANDARD_TYPE(IGESSolid_ManifoldSolid))) {
DeclareAndCast(IGESSolid_ManifoldSolid, st186, start);
res = TransferManifoldSolid(st186);
}
else {
Message_Msg Msg1005("IGES_1005");
SendFail(start,Msg1005);
}
return res;
}
//=======================================================================
//function : TransferVertex
//purpose :
//=======================================================================
TopoDS_Vertex IGESToBRep_BRepEntity::TransferVertex
(const Handle(IGESSolid_VertexList)& start,
const Standard_Integer index)
{
TopoDS_Vertex res;
Standard_Integer nbshapes = NbShapeResult(start);
if (nbshapes == 0 ) {
BRep_Builder B;
for (Standard_Integer inum = 1; inum <= start->NbVertices(); inum++) {
gp_Pnt point = start-> Vertex(inum);
point.Scale(gp_Pnt(0,0,0),GetUnitFactor());
TopoDS_Vertex V;
//pdn 12.03.99 S4135 Constructing vertex with minimal tolerance
B.MakeVertex(V, point, Precision::Confusion());
AddShapeResult(start,V);
}
}
TopoDS_Shape Sh = GetShapeResult(start,index);
if ( Sh.IsNull()) {
Message_Msg Msg1156("IGES_1156"); //"the Vertex number %d is a null object." FAIL!!!
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1156.Arg("vertex %d");
Msg1156.Arg(index);
Msg1156.Arg(label);
SendWarning(start,Msg1156);
}
res = TopoDS::Vertex(Sh);
return res;
}
//=======================================================================
//function : TransferEdge
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_BRepEntity::TransferEdge
(const Handle(IGESSolid_EdgeList)& start,
const Standard_Integer index)
{
TopoDS_Shape res;
BRep_Builder B;
Standard_Integer nbshapes = NbShapeResult(start);
if (nbshapes == 0) {
IGESToBRep_TopoCurve TC(*this);
for (Standard_Integer inum = 1; inum <= start->NbEdges(); inum++) {
// Vertices
// --------
Handle(IGESSolid_VertexList) thestartlist = start->StartVertexList(inum);
Standard_Integer thestartindex = start->StartVertexIndex(inum);
TopoDS_Vertex V1 = TransferVertex(thestartlist,thestartindex);
Handle(IGESSolid_VertexList) theendlist = start->EndVertexList(inum);
Standard_Integer theendindex = start->EndVertexIndex(inum);
TopoDS_Vertex V2 = TransferVertex(theendlist,theendindex);
// Curve
// -----
Handle(IGESData_IGESEntity) thecurve = start->Curve(inum);
if (thecurve.IsNull() ||
!IGESToBRep::IsTopoCurve(thecurve) ||
thecurve->IsKind(STANDARD_TYPE(IGESGeom_CurveOnSurface)) ||
thecurve->IsKind(STANDARD_TYPE(IGESGeom_Boundary)) ) {
Message_Msg Msg1306("IGES_1306");//one underlying curve is a Null object.
Msg1306.Arg(inum);
SendWarning(start,Msg1306);
TopoDS_Edge Sh;
AddShapeResult(start,Sh);
}
else {
TopoDS_Shape Sh = TC.TransferTopoCurve(thecurve);
if (!Sh.IsNull()) {
if (Sh.ShapeType() == TopAbs_EDGE) {
TopoDS_Edge edge = TopoDS::Edge(Sh);
TopoDS_Vertex Vf,Vl;
TopExp::Vertices (edge, Vf, Vl);
TopoDS_Edge E;
B.MakeEdge(E);
TopLoc_Location loc;
Standard_Real first, last;
Handle(Geom_Curve) Crv = BRep_Tool::Curve(edge, loc, first, last);
Handle(Geom_Curve) newC3d;
// dams le cas d`une conique, il faut reverser
// sens de parcours IGES inverse sens de parcours CASCADE.
if (Crv->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
DeclareAndCast(Geom_TrimmedCurve, acurve, Crv);
newC3d = acurve->BasisCurve();
}
else {
newC3d = Crv;
}
B.UpdateEdge(E,newC3d,loc,0.);//S4054:GetEpsGeom()*GetUnitFactor()
gp_Pnt p1 = BRep_Tool::Pnt ( V1 );
gp_Pnt p2 = BRep_Tool::Pnt ( V2 );
gp_Pnt pf = BRep_Tool::Pnt ( Vf );
gp_Pnt pl = BRep_Tool::Pnt ( Vl );
Standard_Real dist1f = p1.Distance ( pf );
Standard_Real dist2f = p2.Distance ( pf );
Standard_Real dist1l = p1.Distance ( pl );
Standard_Real dist2l = p2.Distance ( pl );
if ( E.Closed() || dist1f + dist2l <= dist1l + dist2f ) {
//:77 if (BRepTools::Compare(V1, Vf)) //the part 'else' only if, in fact, edge should be reversed
V1.Orientation(TopAbs_FORWARD);
B.Add(E,V1);
V2.Orientation(TopAbs_REVERSED);
B.Add(E,V2);
B.UpdateVertex(V1, first, E, 0.);//S4054 1.001 * dist1f //:77 GetEpsGeom()*GetUnitFactor();
B.UpdateVertex(V2, last, E, 0.);//S4054 1.001 * dist2l //:77 GetEpsGeom()*GetUnitFactor();
B.Range (E, first, last);
}
// modif mjm du 13/10/97 : Reverse de l`edge ?
else {
E.Reverse();
V1.Orientation(TopAbs_FORWARD);
B.Add(E,V1);
V2.Orientation(TopAbs_REVERSED);
B.Add(E,V2);
B.UpdateVertex(V1, last, E, 0.);//S4054 1.001 * dist1l //:77 GetEpsGeom()*GetUnitFactor();
B.UpdateVertex(V2, first, E, 0.);//S4054 1.001 * dist2f //:77 GetEpsGeom()*GetUnitFactor();
B.Range (E, first, last);
}
AddShapeResult(start,E);
}
else if (Sh.ShapeType() == TopAbs_WIRE) {
// pas traite
Message_Msg Msg1325("IGES_1325"); //"Edge : result of TransferTopoCurve is WIRE"
Msg1325.Arg(inum);
SendWarning(start,Msg1325);
//AddWarning(start,"Edge : result of TransferTopoCurve is WIRE");
}
}
else {
Message_Msg Msg1156("IGES_1156");
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(thecurve);
Msg1156.Arg("underlying curve");
Msg1156.Arg(label);
SendWarning(start,Msg1156);
}
}
}
}
TopoDS_Shape Sh = GetShapeResult(start,index);
if ( Sh.IsNull()) {
Message_Msg Msg1156("IGES_1156");
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1156.Arg("edge %d");
Msg1156.Arg(index);
Msg1156.Arg(label);
SendWarning(start,Msg1156);
}
return Sh;
}
//=======================================================================
//function : TransferLoop
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_BRepEntity::TransferLoop(const Handle(IGESSolid_Loop)& start,
const TopoDS_Face& face,
const gp_Trsf2d& trans,
const Standard_Real uFact)
{
TopoDS_Shape res;
if (!HasShapeResult(start)) {
TopoDS_Wire mywire;
Standard_Boolean okCurve = Standard_True, okCurve3d = Standard_True, okCurve2d = Standard_True;
Handle(ShapeExtend_WireData) sewd;
Standard_Integer filepreference = 3;//3D is preferred by default
Standard_Boolean Result = Standard_True;
Handle(IGESToBRep_IGESBoundary) IB = IGESToBRep::AlgoContainer()->ToolContainer()->IGESBoundary();
IB->Init (*this, start, face, trans, uFact, filepreference);
BRep_Builder B;
ShapeBuild_Edge sbe;
for ( Standard_Integer iedge = 1; iedge <= start->NbEdges(); iedge++ ) {
Standard_Integer itype = start->EdgeType(iedge);
Handle(IGESData_IGESEntity) theedge = start->Edge(iedge);
Standard_Integer indexlist = start->ListIndex(iedge);
Standard_Boolean orientation = start->Orientation(iedge);
Standard_Integer nbparam = start->NbParameterCurves(iedge);
if (theedge.IsNull()) {
Message_Msg Msg1365("IGES_1365"); //"Loop : one edge is null"
Msg1365.Arg(iedge);
SendWarning(start,Msg1365);
// AddWarning (start,"Loop : one edge is null");
}
else {
// edge
// ----
Handle(ShapeExtend_WireData) curve3d = new ShapeExtend_WireData;
if (( itype == 1) && (theedge ->IsKind(STANDARD_TYPE(IGESSolid_VertexList)))) {
DeclareAndCast(IGESSolid_VertexList,thelist,theedge);
TopoDS_Vertex V1 = TransferVertex(thelist,indexlist);
TopoDS_Edge E;
B.MakeEdge(E);
//szv#4:S4163:12Mar99 SGI warns
TopoDS_Shape sh = V1.Oriented(TopAbs_FORWARD);
B.Add(E, TopoDS::Vertex(sh));
sh = V1.Oriented(TopAbs_REVERSED);
B.Add(E, TopoDS::Vertex(sh));
B.Degenerated(E, Standard_True);
curve3d->Add (E);
}
else if (( itype == 0) && (theedge ->IsKind(STANDARD_TYPE(IGESSolid_EdgeList)))) {
DeclareAndCast(IGESSolid_EdgeList,thelist,theedge);
TopoDS_Shape Sh = TransferEdge(thelist,indexlist);
curve3d->Add (Sh);
}
else {
Message_Msg Msg1365("IGES_1365"); //"Improper type for the edge"
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1365.Arg(iedge);
SendWarning(start,Msg1365);
//AddWarning (start, "Improper type for the edge");
continue;
}
if (!orientation) curve3d->Reverse();
// traitement des courbes 2d.
// -------------------------
Handle(IGESData_HArray1OfIGESEntity) Curves2d;
//Current limitation:
//2D representation is not translated if:
//- 3D curve was translated into wire (i.e. if it is 102)
//- more than 1 2D curve,
//- 2D curve is 102
Handle(TColStd_HSequenceOfTransient) seq2d;
if (curve3d->NbEdges() == 1 && nbparam == 1 &&
IGESToBRep::IGESCurveToSequenceOfIGESCurve (start->ParametricCurve(iedge, 1), seq2d) == 1) {
Curves2d = new IGESData_HArray1OfIGESEntity (1, nbparam);
for (Standard_Integer i = 1; i <= nbparam; i++)
Curves2d->SetValue (i, start->ParametricCurve(iedge,i));
}
Handle(ShapeExtend_WireData) lsewd;//result of translation of current edge
Result = Result & IB->Transfer (okCurve, okCurve3d, okCurve2d,
curve3d, Curves2d, !orientation,
iedge, lsewd);
if (iedge == 1) sewd = IB->WireData();//initialization
if (curve3d->NbEdges() == 1 && lsewd->NbEdges() == 1) {//the condition corresponds to limitation above
//to keep sharing of edges all geometric representations should be put
//into the edge from EdgeList
TopoDS_Edge fromedge = lsewd->Edge(1), toedge = curve3d->Edge(1);
if (!fromedge.IsSame (toedge)) {
sbe.RemoveCurve3d (toedge);
IGESToBRep::TransferPCurve (fromedge, toedge, face);
sewd->Set (toedge, sewd->Index (fromedge));
}
}
}
}
//IB->Check(Result, Standard_True);
//pdn 20.04.99 CTS22655 avoid of exceptions in case of empty loops
if(!sewd.IsNull()) {
//IB.Fix (sewd, Standard_False, Standard_True, Standard_True, Standard_True, Standard_True);
mywire = sewd->Wire();
}
SetShapeResult(start, mywire);
}
TopoDS_Shape Sh = GetShapeResult(start);
if ( Sh.IsNull()) {
Message_Msg Msg1156("IGES_1156"); //The Loop is null
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1156.Arg("loop");
Msg1156.Arg(label);
SendWarning(start,Msg1156);
}
return Sh;
}
//=======================================================================
//function : TransferFace
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_BRepEntity::TransferFace
(const Handle(IGESSolid_Face)& start)
{
TopoDS_Shape res;
if (!HasShapeResult(start)) {
BRep_Builder B;
TopoDS_Face F;
Handle(IGESData_IGESEntity) surf = start->Surface();
Standard_Integer nbloops = start->NbLoops();
Standard_Boolean hasouterloop = start->HasOuterLoop();
IGESToBRep_TopoSurface TS(*this);
// surface
// -------
if (surf.IsNull() ||
!IGESToBRep::IsTopoSurface(surf) ||
surf->IsKind(STANDARD_TYPE(IGESGeom_Plane)) ||
surf->IsKind(STANDARD_TYPE(IGESGeom_BoundedSurface)) ||
surf->IsKind(STANDARD_TYPE(IGESGeom_TrimmedSurface)) ||
surf->IsKind(STANDARD_TYPE(IGESBasic_SingleParent)) ){
Message_Msg Msg196("XSTEP_196"); //"pas de surface de base pour creer la face"
SendWarning(start,Msg196);
// AddWarning(start, "pas de surface de base pour creer la face");
TopoDS_Shape Sh;
SetShapeResult(start,Sh);
}
else {
// si la surface IGES est une surface de revolution , il faudra
// inverser les courbes 2d (u,v) pour etre en accord avec le parametrage
// BRep.
gp_Trsf2d trans;
Standard_Real uFact;
TopoDS_Shape myshape = TS.ParamSurface(surf, trans, uFact);
if (!myshape.IsNull()) {
if (myshape.ShapeType() == TopAbs_FACE) {
//#62 rln 10.01.99 PRO17015 (reading back IGES written in 'BRep' mode) face #65
F = TopoDS::Face (myshape);
F.EmptyCopy();
if (!hasouterloop) B.NaturalRestriction (F,Standard_True);
// Loops
// -----
for (Standard_Integer iloop = 1; iloop <= nbloops; iloop++){
Handle(IGESSolid_Loop) loop = start->Loop(iloop);
TopoDS_Shape Shape = TransferLoop (loop, F, trans, uFact);
//pdn 20.04.99 CTS22655 avoid of exceptions in case of empty loops
if(!Shape.IsNull())
B.Add(F,Shape);
}
// update the face
BRepTools::Update (F);
F.Orientable(Standard_True);
SetShapeResult(start,F);
}
}
else {
Message_Msg Msg1156("IGES_1156"); //Face : result of TransferTopoSurface is Null
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(surf);
Msg1156.Arg("surface");
Msg1156.Arg(label);
SendFail(start,Msg1156);
// AddWarning(start,"Face : result of TransferTopoSurface is Null");
TopoDS_Shape Sh;
SetShapeResult(start,Sh);
}
}
}
TopoDS_Shape Sh = GetShapeResult(start);
if ( Sh.IsNull()) {
Message_Msg Msg1156("IGES_1156"); //the Face is a Null object.
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1156.Arg("face");
Msg1156.Arg(label);
SendFail(start,Msg1156);
// AddWarning (start, "the Face is a Null object.");
}
return Sh;
}
//=======================================================================
//function : TransferShell
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_BRepEntity::TransferShell
(const Handle(IGESSolid_Shell)& start)
{
TopoDS_Shape res;
if (!HasShapeResult(start)) {
TopoDS_Shell S;
BRep_Builder B;
B.MakeShell(S);
Standard_Integer nbfaces = start->NbFaces();
if (nbfaces != 0) {
Standard_Boolean closed = Standard_True; //:39
Handle(Message_ProgressIndicator) progress = GetTransferProcess()->GetProgress();
if ( ! progress.IsNull() ) progress->SetScale ( "Face", 0, nbfaces, 1 );
for (Standard_Integer iface = 1; iface <= nbfaces; iface++) {
if ( ! progress.IsNull() ) {
progress->Increment();
if ( progress->UserBreak() ) break;
}
Handle(IGESSolid_Face) face = start->Face(iface);
Standard_Boolean orientation = start->Orientation(iface);
TopoDS_Shape Sh = TransferFace(face);
if ( Sh.IsNull() ) { //:39 by abv 15.12.97
closed = Standard_False;
continue;
}
if (!orientation) Sh.Reverse();
B.Add(S,Sh);
}
if ( ! closed ) {
Message_Msg Msg1360("IGES_1360");
SendFail(start,Msg1360);
}
//AddWarning ( start, "Shell is not closed" ); //:39
S.Closed ( closed ); //:39
S.Orientable(Standard_True);
SetShapeResult(start,S);
}
else {
Message_Msg Msg200("XSTEP_200"); //Number of Faces = 0
SendFail(start,Msg200);
}
}
TopoDS_Shape Sh = GetShapeResult(start);
if ( Sh.IsNull()) {
Message_Msg Msg1156("IGES_1156"); //the Shell is a null object
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1156.Arg("shell");
Msg1156.Arg(label);
SendFail(start,Msg1156);
}
//AddWarning (start, "the Shell is a null object.");
res = Sh;
return res;
}
//=======================================================================
//function : TransferManifoldSolid
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_BRepEntity::TransferManifoldSolid
(const Handle(IGESSolid_ManifoldSolid)& start)
{
TopoDS_Shape res;
if (!HasShapeResult(start)) {
TopoDS_Solid S;
BRep_Builder B;
B.MakeSolid(S);
Handle(IGESSolid_Shell) shell = start->Shell();
Standard_Boolean isoriented = start->OrientationFlag();
Standard_Integer nbshell = start->NbVoidShells();
TopoDS_Shape Sh = TransferShell(shell);
if (!Sh.IsNull()) {
if (Sh.ShapeType() == TopAbs_SHELL) {
TopoDS_Shell Shell = TopoDS::Shell(Sh);
if (!isoriented) Shell.Reverse();
B.Add(S,Shell);
}
if (nbshell != 0) {
// progress scope without name, since usually we have single shell in solid
Message_ProgressSentry PS ( GetTransferProcess()->GetProgress(), 0, 0, nbshell, 1 );
for (Standard_Integer ishell=1; ishell<= nbshell && PS.More(); ishell++, PS.Next()) {
Handle(IGESSolid_Shell) voidshell= start->VoidShell(ishell);
// Standard_Boolean orientation = start->VoidOrientationFlag(ishell);
TopoDS_Shape aSh = TransferShell(voidshell);
if (!aSh.IsNull()) {
if (aSh.ShapeType() == TopAbs_SHELL) {
TopoDS_Shell Shell = TopoDS::Shell(aSh);
if (!isoriented) Shell.Reverse();
B.Add(S,Shell);
}
}
else {
// AddWarning(start,"ManifoldSolid : one VoidShell is Null");
TopoDS_Shell Shell;
B.Add(S,Shell);
}
}
}
}
SetShapeResult(start,S);
}
TopoDS_Shape Sh = GetShapeResult(start);
if ( Sh.IsNull()) {
Message_Msg Msg1156("IGES_1156"); //the ManifoldSolid is a null object.
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1156.Arg("solid");
Msg1156.Arg(label);
SendFail(start,Msg1156);
}
// AddWarning (start, "the ManifoldSolid is a null object.");
res = Sh;
return res;
}

View File

@@ -0,0 +1,136 @@
-- File: IGESToBRep_BasicCurve.cdl
-- Created: Mon Mar 14 14:02:21 1994
-- Authors: Christophe GUYOT & Frederic UNTEREINER
-- <fun@ecolox>
---Copyright: Matra Datavision 1994
class BasicCurve from IGESToBRep inherits CurveAndSurface from IGESToBRep
---Purpose : Provides methods to transfer basic geometric curves entities
-- from IGES to CASCADE.
-- These can be :
-- * Circular arc
-- * Conic arc
-- * Spline curve
-- * BSpline curve
-- * Line
-- * Copious data
-- * Point
-- * Transformation matrix
uses
CurveAndSurface from IGESToBRep,
IGESEntity from IGESData,
BSplineCurve from IGESGeom,
CircularArc from IGESGeom,
ConicArc from IGESGeom,
CopiousData from IGESGeom,
Line from IGESGeom,
Point from IGESGeom,
SplineCurve from IGESGeom,
TransformationMatrix from IGESGeom,
Curve from Geom,
BezierCurve from Geom,
BSplineCurve from Geom,
TrimmedCurve from Geom,
CartesianPoint from Geom,
Transformation from Geom,
Curve from Geom2d,
BezierCurve from Geom2d,
BSplineCurve from Geom2d,
TrimmedCurve from Geom2d,
CartesianPoint from Geom2d
is
Create returns BasicCurve;
---Purpose : Creates a tool BasicCurve ready to run, with
-- epsilons set to 1.E-04, TheModeTopo to True, the
-- optimization of the continuity to False.
Create(CS : CurveAndSurface from IGESToBRep) returns BasicCurve;
---Purpose : Creates a tool BasicCurve ready to run and sets its
-- fields as CS's.
Create(eps : Real;
epsGeom : Real;
epsCoeff : Real;
mode : Boolean;
modeapprox : Boolean;
optimized : Boolean) returns BasicCurve;
---Purpose : Creates a tool BasicCurve ready to run.
TransferBasicCurve (me : in out;
start : IGESEntity from IGESData)
returns mutable Curve from Geom;
---Purpose : Transfert a IGESEntity which answer True to the
-- member : IGESToBRep::IsBasicCurve(IGESEntity). If this
-- Entity could not be converted, this member returns a NullEntity.
Transfer2dBasicCurve (me : in out;
start : IGESEntity from IGESData)
returns mutable Curve from Geom2d;
---Purpose : Transfert a IGESEntity which answer True to the
-- member : IGESToBRep::IsBasicCurve(IGESEntity).
-- The IGESEntity must be a curve UV and its associed TRSF must
-- be planar .If this Entity could not be converted, this member
-- returns a NullEntity.
TransferBSplineCurve (me : in out;
start : BSplineCurve from IGESGeom)
returns mutable Curve from Geom;
Transfer2dBSplineCurve (me : in out;
start : BSplineCurve from IGESGeom)
returns mutable Curve from Geom2d;
TransferCircularArc (me : in out;
start : CircularArc from IGESGeom)
returns mutable Curve from Geom;
Transfer2dCircularArc (me : in out;
start : CircularArc from IGESGeom)
returns mutable Curve from Geom2d;
TransferConicArc (me : in out;
start : ConicArc from IGESGeom)
returns mutable Curve from Geom;
Transfer2dConicArc (me : in out;
start : ConicArc from IGESGeom)
returns mutable Curve from Geom2d;
TransferCopiousData (me : in out;
start : CopiousData from IGESGeom)
returns mutable BSplineCurve from Geom;
Transfer2dCopiousData (me : in out;
start : CopiousData from IGESGeom)
returns mutable BSplineCurve from Geom2d;
TransferLine (me : in out;
start : Line from IGESGeom)
returns mutable Curve from Geom;
Transfer2dLine (me : in out;
start : Line from IGESGeom)
returns mutable Curve from Geom2d;
TransferSplineCurve (me : in out;
start : SplineCurve from IGESGeom)
returns mutable BSplineCurve from Geom;
Transfer2dSplineCurve (me : in out;
start : SplineCurve from IGESGeom)
returns mutable BSplineCurve from Geom2d;
TransferTransformation (me : in out;
start : TransformationMatrix from IGESGeom)
returns mutable Transformation from Geom;
end BasicCurve;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,103 @@
-- File: IGESToBRep_BasicSurface.cdl
-- Created: Mon Mar 14 14:02:21 1994
-- Author: Frederic UNTEREINER
-- <fun@ecolox>
---Copyright: Matra Datavision 1994
class BasicSurface from IGESToBRep inherits CurveAndSurface from IGESToBRep
---Purpose : Provides methods to transfer basic geometric surface entities
-- from IGES to CASCADE.
-- These can be :
-- * Spline surface
-- * BSpline surface
uses
CurveAndSurface from IGESToBRep,
PlaneSurface from IGESSolid,
CylindricalSurface from IGESSolid,
ConicalSurface from IGESSolid,
SphericalSurface from IGESSolid,
ToroidalSurface from IGESSolid,
IGESEntity from IGESData,
SplineSurface from IGESGeom,
BSplineSurface from IGESGeom,
Surface from Geom,
BSplineSurface from Geom,
Plane from Geom,
CylindricalSurface from Geom,
ConicalSurface from Geom,
SphericalSurface from Geom,
ToroidalSurface from Geom
is
Create returns BasicSurface;
---Purpose: Creates a tool BasicSurface ready to run, with
-- epsilons set to 1.E-04, TheModeTopo to True, the
-- optimization of the continuity to False.
Create(CS : CurveAndSurface from IGESToBRep) returns BasicSurface;
---Purpose: Creates a tool BasicSurface ready to run and sets its
-- fields as CS's.
Create(eps : Real;
epsGeom : Real;
epsCoeff : Real;
mode : Boolean;
modeapprox : Boolean;
optimized : Boolean)
returns BasicSurface;
---Purpose: Creates a tool BasicSurface ready to run.
TransferBasicSurface (me : in out;
start : IGESEntity from IGESData)
returns mutable Surface from Geom;
---Purpose: Returns Surface from Geom if the last transfer has
-- succeded.
TransferPlaneSurface (me : in out;
start : PlaneSurface from IGESSolid)
returns mutable Plane from Geom;
---Purpose: Returns Plane from Geom if the transfer has
-- succeded.
TransferRigthCylindricalSurface(me : in out;
start: CylindricalSurface from IGESSolid)
returns mutable CylindricalSurface from Geom;
---Purpose: Returns CylindricalSurface from Geom if the transfer has
-- succeded.
TransferRigthConicalSurface (me : in out;
start: ConicalSurface from IGESSolid)
returns mutable ConicalSurface from Geom;
---Purpose: Returns ConicalSurface from Geom if the transfer has
-- succeded.
TransferSphericalSurface(me : in out;
start: SphericalSurface from IGESSolid)
returns mutable SphericalSurface from Geom;
---Purpose: Returns SphericalSurface from Geom if the transfer has
-- succeded.
TransferToroidalSurface (me : in out;
start: ToroidalSurface from IGESSolid)
returns mutable ToroidalSurface from Geom;
---Purpose: Returns SphericalSurface from Geom if the transfer has
-- succeded.
TransferSplineSurface (me : in out;
start: SplineSurface from IGESGeom)
returns mutable BSplineSurface from Geom;
---Purpose: Returns BSplineSurface from Geom if the transfer has
-- succeded.
TransferBSplineSurface (me : in out;
start: BSplineSurface from IGESGeom)
returns mutable BSplineSurface from Geom;
---Purpose: Returns BSplineSurface from Geom if the transfer has
-- succeded.
end BasicSurface;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,236 @@
-- File: IGESToBRep_CurveAndSurface.cdl
-- Created: Mon Mar 14 14:02:21 1994
-- Authors: Christophe GUYOT & Frederic UNTEREINER
-- <fun@ecolox>
---Copyright: Matra Datavision 1994
class CurveAndSurface from IGESToBRep
---Purpose: Provides methods to transfer CurveAndSurface from IGES to CASCADE.
uses
Integer from Standard,
Real from Standard,
Boolean from Standard,
Shape from TopoDS,
IGESEntity from IGESData,
IGESModel from IGESData,
CString from Standard,
TransientProcess from Transfer,
Surface from Geom,
Msg from Message
is
Create returns CurveAndSurface;
---Purpose: Creates a tool CurveAndSurface ready to run, with
-- epsilons set to 1.E-04, myModeTopo to True, the
-- optimization of the continuity to False.
Create(CS : CurveAndSurface from IGESToBRep) returns CurveAndSurface;
---Purpose: Creates a tool CurveAndSurface ready to run and sets its
-- fields as CS's.
Create(eps : Real;
epsGeom : Real;
epsCoeff : Real;
mode : Boolean;
modeapprox : Boolean;
optimized : Boolean) returns CurveAndSurface;
---Purpose: Creates a tool CurveAndSurface ready to run.
Init(me: in out);
---Purpose: Initializes the field of the tool CurveAndSurface with
-- default creating values.
SetEpsilon(me: in out; eps : Real);
---C++: inline
---Purpose: Changes the value of "myEps"
GetEpsilon(me) returns Real;
---C++: inline
---Purpose: Returns the value of "myEps"
SetEpsCoeff(me: in out; eps : Real);
---C++: inline
---Purpose: Changes the value of "myEpsCoeff"
GetEpsCoeff(me) returns Real;
---C++: inline
---Purpose: Returns the value of "myEpsCoeff"
SetEpsGeom(me: in out; eps : Real);
---Purpose: Changes the value of "myEpsGeom"
GetEpsGeom(me) returns Real;
---C++: inline
---Purpose: Returns the value of "myEpsGeom"
SetMinTol(me: in out; mintol: Real);
---C++: inline
---Purpose: Changes the value of "myMinTol"
SetMaxTol(me: in out; maxtol: Real);
---C++: inline
---Purpose: Changes the value of "myMaxTol"
UpdateMinMaxTol(me: in out);
---Purpose: Sets values of "myMinTol" and "myMaxTol" as follows
-- myMaxTol = Max ("read.maxprecision.val", myEpsGeom * myUnitFactor)
-- myMinTol = Precision::Confusion()
-- Remark: This method is automatically invoked each time the values
-- of "myEpsGeom" or "myUnitFactor" are changed
GetMinTol(me) returns Real;
---C++: inline
---Purpose: Returns the value of "myMinTol"
GetMaxTol(me) returns Real;
---C++: inline
---Purpose: Returns the value of "myMaxTol"
SetModeApprox(me: in out; mode : Boolean);
---C++: inline
---Purpose: Changes the value of "myModeApprox"
GetModeApprox(me) returns Boolean;
---C++: inline
---Purpose: Returns the value of "myModeApprox"
SetModeTransfer(me: in out; mode : Boolean);
---C++: inline
---Purpose: Changes the value of "myModeIsTopo"
GetModeTransfer(me) returns Boolean;
---C++: inline
---Purpose: Returns the value of "myModeIsTopo"
SetOptimized(me: in out; optimized : Boolean);
---C++: inline
---Purpose: Changes the value of "myContIsOpti"
GetOptimized(me) returns Boolean;
---C++: inline
---Purpose: Returns the value of "myContIsOpti"
GetUnitFactor(me) returns Real;
---C++: inline
---Purpose: Returns the value of " myUnitFactor"
SetSurfaceCurve(me: in out; ival : Integer);
---C++: inline
---Purpose: Changes the value of "mySurfaceCurve"
GetSurfaceCurve(me) returns Integer;
---C++: inline
---Purpose: Returns the value of " mySurfaceCurve" 0 = value in
-- file , 2 = kepp 2d and compute 3d 3 = keep 3d and
-- compute 2d
SetModel(me: in out; model : IGESModel from IGESData);
---Purpose: Set the value of "myModel"
GetModel(me) returns IGESModel from IGESData;
---C++: inline
---Purpose: Returns the value of "myModel"
SetContinuity(me: in out; continuity : Integer);
---C++: inline
---Purpose: Changes the value of "myContinuity"
-- if continuity = 0 do nothing else
-- if continuity = 1 try C1
-- if continuity = 2 try C2
GetContinuity(me) returns Integer;
---C++: inline
---Purpose: Returns the value of "myContinuity"
SetTransferProcess(me: in out; TP: TransientProcess from Transfer);
---C++: inline
---Purpose: Set the value of "myMsgReg"
GetTransferProcess(me) returns TransientProcess from Transfer;
---C++: inline
---Purpose: Returns the value of "myMsgReg"
TransferCurveAndSurface(me: in out; start : IGESEntity from IGESData)
returns Shape from TopoDS;
---Purpose: Returns the result of the transfert of any IGES Curve
-- or Surface Entity. If the transfer has failed, this
-- member return a NullEntity.
TransferGeometry(me: in out; start : IGESEntity from IGESData)
returns Shape from TopoDS;
---Purpose: Returns the result of the transfert the geometry of
-- any IGESEntity. If the transfer has failed, this
-- member return a NullEntity.
SendFail (me: in out; start: IGESEntity from IGESData; amsg: Msg from Message);
---C++: inline
---Purpose: Records a new Fail message
SendWarning (me: in out; start: IGESEntity from IGESData; amsg: Msg from Message);
---C++: inline
---Purpose: Records a new Warning message
SendMsg (me: in out; start: IGESEntity from IGESData; amsg: Msg from Message);
---C++: inline
---Purpose: Records a new Information message from the definition
-- of a Msg (Original+Value)
HasShapeResult (me; start : IGESEntity from IGESData) returns Boolean;
---Purpose: Returns True if start was already treated and has a result in "myMap"
-- else returns False.
GetShapeResult (me; start : IGESEntity from IGESData) returns Shape from TopoDS;
---Purpose: Returns the result of the transfer of the IGESEntity "start" contained
-- in "myMap" . (if HasShapeResult is True).
SetShapeResult (me: in out; start : IGESEntity from IGESData; result : Shape from TopoDS);
---Purpose: set in "myMap" the result of the transfer of the IGESEntity "start".
NbShapeResult (me; start : IGESEntity from IGESData) returns Integer;
---Purpose: Returns the number of shapes results contained in "myMap" for the
-- IGESEntity start ( type VertexList or EdgeList).
GetShapeResult (me; start: IGESEntity from IGESData; num: Integer) returns Shape from TopoDS;
---Purpose: Returns the numth result of the IGESEntity start (type VertexList or
-- EdgeList) in "myMap". (if NbShapeResult is not null).
AddShapeResult (me: in out; start: IGESEntity from IGESData; result: Shape from TopoDS);
---Purpose: set in "myMap" the result of the transfer of the entity of the
-- IGESEntity start ( type VertexList or EdgeList).
SetSurface(me: in out; theSurface: Surface from Geom);
Surface(me) returns Surface from Geom;
GetUVResolution(me: in out) returns Real;
fields
myEps : Real;
myEpsCoeff : Real;
myEpsGeom : Real;
myMinTol : Real; -- Minimum tolerance used by translation algorithms
myMaxTol : Real; -- Maximum tolerance used by translation algorithms
myModeIsTopo : Boolean;
myModeApprox : Boolean;
myContIsOpti : Boolean;
myUnitFactor : Real;
mySurfaceCurve : Integer;
myContinuity : Integer;
mySurface : Surface from Geom;
myUVResolution : Real;
myIsResolCom : Boolean;
myModel : IGESModel from IGESData ;
myTP : TransientProcess from Transfer;
end CurveAndSurface;

View File

@@ -0,0 +1,662 @@
// 22.12.98 dce S3767
// 21.12.98 rln, gka S4054
//#74 rln,pdn 11.03.99 S4135: Setting minimum and maximum tolerances according to static parameters
// sln 13.06.2002 OCC448 : Correction in method TransferGeometry to avoid transfering invisiable sub entities
#include <Standard_ErrorHandler.hxx>
#include <IGESToBRep_CurveAndSurface.ixx>
#include <Standard_Failure.hxx>
#include <IGESToBRep.hxx>
#include <IGESToBRep_TopoCurve.hxx>
#include <IGESToBRep_TopoSurface.hxx>
#include <IGESToBRep_BRepEntity.hxx>
#include <IGESBasic_Group.hxx>
#include <IGESBasic_GroupWithoutBackP.hxx>
#include <IGESBasic_SubfigureDef.hxx>
#include <IGESBasic_SingularSubfigure.hxx>
#include <IGESData_ToolLocation.hxx>
#include <BRep_Builder.hxx>
#include <BRepLib.hxx>
#include <gp_Trsf.hxx>
#include <gp_GTrsf.hxx>
#include <gp_Vec.hxx>
#include <Precision.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Static.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
#include <Transfer_TransientProcess.hxx>
#include <TransferBRep_ShapeBinder.hxx>
#include <TransferBRep_ShapeListBinder.hxx>
#include <stdio.h>
#include <Message_Msg.hxx>
#include <Message_Messenger.hxx>
#include <Message_ProgressSentry.hxx>
#include <GeomAdaptor_Surface.hxx>
//=======================================================================
//function : IGESToBRep_CurveAndSurface
//purpose :
//=======================================================================
IGESToBRep_CurveAndSurface::IGESToBRep_CurveAndSurface()
{
Init();
}
//=======================================================================
//function : IGESToBRep_CurveAndSurface
//purpose :
//=======================================================================
IGESToBRep_CurveAndSurface::IGESToBRep_CurveAndSurface
(const IGESToBRep_CurveAndSurface& other)
{
myEps = other.GetEpsilon();
myEpsCoeff = other.GetEpsCoeff();
myEpsGeom = other.GetEpsGeom();
myMaxTol = other.GetMaxTol();
myModeIsTopo = other.GetModeTransfer();
myModeApprox = other.GetModeApprox();
myContIsOpti = other.GetOptimized();
myUnitFactor = other.GetUnitFactor();
mySurfaceCurve = other.GetSurfaceCurve();
myContinuity = other.GetContinuity();
myModel = other.GetModel();
myTP = other.GetTransferProcess();
myMinTol = other.GetMinTol();
mySurface = other.Surface();
myIsResolCom = other.myIsResolCom;
myUVResolution = other.myUVResolution;
}
//=======================================================================
//function : IGESToBRep_CurveAndSurface
//purpose :
//=======================================================================
IGESToBRep_CurveAndSurface::IGESToBRep_CurveAndSurface
(const Standard_Real eps,
const Standard_Real epsCoeff,
const Standard_Real epsGeom,
const Standard_Boolean mode,
const Standard_Boolean modeapprox,
const Standard_Boolean optimized)
{
myEps = eps;
myEpsCoeff = epsCoeff;
myEpsGeom = epsGeom;
myModeIsTopo = mode;
myModeApprox = modeapprox;
myContIsOpti = optimized;
myUnitFactor = 1.;
mySurfaceCurve = 0;
myContinuity = 0;
myTP = new Transfer_TransientProcess();
myIsResolCom = Standard_False;
myUVResolution = 0.;
UpdateMinMaxTol();
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void IGESToBRep_CurveAndSurface::Init()
{
myEps = 1.E-04;
myEpsCoeff = 1.E-06;
myEpsGeom = 1.E-04;
myModeIsTopo = Standard_True;
myModeApprox = Standard_False;
myContIsOpti = Standard_False;
myUnitFactor = 1.;
mySurfaceCurve = 0;
myContinuity = 0;
myTP = new Transfer_TransientProcess();
mySurface.Nullify();
myIsResolCom = Standard_False;
myUVResolution = 0.;
UpdateMinMaxTol();
}
//=======================================================================
//function : SetEpsGeom
//purpose :
//=======================================================================
void IGESToBRep_CurveAndSurface::SetEpsGeom(const Standard_Real eps)
{
myEpsGeom = eps;
UpdateMinMaxTol();
}
//=======================================================================
//function : UpdateMinMaxTol
//purpose :
//=======================================================================
void IGESToBRep_CurveAndSurface::UpdateMinMaxTol()
{
//#74 rln 11.03.99 S4135: Setting maximum tolerances according to
//static parameter
myMaxTol = Max (Interface_Static::RVal ("read.maxprecision.val"), myEpsGeom * myUnitFactor);
myMinTol = Precision::Confusion();
}
//=======================================================================
//function : SetModel
//purpose :
//=======================================================================
void IGESToBRep_CurveAndSurface::SetModel(const Handle(IGESData_IGESModel)& model)
{
myModel = model;
Standard_Real unitfactor = myModel->GlobalSection().UnitValue();
if (unitfactor != 1.)
{
if ( myTP->TraceLevel() > 2 )
myTP->Messenger() << "UnitFactor = "<< unitfactor << endl;
myUnitFactor = unitfactor;
}
UpdateMinMaxTol();
}
//=======================================================================
//function : TransferCurveAndSurface
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_CurveAndSurface::TransferCurveAndSurface
(const Handle(IGESData_IGESEntity)& start)
{
TopoDS_Shape res;
if (start.IsNull()) {
Message_Msg msg1005("IGES_1005");
SendFail(start, msg1005);
return res;
}
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
// Standard_Integer typeNumber = start->TypeNumber();
if (IGESToBRep::IsTopoCurve(start)) {
IGESToBRep_TopoCurve TC(*this);
res = TC.TransferTopoCurve(start);
}
else if (IGESToBRep::IsTopoSurface(start)) {
IGESToBRep_TopoSurface TS(*this);
res = TS.TransferTopoSurface(start);
}
else if (IGESToBRep::IsBRepEntity(start)) {
IGESToBRep_BRepEntity TS(*this);
res = TS.TransferBRepEntity(start);
}
else {
Message_Msg msg1015("IGES_1015");
SendFail(start, msg1015);
// AddFail(start, "The IGESEntity is not a curve a Surface or a BRep Entity.");
}
// mjm le 12/09/96
/*
if (!res.IsNull()) {
try {
OCC_CATCH_SIGNALS
Standard_Real Eps = GetEpsGeom()*GetUnitFactor();
BRepLib::SameParameter(res,Eps);
}
catch(Standard_Failure) {
Message_Msg msg1010("IGES_1010");
SendWarning (start,msg1010);
}
}
*/
return res;
}
//=======================================================================
//function : TransferGeometry
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry
(const Handle(IGESData_IGESEntity)& start)
{
// Declaration of messages//
// DCE 22/12/98
//Message_Msg msg1005("IGES_1005"); // Software error : start IsNull.
//Message_Msg msg1015("IGES_1015"); // invalid type or execption raising (software error).
//Message_Msg msg1010("IGES_1010"); // Not sameparameter.
// Message_Msg msg1015("IGES_1015");
//Message_Msg msg210 ("XSTEP_210");
//Message_Msg msg202 ("XSTEP_202");
////////////////////////////
TopoDS_Shape res;
gp_Trsf T408;
if (start.IsNull()) {
Message_Msg msg1005("IGES_1005"); // Software error : start IsNull.
SendFail(start, msg1005);
return res;
}
// Read of the DE number and the type number of the entity
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
//Standard_Integer typeNumber = start->TypeNumber();
// sln 13.06.2002 OCC448: Avoid transfering invisiable sub entities which
// logicaly depend on the one
Standard_Integer onlyvisible = Interface_Static::IVal("read.iges.onlyvisible");
if (IGESToBRep::IsCurveAndSurface(start)) {
if(onlyvisible && start->BlankStatus() == 1)
return res;
try {
OCC_CATCH_SIGNALS
res = TransferCurveAndSurface(start);
}
catch(Standard_Failure) {
Message_Msg msg1015("IGES_1015");
SendFail(start, msg1015);
}
return res;
}
//408 : SingularSubfigure
if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure)))
{
if(onlyvisible && start->BlankStatus() == 1)
return res;
DeclareAndCast(IGESBasic_SingularSubfigure, st408, start);
Handle (IGESBasic_SubfigureDef) stsub = st408->Subfigure();
gp_XYZ trans = st408->Translation();
gp_Vec vectr(trans);
Standard_Real scunit = GetUnitFactor();
vectr.Multiply(scunit);
T408.SetTranslation(vectr);
if (st408->HasScaleFactor()) {
Standard_Real scalef = st408->ScaleFactor();
T408.SetScaleFactor(scalef);
}
if (HasShapeResult(stsub)) {
res = GetShapeResult(stsub);
}
else {
try {
OCC_CATCH_SIGNALS
res = TransferGeometry(stsub);
}
catch(Standard_Failure) {
res.Nullify();
Message_Msg msg1015("IGES_1015");
SendFail( st408, msg1015);
}
if (!res.IsNull()) {
SetShapeResult(stsub,res);
}
}
}
// 308 : SubfigureDefinition
else if (start->IsKind(STANDARD_TYPE(IGESBasic_SubfigureDef))) {
DeclareAndCast(IGESBasic_SubfigureDef, st308, start);
TopoDS_Compound group;
BRep_Builder B;
B.MakeCompound (group);
if (st308->NbEntities() < 1) {
Message_Msg msg210 ("XSTEP_210");
SendFail( st308, msg210);
return res;
}
Message_ProgressSentry PS ( myTP->GetProgress(), "Subfigure item", 0, st308->NbEntities(), 1 );
for (Standard_Integer i=1; i <= st308->NbEntities() && PS.More(); i++, PS.Next()) {
TopoDS_Shape item;
if (st308->AssociatedEntity(i).IsNull()) {
Message_Msg msg1020("IGES_1020");
msg1020.Arg(i);
SendWarning( st308, msg1020);
continue;
}
if(onlyvisible && st308->AssociatedEntity(i)->BlankStatus() == 1 )
continue;
if (HasShapeResult(st308->AssociatedEntity(i)))
{
item = GetShapeResult(st308->AssociatedEntity(i));
}
else {
try {
OCC_CATCH_SIGNALS
item = TransferGeometry(st308->AssociatedEntity(i));
}
catch(Standard_Failure) {
item.Nullify();
Message_Msg msg1015("IGES_1015");
SendFail( st308->AssociatedEntity(i), msg1015);
}
}
if (item.IsNull()) {
Message_Msg msg1025("IGES_1025");
msg1025.Arg(i);
SendWarning (start,msg1025);
}
else {
B.Add(group, item);
SetShapeResult (st308->AssociatedEntity(i),item);
}
}
res = group;
}
else if (start->IsKind(STANDARD_TYPE(IGESBasic_Group))) {
if(onlyvisible && start->BlankStatus() == 1)
return res;
DeclareAndCast(IGESBasic_Group, st402f1, start);
TopoDS_Compound group;
BRep_Builder B;
B.MakeCompound (group);
if (st402f1->NbEntities() < 1) {
Message_Msg msg202 ("XSTEP_202");
msg202.Arg(st402f1->FormNumber());
SendFail(st402f1, msg202);
return res;
}
Message_ProgressSentry PS ( myTP->GetProgress(), "Group item", 0, st402f1->NbEntities(), 1 );
Standard_Boolean ProblemInGroup = Standard_False;
for (Standard_Integer i=1; i <= st402f1->NbEntities() && PS.More(); i++, PS.Next()) {
TopoDS_Shape item;
if (st402f1->Entity(i).IsNull()) {
Message_Msg msg1020("IGES_1020");
msg1020.Arg(i);
SendFail( st402f1, msg1020);
continue;
}
if(onlyvisible && st402f1->Entity(i)->BlankStatus() == 1)
continue;
if (HasShapeResult(st402f1->Entity(i))) {
item = GetShapeResult(st402f1->Entity(i));
}
else {
try {
OCC_CATCH_SIGNALS
item = TransferGeometry(st402f1->Entity(i));
}
catch(Standard_Failure) {
item.Nullify();
Message_Msg msg1015("IGES_1015");
SendFail(st402f1->Entity(i),msg1015);
}
}
if (item.IsNull()) {
//Message_Msg msg1030("IGES_1030");
//msg1030.Arg(st402f1->FormNumber());
//msg1030.Arg(i);
//SendWarning (st402f1,msg1030);
ProblemInGroup = Standard_True;
}
else {
B.Add(group, item);
SetShapeResult (st402f1->Entity(i),item);
}
}
res = group;
if(ProblemInGroup) {
Message_Msg msg1030("IGES_1030");
msg1030.Arg(st402f1->FormNumber());
SendWarning (st402f1,msg1030);
}
}
else if (start->IsKind(STANDARD_TYPE(IGESBasic_GroupWithoutBackP))) {
if(onlyvisible && start->BlankStatus() == 1)
return res;
DeclareAndCast(IGESBasic_GroupWithoutBackP, st402f7, start);
TopoDS_Compound group;
//unused Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(st402f7);
BRep_Builder B;
B.MakeCompound (group);
if (st402f7->NbEntities() < 1) {
Message_Msg msg202 ("XSTEP_202");
msg202.Arg(st402f7->FormNumber());
SendFail(st402f7, msg202);
return res;
}
Message_ProgressSentry PS ( myTP->GetProgress(), "Group item", 0, st402f7->NbEntities(), 1 );
Standard_Boolean ProblemInGroup = Standard_False;
for (Standard_Integer i=1; i <= st402f7->NbEntities() && PS.More(); i++, PS.Next()) {
TopoDS_Shape item;
if (st402f7->Entity(i).IsNull()) {
Message_Msg msg1020("IGES_1020");
msg1020.Arg(i);
SendFail( st402f7, msg1020);
continue;
}
if(onlyvisible && st402f7->Entity(i)->BlankStatus() == 1 )
continue;
if (HasShapeResult(st402f7->Entity(i))) {
item = GetShapeResult(st402f7->Entity(i));
}
else {
try {
OCC_CATCH_SIGNALS
item = TransferGeometry(st402f7->Entity(i));
}
catch(Standard_Failure) {
item.Nullify();
Message_Msg msg1015("IGES_1015");
SendFail(st402f7->Entity(i),msg1015);
}
}
if (item.IsNull()) {
//Message_Msg msg1030("IGES_1030");
//msg1030.Arg(st402f7->FormNumber());
//msg1030.Arg(i);
//SendWarning (st402f7,msg1030);
ProblemInGroup = Standard_True;
}
else {
B.Add(group, item);
SetShapeResult (st402f7->Entity(i),item);
}
}
res = group;
if(ProblemInGroup) {
Message_Msg msg1030("IGES_1030");
msg1030.Arg(st402f7->FormNumber());
SendWarning (st402f7,msg1030);
}
}
else {
Message_Msg msg1001("IGES_1001");
msg1001.Arg(start->FormNumber());
SendFail (start,msg1001);
return res;
}
if (start->HasTransf()) {
gp_Trsf T;
SetEpsilon(1.E-04);
if (IGESData_ToolLocation::ConvertLocation(GetEpsilon(),start->CompoundLocation(),
T,GetUnitFactor())) {
if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure)))
{
gp_XYZ tra = T.TranslationPart();
gp_XYZ trans = T408.TranslationPart();
tra.Add(trans);
T.SetTranslationPart(tra);
Standard_Real sc = T.ScaleFactor();
Standard_Real scalef = T408.ScaleFactor();
sc = sc*scalef;
T.SetScaleFactor(sc);
}
TopLoc_Location L(T);
res.Move(L);
}
else {
Message_Msg msg1035("IGES_1035");
SendWarning (start,msg1035);
}
}
else {
if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure))) {
TopLoc_Location L(T408);
res.Move(L);
}
}
return res;
}
//=======================================================================
//function : HasShapeResult
//purpose :
//=======================================================================
Standard_Boolean IGESToBRep_CurveAndSurface::HasShapeResult
(const Handle(IGESData_IGESEntity)& start) const
{
DeclareAndCast(TransferBRep_ShapeBinder,binder,myTP->Find(start));
if (binder.IsNull()) return Standard_False;
return binder->HasResult();
}
//=======================================================================
//function : GetShapeResult
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_CurveAndSurface::GetShapeResult
(const Handle(IGESData_IGESEntity)& start) const
{
TopoDS_Shape res;
DeclareAndCast(TransferBRep_ShapeBinder, binder, myTP->Find(start));
if (binder.IsNull()) return res;
if (binder->HasResult())
res = binder->Result();
return res;
}
//=======================================================================
//function : SetShapeResult
//purpose :
//=======================================================================
void IGESToBRep_CurveAndSurface::SetShapeResult
(const Handle(IGESData_IGESEntity)& start,
const TopoDS_Shape& result)
{
Handle(TransferBRep_ShapeBinder) binder = new TransferBRep_ShapeBinder;
myTP->Bind(start,binder);
binder->SetResult(result);
}
//=======================================================================
//function : NbShapeResult
//purpose :
//=======================================================================
Standard_Integer IGESToBRep_CurveAndSurface::NbShapeResult
(const Handle(IGESData_IGESEntity)& start) const
{
Standard_Integer nbres = 0;
DeclareAndCast(TransferBRep_ShapeListBinder,binder,myTP->Find(start));
if (binder.IsNull()) return nbres;
nbres = binder->NbShapes();
return nbres;
}
//=======================================================================
//function : GetShapeResult
//purpose :
//=======================================================================
TopoDS_Shape IGESToBRep_CurveAndSurface::GetShapeResult
(const Handle(IGESData_IGESEntity)& start, const Standard_Integer num) const
{
TopoDS_Shape res;
DeclareAndCast(TransferBRep_ShapeListBinder,binder,myTP->Find(start));
if (binder.IsNull()) return res;
if (num <= binder->NbShapes())
res = binder->Shape(num);
return res;
}
//=======================================================================
//function : AddShapeResult
//purpose :
//=======================================================================
void IGESToBRep_CurveAndSurface::AddShapeResult
(const Handle(IGESData_IGESEntity)& start,
const TopoDS_Shape& result)
{
DeclareAndCast(TransferBRep_ShapeListBinder,binder,myTP->Find(start));
if (binder.IsNull()){
binder = new TransferBRep_ShapeListBinder;
myTP->Bind(start,binder);
}
binder->AddResult(result);
}
void IGESToBRep_CurveAndSurface::SetSurface(const Handle(Geom_Surface)& theSurface)
{
if(mySurface!=theSurface) {
mySurface = theSurface;
myIsResolCom = Standard_False;
myUVResolution = 0.;
}
}
Handle(Geom_Surface) IGESToBRep_CurveAndSurface::Surface() const
{
return mySurface;
}
Standard_Real IGESToBRep_CurveAndSurface::GetUVResolution()
{
if(!myIsResolCom && !mySurface.IsNull()) {
myIsResolCom = Standard_True;
GeomAdaptor_Surface aGAS(mySurface);
myUVResolution = Min(aGAS.UResolution(1.), aGAS.VResolution(1.));
}
return myUVResolution;
}

View File

@@ -0,0 +1,296 @@
// File: IGESToBRep_CurveAndSurface.lxx
// Created: Mon Jan 31 15:34:59 2000
// Author: data exchange team
// <det@kinox>
#include <Transfer_TransientProcess.hxx>
//=======================================================================
//function : SetEpsilon
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetEpsilon(const Standard_Real eps)
{
myEps = eps;
}
//=======================================================================
//function : GetEpsilon
//purpose :
//=======================================================================
inline Standard_Real IGESToBRep_CurveAndSurface::GetEpsilon() const
{
return myEps;
}
//=======================================================================
//function : SetEpsCoeff
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetEpsCoeff(const Standard_Real eps)
{
myEpsCoeff = eps;
}
//=======================================================================
//function : GetEpsCoeff
//purpose :
//=======================================================================
inline Standard_Real IGESToBRep_CurveAndSurface::GetEpsCoeff() const
{
return myEpsCoeff;
}
//=======================================================================
//function : GetEpsGeom
//purpose :
//=======================================================================
inline Standard_Real IGESToBRep_CurveAndSurface::GetEpsGeom() const
{
return myEpsGeom;
}
//=======================================================================
//function : SetMinTol
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetMinTol(const Standard_Real mintol)
{
myMinTol = mintol;
}
//=======================================================================
//function : SetMaxTol
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetMaxTol(const Standard_Real maxtol)
{
myMaxTol = maxtol;
}
//=======================================================================
//function : GetMinTol
//purpose :
//=======================================================================
inline Standard_Real IGESToBRep_CurveAndSurface::GetMinTol() const
{
return myMinTol;
}
//=======================================================================
//function : GetMaxTol
//purpose :
//=======================================================================
inline Standard_Real IGESToBRep_CurveAndSurface::GetMaxTol() const
{
return myMaxTol;
}
//=======================================================================
//function : SetModeApprox
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetModeApprox(const Standard_Boolean mode)
{
myModeApprox = mode;
}
//=======================================================================
//function : GetModeApprox
//purpose :
//=======================================================================
inline Standard_Boolean IGESToBRep_CurveAndSurface::GetModeApprox() const
{
return myModeApprox;
}
//=======================================================================
//function : SetModeTransfer
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetModeTransfer(const Standard_Boolean mode)
{
myModeIsTopo = mode;
}
//=======================================================================
//function : GetModeTransfer
//purpose :
//=======================================================================
inline Standard_Boolean IGESToBRep_CurveAndSurface::GetModeTransfer() const
{
return myModeIsTopo;
}
//=======================================================================
//function : SetOptimized
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetOptimized(const Standard_Boolean optimized)
{
myContIsOpti = optimized;
}
//=======================================================================
//function : GetOptimized
//purpose :
//=======================================================================
inline Standard_Boolean IGESToBRep_CurveAndSurface::GetOptimized() const
{
return myContIsOpti;
}
//=======================================================================
//function : GetUnitFactor
//purpose :
//=======================================================================
inline Standard_Real IGESToBRep_CurveAndSurface::GetUnitFactor() const
{
return myUnitFactor;
}
//=======================================================================
//function : SetSurfaceCurve
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetSurfaceCurve(const Standard_Integer ival)
{
mySurfaceCurve = ival;
}
//=======================================================================
//function : GetSurfaceCurve
//purpose :
//=======================================================================
inline Standard_Integer IGESToBRep_CurveAndSurface::GetSurfaceCurve() const
{
return mySurfaceCurve;
}
//=======================================================================
//function : GetModel
//purpose :
//=======================================================================
inline Handle(IGESData_IGESModel) IGESToBRep_CurveAndSurface::GetModel() const
{
return myModel;
}
//=======================================================================
//function : SetContinuity
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetContinuity(const Standard_Integer continuity)
{
myContinuity = continuity;
}
//=======================================================================
//function : GetContinuity
//purpose :
//=======================================================================
inline Standard_Integer IGESToBRep_CurveAndSurface::GetContinuity() const
{
return myContinuity;
}
//=======================================================================
//function : SetTransferProcess
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SetTransferProcess(const Handle(Transfer_TransientProcess)& TP)
{
myTP = TP;
}
//=======================================================================
//function : GetTransferProcess
//purpose :
//=======================================================================
inline Handle(Transfer_TransientProcess) IGESToBRep_CurveAndSurface::GetTransferProcess() const
{
return myTP;
}
//=======================================================================
//function : SendFail
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SendFail (const Handle(IGESData_IGESEntity)& start,
const Message_Msg& amsg)
{
GetTransferProcess()->SendFail(start,amsg);
}
//=======================================================================
//function : SendWarning
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SendWarning (const Handle(IGESData_IGESEntity)& start,
const Message_Msg& amsg)
{
GetTransferProcess()->SendWarning(start,amsg);
}
//=======================================================================
//function : SendMsg
//purpose :
//=======================================================================
inline void IGESToBRep_CurveAndSurface::SendMsg (const Handle(IGESData_IGESEntity)& start,
const Message_Msg& amsg)
{
GetTransferProcess()->SendMsg(start,amsg);
}

View File

@@ -0,0 +1,151 @@
-- File: IGESToBRep_IGESBoundary.cdl
-- Created: Wed Dec 16 16:27:16 1998
-- Author: Roman LYGIN
-- <rln@kinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class IGESBoundary from IGESToBRep inherits TShared from MMgt
---Purpose: This class is intended to translate IGES boundary entity
-- (142-CurveOnSurface, 141-Boundary or 508-Loop) into the wire.
-- Methods Transfer are virtual and are redefined in Advanced
-- Data Exchange to optimize the translation and take into
-- account advanced parameters.
uses
Trsf2d from gp,
Face from TopoDS,
IGESEntity from IGESData,
HArray1OfIGESEntity from IGESData,
CurveAndSurface from IGESToBRep,
WireData from ShapeExtend
is
Create returns mutable IGESBoundary from IGESToBRep;
---Purpose: Empty constructor
Create (CS: CurveAndSurface from IGESToBRep) returns mutable IGESBoundary from IGESToBRep;
---Purpose: Empty constructor
Init (me: mutable; CS : CurveAndSurface from IGESToBRep;
entity : IGESEntity from IGESData;
face : Face from TopoDS;
trans : Trsf2d from gp;
uFact : Real;
filepreference: Integer);
---Purpose: Inits the object with parameters common for all
-- types of IGES boundaries.
-- <CS>: object to be used for retrieving translation parameters
-- and sending messages,
-- <entity>: boundary entity to be processed,
-- <face>, <trans>, <uFact>: as for IGESToBRep_TopoCurve
-- <filepreference>: preferred representation (2 or 3) given
-- in the IGES file
WireData (me) returns WireData from ShapeExtend;
---Purpose: Returns the resulting wire
---C++: inline
WireData3d (me) returns WireData from ShapeExtend;
---Purpose: Returns the wire from 3D curves (edges contain 3D curves
-- and may contain pcurves)
---C++: inline
WireData2d (me) returns WireData from ShapeExtend;
---Purpose: Returns the the wire from 2D curves (edges contain pcurves
-- only)
---C++: inline
Transfer (me: mutable; okCurve : in out Boolean;
okCurve3d : in out Boolean;
okCurve2d : in out Boolean;
curve3d : IGESEntity from IGESData;
toreverse3d: Boolean;
curves2d : HArray1OfIGESEntity from IGESData;
number : Integer)
returns Boolean;
---Purpose: Translates 141 and 142 entities.
-- Returns True if the curve has been successfully translated,
-- otherwise returns False.
-- <okCurve..>: flags that indicate whether corresponding
-- representation has been successfully translated
-- (must be set to True before first call),
-- <curve3d>: model space curve for 142 and current model space
-- curve for 141,
-- <toreverse3d>: False for 142 and current orientation flag
-- for 141,
-- <curves2d>: 1 parameter space curve for 142 or list of
-- them for current model space curves for 141,
-- <number>: 1 for 142 and rank number of model space curve for 141.
Transfer (me: mutable; okCurve : in out Boolean;
okCurve3d : in out Boolean;
okCurve2d : in out Boolean;
curve3d : WireData from ShapeExtend;
curves2d : HArray1OfIGESEntity from IGESData;
toreverse2d: Boolean;
number : Integer;
lsewd : out WireData from ShapeExtend)
returns Boolean;
---Purpose: Translates 508 entity.
-- Returns True if the curve has been successfully translated,
-- otherwise returns False.
-- Input object IGESBoundary must be created and initialized
-- before.
-- <okCurve..>: flags that indicate whether corresponding
-- representation has been successfully translated
-- (must be set to True before first call),
-- <curve3d>: result of translation of current edge,
-- <curves2d>: list of parameter space curves for edge,
-- <toreverse2d>: orientation flag of current edge in respect
-- to its model space curve,
-- <number>: rank number of edge,
-- <lsewd>: returns the result of translation of current edge.
Check (me: mutable; result, checkclosure, okCurve3d, okCurve2d: Boolean) is virtual;
---Purpose: Checks result of translation of IGES boundary entities
-- (types 141, 142 or 508).
-- Checks consistency of 2D and 3D representations and keeps
-- only one if they are inconsistent.
-- <result>: result of translation (returned by Transfer),
-- <checkclosure>: False for 142 without parent 144 entity,
-- otherwise True,
-- <okCurve3d>, <okCurve2d>: those returned by Transfer.
---Remark : Empty method for Open CASCADE and implemented for Advanced
-- Data Exchange.
---Level: Internal
Transfer (me: mutable; okCurve : in out Boolean;
okCurve3d : in out Boolean;
okCurve2d : in out Boolean;
icurve3d : IGESEntity from IGESData;
scurve3d : WireData from ShapeExtend;
usescurve : Boolean;
toreverse3d: Boolean;
curves2d : HArray1OfIGESEntity from IGESData;
toreverse2d: Boolean;
number : Integer;
lsewd : out WireData from ShapeExtend)
returns Boolean is virtual protected;
---Purpose: Methods called by both Transfer methods.
ReverseCurves3d (myclass; sewd: WireData from ShapeExtend) is protected;
ReverseCurves2d (myclass; sewd: WireData from ShapeExtend;
face: Face from TopoDS) is protected;
fields
myCS : CurveAndSurface from IGESToBRep is protected;
myentity : IGESEntity from IGESData is protected;
mysewd : WireData from ShapeExtend is protected; -- resulting wire
mysewd3d : WireData from ShapeExtend is protected; -- wire from 3D curves (edges contain 3D curves and may contain pcurves)
mysewd2d : WireData from ShapeExtend is protected; -- wire from 2D curves (edges contain pcurves only)
myface : Face from TopoDS is protected;
mytrsf : Trsf2d from gp is protected;
myuFact : Real is protected;
myfilepreference: Integer is protected;
end IGESBoundary;

View File

@@ -0,0 +1,311 @@
// File: IGESToBRep_IGESBoundary.cxx
// Created: Wed Dec 16 17:00:20 1998
// Author: Roman LYGIN
// <rln@kinox.nnov.matra-dtv.fr>
#include <IGESToBRep_IGESBoundary.ixx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Plane.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Precision.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <ShapeBuild_Edge.hxx>
#include <IGESToBRep.hxx>
#include <IGESToBRep_TopoCurve.hxx>
//=======================================================================
//function : IGESToBRep_IGESBoundary
//purpose :
//=======================================================================
IGESToBRep_IGESBoundary::IGESToBRep_IGESBoundary()
{
}
//=======================================================================
//function : IGESToBRep_IGESBoundary
//purpose :
//=======================================================================
IGESToBRep_IGESBoundary::IGESToBRep_IGESBoundary(const IGESToBRep_CurveAndSurface& CS)
: myCS (CS)
{
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void IGESToBRep_IGESBoundary::Init(const IGESToBRep_CurveAndSurface& CS,
const Handle(IGESData_IGESEntity)& entity,
const TopoDS_Face& face,
const gp_Trsf2d& trans,
const Standard_Real uFact,
const Standard_Integer filepreference)
{
myCS = CS;
myentity = entity;
myface = face;
mytrsf = trans;
myuFact = uFact;
myfilepreference = filepreference;
}
//=======================================================================
//function : Transfer
//purpose :
//=======================================================================
Standard_Boolean IGESToBRep_IGESBoundary::Transfer(Standard_Boolean& okCurve,
Standard_Boolean& okCurve3d,
Standard_Boolean& okCurve2d,
const Handle(IGESData_IGESEntity)& curve3d,
const Standard_Boolean toreverse3d,
const Handle(IGESData_HArray1OfIGESEntity)& curves2d,
const Standard_Integer number)
{
Handle(ShapeExtend_WireData) scurve3d, lsewd; //temporary objects
return Transfer (okCurve, okCurve3d, okCurve2d,
curve3d, scurve3d, Standard_False, toreverse3d,
curves2d, Standard_False,
number, lsewd);
}
//=======================================================================
//function : Transfer
//purpose :
//=======================================================================
Standard_Boolean IGESToBRep_IGESBoundary::Transfer(Standard_Boolean& okCurve,
Standard_Boolean& okCurve3d,
Standard_Boolean& okCurve2d,
const Handle(ShapeExtend_WireData)& curve3d,
const Handle(IGESData_HArray1OfIGESEntity)& curves2d,
const Standard_Boolean toreverse2d,
const Standard_Integer number,
Handle(ShapeExtend_WireData)& lsewd)
{
Handle(IGESData_IGESEntity) icurve3d; //temporary object
return Transfer (okCurve, okCurve3d, okCurve2d,
icurve3d, curve3d, Standard_True, Standard_False,
curves2d, toreverse2d,
number, lsewd);
}
//=======================================================================
//function : Check
//purpose :
//=======================================================================
void IGESToBRep_IGESBoundary::Check(const Standard_Boolean,const Standard_Boolean,const Standard_Boolean,const Standard_Boolean)
{
// Implemented in Advanced Data Exchange
}
//=======================================================================
//function : Transfer
//purpose :
//=======================================================================
Standard_Boolean IGESToBRep_IGESBoundary::Transfer(Standard_Boolean&,
Standard_Boolean&,
Standard_Boolean&,
const Handle(IGESData_IGESEntity)& icurve3d,
const Handle(ShapeExtend_WireData)& scurve3d,
const Standard_Boolean usescurve,
const Standard_Boolean toreverse3d,
const Handle(IGESData_HArray1OfIGESEntity)& curves2d,
const Standard_Boolean toreverse2d,
const Standard_Integer number,
Handle(ShapeExtend_WireData)& Gsewd)
{
Gsewd = new ShapeExtend_WireData;//local translation (for mysewd)
Handle(ShapeExtend_WireData) Gsewd3d = new ShapeExtend_WireData;//local translation (for mysewd3d)
Handle(ShapeExtend_WireData) Gsewd2d = new ShapeExtend_WireData;//local translation (for mysewd2d)
Standard_Boolean GTranslate3d = Standard_True, GTranslate2d = Standard_True,
Preferred3d = Standard_True, Preferred2d = Standard_True;
Standard_Integer len3d = 0, len2d = 0;
Handle(TColStd_HSequenceOfTransient) seq3d, seq2d;
if (usescurve)
len3d = scurve3d->NbEdges();
else {
IGESToBRep::IGESCurveToSequenceOfIGESCurve (icurve3d, seq3d);
len3d = seq3d->Length();
}
if (!curves2d.IsNull()) {
for (Standard_Integer i = 1; i <= curves2d->Length(); i++)
IGESToBRep::IGESCurveToSequenceOfIGESCurve (curves2d->Value (i), seq2d);
len2d = seq2d->Length();
}
if (len3d == 0)
GTranslate3d = Standard_False;
else if (len2d == 0)
GTranslate2d = Standard_False;
if (GTranslate3d && GTranslate2d)
//Setting preference in the case of inconsitency between 3D and 2D
if (myfilepreference == 2) Preferred3d = Standard_False;
else if (myfilepreference == 3) Preferred2d = Standard_False;
else Preferred3d = Standard_False;
if (GTranslate3d && GTranslate2d && len3d != len2d) {
GTranslate3d = Preferred3d;
GTranslate2d = Preferred2d;
}
IGESToBRep_TopoCurve TC (myCS);
if (GTranslate3d && !GTranslate2d) {
if (usescurve)
Gsewd->Add (scurve3d->Wire());
else {
TopoDS_Shape Sh = TC.TransferTopoCurve (icurve3d);
if (!Sh.IsNull()) {
Gsewd3d->Add (Sh);
if (toreverse3d) {
ReverseCurves3d (Gsewd3d);
Gsewd->Add (Gsewd3d->Wire());
}
else Gsewd->Add (Sh);//Gsewd = Gsewd3d is impossible to avoid sharing of sewd (UK1.igs entity 7)
}
}
}
else if (!GTranslate3d && GTranslate2d) {
for (Standard_Integer i = curves2d->Lower(); i <= curves2d->Upper(); i++) {
TopoDS_Shape Sh = TC.Transfer2dTopoCurve (Handle(IGESData_IGESEntity)::DownCast (curves2d->Value (i)),
myface, mytrsf, myuFact);
if (!Sh.IsNull()) Gsewd2d->Add (Sh);
}
if (toreverse2d)
ReverseCurves2d (Gsewd2d, myface);
Gsewd->Add (Gsewd2d->Wire());
}
else if (GTranslate3d && GTranslate2d) {
//Translate both curves 3D and 2D
//Suppose that i-th segment in 2D curve corresponds to i-th segment in 3D curve
for (Standard_Integer i = 1; i <= len3d; i++) {
Standard_Boolean LTranslate3d = Standard_True, LTranslate2d = Standard_True;
Handle(ShapeExtend_WireData) Lsewd3d = new ShapeExtend_WireData;
TC.SetBadCase (Standard_False); //:27
if (usescurve)
Lsewd3d->Add (scurve3d->Edge (i));
else {
TopoDS_Shape shape3d = TC.TransferTopoCurve (Handle(IGESData_IGESEntity)::DownCast (seq3d->Value (i)));
if (!shape3d.IsNull()) {
Lsewd3d->Add (shape3d);
if (toreverse3d)
ReverseCurves3d (Lsewd3d);
}
else LTranslate3d = Standard_False;
}
Gsewd3d->Add (Lsewd3d->Wire());
Handle(ShapeExtend_WireData) Lsewd2d = new ShapeExtend_WireData;
TopoDS_Shape shape2d = TC.Transfer2dTopoCurve (Handle(IGESData_IGESEntity)::DownCast (seq2d->Value (i)),
myface, mytrsf, myuFact);
if (!shape2d.IsNull()) {
Lsewd2d->Add (shape2d);
if (toreverse2d)
ReverseCurves2d (Lsewd2d, myface);
Gsewd2d->Add (Lsewd2d->Wire());
}
else LTranslate2d = Standard_False;
if (LTranslate3d && LTranslate2d && Lsewd3d->NbEdges() != Lsewd2d->NbEdges()) {
LTranslate3d = Preferred3d;
LTranslate2d = Preferred2d;
}
Handle(ShapeExtend_WireData) Lsewd;//Lsewd3d or Lsewd2d or Lsewd3d+pcurve
if ( LTranslate3d && !LTranslate2d) Lsewd = Lsewd3d;
else if (!LTranslate3d && LTranslate2d) Lsewd = Lsewd2d;
else {
Lsewd = Lsewd3d;
//copying pcurve to edge with 3D curve
for (Standard_Integer iedge = 1; iedge <= Lsewd3d->NbEdges(); iedge++) {
TopoDS_Edge edge3d = Lsewd3d->Edge (iedge), edge2d = Lsewd2d->Edge (iedge);
if (!IGESToBRep::TransferPCurve (edge2d, edge3d, myface)) continue;
}
}
Gsewd->Add (Lsewd->Wire());
}
}
if (number > 1) {
mysewd ->Add (Gsewd ->Wire());
mysewd3d->Add (Gsewd3d->Wire());
mysewd2d->Add (Gsewd2d->Wire());
}
else {
mysewd = Gsewd;
mysewd3d = Gsewd3d;
mysewd2d = Gsewd2d;
}
return Standard_True;
}
//=======================================================================
//function : ReverseCurves3d
//purpose : Reverses 3D curves of the edges in the wire and reverses
// the order of edges in the wire.
// Orientation of each edge is not changed
//=======================================================================
void IGESToBRep_IGESBoundary::ReverseCurves3d (const Handle(ShapeExtend_WireData)& sewd)
{
sewd->Reverse();
for (Standard_Integer i = 1; i <= sewd->NbEdges(); i++) {
TopoDS_Edge oldedge = sewd->Edge (i), newedge;
TopLoc_Location L;
Standard_Real p1, p2;
Handle(Geom_Curve) curve = BRep_Tool::Curve (oldedge, L, p1, p2);
if (curve->IsPeriodic()) //#21
ShapeBuild_Edge().MakeEdge (newedge, curve->Reversed(), L,
curve->ReversedParameter (p2),
curve->ReversedParameter (p1));
else ShapeBuild_Edge().MakeEdge (newedge, curve->Reversed(), L,
Max (curve->ReversedParameter(curve->LastParameter()), curve->ReversedParameter (p2)),
Min (curve->ReversedParameter(curve->FirstParameter()), curve->ReversedParameter (p1)));
newedge.Orientation(TopAbs::Reverse (oldedge.Orientation()));
sewd->Set (newedge, i);
}
}
//=======================================================================
//function : ReverseCurves2d
//purpose : Reverses pcurves of the edges in the wire and reverses
// the order of edges in the wire.
// Orientation of each edge is also changed
//=======================================================================
void IGESToBRep_IGESBoundary::ReverseCurves2d (const Handle(ShapeExtend_WireData)& sewd, const TopoDS_Face& face)
{
sewd->Reverse(face);
for (Standard_Integer i = 1; i <= sewd->NbEdges(); i++) {
TopoDS_Edge oldedge = sewd->Edge (i), newedge;
Standard_Real p1, p2;
Handle(Geom2d_Curve) curve = BRep_Tool::CurveOnSurface (oldedge, face, p1, p2);
// skl 24.04.2002 for OCC314
if(curve->IsPeriodic())
ShapeBuild_Edge().MakeEdge (newedge, curve->Reversed(), face,
curve->ReversedParameter (p2),
curve->ReversedParameter (p1));
else
ShapeBuild_Edge().MakeEdge (newedge, curve->Reversed(), face,
Max (curve->FirstParameter(), curve->ReversedParameter (p2)),//BUC50001 entity 936 2DForced
Min (curve->LastParameter(), curve->ReversedParameter (p1)));
newedge.Orientation(oldedge.Orientation());
sewd->Set (newedge, i);
}
}

View File

@@ -0,0 +1,21 @@
// File: IGESToBRep_IGESBoundary.lxx
// Created: Wed Dec 16 16:59:43 1998
// Author: data exchange team
// <det@kinox.nnov.matra-dtv.fr>
inline Handle(ShapeExtend_WireData) IGESToBRep_IGESBoundary::WireData() const
{
return mysewd;
}
inline Handle(ShapeExtend_WireData) IGESToBRep_IGESBoundary::WireData3d() const
{
return mysewd3d;
}
inline Handle(ShapeExtend_WireData) IGESToBRep_IGESBoundary::WireData2d() const
{
return mysewd2d;
}

View File

@@ -0,0 +1,99 @@
-- File: IGESToBRep_Reader.cdl
-- Created: Thu Sep 1 10:22:08 1994
-- Author: Marie Jose MARTZ
-- <mjm@anion>
---Copyright: Matra Datavision 1994
class Reader from IGESToBRep
---Purpose : A simple way to read geometric IGES data.
-- Encapsulates reading file and calling transfer tools
uses
IGESModel from IGESData,
ShareFlags from Interface,
TransientProcess from Transfer,
Shape from TopoDS,
SequenceOfShape from TopTools,
Actor from IGESToBRep
is
Create returns Reader;
---Purpose : Creates a Reader
LoadFile (me : in out; filename : CString) returns Integer;
---Purpose : Loads a Model from a file.Returns 0 if success.
-- returns 1 if the file could not be opened,
-- returns -1 if an error occurred while the file was being loaded.
SetModel (me : in out; model : IGESModel);
---Purpose : Specifies a Model to work on
-- Also clears the result and Done status, sets TransientProcess
Model (me) returns IGESModel;
---Purpose : Returns the Model to be worked on.
SetTransientProcess (me : in out; TP : mutable TransientProcess);
---Purpose : Allows to set an already defined TransientProcess
-- (to be called after LoadFile or SetModel)
TransientProcess (me) returns TransientProcess;
---Purpose : Returns the TransientProcess
Actor (me) returns Actor from IGESToBRep;
---Purpose : Returns "theActor"
Clear (me : in out);
---Purpose : Clears the results between two translation operations.
Check (me; withprint : Boolean) returns Boolean;
---Purpose : Checks the IGES file that was
-- loaded into memory. Displays error messages in the default
-- message file if withprint is true. Returns True if no fail
-- message was found and False if there was at least one fail message.
TransferRoots (me : in out; onlyvisible : Boolean = Standard_True);
---Purpose : Translates root entities in an
-- IGES file. Standard_True is the default value and means that only
-- visible root entities are translated. Standard_False
-- translates all of the roots (visible and invisible).
Transfer (me : in out; num : Integer) returns Boolean;
---Purpose : Transfers an Entity given its rank in the Model (Root or not)
-- Returns True if it is recognized as Geom-Topol.
-- (But it can have failed : see IsDone)
IsDone (me) returns Boolean;
---Purpose : Returns True if the LAST Transfer/TransferRoots was a success
UsedTolerance (me) returns Real;
---Purpose : Returns the Tolerance which has been actually used, converted
-- in millimeters
-- (either that from File or that from Session, according the mode)
NbShapes (me) returns Integer;
---Purpose : Returns the number of shapes produced by the translation.
Shape (me; num : Integer = 1) returns Shape from TopoDS;
---Purpose : Returns the num the resulting shape in a translation operation.
OneShape (me) returns Shape from TopoDS;
---Purpose : Returns all of the results in a
-- single shape which is:
-- - a null shape if there are no results,
-- - a shape if there is one result,
-- - a compound containing the resulting shapes if there are several.
fields
theModel : IGESModel from IGESData;
theDone : Boolean;
theShapes : SequenceOfShape from TopTools;
theActor : Actor from IGESToBRep;
theProc : TransientProcess from Transfer;
end Reader;

View File

@@ -0,0 +1,629 @@
//pdn 11.01.99 including <stdio.h> for compilation on NT
//#70 rln 03.03.99 syntax correction
// sln 11.06.2002 OCC448 : Initialize "read.onlyvisiable" parameter to control transfering invisiable sub entities which logicaly depend on the grouping entities
#include <stdio.h>
#include <IGESToBRep_Reader.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <OSD_Timer.hxx>
#include <gp_Trsf.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Shape.hxx>
#include <BRep_Builder.hxx>
#include <BRepLib.hxx>
#include <BRepTools_Modifier.hxx>
#include <Message_Msg.hxx>
#include <Message_Messenger.hxx>
#include <IGESFile_Read.hxx>
#include <IGESData_FileProtocol.hxx>
#include <IGESData_GlobalSection.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESSolid.hxx>
#include <IGESSolid_Protocol.hxx>
#include <IGESAppli.hxx>
#include <IGESAppli_Protocol.hxx>
#include <Interface_Macros.hxx>
#include <Interface_CheckTool.hxx>
#include <Interface_CheckIterator.hxx>
#include <Interface_ShareFlags.hxx>
#include <Interface_Static.hxx>
#include <Interface_Check.hxx>
#include <IGESToBRep.hxx>
#include <IGESToBRep_Actor.hxx>
#include <IGESToBRep_CurveAndSurface.hxx>
//#include <ShapeCustom.hxx>
#include <ShapeExtend_Explorer.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <Transfer_TransferOutput.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <TransferBRep.hxx>
#include <TransferBRep_ShapeBinder.hxx>
#include <TransferBRep_ShapeListBinder.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <ShapeAlgo.hxx>
#include <ShapeAlgo_AlgoContainer.hxx>
#include <Message_ProgressSentry.hxx>
#ifdef WNT
#include <stdlib.h>
#else
#include <errno.h>
#endif
//extern int errno;
static Handle(IGESData_FileProtocol) protocol;
//=======================================================================
//function : IGESToBRep_Reader
//purpose :
//=======================================================================
IGESToBRep_Reader::IGESToBRep_Reader ()
{
theDone = Standard_False;
if (protocol.IsNull()) {
IGESAppli::Init(); IGESSolid::Init();
protocol = new IGESData_FileProtocol;
protocol->Add(IGESAppli::Protocol());
protocol->Add(IGESSolid::Protocol());
}
theActor = new IGESToBRep_Actor;
theProc = new Transfer_TransientProcess;
}
//=======================================================================
//function : LoadFile
//purpose : loads a Model from a file
//=======================================================================
Standard_Integer IGESToBRep_Reader::LoadFile (const Standard_CString filename)
{
if ( theProc.IsNull() )
theProc = new Transfer_TransientProcess;
Handle(Message_Messenger) TF = theProc->Messenger();
// Message for Diagnostic file.
Message_Msg msg2000("IGES_2000");
msg2000.Arg(filename);
TF->Send (msg2000, Message_Info);
//Message_Msg msg2001("IGES_2001"); // Date
Message_Msg msg2005("IGES_2005");
msg2005.Arg(theProc->TraceLevel());
TF->Send (msg2005, Message_Info);
/////////////////////////////////////////////////////////
Handle(IGESData_IGESModel) model = new IGESData_IGESModel;
OSD_Timer c; c.Reset(); c.Start();
char *pfilename=(char *)filename;
Standard_Integer StatusFile = IGESFile_Read(pfilename,model,protocol);
if (StatusFile != 0) {
// Sending of message : IGES file opening error
Message_Msg Msg2("XSTEP_2");
TF->Send (Msg2, Message_Info);
//Message_Msg Msg3("XSTEP_3");
//Message_Msg Msg4("XSTEP_4");
//Message_Msg Msg5("XSTEP_5");
//Message_Msg Msg6("XSTEP_6");
//Message_Msg Msg7("XSTEP_7");
// Reasons of the file opening error
switch(errno)
{
case 2 : // Sending of message : No such file or directory
{
Message_Msg Msg3("XSTEP_3");
TF->Send (Msg3, Message_Info);
}
break;
case 12 : // Sending of message : Not enough space
{
Message_Msg Msg4("XSTEP_4");
TF->Send (Msg4, Message_Info);
}
break;
case 13 : // Sending of message : Permission Denied
{
Message_Msg Msg5("XSTEP_5");
TF->Send (Msg5, Message_Info);
}
break;
case 24 : // Sending of message : Too many open files
{
Message_Msg Msg6("XSTEP_6");
TF->Send (Msg6, Message_Info);
}
break;
default : // Sending of message : No determined
{
Message_Msg Msg7("XSTEP_7");
TF->Send (Msg7, Message_Info);
}
break;
}
}
Message_Msg Msg8 ("XSTEP_8");
Message_Msg Msg25 ("XSTEP_25");
Message_Msg Msg26 ("XSTEP_26");
// Nb warning in global section.
Standard_Integer nbWarn = 0,nbFail = 0;
// Add the number of warning on enities :
Interface_CheckTool cht (model,protocol);
Interface_CheckIterator anIter = cht.CompleteCheckList();
for(anIter.Start(); anIter.More(); anIter.Next()) {
const Handle(Interface_Check) ach = anIter.Value();
nbWarn += ach->NbWarnings();
nbFail += ach->NbFails();
}
// Messages nbWarn and nbFail;
Msg25.Arg(nbFail);
Msg26.Arg(nbWarn);
TF->Send (Msg25, Message_Info);
TF->Send (Msg26, Message_Info);
// Message fin de loading iGES file (elapsed time %s)
char t[20];
t[0]='\0';
Standard_Real second, cpu;
Standard_Integer minute, hour;
c.Show(second, minute, hour,cpu);
if (hour > 0)
sprintf(t,"%dh:%dm:%.2fs",hour,minute,second);
else if (minute > 0)
sprintf(t,"%dm:%.2fs",minute,second);
else
sprintf(t,"%.2fs",second);
// Sending of message : End of Loading
Msg8.Arg(t);
TF->Send (Msg8, Message_Info);
SetModel(model);
return StatusFile;
}
//=======================================================================
//function : SetModel
//purpose : Specifies a Model to work on
//=======================================================================
void IGESToBRep_Reader::SetModel (const Handle(IGESData_IGESModel)& model)
{
theModel = model;
theDone = Standard_False;
theShapes.Clear();
if ( theProc.IsNull() )
theProc = new Transfer_TransientProcess (theModel->NbEntities());
else
theProc->Clear();
}
//=======================================================================
//function : Model
//purpose : returns the Model to be worked on
//=======================================================================
Handle(IGESData_IGESModel) IGESToBRep_Reader::Model () const
{ return theModel; }
//=======================================================================
//function : SetTransientProcess
//purpose : Specifies a TransferProcess
//=======================================================================
void IGESToBRep_Reader::SetTransientProcess
(const Handle(Transfer_TransientProcess)& TP)
{ theProc = TP; }
//=======================================================================
//function : TransientProcess
//purpose : Returns the TransferProcess
//=======================================================================
Handle(Transfer_TransientProcess) IGESToBRep_Reader::TransientProcess () const
{ return theProc; }
//=======================================================================
//function : Actor
//purpose : returns theActor
//=======================================================================
Handle(IGESToBRep_Actor) IGESToBRep_Reader::Actor () const
{ return theActor; }
//=======================================================================
//function : Clear
//purpose : Clears the result and Done status
//=======================================================================
void IGESToBRep_Reader::Clear ()
{
theDone = Standard_False;
theShapes.Clear();
}
//=======================================================================
//function : Check
//purpose : Checks the Model
//=======================================================================
Standard_Boolean IGESToBRep_Reader::Check
(const Standard_Boolean withprint) const
{
Interface_CheckTool cht (theModel,protocol);
Interface_CheckIterator chl = cht.CompleteCheckList();
if (withprint && !theProc.IsNull())
cht.Print(chl, theProc->Messenger());
return chl.IsEmpty(Standard_True);
}
//=======================================================================
//function : IsDone
//purpose : returns True if the last transfert was a success
//=======================================================================
Standard_Boolean IGESToBRep_Reader::IsDone () const
{ return theDone; }
//=======================================================================
//function : EncodeRegul
//purpose : INTERNAL to encode regularity on edges
//=======================================================================
static Standard_Boolean EncodeRegul (const TopoDS_Shape& sh)
{
Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle");
if (sh.IsNull()) return Standard_True;
if (tolang <= 0) return Standard_True;
try {
OCC_CATCH_SIGNALS
BRepLib::EncodeRegularity (sh,tolang);
}
catch(Standard_Failure) {
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : UpdateMap
//purpose : Updates the correspondence map (Transfer_TransientProcess),
// setting as translation results, the shapes received after
// modification by modifier (BRepTools_Modifier)
//warning : BRepTools_Modifier raises exception when it cannot find input
// shape in its internal list
//=======================================================================
// coment as unused PTV 18.09.2000
// static void UpdateMap (const Handle(Transfer_TransientProcess)& map,
// const BRepTools_Modifier& modifier)
// {
// Transfer_IteratorOfProcessForTransient iterator = map->CompleteResult(Standard_True);
// for (iterator.Start(); iterator.More(); iterator.Next()) {
// const Handle(Transfer_Binder) binder = iterator.Value();
// try { //to avoid exception in BRepTools_Modifier
// OCC_CATCH_SIGNALS
// if (binder->IsKind (STANDARD_TYPE (TransferBRep_ShapeBinder))) {
// DeclareAndCast(TransferBRep_ShapeBinder, shapebinder, binder);
// if (shapebinder->HasResult()) {
// TopoDS_Shape result = shapebinder->Result();
// TopoDS_Shape modified = modifier.ModifiedShape (result);
// if (shapebinder->Status() != Transfer_StatusUsed) //to avoid exception
// shapebinder->SetResult (modified);
// }
// }
// else if (binder->IsKind (STANDARD_TYPE (TransferBRep_ShapeListBinder))) {
// DeclareAndCast(TransferBRep_ShapeListBinder, shapelistbinder, binder);
// for (Standard_Integer i = 1; i <= shapelistbinder->NbShapes(); i++) {
// TopoDS_Shape result = shapelistbinder->Shape (i);
// TopoDS_Shape modified = modifier.ModifiedShape (result);
// shapelistbinder->SetResult (i, modified);
// }
// }
// }
// catch(Standard_Failure) {
// continue;
// }
// }
// }
//=======================================================================
//function : TrimTolerances
//purpose : Trims tolerances of the shape according to static parameters
//
//=======================================================================
static void TrimTolerances (const TopoDS_Shape& shape,
const Standard_Real tol)
{
if( Interface_Static::IVal("read.maxprecision.mode")==1) {
ShapeFix_ShapeTolerance SFST;
SFST.LimitTolerance (shape, 0, Max(tol,Interface_Static::RVal ("read.maxprecision.val")));
}
}
//=======================================================================
//function : TransferRoots
//purpose : Transfers all Roots Entities
//=======================================================================
void IGESToBRep_Reader::TransferRoots (const Standard_Boolean onlyvisible)
{
if (theModel.IsNull() || theProc.IsNull()) return;
Handle(Message_Messenger) TF = theProc->Messenger();
// Declaration of messages.
Message_Msg msg2030("IGES_2030");
TF->Send (msg2030, Message_Info);
Message_Msg msg2065("IGES_2065");
OSD_Timer c; c.Reset(); c.Start(); // Initialisation du CHRONO
theDone = Standard_False;
theShapes.Clear();
Standard_Integer level = theProc->TraceLevel();
theProc->SetErrorHandle(Standard_True);
theProc->SetRootManagement(Standard_True);
// PrepareTransfer(); -> protocol, actor
theActor->SetModel(theModel);
Standard_Integer continuity = Interface_Static::IVal("read.iges.bspline.continuity");
theActor->SetContinuity (continuity);
theProc->SetModel (theModel);
theProc->SetActor (theActor);
Transfer_TransferOutput TP (theProc,theModel);
Interface_ShareFlags SH (theModel,protocol);
Standard_Integer nb = theModel->NbEntities();
ShapeExtend_Explorer SBE;
Standard_Integer precisionMode = Interface_Static::IVal("read.precision.mode");
Message_Msg msg2035("IGES_2035");
msg2035.Arg(precisionMode);
TF->Send (msg2035, Message_Info);
if (precisionMode==1) {
Message_Msg msg2040("IGES_2040");
msg2040.Arg(Interface_Static::RVal("read.precision.val"));//#70 rln 03.03.99
TF->Send (msg2040, Message_Info);
}
Message_Msg msg2045("IGES_2045");
msg2045.Arg(continuity);
TF->Send (msg2045, Message_Info);
Message_Msg msg2050("IGES_2050");
msg2050.Arg(Interface_Static::IVal("read.surfacecurve.mode"));
TF->Send (msg2050, Message_Info);
// sln 11.06.2002 OCC448
Interface_Static::SetIVal("read.iges.onlyvisible",onlyvisible);
Message_ProgressSentry PS ( theProc->GetProgress(), "Root", 0, nb, 1 );
for (Standard_Integer i = 1; i <= nb && PS.More(); i++, PS.Next()) {
Handle(IGESData_IGESEntity) ent = theModel->Entity(i);
if ( SH.IsShared(ent) || ! theActor->Recognize (ent) ) continue;
if (level > 0) {
Message_Msg msg2070("IGES_2070");
msg2070.Arg(2*i-1);
msg2070.Arg(ent->TypeNumber());
TF->Send (msg2070, Message_Info);
}
// on ajoute un traitement pour ne prendre que les entites visibles
if ( ! onlyvisible || ent->BlankStatus() == 0 ) {
TopoDS_Shape shape;
theDone = Standard_True;
try {
OCC_CATCH_SIGNALS
TP.Transfer(ent);
shape = TransferBRep::ShapeResult (theProc,ent);
}
catch(Standard_Failure) {
Message_Msg msg1005("IGES_1005");
TF->Send (msg1005, Message_Info);
continue;
}
if (shape.IsNull()) {
Message_Msg msg2076("IGES_2076");
TF->Send (msg2076, Message_Info);
}
else {
if (SBE.ShapeType(shape,Standard_True) != TopAbs_SHAPE) {
if (!shape.IsNull()) {
EncodeRegul (shape);
//#74 rln 03.03.99 S4135
TrimTolerances (shape, theActor->UsedTolerance());
theShapes.Append(shape);
}
}
}
}
}
char t [20];
t[0]='\0';
Standard_Real second, cpu;
Standard_Integer minute, hour;
c.Show(second, minute, hour,cpu);
if (hour > 0)
sprintf(t,"%dh:%dm:%.2fs",hour,minute,second);
else if (minute > 0)
sprintf(t,"%dm:%.2fs",minute,second);
else
sprintf(t,"%.2fs",second);
// Sending of message : End of Loading
msg2065.Arg(t);
TF->Send (msg2065, Message_Info);
}
//=======================================================================
//function : Transfer
//purpose : Transfers an Entity given
//=======================================================================
Standard_Boolean IGESToBRep_Reader::Transfer(const Standard_Integer num)
{
Handle(Message_Messenger) TF = theProc->Messenger();
theDone = Standard_False;
if (theModel.IsNull()) {
Message_Msg msg2031("IGES_2031");
TF->Send (msg2031, Message_Info);
return Standard_False;
}
if (num <= 0 || num > theModel->NbEntities()) {
Message_Msg msg2032("IGES_2032");
msg2032.Arg(num);
TF->Send (msg2032, Message_Info);
return Standard_False;
}
// declaration of messages
Message_Msg msg2030("IGES_2030");
TF->Send (msg2030, Message_Info);
Message_Msg msg2065("IGES_2065");
OSD_Timer c; c.Reset(); c.Start(); // Initialisation du CHRONO
Handle(IGESData_IGESEntity) ent = theModel->Entity(num);
Message_ProgressSentry PS ( theProc->GetProgress(), "OneEnt", 0, 1, 1 ); //skl
XSAlgo::AlgoContainer()->PrepareForTransfer();
IGESToBRep_CurveAndSurface CAS;
CAS.SetModel(theModel);
Standard_Real eps;
Standard_Integer Ival = Interface_Static::IVal("read.precision.mode");
Message_Msg msg2035("IGES_2035");
msg2035.Arg(Ival);
TF->Send (msg2035, Message_Info);
if ( Ival == 0)
eps = theModel->GlobalSection().Resolution();
else {
//mjm : modif du 19/12/97 pour prise en compte effective du parametre
eps = Interface_Static::RVal("read.precision.val");
Message_Msg msg2040("IGES_2040");
msg2040.Arg(eps);//#70 rln 03.03.99
TF->Send (msg2040, Message_Info);
}
Ival = Interface_Static::IVal("read.iges.bspline.approxd1.mode");
CAS.SetModeApprox ( (Ival > 0) );
Message_Msg msg2045("IGES_2045");
Ival = Interface_Static::IVal("read.iges.bspline.continuity");
msg2045.Arg(Ival);
TF->Send (msg2045, Message_Info);
CAS.SetContinuity(Ival);
Message_Msg msg2050("IGES_2050");
Ival = Interface_Static::IVal("read.surfacecurve.mode");
msg2050.Arg(Ival);
TF->Send (msg2050, Message_Info);
CAS.SetSurfaceCurve (Ival);
if (eps > 1.E-08) CAS.SetEpsGeom(eps);
CAS.SetTransferProcess(theProc);
Standard_Boolean exceptionRaised = Standard_False;
TopoDS_Shape shape;
Standard_Integer nbTPitems = theProc->NbMapped();
{
try {
OCC_CATCH_SIGNALS
shape = CAS.TransferGeometry (ent);
}
catch(Standard_Failure) {
Message_Msg msg1015("IGES_1015");
TF->Send (msg1015, Message_Info);
exceptionRaised = Standard_True;
}
}
if (!exceptionRaised) {
// fixing shape
// shape = XSAlgo::AlgoContainer()->PerformFixShape ( shape, theProc, eps*CAS.GetUnitFactor(), CAS.GetMaxTol() );
Handle(Standard_Transient) info;
shape = XSAlgo::AlgoContainer()->ProcessShape( shape, eps*CAS.GetUnitFactor(), CAS.GetMaxTol(),
"read.iges.resource.name",
"read.iges.sequence", info );
XSAlgo::AlgoContainer()->MergeTransferInfo(theProc, info, nbTPitems);
ShapeExtend_Explorer SBE;
if (SBE.ShapeType (shape,Standard_True) != TopAbs_SHAPE) {
TransferBRep::SetShapeResult (theProc,ent,shape);
theProc->SetRoot (ent);
if (!shape.IsNull()) {
theDone = Standard_True;
EncodeRegul (shape);
//#74 rln 03.03.99 S4135
TrimTolerances (shape, CAS.GetMaxTol());
theShapes.Append(shape);
}
}
}
PS.Relieve(); //skl
char t [20];
t[0]='\0';
Standard_Real second, cpu;
Standard_Integer minute, hour;
c.Show(second, minute, hour,cpu);
if (hour > 0)
sprintf(t,"%dh:%dm:%.2fs",hour,minute,second);
else if (minute > 0)
sprintf(t,"%dm:%.2fs",minute,second);
else
sprintf(t,"%.2fs",second);
// Sending of message : End of Loading
msg2065.Arg(t);
TF->Send (msg2065, Message_Info);
return Standard_True;
}
//=======================================================================
//function : UsedTolerance
//purpose : Returns the used tolerance (input)
//=======================================================================
Standard_Real IGESToBRep_Reader::UsedTolerance () const
{ return theActor->UsedTolerance(); }
//=======================================================================
//function : NbShapes
//purpose : Returns the count of produced Shapes
//=======================================================================
Standard_Integer IGESToBRep_Reader::NbShapes () const
{ return theShapes.Length(); }
//=======================================================================
//function : Shape
//purpose : Returns a Shape given its rank
//=======================================================================
TopoDS_Shape IGESToBRep_Reader::Shape (const Standard_Integer num) const
{
TopoDS_Shape res;
if (num > 0 && num <= theShapes.Length()) res = theShapes.Value(num);
return res;
}
//=======================================================================
//function : OneShape
//purpose : Returns a unique Shape
//=======================================================================
TopoDS_Shape IGESToBRep_Reader::OneShape () const
{
TopoDS_Shape res;
Standard_Integer nb = theShapes.Length();
if (nb == 0) return res;
else if (nb == 1) return theShapes.Value(1);
else {
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound(C);
for (Standard_Integer i = 1; i <= nb; i ++) B.Add (C,theShapes.Value(i));
return C;
}
}

View File

@@ -0,0 +1,24 @@
-- File: IGESToBRep_ToolContainer.cdl
-- Created: Mon Feb 7 13:08:17 2000
-- Author: data exchange team
-- <det@kinox>
---Copyright: Matra Datavision 2000
class ToolContainer from IGESToBRep inherits TShared from MMgt
---Purpose:
uses
IGESBoundary from IGESToBRep
is
Create returns mutable ToolContainer from IGESToBRep;
---Purpose: Empty constructor
IGESBoundary (me) returns IGESBoundary from IGESToBRep is virtual;
---Purpose: Returns IGESToBRep_IGESBoundary
end ToolContainer;

View File

@@ -0,0 +1,26 @@
// File: IGESToBRep_ToolContainer.cxx
// Created: Mon Feb 7 13:08:56 2000
// Author: data exchange team
// <det@kinox>
#include <IGESToBRep_ToolContainer.ixx>
//=======================================================================
//function : IGESToBRep_ToolContainer
//purpose :
//=======================================================================
IGESToBRep_ToolContainer::IGESToBRep_ToolContainer()
{
}
//=======================================================================
//function : IGESBoundary
//purpose :
//=======================================================================
Handle(IGESToBRep_IGESBoundary) IGESToBRep_ToolContainer::IGESBoundary() const
{
return new IGESToBRep_IGESBoundary;
}

View File

@@ -0,0 +1,189 @@
-- File: IGESToBRep_TopoCurve.cdl
-- Created: Thu Apr 21 14:02:21 1994
-- Authors: Christophe GUYOT & Frederic UNTEREINER
-- <fun@ecolox>
---Copyright: Matra Datavision 1994
class TopoCurve from IGESToBRep inherits CurveAndSurface from IGESToBRep
---Purpose : Provides methods to transfer topologic curves entities
-- from IGES to CASCADE.
uses
CurveAndSurface from IGESToBRep,
IGESEntity from IGESData,
HArray1OfIGESEntity from IGESData,
Boundary from IGESGeom,
CompositeCurve from IGESGeom,
OffsetCurve from IGESGeom,
CurveOnSurface from IGESGeom,
Point from IGESGeom,
Edge from TopoDS,
Face from TopoDS,
Shape from TopoDS,
Vertex from TopoDS,
Wire from TopoDS,
Curve from Geom,
Surface from Geom,
BSplineCurve from Geom,
SequenceOfCurve from TColGeom,
Curve from Geom2d,
BSplineCurve from Geom2d,
SequenceOfCurve from TColGeom2d,
WireData from ShapeExtend,
Trsf2d from gp
is
Create returns TopoCurve;
---Purpose : Creates a tool TopoCurve ready to run, with
-- epsilons set to 1.E-04, TheModeTopo to True, the
-- optimization of the continuity to False.
Create(CS : CurveAndSurface from IGESToBRep) returns TopoCurve;
---Purpose : Creates a tool TopoCurve ready to run and sets its
-- fields as CS's.
Create(CS : TopoCurve from IGESToBRep) returns TopoCurve;
---Purpose : Creates a tool TopoCurve ready to run and sets its
-- fields as CS's.
Create(eps : Real;
epsGeom : Real;
epsCoeff : Real;
mode : Boolean;
modeapprox : Boolean;
optimized : Boolean) returns TopoCurve;
---Purpose : Creates a tool TopoCurve ready to run.
TransferTopoCurve (me : in out;
start : IGESEntity from IGESData)
returns Shape from TopoDS;
Transfer2dTopoCurve (me : in out;
start : IGESEntity from IGESData;
face : Face from TopoDS;
trans : Trsf2d from gp;
uFact : Real)
returns Shape from TopoDS;
TransferTopoBasicCurve (me : in out;
start : IGESEntity from IGESData)
returns Shape from TopoDS;
Transfer2dTopoBasicCurve (me : in out;
start : IGESEntity from IGESData;
face : Face from TopoDS;
trans : Trsf2d from gp;
uFact : Real)
returns Shape from TopoDS;
TransferPoint (me : in out;
start : Point from IGESGeom)
returns Vertex from TopoDS;
Transfer2dPoint (me : in out;
start : Point from IGESGeom)
returns Vertex from TopoDS;
TransferCompositeCurveGeneral (me : in out;
start : CompositeCurve from IGESGeom;
is2d : Boolean;
face : Face from TopoDS;
trans : Trsf2d from gp;
uFact : Real)
returns Shape from TopoDS is private;
TransferCompositeCurve (me : in out;
start : CompositeCurve from IGESGeom)
returns Shape from TopoDS;
Transfer2dCompositeCurve (me : in out;
start : CompositeCurve from IGESGeom;
face : Face from TopoDS;
trans : Trsf2d from gp;
uFact : Real)
returns Shape from TopoDS;
TransferOffsetCurve (me : in out;
start : OffsetCurve from IGESGeom)
returns Shape from TopoDS;
Transfer2dOffsetCurve (me : in out;
start : OffsetCurve from IGESGeom;
face : Face from TopoDS;
trans : Trsf2d from gp;
uFact : Real)
returns Shape from TopoDS;
TransferCurveOnSurface (me : in out;
start : CurveOnSurface from IGESGeom)
returns Shape from TopoDS;
TransferCurveOnFace (me : in out;
face : in out Face from TopoDS;
start : CurveOnSurface from IGESGeom;
trans : Trsf2d from gp;
uFact : Real;
IsCurv : Boolean from Standard)
returns Shape from TopoDS;
---Purpose : Transfers a CurveOnSurface directly on a face to trim it.
-- The CurveOnSurface have to be defined Outer or Inner.
TransferBoundary (me : in out;
start : Boundary from IGESGeom)
returns Shape from TopoDS;
TransferBoundaryOnFace (me : in out;
face : in out Face from TopoDS;
start : Boundary from IGESGeom;
trans : Trsf2d from gp;
uFact : Real)
returns Shape from TopoDS;
---Purpose : Transfers a Boundary directly on a face to trim it.
ApproxBSplineCurve (me : in out;
start : BSplineCurve from Geom);
NbCurves (me)
returns Integer;
---Purpose : Returns the count of Curves in "TheCurves"
Curve (me;
num : Integer = 1)
returns Curve from Geom;
---Purpose : Returns a Curve given its rank, by default the first one
-- (null Curvee if out of range) in "TheCurves"
Approx2dBSplineCurve (me : in out;
start : BSplineCurve from Geom2d);
NbCurves2d (me)
returns Integer;
---Purpose : Returns the count of Curves in "TheCurves2d"
Curve2d (me;
num : Integer = 1)
returns Curve from Geom2d;
---Purpose : Returns a Curve given its rank, by default the first one
-- (null Curvee if out of range) in "TheCurves2d"
SetBadCase (me: in out; value: Boolean);
---Purpose: Sets TheBadCase flag
BadCase (me) returns Boolean;
---Purpose: Returns TheBadCase flag
fields
TheCurves : SequenceOfCurve from TColGeom;
TheCurves2d : SequenceOfCurve from TColGeom2d;
TheBadCase : Boolean from Standard;
end TopoCurve;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,117 @@
-- File: IGESToBRep_TopoSurface.cdl
-- Created: Thu Apr 21 14:02:21 1994
-- Authors: Christophe GUYOT & Frederic UNTEREINER
-- <fun@ecolox>
---Copyright: Matra Datavision 1994
class TopoSurface from IGESToBRep inherits CurveAndSurface from IGESToBRep
---Purpose : Provides methods to transfer topologic surfaces entities
-- from IGES to CASCADE.
uses
CurveAndSurface from IGESToBRep,
IGESEntity from IGESData,
RuledSurface from IGESGeom,
SurfaceOfRevolution from IGESGeom,
TabulatedCylinder from IGESGeom,
OffsetSurface from IGESGeom,
Plane from IGESGeom,
TrimmedSurface from IGESGeom,
BoundedSurface from IGESGeom,
PlaneSurface from IGESSolid,
SingleParent from IGESBasic,
Shape from TopoDS,
Face from TopoDS,
Pln from gp,
Trsf from gp,
Trsf2d from gp
is
Create returns TopoSurface;
---Purpose : Creates a tool TopoSurface ready to run, with
-- epsilons set to 1.E-04, TheModeTopo to True, the
-- optimization of the continuity to False.
Create(CS : CurveAndSurface from IGESToBRep) returns TopoSurface;
---Purpose : Creates a tool TopoSurface ready to run and sets its
-- fields as CS's.
Create(eps : Real;
epsGeom : Real;
epsCoeff : Real;
mode : Boolean;
modeapprox : Boolean;
optimized : Boolean)
returns TopoSurface;
---Purpose : Creates a tool TopoSurface ready to run.
TransferTopoSurface (me : in out;
start : IGESEntity from IGESData)
returns Shape from TopoDS;
TransferTopoBasicSurface (me : in out;
start : IGESEntity from IGESData)
returns Shape from TopoDS;
TransferRuledSurface (me : in out;
start : RuledSurface from IGESGeom)
returns Shape from TopoDS;
TransferSurfaceOfRevolution (me : in out;
start : SurfaceOfRevolution from IGESGeom)
returns Shape from TopoDS;
TransferTabulatedCylinder (me : in out;
start : TabulatedCylinder from IGESGeom)
returns Shape from TopoDS;
TransferOffsetSurface (me : in out;
start : OffsetSurface from IGESGeom)
returns Shape from TopoDS;
TransferTrimmedSurface (me : in out;
start : TrimmedSurface from IGESGeom)
returns Shape from TopoDS;
TransferBoundedSurface (me : in out;
start : BoundedSurface from IGESGeom)
returns Shape from TopoDS;
TransferPlane (me : in out;
start : Plane from IGESGeom)
returns Shape from TopoDS;
TransferPlaneSurface (me : in out;
start : PlaneSurface from IGESSolid)
returns Shape from TopoDS;
TransferPerforate (me : in out;
start : SingleParent from IGESBasic)
returns Shape from TopoDS;
TransferPlaneParts (me : in out;
start : Plane from IGESGeom;
gplan : out Pln from gp;
locat : out Trsf from gp;
first : Boolean)
returns Shape from TopoDS is private;
ParamSurface (me : in out;
start : IGESEntity from IGESData;
trans : out Trsf2d from gp;
uFact : out Real)
returns Shape from TopoDS;
-- ---Purpose : Set the surface parameters:
-- IsRevol : True for TabulatedCylinder or SurfaceOfRevolution
-- ParamU ,Paramv, Length used for 2d Curves parametrization.
fields
TheULength : Real from Standard;
end TopoSurface;

File diff suppressed because it is too large Load Diff

122
src/IGESToBRep/project.pxx Executable file
View File

@@ -0,0 +1,122 @@
#include <GeomAbs_CurveType.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <ProjLib_ProjectedCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Hypr2d.hxx>
#include <gp_Parab2d.hxx>
Standard_Boolean IGESToBRep_TopoCurve::Project(TopoDS_Wire& wir,
const TopoDS_Face& face)
{
// Creation du GeomAdaptor pour la surface support :
// =================================================
if (face.IsNull() || wir.IsNull()) return Standard_False;
TopLoc_Location SrfLoc;
Handle(Geom_Surface) Srf = BRep_Tool::Surface(face,SrfLoc);
Standard_Real UMin, UMax, VMin, VMax;
BRepTools::UVBounds(face,UMin, UMax, VMin, VMax);
GeomAdaptor_Surface GASrf(Srf, UMin, UMax, VMin, VMax);
// Creation des GeomAdaptors pour mettre a jour les edges du wire :
// ================================================================
BRep_Builder B;
for (TopoDS_Iterator Iter(wir); Iter.More(); Iter.Next()) {
Standard_Integer num = 1;
TopoDS_Shape Sh = Iter.Value();
if (Sh.IsNull() || Sh.ShapeType()!=TopAbs_EDGE)
continue;
TopoDS_Edge E = TopoDS::Edge(Sh);
TopLoc_Location L;
Standard_Real a,b;
Handle(Geom_Curve) C = BRep_Tool::Curve(E,L,a,b);
GeomAdaptor_Curve GACrv(C,a,b);
// Test of the 3d curve type :
// ===========================
ProjLib_ProjectedCurve PrjCrv;
GeomAbs_CurveType CrvTpe = GACrv.GetType();
if (CrvTpe==GeomAbs_BezierCurve ||
CrvTpe==GeomAbs_BSplineCurve ||
CrvTpe==GeomAbs_OtherCurve) {
return Standard_False;
}
else {
PrjCrv = ProjLib_ProjectedCurve
(new GeomAdaptor_HSurface(GASrf),
new GeomAdaptor_HCurve(GACrv));
CrvTpe = PrjCrv.GetType();
}
// Test of the 2d curve type :
// ===========================
switch (CrvTpe) {
case GeomAbs_Line :
{
gp_Lin2d Lin = PrjCrv.Line();
Handle(Geom2d_Line) GLin = new Geom2d_Line(Lin);
B.UpdateEdge(E,GLin,face,GetEpsGeom());
B.Range(E,face,a,b);
}
break;
case GeomAbs_Circle :
{
gp_Circ2d C = PrjCrv.Circle();
Handle(Geom2d_Circle) GC = new Geom2d_Circle(C);
B.UpdateEdge(E,GC,face,GetEpsGeom());
B.Range(E,face,a,b);
}
break;
case GeomAbs_Ellipse :
{
gp_Elips2d Elps = PrjCrv.Ellipse();
Handle(Geom2d_Ellipse) GElps = new Geom2d_Ellipse(Elps);
B.UpdateEdge(E,GElps,face,GetEpsGeom());
B.Range(E,face,a,b);
}
break;
case GeomAbs_Hyperbola :
{
gp_Hypr2d H = PrjCrv.Hyperbola();
Handle(Geom2d_Hyperbola) GH = new Geom2d_Hyperbola(H);
B.UpdateEdge(E,GH,face,GetEpsGeom());
B.Range(E,face,a,b);
}
break;
case GeomAbs_Parabola :
{
gp_Parab2d P = PrjCrv.Parabola();
Handle(Geom2d_Parabola) GP = new Geom2d_Parabola(P);
B.UpdateEdge(E,GP,face,GetEpsGeom());
B.Range(E,face,a,b);
}
break;
default :
{
return Standard_False;
}
break;
}
}
return Standard_True;
}