aDegree = (long long)log10(abs((long long)v)) + 1;
aDegree = theDecimals - aDegree;
//printf("$$$ 1 v = %.20g , aDegree = %lld \n", v, (long long)aDegree);
- if (aDegree > 0) {
- aDegree = pow(10, aDegree);
- v = ((vtkFloatingPointType)((long long)(v * aDegree))) / aDegree;
- //printf("$$$ 2 v = %.20g , aDegree = %lld \n", v, (long long)aDegree);
- }
+
+ aDegree = pow(10, aDegree);
+ v = ((vtkFloatingPointType)((long long)(v * aDegree))) / aDegree;
+ //printf("$$$ 2 v = %.20g , aDegree = %lld \n", v, (long long)aDegree);
+
return v;
}
TValueType* theOutputPtr,
vtkIdType theNbOfTuples)
{
- // jfa try begin
- SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
- int aDecimals = aResourceMgr->integerValue("VISU", "floating_point_precision", 6);
- // jfa try end
-
vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents();
std::vector<vtkFloatingPointType> anArray(aNbComp < 3? 3: aNbComp);
for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
vtkFloatingPointType aScalar = sqrt(aVector[0]*aVector[0] +
aVector[1]*aVector[1] +
aVector[2]*aVector[2]);
- //*theOutputPtr = TValueType(aScalar);
- // jfa try begin
- *theOutputPtr = TValueType(CutValue(aScalar, aDecimals));
- // jfa try end
+ *theOutputPtr = TValueType(aScalar);
theOutputPtr++;
}
}
vtkIdType theNbOfTuples,
VISU::TGaussMetric theGaussMetric)
{
- // jfa try begin
- SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
- int aDecimals = aResourceMgr->integerValue("VISU", "floating_point_precision", 6);
- // jfa try end
-
vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents();
if (aNbComp != 3) // Min, Max, Avg
return;
case VISU::MAXIMUM_METRIC: *theOutputPtr = TValueType(anArray[1]); break;
case VISU::AVERAGE_METRIC: *theOutputPtr = TValueType(anArray[2]); break;
}
- // jfa try begin
- *theOutputPtr = TValueType(CutValue(*theOutputPtr, aDecimals));
- // jfa try end
theOutputPtr++;
}
}
vtkIdType theNbOfTuples,
vtkIdType theComponentId)
{
- // jfa try begin
- SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
- int aDecimals = aResourceMgr->integerValue("VISU", "floating_point_precision", 6);
- // jfa try end
-
vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents();
for (vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++) {
*theOutputPtr = *(theInputPtr + theComponentId);
- // jfa try begin
- *theOutputPtr = TValueType(CutValue(*theOutputPtr, aDecimals));
- // jfa try end
theInputPtr += aNbComp;
theOutputPtr++;
}
}
+//----------------------------------------------------------------------------
+template<typename TValueType>
+void
+CutFieldDataTempl(vtkDataArray *theInputDataArray,
+ TValueType* theDataPtr,
+ vtkIdType theNbOfTuples)
+{
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+ int aDecimals = aResourceMgr->integerValue("VISU", "floating_point_precision", 6);
+
+ for (vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++) {
+ double aValue;
+ theInputDataArray->GetTuple(aTupleId, &aValue);
+ *theDataPtr = TValueType(CutValue(aValue, aDecimals));
+ theDataPtr++;
+ }
+}
//----------------------------------------------------------------------------
template<typename TDataSetAttributesType> void
int aNbElems = anInput->GetNumberOfPoints();
if ( anInputPointData->GetAttribute( vtkDataSetAttributes::VECTORS ) )
ExecuteScalars( aNbElems, myScalarMode, myGaussMetric, anInputPointData, anOutputPointData );
+ CutFieldData( aNbElems, anOutputPointData );
}
vtkCellData *anInputCellData = anInput->GetCellData();
int aNbElems = anInput->GetNumberOfCells();
if ( anInputCellData->GetAttribute( vtkDataSetAttributes::VECTORS ) )
ExecuteScalars( aNbElems, myScalarMode, myGaussMetric, anInputCellData, anOutputCellData );
+ CutFieldData( aNbElems, anOutputCellData );
}
return 1;
}
+
+//---------------------------------------------------------------
+
+void VISU_Extractor::CutFieldData(int theNbElems, vtkDataSetAttributes *theData )
+{
+ if (theNbElems < 1) return;
+
+ vtkDataArray* aFieldArray = NULL;
+ switch (myGaussMetric) {
+ case VISU::AVERAGE_METRIC: aFieldArray = theData->GetArray("VISU_FIELD"); break;
+ case VISU::MINIMUM_METRIC: aFieldArray = theData->GetArray("VISU_FIELD_GAUSS_MIN"); break;
+ case VISU::MAXIMUM_METRIC: aFieldArray = theData->GetArray("VISU_FIELD_GAUSS_MAX"); break;
+ }
+ if( !aFieldArray ) return;
+
+ vtkIdType anInputDataType = aFieldArray->GetDataType();
+ vtkDataArray *aScalars = vtkDataArray::CreateDataArray(anInputDataType);
+ aScalars->SetNumberOfComponents( 1 );
+ aScalars->SetNumberOfTuples( theNbElems );
+ void *aPtr = aScalars->GetVoidPointer(0);
+
+ switch (anInputDataType) {
+ vtkTemplateMacro3(CutFieldDataTempl,
+ aFieldArray,
+ (VTK_TT *)(aPtr),
+ theNbElems);
+ default:
+ break;
+ }
+
+ theData->SetScalars(aScalars);
+ aScalars->Delete();
+}