(2) vtkmeanactmapper

Source: Internet
Author: User

/* ===================================================== ==========================================

Program: Visualization Toolkit
Module: $ rcsfile: vtkabstractmapper. H, V $

Copyright (c) Ken Martin, will Schroeder, Bill Lorenz
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 participant
Purpose. See the above copyright notice for more information.

========================================================== ======================================= */
//. Name vtkabstractmapper-abstract class specifies interface to map data
//. Section description
// Vtkmeanactmapper is an abstract class to specify interface between data and
// Graphics primitives or software rendering techniques. subclasses
// Vtkmeanactmapper can be used for rendering 2D data, geometry, or volumetric
// Data.
//
//. Section See also
// Vtk1_actmapper3d vtkmapper vtkpolydatamapper vtkvolumemapper

# Ifndef _ vtk1_actmapper_h
# DEFINE _ vtk1_actmapper_h

# Include "vtkalgorithm. H"

# Define vtk_scalar_mode_default 0
# Define vtk_scalar_mode_use_point_data 1
# Define vtk_scalar_mode_use_cell_data 2
# Define vtk_scalar_mode_use_point_field_data 3
# Define vtk_scalar_mode_use_cell_field_data 4
# Define vtk_scalar_mode_use_field_data 5

# Define vtk_get_array_by_id 0
# Define vtk_get_array_by_name 1

Class vtkdataarray;
Class vtkdataset;
Class vtkplane;
Class vtkplanecollection;
Class vtkplanes;
Class vtktimerlog; // time stamp
Class vtkwindow;

Class vtk_filtering_export vtkw.actmapper: Public vtkalgorithm
{
Public: // vtkalgorithm, vtkmeanactmapper
Vtktyperevisionmacro (vtkmeanactmapper, vtkalgorithm );
Void printself (ostream & OS, vtkindent indent );

// Description:
// Override modifiedtime as we have added clipping planes
Virtual unsigned long getmtime (); // timestamp. Make a time mark to record the modification time.

// Description:
// Release any graphics resources that are being consumed by this mapper.
// The parameter window cocould be used to determine which graphic
// Resources to release.
Virtual void releasegraphicsresources (vtkwindow *) {}; // release graphical Resources

// Description:
// Get the time required to draw the geometry last time it was rendered
Vtkgetmacro (timetodraw, double );

// Description:
// Specify clipping planes to be applied when the data is mapped
// (At most 6 clipping planes can be specified ).
Void addclippingplane (vtkplane * plane); // adds a shear plane. When ing geometric data into elements
Void removappspingplane (vtkplane * plane );
Void removeallclippingplanes ();

// Description:
// Get/set the vtkplanecollection which specifies
// Clipping planes.
Virtual void setclippingplanes (vtkplanecollection *); // you can specify a shear plane.
Vtkgetobjectmacro (clippingplanes, vtkplanecollection );

// Description:
// An alternative way to set clipping planes: use up to six planes found
// In the supplied instance of the implicit function vtkplanes.
Void setclippingplanes (vtkplanes * PLANeS );

// Description:
// Make a shallow copy of this mapper.
Void shallowcopy (vtkabstractmapper * m );

// Description:
// Internal helper function for getting the active scalars. The scalar
// Mode indicates where the scalars come from. The cellflag is
// Return value that is set when the scalars are cell scalars.
// (0 for point scalars, 1 for cell scalars, 2 for field scalars)
// The arrayaccessmode is used to indicate how to retrieve the scalars from
// Field data, per ID or per name (if the scalarmode indicates that ).
Static vtkdataarray * getscalars (vtkdataset * input, int scalarmode,
Int arrayaccessmode, int arrayid,
Const char * arrayname, Int & cellflag );

Protected:
Vtkmeanactmapper ();
~ Vtkmeanactmapper ();

Vtktimerlog * timer;
Double timetodraw;
Vtkwindow * lastwindow; // window used for the previous render
Vtkplanecollection * clippingplanes;

PRIVATE:
Vtkabstractmapper (const vtkabstractmapper &); // not implemented.
Void operator = (const vtkabstractmapper &); // not implemented.
};

/* ===================================================== ==========================================

Program: Visualization Toolkit
Module: $ rcsfile: vtkabstractmapper. cxx, V $

Copyright (c) Ken Martin, will Schroeder, Bill Lorenz
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 participant
Purpose. See the above copyright notice for more information.

========================================================== ======================================= */
# Include "vtkmeanactmapper. H"

# Include "vtkcelldata. H"
# Include "vtkdataset. H"
# Include "vtkobjectfactory. H"
# Include "vtkplanecollection. H"
# Include "vtkplanes. H"
# Include "vtkpointdata. H"
# Include "vtktimerlog. H"

Vtkcxxrevisionmacro (vtkw.actmapper, "$ revision: 1.6 $ ");

Vtkcxxsetobjectmacro (vtkw.actmapper, clippingplanes, vtkplanecollection );

