mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
9
src/MeshVS/FILES
Executable file
9
src/MeshVS/FILES
Executable file
@@ -0,0 +1,9 @@
|
||||
MeshVS_Buffer.hxx
|
||||
MeshVS_EntityType.hxx
|
||||
MeshVS_DisplayModeFlags.hxx
|
||||
MeshVS_BuilderPriority.hxx
|
||||
MeshVS_MeshPrsBuilder.lxx
|
||||
MeshVS_TwoColors.hxx
|
||||
MeshVS_TwoColors.cxx
|
||||
MeshVS_TwoNodes.hxx
|
||||
MeshVS_SelectionModeFlags.hxx
|
198
src/MeshVS/MeshVS.cdl
Executable file
198
src/MeshVS/MeshVS.cdl
Executable file
@@ -0,0 +1,198 @@
|
||||
-- File : MeshVS.cdl
|
||||
-- Created : 10 October 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
package MeshVS
|
||||
|
||||
---Purpose: This package provides classes and simple methods of flexible presentation object
|
||||
-- that is responsible for the following tasks:
|
||||
-- 1) Displaying mesh ( some mesh elements and nodes may be hidden )
|
||||
-- 2) Results of calculations and analysis are shown through the single common interface.
|
||||
-- 3) The data can be shown with different visual styles: colors, vectors, texts and deformed mesh.
|
||||
-- 4) Selection of mesh entities (except hidden ones)
|
||||
|
||||
uses
|
||||
Quantity, AIS, PrsMgr, Prs3d, SelectMgr, TColStd, SelectBasics,
|
||||
Graphic3d, gp, TCollection, Bnd, TColgp, Select3D, TopLoc, Aspect, AlienImage
|
||||
|
||||
is
|
||||
---Purpose: The integer keys for most useful constants attuning mesh presentation appearence
|
||||
-- WARNING: DA_TextExpansionFactor, DA_TextSpace, DA_TextDisplayType have no effect and might be removed
|
||||
-- in the future.
|
||||
|
||||
enumeration DrawerAttribute is
|
||||
|
||||
-- Attributes of AspectFillArea3d
|
||||
DA_InteriorStyle,
|
||||
DA_InteriorColor,
|
||||
DA_BackInteriorColor,
|
||||
DA_EdgeColor,
|
||||
DA_EdgeType,
|
||||
DA_EdgeWidth,
|
||||
DA_HatchStyle,
|
||||
DA_FrontMaterial,
|
||||
DA_BackMaterial,
|
||||
-- Attributes of AspectLine3d
|
||||
DA_BeamType,
|
||||
DA_BeamWidth,
|
||||
DA_BeamColor,
|
||||
-- Attributes of AspectMarker3d
|
||||
DA_MarkerType,
|
||||
DA_MarkerColor,
|
||||
DA_MarkerScale,
|
||||
-- Attributes of AspectText3d
|
||||
DA_TextColor,
|
||||
DA_TextHeight,
|
||||
DA_TextFont,
|
||||
DA_TextExpansionFactor,
|
||||
DA_TextSpace,
|
||||
DA_TextStyle,
|
||||
DA_TextDisplayType,
|
||||
DA_TextTexFont,
|
||||
DA_TextFontAspect,
|
||||
-- Attributes of vector presentation
|
||||
DA_VectorColor,
|
||||
DA_VectorMaxLength,
|
||||
DA_VectorArrowPart,
|
||||
|
||||
-- Attributes of MeshVS_Mesh
|
||||
DA_IsAllowOverlapped,
|
||||
---Purpose: Is it allowed to draw beam and face's edge overlapping with this beam.
|
||||
|
||||
DA_Reflection,
|
||||
---Purpose: Is mesh drawn with reflective material
|
||||
|
||||
DA_ColorReflection,
|
||||
---Purpose: Is colored mesh data representation drawn with reflective material
|
||||
|
||||
DA_ShrinkCoeff,
|
||||
---Purpose: What part of face or link will be shown if shrink mode. It is recommended this coeff to be between 0 and 1.
|
||||
|
||||
DA_MaxFaceNodes,
|
||||
---Purpose: How many nodes is possible to be in face
|
||||
|
||||
DA_ComputeTime,
|
||||
---Purpose: If this parameter is true, the compute method CPU time will be displayed in console window
|
||||
|
||||
DA_ComputeSelectionTime,
|
||||
---Purpose: If this parameter is true, the compute selection method CPU time will be displayed in console window
|
||||
|
||||
DA_DisplayNodes,
|
||||
---Purpose: If this parameter is false, the nodes won't be shown in viewer, otherwise will be.
|
||||
|
||||
DA_SelectableAuto,
|
||||
---Purpose: If this parameter is true, the selectable nodes map will be updated automatically when hidden elements change
|
||||
|
||||
DA_ShowEdges,
|
||||
---Purpose: If this parameter is false, the face's edges are not shown
|
||||
-- Warning: in wireframe mode this parameter is ignored
|
||||
|
||||
DA_SmoothShading,
|
||||
---Purpose: Is mesh drawing in smooth shading mode
|
||||
|
||||
DA_SupressBackFaces,
|
||||
---Purpose: Is back faces of volume elements should be supressed
|
||||
|
||||
DA_User
|
||||
|
||||
end DrawerAttribute;
|
||||
|
||||
---Purpose: this enumeration describe what type of sensitive entity will be built
|
||||
-- in 0-th selection mode (it means that whole mesh is selected )
|
||||
enumeration MeshSelectionMethod is
|
||||
|
||||
MSM_PRECISE, -- the list of sensitive entities according to nodes and elements (the slowest method)
|
||||
MSM_NODES, -- only set of sensitive points of nodes
|
||||
MSM_BOX -- mesh bounding box (the fastest method)
|
||||
|
||||
end MeshSelectionMethod;
|
||||
|
||||
class Mesh;
|
||||
pointer MeshPtr to Mesh from MeshVS;
|
||||
class Drawer;
|
||||
deferred class DataSource;
|
||||
deferred class DataSource3D;
|
||||
class DeformedDataSource;
|
||||
|
||||
---Category: Presentation builders for some ordinary types of data
|
||||
|
||||
deferred class PrsBuilder;
|
||||
class MeshPrsBuilder;
|
||||
class NodalColorPrsBuilder;
|
||||
class ElementalColorPrsBuilder;
|
||||
class TextPrsBuilder;
|
||||
class VectorPrsBuilder;
|
||||
|
||||
---Category: Classes for selection: special owner and sensitive entities
|
||||
|
||||
class MeshOwner;
|
||||
class MeshEntityOwner;
|
||||
|
||||
class DummySensitiveEntity;
|
||||
class SensitiveMesh;
|
||||
class SensitiveFace;
|
||||
class SensitiveSegment;
|
||||
class SensitivePolyhedron;
|
||||
|
||||
---Category: miscellaneous types: data maps, enumerations and other
|
||||
|
||||
imported EntityType;
|
||||
imported DisplayModeFlags;
|
||||
imported SelectionModeFlags;
|
||||
imported TwoColors;
|
||||
imported BuilderPriority;
|
||||
imported TwoNodes;
|
||||
imported Buffer;
|
||||
|
||||
class Tool;
|
||||
|
||||
class SequenceOfPrsBuilder instantiates Sequence from TCollection ( PrsBuilder );
|
||||
|
||||
class DataMapOfIntegerColor instantiates DataMap from TCollection
|
||||
( Integer, Color from Quantity, MapIntegerHasher from TColStd );
|
||||
|
||||
class DataMapOfIntegerMaterial instantiates DataMap from TCollection
|
||||
( Integer, MaterialAspect from Graphic3d, MapIntegerHasher from TColStd );
|
||||
|
||||
class DataMapOfIntegerBoolean instantiates DataMap from TCollection
|
||||
( Integer, Boolean, MapIntegerHasher from TColStd );
|
||||
|
||||
class DataMapOfIntegerOwner instantiates DataMap from TCollection
|
||||
( Integer, EntityOwner from SelectMgr, MapIntegerHasher from TColStd );
|
||||
|
||||
class DataMapOfIntegerMeshEntityOwner instantiates DataMap from TCollection
|
||||
( Integer, MeshEntityOwner from MeshVS, MapIntegerHasher from TColStd );
|
||||
|
||||
class DataMapOfIntegerAsciiString instantiates DataMap from TCollection
|
||||
( Integer, AsciiString from TCollection, MapIntegerHasher from TColStd );
|
||||
|
||||
class DataMapOfIntegerTwoColors instantiates DataMap from TCollection
|
||||
( Integer, TwoColors from MeshVS, MapIntegerHasher from TColStd );
|
||||
|
||||
class DataMapOfIntegerVector instantiates DataMap from TCollection
|
||||
( Integer, Vec from gp, MapIntegerHasher from TColStd );
|
||||
|
||||
class TwoColorsHasher instantiates MapHasher from TCollection( TwoColors );
|
||||
|
||||
class ColorHasher;
|
||||
|
||||
class DataMapOfTwoColorsMapOfInteger instantiates DataMap from TCollection
|
||||
( TwoColors from MeshVS, MapOfInteger from TColStd, TwoColorsHasher );
|
||||
|
||||
class DataMapOfColorMapOfInteger instantiates DataMap from TCollection
|
||||
( Color from Quantity, MapOfInteger from TColStd, ColorHasher );
|
||||
|
||||
class Array1OfSequenceOfInteger instantiates Array1 from TCollection( SequenceOfInteger from TColStd );
|
||||
|
||||
class HArray1OfSequenceOfInteger instantiates HArray1 from TCollection
|
||||
( SequenceOfInteger from TColStd, Array1OfSequenceOfInteger );
|
||||
|
||||
class DataMapOfHArray1OfSequenceOfInteger instantiates DataMap from TCollection
|
||||
( Integer, HArray1OfSequenceOfInteger from MeshVS, MapIntegerHasher from TColStd );
|
||||
|
||||
class TwoNodesHasher instantiates MapHasher from TCollection( TwoNodes );
|
||||
|
||||
class MapOfTwoNodes instantiates Map from TCollection( TwoNodes, TwoNodesHasher );
|
||||
|
||||
end MeshVS;
|
72
src/MeshVS/MeshVS_Buffer.hxx
Executable file
72
src/MeshVS/MeshVS_Buffer.hxx
Executable file
@@ -0,0 +1,72 @@
|
||||
// File: MeshVS_Buffer.hxx
|
||||
// Created: 07.03.07 15:53:17
|
||||
// Author: msv@EUCLIDEX
|
||||
// Copyright: Open CASCADE 2007
|
||||
|
||||
#ifndef MeshVS_Buffer_HeaderFile
|
||||
#define MeshVS_Buffer_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
|
||||
/**
|
||||
* General purpose buffer that is allocated on the stack with a
|
||||
* constant size MeshVS_BufSize, or is allocated dynamically if the requested
|
||||
* size exceeds the standard one.
|
||||
* It is useful when an allocation of an array of unknown size is needed,
|
||||
* and most often the array is small enough to allocate as automatic C array.
|
||||
*/
|
||||
|
||||
//! define the constant to the size of 10 points
|
||||
#define MeshVS_BufSize 10*3*sizeof(double)
|
||||
|
||||
class MeshVS_Buffer
|
||||
{
|
||||
public:
|
||||
//! Constructor of the buffer of the requested size
|
||||
MeshVS_Buffer (const Standard_Size theSize)
|
||||
: myDynData (0)
|
||||
{
|
||||
if (theSize > MeshVS_BufSize)
|
||||
myDynData = Standard::Allocate (theSize);
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
~MeshVS_Buffer()
|
||||
{
|
||||
if (myDynData)
|
||||
{
|
||||
Standard::Free (myDynData);
|
||||
myDynData = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//! Cast the buffer to the void pointer
|
||||
operator void* ()
|
||||
{
|
||||
return myDynData ? myDynData : (void*) myAutoData;
|
||||
}
|
||||
|
||||
//! Interpret the buffer as a reference to double
|
||||
operator Standard_Real& ()
|
||||
{
|
||||
return * (myDynData ? (Standard_Real*) myDynData : (Standard_Real*) myAutoData);
|
||||
}
|
||||
|
||||
//! Interpret the buffer as a reference to int
|
||||
operator Standard_Integer& ()
|
||||
{
|
||||
return * (myDynData ? (Standard_Integer*) myDynData : (Standard_Integer*) myAutoData);
|
||||
}
|
||||
|
||||
private:
|
||||
//! Deprecate copy constructor
|
||||
MeshVS_Buffer(const MeshVS_Buffer&) {}
|
||||
|
||||
//! Deprecate copy operation
|
||||
MeshVS_Buffer& operator=(const MeshVS_Buffer&) {return *this;}
|
||||
|
||||
char myAutoData[ MeshVS_BufSize ];
|
||||
void* myDynData;
|
||||
};
|
||||
|
||||
#endif
|
23
src/MeshVS/MeshVS_BuilderPriority.hxx
Executable file
23
src/MeshVS/MeshVS_BuilderPriority.hxx
Executable file
@@ -0,0 +1,23 @@
|
||||
// File: MeshVS_BuilderPriority.hxx
|
||||
// Created: Thu Dec 11 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#ifndef MeshVS_BUILDERPRIORITY_HXX
|
||||
#define MeshVS_BUILDERPRIORITY_HXX
|
||||
|
||||
Standard_EXPORT typedef Standard_Integer MeshVS_BuilderPriority;
|
||||
|
||||
enum
|
||||
{
|
||||
MeshVS_BP_Mesh = 5,
|
||||
MeshVS_BP_NodalColor = 10,
|
||||
MeshVS_BP_ElemColor = 15,
|
||||
MeshVS_BP_Text = 20,
|
||||
MeshVS_BP_Vector = 25,
|
||||
MeshVS_BP_User = 30,
|
||||
MeshVS_BP_Default = MeshVS_BP_User
|
||||
|
||||
};
|
||||
|
||||
#endif
|
19
src/MeshVS/MeshVS_ColorHasher.cdl
Executable file
19
src/MeshVS/MeshVS_ColorHasher.cdl
Executable file
@@ -0,0 +1,19 @@
|
||||
-- File : MeshVS_ColorHasher.cdl
|
||||
-- Created : 5 December 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
|
||||
class ColorHasher from MeshVS inherits MapIntegerHasher from TColStd
|
||||
|
||||
---Purpose: Hasher for using in ColorToIdsMap from MeshVS
|
||||
|
||||
uses
|
||||
Color from Quantity
|
||||
|
||||
is
|
||||
HashCode ( myclass; K : Color from Quantity; Upper : Integer ) returns Integer;
|
||||
|
||||
IsEqual ( myclass; K1, K2 : Color from Quantity ) returns Boolean;
|
||||
|
||||
end ColorHasher;
|
41
src/MeshVS/MeshVS_ColorHasher.cxx
Executable file
41
src/MeshVS/MeshVS_ColorHasher.cxx
Executable file
@@ -0,0 +1,41 @@
|
||||
// File: MeshVS_ColorHasher.cxx
|
||||
// Created: Fri Dec 5 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_ColorHasher.ixx>
|
||||
|
||||
//================================================================
|
||||
// Function : HashCode
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Integer MeshVS_ColorHasher::HashCode ( const Quantity_Color& theCol, const Standard_Integer theUpper )
|
||||
{
|
||||
Standard_Integer r = Standard_Integer( 255 * theCol.Red () ),
|
||||
g = Standard_Integer( 255 * theCol.Green () ),
|
||||
b = Standard_Integer( 255 * theCol.Blue () );
|
||||
|
||||
#define MESHPRS_HASH_BYTE(val) { \
|
||||
aHash += (val); \
|
||||
aHash += (aHash << 10); \
|
||||
aHash ^= (aHash >> 6); \
|
||||
}
|
||||
Standard_Integer aHash = 0;
|
||||
MESHPRS_HASH_BYTE ( r )
|
||||
MESHPRS_HASH_BYTE ( g )
|
||||
MESHPRS_HASH_BYTE ( b )
|
||||
aHash += (aHash << 3);
|
||||
aHash ^= (aHash >> 11);
|
||||
aHash += (aHash << 15);
|
||||
return (( aHash & 0x7fff ) % theUpper) + 1;
|
||||
#undef MESHPRS_HASH_BYTE
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : IsEqual
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_ColorHasher::IsEqual( const Quantity_Color& K1, const Quantity_Color& K2 )
|
||||
{
|
||||
return K1==K2;
|
||||
}
|
209
src/MeshVS/MeshVS_DataSource.cdl
Executable file
209
src/MeshVS/MeshVS_DataSource.cdl
Executable file
@@ -0,0 +1,209 @@
|
||||
-- File : MeshVS_DataSource.cdl
|
||||
-- Created : 10 October 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
deferred class DataSource from MeshVS inherits TShared from MMgt
|
||||
|
||||
---Purpose: The deferred class using for the following tasks:
|
||||
-- 1) Receiving geometry data about single element of node by its number;
|
||||
-- 2) Receiving type of element or node by its number;
|
||||
-- 3) Receiving topological information about links between element and nodes it consist of;
|
||||
-- 4) Receiving information about what element cover this node;
|
||||
-- 5) Receiving information about all nodes and elements the object consist of
|
||||
-- 6) Activation of advanced mesh selection. In the advanced mesh selection mode there is created:
|
||||
-- - one owner for the whole mesh and for all selection modes
|
||||
-- - one sensitive entity for the whole mesh and for each selection mode
|
||||
-- Receiving of IDs of detected entities (nodes and elements) in a viewer is achieved by
|
||||
-- implementation of a group of methods GetDetectedEntities.
|
||||
|
||||
uses
|
||||
Integer from Standard,
|
||||
Boolean from Standard,
|
||||
Address from Standard,
|
||||
|
||||
Array1OfReal from TColStd,
|
||||
Array1OfInteger from TColStd,
|
||||
PackedMapOfInteger from TColStd,
|
||||
HPackedMapOfInteger from TColStd,
|
||||
HArray1OfReal from TColStd,
|
||||
Array1OfPnt2d from TColgp,
|
||||
|
||||
EntityType from MeshVS,
|
||||
HArray1OfSequenceOfInteger from MeshVS,
|
||||
|
||||
Box2d from Bnd,
|
||||
Box from Bnd,
|
||||
|
||||
Mesh from MeshVS
|
||||
|
||||
is
|
||||
|
||||
GetGeom ( me; ID : Integer;
|
||||
IsElement : Boolean;
|
||||
Coords : out Array1OfReal from TColStd;
|
||||
NbNodes : out Integer;
|
||||
Type : out EntityType from MeshVS ) returns Boolean is deferred;
|
||||
---Purpose: Returns geometry information about node or element
|
||||
-- ID is the numerical identificator of node or element
|
||||
-- IsElement indicates this ID describe node ( if Standard_False ) or element ( if Standard_True )
|
||||
-- Coords is an array of co-ordinates of node(s).
|
||||
-- For node it is only 3 numbers: X, Y, Z in the strict order
|
||||
-- For element it is 3*n numbers, where n is number of this element vertices
|
||||
-- The order is strict also: X1, Y1, Z1, X2,...., where Xi, Yi, Zi are co-ordinates of vertices
|
||||
-- NbNodes is number of nodes. It is recommended this parameter to be set to 1 for node.
|
||||
-- Type is type of node or element (from enumeration). It is recommended this parameter to be set to
|
||||
-- MeshVS_ET_Node for node.
|
||||
|
||||
GetGeomType ( me; ID : Integer;
|
||||
IsElement : Boolean;
|
||||
Type : out EntityType from MeshVS ) returns Boolean is deferred;
|
||||
---Purpose: This method is similar to GetGeom, but returns only element or node type.
|
||||
--This method is provided for finer performance.
|
||||
|
||||
Get3DGeom( me; ID : Integer;
|
||||
NbNodes : out Integer;
|
||||
Data : out HArray1OfSequenceOfInteger from MeshVS ) returns Boolean is virtual;
|
||||
---Purpose: This method returns topology information about 3D-element
|
||||
-- Returns false if element with ID isn't 3D or because other troubles
|
||||
|
||||
|
||||
GetAddr ( me; ID : Integer;
|
||||
IsElement : Boolean ) returns Address is deferred;
|
||||
---Purpose: This method returns pointer which represents element or node data structure.
|
||||
-- This address will be saved in MeshVS_MeshEntityOwner, so that you can access to data structure fast
|
||||
-- by the method Owner(). In the redefined method you can return NULL.
|
||||
-- ID is the numerical identificator of node or element
|
||||
-- IsElement indicates this ID describe node ( if Standard_False ) or element ( if Standard_True )
|
||||
|
||||
GetNodesByElement ( me; ID : Integer;
|
||||
NodeIDs : out Array1OfInteger from TColStd;
|
||||
NbNodes : out Integer ) returns Boolean is deferred;
|
||||
---Purpose: This method returns information about nodes this element consist of.
|
||||
-- ID is the numerical identificator of element.
|
||||
-- NodeIDs is the output array of nodes IDs in correct order,
|
||||
-- the same as coordinates returned by GetGeom().
|
||||
-- NbNodes is number of nodes (number of items set in NodeIDs).
|
||||
-- Returns False if element does not exist
|
||||
|
||||
GetAllNodes ( me ) returns PackedMapOfInteger from TColStd is deferred;
|
||||
---C++: return const &
|
||||
---Purpose: This method returns map of all nodes the object consist of.
|
||||
|
||||
GetAllElements ( me ) returns PackedMapOfInteger from TColStd is deferred;
|
||||
---C++: return const &
|
||||
---Purpose: This method returns map of all elements the object consist of.
|
||||
|
||||
GetNormal ( me; Id : Integer; Max : Integer;
|
||||
nx, ny, nz : out Real ) returns Boolean is virtual;
|
||||
---Purpose: This method calculates normal of face, which is using for correct reflection presentation.
|
||||
-- There is default method, for advance reflection this method can be redefined.
|
||||
-- Id is the numerical identificator of only element!
|
||||
-- Max is maximal number of nodes an element can consist of
|
||||
-- nx, ny, nz are values whose represent co-ordinates of normal (will be returned)
|
||||
-- In the redefined method you can return normal with length more then 1, but in this case
|
||||
-- the appearance of element will be more bright than usual. For ordinary brightness you must return
|
||||
-- normal with length 1
|
||||
|
||||
GetNodeNormal ( me; ranknode : Integer; ElementId : Integer;
|
||||
nx, ny, nz : out Real ) returns Boolean is virtual;
|
||||
---Purpose: This method return normal of node ranknode of face Id,
|
||||
-- which is using for smooth shading presentation.
|
||||
-- Returns false if normal isn't defined.
|
||||
|
||||
GetNormalsByElement( me; Id : Integer;
|
||||
IsNodal : Boolean;
|
||||
MaxNodes : Integer;
|
||||
Normals : out HArray1OfReal from TColStd ) returns Boolean is virtual;
|
||||
---Purpose: This method puts components of normal vectors at each node of a mesh face (at each face of a mesh volume)
|
||||
-- into the output array.
|
||||
-- Returns false if some problem was detected during calculation of normals.
|
||||
-- Id is an identifier of the mesh element.
|
||||
-- IsNodal, when true, means that normals at mesh element nodes are needed. If nodal normals
|
||||
-- are not available, or IsNodal is false, or the mesh element is a volume, then the output array contents
|
||||
-- depend on the element type:
|
||||
-- face: a normal calculated by GetNormal() is duplicated for each node of the face;
|
||||
-- volume: normals to all faces of the volume are computed (not for each node!).
|
||||
-- MaxNodes is maximal number of nodes an element can consist of.
|
||||
-- Normals contains the result.
|
||||
|
||||
GetAllGroups ( me; Ids : out PackedMapOfInteger from TColStd ) is virtual;
|
||||
---Purpose: This method returns map of all groups the object contains.
|
||||
|
||||
GetGroup ( me; Id : Integer; Type : out EntityType from MeshVS;
|
||||
Ids : out PackedMapOfInteger from TColStd ) returns Boolean is virtual;
|
||||
---Purpose: This method returns map of all group elements.
|
||||
|
||||
GetGroupAddr ( me; ID : Integer ) returns Address is virtual;
|
||||
---Purpose: This method returns pointer which represents group data structure.
|
||||
-- This address will be saved in MeshVS_MeshOwner, so that you can access to data structure fast
|
||||
-- by the method Owner(). In the redefined method you can return NULL.
|
||||
-- ID is the numerical identificator of group
|
||||
|
||||
IsAdvancedSelectionEnabled( me )
|
||||
returns Boolean from Standard is virtual;
|
||||
---Purpose: Returns True if advanced mesh selection is enabled.
|
||||
-- Default implementation returns False.
|
||||
-- It should be redefined to return True for advanced
|
||||
-- mesh selection activation.
|
||||
|
||||
GetBoundingBox( me ) returns Box from Bnd is virtual;
|
||||
---Purpose: Returns the bounding box of the whole mesh.
|
||||
-- It is used in advanced selection mode to define roughly
|
||||
-- the sensitive area of the mesh.
|
||||
-- It can be redefined to get access to a box computed in advance.
|
||||
|
||||
GetDetectedEntities( me : mutable; Prs : Mesh from MeshVS;
|
||||
X,Y : Real from Standard;
|
||||
aTol : Real from Standard;
|
||||
Nodes : out HPackedMapOfInteger from TColStd;
|
||||
Elements : out HPackedMapOfInteger from TColStd;
|
||||
DMin : out Real from Standard )
|
||||
returns Boolean is virtual;
|
||||
---Purpose: Returns maps of entities (nodes and elements) detected
|
||||
-- by mouse click at the point (X,Y) on the current view plane,
|
||||
-- with the tolerance aTol.
|
||||
-- DMin - is out argument should return actual detection tolerance.
|
||||
-- Returns True if something is detected.
|
||||
-- It should be redefined if the advanced mesh selection is
|
||||
-- activated. Default implementation returns False.
|
||||
|
||||
GetDetectedEntities( me : mutable; Prs : Mesh from MeshVS;
|
||||
XMin, YMin, XMax, YMax : Real;
|
||||
aTol : Real;
|
||||
Nodes : out HPackedMapOfInteger from TColStd;
|
||||
Elements : out HPackedMapOfInteger from TColStd )
|
||||
returns Boolean is virtual;
|
||||
---Purpose: Returns maps of entities (nodes and elements) detected
|
||||
-- by mouse selection with rectangular box (XMin, YMin, XMax, YMax)
|
||||
-- on the current veiw plane, with the tolerance aTol.
|
||||
-- Returns True if something is detected.
|
||||
-- It should be redefined if the advanced mesh selection is
|
||||
-- activated. Default implementation returns False.
|
||||
|
||||
GetDetectedEntities( me : mutable; Prs : Mesh from MeshVS;
|
||||
Polyline : Array1OfPnt2d from TColgp;
|
||||
aBox : Box2d;
|
||||
aTol : Real;
|
||||
Nodes : out HPackedMapOfInteger from TColStd;
|
||||
Elements : out HPackedMapOfInteger from TColStd )
|
||||
returns Boolean is virtual;
|
||||
---Purpose: Returns maps of entities (nodes and elements) detected
|
||||
-- by mouse selection with the polyline <Polyline>
|
||||
-- on the current veiw plane, with the tolerance aTol.
|
||||
-- Returns True if something is detected.
|
||||
-- It should be redefined if the advanced mesh selection is
|
||||
-- activated. Default implementation returns False.
|
||||
|
||||
GetDetectedEntities( me : mutable; Prs : Mesh from MeshVS;
|
||||
Nodes : in out HPackedMapOfInteger from TColStd;
|
||||
Elements : in out HPackedMapOfInteger from TColStd )
|
||||
returns Boolean is virtual;
|
||||
---Purpose: Filter out the maps of mesh entities so as to keep
|
||||
-- only the entities that are allowed to be selected
|
||||
-- according to the current context.
|
||||
-- Returns True if any of the maps has been changed.
|
||||
-- It should be redefined if the advanced mesh selection is
|
||||
-- activated. Default implementation returns False.
|
||||
|
||||
end DataSource;
|
320
src/MeshVS/MeshVS_DataSource.cxx
Executable file
320
src/MeshVS/MeshVS_DataSource.cxx
Executable file
@@ -0,0 +1,320 @@
|
||||
// File: MeshVS_DataSource.cxx
|
||||
// Created: Tue Sep 16 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_DataSource.ixx>
|
||||
#include <MeshVS_Tool.hxx>
|
||||
#include <MeshVS_Buffer.hxx>
|
||||
|
||||
#include <gp.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
|
||||
//================================================================
|
||||
// Function : Get3DGeom
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::Get3DGeom( const Standard_Integer /*ID*/,
|
||||
Standard_Integer& /*NbNodes*/,
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger )& /*Data*/ ) const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetNormal
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::GetNormal ( const Standard_Integer Id,
|
||||
const Standard_Integer Max,
|
||||
Standard_Real &nx,
|
||||
Standard_Real &ny,
|
||||
Standard_Real &nz ) const
|
||||
{
|
||||
if ( Max <= 0 )
|
||||
return Standard_False;
|
||||
|
||||
MeshVS_Buffer aCoordsBuf (3*Max*sizeof(Standard_Real));
|
||||
TColStd_Array1OfReal Coords ( aCoordsBuf, 1, 3*Max );
|
||||
Standard_Integer nbNodes;
|
||||
MeshVS_EntityType Type;
|
||||
|
||||
Standard_Boolean res = Standard_False;
|
||||
|
||||
if ( !GetGeom ( Id, Standard_True, Coords, nbNodes, Type ) )
|
||||
return res;
|
||||
|
||||
if ( Type == MeshVS_ET_Face && nbNodes >= 3 )
|
||||
{
|
||||
Standard_Real x1 = Coords( 1 );
|
||||
Standard_Real y1 = Coords( 2 );
|
||||
Standard_Real z1 = Coords( 3 );
|
||||
Standard_Real x2 = Coords( 4 );
|
||||
Standard_Real y2 = Coords( 5 );
|
||||
Standard_Real z2 = Coords( 6 );
|
||||
Standard_Real x3 = Coords( ( nbNodes - 1 ) * 3 + 1 );
|
||||
Standard_Real y3 = Coords( ( nbNodes - 1 ) * 3 + 2 );
|
||||
Standard_Real z3 = Coords( ( nbNodes - 1 ) * 3 + 3 );
|
||||
Standard_Real p1 = x2 - x1, p2 = y2 - y1, p3 = z2 - z1,
|
||||
q1 = x3 - x1, q2 = y3 - y1, q3 = z3 - z1;
|
||||
nx = p2*q3 - p3*q2;
|
||||
ny = p3*q1 - p1*q3;
|
||||
nz = p1*q2 - p2*q1;
|
||||
Standard_Real len = sqrt ( nx*nx + ny*ny + nz*nz );
|
||||
if ( len <= gp::Resolution() )
|
||||
{
|
||||
nx = ny = nz = 0;
|
||||
return res;
|
||||
}
|
||||
nx /= len; ny /= len; nz /= len;
|
||||
res = Standard_True;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetNodeNormal
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::GetNodeNormal
|
||||
( const Standard_Integer /*ranknode*/,
|
||||
const Standard_Integer /*Id*/,
|
||||
Standard_Real &/*nx*/,
|
||||
Standard_Real &/*ny*/,
|
||||
Standard_Real &/*nz*/ ) const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetNormalsByElement
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::GetNormalsByElement(const Standard_Integer Id,
|
||||
const Standard_Boolean IsNodal,
|
||||
const Standard_Integer MaxNodes,
|
||||
Handle(TColStd_HArray1OfReal)& Normals) const
|
||||
{
|
||||
MeshVS_Buffer aCoordsBuf (3*MaxNodes*sizeof(Standard_Real));
|
||||
TColStd_Array1OfReal Coords ( aCoordsBuf, 1, 3*MaxNodes );
|
||||
Standard_Integer NbNodes;
|
||||
MeshVS_EntityType Type;
|
||||
|
||||
Standard_Boolean res = Standard_False;
|
||||
if ( MaxNodes <= 0 )
|
||||
return res;
|
||||
|
||||
if ( !GetGeom ( Id, Standard_True, Coords, NbNodes, Type ) )
|
||||
return res;
|
||||
|
||||
Standard_Integer aNbNormals = NbNodes;
|
||||
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger ) aTopo;
|
||||
if ( Type == MeshVS_ET_Volume )
|
||||
{
|
||||
if( !Get3DGeom( Id, NbNodes, aTopo ) )
|
||||
return res;
|
||||
// calculate number of normals for faces of volume
|
||||
aNbNormals = aTopo->Upper() - aTopo->Lower() + 1;
|
||||
}
|
||||
|
||||
Handle(TColStd_HArray1OfReal) aNormals = new TColStd_HArray1OfReal(1, 3 * aNbNormals );
|
||||
|
||||
Standard_Boolean allNormals = ( Type == MeshVS_ET_Face && IsNodal );
|
||||
// Try returning nodal normals if possible
|
||||
for( Standard_Integer k=1; k<=NbNodes && allNormals; k++ )
|
||||
allNormals = GetNodeNormal( k,
|
||||
Id,
|
||||
aNormals->ChangeValue(3 * k - 2),
|
||||
aNormals->ChangeValue(3 * k - 1),
|
||||
aNormals->ChangeValue(3 * k ) );
|
||||
|
||||
// Nodal normals not available or not needed
|
||||
if ( !allNormals )
|
||||
{
|
||||
switch ( Type )
|
||||
{
|
||||
// Compute a face normal and duplicate it for all element`s nodes
|
||||
case MeshVS_ET_Face:
|
||||
res = GetNormal( Id,
|
||||
MaxNodes,
|
||||
aNormals->ChangeValue(1),
|
||||
aNormals->ChangeValue(2),
|
||||
aNormals->ChangeValue(3) );
|
||||
if ( res )
|
||||
{
|
||||
for( Standard_Integer k=2; k<=NbNodes; k++ )
|
||||
{
|
||||
aNormals->ChangeValue(3 * k - 2) = aNormals->Value(1);
|
||||
aNormals->ChangeValue(3 * k - 1) = aNormals->Value(2);
|
||||
aNormals->ChangeValue(3 * k ) = aNormals->Value(3);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Compute normals for each of volum`s faces - not for each node!
|
||||
case MeshVS_ET_Volume:
|
||||
{
|
||||
gp_Vec norm;
|
||||
Standard_Integer low = Coords.Lower();
|
||||
for ( Standard_Integer k = aTopo->Lower(), last = aTopo->Upper(), i = 1; k <= last; k++, i++ )
|
||||
{
|
||||
const TColStd_SequenceOfInteger& aSeq = aTopo->Value( k );
|
||||
Standard_Integer m = aSeq.Length(), ind;
|
||||
|
||||
norm.SetCoord( 0, 0, 0 );
|
||||
MeshVS_Buffer PolyNodesBuf (3*m*sizeof(Standard_Real));
|
||||
TColStd_Array1OfReal PolyNodes( PolyNodesBuf, 0, 3*m );
|
||||
PolyNodes.SetValue( 0, m );
|
||||
for( Standard_Integer j=1; j<=m; j++ )
|
||||
{
|
||||
ind = aSeq.Value( j );
|
||||
PolyNodes.SetValue( 3*j-2, Coords( low+3*ind ) );
|
||||
PolyNodes.SetValue( 3*j-1, Coords( low+3*ind+1 ) );
|
||||
PolyNodes.SetValue( 3*j, Coords( low+3*ind+2 ) );
|
||||
}
|
||||
|
||||
MeshVS_Tool::GetAverageNormal( PolyNodes, norm );
|
||||
|
||||
aNormals->ChangeValue(i * 3 - 2) = norm.X();
|
||||
aNormals->ChangeValue(i * 3 - 1) = norm.Y();
|
||||
aNormals->ChangeValue(i * 3 ) = norm.Z();
|
||||
}
|
||||
res = Standard_True;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return res;
|
||||
} // switch ( Type )
|
||||
} // if ( !allNormals )
|
||||
|
||||
if ( res )
|
||||
Normals = aNormals;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetAllGroups
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_DataSource::GetAllGroups( TColStd_PackedMapOfInteger& /*Ids*/ ) const
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetGroup
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::GetGroup( const Standard_Integer /*Id*/,
|
||||
MeshVS_EntityType& Type,
|
||||
TColStd_PackedMapOfInteger& /*Ids*/ ) const
|
||||
{
|
||||
Type = MeshVS_ET_NONE;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//================================================================
|
||||
// Function : GetGroupAddr
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Address MeshVS_DataSource::GetGroupAddr(const Standard_Integer /*ID*/) const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : IsAdvancedSelectionEnabled
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::IsAdvancedSelectionEnabled() const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDetectedEntities
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::GetDetectedEntities(const Handle(MeshVS_Mesh)& /*theMesh*/,
|
||||
const Standard_Real /*X*/,
|
||||
const Standard_Real /*Y*/,
|
||||
const Standard_Real /*aTol*/,
|
||||
Handle(TColStd_HPackedMapOfInteger)& /*Nodes*/,
|
||||
Handle(TColStd_HPackedMapOfInteger)& /*Elements*/,
|
||||
Standard_Real& /*DMin*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDetectedEntities
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::GetDetectedEntities(const Handle(MeshVS_Mesh)& /*theMesh*/,
|
||||
const Standard_Real /*XMin*/,
|
||||
const Standard_Real /*YMin*/,
|
||||
const Standard_Real /*XMax*/,
|
||||
const Standard_Real /*YMax*/,
|
||||
const Standard_Real /*aTol*/,
|
||||
Handle(TColStd_HPackedMapOfInteger)& /*Nodes*/,
|
||||
Handle(TColStd_HPackedMapOfInteger)& /*Elements*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDetectedEntities
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::GetDetectedEntities(const Handle(MeshVS_Mesh)& /*theMesh*/,
|
||||
const TColgp_Array1OfPnt2d& /*Polyline*/,
|
||||
const Bnd_Box2d& /*aBox*/,
|
||||
const Standard_Real /*aTol*/,
|
||||
Handle(TColStd_HPackedMapOfInteger)& /*Nodes*/,
|
||||
Handle(TColStd_HPackedMapOfInteger)& /*Elements*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDetectedEntities
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DataSource::GetDetectedEntities(const Handle(MeshVS_Mesh)& /*theMesh*/,
|
||||
Handle(TColStd_HPackedMapOfInteger)& /*Nodes*/,
|
||||
Handle(TColStd_HPackedMapOfInteger)& /*Elements*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetBoundingBox
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Bnd_Box MeshVS_DataSource::GetBoundingBox() const
|
||||
{
|
||||
// Compute the 3D bounding box for mesh
|
||||
Bnd_Box aBox;
|
||||
const TColStd_PackedMapOfInteger& aNodes = GetAllNodes();
|
||||
if( aNodes.Extent() )
|
||||
{
|
||||
Standard_Real aCoordsBuf[ 3 ];
|
||||
TColStd_Array1OfReal aCoords (*aCoordsBuf, 1, 3);
|
||||
Standard_Integer nbNodes;
|
||||
MeshVS_EntityType aType;
|
||||
TColStd_MapIteratorOfPackedMapOfInteger anIter (aNodes);
|
||||
for ( ; anIter.More(); anIter.Next() )
|
||||
{
|
||||
Standard_Integer aKey = anIter.Key();
|
||||
if ( !GetGeom ( aKey, Standard_False, aCoords, nbNodes, aType ) )
|
||||
continue;
|
||||
aBox.Add( gp_Pnt( aCoordsBuf[0], aCoordsBuf[1], aCoordsBuf[2] ) );
|
||||
}
|
||||
}
|
||||
return aBox;
|
||||
}
|
26
src/MeshVS/MeshVS_DataSource3D.cdl
Executable file
26
src/MeshVS/MeshVS_DataSource3D.cdl
Executable file
@@ -0,0 +1,26 @@
|
||||
-- File : MeshVS_DataSource3D.cdl
|
||||
-- Created : 21 January 2005
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2005
|
||||
|
||||
deferred class DataSource3D from MeshVS inherits DataSource from MeshVS
|
||||
|
||||
uses
|
||||
Integer from Standard,
|
||||
Array1OfPnt from TColgp,
|
||||
|
||||
HArray1OfSequenceOfInteger from MeshVS,
|
||||
DataMapOfHArray1OfSequenceOfInteger from MeshVS
|
||||
|
||||
is
|
||||
|
||||
GetPrismTopology ( me; BasePoints : Integer ) returns HArray1OfSequenceOfInteger from MeshVS;
|
||||
GetPyramidTopology( me; BasePoints : Integer ) returns HArray1OfSequenceOfInteger from MeshVS;
|
||||
|
||||
CreatePrismTopology ( myclass; BasePoints : Integer ) returns HArray1OfSequenceOfInteger from MeshVS;
|
||||
CreatePyramidTopology( myclass; BasePoints : Integer ) returns HArray1OfSequenceOfInteger from MeshVS;
|
||||
|
||||
fields
|
||||
myPrismTopos, myPyramidTopos : DataMapOfHArray1OfSequenceOfInteger from MeshVS;
|
||||
|
||||
end DataSource3D from MeshVS;
|
97
src/MeshVS/MeshVS_DataSource3D.cxx
Executable file
97
src/MeshVS/MeshVS_DataSource3D.cxx
Executable file
@@ -0,0 +1,97 @@
|
||||
// File: MeshVS_DataSource3D.cxx
|
||||
// Created: Fri Jan 21 2005
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2005
|
||||
|
||||
#include <MeshVS_DataSource3D.ixx>
|
||||
|
||||
//================================================================
|
||||
// Function : GetPrismTopology
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger )
|
||||
MeshVS_DataSource3D::GetPrismTopology( const Standard_Integer BasePoints ) const
|
||||
{
|
||||
if( myPrismTopos.IsBound( BasePoints ) )
|
||||
return myPrismTopos.Find( BasePoints );
|
||||
else
|
||||
{
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger ) result = CreatePrismTopology( BasePoints );
|
||||
if( !result.IsNull() )
|
||||
( ( MeshVS_DataSource3D* )this )->myPrismTopos.Bind( BasePoints, result );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetPyramidTopology
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger )
|
||||
MeshVS_DataSource3D::GetPyramidTopology( const Standard_Integer BasePoints ) const
|
||||
{
|
||||
if( myPyramidTopos.IsBound( BasePoints ) )
|
||||
return myPyramidTopos.Find( BasePoints );
|
||||
else
|
||||
{
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger ) result = CreatePyramidTopology( BasePoints );
|
||||
if( !result.IsNull() )
|
||||
( ( MeshVS_DataSource3D* )this )->myPyramidTopos.Bind( BasePoints, result );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : CreatePrismTopology
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger )
|
||||
MeshVS_DataSource3D::CreatePrismTopology( const Standard_Integer BasePoints )
|
||||
{
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger ) result;
|
||||
|
||||
if( BasePoints>=3 )
|
||||
{
|
||||
result = new MeshVS_HArray1OfSequenceOfInteger( 1, BasePoints+2 );
|
||||
Standard_Integer i, next;
|
||||
|
||||
for( i=0; i<BasePoints; i++ )
|
||||
{
|
||||
result->ChangeValue( 1 ).Prepend( i );
|
||||
result->ChangeValue( 2 ).Append( i+BasePoints );
|
||||
|
||||
result->ChangeValue( 3+i ).Prepend( i );
|
||||
result->ChangeValue( 3+i ).Prepend( i+BasePoints );
|
||||
next = ( i+1 ) % BasePoints;
|
||||
result->ChangeValue( 3+i ).Prepend( next+BasePoints );
|
||||
result->ChangeValue( 3+i ).Prepend( next );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : CreatePyramidTopology
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger )
|
||||
MeshVS_DataSource3D::CreatePyramidTopology( const Standard_Integer BasePoints )
|
||||
{
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger ) result;
|
||||
|
||||
if( BasePoints>=3 )
|
||||
{
|
||||
result = new MeshVS_HArray1OfSequenceOfInteger( 1, BasePoints+1 );
|
||||
|
||||
for( Standard_Integer i=1; i<=BasePoints; i++ )
|
||||
{
|
||||
result->ChangeValue( 1 ).Prepend( i );
|
||||
result->ChangeValue( 1+i ).Append( 0 );
|
||||
result->ChangeValue( 1+i ).Append( i );
|
||||
result->ChangeValue( 1+i ).Append( i%BasePoints + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
92
src/MeshVS/MeshVS_DeformedDataSource.cdl
Executable file
92
src/MeshVS/MeshVS_DeformedDataSource.cdl
Executable file
@@ -0,0 +1,92 @@
|
||||
-- File : MeshVS_DeformedDataSource.cdl
|
||||
-- Created : 11 December 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class DeformedDataSource from MeshVS inherits DataSource from MeshVS
|
||||
|
||||
---Purpose: The class provides default class which helps to represent node displacements by deformed mesh
|
||||
-- This class has an internal handle to canonical non-deformed mesh data source and
|
||||
-- map of displacement vectors. The displacement can be magnified to useful size.
|
||||
-- All methods is implemented with calling the corresponding methods of non-deformed data source.
|
||||
|
||||
uses
|
||||
Integer from Standard,
|
||||
Real from Standard,
|
||||
Boolean from Standard,
|
||||
Address from Standard,
|
||||
|
||||
Vec from gp,
|
||||
|
||||
Array1OfReal from TColStd,
|
||||
Array1OfInteger from TColStd,
|
||||
PackedMapOfInteger from TColStd,
|
||||
|
||||
DataMapOfIntegerVector from MeshVS,
|
||||
EntityType from MeshVS,
|
||||
HArray1OfSequenceOfInteger from MeshVS
|
||||
|
||||
is
|
||||
|
||||
Create ( theNonDeformDS : DataSource from MeshVS;
|
||||
theMagnify : Real ) returns mutable DeformedDataSource from MeshVS;
|
||||
---Purpose: Constructor
|
||||
-- theNonDeformDS is canonical non-deformed data source, by which we are able to calculate
|
||||
-- deformed mesh geometry
|
||||
-- theMagnify is coefficient of displacement magnify
|
||||
|
||||
GetGeom ( me; ID : Integer;
|
||||
IsElement : Boolean;
|
||||
Coords : out Array1OfReal from TColStd;
|
||||
NbNodes : out Integer;
|
||||
Type : out EntityType from MeshVS ) returns Boolean is redefined;
|
||||
|
||||
GetGeomType ( me; ID : Integer;
|
||||
IsElement : Boolean;
|
||||
Type : out EntityType from MeshVS ) returns Boolean is redefined;
|
||||
|
||||
Get3DGeom( me; ID : Integer;
|
||||
NbNodes : out Integer;
|
||||
Data : out HArray1OfSequenceOfInteger from MeshVS ) returns Boolean is redefined;
|
||||
|
||||
GetAddr ( me; ID : Integer;
|
||||
IsElement : Boolean ) returns Address is redefined;
|
||||
|
||||
GetNodesByElement ( me; ID : Integer;
|
||||
NodeIDs : out Array1OfInteger from TColStd;
|
||||
NbNodes : out Integer ) returns Boolean is redefined;
|
||||
|
||||
GetAllNodes ( me ) returns PackedMapOfInteger from TColStd is redefined;
|
||||
---C++: return const &
|
||||
|
||||
GetAllElements ( me ) returns PackedMapOfInteger from TColStd is redefined;
|
||||
---C++: return const &
|
||||
|
||||
GetVectors ( me ) returns DataMapOfIntegerVector from MeshVS;
|
||||
---C++: return const &
|
||||
---Purpose: This method returns map of nodal displacement vectors
|
||||
|
||||
SetVectors ( me: mutable; Map : DataMapOfIntegerVector from MeshVS );
|
||||
---Purpose: This method sets map of nodal displacement vectors (Map).
|
||||
|
||||
GetVector ( me; ID : Integer; Vect : out Vec from gp ) returns Boolean;
|
||||
---Purpose: This method returns vector ( Vect ) assigned to node number ID.
|
||||
|
||||
SetVector ( me: mutable; ID : Integer; Vect : Vec from gp );
|
||||
---Purpose: This method sets vector ( Vect ) assigned to node number ID.
|
||||
|
||||
SetNonDeformedDataSource ( me: mutable; theDS : DataSource from MeshVS );
|
||||
GetNonDeformedDataSource ( me ) returns DataSource from MeshVS;
|
||||
---Purpose: With this methods you can read and change internal canonical data source
|
||||
|
||||
SetMagnify ( me: mutable; theMagnify : Real );
|
||||
GetMagnify ( me ) returns Real;
|
||||
---Purpose: With this methods you can read and change magnify coefficient of nodal displacements
|
||||
|
||||
fields
|
||||
myNonDeformedDataSource : DataSource from MeshVS;
|
||||
myEmptyMap : PackedMapOfInteger from TColStd;
|
||||
myVectors : DataMapOfIntegerVector from MeshVS;
|
||||
myMagnify : Real;
|
||||
|
||||
end DataSource;
|
232
src/MeshVS/MeshVS_DeformedDataSource.cxx
Executable file
232
src/MeshVS/MeshVS_DeformedDataSource.cxx
Executable file
@@ -0,0 +1,232 @@
|
||||
// File: MeshVS_DeformedDataSource.cxx
|
||||
// Created: Thu Dec 11 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_DeformedDataSource.ixx>
|
||||
#include <MeshVS_Buffer.hxx>
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_DeformedDataSource
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_DeformedDataSource::MeshVS_DeformedDataSource( const Handle(MeshVS_DataSource)& theNonDeformDS,
|
||||
const Standard_Real theMagnify )
|
||||
{
|
||||
myNonDeformedDataSource = theNonDeformDS;
|
||||
SetMagnify ( theMagnify );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : shiftCoord
|
||||
// Purpose : auxiliary: shift coordinate of the node on a given vector
|
||||
//================================================================
|
||||
|
||||
static inline void shiftCoord (TColStd_Array1OfReal& Coords, Standard_Integer i, const gp_Vec &aVec)
|
||||
{
|
||||
Coords(3*i-2) = Coords(3*i-2) + aVec.X();
|
||||
Coords(3*i-1) = Coords(3*i-1) + aVec.Y();
|
||||
Coords(3*i) = Coords(3*i) + aVec.Z();
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetGeom
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DeformedDataSource::GetGeom( const Standard_Integer ID,
|
||||
const Standard_Boolean IsElement,
|
||||
TColStd_Array1OfReal& Coords,
|
||||
Standard_Integer& NbNodes,
|
||||
MeshVS_EntityType& Type) const
|
||||
{
|
||||
if ( myNonDeformedDataSource.IsNull() ||
|
||||
! myNonDeformedDataSource->GetGeom ( ID, IsElement, Coords, NbNodes, Type ) )
|
||||
return Standard_False;
|
||||
|
||||
if ( Type==MeshVS_ET_Node )
|
||||
{
|
||||
gp_Vec Vect;
|
||||
if ( ! GetVector( ID, Vect ) )
|
||||
return Standard_False;
|
||||
shiftCoord ( Coords, 1, myMagnify * Vect );
|
||||
}
|
||||
else
|
||||
{
|
||||
MeshVS_Buffer aNodesBuf (NbNodes * sizeof(Standard_Integer));
|
||||
TColStd_Array1OfInteger aNodes (aNodesBuf, 1, NbNodes);
|
||||
if ( !myNonDeformedDataSource->GetNodesByElement ( ID, aNodes, NbNodes ) )
|
||||
return Standard_False;
|
||||
for ( int i=1; i <= NbNodes; i++ )
|
||||
{
|
||||
gp_Vec Vect;
|
||||
if ( ! GetVector( aNodes(i), Vect ) )
|
||||
return Standard_False;
|
||||
shiftCoord ( Coords, i, myMagnify * Vect );
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetGeomType
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DeformedDataSource::GetGeomType( const Standard_Integer ID,
|
||||
const Standard_Boolean IsElement,
|
||||
MeshVS_EntityType& Type) const
|
||||
{
|
||||
if ( myNonDeformedDataSource.IsNull() )
|
||||
return Standard_False;
|
||||
else
|
||||
return myNonDeformedDataSource->GetGeomType( ID, IsElement, Type );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Get3DGeom
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DeformedDataSource::Get3DGeom( const Standard_Integer ID,
|
||||
Standard_Integer& NbNodes,
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger )& Data ) const
|
||||
{
|
||||
if( myNonDeformedDataSource.IsNull() )
|
||||
return Standard_False;
|
||||
else
|
||||
return myNonDeformedDataSource->Get3DGeom( ID, NbNodes, Data );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetAddr
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Address MeshVS_DeformedDataSource::GetAddr( const Standard_Integer ID,
|
||||
const Standard_Boolean IsElement ) const
|
||||
{
|
||||
if ( myNonDeformedDataSource.IsNull() )
|
||||
return 0;
|
||||
else
|
||||
return myNonDeformedDataSource->GetAddr( ID, IsElement );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetNodesByElement
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DeformedDataSource::GetNodesByElement
|
||||
(const Standard_Integer ID,
|
||||
TColStd_Array1OfInteger& NodeIDs,
|
||||
Standard_Integer& NbNodes) const
|
||||
{
|
||||
if ( myNonDeformedDataSource.IsNull() )
|
||||
return Standard_False;
|
||||
else
|
||||
return myNonDeformedDataSource->GetNodesByElement( ID, NodeIDs, NbNodes );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetAllNodes
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllNodes() const
|
||||
{
|
||||
if ( myNonDeformedDataSource.IsNull() )
|
||||
return myEmptyMap;
|
||||
else
|
||||
return myNonDeformedDataSource->GetAllNodes();
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetAllElements
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllElements() const
|
||||
{
|
||||
if ( myNonDeformedDataSource.IsNull() )
|
||||
return myEmptyMap;
|
||||
else
|
||||
return myNonDeformedDataSource->GetAllElements();
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetVectors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const MeshVS_DataMapOfIntegerVector& MeshVS_DeformedDataSource::GetVectors() const
|
||||
{
|
||||
return myVectors;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetVectors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_DeformedDataSource::SetVectors( const MeshVS_DataMapOfIntegerVector& Map )
|
||||
{
|
||||
myVectors = Map;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetVector
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DeformedDataSource::GetVector( const Standard_Integer ID,
|
||||
gp_Vec& Vect ) const
|
||||
{
|
||||
Standard_Boolean aRes = myVectors.IsBound ( ID );
|
||||
if ( aRes )
|
||||
Vect = myVectors.Find ( ID );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetVector
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_DeformedDataSource::SetVector( const Standard_Integer ID,
|
||||
const gp_Vec& Vect )
|
||||
{
|
||||
Standard_Boolean aRes = myVectors.IsBound ( ID );
|
||||
if ( aRes )
|
||||
myVectors.ChangeFind ( ID ) = Vect;
|
||||
else
|
||||
myVectors.Bind( ID, Vect );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetNonDeformedDataSource
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_DeformedDataSource::SetNonDeformedDataSource( const Handle(MeshVS_DataSource)& theDS )
|
||||
{
|
||||
myNonDeformedDataSource = theDS;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetNonDeformedDataSource
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle_MeshVS_DataSource MeshVS_DeformedDataSource::GetNonDeformedDataSource() const
|
||||
{
|
||||
return myNonDeformedDataSource;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetMagnify
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_DeformedDataSource::SetMagnify( const Standard_Real theMagnify )
|
||||
{
|
||||
if ( theMagnify<=0 )
|
||||
myMagnify = 1.0;
|
||||
else
|
||||
myMagnify = theMagnify;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetMagnify
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Real MeshVS_DeformedDataSource::GetMagnify() const
|
||||
{
|
||||
return myMagnify;
|
||||
}
|
34
src/MeshVS/MeshVS_DisplayModeFlags.hxx
Executable file
34
src/MeshVS/MeshVS_DisplayModeFlags.hxx
Executable file
@@ -0,0 +1,34 @@
|
||||
// File: MeshVS_DisplayModeFlags.hxx
|
||||
// Created: Tue Sep 9 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#ifndef MeshVS_DISPLAY_MODE_FLAGS_HXX
|
||||
#define MeshVS_DISPLAY_MODE_FLAGS_HXX
|
||||
|
||||
Standard_EXPORT typedef Standard_Integer MeshVS_DisplayModeFlags;
|
||||
|
||||
enum
|
||||
{
|
||||
MeshVS_DMF_WireFrame = 0x0001,
|
||||
MeshVS_DMF_Shading = 0x0002,
|
||||
MeshVS_DMF_Shrink = 0x0003,
|
||||
MeshVS_DMF_OCCMask = ( MeshVS_DMF_WireFrame | MeshVS_DMF_Shading | MeshVS_DMF_Shrink ),
|
||||
// the mask which helps pick out CasCade display mode
|
||||
|
||||
MeshVS_DMF_VectorDataPrs = 0x0004,
|
||||
MeshVS_DMF_NodalColorDataPrs = 0x0008,
|
||||
MeshVS_DMF_ElementalColorDataPrs = 0x0010,
|
||||
MeshVS_DMF_TextDataPrs = 0x0020,
|
||||
MeshVS_DMF_EntitiesWithData = 0x0040,
|
||||
MeshVS_DMF_DeformedPrsWireFrame = 0x0080,
|
||||
MeshVS_DMF_DeformedPrsShading = 0x0100,
|
||||
MeshVS_DMF_DeformedPrsShrink = 0x0180,
|
||||
MeshVS_DMF_DeformedMask = ( MeshVS_DMF_DeformedPrsWireFrame | MeshVS_DMF_DeformedPrsShading | MeshVS_DMF_DeformedPrsShrink ),
|
||||
MeshVS_DMF_SelectionPrs = 0x0200,
|
||||
MeshVS_DMF_HilightPrs = 0x0400,
|
||||
MeshVS_DMF_User = 0x0800
|
||||
};
|
||||
|
||||
|
||||
#endif
|
62
src/MeshVS/MeshVS_Drawer.cdl
Executable file
62
src/MeshVS/MeshVS_Drawer.cdl
Executable file
@@ -0,0 +1,62 @@
|
||||
-- File : MeshVS_Drawer.cdl
|
||||
-- Created : 27 November 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class Drawer from MeshVS inherits TShared from MMgt
|
||||
|
||||
---Purpose: This class provided the common interface to share between classes
|
||||
-- big set of constants affecting to object appearance. By default, this class
|
||||
-- can store integers, doubles, OCC colors, OCC materials. Each of OCC enum members
|
||||
-- can be stored as integers.
|
||||
|
||||
uses
|
||||
DataMapOfIntegerInteger from TColStd,
|
||||
DataMapOfIntegerReal from TColStd,
|
||||
|
||||
Color from Quantity,
|
||||
|
||||
MaterialAspect from Graphic3d,
|
||||
AsciiString from TCollection,
|
||||
|
||||
|
||||
DataMapOfIntegerBoolean from MeshVS,
|
||||
DataMapOfIntegerColor from MeshVS,
|
||||
DataMapOfIntegerMaterial from MeshVS,
|
||||
DataMapOfIntegerAsciiString from MeshVS
|
||||
|
||||
is
|
||||
|
||||
Assign ( me: mutable; aDrawer : Drawer ) is virtual;
|
||||
---Purpose: This method copies other drawer contents to this.
|
||||
|
||||
SetInteger ( me: mutable; Key : Integer; Value : Integer );
|
||||
SetDouble ( me: mutable; Key : Integer; Value : Real );
|
||||
SetBoolean ( me: mutable; Key : Integer; Value : Boolean );
|
||||
SetColor ( me: mutable; Key : Integer; Value : Color from Quantity );
|
||||
SetMaterial ( me: mutable; Key : Integer; Value : MaterialAspect from Graphic3d );
|
||||
SetAsciiString ( me: mutable; Key : Integer; Value : AsciiString from TCollection );
|
||||
|
||||
GetInteger ( me; Key : Integer; Value : out Integer ) returns Boolean;
|
||||
GetDouble ( me; Key : Integer; Value : out Real ) returns Boolean;
|
||||
GetBoolean ( me; Key : Integer; Value : out Boolean ) returns Boolean;
|
||||
GetColor ( me; Key : Integer; Value : out Color from Quantity ) returns Boolean;
|
||||
GetMaterial ( me; Key : Integer; Value : out MaterialAspect from Graphic3d ) returns Boolean;
|
||||
GetAsciiString ( me; Key : Integer; Value : out AsciiString from TCollection ) returns Boolean;
|
||||
|
||||
RemoveInteger ( me: mutable; Key : Integer ) returns Boolean;
|
||||
RemoveDouble ( me: mutable; Key : Integer ) returns Boolean;
|
||||
RemoveBoolean ( me: mutable; Key : Integer ) returns Boolean;
|
||||
RemoveColor ( me: mutable; Key : Integer ) returns Boolean;
|
||||
RemoveMaterial ( me: mutable; Key : Integer ) returns Boolean;
|
||||
RemoveAsciiString ( me: mutable; Key : Integer ) returns Boolean;
|
||||
|
||||
fields
|
||||
myIntegers : DataMapOfIntegerInteger from TColStd;
|
||||
myBooleans : DataMapOfIntegerBoolean from MeshVS;
|
||||
myDoubles : DataMapOfIntegerReal from TColStd;
|
||||
myColors : DataMapOfIntegerColor from MeshVS;
|
||||
myMaterials : DataMapOfIntegerMaterial from MeshVS;
|
||||
myAsciiString : DataMapOfIntegerAsciiString from MeshVS;
|
||||
|
||||
end Drawer;
|
242
src/MeshVS/MeshVS_Drawer.cxx
Executable file
242
src/MeshVS/MeshVS_Drawer.cxx
Executable file
@@ -0,0 +1,242 @@
|
||||
// File: MeshVS_Drawer.cxx
|
||||
// Created: Thu Nov 27 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_Drawer.ixx>
|
||||
|
||||
//================================================================
|
||||
// Function : Assign
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_Drawer::Assign( const Handle(MeshVS_Drawer)& aDrawer )
|
||||
{
|
||||
if ( !aDrawer.IsNull() )
|
||||
{
|
||||
myIntegers = aDrawer->myIntegers;
|
||||
myDoubles = aDrawer->myDoubles;
|
||||
myBooleans = aDrawer->myBooleans;
|
||||
myColors = aDrawer->myColors;
|
||||
myMaterials = aDrawer->myMaterials;
|
||||
myAsciiString = aDrawer->myAsciiString;
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetInteger
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_Drawer::SetInteger( const Standard_Integer Key, const Standard_Integer Value)
|
||||
{
|
||||
if ( myIntegers.IsBound ( Key ) )
|
||||
myIntegers.ChangeFind ( Key ) = Value;
|
||||
else
|
||||
myIntegers.Bind( Key, Value );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetDouble
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_Drawer::SetDouble( const Standard_Integer Key, const Standard_Real Value)
|
||||
{
|
||||
if ( myDoubles.IsBound ( Key ) )
|
||||
myDoubles.ChangeFind ( Key ) = Value;
|
||||
else
|
||||
myDoubles.Bind( Key, Value );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetBoolean
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_Drawer::SetBoolean( const Standard_Integer Key, const Standard_Boolean Value)
|
||||
{
|
||||
if ( myBooleans.IsBound ( Key ) )
|
||||
myBooleans.ChangeFind ( Key ) = Value;
|
||||
else
|
||||
myBooleans.Bind( Key, Value );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetColor
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_Drawer::SetColor( const Standard_Integer Key, const Quantity_Color& Value)
|
||||
{
|
||||
if ( myColors.IsBound ( Key ) )
|
||||
myColors.ChangeFind ( Key ) = Value;
|
||||
else
|
||||
myColors.Bind( Key, Value );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetMaterial
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_Drawer::SetMaterial( const Standard_Integer Key, const Graphic3d_MaterialAspect& Value)
|
||||
{
|
||||
if ( myMaterials.IsBound ( Key ) )
|
||||
myMaterials.ChangeFind ( Key ) = Value;
|
||||
else
|
||||
myMaterials.Bind( Key, Value );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetMaterial
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_Drawer::SetAsciiString( const Standard_Integer Key, const TCollection_AsciiString& Value)
|
||||
{
|
||||
if ( myAsciiString.IsBound ( Key ) )
|
||||
myAsciiString.ChangeFind ( Key ) = Value;
|
||||
else
|
||||
myAsciiString.Bind( Key, Value );
|
||||
}
|
||||
|
||||
|
||||
//================================================================
|
||||
// Function : GetInteger
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::GetInteger( const Standard_Integer Key, Standard_Integer& Value) const
|
||||
{
|
||||
Standard_Boolean aRes = myIntegers.IsBound ( Key );
|
||||
if ( aRes )
|
||||
Value = myIntegers.Find ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDouble
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::GetDouble( const Standard_Integer Key, Standard_Real& Value) const
|
||||
{
|
||||
Standard_Boolean aRes = myDoubles.IsBound ( Key );
|
||||
if ( aRes )
|
||||
Value = myDoubles.Find ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetBoolean
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::GetBoolean( const Standard_Integer Key, Standard_Boolean& Value) const
|
||||
{
|
||||
Standard_Boolean aRes = myBooleans.IsBound ( Key );
|
||||
if ( aRes )
|
||||
Value = myBooleans.Find ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetColor
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::GetColor( const Standard_Integer Key, Quantity_Color& Value) const
|
||||
{
|
||||
Standard_Boolean aRes = myColors.IsBound ( Key );
|
||||
if ( aRes )
|
||||
Value = myColors.Find ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetMaterial
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::GetMaterial( const Standard_Integer Key, Graphic3d_MaterialAspect& Value) const
|
||||
{
|
||||
Standard_Boolean aRes = myMaterials.IsBound ( Key );
|
||||
if ( aRes )
|
||||
Value = myMaterials.Find ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetAsciiSstring
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::GetAsciiString( const Standard_Integer Key, TCollection_AsciiString& Value) const
|
||||
{
|
||||
Standard_Boolean aRes = myAsciiString.IsBound ( Key );
|
||||
if ( aRes )
|
||||
Value = myAsciiString.Find ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
|
||||
//================================================================
|
||||
// Function : RemoveInteger
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::RemoveInteger( const Standard_Integer Key )
|
||||
{
|
||||
Standard_Boolean aRes = myIntegers.IsBound ( Key );
|
||||
if ( aRes )
|
||||
myIntegers.UnBind ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : RemoveDouble
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::RemoveDouble( const Standard_Integer Key )
|
||||
{
|
||||
Standard_Boolean aRes = myDoubles.IsBound ( Key );
|
||||
if ( aRes )
|
||||
myDoubles.UnBind ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : RemoveBoolean
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::RemoveBoolean( const Standard_Integer Key )
|
||||
{
|
||||
Standard_Boolean aRes = myBooleans.IsBound ( Key );
|
||||
if ( aRes )
|
||||
myBooleans.UnBind ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : RemoveColor
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::RemoveColor( const Standard_Integer Key )
|
||||
{
|
||||
Standard_Boolean aRes = myColors.IsBound ( Key );
|
||||
if ( aRes )
|
||||
myColors.UnBind ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : RemoveMaterial
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::RemoveMaterial( const Standard_Integer Key )
|
||||
{
|
||||
Standard_Boolean aRes = myMaterials.IsBound ( Key );
|
||||
if ( aRes )
|
||||
myMaterials.UnBind ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : RemoveAsciiString
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Drawer::RemoveAsciiString( const Standard_Integer Key )
|
||||
{
|
||||
Standard_Boolean aRes = myAsciiString.IsBound ( Key );
|
||||
if ( aRes )
|
||||
myAsciiString.UnBind ( Key );
|
||||
return aRes;
|
||||
}
|
||||
|
44
src/MeshVS/MeshVS_DummySensitiveEntity.cdl
Executable file
44
src/MeshVS/MeshVS_DummySensitiveEntity.cdl
Executable file
@@ -0,0 +1,44 @@
|
||||
-- File: MeshVS_DummySensitiveEntity.cdl
|
||||
-- Created: Mon Sep 29 2003
|
||||
-- Author: Alexander SOLOVYOV and Sergey LITONIN
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class DummySensitiveEntity from MeshVS inherits SensitiveEntity from SelectBasics
|
||||
|
||||
---Purpose: This class allows to create owners to all elements or nodes,
|
||||
-- both hidden and shown, but these owners user cannot select "by hands"
|
||||
-- in viewer. They means for internal application tasks, for example, receiving
|
||||
-- all owners, both for hidden and shown entities.
|
||||
uses
|
||||
EntityOwner from SelectBasics,
|
||||
ListOfBox2d from SelectBasics,
|
||||
|
||||
Array1OfPnt2d from TColgp,
|
||||
|
||||
Box2d from Bnd
|
||||
|
||||
is
|
||||
Create ( OwnerId : EntityOwner from SelectBasics ) returns mutable DummySensitiveEntity from MeshVS;
|
||||
|
||||
Areas ( me: mutable;
|
||||
aresult: in out ListOfBox2d from SelectBasics ) is redefined;
|
||||
|
||||
Matches ( me: mutable;
|
||||
X, Y, aTol: Real;
|
||||
DMin: out Real ) returns Boolean is redefined;
|
||||
|
||||
Matches ( me: mutable;
|
||||
XMin, YMin, XMax, YMax, aTol: Real ) returns Boolean is redefined;
|
||||
|
||||
Matches ( me: mutable;
|
||||
Polyline : Array1OfPnt2d from TColgp;
|
||||
aBox : Box2d from Bnd;
|
||||
aTol : Real ) returns Boolean is redefined;
|
||||
|
||||
Is3D ( me ) returns Boolean is redefined;
|
||||
|
||||
NeedsConversion ( me ) returns Boolean is redefined;
|
||||
|
||||
MaxBoxes ( me ) returns Integer is redefined;
|
||||
|
||||
end DummySensitiveEntity;
|
87
src/MeshVS/MeshVS_DummySensitiveEntity.cxx
Executable file
87
src/MeshVS/MeshVS_DummySensitiveEntity.cxx
Executable file
@@ -0,0 +1,87 @@
|
||||
// File: MeshVS_DummySensitiveEntity.cxx
|
||||
// Created: Mon Sep 29 2003
|
||||
// Author: Alexander SOLOVYOV and Sergey LITONIN
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_DummySensitiveEntity.ixx>
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_DummySensitiveEntity
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_DummySensitiveEntity::MeshVS_DummySensitiveEntity
|
||||
( const Handle(SelectBasics_EntityOwner)& OwnerId )
|
||||
: SelectBasics_SensitiveEntity( OwnerId )
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Areas
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_DummySensitiveEntity::Areas( SelectBasics_ListOfBox2d& )
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Matches
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DummySensitiveEntity::Matches( const Standard_Real,
|
||||
const Standard_Real,
|
||||
const Standard_Real,
|
||||
Standard_Real& )
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Matches
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DummySensitiveEntity::Matches( const Standard_Real,
|
||||
const Standard_Real,
|
||||
const Standard_Real,
|
||||
const Standard_Real,
|
||||
const Standard_Real )
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Matches
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DummySensitiveEntity::Matches( const TColgp_Array1OfPnt2d&,
|
||||
const Bnd_Box2d&,
|
||||
const Standard_Real )
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : NeedsConversion
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DummySensitiveEntity::NeedsConversion() const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Is3D
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_DummySensitiveEntity::Is3D() const
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : MaxBoxes
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Integer MeshVS_DummySensitiveEntity::MaxBoxes() const
|
||||
{
|
||||
return 0;
|
||||
}
|
104
src/MeshVS/MeshVS_ElementalColorPrsBuilder.cdl
Executable file
104
src/MeshVS/MeshVS_ElementalColorPrsBuilder.cdl
Executable file
@@ -0,0 +1,104 @@
|
||||
-- File : MeshVS_ElementalColorPrsBuilder.cdl
|
||||
-- Created : 12 November 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class ElementalColorPrsBuilder from MeshVS inherits PrsBuilder from MeshVS
|
||||
|
||||
---Purpose: This class provides methods to create presentation of elements with
|
||||
-- assigned colors. The class contains two color maps: map of same colors for front
|
||||
-- and back side of face and map of different ones,
|
||||
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
|
||||
Boolean from Standard,
|
||||
Integer from Standard,
|
||||
|
||||
Mesh from MeshVS,
|
||||
MeshPtr from MeshVS,
|
||||
DisplayModeFlags from MeshVS,
|
||||
DataSource from MeshVS,
|
||||
DataMapOfIntegerColor from MeshVS,
|
||||
DataMapOfIntegerTwoColors from MeshVS,
|
||||
TwoColors from MeshVS,
|
||||
BuilderPriority from MeshVS,
|
||||
Color from Quantity,
|
||||
PackedMapOfInteger from TColStd
|
||||
|
||||
is
|
||||
|
||||
Create ( Parent : Mesh from MeshVS;
|
||||
Flags : DisplayModeFlags from MeshVS = MeshVS_DMF_ElementalColorDataPrs;
|
||||
DS : DataSource from MeshVS = 0;
|
||||
Id : Integer = -1;
|
||||
Priority : BuilderPriority from MeshVS = MeshVS_BP_ElemColor )
|
||||
returns mutable ElementalColorPrsBuilder from MeshVS;
|
||||
---Purpose: Constructor
|
||||
|
||||
Build ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IDsToExclude : in out PackedMapOfInteger;
|
||||
IsElement : Boolean;
|
||||
DisplayMode : Integer ) is virtual;
|
||||
---Purpose: Builds presentation of elements with assigned colors.
|
||||
|
||||
GetColors1 ( me ) returns DataMapOfIntegerColor from MeshVS;
|
||||
---C++: return const &
|
||||
---Purpose: Returns map of colors same for front and back side of face.
|
||||
|
||||
SetColors1 ( me : mutable;
|
||||
Map : DataMapOfIntegerColor from MeshVS );
|
||||
---Purpose: Sets map of colors same for front and back side of face.
|
||||
|
||||
HasColors1 ( me ) returns Boolean;
|
||||
---Purpose: Returns true, if map of colors isn't empty
|
||||
|
||||
GetColor1 ( me; ID : Integer;
|
||||
theColor : out Color from Quantity ) returns Boolean;
|
||||
---Purpose: Returns color assigned with element number ID
|
||||
|
||||
SetColor1 ( me : mutable;
|
||||
ID : Integer;
|
||||
theColor : Color from Quantity );
|
||||
---Purpose: Sets color assigned with element number ID
|
||||
|
||||
GetColors2 ( me ) returns DataMapOfIntegerTwoColors from MeshVS;
|
||||
---C++: return const &
|
||||
---Purpose: Returns map of different colors for front and back side of face
|
||||
|
||||
SetColors2 ( me : mutable; Map : DataMapOfIntegerTwoColors from MeshVS );
|
||||
---Purpose: Sets map of different colors for front and back side of face
|
||||
|
||||
HasColors2 ( me ) returns Boolean;
|
||||
---Purpose: Returns true, if map isn't empty
|
||||
|
||||
GetColor2 ( me; ID : Integer;
|
||||
theColor : out TwoColors from MeshVS ) returns Boolean;
|
||||
---Purpose: Returns colors assigned with element number ID
|
||||
|
||||
GetColor2 ( me; ID : Integer;
|
||||
theColor1 : out Color from Quantity;
|
||||
theColor2 : out Color from Quantity ) returns Boolean;
|
||||
---Purpose: Returns colors assigned with element number ID
|
||||
-- theColor1 is the front element color
|
||||
-- theColor2 is the back element color
|
||||
|
||||
SetColor2 ( me : mutable;
|
||||
ID : Integer;
|
||||
theTwoColors : TwoColors from MeshVS );
|
||||
---Purpose: Sets colors assigned with element number ID
|
||||
|
||||
SetColor2 ( me : mutable;
|
||||
ID : Integer;
|
||||
theColor1 : Color from Quantity;
|
||||
theColor2 : Color from Quantity );
|
||||
---Purpose: Sets color assigned with element number ID
|
||||
-- theColor1 is the front element color
|
||||
-- theColor2 is the back element color
|
||||
|
||||
fields
|
||||
myElemColorMap1 : DataMapOfIntegerColor from MeshVS;
|
||||
myElemColorMap2 : DataMapOfIntegerTwoColors from MeshVS;
|
||||
|
||||
end ElementalColorPrsBuilder;
|
681
src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx
Executable file
681
src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx
Executable file
@@ -0,0 +1,681 @@
|
||||
// File: MeshVS_ElementalColorPrsBuilder.cxx
|
||||
// Created: Wed Nov 12 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#define _POLYGONES_
|
||||
// if define _POLYGONES_ ColorPrsBuilder use ArrayOfPolygons for drawing faces
|
||||
|
||||
#include <MeshVS_ElementalColorPrsBuilder.ixx>
|
||||
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_ArrayOfPolygons.hxx>
|
||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
|
||||
#include <TColStd_MapOfInteger.hxx>
|
||||
#include <TColStd_PackedMapOfInteger.hxx>
|
||||
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TColStd_HPackedMapOfInteger.hxx>
|
||||
|
||||
#include <MeshVS_DisplayModeFlags.hxx>
|
||||
#include <MeshVS_DataSource.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_DataMapOfColorMapOfInteger.hxx>
|
||||
#include <MeshVS_DataMapOfTwoColorsMapOfInteger.hxx>
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_DataMapIteratorOfDataMapOfIntegerTwoColors.hxx>
|
||||
#include <MeshVS_DataMapIteratorOfDataMapOfIntegerColor.hxx>
|
||||
#include <MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger.hxx>
|
||||
#include <MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger.hxx>
|
||||
#include <MeshVS_MeshPrsBuilder.hxx>
|
||||
#include <MeshVS_Buffer.hxx>
|
||||
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_ElementalColorPrsBuilder
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_ElementalColorPrsBuilder::MeshVS_ElementalColorPrsBuilder
|
||||
( const Handle(MeshVS_Mesh)& Parent,
|
||||
const MeshVS_DisplayModeFlags& Flags,
|
||||
const Handle (MeshVS_DataSource)& DS,
|
||||
const Standard_Integer Id,
|
||||
const MeshVS_BuilderPriority& Priority )
|
||||
: MeshVS_PrsBuilder ( Parent, Flags, DS, Id, Priority )
|
||||
{
|
||||
SetExcluding ( Standard_True );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Build
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
|
||||
const TColStd_PackedMapOfInteger& IDs,
|
||||
TColStd_PackedMapOfInteger& IDsToExclude,
|
||||
const Standard_Boolean IsElement,
|
||||
const Standard_Integer DisplayMode) const
|
||||
{
|
||||
Handle (MeshVS_DataSource) aSource = GetDataSource();
|
||||
Handle (MeshVS_Drawer) aDrawer = GetDrawer();
|
||||
|
||||
if ( aSource.IsNull() || aDrawer.IsNull() )
|
||||
return;
|
||||
|
||||
Standard_Integer aMaxFaceNodes;
|
||||
if ( !aDrawer->GetInteger ( MeshVS_DA_MaxFaceNodes, aMaxFaceNodes ) && aMaxFaceNodes<=0 )
|
||||
return;
|
||||
|
||||
MeshVS_DataMapOfIntegerColor* anElemColorMap = (MeshVS_DataMapOfIntegerColor*) &myElemColorMap1;
|
||||
MeshVS_DataMapOfIntegerTwoColors* anElemTwoColorsMap = (MeshVS_DataMapOfIntegerTwoColors*)&myElemColorMap2;
|
||||
|
||||
MeshVS_DataMapOfColorMapOfInteger aColorsOfElements;
|
||||
MeshVS_DataMapOfTwoColorsMapOfInteger aTwoColorsOfElements;
|
||||
|
||||
MeshVS_Buffer aCoordsBuf (3*aMaxFaceNodes*sizeof(Standard_Real));
|
||||
TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3*aMaxFaceNodes);
|
||||
Standard_Integer NbNodes;
|
||||
MeshVS_EntityType aType;
|
||||
|
||||
if ( !( DisplayMode & GetFlags() ) || !IsElement ||
|
||||
( myElemColorMap1.IsEmpty() && myElemColorMap2.IsEmpty() ) )
|
||||
return;
|
||||
|
||||
// subtract the hidden elements and ids to exclude (to minimise allocated memory)
|
||||
TColStd_PackedMapOfInteger anIDs;
|
||||
anIDs.Assign( IDs );
|
||||
Handle(TColStd_HPackedMapOfInteger) aHiddenElems = myParentMesh->GetHiddenElems();
|
||||
if ( !aHiddenElems.IsNull() )
|
||||
anIDs.Subtract( aHiddenElems->Map() );
|
||||
anIDs.Subtract( IDsToExclude );
|
||||
|
||||
// STEP 0: We looking for two colored elements, who has equal two colors and move it
|
||||
// to map of elements with one assigned color
|
||||
TColStd_ListOfInteger aColorOne;
|
||||
for ( MeshVS_DataMapIteratorOfDataMapOfIntegerTwoColors anIter ( *anElemTwoColorsMap ); anIter.More(); anIter.Next () )
|
||||
{
|
||||
Standard_Integer aKey = anIter.Key ();
|
||||
MeshVS_TwoColors aValue = anIter.Value ();
|
||||
Quantity_Color aCol1, aCol2;
|
||||
ExtractColors ( aValue, aCol1, aCol2 );
|
||||
if ( aCol1 == aCol2 )
|
||||
{
|
||||
aColorOne.Append ( aKey );
|
||||
anElemColorMap->Bind ( aKey, aCol1 );
|
||||
}
|
||||
}
|
||||
|
||||
for ( TColStd_ListIteratorOfListOfInteger aLIter ( aColorOne ); aLIter.More(); aLIter.Next() )
|
||||
anElemTwoColorsMap->UnBind ( aLIter.Value() );
|
||||
|
||||
// The map is to resort itself by colors.
|
||||
// STEP 1: We start sorting elements with one assigned color
|
||||
for ( MeshVS_DataMapIteratorOfDataMapOfIntegerColor anIterM ( *anElemColorMap ); anIterM.More(); anIterM.Next () )
|
||||
{
|
||||
Standard_Integer aMKey = anIterM.Key ();
|
||||
// The ID of current element
|
||||
Standard_Boolean IsExist = Standard_False;
|
||||
for ( MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger anIterC ( aColorsOfElements );
|
||||
anIterC.More() && !IsExist; anIterC.Next () )
|
||||
if ( anIterC.Key()==anIterM.Value() )
|
||||
{
|
||||
TColStd_MapOfInteger& aChangeValue = (TColStd_MapOfInteger&) anIterC.Value();
|
||||
aChangeValue.Add ( aMKey );
|
||||
IsExist = Standard_True;
|
||||
}
|
||||
|
||||
if ( !IsExist )
|
||||
{
|
||||
TColStd_MapOfInteger aNewMap; aNewMap.Add ( aMKey );
|
||||
aColorsOfElements.Bind ( anIterM.Value(), aNewMap );
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 2: We start sorting elements with two assigned colors
|
||||
for ( MeshVS_DataMapIteratorOfDataMapOfIntegerTwoColors anIterM2 ( *anElemTwoColorsMap ); anIterM2.More();
|
||||
anIterM2.Next () )
|
||||
{
|
||||
Standard_Integer aMKey = anIterM2.Key ();
|
||||
// The ID of current element
|
||||
Standard_Boolean IsExist = Standard_False;
|
||||
for ( MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger anIterC2 ( aTwoColorsOfElements );
|
||||
anIterC2.More() && !IsExist; anIterC2.Next () )
|
||||
if ( IsEqual ( anIterC2.Key(), anIterM2.Value() ) )
|
||||
{
|
||||
TColStd_MapOfInteger& aChangeValue = (TColStd_MapOfInteger&) anIterC2.Value();
|
||||
aChangeValue.Add ( aMKey );
|
||||
IsExist = Standard_True;
|
||||
}
|
||||
|
||||
if ( !IsExist )
|
||||
{
|
||||
TColStd_MapOfInteger aNewMap; aNewMap.Add ( aMKey );
|
||||
aTwoColorsOfElements.Bind ( anIterM2.Value(), aNewMap );
|
||||
}
|
||||
}
|
||||
|
||||
//Now we are ready to draw faces with equal colors
|
||||
Aspect_InteriorStyle aStyle;
|
||||
Standard_Integer aStyleInt;
|
||||
Aspect_TypeOfLine anEdgeType = Aspect_TOL_SOLID;
|
||||
Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
|
||||
Standard_Integer anEdgeInt, aLineInt;
|
||||
Standard_Real anEdgeWidth, aLineWidth;
|
||||
Quantity_Color anInteriorColor;
|
||||
Quantity_Color anEdgeColor, aLineColor;
|
||||
Standard_Boolean anEdgeOn = Standard_True, IsReflect = Standard_False,
|
||||
IsMeshSmoothShading = Standard_False;
|
||||
|
||||
aDrawer->GetColor ( MeshVS_DA_InteriorColor, anInteriorColor );
|
||||
aDrawer->GetColor ( MeshVS_DA_EdgeColor, anEdgeColor );
|
||||
aDrawer->GetColor ( MeshVS_DA_BeamColor, aLineColor );
|
||||
aDrawer->GetDouble ( MeshVS_DA_EdgeWidth, anEdgeWidth );
|
||||
aDrawer->GetDouble ( MeshVS_DA_BeamWidth, aLineWidth );
|
||||
aDrawer->GetBoolean( MeshVS_DA_ShowEdges, anEdgeOn );
|
||||
aDrawer->GetBoolean( MeshVS_DA_ColorReflection, IsReflect );
|
||||
aDrawer->GetBoolean( MeshVS_DA_SmoothShading, IsMeshSmoothShading );
|
||||
|
||||
if ( aDrawer->GetInteger ( MeshVS_DA_InteriorStyle, aStyleInt) )
|
||||
aStyle = (Aspect_InteriorStyle) aStyleInt;
|
||||
|
||||
if ( aDrawer->GetInteger ( MeshVS_DA_EdgeType, anEdgeInt) )
|
||||
anEdgeType = (Aspect_TypeOfLine) anEdgeInt;
|
||||
|
||||
if ( aDrawer->GetInteger ( MeshVS_DA_BeamType, aLineInt) )
|
||||
aLineType = (Aspect_TypeOfLine) aLineInt;
|
||||
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger ) aTopo;
|
||||
Standard_Integer PolygonVerticesFor3D = 0, PolygonBoundsFor3D = 0;
|
||||
TColStd_MapIteratorOfPackedMapOfInteger it (anIDs);
|
||||
for( ; it.More(); it.Next() )
|
||||
{
|
||||
Standard_Integer aKey = it.Key();
|
||||
if( aSource->Get3DGeom( aKey, NbNodes, aTopo ) )
|
||||
MeshVS_MeshPrsBuilder::HowManyPrimitives
|
||||
( aTopo, Standard_True, Standard_False, NbNodes,
|
||||
PolygonVerticesFor3D, PolygonBoundsFor3D );
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect aMaterial[2];
|
||||
Standard_Integer i;
|
||||
for ( i=0; i<2; i++ )
|
||||
{
|
||||
// OCC20644 "plastic" is most suitable here, as it is "non-physic"
|
||||
// so TelUpdateMaterial() from OpenGl_attri.c uses the interior
|
||||
// color from AspectFillArea3d to calculate all material colors
|
||||
aMaterial[i] = Graphic3d_MaterialAspect ( Graphic3d_NOM_PLASTIC );
|
||||
|
||||
// OCC21720 For single-colored elements turning all material components off is a good idea,
|
||||
// as anyhow the normals are not computed and the lighting will be off,
|
||||
// the element color will be taken from Graphic3d_AspectFillArea3d's interior color,
|
||||
// and there is no need to spend time on updating material properties
|
||||
if ( !IsReflect )
|
||||
{
|
||||
aMaterial[i].SetReflectionModeOff(Graphic3d_TOR_AMBIENT);
|
||||
aMaterial[i].SetReflectionModeOff(Graphic3d_TOR_DIFFUSE);
|
||||
aMaterial[i].SetReflectionModeOff(Graphic3d_TOR_SPECULAR);
|
||||
aMaterial[i].SetReflectionModeOff(Graphic3d_TOR_EMISSION);
|
||||
}
|
||||
else
|
||||
{
|
||||
// OCC20644 This stuff is important in order for elemental and nodal colors
|
||||
// to produce similar visual impression and also to make colors match
|
||||
// those in the color scale most exactly (the sum of all reflection
|
||||
// coefficients is equal to 1). See also MeshVS_NodalColorPrsBuilder
|
||||
// class for more explanations.
|
||||
aMaterial[i].SetAmbient( .5 );
|
||||
aMaterial[i].SetDiffuse( .5 );
|
||||
aMaterial[i].SetSpecular( 0. );
|
||||
aMaterial[i].SetEmissive( 0. );
|
||||
}
|
||||
}
|
||||
|
||||
// Draw elements with one color
|
||||
for ( MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger aColIter ( aColorsOfElements ); aColIter.More();
|
||||
aColIter.Next() )
|
||||
{
|
||||
Standard_Integer aSize = aColIter.Value().Extent();
|
||||
if ( aSize<=0 )
|
||||
continue;
|
||||
|
||||
TColStd_PackedMapOfInteger aCustomElements;
|
||||
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle ( Graphic3d_Group ) aGGroup = Prs3d_Root::CurrentGroup ( Prs );
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle ( Graphic3d_Group ) aLGroup = Prs3d_Root::CurrentGroup ( Prs );
|
||||
|
||||
Handle (Graphic3d_ArrayOfPolygons) aPolyGArr = new Graphic3d_ArrayOfPolygons
|
||||
( aMaxFaceNodes*aSize + PolygonVerticesFor3D, aSize + PolygonBoundsFor3D, 0, IsReflect );
|
||||
Standard_Boolean IsPolyG = Standard_False;
|
||||
|
||||
Handle (Graphic3d_ArrayOfPolylines) aPolyLArr = new Graphic3d_ArrayOfPolylines
|
||||
( 2*aSize, aSize );
|
||||
Standard_Boolean IsPolyL = Standard_False;
|
||||
|
||||
// OCC20644 NOTE: aColIter.Key() color is then scaled by TelUpdateMaterial() in OpenGl_attri.c
|
||||
// using the material reflection coefficients. This affects the visual result.
|
||||
Handle(Graphic3d_AspectFillArea3d) anAsp =
|
||||
new Graphic3d_AspectFillArea3d ( Aspect_IS_SOLID, aColIter.Key(), anEdgeColor,
|
||||
anEdgeType, anEdgeWidth, aMaterial[0], aMaterial[1] );
|
||||
|
||||
Handle(Graphic3d_AspectLine3d) anLAsp =
|
||||
new Graphic3d_AspectLine3d ( aColIter.Key(), aLineType, aLineWidth );
|
||||
|
||||
anAsp->SetDistinguishOff ();
|
||||
anAsp->SetInteriorColor ( aColIter.Key() );
|
||||
if (anEdgeOn)
|
||||
anAsp->SetEdgeOn();
|
||||
else
|
||||
anAsp->SetEdgeOff();
|
||||
|
||||
for( it.Reset(); it.More(); it.Next() )
|
||||
{
|
||||
Standard_Integer aKey = it.Key();
|
||||
if( aColIter.Value().Contains( aKey ) )
|
||||
{
|
||||
if ( !aSource->GetGeom ( aKey, Standard_True, aCoords, NbNodes, aType ) )
|
||||
continue;
|
||||
|
||||
if( aType == MeshVS_ET_Face )
|
||||
{
|
||||
aPolyGArr->AddBound ( NbNodes );
|
||||
if( IsExcludingOn() )
|
||||
IDsToExclude.Add( aKey );
|
||||
}
|
||||
else if( aType == MeshVS_ET_Link )
|
||||
{
|
||||
aPolyLArr->AddBound ( NbNodes );
|
||||
if( IsExcludingOn() )
|
||||
IDsToExclude.Add( aKey );
|
||||
}
|
||||
else if( aType == MeshVS_ET_Volume )
|
||||
{
|
||||
if( IsExcludingOn() )
|
||||
IDsToExclude.Add( aKey );
|
||||
if( aSource->Get3DGeom( aKey, NbNodes, aTopo ) )
|
||||
{
|
||||
MeshVS_MeshPrsBuilder::AddVolumePrs( aTopo, aCoords, NbNodes, aPolyGArr, IsReflect, Standard_False, Standard_False, 1.0 );
|
||||
IsPolyG = Standard_True;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
aCustomElements.Add( aKey );
|
||||
continue;
|
||||
}
|
||||
|
||||
// Preparing normal(s) to show reflections if requested
|
||||
Handle(TColStd_HArray1OfReal) aNormals;
|
||||
Standard_Boolean hasNormals = IsReflect && aSource->GetNormalsByElement( aKey, IsMeshSmoothShading, aMaxFaceNodes, aNormals );
|
||||
|
||||
// Adding vertices (with normals if necessary)
|
||||
for ( i=1; i<=NbNodes; i++ )
|
||||
if ( aType == MeshVS_ET_Face )
|
||||
{
|
||||
if ( IsReflect )
|
||||
{
|
||||
hasNormals ? aPolyGArr->AddVertex ( aCoords(3 * i - 2),
|
||||
aCoords(3 * i - 1),
|
||||
aCoords(3 * i ),
|
||||
aNormals->Value(3 * i - 2),
|
||||
aNormals->Value(3 * i - 1),
|
||||
aNormals->Value(3 * i ) ) :
|
||||
aPolyGArr->AddVertex ( aCoords(3 * i - 2),
|
||||
aCoords(3 * i - 1),
|
||||
aCoords(3 * i ),
|
||||
0.,
|
||||
0.,
|
||||
1. );
|
||||
}
|
||||
else
|
||||
aPolyGArr->AddVertex ( aCoords(3 * i - 2),
|
||||
aCoords(3 * i - 1),
|
||||
aCoords(3 * i ) );
|
||||
IsPolyG = Standard_True;
|
||||
}
|
||||
else if ( aType == MeshVS_ET_Link )
|
||||
{
|
||||
aPolyLArr->AddVertex ( aCoords(3*i-2), aCoords(3*i-1), aCoords(3*i) );
|
||||
IsPolyL = Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( IsPolyG )
|
||||
{
|
||||
aGGroup->SetPrimitivesAspect ( anAsp );
|
||||
aGGroup->BeginPrimitives();
|
||||
aGGroup->AddPrimitiveArray ( aPolyGArr );
|
||||
aGGroup->EndPrimitives();
|
||||
}
|
||||
if ( IsPolyL )
|
||||
{
|
||||
anAsp->SetEdgeOff();
|
||||
aLGroup->SetPrimitivesAspect ( anAsp );
|
||||
aLGroup->SetPrimitivesAspect ( anLAsp );
|
||||
aLGroup->BeginPrimitives();
|
||||
aLGroup->AddPrimitiveArray ( aPolyLArr );
|
||||
aLGroup->EndPrimitives();
|
||||
if (anEdgeOn)
|
||||
anAsp->SetEdgeOn();
|
||||
else
|
||||
anAsp->SetEdgeOff();
|
||||
}
|
||||
|
||||
if( !aCustomElements.IsEmpty() )
|
||||
CustomBuild( Prs, aCustomElements, IDsToExclude, DisplayMode );
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect aMaterial2[2];
|
||||
for ( i=0; i<2; i++ )
|
||||
{
|
||||
// OCC20644 "plastic" is most suitable here, as it is "non-physic"
|
||||
// so TelUpdateMaterial() from OpenGl_attri.c uses the interior
|
||||
// color from AspectFillArea3d to calculate all material colors
|
||||
aMaterial2[i] = Graphic3d_MaterialAspect ( Graphic3d_NOM_PLASTIC );
|
||||
|
||||
if ( !IsReflect )
|
||||
{
|
||||
// OCC21720 Cannot turn ALL material components off, as such a material
|
||||
// would be ignored by TelUpdateMaterial(), but we need it in order
|
||||
// to have different materials for front and back sides!
|
||||
// Instead, trying to make material color "nondirectional" with
|
||||
// only ambient component on.
|
||||
aMaterial2[i].SetReflectionModeOn ( Graphic3d_TOR_AMBIENT );
|
||||
aMaterial2[i].SetReflectionModeOff( Graphic3d_TOR_DIFFUSE );
|
||||
aMaterial2[i].SetReflectionModeOff( Graphic3d_TOR_SPECULAR );
|
||||
aMaterial2[i].SetReflectionModeOff( Graphic3d_TOR_EMISSION );
|
||||
aMaterial2[i].SetAmbient ( 1. );
|
||||
aMaterial2[i].SetDiffuse ( 0. );
|
||||
aMaterial2[i].SetSpecular( 0. );
|
||||
aMaterial2[i].SetEmissive( 0. );
|
||||
}
|
||||
else
|
||||
{
|
||||
// OCC20644 This stuff is important in order for elemental and nodal colors
|
||||
// to produce similar visual impression and also to make colors match
|
||||
// those in the color scale most exactly (the sum of all reflection
|
||||
// coefficients is equal to 1). See also MeshVS_NodalColorPrsBuilder
|
||||
// class for more explanations.
|
||||
aMaterial2[i].SetAmbient( .5 );
|
||||
aMaterial2[i].SetDiffuse( .5 );
|
||||
aMaterial2[i].SetSpecular( 0. );
|
||||
aMaterial2[i].SetEmissive( 0. );
|
||||
}
|
||||
}
|
||||
|
||||
// Draw faces with two color
|
||||
for ( MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger aColIter2 ( aTwoColorsOfElements );
|
||||
aColIter2.More(); aColIter2.Next() )
|
||||
{
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle ( Graphic3d_Group ) aGroup2 = Prs3d_Root::CurrentGroup ( Prs );
|
||||
|
||||
Standard_Integer aSize = aColIter2.Value().Extent();
|
||||
if ( aSize<=0 )
|
||||
continue;
|
||||
|
||||
#ifdef _POLYGONES_
|
||||
Handle (Graphic3d_ArrayOfPolygons) aPolyArr = new Graphic3d_ArrayOfPolygons
|
||||
( aMaxFaceNodes*aSize, aSize, 0, IsReflect );
|
||||
#endif
|
||||
|
||||
MeshVS_TwoColors aTC = aColIter2.Key();
|
||||
Quantity_Color aMyIntColor, aMyBackColor;
|
||||
ExtractColors ( aTC, aMyIntColor, aMyBackColor );
|
||||
|
||||
// OCC20644 NOTE: aMyIntColor color is then scaled by TelUpdateMaterial() in OpenGl_attri.c
|
||||
// using the material reflection coefficients. This affects the visual result.
|
||||
Handle(Graphic3d_AspectFillArea3d) anAsp =
|
||||
new Graphic3d_AspectFillArea3d ( Aspect_IS_SOLID, aMyIntColor, anEdgeColor,
|
||||
anEdgeType, anEdgeWidth, aMaterial2[0], aMaterial2[1] );
|
||||
anAsp->SetDistinguishOn ();
|
||||
anAsp->SetInteriorColor ( aMyIntColor );
|
||||
anAsp->SetBackInteriorColor ( aMyBackColor );
|
||||
if (anEdgeOn)
|
||||
anAsp->SetEdgeOn();
|
||||
else
|
||||
anAsp->SetEdgeOff();
|
||||
|
||||
aGroup2->SetPrimitivesAspect ( anAsp );
|
||||
aGroup2->BeginPrimitives();
|
||||
|
||||
for( it.Reset(); it.More(); it.Next() )
|
||||
{
|
||||
Standard_Integer aKey = it.Key();
|
||||
if( aColIter2.Value().Contains( aKey ) )
|
||||
{
|
||||
if ( !aSource->GetGeom ( aKey, Standard_True, aCoords, NbNodes, aType ) )
|
||||
continue;
|
||||
|
||||
if( IsExcludingOn() )
|
||||
IDsToExclude.Add( aKey );
|
||||
|
||||
if ( aType == MeshVS_ET_Face && NbNodes > 0 )
|
||||
{
|
||||
// Preparing normal(s) to show reflections if requested
|
||||
Handle(TColStd_HArray1OfReal) aNormals;
|
||||
// OCC21720 Always passing normals to OpenGL to make materials work
|
||||
// For OpenGL: "No normals" -> "No lighting" -> "no materials taken into account"
|
||||
Standard_Boolean hasNormals = /*IsReflect &&*/
|
||||
aSource->GetNormalsByElement( aKey, IsMeshSmoothShading, aMaxFaceNodes, aNormals );
|
||||
|
||||
#ifdef _POLYGONES_
|
||||
aPolyArr->AddBound ( NbNodes );
|
||||
#else
|
||||
Graphic3d_Array1OfVertex aVertArr ( 1, NbNodes );
|
||||
#endif
|
||||
|
||||
for ( i=1; i<=NbNodes; i++ )
|
||||
{
|
||||
#ifdef _POLYGONES_
|
||||
if ( IsReflect )
|
||||
{
|
||||
hasNormals ? aPolyArr->AddVertex ( aCoords(3 * i - 2),
|
||||
aCoords(3 * i - 1),
|
||||
aCoords(3 * i ),
|
||||
aNormals->Value(3 * i - 2),
|
||||
aNormals->Value(3 * i - 1),
|
||||
aNormals->Value(3 * i ) ) :
|
||||
aPolyArr->AddVertex ( aCoords(3 * i - 2),
|
||||
aCoords(3 * i - 1),
|
||||
aCoords(3 * i ),
|
||||
0.,
|
||||
0.,
|
||||
1. );
|
||||
}
|
||||
else
|
||||
aPolyArr->AddVertex ( aCoords(3*i-2),
|
||||
aCoords(3*i-1),
|
||||
aCoords(3*i ) );
|
||||
#else
|
||||
if ( IsReflect )
|
||||
{
|
||||
aVertArr (i) = hasNormals ? Graphic3d_VertexN( aCoords(3 * i - 2),
|
||||
aCoords(3 * i - 1),
|
||||
aCoords(3 * i ),
|
||||
aNormals->Value(3 * i - 2),
|
||||
aNormals->Value(3 * i - 1),
|
||||
aNormals->Value(3 * i ),
|
||||
Standard_False ) :
|
||||
Graphic3d_VertexN( aCoords(3 * i - 2),
|
||||
aCoords(3 * i - 1),
|
||||
aCoords(3 * i ),
|
||||
0.,
|
||||
0.,
|
||||
1.,
|
||||
Standard_False );
|
||||
|
||||
}
|
||||
else
|
||||
Graphic3d_Vertex ( aCoords(3 * i - 2),
|
||||
aCoords(3 * i - 1),
|
||||
aCoords(3 * i ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef _POLYGONES_
|
||||
aGroup2->Polygon ( aVertArr );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef _POLYGONES_
|
||||
aGroup2->AddPrimitiveArray ( aPolyArr );
|
||||
#endif
|
||||
aGroup2->EndPrimitives();
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetColors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_ElementalColorPrsBuilder::SetColors1 ( const MeshVS_DataMapOfIntegerColor& theColorMap )
|
||||
{
|
||||
myElemColorMap1 = theColorMap;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetColors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const MeshVS_DataMapOfIntegerColor& MeshVS_ElementalColorPrsBuilder::GetColors1 () const
|
||||
{
|
||||
return myElemColorMap1;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : HasColors1
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_ElementalColorPrsBuilder::HasColors1 () const
|
||||
{
|
||||
return ( myElemColorMap1.Extent() >0 );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetColor1
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_ElementalColorPrsBuilder::GetColor1 ( const Standard_Integer ID,
|
||||
Quantity_Color& theColor ) const
|
||||
{
|
||||
Standard_Boolean aRes = myElemColorMap1.IsBound ( ID );
|
||||
if ( aRes )
|
||||
theColor = myElemColorMap1.Find ( ID );
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetColor1
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_ElementalColorPrsBuilder::SetColor1 ( const Standard_Integer theID,
|
||||
const Quantity_Color& theCol )
|
||||
{
|
||||
Standard_Boolean aRes = myElemColorMap1.IsBound ( theID );
|
||||
if ( aRes )
|
||||
myElemColorMap1.ChangeFind ( theID ) = theCol;
|
||||
else
|
||||
myElemColorMap1.Bind ( theID, theCol );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetColors2
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_ElementalColorPrsBuilder::SetColors2 ( const MeshVS_DataMapOfIntegerTwoColors& theColorMap )
|
||||
{
|
||||
myElemColorMap2 = theColorMap;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetColors2
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const MeshVS_DataMapOfIntegerTwoColors& MeshVS_ElementalColorPrsBuilder::GetColors2 () const
|
||||
{
|
||||
return myElemColorMap2;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : HasColors2
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_ElementalColorPrsBuilder::HasColors2 () const
|
||||
{
|
||||
return (myElemColorMap2.Extent()>0);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetColor2
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_ElementalColorPrsBuilder::GetColor2 ( const Standard_Integer ID,
|
||||
MeshVS_TwoColors& theColor ) const
|
||||
{
|
||||
Standard_Boolean aRes = myElemColorMap2.IsBound ( ID );
|
||||
if ( aRes )
|
||||
theColor = myElemColorMap2.Find ( ID );
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetColor2
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_ElementalColorPrsBuilder::GetColor2 ( const Standard_Integer ID,
|
||||
Quantity_Color& theColor1,
|
||||
Quantity_Color& theColor2 ) const
|
||||
{
|
||||
MeshVS_TwoColors aTC;
|
||||
Standard_Boolean aRes = GetColor2 ( ID, aTC );
|
||||
if ( aRes)
|
||||
ExtractColors ( aTC, theColor1, theColor2 );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetColor2
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_ElementalColorPrsBuilder::SetColor2 ( const Standard_Integer theID,
|
||||
const Quantity_Color& theCol1,
|
||||
const Quantity_Color& theCol2 )
|
||||
{
|
||||
SetColor2 ( theID, BindTwoColors ( theCol1, theCol2 ) );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetColor2
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_ElementalColorPrsBuilder::SetColor2 ( const Standard_Integer theID,
|
||||
const MeshVS_TwoColors& theCol )
|
||||
{
|
||||
Standard_Boolean aRes = myElemColorMap2.IsBound ( theID );
|
||||
if ( aRes )
|
||||
myElemColorMap2.ChangeFind ( theID ) = theCol;
|
||||
else
|
||||
myElemColorMap2.Bind ( theID, theCol );
|
||||
}
|
25
src/MeshVS/MeshVS_EntityType.hxx
Executable file
25
src/MeshVS/MeshVS_EntityType.hxx
Executable file
@@ -0,0 +1,25 @@
|
||||
// File: MeshVS_EntityType.hxx
|
||||
// Created: Mon Sep 29 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#ifndef MeshVS_ENTITYTYPEHXX
|
||||
#define MeshVS_ENTITYTYPEHXX
|
||||
|
||||
Standard_EXPORT typedef enum
|
||||
{
|
||||
MeshVS_ET_NONE = 0x00,
|
||||
MeshVS_ET_Node = 0x01,
|
||||
MeshVS_ET_0D = 0x02,
|
||||
MeshVS_ET_Link = 0x04,
|
||||
MeshVS_ET_Face = 0x08,
|
||||
MeshVS_ET_Volume = 0x10,
|
||||
|
||||
MeshVS_ET_Element = MeshVS_ET_0D | MeshVS_ET_Link | MeshVS_ET_Face | MeshVS_ET_Volume,
|
||||
MeshVS_ET_All = MeshVS_ET_Element | MeshVS_ET_Node
|
||||
|
||||
|
||||
} MeshVS_EntityType;
|
||||
|
||||
#endif
|
||||
|
223
src/MeshVS/MeshVS_Mesh.cdl
Executable file
223
src/MeshVS/MeshVS_Mesh.cdl
Executable file
@@ -0,0 +1,223 @@
|
||||
-- File : MeshVS_Mesh.cdl
|
||||
-- Created : 10 October 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
|
||||
class Mesh from MeshVS inherits InteractiveObject from AIS
|
||||
|
||||
---Purpose: the main class provides interface to create mesh presentation as a whole
|
||||
|
||||
uses
|
||||
PackedMapOfInteger from TColStd,
|
||||
HPackedMapOfInteger from TColStd,
|
||||
|
||||
InteractiveObject from AIS,
|
||||
|
||||
PresentationManager3d from PrsMgr,
|
||||
|
||||
Presentation from Prs3d,
|
||||
|
||||
NameOfColor from Quantity,
|
||||
|
||||
Selection from SelectMgr,
|
||||
EntityOwner from SelectMgr,
|
||||
SequenceOfOwner from SelectMgr,
|
||||
|
||||
Boolean from Standard,
|
||||
CString from Standard,
|
||||
|
||||
PrsBuilder from MeshVS,
|
||||
Drawer from MeshVS,
|
||||
DataMapOfIntegerOwner from MeshVS,
|
||||
DataSource from MeshVS,
|
||||
SequenceOfPrsBuilder from MeshVS,
|
||||
MeshSelectionMethod from MeshVS
|
||||
|
||||
is
|
||||
|
||||
Create ( theIsAllowOverlapped : Boolean = Standard_False ) returns mutable Mesh;
|
||||
---Purpose: Constructor.
|
||||
-- theIsAllowOverlapped is Standard_True, if it is allowed to draw edges overlapped with beams
|
||||
-- Its value is stored in drawer
|
||||
|
||||
Destroy( me: mutable ) is virtual;
|
||||
---C++: alias ~
|
||||
|
||||
Compute ( me : mutable;
|
||||
PM : PresentationManager3d from PrsMgr;
|
||||
Prs : Presentation from Prs3d;
|
||||
DisplayMode : Integer ) is redefined;
|
||||
---Purpose: Computes presentation using builders added to sequence. Each builder computes
|
||||
-- own part of mesh presentation according to its type.
|
||||
|
||||
ComputeSelection ( me : mutable;
|
||||
Sel : Selection from SelectMgr;
|
||||
SelectMode : Integer ) is redefined;
|
||||
---Purpose: Computes selection according to SelectMode
|
||||
|
||||
HilightSelected ( me : mutable;
|
||||
PM : PresentationManager3d from PrsMgr;
|
||||
Owners : SequenceOfOwner from SelectMgr ) is redefined;
|
||||
---Purpose: Draw selected owners presentation
|
||||
|
||||
HilightOwnerWithColor ( me : mutable;
|
||||
PM : PresentationManager3d from PrsMgr;
|
||||
Color : NameOfColor from Quantity;
|
||||
Owner : EntityOwner from SelectMgr ) is redefined;
|
||||
---Purpose: Draw hilighted owner presentation
|
||||
|
||||
ClearSelected ( me : mutable ) is redefined;
|
||||
---Purpose: Clears internal selection presentation
|
||||
|
||||
GetBuildersCount ( me ) returns Integer;
|
||||
---Purpose: How many builders there are in sequence
|
||||
|
||||
GetBuilder ( me; Index : Integer ) returns PrsBuilder from MeshVS;
|
||||
---Purpose: Returns builder by its index in sequence
|
||||
|
||||
GetBuilderById ( me; Id : Integer ) returns PrsBuilder from MeshVS;
|
||||
---Purpose: Returns builder by its ID
|
||||
|
||||
GetFreeId ( me ) returns Integer;
|
||||
---Purpose: Returns the smallest positive ID, not occupied by any builder.
|
||||
-- This method using when builder is created with ID = -1
|
||||
|
||||
AddBuilder ( me : mutable;
|
||||
Builder : PrsBuilder from MeshVS;
|
||||
TreatAsHilighter : Boolean = Standard_False );
|
||||
---Purpose: Adds builder to tale of sequence.
|
||||
-- PrsBuilder is builder to be added
|
||||
-- If TreatAsHilighter is true, MeshVS_Mesh will use this builder to create
|
||||
-- presentation of hilighted and selected owners.
|
||||
-- Only one builder can be hilighter, so that if you call this method with
|
||||
-- TreatAsHilighter = Standard_True some times, only last builder will be hilighter
|
||||
-- WARNING: As minimum one builder must be added as hilighter, otherwise selection cannot be computed
|
||||
|
||||
SetHilighter ( me : mutable; Builder : PrsBuilder from MeshVS );
|
||||
---Purpose: Changes hilighter ( see above )
|
||||
|
||||
SetHilighter ( me : mutable; Index : Integer ) returns Boolean;
|
||||
---Purpose: Sets builder with sequence index "Index" as hilighter
|
||||
|
||||
SetHilighterById ( me : mutable; Id : Integer ) returns Boolean;
|
||||
---Purpose: Sets builder with identificator "Id" as hilighter
|
||||
|
||||
GetHilighter ( me ) returns PrsBuilder from MeshVS;
|
||||
---Purpose: Returns hilighter
|
||||
|
||||
RemoveBuilder ( me : mutable; Index : Integer );
|
||||
---Purpose: Removes builder from sequence. If it is hilighter, hilighter will be NULL
|
||||
-- ( Don't remember to set it to other after!!! )
|
||||
|
||||
RemoveBuilderById ( me : mutable; Id : Integer );
|
||||
---Purpose: Removes builder with identificator Id
|
||||
|
||||
FindBuilder ( me; TypeString : CString ) returns PrsBuilder from MeshVS;
|
||||
---Purpose: Finds builder by its type the string represents
|
||||
|
||||
GetOwnerMaps ( me : mutable; IsElement : Boolean ) returns DataMapOfIntegerOwner from MeshVS;
|
||||
---C++: return const &
|
||||
---Purpose: Returns map of owners.
|
||||
|
||||
GetDataSource ( me ) returns DataSource from MeshVS;
|
||||
---Purpose: Returns default builders' data source
|
||||
|
||||
SetDataSource ( me : mutable; aDataSource : DataSource from MeshVS );
|
||||
---Purpose: Sets default builders' data source
|
||||
|
||||
GetDrawer ( me ) returns Drawer from MeshVS;
|
||||
---Purpose: Returns default builders' drawer
|
||||
|
||||
SetDrawer ( me: mutable; aDrawer : Drawer from MeshVS );
|
||||
---Purpose: Sets default builders' drawer
|
||||
|
||||
IsHiddenElem ( me; ID: Integer ) returns Boolean;
|
||||
---Purpose: Returns True if specified element is hidden
|
||||
-- By default no elements are hidden
|
||||
|
||||
IsHiddenNode ( me; ID: Integer ) returns Boolean;
|
||||
---Purpose: Returns True if specified node is hidden.
|
||||
-- By default all nodes are hidden
|
||||
|
||||
IsSelectableElem ( me; ID: Integer ) returns Boolean;
|
||||
---Purpose: Returns True if specified element is not hidden
|
||||
|
||||
IsSelectableNode ( me; ID: Integer ) returns Boolean;
|
||||
---Purpose: Returns True if specified node is specified as selectable.
|
||||
|
||||
GetHiddenNodes ( me )
|
||||
returns HPackedMapOfInteger from TColStd;
|
||||
---C++: return const &
|
||||
---Purpose: Returns map of hidden nodes (may be null handle)
|
||||
|
||||
SetHiddenNodes ( me: mutable; Ids : HPackedMapOfInteger from TColStd );
|
||||
---Purpose: Sets map of hidden nodes, which shall not be displayed individually.
|
||||
-- If nodes shared by some elements shall not be drawn,
|
||||
-- they should be included into that map
|
||||
|
||||
GetHiddenElems ( me )
|
||||
returns HPackedMapOfInteger from TColStd;
|
||||
---C++: return const &
|
||||
---Purpose: Returns map of hidden elements (may be null handle)
|
||||
|
||||
SetHiddenElems ( me: mutable; Ids : HPackedMapOfInteger from TColStd );
|
||||
---Purpose: Sets map of hidden elements
|
||||
|
||||
GetSelectableNodes ( me )
|
||||
returns HPackedMapOfInteger from TColStd;
|
||||
---C++: return const &
|
||||
---Purpose: Returns map of selectable elements (may be null handle)
|
||||
|
||||
SetSelectableNodes ( me: mutable; Ids : HPackedMapOfInteger from TColStd );
|
||||
---Purpose: Sets map of selectable nodes.
|
||||
|
||||
UpdateSelectableNodes ( me: mutable );
|
||||
---Purpose: Automatically computes selectable nodes; the node is considered
|
||||
-- as being selectable if it is either not hidden, or is hidden
|
||||
-- but referred by at least one non-hidden element.
|
||||
-- Thus all nodes that are visible (either individually, or as ends or
|
||||
-- corners of elements) are selectable by default.
|
||||
|
||||
GetMeshSelMethod( me ) returns MeshSelectionMethod from MeshVS;
|
||||
---Purpose: Returns set mesh selection method (see MeshVS.cdl)
|
||||
|
||||
SetMeshSelMethod( me: mutable; M : MeshSelectionMethod from MeshVS );
|
||||
---Purpose: Sets mesh selection method (see MeshVS.cdl)
|
||||
|
||||
IsWholeMeshOwner( me; theOwner: EntityOwner from SelectMgr)
|
||||
returns Boolean from Standard
|
||||
is virtual;
|
||||
---Purpose: Returns True if the given owner represents a whole mesh.
|
||||
|
||||
fields
|
||||
myBuilders : SequenceOfPrsBuilder from MeshVS;
|
||||
myHilighter : PrsBuilder from MeshVS;
|
||||
|
||||
myHiddenElements : HPackedMapOfInteger from TColStd;
|
||||
myHiddenNodes : HPackedMapOfInteger from TColStd;
|
||||
mySelectableNodes : HPackedMapOfInteger from TColStd;
|
||||
|
||||
myNodeOwners : DataMapOfIntegerOwner from MeshVS is protected;
|
||||
myElementOwners : DataMapOfIntegerOwner from MeshVS is protected;
|
||||
my0DOwners : DataMapOfIntegerOwner from MeshVS is protected;
|
||||
myLinkOwners : DataMapOfIntegerOwner from MeshVS is protected;
|
||||
myFaceOwners : DataMapOfIntegerOwner from MeshVS is protected;
|
||||
myVolumeOwners : DataMapOfIntegerOwner from MeshVS is protected;
|
||||
myGroupOwners : DataMapOfIntegerOwner from MeshVS is protected;
|
||||
myMeshOwners : DataMapOfIntegerOwner from MeshVS is protected;
|
||||
|
||||
myDataSource : DataSource from MeshVS;
|
||||
myCurrentDrawer : Drawer from MeshVS is protected;
|
||||
mySelectionDrawer : Drawer from MeshVS is protected;
|
||||
myHilightDrawer : Drawer from MeshVS is protected;
|
||||
-- mySelectionPrs : Presentation from Prs3d is protected;
|
||||
-- myHilightPrs : Presentation from Prs3d is protected;
|
||||
|
||||
myWholeMeshOwner : EntityOwner from SelectMgr is protected;
|
||||
mySelectionMethod : MeshSelectionMethod from MeshVS;
|
||||
|
||||
friends
|
||||
class PrsBuilder from MeshVS
|
||||
|
||||
end Mesh;
|
1304
src/MeshVS/MeshVS_Mesh.cxx
Executable file
1304
src/MeshVS/MeshVS_Mesh.cxx
Executable file
File diff suppressed because it is too large
Load Diff
79
src/MeshVS/MeshVS_MeshEntityOwner.cdl
Executable file
79
src/MeshVS/MeshVS_MeshEntityOwner.cdl
Executable file
@@ -0,0 +1,79 @@
|
||||
-- File : MeshVS_MeshEntityOwner.cdl
|
||||
-- Created : 10 October 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
|
||||
class MeshEntityOwner from MeshVS inherits EntityOwner from SelectMgr
|
||||
|
||||
---Purpose: The custom owner. This class provides methods to store owner information:
|
||||
-- 1) An address of element or node data structure
|
||||
-- 2) Type of node or element owner assigned
|
||||
-- 3) ID of node or element owner assigned
|
||||
|
||||
uses
|
||||
SOPtr from SelectMgr,
|
||||
|
||||
Integer from Standard,
|
||||
Address from Standard,
|
||||
|
||||
Array1OfReal from TColStd,
|
||||
|
||||
EntityType from MeshVS,
|
||||
|
||||
PresentationManager3d from PrsMgr,
|
||||
PresentationManager from PrsMgr,
|
||||
|
||||
NameOfColor from Quantity
|
||||
|
||||
is
|
||||
|
||||
Create ( SelObj : SOPtr from SelectMgr;
|
||||
ID : Integer;
|
||||
MeshEntity : Address;
|
||||
Type : EntityType from MeshVS;
|
||||
Priority : Integer = 0;
|
||||
IsGroup : Boolean = Standard_False ) returns mutable MeshEntityOwner from MeshVS;
|
||||
|
||||
Owner ( me ) returns Address;
|
||||
---Purpose: Returns an address of element or node data structure
|
||||
|
||||
Type ( me ) returns EntityType;
|
||||
---Purpose: Returns type of element or node data structure
|
||||
|
||||
ID ( me ) returns Integer;
|
||||
---Purpose: Returns ID of element or node data structure
|
||||
|
||||
IsGroup ( me ) returns Boolean;
|
||||
---Purpose: Returns true if owner represents group of nodes or elements
|
||||
|
||||
IsHilighted ( me; PM : PresentationManager from PrsMgr;
|
||||
Mode : Integer = 0 ) returns Boolean is redefined;
|
||||
---Purpose: Returns true if owner is hilighted
|
||||
|
||||
Hilight ( me : mutable ) is redefined;
|
||||
---Purpose: Hilights owner
|
||||
|
||||
Hilight ( me : mutable; PM : PresentationManager from PrsMgr;
|
||||
Mode : Integer = 0 ) is redefined;
|
||||
---Purpose: Hilights owner
|
||||
|
||||
HilightWithColor ( me : mutable; PM : PresentationManager3d from PrsMgr;
|
||||
theColor : NameOfColor from Quantity;
|
||||
Mode : Integer = 0 ) is redefined;
|
||||
---Purpose: Hilights owner with the certain color
|
||||
|
||||
Unhilight ( me : mutable; PM : PresentationManager from PrsMgr;
|
||||
Mode : Integer = 0 ) is redefined;
|
||||
---Purpose: Strip hilight of owner
|
||||
|
||||
Clear ( me : mutable; PM : PresentationManager from PrsMgr;
|
||||
Mode : Integer = 0 ) is redefined;
|
||||
|
||||
fields
|
||||
myAddr : Address;
|
||||
myType : EntityType from MeshVS;
|
||||
myID : Integer;
|
||||
myIsGroup : Boolean;
|
||||
|
||||
end MeshEntityOwner;
|
143
src/MeshVS/MeshVS_MeshEntityOwner.cxx
Executable file
143
src/MeshVS/MeshVS_MeshEntityOwner.cxx
Executable file
@@ -0,0 +1,143 @@
|
||||
// File: MeshVS_MeshEntityOwner.cxx
|
||||
// Created: Tue Sep 9 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_MeshEntityOwner.ixx>
|
||||
|
||||
#include <SelectBasics_EntityOwner.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfReal.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <SelectMgr_SelectableObject.hxx>
|
||||
#include <PrsMgr_PresentationManager.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
|
||||
|
||||
#ifndef MeshVS_PRSBUILDERHXX
|
||||
#include <MeshVS_PrsBuilder.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_MeshEntityOwner
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_MeshEntityOwner::MeshVS_MeshEntityOwner
|
||||
( const SelectMgr_SOPtr& SelObj,
|
||||
const Standard_Integer ID,
|
||||
const Standard_Address MeshEntity,
|
||||
const MeshVS_EntityType& Type,
|
||||
const Standard_Integer Priority,
|
||||
const Standard_Boolean IsGroup )
|
||||
: SelectMgr_EntityOwner ( SelObj, Priority ),
|
||||
myAddr ( MeshEntity ),
|
||||
myType ( Type ),
|
||||
myID ( ID ),
|
||||
myIsGroup ( IsGroup )
|
||||
{
|
||||
SelectBasics_EntityOwner::Set ( Priority );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Owner
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Address MeshVS_MeshEntityOwner::Owner() const
|
||||
{
|
||||
return myAddr;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Type
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_EntityType MeshVS_MeshEntityOwner::Type() const
|
||||
{
|
||||
return myType;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : IsGroup
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_MeshEntityOwner::IsGroup() const
|
||||
{
|
||||
return myIsGroup;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : IsHilighted
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_MeshEntityOwner::IsHilighted ( const Handle(PrsMgr_PresentationManager)&,
|
||||
const Standard_Integer ) const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Hilight
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_MeshEntityOwner::Hilight ()
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Hilight
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_MeshEntityOwner::Hilight ( const Handle(PrsMgr_PresentationManager)&,
|
||||
const Standard_Integer )
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : HilightWithColor
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_MeshEntityOwner::HilightWithColor ( const Handle(PrsMgr_PresentationManager3d)& thePM,
|
||||
const Quantity_NameOfColor theColor,
|
||||
const Standard_Integer /*theMode*/ )
|
||||
{
|
||||
Handle( SelectMgr_SelectableObject ) aSelObj;
|
||||
if ( HasSelectable() )
|
||||
aSelObj = Selectable();
|
||||
|
||||
if ( thePM->IsImmediateModeOn() && aSelObj->IsKind( STANDARD_TYPE( MeshVS_Mesh ) ) )
|
||||
{
|
||||
Handle( MeshVS_Mesh ) aMesh = Handle( MeshVS_Mesh )::DownCast ( aSelObj );
|
||||
aMesh->HilightOwnerWithColor ( thePM, theColor, this );
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Unhilight
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_MeshEntityOwner::Unhilight ( const Handle(PrsMgr_PresentationManager)&,
|
||||
const Standard_Integer )
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Clear
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_MeshEntityOwner::Clear ( const Handle(PrsMgr_PresentationManager)&,
|
||||
const Standard_Integer )
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : ID
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Integer MeshVS_MeshEntityOwner::ID () const
|
||||
{
|
||||
return myID;
|
||||
}
|
77
src/MeshVS/MeshVS_MeshOwner.cdl
Executable file
77
src/MeshVS/MeshVS_MeshOwner.cdl
Executable file
@@ -0,0 +1,77 @@
|
||||
-- File : MeshVS_MeshOwner.cdl
|
||||
-- Created : 24 January 2007
|
||||
-- Author : Sergey Kochetkov
|
||||
---Copyright: Open CASCADE 2007
|
||||
|
||||
|
||||
class MeshOwner from MeshVS inherits EntityOwner from SelectMgr
|
||||
|
||||
---Purpose: The custom mesh owner used for advanced mesh selection. This class provides methods to store information:
|
||||
-- 1) IDs of hilighted mesh nodes and elements
|
||||
-- 2) IDs of mesh nodes and elements selected on the mesh
|
||||
|
||||
uses
|
||||
SOPtr from SelectMgr,
|
||||
Integer from Standard,
|
||||
EntityType from MeshVS,
|
||||
HPackedMapOfInteger from TColStd,
|
||||
PresentationManager3d from PrsMgr,
|
||||
PresentationManager from PrsMgr,
|
||||
NameOfColor from Quantity,
|
||||
DataSource from MeshVS
|
||||
|
||||
is
|
||||
|
||||
Create ( theSelObj : SOPtr from SelectMgr;
|
||||
theDS : DataSource from MeshVS;
|
||||
thePriority : Integer = 0 ) returns mutable MeshOwner from MeshVS;
|
||||
|
||||
GetDataSource( me ) returns DataSource from MeshVS;
|
||||
---C++: return const &
|
||||
|
||||
GetSelectedNodes( me ) returns HPackedMapOfInteger from TColStd;
|
||||
---C++: return const &
|
||||
---Purpose: Returns ids of selected mesh nodes
|
||||
|
||||
GetSelectedElements( me ) returns HPackedMapOfInteger from TColStd;
|
||||
---C++: return const &
|
||||
---Purpose: Returns ids of selected mesh elements
|
||||
|
||||
AddSelectedEntities( me : mutable; Nodes : HPackedMapOfInteger from TColStd;
|
||||
Elems : HPackedMapOfInteger from TColStd ) is virtual;
|
||||
---Purpose: Saves ids of selected mesh entities
|
||||
|
||||
ClearSelectedEntities( me : mutable ) is virtual;
|
||||
---Purpose: Clears ids of selected mesh entities
|
||||
|
||||
GetDetectedNodes( me ) returns HPackedMapOfInteger from TColStd;
|
||||
---C++: return const &
|
||||
---Purpose: Returns ids of hilighted mesh nodes
|
||||
|
||||
GetDetectedElements( me ) returns HPackedMapOfInteger from TColStd;
|
||||
---C++: return const &
|
||||
---Purpose: Returns ids of hilighted mesh elements
|
||||
|
||||
SetDetectedEntities( me : mutable; Nodes : HPackedMapOfInteger from TColStd;
|
||||
Elems : HPackedMapOfInteger from TColStd );
|
||||
---Purpose: Saves ids of hilighted mesh entities
|
||||
|
||||
HilightWithColor ( me : mutable; PM : PresentationManager3d from PrsMgr;
|
||||
theColor : NameOfColor from Quantity;
|
||||
Mode : Integer = 0 ) is redefined;
|
||||
|
||||
Unhilight( me : mutable; PM : PresentationManager from PrsMgr;
|
||||
Mode : Integer from Standard = 0 ) is redefined;
|
||||
|
||||
IsForcedHilight ( me ) returns Boolean from Standard is redefined;
|
||||
|
||||
fields
|
||||
|
||||
myDataSource : DataSource from MeshVS;
|
||||
mySelectedNodes : HPackedMapOfInteger from TColStd is protected;
|
||||
mySelectedElems : HPackedMapOfInteger from TColStd is protected;
|
||||
myDetectedNodes : HPackedMapOfInteger from TColStd;
|
||||
myDetectedElems : HPackedMapOfInteger from TColStd;
|
||||
myLastID : Integer from Standard;
|
||||
|
||||
end MeshOwner;
|
211
src/MeshVS/MeshVS_MeshOwner.cxx
Executable file
211
src/MeshVS/MeshVS_MeshOwner.cxx
Executable file
@@ -0,0 +1,211 @@
|
||||
// File: MeshVS_MeshOwner.cxx
|
||||
// Created: Thu Jan 25 2007
|
||||
// Author: Sergey KOCHETKOV
|
||||
// Copyright: Open CASCADE 2007
|
||||
|
||||
#include <MeshVS_MeshOwner.ixx>
|
||||
|
||||
#include <SelectBasics_EntityOwner.hxx>
|
||||
#include <SelectMgr_SelectableObject.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
|
||||
|
||||
#ifndef MeshVS_PRSBUILDERHXX
|
||||
#include <MeshVS_PrsBuilder.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_MeshOwner
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_MeshOwner::MeshVS_MeshOwner (const SelectMgr_SOPtr& theSelObj,
|
||||
const Handle(MeshVS_DataSource)& theDS,
|
||||
const Standard_Integer thePriority)
|
||||
: SelectMgr_EntityOwner ( theSelObj, thePriority )
|
||||
{
|
||||
myLastID = -1;
|
||||
if( !theDS.IsNull() )
|
||||
myDataSource = theDS;
|
||||
SelectBasics_EntityOwner::Set ( thePriority );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDataSource
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const Handle(MeshVS_DataSource)& MeshVS_MeshOwner::GetDataSource () const
|
||||
{
|
||||
return myDataSource;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetSelectedNodes
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const Handle(TColStd_HPackedMapOfInteger)& MeshVS_MeshOwner::GetSelectedNodes () const
|
||||
{
|
||||
return mySelectedNodes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetSelectedElements
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const Handle(TColStd_HPackedMapOfInteger)& MeshVS_MeshOwner::GetSelectedElements () const
|
||||
{
|
||||
return mySelectedElems;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : AddSelectedEntities
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_MeshOwner::AddSelectedEntities (const Handle(TColStd_HPackedMapOfInteger)& Nodes,
|
||||
const Handle(TColStd_HPackedMapOfInteger)& Elems)
|
||||
{
|
||||
if( mySelectedNodes.IsNull() )
|
||||
mySelectedNodes = Nodes;
|
||||
else if( !Nodes.IsNull() )
|
||||
mySelectedNodes->ChangeMap().Unite( Nodes->Map() );
|
||||
if( mySelectedElems.IsNull() )
|
||||
mySelectedElems = Elems;
|
||||
else if( !Elems.IsNull() )
|
||||
mySelectedElems->ChangeMap().Unite( Elems->Map() );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : ClearSelectedEntities
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_MeshOwner::ClearSelectedEntities ()
|
||||
{
|
||||
mySelectedNodes.Nullify();
|
||||
mySelectedElems.Nullify();
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDetectedNodes
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const Handle(TColStd_HPackedMapOfInteger)& MeshVS_MeshOwner::GetDetectedNodes () const
|
||||
{
|
||||
return myDetectedNodes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDetectedElements
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const Handle(TColStd_HPackedMapOfInteger)& MeshVS_MeshOwner::GetDetectedElements () const
|
||||
{
|
||||
return myDetectedElems;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetDetectedEntities
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_MeshOwner::SetDetectedEntities (const Handle(TColStd_HPackedMapOfInteger)& Nodes,
|
||||
const Handle(TColStd_HPackedMapOfInteger)& Elems)
|
||||
{
|
||||
myDetectedNodes = Nodes;
|
||||
myDetectedElems = Elems;
|
||||
if( State() ) State( 0 );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : HilightWithColor
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_MeshOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
|
||||
const Quantity_NameOfColor theColor,
|
||||
const Standard_Integer /*theMode*/)
|
||||
{
|
||||
Handle( SelectMgr_SelectableObject ) aSelObj;
|
||||
if ( HasSelectable() )
|
||||
aSelObj = Selectable();
|
||||
|
||||
if ( thePM->IsImmediateModeOn() && aSelObj->IsKind( STANDARD_TYPE( MeshVS_Mesh ) ) )
|
||||
{
|
||||
// Update last detected entity ID
|
||||
Handle(TColStd_HPackedMapOfInteger) aNodes = GetDetectedNodes();
|
||||
Handle(TColStd_HPackedMapOfInteger) aElems = GetDetectedElements();
|
||||
if( !aNodes.IsNull() && aNodes->Map().Extent() == 1 )
|
||||
{
|
||||
TColStd_MapIteratorOfPackedMapOfInteger anIt( aNodes->Map() );
|
||||
for( ; anIt.More(); anIt.Next() )
|
||||
{
|
||||
if( myLastID != anIt.Key() )
|
||||
myLastID = anIt.Key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( !aElems.IsNull() && aElems->Map().Extent() == 1 )
|
||||
{
|
||||
TColStd_MapIteratorOfPackedMapOfInteger anIt( aElems->Map() );
|
||||
for( ; anIt.More(); anIt.Next() )
|
||||
{
|
||||
if( myLastID != anIt.Key() )
|
||||
myLastID = anIt.Key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// hilight detected entities
|
||||
Handle( MeshVS_Mesh ) aMesh = Handle( MeshVS_Mesh )::DownCast ( aSelObj );
|
||||
aMesh->HilightOwnerWithColor ( thePM, theColor, this );
|
||||
}
|
||||
}
|
||||
|
||||
void MeshVS_MeshOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
SelectMgr_EntityOwner::Unhilight( thePM, theMode );
|
||||
|
||||
Handle(TColStd_HPackedMapOfInteger) aNodes = GetDetectedNodes();
|
||||
Handle(TColStd_HPackedMapOfInteger) aElems = GetDetectedElements();
|
||||
if( ( !aNodes.IsNull() && !aNodes->Map().Contains( myLastID ) ) ||
|
||||
( !aElems.IsNull() && !aElems->Map().Contains( myLastID ) ) )
|
||||
return;
|
||||
// Reset last detected ID
|
||||
myLastID = -1;
|
||||
}
|
||||
|
||||
Standard_Boolean MeshVS_MeshOwner::IsForcedHilight () const
|
||||
{
|
||||
Standard_Boolean aHilight = Standard_True;
|
||||
Standard_Integer aKey = -1;
|
||||
if( myLastID > 0 )
|
||||
{
|
||||
// Check the detected entity and
|
||||
// allow to hilight it if it differs from the last detected entity <myLastID>
|
||||
Handle(TColStd_HPackedMapOfInteger) aNodes = GetDetectedNodes();
|
||||
if( !aNodes.IsNull() && aNodes->Map().Extent() == 1 )
|
||||
{
|
||||
TColStd_MapIteratorOfPackedMapOfInteger anIt( aNodes->Map() );
|
||||
for( ; anIt.More(); anIt.Next() )
|
||||
{
|
||||
aKey = anIt.Key();
|
||||
if( myLastID == aKey )
|
||||
aHilight = Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Handle(TColStd_HPackedMapOfInteger) aElems = GetDetectedElements();
|
||||
if( !aElems.IsNull() && aElems->Map().Extent() == 1 )
|
||||
{
|
||||
TColStd_MapIteratorOfPackedMapOfInteger anIt( aElems->Map() );
|
||||
for( ; anIt.More(); anIt.Next() )
|
||||
{
|
||||
aKey = anIt.Key();
|
||||
if( myLastID == aKey )
|
||||
aHilight = Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return aHilight;
|
||||
}
|
133
src/MeshVS/MeshVS_MeshPrsBuilder.cdl
Executable file
133
src/MeshVS/MeshVS_MeshPrsBuilder.cdl
Executable file
@@ -0,0 +1,133 @@
|
||||
-- File : MeshVS_MeshPrsBuilder.cdl
|
||||
-- Created : 10 October 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
|
||||
class MeshPrsBuilder from MeshVS inherits PrsBuilder from MeshVS
|
||||
|
||||
---Purpose: This class provides methods to compute base mesh presentation
|
||||
|
||||
uses
|
||||
Integer from Standard,
|
||||
Boolean from Standard,
|
||||
|
||||
Presentation from Prs3d,
|
||||
|
||||
PrsBuilder from MeshVS,
|
||||
Mesh from MeshVS,
|
||||
MeshPtr from MeshVS,
|
||||
DisplayModeFlags from MeshVS,
|
||||
DataSource from MeshVS,
|
||||
BuilderPriority from MeshVS,
|
||||
Drawer from MeshVS,
|
||||
HArray1OfSequenceOfInteger from MeshVS,
|
||||
MaterialAspect from Graphic3d,
|
||||
AspectFillArea3d from Graphic3d,
|
||||
AspectLine3d from Graphic3d,
|
||||
AspectMarker3d from Graphic3d,
|
||||
Array1OfReal from TColStd,
|
||||
ArrayOfPolylines from Graphic3d,
|
||||
ArrayOfPolygons from Graphic3d,
|
||||
ArrayOfPrimitives from Graphic3d,
|
||||
PackedMapOfInteger from TColStd
|
||||
|
||||
is
|
||||
|
||||
Create ( Parent : Mesh from MeshVS;
|
||||
Flags : DisplayModeFlags from MeshVS = MeshVS_DMF_OCCMask;
|
||||
DS : DataSource from MeshVS = 0;
|
||||
Id : Integer = -1;
|
||||
Priority : BuilderPriority from MeshVS = MeshVS_BP_Mesh ) returns mutable MeshPrsBuilder from MeshVS;
|
||||
---Purpose: Creates builder with certain display mode flags, data source, ID and priority
|
||||
|
||||
Build ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IDsToExclude: in out PackedMapOfInteger;
|
||||
IsElement : Boolean;
|
||||
DisplayMode : Integer ) is virtual;
|
||||
---Purpose: Builds base mesh presentation by calling the methods below
|
||||
|
||||
BuildNodes ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IDsToExclude: in out PackedMapOfInteger;
|
||||
DisplayMode : Integer ) is virtual;
|
||||
---Purpose: Builds nodes presentation
|
||||
|
||||
BuildElements ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IDsToExclude: in out PackedMapOfInteger;
|
||||
DisplayMode : Integer ) is virtual;
|
||||
---Purpose: Builds elements presentation
|
||||
|
||||
BuildHilightPrs ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IsElement : Boolean
|
||||
) is virtual;
|
||||
---Purpose: Builds presentation of hilighted entity
|
||||
|
||||
AddLinkPrs ( me; theCoords : Array1OfReal from TColStd;
|
||||
theLines : ArrayOfPolylines from Graphic3d;
|
||||
IsShrinked : Boolean;
|
||||
ShrinkCoef : Real
|
||||
) is protected;
|
||||
---Purpose: Add to array of polylines some lines representing link
|
||||
|
||||
AddFaceWirePrs ( me; theCoords : Array1OfReal from TColStd;
|
||||
NbNodes : Integer;
|
||||
theLines : ArrayOfPolylines from Graphic3d;
|
||||
IsShrinked : Boolean;
|
||||
ShrinkCoef : Real
|
||||
) is protected;
|
||||
---Purpose: Add to array of polylines some lines representing face's wire
|
||||
|
||||
AddFaceSolidPrs ( me; ID : Integer;
|
||||
theCoords : Array1OfReal from TColStd;
|
||||
NbNodes : Integer;
|
||||
MaxNodes : Integer;
|
||||
thePolygons : ArrayOfPolygons from Graphic3d;
|
||||
IsReflected : Boolean;
|
||||
IsShrinked : Boolean;
|
||||
ShrinkCoef : Real;
|
||||
IsMeshSmoothShading : Boolean
|
||||
) is protected;
|
||||
---Purpose: Add to array of polygons a polygon representing face
|
||||
|
||||
AddVolumePrs ( myclass; Topo : HArray1OfSequenceOfInteger from MeshVS;
|
||||
Nodes : Array1OfReal from TColStd;
|
||||
NbNodes : Integer;
|
||||
Array : ArrayOfPrimitives from Graphic3d;
|
||||
IsReflected : Boolean;
|
||||
IsShrinked : Boolean;
|
||||
IsSelect : Boolean;
|
||||
ShrinkCoef : Real );
|
||||
---Purpose: Add to array polygons or polylines representing volume
|
||||
|
||||
HowManyPrimitives( myclass; Topo : HArray1OfSequenceOfInteger from MeshVS;
|
||||
AsPolygons : Boolean;
|
||||
IsSelect : Boolean;
|
||||
NbNodes : Integer;
|
||||
Vertices, Bounds : out Integer );
|
||||
---Purpose: Calculate how many polygons or polylines are necessary to draw passed topology
|
||||
|
||||
DrawArrays ( me; Prs : Presentation from Prs3d;
|
||||
thePolygons : ArrayOfPolygons from Graphic3d;
|
||||
theLines : ArrayOfPolylines from Graphic3d;
|
||||
theLinkLines : ArrayOfPolylines from Graphic3d;
|
||||
theVolumesInShad : ArrayOfPolygons from Graphic3d;
|
||||
IsPolygonsEdgesOff : Boolean;
|
||||
IsSelected : Boolean;
|
||||
theFillAsp : AspectFillArea3d from Graphic3d;
|
||||
theLineAsp : AspectLine3d from Graphic3d
|
||||
) is protected;
|
||||
---Purpose: Draw array of polygons and polylines in the certain order according to transparency
|
||||
|
||||
CalculateCenter ( myclass; theCoords : Array1OfReal from TColStd;
|
||||
NbNodes : Integer;
|
||||
xG, yG, zG : out Real ) is protected;
|
||||
---Purpose: Default calculation of center of face or link. This method if useful for shrink mode presentation
|
||||
-- theCoords is array of nodes co-ordinates in the strict order X1, Y1, Z1, X2...
|
||||
-- NbNodes is number of nodes an element consist of
|
||||
-- xG, yG, zG are co-ordinates of center whose will be returned
|
||||
|
||||
end MeshPrsBuilder;
|
1056
src/MeshVS/MeshVS_MeshPrsBuilder.cxx
Executable file
1056
src/MeshVS/MeshVS_MeshPrsBuilder.cxx
Executable file
File diff suppressed because it is too large
Load Diff
0
src/MeshVS/MeshVS_MeshPrsBuilder.lxx
Executable file
0
src/MeshVS/MeshVS_MeshPrsBuilder.lxx
Executable file
124
src/MeshVS/MeshVS_NodalColorPrsBuilder.cdl
Executable file
124
src/MeshVS/MeshVS_NodalColorPrsBuilder.cdl
Executable file
@@ -0,0 +1,124 @@
|
||||
-- File : MeshVS_NodalColorPrsBuilder.cdl
|
||||
-- Created : 12 November 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class NodalColorPrsBuilder from MeshVS inherits PrsBuilder from MeshVS
|
||||
|
||||
---Purpose: This class provides methods to create presentation of nodes with assigned color.
|
||||
-- There are two ways of presentation building
|
||||
-- 1. Without using texture.
|
||||
-- In this case colors of nodes are specified with DataMapOfIntegerColor and presentation
|
||||
-- is built with gradient fill between these nodes (default behaviour)
|
||||
-- 2. Using texture.
|
||||
-- In this case presentation is built with spectrum filling between nodes. For example, if
|
||||
-- one node has blue color and second one has violet color, parameters of this class may be
|
||||
-- set to fill presentation between nodes with solar spectrum.
|
||||
-- Methods:
|
||||
-- UseTexture - activates/deactivates this way
|
||||
-- SetColorMap - sets colors used for generation of texture
|
||||
-- SetColorindices - specifies correspondence between node IDs and indices of colors from color map
|
||||
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
|
||||
Boolean from Standard,
|
||||
Integer from Standard,
|
||||
|
||||
DisplayModeFlags from MeshVS,
|
||||
Mesh from MeshVS,
|
||||
MeshPtr from MeshVS,
|
||||
DataSource from MeshVS,
|
||||
DataMapOfIntegerColor from MeshVS,
|
||||
BuilderPriority from MeshVS,
|
||||
SequenceOfColor from Aspect,
|
||||
Color from Quantity,
|
||||
DataMapOfIntegerReal from TColStd,
|
||||
Texture2D from Graphic3d,
|
||||
PackedMapOfInteger from TColStd
|
||||
|
||||
is
|
||||
|
||||
Create ( Parent : Mesh from MeshVS;
|
||||
Flags : DisplayModeFlags from MeshVS = MeshVS_DMF_NodalColorDataPrs;
|
||||
DS : DataSource from MeshVS = 0;
|
||||
Id : Integer = -1;
|
||||
Priority : BuilderPriority from MeshVS = MeshVS_BP_NodalColor )
|
||||
returns mutable NodalColorPrsBuilder from MeshVS;
|
||||
|
||||
Build ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IDsToExclude : in out PackedMapOfInteger;
|
||||
IsElement : Boolean;
|
||||
DisplayMode : Integer ) is virtual;
|
||||
---Purpose: Builds presentation of nodes with assigned color.
|
||||
|
||||
|
||||
GetColors ( me ) returns DataMapOfIntegerColor from MeshVS;
|
||||
---C++: return const &
|
||||
---Purpose: Returns map of colors assigned to nodes.
|
||||
|
||||
SetColors ( me : mutable;
|
||||
Map : DataMapOfIntegerColor from MeshVS );
|
||||
---Purpose: Sets map of colors assigned to nodes.
|
||||
|
||||
HasColors ( me ) returns Boolean;
|
||||
---Purpose: Returns true, if map isn't empty
|
||||
|
||||
GetColor ( me; ID : Integer;
|
||||
theColor : out Color from Quantity ) returns Boolean;
|
||||
---Purpose: Returns color assigned to single node
|
||||
|
||||
SetColor ( me : mutable;
|
||||
ID : Integer;
|
||||
theColor : Color from Quantity );
|
||||
---Purpose: Sets color assigned to single node
|
||||
|
||||
UseTexture ( me : mutable; theToUse : Boolean );
|
||||
---Purpose: Specify whether texture must be used to build presentation
|
||||
|
||||
IsUseTexture( me ) returns Boolean;
|
||||
---Purpose: Verify whether texture is used to build presentation
|
||||
|
||||
SetColorMap ( me : mutable; theColors : SequenceOfColor from Aspect );
|
||||
---Purpose: Set colors to be used for texrture presentation
|
||||
--- theColors - colors for valid coordinates (laying in range [0, 1])
|
||||
|
||||
GetColorMap ( me ) returns SequenceOfColor from Aspect;
|
||||
---C++: return const &
|
||||
---Purpose: Return colors used for texrture presentation
|
||||
|
||||
SetInvalidColor ( me : mutable; theInvalidColor : Color from Quantity );
|
||||
---Purpose: Set color representing invalid texture coordinate
|
||||
--- (laying outside range [0, 1])
|
||||
|
||||
GetInvalidColor ( me ) returns Color from Quantity;
|
||||
---Purpose: Return color representing invalid texture coordinate
|
||||
--- (laying outside range [0, 1])
|
||||
|
||||
SetTextureCoords ( me : mutable; theMap : DataMapOfIntegerReal from TColStd );
|
||||
---Purpose: Specify correspondence between node IDs and texture coordinates (range [0, 1])
|
||||
|
||||
GetTextureCoords ( me ) returns DataMapOfIntegerReal from TColStd;
|
||||
---C++: return const &
|
||||
---Purpose: Get correspondence between node IDs and texture coordinates (range [0, 1])
|
||||
|
||||
SetTextureCoord ( me : mutable; theID : Integer; theCoord : Real );
|
||||
---Purpose: Specify correspondence between node ID and texture coordinate (range [0, 1])
|
||||
|
||||
GetTextureCoord ( me : mutable; theID : Integer) returns Real;
|
||||
---Purpose: Return correspondence between node IDs and texture coordinate (range [0, 1])
|
||||
|
||||
CreateTexture ( me ) returns Texture2D from Graphic3d
|
||||
---Purpose: Create texture in accordance with myTextureColorMap
|
||||
is static private;
|
||||
|
||||
|
||||
fields
|
||||
myNodeColorMap : DataMapOfIntegerColor from MeshVS;
|
||||
myUseTexture : Boolean from Standard;
|
||||
myTextureColorMap : SequenceOfColor from Aspect;
|
||||
myTextureCoords : DataMapOfIntegerReal from TColStd;
|
||||
myInvalidColor : Color from Quantity;
|
||||
|
||||
end NodalColorPrsBuilder;
|
713
src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx
Executable file
713
src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx
Executable file
@@ -0,0 +1,713 @@
|
||||
// File: MeshVS_NodalColorPrsBuilder.cxx
|
||||
// Created: Wed Nov 12 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#define _POLYGONES_
|
||||
// if define _POLYGONES_ ColorPrsBuilder use ArrayOfPolygons for drawing faces
|
||||
|
||||
#include <MeshVS_NodalColorPrsBuilder.ixx>
|
||||
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_ArrayOfPolygons.hxx>
|
||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
|
||||
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <TColStd_HPackedMapOfInteger.hxx>
|
||||
|
||||
#include <MeshVS_DisplayModeFlags.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_DataSource.hxx>
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_MeshPrsBuilder.hxx>
|
||||
#include <MeshVS_HArray1OfSequenceOfInteger.hxx>
|
||||
#include <MeshVS_Buffer.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Image_ColorImage.hxx>
|
||||
#include <AlienImage_AlienImage.hxx>
|
||||
#include <AlienImage_BMPAlienImage.hxx>
|
||||
#include <Graphic3d_Texture2D.hxx>
|
||||
#include <Graphic3d_TypeOfTextureMode.hxx>
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <Graphic3d_Array1OfVertexNT.hxx>
|
||||
#include <AIS_Drawer.hxx>
|
||||
#include <Quantity_Array1OfColor.hxx>
|
||||
#include <Aspect_SequenceOfColor.hxx>
|
||||
|
||||
/*
|
||||
Class : MeshVS_ImageTexture2D
|
||||
Description : Texture for nodal presentation
|
||||
*/
|
||||
class MeshVS_ImageTexture2D : public Graphic3d_Texture2D
|
||||
{
|
||||
public:
|
||||
MeshVS_ImageTexture2D( Handle(Graphic3d_StructureManager) theSM,
|
||||
const Handle(AlienImage_AlienImage)& theImg );
|
||||
virtual ~MeshVS_ImageTexture2D();
|
||||
|
||||
public:
|
||||
DEFINE_STANDARD_RTTI(MeshVS_ImageTexture2D)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(MeshVS_ImageTexture2D,Graphic3d_Texture2D)
|
||||
IMPLEMENT_STANDARD_HANDLE(MeshVS_ImageTexture2D,Graphic3d_Texture2D)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(MeshVS_ImageTexture2D, Graphic3d_Texture2D)
|
||||
|
||||
MeshVS_ImageTexture2D::MeshVS_ImageTexture2D
|
||||
(Handle(Graphic3d_StructureManager) theSM,
|
||||
const Handle(AlienImage_AlienImage)& theImg)
|
||||
: Graphic3d_Texture2D( theSM, "", Graphic3d_TOT_2D )
|
||||
{
|
||||
MyCInitTexture.doModulate = 0/*1*/;
|
||||
MyCInitTexture.doRepeat = 0;
|
||||
MyCInitTexture.Mode = (int)Graphic3d_TOTM_MANUAL;
|
||||
MyCInitTexture.doLinear = 1;
|
||||
MyCInitTexture.sx = 1.0F;
|
||||
MyCInitTexture.sy = 1.0F;
|
||||
MyCInitTexture.tx = 0.0F;
|
||||
MyCInitTexture.ty = 0.0F;
|
||||
MyCInitTexture.angle = 0.0F;
|
||||
MyCInitTexture.sparams[0] = 0.0F;
|
||||
MyCInitTexture.sparams[1] = 0.0F;
|
||||
MyCInitTexture.sparams[2] = 0.0F;
|
||||
MyCInitTexture.sparams[3] = 0.0F;
|
||||
MyCInitTexture.tparams[0] = 0.0F;
|
||||
MyCInitTexture.tparams[1] = 0.0F;
|
||||
MyCInitTexture.tparams[2] = 0.0F;
|
||||
MyCInitTexture.tparams[3] = 0.0F;
|
||||
Update();
|
||||
LoadTexture(theImg);
|
||||
}
|
||||
|
||||
MeshVS_ImageTexture2D::~MeshVS_ImageTexture2D()
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : getNearestPow2
|
||||
// Purpose : Returns the nearest power of two greater than the
|
||||
// argument value
|
||||
//================================================================
|
||||
static inline Standard_Integer getNearestPow2( Standard_Integer theValue )
|
||||
{
|
||||
// Precaution against overflow
|
||||
Standard_Integer aHalfMax = IntegerLast() >> 1, aRes = 1;
|
||||
if ( theValue > aHalfMax ) theValue = aHalfMax;
|
||||
while ( aRes < theValue ) aRes <<= 1;
|
||||
return aRes;
|
||||
}
|
||||
|
||||
/*
|
||||
Class : MeshVS_NodalColorPrsBuilder
|
||||
Description : This class provides methods to create presentation of
|
||||
nodes with assigned color (See hxx for more description )
|
||||
*/
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_NodalColorPrsBuilder
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_NodalColorPrsBuilder::MeshVS_NodalColorPrsBuilder ( const Handle(MeshVS_Mesh)& Parent,
|
||||
const MeshVS_DisplayModeFlags& Flags,
|
||||
const Handle (MeshVS_DataSource)& DS,
|
||||
const Standard_Integer Id,
|
||||
const MeshVS_BuilderPriority& Priority )
|
||||
: MeshVS_PrsBuilder ( Parent, Flags, DS, Id, Priority ),
|
||||
myUseTexture( Standard_False ),
|
||||
myInvalidColor( Quantity_NOC_GRAY )
|
||||
{
|
||||
SetExcluding ( Standard_True );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Build
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
|
||||
const TColStd_PackedMapOfInteger& IDs,
|
||||
TColStd_PackedMapOfInteger& IDsToExclude,
|
||||
const Standard_Boolean IsElement,
|
||||
const Standard_Integer DisplayMode) const
|
||||
{
|
||||
Handle (MeshVS_DataSource) aSource = GetDataSource();
|
||||
Handle (MeshVS_Drawer) aDrawer = GetDrawer();
|
||||
if ( aSource.IsNull() || aDrawer.IsNull() )
|
||||
return;
|
||||
|
||||
Standard_Integer aMaxFaceNodes;
|
||||
if ( !aDrawer->GetInteger ( MeshVS_DA_MaxFaceNodes, aMaxFaceNodes ) || aMaxFaceNodes <= 0 )
|
||||
return;
|
||||
|
||||
MeshVS_Buffer aCoordsBuf (3*aMaxFaceNodes*sizeof(Standard_Real));
|
||||
TColStd_Array1OfReal aCoords ( aCoordsBuf, 1, 3 * aMaxFaceNodes );
|
||||
Standard_Integer NbNodes;
|
||||
MeshVS_EntityType aType;
|
||||
|
||||
if ( !( DisplayMode & GetFlags() ) || !IsElement )
|
||||
return;
|
||||
|
||||
if ( myUseTexture && ( !myTextureCoords.Extent() || !myTextureColorMap.Length() ) ||
|
||||
!myUseTexture && !myNodeColorMap.Extent() )
|
||||
return;
|
||||
|
||||
// subtract the hidden elements and ids to exclude (to minimise allocated memory)
|
||||
TColStd_PackedMapOfInteger anIDs;
|
||||
anIDs.Assign( IDs );
|
||||
Handle(TColStd_HPackedMapOfInteger) aHiddenElems = myParentMesh->GetHiddenElems();
|
||||
if ( !aHiddenElems.IsNull() )
|
||||
anIDs.Subtract( aHiddenElems->Map() );
|
||||
anIDs.Subtract( IDsToExclude );
|
||||
|
||||
Standard_Boolean IsReflect = Standard_False, IsMeshSmoothShading = Standard_False;
|
||||
aDrawer->GetBoolean( MeshVS_DA_ColorReflection, IsReflect );
|
||||
aDrawer->GetBoolean( MeshVS_DA_SmoothShading, IsMeshSmoothShading );
|
||||
|
||||
// NOTE: Lighting effect not tested with textures, so turning off reflectance when textures are used.
|
||||
// This can be improved if necessary...
|
||||
IsReflect = IsReflect && !myUseTexture;
|
||||
|
||||
// Following parameter are used for texture presentation only
|
||||
int nbColors = 0; // Number of colors from color map
|
||||
int nbTextureColors = 0; // Number of colors in texture (it will be pow of 2)
|
||||
if ( myUseTexture )
|
||||
{
|
||||
nbColors = myTextureColorMap.Length();
|
||||
nbTextureColors = getNearestPow2( nbColors );
|
||||
}
|
||||
|
||||
Standard_Integer aSize = anIDs.Extent();
|
||||
|
||||
// Calculate maximum possible number of vertices and bounds
|
||||
Handle( MeshVS_HArray1OfSequenceOfInteger ) aTopo;
|
||||
Standard_Integer PolygonVerticesFor3D = 0, PolygonBoundsFor3D = 0;
|
||||
TColStd_MapIteratorOfPackedMapOfInteger it (anIDs);
|
||||
for( ; it.More(); it.Next() )
|
||||
{
|
||||
Standard_Integer aKey = it.Key();
|
||||
if ( aSource->Get3DGeom( aKey, NbNodes, aTopo ) )
|
||||
MeshVS_MeshPrsBuilder::HowManyPrimitives
|
||||
( aTopo, Standard_True, Standard_False, NbNodes,
|
||||
PolygonVerticesFor3D, PolygonBoundsFor3D );
|
||||
}
|
||||
|
||||
// Draw faces with nodal color
|
||||
// OCC20644 Use "plastic" material as it is "non-physic" and so it is easier
|
||||
// to get the required colors (see TelUpdateMaterial() function in OpenGl_attri.c)
|
||||
Graphic3d_MaterialAspect aMaterial[ 2 ];
|
||||
aMaterial[ 0 ] = Graphic3d_MaterialAspect( Graphic3d_NOM_PLASTIC );
|
||||
aMaterial[ 1 ] = Graphic3d_MaterialAspect( Graphic3d_NOM_PLASTIC );
|
||||
Standard_Integer i;
|
||||
for ( i = 0; i < 2; i++ )
|
||||
{
|
||||
if ( !IsReflect )
|
||||
{
|
||||
aMaterial[ i ].SetReflectionModeOff( Graphic3d_TOR_SPECULAR );
|
||||
aMaterial[ i ].SetReflectionModeOff( Graphic3d_TOR_AMBIENT );
|
||||
aMaterial[ i ].SetReflectionModeOff( Graphic3d_TOR_DIFFUSE );
|
||||
aMaterial[ i ].SetReflectionModeOff( Graphic3d_TOR_EMISSION );
|
||||
}
|
||||
else{
|
||||
// OCC20644 Using the material with reflection properties same as in
|
||||
// ElementalColorPrsBuilder, to get the same colors.
|
||||
// Additionally, ambient and diffuse coefficients are used below to scale incoming colors,
|
||||
// to simulate TelUpdateMaterial() function from OpenGl_attri.c.
|
||||
// This is mandatory, as these "scaled" colors are then passed directly to OpenGL
|
||||
// as ambient and diffuse colors of the current material using glColorMaterial().
|
||||
// In ElementalColorPrsBuilder we do not need to do scale the colors, as this
|
||||
// is done by TelUpdateMaterial().
|
||||
// 0.5 is used to have the colors in 3D maximally similar to those in the color scale.
|
||||
// This is possible when the sum of all coefficient is equal to 1.
|
||||
aMaterial[i].SetAmbient( .5 );
|
||||
aMaterial[i].SetDiffuse( .5 );
|
||||
aMaterial[i].SetSpecular( 0. );
|
||||
aMaterial[i].SetEmissive( 0. );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Create array of polygons for interior presentation of faces and volumes
|
||||
Handle(Graphic3d_ArrayOfPolygons) aCPolyArr = new Graphic3d_ArrayOfPolygons
|
||||
( aMaxFaceNodes * aSize + PolygonVerticesFor3D, aSize + PolygonBoundsFor3D,
|
||||
0, myUseTexture || IsReflect, !myUseTexture, Standard_False, myUseTexture );
|
||||
|
||||
// Create array of polylines for presentation of edges
|
||||
// (used for optimization insted of SetEdgeOn method call)
|
||||
Handle(Graphic3d_ArrayOfPolylines) aPolyL = new Graphic3d_ArrayOfPolylines
|
||||
( ( aMaxFaceNodes + 1 ) * aSize + PolygonVerticesFor3D, aSize + PolygonBoundsFor3D );
|
||||
|
||||
gp_Pnt P, Start;
|
||||
Standard_Real aMin = gp::Resolution() * gp::Resolution();
|
||||
gp_Dir aDefNorm( 0., 0., 1. );
|
||||
|
||||
// Prepare for scaling the incoming colors
|
||||
Standard_Real anColorRatio = aMaterial[0].Ambient();
|
||||
|
||||
for( it.Reset(); it.More(); it.Next() )
|
||||
{
|
||||
Standard_Integer aKey = it.Key();
|
||||
if ( aSource->GetGeom ( aKey, Standard_True, aCoords, NbNodes, aType ) )
|
||||
{
|
||||
MeshVS_Buffer aNodesBuf (NbNodes*sizeof(Standard_Integer));
|
||||
TColStd_Array1OfInteger aNodes(aNodesBuf, 1, NbNodes);
|
||||
if ( !aSource->GetNodesByElement ( aKey, aNodes, NbNodes ) )
|
||||
continue;
|
||||
|
||||
Quantity_Color aNColor;
|
||||
|
||||
Standard_Boolean isValid = Standard_True;
|
||||
Standard_Integer i;
|
||||
if ( myUseTexture )
|
||||
{
|
||||
for ( i = 1; i <= NbNodes && isValid; i++ )
|
||||
isValid = myTextureCoords.IsBound( aNodes( i ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( i = 1; i <= NbNodes && isValid; i++ )
|
||||
isValid = GetColor ( aNodes( i ), aNColor );
|
||||
}
|
||||
|
||||
if ( !isValid )
|
||||
continue;
|
||||
|
||||
// Preparing normal(s) to show reflections if requested
|
||||
Handle(TColStd_HArray1OfReal) aNormals;
|
||||
Standard_Boolean hasNormals =
|
||||
( IsReflect && aSource->GetNormalsByElement( aKey, IsMeshSmoothShading, aMaxFaceNodes, aNormals ) );
|
||||
|
||||
if ( aType == MeshVS_ET_Face )
|
||||
{
|
||||
aCPolyArr->AddBound ( NbNodes );
|
||||
aPolyL->AddBound ( NbNodes + 1 );
|
||||
|
||||
for ( i = 1; i <= NbNodes; i++)
|
||||
{
|
||||
P = gp_Pnt( aCoords( 3 * i - 2 ), aCoords( 3 * i - 1 ), aCoords( 3 * i ) );
|
||||
if ( myUseTexture )
|
||||
{
|
||||
int anId = aNodes( i );
|
||||
double aTexCoord = myTextureCoords( anId );
|
||||
|
||||
// transform texture coordinate in accordance with number of colors specified
|
||||
// by upper level and real size of Gl texture
|
||||
aTexCoord = aTexCoord * nbColors / nbTextureColors;
|
||||
|
||||
aCPolyArr->AddVertex( P, aDefNorm,
|
||||
gp_Pnt2d( aTexCoord, aTexCoord >= 0 && aTexCoord <= 1 ? 1 : 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
GetColor ( aNodes( i ), aNColor );
|
||||
|
||||
if ( IsReflect )
|
||||
{
|
||||
// Simulating TelUpdateMaterial() from OpenGl_attri.c
|
||||
// to get the same colors in elemental and nodal color prs builders
|
||||
aNColor.SetValues(anColorRatio * aNColor.Red(),
|
||||
anColorRatio * aNColor.Green(),
|
||||
anColorRatio * aNColor.Blue(),
|
||||
Quantity_TOC_RGB);
|
||||
|
||||
if ( hasNormals )
|
||||
{
|
||||
gp_Vec aNorm(aNormals->Value( 3 * i - 2 ),
|
||||
aNormals->Value( 3 * i - 1 ),
|
||||
aNormals->Value( 3 * i ));
|
||||
aNorm.SquareMagnitude() > aMin ?
|
||||
aCPolyArr->AddVertex(P, gp_Dir( aNorm ), aNColor ) :
|
||||
aCPolyArr->AddVertex(P, aDefNorm , aNColor );
|
||||
}
|
||||
else
|
||||
aCPolyArr->AddVertex(P, aDefNorm, aNColor );
|
||||
}
|
||||
else
|
||||
aCPolyArr->AddVertex( P, aNColor );
|
||||
}
|
||||
aPolyL->AddVertex ( P );
|
||||
if ( i == 1 )
|
||||
Start = P;
|
||||
}
|
||||
aPolyL->AddVertex ( Start );
|
||||
|
||||
// if IsExcludingOn then presentation must not be built by other builders
|
||||
if ( IsExcludingOn() )
|
||||
IDsToExclude.Add( aKey );
|
||||
}
|
||||
else if ( aType == MeshVS_ET_Volume )
|
||||
{
|
||||
if ( !aSource->Get3DGeom( aKey, NbNodes, aTopo ) )
|
||||
continue;
|
||||
|
||||
// iterate through faces of volume
|
||||
for ( Standard_Integer k = aTopo->Lower(), last = aTopo->Upper(), normIndex = 1; k <= last; k++, normIndex++ )
|
||||
{
|
||||
const TColStd_SequenceOfInteger& aSeq = aTopo->Value( k );
|
||||
Standard_Integer m = aSeq.Length(), ind;
|
||||
|
||||
// build polygon & polylines for current face
|
||||
aCPolyArr->AddBound( m );
|
||||
aPolyL->AddBound( m + 1 );
|
||||
for ( Standard_Integer j = 1; j <= m; j++ )
|
||||
{
|
||||
ind = aSeq.Value( j );
|
||||
P = gp_Pnt( aCoords( 3 * ind + 1 ),
|
||||
aCoords( 3 * ind + 2 ),
|
||||
aCoords( 3 * ind + 3 ) );
|
||||
if ( myUseTexture )
|
||||
{
|
||||
Standard_Integer anId = aNodes( ind + 1 );
|
||||
Standard_Real aTexCoord = myTextureCoords( anId );
|
||||
|
||||
// transform texture coordinate in accordance with number of colors specified
|
||||
// by upper level and real size of Gl texture
|
||||
aTexCoord = aTexCoord * nbColors / nbTextureColors;
|
||||
|
||||
gp_Pnt2d aTP( aTexCoord, aTexCoord >= 0 && aTexCoord <= 1 ? 1 : 0 );
|
||||
aCPolyArr->AddVertex( P, aDefNorm, aTP );
|
||||
}
|
||||
else
|
||||
{
|
||||
GetColor( aNodes( ind + 1 ), aNColor );
|
||||
if ( IsReflect )
|
||||
{
|
||||
// Simulating TelUpdateMaterial() from OpenGl_attri.c
|
||||
// to get the same colors in elemental and nodal color prs builders
|
||||
aNColor.SetValues(anColorRatio * aNColor.Red(),
|
||||
anColorRatio * aNColor.Green(),
|
||||
anColorRatio * aNColor.Blue(),
|
||||
Quantity_TOC_RGB);
|
||||
|
||||
if ( hasNormals )
|
||||
{
|
||||
gp_Vec aNorm(aNormals->Value( 3 * normIndex - 2 ),
|
||||
aNormals->Value( 3 * normIndex - 1 ),
|
||||
aNormals->Value( 3 * normIndex ));
|
||||
aNorm.SquareMagnitude() > aMin ?
|
||||
aCPolyArr->AddVertex( P, gp_Dir( aNorm ), aNColor ) :
|
||||
aCPolyArr->AddVertex( P, aDefNorm , aNColor );
|
||||
}
|
||||
else
|
||||
aCPolyArr->AddVertex( P, aDefNorm, aNColor );
|
||||
}
|
||||
else
|
||||
aCPolyArr->AddVertex( P, aNColor );
|
||||
}
|
||||
aPolyL->AddVertex ( P );
|
||||
if ( j == 1 )
|
||||
Start = P;
|
||||
}
|
||||
aPolyL->AddVertex ( Start );
|
||||
}
|
||||
|
||||
// if IsExcludingOn then presentation must not be built by other builders
|
||||
if ( IsExcludingOn() )
|
||||
IDsToExclude.Add( aKey );
|
||||
}
|
||||
}
|
||||
} // for ( ...
|
||||
|
||||
Handle(Graphic3d_AspectFillArea3d) anAsp;
|
||||
|
||||
// Aspect_InteriorStyle aStyle;
|
||||
// Standard_Integer aStyleInt;
|
||||
Aspect_TypeOfLine anEdgeType = Aspect_TOL_SOLID;
|
||||
Standard_Integer anEdgeInt;
|
||||
Standard_Real anEdgeWidth;
|
||||
Quantity_Color anInteriorColor;
|
||||
Quantity_Color anEdgeColor, aLineColor;
|
||||
Standard_Boolean aShowEdges = Standard_True;
|
||||
|
||||
aDrawer->GetColor ( MeshVS_DA_InteriorColor, anInteriorColor );
|
||||
aDrawer->GetColor ( MeshVS_DA_EdgeColor, anEdgeColor );
|
||||
aDrawer->GetColor ( MeshVS_DA_BeamColor, aLineColor );
|
||||
aDrawer->GetDouble ( MeshVS_DA_EdgeWidth, anEdgeWidth );
|
||||
aDrawer->GetBoolean( MeshVS_DA_ShowEdges, aShowEdges );
|
||||
|
||||
if ( aDrawer->GetInteger ( MeshVS_DA_EdgeType, anEdgeInt ) )
|
||||
anEdgeType = (Aspect_TypeOfLine) anEdgeInt;
|
||||
|
||||
if ( myUseTexture )
|
||||
{
|
||||
Handle(AIS_Drawer) anAISDrawer = myParentMesh->Attributes();
|
||||
if ( anAISDrawer.IsNull() )
|
||||
return;
|
||||
|
||||
anAISDrawer->SetShadingAspect( new Prs3d_ShadingAspect() );
|
||||
anAsp = anAISDrawer->ShadingAspect()->Aspect();
|
||||
if ( anAsp.IsNull() )
|
||||
return;
|
||||
|
||||
anAsp->SetFrontMaterial( aMaterial[ 0 ] );
|
||||
anAsp->SetBackMaterial( aMaterial[ 1 ] );
|
||||
|
||||
|
||||
Handle(Graphic3d_Texture2D) aTexture = CreateTexture();
|
||||
if ( aTexture.IsNull() )
|
||||
return;
|
||||
|
||||
anAsp->SetTextureMapOn();
|
||||
anAsp->SetTextureMap( aTexture );
|
||||
}
|
||||
else
|
||||
{
|
||||
// if ( aDrawer->GetInteger ( MeshVS_DA_InteriorStyle, aStyleInt ) )
|
||||
// aStyle = (Aspect_InteriorStyle)aStyleInt;
|
||||
|
||||
anAsp = new Graphic3d_AspectFillArea3d (
|
||||
Aspect_IS_SOLID, Quantity_NOC_GRAY, anEdgeColor,
|
||||
anEdgeType, anEdgeWidth, aMaterial[ 0 ], aMaterial[ 1 ] );
|
||||
}
|
||||
|
||||
anAsp->SetDistinguishOff();
|
||||
anAsp->SetEdgeOff();
|
||||
anAsp->SetInteriorColor( Quantity_NOC_GRAY );
|
||||
|
||||
Handle(Graphic3d_AspectLine3d) anLAsp =
|
||||
new Graphic3d_AspectLine3d( anEdgeColor, anEdgeType, anEdgeWidth );
|
||||
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle(Graphic3d_Group) aGroup1 = Prs3d_Root::CurrentGroup ( Prs );
|
||||
|
||||
aGroup1->SetPrimitivesAspect( anAsp );
|
||||
aGroup1->BeginPrimitives();
|
||||
aGroup1->AddPrimitiveArray( aCPolyArr );
|
||||
aGroup1->EndPrimitives();
|
||||
|
||||
if (aShowEdges)
|
||||
{
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle(Graphic3d_Group) aGroup2 = Prs3d_Root::CurrentGroup ( Prs );
|
||||
|
||||
anAsp->SetEdgeOff();
|
||||
anAsp->SetTextureMapOff();
|
||||
aGroup2->SetPrimitivesAspect( anAsp );
|
||||
aGroup2->SetPrimitivesAspect( anLAsp );
|
||||
aGroup2->BeginPrimitives();
|
||||
aGroup2->AddPrimitiveArray( aPolyL );
|
||||
aGroup2->EndPrimitives();
|
||||
anAsp->SetEdgeOn();
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetColors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_NodalColorPrsBuilder::SetColors (
|
||||
const MeshVS_DataMapOfIntegerColor& theColorMap )
|
||||
{
|
||||
myNodeColorMap = theColorMap;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetColors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const MeshVS_DataMapOfIntegerColor& MeshVS_NodalColorPrsBuilder::GetColors() const
|
||||
{
|
||||
return myNodeColorMap;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : HasColors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_NodalColorPrsBuilder::HasColors () const
|
||||
{
|
||||
return ( myNodeColorMap.Extent() >0 );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetColor
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_NodalColorPrsBuilder::GetColor ( const Standard_Integer ID,
|
||||
Quantity_Color& theColor ) const
|
||||
{
|
||||
Standard_Boolean aRes = myNodeColorMap.IsBound ( ID );
|
||||
if ( aRes )
|
||||
theColor = myNodeColorMap.Find ( ID );
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetColor
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_NodalColorPrsBuilder::SetColor ( const Standard_Integer theID,
|
||||
const Quantity_Color& theCol )
|
||||
{
|
||||
Standard_Boolean aRes = myNodeColorMap.IsBound ( theID );
|
||||
if ( aRes )
|
||||
myNodeColorMap.ChangeFind ( theID ) = theCol;
|
||||
else
|
||||
myNodeColorMap.Bind ( theID, theCol );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : UseTexture
|
||||
// Purpose : Specify whether texture must be used to build presentation
|
||||
//================================================================
|
||||
void MeshVS_NodalColorPrsBuilder::UseTexture( const Standard_Boolean theToUse )
|
||||
{
|
||||
myUseTexture = theToUse;
|
||||
if ( myUseTexture )
|
||||
myNodeColorMap.Clear();
|
||||
else
|
||||
myTextureColorMap.Clear();
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : IsUseTexture
|
||||
// Purpose : Verify whether texture is used to build presentation
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_NodalColorPrsBuilder::IsUseTexture() const
|
||||
{
|
||||
return myUseTexture;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetColorMap
|
||||
// Purpose : Set colors to be used for texrture presentation.
|
||||
// Generate texture in accordance with given parameters
|
||||
//================================================================
|
||||
void MeshVS_NodalColorPrsBuilder::SetColorMap( const Aspect_SequenceOfColor& theColors )
|
||||
{
|
||||
myTextureColorMap = theColors;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetColorMap
|
||||
// Purpose : Return colors used for texrture presentation
|
||||
//================================================================
|
||||
const Aspect_SequenceOfColor& MeshVS_NodalColorPrsBuilder::GetColorMap() const
|
||||
{
|
||||
return myTextureColorMap;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetInvalidColor
|
||||
// Purpose : Set color representing invalid texture coordinate
|
||||
// (laying outside range [0, 1])
|
||||
//================================================================
|
||||
void MeshVS_NodalColorPrsBuilder::SetInvalidColor(
|
||||
const Quantity_Color& theInvalidColor )
|
||||
{
|
||||
myInvalidColor = theInvalidColor;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetInvalidColor
|
||||
// Purpose : Return color representing invalid texture coordinate
|
||||
// (laying outside range [0, 1])
|
||||
//================================================================
|
||||
Quantity_Color MeshVS_NodalColorPrsBuilder::GetInvalidColor() const
|
||||
{
|
||||
return myInvalidColor;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetTextureCoords
|
||||
// Purpose : Specify correspondence between node IDs and texture
|
||||
// coordinates (range [0, 1])
|
||||
//================================================================
|
||||
void MeshVS_NodalColorPrsBuilder::SetTextureCoords (
|
||||
const TColStd_DataMapOfIntegerReal& theMap )
|
||||
{
|
||||
myTextureCoords = theMap;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetTextureCoords
|
||||
// Purpose : Get correspondence between node IDs and texture
|
||||
// coordinates (range [0, 1])
|
||||
//================================================================
|
||||
const TColStd_DataMapOfIntegerReal& MeshVS_NodalColorPrsBuilder::GetTextureCoords() const
|
||||
{
|
||||
return myTextureCoords;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetTextureCoord
|
||||
// Purpose : Specify correspondence between node ID and texture
|
||||
// coordinate (range [0, 1])
|
||||
//================================================================
|
||||
void MeshVS_NodalColorPrsBuilder::SetTextureCoord( const Standard_Integer theID,
|
||||
const Standard_Real theCoord )
|
||||
{
|
||||
myTextureCoords.Bind( theID, theCoord );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetTextureCoord
|
||||
// Purpose : Return correspondence between node IDs and texture
|
||||
// coordinate (range [0, 1])
|
||||
//================================================================
|
||||
Standard_Real MeshVS_NodalColorPrsBuilder::GetTextureCoord( const Standard_Integer theID )
|
||||
{
|
||||
return myTextureCoords.IsBound( theID ) ? myTextureCoords( theID ) : -1;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : CreateTexture
|
||||
// Purpose : Create texture in accordance with myTextureColorMap
|
||||
//================================================================
|
||||
Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const
|
||||
{
|
||||
Handle(Graphic3d_Texture2D) aTexture;
|
||||
|
||||
int nbColors = myTextureColorMap.Length();
|
||||
if ( nbColors == 0 )
|
||||
return aTexture;
|
||||
|
||||
Handle(PrsMgr_PresentationManager3d) aPrsMgr = GetPresentationManager();
|
||||
if ( aPrsMgr.IsNull() )
|
||||
return aTexture;
|
||||
|
||||
int nbTextureColors = getNearestPow2( nbColors );
|
||||
|
||||
// Create and fill image with colors
|
||||
Handle(Image_ColorImage) aCImage =
|
||||
new Image_ColorImage( 0, 0, nbTextureColors, 2 );
|
||||
|
||||
if ( nbColors > 0 )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < nbColors; i++ )
|
||||
{
|
||||
aCImage->SetPixel( i, 0, Aspect_ColorPixel( myTextureColorMap( i + 1 ) ) );
|
||||
aCImage->SetPixel( i, 1, Aspect_ColorPixel( myInvalidColor ) );
|
||||
}
|
||||
Quantity_Color aLastColor = myTextureColorMap( nbColors );
|
||||
for ( i = nbColors; i < nbTextureColors; i++ )
|
||||
{
|
||||
aCImage->SetPixel( i, 0, aLastColor );
|
||||
aCImage->SetPixel( i, 1, Aspect_ColorPixel( myInvalidColor ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Convert image to bmp
|
||||
Handle(AlienImage_BMPAlienImage) aTextureImage = new AlienImage_BMPAlienImage();
|
||||
aTextureImage->FromImage( aCImage );
|
||||
|
||||
// Create texture
|
||||
aTexture = new MeshVS_ImageTexture2D( aPrsMgr->StructureManager(), aTextureImage );
|
||||
return aTexture;
|
||||
}
|
129
src/MeshVS/MeshVS_PrsBuilder.cdl
Executable file
129
src/MeshVS/MeshVS_PrsBuilder.cdl
Executable file
@@ -0,0 +1,129 @@
|
||||
-- File : MeshVS_PrsBuilder.cdl
|
||||
-- Created : 10 October 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
|
||||
deferred class PrsBuilder from MeshVS inherits TShared from MMgt
|
||||
|
||||
---Purpose: This class is parent for all builders using in MeshVS_Mesh.
|
||||
-- It provides base fields and methods all buildes need.
|
||||
|
||||
uses
|
||||
Integer from Standard,
|
||||
Boolean from Standard,
|
||||
|
||||
Presentation from Prs3d,
|
||||
|
||||
EntityOwner from SelectBasics,
|
||||
SensitiveEntity from SelectBasics,
|
||||
|
||||
DisplayModeFlags from MeshVS,
|
||||
Mesh from MeshVS,
|
||||
MeshPtr from MeshVS,
|
||||
DataSource from MeshVS,
|
||||
Drawer from MeshVS,
|
||||
BuilderPriority from MeshVS,
|
||||
PresentationManager3d from PrsMgr,
|
||||
PackedMapOfInteger from TColStd
|
||||
|
||||
is
|
||||
|
||||
Initialize ( Parent : Mesh from MeshVS;
|
||||
Flags : DisplayModeFlags from MeshVS;
|
||||
DS : DataSource from MeshVS;
|
||||
Id : Integer;
|
||||
Priority : BuilderPriority from MeshVS = MeshVS_BP_Default );
|
||||
---Purpose: Constructor
|
||||
-- Parent is pointer to MeshVS_Mesh object
|
||||
-- Flags is set of display modes corresponding to this builder
|
||||
-- DS is data source object, from which builder will pick geometry and topological information
|
||||
-- Id is numeric identificator of builder. You must set it to positive integer, but if
|
||||
-- you set it to -1, constructor will select the smallest integer, not occupied by other builders
|
||||
-- Priority is numerical priority constant. As priority bigger, as sooner builder starts during
|
||||
-- presentation construction
|
||||
|
||||
Build ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IDsToExclude: in out PackedMapOfInteger;
|
||||
IsElement : Boolean;
|
||||
DisplayMode : Integer ) is deferred;
|
||||
---Purpose: Builds presentation of certain type of data.
|
||||
-- Prs is presentation object which this method constructs.
|
||||
-- IDs is set of numeric identificators forming object appearance.
|
||||
-- IDsToExclude is set of IDs to exclude from processing. If some entity
|
||||
-- has been excluded, it is not processed by other builders.
|
||||
-- IsElement indicates, IDs is identificators of nodes or elements.
|
||||
-- DisplayMode is numeric constant describing display mode (see MeshVS_DisplayModeFlags.hxx)
|
||||
|
||||
CustomBuild ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IDsToExclude: in out PackedMapOfInteger;
|
||||
DisplayMode : Integer ) is virtual;
|
||||
---Purpose: This method is called to build presentation of custom elements (they have MeshVS_ET_0D type).
|
||||
-- IDs is set of numeric identificators of elements for custom building.
|
||||
-- IDsToExclude is set of IDs to exclude from processing. If some entity
|
||||
-- has been excluded, it is not processed by other builders.
|
||||
-- DisplayMode is numeric constant describing display mode (see MeshVS_DisplayModeFlags.hxx)
|
||||
|
||||
CustomSensitiveEntity ( me; Owner : EntityOwner from SelectBasics;
|
||||
SelectMode : Integer ) returns SensitiveEntity from SelectBasics is virtual;
|
||||
---Purpose: This method is called to build sensitive of custom elements ( they have MeshVS_ET_0D type )
|
||||
|
||||
GetFlags ( me ) returns Integer;
|
||||
---Purpose: Returns flags, assigned with builder during creation
|
||||
|
||||
TestFlags ( me; DisplayMode : Integer ) returns Boolean is virtual;
|
||||
---Purpose: Test whether display mode has flags assigned with this builder.
|
||||
-- This method has default implementation and can be redefined for advance behavior
|
||||
-- Returns Standard_True only if display mode is appropriate for this builder
|
||||
|
||||
GetId ( me ) returns Integer;
|
||||
---Purpose: Returns builder ID
|
||||
|
||||
GetPriority ( me ) returns Integer;
|
||||
---Purpose: Returns priority; as priority bigger, as soon builder will be called.
|
||||
|
||||
GetDataSource ( me ) returns DataSource from MeshVS;
|
||||
---Purpose: Returns custom data source or default ( from MeshVS_Mesh ) if custom is NULL
|
||||
|
||||
DataSource ( me ) returns DataSource from MeshVS is protected;
|
||||
---Purpose: Returns only custom data source
|
||||
|
||||
SetDataSource ( me : mutable; newDS : DataSource from MeshVS );
|
||||
---Purpose: Change custom data source
|
||||
|
||||
GetDrawer ( me ) returns Drawer from MeshVS;
|
||||
---Purpose: Returns custom drawer or default ( from MeshVS_Mesh ) if custom is NULL
|
||||
|
||||
Drawer ( me ) returns Drawer from MeshVS is protected;
|
||||
---Purpose: Returns only custom drawer
|
||||
|
||||
SetDrawer ( me : mutable; newDr : Drawer from MeshVS );
|
||||
---Purpose: Change custom drawer
|
||||
|
||||
SetExcluding ( me : mutable; state : Boolean );
|
||||
---Purpose: Set excluding state. If it is Standard_True, the nodes or elements, processed by current builder
|
||||
-- will be noted and next builder won't process its.
|
||||
|
||||
IsExcludingOn ( me ) returns Boolean;
|
||||
---Purpose: Read excluding state
|
||||
|
||||
SetPresentationManager( me : mutable; thePrsMgr : PresentationManager3d from PrsMgr );
|
||||
---Purpose: Set presentation manager for builder
|
||||
|
||||
GetPresentationManager ( me ) returns PresentationManager3d from PrsMgr;
|
||||
---Purpose: Get presentation manager of builder
|
||||
|
||||
fields
|
||||
myIsExcluding : Boolean;
|
||||
myParentMesh : MeshPtr from MeshVS is protected;
|
||||
myDataSource : DataSource from MeshVS;
|
||||
myDrawer : Drawer from MeshVS;
|
||||
myFlags : Integer;
|
||||
myId : Integer;
|
||||
myPriority : Integer;
|
||||
myPrsMgr : PresentationManager3d from PrsMgr;
|
||||
|
||||
end PrsBuilder;
|
||||
|
190
src/MeshVS/MeshVS_PrsBuilder.cxx
Executable file
190
src/MeshVS/MeshVS_PrsBuilder.cxx
Executable file
@@ -0,0 +1,190 @@
|
||||
// File: MeshVS_PrsBuilder.cxx
|
||||
// Created: Tue Sep 9 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_PrsBuilder.ixx>
|
||||
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_PrsBuilder
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_PrsBuilder::MeshVS_PrsBuilder ( const Handle(MeshVS_Mesh)& Parent,
|
||||
const MeshVS_DisplayModeFlags& Flags,
|
||||
const Handle(MeshVS_DataSource)& DS,
|
||||
const Standard_Integer Id,
|
||||
const MeshVS_BuilderPriority& Priority )
|
||||
{
|
||||
if (Id<0 && Parent!=0 )
|
||||
myId = Parent->GetFreeId();
|
||||
else
|
||||
myId = Id;
|
||||
|
||||
myParentMesh = Parent.operator->();
|
||||
myDataSource = DS;
|
||||
myDrawer = 0;
|
||||
|
||||
myFlags = Flags;
|
||||
myIsExcluding = Standard_False;
|
||||
|
||||
myPriority = Priority;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : CustomDraw
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_PrsBuilder::CustomBuild ( const Handle(Prs3d_Presentation)&,
|
||||
const TColStd_PackedMapOfInteger&,
|
||||
TColStd_PackedMapOfInteger&,
|
||||
const Standard_Integer ) const
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : CustomSensitiveEntity
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( SelectBasics_SensitiveEntity ) MeshVS_PrsBuilder::CustomSensitiveEntity
|
||||
( const Handle( SelectBasics_EntityOwner )&,
|
||||
const Standard_Integer ) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : DataSource
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle (MeshVS_DataSource) MeshVS_PrsBuilder::DataSource () const
|
||||
{
|
||||
return myDataSource;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDataSource
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle (MeshVS_DataSource) MeshVS_PrsBuilder::GetDataSource () const
|
||||
{
|
||||
if ( myDataSource.IsNull() )
|
||||
return myParentMesh->GetDataSource();
|
||||
else
|
||||
return myDataSource;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetDataSource
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_PrsBuilder::SetDataSource ( const Handle (MeshVS_DataSource)& DS )
|
||||
{
|
||||
myDataSource = DS;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetFlags
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Integer MeshVS_PrsBuilder::GetFlags () const
|
||||
{
|
||||
return myFlags;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetId
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Integer MeshVS_PrsBuilder::GetId () const
|
||||
{
|
||||
return myId;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : TestFlags
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_PrsBuilder::TestFlags ( const Standard_Integer DisplayMode ) const
|
||||
{
|
||||
return ( ( DisplayMode & GetFlags() ) > 0 );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetExcluding
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_PrsBuilder::SetExcluding ( const Standard_Boolean state )
|
||||
{
|
||||
myIsExcluding = state;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : IsExcludingOn
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_PrsBuilder::IsExcludingOn () const
|
||||
{
|
||||
return myIsExcluding;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetPriority
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Integer MeshVS_PrsBuilder::GetPriority () const
|
||||
{
|
||||
return myPriority;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetDrawer
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle (MeshVS_Drawer) MeshVS_PrsBuilder::GetDrawer () const
|
||||
{
|
||||
if ( myDrawer.IsNull() )
|
||||
return myParentMesh->GetDrawer();
|
||||
else
|
||||
return myDrawer;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetDataSource
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_PrsBuilder::SetDrawer ( const Handle (MeshVS_Drawer)& Dr )
|
||||
{
|
||||
myDrawer = Dr;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Drawer
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle (MeshVS_Drawer) MeshVS_PrsBuilder::Drawer () const
|
||||
{
|
||||
return myDrawer;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetPresentationManager
|
||||
// Purpose : Set presentation manager. This method is used by
|
||||
// MeshVS_Mesh::Compute methodto assign presentation
|
||||
// manager to the builder.
|
||||
//================================================================
|
||||
void MeshVS_PrsBuilder::SetPresentationManager( const Handle(PrsMgr_PresentationManager3d)& thePrsMgr )
|
||||
{
|
||||
myPrsMgr = thePrsMgr;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetPresentationManager
|
||||
// Purpose : Get presentation manager
|
||||
//================================================================
|
||||
Handle(PrsMgr_PresentationManager3d) MeshVS_PrsBuilder::GetPresentationManager() const
|
||||
{
|
||||
return myPrsMgr;
|
||||
}
|
27
src/MeshVS/MeshVS_SelectionModeFlags.hxx
Executable file
27
src/MeshVS/MeshVS_SelectionModeFlags.hxx
Executable file
@@ -0,0 +1,27 @@
|
||||
// File: MeshVS_SelectionModeFlags.hxx
|
||||
// Created: Wed Apr 25 2007
|
||||
// Author: Natalia KOPNOVA
|
||||
// Copyright: Open CASCADE 2007
|
||||
|
||||
#ifndef MeshVS_SELECTION_MODE_FLAGS_HXX
|
||||
#define MeshVS_SELECTION_MODE_FLAGS_HXX
|
||||
|
||||
Standard_EXPORT typedef enum
|
||||
{
|
||||
MeshVS_SMF_Mesh = 0x0000,
|
||||
MeshVS_SMF_Node = 0x0001,
|
||||
MeshVS_SMF_0D = 0x0002,
|
||||
MeshVS_SMF_Link = 0x0004,
|
||||
MeshVS_SMF_Face = 0x0008,
|
||||
MeshVS_SMF_Volume = 0x0010,
|
||||
|
||||
MeshVS_SMF_Element = MeshVS_SMF_0D | MeshVS_SMF_Link | MeshVS_SMF_Face | MeshVS_SMF_Volume,
|
||||
MeshVS_SMF_All = MeshVS_SMF_Element | MeshVS_SMF_Node,
|
||||
|
||||
MeshVS_SMF_Group = 0x0100
|
||||
|
||||
|
||||
} MeshVS_SelectionModeFlags;
|
||||
|
||||
#endif
|
||||
|
44
src/MeshVS/MeshVS_SensitiveFace.cdl
Executable file
44
src/MeshVS/MeshVS_SensitiveFace.cdl
Executable file
@@ -0,0 +1,44 @@
|
||||
-- File: MeshVS_SensitiveFace.hxx
|
||||
-- Created: Mon Sep 29 2003
|
||||
-- Author: Alexander SOLOVYOV and Sergey LITONIN
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class SensitiveFace from MeshVS inherits SensitiveFace from Select3D
|
||||
|
||||
---Purpose: This class provides custom sensitive face, which will be selected if it center is in rectangle.
|
||||
|
||||
uses
|
||||
EntityOwner from SelectBasics,
|
||||
|
||||
Array1OfPnt from TColgp,
|
||||
|
||||
TypeOfSensitivity from Select3D,
|
||||
Projector from Select3D,
|
||||
|
||||
Pnt from gp,
|
||||
Pnt2d from gp,
|
||||
|
||||
Array1OfPnt2d from TColgp,
|
||||
|
||||
Box2d from Bnd
|
||||
|
||||
is
|
||||
|
||||
Create ( theOwner : EntityOwner from SelectBasics;
|
||||
thePoints : Array1OfPnt from TColgp;
|
||||
theSensType : TypeOfSensitivity from Select3D = Select3D_TOS_INTERIOR )
|
||||
returns mutable SensitiveFace from MeshVS;
|
||||
|
||||
Project( me: mutable; aProjector : Projector from Select3D ) is redefined;
|
||||
|
||||
Matches ( me: mutable; XMin, YMin, XMax, YMax: Real;
|
||||
aTol: Real ) returns Boolean is redefined;
|
||||
|
||||
Matches ( me: mutable; Polyline: Array1OfPnt2d from TColgp;
|
||||
aBox:Box2d; aTol: Real ) returns Boolean is redefined;
|
||||
|
||||
fields
|
||||
myCentre : Pnt from gp is protected;
|
||||
myProjCentre : Pnt2d from gp is protected;
|
||||
|
||||
end SensitiveFace;
|
72
src/MeshVS/MeshVS_SensitiveFace.cxx
Executable file
72
src/MeshVS/MeshVS_SensitiveFace.cxx
Executable file
@@ -0,0 +1,72 @@
|
||||
// File: MeshVS_SensitiveFace.cxx
|
||||
// Created: Mon Sep 29 2003
|
||||
// Author: Alexander SOLOVYOV and Sergey LITONIN
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_SensitiveFace.ixx>
|
||||
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <Select3D_Projector.hxx>
|
||||
#include <CSLib_Class2d.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
|
||||
//=======================================================================
|
||||
// name : MeshVS_SensitiveFace::MeshVS_SensitiveFace
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
MeshVS_SensitiveFace::MeshVS_SensitiveFace (
|
||||
const Handle(SelectBasics_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePnts,
|
||||
const Select3D_TypeOfSensitivity theSensitivity )
|
||||
: Select3D_SensitiveFace( theOwnerId, thePnts, theSensitivity )
|
||||
{
|
||||
gp_XYZ c( 0, 0, 0 );
|
||||
Standard_Integer nbPnts = thePnts.Upper() - thePnts.Lower() + 1;
|
||||
for ( Standard_Integer i = thePnts.Lower(); i <= thePnts.Upper(); i++ )
|
||||
c += thePnts( i ).XYZ();
|
||||
myCentre.SetXYZ( c / nbPnts );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : MeshVS_SensitiveFace::Project
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
void MeshVS_SensitiveFace::Project( const Select3D_Projector& aProj )
|
||||
{
|
||||
Select3D_SensitiveFace::Project( aProj );
|
||||
if ( HasLocation() )
|
||||
aProj.Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
|
||||
else
|
||||
aProj.Project( myCentre, myProjCentre );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : MeshVS_SensitiveFace::Matches
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_SensitiveFace::Matches( const Standard_Real XMin,
|
||||
const Standard_Real YMin,
|
||||
const Standard_Real XMax,
|
||||
const Standard_Real YMax,
|
||||
const Standard_Real aTol )
|
||||
{
|
||||
Bnd_Box2d aBox;
|
||||
aBox.Update( XMin-aTol, YMin-aTol, XMax+aTol, YMax+aTol );
|
||||
return !aBox.IsOut( myProjCentre );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : MeshVS_SensitiveFace::Matches
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_SensitiveFace::Matches( const TColgp_Array1OfPnt2d& Polyline,
|
||||
const Bnd_Box2d& aBox,
|
||||
const Standard_Real aTol )
|
||||
{
|
||||
Standard_Real Umin, Vmin, Umax, Vmax;
|
||||
aBox.Get ( Umin,Vmin,Umax,Vmax );
|
||||
CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
|
||||
Standard_Integer aRes = aClassifier2d.SiDans( myProjCentre );
|
||||
|
||||
return ( aRes == 1) ;
|
||||
}
|
61
src/MeshVS/MeshVS_SensitiveMesh.cdl
Executable file
61
src/MeshVS/MeshVS_SensitiveMesh.cdl
Executable file
@@ -0,0 +1,61 @@
|
||||
-- File: MeshVS_SensitiveMesh.cdl
|
||||
-- Created: Thu Jan 25 2007
|
||||
-- Author: Sergey KOCHETKOV
|
||||
---Copyright: Open CASCADE 2007
|
||||
|
||||
class SensitiveMesh from MeshVS inherits SensitiveEntity from Select3D
|
||||
|
||||
---Purpose: This class provides custom mesh sensitive entity used in advanced mesh selection.
|
||||
---It provides detection of mesh entities accordingly to activated selection mode
|
||||
|
||||
uses
|
||||
EntityOwner from SelectBasics,
|
||||
Array1OfPnt2d from TColgp,
|
||||
Box from Bnd,
|
||||
Box2d from Bnd,
|
||||
Location from TopLoc,
|
||||
Lin from gp,
|
||||
ListOfBox2d from SelectBasics,
|
||||
Projector from Select3D
|
||||
is
|
||||
|
||||
Create ( theOwner : EntityOwner from SelectBasics;
|
||||
theMode : Integer = 0 )
|
||||
returns mutable SensitiveMesh from MeshVS;
|
||||
|
||||
GetMode( me ) returns Integer from Standard;
|
||||
|
||||
GetConnected( me: mutable; aLocation : Location from TopLoc )
|
||||
returns SensitiveEntity from Select3D is redefined;
|
||||
|
||||
ComputeDepth( me; EyeLine : Lin from gp ) returns Real from Standard
|
||||
is redefined;
|
||||
|
||||
Matches( me: mutable; X,Y : Real from Standard;
|
||||
aTol: Real from Standard;
|
||||
DMin: out Real from Standard ) returns Boolean
|
||||
is redefined;
|
||||
|
||||
Matches ( me: mutable; XMin, YMin, XMax, YMax : Real;
|
||||
aTol : Real ) returns Boolean
|
||||
is redefined;
|
||||
|
||||
Matches ( me: mutable; Polyline : Array1OfPnt2d from TColgp;
|
||||
aBox : Box2d;
|
||||
aTol : Real ) returns Boolean
|
||||
is redefined;
|
||||
|
||||
Project ( me:mutable; aProjector : Projector from Select3D ) is redefined static;
|
||||
|
||||
Areas ( me: mutable ; boxes : in out ListOfBox2d from SelectBasics ) is redefined static;
|
||||
|
||||
ProjectOneCorner( me: mutable; aProjector : Projector from Select3D;
|
||||
X,Y,Z : Real from Standard ) is private;
|
||||
|
||||
fields
|
||||
|
||||
myMode : Integer from Standard;
|
||||
mybox : Box from Bnd;
|
||||
mybox2d : Box2d from Bnd;
|
||||
|
||||
end SensitiveMesh;
|
200
src/MeshVS/MeshVS_SensitiveMesh.cxx
Executable file
200
src/MeshVS/MeshVS_SensitiveMesh.cxx
Executable file
@@ -0,0 +1,200 @@
|
||||
// File: MeshVS_SensitiveMesh.cxx
|
||||
// Created: Thu Jan 29 2007
|
||||
// Author: Sergey KOCHETKOV
|
||||
// Copyright: Open CASCADE 2007
|
||||
|
||||
#include <MeshVS_SensitiveMesh.ixx>
|
||||
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_HPackedMapOfInteger.hxx>
|
||||
#include <Select3D_Projector.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <MeshVS_DataSource.hxx>
|
||||
#include <MeshVS_MeshOwner.hxx>
|
||||
|
||||
//=======================================================================
|
||||
// name : MeshVS_SensitiveMesh::MeshVS_SensitiveMesh
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
MeshVS_SensitiveMesh::MeshVS_SensitiveMesh (const Handle(SelectBasics_EntityOwner)& theOwnerId,
|
||||
const Standard_Integer theMode)
|
||||
: Select3D_SensitiveEntity( theOwnerId )
|
||||
{
|
||||
myMode = theMode;
|
||||
mybox.SetVoid();
|
||||
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
|
||||
if( !anOwner.IsNull() )
|
||||
{
|
||||
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
|
||||
if( !aDS.IsNull() )
|
||||
mybox = aDS->GetBoundingBox();
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetMode
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Integer MeshVS_SensitiveMesh::GetMode () const
|
||||
{
|
||||
return myMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : Matches
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_SensitiveMesh::Matches(const Standard_Real X,
|
||||
const Standard_Real Y,
|
||||
const Standard_Real aTol,
|
||||
Standard_Real& DMin)
|
||||
{
|
||||
DMin = 0.;
|
||||
|
||||
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
|
||||
if( anOwner.IsNull() ) return Standard_False;
|
||||
Handle(MeshVS_Mesh) aMeshPrs = Handle(MeshVS_Mesh)::DownCast( anOwner->Selectable() );
|
||||
if( aMeshPrs.IsNull() ) return Standard_False;
|
||||
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
|
||||
if( aDS.IsNull() ) return Standard_False;
|
||||
Handle(TColStd_HPackedMapOfInteger) NodesMap;
|
||||
Handle(TColStd_HPackedMapOfInteger) ElemsMap;
|
||||
// Mesh data source should provide the algorithm for computation
|
||||
// of detected entities from 2D point
|
||||
Standard_Boolean isDetected = aDS->GetDetectedEntities( aMeshPrs, X, Y, aTol, NodesMap, ElemsMap, DMin );
|
||||
// The detected entites will be available from mesh owner
|
||||
anOwner->SetDetectedEntities( NodesMap, ElemsMap );
|
||||
|
||||
return isDetected;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : Matches
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_SensitiveMesh::Matches(const Standard_Real XMin,
|
||||
const Standard_Real YMin,
|
||||
const Standard_Real XMax,
|
||||
const Standard_Real YMax,
|
||||
const Standard_Real aTol)
|
||||
{
|
||||
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
|
||||
if( anOwner.IsNull() ) return Standard_False;
|
||||
Handle(MeshVS_Mesh) aMeshPrs = Handle(MeshVS_Mesh)::DownCast( anOwner->Selectable() );
|
||||
if( aMeshPrs.IsNull() ) return Standard_False;
|
||||
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
|
||||
if( aDS.IsNull() ) return Standard_False;
|
||||
Handle(TColStd_HPackedMapOfInteger) NodesMap;
|
||||
Handle(TColStd_HPackedMapOfInteger) ElemsMap;
|
||||
// Mesh data source should provide the algorithm for computation
|
||||
// of detected entities from 2D box area
|
||||
Standard_Boolean isDetected = aDS->GetDetectedEntities( aMeshPrs, XMin, YMin, XMax, YMax, aTol, NodesMap, ElemsMap );
|
||||
// The detected entites will be available from mesh owner
|
||||
anOwner->SetDetectedEntities( NodesMap, ElemsMap );
|
||||
|
||||
return isDetected;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : Matches
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_SensitiveMesh::Matches(const TColgp_Array1OfPnt2d& Polyline,
|
||||
const Bnd_Box2d& aBox,
|
||||
const Standard_Real aTol)
|
||||
{
|
||||
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
|
||||
if( anOwner.IsNull() ) return Standard_False;
|
||||
Handle(MeshVS_Mesh) aMeshPrs = Handle(MeshVS_Mesh)::DownCast( anOwner->Selectable() );
|
||||
if( aMeshPrs.IsNull() ) return Standard_False;
|
||||
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
|
||||
if( aDS.IsNull() ) return Standard_False;
|
||||
Handle(TColStd_HPackedMapOfInteger) NodesMap;
|
||||
Handle(TColStd_HPackedMapOfInteger) ElemsMap;
|
||||
// Mesh data source should provide the algorithm for computation
|
||||
// of detected entities from 2D polyline
|
||||
Standard_Boolean isDetected = aDS->GetDetectedEntities( aMeshPrs, Polyline, aBox, aTol, NodesMap, ElemsMap );
|
||||
// The detected entites will be available from mesh owner
|
||||
anOwner->SetDetectedEntities( NodesMap, ElemsMap );
|
||||
|
||||
return isDetected;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : GetConnected
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Handle(Select3D_SensitiveEntity) MeshVS_SensitiveMesh::GetConnected( const TopLoc_Location& aLoc )
|
||||
{
|
||||
Handle(MeshVS_SensitiveMesh) aMeshEnt = new MeshVS_SensitiveMesh( myOwnerId );
|
||||
if(HasLocation()) aMeshEnt->SetLocation( Location() );
|
||||
aMeshEnt->UpdateLocation( aLoc );
|
||||
return aMeshEnt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeDepth
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real MeshVS_SensitiveMesh::ComputeDepth( const gp_Lin& /*EyeLine*/ ) const
|
||||
{
|
||||
return 0.;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: ProjectOneCorner
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void MeshVS_SensitiveMesh::ProjectOneCorner(const Select3D_Projector& theProj,
|
||||
const Standard_Real theX,
|
||||
const Standard_Real theY,
|
||||
const Standard_Real theZ)
|
||||
{
|
||||
gp_Pnt aPnt( theX, theY, theZ );
|
||||
gp_Pnt2d aProjPnt;
|
||||
if( HasLocation() )
|
||||
theProj.Project( aPnt.Transformed(Location().Transformation()), aProjPnt );
|
||||
else
|
||||
theProj.Project( aPnt, aProjPnt );
|
||||
mybox2d.Add( aProjPnt );
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Project
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void MeshVS_SensitiveMesh::Project(const Select3D_Projector& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
|
||||
mybox2d.SetVoid();
|
||||
if (mybox.IsVoid())
|
||||
return;
|
||||
// Compute the 2D bounding box - projection of mesh bounding box
|
||||
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
|
||||
if( anOwner.IsNull() ) return;
|
||||
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
|
||||
if( aDS.IsNull() ) return;
|
||||
|
||||
Standard_Real XMin, YMin, ZMin, XMax, YMax, ZMax;
|
||||
mybox.Get( XMin, YMin, ZMin, XMax, YMax, ZMax );
|
||||
|
||||
ProjectOneCorner (aProj, XMin, YMin, ZMin);
|
||||
ProjectOneCorner (aProj, XMin, YMin, ZMax);
|
||||
ProjectOneCorner (aProj, XMin, YMax, ZMin);
|
||||
ProjectOneCorner (aProj, XMin, YMax, ZMax);
|
||||
ProjectOneCorner (aProj, XMax, YMin, ZMin);
|
||||
ProjectOneCorner (aProj, XMax, YMin, ZMax);
|
||||
ProjectOneCorner (aProj, XMax, YMax, ZMin);
|
||||
ProjectOneCorner (aProj, XMax, YMax, ZMax);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Areas
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void MeshVS_SensitiveMesh::Areas( SelectBasics_ListOfBox2d& aSeq )
|
||||
{
|
||||
aSeq.Append(mybox2d);
|
||||
}
|
67
src/MeshVS/MeshVS_SensitivePolyhedron.cdl
Executable file
67
src/MeshVS/MeshVS_SensitivePolyhedron.cdl
Executable file
@@ -0,0 +1,67 @@
|
||||
-- File : MeshVS_SensitivePolyhedron.cdl
|
||||
-- Created : 21 January 2005
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2005
|
||||
|
||||
class SensitivePolyhedron from MeshVS inherits SensitiveEntity from Select3D
|
||||
|
||||
uses
|
||||
EntityOwner from SelectBasics,
|
||||
Projector from Select3D,
|
||||
Location from TopLoc,
|
||||
Real from Standard,
|
||||
Boolean from Standard,
|
||||
Array1OfPnt2d from TColgp,
|
||||
SequenceOfInteger from TColStd,
|
||||
Box2d from Bnd,
|
||||
Lin from gp,
|
||||
ListOfBox2d from SelectBasics,
|
||||
Array1OfPnt from TColgp,
|
||||
HArray1OfPnt from TColgp,
|
||||
HArray1OfPnt2d from TColgp,
|
||||
HArray1OfSequenceOfInteger from MeshVS,
|
||||
XY from gp
|
||||
|
||||
is
|
||||
Create( Owner : EntityOwner from SelectBasics;
|
||||
Nodes : Array1OfPnt from TColgp;
|
||||
Topo : HArray1OfSequenceOfInteger from MeshVS ) returns mutable SensitivePolyhedron from MeshVS;
|
||||
|
||||
Project( me:mutable; aProjector: Projector from Select3D ) is redefined;
|
||||
|
||||
GetConnected( me:mutable; aLocation: Location from TopLoc ) returns SensitiveEntity from Select3D
|
||||
is redefined;
|
||||
|
||||
Matches( me : mutable;
|
||||
X,Y : Real from Standard;
|
||||
aTol : Real from Standard;
|
||||
DMin : out Real from Standard ) returns Boolean is redefined;
|
||||
|
||||
Matches( me : mutable;
|
||||
XMin,YMin,XMax,YMax : Real from Standard;
|
||||
aTol : Real from Standard ) returns Boolean from Standard is redefined;
|
||||
|
||||
Matches( me : mutable;
|
||||
Polyline : Array1OfPnt2d from TColgp;
|
||||
aBox : Box2d from Bnd;
|
||||
aTol : Real from Standard ) returns Boolean from Standard is redefined;
|
||||
|
||||
GetBox2d( me; aBox : out Box2d from Bnd ) is protected;
|
||||
|
||||
FindIntersection( me; NodesIndices : SequenceOfInteger from TColStd;
|
||||
EyeLine : Lin from gp ) returns Real is protected;
|
||||
|
||||
ComputeDepth( me; EyeLine: Lin from gp ) returns Real from Standard is redefined;
|
||||
|
||||
-- ComputeSize( me ) returns Real from Standard is redefined;
|
||||
|
||||
Areas( me: mutable; aResult : in out ListOfBox2d from SelectBasics ) is redefined;
|
||||
|
||||
fields
|
||||
myNodes : HArray1OfPnt from TColgp;
|
||||
myNodes2d : HArray1OfPnt2d from TColgp;
|
||||
myTopo : HArray1OfSequenceOfInteger from MeshVS;
|
||||
myCenter : XY from gp;
|
||||
|
||||
end SensitiveEntity;
|
||||
|
291
src/MeshVS/MeshVS_SensitivePolyhedron.cxx
Executable file
291
src/MeshVS/MeshVS_SensitivePolyhedron.cxx
Executable file
@@ -0,0 +1,291 @@
|
||||
// File: MeshVS_SensitivePolyhedron.cxx
|
||||
// Created: Fri Jan 21 2005
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2005
|
||||
|
||||
|
||||
#include <MeshVS_SensitivePolyhedron.ixx>
|
||||
|
||||
#include <MeshVS_Tool.hxx>
|
||||
#include <CSLib_Class2d.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_SensitivePolyhedron
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_SensitivePolyhedron::
|
||||
MeshVS_SensitivePolyhedron( const Handle( SelectBasics_EntityOwner )& Owner,
|
||||
const TColgp_Array1OfPnt& Nodes,
|
||||
const Handle( MeshVS_HArray1OfSequenceOfInteger )& Topo )
|
||||
: Select3D_SensitiveEntity( Owner ),
|
||||
myTopo( Topo )
|
||||
{
|
||||
Standard_Integer low = Nodes.Lower(), up = Nodes.Upper(), i;
|
||||
|
||||
myNodes = new TColgp_HArray1OfPnt ( low, up );
|
||||
for( i=low; i<=up; i++ )
|
||||
myNodes->SetValue( i, Nodes.Value( i ) );
|
||||
|
||||
myNodes2d = new TColgp_HArray1OfPnt2d( low, up );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Project
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_SensitivePolyhedron::Project( const Select3D_Projector& aProjector )
|
||||
{
|
||||
Select3D_SensitiveEntity::Project( aProjector );
|
||||
|
||||
if( myNodes.IsNull() || myNodes2d.IsNull() )
|
||||
return;
|
||||
|
||||
Standard_Integer low = myNodes->Lower(),
|
||||
up = myNodes->Upper();
|
||||
|
||||
gp_Pnt pnt;
|
||||
gp_Pnt2d proj;
|
||||
|
||||
Standard_Boolean hasLoc = HasLocation();
|
||||
|
||||
myCenter = gp_XY( 0, 0 );
|
||||
|
||||
for( Standard_Integer i=low; i<=up; i++ )
|
||||
{
|
||||
pnt = myNodes->Value( i );
|
||||
if( !hasLoc )
|
||||
aProjector.Project( pnt, proj );
|
||||
else
|
||||
aProjector.Project( pnt.Transformed( Location().Transformation() ), proj );
|
||||
|
||||
myNodes2d->SetValue( i, proj.XY() );
|
||||
myCenter += proj.XY();
|
||||
}
|
||||
|
||||
myCenter /= ( up-low+1 );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetConnected
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( Select3D_SensitiveEntity ) MeshVS_SensitivePolyhedron::GetConnected
|
||||
( const TopLoc_Location& aLocation )
|
||||
{
|
||||
Handle( MeshVS_SensitivePolyhedron ) NewEnt = new
|
||||
MeshVS_SensitivePolyhedron( myOwnerId, myNodes->Array1(), myTopo );
|
||||
|
||||
if( HasLocation() )
|
||||
NewEnt->SetLocation( Location() );
|
||||
|
||||
NewEnt->UpdateLocation( aLocation );
|
||||
|
||||
return NewEnt;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : sort
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void sort( Standard_Real& a, Standard_Real& b )
|
||||
{
|
||||
if( a>b )
|
||||
{
|
||||
Standard_Real temp = a; a = b; b = temp;
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Matches
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_SensitivePolyhedron::Matches( const Standard_Real X,
|
||||
const Standard_Real Y,
|
||||
const Standard_Real aTol,
|
||||
Standard_Real& DMin )
|
||||
{
|
||||
if( myNodes2d.IsNull() || myTopo.IsNull() )
|
||||
return Standard_False;
|
||||
|
||||
Standard_Integer R1 = myTopo->Lower(),
|
||||
R2 = myTopo->Upper(),
|
||||
low = myNodes2d->Lower();
|
||||
|
||||
Standard_Real rTol = aTol*SensitivityFactor();
|
||||
|
||||
Standard_Boolean inside = Standard_False;
|
||||
|
||||
// "odd-even" algorithm: with ray parallel axis of absciss and toward positive
|
||||
for( Standard_Integer i=R1; i<=R2 && !inside; i++ )
|
||||
{
|
||||
Standard_Integer intersect = 0, cur, next, C1 = 1, C2 = myTopo->Value( i ).Length();
|
||||
Standard_Real k, b, // y=kx+b -- equation of polygon's edge
|
||||
x1, y1, x2, y2, xp; // auxiliary points
|
||||
|
||||
for( Standard_Integer j=C1; j<=C2; j++ )
|
||||
{
|
||||
cur = myTopo->Value( i ).Value( j );
|
||||
next = myTopo->Value( i ).Value( j<C2 ? j+1 : C1 );
|
||||
|
||||
x1 = myNodes2d->Value( low+cur ).X(),
|
||||
y1 = myNodes2d->Value( low+cur ).Y(),
|
||||
x2 = myNodes2d->Value( low+next ).X(),
|
||||
y2 = myNodes2d->Value( low+next ).Y();
|
||||
|
||||
if( Abs( x2-x1 )<Precision::Confusion() )
|
||||
{
|
||||
//vertical edge!!!
|
||||
|
||||
sort( y1, y2 );
|
||||
if( Y>=y1-rTol && Y<=y2+rTol && x1>X-rTol )
|
||||
intersect++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//inclined edge!!!
|
||||
|
||||
k = ( y2-y1 ) / ( x2-x1 );
|
||||
b = y1 - k*x1;
|
||||
|
||||
if( Abs( k )>Precision::Confusion() )
|
||||
{
|
||||
xp = ( Y-b ) / k; // absciss of point of intersection
|
||||
sort( x1, x2 );
|
||||
if( xp>=x1 && xp<=x2 && xp>X-rTol )
|
||||
intersect++;
|
||||
}
|
||||
}
|
||||
}
|
||||
inside = ( intersect%2 ) == 1;
|
||||
}
|
||||
|
||||
if( inside )
|
||||
Select3D_SensitiveEntity::Matches( X, Y, aTol, DMin );
|
||||
|
||||
return inside;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Matches
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_SensitivePolyhedron::Matches( const Standard_Real XMin,
|
||||
const Standard_Real YMin,
|
||||
const Standard_Real XMax,
|
||||
const Standard_Real YMax,
|
||||
const Standard_Real aTol )
|
||||
{
|
||||
Standard_Real rTol = aTol*SensitivityFactor();
|
||||
|
||||
return myCenter.X()>=XMin-rTol && myCenter.X()<=XMax+rTol &&
|
||||
myCenter.Y()>=YMin-rTol && myCenter.Y()<=YMax+rTol;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Matches
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_SensitivePolyhedron::Matches
|
||||
( const TColgp_Array1OfPnt2d& Polyline,
|
||||
const Bnd_Box2d& aBox,
|
||||
const Standard_Real aTol )
|
||||
{
|
||||
Standard_Real Umin, Vmin, Umax, Vmax;
|
||||
aBox.Get( Umin, Vmin, Umax, Vmax );
|
||||
|
||||
CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
|
||||
|
||||
Standard_Integer res = aClassifier2d.SiDans( myCenter );
|
||||
return( res==1 );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : FindIntersection
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Real MeshVS_SensitivePolyhedron::FindIntersection
|
||||
( const TColStd_SequenceOfInteger& NodesIndices,
|
||||
const gp_Lin& EyeLine) const
|
||||
{
|
||||
Standard_Real val( Precision::Infinite() );
|
||||
for( Standard_Integer i=1, n=NodesIndices.Length(); i<=n; i++ )
|
||||
val = Min( val, ElCLib::Parameter(
|
||||
EyeLine, myNodes->Value( myNodes->Lower()+NodesIndices.Value( i ) ) ) );
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : ComputeDepth
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Real MeshVS_SensitivePolyhedron::ComputeDepth( const gp_Lin& EyeLine ) const
|
||||
{
|
||||
Standard_Real val = Precision::Infinite();
|
||||
|
||||
if( !myTopo.IsNull() )
|
||||
for( Standard_Integer i=myTopo->Lower(), up=myTopo->Upper(); i<=up; i++ )
|
||||
val = Min( val, FindIntersection( myTopo->Value( i ), EyeLine ) );
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : ComputeSize
|
||||
// Purpose :
|
||||
//================================================================
|
||||
/*Standard_Real MeshVS_SensitivePolyhedron::ComputeSize() const
|
||||
{
|
||||
Bnd_Box2d aBox;
|
||||
GetBox2d( aBox );
|
||||
|
||||
Standard_Real aXmin, aYmin, aXmax, aYmax;
|
||||
aBox.Get( aXmin, aYmin, aXmax, aYmax );
|
||||
return Abs( ( aXmax-aXmin ) * ( aYmax-aYmin ) );
|
||||
} */
|
||||
|
||||
//================================================================
|
||||
// Function : Areas
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_SensitivePolyhedron::Areas( SelectBasics_ListOfBox2d& aResult )
|
||||
{
|
||||
Bnd_Box2d aBox;
|
||||
GetBox2d( aBox );
|
||||
aResult.Append( aBox );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetBox2d
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_SensitivePolyhedron::GetBox2d( Bnd_Box2d& aBox ) const
|
||||
{
|
||||
aBox.SetVoid();
|
||||
|
||||
Standard_Real xmin = 0., ymin = 0., xmax = 0., ymax = 0., x, y;
|
||||
Standard_Integer low = myNodes2d->Lower(),
|
||||
up = myNodes2d->Upper();
|
||||
|
||||
if( !myNodes2d.IsNull() )
|
||||
{
|
||||
xmin = xmax = myNodes2d->Value( low ).X();
|
||||
ymin = ymax = myNodes2d->Value( low ).Y();
|
||||
for( Standard_Integer i=low+1; i<=up; i++ )
|
||||
{
|
||||
x = myNodes2d->Value( i ).X();
|
||||
y = myNodes2d->Value( i ).Y();
|
||||
if( x>xmax )
|
||||
xmax = x;
|
||||
else if( x<xmin )
|
||||
xmin = x;
|
||||
if( y>ymax )
|
||||
ymax = y;
|
||||
else if( y<ymin )
|
||||
ymin = y;
|
||||
}
|
||||
}
|
||||
|
||||
aBox.Update( xmin, ymin, xmax, ymax );
|
||||
}
|
43
src/MeshVS/MeshVS_SensitiveSegment.cdl
Executable file
43
src/MeshVS/MeshVS_SensitiveSegment.cdl
Executable file
@@ -0,0 +1,43 @@
|
||||
-- File: MeshVS_SensitiveSegment.cdl
|
||||
-- Created: Mon Sep 29 2003
|
||||
-- Author: Alexander SOLOVYOV and Sergey LITONIN
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class SensitiveSegment from MeshVS inherits SensitiveSegment from Select3D
|
||||
|
||||
---Purpose: This class provides custom sensitive face, which will be selected if it center is in rectangle.
|
||||
|
||||
uses
|
||||
EntityOwner from SelectBasics,
|
||||
|
||||
Array1OfPnt from TColgp,
|
||||
|
||||
TypeOfSensitivity from Select3D,
|
||||
Projector from Select3D,
|
||||
|
||||
Pnt from gp,
|
||||
Pnt2d from gp,
|
||||
|
||||
Array1OfPnt2d from TColgp,
|
||||
|
||||
Box2d from Bnd
|
||||
|
||||
is
|
||||
|
||||
Create ( theOwner : EntityOwner from SelectBasics;
|
||||
theFirstP, theLastP : Pnt from gp;
|
||||
theMaxRect : Integer = 1 ) returns mutable SensitiveSegment from MeshVS;
|
||||
|
||||
Project( me: mutable; aProjector : Projector from Select3D ) is redefined;
|
||||
|
||||
Matches ( me: mutable; XMin, YMin, XMax, YMax: Real;
|
||||
aTol: Real ) returns Boolean is redefined;
|
||||
|
||||
Matches ( me: mutable; Polyline: Array1OfPnt2d from TColgp;
|
||||
aBox: Box2d; aTol: Real ) returns Boolean is redefined;
|
||||
|
||||
fields
|
||||
myCentre : Pnt from gp is protected;
|
||||
myProjCentre : Pnt2d from gp is protected;
|
||||
|
||||
end SensitiveSegment;
|
68
src/MeshVS/MeshVS_SensitiveSegment.cxx
Executable file
68
src/MeshVS/MeshVS_SensitiveSegment.cxx
Executable file
@@ -0,0 +1,68 @@
|
||||
// File: MeshVS_SensitiveSegment.cxx
|
||||
// Created: Mon Sep 29 2003
|
||||
// Author: Alexander SOLOVYOV and Sergey LITONIN
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_SensitiveSegment.ixx>
|
||||
#include <Select3D_Projector.hxx>
|
||||
#include <Bnd_Box2d.hxx>
|
||||
#include <CSLib_Class2d.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
|
||||
//=======================================================================
|
||||
// name : MeshVS_SensitiveSegment::MeshVS_SensitiveSegment
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
MeshVS_SensitiveSegment::MeshVS_SensitiveSegment (
|
||||
const Handle(SelectBasics_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& theFirstP,
|
||||
const gp_Pnt& theLastP,
|
||||
const Standard_Integer theMaxRect )
|
||||
: Select3D_SensitiveSegment( theOwnerId, theFirstP, theLastP, theMaxRect )
|
||||
{
|
||||
myCentre.SetXYZ( ( theFirstP.XYZ() + theLastP.XYZ() ) / 2 );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : MeshVS_SensitiveSegment::Project
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
void MeshVS_SensitiveSegment::Project( const Select3D_Projector& aProj )
|
||||
{
|
||||
Select3D_SensitiveSegment::Project( aProj );
|
||||
if ( HasLocation() )
|
||||
aProj.Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
|
||||
else
|
||||
aProj.Project( myCentre, myProjCentre );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : MeshVS_SensitiveSegment::Matches
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_SensitiveSegment::Matches( const Standard_Real XMin,
|
||||
const Standard_Real YMin,
|
||||
const Standard_Real XMax,
|
||||
const Standard_Real YMax,
|
||||
const Standard_Real aTol )
|
||||
{
|
||||
Bnd_Box2d aBox;
|
||||
aBox.Update( XMin-aTol, YMin-aTol, XMax+aTol, YMax+aTol );
|
||||
return !aBox.IsOut( myProjCentre );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : MeshVS_SensitiveSegment::Matches
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean MeshVS_SensitiveSegment::Matches( const TColgp_Array1OfPnt2d& Polyline,
|
||||
const Bnd_Box2d& aBox,
|
||||
const Standard_Real aTol )
|
||||
{
|
||||
Standard_Real Umin, Vmin, Umax, Vmax;
|
||||
aBox.Get ( Umin,Vmin,Umax,Vmax );
|
||||
CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
|
||||
Standard_Integer aRes = aClassifier2d.SiDans( myProjCentre );
|
||||
|
||||
return ( aRes == 1) ;
|
||||
}
|
73
src/MeshVS/MeshVS_TextPrsBuilder.cdl
Executable file
73
src/MeshVS/MeshVS_TextPrsBuilder.cdl
Executable file
@@ -0,0 +1,73 @@
|
||||
-- File : MeshVS_TextPrsBuilder.cdl
|
||||
-- Created : 13 October 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class TextPrsBuilder from MeshVS inherits PrsBuilder from MeshVS
|
||||
|
||||
---Purpose: This class provides methods to create text data presentation.
|
||||
-- It store map of texts assigned with nodes or elements.
|
||||
|
||||
uses
|
||||
Real from Standard,
|
||||
|
||||
Presentation from Prs3d,
|
||||
|
||||
Boolean from Standard,
|
||||
Integer from Standard,
|
||||
|
||||
Mesh from MeshVS,
|
||||
MeshPtr from MeshVS,
|
||||
DisplayModeFlags from MeshVS,
|
||||
DataSource from MeshVS,
|
||||
DataMapOfIntegerAsciiString from MeshVS,
|
||||
BuilderPriority from MeshVS,
|
||||
Color from Quantity,
|
||||
AsciiString from TCollection,
|
||||
PackedMapOfInteger from TColStd
|
||||
|
||||
is
|
||||
|
||||
Create ( Parent : Mesh from MeshVS;
|
||||
Height : Real;
|
||||
Color : Color from Quantity;
|
||||
Flags : DisplayModeFlags from MeshVS = MeshVS_DMF_TextDataPrs;
|
||||
DS : DataSource from MeshVS = 0;
|
||||
Id : Integer = -1;
|
||||
Priority : BuilderPriority from MeshVS = MeshVS_BP_Text ) returns mutable TextPrsBuilder from MeshVS;
|
||||
|
||||
Build ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IDsToExclude : in out PackedMapOfInteger;
|
||||
IsElement : Boolean;
|
||||
theDisplayMode : Integer ) is virtual;
|
||||
---Purpose: Builds presentation of text data
|
||||
|
||||
GetTexts ( me; IsElement : Boolean ) returns DataMapOfIntegerAsciiString from MeshVS;
|
||||
---C++: return const &
|
||||
---Purpose: Returns map of text assigned with nodes ( IsElement = False ) or elements ( IsElement = True )
|
||||
|
||||
SetTexts ( me : mutable;
|
||||
IsElement : Boolean;
|
||||
Map : DataMapOfIntegerAsciiString from MeshVS );
|
||||
---Purpose: Sets map of text assigned with nodes or elements
|
||||
|
||||
HasTexts ( me; IsElement : Boolean ) returns Boolean;
|
||||
---Purpose: Returns True if map isn't empty
|
||||
|
||||
GetText ( me; IsElement : Boolean;
|
||||
ID : Integer;
|
||||
Text : out AsciiString from TCollection ) returns Boolean;
|
||||
---Purpose: Returns text assigned with single node or element
|
||||
|
||||
SetText ( me : mutable;
|
||||
IsElement : Boolean;
|
||||
ID : Integer;
|
||||
Text : AsciiString from TCollection );
|
||||
---Purpose: Sets text assigned with single node or element
|
||||
|
||||
fields
|
||||
myNodeTextMap : DataMapOfIntegerAsciiString from MeshVS;
|
||||
myElemTextMap : DataMapOfIntegerAsciiString from MeshVS;
|
||||
|
||||
end TextPrsBuilder;
|
263
src/MeshVS/MeshVS_TextPrsBuilder.cxx
Executable file
263
src/MeshVS/MeshVS_TextPrsBuilder.cxx
Executable file
@@ -0,0 +1,263 @@
|
||||
// File: MeshVS_TextPrsBuilder.cxx
|
||||
// Created: Mon Sep 22 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_TextPrsBuilder.ixx>
|
||||
|
||||
#include <MeshVS_DisplayModeFlags.hxx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfReal.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
#include <TColStd_HPackedMapOfInteger.hxx>
|
||||
|
||||
#include <MeshVS_DataSource.hxx>
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_Buffer.hxx>
|
||||
|
||||
#include <Graphic3d_NameOfFont.hxx>
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_TextPrsBuilder
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_TextPrsBuilder::MeshVS_TextPrsBuilder ( const Handle(MeshVS_Mesh)& Parent,
|
||||
const Standard_Real Height,
|
||||
const Quantity_Color& Color,
|
||||
const MeshVS_DisplayModeFlags& Flags,
|
||||
const Handle (MeshVS_DataSource)& DS,
|
||||
const Standard_Integer Id,
|
||||
const MeshVS_BuilderPriority& Priority )
|
||||
: MeshVS_PrsBuilder ( Parent, Flags, DS, Id, Priority )
|
||||
{
|
||||
Handle ( MeshVS_Drawer ) aDrawer = GetDrawer();
|
||||
if ( !aDrawer.IsNull() )
|
||||
{
|
||||
aDrawer->SetDouble ( MeshVS_DA_TextHeight, Height );
|
||||
aDrawer->SetColor ( MeshVS_DA_TextColor, Color );
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetTexts
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const MeshVS_DataMapOfIntegerAsciiString& MeshVS_TextPrsBuilder::GetTexts ( const Standard_Boolean IsElements ) const
|
||||
{
|
||||
if ( IsElements )
|
||||
return myElemTextMap;
|
||||
else
|
||||
return myNodeTextMap;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetTexts
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_TextPrsBuilder::SetTexts ( const Standard_Boolean IsElements,
|
||||
const MeshVS_DataMapOfIntegerAsciiString& Map )
|
||||
{
|
||||
if ( IsElements )
|
||||
myElemTextMap = Map;
|
||||
else
|
||||
myNodeTextMap = Map;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : HasTexts
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_TextPrsBuilder::HasTexts ( const Standard_Boolean IsElement ) const
|
||||
{
|
||||
Standard_Boolean aRes = (myNodeTextMap.Extent()>0);
|
||||
if ( IsElement )
|
||||
aRes = (myElemTextMap.Extent()>0);
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetText
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_TextPrsBuilder::GetText ( const Standard_Boolean IsElement,
|
||||
const Standard_Integer theID,
|
||||
TCollection_AsciiString& theStr ) const
|
||||
{
|
||||
const MeshVS_DataMapOfIntegerAsciiString* aMap = &myNodeTextMap;
|
||||
if ( IsElement )
|
||||
aMap = &myElemTextMap;
|
||||
|
||||
Standard_Boolean aRes = aMap->IsBound ( theID );
|
||||
if ( aRes )
|
||||
theStr = aMap->Find ( theID );
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetText
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_TextPrsBuilder::SetText ( const Standard_Boolean IsElement,
|
||||
const Standard_Integer ID,
|
||||
const TCollection_AsciiString& Text )
|
||||
{
|
||||
MeshVS_DataMapOfIntegerAsciiString* aMap = &myNodeTextMap;
|
||||
if ( IsElement )
|
||||
aMap = &myElemTextMap;
|
||||
|
||||
Standard_Boolean aRes = aMap->IsBound ( ID );
|
||||
if ( aRes )
|
||||
aMap->ChangeFind ( ID ) = Text;
|
||||
else
|
||||
aMap->Bind ( ID, Text );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Build
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
|
||||
const TColStd_PackedMapOfInteger& IDs,
|
||||
TColStd_PackedMapOfInteger& IDsToExclude,
|
||||
const Standard_Boolean IsElement,
|
||||
const Standard_Integer theDisplayMode ) const
|
||||
{
|
||||
Handle (MeshVS_DataSource) aSource = GetDataSource();
|
||||
Handle (MeshVS_Drawer) aDrawer = GetDrawer();
|
||||
if ( aSource.IsNull() || aDrawer.IsNull() || !HasTexts( IsElement ) ||
|
||||
( theDisplayMode & GetFlags() ) == 0 )
|
||||
return;
|
||||
|
||||
Standard_Integer aMaxFaceNodes;
|
||||
Standard_Real aHeight;
|
||||
if ( !aDrawer->GetInteger ( MeshVS_DA_MaxFaceNodes, aMaxFaceNodes ) ||
|
||||
aMaxFaceNodes <= 0 ||
|
||||
!aDrawer->GetDouble ( MeshVS_DA_TextHeight, aHeight ) )
|
||||
return;
|
||||
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle (Graphic3d_Group) aTextGroup = Prs3d_Root::CurrentGroup ( Prs );
|
||||
|
||||
Quantity_Color AColor = Quantity_NOC_YELLOW;
|
||||
#ifdef WNT
|
||||
Standard_CString AFont = "Courier New";
|
||||
#else
|
||||
Standard_CString AFont = "Courier";
|
||||
#endif
|
||||
Standard_Real AExpansionFactor = 1.0;
|
||||
Standard_Real ASpace = 0.0;
|
||||
Aspect_TypeOfStyleText ATextStyle = Aspect_TOST_ANNOTATION;
|
||||
Standard_Integer AStyleInt;
|
||||
Aspect_TypeOfDisplayText ADisplayType = Aspect_TODT_NORMAL;
|
||||
TCollection_AsciiString AFontString;
|
||||
Standard_Integer ADispInt;
|
||||
Standard_Boolean ATexFont;
|
||||
// Bold font is used by default for better text readability
|
||||
OSD_FontAspect AFontAspectType = OSD_FA_Bold;
|
||||
Standard_Integer AAspect;
|
||||
|
||||
|
||||
aDrawer->GetColor ( MeshVS_DA_TextColor, AColor );
|
||||
aDrawer->GetDouble ( MeshVS_DA_TextExpansionFactor, AExpansionFactor );
|
||||
aDrawer->GetDouble ( MeshVS_DA_TextSpace, ASpace );
|
||||
|
||||
if ( aDrawer->GetAsciiString ( MeshVS_DA_TextFont, AFontString ) )
|
||||
AFont = AFontString.ToCString();
|
||||
if ( aDrawer->GetInteger ( MeshVS_DA_TextStyle, AStyleInt ) )
|
||||
ATextStyle = (Aspect_TypeOfStyleText) AStyleInt;
|
||||
if ( aDrawer->GetInteger ( MeshVS_DA_TextDisplayType, ADispInt ) )
|
||||
ADisplayType = (Aspect_TypeOfDisplayText) ADispInt;
|
||||
if ( aDrawer->GetInteger ( MeshVS_DA_TextFontAspect, AAspect ) )
|
||||
AFontAspectType = (OSD_FontAspect)AAspect;
|
||||
|
||||
Handle (Graphic3d_AspectText3d) aTextAspect = new Graphic3d_AspectText3d ( AColor, AFont, AExpansionFactor, ASpace,
|
||||
ATextStyle, ADisplayType );
|
||||
aTextAspect->SetTextFontAspect( AFontAspectType );
|
||||
Handle (Graphic3d_AspectMarker3d) anAspectMarker3d =
|
||||
new Graphic3d_AspectMarker3d( Aspect_TOM_POINT, Quantity_NOC_GRAY, 1. );
|
||||
aTextGroup->SetPrimitivesAspect( aTextAspect );
|
||||
aTextGroup->SetPrimitivesAspect( anAspectMarker3d );
|
||||
|
||||
aTextGroup->BeginPrimitives();
|
||||
|
||||
MeshVS_Buffer aCoordsBuf (3*aMaxFaceNodes*sizeof(Standard_Real));
|
||||
TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3*aMaxFaceNodes);
|
||||
Standard_Integer NbNodes;
|
||||
TCollection_AsciiString aStr;
|
||||
MeshVS_EntityType aType;
|
||||
TColStd_PackedMapOfInteger aCustomElements;
|
||||
|
||||
Standard_Real X, Y, Z;
|
||||
|
||||
// subtract the hidden elements and ids to exclude (to minimise allocated memory)
|
||||
TColStd_PackedMapOfInteger anIDs;
|
||||
anIDs.Assign( IDs );
|
||||
if ( IsElement )
|
||||
{
|
||||
Handle(TColStd_HPackedMapOfInteger) aHiddenElems = myParentMesh->GetHiddenElems();
|
||||
if ( !aHiddenElems.IsNull() )
|
||||
anIDs.Subtract( aHiddenElems->Map() );
|
||||
}
|
||||
anIDs.Subtract( IDsToExclude );
|
||||
|
||||
TColStd_MapIteratorOfPackedMapOfInteger it (anIDs);
|
||||
for( ; it.More(); it.Next() )
|
||||
{
|
||||
Standard_Integer aKey = it.Key();
|
||||
if( GetText ( IsElement, aKey, aStr ) )
|
||||
{
|
||||
if( aSource->GetGeom ( aKey, IsElement, aCoords, NbNodes, aType ) )
|
||||
{
|
||||
if( aType == MeshVS_ET_Node )
|
||||
{
|
||||
X = aCoords(1);
|
||||
Y = aCoords(2);
|
||||
Z = aCoords(3);
|
||||
}
|
||||
else if( aType == MeshVS_ET_Link ||
|
||||
aType == MeshVS_ET_Face ||
|
||||
aType == MeshVS_ET_Volume )
|
||||
{
|
||||
if( IsElement && IsExcludingOn() )
|
||||
IDsToExclude.Add( aKey );
|
||||
X = Y = Z = 0;
|
||||
for ( Standard_Integer i=1; i<=NbNodes; i++ )
|
||||
{
|
||||
X += aCoords (3*i-2);
|
||||
Y += aCoords (3*i-1);
|
||||
Z += aCoords (3*i);
|
||||
}
|
||||
X /= Standard_Real ( NbNodes );
|
||||
Y /= Standard_Real ( NbNodes );
|
||||
Z /= Standard_Real ( NbNodes );
|
||||
}
|
||||
else
|
||||
{
|
||||
aCustomElements.Add( aKey );
|
||||
continue;
|
||||
}
|
||||
|
||||
Graphic3d_Vertex aPoint( X, Y, Z );
|
||||
|
||||
aTextGroup->Marker ( aPoint );
|
||||
aTextGroup->Text ( aStr.ToCString(), aPoint, aHeight );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aTextGroup->EndPrimitives();
|
||||
|
||||
if (!aCustomElements.IsEmpty())
|
||||
CustomBuild ( Prs, aCustomElements, IDsToExclude, theDisplayMode );
|
||||
}
|
53
src/MeshVS/MeshVS_Tool.cdl
Executable file
53
src/MeshVS/MeshVS_Tool.cdl
Executable file
@@ -0,0 +1,53 @@
|
||||
-- File : MeshVS_Tool.cdl
|
||||
-- Created : 17 December 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class Tool from MeshVS
|
||||
|
||||
---Purpose: This class provides auxiliary methods to create differents aspects
|
||||
|
||||
uses
|
||||
Boolean from Standard,
|
||||
|
||||
Drawer from MeshVS,
|
||||
|
||||
AspectFillArea3d from Graphic3d,
|
||||
AspectLine3d from Graphic3d,
|
||||
AspectMarker3d from Graphic3d,
|
||||
AspectText3d from Graphic3d,
|
||||
MaterialAspect from Graphic3d,
|
||||
|
||||
Array1OfReal from TColStd,
|
||||
|
||||
Vec from gp,
|
||||
Dir from gp
|
||||
|
||||
is
|
||||
CreateAspectFillArea3d ( myclass; theDr : Drawer; UseDefaults : Boolean = Standard_True ) returns AspectFillArea3d from Graphic3d;
|
||||
---Purpose: Creates fill area aspect with values from Drawer according to keys from DrawerAttribute
|
||||
|
||||
CreateAspectFillArea3d ( myclass; theDr : Drawer; Mat : MaterialAspect; UseDefaults : Boolean = Standard_True ) returns AspectFillArea3d from Graphic3d;
|
||||
---Purpose: Creates fill aspect with values from Drawer according to keys from DrawerAttribute
|
||||
-- and specific material aspect
|
||||
|
||||
CreateAspectLine3d ( myclass; theDr : Drawer; UseDefaults : Boolean = Standard_True ) returns AspectLine3d from Graphic3d;
|
||||
---Purpose: Creates line aspect with values from Drawer according to keys from DrawerAttribute
|
||||
|
||||
CreateAspectMarker3d ( myclass; theDr : Drawer; UseDefaults : Boolean = Standard_True ) returns AspectMarker3d from Graphic3d;
|
||||
---Purpose: Creates marker aspect with values from Drawer according to keys from DrawerAttribute
|
||||
|
||||
CreateAspectText3d ( myclass; theDr : Drawer; UseDefaults : Boolean = Standard_True ) returns AspectText3d from Graphic3d;
|
||||
---Purpose: Creates text aspect with values from Drawer according to keys from DrawerAttribute
|
||||
|
||||
GetNormal( myclass; Nodes : Array1OfReal from TColStd;
|
||||
Norm : out Vec from gp ) returns Boolean;
|
||||
---Purpose: Get one of normals to polygon described by these points.
|
||||
-- If the polygon isn't planar, function returns false
|
||||
|
||||
GetAverageNormal( myclass; Nodes : Array1OfReal from TColStd;
|
||||
Norm : out Vec from gp ) returns Boolean;
|
||||
---Purpose: Get an average of normals to non-planar polygon described by these points or compute
|
||||
-- normal of planar polygon. If the polygon isn't planar, function returns false
|
||||
|
||||
end Tool;
|
389
src/MeshVS/MeshVS_Tool.cxx
Executable file
389
src/MeshVS/MeshVS_Tool.cxx
Executable file
@@ -0,0 +1,389 @@
|
||||
// File: MeshVS_Tool.cxx
|
||||
// Created: Wed Dec 17 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_Tool.ixx>
|
||||
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Graphic3d_NameOfFont.hxx>
|
||||
|
||||
//================================================================
|
||||
// Function : CreateAspectFillArea3d
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( Graphic3d_AspectFillArea3d ) MeshVS_Tool::CreateAspectFillArea3d
|
||||
( const Handle(MeshVS_Drawer)& theDr,
|
||||
const Graphic3d_MaterialAspect& Mat,
|
||||
const Standard_Boolean UseDefaults )
|
||||
{
|
||||
Handle( Graphic3d_AspectFillArea3d ) anAsp;
|
||||
if ( theDr.IsNull() )
|
||||
return anAsp;
|
||||
|
||||
Aspect_InteriorStyle anIntStyle = Aspect_IS_EMPTY;
|
||||
Quantity_Color anIntColor = Quantity_NOC_CYAN1,
|
||||
anEdgeColor = Quantity_NOC_WHITE;
|
||||
Aspect_TypeOfLine anEdgeType = Aspect_TOL_SOLID;
|
||||
Standard_Real anEdgeWidth = 1.0;
|
||||
Aspect_HatchStyle aHStyle = Aspect_HS_HORIZONTAL;
|
||||
Graphic3d_MaterialAspect aFrMat = Mat,
|
||||
aBackMat = Mat;
|
||||
|
||||
Standard_Integer anIntStyleI = (Standard_Integer)Aspect_IS_EMPTY;
|
||||
Standard_Integer anEdgeTypeI = (Standard_Integer)Aspect_TOL_SOLID;
|
||||
Standard_Integer aHStyleI = (Standard_Integer)Aspect_HS_HORIZONTAL;
|
||||
|
||||
if ( !theDr->GetColor ( MeshVS_DA_InteriorColor, anIntColor ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
Quantity_Color aBackIntColor = anIntColor;
|
||||
if ( !theDr->GetColor ( MeshVS_DA_BackInteriorColor, aBackIntColor ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetColor ( MeshVS_DA_EdgeColor, anEdgeColor ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetDouble ( MeshVS_DA_EdgeWidth, anEdgeWidth ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_InteriorStyle, anIntStyleI ) && !UseDefaults )
|
||||
return anAsp;
|
||||
else
|
||||
anIntStyle = (Aspect_InteriorStyle) anIntStyleI;
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_EdgeType, anEdgeTypeI ) && !UseDefaults )
|
||||
return anAsp;
|
||||
else
|
||||
anEdgeType = (Aspect_TypeOfLine) anEdgeTypeI;
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_HatchStyle, aHStyleI ) && !UseDefaults )
|
||||
return anAsp;
|
||||
else
|
||||
aHStyle = (Aspect_HatchStyle) aHStyleI;
|
||||
|
||||
anAsp = new Graphic3d_AspectFillArea3d ( anIntStyle, anIntColor, anEdgeColor, anEdgeType,
|
||||
anEdgeWidth, aFrMat, aBackMat );
|
||||
anAsp->SetBackInteriorColor ( aBackIntColor );
|
||||
anAsp->SetHatchStyle ( aHStyle );
|
||||
|
||||
return anAsp;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : CreateAspectFillArea3d
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( Graphic3d_AspectFillArea3d ) MeshVS_Tool::CreateAspectFillArea3d
|
||||
( const Handle(MeshVS_Drawer)& theDr,
|
||||
const Standard_Boolean UseDefaults )
|
||||
{
|
||||
Graphic3d_MaterialAspect aFrMat = Graphic3d_NOM_BRASS;
|
||||
Graphic3d_MaterialAspect aBackMat = Graphic3d_NOM_BRASS;
|
||||
Standard_Integer aFrMatI = (Standard_Integer)Graphic3d_NOM_BRASS;
|
||||
Standard_Integer aBackMatI = (Standard_Integer)Graphic3d_NOM_BRASS;
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_FrontMaterial, aFrMatI ) && !UseDefaults )
|
||||
return 0;
|
||||
else
|
||||
aFrMat = (Graphic3d_MaterialAspect)(Graphic3d_NameOfMaterial)aFrMatI;
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_BackMaterial, aBackMatI ) && !UseDefaults )
|
||||
return 0;
|
||||
else
|
||||
aBackMat = (Graphic3d_MaterialAspect)(Graphic3d_NameOfMaterial)aBackMatI;
|
||||
|
||||
Handle( Graphic3d_AspectFillArea3d ) aFill =
|
||||
CreateAspectFillArea3d ( theDr, aFrMat, UseDefaults );
|
||||
aFill->SetBackMaterial ( aBackMat );
|
||||
|
||||
return aFill;
|
||||
}
|
||||
//================================================================
|
||||
// Function : CreateAspectLine3d
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( Graphic3d_AspectLine3d ) MeshVS_Tool::CreateAspectLine3d
|
||||
( const Handle(MeshVS_Drawer)& theDr,
|
||||
const Standard_Boolean UseDefaults )
|
||||
{
|
||||
Handle( Graphic3d_AspectLine3d ) anAsp;
|
||||
if ( theDr.IsNull() )
|
||||
return anAsp;
|
||||
|
||||
Quantity_Color aBeamColor = Quantity_NOC_YELLOW;
|
||||
Aspect_TypeOfLine aBeamType = Aspect_TOL_SOLID;
|
||||
Standard_Real aBeamWidth = 1.0;
|
||||
Standard_Integer aBeamTypeI = (Standard_Integer)Aspect_TOL_SOLID;
|
||||
|
||||
if ( !theDr->GetColor ( MeshVS_DA_BeamColor, aBeamColor ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetDouble ( MeshVS_DA_BeamWidth, aBeamWidth ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_BeamType, aBeamTypeI ) && !UseDefaults )
|
||||
return anAsp;
|
||||
else
|
||||
aBeamType = (Aspect_TypeOfLine) aBeamTypeI;
|
||||
|
||||
anAsp = new Graphic3d_AspectLine3d ( aBeamColor, aBeamType, aBeamWidth );
|
||||
|
||||
return anAsp;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : CreateAspectMarker3d
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( Graphic3d_AspectMarker3d ) MeshVS_Tool::CreateAspectMarker3d
|
||||
( const Handle(MeshVS_Drawer)& theDr,
|
||||
const Standard_Boolean UseDefaults )
|
||||
{
|
||||
Handle( Graphic3d_AspectMarker3d ) anAsp;
|
||||
if ( theDr.IsNull() )
|
||||
return anAsp;
|
||||
|
||||
Quantity_Color aMColor = Quantity_NOC_YELLOW;
|
||||
Aspect_TypeOfMarker aMType = Aspect_TOM_X;
|
||||
Standard_Real aMScale = 1.0;
|
||||
Standard_Integer aMTypeI = (Standard_Integer)Aspect_TOM_X;
|
||||
|
||||
if ( !theDr->GetColor ( MeshVS_DA_MarkerColor, aMColor ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetDouble ( MeshVS_DA_MarkerScale, aMScale ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_MarkerType, aMTypeI ) && !UseDefaults )
|
||||
return anAsp;
|
||||
else
|
||||
aMType = (Aspect_TypeOfMarker) aMTypeI;
|
||||
|
||||
anAsp = new Graphic3d_AspectMarker3d ( aMType, aMColor, aMScale );
|
||||
|
||||
return anAsp;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : CreateAspectText3d
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Handle( Graphic3d_AspectText3d ) MeshVS_Tool::CreateAspectText3d
|
||||
( const Handle(MeshVS_Drawer)& theDr,
|
||||
const Standard_Boolean UseDefaults )
|
||||
{
|
||||
Handle( Graphic3d_AspectText3d ) anAsp;
|
||||
if ( theDr.IsNull() )
|
||||
return anAsp;
|
||||
|
||||
Quantity_Color aTColor = Quantity_NOC_YELLOW;
|
||||
Standard_Real anExpFactor = 1.0,
|
||||
aSpace = 0.0;
|
||||
Standard_CString aFont = Graphic3d_NOF_ASCII_MONO;
|
||||
Aspect_TypeOfStyleText aStyle = Aspect_TOST_NORMAL;
|
||||
Aspect_TypeOfDisplayText aDispText = Aspect_TODT_NORMAL;
|
||||
TCollection_AsciiString aFontString = Graphic3d_NOF_ASCII_MONO;
|
||||
OSD_FontAspect aFontAspect = OSD_FA_Regular;
|
||||
Standard_Integer aStyleI = (Standard_Integer)Aspect_TOST_NORMAL;
|
||||
Standard_Integer aDispTextI = (Standard_Integer)Aspect_TODT_NORMAL;
|
||||
// Bold font is used by default for better text readability
|
||||
Standard_Integer aFontAspectI = (Standard_Integer)OSD_FA_Bold;
|
||||
|
||||
if ( !theDr->GetColor ( MeshVS_DA_TextColor, aTColor ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetDouble ( MeshVS_DA_TextExpansionFactor, anExpFactor ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetDouble ( MeshVS_DA_TextSpace, aSpace ) && !UseDefaults )
|
||||
return anAsp;
|
||||
|
||||
if ( !theDr->GetAsciiString ( MeshVS_DA_TextFont, aFontString ) && !UseDefaults )
|
||||
return anAsp;
|
||||
else
|
||||
aFont = aFontString.ToCString();
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_TextStyle, aStyleI ) && !UseDefaults )
|
||||
return anAsp;
|
||||
else
|
||||
aStyle = (Aspect_TypeOfStyleText) aStyleI;
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_TextDisplayType, aDispTextI ) && !UseDefaults )
|
||||
return anAsp;
|
||||
else
|
||||
aDispText = (Aspect_TypeOfDisplayText) aDispTextI;
|
||||
|
||||
if ( !theDr->GetInteger ( MeshVS_DA_TextFontAspect, aFontAspectI ) && !UseDefaults )
|
||||
return anAsp;
|
||||
else
|
||||
aFontAspect = (OSD_FontAspect) aFontAspectI;
|
||||
|
||||
anAsp = new Graphic3d_AspectText3d ( aTColor, aFont, anExpFactor, aSpace, aStyle, aDispText );
|
||||
anAsp->SetTextFontAspect( aFontAspect );
|
||||
return anAsp;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetNormal
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Tool::GetNormal( const TColStd_Array1OfReal& Nodes,
|
||||
gp_Vec& Norm )
|
||||
{
|
||||
Standard_Integer first = Nodes.Lower(),
|
||||
last = Nodes.Upper(),
|
||||
count = (last-first+1)/3, i, j;
|
||||
if( first==0 )
|
||||
{
|
||||
first = 1;
|
||||
count = Standard_Integer( Nodes.Value( 0 ) );
|
||||
}
|
||||
|
||||
if( count<3 )
|
||||
return Standard_False;
|
||||
|
||||
Standard_Boolean res = Standard_True;
|
||||
|
||||
|
||||
Standard_Real normal[3], first_vec[3], cur_vec[3], xx, yy, zz,
|
||||
conf = Precision::Confusion();
|
||||
|
||||
for( i=0; i<3; i++ )
|
||||
{
|
||||
normal[i] = 0.0;
|
||||
first_vec[i] = Nodes.Value( first+3+i ) - Nodes.Value( first+i );
|
||||
}
|
||||
|
||||
for( i=2; i<count; i++ )
|
||||
{
|
||||
for( j=0; j<3; j++ )
|
||||
cur_vec[j] = Nodes.Value( first+3*i+j ) - Nodes.Value( first+j );
|
||||
|
||||
xx = first_vec[1] * cur_vec[2] - first_vec[2] * cur_vec[1];
|
||||
yy = first_vec[2] * cur_vec[0] - first_vec[0] * cur_vec[2];
|
||||
zz = first_vec[0] * cur_vec[1] - first_vec[1] * cur_vec[0];
|
||||
|
||||
cur_vec[0] = xx;
|
||||
cur_vec[1] = yy;
|
||||
cur_vec[2] = zz;
|
||||
|
||||
if( fabs( cur_vec[0] ) > conf ||
|
||||
fabs( cur_vec[1] ) > conf ||
|
||||
fabs( cur_vec[2] ) > conf )
|
||||
{
|
||||
Standard_Real cur = Sqrt( cur_vec[0]*cur_vec[0] + cur_vec[1]*cur_vec[1] + cur_vec[2]*cur_vec[2] );
|
||||
for( Standard_Integer k=0; k<3; k++ )
|
||||
cur_vec[k] /= cur;
|
||||
}
|
||||
|
||||
if( fabs( normal[0] ) <= conf &&
|
||||
fabs( normal[1] ) <= conf &&
|
||||
fabs( normal[2] ) <= conf )
|
||||
for( Standard_Integer k=0; k<3; k++ )
|
||||
normal[k] = cur_vec[k];
|
||||
|
||||
if( fabs( normal[0]-cur_vec[0] ) > conf ||
|
||||
fabs( normal[1]-cur_vec[1] ) > conf ||
|
||||
fabs( normal[2]-cur_vec[2] ) > conf )
|
||||
{
|
||||
res = Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( res )
|
||||
Norm.SetCoord( normal[0], normal[1], normal[2] );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
//================================================================
|
||||
// Function : GetAverageNormal
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_Tool::GetAverageNormal( const TColStd_Array1OfReal& Nodes,
|
||||
gp_Vec& Norm )
|
||||
{
|
||||
Standard_Integer first = Nodes.Lower(),
|
||||
last = Nodes.Upper(),
|
||||
count = (last-first+1)/3, i, j;
|
||||
if( first==0 )
|
||||
{
|
||||
first = 1;
|
||||
count = Standard_Integer( Nodes.Value( 0 ) );
|
||||
}
|
||||
|
||||
if( count<3 )
|
||||
return Standard_False;
|
||||
|
||||
Standard_Boolean res = Standard_True;
|
||||
|
||||
|
||||
Standard_Real normal[3], first_vec[3], cur_vec[3], xx, yy, zz,
|
||||
conf = Precision::Confusion();
|
||||
|
||||
for( i=0; i<3; i++ )
|
||||
{
|
||||
normal[i] = 0.0;
|
||||
first_vec[i] = Nodes.Value( first+3+i ) - Nodes.Value( first+i );
|
||||
}
|
||||
|
||||
gp_XYZ* norm_vec = new gp_XYZ[count-2];
|
||||
for ( i = 0; i < count-2; i++ )
|
||||
norm_vec[i].SetCoord(0, 0, 0);
|
||||
|
||||
for( i=2; i<count; i++ )
|
||||
{
|
||||
for( j=0; j<3; j++ )
|
||||
cur_vec[j] = Nodes.Value( first+3*i+j ) - Nodes.Value( first+j );
|
||||
|
||||
xx = first_vec[1] * cur_vec[2] - first_vec[2] * cur_vec[1];
|
||||
yy = first_vec[2] * cur_vec[0] - first_vec[0] * cur_vec[2];
|
||||
zz = first_vec[0] * cur_vec[1] - first_vec[1] * cur_vec[0];
|
||||
|
||||
cur_vec[0] = xx;
|
||||
cur_vec[1] = yy;
|
||||
cur_vec[2] = zz;
|
||||
|
||||
if( fabs( cur_vec[0] ) > conf ||
|
||||
fabs( cur_vec[1] ) > conf ||
|
||||
fabs( cur_vec[2] ) > conf )
|
||||
{
|
||||
Standard_Real cur = Sqrt( cur_vec[0]*cur_vec[0] + cur_vec[1]*cur_vec[1] + cur_vec[2]*cur_vec[2] );
|
||||
for( Standard_Integer k=0; k<3; k++ )
|
||||
cur_vec[k] /= cur;
|
||||
}
|
||||
|
||||
norm_vec[i-2].SetCoord(cur_vec[0], cur_vec[1], cur_vec[2]);
|
||||
|
||||
if( fabs( normal[0] ) <= conf &&
|
||||
fabs( normal[1] ) <= conf &&
|
||||
fabs( normal[2] ) <= conf )
|
||||
for( Standard_Integer k=0; k<3; k++ )
|
||||
normal[k] = cur_vec[k];
|
||||
|
||||
if( fabs( normal[0]-cur_vec[0] ) > conf ||
|
||||
fabs( normal[1]-cur_vec[1] ) > conf ||
|
||||
fabs( normal[2]-cur_vec[2] ) > conf )
|
||||
{
|
||||
res = Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
if( !res ) {
|
||||
for( j=0; j<3; j++ ) {
|
||||
normal[j] = 0.0;
|
||||
for (i = 0; i < count-2; i++)
|
||||
normal[j] += norm_vec[i].Coord(j+1);
|
||||
normal[j] /= (count-2);
|
||||
}
|
||||
}
|
||||
delete [] norm_vec;
|
||||
|
||||
Norm.SetCoord( normal[0], normal[1], normal[2] );
|
||||
|
||||
return res;
|
||||
}
|
110
src/MeshVS/MeshVS_TwoColors.cxx
Executable file
110
src/MeshVS/MeshVS_TwoColors.cxx
Executable file
@@ -0,0 +1,110 @@
|
||||
// File: MeshVS_TwoColors.hxx
|
||||
// Created: Wed Oct 08 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_TwoColors.hxx>
|
||||
|
||||
|
||||
//================================================================
|
||||
// Function : HashCode
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Integer HashCode ( const MeshVS_TwoColors& theKey,
|
||||
const Standard_Integer theUpper)
|
||||
{
|
||||
#define MESHPRS_HASH_BYTE(val) { \
|
||||
aHash += (val); \
|
||||
aHash += (aHash << 10); \
|
||||
aHash ^= (aHash >> 6); \
|
||||
}
|
||||
Standard_Integer aHash = 0;
|
||||
MESHPRS_HASH_BYTE (theKey.r1)
|
||||
MESHPRS_HASH_BYTE (theKey.g1)
|
||||
MESHPRS_HASH_BYTE (theKey.b1)
|
||||
MESHPRS_HASH_BYTE (theKey.r2)
|
||||
MESHPRS_HASH_BYTE (theKey.g2)
|
||||
MESHPRS_HASH_BYTE (theKey.b2)
|
||||
aHash += (aHash << 3);
|
||||
aHash ^= (aHash >> 11);
|
||||
aHash += (aHash << 15);
|
||||
return (( aHash & 0x7fffffff ) % theUpper) + 1;
|
||||
#undef MESHPRS_HASH_BYTE
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : IsEqual
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean IsEqual (const MeshVS_TwoColors& K1,
|
||||
const MeshVS_TwoColors& K2)
|
||||
{
|
||||
return (((K1.r1 * 256 + K1.g1) * 256 + K1.b1) ==
|
||||
((K2.r1 * 256 + K2.g1) * 256 + K2.b1) &&
|
||||
((K1.r2 * 256 + K1.g2) * 256 + K1.b2) ==
|
||||
((K2.r2 * 256 + K2.g2) * 256 + K2.b2));
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : operator ==
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean operator== ( const MeshVS_TwoColors& K1,
|
||||
const MeshVS_TwoColors& K2 )
|
||||
{
|
||||
return IsEqual ( K1, K2 );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : BindTwoColors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_TwoColors BindTwoColors ( const Quantity_Color& theCol1, const Quantity_Color& theCol2 )
|
||||
{
|
||||
MeshVS_TwoColors aRes;
|
||||
|
||||
aRes.r1 = unsigned ( theCol1.Red() * 255.0 );
|
||||
aRes.g1 = unsigned ( theCol1.Green() * 255.0 );
|
||||
aRes.b1 = unsigned ( theCol1.Blue() * 255.0 );
|
||||
aRes.r2 = unsigned ( theCol2.Red() * 255.0 );
|
||||
aRes.g2 = unsigned ( theCol2.Green() * 255.0 );
|
||||
aRes.b2 = unsigned ( theCol2.Blue() * 255.0 );
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : ExtractColor
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Quantity_Color ExtractColor ( MeshVS_TwoColors& theTwoColors, const Standard_Integer Index )
|
||||
{
|
||||
Quantity_Color aRes;
|
||||
Standard_Real max = 255.0;
|
||||
|
||||
if ( Index == 1 )
|
||||
aRes.SetValues ( Standard_Real (theTwoColors.r1) / max,
|
||||
Standard_Real (theTwoColors.g1) / max,
|
||||
Standard_Real (theTwoColors.b1) / max, Quantity_TOC_RGB );
|
||||
else if (Index == 2)
|
||||
aRes.SetValues ( Standard_Real (theTwoColors.r2) / max,
|
||||
Standard_Real (theTwoColors.g2) / max,
|
||||
Standard_Real (theTwoColors.b2) / max, Quantity_TOC_RGB );
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : ExtractColors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void ExtractColors ( MeshVS_TwoColors& theTwoColors, Quantity_Color& theCol1, Quantity_Color& theCol2 )
|
||||
{
|
||||
Standard_Real max = 255.0;
|
||||
theCol1.SetValues ( Standard_Real (theTwoColors.r1) / max,
|
||||
Standard_Real (theTwoColors.g1) / max,
|
||||
Standard_Real (theTwoColors.b1) / max, Quantity_TOC_RGB );
|
||||
theCol2.SetValues ( Standard_Real (theTwoColors.r2) / max,
|
||||
Standard_Real (theTwoColors.g2) / max,
|
||||
Standard_Real (theTwoColors.b2) / max, Quantity_TOC_RGB );
|
||||
}
|
41
src/MeshVS/MeshVS_TwoColors.hxx
Executable file
41
src/MeshVS/MeshVS_TwoColors.hxx
Executable file
@@ -0,0 +1,41 @@
|
||||
// File: MeshVS_TwoColors.hxx
|
||||
// Created: Wed Oct 08 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#ifndef MeshVS_TWOCOLORSHXX
|
||||
#define MeshVS_TWOCOLORSHXX
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
Standard_EXPORT typedef struct {
|
||||
unsigned int r1 : 8;
|
||||
unsigned int g1 : 8;
|
||||
unsigned int b1 : 8;
|
||||
unsigned int r2 : 8;
|
||||
unsigned int g2 : 8;
|
||||
unsigned int b2 : 8;
|
||||
} MeshVS_TwoColors;
|
||||
|
||||
|
||||
Standard_EXPORT Standard_Integer HashCode ( const MeshVS_TwoColors& theKey,
|
||||
const Standard_Integer theUpper );
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsEqual (const MeshVS_TwoColors& K1,
|
||||
const MeshVS_TwoColors& K2 );
|
||||
|
||||
Standard_EXPORT Standard_Boolean operator== ( const MeshVS_TwoColors& K1,
|
||||
const MeshVS_TwoColors& K2 );
|
||||
|
||||
Standard_EXPORT MeshVS_TwoColors BindTwoColors ( const Quantity_Color&, const Quantity_Color& );
|
||||
Standard_EXPORT Quantity_Color ExtractColor ( MeshVS_TwoColors&, const Standard_Integer );
|
||||
Standard_EXPORT void ExtractColors ( MeshVS_TwoColors&, Quantity_Color&, Quantity_Color& );
|
||||
|
||||
#endif
|
48
src/MeshVS/MeshVS_TwoNodes.hxx
Executable file
48
src/MeshVS/MeshVS_TwoNodes.hxx
Executable file
@@ -0,0 +1,48 @@
|
||||
|
||||
#ifndef __TWO_NODES_STRUCT_HEADER__
|
||||
#define __TWO_NODES_STRUCT_HEADER__
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
//! Structure containing two IDs (of nodes) for using as a key in a map
|
||||
//! (as representation of a mesh link)
|
||||
//!
|
||||
struct MeshVS_TwoNodes
|
||||
{
|
||||
Standard_Integer First, Second;
|
||||
|
||||
MeshVS_TwoNodes (Standard_Integer aFirst=0, Standard_Integer aSecond=0)
|
||||
: First(aFirst), Second(aSecond) {}
|
||||
};
|
||||
|
||||
//================================================================
|
||||
// Function : HashCode
|
||||
// Purpose :
|
||||
//================================================================
|
||||
|
||||
inline Standard_Integer HashCode( const MeshVS_TwoNodes& obj,
|
||||
const Standard_Integer Upper )
|
||||
{
|
||||
// symmetrical with respect to obj.First and obj.Second
|
||||
const Standard_Integer aKey = obj.First + obj.Second;
|
||||
return HashCode (aKey, Upper);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : operator ==
|
||||
// Purpose :
|
||||
//================================================================
|
||||
|
||||
inline Standard_Boolean operator==( const MeshVS_TwoNodes& obj1,
|
||||
const MeshVS_TwoNodes& obj2 )
|
||||
{
|
||||
return ( ( obj1.First == obj2.First ) && ( obj1.Second == obj2.Second ) ) ||
|
||||
( ( obj1.First == obj2.Second ) && ( obj1.Second == obj2.First ) );
|
||||
}
|
||||
|
||||
#endif
|
124
src/MeshVS/MeshVS_VectorPrsBuilder.cdl
Executable file
124
src/MeshVS/MeshVS_VectorPrsBuilder.cdl
Executable file
@@ -0,0 +1,124 @@
|
||||
-- File : MeshVS_VectorPrsBuilder.cdl
|
||||
-- Created : 13 October 2003
|
||||
-- Author : Alexander SOLOVYOV
|
||||
---Copyright: Open CASCADE 2003
|
||||
|
||||
class VectorPrsBuilder from MeshVS inherits PrsBuilder from MeshVS
|
||||
|
||||
---Purpose: This class provides methods to create vector data presentation.
|
||||
-- It store map of vectors assigned with nodes or elements.
|
||||
-- In simplified mode vectors draws with thickened ends instead of arrows
|
||||
|
||||
uses
|
||||
Real from Standard,
|
||||
Boolean from Standard,
|
||||
Integer from Standard,
|
||||
|
||||
Color from Quantity,
|
||||
|
||||
Presentation from Prs3d,
|
||||
|
||||
Trsf from gp,
|
||||
Pnt from gp,
|
||||
Vec from gp,
|
||||
|
||||
ArrayOfPrimitives from Graphic3d,
|
||||
|
||||
Array1OfPnt from TColgp,
|
||||
|
||||
Mesh from MeshVS,
|
||||
MeshPtr from MeshVS,
|
||||
DataSource from MeshVS,
|
||||
DisplayModeFlags from MeshVS,
|
||||
DataMapOfIntegerVector from MeshVS,
|
||||
BuilderPriority from MeshVS,
|
||||
PackedMapOfInteger from TColStd
|
||||
|
||||
is
|
||||
|
||||
Create ( Parent : Mesh from MeshVS;
|
||||
MaxLength : Real;
|
||||
VectorColor : Color from Quantity;
|
||||
Flags : DisplayModeFlags from MeshVS = MeshVS_DMF_VectorDataPrs;
|
||||
DS : DataSource from MeshVS = 0;
|
||||
Id : Integer = -1;
|
||||
Priority : BuilderPriority from MeshVS = MeshVS_BP_Vector;
|
||||
IsSimplePrs : Boolean = Standard_False ) returns mutable VectorPrsBuilder from MeshVS;
|
||||
|
||||
Build ( me; Prs : Presentation from Prs3d;
|
||||
IDs : PackedMapOfInteger;
|
||||
IDsToExclude : in out PackedMapOfInteger;
|
||||
IsElement : Boolean;
|
||||
theDisplayMode : Integer ) is virtual;
|
||||
---Purpose: Builds vector data presentation
|
||||
|
||||
|
||||
DrawVector ( me; theTrsf : Trsf from gp;
|
||||
Length : Real;
|
||||
MaxLength : Real;
|
||||
ArrowPoints : Array1OfPnt from TColgp;
|
||||
Lines : ArrayOfPrimitives from Graphic3d;
|
||||
ArrowLines : ArrayOfPrimitives from Graphic3d;
|
||||
Triangles : ArrayOfPrimitives from Graphic3d );
|
||||
---Purpose: Adds to array of polygons and polylines some primitive representing single vector
|
||||
|
||||
calculateArrow ( myclass; Points : out Array1OfPnt from TColgp;
|
||||
Length : Real;
|
||||
ArrowPart : Real ) returns Real;
|
||||
---Purpose: Calculates points of arrow presentation
|
||||
|
||||
GetVectors ( me; IsElement : Boolean ) returns DataMapOfIntegerVector from MeshVS;
|
||||
---C++: return const &
|
||||
---Purpose: Returns map of vectors assigned with nodes or elements
|
||||
|
||||
SetVectors ( me : mutable;
|
||||
IsElement : Boolean;
|
||||
Map : DataMapOfIntegerVector from MeshVS );
|
||||
---Purpose: Sets map of vectors assigned with nodes or elements
|
||||
|
||||
HasVectors ( me; IsElement : Boolean ) returns Boolean;
|
||||
---Purpose: Returns true, if map isn't empty
|
||||
|
||||
GetVector ( me; IsElement : Boolean;
|
||||
ID : Integer;
|
||||
Vect : out Vec from gp ) returns Boolean;
|
||||
---Purpose: Returns vector assigned with certain node or element
|
||||
|
||||
SetVector ( me : mutable;
|
||||
IsElement : Boolean;
|
||||
ID : Integer;
|
||||
Vect : Vec from gp );
|
||||
---Purpose: Sets vector assigned with certain node or element
|
||||
|
||||
GetMinMaxVectorValue ( me; IsElement : Boolean;
|
||||
MinValue : out Real;
|
||||
MaxValue : out Real );
|
||||
---Purpose: Calculates minimal and maximal length of vectors in map
|
||||
-- ( nodal, if IsElement = False or elemental, if IsElement = True )
|
||||
|
||||
SetSimplePrsMode ( me : mutable;
|
||||
IsSimpleArrow : Boolean );
|
||||
---Purpose: Sets flag that indicates is simple vector arrow mode uses or not
|
||||
-- default value is False
|
||||
|
||||
SetSimplePrsParams ( me : mutable;
|
||||
theLineWidthParam : Real;
|
||||
theStartParam, theEndParam : Real );
|
||||
---Purpose: Sets parameters of simple vector arrwo presentation
|
||||
-- theLineWidthParam - coefficient of vector line width (to draw line instead of arrow)
|
||||
-- theStartParam and theEndParam parameters of start and end of thickened ends
|
||||
-- position of thickening calculates according to parameters and maximum vector length
|
||||
-- default values are:
|
||||
-- theLineWidthParam = 2.5
|
||||
-- theStartParam = 0.85
|
||||
-- theEndParam = 0.95
|
||||
|
||||
fields
|
||||
myIsSimplePrs : Boolean;
|
||||
mySimpleWidthPrm : Real;
|
||||
mySimpleStartPrm : Real;
|
||||
mySimpleEndPrm : Real;
|
||||
myNodeVectorMap : DataMapOfIntegerVector from MeshVS;
|
||||
myElemVectorMap : DataMapOfIntegerVector from MeshVS;
|
||||
|
||||
end VectorPrsBuilder;
|
469
src/MeshVS/MeshVS_VectorPrsBuilder.cxx
Executable file
469
src/MeshVS/MeshVS_VectorPrsBuilder.cxx
Executable file
@@ -0,0 +1,469 @@
|
||||
// File: MeshVS_VectorPrsBuilder.cxx
|
||||
// Created: Fri Sep 19 2003
|
||||
// Author: Alexander SOLOVYOV
|
||||
// Copyright: Open CASCADE 2003
|
||||
|
||||
#include <MeshVS_VectorPrsBuilder.ixx>
|
||||
|
||||
#include <MeshVS_DisplayModeFlags.hxx>
|
||||
|
||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||
#include <Graphic3d_ArrayOfPolygons.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangleFans.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
|
||||
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_HPackedMapOfInteger.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <gp_Ax3.hxx>
|
||||
|
||||
#include <Prs3d_Root.hxx>
|
||||
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
|
||||
#include <MeshVS_DataSource.hxx>
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_EntityType.hxx>
|
||||
#include <MeshVS_DataMapIteratorOfDataMapOfIntegerVector.hxx>
|
||||
#include <MeshVS_Buffer.hxx>
|
||||
|
||||
//================================================================
|
||||
// Function : Constructor MeshVS_VectorPrsBuilder
|
||||
// Purpose :
|
||||
//================================================================
|
||||
MeshVS_VectorPrsBuilder::MeshVS_VectorPrsBuilder ( const Handle(MeshVS_Mesh)& Parent,
|
||||
const Standard_Real MaxLength,
|
||||
const Quantity_Color& VectorColor,
|
||||
const MeshVS_DisplayModeFlags& Flags,
|
||||
const Handle (MeshVS_DataSource)& DS,
|
||||
const Standard_Integer Id,
|
||||
const MeshVS_BuilderPriority& Priority,
|
||||
const Standard_Boolean IsSimplePrs )
|
||||
: MeshVS_PrsBuilder ( Parent, Flags, DS, Id, Priority ),
|
||||
myIsSimplePrs( IsSimplePrs ),
|
||||
mySimpleWidthPrm( 2.5 ),
|
||||
mySimpleStartPrm( 0.85 ),
|
||||
mySimpleEndPrm( 0.95 )
|
||||
{
|
||||
Handle ( MeshVS_Drawer ) aDrawer = GetDrawer();
|
||||
if ( !aDrawer.IsNull() )
|
||||
{
|
||||
aDrawer->SetDouble ( MeshVS_DA_VectorMaxLength, MaxLength );
|
||||
aDrawer->SetColor ( MeshVS_DA_VectorColor, VectorColor );
|
||||
aDrawer->SetDouble ( MeshVS_DA_VectorArrowPart, 0.1 );
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetVectors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
const MeshVS_DataMapOfIntegerVector& MeshVS_VectorPrsBuilder::GetVectors
|
||||
( const Standard_Boolean IsElements ) const
|
||||
{
|
||||
if ( IsElements )
|
||||
return myElemVectorMap;
|
||||
else
|
||||
return myNodeVectorMap;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetVectors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_VectorPrsBuilder::SetVectors ( const Standard_Boolean IsElements,
|
||||
const MeshVS_DataMapOfIntegerVector& theMap )
|
||||
{
|
||||
if ( IsElements )
|
||||
myElemVectorMap = theMap;
|
||||
else
|
||||
myNodeVectorMap = theMap;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : HasVectors
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_VectorPrsBuilder::HasVectors ( const Standard_Boolean IsElement ) const
|
||||
{
|
||||
Standard_Boolean aRes = (myNodeVectorMap.Extent()>0);
|
||||
if ( IsElement )
|
||||
aRes = (myElemVectorMap.Extent()>0);
|
||||
return aRes;
|
||||
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetVector
|
||||
// Purpose :
|
||||
//================================================================
|
||||
Standard_Boolean MeshVS_VectorPrsBuilder::GetVector ( const Standard_Boolean IsElement,
|
||||
const Standard_Integer ID,
|
||||
gp_Vec& Vect ) const
|
||||
{
|
||||
const MeshVS_DataMapOfIntegerVector* aMap = &myNodeVectorMap;
|
||||
if ( IsElement )
|
||||
aMap = &myElemVectorMap;
|
||||
|
||||
Standard_Boolean aRes = aMap->IsBound ( ID );
|
||||
if ( aRes )
|
||||
Vect = aMap->Find ( ID );
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : SetVector
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_VectorPrsBuilder::SetVector ( const Standard_Boolean IsElement,
|
||||
const Standard_Integer ID,
|
||||
const gp_Vec& Vect )
|
||||
{
|
||||
MeshVS_DataMapOfIntegerVector* aMap = &myNodeVectorMap;
|
||||
if ( IsElement )
|
||||
aMap = &myElemVectorMap;
|
||||
|
||||
Standard_Boolean aRes = aMap->IsBound ( ID );
|
||||
if ( aRes )
|
||||
aMap->ChangeFind ( ID ) = Vect;
|
||||
else
|
||||
aMap->Bind ( ID, Vect );
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : GetMaxVectorValue
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_VectorPrsBuilder::GetMinMaxVectorValue ( const Standard_Boolean IsElement,
|
||||
Standard_Real& MinValue,
|
||||
Standard_Real& MaxValue ) const
|
||||
{
|
||||
const MeshVS_DataMapOfIntegerVector* aMap = &myNodeVectorMap;
|
||||
if ( IsElement )
|
||||
aMap = &myElemVectorMap;
|
||||
|
||||
MeshVS_DataMapIteratorOfDataMapOfIntegerVector anIt ( *aMap );
|
||||
if ( anIt.More() )
|
||||
MinValue = MaxValue = anIt.Value().Magnitude();
|
||||
|
||||
Standard_Real aCurValue;
|
||||
|
||||
for ( ; anIt.More(); anIt.Next() )
|
||||
{
|
||||
aCurValue = anIt.Value().Magnitude();
|
||||
if ( MinValue > aCurValue )
|
||||
MinValue = aCurValue;
|
||||
if ( MaxValue < aCurValue )
|
||||
MaxValue = aCurValue;
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Build
|
||||
// Purpose :
|
||||
//================================================================
|
||||
|
||||
#define NB_VERTICES 2
|
||||
#define NB_BOUNDS 1
|
||||
#define NB_TRIANGLES 6
|
||||
#define NB_FANS 1
|
||||
|
||||
void MeshVS_VectorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
|
||||
const TColStd_PackedMapOfInteger& IDs,
|
||||
TColStd_PackedMapOfInteger& IDsToExclude,
|
||||
const Standard_Boolean IsElement,
|
||||
const Standard_Integer theDisplayMode ) const
|
||||
{
|
||||
Handle ( MeshVS_Drawer ) aDrawer = GetDrawer();
|
||||
Handle (MeshVS_DataSource) aSource = GetDataSource();
|
||||
if ( aSource.IsNull() || aDrawer.IsNull() || !HasVectors( IsElement ) ||
|
||||
( theDisplayMode & GetFlags() )==0 )
|
||||
return;
|
||||
|
||||
Standard_Integer aMaxFaceNodes;
|
||||
Standard_Real aMaxLen, anArrowPart = 0.1;
|
||||
|
||||
if ( !aDrawer->GetInteger ( MeshVS_DA_MaxFaceNodes, aMaxFaceNodes ) ||
|
||||
aMaxFaceNodes <= 0 ||
|
||||
!aDrawer->GetDouble ( MeshVS_DA_VectorMaxLength, aMaxLen ) ||
|
||||
aMaxLen <= 0 ||
|
||||
!aDrawer->GetDouble ( MeshVS_DA_VectorArrowPart, anArrowPart ) ||
|
||||
anArrowPart <= 0
|
||||
)
|
||||
return;
|
||||
|
||||
MeshVS_Buffer aCoordsBuf (3*aMaxFaceNodes*sizeof(Standard_Real));
|
||||
TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3*aMaxFaceNodes);
|
||||
Standard_Integer NbNodes;
|
||||
MeshVS_EntityType aType;
|
||||
|
||||
// DECLARE ARRAYS OF PRIMITIVES
|
||||
const MeshVS_DataMapOfIntegerVector& aMap = GetVectors ( IsElement );
|
||||
Standard_Integer aNbVectors = aMap.Extent();
|
||||
|
||||
if ( aNbVectors <= 0 )
|
||||
return;
|
||||
|
||||
// polylines
|
||||
Standard_Integer aNbVertices = aNbVectors * NB_VERTICES;
|
||||
Standard_Integer aNbBounds = aNbVectors * NB_BOUNDS;
|
||||
|
||||
// fans
|
||||
Standard_Integer aNbTriangleVertices = aNbVectors * (NB_TRIANGLES + 2);
|
||||
Standard_Integer aNbFans = aNbVectors * NB_TRIANGLES;
|
||||
|
||||
Handle(Graphic3d_ArrayOfPrimitives) aLineArray =
|
||||
new Graphic3d_ArrayOfPolylines(aNbVertices, aNbBounds);
|
||||
Handle(Graphic3d_ArrayOfPrimitives) aArrowLineArray =
|
||||
new Graphic3d_ArrayOfPolylines(aNbVertices, aNbBounds);
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangleFans) aTriangleArray =
|
||||
new Graphic3d_ArrayOfTriangleFans(aNbTriangleVertices, aNbFans);
|
||||
|
||||
TColgp_Array1OfPnt anArrowPnt(1,8);
|
||||
Standard_Real k, b, aMaxValue, aMinValue, aValue, X, Y, Z;
|
||||
|
||||
Standard_Real aMinLength = calculateArrow( anArrowPnt, aMaxLen, anArrowPart );
|
||||
gp_Vec aVec; gp_Trsf aTrsf;
|
||||
|
||||
GetMinMaxVectorValue ( IsElement, aMinValue, aMaxValue );
|
||||
|
||||
if ( aMaxValue - aMinValue > Precision::Confusion() )
|
||||
{
|
||||
k = 0.8 * aMaxLen / ( aMaxValue - aMinValue );
|
||||
b = aMaxLen - k * aMaxValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
k = 0;
|
||||
b = aMaxLen;
|
||||
}
|
||||
|
||||
TColStd_PackedMapOfInteger aCustomElements;
|
||||
|
||||
// subtract the hidden elements and ids to exclude (to minimise allocated memory)
|
||||
TColStd_PackedMapOfInteger anIDs;
|
||||
anIDs.Assign( IDs );
|
||||
if ( IsElement )
|
||||
{
|
||||
Handle(TColStd_HPackedMapOfInteger) aHiddenElems = myParentMesh->GetHiddenElems();
|
||||
if ( !aHiddenElems.IsNull() )
|
||||
anIDs.Subtract( aHiddenElems->Map() );
|
||||
}
|
||||
anIDs.Subtract( IDsToExclude );
|
||||
|
||||
TColStd_MapIteratorOfPackedMapOfInteger it (anIDs);
|
||||
for( ; it.More(); it.Next() )
|
||||
{
|
||||
Standard_Integer aKey = it.Key();
|
||||
if( GetVector ( IsElement, aKey, aVec ) )
|
||||
{
|
||||
aValue = aVec.Magnitude();
|
||||
|
||||
if ( Abs( aValue ) < Precision::Confusion() )
|
||||
continue;
|
||||
|
||||
if( aSource->GetGeom ( aKey, IsElement, aCoords, NbNodes, aType ) )
|
||||
{
|
||||
if( aType == MeshVS_ET_Node )
|
||||
{
|
||||
X = aCoords(1);
|
||||
Y = aCoords(2);
|
||||
Z = aCoords(3);
|
||||
}
|
||||
else if( aType == MeshVS_ET_Link ||
|
||||
aType == MeshVS_ET_Face ||
|
||||
aType == MeshVS_ET_Volume )
|
||||
{
|
||||
if( IsElement && IsExcludingOn() )
|
||||
IDsToExclude.Add( aKey );
|
||||
X = Y = Z = 0;
|
||||
for ( Standard_Integer i=1; i<=NbNodes; i++ )
|
||||
{
|
||||
X += aCoords (3*i-2);
|
||||
Y += aCoords (3*i-1);
|
||||
Z += aCoords (3*i);
|
||||
}
|
||||
X /= Standard_Real ( NbNodes );
|
||||
Y /= Standard_Real ( NbNodes );
|
||||
Z /= Standard_Real ( NbNodes );
|
||||
}
|
||||
else
|
||||
{
|
||||
aCustomElements.Add( aKey );
|
||||
continue;
|
||||
}
|
||||
|
||||
aTrsf.SetDisplacement ( gp_Ax3 ( gp_Pnt ( 0, 0, 0 ), gp_Dir(0, 0, 1)),
|
||||
gp_Ax3 ( gp_Pnt ( X, Y, Z ), aVec ) );
|
||||
|
||||
DrawVector ( aTrsf, Max( k * fabs( aValue ) + b, aMinLength), aMaxLen,
|
||||
anArrowPnt, aLineArray, aArrowLineArray, aTriangleArray );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle (Graphic3d_Group) aVGroup = Prs3d_Root::CurrentGroup ( Prs );
|
||||
|
||||
Quantity_Color aColor;
|
||||
aDrawer->GetColor ( MeshVS_DA_VectorColor, aColor );
|
||||
|
||||
// Add primitive arrays to group
|
||||
Handle(Graphic3d_AspectLine3d) aLinAspect =
|
||||
new Graphic3d_AspectLine3d ( aColor, Aspect_TOL_SOLID, 1.5 );
|
||||
|
||||
aVGroup->SetPrimitivesAspect( aLinAspect );
|
||||
|
||||
aVGroup->BeginPrimitives();
|
||||
aVGroup->AddPrimitiveArray( aLineArray );
|
||||
aVGroup->EndPrimitives();
|
||||
if ( !myIsSimplePrs )
|
||||
{
|
||||
Graphic3d_MaterialAspect aMatAspect;
|
||||
aMatAspect.SetAmbient( 1 );
|
||||
aMatAspect.SetDiffuse( 0 );
|
||||
aMatAspect.SetEmissive( 0 );
|
||||
aMatAspect.SetShininess( 1 );
|
||||
aMatAspect.SetSpecular( 0 );
|
||||
Handle(Graphic3d_AspectFillArea3d) aFillAspect =
|
||||
new Graphic3d_AspectFillArea3d (Aspect_IS_HOLLOW, aColor, aColor, Aspect_TOL_SOLID,
|
||||
1., aMatAspect, aMatAspect );
|
||||
|
||||
aVGroup->SetPrimitivesAspect( aFillAspect );
|
||||
|
||||
aVGroup->BeginPrimitives();
|
||||
aVGroup->AddPrimitiveArray( aTriangleArray );
|
||||
aVGroup->EndPrimitives();
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle(Graphic3d_AspectLine3d) anArrowLinAspect =
|
||||
new Graphic3d_AspectLine3d ( aColor, Aspect_TOL_SOLID, mySimpleWidthPrm * 1.5 );
|
||||
|
||||
aVGroup->SetPrimitivesAspect( anArrowLinAspect );
|
||||
|
||||
aVGroup->BeginPrimitives();
|
||||
aVGroup->AddPrimitiveArray( aArrowLineArray );
|
||||
aVGroup->EndPrimitives();
|
||||
}
|
||||
|
||||
if( !aCustomElements.IsEmpty() )
|
||||
CustomBuild( Prs, aCustomElements, IDsToExclude, theDisplayMode );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : DrawVector
|
||||
// Purpose : Fill arrays of primitives for drawing force
|
||||
//=======================================================================
|
||||
void MeshVS_VectorPrsBuilder::DrawVector ( const gp_Trsf& theTrsf,
|
||||
const Standard_Real Length,
|
||||
const Standard_Real MaxLength,
|
||||
const TColgp_Array1OfPnt& ArrowPoints,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& Lines,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& ArrowLines,
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& Triangles) const
|
||||
{
|
||||
const int PntNum = 8;
|
||||
|
||||
const Standard_Real aMinLength = MaxLength * ( 1 - mySimpleStartPrm );
|
||||
const Standard_Real aLocalLength = ( !myIsSimplePrs || Length > aMinLength ? Length : aMinLength );
|
||||
// draw line
|
||||
gp_Pnt aLinePnt[ 2 ] = { gp_Pnt( 0, 0, 0 ) , gp_Pnt( 0, 0, aLocalLength ) };
|
||||
theTrsf.Transforms( aLinePnt[ 0 ].ChangeCoord() );
|
||||
theTrsf.Transforms( aLinePnt[ 1 ].ChangeCoord() );
|
||||
|
||||
Lines->AddBound( 2 );
|
||||
Lines->AddVertex( aLinePnt[ 0 ] );
|
||||
Lines->AddVertex( aLinePnt[ 1 ] );
|
||||
|
||||
// draw arrow
|
||||
if ( !myIsSimplePrs )
|
||||
{
|
||||
Standard_Integer l = ArrowPoints.Lower(),
|
||||
u = ArrowPoints.Upper(),
|
||||
i;
|
||||
if ( u-l < PntNum-1 )
|
||||
return;
|
||||
|
||||
TColgp_Array1OfPnt anArrowPnt( l, u );
|
||||
for ( i = l; i < l+PntNum; i++ )
|
||||
{
|
||||
anArrowPnt( i ).ChangeCoord() = ArrowPoints ( i ).Coord() + gp_XYZ( 0, 0, aLocalLength );
|
||||
theTrsf.Transforms( anArrowPnt( i ).ChangeCoord() );
|
||||
}
|
||||
|
||||
Triangles->AddBound(8);
|
||||
for ( i = 0; i < PntNum; i++ )
|
||||
Triangles->AddVertex( anArrowPnt( l+i ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
const Standard_Real aEndPos = aLocalLength - MaxLength * ( 1 - mySimpleEndPrm );
|
||||
const Standard_Real aArrowLength = MaxLength * ( mySimpleEndPrm - mySimpleStartPrm );
|
||||
gp_Pnt aArrowPnt[ 2 ] = { gp_Pnt( 0, 0, aEndPos - aArrowLength ),
|
||||
gp_Pnt( 0, 0, aEndPos ) };
|
||||
theTrsf.Transforms( aArrowPnt[ 0 ].ChangeCoord() );
|
||||
theTrsf.Transforms( aArrowPnt[ 1 ].ChangeCoord() );
|
||||
|
||||
ArrowLines->AddBound( 2 );
|
||||
ArrowLines->AddVertex( aArrowPnt[ 0 ] );
|
||||
ArrowLines->AddVertex( aArrowPnt[ 1 ] );
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : calculateArrow
|
||||
// Purpose : Calculate points of arrow ( 8 pnts )
|
||||
//=======================================================================
|
||||
Standard_Real MeshVS_VectorPrsBuilder::calculateArrow ( TColgp_Array1OfPnt& Points,
|
||||
const Standard_Real Length,
|
||||
const Standard_Real ArrowPart )
|
||||
{
|
||||
Standard_Real h = Length * ArrowPart;
|
||||
Standard_Real w = h / 5.;
|
||||
|
||||
Standard_Integer f = Points.Lower();
|
||||
Points( f ) = gp_Pnt( 0, 0, 0 );
|
||||
Points( f+1 ) = gp_Pnt( 0, -w, -h );
|
||||
Points( f+2 ) = gp_Pnt( w * 0.866, -w * 0.5, -h );
|
||||
Points( f+3 ) = gp_Pnt( w * 0.866, w * 0.5, -h );
|
||||
Points( f+4 ) = gp_Pnt( 0 , w, -h );
|
||||
Points( f+5 ) = gp_Pnt( -w * 0.866, w * 0.5, -h );
|
||||
Points( f+6 ) = gp_Pnt( -w * 0.866, -w * 0.5, -h );
|
||||
Points( f+7 ) = gp_Pnt( 0, -w, -h );
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : SetSimplePrsMode
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
void MeshVS_VectorPrsBuilder::SetSimplePrsMode( const Standard_Boolean IsSimpleArrow )
|
||||
{
|
||||
myIsSimplePrs = IsSimpleArrow;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// name : SetSimplePrsParams
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
void MeshVS_VectorPrsBuilder::SetSimplePrsParams( const Standard_Real theLineWidthParam,
|
||||
const Standard_Real theStartParam,
|
||||
const Standard_Real theEndParam )
|
||||
{
|
||||
mySimpleWidthPrm = theLineWidthParam;
|
||||
mySimpleStartPrm = theStartParam;
|
||||
mySimpleEndPrm = theEndParam;
|
||||
}
|
Reference in New Issue
Block a user