Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:15:48

0001 // Created on: 1998-06-03
0002 // Created by: data exchange team
0003 // Copyright (c) 1998-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _ShapeBuild_ReShape_HeaderFile
0018 #define _ShapeBuild_ReShape_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <BRepTools_ReShape.hxx>
0024 #include <NCollection_Map.hxx>
0025 #include <TopAbs_ShapeEnum.hxx>
0026 #include <TopoDS_TShape.hxx>
0027 #include <Standard_Integer.hxx>
0028 #include <ShapeExtend_Status.hxx>
0029 class TopoDS_Shape;
0030 
0031 // resolve name collisions with X11 headers
0032 #ifdef Status
0033   #undef Status
0034 #endif
0035 
0036 //! Rebuilds a Shape by making pre-defined substitutions on some
0037 //! of its components
0038 //!
0039 //! In a first phase, it records requests to replace or remove
0040 //! some individual shapes
0041 //! For each shape, the last given request is recorded
0042 //! Requests may be applied "Oriented" (i.e. only to an item with
0043 //! the SAME orientation) or not (the orientation of replacing
0044 //! shape is respectful of that of the original one)
0045 //!
0046 //! Then, these requests may be applied to any shape which may
0047 //! contain one or more of these individual shapes
0048 class ShapeBuild_ReShape : public BRepTools_ReShape
0049 {
0050 
0051 public:
0052   //! Returns an empty Reshape
0053   Standard_EXPORT ShapeBuild_ReShape();
0054 
0055   //! Applies the substitutions requests to a shape
0056   //!
0057   //! <until> gives the level of type until which requests are taken
0058   //! into account. For subshapes of the type <until> no rebuild
0059   //! and further exploring are done.
0060   //! ACTUALLY, NOT IMPLEMENTED BELOW TopAbs_FACE
0061   //!
0062   //! <buildmode> says how to do on a SOLID,SHELL ... if one of its
0063   //! sub-shapes has been changed:
0064   //! 0: at least one Replace or Remove -> COMPOUND, else as such
0065   //! 1: at least one Remove (Replace are ignored) -> COMPOUND
0066   //! 2: Replace and Remove are both ignored
0067   //! If Replace/Remove are ignored or absent, the result as same
0068   //! type as the starting shape
0069   Standard_EXPORT virtual TopoDS_Shape Apply(const TopoDS_Shape&    shape,
0070                                              const TopAbs_ShapeEnum until,
0071                                              const int              buildmode);
0072 
0073   //! Applies the substitutions requests to a shape.
0074   //!
0075   //! <until> gives the level of type until which requests are taken
0076   //! into account. For subshapes of the type <until> no rebuild
0077   //! and further exploring are done.
0078   //!
0079   //! NOTE: each subshape can be replaced by shape of the same type
0080   //! or by shape containing only shapes of that type (for
0081   //! example, TopoDS_Edge can be replaced by TopoDS_Edge,
0082   //! TopoDS_Wire or TopoDS_Compound containing TopoDS_Edges).
0083   //! If incompatible shape type is encountered, it is ignored
0084   //! and flag FAIL1 is set in Status.
0085   Standard_EXPORT TopoDS_Shape Apply(const TopoDS_Shape&    shape,
0086                                      const TopAbs_ShapeEnum until = TopAbs_SHAPE) override;
0087 
0088   //! Returns a complete substitution status for a shape
0089   //! 0  : not recorded,   <newsh> = original <shape>
0090   //! < 0: to be removed,  <newsh> is NULL
0091   //! > 0: to be replaced, <newsh> is a new item
0092   //! If <last> is False, returns status and new shape recorded in
0093   //! the map directly for the shape, if True and status > 0 then
0094   //! recursively searches for the last status and new shape.
0095   Standard_EXPORT int Status(const TopoDS_Shape& shape,
0096                              TopoDS_Shape&       newsh,
0097                              const bool          last = false) override;
0098 
0099   //! Queries the status of last call to Apply(shape,enum)
0100   //! OK   : no (sub)shapes replaced or removed
0101   //! DONE1: source (starting) shape replaced
0102   //! DONE2: source (starting) shape removed
0103   //! DONE3: some subshapes replaced
0104   //! DONE4: some subshapes removed
0105   //! FAIL1: some replacements not done because of bad type of subshape
0106   Standard_EXPORT virtual bool Status(const ShapeExtend_Status status) const;
0107 
0108   DEFINE_STANDARD_RTTIEXT(ShapeBuild_ReShape, BRepTools_ReShape)
0109 
0110 private:
0111   //! Recursive worker for Apply with a DFS in-flight set keyed by TShape handle.
0112   //! Prevents unbounded descent when a replacement is a compound that transitively
0113   //! contains the original shape as a sub-shape (cyclic containment, distinct from
0114   //! cycles in the replacement map itself).
0115   TopoDS_Shape applyImpl(const TopoDS_Shape&                          theShape,
0116                          const TopAbs_ShapeEnum                       theUntil,
0117                          NCollection_Map<occ::handle<TopoDS_TShape>>& theInFlight);
0118 };
0119 
0120 #endif // _ShapeBuild_ReShape_HeaderFile