#include <vtkDijkstraImageData.h>
Definition at line 18 of file vtkDijkstraImageData.h.
vtkDijkstraImageData::vtkDijkstraImageData | ( | ) | [protected] |
Definition at line 37 of file vtkDijkstraImageData.cxx.
References BoundaryScalars, lineas, logger, NumberOfInputPoints, Parent, PathPointer, PQ, puntos, ShortestPathIdList, SinkID, SourceID, StopWhenEndReached, UseInverseDistance, UseInverseExponentialDistance, UseInverseSquaredDistance, UseSquaredDistance, and Visited.
00038 { 00039 this->SourceID = 0; 00040 this->SinkID = 0; 00041 this->NumberOfInputPoints = 0; 00042 this->PathPointer = -1; 00043 this->StopWhenEndReached = 1; 00044 00045 this->ShortestPathIdList = NULL; 00046 this->Parent = NULL; 00047 this->Visited = NULL; 00048 this->PQ = NULL; 00049 this->BoundaryScalars = NULL; 00050 00051 this->UseInverseDistance = 0; 00052 this->UseInverseSquaredDistance = 0; 00053 this->UseInverseExponentialDistance = 1; 00054 this->UseSquaredDistance = 0; 00055 00056 this->puntos = NULL; 00057 this->lineas = NULL; 00058 00059 00060 this->logger = NULL; 00061 00062 //if ((this->logger = freopen("c:\\creatis\\maracas\\dijkstra.txt","w", stdout)) == NULL) 00063 // exit(-1); 00064 00065 }
vtkDijkstraImageData::~vtkDijkstraImageData | ( | ) | [protected] |
Definition at line 69 of file vtkDijkstraImageData.cxx.
References BoundaryScalars, Parent, and ShortestPathIdList.
00070 { 00071 00072 00073 if (this->ShortestPathIdList) 00074 this->ShortestPathIdList->Delete(); 00075 if (this->Parent) 00076 this->Parent->Delete(); 00077 if(this->BoundaryScalars) 00078 this->BoundaryScalars->Delete(); 00079 //if (this->Visited) 00080 // this->Visited->Delete(); 00081 //if (this->PQ) 00082 // this->PQ->Delete(); 00083 //if (this->Heap) 00084 //this->Heap->Delete(); 00085 //if (this->p) 00086 //this->p->Delete(); 00087 //if(this->BoundaryScalars) 00088 //this->BoundaryScalars->Delete(); 00089 //DeleteGraph(); 00090 //if (this->CumulativeWeightFromSource) 00091 //this->CumulativeWeightFromSource->Delete(); 00092 00093 }
void vtkDijkstraImageData::BuildShortestPath | ( | int | start, | |
int | end | |||
) |
Definition at line 481 of file vtkDijkstraImageData.cxx.
References GetInput(), lineas, New(), Parent, printPointData(), puntos, and ShortestPathIdList.
Referenced by Execute().
00482 { 00483 00484 int p = end; 00485 int next = 0; 00486 int i = 0; 00487 double punto[3]; 00488 00489 this->puntos = vtkPoints::New(); 00490 this->lineas = vtkCellArray::New(); 00491 00492 00493 00494 //printf("======================camino minimo========================\n"); 00495 //printf("Punto Inicial = %i, Punto Final = %i\n",start, end); 00496 00497 while (p != start && p > 0) 00498 { 00499 printPointData(p); 00500 00501 this->GetInput()->GetPoint(p,punto); 00502 this->puntos->InsertPoint(i,punto); //puntos y lineas usados como resultado (vtkPolyData) 00503 00504 next = this->Parent->GetValue(p); 00505 00506 this->GetInput()->GetPoint(next,punto); 00507 this->puntos->InsertPoint(i+1,punto); 00508 00509 this->lineas->InsertNextCell(2); 00510 this->lineas->InsertCellPoint(i); 00511 this->lineas->InsertCellPoint(i+1); 00512 00513 this->ShortestPathIdList->InsertNextId(p); 00514 p = next; 00515 i++; 00516 } 00517 00518 this->ShortestPathIdList->InsertNextId(p); 00519 printPointData(p); 00520 //printf("===========================================================\n"); 00521 00522 00523 00524 this->GetOutput()->SetPoints (this->puntos); 00525 this->GetOutput()->SetLines(this->lineas); 00526 this->GetOutput()->Modified(); 00527 //fclose(logger); 00528 00529 }
void vtkDijkstraImageData::CreateGraph | ( | vtkImageData * | inData | ) |
Definition at line 163 of file vtkDijkstraImageData.cxx.
Referenced by init().
00163 { 00164 00165 00166 //DeleteGraph(); 00167 //delete old arrays in case we are re-executing this filter 00168 int numPoints = inData->GetNumberOfPoints(); 00169 this->SetNumberOfInputPoints(numPoints); 00170 00171 // initialization 00172 int *dim = inData->GetDimensions(); 00173 vtkDataArray *scalars = inData->GetPointData()->GetScalars(); 00174 vtkIdList *graphNodes = vtkIdList::New(); 00175 int graphSize = 0; 00176 // create the graph 00177 for(int k = 0; k <dim[2]; k++) { 00178 this->UpdateProgress ((float) k / (2 * ((float) dim[2] - 1))); 00179 for(int j = 0; j <dim[1]; j++) { 00180 for(int i = 0; i <dim[0]; i++) { 00181 00182 int id = k*(dim[1]*dim[0]) + j*dim[0] + i; 00183 float maskValue = scalars->GetTuple1(id); 00184 // only add neighbor if it is in the graph 00185 00186 if(maskValue > 0) { 00187 // add to graph 00188 graphNodes->InsertNextId(id); 00189 graphSize++; 00190 } 00191 } 00192 } 00193 } 00194 00195 this->SetNumberOfGraphNodes(graphSize); 00196 //printf("graph size %i \n ",graphSize); 00197 00198 // fill the PQ 00199 PQ->Allocate(graphSize); 00200 for(int i=0; i<graphSize;i++) { 00201 PQ->Insert(VTK_LARGE_FLOAT,graphNodes->GetId(i)); 00202 } 00203 // free some memory 00204 graphNodes->Delete(); 00205 00206 }
void vtkDijkstraImageData::DeleteGraph | ( | ) |
Definition at line 144 of file vtkDijkstraImageData.cxx.
00145 { 00146 00147 /*const int npoints = this->GetNumberOfInputPoints(); 00148 00149 if (this->Neighbors) 00150 { 00151 for (int i = 0; i < npoints; i++) 00152 { 00153 if(this->Neighbors[i]) 00154 this->Neighbors[i]->Delete(); 00155 } 00156 delete [] this->Neighbors; 00157 } 00158 this->Neighbors = NULL; 00159 */ 00160 }
float vtkDijkstraImageData::EdgeCost | ( | vtkDataArray * | scalars, | |
int | u, | |||
int | v | |||
) |
Definition at line 459 of file vtkDijkstraImageData.cxx.
References UseInverseDistance, UseInverseExponentialDistance, UseInverseSquaredDistance, and UseSquaredDistance.
Referenced by RunDijkstra().
00460 { 00461 00462 float w; 00463 00464 float dist2 = scalars->GetTuple1(v); //+ fuerzaAtraccion(v, scalars->GetTuple1(v)); 00465 float dist = sqrt(dist2); 00466 if(this->UseInverseDistance) 00467 w = (1.0/dist); 00468 else if(this->UseInverseSquaredDistance) 00469 w = (1.0/(dist2)); 00470 else if(this->UseInverseExponentialDistance) 00471 w = (1.0/exp(dist)); 00472 else if(this->UseSquaredDistance) 00473 w = dist2; 00474 00475 00476 00477 return w; 00478 }
void vtkDijkstraImageData::Execute | ( | ) | [protected] |
Definition at line 662 of file vtkDijkstraImageData.cxx.
References BuildShortestPath(), findClosestPointInGraph(), GetInput(), init(), New(), and RunDijkstra().
00663 { 00664 00665 vtkImageData *inData = this->GetInput(); 00666 vtkPolyData *outData = this->GetOutput(); 00667 00668 00669 00670 00671 // Components turned into x, y and z 00672 if (inData->GetNumberOfScalarComponents() > 3) 00673 { 00674 vtkErrorMacro("This filter can handle upto 3 components"); 00675 return; 00676 } 00677 00678 00679 //printf("*************** vtkDijkstraImageData Execute **************\n\n\n"); 00680 this->init(inData); 00681 //printf("*************** after init ****************\n\n\n"); 00682 00683 int *dim = inData->GetDimensions(); 00684 vtkDataArray *scalars = inData->GetPointData()->GetScalars(); 00685 00686 // find closest point in graph to source and sink if their value is not 0 00687 printf("source ID %i value is %f\n",this->GetSourceID(),scalars->GetTuple1(this->GetSourceID())); 00688 if(scalars->GetTuple1(this->GetSourceID()) == 0) { 00689 00690 vtkFloatArray *copyScalars = vtkFloatArray::New(); 00691 copyScalars->DeepCopy(inData->GetPointData()->GetScalars()); 00692 00693 this->SetSourceID(this->findClosestPointInGraph(copyScalars,this->GetSourceID(),dim[0],dim[1],dim[2])); 00694 00695 copyScalars->Delete(); 00696 printf("NEW source ID %i value is %f\n",this->GetSourceID(),scalars->GetTuple1(this->GetSourceID())); 00697 00698 } 00699 00700 printf("sink ID %i value is %f\n",this->GetSinkID(),scalars->GetTuple1(this->GetSinkID())); 00701 if(scalars->GetTuple1(this->GetSinkID()) == 0) { 00702 vtkFloatArray *copyScalars2 = vtkFloatArray::New(); 00703 copyScalars2->DeepCopy(inData->GetPointData()->GetScalars()); 00704 this->SetSinkID(this->findClosestPointInGraph(copyScalars2,this->GetSinkID(),dim[0],dim[1],dim[2])); 00705 copyScalars2->Delete(); 00706 00707 printf("NEW sink ID %i value is %f\n",this->GetSinkID(),scalars->GetTuple1(this->GetSinkID())); 00708 } 00709 00710 00711 this->RunDijkstra(scalars,this->GetSourceID(),this->GetSinkID()); 00712 00713 this->BuildShortestPath(this->GetSourceID(),this->GetSinkID()); 00714 00715 00716 00717 00718 }
int vtkDijkstraImageData::findClosestPointInGraph | ( | vtkDataArray * | scalars, | |
int | id, | |||
int | dim0, | |||
int | dim1, | |||
int | dim2 | |||
) |
Definition at line 579 of file vtkDijkstraImageData.cxx.
References New().
Referenced by Execute().
00579 { 00580 00581 00582 int kFactor = dim0 * dim1; 00583 int jFactor = dim0; 00584 00585 int numPoints = kFactor * dim2; 00586 vtkIdList* Q = vtkIdList::New(); 00587 Q->InsertNextId(id); 00588 00589 int pointer = 0; 00590 int foundID = -1; 00591 00592 while(Q->GetNumberOfIds() != 0) { 00593 00594 int current = Q->GetId(pointer); 00595 pointer = pointer + 1; 00596 //printf("we are looking at id %i \n",current); 00597 00598 // check to see if we found something in the graph 00599 if(scalars->GetTuple1(current) >0) { 00600 //printf("before return"); 00601 return current; 00602 } else { 00603 // set it to -1 to show that we already looked at it 00604 scalars->SetTuple1(current,-1); 00605 // put the neighbors on the stack 00606 // top 00607 if (current + kFactor <numPoints) { 00608 if(scalars->GetTuple1(current + kFactor) != -1){ 00609 //printf("expand k+1 %i",current + kFactor); 00610 Q->InsertNextId(current+kFactor); 00611 } 00612 } 00613 // bottom 00614 if (current - kFactor >= 0){ 00615 if(scalars->GetTuple1(current - kFactor) != -1){ 00616 //printf("expand k-1 %i", current - kFactor); 00617 Q->InsertNextId(current-kFactor); 00618 } 00619 } 00620 // front 00621 if (current + jFactor < numPoints) { 00622 if(scalars->GetTuple1(current + jFactor) != -1){ 00623 //printf("expand j+1 %i",current + jFactor); 00624 Q->InsertNextId(current + jFactor); 00625 } 00626 } 00627 // back 00628 if (current - jFactor >= 0) { 00629 if(scalars->GetTuple1(current - jFactor) != -1){ 00630 //printf("expand j-1 %i",current - jFactor); 00631 Q->InsertNextId(current - jFactor); 00632 } 00633 } 00634 // left 00635 if (current+1 <numPoints){ 00636 if(scalars->GetTuple1(current + 1) != -1){ 00637 //printf("expand i+1 %i",current+1); 00638 Q->InsertNextId(current + 1); 00639 } 00640 } 00641 // right 00642 if (current -1 >= 0) { 00643 if(scalars->GetTuple1(current - 1) != -1){ 00644 //printf("expand i-1 %i",current - 1); 00645 Q->InsertNextId(current - 1); 00646 } 00647 } 00648 } 00649 } 00650 Q->Delete(); 00651 return foundID; 00652 }
void vtkDijkstraImageData::FindNeighbors | ( | vtkIdList * | list, | |
int | id, | |||
vtkDataArray * | scalars | |||
) |
Definition at line 380 of file vtkDijkstraImageData.cxx.
References GetInput(), and input.
Referenced by RunDijkstra().
00380 { 00381 00382 // find i, j, k for that node 00383 vtkImageData *input = this->GetInput(); 00384 00385 int *dim = input->GetDimensions(); 00386 int numPts = dim[0] * dim[1] * dim[2]; 00387 00388 //printf("vecinos de %i :(",id); 00389 for(int vk = -1; vk<2; vk++) { 00390 for(int vj = -1; vj<2; vj++) { 00391 for(int vi = -1; vi<2; vi++) { 00392 00393 int tmpID = id + (vk * dim[1]*dim[0]) + (vj * dim[0]) + vi; 00394 // check we are in bounds (for volume faces) 00395 if( tmpID >= 0 && tmpID < numPts && tmpID != 0) { 00396 float mask = scalars->GetTuple1(tmpID); 00397 // only add neighbor if it is in the graph 00398 if(mask > 0 && tmpID != id) { 00399 list->InsertUniqueId(tmpID); 00400 //printf("%i,",tmpID); 00401 //printPointData(tmpID); 00402 } 00403 } 00404 } 00405 } 00406 } 00407 //printf(")\n"); 00408 }
float vtkDijkstraImageData::fuerzaAtraccion | ( | int | u, | |
float | w | |||
) |
Definition at line 412 of file vtkDijkstraImageData.cxx.
References GetInput().
00413 { 00414 //1. Identificar las coordenadas del punto de inicio y del punto final (polos) 00415 double coordsSource[3]; 00416 double coordsSink[3]; 00417 double coordsPoint[3]; 00418 00419 this->GetInput()->GetPoint(this->GetSourceID(), coordsSource); 00420 this->GetInput()->GetPoint(this->GetSinkID(), coordsSink); 00421 00422 00423 //2. Identificar las coordenadas del punto al cual se le quiere sacar el potencial electrico 00424 this->GetInput()->GetPoint(u, coordsPoint); 00425 00426 00427 //3 Calcular r1 y r2 00428 00429 float r1 = sqrt((coordsSource[0]-coordsPoint[0])*(coordsSource[0]-coordsPoint[0]) + 00430 (coordsSource[1]-coordsPoint[1])*(coordsSource[1]-coordsPoint[1]) + 00431 (coordsSource[2]-coordsPoint[2])*(coordsSource[2]-coordsPoint[2])); 00432 00433 00434 float r2 = sqrt((coordsSink[0]-coordsPoint[0])*(coordsSink[0]-coordsPoint[0]) + 00435 (coordsSink[1]-coordsPoint[1])*(coordsSink[1]-coordsPoint[1]) + 00436 (coordsSink[2]-coordsPoint[2])*(coordsSink[2]-coordsPoint[2])); 00437 00438 float d = sqrt((coordsSink[0]-coordsSource[0])*(coordsSink[0]-coordsSource[0]) + 00439 (coordsSink[1]-coordsSource[1])*(coordsSink[1]-coordsSource[1]) + 00440 (coordsSink[2]-coordsSource[2])*(coordsSink[2]-coordsSource[2])); 00441 00442 00443 00444 if (r2 < d && r1 > d){ 00445 return w/2; 00446 } else if ( r2 > d && r1 < d){ 00447 return w/2; 00448 } else if (r1 < d && r2 < d){ 00449 return w*w; 00450 } else return w/2; 00451 00452 00453 00454 }
vtkImageData * vtkDijkstraImageData::GetInput | ( | ) |
Definition at line 108 of file vtkDijkstraImageData.cxx.
Referenced by BuildShortestPath(), Execute(), FindNeighbors(), fuerzaAtraccion(), and printPointData().
unsigned long vtkDijkstraImageData::GetMTime | ( | ) |
Definition at line 96 of file vtkDijkstraImageData.cxx.
int vtkDijkstraImageData::GetNextPathNode | ( | ) |
Definition at line 566 of file vtkDijkstraImageData.cxx.
References GetNumberOfPathNodes(), PathPointer, and ShortestPathIdList.
00566 { 00567 this->PathPointer = this->PathPointer + 1; 00568 00569 if(this->PathPointer < this->GetNumberOfPathNodes()) { 00570 //printf("this->GetPathNode(this->PathPointer) %i",this->GetPathNode(this->PathPointer)); 00571 return this->ShortestPathIdList->GetId(this->PathPointer); 00572 } else { 00573 return -1; 00574 } 00575 }
int vtkDijkstraImageData::GetNumberOfPathNodes | ( | ) |
Definition at line 561 of file vtkDijkstraImageData.cxx.
References ShortestPathIdList.
Referenced by GetNextPathNode().
00561 { 00562 return this->ShortestPathIdList->GetNumberOfIds(); 00563 }
vtkIdList * vtkDijkstraImageData::GetShortestPathIdList | ( | ) |
Definition at line 531 of file vtkDijkstraImageData.cxx.
References ShortestPathIdList.
Referenced by wxPathologyWidget_01::OnBtnExtractAxis().
00532 { 00533 return this->ShortestPathIdList; 00534 }
void vtkDijkstraImageData::init | ( | vtkImageData * | inData | ) |
Definition at line 113 of file vtkDijkstraImageData.cxx.
References CreateGraph(), New(), Parent, PQ, ShortestPathIdList, and Visited.
Referenced by Execute().
00114 { 00115 00116 if (this->ShortestPathIdList) 00117 this->ShortestPathIdList->Delete(); 00118 00119 if (this->Parent) 00120 this->Parent->Delete(); 00121 if (this->Visited) 00122 this->Visited->Delete(); 00123 if (this->PQ) 00124 this->PQ->Delete(); 00125 00126 this->ShortestPathIdList = vtkIdList::New(); 00127 this->Parent = vtkIntArray::New(); 00128 this->Visited = vtkIntArray::New(); 00129 this->PQ = vtkPriorityQueue::New(); 00130 00131 00132 CreateGraph(inData); 00133 00134 00135 int numPoints = inData->GetNumberOfPoints(); 00136 00137 this->Parent->SetNumberOfComponents(1); 00138 this->Parent->SetNumberOfTuples(numPoints); 00139 this->Visited->SetNumberOfComponents(1); 00140 this->Visited->SetNumberOfTuples(numPoints); 00141 00142 }
void vtkDijkstraImageData::InitSingleSource | ( | int | startv | ) |
Definition at line 365 of file vtkDijkstraImageData.cxx.
References Parent, PQ, and Visited.
Referenced by RunDijkstra().
00366 { 00367 for (int v = 0; v < this->GetNumberOfInputPoints(); v++) 00368 { 00369 this->Parent->SetValue(v, -1); 00370 this->Visited->SetValue(v, 0); 00371 } 00372 PQ->DeleteId(startv); 00373 // re-insert the source with priority 0 00374 PQ->Insert(0,startv); 00375 //printf("priority of startv %f",PQ->GetPriority(startv)); 00376 }
void vtkDijkstraImageData::InitTraversePath | ( | ) |
Definition at line 556 of file vtkDijkstraImageData.cxx.
References PathPointer.
00556 { 00557 this->PathPointer = -1; 00558 }
vtkDijkstraImageData * vtkDijkstraImageData::New | ( | ) | [static] |
Definition at line 16 of file vtkDijkstraImageData.cxx.
Referenced by BuildShortestPath(), CreateGraph(), Execute(), findClosestPointInGraph(), init(), wxPathologyWidget_01::OnBtnExtractAxis(), and RunDijkstra().
00017 { 00018 00019 00020 00021 00022 // First try to create the object from the vtkObjectFactory 00023 vtkObject* ret = vtkObjectFactory::CreateInstance("vtkDijkstraImageData"); 00024 if(ret) 00025 { 00026 return (vtkDijkstraImageData*)ret; 00027 } 00028 // If the factory was unable to create the object, then create it here. 00029 return new vtkDijkstraImageData; 00030 }
void vtkDijkstraImageData::operator= | ( | const vtkDijkstraImageData & | ) | [private] |
void vtkDijkstraImageData::printPointData | ( | int | pointID | ) |
Definition at line 538 of file vtkDijkstraImageData.cxx.
References GetInput().
Referenced by BuildShortestPath().
00539 { 00540 double coords[3]; 00541 00542 this->GetInput()->GetPoint(pointID, coords); 00543 double scalar = this->GetInput()->GetPointData()->GetScalars()->GetTuple1(pointID); 00544 00545 printf("Punto ID: %i ",pointID); 00546 printf("Coords[%.0f, %.0f, %.0f] ", coords[0], coords[1], coords[2]); 00547 printf("Scalar: %.2f\n", scalar); 00548 00549 }
void vtkDijkstraImageData::PrintSelf | ( | ostream & | os, | |
vtkIndent | indent | |||
) |
Definition at line 722 of file vtkDijkstraImageData.cxx.
00723 { 00724 Superclass::PrintSelf(os,indent); 00725 00726 os << indent << "Source ID: ( " 00727 << this->GetSourceID() << " )\n"; 00728 00729 os << indent << "Sink ID: ( " 00730 << this->GetSinkID() << " )\n"; 00731 }
void vtkDijkstraImageData::RunDijkstra | ( | vtkDataArray * | scalars, | |
int | source, | |||
int | sink | |||
) |
Definition at line 210 of file vtkDijkstraImageData.cxx.
References EdgeCost(), FindNeighbors(), InitSingleSource(), New(), Parent, PQ, StopWhenEndReached, UseInverseDistance, UseInverseExponentialDistance, UseInverseSquaredDistance, Visited, and vtkFloatingPointType.
Referenced by Execute().
00211 { 00212 00213 int i, u, v; 00214 00215 printf("tipo de ponderacion de pesos : linear %i, squared %i, exponential %i\n",this->UseInverseDistance,this->UseInverseSquaredDistance,this->UseInverseExponentialDistance); 00216 00217 00218 00219 //------------------------------------------------------------------------------- 00220 // INICIALIZACION. 00221 //------------------------------------------------------------------------------- 00222 00223 // 1. Se marcan todos los vertices del grafo como no visitados. 00224 InitSingleSource(startv); 00225 00226 // 2. Se marca el punto de arranque como visitado 00227 this->Visited->SetValue(startv, 1); 00228 00229 // 3. Se obtiene el tamanio inicial de los vertices no visitados 00230 int initialSize = PQ->GetNumberOfItems(); 00231 int size = initialSize; 00232 int stop = 0; 00233 00234 //Nota: PQ contiene los nodos del grafo no evaluados. 00235 //Segun Dijkstra, el algoritmo termina cuando todos los nodos tienen un valor de distancia minima. 00236 00237 //------------------------------------------------------------------------ 00238 // PARA TODOS LOS VERTICES EN PQ (SIN EVALUAR) 00239 //------------------------------------------------------------------------ 00240 while ((PQ->GetNumberOfItems() > 0) && !stop) 00241 { 00242 00243 this->UpdateProgress (0.5 + (float) (initialSize - size) / ((float) 2 * initialSize)); 00244 00245 00246 vtkFloatingPointType u_weight; 00247 00248 //---------------------------------------------------------------------- 00249 //1. Aqui obtiene el siguiente punto a evaluar. Al retirarlo de la cola 00250 // se asume que ya ha sido evaluado, se evaluaran sus vecinos. 00251 // u is now in S since the shortest path to u is determined 00252 //---------------------------------------------------------------------- 00253 #if (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION == 0) 00254 u = PQ->Pop(u_weight,0); 00255 #else 00256 u = PQ->Pop(0, u_weight); 00257 #endif 00258 //printf("Evaluando el nodo %i con prioridad %.2f\n",u,u_weight); 00259 //printPointData(u); 00260 00261 00262 //----------------------------------------- 00263 //2. Se marca "u" como ya visitado. 00264 //----------------------------------------- 00265 this->Visited->SetValue(u, 1); 00266 00267 00268 00269 //------------------------------------------------------------------------------------ 00270 //3. Si u es el nodo final el algoritmo se detiene. (despues de evaluar sus vecinos) 00271 //------------------------------------------------------------------------------------ 00272 if (u == endv && StopWhenEndReached) 00273 stop = 1; 00274 00275 // Update all vertices v neighbors to u 00276 // find the neighbors of u 00277 00278 00279 00280 //----------------------------------------- 00281 //4. Encontrar los vecinos de u 00282 //----------------------------------------- 00283 vtkIdList *list = vtkIdList::New(); 00284 this->FindNeighbors(list,u,scalars); 00285 00286 //printf("%i tiene %i vecinos\n",u,list->GetNumberOfIds()); 00287 00288 //----------------------------------------- 00289 // 5. Para cada vecino .... 00290 //----------------------------------------- 00291 for (i = 0; i < list->GetNumberOfIds(); i++) 00292 { 00293 00294 //--------------------------------------------------------------------- 00295 // 5.1 Se obtiene su ID (el indice es el orden en la lista de vecinos) 00296 //--------------------------------------------------------------------- 00297 v = list->GetId(i); 00298 //printf("---> evaluando el vecino % i\n",v); 00299 00300 // s is the set of vertices with determined shortest path...do not 00301 // use them again 00302 00303 //----------------------------------------------------------------- 00304 // 5.2 Si ya ha sido visitado se descarta... 00305 //----------------------------------------------------------------- 00306 if (this->Visited->GetValue(v) != 1) 00307 { 00308 //printf("---> ---> el vecino %i no ha sido visitado\n",v); 00309 // Only relax edges where the end is not in s and edge 00310 // is in the front 00311 //--------------------------------------------------- 00312 // 5.2.1 Se obtiene el COSTO W 00313 //--------------------------------------------------- 00314 float w = EdgeCost(scalars, u, v); 00315 00316 //--------------------------------------------------- 00317 // 5.2.2 00318 //--------------------------------------------------- 00319 float v_weight = this->PQ->GetPriority(v); 00320 if(v == endv) { 00321 //printf("we have found endv %i, its weight is %f, neighbor is %i , weight is %f, edge weight is %f\n",v,v_weight,u,u_weight,w); 00322 //stop=1; 00323 //break; 00324 } 00325 00326 //printf("---> ---> el costo de %i es %.2f\n",v,(w+u_weight)); 00327 //printf("---> ---> el costo previo de %i es %.2f\n",v,v_weight); 00328 00329 00330 //------------------------------------------------------------------------------- 00331 // 5.2.3 Si se encuentra un camino menor, se reajusta el costo (Node Relaxation) 00332 //------------------------------------------------------------------------------- 00333 if (v_weight > (u_weight + w)) 00334 { 00335 // 5.2.3.1 Se elimina V de la cola de nodos por evaluar (PQ). Porque se encontro un costo mas bajo 00336 this->PQ->DeleteId(v); 00337 00338 // 5.2.3.2 Se inserta nuevamente V en la cola de nodos por evaluar con el nuevo costo. 00339 this->PQ->Insert((u_weight + w),v); 00340 //printf("---> ---> reajustando el peso de %i a %.2f\n",v,u_weight + w); 00341 //printf("u_weight=%.2f\n",u_weight); 00342 00343 // 5.2.3.3 se coloca V conectado con U (esto sirve para reconstruir el camino minimo) 00344 00345 this->Parent->SetValue(v, u); 00346 //printf("setting parent of %i to be %i",v,u); 00347 } 00348 } 00349 else{ 00350 //printf("---> el vecino %i ya se visito\n",v); 00351 } 00352 } 00353 00354 //------------------------------------------------------- 00355 // 6. Liberar la memoria ocupada por la lista de vecinos 00356 //------------------------------------------------------- 00357 list->Delete(); 00358 size--; 00359 } 00360 this->PQ->Delete(); 00361 this->Visited->Delete(); 00362 }
virtual void vtkDijkstraImageData::SetBoundaryScalars | ( | vtkDataArray * | ) | [virtual] |
void vtkDijkstraImageData::SetInput | ( | vtkImageData * | data | ) |
Definition at line 104 of file vtkDijkstraImageData.cxx.
Referenced by wxPathologyWidget_01::OnBtnExtractAxis().
vtkDijkstraImageData::vtkGetMacro | ( | UseSquaredDistance | , | |
int | ||||
) |
vtkDijkstraImageData::vtkGetMacro | ( | UseInverseExponentialDistance | , | |
int | ||||
) |
vtkDijkstraImageData::vtkGetMacro | ( | UseInverseSquaredDistance | , | |
int | ||||
) |
vtkDijkstraImageData::vtkGetMacro | ( | UseInverseDistance | , | |
int | ||||
) |
vtkDijkstraImageData::vtkGetMacro | ( | NumberOfGraphNodes | , | |
int | ||||
) |
vtkDijkstraImageData::vtkGetMacro | ( | NumberOfInputPoints | , | |
int | ||||
) |
vtkDijkstraImageData::vtkGetMacro | ( | SinkID | , | |
int | ||||
) |
vtkDijkstraImageData::vtkGetMacro | ( | SourceID | , | |
int | ||||
) |
vtkDijkstraImageData::vtkGetObjectMacro | ( | BoundaryScalars | , | |
vtkDataArray | ||||
) |
vtkDijkstraImageData::vtkGetObjectMacro | ( | Parent | , | |
vtkIntArray | ||||
) |
vtkDijkstraImageData::vtkSetMacro | ( | UseSquaredDistance | , | |
int | ||||
) |
vtkDijkstraImageData::vtkSetMacro | ( | UseInverseExponentialDistance | , | |
int | ||||
) |
vtkDijkstraImageData::vtkSetMacro | ( | UseInverseSquaredDistance | , | |
int | ||||
) |
vtkDijkstraImageData::vtkSetMacro | ( | UseInverseDistance | , | |
int | ||||
) |
vtkDijkstraImageData::vtkSetMacro | ( | NumberOfGraphNodes | , | |
int | ||||
) |
vtkDijkstraImageData::vtkSetMacro | ( | NumberOfInputPoints | , | |
int | ||||
) |
vtkDijkstraImageData::vtkSetMacro | ( | SinkID | , | |
int | ||||
) |
vtkDijkstraImageData::vtkSetMacro | ( | SourceID | , | |
int | ||||
) |
vtkDijkstraImageData::vtkTypeMacro | ( | vtkDijkstraImageData | , | |
vtkPolyDataSource | ||||
) |
vtkDataArray* vtkDijkstraImageData::BoundaryScalars |
Definition at line 104 of file vtkDijkstraImageData.h.
Referenced by vtkDijkstraImageData(), and ~vtkDijkstraImageData().
vtkImageData* vtkDijkstraImageData::input |
Definition at line 134 of file vtkDijkstraImageData.h.
Referenced by FindNeighbors().
vtkCellArray* vtkDijkstraImageData::lineas |
Definition at line 133 of file vtkDijkstraImageData.h.
Referenced by BuildShortestPath(), and vtkDijkstraImageData().
FILE* vtkDijkstraImageData::logger [protected] |
Definition at line 151 of file vtkDijkstraImageData.h.
Referenced by vtkDijkstraImageData().
Definition at line 108 of file vtkDijkstraImageData.h.
Definition at line 107 of file vtkDijkstraImageData.h.
Referenced by vtkDijkstraImageData().
vtkIntArray* vtkDijkstraImageData::Parent |
Definition at line 122 of file vtkDijkstraImageData.h.
Referenced by BuildShortestPath(), init(), InitSingleSource(), RunDijkstra(), vtkDijkstraImageData(), and ~vtkDijkstraImageData().
Definition at line 127 of file vtkDijkstraImageData.h.
Referenced by GetNextPathNode(), InitTraversePath(), and vtkDijkstraImageData().
vtkPriorityQueue* vtkDijkstraImageData::PQ |
Definition at line 117 of file vtkDijkstraImageData.h.
Referenced by CreateGraph(), init(), InitSingleSource(), RunDijkstra(), and vtkDijkstraImageData().
vtkPoints* vtkDijkstraImageData::puntos |
Definition at line 132 of file vtkDijkstraImageData.h.
Referenced by BuildShortestPath(), and vtkDijkstraImageData().
vtkIdList* vtkDijkstraImageData::ShortestPathIdList |
Definition at line 120 of file vtkDijkstraImageData.h.
Referenced by BuildShortestPath(), GetNextPathNode(), GetNumberOfPathNodes(), GetShortestPathIdList(), init(), vtkDijkstraImageData(), and ~vtkDijkstraImageData().
Definition at line 101 of file vtkDijkstraImageData.h.
Referenced by wxPathologyWidget_01::OnBtnExtractAxis(), and vtkDijkstraImageData().
Definition at line 98 of file vtkDijkstraImageData.h.
Referenced by wxPathologyWidget_01::OnBtnExtractAxis(), and vtkDijkstraImageData().
Definition at line 129 of file vtkDijkstraImageData.h.
Referenced by RunDijkstra(), and vtkDijkstraImageData().
Definition at line 110 of file vtkDijkstraImageData.h.
Referenced by EdgeCost(), RunDijkstra(), and vtkDijkstraImageData().
Definition at line 112 of file vtkDijkstraImageData.h.
Referenced by EdgeCost(), RunDijkstra(), and vtkDijkstraImageData().
Definition at line 111 of file vtkDijkstraImageData.h.
Referenced by EdgeCost(), RunDijkstra(), and vtkDijkstraImageData().
Definition at line 113 of file vtkDijkstraImageData.h.
Referenced by EdgeCost(), and vtkDijkstraImageData().
vtkIntArray* vtkDijkstraImageData::Visited |
Definition at line 124 of file vtkDijkstraImageData.h.
Referenced by init(), InitSingleSource(), RunDijkstra(), and vtkDijkstraImageData().