// Construct object.
Vtkymactmapper: vtkymactmapper ()
{
This-> timetodraw = 0.0;
This-> lastwindow = NULL;
This-> clippingplanes = NULL;
This-> timer = vtktimerlog: New ();//
This-> setnumberofoutputports (0 );//
No output, directly mapped to elements, that is, directly executed
Glbegin (gl_vertex)
Glend ()
Function
This-> setnumberofinputports (1); // This-> setnumberofinputports (1)
}

Vtkabstractmapper ::~ Vtkabstractmapper ()
{
This-> timer-> Delete ();
If (this-> clippingplanes)
{
This-> clippingplanes-> unregister (this );
}
}

// Description:
// Override modifiedtime as we have added clipping planes //
Unsigned long vtkw.actmapper: getmtime ()
{
Unsigned long mtime = This-> superclass: getmtime ();
Unsigned long clipmtime;

If (this-> clippingplanes! = NULL)
{
Clipmtime = This-> clippingplanes-> getmtime ();
Mtime = (clipmtime> mtime? Clipmtime: mtime );
}

Return mtime;
}

Void vtkabstractmapper: addclippingplane (vtkplane * plane) // Add a cut surface
{
If (this-> clippingplanes = NULL)
{
This-> clippingplanes = vtkplanecollection: New ();
This-> clippingplanes-> Register (this );
This-> clippingplanes-> Delete ();
}

This-> clippingplanes-> additem (plane );
This-> modified ();
}

Void vtkabstractmapper: remov?pingplane (vtkplane * plane)
{
If (this-> clippingplanes = NULL)
{
Vtkerrormacro (<"cannot remove clipping plane: mapper has none ");
}
This-> clippingplanes-> removeitem (plane );
This-> modified ();
}

Void vtkabstractmapper: removeallclippingplanes ()
{
If (this-> clippingplanes)
{
This-> clippingplanes-> removeallitems ();
}
}

Void vtkabstractmapper: setclippingplanes (vtkplanes * PLANeS)
{
Vtkplane * plane;
If (! Planes)
{
Return;
}

Int numplanes = planes-> getnumberofplanes ();

This-> removeallclippingplanes ();
For (INT I = 0; I <numplanes & I <6; I ++)
{
Plane = vtkplane: New ();
Planes-> getplane (I, plane );
This-> addclippingplane (plane );
Plane-> Delete ();
}
}

Vtkdataarray * vtkabstractmapper: getscalars (vtkdataset * input,
Int scalarmode,
Int arrayaccessmode,
Int arrayid,
Const char * arrayname,
Int & cellflag)
{
Vtkdataarray * scalars = NULL;
Vtkpointdata * PD;
Vtkcelldata * CD;
Vtkfielddata * FD;

// Make sure we have an input
If (! Input)
{
Return NULL;
}

// Get and scalar data according to scalar Mode
If (scalarmode = vtk_scalar_mode_default)
{
Scalars = input-> getpointdata ()-> getscalars ();
Cellflag = 0;
If (! Scalars)
{
Scalars = input-> getcelldata ()-> getscalars ();
Cellflag = 1;
}
}
Else if (scalarmode = vtk_scalar_mode_use_point_data)
{
Scalars = input-> getpointdata ()-> getscalars ();
Cellflag = 0;
}
Else if (scalarmode = vtk_scalar_mode_use_cell_data)
{
Scalars = input-> getcelldata ()-> getscalars ();
Cellflag = 1;
}
Else if (scalarmode = vtk_scalar_mode_use_point_field_data)
{
Pd = input-> getpointdata ();
If (arrayaccessmode = vtk_get_array_by_id)
{
Scalars = Pd-> getarray (arrayid );
}
Else
{
Scalars = Pd-> getarray (arrayname );
}
Cellflag = 0;
}
Else if (scalarmode = vtk_scalar_mode_use_cell_field_data)
{
Cd = input-> getcelldata ();
If (arrayaccessmode = vtk_get_array_by_id)
{
Scalars = Cd-> getarray (arrayid );
}
Else
{
Scalars = Cd-> getarray (arrayname );
}
Cellflag = 1;
}
Else if (scalarmode = vtk_scalar_mode_use_field_data)
{
FD = input-> getfielddata ();
If (arrayaccessmode = vtk_get_array_by_id)
{
Scalars = FD-> getarray (arrayid );
}
Else
{
Scalars = FD-> getarray (arrayname );
}
Cellflag = 2;
}

Return scalars;
}

// Shallow copy of vtkprop.
Void vtkabstractmapper: shallowcopy (vtkabstractmapper * Mapper)
{
This-> setclippingplanes (mapper-> getclippingplanes ());
}

Void vtkabstractmapper: printself (ostream & OS, vtkindent indent)
{
This-> superclass: printself (OS, indent );

OS <indent <"timetodraw:" <this-> timetodraw <"\ n ";

If (this-> clippingplanes)
{
OS <indent <"clippingplanes: \ n ";
This-> clippingplanes-> printself (OS, indent. getnextindent ());
}
Else
{
OS <indent <"clippingplanes: (none) \ n ";
}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.