CGAL ERROR: assertion violation! Expr: e->incident_sface() - openscad

I'm trying to combine two .stl files together. Individually each one seems to render ok, but when I place them together I'm seeing this compile error:
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /usr/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326
When I google this error I see:
How can I render a dxf file with Sphere in OpenSCAD
Which references this: http://forum.openscad.org/Assertion-Violation-in-Render-td10598.html
Based on that it sounds like I need to shift my model off the X-axis, but even when I did that it still seems to be failing. I think I'm miss-understanding the solution. Where should I be looking at to do the X-axis shift?
Here is my code that imports the two stls:
import("globe_bigger_windows.stl");
scale=.5;
rotate([0, 0, -1]) {
translate([0, 0, -5]) {
scale([1*scale, 1*scale, 1*scale]){
translate([0, -25, -40]){
import("Dragon.stl");
}
}
}
}
Here is my repository which holds the stls.

There are some issues with the dragon file.
It works individually because it is not actually processing the model until you mesh it with something.
It works after repairing it with MeshMixer, using the "Make Solid" function.

Related

Reading STEP file into Open Cascade loses size information

I'm working on reading a STEP file into my C++ application, translating it into OCCT shapes, and displaying them using VTK. Everything seems to be working fine EXCEPT the scale. The shape I'm importing is just under 20 mm in diameter according to a 3D viewer (which matches what it was when I exported it from my app), but when I import it, it displays as the expected shape but at just under 20 meters in diameter. The program uses meters internally; OCCT appears to be ignoring units during import.
My program runs the following on initialization:
STEPControl_Controller::Init();
Interface_Static::SetCVal("xstep.cascade.unit","M");
The import code is:
STEPControl_Reader rdr;
IFSelect_ReturnStatus ret = rdr.ReadFile(filname);
if (ret == IFSelect_RetDone)
{
int navail = rdr.NbRootsForTransfer();
debugPrint("Found ",std::to_string(navail)," roots available");
int nroots = rdr.TransferRoots();
debugPrint("Transferred ",std::to_string(nroots)," roots");
TopoDS_Shape s = rdr.OneShape();
// Process the returned shape for display after this...
}
I've tried changing the value of "xstep.cascade.unit", and it has no effect on the size of the imported shape. It works as expected when exporting OCCT shapes to a STEP file, but not importing. Is there some parameter or initialization step I'm missing? We're using OCCT version 7.6.0.
ADDENDUM: I did check inside the STEP file, and the units are recorded with lines like:
#68 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) );
So it shouldn't be a matter of not knowing what it's translating from.

Why does this code to stash babylonjs meshes cause an error?

I am loading a .obj file containing meshes of numerals. I want to stash each mesh against its name so that I can create instances later.
The code works fine if I remove the line that is actually stashing the mesh in 'originals'. However when I leave it in it appears that an exception is thrown and caught inside Babylon with the message "BJS - [12:17:50]: Unable to load assets from /threedee/InputMonoNumerics.obj: Error in onSuccess callback".
originals = {}
BABYLON.SceneLoader.LoadAssetContainer(assetPath, assetName, scene, (container) ->
container.addAllToScene()
for i in[0...scene.meshes.length]
mesh = scene.meshes[i]
if (mesh.name.startsWith('numeral'))
character = mesh.name.charAt('numeral_'.length)
originals["_#{character}"] = mesh
console.log("This line is never reached.")
mesh
)
This is coffeescript source - but the transpiled code looks exactly as you would expect
Yes - much thanks to caffeinated.tech - obviously (now you come to mention it) try and catch to see the underlying error!
... which was that the debug statements I had put in to help were throwing an error by calling JSON.stringify on Babylon Mesh objects - which are circular - I think because they have a reference to their parent which of course has a reference back to the Mesh.
It is no longer clear what the original problem was - but that's not a problem.

Why is my "waterproof" polyhedron causing "WARNING: Object may not be a valid 2-manifold and may need repair!"?

