}
GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
- const Standard_CString aName): SALOME_AISShape(shape)
+ const Standard_CString aName)
+ : SALOME_AISShape(shape), myName(aName)
{
- myName = new char [strlen(aName)+1];
- strcpy( myName, aName);
-
myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
}
void GEOM_AISShape::setName(const Standard_CString aName)
{
- myName = new char [strlen(aName)+1];
- strcpy( myName, aName);
+ myName = aName;
Handle(SALOME_InteractiveObject) IO = getIO();
if ( !IO.IsNull() )
}
Standard_CString GEOM_AISShape::getName(){
- return myName;
+ return myName.ToCString();
}
void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
#include <Handle_Prs3d_Presentation.hxx>
#endif
+#include <TCollection_AsciiString.hxx>
+
class PrsMgr_PresentationManager3d;
class Prs3d_Presentation;
class SALOME_InteractiveObject;
//
friend Handle_Standard_Type& GEOM_AISShape_Type_();
const Handle(Standard_Type)& DynamicType() const;
- Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
-
-protected:
-
- // Methods PROTECTED
- //
-
-
- // Fields PROTECTED
- //
+ Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
+protected:
+ Quantity_Color myShadingColor;
private:
-
- // Methods PRIVATE
- //
-
-
- // Fields PRIVATE
- //
- Standard_CString myName;
- Quantity_Color myShadingColor;
+ TCollection_AsciiString myName;
};
-
-
-
// other inline functions and methods (like "C++: function call" methods)
//
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : GEOM_AISVector.cxx
+// Author : Julia DOROVSKIKH
+// $Header$
+
+
+#include <GEOM_AISVector.hxx>
+
+// OCCT Includes
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <Graphic3d_Group.hxx>
+#include <BRep_Tool.hxx>
+#include <TopExp.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Vec.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(GEOM_AISVector, GEOM_AISShape)
+IMPLEMENT_STANDARD_RTTIEXT(GEOM_AISVector, GEOM_AISShape)
+
+//=======================================================================
+//function : GEOM_AISVector
+//purpose : Constructor
+//=======================================================================
+GEOM_AISVector::GEOM_AISVector (const TopoDS_Shape& theShape, const Standard_CString theName)
+ : GEOM_AISShape(theShape, theName)
+{
+}
+
+//=======================================================================
+//function : Compute
+//purpose : Compute a presentation
+//=======================================================================
+void GEOM_AISVector::Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode)
+{
+ GEOM_AISShape::Compute(thePresentationManager, thePrs, theMode);
+
+ if (myshape.ShapeType() == TopAbs_EDGE)
+ {
+ TopoDS_Vertex aV1, aV2;
+ TopoDS_Edge anEdgeE = TopoDS::Edge(myshape);
+ TopExp::Vertices(anEdgeE, aV1, aV2);
+ gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
+ gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
+
+ gp_Vec aVec (aP1, aP2);
+ Standard_Real aDist = aVec.Magnitude();
+ if (aDist > gp::Resolution())
+ {
+ gp_Dir aDir (aVec);
+
+ Handle(Graphic3d_Group) aG = Prs3d_Root::CurrentGroup(thePrs);
+
+ thePrs->Color(myShadingColor.Name());
+ //aG->BeginPrimitives();
+ Prs3d_Arrow::Draw(thePrs, aP2, aDir, PI/180.*5., aDist/10.);
+ //aG->EndPrimitives();
+ }
+ }
+ //thePrs->ReCompute(); // for hidden line recomputation if necessary...
+}
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : GEOM_AISVector.hxx
+// Author : Julia DOROVSKIKH
+// Module : GEOM
+
+#ifndef GEOM_AISVector_HeaderFile
+#define GEOM_AISVector_HeaderFile
+
+#include <GEOM_AISShape.hxx>
+#include <Standard_DefineHandle.hxx>
+
+/*!
+ * \class GEOM_AISVector
+ * \brief Interactive object, representing a vector with arrow on its end
+ */
+
+class GEOM_AISVector : public GEOM_AISShape
+{
+public:
+ /*!
+ * Constructor
+ * \param theShape A linear edge to be represented as a vector
+ * \param theName A name to be passed in constructor of \a GEOM_AISShape
+ */
+ Standard_EXPORT GEOM_AISVector (const TopoDS_Shape& theShape, const Standard_CString theName);
+
+protected:
+ /*!
+ * Redefined from GEOM_AISShape
+ */
+ virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode = 0);
+
+public:
+ DEFINE_STANDARD_RTTI (GEOM_AISVector)
+};
+
+DEFINE_STANDARD_HANDLE(GEOM_AISVector, GEOM_AISShape)
+
+#endif
GEOM_Actor *f = GEOM_Actor::SafeDownCast(prop);
if ( f != NULL )
{
- this->setInputShape(f->getTopo(),f->getDeflection(),f->getDisplayMode());
+ this->setInputShape(f->getTopo(),f->getDeflection(),f->getDisplayMode(),f->isVector());
this->setName( f->getName() );
if ( f->hasIO() )
this->setIO( f->getIO() );
deflection = adef;
}
-void GEOM_Actor::setInputShape(const TopoDS_Shape& aShape,double adef,int imode) {
+void GEOM_Actor::setInputShape(const TopoDS_Shape& aShape, double adef,
+ int imode, bool isVector)
+{
myShape = aShape;
deflection = adef;
+ myIsVector = isVector;
setDisplayMode(imode);
}
this->SetPosition(aPnt.X(),aPnt.Y(),aPnt.Z());
}
GEOM_OCCReader* aread = GEOM_OCCReader::New();
- aread->setTopo(myShape);
+ aread->setTopo(myShape, myIsVector);
aread->setDisplayMode(theMode);
aread->GetOutput()->ReleaseDataFlagOn();
-
+
vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
if (theMode == 0) {
aMapper->SetInput(aread->GetOutput());
void ReleaseGraphicsResources(vtkWindow *);
const TopoDS_Shape& getTopo();
- void setInputShape(const TopoDS_Shape& ashape,double adef1,int imode);
+ void setInputShape(const TopoDS_Shape& ashape, double adef1,
+ int imode, bool isVector = false);
double getDeflection();
void setDeflection(double adefl);
+ double isVector() { return myIsVector; }
+
// SubShape
void SubShapeOn();
void SubShapeOff();
TopoDS_Shape myShape;
double deflection;
+ bool myIsVector;
vtkMapper* ShadingMapper;
vtkMapper* WireframeMapper;
vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShape,
- Standard_Real deflection,
- Standard_Integer mode,
- Standard_Boolean forced) {
-
+ Standard_Real deflection,
+ Standard_Integer mode,
+ Standard_Boolean forced,
+ Standard_Boolean isVector)
+{
vtkActorCollection* AISActors = vtkActorCollection::New();
if(myShape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator anItr(myShape);
for(; anItr.More(); anItr.Next()) {
- vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(anItr.Value(), deflection, mode, forced);
+ vtkActorCollection* theActors =
+ GEOM_AssemblyBuilder::BuildActors(anItr.Value(), deflection, mode, forced);
theActors->InitTraversal();
vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
while(!(anActor==NULL)) {
- AISActors->AddItem(anActor);
- anActor = (vtkActor*)theActors->GetNextActor();
+ AISActors->AddItem(anActor);
+ anActor = (vtkActor*)theActors->GetNextActor();
}
}
}
}
} else if ( myShape.ShapeType() == TopAbs_EDGE ) { // EDGE Actor
GEOM_Actor* EdgeActor = GEOM_Actor::New();
- EdgeActor->setInputShape(myShape,deflection,mode);
+ EdgeActor->setInputShape(myShape,deflection,mode,isVector);
EdgeActor->SetShadingProperty(EdgeIProp);
EdgeActor->SetWireframeProperty(EdgeIProp);
EdgeActor->SetPreviewProperty(EdgePVProp);
static vtkActorCollection* BuildActors(const TopoDS_Shape& myShape,
Standard_Real deflection,
Standard_Integer amode,
- Standard_Boolean forced);
+ Standard_Boolean forced,
+ Standard_Boolean isVector = Standard_False);
//------------------------------------------------------------------
edgeTransf = aEdgeLoc.Transformation();
}
+ gp_Pnt aP1, aP2;
+
Standard_Integer nbnodes;
if (aEdgePoly.IsNull()) {
nbnodes = P->NbNodes();
const TColgp_Array1OfPnt& theNodesP = P->Nodes();
+ aP1 = theNodesP(1);
+ aP2 = theNodesP(nbnodes);
+
float coord[3];
int pts[2];
-
+
for(int j=1;j<nbnodes;j++) {
gp_Pnt pt1 = theNodesP(j);
gp_Pnt pt2 = theNodesP(j+1);
const TColStd_Array1OfInteger& Nodesidx = aEdgePoly->Nodes();
const TColgp_Array1OfPnt& theNodesPoly = T->Nodes();
+ aP1 = theNodesPoly(1);
+ aP2 = theNodesPoly(nbnodes);
+
float coord[3];
int pts[2];
Cells->InsertNextCell(2,pts);
}
}
+
+ // vector representation has an arrow on its end
+ if (myIsVector)
+ {
+ if (!isidtrsf) {
+ // apply edge transformation
+ aP1.Transform(edgeTransf);
+ aP2.Transform(edgeTransf);
+ }
+
+ // draw an arrow
+ gp_Vec aDirVec (aP1, aP2);
+ Standard_Real aDist = aDirVec.Magnitude();
+ if (aDist < gp::Resolution()) return;
+ gp_Dir aDirection (aDirVec);
+
+ Standard_Real anAngle = PI/180.*5.;
+ Standard_Real aLength = aDist/10.;
+
+ Standard_Real dx,dy,dz;
+ aDirection.Coord(dx,dy,dz);
+
+ // Pointe de la fleche
+ Standard_Real xo,yo,zo;
+ aP2.Coord(xo,yo,zo);
+
+ // Centre du cercle base de la fleche
+ gp_XYZ aPc = aP2.XYZ() - aDirection.XYZ() * aLength;
+
+ // Construction d'un repere i,j pour le cercle
+ gp_Dir aDirN;
+ if (Abs(dx) <= Abs(dy) && Abs(dx) <= Abs(dz)) aDirN = gp::DX();
+ else if (Abs(dy) <= Abs(dz) && Abs(dy) <= Abs(dx)) aDirN = gp::DY();
+ else aDirN = gp::DZ();
+
+ gp_Dir aDirI = aDirection ^ aDirN;
+ gp_Dir aDirJ = aDirection ^ aDirI;
+
+ // Add points and segments, composing the arrow
+ Standard_Real cosinus, sinus, Tg = tan(anAngle);
+
+ float coord[3];
+ coord[0] = xo; coord[1] = yo; coord[2] = zo;
+
+ int ptLoc = Pts->InsertNextPoint(coord);
+ int ptFirst = 0;
+ int ptPrev = 0;
+ int ptCur = 0;
+
+ int pts[2];
+
+ int NbPoints = 15;
+ for (int i = 1; i <= NbPoints; i++, ptPrev = ptCur)
+ {
+ cosinus = cos(2. * PI / NbPoints * (i-1));
+ sinus = sin(2. * PI / NbPoints * (i-1));
+
+ gp_XYZ aP = aPc + (aDirI.XYZ() * cosinus + aDirJ.XYZ() * sinus) * aLength * Tg;
+ coord[0] = aP.X();
+ coord[1] = aP.Y();
+ coord[2] = aP.Z();
+
+ // insert pts
+ ptCur = Pts->InsertNextPoint(coord);
+ pts[0] = ptCur;
+
+ if (i == 1) {
+ ptFirst = ptCur;
+ }
+ else {
+ // insert line (ptCur,ptPrev)
+ pts[1] = ptPrev;
+ Cells->InsertNextCell(2,pts);
+ }
+
+ // insert line (ptCur,ptLoc)
+ pts[1] = ptLoc;
+ Cells->InsertNextCell(2,pts);
+ }
+
+ // insert line (ptCur,ptFirst)
+ pts[0] = ptCur;
+ pts[1] = ptFirst;
+ Cells->InsertNextCell(2,pts);
+ }
}
/* Standard_Integer nbnodes = aEdgePoly->NbNodes();
amode = thenewmode;
}
-void GEOM_OCCReader::setTopo(const TopoDS_Shape& aShape) {
+void GEOM_OCCReader::setTopo(const TopoDS_Shape& aShape, bool isVector) {
myShape = aShape;
+ myIsVector = isVector;
}
void GEOM_OCCReader::setForceUpdate(Standard_Boolean bol) {
const TopoDS_Shape& getTopo();
- void setTopo(const TopoDS_Shape& ashape);
+ void setTopo(const TopoDS_Shape& ashape, bool isVector = false);
int getDisplayMode();
void setDisplayMode(int);
int amode;
int nbisos;
TopoDS_Shape myShape;
+ bool myIsVector;
};
GEOM_AssemblyBuilder.h \
GEOM_AISShape.hxx \
Handle_GEOM_AISShape.hxx \
+ GEOM_AISVector.hxx \
GEOM_InteractiveObject.hxx \
Handle_GEOM_InteractiveObject.hxx \
GEOM_AISTrihedron.hxx \
GEOM_OCCReader.cxx \
GEOM_AssemblyBuilder.cxx \
GEOM_AISShape.cxx \
+ GEOM_AISVector.cxx \
GEOM_InteractiveObject.cxx \
GEOM_AISTrihedron.cxx \
GEOM_VTKTrihedron.cxx