Commit 797e45a0 authored by George Zagaris's avatar George Zagaris Committed by Marcus D. Hanwell
Browse files

ENH:Mesh Property Encoder/Decoder and Definitions

Initial commit of mesh property encoder mesh entity
property definitions.

Change-Id: I5e72f65454524053f432d2a1fc49cf53e2bc2c7b
parent 48b1d1bf
......@@ -117,6 +117,7 @@ vtkMatrix3x3.cxx
vtkMatrix4x4.cxx
vtkMatrixToHomogeneousTransform.cxx
vtkMatrixToLinearTransform.cxx
vtkMeshPropertyEncoder.cxx
vtkMinimalStandardRandomSequence.cxx
vtkMultiThreader.cxx
vtkMutexLock.cxx
......
......@@ -17,6 +17,7 @@ CREATE_TEST_SOURCELIST(Tests ${KIT}CxxTests.cxx
TestFastNumericConversion.cxx
TestMath.cxx
TestMatrix3x3.cxx
TestMeshPropertyEncoder.cxx
TestMinimalStandardRandomSequence.cxx
TestNew.cxx
TestObservers.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestMeshPropertyEncoder.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME TestMeshPropertyEncoder.cxx -- Tests vtkMeshPropertyEncoder
//
// .SECTION Description
// A simple test for the vtkMeshPropertyEncoder
#include "vtkMeshProperty.h"
#include "vtkMeshPropertyEncoder.h"
int CheckSetAndUnsetProperty( unsigned char &u, const int p )
{
int rc = 0;
vtkMeshPropertyEncoder::SetProperty( u, p);
if( !vtkMeshPropertyEncoder::IsPropertySet( u, p) )
{
std::cerr << "Could not set property " << p << std::endl;
++rc;
}
vtkMeshPropertyEncoder::UnsetProperty( u, p);
if( vtkMeshPropertyEncoder::IsPropertySet( u, p) )
{
std::cerr << "Could not unset property " << p << std::endl;
++rc;
}
return( rc );
}
//------------------------------------------------------------------------------
int TestMeshPropertyEncoder(int,char *[])
{
int rc = 0;
unsigned char propertyField;
// Ensure all bits are set to 0
for( int i=0; i < 8; ++i )
{
if( vtkMeshPropertyEncoder::IsPropertySet( propertyField, i) )
++rc;
} // END for
// Try setting/unsetting some node properties
rc += CheckSetAndUnsetProperty( propertyField, VTKNodeProperties::INTERNAL );
rc += CheckSetAndUnsetProperty( propertyField, VTKNodeProperties::SHARED );
rc += CheckSetAndUnsetProperty( propertyField, VTKNodeProperties::GHOST );
rc += CheckSetAndUnsetProperty( propertyField, VTKNodeProperties::IGNORE );
rc += CheckSetAndUnsetProperty( propertyField, VTKNodeProperties::VOID );
rc += CheckSetAndUnsetProperty( propertyField, VTKNodeProperties::BOUNDARY );
// Try setting/unsetting some cell properties
rc += CheckSetAndUnsetProperty( propertyField, VTKCellProperties::DUPLICATE );
rc += CheckSetAndUnsetProperty( propertyField, VTKCellProperties::EXTERNAL );
// Ensure all bits are set to 0
for( int i=0; i < 8; ++i )
{
if( vtkMeshPropertyEncoder::IsPropertySet( propertyField, i) )
++rc;
} // END for
return( rc );
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGhostData.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkMeshProperty.h -- Defines node types and cell properties
//
// .SECTION Description
// This header consists of the valid ghost node types and ghost cell types.
#ifndef VTKMESHPROPERTY_H_
#define VTKMESHPROPERTY_H_
namespace VTKNodeProperties {
enum
{
INTERNAL = 0, // Nodes that are on the interior domain of a partition
SHARED = 1, // Nodes that are on the abutting/internal interface of two or
// more partitions.
GHOST = 2, // Nodes whose value is coming from another process/partition
VOID = 3, // Nodes that are ignored in computation/visualization,
// their value is typically garbage.
IGNORE = 4, // Nodes that are ignored in computation/visualization but have
// a valid value, e.g., if a SHARED node is going to be processed
// by another partition, then, this property is used to indicate
// to the rest of the partitions sharing that node to ignore it.
BOUNDARY = 5 // Nodes that are on the boundaries of the domain
};
}
namespace VTKCellProperties {
enum
{
DUPLICATE = 0,// Ghost cells that exist in another partition, i.e, are composed
// of internal boundary and ghost nodes
EXTERNAL = 1 // Cells that are created "artificially" outside the domain, i.e.,
// are composed from boundary nodes and nodes outside the domain.
};
}
#endif /* VTKMESHPROPERTY_H_ */
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGhostDataEncoder.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// C++ includes
#include <cassert>
// VTK includes
#include "vtkMeshProperty.h"
#include "vtkMeshPropertyEncoder.h"
#include "vtkObjectFactory.h"
vtkStandardNewMacro( vtkMeshPropertyEncoder );
//------------------------------------------------------------------------------
vtkMeshPropertyEncoder::vtkMeshPropertyEncoder()
{
}
//------------------------------------------------------------------------------
vtkMeshPropertyEncoder::~vtkMeshPropertyEncoder()
{
}
//------------------------------------------------------------------------------
void vtkMeshPropertyEncoder::PrintSelf( std::ostream &os, vtkIndent indent )
{
this->Superclass::PrintSelf( os, indent );
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMeshPropertyEncoder.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkMeshPropertyEncoder.h -- Encodes/Decodes mesh entity property info.
//
// .SECTION Description
// vtkMeshPropertyEncoder provides functionality for manipulating a mesh entity
// property field, represented by an "unsigned char". Each mesh entity, e.g.,
// a vertex or cell is associated with an "unsigned char" where each individual
// bit represents the state of a particular property. This class provides
// the logic required to manipulate individual bits in the "unsigned char".
//
// .SECTION Caveats
// Since a mesh property field is used to represent a mesh property field, we
// are restricted to 8 properties that each property field can be associated
// with.
//
// .SECTION See Also
// vtkMeshProperty
#ifndef vtkMeshPropertyEncoder_H_
#define vtkMeshPropertyEncoder_H_
#include "vtkObject.h"
#include <cassert> // For assert
class VTK_COMMON_EXPORT vtkMeshPropertyEncoder : public vtkObject
{
public:
static vtkMeshPropertyEncoder* New();
vtkTypeMacro( vtkMeshPropertyEncoder, vtkObject );
void PrintSelf( std::ostream& os, vtkIndent indent );
// Description:
// Sets the given property in the propertyField.
static void SetProperty( unsigned char &propertyField,const int property )
{
assert("pre:invalid property" && (property >= 0 && property < 8));
propertyField |= (1 << property);
}
// Description:
// Unsets the property from the given propertyField.
static void UnsetProperty(unsigned char &propertyField,const int property )
{
assert("pre:invalid property" && (property >= 0 && property < 8));
propertyField &= ~(1 << property);
}
// Description:
// Checks if a property is set in the given property field.
static bool IsPropertySet( unsigned char &propertyField,const int property )
{
assert("pre:invalid property" && (property >= 0 && property < 8));
return( propertyField & (1 << property) );
}
protected:
vtkMeshPropertyEncoder();
~vtkMeshPropertyEncoder();
private:
vtkMeshPropertyEncoder( const vtkMeshPropertyEncoder& ); // Not implemented
void operator=(const vtkMeshPropertyEncoder& ); // Not implemented
};
#endif /* vtkMeshPropertyEncoder_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment