Index

NAME

IndexSetBoxObstacles  - box shaped index set in 1D, 2D, 3D and MD
with exception of a list of points.


INCLUDE

include "IndexSetBoxObstacles.h"

SYNTAX

 //-----------------------------------------------------------------------------
 class IndexSetBoxObstacles : public IndexSetBox
 //-----------------------------------------------------------------------------
 {
 protected :

   Handle(VecSimpleH(Ptv(int))) obstacles;   // Indices for obstacle points
   VecSimple(int) obstacle_lines;            // Line number for each obstacle
   bool active_obstacles;                    // Any obstacles present?
   bool more_obstacles;                      // More obstacles to treat?
   int cnt_obstacle;                         // Counter for obstacles
   Ptv(int)* curr_obstacle;                  // Current obstacle

   int cnt_line;                             // Counter for index lines

   void getNextObstacle ();                  // Go to next obstacle
   void getPrevObstacle ();                  // Go to previous obstacle

   virtual void specialStartIterator();
   virtual void specialReverseStartIterator();
   virtual void computeNoIndices();
   virtual void computeObstacleLines();

 public :

   IndexSetBoxObstacles () {}
   IndexSetBoxObstacles (int nsd);
   IndexSetBoxObstacles (const Ptv(int)& min_ind_, const Ptv(int)& max_ind_);
   IndexSetBoxObstacles (const IndexSetBoxObstacles& b);
   IndexSetBoxObstacles (const IndexSet_prm& pm);

   virtual ~IndexSetBoxObstacles () {}

   IndexSetBoxObstacles& operator=(const IndexSetBoxObstacles& b);

   virtual bool redim (const Ptv(int)& min_ind_,const Ptv(int)& max_ind_);

   void insert(/*const*/ MatSimple(int)&              obstacles_);
   void insert(/*const*/ List(Ptv(int),ListItemInst)& obstacles_);
   void insert(/*const*/ IndexSet&                    obstacles_);
   void insert(/*const*/ VecSimpleH(Ptv(int))&        obstacles_,
               bool allocate = false);
   void remove ();
   void checkObstacles ();

   bool activeObstacles () const;
   bool moreObstacles   () const;

   int getNoObstacles () const;

   Ptv(int) getObstacle (int i) const;

   virtual void getIndexIterator (Handle(IndexSet)& I) const;

   // get a new index line:
   virtual void specialIterate();
   virtual void specialReverseIterate();

   void scan (Is is, bool read_obstacles);
   void print(Os os, bool print_obstacles) const;

   virtual void scan (Is is);
   virtual void print(Os os) const;

   CLASS_INFO
 };



KEYWORDS

index set, box shape, exceptions, obstacle



DESCRIPTION

The class implements a box shaped index set including a  list  of
exceptions  or  obstacles.  It  is  derived  from  the base class
IndexSetBox. The idea is to iterate over all points in a box with
the exception of a certain set of given obstacles.



CONSTRUCTORS AND INITIALIZATION

There is specialized constructor that takes two Ptv(int) objects,
specifying the lower and upper index of  the  set.  In  addition,
there  are constructors that must be combined with calls to redim
or scan in order to complete the initialization of the object.

However, in any case the exception points have to be imposed  via
insert.   If  no obstacles are attached, the class will behave as
the corresponding IndexSetBox class, but with  slight  efficiency
overhead.


MEMBER FUNCTIONS

Please  note  that  the inherited member functions from the class
IndexSetBox are described within the documentation  of  IndexSet­
Box.



insert  - inserts a list of exception points. This is crucial for
this class and is the difference from the base class IndexSetBox.
The  input  to  an insert call is either a vector (VecSimpleH), a
coordinate array (MatSimple), a list  (List),  or  an  index  set
(IndexSet)  of  exception points. In the case of inserting a Vec­
SimpleH object, the input data can be copied  (allocate=true)  or
shared  (allocate=false)through  use of a Handle. Any other input
format implies that exception point data are copied to an  inter­
nally  managed  data  structure. It is assumed that the exception
points are ORDERED in the same  order  as  the  forward  iterator
(iterate) runs trough them. Otherwise the results are not guaran­
teed.

remove - removes the  obstacles,  leading  to  a  behaviour  that
resembles the class IndexSetBox.

activeObstacles - returns true if there are obstacles present.

moreObstacles  -  returns  true  if  there  are still unprocessed
obstacles.

getNoObstacles - returns the number of obstacles inserted to  the
index set.

getObstacle - returns the i-th obstacle as a Ptv(int) object.



EXAMPLE

| #include <IndexSetBoxObstacles.h>

main ()
{
  IndexSetBoxObstacles box_obst;

  box_obst.scan("2(1,1)x(5,5)");

  VecSimple(Ptv(int)) obst(4);
  obst(1).fill(2,2);
  obst(2).fill(3,3);
  obst(3).fill(4,3);
  obst(4).fill(3,4);

  box_obst.insert(obst);

  s_o << "Obstacle index set0;
  s_o << "------------------0;

  box_obst.print(s_o);

  Ptv(int) ind_obst(2);
  box_obst.startIterator(ind_obst);

  s_o << "Iteration of obstacle index set0;
  s_o << "-------------------------------0;

  Ptv(int) prev(2);
  prev(1) = 0;
  prev(2) = 0;

  while (box_obst.iterate()) {
    if (ind_obst(1) == 1)
      s_o << "0;
    for  (int  i  =  prev(1)+1; i < ind_obst(1); i+=box_obst.get­
Step())
      s_o << "XXX" << "  ";
    s_o << ind_obst << " ";
    prev = ind_obst;
  }
}



SEE ALSO

class IndexSet, class IndexSetBox.


DEVELOPED BY

Numerical Objects AS


AUTHOR

Are Magnus Bruaset, Numerical Objects AS