b311480e |
1 | // Created on: 1993-07-23 |
2 | // Created by: Martine LANGLOIS |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <BRepClass3d.hxx> |
7e785937 |
19 | #include <Message_ProgressScope.hxx> |
7fd59977 |
20 | #include <StdFail_NotDone.hxx> |
42cf5bc1 |
21 | #include <StepShape_ClosedShell.hxx> |
22 | #include <StepShape_HArray1OfFace.hxx> |
23 | #include <StepShape_ManifoldSolidBrep.hxx> |
24 | #include <StepShape_OpenShell.hxx> |
25 | #include <TCollection_HAsciiString.hxx> |
26 | #include <TopoDS_Shell.hxx> |
27 | #include <TopoDS_Solid.hxx> |
7fd59977 |
28 | #include <TopoDSToStep.hxx> |
29 | #include <TopoDSToStep_Builder.hxx> |
42cf5bc1 |
30 | #include <TopoDSToStep_MakeManifoldSolidBrep.hxx> |
7fd59977 |
31 | #include <TopoDSToStep_Tool.hxx> |
7fd59977 |
32 | #include <Transfer_FinderProcess.hxx> |
33 | #include <TransferBRep_ShapeMapper.hxx> |
7fd59977 |
34 | |
35 | static Handle(StepShape_ManifoldSolidBrep) MakeManifoldSolidBrep (const TopoDS_Shell& aShell, |
7e785937 |
36 | const Handle(Transfer_FinderProcess)& FP, |
37 | const Message_ProgressRange& theProgress) |
7fd59977 |
38 | { |
39 | Handle(StepShape_ManifoldSolidBrep) theManifoldSolidBrep; |
40 | |
41 | MoniTool_DataMapOfShapeTransient aMap; |
42 | TopoDSToStep_Tool aTool(aMap, Standard_False); |
43 | |
7e785937 |
44 | TopoDSToStep_Builder StepB(aShell, aTool, FP, theProgress); |
45 | if (theProgress.UserBreak()) |
46 | return theManifoldSolidBrep; |
7fd59977 |
47 | |
48 | TopoDSToStep::AddResult(FP, aTool); |
49 | |
50 | if (StepB.IsDone()) { |
51 | Handle(StepShape_ClosedShell) aCShell = Handle(StepShape_ClosedShell)::DownCast(StepB.Value()); |
52 | // si OPEN on le force a CLOSED mais que c est une honte ! |
53 | if (aCShell.IsNull()) { |
54 | Handle(StepShape_OpenShell) aOShell = Handle(StepShape_OpenShell)::DownCast(StepB.Value()); |
55 | if (aOShell.IsNull()) return theManifoldSolidBrep; |
56 | else { |
57 | aCShell = new StepShape_ClosedShell; |
58 | aCShell->Init(aOShell->Name(),aOShell->CfsFaces()); |
59 | } |
60 | } |
61 | theManifoldSolidBrep = new StepShape_ManifoldSolidBrep(); |
62 | Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(""); |
63 | theManifoldSolidBrep->Init(aName, aCShell); |
64 | } |
65 | |
66 | return theManifoldSolidBrep; |
67 | } |
68 | |
69 | //============================================================================= |
70 | // Create a ManifoldSolidBrep of StepShape from a Shell of TopoDS |
71 | //============================================================================= |
72 | |
73 | TopoDSToStep_MakeManifoldSolidBrep:: |
74 | TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Shell& aShell, |
7e785937 |
75 | const Handle(Transfer_FinderProcess)& FP, |
76 | const Message_ProgressRange& theProgress) |
7fd59977 |
77 | { |
7e785937 |
78 | theManifoldSolidBrep = MakeManifoldSolidBrep(aShell, FP, theProgress); |
7fd59977 |
79 | done = !theManifoldSolidBrep.IsNull(); |
7e785937 |
80 | if (!done && !theProgress.UserBreak()) { |
7fd59977 |
81 | Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aShell); |
82 | FP->AddWarning(errShape, " Closed Shell not mapped to ManifoldSolidBrep"); |
83 | } |
84 | } |
85 | |
86 | //============================================================================= |
87 | // Create a ManifoldSolidBrep of StepShape from a Solid of TopoDS containing |
88 | // only one closed shell |
89 | //============================================================================= |
90 | |
91 | TopoDSToStep_MakeManifoldSolidBrep:: |
92 | TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Solid& aSolid, |
7e785937 |
93 | const Handle(Transfer_FinderProcess)& FP, |
94 | const Message_ProgressRange& theProgress) |
7fd59977 |
95 | { |
2f0109b7 |
96 | TopoDS_Shell aOuterShell = BRepClass3d::OuterShell(aSolid); |
7fd59977 |
97 | if (!aOuterShell.IsNull()) { |
98 | |
7e785937 |
99 | theManifoldSolidBrep = MakeManifoldSolidBrep(aOuterShell, FP, theProgress); |
7fd59977 |
100 | done = !theManifoldSolidBrep.IsNull(); |
7e785937 |
101 | if (!done && !theProgress.UserBreak()) { |
7fd59977 |
102 | Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aOuterShell); |
103 | FP->AddWarning(errShape, " Outer Shell of Solid not mapped to ManifoldSolidBrep"); |
104 | } |
105 | } |
106 | else { |
107 | Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aOuterShell); |
108 | FP->AddWarning(errShape, " Outer Shell is null; not mapped to ManifoldSolidBrep "); |
109 | done = Standard_False; |
110 | } |
111 | } |
112 | |
113 | //============================================================================= |
114 | // renvoi des valeurs |
115 | //============================================================================= |
116 | |
117 | const Handle(StepShape_ManifoldSolidBrep) & |
118 | TopoDSToStep_MakeManifoldSolidBrep::Value() const |
119 | { |
2d2b3d53 |
120 | StdFail_NotDone_Raise_if (!done, "TopoDSToStep_MakeManifoldSolidBrep::Value() - no result"); |
7fd59977 |
121 | return theManifoldSolidBrep; |
122 | } |