Direct 3D 11 Rasterizer Desc Error - c++

for starters, I am a complete novice with D3D11, so I apologize for my ignorance in advance.
For my games programming module I am trying to render my cubes in a wireframe format.
I have followed my lecturers' code exactly and cannot figure out what is causing the following error.
On the line "hr = _pd3dDevice->CreateRasterizerState(&wfdesc, &_wireFrame);".
I get the error that &wfDesc is of type Application::"D3D11_RASTERIZER_DESC", is not compatible with parameter of type, "const D3D11_RASTERIZER_DESC".
//Wireframe creation............................................
D3D11_RASTERIZER_DESC wfdesc;
ZeroMemory(&wfdesc, sizeof(D3D11_RASTERIZER_DESC));
wfdesc.FillMode = D3D11_FILL_WIREFRAME;
wfdesc.CullMode = D3D11_CULL_NONE;
hr = _pd3dDevice->CreateRasterizerState(&wfdesc, &_wireFrame);
_pImmediateContext->RSSetState(_wireFrame);
ID3D11DeviceContext::RSSetState;
//Wireframe creation............................................
Any ideas? My apologies for the poor asking etiquette.

Related

Can't get EPSG from Shapefile with OGR/GDAL

At this moment, i'm working in a shapefile visor in C++ and QT and using the GDAL/OGR library. I have this method to get the EPSG of my shapefiles:
OGRLayer layer = dataset->GetLayer(0);
OGRSpatialReference *spatialRef = layer->GetSpatialRef();
With this I get the EPSG number with:
atoi(spatialRef->GetAuthorityCode(NULL));
This work fine in all my shape files less one. In this case, the method always retun null.
I try use:
spatialRef->GetAuthorityCode("PROJCS");
spatialRef->GetAuthorityCode("GEOGCS");
spatialRef->GetAuthorityName("GEOGCS");
And all this method return "".
I check this shapefile in a gis program as QGIS and QGIS autodetected that his EPSG is 25830.
My question is this: could the projection information be readed with a different method than what I'm doing?
I wait yours suggestions.
Thank a lot.
EDIT
This is the content of .prj file:
PROJCS["ETRS89_UTM_zone_30N",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
Something like this should work:
OGRLayer * layer = dataset->GetLayer(0);
layer->ResetReading();
OGRFeature * feat= layer->GetNextFeature();
OGRGeometry * geom = feat->GetGeometryRef();
OGRSpatialReference * spatRef = geom->getSpatialReference();
int EPSG = spatRef->GetEPSGGeogCS();
Hope it helps!

Kernel-PCA, KPCA: embed new data, error

I want to apply KPCA on my training data before I pass it to my SVM which seems to work fine with kernlab. Afterwards I want to embed my testing input into the new space in order to make prediction with my SVM. The documentary recommends to use the predict function, which gives me an error:
dataTrain=as.xts(data)
inputTrain=dataTrain[1:settings$windowTrain,1:ncol(dataTrain)-1]
outputTrain=dataTrain[1:settings$windowTrain,ncol(dataTrain)]
kpcaa=kpca(x=inputTrain,data=NULL,kernel="rbfdot",kpar=list(sigma=0.01))
inputTrain=kpcaa#pcv
predict(object = kpcaa,newdata=inputTest)
predict(object = kpcaa,newdata=inputTest)
Error in .local(object, ...) :
unused argument (newdata = c(0.00065527734617099, -0.00281135973754587, 0.00121922641129046, -0.00356807890285626, 0.00140997344409755, 0.000281756282681123, 0.000657122764787132, -0.000469329337005497, -0.000187793427781635, 0.00046941746156115, -0.000751173744242273, 0.000281756282681123, 0.000187793427781635, -0.000469549710462758, 0.000751173744242273, 0.00140693171451645, -0.000937734502324261, -0.000469197212192185, 0.00112570368360299, -0.0014073277173825, 0.0014073277173825, -0.00112570368360299,
0.000656814473530609, -0.00253580788619168, 0.00187899341266107, -0.00310223515540553, 0.00282061112162602, 0.00121979841537989, -0.00150150178359798, 0.000469461536250826, -0.00140904630893512, -0.000188022939352273, -0.000470212074305643, -0.000282233408900545, 0.00094046842255846, -0.000188022939352273, -0.000470212074305643, -0.000470433277716786, 0.00234995643227709, 0.000938438507310124, 0.000937558666089799, 0.0034613440236777, 0.00493736156014979, 0.00046453292050951
Does anybody can help me with this one?
Thank you!
fortunately I found that there was an error in the code.
kpcaa=kpca(x=inputTrain,data=NULL,kernel="rbfdot",kpar=list(sigma=0.01))
has to be something like...
kpcaa=kpca(~.,data=inputTrain,...)

How to parse output from sse.client in Python?

I am new to Python and am trying to get my ahead around parsing SSE client code. I am using the SSE Client library. My code is very basic and follows the sample exactly. Here it is:
from sseclient import SSEClient
devID = "xxx"
AToken = "xxx"
sparkURL = 'https://api.spark.io/v1/devices/' + devID + '/events/?access_token=' + AToken
messages = SSEClient(sparkURL)
for msg in messages:
print(msg)
print(type(msg))
The code runs without a problem and I see some blank lines and SSE data coming through. Here is the sample output:
<class 'sseclient.Event'>
{"data":"0 days, 0:54:43","ttl":"60","published_at":"2015-04-09T22:43:52.084Z","coreid":"xxxx"}
<class 'sseclient.Event'>
<class 'sseclient.Event'>
{"data":"0 days, 0:55:3","ttl":"60","published_at":"2015-04-09T22:44:12.092Z","coreid":"xxx"}
<class 'sseclient.Event'>
The actual output above looks like a dictionary, but its type is "sseclient.Event". I am trying to figure out how to parse the output so I can pull out one of the fields and nothing I have tried has worked.
Sorry if this is basic questions, but can someone provide some simple guidance on how I would either convert the entire output to a dictionary or perhaps just pull out one of the fields?
Thank you in advance!
I figured this out. In case anyone else experiences the same problem, here is how I got it to work. The key was using msg.data and not just msg. I then converted the out using the JSON library and am good to go.
messages = SSEClient(sparkURL)
for msg in messages:
outputMsg = msg.data
if type(outputMsg) is not str:
outputJS = json.loads(outputMsg)
FilterName = "data"
#print( FilterName, outputJS[FilterName] )
print(outputJS[FilterName])

Reading theme1.xml from a .docx, attribute without namespace

Im making a docx reader (libopc and C++) and I have problem when I want to get the minor and major Font from the theme1.xml. The problem is that I dont know how I have to write the namespace for attributes without it:
<a:latin typeface="Calibri"/>
I have tryed with:
mce_start_attribute(&reader, _X(""), _X("typeface")) {//type
_majorFont = (char*) xmlTextReaderConstValue(reader.reader);
}mce_end_attribute(&reader);
and:
mce_start_attribute(&reader, _X("http://www.3w.org/2000/xmlns"), _X("typeface")) {//type
_majorFont = (char*) xmlTextReaderConstValue(reader.reader);
}mce_end_attribute(&reader);
And I get the same result: nothing.
Any Suggestion.
Thanks in advance.
I answer myself.
After ckeck libopc source code the solution is set namespace value in mce_start_attribute macro as NULL:
mce_start_attribute(&reader, NULL, _X("typeface")) {//type
_majorFont = (char*) xmlTextReaderConstValue(reader.reader);
}mce_end_attribute(&reader);

How to Mole SPFieldUser from SPField

Im writing the unit test case using Moles for my SharePoint application
I'm stuck up at the below lines of code I'm unable to type cast SPField to SPFieldUser.
SField subfield = list.Fields.GetField("Subscriber");
SPFieldUser userfield = (SPFieldUser)subfield;
userfield.SelectionGroup = web.Groups["Focal Points"].ID; //error line shown in pex
I'm getting "NullReference" exception at the above line
Can someone guide me here..
Although I am sure you have already checked these...:
Does GetField("Subscriber") return an object?
Does userfield get set to an object?
Is userfield.SelectionGroup null?
Try this syntax:
SPFieldUser userfield = subfield as SPFieldUser;
So, these all fail. Let's examine covariance of SPFieldUser to SField. The inheritance hierarchy is:
System.Object
Microsoft.SharePoint.SPField
Microsoft.SharePoint.SPFieldLookup
Microsoft.SharePoint.SPFieldUser
Unfortunately, I do not have the Microsoft.SharePoint library, to see if the SPFieldLookup classis hiding something important in SPField.