Fix bug 17598: restore fix for 12874 in 4.X.

This commit is contained in:
jfa 2007-12-05 12:37:56 +00:00
parent 76b38a4f25
commit 4ed263105c
5 changed files with 268 additions and 171 deletions

View File

@ -379,94 +379,93 @@ SetDeflection(float theDeflection, bool theIsRelative)
SetModified(); SetModified();
} }
void void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
GEOM_Actor:: float theDeflection,
SetShape(const TopoDS_Shape& theShape, bool theIsRelative,
float theDeflection, bool theIsVector)
bool theIsRelative) {
{ myShape = theShape;
myShape = theShape;
myVertexSource->Clear();
myVertexSource->Clear(); myIsolatedEdgeSource->Clear();
myIsolatedEdgeSource->Clear(); myOneFaceEdgeSource->Clear();
myOneFaceEdgeSource->Clear(); mySharedEdgeSource->Clear();
mySharedEdgeSource->Clear(); myWireframeFaceSource->Clear();
myWireframeFaceSource->Clear(); myShadingFaceSource->Clear();
myShadingFaceSource->Clear();
TopExp_Explorer aVertexExp (theShape,TopAbs_VERTEX);
TopExp_Explorer aVertexExp(theShape,TopAbs_VERTEX); for (; aVertexExp.More(); aVertexExp.Next())
for(; aVertexExp.More(); aVertexExp.Next()){ {
const TopoDS_Vertex& aVertex = TopoDS::Vertex(aVertexExp.Current()); const TopoDS_Vertex& aVertex = TopoDS::Vertex(aVertexExp.Current());
myVertexSource->AddVertex(aVertex); myVertexSource->AddVertex(aVertex);
} }
SetDeflection(theDeflection,theIsRelative); SetDeflection(theDeflection, theIsRelative);
// look if edges are free or shared // look if edges are free or shared
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap; TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap); TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap);
SetShape(theShape,anEdgeMap); SetShape(theShape,anEdgeMap,theIsVector);
} }
void void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
GEOM_Actor:: const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
SetShape(const TopoDS_Shape& theShape, bool theIsVector)
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap) {
{ if (theShape.ShapeType() == TopAbs_COMPOUND) {
if(theShape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator anItr(theShape); TopoDS_Iterator anItr(theShape);
for(; anItr.More(); anItr.Next()) { for (; anItr.More(); anItr.Next()) {
SetShape(anItr.Value(),theEdgeMap); SetShape(anItr.Value(),theEdgeMap,theIsVector);
} }
} }
switch(theShape.ShapeType()){ switch (theShape.ShapeType()) {
case TopAbs_WIRE: { case TopAbs_WIRE: {
TopExp_Explorer anEdgeExp(theShape,TopAbs_EDGE); TopExp_Explorer anEdgeExp(theShape,TopAbs_EDGE);
for(; anEdgeExp.More(); anEdgeExp.Next()){ for (; anEdgeExp.More(); anEdgeExp.Next()){
const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current()); const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
if(!BRep_Tool::Degenerated(anEdge)) if (!BRep_Tool::Degenerated(anEdge))
myIsolatedEdgeSource->AddEdge(anEdge); myIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
} }
break; break;
} }
case TopAbs_EDGE: { case TopAbs_EDGE: {
const TopoDS_Edge& anEdge = TopoDS::Edge(theShape); const TopoDS_Edge& anEdge = TopoDS::Edge(theShape);
if(!BRep_Tool::Degenerated(anEdge)) if (!BRep_Tool::Degenerated(anEdge))
myIsolatedEdgeSource->AddEdge(anEdge); myIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
break; break;
} }
case TopAbs_VERTEX: { case TopAbs_VERTEX: {
break; break;
} }
default: { default: {
TopExp_Explorer aFaceExp(theShape,TopAbs_FACE); TopExp_Explorer aFaceExp (theShape,TopAbs_FACE);
for(; aFaceExp.More(); aFaceExp.Next()) { for(; aFaceExp.More(); aFaceExp.Next()) {
const TopoDS_Face& aFace = TopoDS::Face(aFaceExp.Current()); const TopoDS_Face& aFace = TopoDS::Face(aFaceExp.Current());
myWireframeFaceSource->AddFace(aFace); myWireframeFaceSource->AddFace(aFace);
myShadingFaceSource->AddFace(aFace); myShadingFaceSource->AddFace(aFace);
TopExp_Explorer anEdgeExp(aFaceExp.Current(), TopAbs_EDGE); TopExp_Explorer anEdgeExp(aFaceExp.Current(), TopAbs_EDGE);
for(; anEdgeExp.More(); anEdgeExp.Next()) { for(; anEdgeExp.More(); anEdgeExp.Next()) {
const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current()); const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
if(!BRep_Tool::Degenerated(anEdge)){ if(!BRep_Tool::Degenerated(anEdge)){
// compute the number of faces // compute the number of faces
int aNbOfFaces = theEdgeMap.FindFromKey(anEdge).Extent(); int aNbOfFaces = theEdgeMap.FindFromKey(anEdge).Extent();
switch(aNbOfFaces){ switch(aNbOfFaces){
case 0: // isolated edge case 0: // isolated edge
myIsolatedEdgeSource->AddEdge(anEdge); myIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
break; break;
case 1: // edge in only one face case 1: // edge in only one face
myOneFaceEdgeSource->AddEdge(anEdge); myOneFaceEdgeSource->AddEdge(anEdge,theIsVector);
break; break;
default: // edge shared by at least two faces default: // edge shared by at least two faces
mySharedEdgeSource->AddEdge(anEdge); mySharedEdgeSource->AddEdge(anEdge,theIsVector);
} }
} }
} }
} }
} }
} }
} }
// OLD METHODS // OLD METHODS
void GEOM_Actor::setDeflection(double adef) { void GEOM_Actor::setDeflection(double adef) {

View File

@ -32,54 +32,55 @@
#include "GEOM_OBJECT_defs.hxx" #include "GEOM_OBJECT_defs.hxx"
#include "SALOME_Actor.h" #include "SALOME_Actor.h"
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include "GEOM_SmartPtr.h" #include "GEOM_SmartPtr.h"
#include <vtkSmartPointer.h> #include <vtkSmartPointer.h>
class GEOM_VertexSource; class GEOM_VertexSource;
typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource; typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
class GEOM_EdgeSource; class GEOM_EdgeSource;
typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource; typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
class GEOM_WireframeFace; class GEOM_WireframeFace;
typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource; typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
class GEOM_ShadingFace; class GEOM_ShadingFace;
typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource; typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
class vtkRenderer; class vtkRenderer;
class vtkAppendPolyData; class vtkAppendPolyData;
typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter; typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
{ {
public: public:
vtkTypeMacro(GEOM_Actor,SALOME_Actor); vtkTypeMacro(GEOM_Actor,SALOME_Actor);
static GEOM_Actor* New(); static GEOM_Actor* New();
void SetShape(const TopoDS_Shape& theShape, void SetShape(const TopoDS_Shape& theShape,
float theDeflection, float theDeflection,
bool theIsRelative); bool theIsRelative,
bool theIsVector = false);
void SetDeflection(float theDeflection, bool theIsRelative);
float GetDeflection() const{ return myDeflection;} void SetDeflection(float theDeflection, bool theIsRelative);
bool GetIsRelative() const{ return myIsRelative;} float GetDeflection() const{ return myDeflection;}
bool GetIsRelative() const{ return myIsRelative;}
void AddToRender(vtkRenderer* theRenderer);
void AddToRender(vtkRenderer* theRenderer);
void RemoveFromRender(vtkRenderer* theRenderer); void RemoveFromRender(vtkRenderer* theRenderer);
enum EDisplayMode{ eWireframe, eShading}; enum EDisplayMode{ eWireframe, eShading};
/* void SetDisplayMode(EDisplayMode theMode); */ /* void SetDisplayMode(EDisplayMode theMode); */
/* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */ /* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */
void SetSelected(bool theIsSelected); void SetSelected(bool theIsSelected);
bool IsSelected() const { return myIsSelected;} bool IsSelected() const { return myIsSelected;}
// OLD METHODS // OLD METHODS
// Properties // Properties
@ -108,7 +109,7 @@ public:
// SubShape // SubShape
void SubShapeOn(); void SubShapeOn();
void SubShapeOff(); void SubShapeOff();
// Highlight // Highlight
virtual void highlight(bool theHighlight); virtual void highlight(bool theHighlight);
virtual bool hasHighlight() { return true; } virtual bool hasHighlight() { return true; }
@ -130,19 +131,19 @@ public:
virtual virtual
void void
Highlight(bool theHighlight); Highlight(bool theHighlight);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//! To process prehighlight (called from #SVTK_InteractorStyle) //! To process prehighlight (called from #SVTK_InteractorStyle)
virtual virtual
bool bool
PreHighlight(vtkInteractorStyle* theInteractorStyle, PreHighlight(vtkInteractorStyle* theInteractorStyle,
SVTK_SelectionEvent* theSelectionEvent, SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight); bool theIsHighlight);
//! To process highlight (called from #SVTK_InteractorStyle) //! To process highlight (called from #SVTK_InteractorStyle)
virtual virtual
bool bool
Highlight(vtkInteractorStyle* theInteractorStyle, Highlight(vtkInteractorStyle* theInteractorStyle,
SVTK_SelectionEvent* theSelectionEvent, SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight); bool theIsHighlight);
@ -157,63 +158,64 @@ public:
virtual virtual
void void
SetNbIsos(const int theNb[2]); SetNbIsos(const int theNb[2]);
virtual virtual
void void
GetNbIsos(int &theNbU,int &theNbV); GetNbIsos(int &theNbU,int &theNbV);
protected: protected:
void SetShape(const TopoDS_Shape& theShape, void SetShape(const TopoDS_Shape& theShape,
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap); const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
bool theIsVector = false);
void SetModified();
void SetModified();
void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result); void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
GEOM_Actor(); GEOM_Actor();
~GEOM_Actor(); ~GEOM_Actor();
private: private:
TopoDS_Shape myShape; TopoDS_Shape myShape;
int myNbIsos[2]; int myNbIsos[2];
float myDeflection; float myDeflection;
bool myIsRelative; bool myIsRelative;
bool myIsForced; bool myIsForced;
// EDisplayMode myDisplayMode; // EDisplayMode myDisplayMode;
bool myIsSelected; bool myIsSelected;
PDeviceActor myVertexActor; PDeviceActor myVertexActor;
PVertexSource myVertexSource; PVertexSource myVertexSource;
PDeviceActor myIsolatedEdgeActor; PDeviceActor myIsolatedEdgeActor;
PEdgeSource myIsolatedEdgeSource; PEdgeSource myIsolatedEdgeSource;
PDeviceActor myOneFaceEdgeActor; PDeviceActor myOneFaceEdgeActor;
PEdgeSource myOneFaceEdgeSource; PEdgeSource myOneFaceEdgeSource;
PDeviceActor mySharedEdgeActor; PDeviceActor mySharedEdgeActor;
PEdgeSource mySharedEdgeSource; PEdgeSource mySharedEdgeSource;
PDeviceActor myWireframeFaceActor; PDeviceActor myWireframeFaceActor;
PWFaceSource myWireframeFaceSource; PWFaceSource myWireframeFaceSource;
PDeviceActor myShadingFaceActor; PDeviceActor myShadingFaceActor;
PSFaceSource myShadingFaceSource; PSFaceSource myShadingFaceSource;
PDeviceActor myHighlightActor; PDeviceActor myHighlightActor;
vtkSmartPointer<vtkProperty> myHighlightProp; vtkSmartPointer<vtkProperty> myHighlightProp;
vtkSmartPointer<vtkProperty> myPreHighlightProp; vtkSmartPointer<vtkProperty> myPreHighlightProp;
vtkSmartPointer<vtkProperty> myShadingFaceProp; vtkSmartPointer<vtkProperty> myShadingFaceProp;
PAppendFilter myAppendFilter; PAppendFilter myAppendFilter;
PPolyDataMapper myPolyDataMapper; PPolyDataMapper myPolyDataMapper;
virtual void SetMapper(vtkMapper*); virtual void SetMapper(vtkMapper*);
GEOM_Actor(const GEOM_Actor&); GEOM_Actor(const GEOM_Actor&);
void operator=(const GEOM_Actor&); void operator=(const GEOM_Actor&);
}; };
#endif //GEOM_ACTOR_H #endif //GEOM_ACTOR_H

View File

@ -207,7 +207,7 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap
vtkActorCollection* AISActors = vtkActorCollection::New(); vtkActorCollection* AISActors = vtkActorCollection::New();
MeshShape(myShape,deflection,forced); MeshShape(myShape,deflection,forced);
GEOM_Actor* aGeomActor = GEOM_Actor::New(); GEOM_Actor* aGeomActor = GEOM_Actor::New();
aGeomActor->SetShape(myShape,(float)deflection,false); aGeomActor->SetShape(myShape,(float)deflection,false,isVector);
AISActors->AddItem(aGeomActor); AISActors->AddItem(aGeomActor);
aGeomActor->Delete(); aGeomActor->Delete();

View File

@ -23,14 +23,14 @@ GEOM_EdgeSource::GEOM_EdgeSource()
GEOM_EdgeSource::~GEOM_EdgeSource() GEOM_EdgeSource::~GEOM_EdgeSource()
{ {
} }
void void GEOM_EdgeSource::AddEdge (const TopoDS_Edge& theEdge,
GEOM_EdgeSource:: bool theIsVector)
AddEdge(const TopoDS_Edge& theEdge) {
{ myEdgeSet.Add(theEdge);
myEdgeSet.Add(theEdge); myIsVector = theIsVector;
} }
void void
GEOM_EdgeSource:: GEOM_EdgeSource::
Execute() Execute()
@ -41,25 +41,24 @@ Execute()
aPolyData->SetPoints(aPts); aPolyData->SetPoints(aPts);
aPts->Delete(); aPts->Delete();
TEdgeSet::Iterator anIter(myEdgeSet); TEdgeSet::Iterator anIter (myEdgeSet);
for(; anIter.More(); anIter.Next()){ for (; anIter.More(); anIter.Next()) {
const TopoDS_Edge& anEdge = anIter.Value(); const TopoDS_Edge& anEdge = anIter.Value();
OCC2VTK(anEdge,aPolyData,aPts); OCC2VTK(anEdge,aPolyData,aPts,myIsVector);
} }
} }
void void GEOM_EdgeSource::OCC2VTK (const TopoDS_Edge& theEdge,
GEOM_EdgeSource:: vtkPolyData* thePolyData,
OCC2VTK(const TopoDS_Edge& theEdge, vtkPoints* thePts,
vtkPolyData* thePolyData, bool theIsVector)
vtkPoints* thePts)
{ {
Handle(Poly_PolygonOnTriangulation) aEdgePoly; Handle(Poly_PolygonOnTriangulation) aEdgePoly;
Standard_Integer i = 1; Standard_Integer i = 1;
Handle(Poly_Triangulation) T; Handle(Poly_Triangulation) T;
TopLoc_Location aEdgeLoc; TopLoc_Location aEdgeLoc;
BRep_Tool::PolygonOnTriangulation(theEdge, aEdgePoly, T, aEdgeLoc, i); BRep_Tool::PolygonOnTriangulation(theEdge, aEdgePoly, T, aEdgeLoc, i);
Handle(Poly_Polygon3D) P; Handle(Poly_Polygon3D) P;
if(aEdgePoly.IsNull()) if(aEdgePoly.IsNull())
P = BRep_Tool::Polygon3D(theEdge, aEdgeLoc); P = BRep_Tool::Polygon3D(theEdge, aEdgeLoc);
@ -76,24 +75,29 @@ OCC2VTK(const TopoDS_Edge& theEdge,
edgeTransf = aEdgeLoc.Transformation(); edgeTransf = aEdgeLoc.Transformation();
} }
gp_Pnt aP1, aP2;
if (aEdgePoly.IsNull()) { if (aEdgePoly.IsNull()) {
Standard_Integer aNbNodes = P->NbNodes(); Standard_Integer aNbNodes = P->NbNodes();
const TColgp_Array1OfPnt& aNodesP = P->Nodes(); const TColgp_Array1OfPnt& aNodesP = P->Nodes();
for(int j = 1; j < aNbNodes; j++){ aP1 = aNodesP(1);
aP2 = aNodesP(aNbNodes);
for (int j = 1; j < aNbNodes; j++) {
gp_Pnt pt1 = aNodesP(j); gp_Pnt pt1 = aNodesP(j);
gp_Pnt pt2 = aNodesP(j+1); gp_Pnt pt2 = aNodesP(j+1);
if(!isidtrsf) { if (!isidtrsf) {
// apply edge transformation // apply edge transformation
pt1.Transform(edgeTransf); pt1.Transform(edgeTransf);
pt2.Transform(edgeTransf); pt2.Transform(edgeTransf);
} }
float aCoord1[3] = {pt1.X(), pt1.Y(), pt1.Z()}; float aCoord1[3] = {pt1.X(), pt1.Y(), pt1.Z()};
vtkIdType anIds[2]; vtkIdType anIds[2];
anIds[0] = thePts->InsertNextPoint(aCoord1); anIds[0] = thePts->InsertNextPoint(aCoord1);
float aCoord2[3] = {pt2.X(), pt2.Y(), pt2.Z()}; float aCoord2[3] = {pt2.X(), pt2.Y(), pt2.Z()};
anIds[1] = thePts->InsertNextPoint(aCoord2); anIds[1] = thePts->InsertNextPoint(aCoord2);
@ -104,6 +108,9 @@ OCC2VTK(const TopoDS_Edge& theEdge,
const TColStd_Array1OfInteger& aNodeIds = aEdgePoly->Nodes(); const TColStd_Array1OfInteger& aNodeIds = aEdgePoly->Nodes();
const TColgp_Array1OfPnt& anId2Pnts = T->Nodes(); const TColgp_Array1OfPnt& anId2Pnts = T->Nodes();
aP1 = anId2Pnts(1);
aP2 = anId2Pnts(aNbNodes);
for(int j = 1; j < aNbNodes; j++) { for(int j = 1; j < aNbNodes; j++) {
Standard_Integer id1 = aNodeIds(j); Standard_Integer id1 = aNodeIds(j);
Standard_Integer id2 = aNodeIds(j+1); Standard_Integer id2 = aNodeIds(j+1);
@ -113,18 +120,102 @@ OCC2VTK(const TopoDS_Edge& theEdge,
if(!isidtrsf) { if(!isidtrsf) {
// apply edge transformation // apply edge transformation
pt1.Transform(edgeTransf); pt1.Transform(edgeTransf);
pt2.Transform(edgeTransf); pt2.Transform(edgeTransf);
} }
float aCoord1[3] = {pt1.X(), pt1.Y(), pt1.Z()}; float aCoord1[3] = {pt1.X(), pt1.Y(), pt1.Z()};
vtkIdType anIds[2]; vtkIdType anIds[2];
anIds[0] = thePts->InsertNextPoint(aCoord1); anIds[0] = thePts->InsertNextPoint(aCoord1);
float aCoord2[3] = {pt2.X(), pt2.Y(), pt2.Z()}; float aCoord2[3] = {pt2.X(), pt2.Y(), pt2.Z()};
anIds[1] = thePts->InsertNextPoint(aCoord2); anIds[1] = thePts->InsertNextPoint(aCoord2);
thePolyData->InsertNextCell(VTK_LINE,2,anIds); thePolyData->InsertNextCell(VTK_LINE,2,anIds);
} }
} }
}
// vector representation has an arrow on its end
if (theIsVector)
{
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] = {xo, yo, zo};
vtkIdType ptLoc = thePts->InsertNextPoint(coord);
vtkIdType ptFirst = 0;
vtkIdType ptPrev = 0;
vtkIdType ptCur = 0;
vtkIdType 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 = thePts->InsertNextPoint(coord);
pts[0] = ptCur;
if (i == 1) {
ptFirst = ptCur;
}
else {
// insert line (ptCur,ptPrev)
pts[1] = ptPrev;
thePolyData->InsertNextCell(VTK_LINE,2,pts);
}
// insert line (ptCur,ptLoc)
pts[1] = ptLoc;
thePolyData->InsertNextCell(VTK_LINE,2,pts);
}
// insert line (ptCur,ptFirst)
pts[0] = ptCur;
pts[1] = ptFirst;
thePolyData->InsertNextCell(VTK_LINE,2,pts);
}
}

View File

@ -17,16 +17,21 @@ public:
vtkTypeMacro(GEOM_EdgeSource,vtkPolyDataSource); vtkTypeMacro(GEOM_EdgeSource,vtkPolyDataSource);
static GEOM_EdgeSource* New(); static GEOM_EdgeSource* New();
void AddEdge(const TopoDS_Edge& theEdge); void AddEdge (const TopoDS_Edge& theEdge,
bool theIsVector = false);
void Clear(){ myEdgeSet.Clear();} void Clear(){ myEdgeSet.Clear();}
static static
void OCC2VTK(const TopoDS_Edge& theEdge, void OCC2VTK(const TopoDS_Edge& theEdge,
vtkPolyData* thePolyData, vtkPolyData* thePolyData,
vtkPoints* thePts); vtkPoints* thePts,
bool theIsVector = false);
protected: protected:
TEdgeSet myEdgeSet; TEdgeSet myEdgeSet;
// The <myIsVector> flag is common for all edges, because the shape,
// representing a vector, can have only one edge.
bool myIsVector;
void Execute(); void Execute();