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

36
src/IGESControl/IGESControl.cdl Executable file
View File

@@ -0,0 +1,36 @@
-- File: IGESControl.cdl
-- Created: Tue Jan 30 18:44:36 1996
-- Author: Christian CAILLET
-- <cky@paris1>
---Copyright: Matra Datavision 1996
package IGESControl
---Purpose : This package provide external access and control to use IGES
-- See also IGESToBRep for reading IGES to Shapes
uses
TColStd,
Interface,
Transfer,
IFSelect,
XSControl,
IGESData,
TopoDS,
IGESToBRep,
ShapeExtend,
Message
is
class Controller;
class Writer;
class Reader;
class ActorWrite;
class IGESBoundary;
class AlgoContainer;
class ToolContainer;
end;

View File

@@ -0,0 +1,34 @@
-- File: IGESControl_ActorWrite.cdl
-- Created: Mon Sep 7 14:33:09 1998
-- Author: Christian CAILLET
-- <cky@paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class ActorWrite from IGESControl
inherits ActorOfFinderProcess from Transfer
---Purpose : Actor to write Shape to IGES
uses
Finder from Transfer,
FinderProcess from Transfer,
Binder from Transfer
is
Create returns ActorWrite;
Recognize (me : mutable; start : Finder from Transfer) returns Boolean
is redefined;
---Purpose : Recognizes a ShapeMapper
Transfer (me : mutable; start : Finder from Transfer;
FP : mutable FinderProcess) returns Binder is redefined;
---Purpose : Transfers Shape to IGES Entities
--
-- ModeTrans may be : 0 -> groups of Faces
-- or 1 -> BRep
end ActorWrite;

View File

@@ -0,0 +1,93 @@
#include <IGESControl_ActorWrite.ixx>
#include <TransferBRep_ShapeMapper.hxx>
#include <Interface_Macros.hxx>
#include <IGESData_IGESModel.hxx>
#include <BRepToIGES_BREntity.hxx>
#include <BRepToIGESBRep_Entity.hxx>
#include <Transfer_TransientMapper.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <GeomToIGES_GeomCurve.hxx>
#include <GeomToIGES_GeomSurface.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <Interface_Static.hxx>
IGESControl_ActorWrite::IGESControl_ActorWrite () { ModeTrans() = 0; }
Standard_Boolean IGESControl_ActorWrite::Recognize
(const Handle(Transfer_Finder)& start)
{
DeclareAndCast(TransferBRep_ShapeMapper,shmap,start);
if (!shmap.IsNull()) return Standard_True;
DeclareAndCast(Transfer_TransientMapper,gemap,start);
if (!gemap.IsNull()) {
Handle(Standard_Transient) geom = gemap->Value();
DeclareAndCast(Geom_Curve,Curve,geom);
DeclareAndCast(Geom_Surface,Surf,geom);
if (!Curve.IsNull() || !Surf.IsNull()) return Standard_True;
}
return Standard_False;
}
Handle(Transfer_Binder) IGESControl_ActorWrite::Transfer
(const Handle(Transfer_Finder)& start,
const Handle(Transfer_FinderProcess)& FP)
{
XSAlgo::AlgoContainer()->PrepareForTransfer();
DeclareAndCast(IGESData_IGESModel,modl,FP->Model());
if (modl.IsNull()) return NullResult();
if (themodetrans < 0 || themodetrans > 1) return NullResult();
Handle(Standard_Transient) ent;
DeclareAndCast(TransferBRep_ShapeMapper,shmap,start);
if (!shmap.IsNull()) {
TopoDS_Shape shape = shmap->Value();
if (shape.IsNull()) return NullResult();
// modified by NIZHNY-EAP Tue Aug 29 11:16:54 2000 ___BEGIN___
Handle(Standard_Transient) info;
Standard_Real Tol = Interface_Static::RVal("write.precision.val");
Standard_Real maxTol = Interface_Static::RVal("read.maxprecision.val");
shape = XSAlgo::AlgoContainer()->ProcessShape( shape, Tol, maxTol,
"write.iges.resource.name",
"write.iges.sequence", info );
// modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___
BRepToIGES_BREntity BR0; BR0.SetModel(modl); BR0.SetTransferProcess(FP);
BRepToIGESBRep_Entity BR1; BR1.SetModel(modl); BR1.SetTransferProcess(FP);
if (themodetrans == 0) ent = BR0.TransferShape(shape);
if (themodetrans == 1) ent = BR1.TransferShape(shape);
// modified by NIZHNY-EAP Tue Aug 29 11:37:18 2000 ___BEGIN___
XSAlgo::AlgoContainer()->MergeTransferInfo(FP, info);
// modified by NIZHNY-EAP Tue Aug 29 11:37:25 2000 ___END___
if (!ent.IsNull()) return TransientResult(ent);
}
DeclareAndCast(Transfer_TransientMapper,gemap,start);
if (!gemap.IsNull()) {
Handle(Standard_Transient) geom = gemap->Value();
DeclareAndCast(Geom_Curve,Curve,geom);
DeclareAndCast(Geom_Surface,Surf,geom);
// On reconnait : Curve et Surface de Geom
// quid de Point; Geom2d ?
// GeomToIGES_GeomPoint GP;
GeomToIGES_GeomCurve GC; GC.SetModel(modl);
GeomToIGES_GeomSurface GS; GS.SetModel(modl);
if (!Curve.IsNull())
ent = GC.TransferCurve(Curve,Curve->FirstParameter(),Curve->LastParameter())
;
else if (!Surf.IsNull()) {
Standard_Real U1,U2,V1,V2;
Surf->Bounds(U1,U2,V1,V2);
ent = GS.TransferSurface(Surf,U1,U2,V1,V2);
}
if (!ent.IsNull()) return TransientResult(ent);
}
return NullResult();
}

View File

@@ -0,0 +1,17 @@
-- File: IGESControl_AlgoContainer.cdl
-- Created: Tue Feb 8 09:24:41 2000
-- Author: data exchange team
-- <det@kinox>
---Copyright: Matra Datavision 2000
class AlgoContainer from IGESControl inherits AlgoContainer from IGESToBRep
---Purpose:
is
Create returns mutable AlgoContainer from IGESControl;
---Purpose: Empty constructor
end AlgoContainer;

View File

@@ -0,0 +1,19 @@
// File: IGESControl_AlgoContainer.cxx
// Created: Tue Feb 8 09:29:29 2000
// Author: data exchange team
// <det@kinox>
#include <IGESControl_AlgoContainer.ixx>
#include <IGESControl_ToolContainer.hxx>
//=======================================================================
//function : IGESControl_AlgoContainer
//purpose :
//=======================================================================
IGESControl_AlgoContainer::IGESControl_AlgoContainer():IGESToBRep_AlgoContainer()
{
SetToolContainer (new IGESControl_ToolContainer);
}

View File

@@ -0,0 +1,66 @@
-- File: IGESControl_Controller.cdl
-- Created: Wed Mar 15 13:09:14 1995
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1995
class Controller from IGESControl inherits Controller from XSControl
---Purpose : Controller for IGES-5.1
uses
CString,
Protocol from Interface,
InterfaceModel from Interface,
WorkLibrary from IFSelect,
ReturnStatus from IFSelect,
ActorOfTransientProcess from Transfer,
FinderProcess from Transfer,
ActorOfFinderProcess from Transfer,
WorkSession from XSControl,
Shape from TopoDS
is
Create (modefnes : Boolean = Standard_False)
returns mutable Controller from IGESControl;
---Purpose : Initializes the use of IGES Norm (the first time) and returns
-- a Controller for IGES-5.1
-- If <modefnes> is True, sets it to internal FNES format
NewModel (me) returns mutable InterfaceModel from Interface;
---Purpose : Creates a new empty Model ready to receive data of the Norm.
-- It is taken from IGES Template Model
ActorRead (me; model : InterfaceModel)
returns mutable ActorOfTransientProcess from Transfer;
---Purpose : Returns the Actor for Read attached to the pair (norm,appli)
-- It is an Actor from IGESToBRep, adapted from an IGESModel :
-- Unit, tolerances
TransferWriteShape (me; shape : Shape from TopoDS;
FP : mutable FinderProcess from Transfer;
model : mutable InterfaceModel from Interface;
modetrans : Integer = 0)
returns ReturnStatus is redefined;
---Purpose : Takes one Shape and transfers it to the InterfaceModel
-- (already created by NewModel for instance)
-- <modetrans> is to be interpreted by each kind of XstepAdaptor
-- Returns a status : 0 OK 1 No result 2 Fail -1 bad modeshape
-- -2 bad model (requires an IGESModel)
-- modeshape : 0 groupe of face (version < 5.1)
-- 1 BREP-version 5.1 of IGES
Init (myclass) returns Boolean;
---Purpose : Standard Initialisation. It creates a Controller for IGES and
-- records it to various names, available to select it later
-- Returns True when done, False if could not be done
-- Also, it creates and records an Adaptor for FNES
Customise (me: mutable; WS : in out WorkSession from XSControl) is redefined;
fields
themode : Boolean;
end Controller;

