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 <MoniTool_DataMapOfShapeTransient.hxx>
20 #include <StdFail_NotDone.hxx>
21 #include <StepShape_ClosedShell.hxx>
22 #include <StepShape_FacetedBrepAndBrepWithVoids.hxx>
23 #include <StepShape_HArray1OfOrientedClosedShell.hxx>
24 #include <StepShape_OrientedClosedShell.hxx>
25 #include <StepShape_TopologicalRepresentationItem.hxx>
26 #include <TCollection_HAsciiString.hxx>
27 #include <TColStd_SequenceOfTransient.hxx>
29 #include <TopoDS_Iterator.hxx>
30 #include <TopoDS_Shell.hxx>
31 #include <TopoDS_Solid.hxx>
32 #include <TopoDSToStep.hxx>
33 #include <TopoDSToStep_Builder.hxx>
34 #include <TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.hxx>
35 #include <TopoDSToStep_Tool.hxx>
36 #include <Transfer_FinderProcess.hxx>
37 #include <TransferBRep_ShapeMapper.hxx>
39 //=============================================================================
40 // Create a FacetedBrepAndBrepWithVoids of StepShape from a Solid of TopoDS
41 // containing more than one closed shell
42 //=============================================================================
43 TopoDSToStep_MakeFacetedBrepAndBrepWithVoids::
44 TopoDSToStep_MakeFacetedBrepAndBrepWithVoids(const TopoDS_Solid& aSolid,
45 const Handle(Transfer_FinderProcess)& FP)
47 done = Standard_False;
49 MoniTool_DataMapOfShapeTransient aMap;
50 TColStd_SequenceOfTransient S;
51 TopoDS_Shell aOutShell;
53 Handle(StepShape_TopologicalRepresentationItem) aItem;
54 Handle(StepShape_ClosedShell) aOuter, aCShell;
55 Handle(StepShape_OrientedClosedShell) aOCShell;
56 Handle(StepShape_HArray1OfOrientedClosedShell) aVoids;
58 aOutShell = BRepClass3d::OuterShell(aSolid);
60 TopoDSToStep_Builder StepB;
61 TopoDSToStep_Tool aTool;
63 if (!aOutShell.IsNull()) {
64 It.Initialize(aSolid);
65 for ( ; It.More(); It.Next() ) {
66 if (It.Value().ShapeType() == TopAbs_SHELL) {
67 TopoDS_Shell CurrentShell = TopoDS::Shell(It.Value());
68 if (It.Value().Closed()) {
70 aTool.Init(aMap, Standard_False);
71 StepB.Init(CurrentShell, aTool, FP);
72 TopoDSToStep::AddResult ( FP, aTool );
75 aCShell = Handle(StepShape_ClosedShell)::DownCast(StepB.Value());
76 if ( aOutShell.IsEqual(It.Value()) )
82 Handle(TransferBRep_ShapeMapper) errShape =
83 new TransferBRep_ShapeMapper(CurrentShell);
84 FP->AddWarning(errShape," Shell from Solid not mapped to FacetedBrepAndBrepWithVoids");
88 done = Standard_False;
89 Handle(TransferBRep_ShapeMapper) errShape =
90 new TransferBRep_ShapeMapper(CurrentShell);
91 FP->AddWarning(errShape," Shell from Solid not closed; not mapped to FacetedBrepAndBrepWithVoids");
96 Standard_Integer N = S.Length();
98 aVoids = new StepShape_HArray1OfOrientedClosedShell(1,N);
99 Handle(TCollection_HAsciiString) aName =
100 new TCollection_HAsciiString("");
101 for ( Standard_Integer i=1; i<=N; i++ ) {
102 aOCShell = new StepShape_OrientedClosedShell();
103 aOCShell->Init(aName, Handle(StepShape_ClosedShell)::DownCast(S.Value(i)),
105 aVoids->SetValue(i, aOCShell);
107 theFacetedBrepAndBrepWithVoids =
108 new StepShape_FacetedBrepAndBrepWithVoids();
109 theFacetedBrepAndBrepWithVoids->Init(aName, aOuter, aVoids);
110 done = Standard_True;
113 done = Standard_False;
114 Handle(TransferBRep_ShapeMapper) errShape =
115 new TransferBRep_ShapeMapper(aSolid);
116 FP->AddWarning(errShape," Solid contains no Shell to be mapped to FacetedBrepAndBrepWithVoids");
120 //=============================================================================
121 // renvoi des valeurs
122 //=============================================================================
124 const Handle(StepShape_FacetedBrepAndBrepWithVoids) &
125 TopoDSToStep_MakeFacetedBrepAndBrepWithVoids::Value() const
127 StdFail_NotDone_Raise_if (!done, "TopoDSToStep_MakeFacetedBrepAndBrepWithVoids::Value() - no result");
128 return theFacetedBrepAndBrepWithVoids;