Class PwVectorField
- java.lang.Object
-
- jv.object.PsObject
-
- jvx.project.PjWorkshop
-
- jvx.vector.PwVectorField
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, PsUpdateIf, PjWorkshopIf
public class PwVectorField extends PjWorkshop
Creates a vector field on a given geometry.- See Also:
- Serialized Form
- Author:
- Eike Preuss
- Version:
- 07.10.07, 4.50 revised (kp) Full revision of update mechanism and optimization.
09.12.06, 4.00 revised (kp) Moved to jvx.vector from jvx.geom.
13.07.04, 3.50 revised (ep) Reworked the update mechanism.
12.07.04, 3.40 revised (ep) Removed most 'vector transformation' type of functionality.
23.05.03, 3.30 revised (ep) Added 1/z^k type.
14.03.03, 3.20 revised (ep) Bug with missing normals corrected.
04.03.03, 3.10 revised (kh) static Method vectorFieldFromEigenVectors added.
28.01.03, 3.00 revised (ep) Removing singularities now functions properly.
28.01.03, 2.90 revised (ep) Additional parameter 'sheer' for linear fields.
18.12.02, 2.80 revised (ep) Show edges.
20.06.02, 2.70 revised (ep) New: Make element based from vertex based vector field.
14.11.01, 2.60 revised (ep) Removed bug that occurred when dialog is opened but no vector field is created.
22.10.01, 2.50 revised (ep) Removed an update-bug.
26.09.01, 2.40 revised (ep) Disable some things for geometries withvertex dimension > 2.
19.09.01, 2.30 revised (ep) Restore visibility of elements after close.
30.08.01, 2.20 revised (ep) Added constructor without display parameter.
07.06.01, 2.10 revised (ep) Send an update in addVF and removeVF, and some checks for null.
28.05.01, 2.00 revised (ep) Do not set display to XY.
11.05.00, 1.00 created (ep)
-
-
Field Summary
Fields Modifier and Type Field and Description static intTYPE_1_Z_Kstatic intTYPE_GRADIENTstatic intTYPE_LINEARstatic intTYPE_ROTATIONstatic intTYPE_STRAIGHTstatic intTYPE_Z_K-
Fields inherited from class jv.object.PsObject
HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS
-
Fields inherited from interface jv.project.PjWorkshopIf
MODE_BUG, MODE_STANDARD, MODE_VALIDATE
-
-
Constructor Summary
Constructors Constructor and Description PwVectorField()PwVectorField(PvDisplayIf disp)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddCenter(int type)Adds a feature center of given type with default values for parameters.voidaddCenter(int type, double infl)Adds a feature center of given type.voidaddCenter(PdVector position, int type)Adds a feature center of given type at specified position with default values for parameters.voidaddCenter(PdVector position, int type, double infl)Adds a feature center of given type at specified position.static doubleangleWithNormals(PdVector v, PdVector vNormal, PdVector w, PdVector wNormal)Measure the angle between two tangential vectorsvandw, which are tangential to the planes defined by the two normalsvNormalandwNormalrespectively.static doublecalcAngle(PgVectorField field, int e1, int e2)Calculate the angle between the vectors of two adjacent elements by parallel transporting one vector to the other.voidcalculateVF()Re-calculates the vector field.static doublecalcVertexAngle(PgVectorField field, int v1, int v2)Calculate the angle between tangential vectors in two adjacent vertices, by parallel transporting v from the into the tangent plane of w and then measuring the angle.voidcancel()Removes all added features to get the original state and closes the workshop.voidclearCenter()Removes all feature centers that where added in this session.voidclose()Close workshop and remove itself as listener from various classes.voidfixVF()'Burns' the features into the vector field irreversible.intgetCenterType(int index)Type of the given feature.static PgVectorFieldgetInterpolatedElementBased(PgVectorField input, PgVectorField output)If this vector field is element based, simply a copy is returned.static PgVectorFieldgetInterpolatedVertexBased(PgVectorField input, PgVectorField output)intgetNumCenters()Number of feature center added in this session.intgetSelectedCenter()Index of the feature center currently active in the info panel.PgVectorFieldgetSelectedVF()Currently active vector field used in this workshop.intgetSelectedVFIndex()Index of currently active vector field as used in the underlying geometry.voidinit()Initialize and reset project, stops the running animation if any.booleanisEnabledConvert()Whether the user interface allows conversion to other base.voidmakeNewVF(int type)Creates a new vector field, puts it onto the surface and selects it.static voidnormalizeVectorField(PgVectorField vf)Normalize all vectors of a vector field to unit length.voidok()Applies the features to the vector field and closes the workshop.static PdVectorparallelTransport(PgElementSet geom, PdVector vector, int e, int i, PdVector outVec)Parallel transport a vector from element e into its neighbour element with local neighbour index i.voidremoveCenter(int index)Removes the given feature center.voidremoveGeometry()Remove the assigned geometry and its backup clone.voidreset()TODO: Not implemented yet (call of init() not tested yet).static voidrotateVectorField(PgVectorField vf)Rotate a tangential vector field by 90 degree in the tangent plane of the geometry.static voidrotateVectorField(PgVectorField vf, double angle)Rotate a vector field in the tangent plane of the geometry.voidselectCenter(int centerIndex)Selects the specified feature center.voidsetCenterInfluence(int centerIndex, double influence)Sets all parameters of the given feature center to the given value.voidsetCenterType(int centerIndex, int type)Sets the type of given feature center to different type.voidsetDisplay(PvDisplayIf disp)In this display the feature centers are shown and can be interactively changed.voidsetEnabledConvert(boolean flag)Controls the user interface for converting vertex based vector fields into element based vector fields.voidsetGeometry(PgGeometry geom)Assign a geometry on which this workshop operates, and create a backup clone of the geometry.voidsetMakeTangential(boolean flag)Specifies whether the vector field should be made tangential (for element sets).voidsetSelectedVF(int index)Selects a vector field from the list of fields in underlying geometry.booleanupdate(java.lang.Object event)React on events.static PdVector[][]vectorFieldFromEigenVectors(PdVector[][] vec, PgElementSet geom)Given a vertex based (1,1)-tensor field t as a double array of vectors, where each vector points into an eigendirection of t and has the length of the absolute of the corresponding eigenvalue, the method changes the order of the vectors at a vertex and the sign of the vector, in order to make it consistent on the geometry.-
Methods inherited from class jvx.project.PjWorkshop
getDisplay, getDisplays, getGeometry, getMode, getSavedGeometry, getViewer, isModal, isStandalone, setDisplays, setModal, setMode, setStandalone, setViewer
-
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, toString, updatePanels
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jv.object.PsUpdateIf
getFather, getName, setParent
-
-
-
-
Field Detail
-
TYPE_ROTATION
public static final int TYPE_ROTATION
- See Also:
- Constant Field Values
-
TYPE_GRADIENT
public static final int TYPE_GRADIENT
- See Also:
- Constant Field Values
-
TYPE_STRAIGHT
public static final int TYPE_STRAIGHT
- See Also:
- Constant Field Values
-
TYPE_LINEAR
public static final int TYPE_LINEAR
- See Also:
- Constant Field Values
-
TYPE_Z_K
public static final int TYPE_Z_K
- See Also:
- Constant Field Values
-
TYPE_1_Z_K
public static final int TYPE_1_Z_K
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PwVectorField
public PwVectorField()
-
PwVectorField
public PwVectorField(PvDisplayIf disp)
-
-
Method Detail
-
init
public void init()
Description copied from class:PjWorkshopInitialize and reset project, stops the running animation if any. Does not reset any registered display nor geometry. They must be reset individually in each subclass.- Overrides:
initin classPjWorkshop
-
setDisplay
public void setDisplay(PvDisplayIf disp)
In this display the feature centers are shown and can be interactively changed.- Specified by:
setDisplayin interfacePjWorkshopIf- Overrides:
setDisplayin classPjWorkshop
-
setGeometry
public void setGeometry(PgGeometry geom)
Description copied from class:PjWorkshopAssign a geometry on which this workshop operates, and create a backup clone of the geometry. The backup geometry is restored if the workshop is canceled.Subclasses frequently overwrite this method but are advised to call this method.
- Specified by:
setGeometryin interfacePjWorkshopIf- Overrides:
setGeometryin classPjWorkshop- Parameters:
geom- Special things happen if geometry is an element set, tangential vector fields etc.- Version:
- 03.02.07, 2.00 revised (kp) Method now overloads PjWorkshop#setGeometry(PgGeometry).
-
removeGeometry
public void removeGeometry()
Description copied from class:PjWorkshopRemove the assigned geometry and its backup clone. Subclasses frequently overwrite this method but are advised to call this method.- Overrides:
removeGeometryin classPjWorkshop
-
update
public boolean update(java.lang.Object event)
React on events.- Specified by:
updatein interfacePsUpdateIf- Overrides:
updatein classPjWorkshop- Parameters:
event- if event is 'this' then the various objects are updated and the vector field computed- Returns:
- true at success
- See Also:
PsUpdateIf.update(java.lang.Object)
-
setEnabledConvert
public void setEnabledConvert(boolean flag)
Controls the user interface for converting vertex based vector fields into element based vector fields.You need to call
update(this)to apply changes.- Parameters:
flag- default is true
-
isEnabledConvert
public boolean isEnabledConvert()
Whether the user interface allows conversion to other base.- See Also:
setEnabledConvert(boolean)
-
setCenterType
public void setCenterType(int centerIndex, int type)Sets the type of given feature center to different type.You need to call
update(this)to apply the changes!- Parameters:
centerIndex- starts at 0type- see the TYPE_... constants
-
setCenterInfluence
public void setCenterInfluence(int centerIndex, double influence)Sets all parameters of the given feature center to the given value.You need to call
update(this)to apply the changes!- Parameters:
centerIndex- starts at 0
-
selectCenter
public void selectCenter(int centerIndex)
Selects the specified feature center.You must call
update(this)afterwards.- Parameters:
centerIndex- starts at 0
-
getCenterType
public int getCenterType(int index)
Type of the given feature. Compare the TYPE_... constants.- Parameters:
index- starts at 0- Returns:
- -1 at error
-
getNumCenters
public int getNumCenters()
Number of feature center added in this session.- Returns:
- -1 at error
-
getSelectedCenter
public int getSelectedCenter()
Index of the feature center currently active in the info panel.- Returns:
- index starting with 0; -1 at error
-
getSelectedVFIndex
public int getSelectedVFIndex()
Index of currently active vector field as used in the underlying geometry.- Returns:
- -1 at error
-
getSelectedVF
public PgVectorField getSelectedVF()
Currently active vector field used in this workshop.- Returns:
- null if no vector field active
-
addCenter
public void addCenter(int type)
Adds a feature center of given type with default values for parameters.You need to call
update(this)to apply the changes!- Parameters:
type- see the TYPE_... constants.
-
addCenter
public void addCenter(int type, double infl)Adds a feature center of given type. Sets all parameters to 'infl'.You need to call
update(this)to apply the changes!- Parameters:
type- see the TYPE_... constants.infl- value for all parameters of this feature
-
addCenter
public void addCenter(PdVector position, int type, double infl)
Adds a feature center of given type at specified position. Sets all parameters to 'infl'.You need to call
update(this)to apply the changes!- Parameters:
position- zeros are added if dimension of this parameter is to small, and excessive entries are ignored.type- see the TYPE_... constants.infl- value for all parameters of this feature
-
addCenter
public void addCenter(PdVector position, int type)
Adds a feature center of given type at specified position with default values for parameters.You need to call
update(this)to apply the changes!- Parameters:
position- zeros are added if dimension of this parameter is to small, and excessive entries are ignored.type- see the TYPE_... constants.
-
removeCenter
public void removeCenter(int index)
Removes the given feature center.You need to call
update(this)afterwards!- Parameters:
index- starts at 0
-
clearCenter
public void clearCenter()
Removes all feature centers that where added in this session.You need to call
update(this)to apply the changes!
-
makeNewVF
public void makeNewVF(int type)
Creates a new vector field, puts it onto the surface and selects it.Must call
update(this)to apply.- Parameters:
type- element based or vertex based- See Also:
PgVectorField,PgVectorField.setBasedOn(int)
-
setSelectedVF
public void setSelectedVF(int index)
Selects a vector field from the list of fields in underlying geometry.You need to call
update(this)afterwards.- Parameters:
index- starts at 0
-
fixVF
public void fixVF()
'Burns' the features into the vector field irreversible.Need to call
update(this)afterwards!
-
setMakeTangential
public void setMakeTangential(boolean flag)
Specifies whether the vector field should be made tangential (for element sets). Tangential vector fields are orthogonal to normal vectors.Call
update(this)to apply changes.- Parameters:
flag- true is default
-
cancel
public void cancel()
Removes all added features to get the original state and closes the workshop. (Removes geometry, display, ...).- Overrides:
cancelin classPjWorkshop- See Also:
PjWorkshop.cancel()
-
close
public void close()
Close workshop and remove itself as listener from various classes. The workshop will no longer be working after this call.Subclasses may remove workshop from geometry as update listener, or remove any temporary geometries from display, if necessary.
Implementation in this class simply calls
removeGeometry().- Overrides:
closein classPjWorkshop
-
ok
public void ok()
Applies the features to the vector field and closes the workshop. (Removes geometry, display, ...).- Overrides:
okin classPjWorkshop- See Also:
PjWorkshop.close()
-
reset
public void reset()
TODO: Not implemented yet (call of init() not tested yet).- Overrides:
resetin classPjWorkshop
-
calculateVF
public void calculateVF()
Re-calculates the vector field.
-
parallelTransport
public static PdVector parallelTransport(PgElementSet geom, PdVector vector, int e, int i, PdVector outVec)
Parallel transport a vector from element e into its neighbour element with local neighbour index i.- Parameters:
vector- A vector in e.e- Element.i- Local neighbour index of neighbour element.- Author:
- Matthias Nieser
- Version:
- 08.03.2015, 2.00 revised (kp) Moved to jvx.vector.PwVectorField from dev.vecmath.PuVectorGeom.
09.06.09, 1.00 created (mn)
-
calcVertexAngle
public static double calcVertexAngle(PgVectorField field, int v1, int v2)
Calculate the angle between tangential vectors in two adjacent vertices, by parallel transporting v from the into the tangent plane of w and then measuring the angle.- Parameters:
field- vector field to measure the angles in. The vector field contains the underlying geometry.v1- A vertex.v2- A vertex adjacent to v1.- Returns:
- The angle measured in radians.
- Author:
- Felix Kaelberer
- Version:
- 08.03.2015, 2.00 revised (kp) Moved to jvx.vector.PwVectorField from dev.vecmath.PuVectorGeom.
22.06.2006, 1.00 created (fk)
-
calcAngle
public static double calcAngle(PgVectorField field, int e1, int e2)
Calculate the angle between the vectors of two adjacent elements by parallel transporting one vector to the other.- Parameters:
field- vector field to measure the angles in. The vector field contains the underlying geometry.e1- An element.e2- An element adjacent to e1.- Returns:
- The angle in radians in [0, 2*pi].
- Author:
- Felix Kaelberer
- Version:
- 08.03.2015, 2.00 revised (kp) Moved to jvx.vector.PwVectorField from dev.vecmath.PuVectorGeom.
22.06.2006, 1.00 created (fk)
-
angleWithNormals
public static double angleWithNormals(PdVector v, PdVector vNormal, PdVector w, PdVector wNormal)
Measure the angle between two tangential vectorsvandw, which are tangential to the planes defined by the two normalsvNormalandwNormalrespectively. Before measuring the angle, one vector is parallel transported into the tangential plane of the other.- Parameters:
v- One vectorvNormal- Normal vector to the tangential plane ofv.w- Another vectorwNormal- Normal vector to the tangential plane ofw.- Returns:
- Angle between
vandw, in radians. - Author:
- Felix Kaelberer, Matthias Nieser
- Version:
- 08.03.2015, 2.00 revised (kp) Moved to jvx.vector.PwVectorField from dev.vecmath.PuVectorGeom.
22.06.2006, 1.00 created (fk) Extracted functionality from method calcMatching().
-
getInterpolatedElementBased
public static PgVectorField getInterpolatedElementBased(PgVectorField input, PgVectorField output)
If this vector field is element based, simply a copy is returned. Otherwise, an element based vector field is created by adding the vectors of all vertices that belong to an element, divided by the number of vertices.- Parameters:
output- if notnullthen the created vector field is copied to it
-
getInterpolatedVertexBased
public static PgVectorField getInterpolatedVertexBased(PgVectorField input, PgVectorField output)
-
vectorFieldFromEigenVectors
public static PdVector[][] vectorFieldFromEigenVectors(PdVector[][] vec, PgElementSet geom)
Given a vertex based (1,1)-tensor field t as a double array of vectors, where each vector points into an eigendirection of t and has the length of the absolute of the corresponding eigenvalue, the method changes the order of the vectors at a vertex and the sign of the vector, in order to make it consistent on the geometry. This is useful for example to visualize the tensor field with LIC.- Parameters:
vec- vertex based (1,1)-tensor field represented by eigenvectors that have the length of the absolute of the corresponding eigenvalue. The first index specifies the eigenvector (0 or 1), the second one the vertex by index.- Author:
- Klaus Hildebrandt
- Version:
- 12.02.03, 1.00 created (kh) separated from PwCurvature.getPrincipalCurvatureFromEdgeCurvature
-
rotateVectorField
public static void rotateVectorField(PgVectorField vf)
Rotate a tangential vector field by 90 degree in the tangent plane of the geometry. For element based vector fields this means in the plane of the triangle, for vertex based vector fields this means in the plane orthogonal to the vertex normal.Method only applies to vector fields that live on a geometry in (HACK: currently) 2- or 3-dimensional Euclidean space. HACK: 3D version currently relies on correct element normals respectively vertex normal, but this will change.
- Author:
- Klaus Hildebrandt, Konrad Polthier
- Version:
- 27.10.12, 2.00 revised (kp) Check validity of data, streamlined code.
27.07.11, 1.60 revised (mn) Bugfix with assure element normals
22.08.07, 1.50 revised (kp) Implement rotation in 2D.
08.11.04, 1.00 created (kh)
-
rotateVectorField
public static void rotateVectorField(PgVectorField vf, double angle)
Rotate a vector field in the tangent plane of the geometry. For element based vector fields this means in the plane of the triangle, for vertex based vector fields this means in the plane orthogonal to the vertex normal.Method only applies to vector fields that live on a geometry in (HACK: currently) 2- or 3-dimensional Euclidean space. HACK: currently relies on correct element normals resp. vertex normal, but this will change.
- Parameters:
vf- vector field to be rotated.angle- angle of the rotation in radians.- Author:
- Klaus Hildebrandt
- Version:
- 27.10.12, 2.00 revised (kp) Check validity of data, streamlined code.
08.11.04, 1.00 created (kh)
-
normalizeVectorField
public static void normalizeVectorField(PgVectorField vf)
Normalize all vectors of a vector field to unit length.- Author:
- Klaus Hildebrandt
- Version:
- 09.12.06, 1.10 revised (kp) Only operate on number of vectors, not max number.
08.11.04, 1.00 created (kh)
-
-
"