View File

@@ -0,0 +1,370 @@
//#58 rln 28.12.98 changing default values for Global Section
//sln 14.01.2002 OCC51 : verifying whether entry model of method ActorRead is IGESDatat_IGESModel
#include <IGESControl_Controller.ixx>
#include <IGESSelect_WorkLibrary.hxx>
#include <IGESToBRep_Actor.hxx>
#include <IGESData_IGESModel.hxx>
#include <IGESSolid.hxx>
#include <IGESAppli.hxx>
#include <Interface_Static.hxx>
#include <IGESSelect_AutoCorrect.hxx>
#include <IGESSelect_ComputeStatus.hxx>
#include <IGESSelect_UpdateFileName.hxx>
#include <IGESSelect_SetGlobalParameter.hxx>
#include <IGESSelect_FloatFormat.hxx>
#include <IGESSelect_SelectBypassGroup.hxx>
#include <IGESSelect_SelectBypassSubfigure.hxx>
#include <IGESSelect_SelectBasicGeom.hxx>
#include <IGESSelect_SelectFaces.hxx>
#include <IGESSelect_SelectPCurves.hxx>
#include <IGESSelect_SelectVisibleStatus.hxx>
#include <IGESSelect_SelectSubordinate.hxx>
#include <IFSelect_SelectType.hxx>
#include <IGESBasic_SubfigureDef.hxx>
#include <IGESSelect_IGESTypeForm.hxx>
#include <IGESSelect_SignStatus.hxx>
#include <IGESSelect_SignLevelNumber.hxx>
#include <IGESSelect_SignColor.hxx>
#include <IGESSelect_IGESName.hxx>
#include <IFSelect_SignType.hxx>
#include <IFSelect_SignMultiple.hxx>
#include <IGESSelect_CounterOfLevelNumber.hxx>
#include <IFSelect_SignCounter.hxx>
#include <IGESSelect_EditHeader.hxx>
#include <IGESSelect_EditDirPart.hxx>
#include <IFSelect_EditForm.hxx>
#include <IGESSelect_RemoveCurves.hxx>
#include <IGESSelect_SetLabel.hxx>
#include <TCollection_HAsciiString.hxx>
#include <IGESControl_ActorWrite.hxx>
#include <IGESControl_AlgoContainer.hxx>
#include <XSAlgo.hxx>
#include <Interface_Macros.hxx>
#include <IGESToBRep.hxx>
#include <IFSelect_SelectModelEntities.hxx>
#include <IFSelect_SelectModelEntities.hxx>
#include <IFSelect_SelectModelRoots.hxx>
#include <XSControl_SelectForTransfer.hxx>
//szv#4:S4163:12Mar99 never referenced
//static const Standard_CString thelong = "IGES";
//static const Standard_CString theshort = "iges";
//=======================================================================
//function : IGESControl_Controller
//purpose :
//=======================================================================
IGESControl_Controller::IGESControl_Controller (const Standard_Boolean mod)
//JR/Hp
: XSControl_Controller ((Standard_CString ) (mod ? "FNES" : "IGES") , (Standard_CString ) (mod ? "fnes" : "iges") ) ,
// : XSControl_Controller ( (mod ? "FNES" : "iges") , (mod ? "fnes" : "iges") ) ,
themode (mod)
{
static Standard_Boolean init = Standard_False;
if (!init) {
IGESSolid::Init();
IGESAppli::Init();
init = Standard_True;
}
AddSessionItem (new IGESSelect_RemoveCurves(Standard_True) ,"iges-remove-pcurves");
AddSessionItem (new IGESSelect_RemoveCurves(Standard_False),"iges-remove-curves-3d");
AddSessionItem (new IGESSelect_SetLabel (0,Standard_True) ,"iges-clear-label");
AddSessionItem (new IGESSelect_SetLabel (1,Standard_False),"iges-set-label-dnum");
AddSessionItem (new IGESSelect_AutoCorrect,"iges-auto-correct","send");
AddSessionItem (new IGESSelect_ComputeStatus,"iges-compute-status","send");
Handle(IGESSelect_FloatFormat) flf = new IGESSelect_FloatFormat;
flf->SetDefault (12);
AddSessionItem (flf,"iges-float-digits-12","send");
// -- Sender Product Identification -- (pas un statique ...)
Handle(IGESSelect_SetGlobalParameter) set3 = new IGESSelect_SetGlobalParameter(3);
//#58 rln Handle(TCollection_HAsciiString) pa3 = new TCollection_HAsciiString("MDTV X-STEP");
Handle(TCollection_HAsciiString) pa3 =
Interface_Static::Static("write.iges.header.product")->HStringValue();
set3->SetValue(pa3);
AddSessionItem (pa3, "iges-header-val-sender");
AddSessionItem (set3,"iges-header-set-sender","send");
AddSessionItem (new IGESSelect_UpdateFileName,"iges-update-file-name","send");
// -- Receiver -- Acces par Static, ajustable
Handle(IGESSelect_SetGlobalParameter) set12 = new IGESSelect_SetGlobalParameter(12);
// Handle(TCollection_HAsciiString) pa12 = new TCollection_HAsciiString("Unknown");
Handle(TCollection_HAsciiString) pa12 =
Interface_Static::Static("write.iges.header.receiver")->HStringValue();
set12->SetValue(pa12);
AddSessionItem (pa12, "iges-header-val-receiver");
AddSessionItem (set12,"iges-header-set-receiver","send");
// -- Auteur -- acces par Static (demarre par whoami), ajustable
Handle(IGESSelect_SetGlobalParameter) set21 = new IGESSelect_SetGlobalParameter(21);
// Handle(TCollection_HAsciiString) pa21 = new TCollection_HAsciiString("Unknown");
Handle(TCollection_HAsciiString) pa21 =
Interface_Static::Static("write.iges.header.author")->HStringValue();
set21->SetValue(pa21);
AddSessionItem (pa21, "iges-header-val-author");
AddSessionItem (set21,"iges-header-set-author","send");
// -- Compagnie (de l auteur) -- acces par Static, ajustable
Handle(IGESSelect_SetGlobalParameter) set22 = new IGESSelect_SetGlobalParameter(22);
// Handle(TCollection_HAsciiString) pa22 = new TCollection_HAsciiString("MATRA-DATAVISION");
Handle(TCollection_HAsciiString) pa22 =
Interface_Static::Static("write.iges.header.company")->HStringValue();
set22->SetValue(pa22);
AddSessionItem (pa22, "iges-header-val-company");
AddSessionItem (set22,"iges-header-set-company","send");
// -- STATICS
TraceStatic ("read.iges.bspline.approxd1.mode",5);
TraceStatic ("read.iges.bspline.continuity",5);
TraceStatic ("write.iges.header.receiver",2);
TraceStatic ("write.iges.header.author",2);
TraceStatic ("write.iges.header.company",2);
TraceStatic ("write.iges.unit",6);
TraceStatic ("write.iges.brep.mode",6);
theAdaptorLibrary = new IGESSelect_WorkLibrary(themode);
theAdaptorProtocol = IGESSelect_WorkLibrary::DefineProtocol();
Handle(IGESToBRep_Actor) anactiges = new IGESToBRep_Actor;
anactiges->SetContinuity(0);
theAdaptorRead = anactiges;
theAdaptorWrite = new IGESControl_ActorWrite;
SetModeWrite (0,1);
SetModeWriteHelp (0,"Faces");
SetModeWriteHelp (1,"BRep");
}
void IGESControl_Controller::Customise(Handle(XSControl_WorkSession)& WS)
{
XSControl_Controller::Customise(WS);
// --- SELECTIONS, SIGNATURES, COMPTEURS, EDITEURS
// -- BypassGroup / xst-model-roots
//DeclareAndCast(IFSelect_Selection,xma,SessionItem("xst-model-all"));
Handle(IFSelect_SelectModelEntities) xma;
Handle(Standard_Transient) xma1 = WS->NamedItem("xst-model-all");
if(xma1.IsNull()) xma = new IFSelect_SelectModelEntities;
else {
xma =Handle(IFSelect_SelectModelEntities)::DownCast(xma1);
WS->AddNamedItem ("xst-model-all",xma);
}
//DeclareAndCast(IFSelect_Selection,xmr,SessionItem("xst-model-roots"));
Handle(IFSelect_SelectModelRoots) xmr;
Handle(Standard_Transient) xmr1 = WS->NamedItem("xst-model-roots");
if(!xmr1.IsNull())
xmr = Handle(IFSelect_SelectModelRoots)::DownCast(xmr1);
else {
xmr = new IFSelect_SelectModelRoots;
WS->AddNamedItem ("xst-model-roots",xmr);
}
// DeclareAndCast(IFSelect_Selection,xtr,SessionItem("xst-transferrable-roots"));
Handle(XSControl_SelectForTransfer) xtr;
Handle(Standard_Transient) xtr1 = WS->NamedItem("xst-transferrable-roots");
if(!xtr1.IsNull())
xtr = Handle(XSControl_SelectForTransfer)::DownCast(xtr1);
//st1->SetInput (slr);
else {
xtr= new XSControl_SelectForTransfer;
xtr->SetReader (WS->TransferReader());
WS->AddNamedItem ("xst-transferrable-roots",xtr);
}
if (!xmr.IsNull()) {
Handle(IGESSelect_SelectVisibleStatus) visa = new IGESSelect_SelectVisibleStatus;
visa->SetInput(xmr);
WS->AddNamedItem ("iges-visible-roots",visa);
Handle(IGESSelect_SelectVisibleStatus) vist = new IGESSelect_SelectVisibleStatus;
vist->SetInput(xtr);
WS->AddNamedItem ("iges-visible-transf-roots",vist);
Handle(IGESSelect_SelectVisibleStatus) blka = new IGESSelect_SelectVisibleStatus;
blka->SetDirect (Standard_False);
blka->SetInput(xmr);
WS->AddNamedItem ("iges-blanked-roots",blka);
Handle(IGESSelect_SelectVisibleStatus) blkt = new IGESSelect_SelectVisibleStatus;
blkt->SetDirect (Standard_False);
blkt->SetInput(xtr);
WS->AddNamedItem ("iges-blanked-transf-roots",blkt);
Handle(IGESSelect_SelectSubordinate) indp = new IGESSelect_SelectSubordinate (0);
indp->SetInput (xma);
WS->AddNamedItem ("iges-status-independant",indp);
Handle(IGESSelect_SelectBypassGroup) sb = new IGESSelect_SelectBypassGroup;
sb->SetInput(xmr);
WS->AddNamedItem ("iges-bypass-group",sb);
Handle(IGESSelect_SelectBypassSubfigure) sfi = new IGESSelect_SelectBypassSubfigure;
sfi->SetInput(xmr);
WS->AddNamedItem ("iges-bypass-subfigure",sfi);
Handle(IGESSelect_SelectBypassGroup) sfb = new IGESSelect_SelectBypassGroup;
sfb->SetInput(sfi);
WS->AddNamedItem ("iges-bypass-group-subfigure",sfb);
Handle(IGESSelect_SelectBasicGeom) sc3d = new IGESSelect_SelectBasicGeom(1);
sc3d->SetInput(sfi);
WS->AddNamedItem ("iges-curves-3d",sc3d);
Handle(IGESSelect_SelectBasicGeom) sb3d = new IGESSelect_SelectBasicGeom(2);
sb3d->SetInput(sfi);
WS->AddNamedItem ("iges-basic-curves-3d",sb3d);
Handle(IGESSelect_SelectBasicGeom) sbg = new IGESSelect_SelectBasicGeom(0);
sbg->SetInput(sfi);
WS->AddNamedItem ("iges-basic-geom",sbg);
Handle(IGESSelect_SelectBasicGeom) srf = new IGESSelect_SelectBasicGeom(-1);
srf->SetInput(sfi);
WS->AddNamedItem ("iges-surfaces",srf);
Handle(IGESSelect_SelectFaces) sfa = new IGESSelect_SelectFaces;
sfa->SetInput(sfi);
WS->AddNamedItem ("iges-faces",sfa );
Handle(IGESSelect_SelectPCurves) spc = new IGESSelect_SelectPCurves(Standard_True);
spc->SetInput(sfa);
WS->AddNamedItem ("iges-pcurves",spc);
Handle(IFSelect_SelectType) snosub = new IFSelect_SelectType
(STANDARD_TYPE(IGESBasic_SubfigureDef));
snosub->SetDirect(Standard_False);
snosub->SetInput(xmr);
WS->AddNamedItem ("iges-no-indep-subfigure-def",snosub);
Handle(IGESSelect_IGESTypeForm) itf = new IGESSelect_IGESTypeForm(Standard_True);
WS->AddNamedItem ("iges-type",itf);
Handle(IGESSelect_SignStatus) sigst = new IGESSelect_SignStatus;
Handle(IFSelect_SignMultiple) typsta = new IFSelect_SignMultiple
("IGES Type Form Status");
typsta->Add (itf,15);
typsta->Add (sigst);
WS->AddNamedItem ("iges-type-status",typsta);
Handle(IFSelect_SignMultiple) typnam = new IFSelect_SignMultiple
("IGES Type Form TypeName");
typnam->Add (itf,4);
typnam->Add (new IFSelect_SignType(Standard_True));
WS->AddNamedItem ("iges-type-name",typnam);
Handle(IFSelect_SignCounter) itfs = new IFSelect_SignCounter
(itf,Standard_False,Standard_True);
WS->AddNamedItem ("iges-types",itfs);
Handle(IGESSelect_CounterOfLevelNumber) levs =
new IGESSelect_CounterOfLevelNumber;
WS->AddNamedItem ("iges-levels",levs);
Handle(IGESSelect_SignLevelNumber) slev = new IGESSelect_SignLevelNumber(Standard_False);
WS->AddNamedItem ("iges-level-number",slev);
Handle(IGESSelect_IGESName) igna = new IGESSelect_IGESName;
WS->AddNamedItem ("iges-name",igna);
Handle(IGESSelect_SignColor) scol1 = new IGESSelect_SignColor (1);
WS->AddNamedItem ("iges-color-number",scol1);
Handle(IGESSelect_SignColor) scol2 = new IGESSelect_SignColor (2);
WS->AddNamedItem ("iges-color-name",scol2);
Handle(IGESSelect_SignColor) scol3 = new IGESSelect_SignColor (3);
WS->AddNamedItem ("iges-color-rgb",scol3);
Handle(IGESSelect_SignColor) scol4 = new IGESSelect_SignColor (4);
WS->AddNamedItem ("iges-color-red",scol4);
Handle(IGESSelect_SignColor) scol5 = new IGESSelect_SignColor (5);
WS->AddNamedItem ("iges-color-green",scol5);
Handle(IGESSelect_SignColor) scol6 = new IGESSelect_SignColor (6);
WS->AddNamedItem ("iges-color-blue",scol6);
Handle(IGESSelect_EditHeader) edhead = new IGESSelect_EditHeader;
WS->AddNamedItem ("iges-header-edit",edhead);
Handle(IFSelect_EditForm) edheadf = edhead->Form(Standard_False);
WS->AddNamedItem ("iges-header",edheadf);
Handle(IGESSelect_EditDirPart) eddirp = new IGESSelect_EditDirPart;
WS->AddNamedItem ("iges-dir-part-edit",eddirp);
Handle(IFSelect_EditForm) eddirpf = eddirp->Form(Standard_False);
WS->AddNamedItem ("iges-dir-part",eddirpf);
theSignType = typnam;
}
}
//=======================================================================
//function : NewModel
//purpose :
//=======================================================================
Handle(Interface_InterfaceModel) IGESControl_Controller::NewModel () const
{
// On prend un modele qu on prepare avec les statiques enregistres
DeclareAndCast(IGESData_IGESModel,igm,Interface_InterfaceModel::Template("iges"));
IGESData_GlobalSection GS = igm->GlobalSection();
GS.SetReceiveName (Interface_Static::Static("write.iges.header.receiver")->HStringValue());
GS.SetUnitFlag (Interface_Static::IVal("write.iges.unit"));
GS.SetUnitName (new TCollection_HAsciiString(Interface_Static::CVal("write.iges.unit")));
GS.SetAuthorName (Interface_Static::Static("write.iges.header.author")->HStringValue());
GS.SetCompanyName (Interface_Static::Static("write.iges.header.company")->HStringValue());
igm->SetGlobalSection (GS);
return igm;
}
//=======================================================================
//function : ActorRead
//purpose :
//=======================================================================
Handle(Transfer_ActorOfTransientProcess) IGESControl_Controller::ActorRead
(const Handle(Interface_InterfaceModel)& model) const
{
DeclareAndCast(IGESToBRep_Actor,anactiges,theAdaptorRead);
if (anactiges.IsNull()) return theAdaptorRead;
//sln 14.01.2002 OCC51 : verifying whether entry model is IGESDatat_IGESModel,
// if this condition is false new model is created
Handle(Interface_InterfaceModel) aModel;
if(model->IsKind(STANDARD_TYPE(IGESData_IGESModel)))
aModel = model;
else
aModel = NewModel();
anactiges->SetModel(GetCasted(IGESData_IGESModel,aModel));
anactiges->SetContinuity(Interface_Static::IVal("read.iges.bspline.continuity"));
return anactiges;
}
// #### TRANSFERT (ECRITURE SHAPE) ####
// modetrans : 0 <5.1 (groupe de faces), 1 BREP-5.1
//=======================================================================
//function : TransferWriteShape
//purpose :
//=======================================================================
IFSelect_ReturnStatus IGESControl_Controller::TransferWriteShape (const TopoDS_Shape& shape,
const Handle(Transfer_FinderProcess)& FP,
const Handle(Interface_InterfaceModel)& model,
const Standard_Integer modetrans) const
{
return XSControl_Controller::TransferWriteShape (shape,FP,model,modetrans);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean IGESControl_Controller::Init ()
{
static Standard_Boolean inic = Standard_False;
if (!inic) {
Handle(IGESControl_Controller) ADIGES = new IGESControl_Controller(Standard_False);
ADIGES->AutoRecord();
XSAlgo::Init();
IGESToBRep::Init();
IGESToBRep::SetAlgoContainer (new IGESControl_AlgoContainer());
inic = Standard_True;
}
return Standard_True;
}

View File

@@ -0,0 +1,57 @@
-- File: IGESControl_IGESBoundary.cdl
-- Created: Sat Feb 5 15:58:02 2000
-- Author: data exchange team
-- <det@kinox>
---Copyright: Matra Datavision 2000
class IGESBoundary from IGESControl inherits IGESBoundary from IGESToBRep
---Purpose: Translates IGES boundary entity (types 141, 142 and 508)
-- in Advanced Data Exchange.
-- Redefines translation and treatment methods from inherited
-- open class IGESToBRep_IGESBoundary.
uses
IGESEntity from IGESData,
HArray1OfIGESEntity from IGESData,
CurveAndSurface from IGESToBRep,
WireData from ShapeExtend
is
Create returns mutable IGESBoundary from IGESControl;
---Purpose: Creates an object and calls inherited constuctor.
Create (CS: CurveAndSurface from IGESToBRep) returns mutable IGESBoundary from IGESControl;
---Purpose: Creates an object and calls inherited constuctor.
Check (me: mutable; result, checkclosure, okCurve3d, okCurve2d: Boolean) is redefined;
---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.
-- Checks the closure of resulting wire and if it is not closed,
-- checks 2D and 3D representation and updates the resulting
-- wire to contain only closed representation.
---Remark : If resulting representation will be 3D, some edges may still
-- contain pcurves which are consistent with 3D curves for the
-- given edge.
---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 redefined protected;
end IGESBoundary;

View File

@@ -0,0 +1,380 @@
// File: IGESControl_IGESBoundary.cxx
// Created: Sat Feb 5 16:35:04 2000
// Author: data exchange team
// <det@kinox>
//06.01.99 pdn renaming ShapeFix_Wire::FixLittle to ShapeFix_Wire::FixSmall
//:n1 abv 20.01.99: BUC60328.rle (loopback): call FixSmall with Max(1.,preci)
//smh #1 11.03.99 PRO15640/15641, szv#2 PRO17393: call FixSameParameter after BuildCurve3d
//#74 rln 10.03.99 S4135: handling use of BRepLib::SameParameter by new static parameter
// pdn 18.03.99 S4135: using mintol instead of resolution from IGES file
// pdn 18.03.99 S4135: projecting with resolution from IGES file.
//%14 pdn 06.03.99 implementing fixFace in IGES
// S4135 pdn improvements in using of stdsameparameter flag
//#21 gka 12.04.99 CSR UKI60998 entities number - 13, 24 lost of boundaries during translation of tabulated cylinders
//S4181 pdn 15.04.99 implementing of reading IGES elementary surfaces. (instead of shift, reverce and
//scale factors the transformation matrix and scale factor used)
#include <IGESControl_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 <ShapeAnalysis_Wire.hxx>
#include <ShapeAnalysis_ShapeTolerance.hxx>
#include <ShapeFix_Edge.hxx>
#include <ShapeFix_Wire.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <IGESToBRep.hxx>
#include <IGESToBRep_TopoCurve.hxx>
#include <Message_Msg.hxx>
#include <Interface_Static.hxx>
#include <ShapeAlgo.hxx>
#include <ShapeAlgo_AlgoContainer.hxx>
#include <ShapeAlgo_ToolContainer.hxx>
#include <IGESGeom_BSplineCurve.hxx>
//=======================================================================
//function : IGESControl_IGESBoundary
//purpose :
//=======================================================================
IGESControl_IGESBoundary::IGESControl_IGESBoundary() : IGESToBRep_IGESBoundary()
{
}
//=======================================================================
//function : IGESControl_IGESBoundary
//purpose :
//=======================================================================
IGESControl_IGESBoundary::IGESControl_IGESBoundary(const IGESToBRep_CurveAndSurface& CS) :
IGESToBRep_IGESBoundary (CS)
{
}
//=======================================================================
//function : Check
//purpose :
//=======================================================================
void IGESControl_IGESBoundary::Check(const Standard_Boolean result,const Standard_Boolean checkclosure,
const Standard_Boolean aokCurve3d, const Standard_Boolean aokCurve2d)
{
Standard_Boolean Result = result;
Standard_Boolean okCurve3d = aokCurve3d, okCurve2d = aokCurve2d;
Standard_Real maxtol = myCS.GetMaxTol();
if (Result && checkclosure) {
//USA60022 7277 check of closure
Handle(ShapeAnalysis_Wire) saw = new ShapeAnalysis_Wire;
saw->Load (mysewd);
saw->SetPrecision (maxtol);
saw->CheckConnected (1);
if (saw->LastCheckStatus (ShapeExtend_FAIL)) {
saw->Load (mysewd3d);
saw->CheckConnected (1);
if (saw->LastCheckStatus (ShapeExtend_FAIL)) okCurve3d = Standard_False;
else okCurve2d = Standard_False;
Result = Standard_False;
}
}
if (!Result) {
mysewd->Clear();
if (okCurve3d && mysewd3d->NbEdges() > 0) {
Message_Msg Msg1070("IGES_1070");//"Representations in the file are inconsistent. Recomputation from 3d"
Msg1070.Arg(3);
myCS.SendWarning(myentity,Msg1070);
mysewd = mysewd3d;
}
else if (okCurve2d && mysewd2d->NbEdges() > 0) {
Message_Msg Msg1070("IGES_1070");//"Representations in the file are inconsistent. Recomputation from 2d"
Msg1070.Arg(2);
myCS.SendWarning(myentity,Msg1070);
mysewd = mysewd2d;
}
}
}
//=======================================================================
//function : Transfer
//purpose :
//=======================================================================
Standard_Boolean IGESControl_IGESBoundary::Transfer(Standard_Boolean& okCurve,
Standard_Boolean& okCurve3d,
Standard_Boolean& okCurve2d,
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 revsewd, revnextsewd;
Standard_Real distmin, precision = myCS.GetEpsGeom() * myCS.GetUnitFactor(), maxtol = myCS.GetMaxTol();
Handle(ShapeAnalysis_Wire) saw = new ShapeAnalysis_Wire,
saw3d = new ShapeAnalysis_Wire,
saw2d = new ShapeAnalysis_Wire;
saw->Load (Gsewd); saw->SetPrecision (precision);
saw3d->Load (Gsewd3d); saw3d->SetPrecision (precision);
saw2d->Load (Gsewd2d); saw2d->SetPrecision (precision);
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();
}
Standard_Integer surfcurv = myCS.GetSurfaceCurve();
if ((surfcurv == -2 && len2d > 0) || len3d == 0)
GTranslate3d = Standard_False;
else if (( surfcurv == -3 && len3d > 0) || len2d == 0)
GTranslate2d = Standard_False;
if (GTranslate3d && GTranslate2d)
//Setting preference in the case of inconsitency between 3D and 2D
if (surfcurv == 2) Preferred3d = Standard_False;
else if (surfcurv == 3) Preferred2d = Standard_False;
else 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;
}
Standard_Boolean bad3d = TC.BadCase(); //:27
okCurve3d = okCurve3d && ShapeAlgo::AlgoContainer()->ConnectNextWire (saw3d, Lsewd3d, maxtol, distmin, revsewd, revnextsewd);
Handle(ShapeExtend_WireData) Lsewd2d = new ShapeExtend_WireData;
TC.SetBadCase (Standard_False); //:27
TopoDS_Shape shape2d = TC.Transfer2dTopoCurve (Handle(IGESData_IGESEntity)::DownCast (seq2d->Value (i)),
myface, mytrsf, myuFact);
Standard_Boolean bad2d = TC.BadCase(); //:27
if (!shape2d.IsNull()) {
Lsewd2d->Add (shape2d);
if (toreverse2d) {
ReverseCurves2d (Lsewd2d, myface);
}
okCurve2d = okCurve2d && ShapeAlgo::AlgoContainer()->ConnectNextWire (saw2d, Lsewd2d, maxtol, distmin, revsewd, revnextsewd);
}
else LTranslate2d = Standard_False;
// if (LTranslate3d && LTranslate2d && (Lsewd3d->NbEdges() != Lsewd2d->NbEdges() || bad3d || bad2d)) {
Standard_Boolean isBSpline = Standard_False;
if(!usescurve && !seq3d->Value (i).IsNull() && !seq2d->Value (i).IsNull())
isBSpline = seq3d->Value (i)->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve)) &&
seq2d->Value (i)->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve));
if (LTranslate3d && LTranslate2d &&
(
(isBSpline && (Lsewd3d->NbEdges() != Lsewd2d->NbEdges())) ||
(!isBSpline && (Lsewd3d->NbEdges() != 1 || Lsewd2d->NbEdges() != 1)) ||
bad3d || bad2d
)) {
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
Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge;
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;
if (sfe->FixReversed2d (edge3d, myface)) {
#ifdef DEB
cout << "Warning: IGESToBRep_IGESBoundary: 2D curve of edge was reversed" << endl;
#endif
}
//#74 rln 10.03.99 S4135: handling use of BRepLib::SameParameter by new static parameter
if (Interface_Static::IVal ("read.stdsameparameter.mode")) {
Standard_Real first, last;
BRep_Tool::Range(edge3d,first,last);
// pdn 08.04.99 S4135 optimizing in computation of SPTol
//choosing tolerance according to Approx_SameParameter: 50 * 22
Standard_Real SPTol = Min (precision, Abs (last - first)/1000);
BRep_Builder B;
B.SameParameter (edge3d, Standard_False);
sfe->FixSameParameter (edge3d, SPTol);
}
else
sfe->FixSameParameter (edge3d);
Standard_Real maxdev = BRep_Tool::Tolerance (edge3d);
//pdn 08.04.99 S4135 recomputing only if deviation is greater than maxtol
if (maxdev > maxtol) { //:e2
#ifdef DEB
cout << "Warning: IGESToBRep_IGESBoundary: Deviation = " << maxdev << endl;
#endif
ShapeFix_ShapeTolerance().SetTolerance (edge3d, Precision::Confusion());
for (Standard_Integer ie = 1; ie <= iedge; ie++)
ShapeBuild_Edge().RemovePCurve (Lsewd3d->Edge (ie), myface);
if (Preferred3d) {
#ifdef DEB
cout << "Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 2D is ignored" << endl;
#endif
}
else {
#ifdef DEB
cout << "Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored" << endl;
#endif
Lsewd = Lsewd2d;
}
break;
}
}
}
okCurve = okCurve && ShapeAlgo::AlgoContainer()->ConnectNextWire (saw, Lsewd, maxtol, distmin, revsewd, revnextsewd);
if (!okCurve) {
#ifdef DEB
cout << "Warning: IGESToBRep_IGESBoundary: Curves " << i - 1 << " and " << i << " cannot be connected" << endl;
#endif
Gsewd3d = new ShapeExtend_WireData;
for (Standard_Integer i = 1; i <= len3d; i++) {
if (usescurve)
Gsewd3d->Add (scurve3d->Edge (i));
else {
TopoDS_Shape Sh =
TC.TransferTopoCurve (Handle(IGESData_IGESEntity)::DownCast (seq3d->Value (i)));
if (!Sh.IsNull()) Gsewd3d->Add (Sh);
}
}
if (toreverse3d) {
ReverseCurves3d(Gsewd3d);
}
Gsewd2d = new ShapeExtend_WireData;
for (Standard_Integer i = 1; i <= len2d; i++) {
TopoDS_Shape Sh = TC.Transfer2dTopoCurve (Handle(IGESData_IGESEntity)::DownCast (seq2d->Value (i)),
myface, mytrsf, myuFact);
if (!Sh.IsNull()) Gsewd2d->Add (Sh);
}
if (toreverse2d) {
ReverseCurves2d (Gsewd2d, myface);
}
Handle(ShapeFix_Wire) sfw3 = new ShapeFix_Wire(Gsewd3d->Wire(),myface,precision);
sfw3->Perform();
TopoDS_Wire w3 = sfw3->Wire();
Handle(ShapeFix_Wire) sfw2 = new ShapeFix_Wire(Gsewd2d->Wire(),myface,precision);
sfw2->Perform();
TopoDS_Wire w2 = sfw2->Wire();
ShapeAnalysis_ShapeTolerance ST;
double tol3 = ST.Tolerance(w3,1);
double tol2 = ST.Tolerance(w2,1);
Gsewd3d = new ShapeExtend_WireData;
Gsewd2d = new ShapeExtend_WireData;
Gsewd3d->Add(w3);
Gsewd2d->Add(w3);
if(tol3<tol2)
Gsewd->Add(w3);
else
Gsewd->Add(w2);
okCurve = Standard_True;
okCurve2d = Standard_True;
okCurve3d = Standard_True;
}
}
}
if (number > 1) {
saw->Load (mysewd);
okCurve = okCurve &&
ShapeAlgo::AlgoContainer()->ConnectNextWire (saw, Gsewd, maxtol,
distmin, revsewd, revnextsewd);
saw3d->Load (mysewd3d);
okCurve3d = okCurve3d &&
ShapeAlgo::AlgoContainer()->ConnectNextWire (saw3d, Gsewd3d, maxtol,
distmin, revsewd, revnextsewd);
saw2d->Load (mysewd2d);
okCurve2d = okCurve2d &&
ShapeAlgo::AlgoContainer()->ConnectNextWire (saw2d, Gsewd2d, maxtol,
distmin, revsewd, revnextsewd);
}
else {
mysewd = Gsewd;
mysewd3d = Gsewd3d;
mysewd2d = Gsewd2d;
}
return okCurve;
}

