import org.jcae.opencascade.jni.TopoDS_Face;\r
import org.jcae.opencascade.jni.TopoDS_Shape;\r
import org.simantics.opencascade.OCCTTool;\r
+import org.simantics.utils.datastructures.Pair;\r
import org.simantics.utils.threads.AWTThread;\r
import org.simantics.utils.threads.ThreadUtils;\r
\r
private List<vtkProp3D> edges = new ArrayList<vtkProp3D>(1);\r
private vtkActor silhouette = null;\r
\r
+ private boolean errors = false;\r
+ \r
public vtkSolidObject(vtkPanel panel,TopoDS_Shape shape) {\r
this.shape = shape;\r
this.panel = panel;\r
\r
public void visualizeSolid(boolean showFaces, boolean showEdges, boolean showVertices, boolean showSilhouette) {\r
clearActorsAWT();\r
- vtkPolyData data = createSolidMesh(shape);\r
- if (data == null)\r
+ errors = false;\r
+ Pair<vtkPolyData, Boolean> res = createSolidMesh(shape);\r
+ if (res == null) {\r
+ errors = true;\r
return;\r
+ }\r
+ vtkPolyData data = res.first;\r
+ if (!res.second)\r
+ errors = true;\r
if (showFaces) {\r
solid.add(createActor(data)); \r
}\r
}\r
\r
public void visualizeFaces(boolean showEdges, boolean showVertices) {\r
+ errors = false;\r
clearActorsAWT();\r
Collection<vtkPolyData> datas = createFaceMeshes(shape);\r
for (vtkPolyData data : datas) {\r
+ if (data == null) {\r
+ errors = true;\r
+ continue;\r
+ }\r
+ \r
solid.add(createActor(data));\r
\r
if (showEdges) {\r
showActorsAWT();\r
}\r
\r
+ public boolean hasErrors() {\r
+ return errors;\r
+ }\r
+ \r
public List<vtkProp3D> getActors() {\r
assert (Thread.currentThread() == AWTThread.getThreadAccess().getThread());\r
return actors;\r
\r
private static double TOLERANCE = 0.01;\r
\r
- public static vtkPolyData createSolidMesh(TopoDS_Shape shape) {\r
+ public static Pair<vtkPolyData, Boolean> createSolidMesh(TopoDS_Shape shape) {\r
+ \r
+ boolean success = true;\r
\r
double volume = OCCTTool.getBoundingBoxDiagonal(shape);\r
if (volume < TOLERANCE)\r
List<Integer> meshTriangles = new ArrayList<Integer>();\r
for (expFace.init(shape, TopAbs_ShapeEnum.FACE); expFace.more(); expFace.next()) {\r
TopoDS_Face face = (TopoDS_Face) expFace.current();\r
- OCCTTool.appendToMesh(face, meshPoints, meshTriangles);\r
+ if (!OCCTTool.appendToMesh(face, meshPoints, meshTriangles))\r
+ success = false;\r
face.delete();\r
}\r
if (meshPoints.size() == 0 || meshTriangles.size() == 0)\r
expFace.delete();\r
mesh.delete();\r
\r
- return data;\r
+ return new Pair<vtkPolyData, Boolean>(data, success);\r
}\r
\r
public static Collection<vtkPolyData> createFaceMeshes(TopoDS_Shape shape) {\r