Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 09:17:47

0001 // Created on: 1993-10-07
0002 // Created by: Yves FRICAUD
0003 // Copyright (c) 1993-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 _MAT2d_MiniPath_HeaderFile
0018 #define _MAT2d_MiniPath_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <MAT2d_Connexion.hxx>
0026 #include <NCollection_Sequence.hxx>
0027 #include <NCollection_DataMap.hxx>
0028 #include <Geom2d_Geometry.hxx>
0029 class MAT2d_Connexion;
0030 
0031 //! MiniPath computes a path to link all the lines in
0032 //! a set of lines. The path is described as a set of
0033 //! connexions.
0034 //!
0035 //! The set of connexions can be seen as an arbitrary Tree.
0036 //! The node of the tree are the lines. The arcs of the
0037 //! tree are the connexions. The ancestror of a line is
0038 //! the connexion which ends on it. The children of a line
0039 //! are the connexions which start on it.
0040 //!
0041 //! The children of a line are ordered by the relation
0042 //! <IsAfter> defined on the connexions.
0043 //! (See MAT2s_Connexion.cdl).
0044 class MAT2d_MiniPath
0045 {
0046 public:
0047   DEFINE_STANDARD_ALLOC
0048 
0049   Standard_EXPORT MAT2d_MiniPath();
0050 
0051   //! Computes the path to link the lines in <Figure>.
0052   //! the path starts on the line of index <IndStart>
0053   //! <Sense> = True if the Circuit turns in the
0054   //! trigonometric sense.
0055   Standard_EXPORT void Perform(
0056     const NCollection_Sequence<NCollection_Sequence<occ::handle<Geom2d_Geometry>>>& Figure,
0057     const int                                                                       IndStart,
0058     const bool                                                                      Sense);
0059 
0060   //! Run on the set of connexions to compute the path.
0061   //! the path is an exploration of the tree which contains
0062   //! the connexions and their reverses.
0063   //! if the tree of connexions is
0064   //! A
0065   //! / |
0066   //! B  E
0067   //! / |  |
0068   //! C  D  F
0069   //!
0070   //! the path is A->B, B->C, C->B, B->D, D->B, B->A, A->E,
0071   //! E->F, F->E, E->A.
0072   Standard_EXPORT void RunOnConnexions();
0073 
0074   //! Returns the sequence of connexions corresponding to
0075   //! the path.
0076   Standard_EXPORT const NCollection_Sequence<occ::handle<MAT2d_Connexion>>& Path() const;
0077 
0078   //! Returns <True> if there is one Connexion which starts
0079   //! on line designed by <Index>.
0080   Standard_EXPORT bool IsConnexionsFrom(const int Index) const;
0081 
0082   //! Returns the connexions which start on line
0083   //! designed by <Index>.
0084   Standard_EXPORT NCollection_Sequence<occ::handle<MAT2d_Connexion>>& ConnexionsFrom(
0085     const int Index);
0086 
0087   //! Returns <True> if the line designed by <Index> is
0088   //! the root.
0089   Standard_EXPORT bool IsRoot(const int Index) const;
0090 
0091   //! Returns the connexion which ends on line
0092   //! designed by <Index>.
0093   Standard_EXPORT occ::handle<MAT2d_Connexion> Father(const int Index);
0094 
0095 private:
0096   //! Add a connexion to the path.
0097   Standard_EXPORT void Append(const occ::handle<MAT2d_Connexion>& Connexion);
0098 
0099   Standard_EXPORT void ExploSons(NCollection_Sequence<occ::handle<MAT2d_Connexion>>& aPath,
0100                                  const occ::handle<MAT2d_Connexion>&                 aConnexion);
0101 
0102   //! Returns the connexion which realises the minimum of
0103   //! distance between the lines of index <L1> and <L2> in
0104   //! <aFigure>. The connexion is oriented from <L1> to <L2>.
0105   Standard_EXPORT occ::handle<MAT2d_Connexion> MinimumL1L2(
0106     const NCollection_Sequence<NCollection_Sequence<occ::handle<Geom2d_Geometry>>>& Figure,
0107     const int                                                                       L1,
0108     const int                                                                       L2) const;
0109 
0110   NCollection_DataMap<int, NCollection_Sequence<occ::handle<MAT2d_Connexion>>> theConnexions;
0111   NCollection_DataMap<int, occ::handle<MAT2d_Connexion>>                       theFather;
0112   NCollection_Sequence<occ::handle<MAT2d_Connexion>>                           thePath;
0113   double                                                                       theDirection;
0114   int                                                                          indStart;
0115 };
0116 
0117 #endif // _MAT2d_MiniPath_HeaderFile