43 wxLogTrace( MASK_3D_SG,
44 wxT(
"%s:%s:%d * [BUG] inappropriate parent to SGCOORDS (type %s)" ),
45 __FILE__, __FUNCTION__, __LINE__, aParent->
GetNodeType() );
73 if(
nullptr == aParent )
92 if(
nullptr == aNodeName || 0 == aNodeName[0] )
95 if( !m_Name.compare( aNodeName ) )
116 wxCHECK( aNode,
false );
124 wxCHECK( aNode,
false );
135 aCoordsList =
nullptr;
139 aListSize =
coords.size();
149 if( 0 == aListSize ||
nullptr == aCoordsList )
152 for(
size_t i = 0; i < aListSize; ++i )
153 coords.push_back( aCoordsList[i] );
159 coords.emplace_back( aXValue, aYValue, aZValue );
165 coords.push_back( aPoint );
188 aFile <<
" coord DEF " <<
GetName() <<
" Coordinate { point [\n ";
193 aFile <<
" coord USE " <<
GetName() <<
"\n";
199 aFile <<
" coord Coordinate { point [\n ";
207 for(
size_t i = 0; i < n; )
243 if(
nullptr == parentNode )
261 wxCHECK( parentNode ==
m_Parent,
false );
265 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad stream" ),
266 __FILE__, __FUNCTION__, __LINE__ );
271 aFile <<
"[" <<
GetName() <<
"]";
272 size_t npts =
coords.size();
273 aFile.write( (
char*)&npts,
sizeof(
size_t) );
275 for(
size_t i = 0; i < npts; ++i )
288 wxCHECK(
coords.empty(),
false );
291 aFile.read( (
char*) &npts,
sizeof(
size_t ) );
297 for(
size_t i = 0; i < npts; ++i )
314 if(
nullptr ==
m_Parent ||
nullptr == callingNode )
319 std::vector< int > ilist;
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
void unlinkChildNode(const SGNODE *aNode) noexcept override
Remove references to an owned child.
void unlinkRefNode(const SGNODE *aNode) noexcept override
Remove pointers to a referenced node.
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
std::vector< SGPOINT > coords
bool AddRefNode(SGNODE *aNode) noexcept override
void AddCoord(double aXValue, double aYValue, double aZValue)
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
SGCOORDS(SGNODE *aParent)
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override
Search the tree of linked nodes and return a reference to the first node found with the given name.
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
bool AddChildNode(SGNODE *aNode) noexcept override
bool GetCoordsList(size_t &aListSize, SGPOINT *&aCoordsList)
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
void SetCoordsList(size_t aListSize, const SGPOINT *aCoordsList)
bool CalcNormals(SGFACESET *callingNode, SGNODE **aPtr=nullptr)
Calculate normals for this coordinate list and sets the normals list in the parent SGFACESET.
Define an indexed face set for a scenegraph.
void GatherCoordIndices(std::vector< int > &aIndexList)
Add all internal coordinate indices to the given list in preparation for a normals calculation.
The base class of all Scene Graph nodes.
virtual bool WriteCache(std::ostream &aFile, SGNODE *parentNode)=0
Write this node's data to a binary cache file.
const char * GetName(void)
SGNODE * GetParent(void) const noexcept
Returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
S3D::SGTYPES GetNodeType(void) const noexcept
Return the type of this node instance.
virtual bool AddChildNode(SGNODE *aNode)=0
std::list< SGNODE * > m_BackPointers
nodes which hold a reference to this.
SGNODE * m_Parent
Pointer to parent node; may be NULL for top level transform.
std::string m_Name
name to use for referencing the entity by name.
virtual void unlinkChildNode(const SGNODE *aNode)=0
Remove references to an owned child.
bool m_written
Set to true when the object has been written after a ReNameNodes().
S3D::SGTYPES m_SGtype
Type of Scene Graph node.
Define a set of vertex normals for a scene graph object.
std::vector< SGVECTOR > norms
bool ReadPoint(std::istream &aFile, SGPOINT &aPoint)
bool WritePoint(std::ostream &aFile, const SGPOINT &aPoint)
bool CalcTriangleNormals(std::vector< SGPOINT > coords, std::vector< int > &index, std::vector< SGVECTOR > &norms)
void FormatPoint(std::string &result, const SGPOINT &point)
Define a number of macros to aid in repetitious code which is probably best expressed as a preprocess...