Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:15:56

0001 // Created on: 2016-07-07
0002 // Copyright (c) 2016 OPEN CASCADE SAS
0003 // Created by: Oleg AGASHIN
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 _BRepMesh_BaseMeshAlgo_HeaderFile
0017 #define _BRepMesh_BaseMeshAlgo_HeaderFile
0018 
0019 #include <IMeshTools_MeshAlgo.hxx>
0020 #include <NCollection_Shared.hxx>
0021 #include <IMeshTools_Parameters.hxx>
0022 #include <BRepMesh_DegreeOfFreedom.hxx>
0023 #include <Poly_Triangulation.hxx>
0024 
0025 class BRepMesh_DataStructureOfDelaun;
0026 
0027 //! Class provides base functionality for algorithms building face triangulation.
0028 //! Performs initialization of BRepMesh_DataStructureOfDelaun and nodes map structures.
0029 class BRepMesh_BaseMeshAlgo : public IMeshTools_MeshAlgo
0030 {
0031 public:
0032   typedef NCollection_Shared<NCollection_DynamicArray<gp_Pnt>> VectorOfPnt;
0033 
0034   //! Constructor.
0035   Standard_EXPORT BRepMesh_BaseMeshAlgo();
0036 
0037   //! Destructor.
0038   Standard_EXPORT ~BRepMesh_BaseMeshAlgo() override;
0039 
0040   //! Performs processing of the given face.
0041   Standard_EXPORT void Perform(
0042     const IMeshData::IFaceHandle& theDFace,
0043     const IMeshTools_Parameters&  theParameters,
0044     const Message_ProgressRange&  theRange = Message_ProgressRange()) override;
0045 
0046   DEFINE_STANDARD_RTTIEXT(BRepMesh_BaseMeshAlgo, IMeshTools_MeshAlgo)
0047 
0048 protected:
0049   //! Gets discrete face.
0050   const IMeshData::IFaceHandle& getDFace() const { return myDFace; }
0051 
0052   //! Gets meshing parameters.
0053   const IMeshTools_Parameters& getParameters() const { return myParameters; }
0054 
0055   //! Gets common allocator.
0056   const occ::handle<NCollection_IncAllocator>& getAllocator() const { return myAllocator; }
0057 
0058   //! Gets mesh structure.
0059   const occ::handle<BRepMesh_DataStructureOfDelaun>& getStructure() const { return myStructure; }
0060 
0061   //! Gets 3d nodes map.
0062   const occ::handle<VectorOfPnt>& getNodesMap() const { return myNodesMap; }
0063 
0064 protected:
0065   //! Registers the given point in vertex map and adds 2d point to mesh data structure.
0066   //! Returns index of node in the structure.
0067   Standard_EXPORT virtual int registerNode(const gp_Pnt&                  thePoint,
0068                                            const gp_Pnt2d&                thePoint2d,
0069                                            const BRepMesh_DegreeOfFreedom theMovability,
0070                                            const bool                     isForceAdd);
0071 
0072   //! Adds the given 2d point to mesh data structure.
0073   //! Returns index of node in the structure.
0074   Standard_EXPORT virtual int addNodeToStructure(const gp_Pnt2d&                thePoint,
0075                                                  const int                      theLocation3d,
0076                                                  const BRepMesh_DegreeOfFreedom theMovability,
0077                                                  const bool                     isForceAdd);
0078 
0079   //! Returns 2d point associated to the given vertex.
0080   Standard_EXPORT virtual gp_Pnt2d getNodePoint2d(const BRepMesh_Vertex& theVertex) const;
0081 
0082   //! Performs initialization of data structure using existing model data.
0083   Standard_EXPORT virtual bool initDataStructure();
0084 
0085   //! Generates mesh for the contour stored in data structure.
0086   Standard_EXPORT virtual void generateMesh(const Message_ProgressRange& theRange) = 0;
0087 
0088 private:
0089   //! If the given edge has another pcurve for current face coinciding with specified one,
0090   //! returns TopAbs_INTERNAL flag. Elsewhere returns orientation of specified pcurve.
0091   TopAbs_Orientation fixSeamEdgeOrientation(const IMeshData::IEdgeHandle&   theDEdge,
0092                                             const IMeshData::IPCurveHandle& thePCurve) const;
0093 
0094   //! Adds new link to the mesh data structure.
0095   //! Movability of the link and order of nodes depend on orientation parameter.
0096   int addLinkToMesh(const int                theFirstNodeId,
0097                     const int                theLastNodeId,
0098                     const TopAbs_Orientation theOrientation);
0099 
0100   //! Commits generated triangulation to TopoDS face.
0101   void commitSurfaceTriangulation();
0102 
0103   //! Collects triangles to output data.
0104   occ::handle<Poly_Triangulation> collectTriangles();
0105 
0106   //! Collects nodes to output data.
0107   void collectNodes(const occ::handle<Poly_Triangulation>& theTriangulation);
0108 
0109 private:
0110   typedef NCollection_Shared<NCollection_DataMap<int, int>> DMapOfIntegerInteger;
0111 
0112   IMeshData::IFaceHandle                      myDFace;
0113   IMeshTools_Parameters                       myParameters;
0114   occ::handle<NCollection_IncAllocator>       myAllocator;
0115   occ::handle<BRepMesh_DataStructureOfDelaun> myStructure;
0116   occ::handle<VectorOfPnt>                    myNodesMap;
0117   occ::handle<DMapOfIntegerInteger>           myUsedNodes;
0118 };
0119 
0120 #endif