Пример #1
0
void NucleusGridFunction::
printInfo()
{
  DPrintf(DebugSolver,"--List of Nuclei:\n");
  for(int i=0; i<nucleus.size(); ++i ) {
    Nucleus &nucl= nucleus[i];
    int id;
    double x,y,z,rad;
    
    id= nucl.getID();
    rad=nucl.getRadius();
    nucl.getCenter( x,y,z);
    
    DPrintf(DebugSolver," id=%d, x=%f, y=%f, z=%f, r=%f", id,x,y,z,rad);

    IDVector nucleusGrids;
    getNucleusGrids( id, nucleusGrids);

    DPrintf(DebugSolver,", grids= ");
    for( int i=0; i<nucleusGrids.size(); ++i ) {
      DPrintf(DebugSolver," %d ",nucleusGrids[i]);
    }
    DPrintf(DebugSolver,"\n");

  }
}
Пример #2
0
int NucleusGridFunction::
getAllNuclei( IDVector &nuclei )
{
  nuclei.clear();
  DPrintf(DebugSolver,"..getAllNuclei -- # of nuclei= %d\n", getNumberOfNuclei() );
  fflush(0);
  for(int i=1; i<= getNumberOfNuclei(); ++i ) {
    nuclei.push_back( i );
  }
  return ( getNumberOfNuclei());
};
Пример #3
0
BOOST_AUTO_TEST_CASE_TEMPLATE( testSimpleSortingWithPops, DPQ, novolatile )
{
    DPQ dpq;
    typedef typename DPQ::Index Index;

    IDVector idVector;

    const Index MAXI( 100 );
    for( int n( MAXI ); n != 0  ; --n )
    {
        ID id( dpq.push( n ) );
        if( n == 11 || n == 45 )
        {
            idVector.push_back( id );
        }
    }

    BOOST_CHECK( dpq.check() );

    BOOST_CHECK_EQUAL( MAXI, dpq.getSize() );

    for( IDVector::const_iterator i( idVector.begin() );
         i != idVector.end(); ++i )
    {
        dpq.pop( *i );
    }

    BOOST_CHECK_EQUAL( MAXI - 2, dpq.getSize() );

    int n( 0 );
    while( ! dpq.isEmpty() )
    {
        ++n;
        if( n == 11 || n == 45 )
        {
            continue; // skip
        }
        BOOST_CHECK_EQUAL( int( n ), dpq.getTop() );
        dpq.popTop();
    }

    BOOST_CHECK_EQUAL( MAXI, Index( n ) );

    BOOST_CHECK( dpq.isEmpty() );
    BOOST_CHECK( dpq.check() );
}
Пример #4
0
int NucleusGridFunction::
getNucleusGrids( int nucleusID, IDVector &gridIDs)
{
  int numberOfNucleusGrids=0;
  gridIDs.clear();
  IterateIntMap pos;
  //  DPrintf(DebugSolver,"..getNucleusGrids( nID = %d ), grids= ",nucleusID);
  for (pos =nucleus2GridMap.lower_bound( nucleusID );
       pos!=nucleus2GridMap.upper_bound( nucleusID );
       ++pos ) {
    
    //DPrintf(DebugSolver," %d ", pos->second );
    gridIDs.push_back( pos->second );
    numberOfNucleusGrids++;
  }
  //DPrintf(DebugSolver,"\n");
  
  return( numberOfNucleusGrids );
}
Пример #5
0
int NucleusGridFunction::
getGridNuclei( int gridID, IDVector &nuclei)
{
  int numberOfNuclei=0;
  nuclei.clear();
  IterateIntMap pos;
  //DPrintf(DebugSolver,"..getGridNuclei( gridID = %d ), nuclei= ",gridID );
  for (pos =grid2NucleusMap.lower_bound( gridID );
       pos!=grid2NucleusMap.upper_bound( gridID );
       ++pos ) {

    //DPrintf(DebugSolver," %d ", pos->second);
    nuclei.push_back( pos->second );
    numberOfNuclei++;
  }
  //DPrintf(DebugSolver,"\n");

  return( numberOfNuclei );
}
Пример #6
0
void NucleusGridFunction::
evaluateGridFunction( double tcomp  /* = 0. */ ) //CONTINUE FROM HERE
{
  assert( pCG != NULL );
  int grid;
  Index If1,If2,If3; // full range
  const int ncomp=1; // number of components in the mask

  DPrintf(DebugSolver,">evaluateGridFunction:\n");
  for( grid=0; grid< pCG->numberOfComponentGrids(); grid++ )  {
    DPrintf(DebugSolver,"..grid %d\n", grid);
    MappedGrid & mg =   (*pCG)[grid];
    getIndex(mg.dimension(),     If1,If2,If3);    // INDICES = by dimension   
    realArray & mask  =   (*pNucleusGF)[grid];
    realArray & x     =   mg.vertex();  // array of vertices

    realArray temp(If1,If2,If3, ncomp);

    const IntegerArray & d = mg.dimension();
    const IntegerArray & gir= mg.gridIndexRange();
    const int nd= pCG->numberOfDimensions();

    //..Loop over the nuclei for this grid
    mask = 1.; // mask is ==1 for points in cytosol, ==0 inside the nucleus

    IDVector nuclei;
    //getGridNuclei( grid, nuclei); //optimized
    getAllNuclei( nuclei );
    for ( int j=0; j<nuclei.size(); ++j ) {
      Nucleus &thisNuc = getNucleus( nuclei[ j ] );
      std::string nucleusType;
      
      DPrintf(DebugSolver,".... on grid %d, evaluate nucleus %d (%s)\n", 
	     grid, thisNuc.getID(), thisNuc.getNucleusShapeName().c_str());

      thisNuc.getMaskArray(tcomp,nd, ncomp, d(0,0),d(1,0),d(0,1),d(1,1),d(0,2),d(1,2),
			   gir(0,0),gir(1,0),gir(0,1),gir(1,1),gir(0,2),gir(1,2),
			   *x.getDataPointer(),*temp.getDataPointer() );
      mask = mask*temp; // collect masks from the nuclei to one mask for this grid
    } // end for j (over the nuclei for this grid) 
  } // end for grid
}
Пример #7
0
BOOST_AUTO_TEST_CASE_TEMPLATE( testInterleavedSortingWithPops, DPQ, 
                               novolatile )
{
    DPQ dpq;
    typedef typename DPQ::Index Index;

    IDVector idVector;

    const Index MAXI( 101 );
    for( int n( MAXI-1 ); n != 0  ; n-=2 )
    {
        const ID id( dpq.push( n ) );

        if( n == 12 || n == 46 )
        {
            idVector.push_back( id );
        }
    }

    dpq.pop( idVector.back() );
    idVector.pop_back();

    BOOST_CHECK_EQUAL( MAXI/2 -1, dpq.getSize() );

    BOOST_CHECK( dpq.check() );

    for( int n( MAXI ); n != -1  ; n-=2 )
    {
        const ID id( dpq.push( n ) );

        if( n == 17 || n == 81 )
        {
            idVector.push_back( id );
        }
    }

    for( IDVector::const_iterator i( idVector.begin() );
         i != idVector.end(); ++i )
    {
        dpq.pop( *i );
    }

    BOOST_CHECK( dpq.check() );
    BOOST_CHECK_EQUAL( MAXI-4, dpq.getSize() );

    int n( 0 );
    while( ! dpq.isEmpty() )
    {
        ++n;
        if( n == 12 || n == 46 || n == 17 || n == 81 )
        {
            continue;
        }
        BOOST_CHECK_EQUAL( n, dpq.getTop() );
        dpq.popTop();
    }

    BOOST_CHECK_EQUAL( MAXI, Index( n ) );

    BOOST_CHECK( dpq.isEmpty() );
    BOOST_CHECK( dpq.check() );
}
Пример #8
0
//+----------------------------------------------------------------------------+
//| main()                                                                     |
//-----------------------------------------------------------------------------+
int
main(int argc, char** argv)
{
  common::PathFileString pfs(argv[0]);
  //////////////////////////////////////////////////////////////////////////////
  // User command line parser
  AnyOption *opt = new AnyOption();
  opt->autoUsagePrint(true);

  opt->addUsage( "" );
  opt->addUsage( "Usage: " );
  char buff[256];
  sprintf(buff, "       Example: %s -r example1_noisy.cfg", pfs.getFileName().c_str());
  opt->addUsage( buff );
  opt->addUsage( " -h  --help                 Prints this help" );
  opt->addUsage( " -r  --readfile <filename>  Reads the polyhedra description file" );
  opt->addUsage( " -t  --gltopic <topic name> (opt) ROS Topic to send OpenGL commands " );
  opt->addUsage( "" );

  opt->setFlag(  "help", 'h' );
  opt->setOption(  "readfile", 'r' );

  opt->processCommandArgs( argc, argv );

  if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) ) {opt->printUsage(); delete opt; return(1);}

  std::string gltopic("OpenGLRosComTopic");
  if( opt->getValue( 't' ) != NULL  || opt->getValue( "gltopic" ) != NULL  ) gltopic = opt->getValue( 't' );
	std::cerr << "[OpenGL communication topic is set to : \"" << gltopic << "\"]\n";

  std::string readfile;
	if( opt->getValue( 'r' ) != NULL  || opt->getValue( "readfile" ) != NULL  )
	{
    readfile = opt->getValue( 'r' );
    std::cerr << "[ World description is read from \"" << readfile << "\"]\n";
	}
	else{opt->printUsage(); delete opt; return(-1);}

  delete opt;
  //
  //////////////////////////////////////////////////////////////////////////////

  //////////////////////////////////////////////////////////////////////////////
  // Initialize ROS and OpenGLRosCom node (visualization)
  std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]"<< std::endl;
  ros::init(argc, argv, pfs.getFileName().c_str());
  if(ros::isInitialized())
    std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[OK]\n"<< std::endl;
  else{
    std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[FAILED]\n"<< std::endl;
    return(1);
  }
  COpenGLRosCom glNode;
  glNode.CreateNode(gltopic);
  //
  //////////////////////////////////////////////////////////////////////////////

  //////////////////////////////////////////////////////////////////////////////
  // Reading the input file
  std::cerr << "Reading the input file..." << std::endl;
  ShapeVector shapes;
  PoseVector  poses;
  IDVector    ID;
  if(ReadPolyhedraConfigFile(readfile, shapes, poses, ID)==false)
  {
    std::cerr << "["<<pfs.getFileName()<<"]:" << "Error reading file \"" << readfile << "\"\n";
    return(-1);
  }
  std::cerr << "Read " << poses.size() << " poses of " << shapes.size() << " shapes with " << ID.size() << " IDs.\n";
  //
  //////////////////////////////////////////////////////////////////////////////

  //////////////////////////////////////////////////////////////////////////////
  // Visualizing the configuration of objects
  std::cerr << "Visualizing the configuration of objects..." << std::endl;
  for(unsigned int i=0; i<shapes.size(); i++)
  {
    for(size_t j=0; j<shapes[i].F.size(); j++)
    {
      glNode.LineWidth(1.0f);
      glNode.AddColor3(0.3f, 0.6f, 0.5f);
      glNode.AddBegin("LINE_LOOP");
      for(size_t k=0; k<shapes[i].F[j].Idx.size(); k++)
      {
        int idx = shapes[i].F[j].Idx[k];
        Eigen::Matrix<Real,3,1> Vt = poses[i]*shapes[i].V[ idx ];
        glNode.AddVertex(Vt.x(), Vt.y(), Vt.z());
      }
      glNode.AddEnd();
    }
  }
  glNode.SendCMDbuffer();
  ros::spinOnce();
  common::PressEnterToContinue();
  //
  //////////////////////////////////////////////////////////////////////////////

  //////////////////////////////////////////////////////////////////////////////
  // Running PROMTS with A* search algorithm
  std::cerr << "Running PROMTS with Depth Limited search algorithm..." << std::endl;
  promts::ProblemDataStruct pds("Depth-Limited Search");
  pds.m_glNodePtr = &glNode;
  PoseVector refined_poses(shapes.size());
  refinePoses_DLSearch(shapes, poses, ID, refined_poses, pds);
  //
  //////////////////////////////////////////////////////////////////////////////

  return(0);
}