C:/cmcintos/defOrgs/source/geometrical/Geom_MeshSpatialObject.cxx

00001 #ifndef _Geom_MeshSpatialObject_cxx
00002 #define _Geom_MeshSpatialObject_cxx
00003 #include "Geom_MeshSpatialObject.h"
00004 
00005 namespace mial
00006 {
00007 
00008         template <class dType, int nDims,class MType, class VType >
00009         Geom_MeshSpatialObject<dType, nDims,MType,VType>
00010                 ::Geom_MeshSpatialObject(dType p)
00011         {
00012                 theMeshSpatialObject = MeshSpatialObjectType::New();
00013                 theMesh = theMeshSpatialObject->GetMesh();
00014                 writer = WriterType::New();
00015                 m_IsInsidePrecision = p;
00016         }
00017 
00018         template <class dType, int nDims,class MType, class VType >
00019         MType 
00020                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00021 		::getMatrixNodePositions()
00022         {
00023                 this->mNodes.set_size(this->numNodes,nDims);
00024                 this->updateMatrixNodePositions();
00025                 return this->mNodes;
00026         }
00027 
00028         /*template <class dType, int nDims,class MType, class VType >
00029         vType Geom_MeshSpatialObject<dType, nDims,MType,VType>::getVectorNodePositions()
00030         {
00031         // TODO finish this function ;)
00032         this.updateVectorNodePositions();
00033         //double a[nDims];
00034         /*for(int i=0; i<nDims; i++)
00035         {
00036         container[i] = nodes(index,i);
00037         }
00038         return vNodes;
00039         //return a;
00040         }*/
00041 
00042         template <class dType, int nDims,class MType, class VType >
00043         bool 
00044                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00045 		::setMatrixNodePositions(MatrixType pos, int * inds)
00046         {
00047                 for(int i=0; i< sizeof(inds)/sizeof(int); i++)
00048                         this->mNodes.set_row(i,pos.get_row(i));
00049                 this->updateMeshNodePositions();
00050                 return true;
00051         }
00052 
00053         template <class dType, int nDims,class MType, class VType >
00054         bool 
00055                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00056 		::addNodes(MatrixType pos, VectorType classes)
00057         {
00058                 
00059                 MatrixType tmp;
00060                 tmp.set_size(this->numNodes+pos.rows(),nDims);
00061                 VectorType tmpC;
00062                 tmpC.set_size(this->numNodes+pos.rows());
00063 
00064                 //Copy the information
00065                 for(int i=0;i<this->numNodes;i++)
00066                 {
00067                         tmp.set_row(i,this->mNodes.get_row(i));
00068                         tmpC(i) = this->nodeClass(i);
00069                 }
00070                 //Add the new information
00071                 for(int i=this->numNodes, c=0;i<this->numNodes+pos.rows();i++,c++)
00072                 {
00073                         tmp.set_row(i,pos.get_row(c));
00074                         tmpC(i) = classes(c);
00075                 }
00076 
00077                 this->numNodes +=pos.rows();
00078 
00079                 this->mNodes.set_size(this->numNodes,nDims);
00080                 this->mNodes = tmp;//Copy back the old information plus the new information
00081                 this->nodeClass = tmpC;
00082 
00083                 //Update the mesh node positions to include the new nodes
00084                 this->updateMeshNodePositions();
00085                 return true;
00086         }
00087         template <class dType, int nDims,class MType, class VType >
00088         bool 
00089                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00090 		::setMatrixNodePositions(MatrixType pos)
00091         {
00092                 this->mNodes = pos;
00093                 this->updateMeshNodePositions();
00094                 return true;
00095         }
00096 
00097         template <class dType, int nDims,class MType, class VType >
00098         void 
00099                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00100 		::updateMatrixNodePositions()
00101         {
00102                 typename MeshType::PointsContainer::Iterator pointIterator;
00103                 pointIterator = theMesh->GetPoints()->Begin();
00104                 typename MeshType::PointsContainer::Iterator end = theMesh->GetPoints()->End();
00105 
00106                 int count =0;
00107                 this->numNodes =0;
00108                 //TODO just get the # of points from the mes
00109                 while( pointIterator != end )
00110                 {       ++pointIterator; // advance to next point
00111                 this->numNodes++;
00112                 }
00113 
00114 
00115                 pointIterator = theMesh->GetPoints()->Begin();
00116                 this->mNodes.set_size(this->numNodes,nDims);
00117                 while( pointIterator != end )
00118                 {       
00119                         typename MeshType::PointType p = pointIterator.Value(); // access the point
00120                         for(int i=0;i<nDims;i++)
00121                         {
00122                                 this->mNodes(count,i)=p[i];
00123                         }
00124                         ++pointIterator; // advance to next point
00125                         count++;
00126                 }
00127         }
00128 
00129         template <class dType, int nDims,class MType, class VType >
00130         void 
00131                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00132                 ::updateMeshNodePositions()
00133         {
00134 
00135                 PointType tmp;
00136                 for(int count=0;count < this->numNodes; count++)
00137                 {
00138                         for(int i=0; i<nDims; i++)
00139                         {
00140                                 tmp[i] = this->mNodes(count,i);
00141                         }
00142                         theMesh->SetPoint(count,tmp); //Add the point to the mesh
00143                 }
00144                 theMeshSpatialObject->SetMesh(theMesh);
00145         }
00146 
00147         template <class dType, int nDims,class MType, class VType >
00148         void 
00149                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00150                 ::updateMatrixConnections()
00151         {
00152                 CellIterator cellIterator = theMesh->GetCells()->Begin();
00153                 CellIterator cellEnd = theMesh->GetCells()->End();
00154 
00155                 cellIterator = theMesh->GetCells()->Begin();
00156                 cellEnd = theMesh->GetCells()->End();
00157 
00158                 typename TriangleType::PointIdIterator pit;
00159 
00160                 //TODO dynamically figure out the number of connections
00161                 //There are three connections per cell
00162                 this->mConnections.set_size(3*theMesh->GetNumberOfCells(),2);
00163                 this->numConnections =0;
00164                 while( cellIterator != cellEnd )
00165                 {
00166                         CellType * cell = cellIterator.Value();
00167                         switch( cell->GetType() )
00168                         {
00169                         case CellType::TRIANGLE_CELL:
00170                                 {
00171                                         TriangleType * tri = dynamic_cast<TriangleType *>( cell );
00172                                         pit = tri->PointIdsBegin();
00173                                         //Create a spring for each edge of the triangle
00174 
00175                                         mConnections(this->numConnections,0) = *(pit);
00176                                         mConnections(this->numConnections,1) = *(pit+1);
00177                                         this->numConnections++;
00178 
00179                                         mConnections(this->numConnections,0) = *(pit+1);
00180                                         mConnections(this->numConnections,1) = *(pit+2);
00181                                         this->numConnections++;
00182 
00183                                         mConnections(this->numConnections,0) = *(pit+2);
00184                                         mConnections(this->numConnections,1) = *(pit);
00185                                         this->numConnections++;
00186 
00187                                         break;
00188                                 }
00189                         }
00190                         ++cellIterator;
00191                 }
00192         }
00193 
00194         template <class dType, int nDims,class MType, class VType >
00195         void 
00196                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00197                 ::writeNodesToFile( std::string fileName )
00198         {
00199                 std::ofstream out(fileName.c_str());
00200 
00201                 typename MeshType::PointsContainer::Iterator pointIterator;
00202                 pointIterator = theMesh->GetPoints()->Begin();
00203                 typename MeshType::PointsContainer::Iterator end = theMesh->GetPoints()->End();
00204                 out << theMesh->GetNumberOfPoints() << std::endl;
00205                 while( pointIterator != end )
00206                 {
00207                         typename MeshType::PointType p = pointIterator.Value(); // access the point
00208                         out << p << std::endl; // print the point
00209                         ++pointIterator; // advance to next point
00210                 }
00211         }
00212 
00213         template <class dType, int nDims,class MType, class VType >
00214         void 
00215                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00216 		::writeObjectToFile(std::string fileName)
00217         {
00218                 writer->SetInput( theMeshSpatialObject );
00219                 writer->SetFileName( fileName.c_str() );
00220                 writer->Update();
00221         }
00222 
00223         template <class dType, int nDims,class MType, class VType >
00224         void 
00225                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00226 		::readNodesFromFile( std::string fileName )
00227         {
00228                 std::ifstream in(fileName.c_str());
00229                 int count = 0;
00230                 int size =0;
00231                 in >> size;
00232                 //MeshType::CoordRepType nodes[size][nDims];
00233                 PointType tmp;
00234                 while(count < size)
00235                 {
00236                         for(int i=0; i<nDims; i++)
00237                         {
00238                                 in >> tmp[i];
00239                         }
00240                         theMesh->SetPoint(count,tmp); //Add the point to the mesh
00241                         count++;
00242                 }
00243                 this->numNodes = theMesh->GetNumberOfPoints();
00244                 theMeshSpatialObject->SetMesh(theMesh);
00245                 updateMatrixNodePositions();
00246 
00247                 //Update the state variable
00248                 this->nodesChange = true;
00249         }
00250 
00251         template <class dType, int nDims,class MType, class VType >
00252         bool 
00253                 Geom_MeshSpatialObject<dType, nDims,MType,VType>
00254 		::readTopologyFromFile( std::string fileName )
00255         {
00256                 //TODO error checking on correct input type
00257 
00258                 typename ReaderType::Pointer reader = ReaderType::New();
00259                 reader->SetFileName(fileName.c_str());
00260                 reader->Update();
00261 
00262 
00263                 /*typedef itk::SpatialObjectToImageFilter< GroupType,BinaryImageType >          SpatialObjectToImageFilterType;
00264                 SpatialObjectToImageFilterType::Pointer objectToImageFilter = SpatialObjectToImageFilterType::New();
00265                 objectToImageFilter->SetInput( reader->GetGroup());
00266 
00267                 objectToImageFilter->Update();
00268                 typedef typename itk::ImageFileWriter<BinaryImageType> writerType;
00269                 writerType::Pointer writer = writerType::New();
00270                 writer->SetFileName("C:\\testSpatial.mhd");
00271                 writer->SetInput( objectToImageFilter->GetOutput() );
00272                 writer->Update();*/
00273 
00274 
00275 
00276                 /*      typedef itk::SceneSpatialObject<3> SceneSpatialObjectType;
00277                 SceneSpatialObjectType::Pointer scene = SceneSpatialObjectType::New();
00278                 typedef itk::EllipseSpatialObject<3> EllipseType;
00279                 EllipseType::Pointer ellipse1 = EllipseType::New();
00280                 ellipse1->SetRadius(1);
00281                 ellipse1->SetId(1);
00282                 EllipseType::Pointer ellipse2 = EllipseType::New();
00283                 ellipse2->SetId(2);
00284                 ellipse2->SetRadius(2);
00285                 scene->AddSpatialObject(ellipse1);
00286                 scene->AddSpatialObject(ellipse2);
00287 
00288                 EllipseType* ellipse3;// = EllipseType::New();
00289                 ellipse3 = dynamic_cast<EllipseType *> (scene->GetObjectById(1)); */
00290 
00291 
00292 
00293 
00294 
00295 
00296                 //GroupType::ChildrenListPointer children = (reader->GetGroup())->GetChildren();
00297                 //GroupType::ChildrenListType::iterator it = children->begin();
00298 
00299                 //Get the first child's mesh
00300                 MeshSpatialObjectType* t = dynamic_cast<MeshSpatialObjectType *> ( (reader->GetScene())->GetObjectById(0));
00301                 theMeshSpatialObject->SetMesh( t->GetMesh());
00302                 theMesh = theMeshSpatialObject->GetMesh();
00303                 //theMeshSpatialObject->SetMesh( ->GetMesh() );
00304 
00305                 //Update the points
00306                 updateMatrixNodePositions();
00307 
00308                 //Update the matrix connections
00309                 updateMatrixConnections();
00310 
00311                 //Set the state variable so other modules are aware of the change.
00312                 this->topologyChange = true;
00313 
00314                 /*
00315                 int count = 0;
00316                 int size =0;
00317                 int start =0;
00318                 int middle =0;
00319                 int end =0;
00320                 in >> size;
00321                 //MeshType::CoordRepType nodes[size][nDims];
00322                 PointType tmp;
00323                 CellAutoPointer Lines;
00324                 mConnections.set_size(size,2);//Store all of the connections in vector format
00325                 while(count < size)
00326                 {
00327                 in >> start >> end;
00328                 Lines.TakeOwnership( new LineType);
00329                 Lines->SetPointId(0,start);
00330                 Lines->SetPointId(1,end);
00331                 //theMesh->SetCell(theMesh->GetNumberOfCells(),Lines);
00332 
00333                 mConnections(count,0) = start;
00334                 mConnections(count,1) = end;
00335                 count++;
00336                 }
00337                 numConnections = count;
00338                 theMeshSpatialObject->SetMesh(theMesh);
00339                 //std::cout << "Mesh bounds : " << theMeshSpatialObject->GetBoundingBox()->GetBounds() << std::endl;
00340                 topologyChange = true;*/
00341                 return false;
00342         }
00343 
00344         template < class dType, int nDims, class MType, class VType >
00345         typename itk::Image< unsigned char, nDims>::Pointer
00346                 Geom_MeshSpatialObject< dType, nDims, MType, VType >
00347 		::generateBinaryImageFromTopology( typename Geom_MeshSpatialObject<dType,nDims,MType,VType>::BinaryImageType::SizeType size)
00348         {
00349 //              std::cout << "Starting binary image generation from mesh..." << std::endl;
00350                 typename BinaryImageType::Pointer image = BinaryImageType::New();
00351 
00352                 typedef itk::TriangleMeshToBinaryImageFilter< MeshType, BinaryImageType >  meshToImageFilterType;
00353                 typename meshToImageFilterType::Pointer meshToImageFilter = meshToImageFilterType::New();
00354                 
00355                 // TODO fix this workaround and pass BinaryImageType::SizeType variable instead of dType*
00356                 /*BinaryImageType::SizeType size;
00357                 for( unsigned int i=0; i<nDims; i++)
00358                 {
00359                         size[i] = imageSize[i];
00360                 }*/
00361 
00362                 meshToImageFilter->SetSize( size );
00363 
00364                 meshToImageFilter->SetInput( theMeshSpatialObject->GetMesh() );
00365                 image = meshToImageFilter->GetOutput();
00366                 meshToImageFilter->Update();
00367 
00368 //              std::cout << "Finished binary image generation from mesh." << std::endl;
00369 //              BinaryImageType::IndexType start;
00370 //              BinaryImageType::SizeType size;
00371 //              dType origin[ nDims ]; 
00372 //
00373 //              //Compute the size of the spatial object
00374 //              theMeshSpatialObject->ComputeBoundingBox();
00375 //              //std::cout << "Mesh bounds : " << theMeshSpatialObject->GetBoundingBox()->GetBounds() << std::endl;
00376 //              for(unsigned int i=0;i<nDims;i++)
00377 //              {
00378 //                      size[i] = (long unsigned int)(theMeshSpatialObject->GetBoundingBox()->GetMaximum()[i]- theMeshSpatialObject->GetBoundingBox()->GetMinimum()[i]);
00379 //                      start[i] =0;
00380 //                      origin[i] =theMeshSpatialObject->GetBoundingBox()->GetMinimum()[i];
00381 //              }
00382 //              BinaryImageType::RegionType region;
00383 //              region.SetSize( size );
00384 //              region.SetIndex( start);
00385 //
00386 //              image->SetRegions( region );
00387 //              image->Allocate();
00388 //
00389 //              //TODO get spacing from input image
00390 //              /*dType spacing[ nDims ];
00391 //              image->SetSpacing( spacing );*/
00392 //
00393 //              //TODO get correct origin (offset) to map to world coridinates
00394 //              image->SetOrigin( origin );
00395 //
00396 //              //Define a point for the image and the iterators
00397 //              BinaryImageType::PointType pointXYZ;
00398 //              typedef itk::ImageRegionIterator< BinaryImageType> IteratorType;
00399 //
00400 //              IteratorType imgIt( image, region );
00401 //              VectorType vPoint(nDims);
00402 //              for ( imgIt.GoToBegin(); !imgIt.IsAtEnd();++imgIt)
00403 //              {
00404 //                      //Convert from index to 3-space
00405 //                      image->TransformIndexToPhysicalPoint(imgIt.GetIndex(),pointXYZ);
00406 //                      for(int i=0;i<nDims;i++)
00407 //                      {
00408 //                              vPoint(i) = pointXYZ[i];
00409 //                      }
00410 //                      imgIt.Set( 255*isInside(vPoint) );
00411 //              }
00413 //              MeshSpatialObjectType::PointType myPhysicalPoint; 
00414 //              myPhysicalPoint.Fill(50);
00415 //              std::cout << "Is my physical point inside? : " << theMeshSpatialObject->IsInside(myPhysicalPoint) << std::endl;
00416 //
00417 //              VectorType p(nDims);
00418 //              p(0) = 50;
00419 //              p(1) = 60;
00420 //              p(2) = 30;
00421 //              std::cout << "Is my physical point REALLY inside? : " << this->isInside(p) << std::endl;
00422 //
00423 //
00424 //              p(0) = 5;
00425 //              p(1) = 5;
00426 //              p(2) = 5;
00427 //              std::cout << "Is my other physical point REALLY inside? : " << this->isInside(p) << std::endl;
00428 //
00429 //
00430 //              typedef typename itk::ImageFileWriter<BinaryImageType> writerType;
00431 //              writerType::Pointer writer = writerType::New();
00432 //              writer->SetFileName("C:\\testSpatial.mhd");
00433 //              writer->SetInput( image );
00434 //              writer->Update();
00435 //
00436 //              //end testing*/
00437 
00438                 return image;
00439         }
00440 
00441         template < class dType, int nDims, class MType, class VType >
00442         void 
00443                 Geom_MeshSpatialObject< dType, nDims, MType, VType >
00444                 ::generateTopologyFromBinaryImage( BinaryImageTypePointer binaryInputImage )
00445         {
00446                 typedef itk::BinaryMask3DMeshSource< BinaryImageType, MeshType >                MeshSourceType;
00447                 typename MeshSourceType::Pointer imgToMeshFilter = MeshSourceType::New();
00448 
00449                 imgToMeshFilter->SetInput( binaryInputImage );
00450 
00451                 // Get the max binary image value so we can define what is "inside" the mesh:
00452                 typedef itk::MinimumMaximumImageFilter< BinaryImageType >                               MinMaxFilterType;
00453                 typename MinMaxFilterType::Pointer minMaxFilter = MinMaxFilterType::New();
00454                 minMaxFilter->SetInput( binaryInputImage );
00455                 minMaxFilter->Update();
00456 
00457                 imgToMeshFilter->SetObjectValue( minMaxFilter->GetMaximum() ); 
00458 
00459                 imgToMeshFilter->Update();
00460 
00461                 std::cout << "BinaryMask3DMeshSource update completed." << std::endl; // DEBUG
00462                 theMesh = imgToMeshFilter->GetOutput();
00463 
00464                 // TODO: find out why CellData is bad and use a better solution
00465                 // for some reason, unknown CellData is being written to file; temporary workaround:
00466                 typename MeshType::CellDataContainer::Pointer emptyCellDataContainer = MeshType::CellDataContainer::New();
00467                 theMesh->SetCellData( emptyCellDataContainer );
00468                 theMeshSpatialObject->SetMesh( theMesh );
00469         }
00470         template < class dType, int nDims, class MType, class VType >
00471         bool
00472                 Geom_MeshSpatialObject< dType, nDims, MType, VType >
00473 		::isInside( VectorType p)
00474         {//Check if a given point is inside the object
00475 
00476                 //For all triangles, check if a ray extending from the object in both directions intersects.
00477                 //If the ray intersects an odd number of triangles on both sides in it is inside.
00478                 CellIterator cellIterator = theMesh->GetCells()->Begin();
00479                 CellIterator cellEnd = theMesh->GetCells()->End();
00480 
00481                 cellIterator = theMesh->GetCells()->Begin();
00482                 cellEnd = theMesh->GetCells()->End();
00483 
00484                 TriangleType * tri;
00485                 int pCount = 0;
00486                 int nCount = 0;
00487                 VectorType ray(nDims);
00488 
00489                 //Since any arbritary ray can be checked always use x-axis
00490                 ray.fill(0);
00491                 ray(0)=1;
00492                 ray(1)=0;
00493                 ray(2)=0;
00494 
00495                 double minDist =0;
00496                 CoordRepType closestPoint[nDims];
00497                 CoordRepType position[nDims]; //A point
00498 
00499                 for(int i=0; i<nDims;i++)
00500                         position[i] = p(i);
00501 
00502                 while( cellIterator != cellEnd )
00503                 {
00504                         CellType * cell = cellIterator.Value();
00505                         if( cell->GetType() == CellType::TRIANGLE_CELL )
00506                         {
00507                                 tri = dynamic_cast<TriangleType *>( cell );
00508                                 tri->EvaluatePosition(position,theMesh->GetPoints(),closestPoint,NULL,&minDist,NULL);
00509                                 if(abs(minDist) <= m_IsInsidePrecision)
00510                                 {//If the point is on the surface return true
00511                                         return true;
00512                                 }else
00513                                 {//otherwise check if it is within the object.
00514                                         if(intersectWithLine(ray,p,tri))
00515                                                 pCount++;
00516                                         if(intersectWithLine(-ray,p,tri))
00517                                                 nCount++;
00518                                 }
00519                         }
00520                         ++cellIterator;
00521                 }
00522                 return ( (pCount%2 !=0)&&(nCount%2!=0));//Return true iff both are odd
00523         }
00524 
00525         template < class dType, int nDims, class MType, class VType >
00526         bool
00527                 Geom_MeshSpatialObject< dType, nDims, MType, VType >
00528 		::intersectWithLine( VectorType L, VectorType P, TriangleType* tri)
00529         {//Check if a line L(s) = P + s*L intersects a triangle tri
00530 
00531                 if(this->nodesChange) //Make sure the positions are up to date
00532                         updateMatrixNodePositions();
00533 
00534                 typename TriangleType::PointIdIterator pit;
00535                 pit = tri->PointIdsBegin();
00536 
00537                 //Compute the normal to triangle
00538                 VectorType v1(nDims);
00539                 VectorType v2(nDims);
00540                 VectorType n(nDims);
00541                 VectorType w(nDims);
00542                 VectorType intersectionPoint(nDims);
00543 
00544                 v1 = this->mNodes.get_row(*(pit+1))-this->mNodes.get_row(*pit);
00545                 v2 = this->mNodes.get_row(*(pit+2))-this->mNodes.get_row(*pit);
00546                 n = vnl_cross_3d(v1,v2);
00547                 n.normalize(); //Ensure that n is unit length
00548                 L.normalize(); //Ensure that L is unit length
00549 
00550                 /*std::cout << "v1 : " << v1(0) << " " << v1(1) << " " << v1(2) <<std::endl;
00551                 std::cout << "v2 : " << v2(0) << " " << v2(1) << " " << v2(2) <<std::endl;
00552                 std::cout << "n : " << n(0) << " " << n(1) << " " << n(2) <<std::endl;
00553                 std::cout << "L : " << L(0) << " " << L(1) << " " << L(2) <<std::endl;*/
00554                 dType s;
00555                 CoordRepType position[nDims]; //A point
00556                 double minDist;
00557                 CoordRepType closestPoint[nDims];
00558                 //Are L and the normal orthogonal, if so return false
00559                 double t;
00560                 t = dot_product(n,L);
00561                 if( t != 0)
00562                 {
00563                         w = P - this->mNodes.get_row(*(pit));//Vector from a point on the line to a point on the plane
00564                         s = -dot_product(n,w)/dot_product(n,L);
00565                         if(s>=0)
00566                         {
00567                                 intersectionPoint = P+ s*L;
00568                                 //std::cout << "Intersection at : " << intersectionPoint(0) << " " << intersectionPoint(1) << " " << intersectionPoint(2) <<std::endl;
00569                                 for(int i=0;i<nDims;i++)
00570                                         position[i] = intersectionPoint(i);
00571 
00572                                 //Does the point lie within the triangle?
00573                                 //Check how close the intersection point is to the triangle, accept if its within a tolerance.
00574                                 //The distance will be returned in minDist;
00575                                 tri->EvaluatePosition(position,theMesh->GetPoints(),closestPoint,NULL,&minDist,NULL);
00576                                 //std::cout << "Min dist: " << minDist << std::endl;
00577                                 if(abs(minDist) <= m_IsInsidePrecision)
00578                                         return true;
00579                                 else
00580                                 {
00581                                         return false;
00582                                 }
00583                         }
00584                         else
00585                                 return false;
00586                 }
00587                 else
00588                 {
00589                         return false;
00590                 }
00591         }
00592 
00593         template < class dType, int nDims, class MType, class VType >
00594         bool
00595                 Geom_MeshSpatialObject< dType, nDims, MType, VType >
00596                 ::addConnection(int start,int end)
00597         {
00598                 MatrixType tmp;
00599                 tmp.set_size(this->numConnections+1,2);
00600 
00601                 //Copy the information
00602                 for(int i=0;i<this->numConnections;i++)
00603                 {
00604                         tmp(i,0) = this->mConnections(i,0);
00605                         tmp(i,1) = this->mConnections(i,1);
00606                 }
00607                 tmp(this->numConnections,0) = start;
00608                 tmp(this->numConnections,1) = end;
00609 
00610                 this->numConnections++;
00611 
00612                 this->mConnections.set_size(this->numConnections,2);
00613                 this->mConnections = tmp;//Copy back the old information plus the new information
00614 
00615                 CellAutoPointer Lines;
00616                 //Add a new line
00617                 
00618                 //Can't use lines, as SOV will not render them
00619                 /*Lines.TakeOwnership( new LineType);
00620                 Lines->SetPointId(0,start);
00621                 Lines->SetPointId(1,end);
00622                 this->theMesh->SetCell(theMesh->GetNumberOfCells(),Lines);*/
00623 
00624                 //Need triangles instead.
00625 
00626 
00627                 this->topologyChange = true;
00628 
00629                 return false;
00630         }
00631 
00632 }//end mial
00633 #endif

Generated on Wed Jul 19 13:05:17 2006 for IDO by  doxygen 1.4.7