// after adding triangles (and edges) initialize DLL_HEADER Ng_Result Ng_STL_InitSTLGeometry (Ng_STL_Geometry * geom) { STLGeometry* geo = (STLGeometry*)geom; geo->InitSTLGeometry(readtrias); readtrias.SetSize(0); if (readedges.Size() != 0) { /* for (int i = 1; i <= readedges.Size(); i+=2) { cout << "e(" << readedges.Get(i) << "," << readedges.Get(i+1) << ")" << endl; } */ geo->AddEdges(readedges); } if (geo->GetStatus() == STLTopology::STL_GOOD || geo->GetStatus() == STLTopology::STL_WARNING) return NG_OK; return NG_SURFACE_INPUT_ERROR; }
int Ng_STLInfo (ClientData clientData, Tcl_Interp * interp, int argc, tcl_const char *argv[]) { double data[10]; static char buf[20]; STLGeometry * stlgeometry = dynamic_cast<STLGeometry*> (ng_geometry); if (!stlgeometry) { Tcl_SetResult (interp, err_needsstlgeometry, TCL_STATIC); return TCL_ERROR; } if (stlgeometry) { stlgeometry->STLInfo(data); // cout << "NT=" << data[0] << endl; if (argc == 2) { if (strcmp (argv[1], "status") == 0) { switch (stlgeometry->GetStatus()) { case STLGeometry::STL_GOOD: strcpy (buf, "GOOD"); break; case STLGeometry::STL_WARNING: strcpy (buf, "WARNING"); break; case STLGeometry::STL_ERROR: strcpy (buf, "ERROR"); break; } Tcl_SetResult (interp, buf, TCL_STATIC); return TCL_OK; } if (strcmp (argv[1], "statustext") == 0) { Tcl_SetResult (interp, (char*)stlgeometry->GetStatusText().c_str(), TCL_STATIC); return TCL_OK; } if (strcmp (argv[1], "topology_ok") == 0) { sprintf (buf, "%d", stlgeometry->Topology_Ok()); Tcl_SetResult (interp, buf, TCL_STATIC); } if (strcmp (argv[1], "orientation_ok") == 0) { sprintf (buf, "%d", stlgeometry->Orientation_Ok()); Tcl_SetResult (interp, buf, TCL_STATIC); } } } else { data[0] = 0; data[1] = 0; data[2] = 0; data[3] = 0; data[4] = 0; data[5] = 0; data[6] = 0; data[7] = 0; } sprintf (buf, "%i", (int)data[0]); Tcl_SetVar (interp, argv[1], buf, 0); sprintf (buf, "%5.3g", data[1]); Tcl_SetVar (interp, argv[2], buf, 0); sprintf (buf, "%5.3g", data[2]); Tcl_SetVar (interp, argv[3], buf, 0); sprintf (buf, "%5.3g", data[3]); Tcl_SetVar (interp, argv[4], buf, 0); sprintf (buf, "%5.3g", data[4]); Tcl_SetVar (interp, argv[5], buf, 0); sprintf (buf, "%5.3g", data[5]); Tcl_SetVar (interp, argv[6], buf, 0); sprintf (buf, "%5.3g", data[6]); Tcl_SetVar (interp, argv[7], buf, 0); sprintf (buf, "%i", (int)data[7]); Tcl_SetVar (interp, argv[8], buf, 0); return TCL_OK; }