TopoDS_Shape aTestedShape;
aTestedShape.TShape (aShape.TShape());
aTestedShape.Orientation (isReverse ? TopAbs_REVERSED : TopAbs_FORWARD);
- Standard_Boolean isTessellate (Standard_False);
switch (ShapeType[i]) {
case TopAbs_FACE:
{
break;
}
- if (aTri.IsNull())
- isTessellate = Standard_True;
- // Check the existing deflection
- else if (aTri->Deflection() > aDeflection+ Precision::Confusion())
- isTessellate = Standard_True;
- if (isTessellate) {
- // Triangulate the face by the standard OCC mesher
- BRepMesh_IncrementalMesh IM(aFace, aDeflection, Standard_False, theDeflAngle);
- aTri = BRep_Tool::Triangulation (aFace, aLoc);
- }
if (aTri.IsNull() == Standard_False) {
TopoDS_Shape aTestedShapeRev = aTestedShape;
aTestedShapeRev.Orientation (isReverse ?
{
const TopoDS_Edge& aEdge = TopoDS::Edge (aShape);
if (aEdge.IsNull() == Standard_False) {
- Handle(Poly_Polygon3D) aPol = BRep_Tool::Polygon3D (aEdge, aLoc);
-
if (aRelMap.IsBound (aTestedShape)) {
aTShapeNode = aRelMap(aTestedShape);
break;
aTShapeNode = aRelMap(aTestedShape);
break;
}
-
- if (aPol.IsNull())
- isTessellate = Standard_True;
- // Check the existing deflection
- else if (aPol->Deflection() > aDeflection+ Precision::Confusion()
- && BRep_Tool::IsGeometric(aEdge))
- isTessellate = Standard_True;
-
- if (isTessellate && BRep_Tool::IsGeometric(aEdge)) {
- //try to find PolygonOnTriangulation
- Handle(Poly_PolygonOnTriangulation) aPT;
- Handle(Poly_Triangulation) aT;
- TopLoc_Location aL;
-
- Standard_Boolean found = Standard_False;
- for(i = 1; ; i++) {
-
- BRep_Tool::PolygonOnTriangulation(aEdge, aPT, aT, aL, i);
-
- if(aPT.IsNull() || aT.IsNull()) break;
-
- if(aPT->Deflection() <= aDeflection + Precision::Confusion() &&
- aPT->HasParameters()) {
- found = Standard_True;
- break;
- }
+ //try to find PolygonOnTriangulation
+ Handle(Poly_PolygonOnTriangulation) aPT;
+ Handle(Poly_Triangulation) aT;
+ TopLoc_Location aL;
+ BRep_Tool::PolygonOnTriangulation(aEdge, aPT, aT, aL);
+
+ // If PolygonOnTriangulation was found -> get the Polygon3D
+ Handle(Poly_Polygon3D) aPol;
+ if(!aPT.IsNull() && !aT.IsNull() && aPT->HasParameters()) {
+ BRepAdaptor_Curve aCurve(aEdge);
+ Handle(TColStd_HArray1OfReal) aPrs = aPT->Parameters();
+ Standard_Integer nbNodes = aPT->NbNodes();
+ TColgp_Array1OfPnt arrNodes(1, nbNodes);
+ TColStd_Array1OfReal arrUVNodes(1, nbNodes);
+
+ for(Standard_Integer j = 1; j <= nbNodes; j++) {
+ arrUVNodes(j) = aPrs->Value(aPrs->Lower() + j - 1);
+ arrNodes(j) = aCurve.Value(arrUVNodes(j));
}
-
- if(found) {
-
- BRepAdaptor_Curve aCurve(aEdge);
- Handle(TColStd_HArray1OfReal) aPrs = aPT->Parameters();
- Standard_Integer nbNodes = aPT->NbNodes();
- TColgp_Array1OfPnt arrNodes(1, nbNodes);
- TColStd_Array1OfReal arrUVNodes(1, nbNodes);
+ aPol = new Poly_Polygon3D(arrNodes, arrUVNodes);
+ aPol->Deflection (aPT->Deflection());
+ }
+ else {
+ aPol = BRep_Tool::Polygon3D(aEdge, aL);
- for(Standard_Integer j = 1; j <= nbNodes; j++) {
- arrUVNodes(j) = aPrs->Value(aPrs->Lower() + j - 1);
- arrNodes(j) = aCurve.Value(arrUVNodes(j));
- }
- aPol = new Poly_Polygon3D(arrNodes, arrUVNodes);
- aPol->Deflection (aPT->Deflection());
- }
- else{
-
+ // If polygon was not found -> generate it
+ if (aPol.IsNull()) {
BRepAdaptor_Curve aCurve(aEdge);
const Standard_Real aFirst = aCurve.FirstParameter();
const Standard_Real aLast = aCurve.LastParameter();
aPol = new Poly_Polygon3D(arrNodes, arrUVNodes);
aPol->Deflection (aDeflection);
}
-
- BRep_Builder aBld;
- aBld.UpdateEdge (aEdge, aPol);
}
+
+ if (aPol.IsNull())
+ continue;
+
aTShapeNode = polToIndexedLineSet (aPol);
myScene.AddNode (aTShapeNode, Standard_False);
// Bind the converted face