+ //=======================================================================
+ /*!
+ * \brief Cut faces of a triangular mesh.
+ * Usage work-flow: 1) call Cut() methods as many times as needed
+ * 2) call MakeNewFaces() to really modify the mesh faces
+ */
+ //=======================================================================
+ // implemented in SMESH_Offset.cxx
+
+ class SMESHUtils_EXPORT Intersector
+ {
+ public:
+ Intersector( SMDS_Mesh* mesh, double tol, const std::vector< gp_XYZ >& normals );
+ ~Intersector();
+
+ //! Compute cut of two faces of the mesh
+ void Cut( const SMDS_MeshElement* face1,
+ const SMDS_MeshElement* face2,
+ const int nbCommonNodes = -1 );
+
+ //! Store a face cut by a line given by its ends lying either on face edges or inside the face.
+ // Line ends are accompanied by indices of intersected face edges.
+ // Edge index is <0 if a line end is inside the face.
+ void Cut( const SMDS_MeshElement* face,
+ SMESH_NodeXYZ& lineEnd1,
+ int edgeIndex1,
+ SMESH_NodeXYZ& lineEnd2,
+ int edgeIndex2 );
+
+ //! Split all faces intersected by Cut() methods.
+ // theSign = (-1|1) is used to choose which part of a face cut by another one to remove.
+ // 1 means to remove a part opposite to face normal.
+ // Optionally optimize quality of split faces by edge swapping.
+ void MakeNewFaces( SMESH_MeshAlgos::TElemIntPairVec& theNew2OldFaces,
+ SMESH_MeshAlgos::TNodeIntPairVec& theNew2OldNodes,
+ const double theSign = 1.,
+ const bool theOptimize = false );
+
+ typedef std::vector< SMESH_NodeXYZ > TFace;
+
+ //! Cut a face by planes, whose normals point to parts to keep.
+ // Return true if the whole face is cut off
+ static bool CutByPlanes(const SMDS_MeshElement* face,
+ const std::vector< gp_Ax1 > & planes,
+ const double tol,
+ std::vector< TFace > & newFaceConnectivity );
+
+ private:
+ struct Algo;
+ Algo* myAlgo;
+ };
+
+ //=======================================================================