View File

@@ -0,0 +1,92 @@
-- File: IGESControl_Reader.cdl
-- Created: Fri Sep 6 09:18:33 1996
-- Author: Christian CAILLET
-- <cky@fidox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class Reader from IGESControl inherits Reader from XSControl
---Purpose :
-- Reads IGES files, checks them and translates their contents into Open CASCADE models.
-- The IGES data can be that of a whole model or that of a specific list of entities in the model.
-- As in XSControl_Reader, you specify the list using a selection.
-- For translation of iges files it is possible to use the following sequence:
-- To change parameters of translation
-- class Interface_Static should be used before the beginning of translation
-- (see IGES Parameters and General Parameters)
-- Creation of reader
-- IGESControl_Reader reader;
-- To load a file in a model use method:
-- reader.ReadFile("filename.igs")
-- To check a loading file use method Check:
-- reader.Check(failsonly); where failsonly is equal to Standard_True or
-- Standard_False;
-- To print the results of load:
-- reader.PrintCheckLoad(failsonly,mode) where mode is equal to the value of
-- enumeration IFSelect_PrintCount
-- To transfer entities from a model the following methods can be used:
-- for the whole model
-- reader.TransferRoots(onlyvisible); where onlyvisible is equal to
-- Standard_True or Standard_False;
-- To transfer a list of entities:
-- reader.TransferList(list);
-- To transfer one entity
-- reader.TransferEntity(ent) or reader.Transfer(num);
-- To obtain a result the following method can be used:
-- reader.IsDone()
-- reader.NbShapes() and reader.Shape(num); or reader.OneShape();
-- To print the results of transfer use method:
-- reader.PrintTransferInfo(failwarn,mode); where printfail is equal to the
-- value of enumeration IFSelect_PrintFail, mode see above.
-- Gets correspondence between an IGES entity and a result shape obtained therefrom.
-- reader.TransientProcess();
-- TopoDS_Shape shape =
-- TransferBRep::ShapeResult(reader.TransientProcess(),ent);
uses CString, HSequenceOfTransient from TColStd,
IGESModel from IGESData,
PrintFail from IFSelect,
PrintCount from IFSelect,
ReturnStatus from IFSelect,
WorkSession from XSControl
is
Create returns Reader from IGESControl;
---Purpose : Creates a Reader from scratch
Create (WS : mutable WorkSession from XSControl;
scratch : Boolean = Standard_True)
returns Reader from IGESControl;
---Purpose : Creates a Reader from an already existing Session
SetReadVisible(me: in out; ReadRoot: Boolean from Standard);
---Purpose : Set the transion of ALL Roots (if theReadOnlyVisible is False)
-- or of Visible Roots (if theReadOnlyVisible is True)
---C++: inline
GetReadVisible(me) returns Boolean;
---C++: inline
IGESModel (me) returns IGESModel;
---Purpose : Returns the model as a IGESModel.
-- It can then be consulted (header, product)
NbRootsForTransfer (me : in out) returns Integer is redefined;
---Purpose : Determines the list of root entities from Model which are candidate for
-- a transfer to a Shape (type of entities is PRODUCT)
-- <theReadOnlyVisible> is taken into account to define roots
PrintTransferInfo(me; failwarn: PrintFail from IFSelect; mode: PrintCount from IFSelect);
---Purpose : Prints Statistics and check list for Transfer
-- other methods are inherited from Reader in IGESToBRep
fields
theReadOnlyVisible : Boolean from Standard;
end Reader;

