@@ -458,28 +458,50 @@ void InterventionalRadiologyController<DataTypes>::interventionalRadiologyComput
458
458
const Real& xend)
459
459
460
460
{
461
- // Step 1 = put the noticeable Nodes
461
+ // Step 1 => put the noticeable Nodes
462
+ // Step 2 => add the beams given the sampling parameters
462
463
double maxAbsLength=0.0 ;
463
- for (unsigned int i=0 ; i<m_instrumentsList.size (); i++)
464
+ Real xSampling = 0.0 ;
465
+ for (auto i=0 ; i<m_instrumentsList.size (); i++)
464
466
{
465
467
type::vector<Real> xP_noticeable_I;
466
468
type::vector< int > density_I;
467
469
m_instrumentsList[i]->getSamplingParameters (xP_noticeable_I, density_I);
468
470
469
- for (unsigned int j=0 ; j<xP_noticeable_I.size (); j++)
471
+ // check each interval of noticeable point to see if they go out (>0) and use corresponding density to sample the interval.
472
+ for (unsigned int j=0 ; j<xP_noticeable_I.size ()-1 ; j++)
470
473
{
474
+ const Real xP = xP_noticeable_I[j];
475
+ const Real nxP = xP_noticeable_I[j + 1 ];
476
+
471
477
// compute the corresponding abs curv of this "noticeable point" on the combined intrument
472
- Real curvAbs_xP = xBegin[i] + xP_noticeable_I[j];
473
- if (curvAbs_xP>0.0 ) // all the noticiable point that have a negative curv abs are not simulated => considered as outside of the patient...
478
+ const Real curvAbs_xP = xBegin[i] + xP;
479
+ const Real curvAbs_nxP = xBegin[i] + nxP;
480
+
481
+ // compute interval between next point and previous one (0 for the first iter)
482
+ const Real curvAbs_interval = (curvAbs_nxP - xSampling);
483
+
484
+ if (curvAbs_interval > 0 )
474
485
{
475
- newCurvAbs.push_back (curvAbs_xP);
486
+ // compute the number of point of the emerged interval (if all the interval is emerged, i.e >0 , numNewNodes == density[j])
487
+ Real ratio = Real (density_I[j]) / (nxP - xP);
488
+ int numNewNodes = int (floor (curvAbs_interval * ratio)); // if density == 0, no sampling (numNewNodes == 0)
476
489
477
- if (curvAbs_xP > maxAbsLength)
478
- maxAbsLength=curvAbs_xP;
490
+ // Add the new points in reverse order
491
+ for (int k = numNewNodes; k>0 ; k--)
492
+ {
493
+ auto value = curvAbs_nxP - (k / ratio);
494
+ newCurvAbs.push_back (value);
495
+ }
496
+
497
+ // Add j+1 bound point
498
+ newCurvAbs.push_back (curvAbs_nxP);
499
+ xSampling = curvAbs_nxP;
479
500
}
480
501
}
481
502
}
482
503
504
+
483
505
// Step 1(bis) = add Nodes the curv_abs of the rigid parts border
484
506
// When there are rigid segments, # of dofs is different than # of edges and beams
485
507
const type::vector< Real > *rigidCurvAbs = &d_rigidCurvAbs.getValue ();
@@ -510,34 +532,6 @@ void InterventionalRadiologyController<DataTypes>::interventionalRadiologyComput
510
532
}
511
533
}
512
534
513
- // Step 2 => add the beams given the sampling parameters
514
- Real xSampling = 0.0 ;
515
- for (unsigned int i=0 ; i<m_instrumentsList.size (); i++)
516
- {
517
- type::vector<Real> xPNoticeableI;
518
- type::vector< int > density_I;
519
- m_instrumentsList[i]->getSamplingParameters (xPNoticeableI, density_I);
520
-
521
- for (unsigned int j=0 ; j<density_I.size (); j++){
522
-
523
- // compute the corresponding abs curv of this "noticeable point" on the combined intrument
524
- Real curvAbsxP = xBegin[i] + xPNoticeableI[j+1 ];
525
-
526
- // use density parameter (size = xP_noticeable_I -1 )
527
- if (curvAbsxP > xSampling && density_I[j]>0 )
528
- {
529
- Real ratio = (Real)density_I[j] / (xPNoticeableI[j+1 ] - xPNoticeableI[j]) ;
530
- int numNewNodes = (int )floor ( (curvAbsxP- xSampling) *ratio) ;
531
-
532
- for (int k=0 ; k<numNewNodes; k++)
533
- {
534
- newCurvAbs.push_back ( xPNoticeableI[j+1 ] + xBegin[i] - (k+1 ) * (1 /ratio) );
535
- }
536
- xSampling = curvAbsxP;
537
- }
538
- }
539
- }
540
-
541
535
sortCurvAbs (newCurvAbs, idInstrumentTable);
542
536
}
543
537
0 commit comments