A NurbsSurfaceMesh is a kind of Geometry.
We can navigate the NurbsSurfaceMesh using the generic terms such as Facets or Points or we can choose to use navigate using terms that are specific to the NurbsSurfaceMesh such as NurbsSurfaces, ControlPoints. There are some functions that do not fit with a generic terms such as Knots, which are specific to NURBS, this is why there are specific terms as well as generic terms.
using namespace XSI; Application app; Model root = app.GetActiveSceneRoot(); X3DObject mySphere; root.AddGeometry( L"Sphere", L"NurbsSurface", L"", mySphere ); NurbsSurfaceMesh mySurfaceMesh(mySphere.GetActivePrimitive().GetGeometry());
#include <xsi_nurbssurfacemesh.h>
Public Member Functions | |
NurbsSurfaceMesh () | |
~NurbsSurfaceMesh () | |
NurbsSurfaceMesh (const CRef &in_ref) | |
NurbsSurfaceMesh (const NurbsSurfaceMesh &in_obj) | |
NurbsSurfaceMesh (const Geometry &in_obj) | |
bool | IsA (siClassID in_ClassID) const |
siClassID | GetClassID () const |
NurbsSurfaceMesh & | operator= (const NurbsSurfaceMesh &in_obj) |
NurbsSurfaceMesh & | operator= (const Geometry &in_geom) |
NurbsSurfaceMesh & | operator= (const CRef &in_ref) |
CNurbsSurfaceRefArray | GetSurfaces () const |
CStatus | GetClosestSurfacePosition (MATH::CVector3 &in_vPosition, LONG &out_lSurfaceIndex, double &out_dSquaredDistance, double &out_dUValue, double &out_dVValue, MATH::CVector3 &out_vPosition) const |
CStatus | Get (siNurbsFormat in_siNurbsFormat, CNurbsSurfaceDataArray &out_surfaces) const |
CStatus | Set (const CNurbsSurfaceDataArray &in_surfaces, siNurbsFormat in_siNurbsFormat=siSINurbs) |
CStatus | AddSurfaceWithTrim (const CNurbsSurfaceData &in_surface, const CTrimCurveDataArray &in_trims, siNurbsFormat in_siNurbsFormat, NurbsSurface &out_Surface) |
CStatus | AddSurface (const CNurbsSurfaceData &in_surface, siNurbsFormat in_siNurbsFormat, NurbsSurface &out_Surface) |
CStatus | GetSubSurfaceIndexArray (const PointLocatorData &in_ptLocators, LONG in_nbPointLocatorsIndices, const LONG *in_pPointLocatorsIndices, LONG *out_pIndices) const |
CStatus | GetNormalizedUVArray (const PointLocatorData &in_ptLocators, LONG in_nbPointLocatorsIndices, const LONG *in_pPointLocatorsIndices, float *out_pNormalizedUVs) const |
PointLocatorData | ConstructPointLocators (LONG in_nbPointLocators, const LONG *in_pSubSurfaceIndices, const float *in_pNormalizedUVs) const |
NurbsSurfaceMesh | ( | ) |
Default constructor.
~NurbsSurfaceMesh | ( | ) |
Default destructor.
NurbsSurfaceMesh | ( | const CRef & | in_ref | ) |
Constructor.
in_ref | constant reference object. |
NurbsSurfaceMesh | ( | const NurbsSurfaceMesh & | in_obj | ) |
Copy constructor.
in_obj | constant class object. |
NurbsSurfaceMesh | ( | const Geometry & | in_obj | ) |
Copy constructor.
in_obj | Geometry object. |
bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if a given class type is compatible with this API class.
in_ClassID | class type. |
Reimplemented from Geometry.
siClassID GetClassID | ( | ) | const [virtual] |
NurbsSurfaceMesh& operator= | ( | const NurbsSurfaceMesh & | in_obj | ) |
Creates an object from another object. The newly created object is set to empty if the input object is not compatible.
in_obj | constant class object. |
NurbsSurfaceMesh& operator= | ( | const Geometry & | in_geom | ) |
Creates a Polygon object from a Geometry object. The newly created object is set to empty if the input Geometry object is not compatible.
in_geom | constant class object. |
Reimplemented from Geometry.
NurbsSurfaceMesh& operator= | ( | const CRef & | in_ref | ) |
Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.
in_ref | constant class object. |
Reimplemented from Geometry.
CNurbsSurfaceRefArray GetSurfaces | ( | ) | const |
Returns an array of all NurbsSurface objects on this NurbsSurfaceMesh object.
CStatus GetClosestSurfacePosition | ( | MATH::CVector3 & | in_vPosition, |
LONG & | out_lSurfaceIndex, | ||
double & | out_dSquaredDistance, | ||
double & | out_dUValue, | ||
double & | out_dVValue, | ||
MATH::CVector3 & | out_vPosition | ||
) | const |
Returns the surface index, position of the point on it, UV values and distance from the given position.
in_vPosition | A position expressed in the NurbsSurfaceMesh object frame of reference. |
out_lSurfaceIndex | The surface index to which the position is the closest. |
out_dSquaredDistance | The distance of the input position to the curve point. |
out_dUValue | The corresponding UValue on the NurbsSurface. |
out_dVValue | The corresponding VValue on the NurbsSurface. |
out_vPosition | The actual curve point position at U value. |
CStatus Get | ( | siNurbsFormat | in_siNurbsFormat, |
CNurbsSurfaceDataArray & | out_surfaces | ||
) | const |
Returns a complete data description of a nurbs surface mesh.
in_siNurbsFormat | Specifies how the data is formatted. |
out_surfaces | The data description of all surfaces. |
CStatus Set | ( | const CNurbsSurfaceDataArray & | in_surfaces, |
siNurbsFormat | in_siNurbsFormat = siSINurbs |
||
) |
Sets from a complete data description of the nurbs surface mesh. This is only available from compiled operators. For non-compiled operators this property can only be set if the object has been frozen.
in_surfaces | NurbsSurfaces data description. |
in_siNurbsFormat | Specifies how the data is formatted. |
CStatus AddSurfaceWithTrim | ( | const CNurbsSurfaceData & | in_surface, |
const CTrimCurveDataArray & | in_trims, | ||
siNurbsFormat | in_siNurbsFormat, | ||
NurbsSurface & | out_Surface | ||
) |
Adds a trimmed surface to the mesh.
in_surface | The surface descriptsion |
in_trims | The trims data that will apply to this surface. |
in_siNurbsFormat | The format of representation for the nurbs data. |
out_Surface | The newly created surface. |
CStatus AddSurface | ( | const CNurbsSurfaceData & | in_surface, |
siNurbsFormat | in_siNurbsFormat, | ||
NurbsSurface & | out_Surface | ||
) |
Adds a surface to the mesh.
in_surface | The surface description |
in_siNurbsFormat | The format of representation for the nurbs data. |
out_Surface | The newly created surface. |
CStatus GetSubSurfaceIndexArray | ( | const PointLocatorData & | in_ptLocators, |
LONG | in_nbPointLocatorsIndices, | ||
const LONG * | in_pPointLocatorsIndices, | ||
LONG * | out_pIndices | ||
) | const |
Returns the subsurface indices on which point locators are defined. Notice that this information is part of the NURBS surface mesh point locator's definition, and depends on the topology only (won't change if the geometry is deformed).
The normalized UV parameters within the subsurface can be queried with NurbsSurfaceMesh::GetNormalizedUVArray.
in_ptLocators | Contains the point locations to be queried. |
in_nbPointLocatorsIndices | Number of point locators to be queried (-1 if all) |
in_pPointLocatorsIndices | Point locator indices to be queried (not used if in_nbPointLocatorsIndices is -1) |
out_pIndices | Returned subsurface indices. Size must be in_ptLocators.GetCount() if in_nbPointLocatorsIndices is -1, in_nbPointLocatorsIndices otherwise. |
using namespace XSI; Application app; Model root = app.GetActiveSceneRoot(); X3DObject meshCubeObj; root.AddGeometry( L"Cube", L"MeshSurface", L"", meshCubeObj ); PolygonMesh meshCubeGeom( meshCubeObj.GetActivePrimitive().GetGeometry() ); X3DObject NURBSSphereObj; root.AddGeometry( L"Sphere", L"NurbsSurface", L"", NURBSSphereObj ); NurbsSurfaceMesh NURBSSphereGeom( NURBSSphereObj.GetActivePrimitive().GetGeometry() ); MATH::CVector3Array posArray = meshCubeGeom.GetPoints().GetPositionArray(); PointLocatorData cubeOnSpherePointLocators = NURBSSphereGeom.GetClosestLocations(posArray.GetCount(), (double*)&posArray[0]); LONG i; for(i = 0; i < cubeOnSpherePointLocators.GetCount(); i++) { LONG subsurface; NURBSSphereGeom.GetSubSurfaceIndexArray( cubeOnSpherePointLocators, 1, &i, &subsurface); float UVs[2]; NURBSSphereGeom.GetNormalizedUVArray( cubeOnSpherePointLocators, 1, &i, UVs); app.LogMessage(L"Point locator " + CString(CValue(i)) + L" is on subsurface " + CString(CValue(subsurface)) + L" at {U = " + CString(CValue(UVs[0])) + L" , V = " + CString(CValue(UVs[1])) + L"}."); } //Expected results: //INFO : Point locator 0 is on subsurface 0 at {U = 1.35528e-016 , V = 0.30423}. //INFO : Point locator 1 is on subsurface 0 at {U = 0.75 , V = 0.304065}. //INFO : Point locator 2 is on subsurface 0 at {U = 2.45219e-017 , V = 0.695454}. //etc.
CStatus GetNormalizedUVArray | ( | const PointLocatorData & | in_ptLocators, |
LONG | in_nbPointLocatorsIndices, | ||
const LONG * | in_pPointLocatorsIndices, | ||
float * | out_pNormalizedUVs | ||
) | const |
Returns the normalized UV surface parameters defining point locators. Notice that this information is part of NURBS surface mesh point locator's definition, and depends on the topology only (won't change if the geometry is deformed).
The subsurface index on which the normalized UVs apply can be queried with NurbsSurfaceMesh::GetSubSurfaceIndexArray.
in_ptLocators | Contains the point locations to be queried. |
in_nbPointLocatorsIndices | Number of point locators to be queried (-1 if all) |
in_pPointLocatorsIndices | Point locator indices to be queried (not used if in_nbPointLocatorsIndices is -1) |
out_pNormalizedUVs | Returned UV normalized values. Size must be 2*in_ptLocators.GetCount() if in_nbPointLocatorsIndices is -1, 2*in_nbPointLocatorsIndices otherwise. |
using namespace XSI; void CreateNullsAtPointLocations( X3DObject& inObj, const PointLocatorData& inPointLocators ) { Geometry geom( inObj.GetActivePrimitive().GetGeometry() ); std::vector<double> posData, normData; posData.resize(inPointLocators.GetCount()*3); normData.resize(inPointLocators.GetCount()*3); geom.EvaluatePositions(inPointLocators, -1, 0, &posData.front()); geom.EvaluateNormals(inPointLocators, siInterpolatedVertexGeometricNormals, -1, 0, &normData.front()); MATH::CVector3 trans; MATH::CRotation rot; LONG i; for (i = 0; i < (LONG)posData.size(); i+=3) { Null nullObj; inObj.AddNull(L"",nullObj); trans.Set(posData[i], posData[i+1], posData[i+2]); nullObj.PutLocalTranslation(trans); trans.Set(normData[i], normData[i+1], normData[i+2]); rot.SetFromXYZAxes( trans, trans, trans ); nullObj.PutLocalRotation(rot); } } float GetNormalizedRandom(){return float(rand())/RAND_MAX;} LONG RandInRange(LONG in_bound) { float fRand = GetNormalizedRandom()*0.99999f; return (LONG)(in_bound*fRand); } void main() { Application app; Model root = app.GetActiveSceneRoot(); X3DObject NURBSSphereObj; root.AddGeometry( L"Sphere", L"NurbsSurface", L"", NURBSSphereObj ); NurbsSurfaceMesh NURBSSphereGeom( NURBSSphereObj.GetActivePrimitive().GetGeometry() ); LONG nbPtLocators = 50; std::vector<LONG> subSurfaceIndexArray; std::vector<float> normalizedUVArray; subSurfaceIndexArray.resize(nbPtLocators); normalizedUVArray.resize(nbPtLocators*2); LONG i; for(i = 0; i < nbPtLocators; i++) { subSurfaceIndexArray[i] = 0; normalizedUVArray[i*2] = NormalizedRand(); normalizedUVArray[i*2+1] = NormalizedRand(); } PointLocatorData randomPointLocators = NURBSSphereGeom.ConstructPointLocators(nbPtLocators, &subSurfaceIndexArray.front(), &normalizedUVArray.front()); CreateNullsAtPointLocations(NURBSSphereObj, randomPointLocators); }
PointLocatorData ConstructPointLocators | ( | LONG | in_nbPointLocators, |
const LONG * | in_pSubSurfaceIndices, | ||
const float * | in_pNormalizedUVs | ||
) | const |
Builds a PointLocatorData from NurbsSurfaceMesh-specific topological information. Subsurface indices and normalized UV surface parameters are required in order to define each point locator. The UV array should contain two values for each specified subsurface index.
Notice that the returned point locators can be evaluated on any NurbsSurfaceMesh instance having the same topology.
in_nbPointLocators | Number of points locators to be constructed |
in_pSubSurfaceIndices | Subsurface indices (size must be in_nbPoints) |
in_pNormalizedUVs | Normalized UV coordinates on the subsurface (size must be in_nbPoints*2) |