/src/contrib/geom-5.1.2.7/src/GEOMAlgo/GEOMAlgo_StateCollector.cpp

http://pythonocc.googlecode.com/ · C++ · 91 lines · 44 code · 1 blank · 46 comment · 14 complexity · 5e9aade5c4ca40a45ec31efd2ccc290a MD5 · raw file

  1. // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
  2. //
  3. // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
  4. // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
  5. //
  6. // This library is free software; you can redistribute it and/or
  7. // modify it under the terms of the GNU Lesser General Public
  8. // License as published by the Free Software Foundation; either
  9. // version 2.1 of the License.
  10. //
  11. // This library is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. // Lesser General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Lesser General Public
  17. // License along with this library; if not, write to the Free Software
  18. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. //
  20. // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  21. //
  22. // File: GEOMAlgo_StateCollector.cxx
  23. // Created: Thu Mar 10 09:42:11 2005
  24. // Author: Peter KURNEV
  25. // <pkv@irinox>
  26. //
  27. #include <GEOMAlgo_StateCollector.ixx>
  28. //=======================================================================
  29. //function : GEOMAlgo_StateCollector
  30. //purpose :
  31. //=======================================================================
  32. GEOMAlgo_StateCollector::GEOMAlgo_StateCollector()
  33. {
  34. myCounter[0]=0;
  35. myCounter[1]=0;
  36. myCounter[2]=0;
  37. }
  38. //=======================================================================
  39. //function : AppendState
  40. //purpose :
  41. //=======================================================================
  42. Standard_Boolean GEOMAlgo_StateCollector::AppendState(const TopAbs_State aSt)
  43. {
  44. Standard_Boolean bIsToBreak;
  45. //
  46. switch(aSt) {
  47. case TopAbs_IN:
  48. ++myCounter[0];
  49. break;
  50. case TopAbs_OUT:
  51. ++myCounter[1];
  52. break;
  53. case TopAbs_ON:
  54. ++myCounter[2];
  55. break;
  56. default:
  57. break;
  58. }
  59. bIsToBreak=(myCounter[0] && myCounter[1]);
  60. //
  61. return bIsToBreak;
  62. }
  63. //=======================================================================
  64. //function : State
  65. //purpose :
  66. //=======================================================================
  67. TopAbs_State GEOMAlgo_StateCollector::State()const
  68. {
  69. TopAbs_State aSt;
  70. //
  71. aSt=TopAbs_UNKNOWN;
  72. //
  73. if (myCounter[0] && myCounter[1]) {
  74. return aSt;
  75. }
  76. //
  77. else if (myCounter[0] && myCounter[2]>=0) {
  78. aSt=TopAbs_IN;
  79. }
  80. //
  81. else if (myCounter[1] && myCounter[2]>=0) {
  82. aSt=TopAbs_OUT;
  83. }
  84. //
  85. else if (!myCounter[0] && !myCounter[1] && myCounter[2]) {
  86. aSt=TopAbs_ON;
  87. }
  88. //
  89. return aSt;
  90. }