Assimp 5.0.0 crash on export - assimp

I'm trying to export my aiScene (which worked correctly with assimp 4.1.0), and I get a crash every time that the procedure ends and the export function it's called.
I subclassed aiScene and the constructor looks like this:
customAiScene::customAiScene()
{
mFlags = 0;
mRootNode = NULL;
mNumMeshes = 0;
mMeshes = NULL;
mNumMaterials = 0;
mMaterials = NULL;
mNumAnimations = 0;
mAnimations = NULL;
mNumTextures = 0;
mTextures = NULL;
mNumLights = 0;
mLights = NULL;
mNumCameras = 0;
mCameras = NULL;
mPrivate = NULL;
exporter = new Assimp::Exporter();
int n = exporter->GetExportFormatCount();
for (int i = 0; i < n; i++) {
const aiExportFormatDesc* formatDescription = exporter->GetExportFormatDescription(i);
wxString sDesc = wxString::FromUTF8(formatDescription->description);
wxString sExt = wxString::FromUTF8(formatDescription->fileExtension);
wxString sID = wxString::FromUTF8(formatDescription->id);
MyApp::showMessage(wxString::Format(wxT("export format: %s,%s,%s"), sDesc, sExt, sID), "l");
}
}
Later on, after setting the data, I export the scene:
exporter->Export(this, exportFormatDesc, filePath);
As I said, with assimp 4.1.0 it is working correctly (but I need FBX export hence the reason for the new version).
Thanks for any help.

I will check your code with our current master. This seems to be a bug.
I opened the issue-report https://github.com/assimp/assimp/issues/2846 to track your issue.

Related

Loop over path points in Photoshop

I'm trying to iterate over a create path in Photoshop finding out the anchor points position etc
var srcDoc = app.activeDocument;
// create the array of PathPointInfo objects
var lineArray = new Array();
lineArray.push(new PathPointInfo());
lineArray[0].kind = PointKind.CORNERPOINT;
lineArray[0].anchor = new Array(20, 160);
lineArray[0].leftDirection = [35, 200];
lineArray[0].rightDirection = lineArray[0].anchor;
lineArray.push(new PathPointInfo());
lineArray[1].kind = PointKind.CORNERPOINT;
lineArray[1].anchor = new Array(20, 40);
lineArray[1].leftDirection = lineArray[1].anchor;
lineArray[1].rightDirection = [220, 260];
// create a SubPathInfo object, which holds the line array in its entireSubPath property.
var lineSubPathArray = new Array();
lineSubPathArray.push(new SubPathInfo());
lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR;
lineSubPathArray[0].closed = false;
lineSubPathArray[0].entireSubPath = lineArray;
//create the path item, passing subpath to add method
var myPathItem = srcDoc.pathItems.add("A Line", lineSubPathArray);
for (var i = 0; i < lineSubPathArray[0].entireSubPath.length; i++)
{
var b = lineSubPathArray[0].entireSubPath[i].anchor;
alert(b);
}
This works fine, but instead of creating the path and finding out it's information I want to loop over each path and get the same. This should be the same as the loop above only without explicitly calling lineSubPathArray and its parts.
for (var i = 0; i < srcDoc.pathItems[0].subPathItems.pathPoints.length; i++) // wrong I think
{
var b = srcDoc.pathItems[0].entireSubPath[i].anchor; // wrong
alert(b);
}
Almost: you need to iterate through subPathItems which consist of pathPoints:
var srcDoc = activeDocument;
var workPath = srcDoc.pathItems[0];
var i, k, b;
for (i = 0; i < workPath.subPathItems.length; i++) {
for (k = 0; k < workPath.subPathItems[i].pathPoints.length; k++) {
b = workPath.subPathItems[i].pathPoints[k].anchor;
alert(b);
}
}

Cannot create logical device only in debug mode