In the script
difference() {
polyhedron(
points=[[0,0,0],
[2,0,0],
[2,1,0],
[0,1,0],
[0,0,2],
[0,1,2]],
faces=[[0,1,2,3],
[5,4,1,2],
[5,4,0,3],
[0,1,4],
[2,3,5]]);
cube([1,1,1]);
};
the polyhedron alone works fine (is rendered without warnings), but adding the cube above causes the warning WARNING: Object may not be a valid 2-manifold and may need repair! to be logged and the output to only render some parts of some surfaces.
I'm using OpenSCAD 2015.03-1 on Ubuntu 16.04.
This is because your polyhedron has some faces pointing into the wrong direction, causing issues when calculating the difference().
See the Manual and FAQ for details.
Changing the winding order of the affected polygons fixes the polyhedron:
difference() {
polyhedron(
points=[[0,0,0],
[2,0,0],
[2,1,0],
[0,1,0],
[0,0,2],
[0,1,2]],
faces=[[0,1,2,3],
[2,1,4,5],
[5,4,0,3],
[0,4,1],
[2,5,3]]);
cube([1,1,1]);
};
The difference is still non-manifold as cutting the cube results in 2 prism shaped objects just touching at one edge. That's also by definition not 2-manifold, so the warning remains.
Depending on how the exported model is supposed to be used, you could choose to ignore this warning and hope the tool processing the 3d model can handle that.
To remove the issue, for example the cube could be made a bit smaller like cube([1, 1, 0.999]).
An unrelated, but still useful strategy for preventing issues later on is to always make the cutting object a bit larger to ensure that no very thin planes remain, e.g. use cube([2,3,1.999], center = true). That will also remove the display artifacts in preview mode.

Batch processing clip layer: " 'NoneType' object has no attribute 'pendingFields' "

I am trying to clip many vector layers to a boundary by following the tutorial at http://www.qgistutorials.com/en/docs/batch_processing.html
ie using Clip in the Processing Toolbox, then 'execute as batch process'. However, I recieve an error message -
Algorithm Clip starting...
'NoneType' object has no attribute 'pendingFields'
but I don't know what that message means or how to fix it. Thanks for any help
EDIT: in the end I clipped the layers one by one through the 'Geoprocessing - Clip' menu. That worked, so now I suppose the issue is with the batch processing command rather than the shapefiles themselves.
I think the problem is that bash didn't get the target layer.
I get the similar error when I run reprojection.
before the input layer was "A layer", the input is a string.
then I redo select from open layers. the quotation mark disappear.
it works for me.
I've had the same problem. I solved it by using layers from file system instead of opened layers.
This is not very convenient but it can help !

Blank output for image subtraction when using raspicam library

I am using raspberry pi with raspicam to run a project. I have downloaded the raspicam library from http://sourceforge.net/projects/raspicam/files/?
I am trying to run a code for image subtraction but not getting results. Here is my code
raspicam::RaspiCam_Cv Camera;
Camera.set(cv::CAP_PROP_FRAME, CV_8UC1);
if(!Camera.open())
{
std::cerr<<"cannot open camera"<<std::endl;
}
Camera.grab();
Camera.retrieve(frame1);
Camera.grab();
Camera.retrieve(frame2);
Camera.grab();
Camera.retrieve(frame3);
while (True)
{
frame1=frame2;
frame2=frame3;
Camera.grab();
Camera.retrieve(frame3);
absdiff(frame2,frame1,d1);
imshow("result1",d1);
absdiff(frame2,frame3,d2);
imshow("result2",d2);
}
when I run this code I get blank frames of result1 and result2 as output. This is just a part of my code ignore if i have missed something.
Well, inside your loop
frame1=frame2;
...
absdiff(frame2,frame1,d1);
that'll be sort of identically zero...
Also, have you considered the timing here? You're grabbing images very close together in the time-domain, so naturally they'll be mostly identical (bar noise and fast motion) so the difference will be near-zero.
Cheers,