myTransformFilter(VTKViewer_TransformFilter::New())
{
vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
- myPolygonOffsetUnits);
+ myPolygonOffsetUnits);
for(int i = 0; i < 6; i++)
myPassFilter.push_back(vtkPassThroughFilter::New());
vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
- myPolygonOffsetUnits);
+ myPolygonOffsetUnits);
Superclass::Render(ren,m);
vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
void
VTKViewer_Actor
::SetPolygonOffsetParameters(vtkFloatingPointType factor,
- vtkFloatingPointType units)
+ vtkFloatingPointType units)
{
myPolygonOffsetFactor = factor;
myPolygonOffsetUnits = units;
void
VTKViewer_Actor
::GetPolygonOffsetParameters(vtkFloatingPointType& factor,
- vtkFloatingPointType& units)
+ vtkFloatingPointType& units)
{
factor = myPolygonOffsetFactor;
units = myPolygonOffsetUnits;
void
VTKViewer_Actor
::SetColor(vtkFloatingPointType r,
- vtkFloatingPointType g,
- vtkFloatingPointType b)
+ vtkFloatingPointType g,
+ vtkFloatingPointType b)
{
GetProperty()->SetColor(r,g,b);
}
void
VTKViewer_Actor
::GetColor(vtkFloatingPointType& r,
- vtkFloatingPointType& g,
- vtkFloatingPointType& b)
+ vtkFloatingPointType& g,
+ vtkFloatingPointType& b)
{
vtkFloatingPointType aColor[3];
GetProperty()->GetColor(aColor);
virtual
void
SetColor(vtkFloatingPointType r,
- vtkFloatingPointType g,
- vtkFloatingPointType b);
+ vtkFloatingPointType g,
+ vtkFloatingPointType b);
//! Get current color
virtual
void
GetColor(vtkFloatingPointType& r,
- vtkFloatingPointType& g,
- vtkFloatingPointType& b);
+ vtkFloatingPointType& g,
+ vtkFloatingPointType& b);
//! Change color
virtual
//! Set ResolveCoincidentTopology parameters
void
SetPolygonOffsetParameters(vtkFloatingPointType factor,
- vtkFloatingPointType units);
+ vtkFloatingPointType units);
//! Get current ResolveCoincidentTopology parameters
void
GetPolygonOffsetParameters(vtkFloatingPointType& factor,
- vtkFloatingPointType& units);
+ vtkFloatingPointType& units);
virtual
void
template<typename TActor, typename TFunction>
TFunction ForEach(vtkActorCollection *theCollection, TFunction theFun)
{
- if(theCollection){
- theCollection->InitTraversal();
- while(vtkActor *anAct = theCollection->GetNextActor())
- if(TActor *anActor = dynamic_cast<TActor*>(anAct))
- theFun(anActor);
- }
- return theFun;
+ if(theCollection){
+ theCollection->InitTraversal();
+ while(vtkActor *anAct = theCollection->GetNextActor())
+ if(TActor *anActor = dynamic_cast<TActor*>(anAct))
+ theFun(anActor);
+ }
+ return theFun;
}
/*!For each actor(for ex: someActor) from \a theCollection(that can be dynamic cast to type TActor and \n
*/
template<typename TActor, typename TPredicate, typename TFunction>
TFunction ForEachIf(vtkActorCollection *theCollection,
- TPredicate thePredicate,
- TFunction theFun)
+ TPredicate thePredicate,
+ TFunction theFun)
{
- if(theCollection){
- theCollection->InitTraversal();
- while(vtkActor *anAct = theCollection->GetNextActor())
- if(TActor *anActor = dynamic_cast<TActor*>(anAct))
- if(thePredicate(anActor))
- theFun(anActor);
- }
- return theFun;
+ if(theCollection){
+ theCollection->InitTraversal();
+ while(vtkActor *anAct = theCollection->GetNextActor())
+ if(TActor *anActor = dynamic_cast<TActor*>(anAct))
+ if(thePredicate(anActor))
+ theFun(anActor);
+ }
+ return theFun;
}
/*!Find actor from collection, that can be dynamicaly cast to \a TActor, \n
template<typename TActor, typename TPredicate>
TActor* Find(vtkActorCollection *theCollection, TPredicate thePredicate)
{
- if(theCollection){
- theCollection->InitTraversal();
- while(vtkActor *anAct = theCollection->GetNextActor())
- if(TActor *anActor = dynamic_cast<TActor*>(anAct))
- if(thePredicate(anActor))
- return anActor;
- }
- return NULL;
+ if(theCollection){
+ theCollection->InitTraversal();
+ while(vtkActor *anAct = theCollection->GetNextActor())
+ if(TActor *anActor = dynamic_cast<TActor*>(anAct))
+ if(thePredicate(anActor))
+ return anActor;
+ }
+ return NULL;
}
}
int
VTKViewer_AppendFilter
::RequestData(
- vtkInformation *request,
- vtkInformationVector **inputVector,
- vtkInformationVector *outputVector)
+ vtkInformation *request,
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
{
int aRet = 0;
if(GetSharedPointsDataSet())
inline
vtkIdType
GetOutputID(vtkIdType theInputID,
- vtkIdType theInputDataSetID,
- const VTKViewer_AppendFilter::TVectorIds& theRanges)
+ vtkIdType theInputDataSetID,
+ const VTKViewer_AppendFilter::TVectorIds& theRanges)
{
theInputID = theInputDataSetID = -1;
vtkIdType
VTKViewer_AppendFilter
::GetPointOutputID(vtkIdType theInputID,
- vtkIdType theInputDataSetID)
+ vtkIdType theInputDataSetID)
{
if(GetSharedPointsDataSet())
return theInputID;
vtkIdType
VTKViewer_AppendFilter
::GetCellOutputID(vtkIdType theInputID,
- vtkIdType theInputDataSetID)
+ vtkIdType theInputDataSetID)
{
if(GetSharedPointsDataSet())
return theInputID;
{
void
GetInputID(vtkIdType theOutputID,
- vtkIdType& theInputID,
- vtkIdType& theStartID,
- vtkIdType& theInputDataSetID,
- const VTKViewer_AppendFilter::TVectorIds& theRanges)
+ vtkIdType& theInputID,
+ vtkIdType& theStartID,
+ vtkIdType& theInputDataSetID,
+ const VTKViewer_AppendFilter::TVectorIds& theRanges)
{
theInputID = theStartID = theInputDataSetID = -1;
for(vtkIdType aDataSetId = 0; aDataSetId < aNbInputs; ++aDataSetId){
vtkIdType aRange = theRanges[aDataSetId];
if(aRange > theOutputID){
- theInputID = theOutputID - aStartId;
- theInputDataSetID = aDataSetId;
- theStartID = aStartId;
- break;
+ theInputID = theOutputID - aStartId;
+ theInputDataSetID = aDataSetId;
+ theStartID = aStartId;
+ break;
}
aStartId = aRange;
}
void
VTKViewer_AppendFilter
::GetPointInputID(vtkIdType theOutputID,
- vtkIdType& theInputID,
- vtkIdType& theStartID,
- vtkIdType& theInputDataSetID)
+ vtkIdType& theInputID,
+ vtkIdType& theStartID,
+ vtkIdType& theInputDataSetID)
{
if(GetSharedPointsDataSet()) {
theStartID = theInputDataSetID = 0;
}
::GetInputID(theOutputID,
- theInputID,
- theStartID,
- theInputDataSetID,
- myNodeRanges);
+ theInputID,
+ theStartID,
+ theInputDataSetID,
+ myNodeRanges);
}
void
VTKViewer_AppendFilter
::GetCellInputID(vtkIdType theOutputID,
- vtkIdType& theInputID,
- vtkIdType& theStartID,
- vtkIdType& theInputDataSetID)
+ vtkIdType& theInputID,
+ vtkIdType& theStartID,
+ vtkIdType& theInputDataSetID)
{
::GetInputID(theOutputID,
- theInputID,
- theStartID,
- theInputDataSetID,
- myCellRanges);
+ theInputID,
+ theStartID,
+ theInputDataSetID,
+ myCellRanges);
}
vtkIdType
GetPointOutputID(vtkIdType theInputID,
- vtkIdType theInputDataSetID);
+ vtkIdType theInputDataSetID);
vtkIdType
GetCellOutputID(vtkIdType theInputID,
- vtkIdType theInputDataSetID);
+ vtkIdType theInputDataSetID);
void
GetPointInputID(vtkIdType theOutputID,
- vtkIdType& theInputID,
- vtkIdType& theStartID,
- vtkIdType& theInputDataSetID);
+ vtkIdType& theInputID,
+ vtkIdType& theStartID,
+ vtkIdType& theInputDataSetID);
void
GetCellInputID(vtkIdType theOutputID,
- vtkIdType& theInputID,
- vtkIdType& theStartID,
- vtkIdType& theInputDataSetID);
+ vtkIdType& theInputID,
+ vtkIdType& theStartID,
+ vtkIdType& theInputDataSetID);
typedef std::vector<vtkIdType> TVectorIds;
Pnt::Pnt(double X,
double Y,
double Z,
- double ScalarValue):
+ double ScalarValue):
coord(X,Y,Z),
scalarValue(ScalarValue)
{
for(vtkIdType idx = 1; idx < aNbPts-1;idx++) {
curID = output->GetPoints()->InsertNextPoint(aPoints->GetPoint(idx));
if( outputScalars )
- outputScalars->InsertNextTuple1(aScalarValues[idx]);
+ outputScalars->InsertNextTuple1(aScalarValues[idx]);
aNewPoints[idx] = curID;
}
aNewPoints[aNbPts-1] = pts[1];
* Array theIds - it is array with ids of added points.
*/
vtkIdType MergevtkPoints(const std::vector<vtkPoints*>& theCollection,
- const std::vector< std::vector<double> >& theScalarCollection,
- vtkPoints* thePoints,
- std::map<int, double>& thePntId2ScalarValue,
- vtkIdType* &theIds){
+ const std::vector< std::vector<double> >& theScalarCollection,
+ vtkPoints* thePoints,
+ std::map<int, double>& thePntId2ScalarValue,
+ vtkIdType* &theIds){
vtkIdType aNbPoints = 0;
vtkIdType anIdCounter = 0;
vtkIdType aNewPntId = 0;
for(vtkIdType idx = 0;idx < aPoints->GetNumberOfPoints()-1;idx++){
aNewPntId = thePoints->InsertNextPoint(aPoints->GetPoint(idx));
theIds[anIdCounter] = aNewPntId;
- thePntId2ScalarValue[ aNewPntId ] = aScalarValues[idx];
+ thePntId2ScalarValue[ aNewPntId ] = aScalarValues[idx];
anIdCounter++;
}
}
typedef std::list<Pnt> PntList;
vtkIdType MergevtkPoints(const std::vector<vtkPoints*>& theCollection,
- const std::vector< std::vector<double> >& theScalarCollection,
+ const std::vector< std::vector<double> >& theScalarCollection,
vtkPoints* thePoints,
- std::map<int, double>& thePntId2ScalarValue,
+ std::map<int, double>& thePntId2ScalarValue,
vtkIdType* &theIds);
vtkIdType Build1DArc(vtkIdType cellId,
vtkFloatingPointType myMaxArcAngle);
Pnt CreatePnt(vtkCell* cell,
- vtkDataArray* scalars,
- vtkIdType index);
+ vtkDataArray* scalars,
+ vtkIdType index);
/*!
* Class for represenation coordinates X,Y,Z
void CalculatePlane(const Pnt& thePnt1, const Pnt& thePnt2, const Pnt& thePnt3);
private:
- double myA;
- double myB;
- double myC;
+ double myA;
+ double myB;
+ double myC;
};
public:
enum ArcStatus {Arc_Done=0, Arc_Error};
VTKViewer_ArcBuilder(const Pnt& thePnt1,
- const Pnt& thePnt2,
- const Pnt& thePnt3,
- double theAngle);
+ const Pnt& thePnt2,
+ const Pnt& thePnt3,
+ double theAngle);
~VTKViewer_ArcBuilder();
void GetAngle(const double theAngle);
static double GetPointAngleOnCircle(const double theXCenter, const double theYCenter,
- const double theXPoint, const double theYPoint);
+ const double theXPoint, const double theYPoint);
vtkPoints* GetPoints();
const std::vector<double>& GetScalarValues();
vtkFloatingPointType myOrigin[3];
vtkFloatingPointType myNormal[3];
TPolygon(const TConnectivities& theConnectivities,
- vtkFloatingPointType theOrigin[3],
- vtkFloatingPointType theNormal[3]):
+ vtkFloatingPointType theOrigin[3],
+ vtkFloatingPointType theNormal[3]):
myConnectivities(theConnectivities)
{
myOrigin[0] = theOrigin[0];
vtkPoints*
VTKViewer_Triangulator
::InitPoints(vtkUnstructuredGrid *theInput,
- vtkIdType theCellId)
+ vtkIdType theCellId)
{
myPoints->Reset();
myPoints->Modified(); // the VTK bug
aCoordDiff[2] = (aBounds[5] - aBounds[4]);
return sqrt(aCoordDiff[0]*aCoordDiff[0] +
- aCoordDiff[1]*aCoordDiff[1] +
- aCoordDiff[2]*aCoordDiff[2]);
+ aCoordDiff[1]*aCoordDiff[1] +
+ aCoordDiff[2]*aCoordDiff[2]);
}
void
VTKViewer_Triangulator
::GetCellNeighbors(vtkUnstructuredGrid *theInput,
- vtkIdType theCellId,
- vtkCell* theFace,
- vtkIdList* theCellIds)
+ vtkIdType theCellId,
+ vtkCell* theFace,
+ vtkIdList* theCellIds)
{
myFaceIds->Reset();
vtkIdList *anIdList = theFace->PointIds;
bool
VTKViewer_Triangulator
::Execute(vtkUnstructuredGrid *theInput,
- vtkCellData* thInputCD,
- vtkIdType theCellId,
- int theShowInside,
- int theAllVisible,
- const char* theCellsVisibility,
- vtkPolyData *theOutput,
- vtkCellData* theOutputCD,
- int theStoreMapping,
- std::vector<vtkIdType>& theVTK2ObjIds,
- bool theIsCheckConvex)
+ vtkCellData* thInputCD,
+ vtkIdType theCellId,
+ int theShowInside,
+ int theAllVisible,
+ const char* theCellsVisibility,
+ vtkPolyData *theOutput,
+ vtkCellData* theOutputCD,
+ int theStoreMapping,
+ std::vector<vtkIdType>& theVTK2ObjIds,
+ bool theIsCheckConvex)
{
vtkPoints *aPoints = InitPoints(theInput, theCellId);
vtkIdType aNumPts = GetNbOfPoints();
vtkIdList *anIdList = aFace->PointIds;
vtkIdType aNewPts[3] = {anIdList->GetId(0), anIdList->GetId(1), anIdList->GetId(2)};
-
+
// To initialize set of points for the plane where the trinangle face belong to
TPointIds aPointIds;
aPointIds.insert(aNewPts[0]);
/* To calculate plane normal for face (aFace)
- ^ aNormal
- |
- | ^ aVector01
- | /
- /_________> aVector02
+ ^ aNormal
+ |
+ | ^ aVector01
+ | /
+ /_________> aVector02
*/
vtkFloatingPointType aVector01[3] = { aCoord[1][0] - aCoord[0][0],
- aCoord[1][1] - aCoord[0][1],
- aCoord[1][2] - aCoord[0][2] };
+ aCoord[1][1] - aCoord[0][1],
+ aCoord[1][2] - aCoord[0][2] };
vtkFloatingPointType aVector02[3] = { aCoord[2][0] - aCoord[0][0],
- aCoord[2][1] - aCoord[0][1],
- aCoord[2][2] - aCoord[0][2] };
+ aCoord[2][1] - aCoord[0][1],
+ aCoord[2][2] - aCoord[0][2] };
vtkMath::Normalize(aVector01);
vtkMath::Normalize(aVector02);
// To calculate bounds of the point set
vtkFloatingPointType aCenter[3] = {0.0, 0.0, 0.0};
{
- TPointIds::const_iterator anIter = anInitialPointIds.begin();
- TPointIds::const_iterator anEndIter = anInitialPointIds.end();
- for(; anIter != anEndIter; anIter++){
- vtkFloatingPointType aPntCoord[3];
- vtkIdType aPntId = *anIter;
- aPoints->GetPoint(aPntId,aPntCoord);
-
- vtkFloatingPointType aVector0Pnt[3] = { aPntCoord[0] - aCoord[0][0],
- aPntCoord[1] - aCoord[0][1],
- aPntCoord[2] - aCoord[0][2] };
-
-
- vtkMath::Normalize(aVector0Pnt);
-
- vtkFloatingPointType aNormalPnt[3];
- // calculate aNormalPnt
- {
- vtkFloatingPointType aCosPnt01 = vtkMath::Dot(aVector0Pnt,aVector01);
- vtkFloatingPointType aCosPnt02 = vtkMath::Dot(aVector0Pnt,aVector02);
- if(aCosPnt01<-1)
- aCosPnt01 = -1;
- if(aCosPnt01>1)
- aCosPnt01 = 1;
- if(aCosPnt02<-1)
- aCosPnt02 = -1;
- if(aCosPnt02>1)
- aCosPnt02 = 1;
-
- vtkFloatingPointType aDist01,aDist02;// deflection from Pi/3 angle (equilateral triangle)
- vtkFloatingPointType aAngPnt01 = fabs(acos(aCosPnt01));
- vtkFloatingPointType aAngPnt02 = fabs(acos(aCosPnt02));
-
- /* check that triangle similar to equilateral triangle
- AOC or COB ?
- aVector0Pnt = (OC)
- aVector01 = (OB)
- aVector02 = (OA)
-
- B
- ^ aVector01 C
- | ^ aVector0Pnt
- | _____/
- | ___/
- |/________> aVector02
- O A
- */
- aDist01 = fabs(aAngPnt01-(vtkMath::Pi())/3.0);
- aDist02 = fabs(aAngPnt02-(vtkMath::Pi())/3.0);
-
- // caculate a normal for best triangle
- if(aDist01 <= aDist02)
- vtkMath::Cross(aVector0Pnt,aVector01,aNormalPnt);
- else
- vtkMath::Cross(aVector0Pnt,aVector02,aNormalPnt);
-
- }
-
- vtkMath::Normalize(aNormalPnt);
-
- if(DEBUG_TRIA_EXECUTE)
- cout<<"\t\taPntId = "<<aPntId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"};";
-
- vtkFloatingPointType aDist = vtkPlane::DistanceToPlane(aPntCoord,aNormal,aCoord[0]);
- if(DEBUG_TRIA_EXECUTE) cout<<": aDist = "<<aDist;
- if(fabs(aDist) < aDistEps){
- aPointIds.insert(aPntId);
- aCenter[0] += aPntCoord[0];
- aCenter[1] += aPntCoord[1];
- aCenter[2] += aPntCoord[2];
- if(DEBUG_TRIA_EXECUTE) cout << "; Added = TRUE" << endl;
- } else {
- if(DEBUG_TRIA_EXECUTE) cout << "; Added = FALSE" << endl;
- }
- }
- int aNbPoints = aPointIds.size();
- aCenter[0] /= aNbPoints;
- aCenter[1] /= aNbPoints;
- aCenter[2] /= aNbPoints;
+ TPointIds::const_iterator anIter = anInitialPointIds.begin();
+ TPointIds::const_iterator anEndIter = anInitialPointIds.end();
+ for(; anIter != anEndIter; anIter++){
+ vtkFloatingPointType aPntCoord[3];
+ vtkIdType aPntId = *anIter;
+ aPoints->GetPoint(aPntId,aPntCoord);
+
+ vtkFloatingPointType aVector0Pnt[3] = { aPntCoord[0] - aCoord[0][0],
+ aPntCoord[1] - aCoord[0][1],
+ aPntCoord[2] - aCoord[0][2] };
+
+
+ vtkMath::Normalize(aVector0Pnt);
+
+ vtkFloatingPointType aNormalPnt[3];
+ // calculate aNormalPnt
+ {
+ vtkFloatingPointType aCosPnt01 = vtkMath::Dot(aVector0Pnt,aVector01);
+ vtkFloatingPointType aCosPnt02 = vtkMath::Dot(aVector0Pnt,aVector02);
+ if(aCosPnt01<-1)
+ aCosPnt01 = -1;
+ if(aCosPnt01>1)
+ aCosPnt01 = 1;
+ if(aCosPnt02<-1)
+ aCosPnt02 = -1;
+ if(aCosPnt02>1)
+ aCosPnt02 = 1;
+
+ vtkFloatingPointType aDist01,aDist02;// deflection from Pi/3 angle (equilateral triangle)
+ vtkFloatingPointType aAngPnt01 = fabs(acos(aCosPnt01));
+ vtkFloatingPointType aAngPnt02 = fabs(acos(aCosPnt02));
+
+ /* check that triangle similar to equilateral triangle
+ AOC or COB ?
+ aVector0Pnt = (OC)
+ aVector01 = (OB)
+ aVector02 = (OA)
+
+ B
+ ^ aVector01 C
+ | ^ aVector0Pnt
+ | _____/
+ | ___/
+ |/________> aVector02
+ O A
+ */
+ aDist01 = fabs(aAngPnt01-(vtkMath::Pi())/3.0);
+ aDist02 = fabs(aAngPnt02-(vtkMath::Pi())/3.0);
+
+ // caculate a normal for best triangle
+ if(aDist01 <= aDist02)
+ vtkMath::Cross(aVector0Pnt,aVector01,aNormalPnt);
+ else
+ vtkMath::Cross(aVector0Pnt,aVector02,aNormalPnt);
+
+ }
+
+ vtkMath::Normalize(aNormalPnt);
+
+ if(DEBUG_TRIA_EXECUTE)
+ cout<<"\t\taPntId = "<<aPntId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"};";
+
+ vtkFloatingPointType aDist = vtkPlane::DistanceToPlane(aPntCoord,aNormal,aCoord[0]);
+ if(DEBUG_TRIA_EXECUTE) cout<<": aDist = "<<aDist;
+ if(fabs(aDist) < aDistEps){
+ aPointIds.insert(aPntId);
+ aCenter[0] += aPntCoord[0];
+ aCenter[1] += aPntCoord[1];
+ aCenter[2] += aPntCoord[2];
+ if(DEBUG_TRIA_EXECUTE) cout << "; Added = TRUE" << endl;
+ } else {
+ if(DEBUG_TRIA_EXECUTE) cout << "; Added = FALSE" << endl;
+ }
+ }
+ int aNbPoints = aPointIds.size();
+ aCenter[0] /= aNbPoints;
+ aCenter[1] /= aNbPoints;
+ aCenter[2] /= aNbPoints;
}
//To sinchronize orientation of the cell and its face
vtkFloatingPointType aVectorC[3] = { aCenter[0] - aCellCenter[0],
- aCenter[1] - aCellCenter[1],
- aCenter[2] - aCellCenter[2] };
+ aCenter[1] - aCellCenter[1],
+ aCenter[2] - aCellCenter[2] };
vtkMath::Normalize(aVectorC);
vtkFloatingPointType aDot = vtkMath::Dot(aNormal,aVectorC);
if(DEBUG_TRIA_EXECUTE) {
- cout<<"\t\taNormal = {"<<aNormal[0]<<", "<<aNormal[1]<<", "<<aNormal[2]<<"}";
- cout<<"; aVectorC = {"<<aVectorC[0]<<", "<<aVectorC[1]<<", "<<aVectorC[2]<<"}\n";
- cout<<"\t\taDot = "<<aDot<<"\n";
+ cout<<"\t\taNormal = {"<<aNormal[0]<<", "<<aNormal[1]<<", "<<aNormal[2]<<"}";
+ cout<<"; aVectorC = {"<<aVectorC[0]<<", "<<aVectorC[1]<<", "<<aVectorC[2]<<"}\n";
+ cout<<"\t\taDot = "<<aDot<<"\n";
}
if(aDot > 0){
- aNormal[0] = -aNormal[0];
- aNormal[1] = -aNormal[1];
- aNormal[2] = -aNormal[2];
+ aNormal[0] = -aNormal[0];
+ aNormal[1] = -aNormal[1];
+ aNormal[2] = -aNormal[2];
}
// To calculate the primary direction for point set
vtkFloatingPointType aVector0[3] = { aCoord[0][0] - aCenter[0],
- aCoord[0][1] - aCenter[1],
- aCoord[0][2] - aCenter[2] };
+ aCoord[0][1] - aCenter[1],
+ aCoord[0][2] - aCenter[2] };
vtkMath::Normalize(aVector0);
if(DEBUG_TRIA_EXECUTE) {
- cout<<"\t\taCenter = {"<<aCenter[0]<<", "<<aCenter[1]<<", "<<aCenter[2]<<"}";
- cout<<"; aVector0 = {"<<aVector0[0]<<", "<<aVector0[1]<<", "<<aVector0[2]<<"}\n";
+ cout<<"\t\taCenter = {"<<aCenter[0]<<", "<<aCenter[1]<<", "<<aCenter[2]<<"}";
+ cout<<"; aVector0 = {"<<aVector0[0]<<", "<<aVector0[1]<<", "<<aVector0[2]<<"}\n";
}
// To calculate the set of points by face those that belong to the plane
TFace2PointIds aRemoveFace2PointIds;
{
- TFace2PointIds::const_iterator anIter = aFace2PointIds.begin();
- TFace2PointIds::const_iterator anEndIter = aFace2PointIds.end();
- for(; anIter != anEndIter; anIter++){
- const TPointIds& anIds = *anIter;
- TPointIds anIntersection;
- std::set_intersection(aPointIds.begin(),aPointIds.end(),
- anIds.begin(),anIds.end(),
- std::inserter(anIntersection,anIntersection.begin()));
-
-
- if(DEBUG_TRIA_EXECUTE) {
- cout << "anIntersection:";
- TPointIds::iterator aII = anIntersection.begin();
- for(;aII!=anIntersection.end();aII++)
- cout << *aII << ",";
- cout << endl;
- cout << "anIds :";
- TPointIds::const_iterator aIIds = anIds.begin();
- for(;aIIds!=anIds.end();aIIds++)
- cout << *aIIds << ",";
- cout << endl;
- }
- if(anIntersection == anIds){
- aRemoveFace2PointIds.insert(anIds);
- }
- }
+ TFace2PointIds::const_iterator anIter = aFace2PointIds.begin();
+ TFace2PointIds::const_iterator anEndIter = aFace2PointIds.end();
+ for(; anIter != anEndIter; anIter++){
+ const TPointIds& anIds = *anIter;
+ TPointIds anIntersection;
+ std::set_intersection(aPointIds.begin(),aPointIds.end(),
+ anIds.begin(),anIds.end(),
+ std::inserter(anIntersection,anIntersection.begin()));
+
+
+ if(DEBUG_TRIA_EXECUTE) {
+ cout << "anIntersection:";
+ TPointIds::iterator aII = anIntersection.begin();
+ for(;aII!=anIntersection.end();aII++)
+ cout << *aII << ",";
+ cout << endl;
+ cout << "anIds :";
+ TPointIds::const_iterator aIIds = anIds.begin();
+ for(;aIIds!=anIds.end();aIIds++)
+ cout << *aIIds << ",";
+ cout << endl;
+ }
+ if(anIntersection == anIds){
+ aRemoveFace2PointIds.insert(anIds);
+ }
+ }
}
// To remove from the set of points by face those that belong to the plane
{
- TFace2PointIds::const_iterator anIter = aRemoveFace2PointIds.begin();
- TFace2PointIds::const_iterator anEndIter = aRemoveFace2PointIds.end();
- for(; anIter != anEndIter; anIter++){
- const TPointIds& anIds = *anIter;
- aFace2PointIds.erase(anIds);
- }
+ TFace2PointIds::const_iterator anIter = aRemoveFace2PointIds.begin();
+ TFace2PointIds::const_iterator anEndIter = aRemoveFace2PointIds.end();
+ for(; anIter != anEndIter; anIter++){
+ const TPointIds& anIds = *anIter;
+ aFace2PointIds.erase(anIds);
+ }
}
// To sort the planar set of the points accrding to the angle
{
- typedef std::map<vtkFloatingPointType,vtkIdType> TSortedPointIds;
- TSortedPointIds aSortedPointIds;
-
- TPointIds::const_iterator anIter = aPointIds.begin();
- TPointIds::const_iterator anEndIter = aPointIds.end();
- for(; anIter != anEndIter; anIter++){
- vtkFloatingPointType aPntCoord[3];
- vtkIdType aPntId = *anIter;
- aPoints->GetPoint(aPntId,aPntCoord);
- vtkFloatingPointType aVector[3] = { aPntCoord[0] - aCenter[0],
- aPntCoord[1] - aCenter[1],
- aPntCoord[2] - aCenter[2] };
- vtkMath::Normalize(aVector);
-
- vtkFloatingPointType aCross[3];
- vtkMath::Cross(aVector,aVector0,aCross);
- vtkFloatingPointType aCr = vtkMath::Dot(aCross,aNormal);
- bool aGreaterThanPi = aCr < 0;
- vtkFloatingPointType aCosinus = vtkMath::Dot(aVector,aVector0);
- vtkFloatingPointType anAngle = 0.0;
- if(aCosinus >= 1.0){
- aCosinus = 1.0;
- } else if (aCosinus <= -1.0){
- aCosinus = -1.0;
- anAngle = vtkMath::Pi();
- } else {
- anAngle = acos(aCosinus);
- if(aGreaterThanPi)
- anAngle = 2*vtkMath::Pi() - anAngle;
- }
-
- if(DEBUG_TRIA_EXECUTE) {
- cout << "\t\t\t vtkMath::Dot(aCross,aNormal)="<<aCr<<endl;
- cout<<"\t\t\taPntId = "<<aPntId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"}";
- cout<<"; aGreaterThanPi = "<<aGreaterThanPi<<"; aCosinus = "<<aCosinus<<"; anAngle = "<<anAngle<<"\n";
- }
- aSortedPointIds[anAngle] = aPntId;
- }
-
- if(!aSortedPointIds.empty()){
- int aNumFacePts = aSortedPointIds.size();
- ::TConnectivities aConnectivities(aNumFacePts);
- TSortedPointIds::const_iterator anIter = aSortedPointIds.begin();
- TSortedPointIds::const_iterator anEndIter = aSortedPointIds.end();
- if(DEBUG_TRIA_EXECUTE) cout << "Polygon:";
- for(vtkIdType anId = 0; anIter != anEndIter; anIter++, anId++){
- vtkIdType aPntId = anIter->second;
- aConnectivities[anId] = GetConnectivity(aPntId);
- if(DEBUG_TRIA_EXECUTE) cout << aPntId << ",";
- }
- if(DEBUG_TRIA_EXECUTE) cout << endl;
- aPolygons.push_back(::TPolygon(aConnectivities,aCenter,aNormal));
- }
+ typedef std::map<vtkFloatingPointType,vtkIdType> TSortedPointIds;
+ TSortedPointIds aSortedPointIds;
+
+ TPointIds::const_iterator anIter = aPointIds.begin();
+ TPointIds::const_iterator anEndIter = aPointIds.end();
+ for(; anIter != anEndIter; anIter++){
+ vtkFloatingPointType aPntCoord[3];
+ vtkIdType aPntId = *anIter;
+ aPoints->GetPoint(aPntId,aPntCoord);
+ vtkFloatingPointType aVector[3] = { aPntCoord[0] - aCenter[0],
+ aPntCoord[1] - aCenter[1],
+ aPntCoord[2] - aCenter[2] };
+ vtkMath::Normalize(aVector);
+
+ vtkFloatingPointType aCross[3];
+ vtkMath::Cross(aVector,aVector0,aCross);
+ vtkFloatingPointType aCr = vtkMath::Dot(aCross,aNormal);
+ bool aGreaterThanPi = aCr < 0;
+ vtkFloatingPointType aCosinus = vtkMath::Dot(aVector,aVector0);
+ vtkFloatingPointType anAngle = 0.0;
+ if(aCosinus >= 1.0){
+ aCosinus = 1.0;
+ } else if (aCosinus <= -1.0){
+ aCosinus = -1.0;
+ anAngle = vtkMath::Pi();
+ } else {
+ anAngle = acos(aCosinus);
+ if(aGreaterThanPi)
+ anAngle = 2*vtkMath::Pi() - anAngle;
+ }
+
+ if(DEBUG_TRIA_EXECUTE) {
+ cout << "\t\t\t vtkMath::Dot(aCross,aNormal)="<<aCr<<endl;
+ cout<<"\t\t\taPntId = "<<aPntId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"}";
+ cout<<"; aGreaterThanPi = "<<aGreaterThanPi<<"; aCosinus = "<<aCosinus<<"; anAngle = "<<anAngle<<"\n";
+ }
+ aSortedPointIds[anAngle] = aPntId;
+ }
+
+ if(!aSortedPointIds.empty()){
+ int aNumFacePts = aSortedPointIds.size();
+ ::TConnectivities aConnectivities(aNumFacePts);
+ TSortedPointIds::const_iterator anIter = aSortedPointIds.begin();
+ TSortedPointIds::const_iterator anEndIter = aSortedPointIds.end();
+ if(DEBUG_TRIA_EXECUTE) cout << "Polygon:";
+ for(vtkIdType anId = 0; anIter != anEndIter; anIter++, anId++){
+ vtkIdType aPntId = anIter->second;
+ aConnectivities[anId] = GetConnectivity(aPntId);
+ if(DEBUG_TRIA_EXECUTE) cout << aPntId << ",";
+ }
+ if(DEBUG_TRIA_EXECUTE) cout << endl;
+ aPolygons.push_back(::TPolygon(aConnectivities,aCenter,aNormal));
+ }
}
}
}
vtkFloatingPointType* aNormal = aPolygon.myNormal;
vtkFloatingPointType* anOrigin = aPolygon.myOrigin;
if(DEBUG_TRIA_EXECUTE) {
- cout<<"\taPolygonId = "<<aPolygonId<<"\n";
- cout<<"\t\taNormal = {"<<aNormal[0]<<", "<<aNormal[1]<<", "<<aNormal[2]<<"}";
- cout<<"; anOrigin = {"<<anOrigin[0]<<", "<<anOrigin[1]<<", "<<anOrigin[2]<<"}\n";
+ cout<<"\taPolygonId = "<<aPolygonId<<"\n";
+ cout<<"\t\taNormal = {"<<aNormal[0]<<", "<<aNormal[1]<<", "<<aNormal[2]<<"}";
+ cout<<"; anOrigin = {"<<anOrigin[0]<<", "<<anOrigin[1]<<", "<<anOrigin[2]<<"}\n";
}
for(vtkIdType aPntId = 0; aPntId < aNumPts; aPntId++){
- vtkFloatingPointType aPntCoord[3];
- vtkIdType anId = GetPointId(aPntId);
- aPoints->GetPoint(anId,aPntCoord);
- vtkFloatingPointType aDist = vtkPlane::Evaluate(aNormal,anOrigin,aPntCoord);
- if(DEBUG_TRIA_EXECUTE) cout<<"\t\taPntId = "<<anId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"}; aDist = "<<aDist<<"\n";
- if(aDist < -aDistEps)
- return false;
+ vtkFloatingPointType aPntCoord[3];
+ vtkIdType anId = GetPointId(aPntId);
+ aPoints->GetPoint(anId,aPntCoord);
+ vtkFloatingPointType aDist = vtkPlane::Evaluate(aNormal,anOrigin,aPntCoord);
+ if(DEBUG_TRIA_EXECUTE) cout<<"\t\taPntId = "<<anId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"}; aDist = "<<aDist<<"\n";
+ if(aDist < -aDistEps)
+ return false;
}
}
}
if(DEBUG_TRIA_EXECUTE) cout << "PoilygonId="<<aPolygonId<<" | ";
TConnectivities& aConnectivities = aPolygon.myConnectivities;
if(DEBUG_TRIA_EXECUTE) {
- for(int i=0;i<aConnectivities.size();i++)
- cout << aConnectivities[i] << ",";
- cout << endl;
+ for(int i=0;i<aConnectivities.size();i++)
+ cout << aConnectivities[i] << ",";
+ cout << endl;
}
int aNbPoints = aConnectivities.size();
vtkIdType aNewCellId = theOutput->InsertNextCell(VTK_POLYGON,aNbPoints,&aConnectivities[0]);
if(theStoreMapping)
- theVTK2ObjIds.push_back(theCellId);
+ theVTK2ObjIds.push_back(theCellId);
theOutputCD->CopyData(thInputCD,theCellId,aNewCellId);
}
}
vtkPoints*
VTKViewer_OrderedTriangulator
::InitPoints(vtkUnstructuredGrid *theInput,
- vtkIdType theCellId)
+ vtkIdType theCellId)
{
myBoundaryTris->Reset();
vtkPoints*
VTKViewer_DelaunayTriangulator
::InitPoints(vtkUnstructuredGrid *theInput,
- vtkIdType theCellId)
+ vtkIdType theCellId)
{
vtkPoints* aPoints = VTKViewer_Triangulator::InitPoints(theInput, theCellId);
inline void InsertCell(vtkUnstructuredGrid *theInput,
- vtkCellArray *theConnectivity,
- vtkUnsignedCharArray* theCellTypesArray,
- vtkIdType theCellId,
- vtkIdList *theIdList,
- bool theStoreMapping,
- vtkIdType theOutId,
- VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId,
- VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId)
+ vtkCellArray *theConnectivity,
+ vtkUnsignedCharArray* theCellTypesArray,
+ vtkIdType theCellId,
+ vtkIdList *theIdList,
+ bool theStoreMapping,
+ vtkIdType theOutId,
+ VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId,
+ VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId)
{
vtkCell *aCell = theInput->GetCell(theCellId);
vtkIdList *aPntIds = aCell->GetPointIds();
}
inline void InsertPointCell(vtkCellArray *theConnectivity,
- vtkUnsignedCharArray* theCellTypesArray,
- vtkIdType theCellId,
- vtkIdList *theIdList,
- bool theStoreMapping,
- vtkIdType theOutId,
- VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId,
- VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId)
+ vtkUnsignedCharArray* theCellTypesArray,
+ vtkIdType theCellId,
+ vtkIdList *theIdList,
+ bool theStoreMapping,
+ vtkIdType theOutId,
+ VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId,
+ VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId)
{
theIdList->SetId(0,theCellId);
theConnectivity->InsertNextCell(theIdList);
// purpose :
//==================================================================
void VTKViewer_FramedTextActor::SetForegroundColor(const vtkFloatingPointType r,
- const vtkFloatingPointType g,
- const vtkFloatingPointType b)
+ const vtkFloatingPointType g,
+ const vtkFloatingPointType b)
{
myTextProperty->SetColor(r, g, b);
myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty);
// purpose :
//==================================================================
void VTKViewer_FramedTextActor::GetForegroundColor(vtkFloatingPointType& r,
- vtkFloatingPointType& g,
- vtkFloatingPointType& b)
+ vtkFloatingPointType& g,
+ vtkFloatingPointType& b)
{
vtkFloatingPointType aColor[3];
myTextProperty->GetColor(aColor);
// purpose :
//==================================================================
void VTKViewer_FramedTextActor::SetBackgroundColor(const vtkFloatingPointType r,
- const vtkFloatingPointType g,
- const vtkFloatingPointType b)
+ const vtkFloatingPointType g,
+ const vtkFloatingPointType b)
{
myBarActor->GetProperty()->SetColor(r, g, b);
Modified();
// purpose :
//==================================================================
void VTKViewer_FramedTextActor::GetBackgroundColor(vtkFloatingPointType& r,
- vtkFloatingPointType& g,
- vtkFloatingPointType& b)
+ vtkFloatingPointType& g,
+ vtkFloatingPointType& b)
{
vtkFloatingPointType aColor[3];
myBarActor->GetProperty()->GetColor(aColor);
}
PositionCoordinate->SetValue(x / (vtkFloatingPointType)aViewPortWidth,
- y / (vtkFloatingPointType)aViewPortHeight);
+ y / (vtkFloatingPointType)aViewPortHeight);
}
aPoints->SetPoint(0, xMin, yMax, 0.0);
vtkFloatingPointType GetDistance() const;
void SetForegroundColor(const vtkFloatingPointType r,
- const vtkFloatingPointType g,
- const vtkFloatingPointType b);
+ const vtkFloatingPointType g,
+ const vtkFloatingPointType b);
void GetForegroundColor(vtkFloatingPointType& r,
- vtkFloatingPointType& g,
- vtkFloatingPointType& b);
+ vtkFloatingPointType& g,
+ vtkFloatingPointType& b);
void SetBackgroundColor(const vtkFloatingPointType r,
- const vtkFloatingPointType g,
- const vtkFloatingPointType b);
+ const vtkFloatingPointType g,
+ const vtkFloatingPointType b);
void GetBackgroundColor(vtkFloatingPointType& r,
- vtkFloatingPointType& g,
- vtkFloatingPointType& b);
+ vtkFloatingPointType& g,
+ vtkFloatingPointType& b);
void SetTransparency(const vtkFloatingPointType theTransparency);
vtkFloatingPointType GetTransparency() const;
{}
void operator()(TActor* theActor)
{
- (theActor->*myAction)(myArg);
+ (theActor->*myAction)(myArg);
}
};
template<class TActor, class TArg = int> struct TSetVisibility: TSetFunction<TActor,TArg>
{
TSetVisibility(TArg theArg):
- TSetFunction<TActor,TArg>(&TActor::SetVisibility,theArg)
+ TSetFunction<TActor,TArg>(&TActor::SetVisibility,theArg)
{}
};
}
int
VTKViewer_GeometryFilter
::UnstructuredGridExecute(
- vtkDataSet *dataSetInput,
- vtkPolyData *output,
- vtkInformation *outInfo)
+ vtkDataSet *dataSetInput,
+ vtkPolyData *output,
+ vtkInformation *outInfo)
{
vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)dataSetInput;
case VTK_VERTEX:
case VTK_POLY_VERTEX:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping){
+ myVTK2ObjIds.push_back(cellId); //apo
+ }
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_LINE:
case VTK_POLY_LINE:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_QUAD:
case VTK_POLYGON:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_TRIANGLE_STRIP:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_PIXEL:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
- outputCD->CopyData(cd,cellId,newCellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ break;
+
+ case VTK_CONVEX_POINT_SET: {
+ bool anIsOk = anOrderedTriangulator.Execute(input,
+ cd,
+ cellId,
+ myShowInside,
+ allVisible,
+ cellVis,
+ output,
+ outputCD,
+ myStoreMapping,
+ myVTK2ObjIds,
+ true);
+ if(!anIsOk)
+ aDelaunayTriangulator.Execute(input,
+ cd,
+ cellId,
+ myShowInside,
+ allVisible,
+ cellVis,
+ output,
+ outputCD,
+ myStoreMapping,
+ myVTK2ObjIds,
+ false);
+
break;
-
- case VTK_CONVEX_POINT_SET: {
- bool anIsOk = anOrderedTriangulator.Execute(input,
- cd,
- cellId,
- myShowInside,
- allVisible,
- cellVis,
- output,
- outputCD,
- myStoreMapping,
- myVTK2ObjIds,
- true);
- if(!anIsOk)
- aDelaunayTriangulator.Execute(input,
- cd,
- cellId,
- myShowInside,
- allVisible,
- cellVis,
- output,
- outputCD,
- myStoreMapping,
- myVTK2ObjIds,
- false);
-
- break;
- }
+ }
case VTK_TETRA: {
for (faceId = 0; faceId < 4; faceId++)
{
faceIds->InsertNextId(pts[faceVerts[0]]);
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
- aCellType = VTK_TRIANGLE;
+ aCellType = VTK_TRIANGLE;
numFacePts = 3;
input->GetCellNeighbors(cellId, faceIds, cellIds);
if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
for ( i=0; i < numFacePts; i++)
aNewPts[i] = pts[faceVerts[i]];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
break;
- }
+ }
case VTK_VOXEL: {
for (faceId = 0; faceId < 6; faceId++)
{
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
faceIds->InsertNextId(pts[faceVerts[3]]);
- aCellType = VTK_QUAD;
+ aCellType = VTK_QUAD;
numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
for ( i=0; i < numFacePts; i++)
aNewPts[i] = pts[faceVerts[PixelConvert[i]]];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
break;
- }
+ }
case VTK_HEXAHEDRON: {
for (faceId = 0; faceId < 6; faceId++)
{
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
faceIds->InsertNextId(pts[faceVerts[3]]);
- aCellType = VTK_QUAD;
+ aCellType = VTK_QUAD;
numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
for ( i=0; i < numFacePts; i++)
aNewPts[i] = pts[faceVerts[i]];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
break;
- }
+ }
case VTK_WEDGE: {
for (faceId = 0; faceId < 5; faceId++)
{
faceIds->InsertNextId(pts[faceVerts[0]]);
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
- aCellType = VTK_TRIANGLE;
+ aCellType = VTK_TRIANGLE;
numFacePts = 3;
if (faceVerts[3] >= 0)
{
faceIds->InsertNextId(pts[faceVerts[3]]);
- aCellType = VTK_QUAD;
+ aCellType = VTK_QUAD;
numFacePts = 4;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
for ( i=0; i < numFacePts; i++)
aNewPts[i] = pts[faceVerts[i]];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
break;
- }
+ }
case VTK_PYRAMID: {
for (faceId = 0; faceId < 5; faceId++)
{
faceIds->InsertNextId(pts[faceVerts[0]]);
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
- aCellType = VTK_TRIANGLE;
+ aCellType = VTK_TRIANGLE;
numFacePts = 3;
if (faceVerts[3] >= 0)
{
faceIds->InsertNextId(pts[faceVerts[3]]);
- aCellType = VTK_QUAD;
+ aCellType = VTK_QUAD;
numFacePts = 4;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
for ( i=0; i < numFacePts; i++)
aNewPts[i] = pts[faceVerts[i]];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
break;
- }
+ }
//Quadratic cells
case VTK_QUADRATIC_EDGE:
case VTK_QUADRATIC_TRIANGLE:
case VTK_QUADRATIC_HEXAHEDRON:
case VTK_QUADRATIC_WEDGE:
case VTK_QUADRATIC_PYRAMID:
- if(!myIsWireframeMode){
- input->GetCell(cellId,cell);
- vtkIdList *lpts = vtkIdList::New();
- vtkPoints *coords = vtkPoints::New();
- vtkIdList *cellIds = vtkIdList::New();
- vtkIdType newCellId;
-
- if ( cell->GetCellDimension() == 1 ) {
+ if(!myIsWireframeMode){
+ input->GetCell(cellId,cell);
+ vtkIdList *lpts = vtkIdList::New();
+ vtkPoints *coords = vtkPoints::New();
+ vtkIdList *cellIds = vtkIdList::New();
+ vtkIdType newCellId;
+
+ if ( cell->GetCellDimension() == 1 ) {
vtkIdType arcResult = -1;
if(myIsBuildArc) {
arcResult = Build1DArc(cellId, input, output, pts, myMaxArcAngle);
outputCD->CopyData(cd,cellId,newCellId);
}
}
- else if ( cell->GetCellDimension() == 2 ) {
+ else if ( cell->GetCellDimension() == 2 ) {
if(!myIsBuildArc) {
aCellType = VTK_TRIANGLE;
numFacePts = 3;
BuildArcedPolygon(cellId,input,output,true);
}
}
- else //3D nonlinear cell
+ else //3D nonlinear cell
{
- aCellType = VTK_TRIANGLE;
- numFacePts = 3;
- for (int j=0; j < cell->GetNumberOfFaces(); j++){
- vtkCell *face = cell->GetFace(j);
- input->GetCellNeighbors(cellId, face->PointIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ) {
- face->Triangulate(0,lpts,coords);
- for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
- aNewPts[0] = lpts->GetId(i);
- aNewPts[1] = lpts->GetId(i+1);
- aNewPts[2] = lpts->GetId(i+2);
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
- outputCD->CopyData(cd,cellId,newCellId);
+ aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
+ for (int j=0; j < cell->GetNumberOfFaces(); j++){
+ vtkCell *face = cell->GetFace(j);
+ input->GetCellNeighbors(cellId, face->PointIds, cellIds);
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ) {
+ face->Triangulate(0,lpts,coords);
+ for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
+ aNewPts[0] = lpts->GetId(i);
+ aNewPts[1] = lpts->GetId(i+1);
+ aNewPts[2] = lpts->GetId(i+2);
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
}
}
}
} //3d nonlinear cell
- cellIds->Delete();
- coords->Delete();
- lpts->Delete();
- break;
+ cellIds->Delete();
+ coords->Delete();
+ lpts->Delete();
+ break;
}else{
- switch(aCellType){
- case VTK_QUADRATIC_EDGE: {
+ switch(aCellType){
+ case VTK_QUADRATIC_EDGE: {
vtkIdType arcResult =-1;
if(myIsBuildArc) {
arcResult = Build1DArc(cellId, input, output, pts,myMaxArcAngle);
if(!myIsBuildArc || arcResult == -1) {
aCellType = VTK_POLY_LINE;
numFacePts = 3;
-
+
aNewPts[0] = pts[0];
aNewPts[2] = pts[1];
aNewPts[1] = pts[2];
-
+
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
}
if(myStoreMapping)
myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
- break;
- }
- case VTK_QUADRATIC_TRIANGLE: {
+
+ outputCD->CopyData(cd,cellId,newCellId);
+ break;
+ }
+ case VTK_QUADRATIC_TRIANGLE: {
if(!myIsBuildArc) {
aCellType = VTK_POLYGON;
numFacePts = 6;
aNewPts[3] = pts[4];
aNewPts[4] = pts[2];
aNewPts[5] = pts[5];
-
+
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
}
else
BuildArcedPolygon(cellId,input,output);
break;
- }
- case VTK_QUADRATIC_QUAD: {
+ }
+ case VTK_QUADRATIC_QUAD: {
if(!myIsBuildArc) {
aCellType = VTK_POLYGON;
numFacePts = 8;
aNewPts[5] = pts[6];
aNewPts[6] = pts[3];
aNewPts[7] = pts[7];
-
+
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
}
else
BuildArcedPolygon(cellId,input,output);
break;
- }
- case VTK_QUADRATIC_TETRA: {
- aCellType = VTK_POLYGON;
- numFacePts = 6;
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[4];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[5];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[6];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[7];
- aNewPts[2] = pts[3];
- aNewPts[3] = pts[8];
- aNewPts[4] = pts[1];
- aNewPts[5] = pts[4];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[1];
- aNewPts[1] = pts[8];
- aNewPts[2] = pts[3];
- aNewPts[3] = pts[9];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[5];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[2];
- aNewPts[1] = pts[9];
- aNewPts[2] = pts[3];
- aNewPts[3] = pts[7];
- aNewPts[4] = pts[0];
- aNewPts[5] = pts[6];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- break;
- }
+ }
+ case VTK_QUADRATIC_TETRA: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 6;
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[4];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[5];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[6];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[7];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[8];
+ aNewPts[4] = pts[1];
+ aNewPts[5] = pts[4];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[1];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[9];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[5];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[2];
+ aNewPts[1] = pts[9];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[7];
+ aNewPts[4] = pts[0];
+ aNewPts[5] = pts[6];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ break;
+ }
case VTK_QUADRATIC_WEDGE: {
aCellType = VTK_POLYGON;
- numFacePts = 6;
+ numFacePts = 6;
//---------------------------------------------------------------
//Face 1
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[6];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[7];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[8];
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[6];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[7];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[8];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
//---------------------------------------------------------------
//Face 2
aNewPts[0] = pts[3];
- aNewPts[1] = pts[9];
- aNewPts[2] = pts[4];
- aNewPts[3] = pts[10];
- aNewPts[4] = pts[5];
- aNewPts[5] = pts[11];
+ aNewPts[1] = pts[9];
+ aNewPts[2] = pts[4];
+ aNewPts[3] = pts[10];
+ aNewPts[4] = pts[5];
+ aNewPts[5] = pts[11];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
//---------------------------------------------------------------
//Face 3
numFacePts = 8;
aNewPts[0] = pts[0];
- aNewPts[1] = pts[8];
- aNewPts[2] = pts[2];
- aNewPts[3] = pts[14];
- aNewPts[4] = pts[5];
- aNewPts[5] = pts[11];
- aNewPts[6] = pts[3];
- aNewPts[7] = pts[12];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[2];
+ aNewPts[3] = pts[14];
+ aNewPts[4] = pts[5];
+ aNewPts[5] = pts[11];
+ aNewPts[6] = pts[3];
+ aNewPts[7] = pts[12];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
//---------------------------------------------------------------
//Face 4
aNewPts[0] = pts[1];
- aNewPts[1] = pts[13];
- aNewPts[2] = pts[4];
- aNewPts[3] = pts[10];
- aNewPts[4] = pts[5];
- aNewPts[5] = pts[14];
- aNewPts[6] = pts[2];
- aNewPts[7] = pts[7];
+ aNewPts[1] = pts[13];
+ aNewPts[2] = pts[4];
+ aNewPts[3] = pts[10];
+ aNewPts[4] = pts[5];
+ aNewPts[5] = pts[14];
+ aNewPts[6] = pts[2];
+ aNewPts[7] = pts[7];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
//---------------------------------------------------------------
//Face 5
aNewPts[0] = pts[0];
- aNewPts[1] = pts[12];
- aNewPts[2] = pts[3];
- aNewPts[3] = pts[9];
- aNewPts[4] = pts[4];
- aNewPts[5] = pts[13];
+ aNewPts[1] = pts[12];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[9];
+ aNewPts[4] = pts[4];
+ aNewPts[5] = pts[13];
aNewPts[6] = pts[1];
aNewPts[7] = pts[6];
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ break;
+ }
+ case VTK_QUADRATIC_HEXAHEDRON: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 8;
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[17];
+ aNewPts[4] = pts[5];
+ aNewPts[5] = pts[12];
+ aNewPts[6] = pts[4];
+ aNewPts[7] = pts[16];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[1];
+ aNewPts[1] = pts[9];
+ aNewPts[2] = pts[2];
+ aNewPts[3] = pts[18];
+ aNewPts[4] = pts[6];
+ aNewPts[5] = pts[13];
+ aNewPts[6] = pts[5];
+ aNewPts[7] = pts[17];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[2];
+ aNewPts[1] = pts[10];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[19];
+ aNewPts[4] = pts[7];
+ aNewPts[5] = pts[14];
+ aNewPts[6] = pts[6];
+ aNewPts[7] = pts[18];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[3];
+ aNewPts[1] = pts[11];
+ aNewPts[2] = pts[0];
+ aNewPts[3] = pts[16];
+ aNewPts[4] = pts[4];
+ aNewPts[5] = pts[15];
+ aNewPts[6] = pts[7];
+ aNewPts[7] = pts[19];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[9];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[10];
+ aNewPts[6] = pts[3];
+ aNewPts[7] = pts[11];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[4];
+ aNewPts[1] = pts[12];
+ aNewPts[2] = pts[5];
+ aNewPts[3] = pts[13];
+ aNewPts[4] = pts[6];
+ aNewPts[5] = pts[14];
+ aNewPts[6] = pts[7];
+ aNewPts[7] = pts[15];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
break;
}
- case VTK_QUADRATIC_HEXAHEDRON: {
- aCellType = VTK_POLYGON;
- numFacePts = 8;
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[8];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[17];
- aNewPts[4] = pts[5];
- aNewPts[5] = pts[12];
- aNewPts[6] = pts[4];
- aNewPts[7] = pts[16];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[1];
- aNewPts[1] = pts[9];
- aNewPts[2] = pts[2];
- aNewPts[3] = pts[18];
- aNewPts[4] = pts[6];
- aNewPts[5] = pts[13];
- aNewPts[6] = pts[5];
- aNewPts[7] = pts[17];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[2];
- aNewPts[1] = pts[10];
- aNewPts[2] = pts[3];
- aNewPts[3] = pts[19];
- aNewPts[4] = pts[7];
- aNewPts[5] = pts[14];
- aNewPts[6] = pts[6];
- aNewPts[7] = pts[18];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[3];
- aNewPts[1] = pts[11];
- aNewPts[2] = pts[0];
- aNewPts[3] = pts[16];
- aNewPts[4] = pts[4];
- aNewPts[5] = pts[15];
- aNewPts[6] = pts[7];
- aNewPts[7] = pts[19];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[8];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[9];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[10];
- aNewPts[6] = pts[3];
- aNewPts[7] = pts[11];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[4];
- aNewPts[1] = pts[12];
- aNewPts[2] = pts[5];
- aNewPts[3] = pts[13];
- aNewPts[4] = pts[6];
- aNewPts[5] = pts[14];
- aNewPts[6] = pts[7];
- aNewPts[7] = pts[15];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- break;
- }
- case VTK_QUADRATIC_PYRAMID: {
- aCellType = VTK_POLYGON;
- numFacePts = 6;
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[8];
- aNewPts[2] = pts[3];
- aNewPts[3] = pts[12];
- aNewPts[4] = pts[4];
- aNewPts[5] = pts[9];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[9];
- aNewPts[2] = pts[4];
- aNewPts[3] = pts[10];
- aNewPts[4] = pts[1];
- aNewPts[5] = pts[5];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[1];
- aNewPts[1] = pts[10];
- aNewPts[2] = pts[4];
- aNewPts[3] = pts[11];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[6];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[2];
- aNewPts[1] = pts[11];
- aNewPts[2] = pts[4];
- aNewPts[3] = pts[12];
- aNewPts[4] = pts[3];
- aNewPts[5] = pts[7];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
+ case VTK_QUADRATIC_PYRAMID: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 6;
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[12];
+ aNewPts[4] = pts[4];
+ aNewPts[5] = pts[9];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[9];
+ aNewPts[2] = pts[4];
+ aNewPts[3] = pts[10];
+ aNewPts[4] = pts[1];
+ aNewPts[5] = pts[5];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[1];
+ aNewPts[1] = pts[10];
+ aNewPts[2] = pts[4];
+ aNewPts[3] = pts[11];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[6];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[2];
+ aNewPts[1] = pts[11];
+ aNewPts[2] = pts[4];
+ aNewPts[3] = pts[12];
+ aNewPts[4] = pts[3];
+ aNewPts[5] = pts[7];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
numFacePts = 8;
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[5];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[6];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[7];
- aNewPts[6] = pts[3];
- aNewPts[7] = pts[8];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- break;
- }}
- }
- } //switch
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[5];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[6];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[7];
+ aNewPts[6] = pts[3];
+ aNewPts[7] = pts[8];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ break;
+ }}
+ }
+ } //switch
} //if visible
} //for all cells
aNewPts[2] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+2));
if(outputScalars) {
- outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i)]);
- outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+1)]);
- outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+2)]);
+ outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i)]);
+ outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+1)]);
+ outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+2)]);
}
aTriangleId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,aTriangleId);
}
pts->Delete();
aNbPoints = MergevtkPoints(aCollection, aScalarCollection, output->GetPoints(), aPntId2ScalarValue, aNewPoints);
if(outputScalars)
for(vtkIdType i = 0; i < aNbPoints; i++)
- outputScalars->InsertNextTuple1(aPntId2ScalarValue[aNewPoints[i]]);
+ outputScalars->InsertNextTuple1(aPntId2ScalarValue[aNewPoints[i]]);
newCellId = output->InsertNextCell(aCellType,aNbPoints,aNewPoints);
outputCD->CopyData(cd,cellId,newCellId);
float aMinDist = 1000000.0, aDist = 0;
for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
- int subId; float pcoords[3], closestPoint[3], weights[3];
- aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
- if (aDist < aMinDist) {
- aMinDist = aDist;
- anEdgeId = i;
- }
+ int subId; float pcoords[3], closestPoint[3], weights[3];
+ aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
+ if (aDist < aMinDist) {
+ aMinDist = aDist;
+ anEdgeId = i;
+ }
}
}
}
*\param theWidth - width..
*/
void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const double& theGreen,
- const double& theBlue, const int& theWidth)
+ const double& theBlue, const int& theWidth)
{
if ( myPreSelectionActor->GetProperty() == 0 )
return;
}
double newAngle = atan2((double)(y - this->CurrentRenderer->GetCenter()[1]),
- (double)(x - this->CurrentRenderer->GetCenter()[0]));
+ (double)(x - this->CurrentRenderer->GetCenter()[0]));
double oldAngle = atan2((double)(oldY -this->CurrentRenderer->GetCenter()[1]),
- (double)(oldX - this->CurrentRenderer->GetCenter()[0]));
+ (double)(oldX - this->CurrentRenderer->GetCenter()[0]));
newAngle *= this->RadianToDegree;
oldAngle *= this->RadianToDegree;
*\param y - y coordinate
*/
void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl),
- int shift,
- int x, int y)
+ int shift,
+ int x, int y)
{
myShiftState = shift;
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
*\param y - y coordinate
*/
void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift,
- int x, int y)
+ int x, int y)
{
if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
*\param y - y coordinate (not used)
*/
void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl),
- int shift,
- int vtkNotUsed(x),
- int vtkNotUsed(y))
+ int shift,
+ int vtkNotUsed(x),
+ int vtkNotUsed(y))
{
myShiftState = shift;
// finishing current viewer operation
*\param y - y coordinate
*/
void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl,
- int shift,
- int x, int y)
+ int shift,
+ int x, int y)
{
if (this->HasObserver(vtkCommand::MiddleButtonPressEvent))
{
*\param y - y coordinate (not used)
*/
void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl),
- int shift,
- int vtkNotUsed(x),
- int vtkNotUsed(y))
+ int shift,
+ int vtkNotUsed(x),
+ int vtkNotUsed(y))
{
myShiftState = shift;
// finishing current viewer operation
*\param y - y coordinate
*/
void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl,
- int shift,
- int x, int y)
+ int shift,
+ int x, int y)
{
if (this->HasObserver(vtkCommand::RightButtonPressEvent))
{
*\param y - y coordinate (not used)
*/
void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl),
- int shift,
- int vtkNotUsed(x),
- int vtkNotUsed(y))
+ int shift,
+ int vtkNotUsed(x),
+ int vtkNotUsed(y))
{
myShiftState = shift;
// finishing current viewer operation
}
else {
if (myPoint == myOtherPoint) {
- // process point selection
+ // process point selection
int w, h, x, y;
m_Interactor->GetSize(w, h);
x = myPoint.x();
y = h - myPoint.y() - 1;
this->FindPokedRenderer(x, y);
- m_Interactor->StartPickCallback();
+ m_Interactor->StartPickCallback();
- vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
+ vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
- SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
+ SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
- int aVtkId = picker->GetCellId();
- if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
- int anObjId = SActor->GetElemObjId(aVtkId);
- if(anObjId >= 0){
- Handle(SALOME_InteractiveObject) IO = SActor->getIO();
- if(aSelectionMode != EdgeOfCellSelection) {
- if(CheckDimensionId(aSelectionMode,SActor,anObjId)){
- if (IsSelected(IO,aSel)) {
- // This IO is already in the selection
- aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
- } else {
- if (!myShiftState) {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
- aSel->AddIObject( IO, false );
- }
- }
- }else{
- if (!myShiftState) {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- int anEdgeId = GetEdgeId(picker,SActor,anObjId);
- if (anEdgeId >= 0) {
- aSel->AddOrRemoveIndex( IO, anObjId, true, false);
- aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true );
- aSel->AddIObject( IO, false );
- }
- }
- }
- } else {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
+ int aVtkId = picker->GetCellId();
+ if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
+ int anObjId = SActor->GetElemObjId(aVtkId);
+ if(anObjId >= 0){
+ Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+ if(aSelectionMode != EdgeOfCellSelection) {
+ if(CheckDimensionId(aSelectionMode,SActor,anObjId)){
+ if (IsSelected(IO,aSel)) {
+ // This IO is already in the selection
+ aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+ } else {
+ if (!myShiftState) {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+ aSel->AddIObject( IO, false );
+ }
+ }
+ }else{
+ if (!myShiftState) {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ int anEdgeId = GetEdgeId(picker,SActor,anObjId);
+ if (anEdgeId >= 0) {
+ aSel->AddOrRemoveIndex( IO, anObjId, true, false);
+ aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true );
+ aSel->AddIObject( IO, false );
+ }
+ }
+ }
+ } else {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
} else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) {
- int aVtkId = picker->GetPointId();
- if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
- if ( SActor && SActor->hasIO() ) {
- int anObjId = SActor->GetNodeObjId(aVtkId);
- if(anObjId >= 0){
- Handle(SALOME_InteractiveObject) IO = SActor->getIO();
- if(IsSelected(IO,aSel)) {
- // This IO is already in the selection
- aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
- } else {
- if(!myShiftState) {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
- aSel->AddIObject( IO, false );
- }
- }
- }
- } else {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- } else {
- if ( SActor && SActor->hasIO() ) {
- this->PropPicked++;
- Handle(SALOME_InteractiveObject) IO = SActor->getIO();
- if(IsSelected(IO,aSel)) {
- // This IO is already in the selection
- if(myShiftState) {
- aSel->RemoveIObject(IO);
- }
- }
- else {
- if(!myShiftState) {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- aSel->AddIObject( IO, false );
- }
- }else{
- // No selection clear all
- this->PropPicked = 0;
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- }
- m_Interactor->EndPickCallback();
+ int aVtkId = picker->GetPointId();
+ if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
+ if ( SActor && SActor->hasIO() ) {
+ int anObjId = SActor->GetNodeObjId(aVtkId);
+ if(anObjId >= 0){
+ Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+ if(IsSelected(IO,aSel)) {
+ // This IO is already in the selection
+ aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+ } else {
+ if(!myShiftState) {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+ aSel->AddIObject( IO, false );
+ }
+ }
+ }
+ } else {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ } else {
+ if ( SActor && SActor->hasIO() ) {
+ this->PropPicked++;
+ Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+ if(IsSelected(IO,aSel)) {
+ // This IO is already in the selection
+ if(myShiftState) {
+ aSel->RemoveIObject(IO);
+ }
+ }
+ else {
+ if(!myShiftState) {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ aSel->AddIObject( IO, false );
+ }
+ }else{
+ // No selection clear all
+ this->PropPicked = 0;
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ }
+ m_Interactor->EndPickCallback();
} else {
//processing rectangle selection
- QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType();
- if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
- m_Interactor->StartPickCallback();
-
- if (!myShiftState) {
- this->PropPicked = 0;
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
-
- // Compute bounds
- // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
- QRect rect(myPoint, myOtherPoint);
- rect = rect.normalize();
- int w, h;
- m_Interactor->GetSize(w, h);
- int x1, y1, x2, y2;
- x1 = rect.left();
- y1 = h - rect.top() - 1;
- x2 = rect.right();
- y2 = h - rect.bottom() - 1;
-
- switch (aSelectionMode) {
- case NodeSelection: {
- if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) {
- vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
- aListActors->InitTraversal();
- while (vtkActor* aActor = aListActors->GetNextActor()) {
- if (!aActor->GetVisibility())
- continue;
- if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (SActor->hasIO()) {
- Handle(SALOME_InteractiveObject) IO = SActor->getIO();
- if (IO.IsNull())
- continue;
- if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
- continue;
- if (vtkDataSet* aDataSet = SActor->GetInput()) {
- SALOME_Selection::TContainerOfId anIndices;
- for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
- float aPoint[3];
- aDataSet->GetPoint(i,aPoint);
- if (IsInRect(aPoint,x1,y1,x2,y2)){
- float aDisp[3];
- ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
- if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
- if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
- if(anActorCollection->IsItemPresent(SActor)){
- float aPickedPoint[3];
- aPointPicker->GetMapperPosition(aPickedPoint);
- vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
- if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
- int anObjId = SActor->GetNodeObjId(aVtkId);
- anIndices.insert(anObjId);
- }
- }
- }
- }
- }
- }
- if (!anIndices.empty()) {
- aSel->AddOrRemoveIndex(IO, anIndices, true, false);
- aSel->AddIObject(IO, false);
- anIndices.clear();
- }else{
- aSel->RemoveIObject(IO, false);
- }
- }
- }
- }
- }
- }
- break;
- }
- case CellSelection:
- case EdgeOfCellSelection:
- case EdgeSelection:
- case FaceSelection:
- case VolumeSelection:
- {
- vtkSmartPointer<VTKViewer_CellRectPicker> picker = VTKViewer_CellRectPicker::New();
- picker->SetTolerance(0.001);
- picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-
- vtkActorCollection* aListActors = picker->GetActors();
- aListActors->InitTraversal();
- while(vtkActor* aActor = aListActors->GetNextActor()) {
- if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (aSActor->hasIO()) {
- Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
- if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
- continue;
- VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
- if ( !cellList.empty() ) {
- SALOME_Selection::TContainerOfId anIndexes;
- VTKViewer_CellDataSet::iterator it;
- for ( it = cellList.begin(); it != cellList.end(); ++it ) {
- int aCellId = (*it).cellId;
-
- if ( !IsValid( aSActor, aCellId ) )
- continue;
-
- int anObjId = aSActor->GetElemObjId(aCellId);
- if (anObjId != -1){
- if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
- anIndexes.insert(anObjId);
- }
- }
- }
- aSel->AddOrRemoveIndex(aIO, anIndexes, true, false);
- aSel->AddIObject(aIO, false);
- }
- }
- }
- }
- }
- break;
- case ActorSelection: // objects selection
- {
- vtkSmartPointer<VTKViewer_RectPicker> picker = VTKViewer_RectPicker::New();
- picker->SetTolerance(0.001);
- picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-
- vtkActorCollection* aListActors = picker->GetActors();
- SALOME_ListIO aListIO;
- aListActors->InitTraversal();
- while(vtkActor* aActor = aListActors->GetNextActor()) {
- if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (aSActor->hasIO()) {
- Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
- if (!IsStored(aIO,aListIO))
- aListIO.Append(aIO);
- }
- }
- }
- if (!aListIO.IsEmpty()) {
- SALOME_ListIteratorOfListIO It(aListIO);
- for(;It.More();It.Next()) {
- Handle(SALOME_InteractiveObject) IOS = It.Value();
- this->PropPicked++;
- aSel->AddIObject( IOS, false );
- }
- }
- } // end case 4
- } //end switch
- m_Interactor->EndPickCallback();
- }
- aActiveStudy->update3dViewers();
+ QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType();
+ if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
+ m_Interactor->StartPickCallback();
+
+ if (!myShiftState) {
+ this->PropPicked = 0;
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+
+ // Compute bounds
+ // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
+ QRect rect(myPoint, myOtherPoint);
+ rect = rect.normalize();
+ int w, h;
+ m_Interactor->GetSize(w, h);
+ int x1, y1, x2, y2;
+ x1 = rect.left();
+ y1 = h - rect.top() - 1;
+ x2 = rect.right();
+ y2 = h - rect.bottom() - 1;
+
+ switch (aSelectionMode) {
+ case NodeSelection: {
+ if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) {
+ vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
+ aListActors->InitTraversal();
+ while (vtkActor* aActor = aListActors->GetNextActor()) {
+ if (!aActor->GetVisibility())
+ continue;
+ if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
+ if (SActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+ if (IO.IsNull())
+ continue;
+ if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
+ continue;
+ if (vtkDataSet* aDataSet = SActor->GetInput()) {
+ SALOME_Selection::TContainerOfId anIndices;
+ for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
+ float aPoint[3];
+ aDataSet->GetPoint(i,aPoint);
+ if (IsInRect(aPoint,x1,y1,x2,y2)){
+ float aDisp[3];
+ ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
+ if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
+ if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
+ if(anActorCollection->IsItemPresent(SActor)){
+ float aPickedPoint[3];
+ aPointPicker->GetMapperPosition(aPickedPoint);
+ vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
+ if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
+ int anObjId = SActor->GetNodeObjId(aVtkId);
+ anIndices.insert(anObjId);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!anIndices.empty()) {
+ aSel->AddOrRemoveIndex(IO, anIndices, true, false);
+ aSel->AddIObject(IO, false);
+ anIndices.clear();
+ }else{
+ aSel->RemoveIObject(IO, false);
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ case CellSelection:
+ case EdgeOfCellSelection:
+ case EdgeSelection:
+ case FaceSelection:
+ case VolumeSelection:
+ {
+ vtkSmartPointer<VTKViewer_CellRectPicker> picker = VTKViewer_CellRectPicker::New();
+ picker->SetTolerance(0.001);
+ picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
+
+ vtkActorCollection* aListActors = picker->GetActors();
+ aListActors->InitTraversal();
+ while(vtkActor* aActor = aListActors->GetNextActor()) {
+ if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
+ if (aSActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
+ if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
+ continue;
+ VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
+ if ( !cellList.empty() ) {
+ SALOME_Selection::TContainerOfId anIndexes;
+ VTKViewer_CellDataSet::iterator it;
+ for ( it = cellList.begin(); it != cellList.end(); ++it ) {
+ int aCellId = (*it).cellId;
+
+ if ( !IsValid( aSActor, aCellId ) )
+ continue;
+
+ int anObjId = aSActor->GetElemObjId(aCellId);
+ if (anObjId != -1){
+ if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
+ anIndexes.insert(anObjId);
+ }
+ }
+ }
+ aSel->AddOrRemoveIndex(aIO, anIndexes, true, false);
+ aSel->AddIObject(aIO, false);
+ }
+ }
+ }
+ }
+ }
+ break;
+ case ActorSelection: // objects selection
+ {
+ vtkSmartPointer<VTKViewer_RectPicker> picker = VTKViewer_RectPicker::New();
+ picker->SetTolerance(0.001);
+ picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
+
+ vtkActorCollection* aListActors = picker->GetActors();
+ SALOME_ListIO aListIO;
+ aListActors->InitTraversal();
+ while(vtkActor* aActor = aListActors->GetNextActor()) {
+ if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
+ if (aSActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
+ if (!IsStored(aIO,aListIO))
+ aListIO.Append(aIO);
+ }
+ }
+ }
+ if (!aListIO.IsEmpty()) {
+ SALOME_ListIteratorOfListIO It(aListIO);
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ this->PropPicked++;
+ aSel->AddIObject( IOS, false );
+ }
+ }
+ } // end case 4
+ } //end switch
+ m_Interactor->EndPickCallback();
+ }
+ aActiveStudy->update3dViewers();
}
}
break;
if ( aVtkId >= 0 ) {
int anObjId = SActor->GetElemObjId(aVtkId);
if ( SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
- bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId);
- bool aResult = anIsSameObjId;
- if(!anIsSameObjId) {
- if(aSelectionMode != EdgeOfCellSelection) {
- aResult = CheckDimensionId(aSelectionMode,SActor,anObjId);
- if(aResult){
- mySelectedActor = SActor;
- myElemId = anObjId;
- m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor);
- }
- }
- }
- if(aSelectionMode == EdgeOfCellSelection){
- int anEdgeId = GetEdgeId(picker,SActor,anObjId);
- bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
- aResult = anIsSameEdgeId;
- if(!anIsSameEdgeId) {
- aResult = (anEdgeId >= 0);
- if (aResult) {
- mySelectedActor = SActor;
- myEdgeId = anEdgeId;
- myElemId = anObjId;
- m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor);
- }
- }
- }
- if(aResult) {
- myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
- myPreSelectionActor->SetVisibility(true);
- }
+ bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId);
+ bool aResult = anIsSameObjId;
+ if(!anIsSameObjId) {
+ if(aSelectionMode != EdgeOfCellSelection) {
+ aResult = CheckDimensionId(aSelectionMode,SActor,anObjId);
+ if(aResult){
+ mySelectedActor = SActor;
+ myElemId = anObjId;
+ m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor);
+ }
+ }
+ }
+ if(aSelectionMode == EdgeOfCellSelection){
+ int anEdgeId = GetEdgeId(picker,SActor,anObjId);
+ bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
+ aResult = anIsSameEdgeId;
+ if(!anIsSameEdgeId) {
+ aResult = (anEdgeId >= 0);
+ if (aResult) {
+ mySelectedActor = SActor;
+ myEdgeId = anEdgeId;
+ myElemId = anObjId;
+ m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor);
+ }
+ }
+ }
+ if(aResult) {
+ myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
+ myPreSelectionActor->SetVisibility(true);
+ }
}
}
}
int aVtkId = picker->GetPointId();
if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
if ( SActor && SActor->hasIO() ) {
- int anObjId = SActor->GetNodeObjId(aVtkId);
- bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId);
- if(!anIsSameObjId) {
- mySelectedActor = SActor;
- myNodeId = anObjId;
- m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor);
- }
- myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
- myPreSelectionActor->SetVisibility(true);
+ int anObjId = SActor->GetNodeObjId(aVtkId);
+ bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId);
+ if(!anIsSameObjId) {
+ mySelectedActor = SActor;
+ myNodeId = anObjId;
+ m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor);
+ }
+ myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
+ myPreSelectionActor->SetVisibility(true);
}
}
}
else if ( vtkPicker::SafeDownCast(aPicker) ) {
if ( SActor ) {
if ( myPreViewActor != SActor ) {
- if ( myPreViewActor != NULL ) {
- myPreViewActor->SetPreSelected( false );
- }
- myPreViewActor = SActor;
-
- if ( SActor->hasIO() ) {
- Handle( SALOME_InteractiveObject) IO = SActor->getIO();
- if ( !IsSelected(IO,Sel) ) {
+ if ( myPreViewActor != NULL ) {
+ myPreViewActor->SetPreSelected( false );
+ }
+ myPreViewActor = SActor;
+
+ if ( SActor->hasIO() ) {
+ Handle( SALOME_InteractiveObject) IO = SActor->getIO();
+ if ( !IsSelected(IO,Sel) ) {
// Find All actors with same IO
- vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
- theActors->InitTraversal();
- while( vtkActor *ac = theActors->GetNextActor() ) {
- if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
- if ( anActor->hasIO() ) {
- Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
- if(IO->isSame(IOS)) {
- anActor->SetPreSelected( true );
- }
- }
- }
- }
- }
- }
+ vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
+ theActors->InitTraversal();
+ while( vtkActor *ac = theActors->GetNextActor() ) {
+ if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
+ if ( anActor->hasIO() ) {
+ Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
+ if(IO->isSame(IOS)) {
+ anActor->SetPreSelected( true );
+ }
+ }
+ }
+ }
+ }
+ }
}
} else {
myPreViewActor = NULL;
cam->GetFocalPoint(viewFocus);
this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1],
- viewFocus[2], viewFocus);
+ viewFocus[2], viewFocus);
focalDepth = viewFocus[2];
this->ComputeDisplayToWorld(vtkFloatingPointType(toX), vtkFloatingPointType(toY),
- focalDepth, newPickPoint);
+ focalDepth, newPickPoint);
this->ComputeDisplayToWorld(vtkFloatingPointType(fromX),vtkFloatingPointType(fromY),
- focalDepth, oldPickPoint);
+ focalDepth, oldPickPoint);
// camera motion is reversed
motionVector[0] = oldPickPoint[0] - newPickPoint[0];
cam->GetFocalPoint(viewFocus);
cam->GetPosition(viewPoint);
cam->SetFocalPoint(motionVector[0] + viewFocus[0],
- motionVector[1] + viewFocus[1],
- motionVector[2] + viewFocus[2]);
+ motionVector[1] + viewFocus[1],
+ motionVector[2] + viewFocus[2]);
cam->SetPosition(motionVector[0] + viewPoint[0],
- motionVector[1] + viewPoint[1],
- motionVector[2] + viewPoint[2]);
+ motionVector[1] + viewPoint[1],
+ motionVector[2] + viewPoint[2]);
}
/*! Checks: is the given Actor within display coordinates?*/
bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor,
- const int left, const int top,
- const int right, const int bottom)
+ const int left, const int top,
+ const int right, const int bottom)
{
vtkFloatingPointType* aBounds = theActor->GetBounds();
vtkFloatingPointType aMin[3], aMax[3];
/*! Checks: is the given Cell within display coordinates?*/
bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell,
- const int left, const int top,
- const int right, const int bottom)
+ const int left, const int top,
+ const int right, const int bottom)
{
vtkFloatingPointType* aBounds = theCell->GetBounds();
vtkFloatingPointType aMin[3], aMax[3];
/*!Checks: is given point \a thePoint in rectangle*/
bool VTKViewer_InteractorStyle::IsInRect(vtkFloatingPointType* thePoint,
- const int left, const int top,
- const int right, const int bottom)
+ const int left, const int top,
+ const int right, const int bottom)
{
vtkFloatingPointType aPnt[3];
ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
void setTriedron(VTKViewer_Trihedron* theTrihedron);
void setPreselectionProp(const double& theRed = 0, const double& theGreen = 1,
- const double& theBlue = 1, const int& theWidth = 5);
+ const double& theBlue = 1, const int& theWidth = 5);
// Generic event bindings must be overridden in subclasses
void OnMouseMove (int ctrl, int shift, int x, int y);
void Place(const int theX, const int theY);
void TranslateView(int toX, int toY, int fromX, int fromY);
bool IsInRect(vtkActor* theActor,
- const int left, const int top,
- const int right, const int bottom);
+ const int left, const int top,
+ const int right, const int bottom);
bool IsInRect(vtkCell* theCell,
- const int left, const int top,
- const int right, const int bottom);
+ const int left, const int top,
+ const int right, const int bottom);
bool IsInRect(vtkFloatingPointType* thePoint,
- const int left, const int top,
- const int right, const int bottom);
+ const int left, const int top,
+ const int right, const int bottom);
int State;
vtkFloatingPointType MotionFactor;
vtkRenderer * theRenderer = theRenderers->GetNextItem();
theRenderer->GetBackground(backint);
- QColor selColor = QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL );
+ QColor selColor = QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL );
if ( selColor.isValid() ) {
theRenderer->SetBackground( selColor.red()/255., selColor.green()/255., selColor.blue()/255. );
/* VSR : PAL5420 ---------------------------------------------------
return ;
}
myInteractorStyle->OnLeftButtonDown((event->modifiers() & Qt::ControlModifier),
- (event->modifiers() & Qt::ShiftModifier),
- event->x(), event->y());
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y());
}
/*!Reaction on left button releases.\n
return ;
}
myInteractorStyle->OnLeftButtonUp( (event->modifiers() & Qt::ControlModifier),
- (event->modifiers() & Qt::ShiftModifier),
- event->x(), event->y() ) ;
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() ) ;
}
/*!Reaction on middle button pressed.\n
return ;
}
myInteractorStyle->OnMiddleButtonDown((event->modifiers() & Qt::ControlModifier),
- (event->modifiers() & Qt::ShiftModifier),
- event->x(), event->y() ) ;
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() ) ;
}
/*!Reaction on middle button released.\n
return ;
}
myInteractorStyle->OnMiddleButtonUp( (event->modifiers() & Qt::ControlModifier),
- (event->modifiers() & Qt::ShiftModifier),
- event->x(), event->y() ) ;
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() ) ;
}
/*!Reaction on right button pressed.\n
return ;
}
myInteractorStyle->OnRightButtonDown( (event->modifiers() & Qt::ControlModifier),
- (event->modifiers() & Qt::ShiftModifier),
- event->x(), event->y() ) ;
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() ) ;
}
/*!Reaction on right button released.\n
}
bool isOperation = myInteractorStyle->CurrentState() != VTK_INTERACTOR_STYLE_CAMERA_NONE;
myInteractorStyle->OnRightButtonUp( (event->modifiers() & Qt::ControlModifier),
- (event->modifiers() & Qt::ShiftModifier),
- event->x(), event->y() );
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() );
if ( !isOperation )
{
QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
{
using namespace VTK;
ForEach<VTKViewer_Actor>(theCollection,
- TSetFunction<VTKViewer_Actor,int>
- (&VTKViewer_Actor::setDisplayMode,0));
+ TSetFunction<VTKViewer_Actor,int>
+ (&VTKViewer_Actor::setDisplayMode,0));
emit RenderWindowModified();
}
{
using namespace VTK;
ForEach<VTKViewer_Actor>(theCollection,
- TSetFunction<VTKViewer_Actor,int>
- (&VTKViewer_Actor::setDisplayMode,1));
+ TSetFunction<VTKViewer_Actor,int>
+ (&VTKViewer_Actor::setDisplayMode,1));
emit RenderWindowModified();
}
* \li Emit render window modified, if flag \a update - true.
*/
bool VTKViewer_RenderWindowInteractor::highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
- VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
- TUpdateActor theFun, bool hilight, bool update)
+ VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
+ TUpdateActor theFun, bool hilight, bool update)
{
if(theMapIndex.Extent() == 0) return false;
/*!Sets actors data.*/
void VTKViewer_RenderWindowInteractor::setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
- VTKViewer_Actor * theMapActor,
- VTKViewer_Actor * theActor,
- TUpdateActor theFun)
+ VTKViewer_Actor * theMapActor,
+ VTKViewer_Actor * theActor,
+ TUpdateActor theFun)
{
(*theFun)(theMapIndex,theMapActor,theActor);
vtkFloatingPointType aPos[3];
/** @name Selection Management */
//@{
bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex,
- VTKViewer_Actor* theMapActor,
- bool hilight,
- bool update = true );
+ VTKViewer_Actor* theMapActor,
+ bool hilight,
+ bool update = true );
bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex,
- VTKViewer_Actor* theMapActor,
- bool hilight,
- bool update = true );
+ VTKViewer_Actor* theMapActor,
+ bool hilight,
+ bool update = true );
bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex,
- VTKViewer_Actor* theMapActor,
- bool hilight,
- bool update = true );
+ VTKViewer_Actor* theMapActor,
+ bool hilight,
+ bool update = true );
void unHighlightSubSelection();
bool unHighlightAll();
//void SetSelectionMode(Selection_Mode mode);
void SetSelectionProp(const double& theRed = 1, const double& theGreen = 1,
- const double& theBlue = 0, const int& theWidth = 5);
+ const double& theBlue = 0, const int& theWidth = 5);
void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001);
//@}
void setViewWindow( VTKViewer_ViewWindow* theViewWnd );
void setCellData(const int& theIndex,
- VTKViewer_Actor* theMapActor,
- VTKViewer_Actor* theActor) {}
+ VTKViewer_Actor* theMapActor,
+ VTKViewer_Actor* theActor) {}
void setEdgeData(const int& theCellIndex,
- VTKViewer_Actor* theMapActor,
- const int& theEdgeIndex,
- VTKViewer_Actor* theActor ) {} //NB
+ VTKViewer_Actor* theMapActor,
+ const int& theEdgeIndex,
+ VTKViewer_Actor* theActor ) {} //NB
void setPointData(const int& theIndex,
- VTKViewer_Actor* theMapActor,
- VTKViewer_Actor* theActor) {}
+ VTKViewer_Actor* theMapActor,
+ VTKViewer_Actor* theActor) {}
typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex,
- VTKViewer_Actor* theMapActor,
- VTKViewer_Actor* theActor);
+ VTKViewer_Actor* theMapActor,
+ VTKViewer_Actor* theActor);
protected:
VTKViewer_RenderWindowInteractor();
VTKViewer_InteractorStyle* myInteractorStyle;
bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
- VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
- TUpdateActor theFun, bool hilight, bool update);
+ VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
+ TUpdateActor theFun, bool hilight, bool update);
void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
- VTKViewer_Actor* theMapActor,
- VTKViewer_Actor *theActor,
- TUpdateActor theFun);
+ VTKViewer_Actor* theMapActor,
+ VTKViewer_Actor *theActor,
+ TUpdateActor theFun);
/*! Timer used during various mouse events to figure
* out mouse movements.
oldId = ptIds->GetId(i);
newId = newPts->InsertNextPoint(pt);
if(myStoreMapping)
- myVTK2ObjIds.push_back(oldId);
+ myVTK2ObjIds.push_back(oldId);
newPtIds->InsertId(i,newId);
outPD->CopyData(pd, oldId, newId);
double aScale[3];
this->GetMatrixScale(aScale);
return (fabs(aScale[0] - 1.0) < EPS &&
- fabs(aScale[1] - 1.0) < EPS &&
- fabs(aScale[2] - 1.0) < EPS);
+ fabs(aScale[1] - 1.0) < EPS &&
+ fabs(aScale[2] - 1.0) < EPS);
}
theRenderer->ViewToWorld(P[0][0],P[0][1],P[0][2]);
theRenderer->ViewToWorld(P[1][0],P[1][1],P[1][2]);
vtkFloatingPointType aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+
- (P[1][1]-P[0][1])*(P[1][1]-P[0][1])+
- (P[1][2]-P[0][2])*(P[1][2]-P[0][2]));
+ (P[1][1]-P[0][1])*(P[1][1]-P[0][1])+
+ (P[1][2]-P[0][2])*(P[1][2]-P[0][2]));
int* aSize = theRenderer->GetRenderWindow()->GetSize();
vtkFloatingPointType aWinDiag = sqrt(vtkFloatingPointType(aSize[0]*aSize[0]+aSize[1]*aSize[1]));
vtkDataSet* aDataSet = GetMapper()->GetInput();
if( prop->GetVisibility())
if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(prop)) {
if(!anActor->IsInfinitive())
- aCount++;
+ aCount++;
}
else if ( !OwnActor( anActor ) ) {
- aCount++;
+ aCount++;
}
//int aCount = theRenderer->VisibleActorCount();
//SetVisibility(aVis);
/*!@see vtkRenderer::ResetCamera(vtkFloatingPointType bounds[6]) method*/
void
ResetCamera(vtkRenderer* theRenderer,
- int theUsingZeroFocalPoint)
+ int theUsingZeroFocalPoint)
{
if(!theRenderer)
return;
vtkFloatingPointType aWidth =
sqrt((aBounds[1]-aBounds[0])*(aBounds[1]-aBounds[0]) +
- (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) +
- (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4]));
+ (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) +
+ (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4]));
if(aWidth < MIN_DISTANCE)
return;
// update the camera
aCamera->SetPosition(aCenter[0]+aDistance*aViewPlaneNormal[0],
- aCenter[1]+aDistance*aViewPlaneNormal[1],
- aCenter[2]+aDistance*aViewPlaneNormal[2]);
+ aCenter[1]+aDistance*aViewPlaneNormal[1],
+ aCenter[2]+aDistance*aViewPlaneNormal[2]);
// find size of the window
int* aWinSize = theRenderer->GetSize();
/*! Compute the bounds of the visible props*/
int
ComputeVisiblePropBounds(vtkRenderer* theRenderer,
- vtkFloatingPointType theBounds[6])
+ vtkFloatingPointType theBounds[6])
{
int aCount = 0;
if(aProp->GetVisibility() && aProp->GetMapper() && vtkMath::AreBoundsInitialized(aProp->GetBounds())){
if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(aProp))
if(anActor->IsInfinitive())
- continue;
-
+ continue;
+
vtkFloatingPointType *aBounds = aProp->GetBounds();
static vtkFloatingPointType MAX_DISTANCE = 0.9*VTK_LARGE_FLOAT;
// make sure we haven't got bogus bounds
if ( aBounds != NULL &&
- aBounds[0] > -MAX_DISTANCE && aBounds[1] < MAX_DISTANCE &&
- aBounds[2] > -MAX_DISTANCE && aBounds[3] < MAX_DISTANCE &&
- aBounds[4] > -MAX_DISTANCE && aBounds[5] < MAX_DISTANCE )
+ aBounds[0] > -MAX_DISTANCE && aBounds[1] < MAX_DISTANCE &&
+ aBounds[2] > -MAX_DISTANCE && aBounds[3] < MAX_DISTANCE &&
+ aBounds[4] > -MAX_DISTANCE && aBounds[5] < MAX_DISTANCE )
{
- aCount++;
+ aCount++;
- theBounds[0] = min(aBounds[0],theBounds[0]);
- theBounds[2] = min(aBounds[2],theBounds[2]);
- theBounds[4] = min(aBounds[4],theBounds[4]);
+ theBounds[0] = min(aBounds[0],theBounds[0]);
+ theBounds[2] = min(aBounds[2],theBounds[2]);
+ theBounds[4] = min(aBounds[4],theBounds[4]);
- theBounds[1] = max(aBounds[1],theBounds[1]);
- theBounds[3] = max(aBounds[3],theBounds[3]);
- theBounds[5] = max(aBounds[5],theBounds[5]);
+ theBounds[1] = max(aBounds[1],theBounds[1]);
+ theBounds[3] = max(aBounds[3],theBounds[3]);
+ theBounds[5] = max(aBounds[5],theBounds[5]);
}//not bogus
}
/*!Compute trihedron size.*/
bool
ComputeTrihedronSize( vtkRenderer* theRenderer,
- vtkFloatingPointType& theNewSize,
- const vtkFloatingPointType theSize,
- const vtkFloatingPointType theSizeInPercents )
+ vtkFloatingPointType& theNewSize,
+ const vtkFloatingPointType theSize,
+ const vtkFloatingPointType theSizeInPercents )
{
// calculating diagonal of visible props of the renderer
vtkFloatingPointType bnd[ 6 ];
if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(anAct))
if(anActor->GetVisibility() && !anActor->IsInfinitive())
{
- vtkFloatingPointType *aBounds = anActor->GetBounds();
- if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT &&
- aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT &&
- aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT)
- isAny = true;
+ vtkFloatingPointType *aBounds = anActor->GetBounds();
+ if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT &&
+ aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT &&
+ aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT)
+ isAny = true;
}
return !isAny;
{
if(anActor->GetVisibility() && !anActor->IsInfinitive())
{
- vtkFloatingPointType *aBounds = anActor->GetBounds();
- if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT &&
- aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT &&
- aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT)
- {
- for(int i = 0; i < 5; i = i + 2){
- if(aBounds[i] < aNewBndBox[i])
- aNewBndBox[i] = aBounds[i];
- if(aBounds[i+1] > aNewBndBox[i+1])
- aNewBndBox[i+1] = aBounds[i+1];
- }
- isAny = true;
- }
+ vtkFloatingPointType *aBounds = anActor->GetBounds();
+ if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT &&
+ aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT &&
+ aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT)
+ {
+ for(int i = 0; i < 5; i = i + 2){
+ if(aBounds[i] < aNewBndBox[i])
+ aNewBndBox[i] = aBounds[i];
+ if(aBounds[i+1] > aNewBndBox[i+1])
+ aNewBndBox[i+1] = aBounds[i+1];
+ }
+ isAny = true;
+ }
}
}
}
vtkFloatingPointType aWidth =
sqrt((aNewBndBox[1]-aNewBndBox[0])*(aNewBndBox[1]-aNewBndBox[0]) +
- (aNewBndBox[3]-aNewBndBox[2])*(aNewBndBox[3]-aNewBndBox[2]) +
- (aNewBndBox[5]-aNewBndBox[4])*(aNewBndBox[5]-aNewBndBox[4]));
+ (aNewBndBox[3]-aNewBndBox[2])*(aNewBndBox[3]-aNewBndBox[2]) +
+ (aNewBndBox[5]-aNewBndBox[4])*(aNewBndBox[5]-aNewBndBox[4]));
if(aWidth < MIN_DISTANCE)
return false;
vtkFloatingPointType aBounds[6];
int aCount = ComputeVisiblePropBounds(theRenderer,aBounds);
printf("aNewBndBox[0] = %f, aNewBndBox[1] = %f,\naNewBndBox[2] = %f, aNewBndBox[3] = %f,\naNewBndBox[4] = %f, aNewBndBox[5] = %f\n",
- aBounds[0],aBounds[1],aBounds[2],aBounds[3],aBounds[4],aBounds[5]);
+ aBounds[0],aBounds[1],aBounds[2],aBounds[3],aBounds[4],aBounds[5]);
printf("aCount = %d\n",aCount);
if(aCount){
vtkFloatingPointType aWidth =
sqrt((aBounds[1]-aBounds[0])*(aBounds[1]-aBounds[0]) +
- (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) +
- (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4]));
+ (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) +
+ (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4]));
if(aWidth < MIN_DISTANCE)
return false;
extern
void
ResetCamera(vtkRenderer* theRenderer,
- int theUsingZeroFocalPoint = false);
+ int theUsingZeroFocalPoint = false);
VTKVIEWER_EXPORT
extern
int
ComputeVisiblePropBounds(vtkRenderer* theRenderer,
- vtkFloatingPointType theBounds[6]);
+ vtkFloatingPointType theBounds[6]);
VTKVIEWER_EXPORT
extern
extern
bool
ComputeTrihedronSize(vtkRenderer* theRenderer,
- vtkFloatingPointType& theNewSize,
- const vtkFloatingPointType theSize,
- const vtkFloatingPointType theSizeInPercents);
+ vtkFloatingPointType& theNewSize,
+ const vtkFloatingPointType theSize,
+ const vtkFloatingPointType theSizeInPercents);
VTKVIEWER_EXPORT
extern
VTKVIEWER_EXPORT
extern
bool ComputeBBCenter(vtkRenderer* theRenderer,
- vtkFloatingPointType theCenter[3]);
+ vtkFloatingPointType theCenter[3]);
#endif
/*! Construction*/
VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop,
VTKViewer_Viewer* theModel,
- VTKViewer_InteractorStyle* iStyle,
- VTKViewer_RenderWindowInteractor* rw )
+ VTKViewer_InteractorStyle* iStyle,
+ VTKViewer_RenderWindowInteractor* rw )
: SUIT_ViewWindow( theDesktop )
{
myModel = theModel;
QString retStr;
retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e",
- pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], viewUp[0], viewUp[1],
- viewUp[2], parScale, scale[0], scale[1], scale[2] );
+ pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], viewUp[0], viewUp[1],
+ viewUp[2], parScale, scale[0], scale[1], scale[2] );
return retStr;
}
public:
VTKViewer_ViewWindow( SUIT_Desktop*, VTKViewer_Viewer*,
VTKViewer_InteractorStyle* = 0,
- VTKViewer_RenderWindowInteractor* = 0 );
+ VTKViewer_RenderWindowInteractor* = 0 );
virtual ~VTKViewer_ViewWindow();
/*!Gets tool bar.*/
/*!Gets renderer.*/
vtkRenderer* getRenderer() { return myRenderer; }
/*!Gets render window.*/
- VTKViewer_RenderWindow* getRenderWindow() { return myRenderWindow; }
+ VTKViewer_RenderWindow* getRenderWindow() { return myRenderWindow; }
/*!Gets render window interactor.*/
VTKViewer_RenderWindowInteractor* getRWInteractor() { return myRWInteractor; }
bool isTrihedronDisplayed();