I'm getting VK_ERROR_FEATURE_NOT_PRESENT(-8).
But i'm using vkGetPhysicalDeviceFeatures to get features.
My Code:
std::vector<VkDeviceQueueCreateInfo> LogicalDevice::CreateDeviceQueueCreateInfos(QueueFamilies queueFamilies)
{
std::vector uniqueQueueFamilies = queueFamilies.GetUniqueQueueFamilies();
std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
for (auto queueFamily : uniqueQueueFamilies)
{
const int countOfQueues = queueFamily.CountOfQueues;
std::vector<float> queuePriorities(countOfQueues);
for (int indexOfPriority = 0; indexOfPriority < countOfQueues; indexOfPriority++)
{
queuePriorities[indexOfPriority] = 1.0f - ( (float) indexOfPriority / countOfQueues);
}
VkDeviceQueueCreateInfo queueCreateInfo{};
queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queueCreateInfo.queueFamilyIndex = queueFamily.Index.value();
queueCreateInfo.queueCount = queueFamily.CountOfQueues;
queueCreateInfo.flags = queueFamily.Flags;
queueCreateInfo.pQueuePriorities = queuePriorities.data();
queueCreateInfos.push_back(queueCreateInfo);
}
return queueCreateInfos;
}
VkDeviceCreateInfo LogicalDevice::GetDeviceCreateInfo(std::vector<VkDeviceQueueCreateInfo> deviceQueueCreateInfos, VkPhysicalDevice physicalDevice)
{
VkPhysicalDeviceFeatures deviceFeatures{};
vkGetPhysicalDeviceFeatures(physicalDevice, &deviceFeatures);
VkDeviceCreateInfo deviceCreateInfo{};
deviceCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
deviceCreateInfo.queueCreateInfoCount = static_cast<uint32_t>(deviceQueueCreateInfos.size());
deviceCreateInfo.pQueueCreateInfos = deviceQueueCreateInfos.data();
deviceCreateInfo.pEnabledFeatures = &deviceFeatures;
return deviceCreateInfo;
}
void LogicalDevice::Initialize(VkPhysicalDevice physicalDevice, VkSurfaceKHR surfaceForPickingPhysicalDevice)
{
m_queueFamilies = QueueFamilies::GetQueueFamilies(physicalDevice, surfaceForPickingPhysicalDevice);
std::vector<VkDeviceQueueCreateInfo> deviceQueueCreateInfos = CreateDeviceQueueCreateInfos(m_queueFamilies);
VkDeviceCreateInfo deviceCreateInfo = GetDeviceCreateInfo(deviceQueueCreateInfos, physicalDevice);
VkResult result = vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &m_vulkanDevice);
if (result != VK_SUCCESS)
{
throw new std::runtime_error("Cannot create logical device.");
}
}
The deviceFeature variable that you read the features into and which is pointed at in the create info structure is local to GetDeviceCreateInfo. This is out-of-scope at the point where you call vkCreateDevice, which results in undefined behavior. You're probably getting random junk at device creation time instead, which causes that error.

Get the "id" of the TD Node

I'm trying to get the "id" of the TD Node that a field is in. I created a function, but I am not getting the data out of the loop ... I'm guessing that the variables are out of scope and I can't figure out how to make it work.
function getTD(vStartNm)
{
vNm = document.getElementsByName(vStartNm),
vId = vNm[0].getAttribute('id'),
vNode = document.getElementById(vId),
vTag = vNode.nodeName;
vTDId = '';
for (i = 0; i >10; i++)
{
vPar = vNode.parentNode;
vTag = vPar.nodeName;
vTDId = vPar.id;
vNode = vPar;
if (vTag == 'TD'){return vTDId; break;}
}
}
vTD_id = getTD('udfchar45');
vTD = document.getElementById(vTD_id);
my syntax on the do loop may be wrong. once i changed it to a while loop, it seems to work just fine.
function getTD(vStartNm)
{
vNm = document.getElementsByName(vStartNm),
vId = vNm[0].getAttribute('id'),
vNode = document.getElementById(vId),
vTag = vNode.nodeName;
vTDId = '';
i=0;
while (i < 10)
{
i++;
vPar = vNode.parentNode;
vTag = vPar.nodeName;
vTDId = vPar.id;
vNode = vPar;
if (vTag == 'TD'){return vTDId; break;}
}
}
vTD_id = getTD('udfchar45');
vTD = document.getElementById(vTD_id);

How to efficiently loop through multiple nested NSDictionaries and compare values?