View File

@@ -0,0 +1,303 @@
//gka 06.01.99 S3767
//abv 10.04.99 S4136: eliminate using BRepAPI::Precision()
#include <IGESControl_Reader.ixx>
#include <IGESControl_Controller.hxx>
#include <XSControl_Controller.hxx>
#include <XSControl_TransferReader.hxx>
#include <Interface_ShareFlags.hxx>
#include <IFSelect_Functions.hxx>
#include <Interface_InterfaceModel.hxx>
#include <IGESData_IGESModel.hxx>
#include <Interface_Static.hxx>
#include <Interface_Check.hxx>
// S3767 dce 18/01/1999
#include <Message_Msg.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_Binder.hxx>
#include <TopoDS_Shape.hxx>
#include <Interface_CheckIterator.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <IFSelect_CheckCounter.hxx>//Transfer_Iterator.hxx>
#include <Dico_DictionaryOfTransient.hxx>
#include <Dico_DictionaryOfInteger.hxx>
#include <Dico_IteratorOfDictionaryOfInteger.hxx>
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
#include <Interface_Macros.hxx>
#include <IGESData_IGESEntity.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
#include <OSD_Timer.hxx>
#include <Transfer_TransferOutput.hxx>
#include <ShapeExtend_Explorer.hxx>
#include <Message_ProgressSentry.hxx>
#include <Message_Messenger.hxx>
#include <Transfer_ActorOfTransientProcess.hxx>
#include <IGESToBRep_Actor.hxx>
#include <IGESData_FileProtocol.hxx>
#include <TransferBRep.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <BRepLib.hxx>
// add of stdio.h for NT compilation
#include <stdio.h>
//=======================================================================
//function : IGESControl_Reader
//purpose :
//=======================================================================
IGESControl_Reader::IGESControl_Reader ()
{
IGESControl_Controller::Init();
SetWS (new XSControl_WorkSession);
SetNorm("IGES");
theReadOnlyVisible = Standard_False;
}
//=======================================================================
//function : IGESControl_Reader
//purpose :
//=======================================================================
IGESControl_Reader::IGESControl_Reader
(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
{
IGESControl_Controller::Init();
SetWS (WS,scratch);
SetNorm ("IGES");
theReadOnlyVisible = Standard_False;
}
//=======================================================================
//function : IGESModel
//purpose :
//=======================================================================
Handle(IGESData_IGESModel) IGESControl_Reader::IGESModel () const
{
return Handle(IGESData_IGESModel)::DownCast(Model());
}
//=======================================================================
//function : NbRootsForTransfer
//purpose :
//=======================================================================
Standard_Integer IGESControl_Reader::NbRootsForTransfer()
{
if (therootsta) return theroots.Length();
therootsta = Standard_True;
Handle(IGESData_IGESModel) model = IGESModel();
if (model.IsNull()) return 0;
Handle(XSControl_WorkSession) session = WS();
Handle(Interface_Protocol) protocol = session->Protocol();
Handle(XSControl_Controller) controller = session->NormAdaptor();
Handle(Transfer_ActorOfTransientProcess) actor = controller->ActorRead(model);
Interface_ShareFlags SH (model,protocol);
// sln 11.06.2002 OCC448
Interface_Static::SetIVal("read.iges.onlyvisible",theReadOnlyVisible);
Standard_Integer nb = model->NbEntities();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(IGESData_IGESEntity) ent = model->Entity(i);
if ( SH.IsShared(ent) || ! actor->Recognize (ent) ) continue;
// on ajoute un traitement pour ne prendre que les entites visibles
if ( ! theReadOnlyVisible || ent->BlankStatus() == 0 ) {
theroots.Append(ent);
}
}
return theroots.Length();
}
// #### Reliquat de methodes a reprendre ####
//=======================================================================
// Function : PrintTransferInfo
// Purpose : Print statistics information on transfer using MoniTool message management
// Created : 18/01/98 DCE for S3767
// Modified :
//=======================================================================
void IGESControl_Reader::PrintTransferInfo
(const IFSelect_PrintFail failsonly, const IFSelect_PrintCount mode) const
{
Standard_Integer nbWarn = 0, nbFail= 0, nbEntities =0, nbRoots = 0, nbResults = 0;
Handle(Transfer_TransientProcess) TP = WS()->MapReader();
Handle(Message_Messenger) TF = TP->Messenger();
Handle(Interface_InterfaceModel) model = TP->Model();
if (! model.IsNull()) {
nbEntities = model->NbEntities();
nbRoots = TP->NbRoots();
//nbResults = TP->NbMapped();
Transfer_IteratorOfProcessForTransient iterTrans = TP->RootResult(Standard_True);
Handle(Dico_DictionaryOfInteger) dicoCountResult = new Dico_DictionaryOfInteger;
Handle(Dico_DictionaryOfInteger) dicoCountMapping = new Dico_DictionaryOfInteger;
for (iterTrans.Start(); iterTrans.More() ; iterTrans.Next() ) {
nbResults++;
// Init for dicoCountResult for IFSelect_ResultCount
if ( mode == IFSelect_ResultCount ) {
char mess[300];
const Handle(Transfer_Binder) aBinder = iterTrans.Value();
sprintf(mess,"\t%s",aBinder->ResultTypeName());
Standard_Boolean deja;
Standard_Integer& nb = dicoCountResult->NewItem(mess,deja);
if (!deja) nb = 0;
nb ++;
}
// Init for dicoCountMapping for IFSelect_Mapping
else if ( mode == IFSelect_Mapping ) {
char mess[300];
const Handle(Transfer_Binder) aBinder = iterTrans.Value();
DeclareAndCast(IGESData_IGESEntity,igesEnt,iterTrans.Starting());
sprintf(mess,"%d\t%d\t%s\t%s", igesEnt->TypeNumber(), igesEnt->FormNumber(),
"%d", aBinder->ResultTypeName());
//cout << mess << endl;
Standard_Boolean deja;
Standard_Integer& nb = dicoCountMapping->NewItem(mess,deja);
if (!deja) nb = 0;
nb ++;
}
}
Interface_CheckIterator checkIterator = TP->CheckList(Standard_False);
Handle(Dico_DictionaryOfInteger) dicoCount = new Dico_DictionaryOfInteger;
Handle(Dico_DictionaryOfTransient) dicoList = new Dico_DictionaryOfTransient;
// Init the dicoCount dicoList and nbWarn ,nb Fail.
for(checkIterator.Start(); checkIterator.More(); checkIterator.Next() ) {
char mess[300];
const Handle(Interface_Check) aCheck = checkIterator.Value();
Handle(Standard_Transient) ent = model->Value(checkIterator.Number());
DeclareAndCast(IGESData_IGESEntity,igesEnt,ent);
Standard_Integer type = igesEnt->TypeNumber(), form = igesEnt->FormNumber();
Standard_Integer nw = aCheck->NbWarnings(), nf = aCheck->NbFails(), i;
for(i = 1; (failsonly==IFSelect_FailAndWarn) && (i<= nw); i++) {
sprintf(mess,"\t W\t%d\t%d\t%s",type,form,aCheck->CWarning(i));
Standard_Boolean deja;
Standard_Integer& nb = dicoCount->NewItem(mess,deja);
if (!deja) nb = 0;
nb ++;
Handle(Standard_Transient)& anitem = dicoList->NewItem(mess,deja);
DeclareAndCast(TColStd_HSequenceOfInteger,alist,anitem);
if (!deja) { alist = new TColStd_HSequenceOfInteger(); anitem = alist; }
alist->Append(model->Number(igesEnt)*2-1);
}
for(i = 1; i<= nf; i++) {
sprintf(mess,"\t F\t%d\t%d\t%s",type,form,aCheck->CFail(i));
// TF << mess << endl;
Standard_Boolean deja;
Standard_Integer& nb = dicoCount->NewItem(mess,deja);
if (!deja) nb = 0;
nb ++;
Handle(Standard_Transient)& anitem = dicoList->NewItem(mess,deja);
DeclareAndCast(TColStd_HSequenceOfInteger,alist,anitem);
if (!deja) { alist = new TColStd_HSequenceOfInteger(); anitem = alist; }
alist->Append(model->Number(igesEnt)*2-1);
}
nbWarn += nw;
nbFail += nf;
}
Message_Msg msg3000("IGES_3000"); // *************************
TF->Send (msg3000, Message_Info); //smh#14
switch (mode) {
case IFSelect_GeneralInfo : {
Message_Msg msg3005("IGES_3005");TF->Send(msg3005, Message_Info);
Message_Msg msg3010("IGES_3010");msg3010.Arg(nbEntities);TF->Send(msg3010, Message_Info);
Message_Msg msg3011("IGES_3011");msg3011.Arg(nbRoots);TF->Send(msg3011, Message_Info);
Message_Msg msg3015("IGES_3015");msg3015.Arg(nbResults);TF->Send(msg3015, Message_Info);
Message_Msg msg3020("IGES_3020");msg3020.Arg(nbWarn);TF->Send(msg3020, Message_Info);
Message_Msg msg3025("IGES_3025");msg3025.Arg(nbFail);TF->Send(msg3025, Message_Info);
break;
}
case IFSelect_CountByItem :
case IFSelect_ListByItem : {
Message_Msg msg3030("IGES_3030");
TF->Send(msg3030, Message_Info);
Dico_IteratorOfDictionaryOfInteger dicoCountIter(dicoCount);
Dico_IteratorOfDictionaryOfTransient dicoListIter(dicoList);
for(dicoCountIter.Start(),dicoListIter.Start();
dicoCountIter.More() && dicoListIter.More();
dicoCountIter.Next(),dicoListIter.Next()) {
TF << dicoCountIter.Value() << dicoCountIter.Name() << endl;
if (mode == IFSelect_ListByItem) {
DeclareAndCast(TColStd_HSequenceOfInteger, entityList, dicoListIter.Value());
Standard_Integer length = entityList->Length();
Message_Msg msg3035("IGES_3035");
TF->Send(msg3035, Message_Info);
char line[80];
sprintf(line,"\t\t\t");
TF << line ;
Standard_Integer nbInLine =0;
for(Standard_Integer i = 1; i <= length ; i++ ) {
// IDT_Out << (entityList->Value(i)) << " ";
sprintf(line,"\t %d", entityList->Value(i));
TF << line ;
if (++nbInLine == 6) {
nbInLine = 0;
sprintf(line,"\n\t\t\t");
TF << line ;
}
}
TF << endl ;
}
}
break;
}
case IFSelect_ResultCount : {
Message_Msg msg3040("IGES_3040");TF->Send(msg3040, Message_Info);
Message_Msg msg3011("IGES_3011");msg3011.Arg(nbRoots);TF->Send(msg3011, Message_Info);
Message_Msg msg3015("IGES_3015");msg3015.Arg(nbResults);TF->Send(msg3015, Message_Info);
Message_Msg msg3045("IGES_3045");TF->Send(msg3045, Message_Info);
Dico_IteratorOfDictionaryOfInteger dicoCountIter(dicoCountResult);
for(dicoCountIter.Start(); dicoCountIter.More(); dicoCountIter.Next()) {
TF << dicoCountIter.Value() << dicoCountIter.Name() << endl;
}
break;
}
case IFSelect_Mapping : {
Message_Msg msg3040("IGES_3050");TF->Send(msg3040, Message_Info);
Message_Msg msg3011("IGES_3011");msg3011.Arg(nbRoots);TF->Send(msg3011, Message_Info);
Message_Msg msg3015("IGES_3015");msg3015.Arg(nbResults);TF->Send(msg3015, Message_Info);
Message_Msg msg3045("IGES_3055");TF->Send(msg3045, Message_Info);
// Add failed entities in dicoCountMapping
if (nbRoots!=nbResults) {
for( Standard_Integer i = 1; i <= nbRoots ; i++) {
DeclareAndCast(IGESData_IGESEntity, root, TP->Root(i));
if (!TP->IsBound(root)) {
char mess[300];
sprintf(mess,"%d\t%d \t%s\t%s", root->TypeNumber(), root->FormNumber(),
"%d", "Failed");
//cout << mess << endl;
Standard_Boolean deja;
Standard_Integer& nb = dicoCountMapping->NewItem(mess,deja);
if (!deja) nb = 0;
nb ++;
}
}
}
Dico_IteratorOfDictionaryOfInteger dicoCountIter(dicoCountMapping);
for(dicoCountIter.Start(); dicoCountIter.More(); dicoCountIter.Next()) {
char mess[80];
sprintf(mess, dicoCountIter.Name().ToCString() , dicoCountIter.Value());
TF << mess << endl; //dicoCountIter.Value() << dicoCountIter.Name() << endl;
}
break;
}
default: break;
}
}
}

