1 // Created on: 1993-07-23
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TopoDSToStep_MakeFacetedBrep.ixx>
18 #include <StdFail_NotDone.hxx>
19 #include <StepShape_TopologicalRepresentationItem.hxx>
20 #include <TopoDSToStep.hxx>
21 #include <TopoDSToStep_Builder.hxx>
22 #include <TopoDSToStep_Tool.hxx>
23 #include <TopoDS_Iterator.hxx>
24 #include <BRepClass3d.hxx>
25 #include <Transfer_FinderProcess.hxx>
26 #include <TransferBRep_ShapeMapper.hxx>
27 #include <TCollection_HAsciiString.hxx>
28 #include <StepShape_ClosedShell.hxx>
30 //=============================================================================
31 // Create a FacetedBrep of StepShape from a Shell of TopoDS
32 //=============================================================================
34 TopoDSToStep_MakeFacetedBrep::
35 TopoDSToStep_MakeFacetedBrep(const TopoDS_Shell& aShell,
36 const Handle(Transfer_FinderProcess)& FP)
38 done = Standard_False;
39 if (aShell.Closed()) {
40 Handle(StepShape_TopologicalRepresentationItem) aItem;
41 MoniTool_DataMapOfShapeTransient aMap;
43 TopoDSToStep_Tool aTool(aMap, Standard_True);
44 TopoDSToStep_Builder StepB(aShell, aTool, FP);
45 TopoDSToStep::AddResult ( FP, aTool );
48 aItem = StepB.Value();
49 Handle(StepShape_ClosedShell) aCShell;
50 aCShell = Handle(StepShape_ClosedShell)::DownCast(aItem);
51 theFacetedBrep = new StepShape_FacetedBrep();
52 Handle(TCollection_HAsciiString) aName =
53 new TCollection_HAsciiString("");
54 theFacetedBrep->Init(aName, aCShell);
58 done = Standard_False;
59 Handle(TransferBRep_ShapeMapper) errShape =
60 new TransferBRep_ShapeMapper(aShell);
61 FP->AddWarning(errShape," Closed Shell not mapped to FacetedBrep");
65 done = Standard_False;
66 Handle(TransferBRep_ShapeMapper) errShape =
67 new TransferBRep_ShapeMapper(aShell);
68 FP->AddWarning(errShape," Shell not closed; not mapped to FacetedBrep");
72 //=============================================================================
73 // Create a FacetedBrep of StepShape from a Solid of TopoDS containing
74 // only one closed shell
75 //=============================================================================
77 TopoDSToStep_MakeFacetedBrep::
78 TopoDSToStep_MakeFacetedBrep(const TopoDS_Solid& aSolid,
79 const Handle(Transfer_FinderProcess)& FP)
81 done = Standard_False;
83 // Looking for the Outer Shell
84 TopoDS_Shell aOuterShell = BRepClass3d::OuterShell(aSolid);
86 if (!aOuterShell.IsNull()) {
87 if (aOuterShell.Closed()) {
88 Handle(StepShape_TopologicalRepresentationItem) aItem;
89 MoniTool_DataMapOfShapeTransient aMap;
91 TopoDSToStep_Tool aTool(aMap, Standard_True);
92 TopoDSToStep_Builder StepB(aOuterShell, aTool, FP);
93 TopoDSToStep::AddResult ( FP, aTool );
96 aItem = StepB.Value();
97 Handle(StepShape_ClosedShell) aCShell;
98 aCShell = Handle(StepShape_ClosedShell)::DownCast(aItem);
99 theFacetedBrep = new StepShape_FacetedBrep();
100 Handle(TCollection_HAsciiString) aName =
101 new TCollection_HAsciiString("");
102 theFacetedBrep->Init(aName, aCShell);
103 done = Standard_True;
106 done = Standard_False;
107 Handle(TransferBRep_ShapeMapper) errShape =
108 new TransferBRep_ShapeMapper(aOuterShell);
109 FP->AddWarning(errShape," Closed Outer Shell from Solid not mapped to FacetedBrep");
113 done = Standard_False;
114 Handle(TransferBRep_ShapeMapper) errShape =
115 new TransferBRep_ShapeMapper(aOuterShell);
116 FP->AddWarning(errShape," Shell not closed; not mapped to FacetedBrep");
120 done = Standard_False;
121 Handle(TransferBRep_ShapeMapper) errShape =
122 new TransferBRep_ShapeMapper(aOuterShell);
123 FP->AddWarning(errShape," Solid contains no Outer Shell to be mapped to FacetedBrep");
127 //=============================================================================
128 // renvoi des valeurs
129 //=============================================================================
131 const Handle(StepShape_FacetedBrep) &
132 TopoDSToStep_MakeFacetedBrep::Value() const
134 StdFail_NotDone_Raise_if(!done,"");
135 return theFacetedBrep;