// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-
#include <AIS_ConnectedInteractive.hxx>
+
#include <AIS_InteractiveContext.hxx>
-#include <AIS_InteractiveObject.hxx>
#include <AIS_Shape.hxx>
#include <BRepTools.hxx>
-#include <Geom_Transformation.hxx>
-#include <gp_Trsf.hxx>
#include <NCollection_DataMap.hxx>
#include <Precision.hxx>
#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
#include <Prs3d_Projector.hxx>
#include <PrsMgr_ModedPresentation.hxx>
-#include <PrsMgr_Presentation.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
}
//=======================================================================
-//function : Connect
-//purpose :
+//function : connect
+//purpose :
//=======================================================================
-void AIS_ConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj)
+void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
+ const Handle(Geom_Transformation)& theLocation)
{
- if (myReference == theAnotherObj) return;
+ if (myReference == theAnotherObj)
+ {
+ setLocalTransformation (theLocation);
+ return;
+ }
Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (theAnotherObj);
if (!aConnected.IsNull())
{
myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
}
+ setLocalTransformation (theLocation);
}
-//=======================================================================
-//function : Connect
-//purpose :
-//=======================================================================
-void AIS_ConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
- const gp_Trsf& theLocation)
-{
- Connect (theAnotherObj);
-
- SetLocalTransformation (theLocation);
-}
-
-
//=======================================================================
//function : Disconnect
//purpose :
#ifndef _AIS_ConnectedInteractive_HeaderFile
#define _AIS_ConnectedInteractive_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <TopoDS_Shape.hxx>
#include <AIS_InteractiveObject.hxx>
-#include <PrsMgr_TypeOfPresentation3d.hxx>
#include <AIS_KindOfInteractive.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Boolean.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
-#include <SelectMgr_Selection.hxx>
-class AIS_InteractiveObject;
-class Standard_NotImplemented;
-class gp_Trsf;
-class Prs3d_Presentation;
-class Prs3d_Projector;
-class Geom_Transformation;
-class TopoDS_Shape;
-
-
-class AIS_ConnectedInteractive;
-DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject)
+#include <TopoDS_Shape.hxx>
//! Creates an arbitrary located instance of another Interactive Object,
//! which serves as a reference.
//! Also ConnectedInteractive will handle HLR if its reference based on AIS_Shape.
class AIS_ConnectedInteractive : public AIS_InteractiveObject
{
-
+ DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
public:
//! Disconnects the previous view and sets highlight
//! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference.
- Standard_EXPORT virtual void Connect (const Handle(AIS_InteractiveObject)& anotherIObj);
+ Standard_EXPORT void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { connect (theAnotherObj, Handle(Geom_Transformation)()); }
//! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference.
//! Locates instance in aLocation.
- Standard_EXPORT virtual void Connect (const Handle(AIS_InteractiveObject)& anotherIobj, const gp_Trsf& aLocation);
+ Standard_EXPORT void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
+ const gp_Trsf& theLocation) { connect (theAnotherObj, new Geom_Transformation (theLocation)); }
+
+ //! Establishes the connection between the Connected
+ //! Interactive Object, anotherIobj, and its reference.
+ //! Locates instance in aLocation.
+ Standard_EXPORT void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
+ const Handle(Geom_Transformation)& theLocation) { connect (theAnotherObj, theLocation); }
//! Returns true if there is a connection established
//! between the presentation and its source reference.
|| myReference->AcceptDisplayMode (theMode);
}
- DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive,AIS_InteractiveObject)
-
protected:
//! Calculates the view aPresentation and its updates.
//! given by <aProjector>.
Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation, const TopoDS_Shape& aShape);
+ Standard_EXPORT void connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
+ const Handle(Geom_Transformation)& theLocation);
+
protected:
Handle(AIS_InteractiveObject) myReference;
};
+DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject)
+
#endif // _AIS_ConnectedInteractive_HeaderFile
aTrsf.SetTransformation (gp_Ax2 (gp::Origin(), aVDir, aXDir), gp::XOY());
}
- AIS_InteractiveObject::SetLocalTransformation (aTrsf);
-
- Handle(Geom_Transformation) aGeomTrsf = new Geom_Transformation (this->Transformation());
-
+ Handle(Geom_Transformation) aGeomTrsf = new Geom_Transformation (aTrsf);
+ // we explicitly call here setLocalTransformation() of the base class
+ // since AIS_Manipulator::setLocalTransformation() implementation throws exception
+ // as protection from external calls
+ AIS_InteractiveObject::setLocalTransformation (aGeomTrsf);
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
myAxes[anIt].Transform (aGeomTrsf);
}
//=======================================================================
-//function : SetLocalTransformation
-//purpose :
+//function : setLocalTransformation
+//purpose :
//=======================================================================
-void AIS_Manipulator::SetLocalTransformation (const gp_Trsf& /*theTransformation*/)
+void AIS_Manipulator::setLocalTransformation (const Handle(Geom_Transformation)& /*theTrsf*/)
{
- Standard_ASSERT_INVOKE (
- "AIS_Manipulator::SetLocalTransformation: "
- "Custom transformation is not supported by this class");
+ Standard_ASSERT_INVOKE ("AIS_Manipulator::setLocalTransformation: "
+ "Custom transformation is not supported by this class");
}
//=======================================================================
//! when enabling zoom persistence.
Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) Standard_OVERRIDE;
- //! Redefines local transformation management method to inform user of inproper use.
- //! @warning this interactive object does not support setting custom local transformation,
- //! this class solely uses this property to implement visual positioning of the manipulator
- //! without need for recomputing presentation.
- //! @warning Invokes debug assertion in debug to catch incompatible usage of the
- //! method, silently does nothing in release mode.
- Standard_EXPORT virtual void SetLocalTransformation (const gp_Trsf& theTransformation) Standard_OVERRIDE;
-
public: //! @name Setters for parameters
AIS_ManipulatorMode ActiveMode() const { return myCurrentMode; }
Standard_EXPORT void setTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
+ //! Redefines local transformation management method to inform user of inproper use.
+ //! @warning this interactive object does not support setting custom local transformation,
+ //! this class solely uses this property to implement visual positioning of the manipulator
+ //! without need for recomputing presentation.
+ //! @warning Invokes debug assertion in debug to catch incompatible usage of the
+ //! method, silently does nothing in release mode.
+ Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
+ using AIS_InteractiveObject::SetLocalTransformation; // hide visibility
+
protected: //! @name Auxilliary classes to fill presentation with proper primitives
class Quadric
{
if (!myHighlightTranslator.IsNull())
{
- myHighlightTranslator->Transform (theTransformation);
+ myHighlightTranslator->SetTransformation (theTransformation);
}
if (!myHighlightScaler.IsNull())
{
- myHighlightScaler->Transform (theTransformation);
+ myHighlightScaler->SetTransformation (theTransformation);
}
if (!myHighlightRotator.IsNull())
{
- myHighlightRotator->Transform (theTransformation);
+ myHighlightRotator->SetTransformation (theTransformation);
}
}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <AIS_MultipleConnectedInteractive.hxx>
#include <AIS_ConnectedInteractive.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
-#include <AIS_MultipleConnectedInteractive.hxx>
-#include <Geom_Transformation.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <NCollection_DataMap.hxx>
-#include <Prs3d_Presentation.hxx>
#include <Prs3d_Projector.hxx>
#include <PrsMgr_ModedPresentation.hxx>
-#include <PrsMgr_Presentation.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive,AIS_InteractiveObject)
}
//=======================================================================
-//function : Connect
+//function : connect
//purpose :
//=======================================================================
-Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
- const gp_Trsf& theTransformation,
+Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
+ const Handle(Geom_Transformation)& theTrsf,
const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
if (myAssemblyOwner.IsNull())
{
Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive();
aNewMultiConnected->myAssemblyOwner = myAssemblyOwner;
- aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformation());
+ aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformationGeom());
// Perform deep copy of instance tree
for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next())
else
{
Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive();
- aNewConnected->Connect (theAnotherObj);
- aNewConnected->SetLocalTransformation (theAnotherObj->LocalTransformation());
+ aNewConnected->Connect (theAnotherObj, theAnotherObj->LocalTransformationGeom());
anObjectToAdd = aNewConnected;
}
- anObjectToAdd->SetLocalTransformation (theTransformation);
+ anObjectToAdd->SetLocalTransformation (theTrsf);
if (!theTrsfPers.IsNull())
{
anObjectToAdd->SetTransformPersistence (theTrsfPers);
return anObjectToAdd;
}
-//=======================================================================
-//function : Connect
-//purpose :
-//=======================================================================
-Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj)
-{
- return Connect (theAnotherObj, theAnotherObj->LocalTransformation(), theAnotherObj->TransformPersistence());
-}
-
-//=======================================================================
-//function : Connect
-//purpose :
-//=======================================================================
-Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
- const gp_Trsf& theTransformation)
-{
- return Connect (theAnotherObj, theTransformation, theAnotherObj->TransformPersistence());
-}
-
//=======================================================================
//function : HasConnection
//purpose :
#ifndef _AIS_MultipleConnectedInteractive_HeaderFile
#define _AIS_MultipleConnectedInteractive_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <AIS_InteractiveObject.hxx>
-#include <Graphic3d_TransModeFlags.hxx>
#include <AIS_KindOfInteractive.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Boolean.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
-#include <SelectMgr_Selection.hxx>
-class AIS_InteractiveObject;
-class gp_Trsf;
-class gp_Pnt;
-class Prs3d_Presentation;
-class Prs3d_Projector;
-class Geom_Transformation;
-
-
-class AIS_MultipleConnectedInteractive;
-DEFINE_STANDARD_HANDLE(AIS_MultipleConnectedInteractive, AIS_InteractiveObject)
//! Defines an Interactive Object by gathering together
//! several object presentations. This is done through a
//! calculations of presentation are avoided.
class AIS_MultipleConnectedInteractive : public AIS_InteractiveObject
{
-
+ DEFINE_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive, AIS_InteractiveObject)
public:
-
//! Initializes the Interactive Object with multiple
//! connections to AIS_Interactive objects.
Standard_EXPORT AIS_MultipleConnectedInteractive();
-
- //! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
- //! Copies local transformation and transformation persistence mode from theInteractive.
- //! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
- Standard_EXPORT Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theInteractive);
-
- //! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
- //! Locates instance in theLocation and copies transformation persistence mode from theInteractive.
- //! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
- Standard_EXPORT Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theInteractive, const gp_Trsf& theLocation);
-
+
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
//! Locates instance in theLocation and applies specified transformation persistence mode.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
- Standard_EXPORT virtual Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theInteractive,
- const gp_Trsf& theLocation,
- const Handle(Graphic3d_TransformPers)& theTrsfPers);
-
- Standard_DEPRECATED("This method is deprecated - Connect() taking Graphic3d_TransformPers should be called instead")
- Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theInteractive,
- const gp_Trsf& theLocation,
- const Graphic3d_TransModeFlags& theTrsfPersFlag,
- const gp_Pnt& theTrsfPersPoint)
+ Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
+ const Handle(Geom_Transformation)& theLocation,
+ const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
- return Connect (theInteractive, theLocation, Graphic3d_TransformPers::FromDeprecatedParams (theTrsfPersFlag, theTrsfPersPoint));
+ return connect (theAnotherObj, theLocation, theTrsfPers);
}
-
+
Standard_EXPORT virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Integer Signature() const Standard_OVERRIDE;
//! children of multiple connected interactive object.
Standard_EXPORT virtual Standard_Boolean HasSelection (const Standard_Integer theMode) const Standard_OVERRIDE;
- DEFINE_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive,AIS_InteractiveObject)
+public: // short aliases to Connect() method
-protected:
+ //! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
+ //! Copies local transformation and transformation persistence mode from theInteractive.
+ //! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
+ Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj)
+ {
+ return connect (theAnotherObj, theAnotherObj->LocalTransformationGeom(), theAnotherObj->TransformPersistence());
+ }
+ //! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
+ //! Locates instance in theLocation and copies transformation persistence mode from theInteractive.
+ //! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
+ Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
+ const gp_Trsf& theLocation)
+ {
+ return connect (theAnotherObj, new Geom_Transformation (theLocation), theAnotherObj->TransformPersistence());
+ }
+
+ //! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
+ //! Locates instance in theLocation and applies specified transformation persistence mode.
+ //! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
+ Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
+ const gp_Trsf& theLocation,
+ const Handle(Graphic3d_TransformPers)& theTrsfPers)
+ {
+ return connect (theAnotherObj, new Geom_Transformation (theLocation), theTrsfPers);
+ }
+
+ Standard_DEPRECATED("This method is deprecated - Connect() taking Graphic3d_TransformPers should be called instead")
+ Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theInteractive,
+ const gp_Trsf& theLocation,
+ const Graphic3d_TransModeFlags& theTrsfPersFlag,
+ const gp_Pnt& theTrsfPersPoint)
+ {
+ return connect (theInteractive, new Geom_Transformation (theLocation), Graphic3d_TransformPers::FromDeprecatedParams (theTrsfPersFlag, theTrsfPersPoint));
+ }
+
+protected:
//! this method is redefined virtual;
//! when the instance is connected to another
//! a transformation if there's one stored.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
+ //! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
+ //! Locates instance in theLocation and applies specified transformation persistence mode.
+ //! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
+ Standard_EXPORT virtual Handle(AIS_InteractiveObject) connect (const Handle(AIS_InteractiveObject)& theInteractive,
+ const Handle(Geom_Transformation)& theLocation,
+ const Handle(Graphic3d_TransformPers)& theTrsfPers);
private:
-
//! Computes the selection for whole subtree in scene hierarchy.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
-
};
-
-
-
-
-
+DEFINE_STANDARD_HANDLE(AIS_MultipleConnectedInteractive, AIS_InteractiveObject)
#endif // _AIS_MultipleConnectedInteractive_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <AIS_Trihedron.hxx>
#include <AIS_Axis.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_Plane.hxx>
#include <AIS_Point.hxx>
-#include <AIS_Trihedron.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <DsgPrs_DatumPrs.hxx>
#include <Geom_Axis2Placement.hxx>
}
//=======================================================================
-//function : SetLocation
-//purpose :
+//function : setLocalTransformation
+//purpose :
//=======================================================================
-void AIS_Trihedron::SetLocalTransformation (const gp_Trsf& theTransformation)
+void AIS_Trihedron::setLocalTransformation (const Handle(Geom_Transformation)& theTrsf)
{
// Update location to the subshapes
Standard_Integer anIdx;
for (anIdx = 0; anIdx < 7; anIdx++)
- myShapes[anIdx]->SetLocalTransformation (theTransformation);
+ myShapes[anIdx]->SetLocalTransformation (theTrsf);
- AIS_InteractiveObject::SetLocalTransformation (theTransformation);
+ AIS_InteractiveObject::setLocalTransformation (theTrsf);
}
//=======================================================================
//! Plane to retrieve the shapes.
class AIS_Trihedron : public AIS_InteractiveObject
{
-
+ DEFINE_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
public:
//! WARNING :<aTrsf> must be applied
//! to the object to display before computation !!!
Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
-
- Standard_EXPORT void SetLocalTransformation (const gp_Trsf& theTransformation) Standard_OVERRIDE;
-
+
//! Returns index 3, selection of the planes XOY, YOZ, XOZ.
Standard_EXPORT virtual Standard_Integer Signature() const Standard_OVERRIDE;
//! Removes the non-default settings for width set in SetWidth.
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
- DEFINE_STANDARD_RTTIEXT(AIS_Trihedron,AIS_InteractiveObject)
-
protected:
-
-
+ Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
private:
-
Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-
#include <Geom_Transformation.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Ax3.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <gp_Vec.hxx>
-#include <Standard_ConstructionError.hxx>
-#include <Standard_OutOfRange.hxx>
-#include <Standard_Type.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Geom_Transformation,MMgt_TShared)
-
-typedef Geom_Transformation Transformation;
-typedef gp_Ax1 Ax1;
-typedef gp_Ax2 Ax2;
-typedef gp_Ax3 Ax3;
-typedef gp_Pnt Pnt;
-typedef gp_TrsfForm TrsfForm;
-typedef gp_Vec Vec;
+
+IMPLEMENT_STANDARD_RTTIEXT(Geom_Transformation, Standard_Transient)
Geom_Transformation::Geom_Transformation () { }
Handle(Geom_Transformation) Geom_Transformation::Copy() const {
Handle(Geom_Transformation) T;
- T = new Transformation (gpTrsf);
+ T = new Geom_Transformation (gpTrsf);
return T;
}
-
-void Geom_Transformation::SetMirror (const gp_Pnt& P) { gpTrsf.SetMirror (P); }
-
-void Geom_Transformation::SetMirror (const gp_Ax1& A1) { gpTrsf.SetMirror (A1); }
-
-void Geom_Transformation::SetMirror (const gp_Ax2& A2) { gpTrsf.SetMirror (A2);}
-
-void Geom_Transformation::SetRotation (const gp_Ax1& A1, const Standard_Real Ang) {
-
- gpTrsf.SetRotation (A1, Ang);
-}
-
-void Geom_Transformation::SetScale (const gp_Pnt& P, const Standard_Real S) {
-
- gpTrsf.SetScale (P, S);
-}
-
-
-void Geom_Transformation::SetTransformation (const gp_Ax3& ToAxis) {
-
- gpTrsf.SetTransformation (ToAxis);
-}
-
-
-void Geom_Transformation::SetTransformation (
-const gp_Ax3& FromAxis1, const gp_Ax3& ToAxis2) {
-
- gpTrsf.SetTransformation (FromAxis1, ToAxis2);
-}
-
-
-void Geom_Transformation::SetTranslation (const gp_Vec& V) {
-
- gpTrsf.SetTranslation (V);
-}
-
-
-void Geom_Transformation::SetTranslation (const gp_Pnt& P1, const gp_Pnt& P2) {
-
- gpTrsf.SetTranslation (P1, P2);
-}
-
-
-void Geom_Transformation::SetTrsf (const gp_Trsf& T) { gpTrsf = T; }
-
-Standard_Boolean Geom_Transformation::IsNegative () const {return gpTrsf.IsNegative();}
-
-TrsfForm Geom_Transformation::Form () const { return gpTrsf.Form(); }
-
-Standard_Real Geom_Transformation::ScaleFactor () const { return gpTrsf.ScaleFactor(); }
-
-const gp_Trsf& Geom_Transformation::Trsf () const { return gpTrsf; }
-
-Standard_Real Geom_Transformation::Value (const Standard_Integer Row, const Standard_Integer Col) const {
-
- return gpTrsf.Value (Row, Col);
-}
-
-
-void Geom_Transformation::Invert () { gpTrsf.Invert(); }
-
-
Handle(Geom_Transformation) Geom_Transformation::Inverted () const {
- return new Transformation (gpTrsf.Inverted());
+ return new Geom_Transformation (gpTrsf.Inverted());
}
Handle(Geom_Transformation) Geom_Transformation::Multiplied (
const Handle(Geom_Transformation)& Other) const {
- return new Transformation (gpTrsf.Multiplied (Other->Trsf()));
+ return new Geom_Transformation (gpTrsf.Multiplied (Other->Trsf()));
}
-
-void Geom_Transformation::Multiply (const Handle(Geom_Transformation)& Other) {
-
- gpTrsf.Multiply (Other->Trsf());
-}
-
-
-void Geom_Transformation::Power (const Standard_Integer N) { gpTrsf.Power (N); }
-
-
Handle(Geom_Transformation) Geom_Transformation::Powered (const Standard_Integer N) const {
gp_Trsf T = gpTrsf;
T.Power (N);
- return new Transformation (T);
+ return new Geom_Transformation (T);
}
gpTrsf.PreMultiply (Other->Trsf());
}
-
-
-void Geom_Transformation::Transforms (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const {
-
- gpTrsf.Transforms (X, Y, Z);
-}
-
#ifndef _Geom_Transformation_HeaderFile
#define _Geom_Transformation_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <gp_Trsf.hxx>
-#include <MMgt_TShared.hxx>
-#include <Standard_Real.hxx>
+#include <Standard.hxx>
#include <Standard_Boolean.hxx>
-#include <gp_TrsfForm.hxx>
#include <Standard_Integer.hxx>
-class Standard_ConstructionError;
-class Standard_OutOfRange;
-class gp_Trsf;
-class gp_Pnt;
-class gp_Ax1;
-class gp_Ax2;
-class gp_Ax3;
-class gp_Vec;
-
+#include <Standard_Real.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
-class Geom_Transformation;
-DEFINE_STANDARD_HANDLE(Geom_Transformation, MMgt_TShared)
+DEFINE_STANDARD_HANDLE(Geom_Transformation, Standard_Transient)
//! Describes how to construct the following elementary transformations
//! - translations,
//! Geom_Transformation transformations are used in
//! a context where they can be shared by several
//! objects contained inside a common data structure.
-class Geom_Transformation : public MMgt_TShared
+class Geom_Transformation : public Standard_Transient
{
-
+ DEFINE_STANDARD_RTTIEXT(Geom_Transformation, Standard_Transient)
public:
-
//! Creates an identity transformation.
Standard_EXPORT Geom_Transformation();
//! Creates a transient copy of T.
Standard_EXPORT Geom_Transformation(const gp_Trsf& T);
-
//! Makes the transformation into a symmetrical transformation
//! with respect to a point P.
//! P is the center of the symmetry.
- Standard_EXPORT void SetMirror (const gp_Pnt& P);
-
+ void SetMirror (const gp_Pnt& thePnt) { gpTrsf.SetMirror (thePnt); }
//! Makes the transformation into a symmetrical transformation
//! with respect to an axis A1.
//! A1 is the center of the axial symmetry.
- Standard_EXPORT void SetMirror (const gp_Ax1& A1);
-
+ void SetMirror (const gp_Ax1& theA1) { gpTrsf.SetMirror (theA1); }
//! Makes the transformation into a symmetrical transformation
//! with respect to a plane. The plane of the symmetry is
//! defined with the axis placement A2. It is the plane
//! (Location, XDirection, YDirection).
- Standard_EXPORT void SetMirror (const gp_Ax2& A2);
-
+ void SetMirror (const gp_Ax2& theA2) { gpTrsf.SetMirror (theA2); }
//! Makes the transformation into a rotation.
//! A1 is the axis rotation and Ang is the angular value
//! of the rotation in radians.
- Standard_EXPORT void SetRotation (const gp_Ax1& A1, const Standard_Real Ang);
-
+ void SetRotation (const gp_Ax1& theA1, const Standard_Real theAng) { gpTrsf.SetRotation (theA1, theAng); }
//! Makes the transformation into a scale. P is the center of
//! the scale and S is the scaling value.
- Standard_EXPORT void SetScale (const gp_Pnt& P, const Standard_Real S);
-
+ void SetScale (const gp_Pnt& thePnt, const Standard_Real theScale) { gpTrsf.SetScale (thePnt, theScale); }
//! Makes a transformation allowing passage from the coordinate
//! system "FromSystem1" to the coordinate system "ToSystem2".
//! T.SetTransformation (FromSystem1, ToSystem2);
//! gp_Pnt P2 = P1.Transformed (T);
//! P2.Coord (x2, y2, z2);
- Standard_EXPORT void SetTransformation (const gp_Ax3& FromSystem1, const gp_Ax3& ToSystem2);
-
+ void SetTransformation (const gp_Ax3& theFromSystem1, const gp_Ax3& theToSystem2) { gpTrsf.SetTransformation (theFromSystem1, theToSystem2); }
//! Makes the transformation allowing passage from the basic
//! coordinate system
//! to the local coordinate system defined with the Ax2 ToSystem.
//! Same utilisation as the previous method. FromSystem1 is
//! defaulted to the absolute coordinate system.
- Standard_EXPORT void SetTransformation (const gp_Ax3& ToSystem);
-
+ void SetTransformation (const gp_Ax3& theToSystem) { gpTrsf.SetTransformation (theToSystem); }
//! Makes the transformation into a translation.
//! V is the vector of the translation.
- Standard_EXPORT void SetTranslation (const gp_Vec& V);
-
+ void SetTranslation (const gp_Vec& theVec) { gpTrsf.SetTranslation (theVec); }
//! Makes the transformation into a translation from the point
//! P1 to the point P2.
- Standard_EXPORT void SetTranslation (const gp_Pnt& P1, const gp_Pnt& P2);
-
+ void SetTranslation (const gp_Pnt& P1, const gp_Pnt& P2) { gpTrsf.SetTranslation (P1, P2); }
+
//! Converts the gp_Trsf transformation T into this transformation.
- Standard_EXPORT void SetTrsf (const gp_Trsf& T);
+ void SetTrsf (const gp_Trsf& theTrsf) { gpTrsf = theTrsf; }
//! Checks whether this transformation is an indirect
//! transformation: returns true if the determinant of the
//! matrix of the vectorial part of the transformation is less than 0.
- Standard_EXPORT Standard_Boolean IsNegative() const;
+ Standard_Boolean IsNegative() const { return gpTrsf.IsNegative(); }
//! Returns the nature of this transformation as a value
//! of the gp_TrsfForm enumeration.
- Standard_EXPORT gp_TrsfForm Form() const;
-
+ gp_TrsfForm Form() const { return gpTrsf.Form(); }
+
//! Returns the scale value of the transformation.
- Standard_EXPORT Standard_Real ScaleFactor() const;
-
+ Standard_Real ScaleFactor() const { return gpTrsf.ScaleFactor(); }
//! Returns a non transient copy of <me>.
- Standard_EXPORT const gp_Trsf& Trsf() const;
-
+ const gp_Trsf& Trsf() const { return gpTrsf; }
- //! Returns the coefficients of the global matrix of tranformation.
+ //! Returns the coefficients of the global matrix of transformation.
//! It is a 3 rows X 4 columns matrix.
//!
//! Raised if Row < 1 or Row > 3 or Col < 1 or Col > 4
- //!
- //! Computes the reverse transformation.
- Standard_EXPORT Standard_Real Value (const Standard_Integer Row, const Standard_Integer Col) const;
-
+ Standard_Real Value (const Standard_Integer theRow, const Standard_Integer theCol) const { return gpTrsf.Value (theRow, theCol); }
//! Raised if the the transformation is singular. This means that
//! the ScaleFactor is lower or equal to Resolution from
//! package gp.
- Standard_EXPORT void Invert();
-
+ void Invert() { gpTrsf.Invert(); }
//! Raised if the the transformation is singular. This means that
//! the ScaleFactor is lower or equal to Resolution from
//! package gp.
Standard_EXPORT Handle(Geom_Transformation) Inverted() const;
-
//! Computes the transformation composed with Other and <me>.
//! <me> * Other.
//! Returns a new transformation
Standard_EXPORT Handle(Geom_Transformation) Multiplied (const Handle(Geom_Transformation)& Other) const;
-
//! Computes the transformation composed with Other and <me> .
//! <me> = <me> * Other.
- Standard_EXPORT void Multiply (const Handle(Geom_Transformation)& Other);
-
+ void Multiply (const Handle(Geom_Transformation)& theOther) { gpTrsf.Multiply (theOther->Trsf()); }
//! Computes the following composition of transformations
//! if N > 0 <me> * <me> * .......* <me>.
//! if N < 0 <me>.Invert() * .........* <me>.Invert()
//!
//! Raised if N < 0 and if the transformation is not inversible
- Standard_EXPORT void Power (const Standard_Integer N);
-
+ void Power (const Standard_Integer N) { gpTrsf.Power (N); }
//! Raised if N < 0 and if the transformation is not inversible
Standard_EXPORT Handle(Geom_Transformation) Powered (const Standard_Integer N) const;
-
//! Computes the matrix of the transformation composed with
//! <me> and Other. <me> = Other * <me>
Standard_EXPORT void PreMultiply (const Handle(Geom_Transformation)& Other);
-
//! Applies the transformation <me> to the triplet {X, Y, Z}.
- Standard_EXPORT void Transforms (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const;
+ void Transforms (Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const { gpTrsf.Transforms (theX, theY, theZ); }
//! Creates a new object which is a copy of this transformation.
Standard_EXPORT Handle(Geom_Transformation) Copy() const;
-
-
-
- DEFINE_STANDARD_RTTIEXT(Geom_Transformation,MMgt_TShared)
-
-protected:
-
-
-
-
private:
-
gp_Trsf gpTrsf;
-
};
-
-
-
-
-
-
#endif // _Geom_Transformation_HeaderFile
#include <Graphic3d_TransformPers.hxx>
#include <Graphic3d_Vec3.hxx>
#include <Graphic3d_ZLayerId.hxx>
+#include <Geom_Transformation.hxx>
class Graphic3d_GraphicDriver;
class Graphic3d_StructureManager;
return myGroups;
}
+ //! Return transformation.
+ const Handle(Geom_Transformation)& Transformation() const { return myTrsf; }
+
+ //! Assign transformation.
+ virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) { myTrsf = theTrsf; }
+
//! Return transformation persistence.
const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
//! Disconnect other structure to this one
virtual void Disconnect (Graphic3d_CStructure& theStructure) = 0;
- //! Synchronize structure transformation
- virtual void UpdateTransformation() = 0;
-
//! Highlight entire structure with color
virtual void HighlightWithColor (const Graphic3d_Vec3& theColor,
const Standard_Boolean theToCreate) = 0;
Quantity_Color HighlightColor;
- Graphic3d_Mat4 Transformation;
-
int ContainsFacet;
Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask
Handle(Graphic3d_GraphicDriver) myGraphicDriver;
Graphic3d_SequenceOfGroup myGroups;
Graphic3d_BndBox4f myBndBox;
+ Handle(Geom_Transformation) myTrsf;
Handle(Graphic3d_TransformPers) myTrsfPers;
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
}
else
{
- TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
- aStruct->Transform (aTrsf);
- Handle(Graphic3d_Structure) aCompStruct = aStruct->IsTransformed() ? aStruct->Compute (this, aTrsf) : aStruct->Compute (this);
+ Handle(Graphic3d_Structure) aCompStruct = aStruct->IsTransformed() ? aStruct->Compute (this, aStruct->Transformation()) : aStruct->Compute (this);
aCompStruct->SetHLRValidation (Standard_True);
const Standard_Boolean toComputeWireframe = myVisualization == Graphic3d_TOV_WIREFRAME
}
// compute + validation
- TColStd_Array2OfReal anIdent (0, 3, 0, 3);
- for (Standard_Integer aRow = 0; aRow <= 3; ++aRow)
- {
- for (Standard_Integer aCol = 0; aCol <= 3; ++aCol)
- {
- anIdent (aRow, aCol) = (aRow == aCol ? 1.0 : 0.0);
- }
- }
- TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
- theStruct->Transform (aTrsf);
-
Handle(Graphic3d_Structure) aCompStructOld = myStructsComputed.ChangeValue (anIndex);
Handle(Graphic3d_Structure) aCompStruct = aCompStructOld;
- aCompStruct->SetTransform (anIdent, Graphic3d_TOC_REPLACE);
- theStruct->IsTransformed() ? theStruct->Compute (this, aTrsf, aCompStruct)
- : theStruct->Compute (this, aCompStruct);
+ aCompStruct->SetTransformation (Handle(Geom_Transformation)());
+ theStruct->IsTransformed() ? theStruct->Compute (this, theStruct->Transformation(), aCompStruct)
+ : theStruct->Compute (this, aCompStruct);
aCompStruct->SetHLRValidation (Standard_True);
// of which type will be the computed?
// Compute + Validation
Handle(Graphic3d_Structure) aStruct;
- TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
- theStructure->Transform (aTrsf);
if (anIndex != 0)
{
- TColStd_Array2OfReal anIdent (0, 3, 0, 3);
- for (Standard_Integer ii = 0; ii <= 3; ++ii)
- {
- for (Standard_Integer jj = 0; jj <= 3; ++jj)
- {
- anIdent (ii, jj) = (ii == jj ? 1.0 : 0.0);
- }
- }
-
aStruct = myStructsComputed.Value (anIndex);
- aStruct->SetTransform (anIdent, Graphic3d_TOC_REPLACE);
+ aStruct->SetTransformation (Handle(Geom_Transformation)());
if (theStructure->IsTransformed())
{
- theStructure->Compute (this, aTrsf, aStruct);
+ theStructure->Compute (this, theStructure->Transformation(), aStruct);
}
else
{
else
{
aStruct = theStructure->IsTransformed()
- ? theStructure->Compute (this, aTrsf)
+ ? theStructure->Compute (this, theStructure->Transformation())
: theStructure->Compute (this);
}
// purpose :
// =======================================================================
void Graphic3d_CView::SetTransform (const Handle(Graphic3d_Structure)& theStructure,
- const TColStd_Array2OfReal& theTrsf)
+ const Handle(Geom_Transformation)& theTrsf)
{
const Standard_Integer anIndex = IsComputed (theStructure);
if (anIndex != 0)
// trsf is transferred only if it is :
// a translation
// a scale
- if (theTrsf (0, 1) != 0.0 || theTrsf (0, 2) != 0.0
- || theTrsf (1, 0) != 0.0 || theTrsf (1, 2) != 0.0
- || theTrsf (2, 0) != 0.0 || theTrsf (2, 1) != 0.0)
+ if (!theTrsf.IsNull()
+ && (theTrsf->Form() == gp_Translation
+ || theTrsf->Form() == gp_Scale
+ || theTrsf->Form() == gp_CompoundTrsf))
{
ReCompute (theStructure);
}
//! Transforms the structure in the view.
Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& theStructure,
- const TColStd_Array2OfReal& theTrsf);
+ const Handle(Geom_Transformation)& theTrsf);
//! Suppress the highlighting on the structure <AStructure>
//! in the view <me>.
#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx>
#include <Standard_Type.hxx>
-#include <TColStd_Array2OfReal.hxx>
#include "Graphic3d_Structure.pxx"
//=============================================================================
Standard_Boolean Graphic3d_Structure::IsTransformed() const
{
- return !myCStructure->Transformation.IsIdentity();
+ return !myCStructure->Transformation().IsNull()
+ && myCStructure->Transformation()->Form() != gp_Identity;
}
//=============================================================================
//purpose :
//=============================================================================
Handle(Graphic3d_Structure) Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ,
- const TColStd_Array2OfReal& )
+ const Handle(Geom_Transformation)& )
{
// Implemented by Presentation
return this;
//purpose :
//=============================================================================
void Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ,
- const TColStd_Array2OfReal& ,
+ const Handle(Geom_Transformation)& ,
Handle(Graphic3d_Structure)& )
{
// Implemented by Presentation
//function : SetTransform
//purpose :
//=============================================================================
-void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& theMatrix,
- const Graphic3d_TypeOfComposition theType)
+void Graphic3d_Structure::SetTransformation (const Handle(Geom_Transformation)& theTrsf)
{
if (IsDeleted()) return;
- Standard_Real valuetrsf;
- Standard_Real valueoldtrsf;
- Standard_Real valuenewtrsf;
- TColStd_Array2OfReal aNewTrsf (0, 3, 0, 3);
- TColStd_Array2OfReal aMatrix44 (0, 3, 0, 3);
-
- // Assign the new transformation in an array [0..3][0..3]
- // Avoid problems if the user has defined matrix [1..4][1..4]
- // or [3..6][-1..2] !!
- Standard_Integer lr = theMatrix.LowerRow();
- Standard_Integer ur = theMatrix.UpperRow();
- Standard_Integer lc = theMatrix.LowerCol();
- Standard_Integer uc = theMatrix.UpperCol();
+ const Standard_Boolean wasTransformed = IsTransformed();
- if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4))
+ if (!theTrsf.IsNull()
+ && theTrsf->Trsf().Form() == gp_Identity)
{
- Graphic3d_TransformError::Raise ("Transform : not a 4x4 matrix");
+ myCStructure->SetTransformation (Handle(Geom_Transformation)());
}
-
- const Standard_Boolean wasTransformed = IsTransformed();
- switch (theType)
+ else
{
- case Graphic3d_TOC_REPLACE:
- {
- // Update of CStructure
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- myCStructure->Transformation.ChangeValue (i, j) = float (theMatrix (lr + i, lc + j));
- aNewTrsf (i, j) = theMatrix (lr + i, lc + j);
- }
- }
- break;
- }
- case Graphic3d_TOC_POSTCONCATENATE:
- {
- // To simplify management of indices
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- aMatrix44 (i, j) = theMatrix (lr + i, lc + j);
- }
- }
-
- // Calculation of the product of matrices
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- aNewTrsf (i, j) = 0.0;
- for (Standard_Integer k = 0; k <= 3; ++k)
- {
- valueoldtrsf = myCStructure->Transformation.GetValue (i, k);
- valuetrsf = aMatrix44 (k, j);
- valuenewtrsf = aNewTrsf (i, j) + valueoldtrsf * valuetrsf;
- aNewTrsf (i, j) = valuenewtrsf;
- }
- }
- }
-
- // Update of CStructure
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- myCStructure->Transformation.ChangeValue (i, j) = float (aNewTrsf (i, j));
- }
- }
- break;
- }
+ myCStructure->SetTransformation (theTrsf);
}
// If transformation, no validation of hidden already calculated parts
ReCompute();
}
- myCStructure->UpdateTransformation();
- myStructureManager->SetTransform (this, aNewTrsf);
+ myStructureManager->SetTransform (this, theTrsf);
Update (true);
}
-//=============================================================================
-//function : Transform
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::Transform (TColStd_Array2OfReal& theMatrix) const
-{
-
- Standard_Integer lr = theMatrix.LowerRow ();
- Standard_Integer ur = theMatrix.UpperRow ();
- Standard_Integer lc = theMatrix.LowerCol ();
- Standard_Integer uc = theMatrix.UpperCol ();
-
- if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4))
- Graphic3d_TransformError::Raise ("Transform : not a 4x4 matrix");
-
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- theMatrix (lr + i, lc + j) = myCStructure->Transformation.GetValue (i, j);
- }
- }
-}
-
-
//=============================================================================
//function : MinMaxValues
//purpose :
aBox = aCombinedBox;
if (aBox.IsValid())
{
- TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
- Transform (aTrsf);
- TransformBoundaries (aTrsf, aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
- aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
+ if (!myCStructure->Transformation().IsNull())
+ {
+ TransformBoundaries (myCStructure->Transformation()->Trsf(),
+ aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
+ aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
+ }
// if box is still valid after transformation
if (aBox.IsValid())
//function : Transforms
//purpose :
//=============================================================================
-void Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& theTrsf,
+void Graphic3d_Structure::Transforms (const gp_Trsf& theTrsf,
const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
Standard_Real& theNewX, Standard_Real& theNewY, Standard_Real& theNewZ)
{
const Standard_Real aRL = RealLast();
const Standard_Real aRF = RealFirst();
+ theNewX = theX;
+ theNewY = theY;
+ theNewZ = theZ;
if ((theX == aRF) || (theY == aRF) || (theZ == aRF)
|| (theX == aRL) || (theY == aRL) || (theZ == aRL))
{
- theNewX = theX;
- theNewY = theY;
- theNewZ = theZ;
- }
- else
- {
- Standard_Real A, B, C, D;
- A = theTrsf (0, 0);
- B = theTrsf (0, 1);
- C = theTrsf (0, 2);
- D = theTrsf (0, 3);
- theNewX = A * theX + B * theY + C * theZ + D;
- A = theTrsf (1, 0);
- B = theTrsf (1, 1);
- C = theTrsf (1, 2);
- D = theTrsf (1, 3);
- theNewY = A * theX + B * theY + C * theZ + D;
- A = theTrsf (2, 0);
- B = theTrsf (2, 1);
- C = theTrsf (2, 2);
- D = theTrsf (2, 3);
- theNewZ = A * theX + B * theY + C * theZ + D;
+ return;
}
-}
-//=============================================================================
-//function : Transforms
-//purpose :
-//=============================================================================
-Graphic3d_Vector Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& theTrsf,
- const Graphic3d_Vector& theCoord)
-{
- Standard_Real anXYZ[3];
- Graphic3d_Structure::Transforms (theTrsf,
- theCoord.X(), theCoord.Y(), theCoord.Z(),
- anXYZ[0], anXYZ[1], anXYZ[2]);
- return Graphic3d_Vector (anXYZ[0], anXYZ[1], anXYZ[2]);
-}
-
-//=============================================================================
-//function : Transforms
-//purpose :
-//=============================================================================
-Graphic3d_Vertex Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& theTrsf,
- const Graphic3d_Vertex& theCoord)
-{
- Standard_Real anXYZ[3];
- Graphic3d_Structure::Transforms (theTrsf,
- theCoord.X(), theCoord.Y(), theCoord.Z(),
- anXYZ[0], anXYZ[1], anXYZ[2]);
- return Graphic3d_Vertex (anXYZ[0], anXYZ[1], anXYZ[2]);
+ theTrsf.Transforms (theNewX, theNewY, theNewZ);
}
//=============================================================================
//function : Transforms
//purpose :
//=============================================================================
-void Graphic3d_Structure::TransformBoundaries (const TColStd_Array2OfReal& theTrsf,
+void Graphic3d_Structure::TransformBoundaries (const gp_Trsf& theTrsf,
Standard_Real& theXMin,
Standard_Real& theYMin,
Standard_Real& theZMin,
//function : GraphicTransform
//purpose :
//=============================================================================
-void Graphic3d_Structure::GraphicTransform (const TColStd_Array2OfReal& theMatrix)
+void Graphic3d_Structure::GraphicTransform (const Handle(Geom_Transformation)& theTrsf)
{
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- myCStructure->Transformation.ChangeValue (i, j) = float (theMatrix (i, j));
- }
- }
- myCStructure->UpdateTransformation();
+ myCStructure->SetTransformation (theTrsf);
}
//=============================================================================
#include <Graphic3d_ZLayerId.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Standard_Real.hxx>
-#include <TColStd_Array2OfReal.hxx>
#include <Graphic3d_SequenceOfGroup.hxx>
#include <Graphic3d_TypeOfConnection.hxx>
#include <Graphic3d_MapOfStructure.hxx>
Standard_EXPORT virtual Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& aProjector);
//! Returns the new Structure defined for the new visualization
- Standard_EXPORT virtual Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, const TColStd_Array2OfReal& AMatrix);
+ Standard_EXPORT virtual Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
+ const Handle(Geom_Transformation)& theTrsf);
//! Returns the new Structure defined for the new visualization
Standard_EXPORT virtual void Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, Handle(Graphic3d_Structure)& aStructure);
//! Returns the new Structure defined for the new visualization
- Standard_EXPORT virtual void Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, const TColStd_Array2OfReal& AMatrix, Handle(Graphic3d_Structure)& aStructure);
-
+ Standard_EXPORT virtual void Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
+ const Handle(Geom_Transformation)& theTrsf,
+ Handle(Graphic3d_Structure)& theStructure);
+
//! Forces a new construction of the structure <me>
//! if <me> is displayed and TOS_COMPUTED.
Standard_EXPORT void ReCompute();
Standard_EXPORT Standard_Boolean HLRValidation() const;
- //! Modifies the current local modelling transformation
- //! in the structure <me>.
- //!
- //! It is defined as a 4*4 real matrix.
- //!
- //! -------------------
- //! | a11 a12 a13 t1 |
- //! | a21 a22 a23 t2 |
- //! | a31 a32 a33 t3 |
- //! | 0 0 0 1 |
- //! -------------------
- //!
- //! TypeOfComposition : TOC_REPLACE
- //! TOC_POSTCONCATENATE
- //!
- //! Then the modified Local Modelling Transformation is composed
- //! with the current Global Modelling Transformation to create a
- //! new Composite Modelling Transformation.
- //!
- //! The compose type specifies the role of the current local
- //! modelling transformation (L) in composing the new value for
- //! the current local modelling transformation (L'), which is
- //! then combined with the current global modelling transforma-
- //! tion (G) to calculate the new composite modelling transfor-
- //! mation (C).
- //!
- //! TOC_REPLACE
- //! The transformation matrix (T) replaces the value of
- //! current local modelling transformation (L).
- //!
- //! L' <- T
- //! C <- G x L'
- //!
- //! TOC_POSTCONCATENATE
- //! The current local modelling transformation (L) is multiplied
- //! by the transformation matrix (T):
- //!
- //! L' <- T x L
- //! C <- G x L'
- //!
- //! Category: Methods to manage the structure transformation
- //! Warning: Raises TransformError if the matrix is not a 4x4 matrix.
- Standard_EXPORT void SetTransform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType);
-
- //! Returns the transformation associated with
- //! the structure <me>.
- Standard_EXPORT void Transform (TColStd_Array2OfReal& AMatrix) const;
+ //! Return local transformation.
+ const Handle(Geom_Transformation)& Transformation() const { return myCStructure->Transformation(); }
+
+ //! Modifies the current local transformation
+ Standard_EXPORT void SetTransformation (const Handle(Geom_Transformation)& theTrsf);
+
+ Standard_DEPRECATED("This method is deprecated - SetTransformation() should be called instead")
+ void Transform (const Handle(Geom_Transformation)& theTrsf) { SetTransformation (theTrsf); }
//! Modifies the current transform persistence (pan, zoom or rotate)
Standard_EXPORT void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! Highlights the structure <me>.
Standard_EXPORT void GraphicHighlight (const Aspect_TypeOfHighlightMethod Method);
- Standard_EXPORT void GraphicTransform (const TColStd_Array2OfReal& AMatrix);
+ //! Internal method which sets new transformation without calling graphic manager callbacks.
+ Standard_EXPORT void GraphicTransform (const Handle(Geom_Transformation)& theTrsf);
//! Suppress the highlight for the structure <me>.
Standard_EXPORT void GraphicUnHighlight();
Standard_EXPORT void SetComputeVisual (const Graphic3d_TypeOfStructure AVisual);
- //! Transforms <X>, <Y>, <Z> with the transformation <ATrsf>.
- Standard_EXPORT static void Transforms (const TColStd_Array2OfReal& ATrsf, const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real& NewX, Standard_Real& NewY, Standard_Real& NewZ);
-
- //! Transforms <Coord> with the transformation <ATrsf>.
- Standard_EXPORT static Graphic3d_Vector Transforms (const TColStd_Array2OfReal& ATrsf, const Graphic3d_Vector& Coord);
-
- //! Transforms <Coord> with the transformation <ATrsf>.
- Standard_EXPORT static Graphic3d_Vertex Transforms (const TColStd_Array2OfReal& ATrsf, const Graphic3d_Vertex& Coord);
-
+ //! Transforms theX, theY, theZ with the transformation theTrsf.
+ Standard_EXPORT static void Transforms (const gp_Trsf& theTrsf,
+ const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
+ Standard_Real& theNewX, Standard_Real& theNewY, Standard_Real& theNewZ);
+
//! Returns the low-level structure
const Handle(Graphic3d_CStructure)& CStructure() const { return myCStructure; }
protected:
//! Transforms boundaries with <theTrsf> transformation.
- Standard_EXPORT static void TransformBoundaries (const TColStd_Array2OfReal& theTrsf, Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin, Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax);
-
+ Standard_EXPORT static void TransformBoundaries (const gp_Trsf& theTrsf,
+ Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
+ Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax);
+
//! Appends new descendant structure.
Standard_EXPORT Standard_Boolean AppendDescendant (const Standard_Address theDescendant);
// purpose :
// ========================================================================
void Graphic3d_StructureManager::SetTransform (const Handle(Graphic3d_Structure)& theStructure,
- const TColStd_Array2OfReal& theTrsf)
+ const Handle(Geom_Transformation)& theTrsf)
{
for (Graphic3d_IndexedMapOfView::Iterator aViewIt (myDefinedViews); aViewIt.More(); aViewIt.Next())
{
Standard_EXPORT virtual void Highlight (const Handle(Graphic3d_Structure)& theStructure, const Aspect_TypeOfHighlightMethod theMethod);
//! Transforms the structure.
- Standard_EXPORT virtual void SetTransform (const Handle(Graphic3d_Structure)& theStructure, const TColStd_Array2OfReal& theTrsf);
+ Standard_EXPORT virtual void SetTransform (const Handle(Graphic3d_Structure)& theStructure, const Handle(Geom_Transformation)& theTrsf);
//! Changes the display priority of the structure <AStructure>.
Standard_EXPORT virtual void ChangeDisplayPriority (const Handle(Graphic3d_Structure)& theStructure, const Standard_Integer theOldPriority, const Standard_Integer theNewPriority);
myCurrent = theNewCurrent;
}
+ //! Change current matrix.
+ typename OpenGl::MatrixType<T>::Mat4& ChangeCurrent()
+ {
+ return myCurrent;
+ }
+
//! Sets given matrix as current.
template <typename Other_t>
void SetCurrent (const typename OpenGl::MatrixType<Other_t>::Mat4& theNewCurrent)
}
// =======================================================================
-// function : UpdateTransformation
+// function : SetTransformation
// purpose :
// =======================================================================
-void OpenGl_Structure::UpdateTransformation()
+void OpenGl_Structure::SetTransformation (const Handle(Geom_Transformation)& theTrsf)
{
- const OpenGl_Mat4& aMat = Graphic3d_CStructure::Transformation;
- Standard_ShortReal aDet =
- aMat.GetValue(0, 0) * (aMat.GetValue(1, 1) * aMat.GetValue(2, 2) - aMat.GetValue(2, 1) * aMat.GetValue(1, 2)) -
- aMat.GetValue(0, 1) * (aMat.GetValue(1, 0) * aMat.GetValue(2, 2) - aMat.GetValue(2, 0) * aMat.GetValue(1, 2)) +
- aMat.GetValue(0, 2) * (aMat.GetValue(1, 0) * aMat.GetValue(2, 1) - aMat.GetValue(2, 0) * aMat.GetValue(1, 1));
-
- // Determinant of transform matrix less then 0 means that mirror transform applied.
- myIsMirrored = aDet < 0.0f;
+ myTrsf = theTrsf;
+ myIsMirrored = Standard_False;
+ if (!myTrsf.IsNull())
+ {
+ // Determinant of transform matrix less then 0 means that mirror transform applied.
+ const Standard_Real aDet = myTrsf->Value(1, 1) * (myTrsf->Value (2, 2) * myTrsf->Value (3, 3) - myTrsf->Value (3, 2) * myTrsf->Value (2, 3))
+ - myTrsf->Value(1, 2) * (myTrsf->Value (2, 1) * myTrsf->Value (3, 3) - myTrsf->Value (3, 1) * myTrsf->Value (2, 3))
+ + myTrsf->Value(1, 3) * (myTrsf->Value (2, 1) * myTrsf->Value (3, 2) - myTrsf->Value (3, 1) * myTrsf->Value (2, 2));
+ myIsMirrored = aDet < 0.0;
+ }
if (IsRaytracable())
{
// Apply local transformation
aCtx->ModelWorldState.Push();
- aCtx->ModelWorldState.SetCurrent (Transformation);
+ OpenGl_Mat4& aModelWorld = aCtx->ModelWorldState.ChangeCurrent();
+ if (!myTrsf.IsNull())
+ {
+ myTrsf->Trsf().GetMat4 (aModelWorld);
+ }
+ else
+ {
+ aModelWorld.InitIdentity();
+ }
const Standard_Boolean anOldGlNormalize = aCtx->IsGlNormalizeEnabled();
#if !defined(GL_ES_VERSION_2_0)
// detect scale transform
- if (aCtx->core11 != NULL)
+ if (aCtx->core11 != NULL
+ && !myTrsf.IsNull())
{
- const Standard_ShortReal aScaleX = Transformation.GetRow (0).xyz().SquareModulus();
- if (Abs (aScaleX - 1.f) > Precision::Confusion())
+ const Standard_Real aScale = myTrsf->ScaleFactor();
+ if (Abs (aScale - 1.0) > Precision::Confusion())
{
aCtx->SetGlNormalizeEnabled (Standard_True);
}
Standard_EXPORT virtual void Disconnect (Graphic3d_CStructure& theStructure) Standard_OVERRIDE;
//! Synchronize structure transformation
- Standard_EXPORT virtual void UpdateTransformation() Standard_OVERRIDE;
+ Standard_EXPORT virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
//! Highlight entire structure with color
Standard_EXPORT virtual void HighlightWithColor (const Graphic3d_Vec3& theColor,
ContainsFacet = myParent->ContainsFacet;
IsInfinite = myParent->IsInfinite;
- Transformation = myParent->Transformation;
- myBndBox = myParent->BoundingBox();
+ myBndBox = myParent->BoundingBox();
- UpdateTransformation();
+ OpenGl_Structure::SetTransformation (myParent->Transformation());
myInstancedStructure = const_cast<OpenGl_Structure*> (myParent->InstancedStructure());
myTrsfPers = myParent->TransformPersistence();
//! Adds OpenGL groups to ray-traced scene geometry.
Standard_Boolean addRaytraceGroups (const OpenGl_Structure* theStructure,
const OpenGl_RaytraceMaterial& theStructMat,
- const Graphic3d_Mat4* theTransform,
+ const Handle(Geom_Transformation)& theTrsf,
const Handle(OpenGl_Context)& theGlContext);
//! Creates ray-tracing material properties.
// Get structure material
OpenGl_RaytraceMaterial aDefaultMaterial;
- Standard_Boolean aResult = addRaytraceGroups (theStructure, aDefaultMaterial, &theStructure->Transformation, theGlContext);
+ Standard_Boolean aResult = addRaytraceGroups (theStructure, aDefaultMaterial, theStructure->Transformation(), theGlContext);
// Process all connected OpenGL structures
const OpenGl_Structure* anInstanced = theStructure->InstancedStructure();
if (anInstanced != NULL && anInstanced->IsRaytracable())
{
- aResult &= addRaytraceGroups (anInstanced, aDefaultMaterial, &theStructure->Transformation, theGlContext);
+ aResult &= addRaytraceGroups (anInstanced, aDefaultMaterial, theStructure->Transformation(), theGlContext);
}
myStructureStates[theStructure] = StructState (theStructure);
// =======================================================================
Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure* theStructure,
const OpenGl_RaytraceMaterial& theStructMat,
- const Graphic3d_Mat4* theTransform,
+ const Handle(Geom_Transformation)& theTrsf,
const Handle(OpenGl_Context)& theGlContext)
{
+ OpenGl_Mat4 aMat4;
for (OpenGl_Structure::GroupIterator aGroupIter (theStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
{
// Get group material
BVH_Transform<Standard_ShortReal, 4>* aTransform = new BVH_Transform<Standard_ShortReal, 4>();
- if (theTransform != NULL)
+ if (!theTrsf.IsNull())
{
- aTransform->SetTransform (*theTransform);
+ theTrsf->Trsf().GetMat4 (aMat4);
+ aTransform->SetTransform (aMat4);
}
aSet->SetProperties (aTransform);
{
BVH_Transform<Standard_ShortReal, 4>* aTransform = new BVH_Transform<Standard_ShortReal, 4>;
- if (theTransform != NULL)
+ if (!theTrsf.IsNull())
{
- aTransform->SetTransform (*theTransform);
+ theTrsf->Trsf().GetMat4 (aMat4);
+ aTransform->SetTransform (aMat4);
}
aSet->SetProperties (aTransform);
#include <Prs3d_Root.hxx>
#include <Standard_Real.hxx>
#include <Standard_Type.hxx>
-#include <TColStd_Array2OfReal.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Presentation,Graphic3d_Structure)
-// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
-// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
-static void MakeGraphicTrsf (const Handle(Geom_Transformation)& aGeomTrsf,
- TColStd_Array2OfReal& Array){
- for (Standard_Integer i=1; i<=3; i++){
- for (Standard_Integer j=1; j<=4; j++){
- Array.SetValue(i,j,aGeomTrsf->Value(i,j));
- }
- }
- Array.SetValue(4,1,0.);
- Array.SetValue(4,2,0.);
- Array.SetValue(4,3,0.);
- Array.SetValue(4,4,1.);
-}
-
//=======================================================================
//function : Prs3d_Presentation
//purpose :
//
}
-//=======================================================================
-//function : Transform
-//purpose :
-//=======================================================================
-
-void Prs3d_Presentation::Transform(const Handle(Geom_Transformation)& aTransformation)
-{
- TColStd_Array2OfReal Array (1,4,1,4);
- MakeGraphicTrsf(aTransformation, Array);
- SetTransform(Array, Graphic3d_TOC_REPLACE);
-}
-
-//=======================================================================
-//function : Transformation
-//purpose :
-//=======================================================================
-
-Handle(Geom_Transformation) Prs3d_Presentation::Transformation() const {
-TColStd_Array2OfReal matrix(1,4,1,4);
-
- Graphic3d_Structure::Transform(matrix);
-
- gp_Trsf trsf;
- trsf.SetValues(
- matrix.Value(1,1),matrix.Value(1,2),matrix.Value(1,3),matrix.Value(1,4),
- matrix.Value(2,1),matrix.Value(2,2),matrix.Value(2,3),matrix.Value(2,4),
- matrix.Value(3,1),matrix.Value(3,2),matrix.Value(3,3),matrix.Value(3,4));
- Handle(Geom_Transformation) gtrsf = new Geom_Transformation(trsf);
-
- return gtrsf;
-}
-
-//=======================================================================
-//function : Place
-//purpose :
-//=======================================================================
-void Prs3d_Presentation::Place (const Quantity_Length X,
- const Quantity_Length Y,
- const Quantity_Length Z)
-{
- Handle(Geom_Transformation) aTransformation = new Geom_Transformation;
- aTransformation->SetTranslation(gp_Vec(X,Y,Z));
- TColStd_Array2OfReal Array (1,4,1,4);
- MakeGraphicTrsf(aTransformation, Array);
- SetTransform(Array, Graphic3d_TOC_REPLACE);
-}
-
-//=======================================================================
-//function : Multiply
-//purpose :
-//=======================================================================
-void Prs3d_Presentation::Multiply(const Handle(Geom_Transformation)& aTransformation)
-{
- TColStd_Array2OfReal Array (1,4,1,4);
- MakeGraphicTrsf(aTransformation, Array);
- SetTransform(Array, Graphic3d_TOC_POSTCONCATENATE);
-}
-
-//=======================================================================
-//function : Move
-//purpose :
-//=======================================================================
-void Prs3d_Presentation::Move (const Quantity_Length X,
- const Quantity_Length Y,
- const Quantity_Length Z)
-{
- Handle(Geom_Transformation) aTransformation = new Geom_Transformation;
- aTransformation->SetTranslation(gp_Vec(X,Y,Z));
- TColStd_Array2OfReal Array (1,4,1,4);
- MakeGraphicTrsf(aTransformation, Array);
- SetTransform(Array, Graphic3d_TOC_POSTCONCATENATE);
-}
//=======================================================================
//function : Connect
//=======================================================================
//function : Compute
-//purpose :
+//purpose :
//=======================================================================
-Handle(Graphic3d_Structure) Prs3d_Presentation::Compute(const Handle(Graphic3d_DataStructureManager)& aDataStruc,
- const TColStd_Array2OfReal& anArray)
+Handle(Graphic3d_Structure) Prs3d_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theDataStruc,
+ const Handle(Geom_Transformation)& theTrsf)
{
- return Graphic3d_Structure::Compute(aDataStruc,anArray);
+ return Graphic3d_Structure::Compute (theDataStruc, theTrsf);
}
//=======================================================================
//function : Compute
-//purpose :
+//purpose :
//=======================================================================
-void Prs3d_Presentation::Compute(const Handle(Graphic3d_DataStructureManager)& aDataStruc,
- const TColStd_Array2OfReal& anArray,
- Handle(Graphic3d_Structure)& aStruc)
+void Prs3d_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theDataStruc,
+ const Handle(Geom_Transformation)& theTrsf,
+ Handle(Graphic3d_Structure)& theStruc)
{
- Graphic3d_Structure::Compute(aDataStruc,anArray,aStruc);
+ Graphic3d_Structure::Compute (theDataStruc, theTrsf, theStruc);
}
#include <Graphic3d_Structure.hxx>
#include <Standard_Boolean.hxx>
-#include <TColStd_Array2OfReal.hxx>
#include <Quantity_Length.hxx>
class Prs3d_Root;
class Graphic3d_StructureManager;
public:
-
//! Constructs a presentation object
//! if <Init> is false, no color initialization is done.
Standard_EXPORT Prs3d_Presentation(const Handle(Graphic3d_StructureManager)& theStructManager, const Standard_Boolean theToInit = Standard_True);
Standard_EXPORT virtual Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& aProjector) Standard_OVERRIDE;
//! Returns the new Structure defined for the new visualization
- Standard_EXPORT virtual Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, const TColStd_Array2OfReal& AMatrix) Standard_OVERRIDE;
-
+ Standard_EXPORT virtual Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
+ const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
+
//! Returns the new Structure defined for the new visualization
Standard_EXPORT virtual void Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, Handle(Graphic3d_Structure)& aStructure) Standard_OVERRIDE;
//! Returns the new Structure defined for the new visualization
- Standard_EXPORT virtual void Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, const TColStd_Array2OfReal& AMatrix, Handle(Graphic3d_Structure)& aStructure) Standard_OVERRIDE;
+ Standard_EXPORT virtual void Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
+ const Handle(Geom_Transformation)& theTrsf,
+ Handle(Graphic3d_Structure)& theStructure) Standard_OVERRIDE;
- Standard_EXPORT void Transform (const Handle(Geom_Transformation)& aTransformation);
-
- Standard_EXPORT void Place (const Quantity_Length X, const Quantity_Length Y, const Quantity_Length Z);
-
- Standard_EXPORT void Multiply (const Handle(Geom_Transformation)& aTransformation);
-
- Standard_EXPORT void Move (const Quantity_Length X, const Quantity_Length Y, const Quantity_Length Z);
-
- Standard_EXPORT Handle(Geom_Transformation) Transformation() const;
-
Standard_EXPORT void Connect (const Handle(Prs3d_Presentation)& aPresentation);
Standard_EXPORT void Remove (const Handle(Prs3d_Presentation)& aPresentation);
Standard_EXPORT void RemoveAll();
-
friend class Prs3d_Root;
-
DEFINE_STANDARD_RTTIEXT(Prs3d_Presentation,Graphic3d_Structure)
-protected:
-
-
-
-
private:
-
Standard_EXPORT Handle(Graphic3d_Group) CurrentGroup() const;
-
-
};
-
-
-
-
-
-
#endif // _Prs3d_Presentation_HeaderFile
#ifndef _PrsMgr_ListOfPresentableObjects_HeaderFile
#define _PrsMgr_ListOfPresentableObjects_HeaderFile
-#include <PrsMgr_PresentableObject.hxx>
#include <NCollection_List.hxx>
+#include <Standard_Transient.hxx>
+class PrsMgr_PresentableObject; // use forward declaration since PrsMgr_PresentableObject.hxx uses PrsMgr_ListOfPresentableObjects
typedef NCollection_List<Handle(PrsMgr_PresentableObject)> PrsMgr_ListOfPresentableObjects;
typedef NCollection_List<Handle(PrsMgr_PresentableObject)>::Iterator PrsMgr_ListOfPresentableObjectsIter;
-
#endif // _PrsMgr_ListOfPresentableObjects_HeaderFile
#include <PrsMgr_PresentableObject.hxx>
-#include <Geom_Transformation.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <Graphic3d_DataStructureManager.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_TypeOfStructure.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Projector.hxx>
#include <PrsMgr_ModedPresentation.hxx>
-#include <PrsMgr_Presentation.hxx>
-#include <PrsMgr_PresentationManager.hxx>
#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentableObject,MMgt_TShared)
+namespace
+{
+ static const gp_Trsf THE_IDENTITY_TRSF;
+}
+
+//=======================================================================
+//function : getIdentityTrsf
+//purpose :
+//=======================================================================
+const gp_Trsf& PrsMgr_PresentableObject::getIdentityTrsf()
+{
+ return THE_IDENTITY_TRSF;
+}
+
//=======================================================================
//function : PrsMgr_PresentableObject
//purpose :
//=======================================================================
PrsMgr_PresentableObject::~PrsMgr_PresentableObject()
{
- gp_Trsf anIdentity;
for (PrsMgr_ListOfPresentableObjectsIter anIter (myChildren); anIter.More(); anIter.Next())
{
- anIter.Value()->SetCombinedParentTransform (anIdentity);
+ anIter.Value()->SetCombinedParentTransform (Handle(Geom_Transformation)());
anIter.Value()->myParent = NULL;
}
}
}
-//=======================================================================
-//function : Presentations
-//purpose :
-//=======================================================================
-PrsMgr_Presentations& PrsMgr_PresentableObject::Presentations() {
- return myPresentations;
-}
-
-//=======================================================================
-//function : HasTransformation
-//purpose :
-//=======================================================================
-Standard_Boolean PrsMgr_PresentableObject::HasTransformation() const
-{
- return myTransformation.Form() != gp_Identity;
-}
-
//=======================================================================
//function : SetToUpdate
//purpose :
}
//=======================================================================
-//function : SetLocalTransformation
-//purpose : WARNING : use with only 3D objects...
+//function : setLocalTransformation
+//purpose :
//=======================================================================
-void PrsMgr_PresentableObject::SetLocalTransformation (const gp_Trsf& theTransformation)
+void PrsMgr_PresentableObject::setLocalTransformation (const Handle(Geom_Transformation)& theTransformation)
{
myLocalTransformation = theTransformation;
UpdateTransformation();
//=======================================================================
void PrsMgr_PresentableObject::ResetTransformation()
{
- SetLocalTransformation (gp_Trsf());
+ setLocalTransformation (Handle(Geom_Transformation)());
}
//=======================================================================
//function : SetCombinedParentTransform
//purpose :
//=======================================================================
-void PrsMgr_PresentableObject::SetCombinedParentTransform (const gp_Trsf& theTransformation)
+void PrsMgr_PresentableObject::SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf)
{
- myCombinedParentTransform = theTransformation;
+ myCombinedParentTransform = theTrsf;
UpdateTransformation();
}
//=======================================================================
void PrsMgr_PresentableObject::UpdateTransformation()
{
- myTransformation = myCombinedParentTransform * myLocalTransformation;
- myInvTransformation = myTransformation.Inverted();
- Handle(Geom_Transformation) aTrsf = new Geom_Transformation (myTransformation);
+ myTransformation.Nullify();
+ myInvTransformation = gp_Trsf();
+ if (!myCombinedParentTransform.IsNull() && myCombinedParentTransform->Form() != gp_Identity)
+ {
+ if (!myLocalTransformation.IsNull() && myLocalTransformation->Form() != gp_Identity)
+ {
+ const gp_Trsf aTrsf = myCombinedParentTransform->Trsf() * myLocalTransformation->Trsf();
+ myTransformation = new Geom_Transformation (aTrsf);
+ myInvTransformation = aTrsf.Inverted();
+ }
+ else
+ {
+ myTransformation = myCombinedParentTransform;
+ myInvTransformation = myCombinedParentTransform->Trsf().Inverted();
+ }
+ }
+ else if (!myLocalTransformation.IsNull() && myLocalTransformation->Form() != gp_Identity)
+ {
+ myTransformation = myLocalTransformation;
+ myInvTransformation = myLocalTransformation->Trsf().Inverted();
+ }
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
{
- myPresentations (aPrsIter).Presentation()->Transform (aTrsf);
+ myPresentations (aPrsIter).Presentation()->SetTransformation (myTransformation);
}
-
- PrsMgr_ListOfPresentableObjectsIter anIter (myChildren);
- for (; anIter.More(); anIter.Next())
+ for (PrsMgr_ListOfPresentableObjectsIter aChildIter (myChildren); aChildIter.More(); aChildIter.Next())
{
- anIter.Value()->SetCombinedParentTransform (myTransformation);
+ aChildIter.Value()->SetCombinedParentTransform (myTransformation);
}
}
//=======================================================================
void PrsMgr_PresentableObject::UpdateTransformation(const Handle(Prs3d_Presentation)& P)
{
- Handle(Geom_Transformation) aTrsf = new Geom_Transformation (myTransformation);
- P->Transform (aTrsf);
+ P->SetTransformation (myTransformation);
}
//=======================================================================
if (anIter.Value() == theObject)
{
theObject->myParent = NULL;
- theObject->SetCombinedParentTransform (gp_Trsf());
+ theObject->SetCombinedParentTransform (Handle(Geom_Transformation)());
myChildren.Remove (anIter);
break;
}
#ifndef _PrsMgr_PresentableObject_HeaderFile
#define _PrsMgr_PresentableObject_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <PrsMgr_Presentations.hxx>
-#include <PrsMgr_TypeOfPresentation3d.hxx>
+#include <gp_GTrsf.hxx>
+#include <Graphic3d_ClipPlane.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
-#include <Standard_Boolean.hxx>
+#include <Graphic3d_TransformPers.hxx>
+#include <Graphic3d_TransModeFlags.hxx>
#include <Graphic3d_ZLayerId.hxx>
-#include <PrsMgr_PresentableObjectPointer.hxx>
-#include <gp_GTrsf.hxx>
-#include <gp_Trsf.hxx>
#include <PrsMgr_ListOfPresentableObjects.hxx>
-#include <MMgt_TShared.hxx>
#include <PrsMgr_Presentation.hxx>
+#include <PrsMgr_Presentations.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
-#include <Standard_Integer.hxx>
-#include <Graphic3d_TransformPers.hxx>
-#include <Graphic3d_TransModeFlags.hxx>
+#include <PrsMgr_PresentableObjectPointer.hxx>
+#include <PrsMgr_TypeOfPresentation3d.hxx>
#include <TColStd_ListOfInteger.hxx>
-#include <Graphic3d_ClipPlane.hxx>
-class Standard_NotImplemented;
-class PrsMgr_Presentation;
-class PrsMgr_PresentationManager;
-class Graphic3d_Structure;
-class Graphic3d_DataStructureManager;
-class Geom_Transformation;
-class Prs3d_Presentation;
-class Prs3d_Projector;
-class gp_Pnt;
-class gp_Trsf;
-
-
-class PrsMgr_PresentableObject;
-DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, MMgt_TShared)
//! A framework to supply the Graphic3d
//! structure of the object to be presented. On the first
//! creation of new interactive objects.
class PrsMgr_PresentableObject : public MMgt_TShared
{
-
+ DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject, MMgt_TShared)
public:
-
- Standard_EXPORT PrsMgr_Presentations& Presentations();
+ PrsMgr_Presentations& Presentations() { return myPresentations; }
//! Returns information on whether the object accepts display in HLR mode or not.
PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; }
//! gives the list of modes which are flagged "to be updated".
Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
+ //! Return the local transformation.
+ const Handle(Geom_Transformation)& LocalTransformationGeom() const { return myLocalTransformation; }
+
//! Sets local transformation to theTransformation.
- Standard_EXPORT virtual void SetLocalTransformation (const gp_Trsf& theTransformation);
-
+ void SetLocalTransformation (const gp_Trsf& theTrsf) { setLocalTransformation (new Geom_Transformation (theTrsf)); }
+
+ //! Sets local transformation to theTransformation.
+ void SetLocalTransformation (const Handle(Geom_Transformation)& theTrsf) { setLocalTransformation (theTrsf); }
+
//! Returns true if object has a transformation that is different from the identity.
- Standard_EXPORT Standard_Boolean HasTransformation() const;
+ Standard_Boolean HasTransformation() const { return !myTransformation.IsNull() && myTransformation->Form() != gp_Identity; }
- const gp_Trsf& LocalTransformation() const { return myLocalTransformation; }
+ //! Return the transformation taking into account transformation of parent object(s).
+ const Handle(Geom_Transformation)& TransformationGeom() const { return myTransformation; }
- const gp_Trsf& Transformation() const { return myTransformation; }
+ //! Return the local transformation.
+ const gp_Trsf& LocalTransformation() const { return !myLocalTransformation.IsNull()
+ ? myLocalTransformation->Trsf()
+ : getIdentityTrsf(); }
+
+ //! Return the transformation taking into account transformation of parent object(s).
+ const gp_Trsf& Transformation() const { return !myTransformation.IsNull()
+ ? myTransformation->Trsf()
+ : getIdentityTrsf(); }
const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
friend
Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf, const Handle(Graphic3d_Structure)& theGivenStruct);
-
- DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject,MMgt_TShared)
-
protected:
//! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
//! from parent node and able to derive its own.
- Standard_EXPORT virtual void SetCombinedParentTransform (const gp_Trsf& theTransformation);
+ Standard_EXPORT virtual void SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf);
//! General virtual method for internal update of presentation state
//! when some modifications on list of clip planes occurs. Base
//! implementation propagate clip planes to every presentation.
Standard_EXPORT virtual void UpdateClipping();
+ //! Sets local transformation to theTransformation.
+ Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTransformation);
+
+private:
+
+ //! Return the identity transformation.
+ Standard_EXPORT static const gp_Trsf& getIdentityTrsf();
+
protected:
PrsMgr_Presentations myPresentations;
Handle(Graphic3d_TransformPers) myTransformPersistence;
PrsMgr_PresentableObjectPointer myParent;
- gp_Trsf myLocalTransformation;
- gp_Trsf myTransformation;
+ Handle(Geom_Transformation) myLocalTransformation;
+ Handle(Geom_Transformation) myTransformation;
+ Handle(Geom_Transformation) myCombinedParentTransform;
gp_GTrsf myInvTransformation;
- gp_Trsf myCombinedParentTransform;
PrsMgr_ListOfPresentableObjects myChildren;
};
+DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, MMgt_TShared)
+
#endif // _PrsMgr_PresentableObject_HeaderFile
}
//=======================================================================
-//function : Transform
+//function : SetTransformation
//purpose :
//=======================================================================
-void PrsMgr_Presentation::Transform (const Handle(Geom_Transformation)& theTrsf) const
+void PrsMgr_Presentation::SetTransformation (const Handle(Geom_Transformation)& theTrsf) const
{
- myStructure->Transform (theTrsf);
-}
-
-//=======================================================================
-//function : Place
-//purpose :
-//=======================================================================
-void PrsMgr_Presentation::Place (const Quantity_Length theX,
- const Quantity_Length theY,
- const Quantity_Length theZ) const
-{
- myStructure->Place (theX, theY, theZ);
-}
-
-//=======================================================================
-//function : Multiply
-//purpose :
-//=======================================================================
-void PrsMgr_Presentation::Multiply (const Handle(Geom_Transformation)& theTrsf) const
-{
- myStructure->Multiply (theTrsf);
-}
-
-//=======================================================================
-//function : Move
-//purpose :
-//=======================================================================
-void PrsMgr_Presentation::Move (const Quantity_Length theX,
- const Quantity_Length theY,
- const Quantity_Length theZ) const
-{
- myStructure->Move (theX, theY, theZ);
+ myStructure->SetTransformation (theTrsf);
}
//=======================================================================
if (theTrsf->Form() == gp_Translation)
{
myPresentableObject->Compute (Projector (theProjector), aPrs3d);
- aPrs3d->Transform (theTrsf);
+ aPrs3d->SetTransformation (theTrsf);
return aPrs3d;
}
}
myPresentableObject->Compute (Projector (theProjector), aPrs3d);
- aPrs3d->Transform (theTrsf);
+ aPrs3d->SetTransformation (theTrsf);
return aPrs3d;
}
Standard_EXPORT void Connect (const Handle(PrsMgr_Presentation)& theOther) const;
- Standard_EXPORT void Transform (const Handle(Geom_Transformation)& theTrsf) const;
-
- Standard_EXPORT void Place (const Quantity_Length theX, const Quantity_Length theY, const Quantity_Length theZ) const;
-
- Standard_EXPORT void Multiply (const Handle(Geom_Transformation)& theTrsf) const;
-
- Standard_EXPORT void Move (const Quantity_Length theX, const Quantity_Length theY, const Quantity_Length theZ) const;
+ Standard_EXPORT void SetTransformation (const Handle(Geom_Transformation)& theTrsf) const;
Standard_EXPORT void Compute (const Handle(Graphic3d_Structure)& theStructure);
const Handle(Geom_Transformation)& theTransformation,
const Standard_Integer theMode)
{
- Presentation (thePrsObj, theMode)->Transform (theTransformation);
+ Presentation (thePrsObj, theMode)->SetTransformation (theTransformation);
}
{
// =======================================================================
// function : updatePrsTransformation
- // purpose : Internal funtion that scans thePrsList for shadow presentations
+ // purpose : Internal function that scans thePrsList for shadow presentations
// and applies transformation theTrsf to them in case if parent ID
// of shadow presentation is equal to theRefId
// =======================================================================
void updatePrsTransformation (const PrsMgr_ListOfPresentations& thePrsList,
const Standard_Integer theRefId,
- const Graphic3d_Mat4& theTrsf)
+ const Handle(Geom_Transformation)& theTrsf)
{
for (PrsMgr_ListOfPresentations::Iterator anIter (thePrsList); anIter.More(); anIter.Next())
{
if (aShadowPrs.IsNull() || aShadowPrs->ParentId() != theRefId)
continue;
- aShadowPrs->CStructure()->Transformation = theTrsf;
+ aShadowPrs->CStructure()->SetTransformation (theTrsf);
}
}
}
aBasePrs : Presentation (theSelObj, theMode, Standard_False)->Presentation();
const Standard_Integer aParentId = aParentPrs->CStructure()->Id;
- updatePrsTransformation (myImmediateList, aParentId, aBasePrs->CStructure()->Transformation);
+ updatePrsTransformation (myImmediateList, aParentId, aBasePrs->CStructure()->Transformation());
if (!myViewDependentImmediateList.IsEmpty())
{
{
updatePrsTransformation (myViewDependentImmediateList,
aViewDepParentPrs->CStructure()->Id,
- aBasePrs->CStructure()->Transformation);
+ aBasePrs->CStructure()->Transformation());
}
}
}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <PrsMgr_Prs.hxx>
#include <Geom_Transformation.hxx>
#include <gp_Trsf.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Precision.hxx>
#include <PrsMgr_Presentation.hxx>
-#include <PrsMgr_Prs.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_Prs,Prs3d_Presentation)
}
//=======================================================================
//function : Compute
-//purpose :
+//purpose :
//=======================================================================
-Handle(Graphic3d_Structure) PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector,
- const TColStd_Array2OfReal& AMatrix)
+Handle(Graphic3d_Structure) PrsMgr_Prs::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
+ const Handle(Geom_Transformation)& theTrsf)
{
- gp_Trsf TheTrsf;
- Standard_Integer LC(AMatrix.LowerCol()),LR(AMatrix.LowerRow());
- TheTrsf.SetValues(AMatrix(LR,LC),AMatrix(LR,LC+1),AMatrix(LR,LC+2),AMatrix(LR,LC+3),
- AMatrix(LR+1,LC),AMatrix(LR+1,LC+1),AMatrix(LR+1,LC+2),AMatrix(LR+1,LC+3),
- AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3));
- Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);
-
- return myPresentation3d->Compute(aProjector,G);
+ return myPresentation3d->Compute (theProjector, theTrsf);
}
//=======================================================================
//=======================================================================
//function : Compute
-//purpose :
+//purpose :
//=======================================================================
-void PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector,
- const TColStd_Array2OfReal& AMatrix,
- Handle(Graphic3d_Structure)& aGivenStruct)
+void PrsMgr_Prs::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
+ const Handle(Geom_Transformation)& theTrsf,
+ Handle(Graphic3d_Structure)& theGivenStruct)
{
- gp_Trsf TheTrsf;
- Standard_Integer LC(AMatrix.LowerCol()),LR(AMatrix.LowerRow());
- TheTrsf.SetValues(AMatrix(LR,LC),AMatrix(LR,LC+1),AMatrix(LR,LC+2),AMatrix(LR,LC+3),
- AMatrix(LR+1,LC),AMatrix(LR+1,LC+1),AMatrix(LR+1,LC+2),AMatrix(LR+1,LC+3),
- AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3));
- Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);
-
-
- myPresentation3d->Compute(aProjector,G,aGivenStruct);
+ myPresentation3d->Compute (theProjector, theTrsf, theGivenStruct);
}
class Graphic3d_Structure;
class Graphic3d_DataStructureManager;
-
class PrsMgr_Prs;
DEFINE_STANDARD_HANDLE(PrsMgr_Prs, Prs3d_Presentation)
-
class PrsMgr_Prs : public Prs3d_Presentation
{
public:
-
Standard_EXPORT PrsMgr_Prs(const Handle(Graphic3d_StructureManager)& theStructManager, const PrsMgr_PresentationPointer& thePresentation, const PrsMgr_TypeOfPresentation3d theTypeOfPresentation3d);
//! We have to take in account this Transformation
//! in the computation of hidden line removal...
//! returns a filled Graphic Structure.
- Standard_EXPORT Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, const TColStd_Array2OfReal& AMatrix) Standard_OVERRIDE;
-
+ Standard_EXPORT Handle(Graphic3d_Structure) Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
+ const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
+
//! No need to return a structure, just to fill
//! <ComputedStruct> ....
Standard_EXPORT void Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, Handle(Graphic3d_Structure)& ComputedStruct) Standard_OVERRIDE;
//! No Need to return a Structure, just to
//! Fill <aStructure>. The Trsf has to be taken in account
//! in the computation (Rotation Part....)
- Standard_EXPORT void Compute (const Handle(Graphic3d_DataStructureManager)& aProjector, const TColStd_Array2OfReal& AMatrix, Handle(Graphic3d_Structure)& aStructure) Standard_OVERRIDE;
-
-
-
+ Standard_EXPORT void Compute (const Handle(Graphic3d_DataStructureManager)& theProjector,
+ const Handle(Geom_Transformation)& theTrsf,
+ Handle(Graphic3d_Structure)& theStructure) Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(PrsMgr_Prs,Prs3d_Presentation)
-protected:
-
-
-
-
private:
-
PrsMgr_PresentationPointer myPresentation3d;
-
};
-
-
-
-
-
-
#endif // _PrsMgr_Prs_HeaderFile
{
const Standard_Real CosAlpha = Cos (RotationAngle ());
const Standard_Real SinAlpha = Sin (RotationAngle ());
- TColStd_Array2OfReal Trsf (1, 4, 1, 4);
- Trsf (4, 4) = 1.0;
- Trsf (4, 1) = Trsf (4, 2) = Trsf (4, 3) = 0.0;
+
+ gp_Trsf aTrsf;
// Translation
- Trsf (1, 4) = xl,
- Trsf (2, 4) = yl,
- Trsf (3, 4) = zl;
- // Transformation change of marker
- Trsf (1, 1) = xdx,
- Trsf (2, 1) = xdy,
- Trsf (3, 1) = xdz,
- Trsf (1, 2) = ydx,
- Trsf (2, 2) = ydy,
- Trsf (3, 2) = ydz,
- Trsf (1, 3) = dx,
- Trsf (2, 3) = dy,
- Trsf (3, 3) = dz;
- myStructure->SetTransform (Trsf, Graphic3d_TOC_REPLACE);
+ // Transformation of change of marker
+ aTrsf.SetValues (xdx, ydx, dx, xl,
+ xdy, ydy, dy, yl,
+ xdz, ydz, dz, zl);
// Translation of the origin
- Trsf (1, 4) = -XOrigin (),
- Trsf (2, 4) = -YOrigin (),
- Trsf (3, 4) = 0.0;
// Rotation Alpha around axis -Z
- Trsf (1, 1) = CosAlpha,
- Trsf (2, 1) = -SinAlpha,
- Trsf (3, 1) = 0.0,
- Trsf (1, 2) = SinAlpha,
- Trsf (2, 2) = CosAlpha,
- Trsf (3, 2) = 0.0,
- Trsf (1, 3) = 0.0,
- Trsf (2, 3) = 0.0,
- Trsf (3, 3) = 1.0;
- myStructure->SetTransform (Trsf,Graphic3d_TOC_POSTCONCATENATE);
+ gp_Trsf aTrsf2;
+ aTrsf2.SetValues ( CosAlpha, SinAlpha, 0.0, -XOrigin(),
+ -SinAlpha, CosAlpha, 0.0, -YOrigin(),
+ 0.0, 0.0, 1.0, 0.0);
+ aTrsf.Multiply (aTrsf2);
+ myStructure->SetTransformation (new Geom_Transformation (aTrsf));
myCurAngle = RotationAngle ();
myCurXo = XOrigin (), myCurYo = YOrigin ();
// =======================================================================
void V3d_Plane::Update()
{
- if(!myGraphicStructure.IsNull())
+ if (myGraphicStructure.IsNull())
{
- TColStd_Array2OfReal aMatrix (1, 4, 1, 4);
- Standard_Real theA, theB, theC, theD;
- this->Plane(theA, theB, theC, theD);
- gp_Pln aGeomPln (theA, theB, theC, theD);
- gp_Trsf aTransform;
- aTransform.SetTransformation (aGeomPln.Position());
- aTransform.Invert();
- for (Standard_Integer i = 1; i <= 3; i++)
- {
- for (Standard_Integer j = 1; j <= 4; j++)
- {
- aMatrix.SetValue (i, j, aTransform.Value (i,j));
- }
- }
-
- aMatrix.SetValue (4,1,0.);
- aMatrix.SetValue (4,2,0.);
- aMatrix.SetValue (4,3,0.);
- aMatrix.SetValue (4,4,1.);
- myGraphicStructure->SetTransform (aMatrix, Graphic3d_TOC_REPLACE);
+ return;
}
+
+ const gp_Pln aGeomPln = myPlane->ToPlane();
+ gp_Trsf aTransform;
+ aTransform.SetTransformation (aGeomPln.Position());
+ aTransform.Invert();
+ myGraphicStructure->SetTransformation (new Geom_Transformation (aTransform));
}
if (MakeTransform) {
const Standard_Real CosAlpha = Cos (RotationAngle ());
const Standard_Real SinAlpha = Sin (RotationAngle ());
- TColStd_Array2OfReal Trsf (1, 4, 1, 4);
- Trsf (4, 4) = 1.0;
- Trsf (4, 1) = Trsf (4, 2) = Trsf (4, 3) = 0.0;
+
+ gp_Trsf aTrsf;
// Translation
- Trsf (1, 4) = xl,
- Trsf (2, 4) = yl,
- Trsf (3, 4) = zl;
// Transformation of change of marker
- Trsf (1, 1) = xdx,
- Trsf (2, 1) = xdy,
- Trsf (3, 1) = xdz,
- Trsf (1, 2) = ydx,
- Trsf (2, 2) = ydy,
- Trsf (3, 2) = ydz,
- Trsf (1, 3) = dx,
- Trsf (2, 3) = dy,
- Trsf (3, 3) = dz;
- myStructure->SetTransform (Trsf, Graphic3d_TOC_REPLACE);
+ aTrsf.SetValues (xdx, ydx, dx, xl,
+ xdy, ydy, dy, yl,
+ xdz, ydz, dz, zl);
// Translation of the origin
- Trsf (1, 4) = -XOrigin (),
- Trsf (2, 4) = -YOrigin (),
- Trsf (3, 4) = 0.0;
// Rotation Alpha around axis -Z
- Trsf (1, 1) = CosAlpha,
- Trsf (2, 1) = -SinAlpha,
- Trsf (3, 1) = 0.0,
- Trsf (1, 2) = SinAlpha,
- Trsf (2, 2) = CosAlpha,
- Trsf (3, 2) = 0.0,
- Trsf (1, 3) = 0.0,
- Trsf (2, 3) = 0.0,
- Trsf (3, 3) = 1.0;
- myStructure->SetTransform (Trsf,Graphic3d_TOC_POSTCONCATENATE);
+ gp_Trsf aTrsf2;
+ aTrsf2.SetValues ( CosAlpha, SinAlpha, 0.0, -XOrigin(),
+ -SinAlpha, CosAlpha, 0.0, -YOrigin(),
+ 0.0, 0.0, 1.0, 0.0);
+ aTrsf.Multiply (aTrsf2);
+ myStructure->SetTransformation (new Geom_Transformation (aTrsf));
myCurAngle = RotationAngle ();
myCurXo = XOrigin (), myCurYo = YOrigin ();
#ifndef _gp_Trsf_HeaderFile
#define _gp_Trsf_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <Standard_Real.hxx>
#include <gp_TrsfForm.hxx>
#include <gp_Mat.hxx>
#include <gp_XYZ.hxx>
+#include <NCollection_Mat4.hxx>
+#include <Standard.hxx>
#include <Standard_Boolean.hxx>
+#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Real.hxx>
+
class Standard_ConstructionError;
class Standard_OutOfRange;
-class gp_GTrsf;
-class gp_Trsf2d;
class gp_Pnt;
class gp_Ax1;
class gp_Ax2;
class gp_Quaternion;
class gp_Ax3;
class gp_Vec;
-class gp_XYZ;
-class gp_Mat;
-
//! Defines a non-persistent transformation in 3D space.
//! The following transformations are implemented :
//! Transformation of a triplet XYZ with a Trsf
void Transforms (gp_XYZ& Coord) const;
+ //! Convert transformation to 4x4 matrix.
+ template<class T>
+ void GetMat4 (NCollection_Mat4<T>& theMat) const
+ {
+ if (shape == gp_Identity)
+ {
+ theMat.InitIdentity();
+ return;
+ }
+
+ theMat.SetValue (0, 0, static_cast<T> (Value (1, 1)));
+ theMat.SetValue (0, 1, static_cast<T> (Value (1, 2)));
+ theMat.SetValue (0, 2, static_cast<T> (Value (1, 3)));
+ theMat.SetValue (0, 3, static_cast<T> (Value (1, 4)));
+ theMat.SetValue (1, 0, static_cast<T> (Value (2, 1)));
+ theMat.SetValue (1, 1, static_cast<T> (Value (2, 2)));
+ theMat.SetValue (1, 2, static_cast<T> (Value (2, 3)));
+ theMat.SetValue (1, 3, static_cast<T> (Value (2, 4)));
+ theMat.SetValue (2, 0, static_cast<T> (Value (3, 1)));
+ theMat.SetValue (2, 1, static_cast<T> (Value (3, 2)));
+ theMat.SetValue (2, 2, static_cast<T> (Value (3, 3)));
+ theMat.SetValue (2, 3, static_cast<T> (Value (3, 4)));
+ theMat.SetValue (3, 0, static_cast<T> (0));
+ theMat.SetValue (3, 1, static_cast<T> (0));
+ theMat.SetValue (3, 2, static_cast<T> (0));
+ theMat.SetValue (3, 3, static_cast<T> (1));
+ }
friend class gp_GTrsf;
-
protected:
-
//! Makes orthogonalization of "matrix"
Standard_EXPORT void Orthogonalize();
-
-
-
private:
-
-
Standard_Real scale;
gp_TrsfForm shape;
gp_Mat matrix;
gp_XYZ loc;
-
};
-
#include <gp_Trsf.lxx>
-
-
-
-
#endif // _gp_Trsf_HeaderFile