View File

@@ -0,0 +1,21 @@
//=======================================================================
//function : SetReadVisible
//purpose :
//=======================================================================
inline void IGESControl_Reader::SetReadVisible (const Standard_Boolean ReadRoot)
{
theReadOnlyVisible = ReadRoot;
}
//=======================================================================
//function : GetReadVisible
//purpose :
//=======================================================================
inline Standard_Boolean IGESControl_Reader::GetReadVisible ()const
{
return theReadOnlyVisible;
}

View File

@@ -0,0 +1,24 @@
-- File: IGESControl_ToolContainer.cdl
-- Created: Tue Feb 8 09:25:35 2000
-- Author: data exchange team
-- <det@kinox>
---Copyright: Matra Datavision 2000
class ToolContainer from IGESControl inherits ToolContainer from IGESToBRep
---Purpose:
uses
IGESBoundary from IGESToBRep
is
Create returns mutable ToolContainer from IGESControl;
---Purpose: Empty constructor
IGESBoundary (me) returns IGESBoundary from IGESToBRep is redefined;
---Purpose: Returns IGESControl_IGESBoundary
end ToolContainer;

View File

@@ -0,0 +1,27 @@
// File: IGESControl_ToolContainer.cxx
// Created: Tue Feb 8 09:30:22 2000
// Author: data exchange team
// <det@kinox>
#include <IGESControl_ToolContainer.ixx>
#include <IGESControl_IGESBoundary.hxx>
//=======================================================================
//function : IGESControl_ToolContainer
//purpose :
//=======================================================================
IGESControl_ToolContainer::IGESControl_ToolContainer():IGESToBRep_ToolContainer()
{
}
//=======================================================================
//function : IGESBoundary
//purpose :
//=======================================================================
Handle(IGESToBRep_IGESBoundary) IGESControl_ToolContainer::IGESBoundary() const
{
return new IGESControl_IGESBoundary;
}

