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_HArray1OfFace.hxx>
22 #include <StepShape_ManifoldSolidBrep.hxx>
23 #include <StepShape_OpenShell.hxx>
24 #include <TCollection_HAsciiString.hxx>
25 #include <TopoDS_Shell.hxx>
26 #include <TopoDS_Solid.hxx>
27 #include <TopoDSToStep.hxx>
28 #include <TopoDSToStep_Builder.hxx>
29 #include <TopoDSToStep_MakeManifoldSolidBrep.hxx>
30 #include <TopoDSToStep_Tool.hxx>
31 #include <Transfer_FinderProcess.hxx>
32 #include <TransferBRep_ShapeMapper.hxx>
34 static Handle(StepShape_ManifoldSolidBrep) MakeManifoldSolidBrep (const TopoDS_Shell& aShell,
35 const Handle(Transfer_FinderProcess)& FP)
37 Handle(StepShape_ManifoldSolidBrep) theManifoldSolidBrep;
39 MoniTool_DataMapOfShapeTransient aMap;
40 TopoDSToStep_Tool aTool(aMap, Standard_False);
42 TopoDSToStep_Builder StepB(aShell, aTool, FP);
44 TopoDSToStep::AddResult(FP, aTool);
47 Handle(StepShape_ClosedShell) aCShell = Handle(StepShape_ClosedShell)::DownCast(StepB.Value());
48 // si OPEN on le force a CLOSED mais que c est une honte !
49 if (aCShell.IsNull()) {
50 Handle(StepShape_OpenShell) aOShell = Handle(StepShape_OpenShell)::DownCast(StepB.Value());
51 if (aOShell.IsNull()) return theManifoldSolidBrep;
53 aCShell = new StepShape_ClosedShell;
54 aCShell->Init(aOShell->Name(),aOShell->CfsFaces());
57 theManifoldSolidBrep = new StepShape_ManifoldSolidBrep();
58 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
59 theManifoldSolidBrep->Init(aName, aCShell);
62 return theManifoldSolidBrep;
65 //=============================================================================
66 // Create a ManifoldSolidBrep of StepShape from a Shell of TopoDS
67 //=============================================================================
69 TopoDSToStep_MakeManifoldSolidBrep::
70 TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Shell& aShell,
71 const Handle(Transfer_FinderProcess)& FP)
73 theManifoldSolidBrep = MakeManifoldSolidBrep(aShell, FP);
74 done = !theManifoldSolidBrep.IsNull();
76 Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aShell);
77 FP->AddWarning(errShape, " Closed Shell not mapped to ManifoldSolidBrep");
81 //=============================================================================
82 // Create a ManifoldSolidBrep of StepShape from a Solid of TopoDS containing
83 // only one closed shell
84 //=============================================================================
86 TopoDSToStep_MakeManifoldSolidBrep::
87 TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Solid& aSolid,
88 const Handle(Transfer_FinderProcess)& FP)
90 TopoDS_Shell aOuterShell = BRepClass3d::OuterShell(aSolid);
91 if (!aOuterShell.IsNull()) {
93 theManifoldSolidBrep = MakeManifoldSolidBrep(aOuterShell, FP);
94 done = !theManifoldSolidBrep.IsNull();
96 Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aOuterShell);
97 FP->AddWarning(errShape, " Outer Shell of Solid not mapped to ManifoldSolidBrep");
101 Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aOuterShell);
102 FP->AddWarning(errShape, " Outer Shell is null; not mapped to ManifoldSolidBrep ");
103 done = Standard_False;
107 //=============================================================================
108 // renvoi des valeurs
109 //=============================================================================
111 const Handle(StepShape_ManifoldSolidBrep) &
112 TopoDSToStep_MakeManifoldSolidBrep::Value() const
114 StdFail_NotDone_Raise_if (!done, "TopoDSToStep_MakeManifoldSolidBrep::Value() - no result");
115 return theManifoldSolidBrep;