@@ -307,45 +307,46 @@ void MultiAdaptiveBeamMapping< TIn, TOut>::init()
307307 // fill topology :
308308 _topology->clear ();
309309 _topology->cleanup ();
310-
311- unsigned int numSeg, numLinesInstrument;
312- numSeg=0 ;
313- InReal DX=0 ;
314- // we chose the collision parameters of the most discretized instrument
310+
311+ // we build the topology according to the description(s) of the tool(s)
312+ // this will ensure that we have enough DOFs/edges for the worst deployment cases
313+ SReal previousXAbs = 0.0 ;
314+ SReal previousNbEdges = 0.0 ;
315+ _topology->addPoint ( 0.0 , 0 , 0 );
315316 for (unsigned int i=0 ; i<m_instrumentList.size (); i++)
316317 {
317318 InReal dx=0 ;
319+ unsigned int numLinesInstrument = 0 ;
320+
318321 m_instrumentList[i]->getNumberOfCollisionSegment (dx, numLinesInstrument);
319- if ( numSeg < numLinesInstrument ){
320- numSeg = numLinesInstrument;
321- DX=dx;
322+
323+ // add the DOFs and edges according to the number set in the tool
324+ // DOFs
325+ for (unsigned int i=1 ; i<numLinesInstrument+1 ; i++)
326+ {
327+ Real px = i*dx;
328+ _topology->addPoint ( previousXAbs + px, 0 , 0 );
322329 }
330+ // Edges
331+ for (unsigned int i=0 ; i<numLinesInstrument; i++)
332+ {
333+ _topology->addEdge (previousNbEdges + i, previousNbEdges + i+1 );
334+ }
335+
336+ previousXAbs += (numLinesInstrument+1 )*dx;
337+ previousNbEdges += numLinesInstrument;
323338 }
324-
325- msg_info () << " numSeg found in MultiAdaptiveBeamMapping=" << numSeg;
326-
327-
328- // add points
329- for ( int i=0 ; i<(int )numSeg+1 ; i++)
330- {
331- Real px = i*DX;
332- _topology->addPoint ( px, 0 , 0 );
333- }
334- // add segments
335- for (int i=0 ; i<(int )numSeg; i++)
336- {
337- _topology->addEdge (i,i+1 );
338- }
339-
339+ const auto totalNbDOFs = previousNbEdges + 1 ;
340+
340341 // create edge around vertex array
341342 _topology->init ();
342343
343344 // resize Mstate
344- this ->toModel ->resize (numSeg+ 1 );
345+ this ->toModel ->resize (totalNbDOFs );
345346
346347 // resize the internal list of the collision points ( for each point : [x_curv on the global wire , id of the corresponding instrument]
347- _xPointList.resize (numSeg+ 1 );
348- _idm_instrumentList.resize (numSeg+ 1 );
348+ _xPointList.resize (totalNbDOFs );
349+ _idm_instrumentList.resize (totalNbDOFs );
349350}
350351
351352
0 commit comments