View File

@@ -0,0 +1,98 @@
-- File: IGESControl_Writer.cdl
-- Created: Tue Jan 30 18:57:48 1996
-- Author: Christian CAILLET
-- <cky@paris1>
---Copyright: Matra Datavision 1996
class Writer from IGESControl
---Purpose : This class creates and writes
-- IGES files from CAS.CADE models. An IGES file can be written to
-- an existing IGES file or to a new one.
-- The translation can be performed in one or several
-- operations. Each translation operation
-- outputs a distinct root entity in the IGES file.
-- To write an IGES file it is possible to use the following sequence:
-- To modify the IGES file header or to change translation
-- parameters it is necessary to use class Interface_Static (see
-- IGESParameters and GeneralParameters).
uses CString, OStream, Transient, Shape from TopoDS,
FinderProcess, BasicEditor from IGESData, IGESModel, IGESEntity
is
Create returns Writer;
---Purpose : Creates a writer object with the
-- default unit (millimeters) and write mode (Face).
-- IGESControl_Writer (const Standard_CString unit,
-- const Standard_Integer modecr = 0);
Create (unit : CString; modecr : Integer = 0) returns Writer;
---Purpose : Creates a writer with given
-- values for units and for write mode.
-- unit may be any unit that is accepted by the IGES standard.
-- By default, it is the millimeter.
-- modecr defines the write mode and may be:
-- - 0: Faces (default)
-- - 1: BRep.
Create (model : mutable IGESModel; modecr : Integer = 0) returns Writer;
---Purpose : Creates a writer object with the
-- prepared IGES model model in write mode.
-- modecr defines the write mode and may be:
-- - 0: Faces (default)
-- - 1: BRep.
Model (me) returns IGESModel;
---Purpose : Returns the IGES model to be written in output.
TransferProcess (me) returns mutable FinderProcess;
SetTransferProcess (me : in out; TP : mutable FinderProcess);
---Purpose : Returns/Sets the TransferProcess : it contains final results
-- and if some, check messages
AddShape (me : in out; sh : Shape) returns Boolean;
---Purpose : Translates a Shape to IGES Entities and adds them to the model
-- Returns True if done, False if Shape not suitable for IGES or null
AddGeom (me : in out; geom : Transient) returns Boolean;
---Purpose : Translates a Geometry (Surface or Curve) to IGES Entities and
-- adds them to the model
-- Returns True if done, False if geom is neither a Surface or
-- a Curve suitable for IGES or is null
AddEntity (me : in out; ent : IGESEntity) returns Boolean;
---Purpose : Adds an IGES entity (and the ones it references) to the model
ComputeModel (me : in out);
---Purpose : Computes the entities found in
-- the model, which is ready to be written.
-- This contrasts with the default computation of headers only.
Write (me : in out; S : in out OStream; fnes : Boolean = Standard_False)
returns Boolean;
---Purpose : Computes then writes the model to an OStream
-- Returns True when done, false in case of error
Write (me : in out; file : CString; fnes : Boolean = Standard_False)
returns Boolean;
---Purpose : Prepares and writes an IGES model
-- either to an OStream, S or to a file name,CString.
-- Returns True if the operation was performed correctly and
-- False if an error occurred (for instance,
-- if the processor could not create the file).
PrintStatsTransfer (me; what : Integer; mode : Integer = 0);
---Purpose : Prints Statistics about Transfer
fields
theTP : FinderProcess;
themod : IGESModel;
thedit : BasicEditor from IGESData;
thecr : Integer; -- mode ecr
thest : Boolean; -- computed ?
end Writer;

