XSIPLUGINCALLBACK CStatus ToonixGetData_BeginEvaluate( ICENodeContext& in_ctxt ) { // Get User Data TXData* data = (TXData*)(CValue::siPtrType)in_ctxt.GetUserData( ); CDataArrayBool cullingData(in_ctxt, ID_IN_CameraCulling); int dirtyState = GetToonixDataDirtyState(in_ctxt,cullingData[0]); if(!dirtyState)return CStatus::OK; // Get geometry object from the input port CICEGeometry geom( in_ctxt, ID_IN_Geometry ); // Get Camera Datas CDataArrayMatrix4f matrixData(in_ctxt, ID_IN_CameraGlobal); CDataArrayFloat fovData(in_ctxt, ID_IN_CameraFov); CDataArrayFloat aspectData(in_ctxt, ID_IN_CameraAspect); CDataArrayFloat nearData(in_ctxt, ID_IN_CameraNear); CDataArrayFloat farData(in_ctxt, ID_IN_CameraFar); CDataArrayBool octreeData(in_ctxt, ID_IN_UseOctree); data->SetCulling(cullingData[0]); data->SetCamera(matrixData[0],fovData[0],aspectData[0],nearData[0],farData[0]); if(dirtyState == 1) { bool bTopologyDirtyState = geom.IsDirty( CICEGeometry::siTopologyDirtyState ); geom.ClearState(); data->Init(geom, bTopologyDirtyState); } data->Update(geom, octreeData[0]); return CStatus::OK; }
MatrixDouble TimeSeriesClassificationDataStream::getDataAsMatrixDouble() const { UINT M = getNumSamples(); UINT N = getNumDimensions(); MatrixDouble matrixData(M,N); for(UINT i=0; i<M; i++){ for(UINT j=0; j<N; j++){ matrixData[i][j] = data[i][j]; } } return matrixData; }
MatrixFloat TimeSeriesClassificationData::getDataAsMatrixFloat() const { //Count how many samples are in the entire dataset UINT M = 0; UINT index = 0; for(UINT x=0; x<totalNumSamples; x++){ M += data[x].getLength(); } if( M == 0 ) MatrixFloat(); //Get all the data and concatenate it into 1 matrix MatrixFloat matrixData(M,numDimensions); for(UINT x=0; x<totalNumSamples; x++){ for(UINT i=0; i<data[x].getLength(); i++){ for(UINT j=0; j<numDimensions; j++){ matrixData[index][j] = data[x][i][j]; } index++; } } return matrixData; }
void cvColor::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { // cout << "cvColor::draw\n"; MStatus stat; MObject thisNode = thisMObject(); MPlug enPlug( thisNode, drawingEnabled ); bool doDrawing; stat = enPlug.getValue ( doDrawing ); if (!stat) { stat.perror("cvColor::draw get drawingEnabled"); return; } if (!doDrawing) return; MPlug szPlug( thisNode, pointSize ); float ptSize; stat = szPlug.getValue ( ptSize ); if (!stat) { stat.perror("cvColor::draw get pointSize"); ptSize = 4.0; } MPlug cvPlug( thisNode, cvLocations ); MObject cvObject; stat = cvPlug.getValue(cvObject); if (!stat) { stat.perror("cvColor::draw get cvObject"); return; } MFnPointArrayData cvData(cvObject, &stat); if (!stat) { stat.perror("cvColor::draw get point array data"); return; } MPointArray cvs = cvData.array( &stat ); if (!stat) { stat.perror("cvColor::draw get point array"); return; } // Extract the 'worldMatrix' attribute that is inherited from 'dagNode' // MFnDependencyNode fnThisNode( thisNode ); MObject worldSpaceAttribute = fnThisNode.attribute( "worldMatrix" ); MPlug matrixPlug( thisNode, worldSpaceAttribute); // 'worldMatrix' is an array so we must specify which element the plug // refers to matrixPlug = matrixPlug.elementByLogicalIndex (0); // Get the value of the 'worldMatrix' attribute // MObject matObject; stat = matrixPlug.getValue(matObject); if (!stat) { stat.perror("cvColor::draw get matObject"); return; } MFnMatrixData matrixData(matObject, &stat); if (!stat) { stat.perror("cvColor::draw get world matrix data"); return; } MMatrix worldSpace = matrixData.matrix( &stat ); if (!stat) { stat.perror("cvColor::draw get world matrix"); return; } if ( view.isColorIndexMode() ) { cerr << "Can't update cv colors in color index mode\n"; return; } view.beginGL(); // Push the color settings // glPushAttrib( GL_CURRENT_BIT | GL_POINT_BIT ); glPointSize( ptSize ); glDisable ( GL_POINT_SMOOTH ); // Draw square "points" glBegin( GL_POINTS ); int numCVs = cvs.length(); for (int i = 0; i < numCVs; i++) { // cout << "cv[" << i << "]: " << cvs[i] << ": "; MPoint cv( cvs[i] ); MColor cvColor; cv *= worldSpace; if (cv.x < 0 && cv.y < 0) { // cout << "Red"; cvColor.r = 1.0; cvColor.g = 0.0; cvColor.b = 0.0; } else if (cv.x < 0 && cv.y >= 0) { // cout << "Cyan"; cvColor.r = 0.0; cvColor.g = 1.0; cvColor.b = 1.0; } else if (cv.x >= 0 && cv.y < 0) { // cout << "Blue"; cvColor.r = 0.0; cvColor.g = 0.0; cvColor.b = 1.0; } else if (cv.x >= 0 && cv.y >= 0) { // cout << "Yellow"; cvColor.r = 1.0; cvColor.g = 1.0; cvColor.b = 0.0; } // cout << endl; view.setDrawColor ( cvColor ); glVertex3f( (float)cvs[i].x, (float)cvs[i].y, (float)cvs[i].z); } glEnd(); glPopAttrib(); view.endGL(); }