// Function: GetPointsFromPolygon
// Purpose :
//==================================================
-static Handle(TColgp_HArray1OfPnt) GetPointsFromPolygon (const TopoDS_Edge& theEdge,
- const Standard_Real theDeflection)
+static Handle(TColgp_HArray1OfPnt) GetPointsFromPolygon (const TopoDS_Edge& theEdge)
{
Handle(TColgp_HArray1OfPnt) aResultPoints;
- Standard_Real fi, la;
- Handle(Geom_Curve) CC3d = BRep_Tool::Curve (theEdge, fi, la);
-
TopLoc_Location aLocation;
Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (theEdge, aLocation);
if (!aPolygon.IsNull())
{
- Standard_Boolean isOK = aPolygon->Deflection() <= theDeflection;
- isOK = isOK || (CC3d.IsNull());
- if (isOK)
+ const TColgp_Array1OfPnt& aNodes = aPolygon->Nodes();
+ aResultPoints = new TColgp_HArray1OfPnt (1, aNodes.Length());
+ if (aLocation.IsIdentity())
{
- const TColgp_Array1OfPnt& aNodes = aPolygon->Nodes();
- aResultPoints = new TColgp_HArray1OfPnt (1, aNodes.Length());
- if (aLocation.IsIdentity())
+ for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
{
- for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
- {
- aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId));
- }
+ aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId));
}
- else
+ }
+ else
+ {
+ for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
{
- for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
- {
- aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId).Transformed (aLocation));
- }
+ aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId).Transformed (aLocation));
}
- return aResultPoints;
}
+ return aResultPoints;
}
Handle(Poly_Triangulation) aTriangulation;
BRep_Tool::PolygonOnTriangulation (theEdge, anHIndices, aTriangulation, aLocation);
if (!anHIndices.IsNull())
{
- Standard_Boolean isOK = anHIndices->Deflection() <= theDeflection;
- isOK = isOK || (CC3d.IsNull());
- if (isOK)
- {
- const TColStd_Array1OfInteger& anIndices = anHIndices->Nodes();
- const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
+ const TColStd_Array1OfInteger& anIndices = anHIndices->Nodes();
+ const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
- aResultPoints = new TColgp_HArray1OfPnt (1, anIndices.Length());
+ aResultPoints = new TColgp_HArray1OfPnt (1, anIndices.Length());
- if (aLocation.IsIdentity())
+ if (aLocation.IsIdentity())
+ {
+ for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
{
- for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
- {
- aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)));
- }
+ aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)));
}
- else
+ }
+ else
+ {
+ for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
{
- for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
- {
- aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)).Transformed (aLocation));
- }
+ aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)).Transformed (aLocation));
}
- return aResultPoints;
}
+ return aResultPoints;
}
return aResultPoints;
}
}
// try to get points from existing polygons
- Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (anEdge, theDeflection);
+ Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (anEdge);
if (!aPoints.IsNull() && aPoints->Length() > 0)
{
theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);