View File

@@ -0,0 +1,265 @@
//cky 16.01.99 Remove couts.
//rln 28.12.98 CCI60005
#include <Standard_Stream.hxx>
#include <IGESControl_Writer.ixx>
#include <IGESControl_Controller.hxx>
#include <IGESSelect_WorkLibrary.hxx>
#include <BRepToIGES_BREntity.hxx>
#include <BRepToIGESBRep_Entity.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <GeomToIGES_GeomCurve.hxx>
#include <GeomToIGES_GeomSurface.hxx>
#include <IGESData_IGESWriter.hxx>
#include <XSControl_TransferWriter.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Static.hxx>
#include <ShapeAnalysis_ShapeTolerance.hxx>
#include <gp_XYZ.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <BndLib_Add3dCurve.hxx>
#include <BndLib_AddSurface.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <TopExp_Explorer.hxx>
#include <Message_ProgressIndicator.hxx>
#include <errno.h>
IGESControl_Writer::IGESControl_Writer ()
: theTP (new Transfer_FinderProcess(10000)) ,
thedit (IGESSelect_WorkLibrary::DefineProtocol()) ,
thecr (0) , thest (Standard_False)
{
// faudrait aussi (?) prendre les parametres par defaut ... ?
IGESControl_Controller::Init();
thedit.SetUnitName(Interface_Static::CVal ("write.iges.unit"));
thedit.ApplyUnit();
themod = thedit.Model();
}
IGESControl_Writer::IGESControl_Writer
(const Standard_CString unit, const Standard_Integer modecr)
: theTP (new Transfer_FinderProcess(10000)) ,
thedit (IGESSelect_WorkLibrary::DefineProtocol()) ,
thecr (modecr) , thest (Standard_False)
{
// faudrait aussi (?) prendre les parametres par defaut ... ?
IGESControl_Controller::Init();
thedit.SetUnitName(unit);
thedit.ApplyUnit();
themod = thedit.Model();
}
IGESControl_Writer::IGESControl_Writer
(const Handle(IGESData_IGESModel)& model, const Standard_Integer modecr)
: theTP (new Transfer_FinderProcess(10000)) ,
themod (model) ,
thedit (model,IGESSelect_WorkLibrary::DefineProtocol()) ,
thecr (modecr) , thest (Standard_False) { }
Handle(IGESData_IGESModel) IGESControl_Writer::Model () const
{
return themod;
}
Handle(Transfer_FinderProcess) IGESControl_Writer::TransferProcess () const
{
return theTP;
}
void IGESControl_Writer::SetTransferProcess
(const Handle(Transfer_FinderProcess)& TP)
{
theTP = TP;
}
Standard_Boolean IGESControl_Writer::AddShape (const TopoDS_Shape& theShape)
{
if (theShape.IsNull()) return Standard_False;
// for progress indication
Handle(Message_ProgressIndicator) progress = theTP->GetProgress();
if ( ! progress.IsNull() ) {
Standard_Integer nbfaces=0;
for( TopExp_Explorer exp(theShape,TopAbs_FACE); exp.More(); exp.Next() )
nbfaces++;
progress->SetScale ( "Faces", 0, nbfaces, 1 );
}
XSAlgo::AlgoContainer()->PrepareForTransfer();
// modified by NIZHNY-EAP Tue Aug 29 11:16:54 2000 ___BEGIN___
Handle(Standard_Transient) info;
Standard_Real Tol = Interface_Static::RVal("write.precision.val");
Standard_Real maxTol = Interface_Static::RVal("read.maxprecision.val");
TopoDS_Shape Shape = XSAlgo::AlgoContainer()->ProcessShape( theShape, Tol, maxTol,
"write.iges.resource.name",
"write.iges.sequence", info );
// modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___
Handle(IGESData_IGESEntity) ent;
BRepToIGES_BREntity B0; B0.SetTransferProcess(theTP); B0.SetModel(themod);
BRepToIGESBRep_Entity B1; B1.SetTransferProcess(theTP); B1.SetModel(themod);
if (thecr) ent = B1.TransferShape(Shape);
else ent = B0.TransferShape(Shape);
// modified by NIZHNY-EAP Tue Aug 29 11:37:18 2000 ___BEGIN___
XSAlgo::AlgoContainer()->MergeTransferInfo(theTP, info);
// modified by NIZHNY-EAP Tue Aug 29 11:37:25 2000 ___END___
//22.10.98 gka BUC60080
Standard_Integer oldnb = themod->NbEntities();
Standard_Boolean aent = AddEntity (ent);
Standard_Integer newnb = themod->NbEntities();
Standard_Real oldtol = themod->GlobalSection().Resolution(), newtol;
Standard_Integer tolmod = Interface_Static::IVal("write.precision.mode");
if (tolmod == 2)
newtol = Interface_Static::RVal("write.precision.val");
else {
ShapeAnalysis_ShapeTolerance stu;
Standard_Real Tolv = stu.Tolerance (Shape, tolmod, TopAbs_VERTEX);
Standard_Real Tole = stu.Tolerance (Shape, tolmod, TopAbs_EDGE);
if (tolmod == 0 ) { //Average
Standard_Real Tol1 = (Tolv + Tole) / 2;
newtol = (oldtol * oldnb + Tol1 * (newnb - oldnb)) / newnb;
}
else if (tolmod < 0) {//Least
newtol = Min (Tolv, Tole);
if (oldnb > 0) newtol = Min (oldtol, newtol);
}
else { //Greatest
newtol = Max (Tolv, Tole);
if (oldnb > 0) newtol = Max (oldtol, newtol);
}
}
IGESData_GlobalSection gs = themod->GlobalSection();
gs.SetResolution (newtol / gs.UnitValue());//rln 28.12.98 CCI60005
//#34 22.10.98 rln BUC60081
Bnd_Box box;
BRepBndLib::Add (Shape, box);
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
box.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
gs.MaxMaxCoords (gp_XYZ (aXmax / gs.UnitValue(),
aYmax / gs.UnitValue(),
aZmax / gs.UnitValue()));
gs.MaxMaxCoords (gp_XYZ (aXmin / gs.UnitValue(),
aYmin / gs.UnitValue(),
aZmin / gs.UnitValue()));
themod->SetGlobalSection(gs);
return aent;
}
Standard_Boolean IGESControl_Writer::AddGeom (const Handle(Standard_Transient)& geom)
{
if (geom.IsNull() || !geom->IsKind (STANDARD_TYPE (Geom_Geometry)))
return Standard_False;
DeclareAndCast(Geom_Curve,Curve,geom);
DeclareAndCast(Geom_Surface,Surf,geom);
Handle(IGESData_IGESEntity) ent;
// On reconnait : Curve et Surface de Geom
// quid de Point; Geom2d ?
// GeomToIGES_GeomPoint GP;
GeomToIGES_GeomCurve GC; GC.SetModel(themod);
GeomToIGES_GeomSurface GS; GS.SetModel(themod);
//#34 22.10.98 rln BUC60081
IGESData_GlobalSection gs = themod->GlobalSection();
Bnd_Box box;
if (!Curve.IsNull()) {
ent = GC.TransferCurve(Curve,Curve->FirstParameter(),Curve->LastParameter());
BndLib_Add3dCurve::Add (GeomAdaptor_Curve (Curve), 0, box); }
else if (!Surf.IsNull()) {
Standard_Real U1,U2,V1,V2;
Surf->Bounds(U1,U2,V1,V2);
ent = GS.TransferSurface(Surf,U1,U2,V1,V2);
BndLib_AddSurface::Add (GeomAdaptor_Surface (Surf), 0, box);
}
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
box.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
gs.MaxMaxCoords (gp_XYZ (aXmax / gs.UnitValue(),
aYmax / gs.UnitValue(),
aZmax / gs.UnitValue()));
gs.MaxMaxCoords (gp_XYZ (aXmin / gs.UnitValue(),
aYmin / gs.UnitValue(),
aZmin / gs.UnitValue()));
themod->SetGlobalSection(gs);
return AddEntity (ent);
}
Standard_Boolean IGESControl_Writer::AddEntity (const Handle(IGESData_IGESEntity)& ent)
{
if (ent.IsNull()) return Standard_False;
themod->AddWithRefs(ent,IGESSelect_WorkLibrary::DefineProtocol());
thest = Standard_False;
return Standard_True;
}
void IGESControl_Writer::ComputeModel ()
{
if (thest) return;
thedit.ComputeStatus();
thedit.AutoCorrectModel();
thest = Standard_True;
}
Standard_Boolean IGESControl_Writer::Write
(Standard_OStream& S, const Standard_Boolean fnes)
{
if (!S) return Standard_False;
ComputeModel();
#ifdef DEBUG
cout<<" IGES Write : "<<themod->NbEntities()<<" ent.s"<< flush;
#endif
IGESData_IGESWriter IW (themod);
// ne pas oublier le mode fnes ... a transmettre a IW
IW.SendModel (IGESSelect_WorkLibrary::DefineProtocol());
#ifdef DEBUG
cout<<" ... ecriture ..."<<flush;
#endif
if (fnes) IW.WriteMode() = 10;
Standard_Boolean status = IW.Print(S);
#ifdef DEBUG
cout<<" ... fichier ecrit ..."<<endl;
#endif
return status;
}
Standard_Boolean IGESControl_Writer::Write
(const Standard_CString file, const Standard_Boolean fnes)
{
ofstream fout(file,ios::out);
if (!fout) return Standard_False;
#ifdef DEBUG
cout<<" Ecriture fichier ("<< (fnes ? "fnes" : "IGES") <<"): "<<file<<endl;
#endif
Standard_Boolean res = Write (fout,fnes);
errno = 0;
fout.close();
res = fout.good() && res && !errno;
return res;
}
void IGESControl_Writer::PrintStatsTransfer
(const Standard_Integer what, const Standard_Integer mode) const
{
XSControl_TransferWriter::PrintStatsProcess (theTP,what,mode);
}