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.
18 #include <BRepClass3d.hxx>
19 #include <StdFail_NotDone.hxx>
20 #include <StepShape_ClosedShell.hxx>
21 #include <StepShape_FacetedBrep.hxx>
22 #include <StepShape_TopologicalRepresentationItem.hxx>
23 #include <TCollection_HAsciiString.hxx>
24 #include <TopoDS_Shell.hxx>
25 #include <TopoDS_Solid.hxx>
26 #include <TopoDSToStep.hxx>
27 #include <TopoDSToStep_Builder.hxx>
28 #include <TopoDSToStep_MakeFacetedBrep.hxx>
29 #include <TopoDSToStep_Tool.hxx>
30 #include <Transfer_FinderProcess.hxx>
31 #include <TransferBRep_ShapeMapper.hxx>
33 //=============================================================================
34 // Create a FacetedBrep of StepShape from a Shell of TopoDS
35 //=============================================================================
36 TopoDSToStep_MakeFacetedBrep::
37 TopoDSToStep_MakeFacetedBrep(const TopoDS_Shell& aShell,
38 const Handle(Transfer_FinderProcess)& FP)
40 done = Standard_False;
41 if (aShell.Closed()) {
42 Handle(StepShape_TopologicalRepresentationItem) aItem;
43 MoniTool_DataMapOfShapeTransient aMap;
45 TopoDSToStep_Tool aTool(aMap, Standard_True);
46 TopoDSToStep_Builder StepB(aShell, aTool, FP);
47 TopoDSToStep::AddResult ( FP, aTool );
50 aItem = StepB.Value();
51 Handle(StepShape_ClosedShell) aCShell;
52 aCShell = Handle(StepShape_ClosedShell)::DownCast(aItem);
53 theFacetedBrep = new StepShape_FacetedBrep();
54 Handle(TCollection_HAsciiString) aName =
55 new TCollection_HAsciiString("");
56 theFacetedBrep->Init(aName, aCShell);
60 done = Standard_False;
61 Handle(TransferBRep_ShapeMapper) errShape =
62 new TransferBRep_ShapeMapper(aShell);
63 FP->AddWarning(errShape," Closed Shell not mapped to FacetedBrep");
67 done = Standard_False;
68 Handle(TransferBRep_ShapeMapper) errShape =
69 new TransferBRep_ShapeMapper(aShell);
70 FP->AddWarning(errShape," Shell not closed; not mapped to FacetedBrep");
74 //=============================================================================
75 // Create a FacetedBrep of StepShape from a Solid of TopoDS containing
76 // only one closed shell
77 //=============================================================================
79 TopoDSToStep_MakeFacetedBrep::
80 TopoDSToStep_MakeFacetedBrep(const TopoDS_Solid& aSolid,
81 const Handle(Transfer_FinderProcess)& FP)
83 done = Standard_False;
85 // Looking for the Outer Shell
86 TopoDS_Shell aOuterShell = BRepClass3d::OuterShell(aSolid);
88 if (!aOuterShell.IsNull()) {
89 if (aOuterShell.Closed()) {
90 Handle(StepShape_TopologicalRepresentationItem) aItem;
91 MoniTool_DataMapOfShapeTransient aMap;
93 TopoDSToStep_Tool aTool(aMap, Standard_True);
94 TopoDSToStep_Builder StepB(aOuterShell, aTool, FP);
95 TopoDSToStep::AddResult ( FP, aTool );
98 aItem = StepB.Value();
99 Handle(StepShape_ClosedShell) aCShell;
100 aCShell = Handle(StepShape_ClosedShell)::DownCast(aItem);
101 theFacetedBrep = new StepShape_FacetedBrep();
102 Handle(TCollection_HAsciiString) aName =
103 new TCollection_HAsciiString("");
104 theFacetedBrep->Init(aName, aCShell);
105 done = Standard_True;
108 done = Standard_False;
109 Handle(TransferBRep_ShapeMapper) errShape =
110 new TransferBRep_ShapeMapper(aOuterShell);
111 FP->AddWarning(errShape," Closed Outer Shell from Solid not mapped to FacetedBrep");
115 done = Standard_False;
116 Handle(TransferBRep_ShapeMapper) errShape =
117 new TransferBRep_ShapeMapper(aOuterShell);
118 FP->AddWarning(errShape," Shell not closed; not mapped to FacetedBrep");
122 done = Standard_False;
123 Handle(TransferBRep_ShapeMapper) errShape =
124 new TransferBRep_ShapeMapper(aOuterShell);
125 FP->AddWarning(errShape," Solid contains no Outer Shell to be mapped to FacetedBrep");
129 //=============================================================================
130 // renvoi des valeurs
131 //=============================================================================
133 const Handle(StepShape_FacetedBrep) &
134 TopoDSToStep_MakeFacetedBrep::Value() const
136 StdFail_NotDone_Raise_if (!done, "TopoDSToStep_MakeFacetedBrep::Value() - no result");
137 return theFacetedBrep;