26CTexGenRenderer::CTexGenRenderer(vtkRenderWindowInteractor *pRenderWindowInteractor)
28, m_pRenderWindow(
NULL)
29, m_pRenderWindowInteractor(pRenderWindowInteractor)
30, m_pOrientationMarkerWidget(
NULL)
33, m_bTrimToDomain(true)
50 pInteractionStyle->Delete();
53 vtkAxesActor* pAxes = vtkAxesActor::New();
54 pAxes->GetXAxisCaptionActor2D()->GetCaptionTextProperty()->ShadowOn();
55 pAxes->GetYAxisCaptionActor2D()->GetCaptionTextProperty()->ShadowOn();
56 pAxes->GetZAxisCaptionActor2D()->GetCaptionTextProperty()->ShadowOn();
66 camera->SetFocalPoint(0, 1, -0.5);
67 camera->SetPosition(0, 0, 0);
68 camera->SetViewUp(0, 0, 1);
103 if (bParallelProjection)
104 m_pRenderer->GetActiveCamera()->ParallelProjectionOn();
106 m_pRenderer->GetActiveCamera()->ParallelProjectionOff();
112 return m_pRenderer->GetActiveCamera()->GetParallelProjection()?
true:
false;
134 TGLOG(
"Starting rendering");
141 vtkRenderLargeImage* pRenderLarge = vtkRenderLargeImage::New();
143 pRenderLarge->SetMagnification(iMagnification);
147 if ( iMagnification > 1 && iAxes )
164 vtkPNGWriter* pPNGWriter = vtkPNGWriter::New();
165 pPNGWriter->SetInputConnection(pRenderLarge->GetOutputPort());
166 pPNGWriter->SetFileName(FileName.c_str());
172 pRenderLarge->Delete();
175 pPNGWriter->Delete();
200 multimap<PROP_TYPE, vtkProp*>::iterator itProp;
214 multimap<PROP_TYPE, vtkProp*>::iterator itProp;
215 for (itProp =
m_Props.lower_bound(Type); itProp !=
m_Props.upper_bound(Type); ++itProp)
217 vtkActor* pActor =
dynamic_cast<vtkActor*
>(itProp->second);
236 vector<vtkProp*> Props;
237 multimap<PROP_TYPE, vtkProp*>::iterator itProp;
240 if (Types.count(itProp->first))
242 Props.push_back(itProp->second);
250 vector<vtkProp*> Props;
251 pair<multimap<PROP_TYPE, vtkProp*>::iterator, multimap<PROP_TYPE, vtkProp*>::iterator> Range =
m_Props.equal_range(Type);
252 multimap<PROP_TYPE, vtkProp*>::iterator itProp;
253 for (itProp = Range.first; itProp != Range.second; ++itProp)
255 Props.push_back(itProp->second);
262 map<vtkProp*, PROP_YARN_INFO>::const_iterator itProp =
m_YarnProps.find(pProp);
265 return &itProp->second;
272 map<vtkProp*, PROP_NODE_INFO>::const_iterator itProp =
m_NodeProps.find(pProp);
275 return &itProp->second;
282 map<vtkProp*, PROP_IMAGE_INFO>::const_iterator itProp =
m_ImageProps.find(pProp);
285 return &itProp->second;
292 vector<vtkProp*> Props;
298 map<vtkProp*, PROP_YARN_INFO>::const_iterator itProp;
301 if (pYarnProp->
iYarn == itProp->second.iYarn &&
302 (bIgnoreTextileName || pYarnProp->
TextileName == itProp->second.TextileName))
303 Props.push_back(itProp->first);
308 map<vtkProp*, PROP_NODE_INFO>::const_iterator itProp;
311 if (pNodeProp->
iNode == itProp->second.iNode &&
312 pNodeProp->
iYarn == itProp->second.iYarn &&
313 (bIgnoreTextileName || pNodeProp->
TextileName == itProp->second.TextileName))
314 Props.push_back(itProp->first);
319 map<vtkProp*, PROP_IMAGE_INFO>::const_iterator itProp;
322 if (pImageProp->
iImageID == itProp->second.iImageID)
323 Props.push_back(itProp->first);
331 vector<vtkProp*> Props;
332 map<vtkProp*, PROP_NODE_INFO>::const_iterator itProp;
335 if (Info.
iYarn == itProp->second.iYarn &&
337 Props.push_back(itProp->first);
349 set<PROP_TYPE> Types;
354 vector<vtkProp*> Props =
GetProps(Types);
355 vector<vtkProp*>::iterator itProp;
356 for (itProp = Props.begin(); itProp != Props.end(); ++itProp)
378 vector<vtkProp*> YarnProps =
GetProps(&YarnInfo);
380 vector<vtkProp*> Props;
381 Props.insert(Props.end(), YarnProps.begin(), YarnProps.end());
382 Props.insert(Props.end(), NodeProps.begin(), NodeProps.end());
383 vector<vtkProp*>::iterator itProp;
384 for (itProp = Props.begin(); itProp != Props.end(); ++itProp)
427 int iNumPropsBefore =
m_Props.size();
430 double dDiagonalBefore = sqrt((Bounds[1]-Bounds[0])*(Bounds[1]-Bounds[0]) +
431 (Bounds[3]-Bounds[2])*(Bounds[3]-Bounds[2]) +
432 (Bounds[5]-Bounds[4])*(Bounds[5]-Bounds[4]));
434 m_Props.insert(make_pair(Type, pProp));
437 double dDiagonalAfter = sqrt((Bounds[1]-Bounds[0])*(Bounds[1]-Bounds[0]) +
438 (Bounds[3]-Bounds[2])*(Bounds[3]-Bounds[2]) +
439 (Bounds[5]-Bounds[4])*(Bounds[5]-Bounds[4]));
440 if (abs(dDiagonalBefore-dDiagonalAfter) > 0.1*dDiagonalBefore || iNumPropsBefore==0)
459 multimap<PROP_TYPE, vtkProp*>::iterator itProp;
462 if (itProp->second == pProp)
471 vtkActor *pActor = vtkActor::New();
472 vtkPolyDataMapper *pPolyDataMapper = vtkPolyDataMapper::New();
473 pPolyDataMapper->SetInputData(pPolyData);
474 pActor->SetMapper(pPolyDataMapper);
476 pPolyDataMapper->Delete();
484 vtkActor *pActor = vtkActor::New();
485 vtkPolyDataMapper *pPolyDataMapper = vtkPolyDataMapper::New();
486 pPolyDataMapper->SetInputConnection(pAlgorithm->GetOutputPort());
487 pActor->SetMapper(pPolyDataMapper);
489 pPolyDataMapper->Delete();
490 pAlgorithm->Delete();
497 if (TextileName ==
"")
499 map<string, CTextile*>::const_iterator itTextile;
502 assert(itTextile->first !=
"");
507 TGLOGINDENT(
"Adding textile \"" << TextileName <<
"\" to renderer");
520 vector<CYarn>::iterator itYarn;
525 for (itYarn = Textile.
GetYarns().begin(), i=0; itYarn != Textile.
GetYarns().end(); ++itYarn, ++i)
557 pActor->GetProperty()->BackfaceCullingOn();
559 pActor->GetProperty()->SetRepresentationToWireframe();
562 pActor->GetProperty()->SetOpacity(dOpacity);
573 if (TextileName ==
"")
575 map<string, CTextile*>::const_iterator itTextile;
578 assert(itTextile->first !=
"");
583 TGLOGINDENT(
"Adding domain of \"" << TextileName <<
"\" to renderer");
597 if (TextileName ==
"")
599 map<string, CTextile*>::const_iterator itTextile;
602 assert(itTextile->first !=
"");
607 TGLOGINDENT(
"Adding textile mesh\"" << TextileName <<
"\" to renderer");
620 vector<CYarn>::iterator itYarn;
625 for (itYarn = Textile.
GetYarns().begin(), i=0; itYarn != Textile.
GetYarns().end(); ++itYarn, ++i)
643 TGLOGINDENT(
"Adding yarn volume mesh to renderer");
656 pActor->GetProperty()->SetRepresentationToWireframe();
673 double extend =
GetLength(Limits.second - Limits.first)*1e-3;
687 pActor->GetProperty()->SetColor(Color.
Array());
688 pActor->GetProperty()->BackfaceCullingOn();
689 pActor->GetProperty()->SetOpacity(dOpacity);
696 if (TextileName ==
"")
698 map<string, CTextile*>::const_iterator itTextile;
701 assert(itTextile->first !=
"");
706 TGLOGINDENT(
"Adding domain of \"" << TextileName <<
"\" to renderer");
725 vtkTextProperty *tprop = vtkTextProperty::New();
726 tprop->SetColor(AnnotationColor.
Array());
731 vtkCubeAxesActor2D* axes = vtkCubeAxesActor2D::New();
732 axes->SetBounds(Limits.first.x, Limits.second.x, Limits.first.y, Limits.second.y, Limits.first.z, Limits.second.z);
734 axes->SetLabelFormat(
"%6.4g");
735 axes->SetFlyModeToOuterEdges();
736 axes->SetFontFactor(1.5);
737 axes->SetAxisTitleTextProperty(tprop);
738 axes->SetAxisLabelTextProperty(tprop);
739 axes->SetNumberOfLabels(2);
740 axes->GetProperty()->SetColor(AnnotationColor.
Array());
749 double BackGroundColor[3];
751 double dIntensity = (BackGroundColor[0]+BackGroundColor[1]+BackGroundColor[2])/3.0;
752 if (dIntensity > 0.5)
753 return COLOR(0, 0, 0);
755 return COLOR(1, 1, 1);
761 typedef multimap<PROP_TYPE, vtkProp*>::iterator PropMapIter;
764 for (itProp = Range.first; itProp != Range.second; ++itProp)
766 vtkCubeAxesActor2D* pAxes =
dynamic_cast<vtkCubeAxesActor2D*
>(itProp->second);
769 pAxes->GetProperty()->SetColor(AnnotationColor.
Array());
770 pAxes->GetAxisTitleTextProperty()->SetColor(AnnotationColor.
Array());
771 pAxes->GetAxisLabelTextProperty()->SetColor(AnnotationColor.
Array());
778 pAxes->GetXAxisCaptionActor2D()->GetCaptionTextProperty()->SetColor(AnnotationColor.
Array());
779 pAxes->GetYAxisCaptionActor2D()->GetCaptionTextProperty()->SetColor(AnnotationColor.
Array());
780 pAxes->GetZAxisCaptionActor2D()->GetCaptionTextProperty()->SetColor(AnnotationColor.
Array());
786 if (TextileName ==
"")
788 map<string, CTextile*>::const_iterator itTextile;
807 vector<CYarn>::iterator itYarn;
808 for (i=0; i<(int)Textile.
GetYarns().size(); ++i)
823 vector<CNode>::const_iterator itNode;
825 for (itNode = Nodes.begin(), i=0; itNode != Nodes.end(); ++itNode, ++i)
827 vtkSphereSource* pSphere = vtkSphereSource::New();
828 pSphere->SetRadius(dRadius);
829 pSphere->SetPhiResolution(10);
830 pSphere->SetThetaResolution(10);
831 Pos = itNode->GetPosition();
832 pSphere->SetCenter(Pos.
x, Pos.
y, Pos.
z);
834 vtkPolyDataMapper* pSphereMapper = vtkPolyDataMapper::New();
835 pSphereMapper->SetInputConnection(pSphere->GetOutputPort());
837 vtkActor* pSphereActor = vtkActor::New();
838 pSphereActor->SetMapper(pSphereMapper);
842 pSphereMapper->Delete();
858 if (TextileName ==
"")
860 map<string, CTextile*>::const_iterator itTextile;
877 int i, iNumYarns = (int)Textile.
GetYarns().size();
879 for (i=0; i < iNumYarns; ++i)
899 vtkTubeFilter* pProfileTubes = vtkTubeFilter::New();
900 pProfileTubes->SetNumberOfSides(8);
901 pProfileTubes->SetInputData(pPolyData);
902 pProfileTubes->SetRadius(dRadius);
903 pProfileTubes->CappingOn();
905 vtkPolyDataMapper* pProfileMapper = vtkPolyDataMapper::New();
906 pProfileMapper->SetInputConnection(pProfileTubes->GetOutputPort());
908 vtkActor* pProfile = vtkActor::New();
909 pProfile->SetMapper(pProfileMapper);
913 pProfileTubes->Delete();
914 pProfileMapper->Delete();
926 if (TextileName ==
"")
928 map<string, CTextile*>::const_iterator itTextile;
945 CMesh InterferingPoints;
946 vector<float> DistToSurface;
947 vector<int> YarnIndices;
948 vector<float>::iterator itDistToSurface;
949 float fMaxDist = 0.0;
952 Textile.
DetectInterference(DistToSurface, YarnIndices, TrimToDomain, &InterferingPoints);
954 vtkPolyData *pPolyData =
GetPolyData(InterferingPoints);
959 vtkFloatArray* pDistance = vtkFloatArray::New();
960 pDistance->SetNumberOfValues( DistToSurface.size() );
964 for ( itDistToSurface = DistToSurface.begin(), i = 0; itDistToSurface != DistToSurface.end(); ++itDistToSurface, ++i )
966 float fDist = fabs( *itDistToSurface );
967 if ( fDist > fMaxDist )
969 pDistance->SetValue( i, fDist );
971 TGLOG(
"Maximum intersection depth to surface " << fMaxDist <<
"\"");
973 pPolyData->GetPointData()->SetScalars( pDistance );
981 vtkSphereSource* pBalls = vtkSphereSource::New();
982 pBalls->SetRadius(dRadius);
983 pBalls->SetPhiResolution(10);
984 pBalls->SetThetaResolution(10);
986 vtkGlyph3D* pGlyphPoints = vtkGlyph3D::New();
987 pGlyphPoints->SetInputData(pPolyData);
988 pGlyphPoints->SetSourceConnection(pBalls->GetOutputPort());
993 pGlyphPoints->SetScaleModeToScaleByScalar();
994 pGlyphPoints->SetColorModeToColorByScale();
995 pGlyphPoints->SetRange( 0.0, fMaxDist );
996 pGlyphPoints->ClampingOn();
997 pGlyphPoints->SetScaleFactor( 1 );
1000 vtkPolyDataMapper* pGlyphMapper = vtkPolyDataMapper::New();
1001 pGlyphMapper->SetInputConnection(pGlyphPoints->GetOutputPort());
1003 vtkActor* pGlyph = vtkActor::New();
1004 pGlyph->SetMapper(pGlyphMapper);
1008 pPolyData->Delete();
1010 pGlyphPoints->Delete();
1011 pGlyphMapper->Delete();
1018 if (TextileName ==
"")
1020 map<string, CTextile*>::const_iterator itTextile;
1023 RenderGrid(*itTextile->second, iResX, iResY, iResZ, dLengthModifier);
1032 RenderGrid(*pTextile, iResX, iResY, iResZ, dLengthModifier);
1041 pair<XYZ, XYZ> Limits;
1049 vector<CYarn> Yarns = Textile.
GetYarns();
1050 vector<CYarn>::iterator itYarns;
1052 for ( itYarns = Yarns.begin(); itYarns != Yarns.end(); ++itYarns )
1054 pair<XYZ, XYZ> YarnLimits = itYarns->GetAABB();
1055 Limits.first =
Min( YarnLimits.first, Limits.first );
1056 Limits.second =
Max( YarnLimits.second, Limits.second );
1064 vector<POINT_INFO> PointInfo;
1068 for (i=0; i<iResX; ++i)
1070 for (j=0; j<iResY; ++j)
1072 for (k=0; k<iResZ; ++k)
1074 Pos.
x = ((double)i+0.5)/(double(iResX)) * (
Max.x-
Min.
x) +
Min.
x;
1075 Pos.
y = ((double)j+0.5)/(double(iResY)) * (
Max.y-
Min.
y) +
Min.
y;
1076 Pos.
z = ((double)k+0.5)/(double(iResZ)) * (
Max.z-
Min.
z) +
Min.
z;
1077 Points.push_back(Pos);
1086 vtkPoints* pPoints = vtkPoints::New();
1087 vtkFloatArray* pNormals = vtkFloatArray::New();
1088 pNormals->SetNumberOfComponents(3);
1089 for (i=0; i<(int)Points.size(); ++i)
1095 if (PointInfo[i].iYarnIndex != -1)
1097 pPoints->InsertNextPoint(Points[i].x, Points[i].y, Points[i].z);
1099 pNormals->InsertNextTuple3(PointInfo[i].Orientation.x, PointInfo[i].Orientation.y, PointInfo[i].Orientation.z);
1102 vtkPolyData* pPolyData = vtkPolyData::New();
1103 pPolyData->SetPoints(pPoints);
1104 pPolyData->GetPointData()->SetVectors(pNormals);
1106 vtkArrowSource *pArrow = vtkArrowSource::New();
1113 vtkGlyph3D* pGlyphPoints = vtkGlyph3D::New();
1114 pGlyphPoints->SetScaleFactor(dLength);
1115 pGlyphPoints->SetVectorModeToUseVector();
1116 pGlyphPoints->SetSourceConnection(pArrow->GetOutputPort());
1117 pGlyphPoints->SetInputData(pPolyData);
1119 vtkPolyDataMapper* pGlyphMapper = vtkPolyDataMapper::New();
1120 pGlyphMapper->SetInputConnection(pGlyphPoints->GetOutputPort());
1122 vtkActor* pGlyph = vtkActor::New();
1123 pGlyph->SetMapper(pGlyphMapper);
1126 pPolyData->Delete();
1128 pGlyphPoints->Delete();
1129 pGlyphMapper->Delete();
1161 vtkCamera *camera =
m_pRenderer->GetActiveCamera();
1165 XYZ Position, FocalPoint;
1166 camera->GetPosition(Position.
x, Position.
y, Position.
z);
1167 camera->GetFocalPoint(FocalPoint.
x, FocalPoint.
y, FocalPoint.
z);
1168 LookDirection = FocalPoint - Position;
1170 XYZ ViewUp(0, 0, 1);
1173 LookDirection =
XYZ(0, 1, -0.5);
1175 camera->SetFocalPoint(LookDirection.
x, LookDirection.
y, LookDirection.
z);
1176 camera->SetPosition(0, 0, 0);
1177 camera->SetViewUp(ViewUp.
x, ViewUp.
y, ViewUp.
z);
1231 vtkPolyData *pPolyData = vtkPolyData::New();
1232 vtkPoints *pPoints = vtkPoints::New();
1233 vtkCellArray *pPolys = vtkCellArray::New();
1234 vtkCellArray *pLines = vtkCellArray::New();
1237 vector<XYZ>::const_iterator itNode;
1240 pPoints->InsertPoint(i, itNode->x, itNode->y, itNode->z);
1242 list<int>::const_iterator itIter;
1243 int iNumNodes, iStartIndex, iEndIndex;
1248 for (itIter = Indices.begin(); itIter != Indices.end(); )
1252 iStartIndex = *(itIter++);
1253 iEndIndex = *(itIter++);
1254 pLines->InsertNextCell(iEndIndex-iStartIndex);
1255 for (i=iStartIndex; i<iEndIndex; ++i)
1257 pLines->InsertCellPoint(i);
1263 for (
int side = 0; side < 2; ++side )
1265 pPolys->InsertNextCell(iNumNodes/2);
1266 for ( i = 0; i < iNumNodes/2; ++i )
1270 iFirst.push_back( *itIter );
1274 pLines->InsertNextCell(2);
1275 pLines->InsertCellPoint( iFirst[i] );
1276 pLines->InsertCellPoint( *itIter );
1278 pPolys->InsertCellPoint(*itIter);
1285 pPolys->InsertNextCell(iNumNodes);
1286 for (i=0; i<iNumNodes; ++i)
1288 pPolys->InsertCellPoint(*itIter);
1299 pPolyData->SetPoints(pPoints);
1301 pPolyData->SetPolys(pPolys);
1303 pPolyData->SetLines(pLines);
1311 vtkPolyDataNormals *pPolyDataNormals = vtkPolyDataNormals::New();
1313 pPolyDataNormals->SetFeatureAngle(45);
1315 pPolyDataNormals->ConsistencyOff();
1316 pPolyDataNormals->NonManifoldTraversalOn();
1317 pPolyDataNormals->SplittingOn();
1318 pPolyDataNormals->ComputePointNormalsOn();
1319 pPolyDataNormals->ComputeCellNormalsOn();
1320 pPolyDataNormals->FlipNormalsOff();
1322 pPolyDataNormals->SetInputData(pInput);
1326 return pPolyDataNormals;
1353 YarnInfo.
iYarn = iYarn;
1354 vector<vtkProp*> Props =
GetProps(&YarnInfo,
true);
1355 vector<vtkProp*>::iterator itProp;
1356 for (itProp = Props.begin(); itProp != Props.end(); ++itProp)
1358 vtkActor* pActor =
dynamic_cast<vtkActor*
>(*itProp);
1367 pActor->GetProperty()->SetDiffuse(0.7);
1368 pActor->GetProperty()->SetDiffuseColor(Color.
Array());
1369 pActor->GetProperty()->SetSpecular(0.3);
1370 pActor->GetProperty()->SetSpecularPower(30);
1371 pActor->GetProperty()->SetAmbient(0.3);
1372 pActor->GetProperty()->SetAmbientColor(Color.
Array());
1379 vector<CTextile*> Textiles;
1380 if (TextileName ==
"")
1382 map<string, CTextile*>::const_iterator itTextile;
1383 for (itTextile =
TEXGEN.GetTextiles().begin(); itTextile !=
TEXGEN.GetTextiles().end(); ++itTextile)
1385 Textiles.push_back(itTextile->second);
1392 Textiles.push_back(pTextile);
1394 if (Textiles.empty())
1396 vector<CTextile*>::iterator itTextile;
1397 for (itTextile = Textiles.begin(); itTextile != Textiles.end(); ++itTextile)
1400 (*itTextile)->AddNodesToMesh(Mesh);
1402 (*itTextile)->AddPathToMesh(Mesh);
1407 const CDomain* pDomain = (*itTextile)->GetDomain();
1419 if (FileName.size()<4 || FileName.rfind(
".vtp") != FileName.size()-4)
1422 vtkXMLPolyDataWriter* pPolyDataWriter = vtkXMLPolyDataWriter::New();
1423 pPolyDataWriter->SetInputData(pPolyData);
1424 pPolyDataWriter->SetDataModeToBinary();
1425 pPolyDataWriter->SetFileName(FileName.c_str());
1426 bool bSuccess = pPolyDataWriter->Write()?
true:
false;
1428 pPolyData->Delete();
1429 pPolyDataWriter->Delete();
1448 map<vtkProp*, PROP_IMAGE_INFO>::iterator itImage;
1449 int iPrevID = 0, iID = 0;
1455 if (iID == itImage->second.iImageID)
1460 }
while (iPrevID != iID);
#define TGLOGINDENT(MESSAGE)
Combines the TGLOG macro and TGLOGAUTOINDENT macro in one.
#define TEXGEN
Helper macro to get the texgen instance.
static CCustomInteractorStyle * New()
Abstract base class representing the domain in which a textile cell may lie.
virtual void Grow(double dDistance)=0
Make the domain larger (used mainly for rendering purposes)
const CMesh & GetMesh() const
Get the mesh representing the domain as a surface mesh.
virtual CDomain * Copy() const =0
Defines the nodes and elements of a surface or volume mesh.
int GetNumNodes() const
Return the number of nodes.
void InsertMesh(const CMesh &Mesh, XYZ Offset=XYZ(0, 0, 0))
Add the contents of Mesh to this mesh.
const list< int > & GetIndices(ELEMENT_TYPE ElemType) const
Get the element indices of a given element type.
ELEMENT_TYPE
Each element type is represented by a unique integer value.
pair< XYZ, XYZ > GetAABB(double dGrowDistance=0) const
Get an axis aligned bounding box for the mesh.
vector< XYZ >::const_iterator NodesBegin() const
const bool NodesEmpty() const
Returns true if the nodes array is empty.
vector< XYZ >::const_iterator NodesEnd() const
static CTexGen & GetInstance()
CTextile * GetTextile(string TextileName="")
Get a textile with given name.
const map< string, CTextile * > & GetTextiles() const
void UpdateAxesColor()
Updates the axes color based on the background color.
void RefreshView()
Re-render the scene to take into account updates to it.
void TakeScreenShot(string FileName, int iMagnification=1)
Saves the current view as a PNG image on the hard disk.
void SetTrimToDomain(bool bTrim)
Render yarns as transparent.
vector< vtkProp * > GetProps(PROP_TYPE Type)
Get the vtkProps of a given type.
map< vtkProp *, PROP_YARN_INFO > m_YarnProps
void RenderDomainAxes(string TextileName="")
Render the dimensions of the domain.
void RenderPaths(string TextileName="")
Render the paths of each yarn in a textile.
void RenderAxes()
Render axes at the bottom left of the window.
void RenderPath(CTextile &Textile, int iYarn)
Render the path of a yarn in a textile.
void SetYarnColor(int iYarn, COLOR Color)
Set the colors of the yarns.
int GetNumProps(PROP_TYPE Type) const
Find out how many actors of given type exist.
vtkProp * RenderYarnMesh(CYarn &Yarn, const CDomain *pDomain=NULL, COLOR Color=COLOR(1, 1, 1))
Render a single yarn mesh with given color.
vtkPolyData * GetPolyData(const CMesh &Mesh)
vtkRenderer * m_pRenderer
vtkProp * RenderYarn(CYarn &Yarn, const CDomain *pDomain=NULL, COLOR Color=COLOR(1, 1, 1), double dOpacity=1)
Render a single yarn with given color.
int GetUniqueImageID()
Return a unique ID assigned to an image.
map< vtkProp *, PROP_IMAGE_INFO > m_ImageProps
const PROP_NODE_INFO * GetNodePropInfo(vtkProp *pProp) const
Get information about the node prop.
void RefreshYarn(PROP_YARN_INFO YarnInfo)
Re-render the yarn after it has been updated.
multimap< PROP_TYPE, vtkProp * > m_Props
This function will render a direction at a given point.
void SetXRay(bool bXRay)
Render yarns as transparent.
void SetPropsColor(PROP_TYPE Type, COLOR Color)
Remove all actors of given type.
void SetCallback(void(*pCallback)())
Set the callback function when an actor is added or deleted.
void AddProp(PROP_TYPE Type, vtkProp *pProp)
Add an actor to the scene.
void RenderGrid(string TextileName="", int iResX=20, int iResY=20, int iResZ=20, double dLengthModifier=1)
vtkAlgorithm * CalculateNormals(vtkPolyData *pInput)
void RefreshTextile(string TextileName)
Re-render the textile after it has been updated.
vector< vtkProp * > GetNodeProps(PROP_YARN_INFO Info, bool bIgnoreTextileName=false)
Get the vtkProps associated with the given object.
void RenderInterference(string TextileName="", bool bDepth=false)
void ClearScene()
Remove all objects being rendered.
bool SaveTextileToVTK(string FileName, string TextileName="", int iExportFlags=EXPORT_NODES|EXPORT_PATH|EXPORT_SURFACE|EXPORT_DOMAIN)
Save textile data to VTK file format.
void EndBatch()
Decrement batch count.
void RenderNodes(string TextileName="")
Render all the master nodes of each yarn in a textile.
void RenderMesh(string TextileName="")
Create the volume mesh and add it to the scene to be rendered.
bool GetParallelProjection() const
Determine if parallel projection or perspective projection is switched on.
map< vtkProp *, PROP_NODE_INFO > m_NodeProps
vtkActor * ConvertToActor(vtkAlgorithm *pAlgorithm)
This function will convert a vtkAlgorithm class into an vtkActor for rendering.
void RemoveProps(PROP_TYPE Type)
Remove all actors of given type.
vtkRenderWindowInteractor * m_pRenderWindowInteractor
vtkOrientationMarkerWidget * m_pOrientationMarkerWidget
void SetParallelProjection(bool bParallelProjection)
Switch between parallel projection and perspective projection.
void BeginBatch()
Increment batch count.
void Start(bool bTakeControl=true, int iWidth=800, int iHeight=600, bool bFullScreen=false)
Create a new render window and render to it (optionally taking control of the thread)
void RenderTextile(string TextileName="", double dOpacity=1)
Create the mesh and add it to the scene to be rendered.
void ApplyDefaultColor(vtkActor *pActor)
Apply the default material color based on the yarn index.
const PROP_IMAGE_INFO * GetImagePropInfo(vtkProp *pProp) const
Get information about the image prop.
void RemoveProp(vtkProp *pProp)
@ PROP_INTERFERENCE_DEPTH
static void ApplyColor(vtkActor *pActor, COLOR Color)
Apply the material properties.
void SetBackgroundColor(COLOR Color)
Render an image.
bool SaveMeshToVTK(string FileName, const CMesh &Mesh)
Save a Mesh to VTK file format.
COLOR GetBestAnnotationColor()
Gets the best text color based on the color of the background.
const PROP_YARN_INFO * GetYarnPropInfo(vtkProp *pProp) const
Get information about the surface prop.
void RenderDomain(string TextileName="", COLOR Color=COLOR(1, 1, 1), double dOpacity=0.5)
Render the domain.
void ResetCamera(XYZ LookDirection=XYZ())
Reset the camera so as to see all objects that are rendered.
vtkRenderWindow * m_pRenderWindow
Represents a textile cell containing yarns.
const CDomain * GetDomain() const
string GetName() const
Get the name associated with this textile.
double GetApproximateSize()
Get an approximate size for the textile.
void GetPointInformation(const vector< XYZ > &Points, vector< POINT_INFO > &PointsInfo, double dTolerance=1e-9)
Get useful information of a list of points.
const vector< CYarn > & GetYarns() const
int DetectInterference(vector< float > &DistanceToSurface, vector< int > &YarnIndex, bool bTrimToDomain, CMesh *pInterferingPoints=NULL)
Find out if any of the yarns are interfering with each other.
Represents a yarn consisting of master nodes, section and interpolation function.
bool AddSurfaceToMesh(CMesh &Mesh, bool bAddEndCaps=true) const
Create surface mesh for this yarn and add it to the surface mesh object.
bool AddVolumeToMesh(CMesh &Mesh) const
Create volume mesh for this yarn and add it to the volume mesh object.
bool AddPathToMesh(CMesh &Mesh) const
Add yarn centerline path to mesh.
const vector< CNode > & GetMasterNodes() const
Namespace containing a series of customised math operations not found in the standard c++ library.
COLOR GetIndexedColor(int iIndex)
double Max(XYZ &Vector)
Get maximum element of vector and return it.
double GetLength(const XYZ &Point1, const XYZ &Point2)
Get the length between two points.
XYZ Min(const XYZ &P1, const XYZ &P2)
Given two points, return a new point who's coordinates are the smaller of the two.
XYZ CrossProduct(const XYZ &left, const XYZ &right)
Get the cross product of two vectors.
Struct for representing points in 3D space.