MCPcopy Create free account
hub / github.com/Kitware/VTK / FollowLoopOrientation

Method FollowLoopOrientation

Filters/General/vtkIntersectionPolyDataFilter.cxx:1518–1593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1516//------------------------------------------------------------------------------
1517
1518int vtkIntersectionPolyDataFilter::Impl ::FollowLoopOrientation(vtkPolyData* pd, simPolygon* loop,
1519 vtkIdType* nextCell, vtkIdType nextPt, vtkIdType prevPt, vtkIdList* pointCells)
1520{
1521 // Follow the orientation of this loop
1522 int foundcell = 0;
1523 double newcell = 0;
1524 double minangle = VTK_DOUBLE_MAX;
1525 for (vtkIdType i = 0; i < pointCells->GetNumberOfIds(); i++)
1526 {
1527 vtkIdType cellId = pointCells->GetId(i);
1528 if (*nextCell != cellId)
1529 {
1530 // Get orientation for newly selected line
1531 int neworient = this->GetLoopOrientation(pd, cellId, prevPt, nextPt);
1532
1533 // If the orientation of the newly selected line is correct, check
1534 // the angle of this it will make with the previous line
1535 if (neworient == loop->orientation)
1536 {
1537 foundcell = 1;
1538 double l0pt0[3], l0pt1[3], l1pt0[3], l1pt1[3];
1539 pd->GetPoint(prevPt, l0pt0);
1540 pd->GetPoint(nextPt, l0pt1);
1541 vtkSmartPointer<vtkIdList> specialCellPoints = vtkSmartPointer<vtkIdList>::New();
1542 pd->GetCellPoints(cellId, specialCellPoints);
1543 if (specialCellPoints->GetId(0) == nextPt)
1544 {
1545 pd->GetPoint(specialCellPoints->GetId(1), l1pt0);
1546 pd->GetPoint(specialCellPoints->GetId(0), l1pt1);
1547 }
1548 else
1549 {
1550 pd->GetPoint(specialCellPoints->GetId(0), l1pt0);
1551 pd->GetPoint(specialCellPoints->GetId(1), l1pt1);
1552 }
1553 double edge1[3], edge2[3];
1554 for (int j = 0; j < 2; j++)
1555 {
1556 edge1[j] = l0pt1[j] - l0pt0[j];
1557 edge2[j] = l1pt1[j] - l1pt0[j];
1558 }
1559 edge1[2] = 0.;
1560 edge2[2] = 0.;
1561 vtkMath::Normalize(edge1);
1562 vtkMath::Normalize(edge2);
1563 double dot = vtkMath::Dot(edge1, edge2);
1564 if (dot > 1.0)
1565 {
1566 dot = 1.0;
1567 }
1568 else if (dot < -1.0)
1569 {
1570 dot = -1.0;
1571 }
1572 double angle = vtkMath::DegreesFromRadians(acos(dot));
1573 if (angle < minangle)
1574 {
1575 minangle = angle;

Callers 1

GetSingleLoopMethod · 0.95

Calls 9

GetLoopOrientationMethod · 0.80
NewFunction · 0.50
NormalizeFunction · 0.50
DotFunction · 0.50
acosFunction · 0.50
GetNumberOfIdsMethod · 0.45
GetIdMethod · 0.45
GetPointMethod · 0.45
GetCellPointsMethod · 0.45

Tested by

no test coverage detected