Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:13

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 
0033   typedef NCollection_Shared<NCollection_Vector<gp_Pnt> > VectorOfPnt;
0034 
0035   //! Constructor.
0036   Standard_EXPORT BRepMesh_BaseMeshAlgo();
0037 
0038   //! Destructor.
0039   Standard_EXPORT virtual ~BRepMesh_BaseMeshAlgo();
0040 
0041   //! Performs processing of the given face.
0042   Standard_EXPORT virtual void Perform(
0043     const IMeshData::IFaceHandle& theDFace,
0044     const IMeshTools_Parameters&  theParameters,
0045     const Message_ProgressRange&  theRange = Message_ProgressRange()) Standard_OVERRIDE;
0046 
0047   DEFINE_STANDARD_RTTIEXT(BRepMesh_BaseMeshAlgo, IMeshTools_MeshAlgo)
0048 
0049 protected:
0050 
0051   //! Gets discrete face.
0052   const IMeshData::IFaceHandle& getDFace() const
0053   {
0054     return myDFace;
0055   }
0056 
0057   //! Gets meshing parameters.
0058   const IMeshTools_Parameters& getParameters() const
0059   {
0060     return myParameters;
0061   }
0062 
0063   //! Gets common allocator.
0064   const Handle(NCollection_IncAllocator)& getAllocator() const
0065   {
0066     return myAllocator;
0067   }
0068 
0069   //! Gets mesh structure.
0070   const Handle(BRepMesh_DataStructureOfDelaun)& getStructure() const
0071   {
0072     return myStructure;
0073   }
0074 
0075   //! Gets 3d nodes map.
0076   const Handle(VectorOfPnt)& getNodesMap() const
0077   {
0078     return myNodesMap;
0079   }
0080 
0081 protected:
0082 
0083   //! Registers the given point in vertex map and adds 2d point to mesh data structure.
0084   //! Returns index of node in the structure.
0085   Standard_EXPORT virtual Standard_Integer registerNode(
0086     const gp_Pnt&                  thePoint,
0087     const gp_Pnt2d&                thePoint2d,
0088     const BRepMesh_DegreeOfFreedom theMovability,
0089     const Standard_Boolean         isForceAdd);
0090 
0091   //! Adds the given 2d point to mesh data structure.
0092   //! Returns index of node in the structure.
0093   Standard_EXPORT virtual Standard_Integer addNodeToStructure(
0094     const gp_Pnt2d&                thePoint,
0095     const Standard_Integer         theLocation3d,
0096     const BRepMesh_DegreeOfFreedom theMovability,
0097     const Standard_Boolean         isForceAdd);
0098 
0099   //! Returns 2d point associated to the given vertex.
0100   Standard_EXPORT virtual gp_Pnt2d getNodePoint2d(const BRepMesh_Vertex& theVertex) const;
0101 
0102   //! Performs initialization of data structure using existing model data.
0103   Standard_EXPORT virtual Standard_Boolean initDataStructure();
0104 
0105   //! Generates mesh for the contour stored in data structure.
0106   Standard_EXPORT virtual void generateMesh(const Message_ProgressRange& theRange) = 0;
0107 
0108 private:
0109 
0110   //! If the given edge has another pcurve for current face coinciding with specified one,
0111   //! returns TopAbs_INTERNAL flag. Elsewhere returns orientation of specified pcurve.
0112   TopAbs_Orientation fixSeamEdgeOrientation(
0113     const IMeshData::IEdgeHandle&   theDEdge,
0114     const IMeshData::IPCurveHandle& thePCurve) const;
0115 
0116   //! Adds new link to the mesh data structure.
0117   //! Movability of the link and order of nodes depend on orientation parameter.
0118   Standard_Integer addLinkToMesh(
0119     const Standard_Integer   theFirstNodeId,
0120     const Standard_Integer   theLastNodeId,
0121     const TopAbs_Orientation theOrientation);
0122 
0123   //! Commits generated triangulation to TopoDS face.
0124   void commitSurfaceTriangulation();
0125 
0126   //! Collects triangles to output data.
0127   Handle(Poly_Triangulation) collectTriangles();
0128 
0129   //! Collects nodes to output data.
0130   void collectNodes(const Handle(Poly_Triangulation)& theTriangulation);
0131 
0132 private:
0133   typedef NCollection_Shared<NCollection_DataMap<Standard_Integer, Standard_Integer> > DMapOfIntegerInteger;
0134 
0135   IMeshData::IFaceHandle                 myDFace;
0136   IMeshTools_Parameters                  myParameters;
0137   Handle(NCollection_IncAllocator)       myAllocator;
0138   Handle(BRepMesh_DataStructureOfDelaun) myStructure;
0139   Handle(VectorOfPnt)                    myNodesMap;
0140   Handle(DMapOfIntegerInteger)           myUsedNodes;
0141 };
0142 
0143 #endif