Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:16:59

0001 // Created on: 2000-08-22
0002 // Created by: Andrey BETENEV
0003 // Copyright (c) 2000-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _ShapeProcess_ShapeContext_HeaderFile
0017 #define _ShapeProcess_ShapeContext_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_Type.hxx>
0021 
0022 #include <TopoDS_Shape.hxx>
0023 #include <TopTools_ShapeMapHasher.hxx>
0024 #include <NCollection_DataMap.hxx>
0025 #include <TopAbs_ShapeEnum.hxx>
0026 #include <ShapeProcess_Context.hxx>
0027 #include <Message_Gravity.hxx>
0028 #include <GeomAbs_Shape.hxx>
0029 class ShapeExtend_MsgRegistrator;
0030 class ShapeBuild_ReShape;
0031 class BRepTools_Modifier;
0032 class Message_Msg;
0033 
0034 //! Extends Context to handle shapes
0035 //! Contains map of shape-shape, and messages
0036 //! attached to shapes
0037 class ShapeProcess_ShapeContext : public ShapeProcess_Context
0038 {
0039 
0040 public:
0041   Standard_EXPORT ShapeProcess_ShapeContext(const char* const file, const char* const seq = "");
0042 
0043   //! Initializes a tool by resource file and shape
0044   //! to be processed
0045   Standard_EXPORT ShapeProcess_ShapeContext(const TopoDS_Shape& S,
0046                                             const char* const   file,
0047                                             const char* const   seq = "");
0048 
0049   //! Initializes tool by a new shape and clears all results
0050   Standard_EXPORT void Init(const TopoDS_Shape& S);
0051 
0052   //! Returns shape being processed
0053   Standard_EXPORT const TopoDS_Shape& Shape() const;
0054 
0055   //! Returns current result
0056   Standard_EXPORT const TopoDS_Shape& Result() const;
0057 
0058   //! Returns map of replacements shape -> shape
0059   //! This map is not recursive
0060   Standard_EXPORT const NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher>&
0061                         Map() const;
0062 
0063   Standard_EXPORT const occ::handle<ShapeExtend_MsgRegistrator>& Messages() const;
0064 
0065   //! Returns messages recorded during shape processing
0066   //! It can be nullified before processing in order to
0067   //! avoid recording messages
0068   Standard_EXPORT occ::handle<ShapeExtend_MsgRegistrator>& Messages();
0069 
0070   Standard_EXPORT void SetDetalisation(const TopAbs_ShapeEnum level);
0071 
0072   //! Set and get value for detalisation level
0073   //! Only shapes of types from TopoDS_COMPOUND and until
0074   //! specified detalisation level will be recorded in maps
0075   //! To cancel mapping, use TopAbs_SHAPE
0076   //! To force full mapping, use TopAbs_VERTEX
0077   //! The default level is TopAbs_FACE
0078   Standard_EXPORT TopAbs_ShapeEnum GetDetalisation() const;
0079 
0080   //! Sets a new result shape
0081   //! NOTE: this method should be used very carefully
0082   //! to keep consistency of modifications
0083   //! It is recommended to use RecordModification() methods
0084   //! with explicit definition of mapping from current
0085   //! result to a new one
0086   Standard_EXPORT void SetResult(const TopoDS_Shape& S);
0087 
0088   Standard_EXPORT void RecordModification(
0089     const NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher>& repl,
0090     const occ::handle<ShapeExtend_MsgRegistrator>&                                  msg = nullptr);
0091 
0092   Standard_EXPORT void RecordModification(const occ::handle<ShapeBuild_ReShape>&         repl,
0093                                           const occ::handle<ShapeExtend_MsgRegistrator>& msg);
0094 
0095   Standard_EXPORT void RecordModification(const occ::handle<ShapeBuild_ReShape>& repl);
0096 
0097   //! Records modifications and resets result accordingly
0098   //! NOTE: modification of resulting shape should be explicitly
0099   //! defined in the maps along with modifications of subshapes
0100   //!
0101   //! In the last function, sh is the shape on which Modifier
0102   //! was run. It can be different from the whole shape,
0103   //! but in that case result as a whole should be reset later
0104   //! either by call to SetResult(), or by another call to
0105   //! RecordModification() which contains mapping of current
0106   //! result to a new one explicitly
0107   Standard_EXPORT void RecordModification(
0108     const TopoDS_Shape&                            sh,
0109     const BRepTools_Modifier&                      repl,
0110     const occ::handle<ShapeExtend_MsgRegistrator>& msg = nullptr);
0111 
0112   //! Record a message for shape S
0113   //! Shape S should be one of subshapes of original shape
0114   //! (or whole one), but not one of intermediate shapes
0115   //! Records only if Message() is not Null
0116   Standard_EXPORT void AddMessage(const TopoDS_Shape&   S,
0117                                   const Message_Msg&    msg,
0118                                   const Message_Gravity gravity = Message_Warning);
0119 
0120   //! Get value of parameter as being of the type GeomAbs_Shape
0121   //! Returns False if parameter is not defined or has a wrong type
0122   Standard_EXPORT bool GetContinuity(const char* const param, GeomAbs_Shape& val) const;
0123 
0124   //! Get value of parameter as being of the type GeomAbs_Shape
0125   //! If parameter is not defined or does not have expected
0126   //! type, returns default value as specified
0127   Standard_EXPORT GeomAbs_Shape ContinuityVal(const char* const   param,
0128                                               const GeomAbs_Shape def) const;
0129 
0130   //! Prints statistics on Shape Processing onto the current Messenger.
0131   Standard_EXPORT void PrintStatistics() const;
0132 
0133   //! Set NonManifold flag
0134   void SetNonManifold(bool theNonManifold) { myNonManifold = theNonManifold; }
0135 
0136   //! Get NonManifold flag
0137   bool IsNonManifold() { return myNonManifold; }
0138 
0139   DEFINE_STANDARD_RTTIEXT(ShapeProcess_ShapeContext, ShapeProcess_Context)
0140 
0141 private:
0142   TopoDS_Shape                                                             myShape;
0143   TopoDS_Shape                                                             myResult;
0144   NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher> myMap;
0145   occ::handle<ShapeExtend_MsgRegistrator>                                  myMsg;
0146   TopAbs_ShapeEnum                                                         myUntil;
0147   bool                                                                     myNonManifold;
0148 };
0149 
0150 #endif // _ShapeProcess_ShapeContext_HeaderFile