1 // Created on: 1994-06-24
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <TopoDSToStep_MakeShellBasedSurfaceModel.ixx>
23 #include <TopoDSToStep.hxx>
24 #include <TopoDSToStep_Builder.hxx>
25 #include <TopoDSToStep_Tool.hxx>
26 #include <MoniTool_DataMapOfShapeTransient.hxx>
27 #include <StepShape_Shell.hxx>
28 #include <StepShape_OpenShell.hxx>
29 #include <StepShape_ClosedShell.hxx>
30 #include <StepShape_TopologicalRepresentationItem.hxx>
31 #include <StepShape_ConnectedFaceSet.hxx>
32 #include <StepShape_OpenShell.hxx>
33 #include <StepShape_ClosedShell.hxx>
34 #include <StepShape_FaceSurface.hxx>
35 #include <StepShape_HArray1OfShell.hxx>
36 #include <StepShape_HArray1OfFace.hxx>
39 #include <TopoDS_Iterator.hxx>
41 #include <TColStd_SequenceOfTransient.hxx>
42 #include <StdFail_NotDone.hxx>
43 #include <Transfer_FinderProcess.hxx>
44 #include <TransferBRep_ShapeMapper.hxx>
45 #include <TCollection_HAsciiString.hxx>
47 //=============================================================================
48 // Create a ShellBasedSurfaceModel of StepShape from a Face of TopoDS
49 //=============================================================================
51 TopoDSToStep_MakeShellBasedSurfaceModel::
52 TopoDSToStep_MakeShellBasedSurfaceModel(const TopoDS_Face& aFace,
53 const Handle(Transfer_FinderProcess)& FP)
55 done = Standard_False;
56 MoniTool_DataMapOfShapeTransient aMap;
58 TopoDSToStep_Tool aTool(aMap, Standard_False);
59 TopoDSToStep_Builder StepB(aFace, aTool, FP);
61 TopoDSToStep::AddResult ( FP, aTool );
64 Handle(StepShape_FaceSurface) aFS =
65 Handle(StepShape_FaceSurface)::DownCast(StepB.Value());
66 StepShape_Shell aShellSelect;
67 Handle(StepShape_OpenShell) aOpenShell
68 = new StepShape_OpenShell();
69 Handle(StepShape_HArray1OfFace) aCfsFaces =
70 new StepShape_HArray1OfFace(1,1);
71 aCfsFaces->SetValue(1,aFS);
72 Handle(TCollection_HAsciiString) aName =
73 new TCollection_HAsciiString("");
74 aOpenShell->Init(aName, aCfsFaces);
75 aShellSelect.SetValue(aOpenShell);
76 Handle(StepShape_HArray1OfShell) aSbsmFaces =
77 new StepShape_HArray1OfShell(1,1);
78 aSbsmFaces->SetValue(1, aShellSelect);
79 theShellBasedSurfaceModel = new StepShape_ShellBasedSurfaceModel();
80 theShellBasedSurfaceModel->Init(aName, aSbsmFaces);
84 done = Standard_False;
85 Handle(TransferBRep_ShapeMapper) errShape =
86 new TransferBRep_ShapeMapper(aFace);
87 FP->AddWarning(errShape, " Single Face not mapped to ShellBasedSurfaceModel");
91 //=============================================================================
92 // Create a ShellBasedSurfaceModel of StepShape from a Shell of TopoDS
93 //=============================================================================
95 TopoDSToStep_MakeShellBasedSurfaceModel::
96 TopoDSToStep_MakeShellBasedSurfaceModel(const TopoDS_Shell& aShell,
97 const Handle(Transfer_FinderProcess)& FP)
99 done = Standard_False;
100 StepShape_Shell aShellSelect;
101 Handle(StepShape_HArray1OfShell) aSbsmBoundary;
102 Handle(StepShape_OpenShell) aOpenShell;
103 Handle(StepShape_ClosedShell) aClosedShell;
104 MoniTool_DataMapOfShapeTransient aMap;
106 TopoDSToStep_Tool aTool(aMap, Standard_False);
107 TopoDSToStep_Builder StepB(aShell, aTool, FP);
108 //TopoDSToStep::AddResult ( FP, aTool );
110 if (StepB.IsDone()) {
111 aSbsmBoundary = new StepShape_HArray1OfShell(1,1);
112 if (aShell.Closed()) {
113 aClosedShell = Handle(StepShape_ClosedShell)::DownCast(StepB.Value());
114 aShellSelect.SetValue(aClosedShell);
117 aOpenShell = Handle(StepShape_OpenShell)::DownCast(StepB.Value());
118 aShellSelect.SetValue(aOpenShell);
120 aSbsmBoundary->SetValue(1,aShellSelect);
121 theShellBasedSurfaceModel = new StepShape_ShellBasedSurfaceModel();
122 Handle(TCollection_HAsciiString) aName =
123 new TCollection_HAsciiString("");
124 theShellBasedSurfaceModel->Init(aName, aSbsmBoundary);
127 TopoDSToStep::AddResult(FP,aShell,theShellBasedSurfaceModel);
128 done = Standard_True;
131 done = Standard_False;
132 Handle(TransferBRep_ShapeMapper) errShape =
133 new TransferBRep_ShapeMapper(aShell);
134 FP->AddWarning(errShape, " Shell not mapped to ShellBasedSurfaceModel");
137 TopoDSToStep::AddResult ( FP, aTool );
140 //=============================================================================
141 // Create a ShellBasedSurfaceModel of StepShape from a Solid of TopoDS
142 //=============================================================================
144 TopoDSToStep_MakeShellBasedSurfaceModel::
145 TopoDSToStep_MakeShellBasedSurfaceModel(const TopoDS_Solid& aSolid,
146 const Handle(Transfer_FinderProcess)& FP)
148 done = Standard_False;
149 StepShape_Shell aShellSelect;
150 Handle(StepShape_HArray1OfShell) aSbsmBoundary;
151 Handle(StepShape_OpenShell) aOpenShell;
152 Handle(StepShape_ClosedShell) aClosedShell;
155 MoniTool_DataMapOfShapeTransient aMap;
156 TColStd_SequenceOfTransient S;
158 It.Initialize(aSolid);
159 for (; It.More(); It.Next() ) {
160 if (It.Value().ShapeType() == TopAbs_SHELL) {
161 aShell = TopoDS::Shell(It.Value());
163 TopoDSToStep_Tool aTool(aMap, Standard_False);
164 TopoDSToStep_Builder StepB(aShell, aTool, FP);
165 TopoDSToStep::AddResult ( FP, aTool );
167 if (StepB.IsDone()) {
168 S.Append(StepB.Value());
171 Handle(TransferBRep_ShapeMapper) errShape =
172 new TransferBRep_ShapeMapper(aShell);
173 FP->AddWarning(errShape," Shell from Solid not mapped to ShellBasedSurfaceModel");
177 Standard_Integer N = S.Length();
179 aSbsmBoundary = new StepShape_HArray1OfShell(1,N);
180 for (Standard_Integer i=1; i<=N; i++) {
181 aOpenShell = Handle(StepShape_OpenShell)::DownCast(S.Value(i));
182 if (!aOpenShell.IsNull()) {
183 aShellSelect.SetValue(aOpenShell);
186 aClosedShell = Handle(StepShape_ClosedShell)::DownCast(S.Value(i));
187 aShellSelect.SetValue(aClosedShell);
189 aSbsmBoundary->SetValue(i,aShellSelect);
192 theShellBasedSurfaceModel = new StepShape_ShellBasedSurfaceModel();
193 Handle(TCollection_HAsciiString) aName =
194 new TCollection_HAsciiString("");
195 theShellBasedSurfaceModel->Init(aName,aSbsmBoundary);
196 done = Standard_True;
199 done = Standard_False;
200 Handle(TransferBRep_ShapeMapper) errShape =
201 new TransferBRep_ShapeMapper(aSolid);
202 FP->AddWarning(errShape," Solid contains no Shell to be mapped to ShellBasedSurfaceModel");
206 //=============================================================================
207 // renvoi des valeurs
208 //=============================================================================
210 const Handle(StepShape_ShellBasedSurfaceModel) &
211 TopoDSToStep_MakeShellBasedSurfaceModel::Value() const
213 StdFail_NotDone_Raise_if(!done,"");
214 return theShellBasedSurfaceModel;