42cf5bc1 |
1 | // Created on: 1998-06-03 |
2 | // Created by: data exchange team |
3 | // Copyright (c) 1998-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _ShapeExtend_Explorer_HeaderFile |
18 | #define _ShapeExtend_Explorer_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <TopTools_HSequenceOfShape.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | #include <TopTools_ListOfShape.hxx> |
27 | #include <TopAbs_ShapeEnum.hxx> |
28 | class Standard_TypeMismatch; |
29 | class TopoDS_Shape; |
30 | |
31 | |
32 | //! This class is intended to |
33 | //! explore shapes and convert different representations |
34 | //! (list, sequence, compound) of complex shapes. It provides tools for: |
35 | //! - obtaining type of the shapes in context of TopoDS_Compound, |
36 | //! - exploring shapes in context of TopoDS_Compound, |
37 | //! - converting different representations of shapes (list, sequence, compound). |
38 | class ShapeExtend_Explorer |
39 | { |
40 | public: |
41 | |
42 | DEFINE_STANDARD_ALLOC |
43 | |
44 | |
45 | //! Creates an object Explorer |
46 | Standard_EXPORT ShapeExtend_Explorer(); |
47 | |
48 | //! Converts a sequence of Shapes to a Compound |
49 | Standard_EXPORT TopoDS_Shape CompoundFromSeq (const Handle(TopTools_HSequenceOfShape)& seqval) const; |
50 | |
51 | //! Converts a Compound to a list of Shapes |
52 | //! if <comp> is not a compound, the list contains only <comp> |
53 | //! if <comp> is Null, the list is empty |
54 | //! if <comp> is a Compound, its sub-shapes are put into the list |
55 | //! then if <expcomp> is True, if a sub-shape is a Compound, it |
56 | //! is not put to the list but its sub-shapes are (recursive) |
57 | Standard_EXPORT Handle(TopTools_HSequenceOfShape) SeqFromCompound (const TopoDS_Shape& comp, const Standard_Boolean expcomp) const; |
58 | |
59 | //! Converts a Sequence of Shapes to a List of Shapes |
60 | //! <clear> if True (D), commands the list to start from scratch |
61 | //! else, the list is cumulated |
62 | Standard_EXPORT void ListFromSeq (const Handle(TopTools_HSequenceOfShape)& seqval, TopTools_ListOfShape& lisval, const Standard_Boolean clear = Standard_True) const; |
63 | |
64 | //! Converts a List of Shapes to a Sequence of Shapes |
65 | Standard_EXPORT Handle(TopTools_HSequenceOfShape) SeqFromList (const TopTools_ListOfShape& lisval) const; |
66 | |
67 | //! Returns the type of a Shape: true type if <compound> is False |
68 | //! If <compound> is True and <shape> is a Compound, iterates on |
69 | //! its items. If all are of the same type, returns this type. |
70 | //! Else, returns COMPOUND. If it is empty, returns SHAPE |
71 | //! For a Null Shape, returns SHAPE |
72 | Standard_EXPORT TopAbs_ShapeEnum ShapeType (const TopoDS_Shape& shape, const Standard_Boolean compound) const; |
73 | |
74 | //! Builds a COMPOUND from the given shape. |
75 | //! It explores the shape level by level, according to the |
76 | //! <explore> argument. If <explore> is False, only COMPOUND |
77 | //! items are explored, else all items are. |
78 | //! The following shapes are added to resulting compound: |
79 | //! - shapes which comply to <type> |
80 | //! - if <type> is WIRE, considers also free edges (and makes wires) |
81 | //! - if <type> is SHELL, considers also free faces (and makes shells) |
82 | //! If <compound> is True, gathers items in compounds which |
83 | //! correspond to starting COMPOUND,SOLID or SHELL containers, or |
84 | //! items directly contained in a Compound |
85 | Standard_EXPORT TopoDS_Shape SortedCompound (const TopoDS_Shape& shape, const TopAbs_ShapeEnum type, const Standard_Boolean explore, const Standard_Boolean compound) const; |
86 | |
87 | //! Dispatches starting list of shapes according to their type, |
88 | //! to the appropriate resulting lists |
89 | //! For each of these lists, if it is null, it is firstly created |
90 | //! else, new items are appended to the already existing ones |
91 | Standard_EXPORT void DispatchList (const Handle(TopTools_HSequenceOfShape)& list, Handle(TopTools_HSequenceOfShape)& vertices, Handle(TopTools_HSequenceOfShape)& edges, Handle(TopTools_HSequenceOfShape)& wires, Handle(TopTools_HSequenceOfShape)& faces, Handle(TopTools_HSequenceOfShape)& shells, Handle(TopTools_HSequenceOfShape)& solids, Handle(TopTools_HSequenceOfShape)& compsols, Handle(TopTools_HSequenceOfShape)& compounds) const; |
92 | |
93 | |
94 | |
95 | |
96 | protected: |
97 | |
98 | |
99 | |
100 | |
101 | |
102 | private: |
103 | |
104 | |
105 | |
106 | |
107 | |
108 | }; |
109 | |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | |
116 | #endif // _ShapeExtend_Explorer_HeaderFile |