void _lucVectorArrowCrossSection_DrawCrossSection( void* drawingObject, lucDatabase* database, Dimension_Index dim ) { lucVectorArrowCrossSection* self = (lucVectorArrowCrossSection*)drawingObject; FieldVariable* vectorVariable = self->fieldVariable; double min = 0.0, max = self->maximum; Index aIndex, bIndex; Journal_Firewall( vectorVariable->fieldComponentCount == vectorVariable->dim, lucError, "Error - in %s(): provided FieldVariable \"%s\" has %u components - but %s Component " "can only visualse FieldVariables with %d components.\n", __func__, vectorVariable->name, vectorVariable->fieldComponentCount, self->type, vectorVariable->dim ); if ( True == self->dynamicRange ) { min = FieldVariable_GetMinGlobalFieldMagnitude( vectorVariable ); max = FieldVariable_GetMaxGlobalFieldMagnitude( vectorVariable ); } /* Force 3d vectors */ lucCrossSection_AllocateSampleData(self, 3); /* Sample the 2d cross-section */ lucCrossSection_SampleField(self, False); /* Write only values that have data on this processor! */ for ( aIndex = 0 ; aIndex < self->resolutionA ; aIndex++ ) { for ( bIndex = 0 ; bIndex < self->resolutionB ; bIndex++ ) { if (self->values[aIndex][bIndex][0] != HUGE_VAL) { lucDatabase_AddVertices(database, 1, lucVectorType, &self->vertices[aIndex][bIndex][0]); lucDatabase_AddVectors(database, 1, lucVectorType, min, max, &self->values[aIndex][bIndex][0]); } } } lucCrossSection_FreeSampleData(self); }
void _lucSwarmVectors_PlotParticle( void* drawingObject, lucDatabase* database, Particle_Index lParticle_I ) { lucSwarmVectors* self = (lucSwarmVectors*)drawingObject; SwarmVariable* lengthVariable = self->lengthVariable; SwarmVariable* thicknessVariable = self->thicknessVariable; float length; XYZ direction = { 1, 0, 0 }; SwarmVariable_ValueAt( self->directionVariable, lParticle_I, direction ); length = lucSwarmViewer_GetScalar(lengthVariable, lParticle_I, self->length); //float max = self->directionVariable ? FieldVariable_GetMaxGlobalFieldMagnitude( self->directionVariable ) : 0; float vecf[3] = {direction[0]*length, direction[1]*length, direction[2]*length}; lucDatabase_AddVectors(database, 1, lucVectorType, 0, 0, vecf); if (thicknessVariable) { float thickness = lucSwarmViewer_GetScalar(thicknessVariable, lParticle_I, self->thickness); lucDatabase_AddValues(database, 1, self->geomType, lucXWidthData, NULL, &thickness); } }
void _lucEigenvectorsCrossSection_DrawCrossSection( void* drawingObject, lucDatabase* database, Dimension_Index dim ) { lucEigenvectorsCrossSection* self = (lucEigenvectorsCrossSection*)drawingObject; FieldVariable* tensorField = self->fieldVariable; SymmetricTensor tensor; Eigenvector eigenvectorList[3]; Dimension_Index dim_I; Index aIndex, bIndex; /* Sample the 2d cross-section */ lucCrossSection_SampleField(self, False); for ( aIndex = 0 ; aIndex < self->resolutionA ; aIndex++ ) { for ( bIndex = 0 ; bIndex < self->resolutionB ; bIndex++ ) { if (self->values[aIndex][bIndex][0] != HUGE_VAL) { /* Get tensor data & position */ int t; for (t=0; t<tensorField->fieldComponentCount; t++) tensor[t] = self->values[aIndex][bIndex][t]; SymmetricTensor_CalcAllEigenvectors( tensor, dim, eigenvectorList ); float pos[3] = {self->vertices[aIndex][bIndex][0], self->vertices[aIndex][bIndex][1], self->vertices[aIndex][bIndex][2]}; if (self->plotEigenVector) { for ( dim_I = 0 ; dim_I < dim ; dim_I++ ) { float vec[3] = {eigenvectorList[ dim_I ].vector[0], eigenvectorList[ dim_I ].vector[1], eigenvectorList[ dim_I ].vector[2]}; lucDatabase_AddVertices(database, 1, lucVectorType, pos); lucDatabase_AddRGBA(database, lucVectorType, self->opacity, &self->colours[ dim_I ]); if (self->useEigenValue) { vec[0] *= eigenvectorList[ dim_I ].eigenvalue; vec[1] *= eigenvectorList[ dim_I ].eigenvalue; if (dim > 2) vec[2] *= eigenvectorList[ dim_I ].eigenvalue; else vec[2] = 0; } lucDatabase_AddVectors(database, 1, lucVectorType, 0, 1, vec); } } if (self->plotEigenValue) { float pointSize = 0; for ( dim_I = 0 ; dim_I < dim ; dim_I++ ) { lucDatabase_AddVertices(database, 1, lucShapeType, pos); /* The EigenValue can be negative.... Got to attribute a potential */ /* colour for negative values, one for each dim as well */ if ( eigenvectorList[ dim_I ].eigenvalue >= 0) { pointSize = eigenvectorList[ dim_I ].eigenvalue; lucDatabase_AddRGBA(database, lucShapeType, self->opacity, &self->colours[ dim_I ]); } else { pointSize = -eigenvectorList[ dim_I ].eigenvalue; lucDatabase_AddRGBA(database, lucShapeType, self->opacity, &self->colourForNegative[ dim_I ]); } lucDatabase_AddValues(database, 1, lucShapeType, lucXWidthData, NULL, &pointSize); } } } } } lucCrossSection_FreeSampleData(self); }