void OnboardEscalatorInSim::CreateEntryPoint() { int nDeckCount = (int)m_pDevice->GetDeckPoint().size(); if (nDeckCount < 2) //less than two point can not calculate entry point return; int nPointCount = m_realpath.getCount(); if (nPointCount < 2) return; CPoint2008 cellPt(GRID_WIDTH,GRID_HEIGHT,0.0); double dDist = cellPt.length();//offset make be able to next cell //first entry point DeckPoint deckFirstPt = m_pDevice->GetDeckPoint().front(); CPoint2008 firstDir(m_realpath.getPoint(0) - m_realpath.getPoint(1)); firstDir.setZ(0.0); firstDir.Normalize(); OnboardCellInSim* pFirstCell = GetGround(deckFirstPt.first)->getCell(m_realpath.getPoint(0)); CPoint2008 firstLocate = pFirstCell->getLocation(); CPoint2008 firstEntryPoint = firstLocate + firstDir*dDist; OnboardCellInSim* pFirstEntryCell = GetGround(deckFirstPt.first)->getCell(firstEntryPoint); m_entryPointList.push_back(pFirstEntryCell); //back entry point DeckPoint deckBackPt = m_pDevice->GetDeckPoint().back(); CPoint2008 backPt = m_realpath.getPoint(nPointCount - 1); CPoint2008 prePt = m_realpath.getPoint(nPointCount - 2); CPoint2008 backDir(backPt - prePt); backDir.setZ(0.0); backDir.Normalize(); backPt += backDir*dDist; OnboardCellInSim* pBackCell = GetGround(deckBackPt.first)->getCell(backPt); CPoint2008 backLocate = pBackCell->getLocation(); CPoint2008 backEntryPoint = backLocate + backDir*(dDist/2); OnboardCellInSim* pBackEntryCell = GetGround(deckBackPt.first)->getCell(backEntryPoint); m_entryPointList.push_back(pBackEntryCell); }
// Make one closed path by adding the points of the inner path void Stroker::endStroke() { switch(endType_) { // Simplest case, just add the inner points case cButtEnd: { for(vplUint i = innerPoints_.getItemCount(); i > 0;i-=2) { outerPoints_.add(innerPoints_[i - 2]); outerPoints_.add(innerPoints_[i - 1]); } // Close the path outerPoints_.add(outerPoints_[0]); outerPoints_.add(outerPoints_[1]); } break; // End outer path with an arc, then add the inner points. // Finalize with a closing arc to the first point case cRoundEnd: { Winding winding = determineWinding(normal_,invert(normal_)); generateArc(currentPoint_,normal_,invert(normal_), winding,&outerPoints_); for(vplUint i = innerPoints_.getItemCount(); i > 0;i-=2) { outerPoints_.add(innerPoints_[i - 2]); outerPoints_.add(innerPoints_[i - 1]); } winding = determineWinding(invert(firstNormal_),firstNormal_); generateArc(firstPoint_,invert(firstNormal_),firstNormal_, winding,&outerPoints_); // Close the path outerPoints_.add(outerPoints_[0]); outerPoints_.add(outerPoints_[1]); } break; // Add a rectangle with sides stroke width/2 x stroke width case cSquareEnd: { // Use the normals for calculation of the ends Vector dir(-normal_.y_,normal_.x_); Vector firstDir(-firstNormal_.y_,firstNormal_.x_); dir.normalize(); firstDir.normalize(); scale_.transform(dir); scale_.transform(firstDir); dir *= size_ / 2; firstDir *= size_ / 2; Vector v1 = currentPoint_ + normal_ + dir; Vector v2 = currentPoint_ - normal_ + dir; addPoint(&outerPoints_,v1); addPoint(&outerPoints_,v2); for(vplUint i = innerPoints_.getItemCount(); i > 0;i-=2) { outerPoints_.add(innerPoints_[i - 2]); outerPoints_.add(innerPoints_[i - 1]); } v1 = firstPoint_ - firstNormal_ - firstDir; v2 = firstPoint_ + firstNormal_ - firstDir; addPoint(&outerPoints_,v1); addPoint(&outerPoints_,v2); // Close the path outerPoints_.add(outerPoints_[0]); outerPoints_.add(outerPoints_[1]); } break; } innerPoints_.clear(); }