I have the following structure in an NSDictionary that I got after parsing the XMl using XMl reader from here http://troybrant.net/blog/2010/09/simple-xml-to-nsdictionary-converter/:
{
Document = {
Page = (
{
TextLR = {
Line = {
LineProps = {
applyBreakingRules = true;
autoDecimalTabPos = 0;
breakJust = BreakOptimal;
direction = ES;
hyphenationZone = 0;
kindAlign = Left;
kindJust = FullInterWord;
left = 0;
presSuppressWiggle = true;
rightBreak = 0;
rightJustify = 0;
text = "\n\t\n\t\t\n\t\t\t\n\t\t\t\t";
treatHyphenAsRegular = true;
};
Text = {
text = "\n\t\t\t\tHello ";
};
betweenBottom = false;
betweenTop = false;
bottomEnable = false;
break = EndPara;
cpLim = 12;
cpStart = 0;
direction = ES;
doc = Main;
firstLineCp = true;
};
bottom = 114115;
cpLim = 12;
cpStart = 0;
doc = Main;
left = 0;
right = 2438349;
text = "\n\t\t";
top = 0;
};
cpLim = 81963072;
fBuggyJust = false;
fEmptyPage = false;
fHasBubbles = false;
fSlicedPage = false;
height = 3448422;
marginBottom = 3448422;
},
{
TextLR = {
Line = {
LineProps = {
applyBreakingRules = true;
autoDecimalTabPos = 0;
breakJust = BreakOptimal;
direction = ES;
hyphenationZone = 0;
kindAlign = Left;
kindJust = FullInterWord;
left = 0;
presSuppressWiggle = true;
rightBreak = 0;
rightJustify = 0;
text = "\n\t\n\t\t\n\t\t\t\n\t\t\t\t";
treatHyphenAsRegular = true;
};
Text = {
text = "\n\t\t\t\tHello SO ";
};
betweenBottom = false;
betweenTop = false;
bottomEnable = false;
break = EndPara;
cpLim = 12;
cpStart = 0;
direction = ES;
doc = Main;
firstLineCp = true;
};
bottom = 114115;
cpLim = 12;
cpStart = 0;
doc = Main;
left = 0;
right = 2438349;
text = "\n\t\t";
top = 0;
};
cpLim = 81963072;
fBuggyJust = false;
fEmptyPage = false;
fHasBubbles = false;
fSlicedPage = false;
height = 3448422;
marginBottom = 3448422;
}
);
doc = "simple1.htm";
xdpi = 72;
xmlns = "http://apple/sites;
"xmlns:xsi" = "http://www.w3.org/2001/XMLSchema-instance";
"xsi:schemaLocation" = "xmlns = "http://apple/sites/Dump.xsd";
ydpi = 72;
};
}
I have been struggling to iterate through this nested NSDictionary and extract each attribute to compare with another NSDictionary of similar structure. The dictionaries can be somewhat dynamic, as in there might be additional levels of nesting for different xml files but the dictionaries to compare are of exact similar structure with same tags. Is there a way to iterate and create nested dictionaries on the go and then have parallel loops going so that I can extract the values and compare with between 2 NSDictionaries? I have tried the following code, but I am stuck in finding a good way to make it create dictionaries dynamically at the same time compare values/attributes with another dictionary. Help is much appreciated.
NSArray *arrPages = [[_xmlDictionary_master objectForKey:#"Document"] objectForKey:#"Page"];//this would return the array of Page dictionaries
for(int i=0;i<[arrPages count];i++){
NSDictionary *aPage = [arrStation objectAtIndex:i];
NSLog(#"id = %#",[aStation objectForKey:#"id"]);
}
Above code returns 2 Nested key/value pairs which in turn have multiple nested dictionaries. I am finding it hard to know which value has nesting and which doesnt during run time.
First tip: Refactor your data so that this isn't such a difficult operation! If that's not possible there's a few things you can try.
Rather than a "for loop", use:
[arrStation enumerateObjectsWithOptions: NSEnumerationConcurrent
usingBlock: ^(NSDictionary *aPage, NSUInteger idx, BOOL *stop) {
// Code here for compare
}];
That may perform your operations in parallel.
Another technique is using GCD. Using a dispatch_async, then a dispatch_apply can achieve something very similar.
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_apply([arrStation count], dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t idx) {
// Work here
});
});
Spend some time reading through the Concurrency Programming Guide. It's a great way to understand what options are available and how they work.

Ti.Include to CommonJS for a beginner

So now that Ti.include is deprecated, I am forced to face the fact that I do not know the correct way to handle commonJS and require.
I have read and re-read many of the posts on SO and elsewhere but still cannot make sense of the syntax. I suspect it is because my original code is somewhat hackish to begin with.
Can anybody help by looking at the small code below and helping me translate it into commonJS?
In the document that contains the current Ti.Include I need to get to the variables dp and ff.
var dp = "";
if (Titanium.Platform.Android) {
dp = (Ti.Platform.displayCaps.dpi / 160);
} else {
dp = 1;
}
var version = Titanium.Platform.version.split(".");
version = version[0];
if (Titanium.Platform.displayCaps.platformWidth == '320') {
ff = 0;
} else if (Titanium.Platform.displayCaps.platformWidth == '768') {
ff = 3;
} else {
ff = 1;
}
Thank you all.
something like this will do.
Create a file named dpAndFfModule.js and place under the lib folder inside your project.
exports.getDp = function () {
var dp = "";
if (Titanium.Platform.Android) {
dp = (Ti.Platform.displayCaps.dpi / 160);
} else {
dp = 1;
}
return dp;
};
exports.getFf = function () {
var version = Titanium.Platform.version.split(".");
version = version[0];
var ff;
if (Titanium.Platform.displayCaps.platformWidth == '320') {
ff = 0;
} else if (Titanium.Platform.displayCaps.platformWidth == '768') {
ff = 3;
} else {
ff = 1;
}
return ff;
};
now inside .js files you need to require the module like this:
var dpAndFf = require('dpAndFfModule'); //you pass the filename (without extention) to require funciton.
dpAndFf.getDp(); // this executes the getDp function and returns your dp.
dpAndFf.getFf(); // same, executes getFf function and returns the result.